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:
+61
@@ -0,0 +1,61 @@
|
||||
import { type MessageDescriptor } from '@lingui/core';
|
||||
import { msg } from '@lingui/core/macro';
|
||||
import { assertUnreachable } from 'twenty-shared/utils';
|
||||
|
||||
import { CustomException } from 'src/utils/custom-exception';
|
||||
|
||||
export enum LogicFunctionExceptionCode {
|
||||
LOGIC_FUNCTION_NOT_FOUND = 'LOGIC_FUNCTION_NOT_FOUND',
|
||||
LOGIC_FUNCTION_VERSION_NOT_FOUND = 'LOGIC_FUNCTION_VERSION_NOT_FOUND',
|
||||
LOGIC_FUNCTION_ALREADY_EXIST = 'LOGIC_FUNCTION_ALREADY_EXIST',
|
||||
LOGIC_FUNCTION_NOT_READY = 'LOGIC_FUNCTION_NOT_READY',
|
||||
LOGIC_FUNCTION_BUILDING = 'LOGIC_FUNCTION_BUILDING',
|
||||
LOGIC_FUNCTION_CODE_UNCHANGED = 'LOGIC_FUNCTION_CODE_UNCHANGED',
|
||||
LOGIC_FUNCTION_EXECUTION_LIMIT_REACHED = 'LOGIC_FUNCTION_EXECUTION_LIMIT_REACHED',
|
||||
LOGIC_FUNCTION_CREATE_FAILED = 'LOGIC_FUNCTION_CREATE_FAILED',
|
||||
LOGIC_FUNCTION_EXECUTION_TIMEOUT = 'LOGIC_FUNCTION_EXECUTION_TIMEOUT',
|
||||
LOGIC_FUNCTION_DISABLED = 'LOGIC_FUNCTION_DISABLED',
|
||||
}
|
||||
|
||||
const getLogicFunctionExceptionUserFriendlyMessage = (
|
||||
code: LogicFunctionExceptionCode,
|
||||
) => {
|
||||
switch (code) {
|
||||
case LogicFunctionExceptionCode.LOGIC_FUNCTION_NOT_FOUND:
|
||||
return msg`Function not found.`;
|
||||
case LogicFunctionExceptionCode.LOGIC_FUNCTION_VERSION_NOT_FOUND:
|
||||
return msg`Function version not found.`;
|
||||
case LogicFunctionExceptionCode.LOGIC_FUNCTION_ALREADY_EXIST:
|
||||
return msg`A function with this name already exists.`;
|
||||
case LogicFunctionExceptionCode.LOGIC_FUNCTION_NOT_READY:
|
||||
return msg`Function is not ready.`;
|
||||
case LogicFunctionExceptionCode.LOGIC_FUNCTION_BUILDING:
|
||||
return msg`Function is currently building.`;
|
||||
case LogicFunctionExceptionCode.LOGIC_FUNCTION_CODE_UNCHANGED:
|
||||
return msg`Function code is unchanged.`;
|
||||
case LogicFunctionExceptionCode.LOGIC_FUNCTION_EXECUTION_LIMIT_REACHED:
|
||||
return msg`Function execution limit reached.`;
|
||||
case LogicFunctionExceptionCode.LOGIC_FUNCTION_CREATE_FAILED:
|
||||
return msg`Failed to create function.`;
|
||||
case LogicFunctionExceptionCode.LOGIC_FUNCTION_EXECUTION_TIMEOUT:
|
||||
return msg`Function execution timed out.`;
|
||||
case LogicFunctionExceptionCode.LOGIC_FUNCTION_DISABLED:
|
||||
return msg`Logic function execution is disabled.`;
|
||||
default:
|
||||
assertUnreachable(code);
|
||||
}
|
||||
};
|
||||
|
||||
export class LogicFunctionException extends CustomException<LogicFunctionExceptionCode> {
|
||||
constructor(
|
||||
message: string,
|
||||
code: LogicFunctionExceptionCode,
|
||||
{ userFriendlyMessage }: { userFriendlyMessage?: MessageDescriptor } = {},
|
||||
) {
|
||||
super(message, code, {
|
||||
userFriendlyMessage:
|
||||
userFriendlyMessage ??
|
||||
getLogicFunctionExceptionUserFriendlyMessage(code),
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user