Add crud actions (#8500)
Adding update / delete / find actions
Update and delete are not really different than creation.
Find uses the same logique as for graphql filters.
Expected formats are:
Filter
```
{
"and": [
{
"name": {
"eq": "salut"
}
},
{
"employees": {
"eq": "0"
}
}
]
}
```
Order
`[ { "name": 'AscNullsFirst' } ]`
This commit is contained in:
@ -10,10 +10,12 @@ import { checkStringIsDatabaseEventAction } from 'src/engine/api/graphql/graphql
|
||||
import { INDEX_FILE_NAME } from 'src/engine/core-modules/serverless/drivers/constants/index-file-name';
|
||||
import { ObjectMetadataEntity } from 'src/engine/metadata-modules/object-metadata/object-metadata.entity';
|
||||
import { ServerlessFunctionService } from 'src/engine/metadata-modules/serverless-function/serverless-function.service';
|
||||
import { generateFakeValue } from 'src/engine/utils/generate-fake-value';
|
||||
import { CodeIntrospectionService } from 'src/modules/code-introspection/code-introspection.service';
|
||||
import { generateFakeObjectRecord } from 'src/modules/workflow/workflow-builder/utils/generate-fake-object-record';
|
||||
import { generateFakeObjectRecordEvent } from 'src/modules/workflow/workflow-builder/utils/generate-fake-object-record-event';
|
||||
import { WorkflowSendEmailStepOutputSchema } from 'src/modules/workflow/workflow-executor/workflow-actions/mail-sender/send-email.workflow-action';
|
||||
import { WorkflowRecordCRUDType } from 'src/modules/workflow/workflow-executor/workflow-actions/record-crud/types/workflow-record-crud-action-input.type';
|
||||
import {
|
||||
WorkflowAction,
|
||||
WorkflowActionType,
|
||||
@ -44,7 +46,7 @@ export class WorkflowBuilderWorkspaceService {
|
||||
|
||||
switch (stepType) {
|
||||
case WorkflowTriggerType.DATABASE_EVENT: {
|
||||
return await this.computeDatabaseEventTriggerOutputSchema({
|
||||
return this.computeDatabaseEventTriggerOutputSchema({
|
||||
eventName: step.settings.eventName,
|
||||
workspaceId,
|
||||
objectMetadataRepository: this.objectMetadataRepository,
|
||||
@ -57,7 +59,7 @@ export class WorkflowBuilderWorkspaceService {
|
||||
return {};
|
||||
}
|
||||
|
||||
return await this.computeRecordOutputSchema({
|
||||
return this.computeRecordOutputSchema({
|
||||
objectType,
|
||||
workspaceId,
|
||||
objectMetadataRepository: this.objectMetadataRepository,
|
||||
@ -70,7 +72,7 @@ export class WorkflowBuilderWorkspaceService {
|
||||
const { serverlessFunctionId, serverlessFunctionVersion } =
|
||||
step.settings.input;
|
||||
|
||||
return await this.computeCodeActionOutputSchema({
|
||||
return this.computeCodeActionOutputSchema({
|
||||
serverlessFunctionId,
|
||||
serverlessFunctionVersion,
|
||||
workspaceId,
|
||||
@ -79,8 +81,9 @@ export class WorkflowBuilderWorkspaceService {
|
||||
});
|
||||
}
|
||||
case WorkflowActionType.RECORD_CRUD:
|
||||
return await this.computeRecordOutputSchema({
|
||||
return this.computeRecordCrudOutputSchema({
|
||||
objectType: step.settings.input.objectName,
|
||||
operationType: step.settings.input.type,
|
||||
workspaceId,
|
||||
objectMetadataRepository: this.objectMetadataRepository,
|
||||
});
|
||||
@ -122,6 +125,34 @@ export class WorkflowBuilderWorkspaceService {
|
||||
);
|
||||
}
|
||||
|
||||
private async computeRecordCrudOutputSchema<Entity>({
|
||||
objectType,
|
||||
operationType,
|
||||
workspaceId,
|
||||
objectMetadataRepository,
|
||||
}: {
|
||||
objectType: string;
|
||||
operationType: string;
|
||||
workspaceId: string;
|
||||
objectMetadataRepository: Repository<ObjectMetadataEntity>;
|
||||
}) {
|
||||
const recordOutputSchema = await this.computeRecordOutputSchema<Entity>({
|
||||
objectType,
|
||||
workspaceId,
|
||||
objectMetadataRepository,
|
||||
});
|
||||
|
||||
if (operationType === WorkflowRecordCRUDType.READ) {
|
||||
return {
|
||||
first: recordOutputSchema,
|
||||
last: recordOutputSchema,
|
||||
totalCount: generateFakeValue('number'),
|
||||
};
|
||||
}
|
||||
|
||||
return recordOutputSchema;
|
||||
}
|
||||
|
||||
private async computeRecordOutputSchema<Entity>({
|
||||
objectType,
|
||||
workspaceId,
|
||||
|
||||
Reference in New Issue
Block a user