From b02d91ddbbacd7ae4825ff5126c7cca79d242ab5 Mon Sep 17 00:00:00 2001 From: Ayobami Akingbade Date: Sat, 18 Nov 2023 05:26:29 +0100 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20feat(packages):=20nuke=20packages?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/__tests__/_/forCodeCoverage.spec.ts | 4 - .../api/_test-utils/_activated-storage.ts | 22 -- src/__tests__/api/_test-utils/_all.ts | 2 - .../storage/[key]/credentials.spec.ts | 70 ----- .../integrations/storage/[key]/index.spec.ts | 294 ------------------ .../api/integrations/storage/active.spec.ts | 26 -- .../api/integrations/storage/list.spec.ts | 78 ----- src/backend/lib/config-persistence/types.ts | 1 - src/backend/npm-packages/constants.ts | 153 --------- .../npm-packages/npm-packages.service.ts | 74 ----- src/backend/npm-packages/portal/index.ts | 1 - src/backend/npm-packages/portal/main.ts | 15 - src/backend/npm-packages/types.ts | 7 - src/backend/storage/integrations/aws/index.ts | 62 ---- .../storage/integrations/cloudinary/index.ts | 40 --- .../storage/integrations/firebase/index.ts | 30 -- .../storage/integrations/google/index.ts | 30 -- src/backend/storage/integrations/index.ts | 44 +-- .../storage/integrations/local/index.ts | 28 -- .../storage/integrations/minio/index.ts | 30 -- src/backend/storage/storage.controller.ts | 40 --- src/backend/storage/storage.service.ts | 115 ------- src/backend/storage/types.ts | 12 - src/bin/index.ts | 3 - src/frontend/views/integrations/_Base.tsx | 50 +-- .../views/integrations/storage/constants.ts | 7 - .../integrations/storage/storage.store.ts | 101 ------ src/pages/api/healthcheck/index.ts | 2 - .../integrations/storage/[key]/credentials.ts | 31 -- .../api/integrations/storage/[key]/index.ts | 62 ---- src/pages/api/integrations/storage/active.ts | 17 - src/pages/api/integrations/storage/list.ts | 8 - src/shared/types/storage.ts | 5 - 33 files changed, 10 insertions(+), 1454 deletions(-) delete mode 100644 src/__tests__/api/_test-utils/_activated-storage.ts delete mode 100644 src/__tests__/api/integrations/storage/[key]/credentials.spec.ts delete mode 100644 src/__tests__/api/integrations/storage/[key]/index.spec.ts delete mode 100644 src/__tests__/api/integrations/storage/active.spec.ts delete mode 100644 src/__tests__/api/integrations/storage/list.spec.ts delete mode 100644 src/backend/npm-packages/constants.ts delete mode 100644 src/backend/npm-packages/npm-packages.service.ts delete mode 100644 src/backend/npm-packages/portal/index.ts delete mode 100644 src/backend/npm-packages/portal/main.ts delete mode 100644 src/backend/npm-packages/types.ts delete mode 100644 src/backend/storage/integrations/aws/index.ts delete mode 100644 src/backend/storage/integrations/cloudinary/index.ts delete mode 100644 src/backend/storage/integrations/firebase/index.ts delete mode 100644 src/backend/storage/integrations/google/index.ts delete mode 100644 src/backend/storage/integrations/local/index.ts delete mode 100644 src/backend/storage/integrations/minio/index.ts delete mode 100644 src/backend/storage/storage.controller.ts delete mode 100644 src/backend/storage/storage.service.ts delete mode 100644 src/backend/storage/types.ts delete mode 100644 src/frontend/views/integrations/storage/constants.ts delete mode 100644 src/frontend/views/integrations/storage/storage.store.ts delete mode 100644 src/pages/api/integrations/storage/[key]/credentials.ts delete mode 100644 src/pages/api/integrations/storage/[key]/index.ts delete mode 100644 src/pages/api/integrations/storage/active.ts delete mode 100644 src/pages/api/integrations/storage/list.ts delete mode 100644 src/shared/types/storage.ts diff --git a/src/__tests__/_/forCodeCoverage.spec.ts b/src/__tests__/_/forCodeCoverage.spec.ts index 0e0f42933..c048306c7 100644 --- a/src/__tests__/_/forCodeCoverage.spec.ts +++ b/src/__tests__/_/forCodeCoverage.spec.ts @@ -16,7 +16,6 @@ import { FOR_CODE_COV as $15 } from "backend/actions/integrations/sendinblue/typ import { FOR_CODE_COV as $16 } from "backend/actions/integrations/slack/types"; import { FOR_CODE_COV as $17 } from "backend/actions/integrations/smtp/types"; import { FOR_CODE_COV as $18 } from "backend/actions/integrations/twilio/types"; -import { FOR_CODE_COV as $19 } from "backend/storage/types"; import { FOR_CODE_COV as $20 } from "frontend/views/settings/Variables/types"; import { FOR_CODE_COV as $21 } from "shared/form-schemas/roles/permissions/base"; import { FOR_CODE_COV as $22 } from "backend/lib/config-persistence/portal/index"; @@ -32,7 +31,6 @@ import { FOR_CODE_COV as $32 } from "shared/configurations/base-types"; import { FOR_CODE_COV as $33 } from "frontend/views/Dashboard/Widget/_components/WidgetHeader/types"; import { FOR_CODE_COV as $34 } from "shared/types/config"; import { FOR_CODE_COV as $35 } from "shared/types/roles"; -import { FOR_CODE_COV as $36 } from "shared/types/storage"; import { FOR_CODE_COV as $37 } from "frontend/views/Dashboard/Widget/_manage/types"; import { FOR_CODE_COV as $38 } from "shared/types/dashboard/types"; import { FOR_CODE_COV as $39 } from "shared/types/dashboard/base"; @@ -63,7 +61,6 @@ noop( $16, $17, $18, - $19, $20, $21, $22, @@ -79,7 +76,6 @@ noop( $33, $34, $35, - $36, $37, $38, $39, diff --git a/src/__tests__/api/_test-utils/_activated-storage.ts b/src/__tests__/api/_test-utils/_activated-storage.ts deleted file mode 100644 index af973c799..000000000 --- a/src/__tests__/api/_test-utils/_activated-storage.ts +++ /dev/null @@ -1,22 +0,0 @@ -import { createConfigDomainPersistenceService } from "backend/lib/config-persistence"; -import { IActivatedStorage } from "shared/types/storage"; - -const TEST_ACTIVATED_STORAGE: IActivatedStorage[] = [ - { - key: "s3", - }, - { - key: "google", - }, -]; - -export const setupActivatedStorageTestData = async ( - testActivatedStorage: IActivatedStorage[] = TEST_ACTIVATED_STORAGE -) => { - const configPersistenceService = - createConfigDomainPersistenceService( - "activated-storage" - ); - - await configPersistenceService.resetState("key", testActivatedStorage); -}; diff --git a/src/__tests__/api/_test-utils/_all.ts b/src/__tests__/api/_test-utils/_all.ts index 2f1e9bd27..2fa9fea1a 100644 --- a/src/__tests__/api/_test-utils/_all.ts +++ b/src/__tests__/api/_test-utils/_all.ts @@ -10,7 +10,6 @@ import { setupUsersTestData } from "./_users"; import { setupIntegrationsEnvTestData } from "./_integrations-env"; import { setupActivatedActionTestData } from "./_activated-actions"; import { setupActionInstanceTestData } from "./_action-instances"; -import { setupActivatedStorageTestData } from "./_activated-storage"; import { setupTestDatabaseData } from "./_data"; import { portalTestData } from "./portal"; @@ -25,7 +24,6 @@ export const setupAllTestData = async (domains: DomainTypes[]) => { ["schema", setupSchemaTestData], ["data", setupTestDatabaseData], ["activated-actions", setupActivatedActionTestData], - ["activated-storage", setupActivatedStorageTestData], ["action-instances", setupActionInstanceTestData], ["constants", setupIntegrationsConstantsTestData], ["environment-variables", setupIntegrationsEnvTestData], diff --git a/src/__tests__/api/integrations/storage/[key]/credentials.spec.ts b/src/__tests__/api/integrations/storage/[key]/credentials.spec.ts deleted file mode 100644 index 0381ed5cb..000000000 --- a/src/__tests__/api/integrations/storage/[key]/credentials.spec.ts +++ /dev/null @@ -1,70 +0,0 @@ -import handler from "pages/api/integrations/storage/[key]/credentials"; -import { - createAuthenticatedMocks, - setupAllTestData, - setupCredentialsTestData, -} from "__tests__/api/_test-utils"; - -describe("/api/integrations/storage/[key]/credentials", () => { - beforeAll(async () => { - await setupAllTestData(["activated-storage", "users"]); - await setupCredentialsTestData({ - RANDOM___accessKeyId: - "aad0f7e776963ae66b7459222d54871433f8e119ab9a9712d4e82e8cbb77246e47a750a773c0ea316c110a1d3f2ee16c2509906fb89f1c4b039d09f139b1d7eacc26908c25137c46f269cfb13f63221da2f1631bf4f59cbe14cc18cbfb8993098bd7e2d865f20717", - AWS_S3___accessKeyId: - "3ff92bb3e142440f4d0a8aba3fab8ac4aabe573f889f1c4e77ec31e4ccdb2b146eb895c6f30c065d5669aca4edf7436d476c33677893caf0fa6ee8ff1a2a0792356f87a482a2d60f289dcca2cc3fc59f560c52a89a9e7787e43c6be8e1fcf4af1e6d5b33a27b9a0b1543581921a903c82b2f5c28'", - AWS_S3___secretAccessKey: - "91e0700d25fb2e3075362140a24308dc4fce6b5b76cfc042da543580391e9a98be61489f6bc91e7ecbb62afc55c888a793387a6f21976ac09ad4ad95fad29abcb2aeee58705297fa24433846d91219061baf873c1c7883064e864ac2c802a21560cc9b5750d049bd17edda5e389c21af6456c13b2735e1af", - AWS_S3___region: - "30a3d16f6bfdff93f54487936317a146c3f686f5defe8b8ed12bf9baf470764d7c5bf99f5162b4da3376484c26f7c159d56d52d15796ae7974a589c34c5afb94043f07e712acbeed080059b5c6c139eb3b54f43e844080cd0adbb97a0733ae64d55541ce278bf73c5bb835ab54", - AWS_S3___shouldNotShowUp: - "68ba76e500daa5d670930d24bbb425018571f18decc16d63ed901b85f6e99f74d3cf68225dcceb677b9a080cb1e8e8fd50abccbcf7d45fcf24c9578395b05b8aec57a763694e92fdbd2836bb91e66f17dc338bce18ae54cbb17098e1f1894c39870d7ff1cd", - }); - }); - - it("should not show storage credentials when password is incorrect", async () => { - const { req, res } = createAuthenticatedMocks({ - method: "POST", - query: { - key: "http", - }, - body: { - password: "invalid password", - }, - }); - await handler(req, res); - - expect(res._getStatusCode()).toBe(400); - expect(res._getJSONData()).toMatchInlineSnapshot(` - { - "message": "Invalid Password", - "method": "POST", - "name": "BadRequestError", - "path": "", - "statusCode": 400, - } - `); - }); - - it("should show storage credentials only when password is correct", async () => { - const { req, res } = createAuthenticatedMocks({ - method: "POST", - query: { - key: "s3", - }, - body: { - _password: "password", - }, - }); - await handler(req, res); - - expect(res._getStatusCode()).toBe(201); - expect(res._getJSONData()).toMatchInlineSnapshot(` - { - "accessKeyId": "some-access-key-id", - "region": "some-region", - "secretAccessKey": "some-secret-access-key", - } - `); - }); -}); diff --git a/src/__tests__/api/integrations/storage/[key]/index.spec.ts b/src/__tests__/api/integrations/storage/[key]/index.spec.ts deleted file mode 100644 index 9dc281d75..000000000 --- a/src/__tests__/api/integrations/storage/[key]/index.spec.ts +++ /dev/null @@ -1,294 +0,0 @@ -import handler from "pages/api/integrations/storage/[key]/index"; -import activeHandler from "pages/api/integrations/storage/active"; -import credentialsHandler from "pages/api/integrations/storage/[key]/credentials"; -import { - createAuthenticatedMocks, - setupAllTestData, -} from "__tests__/api/_test-utils"; -import { setupActivatedStorageTestData } from "__tests__/api/_test-utils/_activated-storage"; - -describe("/api/integrations/actions/[key]/index", () => { - beforeAll(async () => { - await setupAllTestData(["users"]); - await setupActivatedStorageTestData([{ key: "google" }, { key: "minio" }]); - }); - - describe("POST", () => { - describe("with invalid input", () => { - it("should throw error on request", async () => { - const { req, res } = createAuthenticatedMocks({ - method: "POST", - query: { - key: "s3", - }, - body: { - region: "some invalid region", - }, - }); - await handler(req, res); - - expect(res._getStatusCode()).toBe(400); - expect(res._getJSONData()).toMatchInlineSnapshot(` - { - "message": "Invalid Request", - "method": "POST", - "name": "BadRequestError", - "path": "", - "statusCode": 400, - "validations": { - "accessKeyId": "Access Key Id is required", - "secretAccessKey": "Secret Access Key is required", - }, - } - `); - }); - - it("should not show the activated storage in list", async () => { - const { req: activeReq, res: activeRes } = createAuthenticatedMocks({ - method: "GET", - }); - - await activeHandler(activeReq, activeRes); - - expect(activeRes._getJSONData()).toMatchInlineSnapshot(` - [ - "google", - "minio", - ] - `); - }); - - it("should not save the credentials", async () => { - const { req: credentialsReq, res: credentialsRes } = - createAuthenticatedMocks({ - method: "POST", - query: { - key: "s3", - }, - body: { - _password: "password", - }, - }); - await credentialsHandler(credentialsReq, credentialsRes); - - expect(credentialsRes._getStatusCode()).toBe(400); - expect(credentialsRes._getJSONData()).toMatchInlineSnapshot(` - { - "message": "No credentials available for AWS_S3", - "method": "POST", - "name": "BadRequestError", - "path": "", - "statusCode": 400, - } - `); - }); - }); - - describe("valid", () => { - it("should activate a storage key", async () => { - const { req, res } = createAuthenticatedMocks({ - method: "POST", - query: { - key: "s3", - }, - body: { - key1: "should not be saved", - accessKeyId: "some-access-key-id", - secretAccessKey: "some-secret-access-key", - region: "some-region", - }, - }); - await handler(req, res); - - expect(res._getStatusCode()).toBe(201); - }); - - it("should show the activated storage in list", async () => { - const { req: activeReq, res: activeRes } = createAuthenticatedMocks({ - method: "GET", - }); - - await activeHandler(activeReq, activeRes); - - expect(activeRes._getJSONData()).toMatchInlineSnapshot(` - [ - "google", - "minio", - "s3", - ] - `); - }); - - it("should save the credentials", async () => { - const { req: credentialsReq, res: credentialsRes } = - createAuthenticatedMocks({ - method: "POST", - query: { - key: "s3", - }, - body: { - _password: "password", - }, - }); - await credentialsHandler(credentialsReq, credentialsRes); - - expect(credentialsRes._getStatusCode()).toBe(201); - expect(credentialsRes._getJSONData()).toMatchInlineSnapshot(` - { - "accessKeyId": "some-access-key-id", - "region": "some-region", - "secretAccessKey": "some-secret-access-key", - } - `); - }); - }); - }); - - describe("PATCH", () => { - it("should update storage configuration", async () => { - const { req, res } = createAuthenticatedMocks({ - method: "PATCH", - query: { - key: "s3", - }, - body: { - invalid: "should not show up", - accessKeyId: "updated some-access-key-id", - secretAccessKey: "updated some-secret-access-key", - region: "updated some-region", - }, - }); - await handler(req, res); - - expect(res._getStatusCode()).toBe(200); - }); - - it("should return updated storage config", async () => { - const { req: credentialsReq, res: credentialsRes } = - createAuthenticatedMocks({ - method: "POST", - query: { - key: "s3", - }, - body: { - _password: "password", - }, - }); - await credentialsHandler(credentialsReq, credentialsRes); - - expect(credentialsRes._getStatusCode()).toBe(201); - expect(credentialsRes._getJSONData()).toMatchInlineSnapshot(` - { - "accessKeyId": "updated some-access-key-id", - "region": "updated some-region", - "secretAccessKey": "updated some-secret-access-key", - } - `); - }); - - it("should throw error when updating with invalid config", async () => { - const { req, res } = createAuthenticatedMocks({ - method: "POST", - query: { - key: "s3", - }, - body: { - region: "should not save", - }, - }); - await handler(req, res); - - expect(res._getStatusCode()).toBe(400); - expect(res._getJSONData()).toMatchInlineSnapshot(` - { - "message": "Invalid Request", - "method": "POST", - "name": "BadRequestError", - "path": "", - "statusCode": 400, - "validations": { - "accessKeyId": "Access Key Id is required", - "secretAccessKey": "Secret Access Key is required", - }, - } - `); - }); - - it("should return previous storage config", async () => { - const { req: credentialsReq, res: credentialsRes } = - createAuthenticatedMocks({ - method: "POST", - query: { - key: "s3", - }, - body: { - _password: "password", - }, - }); - await credentialsHandler(credentialsReq, credentialsRes); - - expect(credentialsRes._getStatusCode()).toBe(201); - expect(credentialsRes._getJSONData()).toMatchInlineSnapshot(` - { - "accessKeyId": "updated some-access-key-id", - "region": "updated some-region", - "secretAccessKey": "updated some-secret-access-key", - } - `); - }); - }); - - describe("DELETE", () => { - it("should deactivate activated storage", async () => { - const { req, res } = createAuthenticatedMocks({ - method: "DELETE", - query: { - key: "s3", - }, - }); - await handler(req, res); - - expect(res._getStatusCode()).toBe(204); - }); - - it("should remove activated action", async () => { - const { req: activeReq, res: activeRes } = createAuthenticatedMocks({ - method: "GET", - }); - - await activeHandler(activeReq, activeRes); - - expect(activeRes._getJSONData()).toMatchInlineSnapshot(` - [ - "google", - "minio", - ] - `); - }); - - it("should remove access to credentials", async () => { - const { req: credentialsReq, res: credentialsRes } = - createAuthenticatedMocks({ - method: "POST", - query: { - key: "s3", - }, - body: { - _password: "password", - }, - }); - await credentialsHandler(credentialsReq, credentialsRes); - - expect(credentialsRes._getStatusCode()).toBe(400); - expect(credentialsRes._getJSONData()).toMatchInlineSnapshot(` - { - "message": "No credentials available for AWS_S3", - "method": "POST", - "name": "BadRequestError", - "path": "", - "statusCode": 400, - } - `); - }); - }); -}); diff --git a/src/__tests__/api/integrations/storage/active.spec.ts b/src/__tests__/api/integrations/storage/active.spec.ts deleted file mode 100644 index a595bdee4..000000000 --- a/src/__tests__/api/integrations/storage/active.spec.ts +++ /dev/null @@ -1,26 +0,0 @@ -import handler from "pages/api/integrations/storage/active"; -import { - createAuthenticatedMocks, - setupAllTestData, -} from "__tests__/api/_test-utils"; - -describe("/api/integrations/storage/active", () => { - beforeAll(async () => { - await setupAllTestData(["activated-storage"]); - }); - - it("should show all activated storage", async () => { - const { req, res } = createAuthenticatedMocks({ - method: "GET", - }); - - await handler(req, res); - - expect(res._getJSONData()).toMatchInlineSnapshot(` - [ - "s3", - "google", - ] - `); - }); -}); diff --git a/src/__tests__/api/integrations/storage/list.spec.ts b/src/__tests__/api/integrations/storage/list.spec.ts deleted file mode 100644 index d44d24976..000000000 --- a/src/__tests__/api/integrations/storage/list.spec.ts +++ /dev/null @@ -1,78 +0,0 @@ -import handler from "pages/api/integrations/storage/list"; -import { createAuthenticatedMocks } from "__tests__/api/_test-utils"; - -describe("/api/integrations/storage/list", () => { - it("should list storage integrations", async () => { - const { req, res } = createAuthenticatedMocks({ - method: "GET", - }); - await handler(req, res); - - expect(res._getStatusCode()).toBe(200); - expect(res._getJSONData()).toMatchInlineSnapshot(` - [ - { - "configurationSchema": {}, - "description": "Store uploaded files to Local Storage", - "key": "file", - "title": "Local Storage", - }, - { - "configurationSchema": { - "accessKeyId": { - "type": "text", - "validations": [ - { - "validationType": "required", - }, - ], - }, - "region": { - "type": "text", - "validations": [ - { - "validationType": "required", - }, - ], - }, - "secretAccessKey": { - "type": "text", - "validations": [ - { - "validationType": "required", - }, - ], - }, - }, - "description": "Store uploaded files to AWS S3", - "key": "s3", - "title": "AWS S3", - }, - { - "configurationSchema": {}, - "description": "Store uploaded files to Firebase Storage", - "key": "firebase", - "title": "Firebase Storage", - }, - { - "configurationSchema": {}, - "description": "Store uploaded files to Minio", - "key": "minio", - "title": "Minio", - }, - { - "configurationSchema": {}, - "description": "Store uploaded files to Cloudinary", - "key": "cloudinary", - "title": "Cloudinary", - }, - { - "configurationSchema": {}, - "description": "Store uploaded files to Google Cloud Storage", - "key": "google", - "title": "Google Cloud Storage", - }, - ] - `); - }); -}); diff --git a/src/backend/lib/config-persistence/types.ts b/src/backend/lib/config-persistence/types.ts index 8f8305d4f..af9a50f6a 100644 --- a/src/backend/lib/config-persistence/types.ts +++ b/src/backend/lib/config-persistence/types.ts @@ -14,7 +14,6 @@ export type ConfigDomain = | "key-value" | "action-instances" | "activated-actions" - | "activated-storage" | "roles"; export enum ConfigAdaptorTypes { diff --git a/src/backend/npm-packages/constants.ts b/src/backend/npm-packages/constants.ts deleted file mode 100644 index b76fd0ac3..000000000 --- a/src/backend/npm-packages/constants.ts +++ /dev/null @@ -1,153 +0,0 @@ -import { - ConfigKeys, - configApiService, -} from "backend/lib/config/config.service"; -import { CacheAdaptorTypes } from "backend/lib/cache/types"; -import { credentialsApiService } from "backend/integrations-configurations"; -import { DATABASE_CREDENTIAL_GROUP } from "backend/data/fields"; -import { IDataSourceCredentials } from "shared/types/data-sources"; -import { RDMSSources } from "@dashpress/bacteria"; -import { ACTION_INTEGRATIONS } from "backend/actions/integrations"; -import { ActionIntegrationKeys } from "shared/types/actions"; -import { PORTAL_NPM_PACKAGES_CONFIG, PortalNpmPackageDomain } from "./portal"; -import { INpmPackagesConfig } from "./types"; - -enum BaseNpmPackageDomain { - FileUpload = "file-upload", // after any file upload is activated - Mail = "mail", - Redis = "redis", - Postgres = "postgres", - SQlite = "sqlite", - MySQl = "mysql", - MsSQL = "mssql", - Oracle = "oracle", -} - -export const DatabaseNpmPackageDomains = [ - BaseNpmPackageDomain.Postgres, - BaseNpmPackageDomain.MySQl, - BaseNpmPackageDomain.SQlite, - BaseNpmPackageDomain.MsSQL, - BaseNpmPackageDomain.Oracle, -]; - -export type NpmPackageDomain = BaseNpmPackageDomain | PortalNpmPackageDomain; - -const shouldDatabaseNpmPackageBeInstalled = async ( - rdbmsSource: RDMSSources -) => { - const hasDbCredentials = await credentialsApiService.hasGroupKey( - DATABASE_CREDENTIAL_GROUP - ); - - if (!hasDbCredentials) { - return true; - } - - const dbCredentials = - await credentialsApiService.useGroupValue( - DATABASE_CREDENTIAL_GROUP - ); - - return dbCredentials.dataSourceType === rdbmsSource; -}; - -const BASE_NPM_PACKAGES_CONFIG: Record< - BaseNpmPackageDomain, - INpmPackagesConfig -> = { - [BaseNpmPackageDomain.FileUpload]: { - packages: [ - { - package: "multer", - version: "^1.4.5-lts.1", - }, - ], - shouldInstall: async () => true, - }, - [BaseNpmPackageDomain.Mail]: { - packages: [ - { - package: "nodemailer", - version: "^6.8.0", - }, - ], - shouldInstall: async () => - await credentialsApiService.hasGroupKey({ - key: ACTION_INTEGRATIONS[ActionIntegrationKeys.SMTP].credentialsKey, - fields: Object.keys( - ACTION_INTEGRATIONS[ActionIntegrationKeys.SMTP].configurationSchema - ), - }), - }, - [BaseNpmPackageDomain.Redis]: { - packages: [ - { - package: "redis", - version: "^4.4.0", - }, - ], - shouldInstall: async () => { - return ( - configApiService.getConfigValue( - ConfigKeys.CACHE_ADAPTOR - ) === CacheAdaptorTypes.Redis - ); - }, - }, - [BaseNpmPackageDomain.Postgres]: { - packages: [ - { - package: "pg", - version: "^8.7.3", - }, - ], - shouldInstall: async () => - await shouldDatabaseNpmPackageBeInstalled(RDMSSources.Postgres), - }, - [BaseNpmPackageDomain.SQlite]: { - packages: [ - { - package: "sqlite3", - version: "^5.0.8", - }, - ], - shouldInstall: async () => - await shouldDatabaseNpmPackageBeInstalled(RDMSSources.Sqlite), - }, - [BaseNpmPackageDomain.MySQl]: { - packages: [ - { - package: "mysql2", - version: "^2.3.3", - }, - ], - shouldInstall: async () => - await shouldDatabaseNpmPackageBeInstalled(RDMSSources.MySql), - }, - [BaseNpmPackageDomain.MsSQL]: { - packages: [ - { - package: "mssql", - version: "^8.1.2", - }, - ], - shouldInstall: async () => - await shouldDatabaseNpmPackageBeInstalled(RDMSSources.MsSql), - }, - [BaseNpmPackageDomain.Oracle]: { - packages: [ - { - package: "oracledb", - version: "^5.4.0", - }, - ], - shouldInstall: async () => false, - }, -}; - -export const NPM_PACKAGES_CONFIG: Record = - { - ...BASE_NPM_PACKAGES_CONFIG, - ...PORTAL_NPM_PACKAGES_CONFIG, - }; diff --git a/src/backend/npm-packages/npm-packages.service.ts b/src/backend/npm-packages/npm-packages.service.ts deleted file mode 100644 index 05b4504ff..000000000 --- a/src/backend/npm-packages/npm-packages.service.ts +++ /dev/null @@ -1,74 +0,0 @@ -import { IApplicationService } from "backend/types"; - -import { execa } from "execa"; -import { NPM_PACKAGES_CONFIG, NpmPackageDomain } from "./constants"; - -const fs = require("fs-extra"); - -const path = require("path"); - -const BASE_NPM_FILE = { - name: "npm-temp", - version: "1.0.0", - description: "", - main: "index.js", - scripts: { - test: 'echo "Error: no test specified" && exit 1', - }, - keywords: [], - author: "Ayobami Akingbade", - license: "ISC", - dependencies: {}, -}; - -export interface INpmPackage { - packageDomain: NpmPackageDomain; -} - -export class NpmPackagesApiService implements IApplicationService { - async bootstrap() { - await this.installPackages(); - } - - private async installPackages(): Promise { - const dir = "npm-temp"; - - if (!fs.existsSync(dir)) { - fs.mkdirSync(dir); - } - - const dependencies = await this.getPackagesDependencies(); - - BASE_NPM_FILE.dependencies = dependencies; - - // Also move the package.lock file there - - fs.writeFileSync( - path.join(process.cwd(), `${dir}/package.json`), - BASE_NPM_FILE - ); - - const { stdout, stderr } = execa("npm", ["install"], { - cwd: path.join(process.cwd(), `${dir}`), - }); - stdout.pipe(process.stdout); - stderr.pipe(process.stderr); - - // the move the npm packages to the node modules - } - - async getPackagesDependencies(): Promise> { - const packages: Record = {}; - for (const packageConfig of Object.values(NPM_PACKAGES_CONFIG)) { - if (await packageConfig.shouldInstall()) { - packageConfig.packages.forEach((eachPackageDep) => { - // :eyes Check if the package already exist then dont install - packages[eachPackageDep.package] = eachPackageDep.version; - }); - } - } - return packages; - } -} - -export const npmPackagesApiService = new NpmPackagesApiService(); diff --git a/src/backend/npm-packages/portal/index.ts b/src/backend/npm-packages/portal/index.ts deleted file mode 100644 index 82544d55b..000000000 --- a/src/backend/npm-packages/portal/index.ts +++ /dev/null @@ -1 +0,0 @@ -export { PORTAL_NPM_PACKAGES_CONFIG, PortalNpmPackageDomain } from "./main"; diff --git a/src/backend/npm-packages/portal/main.ts b/src/backend/npm-packages/portal/main.ts deleted file mode 100644 index dc47ed85c..000000000 --- a/src/backend/npm-packages/portal/main.ts +++ /dev/null @@ -1,15 +0,0 @@ -import { INpmPackagesConfig } from "../types"; - -export enum PortalNpmPackageDomain { - Empty = "Empty", -} - -export const PORTAL_NPM_PACKAGES_CONFIG: Record< - PortalNpmPackageDomain, - INpmPackagesConfig -> = { - [PortalNpmPackageDomain.Empty]: { - packages: [], - shouldInstall: async () => false, - }, -}; diff --git a/src/backend/npm-packages/types.ts b/src/backend/npm-packages/types.ts deleted file mode 100644 index 21cab1fb9..000000000 --- a/src/backend/npm-packages/types.ts +++ /dev/null @@ -1,7 +0,0 @@ -export interface INpmPackagesConfig { - shouldInstall: () => Promise; - packages: { - package: string; - version: string; - }[]; -} diff --git a/src/backend/storage/integrations/aws/index.ts b/src/backend/storage/integrations/aws/index.ts deleted file mode 100644 index 3d5ce079c..000000000 --- a/src/backend/storage/integrations/aws/index.ts +++ /dev/null @@ -1,62 +0,0 @@ -import { IStorageIntegrationsImplemention } from "backend/storage/types"; - -// https://www.npmjs.com/package/multer-s3 - -export const AWS_STORAGE_INTEGRATION: IStorageIntegrationsImplemention< - { - accessKeyId: string; - secretAccessKey: string; - region: string; - }, - { - bucket: string; - } -> = { - title: "AWS S3", - credentialsGroupKey: "AWS_S3", - packages: ["aws-sdk"], - integrationConfigurationSchema: { - accessKeyId: { - type: "text", - validations: [ - { - validationType: "required", - }, - ], - }, - secretAccessKey: { - type: "text", - validations: [ - { - validationType: "required", - }, - ], - }, - region: { - type: "text", - validations: [ - { - validationType: "required", - }, - ], - }, - }, - uploadConfigurationSchema: { - bucket: { - type: "text", - validations: [ - { - validationType: "required", - }, - ], - }, - }, - store: async (integrationConfig, uploadConfig, file: File) => { - // const foo = new S3Client({ - // region: "string", - // }); - // eslint-disable-next-line no-console - console.log(integrationConfig, uploadConfig, file); - return ""; - }, -}; diff --git a/src/backend/storage/integrations/cloudinary/index.ts b/src/backend/storage/integrations/cloudinary/index.ts deleted file mode 100644 index 08fa16879..000000000 --- a/src/backend/storage/integrations/cloudinary/index.ts +++ /dev/null @@ -1,40 +0,0 @@ -import { IStorageIntegrationsImplemention } from "backend/storage/types"; - -export const CLOUDINARY_STORAGE_INTEGRATION: IStorageIntegrationsImplemention< - {}, - { - folder: string; - } -> = { - title: "Cloudinary", - packages: ["cloudinary", "multer-storage-cloudinary"], - credentialsGroupKey: "CLOUDINARY", - integrationConfigurationSchema: {}, - uploadConfigurationSchema: { - folder: { - type: "text", - validations: [ - { - validationType: "required", - }, - ], - }, - }, - store: async (integrationConfig, uploadConfig, file) => { - // const cloudinary = require("cloudinary").v2; - // const { CloudinaryStorage } = require("multer-storage-cloudinary"); - - // const storage = new CloudinaryStorage({ - // cloudinary, - // params: { - // folder: "some-folder-name", - // format: async (req, file) => "png", - // public_id: (req, file) => "computed-filename-using-request", - // }, - // }); - - // storage._handleFile(req, file, (details) => {}); - - return `${integrationConfig} ${uploadConfig} ${file}`; - }, -}; diff --git a/src/backend/storage/integrations/firebase/index.ts b/src/backend/storage/integrations/firebase/index.ts deleted file mode 100644 index 08498a3e6..000000000 --- a/src/backend/storage/integrations/firebase/index.ts +++ /dev/null @@ -1,30 +0,0 @@ -import { IStorageIntegrationsImplemention } from "backend/storage/types"; - -// https://github.com/khaosdoctor/multer-firebase-storage - -export const FIREBASE_STORAGE_INTEGRATION: IStorageIntegrationsImplemention< - {}, - { - folder: string; - } -> = { - title: "Firebase Storage", - credentialsGroupKey: "FIREBASE_STORAGE", - packages: [], - uploadConfigurationSchema: { - folder: { - type: "text", - validations: [ - { - validationType: "required", - }, - ], - }, - }, - integrationConfigurationSchema: {}, - store: async (integrationConfig, uploadConfig, file: File) => { - // eslint-disable-next-line no-console - console.log(integrationConfig, uploadConfig, file); - return ""; - }, -}; diff --git a/src/backend/storage/integrations/google/index.ts b/src/backend/storage/integrations/google/index.ts deleted file mode 100644 index c1654a65f..000000000 --- a/src/backend/storage/integrations/google/index.ts +++ /dev/null @@ -1,30 +0,0 @@ -import { IStorageIntegrationsImplemention } from "backend/storage/types"; - -// https://www.npmjs.com/package/multer-cloud-storage - -export const GOOGLE_STORAGE_INTEGRATION: IStorageIntegrationsImplemention< - {}, - { - folder: string; - } -> = { - title: "Google Cloud Storage", - credentialsGroupKey: "GOOGLE_CLOUD_STORAGE", - packages: ["aws-sdk"], - integrationConfigurationSchema: {}, - uploadConfigurationSchema: { - folder: { - type: "text", - validations: [ - { - validationType: "required", - }, - ], - }, - }, - store: async (integrationConfig, uploadConfig, file) => { - // eslint-disable-next-line no-console - console.log(integrationConfig, uploadConfig, file); - return ""; - }, -}; diff --git a/src/backend/storage/integrations/index.ts b/src/backend/storage/integrations/index.ts index 403c3be54..c293e87f8 100644 --- a/src/backend/storage/integrations/index.ts +++ b/src/backend/storage/integrations/index.ts @@ -1,35 +1,9 @@ -import { IStorageIntegrationsImplemention } from "../types"; -import { AWS_STORAGE_INTEGRATION } from "./aws"; -import { CLOUDINARY_STORAGE_INTEGRATION } from "./cloudinary"; -import { FIREBASE_STORAGE_INTEGRATION } from "./firebase"; -import { GOOGLE_STORAGE_INTEGRATION } from "./google"; -import { LOCAL_STORAGE_INTEGRATION } from "./local"; -import { MINIO_STORAGE_INTEGRATION } from "./minio"; - -export const STORAGE_INTEGRATIONS: Record< - string, - IStorageIntegrationsImplemention -> = { - file: LOCAL_STORAGE_INTEGRATION, - s3: AWS_STORAGE_INTEGRATION, - firebase: FIREBASE_STORAGE_INTEGRATION, - minio: MINIO_STORAGE_INTEGRATION, - cloudinary: CLOUDINARY_STORAGE_INTEGRATION, - google: GOOGLE_STORAGE_INTEGRATION, - // digital: Digital Ocean Space -}; - -// const AWS = require("aws-sdk"); -// const fs = require("fs"); -// const dotenv = require("dotenv"); - -// dotenv.configure(); -// const spacesEndpoint = new AWS.Endpoint(process.env.DO_SPACES_ENDPOINT); -// const s3 = new AWS.S3({endpoint: spacesEndpoint, accessKeyId: process.env.DO_SPACES_KEY, secretAccessKey: process.env.DO_SPACES_SECRET}); - -// const file = fs.readFileSync("path/to/file.jpg"); - -// s3.putObjet({Bucket: process.env.DO_SPACES_NAME, Key: "any_file_or_path_name.jpg", Body: file, ACL: "public"}, (err, data) => { -// if (err) return console.log(err); -// console.log("Your file has been uploaded successfully!", data); -// }); +export const STORAGES = [ + "local", + "s3", + "firebase", + "minio", + "cloudinary", + "google", + "digital", +]; diff --git a/src/backend/storage/integrations/local/index.ts b/src/backend/storage/integrations/local/index.ts deleted file mode 100644 index 5fa7df228..000000000 --- a/src/backend/storage/integrations/local/index.ts +++ /dev/null @@ -1,28 +0,0 @@ -import { IStorageIntegrationsImplemention } from "backend/storage/types"; - -export const LOCAL_STORAGE_INTEGRATION: IStorageIntegrationsImplemention< - {}, - { - folder: string; - } -> = { - title: "Local Storage", - credentialsGroupKey: "FILE", - packages: [], - integrationConfigurationSchema: {}, - uploadConfigurationSchema: { - folder: { - type: "text", - validations: [ - { - validationType: "required", - }, - ], - }, - }, - store: async (integrationConfig, uploadConfig, file) => { - // eslint-disable-next-line no-console - console.log(integrationConfig, uploadConfig, file); - return ""; - }, -}; diff --git a/src/backend/storage/integrations/minio/index.ts b/src/backend/storage/integrations/minio/index.ts deleted file mode 100644 index 893812256..000000000 --- a/src/backend/storage/integrations/minio/index.ts +++ /dev/null @@ -1,30 +0,0 @@ -import { IStorageIntegrationsImplemention } from "backend/storage/types"; - -// https://www.npmjs.com/package/multer-minio-storage-engine - -export const MINIO_STORAGE_INTEGRATION: IStorageIntegrationsImplemention< - {}, - { - folder: string; - } -> = { - title: "Minio", - credentialsGroupKey: "MINIO", - packages: ["multer-minio-storage-engine@1.0.0", "minio"], - integrationConfigurationSchema: {}, - uploadConfigurationSchema: { - folder: { - type: "text", - validations: [ - { - validationType: "required", - }, - ], - }, - }, - store: async (integrationConfig, uploadConfig, file) => { - // eslint-disable-next-line no-console - console.log(integrationConfig, uploadConfig, file); - return ""; - }, -}; diff --git a/src/backend/storage/storage.controller.ts b/src/backend/storage/storage.controller.ts deleted file mode 100644 index ff4d2f35a..000000000 --- a/src/backend/storage/storage.controller.ts +++ /dev/null @@ -1,40 +0,0 @@ -import { StorageApiService, storageApiService } from "./storage.service"; - -export class StorageApiController { - constructor(private _storageApiService: StorageApiService) {} - - listIntegrations() { - return this._storageApiService.listStorageIntegrations(); - } - - async listActivatedStorage() { - return await this._storageApiService.listActivatedStorage(); - } - - async activateStorage( - storageKey: string, - configuration: Record - ) { - await this._storageApiService.activateStorage(storageKey, configuration); - } - - async showStorageConfig(storageKey: string) { - return await this._storageApiService.showStorageConfig(storageKey); - } - - async updateStorageConfig( - storageKey: string, - configuration: Record - ) { - await this._storageApiService.updateStorageConfig( - storageKey, - configuration - ); - } - - async deactivateStorage(storageKey: string) { - await this._storageApiService.deactivateStorage(storageKey); - } -} - -export const storageApiController = new StorageApiController(storageApiService); diff --git a/src/backend/storage/storage.service.ts b/src/backend/storage/storage.service.ts deleted file mode 100644 index 204a1804c..000000000 --- a/src/backend/storage/storage.service.ts +++ /dev/null @@ -1,115 +0,0 @@ -import { - credentialsApiService, - CredentialsApiService, -} from "backend/integrations-configurations"; -import { - createConfigDomainPersistenceService, - AbstractConfigDataPersistenceService, -} from "backend/lib/config-persistence"; -import { validateSchemaRequestBody } from "backend/lib/errors/validate-schema-request-input"; -import { IApplicationService } from "backend/types"; -import { IIntegrationsList } from "shared/types/actions"; -import { IActivatedStorage } from "shared/types/storage"; -import { STORAGE_INTEGRATIONS } from "./integrations"; - -export class StorageApiService implements IApplicationService { - constructor( - private readonly _activatedStoragePersistenceService: AbstractConfigDataPersistenceService, - private readonly _credentialsApiService: CredentialsApiService - ) {} - - async bootstrap() { - await this._activatedStoragePersistenceService.setup(); - } - - listStorageIntegrations(): IIntegrationsList[] { - return Object.entries(STORAGE_INTEGRATIONS).map( - ([key, { title, integrationConfigurationSchema }]) => ({ - title, - key, - description: `Store uploaded files to ${title}`, - configurationSchema: integrationConfigurationSchema, - }) - ); - } - - async listActivatedStorage(): Promise { - const activatedStorage = - await this._activatedStoragePersistenceService.getAllItems(); - return activatedStorage.map(({ key }) => key); - } - - async activateStorage( - storageKey: string, - configuration: Record - ): Promise { - validateSchemaRequestBody( - STORAGE_INTEGRATIONS[storageKey].integrationConfigurationSchema, - configuration - ); - - await this._activatedStoragePersistenceService.createItem(storageKey, { - key: storageKey, - }); - - await this._credentialsApiService.upsertGroup( - { - key: STORAGE_INTEGRATIONS[storageKey].credentialsGroupKey, - fields: Object.keys( - STORAGE_INTEGRATIONS[storageKey].integrationConfigurationSchema - ), - }, - configuration - ); - } - - async showStorageConfig( - storageKey: string - ): Promise> { - return await this._credentialsApiService.useGroupValue({ - key: STORAGE_INTEGRATIONS[storageKey].credentialsGroupKey, - fields: Object.keys( - STORAGE_INTEGRATIONS[storageKey].integrationConfigurationSchema - ), - }); - } - - async updateStorageConfig( - storageKey: string, - configuration: Record - ): Promise { - validateSchemaRequestBody( - STORAGE_INTEGRATIONS[storageKey].integrationConfigurationSchema, - configuration - ); - - await this._credentialsApiService.upsertGroup( - { - key: STORAGE_INTEGRATIONS[storageKey].credentialsGroupKey, - fields: Object.keys( - STORAGE_INTEGRATIONS[storageKey].integrationConfigurationSchema - ), - }, - configuration - ); - } - - async deactivateStorage(storageKey: string): Promise { - await this._credentialsApiService.deleteGroup({ - key: STORAGE_INTEGRATIONS[storageKey].credentialsGroupKey, - fields: Object.keys( - STORAGE_INTEGRATIONS[storageKey].integrationConfigurationSchema - ), - }); - - await this._activatedStoragePersistenceService.removeItem(storageKey); - } -} - -const activatedStoragePersistenceService = - createConfigDomainPersistenceService("activated-storage"); - -export const storageApiService = new StorageApiService( - activatedStoragePersistenceService, - credentialsApiService -); diff --git a/src/backend/storage/types.ts b/src/backend/storage/types.ts deleted file mode 100644 index cac1ac487..000000000 --- a/src/backend/storage/types.ts +++ /dev/null @@ -1,12 +0,0 @@ -import { IAppliedSchemaFormConfig } from "shared/form-schemas/types"; - -export interface IStorageIntegrationsImplemention { - title: string; - credentialsGroupKey: string; - packages: string[]; - uploadConfigurationSchema: IAppliedSchemaFormConfig; - integrationConfigurationSchema: IAppliedSchemaFormConfig; - store: (integrationConfig: T, uploadConfig: T, file: File) => Promise; -} - -export const FOR_CODE_COV = 1; diff --git a/src/bin/index.ts b/src/bin/index.ts index 71de4634e..b05435c3b 100644 --- a/src/bin/index.ts +++ b/src/bin/index.ts @@ -1,6 +1,5 @@ /* eslint-disable no-console */ import * as randomstring from "randomstring"; -import { npmPackagesApiService } from "backend/npm-packages/npm-packages.service"; import { checkNodeVersion } from "./checkNodeVersion"; const replaceRandomCharaters = (envContent: string) => { @@ -96,8 +95,6 @@ const replaceRandomCharaters = (envContent: string) => { )} `); - await npmPackagesApiService.bootstrap(); - const { stdout, stderr } = execa("npm", ["run", "start"], { cwd: path.join(__dirname, ".."), }); diff --git a/src/frontend/views/integrations/_Base.tsx b/src/frontend/views/integrations/_Base.tsx index e2e01cdf1..8e1148667 100644 --- a/src/frontend/views/integrations/_Base.tsx +++ b/src/frontend/views/integrations/_Base.tsx @@ -2,7 +2,7 @@ import { useRouteParam } from "frontend/lib/routing/useRouteParam"; import { ViewStateMachine } from "frontend/components/ViewStateMachine"; import { useRouter } from "next/router"; import { ReactNode } from "react"; -import { Book, Cloud, UploadCloud, Zap, ZapOff } from "react-feather"; +import { Book, Zap, ZapOff } from "react-feather"; import { ContentLayout } from "frontend/design-system/components/Section/SectionDivider"; import { SectionBox } from "frontend/design-system/components/Section/SectionBox"; import { ListSkeleton } from "frontend/design-system/components/Skeleton/List"; @@ -16,10 +16,6 @@ import { useActionIntegrationsList, useActiveActionList, } from "./actions/actions.store"; -import { - useActiveStorageIntegrationList, - useStorageIntegrationsList, -} from "./storage/storage.store"; import { ACTION_INTEGRATIONS_CRUD_CONFIG } from "./actions/constants"; interface IProps { @@ -32,9 +28,6 @@ export function BaseActionsLayout({ children }: IProps) { const actionIntegrationsList = useActionIntegrationsList(); const activeActionList = useActiveActionList(); - const storageIntegrationsList = useStorageIntegrationsList(); - const activeStorageIntegrationList = useActiveStorageIntegrationList(); - const router = useRouter(); const activeList = [ @@ -77,47 +70,6 @@ export function BaseActionsLayout({ children }: IProps) { - - {process.env.NEXT_PUBLIC_SHOW_UNFINISHED_FEATURES && ( - - } - > - ({ - name: title, - key, - }))} - render={(menuItem) => { - const isActive = activeStorageIntegrationList.data.includes( - menuItem.key - ); - return ( - - ); - }} - /> - - - )} - - useApi("/api/integrations/storage/list", { - errorMessage: STORAGE_INTEGRATIONS_CRUD_CONFIG.TEXT_LANG.NOT_FOUND, - defaultData: [], - }); - -const ACTIVE_STORAGE_INTEGRATIONS_ENDPOINT = "/api/integrations/storage/active"; - -const ACTIVATION_CONFIG = (storageKey: string) => { - return `/api/integrations/storage/${storageKey}/credentials`; -}; - -export const useActiveStorageIntegrationList = () => - useApi(ACTIVE_STORAGE_INTEGRATIONS_ENDPOINT, { - errorMessage: CRUD_CONFIG_NOT_FOUND("Active Storage Integrations"), - defaultData: [], - }); - -export const useStorageIntegrationConfiguration = (storageKey: string) => { - const rootPassword = usePasswordStore((state) => state.password); - return useApi>( - `${ACTIVATION_CONFIG(storageKey)}?${reduceStringToNumber(rootPassword)}`, - { - request: { - body: { - password: rootPassword, - }, - method: "POST", - }, - errorMessage: CRUD_CONFIG_NOT_FOUND("Storage Credentials"), - enabled: !!storageKey && !!rootPassword, - defaultData: {}, - } - ); -}; - -export function useDeactivateStorageMutation() { - const apiMutateOptions = useWaitForResponseMutationOptions< - Record - >({ - endpoints: [ACTIVE_STORAGE_INTEGRATIONS_ENDPOINT], - successMessage: STORAGE_INTEGRATIONS_CRUD_CONFIG.MUTATION_LANG.DE_ACTIVATED, - }); - - return useMutation( - async (storageKey: string) => - await makeActionRequest( - "DELETE", - `/api/integrations/storage/${storageKey}` - ), - apiMutateOptions - ); -} - -export function useActivateStorageMutation(integrationKey: string) { - const apiMutateOptions = useWaitForResponseMutationOptions< - Record - >({ - endpoints: [ACTIVE_STORAGE_INTEGRATIONS_ENDPOINT], - successMessage: STORAGE_INTEGRATIONS_CRUD_CONFIG.MUTATION_LANG.ACTIVATED, - }); - - return useMutation( - async (configuration: Record) => - await makeActionRequest( - "POST", - `/api/integrations/storage/${integrationKey}`, - configuration - ), - apiMutateOptions - ); -} - -export function useUpdateActivatedStorageMutation(storageKey: string) { - const apiMutateOptions = useWaitForResponseMutationOptions< - Record - >({ - endpoints: [ACTIVE_STORAGE_INTEGRATIONS_ENDPOINT], - successMessage: STORAGE_INTEGRATIONS_CRUD_CONFIG.MUTATION_LANG.EDIT, - }); - - return useMutation( - async (configuration: Record) => - await makeActionRequest( - "PATCH", - `/api/integrations/storage/${storageKey}`, - configuration - ), - apiMutateOptions - ); -} diff --git a/src/pages/api/healthcheck/index.ts b/src/pages/api/healthcheck/index.ts index 2ee8a6ca2..fa36f095f 100644 --- a/src/pages/api/healthcheck/index.ts +++ b/src/pages/api/healthcheck/index.ts @@ -12,7 +12,6 @@ import { configApiService } from "backend/lib/config/config.service"; import { rolesApiService } from "backend/roles/roles.service"; import { schemasApiService } from "backend/schema/schema.service"; import { usersApiService } from "backend/users/users.service"; -import { storageApiService } from "backend/storage/storage.service"; import { actionsApiService } from "backend/actions/actions.service"; import { dashboardWidgetsApiService } from "backend/dashboard-widgets/dashboard-widgets.service"; import { listOrderApiService } from "backend/list-order/list-order.service"; @@ -37,7 +36,6 @@ export default requestHandler( await entitiesApiService.bootstrap(); await actionsApiService.bootstrap(); await dashboardWidgetsApiService.bootstrap(); - await storageApiService.bootstrap(); await listOrderApiService.bootstrap(); await bootstrapPortalServices(); diff --git a/src/pages/api/integrations/storage/[key]/credentials.ts b/src/pages/api/integrations/storage/[key]/credentials.ts deleted file mode 100644 index c11a8b962..000000000 --- a/src/pages/api/integrations/storage/[key]/credentials.ts +++ /dev/null @@ -1,31 +0,0 @@ -import { USER_PERMISSIONS } from "shared/constants/user"; -import { storageApiController } from "backend/storage/storage.controller"; -import { requestHandler } from "backend/lib/request"; - -const REQUEST_KEY_FIELD = "key"; - -export default requestHandler( - { - POST: async (getValidatedRequest) => { - const validatedRequest = await getValidatedRequest([ - { - _type: "requestQuery", - options: REQUEST_KEY_FIELD, - }, - ]); - - return await storageApiController.showStorageConfig( - validatedRequest.requestQuery - ); - }, - }, - [ - { - _type: "canUser", - body: USER_PERMISSIONS.CAN_MANAGE_INTEGRATIONS, - }, - { - _type: "withPassword", - }, - ] -); diff --git a/src/pages/api/integrations/storage/[key]/index.ts b/src/pages/api/integrations/storage/[key]/index.ts deleted file mode 100644 index 1fafe7656..000000000 --- a/src/pages/api/integrations/storage/[key]/index.ts +++ /dev/null @@ -1,62 +0,0 @@ -import { USER_PERMISSIONS } from "shared/constants/user"; -import { storageApiController } from "backend/storage/storage.controller"; -import { requestHandler } from "backend/lib/request"; - -const REQUEST_KEY_FIELD = "key"; - -export default requestHandler( - { - POST: async (getValidatedRequest) => { - const validatedRequest = await getValidatedRequest([ - { - _type: "requestQuery", - options: REQUEST_KEY_FIELD, - }, - { - _type: "requestBody", - options: {}, - }, - ]); - - return await storageApiController.activateStorage( - validatedRequest.requestQuery, - validatedRequest.requestBody - ); - }, - PATCH: async (getValidatedRequest) => { - const validatedRequest = await getValidatedRequest([ - { - _type: "requestQuery", - options: REQUEST_KEY_FIELD, - }, - { - _type: "requestBody", - options: {}, - }, - ]); - - return await storageApiController.updateStorageConfig( - validatedRequest.requestQuery, - validatedRequest.requestBody - ); - }, - DELETE: async (getValidatedRequest) => { - const validatedRequest = await getValidatedRequest([ - { - _type: "requestQuery", - options: REQUEST_KEY_FIELD, - }, - ]); - - return await storageApiController.deactivateStorage( - validatedRequest.requestQuery - ); - }, - }, - [ - { - _type: "canUser", - body: USER_PERMISSIONS.CAN_MANAGE_INTEGRATIONS, - }, - ] -); diff --git a/src/pages/api/integrations/storage/active.ts b/src/pages/api/integrations/storage/active.ts deleted file mode 100644 index 9c87d83e9..000000000 --- a/src/pages/api/integrations/storage/active.ts +++ /dev/null @@ -1,17 +0,0 @@ -import { USER_PERMISSIONS } from "shared/constants/user"; -import { storageApiController } from "backend/storage/storage.controller"; -import { requestHandler } from "backend/lib/request"; - -export default requestHandler( - { - GET: async () => { - return await storageApiController.listActivatedStorage(); - }, - }, - [ - { - _type: "canUser", - body: USER_PERMISSIONS.CAN_MANAGE_INTEGRATIONS, - }, - ] -); diff --git a/src/pages/api/integrations/storage/list.ts b/src/pages/api/integrations/storage/list.ts deleted file mode 100644 index d6378759d..000000000 --- a/src/pages/api/integrations/storage/list.ts +++ /dev/null @@ -1,8 +0,0 @@ -import { storageApiController } from "backend/storage/storage.controller"; -import { requestHandler } from "backend/lib/request"; - -export default requestHandler({ - GET: () => { - return storageApiController.listIntegrations(); - }, -}); diff --git a/src/shared/types/storage.ts b/src/shared/types/storage.ts deleted file mode 100644 index b13e0e710..000000000 --- a/src/shared/types/storage.ts +++ /dev/null @@ -1,5 +0,0 @@ -export interface IActivatedStorage { - key: string; -} - -export const FOR_CODE_COV = 1;