Add triggers to cli sync (#14828)
This commit is contained in:
+13
-8
@@ -1,8 +1,8 @@
|
||||
import { Scope } from '@nestjs/common';
|
||||
import { Logger, Scope } from '@nestjs/common';
|
||||
|
||||
import { Process } from 'src/engine/core-modules/message-queue/decorators/process.decorator';
|
||||
import { Processor } from 'src/engine/core-modules/message-queue/decorators/processor.decorator';
|
||||
import { MessageQueue } from 'src/engine/core-modules/message-queue/message-queue.constants';
|
||||
import { Process } from 'src/engine/core-modules/message-queue/decorators/process.decorator';
|
||||
import { ServerlessFunctionService } from 'src/engine/metadata-modules/serverless-function/serverless-function.service';
|
||||
|
||||
export type ServerlessFunctionTriggerJobData = {
|
||||
@@ -16,17 +16,22 @@ export type ServerlessFunctionTriggerJobData = {
|
||||
scope: Scope.REQUEST,
|
||||
})
|
||||
export class ServerlessFunctionTriggerJob {
|
||||
private readonly logger = new Logger(ServerlessFunctionTriggerJob.name);
|
||||
|
||||
constructor(
|
||||
private readonly serverlessFunctionService: ServerlessFunctionService,
|
||||
) {}
|
||||
|
||||
@Process(ServerlessFunctionTriggerJob.name)
|
||||
async handle(data: ServerlessFunctionTriggerJobData) {
|
||||
await this.serverlessFunctionService.executeOneServerlessFunction(
|
||||
data.serverlessFunctionId,
|
||||
data.workspaceId,
|
||||
data.payload || {},
|
||||
'draft',
|
||||
);
|
||||
const result =
|
||||
await this.serverlessFunctionService.executeOneServerlessFunction(
|
||||
data.serverlessFunctionId,
|
||||
data.workspaceId,
|
||||
data.payload || {},
|
||||
'draft',
|
||||
);
|
||||
|
||||
this.logger.log(result.logs);
|
||||
}
|
||||
}
|
||||
|
||||
+13
-10
@@ -13,8 +13,8 @@ import {
|
||||
ServerlessFunctionExceptionCode,
|
||||
} from 'src/engine/metadata-modules/serverless-function/serverless-function.exception';
|
||||
import { type FlatServerlessFunction } from 'src/engine/metadata-modules/serverless-function/types/flat-serverless-function.type';
|
||||
import { mergeUpdateInExistingRecord } from 'src/utils/merge-update-in-existing-record.util';
|
||||
import { serverlessFunctionCreateHash } from 'src/engine/metadata-modules/serverless-function/utils/serverless-function-create-hash.utils';
|
||||
import { mergeUpdateInExistingRecord } from 'src/utils/merge-update-in-existing-record.util';
|
||||
|
||||
export const fromUpdateServerlessFunctionInputToFlatServerlessFunctionToUpdateOrThrow =
|
||||
({
|
||||
@@ -39,15 +39,18 @@ export const fromUpdateServerlessFunctionInputToFlatServerlessFunctionToUpdateOr
|
||||
ServerlessFunctionExceptionCode.SERVERLESS_FUNCTION_NOT_FOUND,
|
||||
);
|
||||
}
|
||||
const updatedEditableFieldProperties = extractAndSanitizeObjectStringFields(
|
||||
{
|
||||
...rawUpdateServerlessFunctionInput,
|
||||
checksum: serverlessFunctionCreateHash(
|
||||
JSON.stringify(rawUpdateServerlessFunctionInput.code),
|
||||
),
|
||||
},
|
||||
FLAT_SERVERLESS_FUNCTION_EDITABLE_PROPERTIES,
|
||||
);
|
||||
const updatedEditableFieldProperties = {
|
||||
...extractAndSanitizeObjectStringFields(
|
||||
{
|
||||
...rawUpdateServerlessFunctionInput,
|
||||
checksum: serverlessFunctionCreateHash(
|
||||
JSON.stringify(rawUpdateServerlessFunctionInput.code),
|
||||
),
|
||||
},
|
||||
FLAT_SERVERLESS_FUNCTION_EDITABLE_PROPERTIES,
|
||||
),
|
||||
code: rawUpdateServerlessFunctionInput.code,
|
||||
};
|
||||
|
||||
return mergeUpdateInExistingRecord({
|
||||
existing: existingFlatServerlessFunctionToUpdate,
|
||||
|
||||
Reference in New Issue
Block a user