Allow bulk records for manual trigger (#14725)
https://github.com/user-attachments/assets/d6c565eb-9a29-4830-9396-5f979c8caa7b - Added a new component for manual trigger (mostly duplicated from previous one). Will remove the old one once all data are migrated - Updated schema output so the current item of the iterator can be typed Todo left: - migrate old triggers - add an util to search iterator output. Today current item fields will be displayed as not found - set new manual triggers for workflow runs
This commit is contained in:
@@ -0,0 +1 @@
|
||||
export const CAPTURE_ALL_VARIABLE_TAG_INNER_REGEX = /{{([^{}]+)}}/g;
|
||||
@@ -7,6 +7,7 @@
|
||||
* |___/
|
||||
*/
|
||||
|
||||
export { CAPTURE_ALL_VARIABLE_TAG_INNER_REGEX } from './constants/CaptureAllVariableTagInnerRegex';
|
||||
export { CONTENT_TYPE_VALUES_HTTP_REQUEST } from './constants/contentTypeValuesHttpRequest';
|
||||
export { TRIGGER_STEP_ID } from './constants/TriggerStepId';
|
||||
export { workflowAiAgentActionSchema } from './schemas/ai-agent-action-schema';
|
||||
@@ -56,5 +57,11 @@ export type {
|
||||
} from './types/WorkflowRunStateStepInfos';
|
||||
export { StepStatus } from './types/WorkflowRunStateStepInfos';
|
||||
export { canObjectBeManagedByWorkflow } from './utils/canObjectBeManagedByWorkflow';
|
||||
export { extractRawVariableNamePart } from './utils/extractRawVariableNameParts';
|
||||
export { getWorkflowRunContext } from './utils/getWorkflowRunContext';
|
||||
export { parseDataFromContentType } from './utils/parseDataFromContentType';
|
||||
export type {
|
||||
GlobalAvailability,
|
||||
SingleRecordAvailability,
|
||||
BulkRecordsAvailability,
|
||||
} from './workflow-trigger/types/workflow-trigger.type';
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { z } from 'zod';
|
||||
import { baseTriggerSchema } from './base-trigger-schema';
|
||||
|
||||
export const workflowManualTriggerSchema = baseTriggerSchema
|
||||
export const workflowManualTriggerSchema = baseTriggerSchema
|
||||
.extend({
|
||||
type: z.literal('MANUAL'),
|
||||
settings: z.object({
|
||||
@@ -13,8 +13,25 @@ export const workflowManualTriggerSchema = baseTriggerSchema
|
||||
),
|
||||
icon: z.string().optional(),
|
||||
isPinned: z.boolean().optional(),
|
||||
availability: z
|
||||
.discriminatedUnion('type', [
|
||||
z.object({
|
||||
type: z.literal('GLOBAL'),
|
||||
locations: z.array(z.string()).optional(),
|
||||
}),
|
||||
z.object({
|
||||
type: z.literal('SINGLE_RECORD'),
|
||||
objectNameSingular: z.string(),
|
||||
}),
|
||||
z.object({
|
||||
type: z.literal('BULK_RECORDS'),
|
||||
objectNameSingular: z.string(),
|
||||
}),
|
||||
])
|
||||
.optional()
|
||||
.nullable(),
|
||||
}),
|
||||
})
|
||||
.describe(
|
||||
'Manual trigger that can be launched by the user. If a record is selected when launched, it is accessible via {{trigger.record.fieldName}}. If no record is selected, no data context is available.',
|
||||
);
|
||||
);
|
||||
@@ -0,0 +1,32 @@
|
||||
import { isDefined } from '@/utils';
|
||||
import { CAPTURE_ALL_VARIABLE_TAG_INNER_REGEX } from '../constants/CaptureAllVariableTagInnerRegex';
|
||||
|
||||
export const extractRawVariableNamePart = ({
|
||||
rawVariableName,
|
||||
part,
|
||||
}: {
|
||||
rawVariableName: string;
|
||||
part: 'stepId' | 'selectedField';
|
||||
}) => {
|
||||
const variableWithoutBrackets = rawVariableName.replace(
|
||||
CAPTURE_ALL_VARIABLE_TAG_INNER_REGEX,
|
||||
(_, variableName) => {
|
||||
return variableName;
|
||||
},
|
||||
);
|
||||
|
||||
const parts = variableWithoutBrackets.split('.');
|
||||
|
||||
const extractedPart =
|
||||
part === 'stepId'
|
||||
? parts[0]
|
||||
: part === 'selectedField'
|
||||
? parts[parts.length - 1]
|
||||
: null;
|
||||
|
||||
if (!isDefined(extractedPart)) {
|
||||
throw new Error('Expected to find at least one splitted chunk.');
|
||||
}
|
||||
|
||||
return extractedPart;
|
||||
};
|
||||
@@ -0,0 +1,14 @@
|
||||
export type GlobalAvailability = {
|
||||
type: 'GLOBAL';
|
||||
locations?: string[];
|
||||
};
|
||||
|
||||
export type SingleRecordAvailability = {
|
||||
type: 'SINGLE_RECORD';
|
||||
objectNameSingular: string;
|
||||
};
|
||||
|
||||
export type BulkRecordsAvailability = {
|
||||
type: 'BULK_RECORDS';
|
||||
objectNameSingular: string;
|
||||
};
|
||||
Reference in New Issue
Block a user