Rename serverlessFunction to logicFunction (#17494)
## Summary Rename "Serverless Function" to "Logic Function" across the codebase for clearer naming. ### Environment Variable Changes | Old | New | |-----|-----| | `SERVERLESS_TYPE` | `LOGIC_FUNCTION_TYPE` | | `SERVERLESS_LAMBDA_REGION` | `LOGIC_FUNCTION_LAMBDA_REGION` | | `SERVERLESS_LAMBDA_ROLE` | `LOGIC_FUNCTION_LAMBDA_ROLE` | | `SERVERLESS_LAMBDA_SUBHOSTING_URL` | `LOGIC_FUNCTION_LAMBDA_SUBHOSTING_URL` | | `SERVERLESS_LAMBDA_ACCESS_KEY_ID` | `LOGIC_FUNCTION_LAMBDA_ACCESS_KEY_ID` | | `SERVERLESS_LAMBDA_SECRET_ACCESS_KEY` | `LOGIC_FUNCTION_LAMBDA_SECRET_ACCESS_KEY` | ### Breaking Changes - Environment variables must be updated in production deployments - Database migration renames `serverlessFunction` → `logicFunction` tables
This commit is contained in:
+33
@@ -0,0 +1,33 @@
|
||||
import gql from 'graphql-tag';
|
||||
import { type PerformMetadataQueryParams } from 'test/integration/metadata/types/perform-metadata-query.type';
|
||||
|
||||
import { type CreateLogicFunctionInput } from 'src/engine/metadata-modules/logic-function/dtos/create-logic-function.input';
|
||||
|
||||
export type CreateOneLogicFunctionFactoryInput = CreateLogicFunctionInput;
|
||||
|
||||
const DEFAULT_LOGIC_FUNCTION_GQL_FIELDS = `
|
||||
id
|
||||
name
|
||||
description
|
||||
runtime
|
||||
latestVersion
|
||||
publishedVersions
|
||||
createdAt
|
||||
updatedAt
|
||||
`;
|
||||
|
||||
export const createOneLogicFunctionQueryFactory = ({
|
||||
input,
|
||||
gqlFields = DEFAULT_LOGIC_FUNCTION_GQL_FIELDS,
|
||||
}: PerformMetadataQueryParams<CreateOneLogicFunctionFactoryInput>) => ({
|
||||
query: gql`
|
||||
mutation CreateOneLogicFunction($input: CreateLogicFunctionInput!) {
|
||||
createOneLogicFunction(input: $input) {
|
||||
${gqlFields}
|
||||
}
|
||||
}
|
||||
`,
|
||||
variables: {
|
||||
input,
|
||||
},
|
||||
});
|
||||
+43
@@ -0,0 +1,43 @@
|
||||
import {
|
||||
type CreateOneLogicFunctionFactoryInput,
|
||||
createOneLogicFunctionQueryFactory,
|
||||
} from 'test/integration/metadata/suites/logic-function/utils/create-one-logic-function-query-factory.util';
|
||||
import { makeMetadataAPIRequest } from 'test/integration/metadata/suites/utils/make-metadata-api-request.util';
|
||||
import { type CommonResponseBody } from 'test/integration/metadata/types/common-response-body.type';
|
||||
import { type PerformMetadataQueryParams } from 'test/integration/metadata/types/perform-metadata-query.type';
|
||||
import { warnIfErrorButNotExpectedToFail } from 'test/integration/metadata/utils/warn-if-error-but-not-expected-to-fail.util';
|
||||
import { warnIfNoErrorButExpectedToFail } from 'test/integration/metadata/utils/warn-if-no-error-but-expected-to-fail.util';
|
||||
|
||||
import { type LogicFunctionDTO } from 'src/engine/metadata-modules/logic-function/dtos/logic-function.dto';
|
||||
|
||||
export const createOneLogicFunction = async ({
|
||||
input,
|
||||
gqlFields,
|
||||
expectToFail = false,
|
||||
token,
|
||||
}: PerformMetadataQueryParams<CreateOneLogicFunctionFactoryInput>): CommonResponseBody<{
|
||||
createOneLogicFunction: LogicFunctionDTO;
|
||||
}> => {
|
||||
const graphqlOperation = createOneLogicFunctionQueryFactory({
|
||||
input,
|
||||
gqlFields,
|
||||
});
|
||||
|
||||
const response = await makeMetadataAPIRequest(graphqlOperation, token);
|
||||
|
||||
if (expectToFail === true) {
|
||||
warnIfNoErrorButExpectedToFail({
|
||||
response,
|
||||
errorMessage: 'Logic Function creation should have failed but did not',
|
||||
});
|
||||
}
|
||||
|
||||
if (expectToFail === false) {
|
||||
warnIfErrorButNotExpectedToFail({
|
||||
response,
|
||||
errorMessage: 'Logic Function creation has failed but should not',
|
||||
});
|
||||
}
|
||||
|
||||
return { data: response.body.data, errors: response.body.errors };
|
||||
};
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
import gql from 'graphql-tag';
|
||||
|
||||
export type DeleteLogicFunctionFactoryInput = {
|
||||
id: string;
|
||||
};
|
||||
|
||||
export const deleteLogicFunctionQueryFactory = ({
|
||||
input,
|
||||
}: {
|
||||
input: DeleteLogicFunctionFactoryInput;
|
||||
}) => ({
|
||||
query: gql`
|
||||
mutation DeleteOneLogicFunction($input: LogicFunctionIdInput!) {
|
||||
deleteOneLogicFunction(input: $input) {
|
||||
id
|
||||
}
|
||||
}
|
||||
`,
|
||||
variables: {
|
||||
input,
|
||||
},
|
||||
});
|
||||
+42
@@ -0,0 +1,42 @@
|
||||
import {
|
||||
type DeleteLogicFunctionFactoryInput,
|
||||
deleteLogicFunctionQueryFactory,
|
||||
} from 'test/integration/metadata/suites/logic-function/utils/delete-logic-function-query-factory.util';
|
||||
import { makeMetadataAPIRequest } from 'test/integration/metadata/suites/utils/make-metadata-api-request.util';
|
||||
import { type CommonResponseBody } from 'test/integration/metadata/types/common-response-body.type';
|
||||
import { warnIfErrorButNotExpectedToFail } from 'test/integration/metadata/utils/warn-if-error-but-not-expected-to-fail.util';
|
||||
import { warnIfNoErrorButExpectedToFail } from 'test/integration/metadata/utils/warn-if-no-error-but-expected-to-fail.util';
|
||||
|
||||
export const deleteLogicFunction = async ({
|
||||
input,
|
||||
expectToFail = false,
|
||||
token,
|
||||
}: {
|
||||
input: DeleteLogicFunctionFactoryInput;
|
||||
expectToFail?: boolean;
|
||||
token?: string;
|
||||
}): CommonResponseBody<{
|
||||
deleteOneLogicFunction: { id: string };
|
||||
}> => {
|
||||
const graphqlOperation = deleteLogicFunctionQueryFactory({
|
||||
input,
|
||||
});
|
||||
|
||||
const response = await makeMetadataAPIRequest(graphqlOperation, token);
|
||||
|
||||
if (expectToFail === true) {
|
||||
warnIfNoErrorButExpectedToFail({
|
||||
response,
|
||||
errorMessage: 'Logic Function deletion should have failed but did not',
|
||||
});
|
||||
}
|
||||
|
||||
if (expectToFail === false) {
|
||||
warnIfErrorButNotExpectedToFail({
|
||||
response,
|
||||
errorMessage: 'Logic Function deletion has failed but should not',
|
||||
});
|
||||
}
|
||||
|
||||
return { data: response.body.data, errors: response.body.errors };
|
||||
};
|
||||
+37
@@ -0,0 +1,37 @@
|
||||
import gql from 'graphql-tag';
|
||||
|
||||
export type ExecuteLogicFunctionFactoryInput = {
|
||||
id: string;
|
||||
payload: Record<string, unknown>;
|
||||
version?: string;
|
||||
};
|
||||
|
||||
const DEFAULT_EXECUTION_RESULT_GQL_FIELDS = `
|
||||
data
|
||||
logs
|
||||
duration
|
||||
status
|
||||
error
|
||||
`;
|
||||
|
||||
export const executeLogicFunctionQueryFactory = ({
|
||||
input,
|
||||
gqlFields = DEFAULT_EXECUTION_RESULT_GQL_FIELDS,
|
||||
}: {
|
||||
input: ExecuteLogicFunctionFactoryInput;
|
||||
gqlFields?: string;
|
||||
}) => ({
|
||||
query: gql`
|
||||
mutation ExecuteOneLogicFunction($input: ExecuteLogicFunctionInput!) {
|
||||
executeOneLogicFunction(input: $input) {
|
||||
${gqlFields}
|
||||
}
|
||||
}
|
||||
`,
|
||||
variables: {
|
||||
input: {
|
||||
...input,
|
||||
version: input.version ?? 'latest',
|
||||
},
|
||||
},
|
||||
});
|
||||
+47
@@ -0,0 +1,47 @@
|
||||
import {
|
||||
type ExecuteLogicFunctionFactoryInput,
|
||||
executeLogicFunctionQueryFactory,
|
||||
} from 'test/integration/metadata/suites/logic-function/utils/execute-logic-function-query-factory.util';
|
||||
import { makeMetadataAPIRequest } from 'test/integration/metadata/suites/utils/make-metadata-api-request.util';
|
||||
import { type CommonResponseBody } from 'test/integration/metadata/types/common-response-body.type';
|
||||
import { warnIfErrorButNotExpectedToFail } from 'test/integration/metadata/utils/warn-if-error-but-not-expected-to-fail.util';
|
||||
import { warnIfNoErrorButExpectedToFail } from 'test/integration/metadata/utils/warn-if-no-error-but-expected-to-fail.util';
|
||||
|
||||
import { type LogicFunctionExecutionResultDTO } from 'src/engine/metadata-modules/logic-function/dtos/logic-function-execution-result.dto';
|
||||
|
||||
export const executeLogicFunction = async ({
|
||||
input,
|
||||
gqlFields,
|
||||
expectToFail = false,
|
||||
token,
|
||||
}: {
|
||||
input: ExecuteLogicFunctionFactoryInput;
|
||||
gqlFields?: string;
|
||||
expectToFail?: boolean;
|
||||
token?: string;
|
||||
}): CommonResponseBody<{
|
||||
executeOneLogicFunction: LogicFunctionExecutionResultDTO;
|
||||
}> => {
|
||||
const graphqlOperation = executeLogicFunctionQueryFactory({
|
||||
input,
|
||||
gqlFields,
|
||||
});
|
||||
|
||||
const response = await makeMetadataAPIRequest(graphqlOperation, token);
|
||||
|
||||
if (expectToFail === true) {
|
||||
warnIfNoErrorButExpectedToFail({
|
||||
response,
|
||||
errorMessage: 'Logic Function execution should have failed but did not',
|
||||
});
|
||||
}
|
||||
|
||||
if (expectToFail === false) {
|
||||
warnIfErrorButNotExpectedToFail({
|
||||
response,
|
||||
errorMessage: 'Logic Function execution has failed but should not',
|
||||
});
|
||||
}
|
||||
|
||||
return { data: response.body.data, errors: response.body.errors };
|
||||
};
|
||||
+31
@@ -0,0 +1,31 @@
|
||||
import gql from 'graphql-tag';
|
||||
|
||||
export type PublishLogicFunctionFactoryInput = {
|
||||
id: string;
|
||||
};
|
||||
|
||||
const DEFAULT_LOGIC_FUNCTION_GQL_FIELDS = `
|
||||
id
|
||||
name
|
||||
latestVersion
|
||||
publishedVersions
|
||||
`;
|
||||
|
||||
export const publishLogicFunctionQueryFactory = ({
|
||||
input,
|
||||
gqlFields = DEFAULT_LOGIC_FUNCTION_GQL_FIELDS,
|
||||
}: {
|
||||
input: PublishLogicFunctionFactoryInput;
|
||||
gqlFields?: string;
|
||||
}) => ({
|
||||
query: gql`
|
||||
mutation PublishLogicFunction($input: PublishLogicFunctionInput!) {
|
||||
publishLogicFunction(input: $input) {
|
||||
${gqlFields}
|
||||
}
|
||||
}
|
||||
`,
|
||||
variables: {
|
||||
input,
|
||||
},
|
||||
});
|
||||
+47
@@ -0,0 +1,47 @@
|
||||
import {
|
||||
type PublishLogicFunctionFactoryInput,
|
||||
publishLogicFunctionQueryFactory,
|
||||
} from 'test/integration/metadata/suites/logic-function/utils/publish-logic-function-query-factory.util';
|
||||
import { makeMetadataAPIRequest } from 'test/integration/metadata/suites/utils/make-metadata-api-request.util';
|
||||
import { type CommonResponseBody } from 'test/integration/metadata/types/common-response-body.type';
|
||||
import { warnIfErrorButNotExpectedToFail } from 'test/integration/metadata/utils/warn-if-error-but-not-expected-to-fail.util';
|
||||
import { warnIfNoErrorButExpectedToFail } from 'test/integration/metadata/utils/warn-if-no-error-but-expected-to-fail.util';
|
||||
|
||||
import { type LogicFunctionDTO } from 'src/engine/metadata-modules/logic-function/dtos/logic-function.dto';
|
||||
|
||||
export const publishLogicFunction = async ({
|
||||
input,
|
||||
gqlFields,
|
||||
expectToFail = false,
|
||||
token,
|
||||
}: {
|
||||
input: PublishLogicFunctionFactoryInput;
|
||||
gqlFields?: string;
|
||||
expectToFail?: boolean;
|
||||
token?: string;
|
||||
}): CommonResponseBody<{
|
||||
publishLogicFunction: LogicFunctionDTO;
|
||||
}> => {
|
||||
const graphqlOperation = publishLogicFunctionQueryFactory({
|
||||
input,
|
||||
gqlFields,
|
||||
});
|
||||
|
||||
const response = await makeMetadataAPIRequest(graphqlOperation, token);
|
||||
|
||||
if (expectToFail === true) {
|
||||
warnIfNoErrorButExpectedToFail({
|
||||
response,
|
||||
errorMessage: 'Logic Function publish should have failed but did not',
|
||||
});
|
||||
}
|
||||
|
||||
if (expectToFail === false) {
|
||||
warnIfErrorButNotExpectedToFail({
|
||||
response,
|
||||
errorMessage: 'Logic Function publish has failed but should not',
|
||||
});
|
||||
}
|
||||
|
||||
return { data: response.body.data, errors: response.body.errors };
|
||||
};
|
||||
+37
@@ -0,0 +1,37 @@
|
||||
import gql from 'graphql-tag';
|
||||
import { type Sources } from 'twenty-shared/types';
|
||||
|
||||
export type UpdateLogicFunctionFactoryInput = {
|
||||
id: string;
|
||||
update: {
|
||||
name: string;
|
||||
description?: string;
|
||||
code: Sources;
|
||||
};
|
||||
};
|
||||
|
||||
const DEFAULT_LOGIC_FUNCTION_GQL_FIELDS = `
|
||||
id
|
||||
name
|
||||
description
|
||||
latestVersion
|
||||
`;
|
||||
|
||||
export const updateLogicFunctionQueryFactory = ({
|
||||
input,
|
||||
gqlFields = DEFAULT_LOGIC_FUNCTION_GQL_FIELDS,
|
||||
}: {
|
||||
input: UpdateLogicFunctionFactoryInput;
|
||||
gqlFields?: string;
|
||||
}) => ({
|
||||
query: gql`
|
||||
mutation UpdateOneLogicFunction($input: UpdateLogicFunctionInput!) {
|
||||
updateOneLogicFunction(input: $input) {
|
||||
${gqlFields}
|
||||
}
|
||||
}
|
||||
`,
|
||||
variables: {
|
||||
input,
|
||||
},
|
||||
});
|
||||
+47
@@ -0,0 +1,47 @@
|
||||
import {
|
||||
type UpdateLogicFunctionFactoryInput,
|
||||
updateLogicFunctionQueryFactory,
|
||||
} from 'test/integration/metadata/suites/logic-function/utils/update-logic-function-query-factory.util';
|
||||
import { makeMetadataAPIRequest } from 'test/integration/metadata/suites/utils/make-metadata-api-request.util';
|
||||
import { type CommonResponseBody } from 'test/integration/metadata/types/common-response-body.type';
|
||||
import { warnIfErrorButNotExpectedToFail } from 'test/integration/metadata/utils/warn-if-error-but-not-expected-to-fail.util';
|
||||
import { warnIfNoErrorButExpectedToFail } from 'test/integration/metadata/utils/warn-if-no-error-but-expected-to-fail.util';
|
||||
|
||||
import { type LogicFunctionDTO } from 'src/engine/metadata-modules/logic-function/dtos/logic-function.dto';
|
||||
|
||||
export const updateLogicFunction = async ({
|
||||
input,
|
||||
gqlFields,
|
||||
expectToFail = false,
|
||||
token,
|
||||
}: {
|
||||
input: UpdateLogicFunctionFactoryInput;
|
||||
gqlFields?: string;
|
||||
expectToFail?: boolean;
|
||||
token?: string;
|
||||
}): CommonResponseBody<{
|
||||
updateOneLogicFunction: LogicFunctionDTO;
|
||||
}> => {
|
||||
const graphqlOperation = updateLogicFunctionQueryFactory({
|
||||
input,
|
||||
gqlFields,
|
||||
});
|
||||
|
||||
const response = await makeMetadataAPIRequest(graphqlOperation, token);
|
||||
|
||||
if (expectToFail === true) {
|
||||
warnIfNoErrorButExpectedToFail({
|
||||
response,
|
||||
errorMessage: 'Logic Function update should have failed but did not',
|
||||
});
|
||||
}
|
||||
|
||||
if (expectToFail === false) {
|
||||
warnIfErrorButNotExpectedToFail({
|
||||
response,
|
||||
errorMessage: 'Logic Function update has failed but should not',
|
||||
});
|
||||
}
|
||||
|
||||
return { data: response.body.data, errors: response.body.errors };
|
||||
};
|
||||
Reference in New Issue
Block a user