Skip to content

Commit

Permalink
✨ feat(upload): file uploads configurations
Browse files Browse the repository at this point in the history
  • Loading branch information
thrownullexception committed Nov 21, 2023
1 parent 187da28 commit fd8993f
Show file tree
Hide file tree
Showing 56 changed files with 546 additions and 850 deletions.
149 changes: 0 additions & 149 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 0 additions & 22 deletions src/__tests__/api/_test-utils/_activated-storage.ts

This file was deleted.

2 changes: 0 additions & 2 deletions src/__tests__/api/_test-utils/_all.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";

Expand All @@ -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],
Expand Down
73 changes: 1 addition & 72 deletions src/__tests__/api/integrations/storage/[key]/index.spec.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
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 credentialsHandler from "pages/api/integrations/storage/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", () => {
Expand Down Expand Up @@ -43,21 +41,6 @@ describe("/api/integrations/actions/[key]/index", () => {
`);
});

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({
Expand Down Expand Up @@ -237,58 +220,4 @@ describe("/api/integrations/actions/[key]/index", () => {
`);
});
});

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,
}
`);
});
});
});
26 changes: 0 additions & 26 deletions src/__tests__/api/integrations/storage/active.spec.ts

This file was deleted.

9 changes: 7 additions & 2 deletions src/backend/actions/actions.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import {
} from "shared/types/actions";
import { IAccountProfile } from "shared/types/user";
import { compileTemplateString } from "shared/lib/strings/templates";
import { sluggify } from "shared/lib/strings";
import { ACTION_INTEGRATIONS } from "./integrations";

export class ActionsApiService implements IApplicationService {
Expand Down Expand Up @@ -206,8 +207,8 @@ export class ActionsApiService implements IApplicationService {
);

const activationId = nanoid();
const credentialsGroupKey =
ACTION_INTEGRATIONS[integrationKey].credentialsKey;

const credentialsGroupKey = this.makeCredentialsGroupKey(integrationKey);

await this._activatedActionsPersistenceService.createItem(activationId, {
activationId,
Expand All @@ -226,6 +227,10 @@ export class ActionsApiService implements IApplicationService {
);
}

private makeCredentialsGroupKey(integrationKey: ActionIntegrationKeys) {
return sluggify(`ACTION__${integrationKey}`).toUpperCase();
}

private async getIntegrationKeyFromActivatedActionId(
activatedActionId: string
): Promise<string> {
Expand Down
1 change: 0 additions & 1 deletion src/backend/actions/integrations/http/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ const ACTION_CONFIGURATION_SCHEMA: IAppliedSchemaFormConfig<IAction> = {

export const HTTP_ACTION_INTEGRATION: IActionIntegrationsImplemention = {
title: "HTTP",
credentialsKey: "HTTP",
description: "Performs HTTP request",
configurationSchema: {},
connect: async () => {},
Expand Down
Loading

0 comments on commit fd8993f

Please sign in to comment.