@xtr-dev/payload-automation 0.0.35 → 0.0.37
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +61 -0
- package/dist/collections/Workflow.js +30 -305
- package/dist/collections/Workflow.js.map +1 -1
- package/dist/components/ErrorDisplay.js +3 -3
- package/dist/components/ErrorDisplay.js.map +1 -1
- package/dist/core/workflow-executor.d.ts +33 -85
- package/dist/core/workflow-executor.js +136 -229
- package/dist/core/workflow-executor.js.map +1 -1
- package/dist/exports/client.d.ts +0 -2
- package/dist/exports/client.js +1 -3
- package/dist/exports/client.js.map +1 -1
- package/dist/fields/parameter.d.ts +4 -0
- package/dist/fields/parameter.js +32 -0
- package/dist/fields/parameter.js.map +1 -0
- package/dist/plugin/collection-hook.d.ts +1 -0
- package/dist/plugin/collection-hook.js +58 -0
- package/dist/plugin/collection-hook.js.map +1 -0
- package/dist/plugin/config-types.d.ts +14 -17
- package/dist/plugin/config-types.js.map +1 -1
- package/dist/plugin/global-hook.d.ts +1 -0
- package/dist/plugin/global-hook.js +83 -0
- package/dist/plugin/global-hook.js.map +1 -0
- package/dist/plugin/index.js +83 -206
- package/dist/plugin/index.js.map +1 -1
- package/dist/plugin/logger.js +23 -7
- package/dist/plugin/logger.js.map +1 -1
- package/dist/test/workflow-executor.test.js +2 -2
- package/dist/test/workflow-executor.test.js.map +1 -1
- package/dist/triggers/collection-trigger.d.ts +2 -0
- package/dist/triggers/collection-trigger.js +36 -0
- package/dist/triggers/collection-trigger.js.map +1 -0
- package/dist/triggers/global-trigger.d.ts +2 -0
- package/dist/triggers/global-trigger.js +29 -0
- package/dist/triggers/global-trigger.js.map +1 -0
- package/dist/triggers/index.d.ts +2 -0
- package/dist/triggers/index.js +4 -0
- package/dist/triggers/index.js.map +1 -0
- package/dist/triggers/types.d.ts +5 -0
- package/dist/triggers/types.js +3 -0
- package/dist/triggers/types.js.map +1 -0
- package/package.json +1 -1
- package/dist/components/TriggerWorkflowButton.d.ts +0 -7
- package/dist/components/TriggerWorkflowButton.js +0 -46
- package/dist/components/TriggerWorkflowButton.js.map +0 -1
- package/dist/components/WorkflowExecutionStatus.d.ts +0 -6
- package/dist/components/WorkflowExecutionStatus.js +0 -287
- package/dist/components/WorkflowExecutionStatus.js.map +0 -1
- package/dist/exports/helpers.d.ts +0 -25
- package/dist/exports/helpers.js +0 -28
- package/dist/exports/helpers.js.map +0 -1
- package/dist/plugin/cron-scheduler.d.ts +0 -32
- package/dist/plugin/cron-scheduler.js +0 -537
- package/dist/plugin/cron-scheduler.js.map +0 -1
- package/dist/plugin/init-collection-hooks.d.ts +0 -4
- package/dist/plugin/init-collection-hooks.js +0 -100
- package/dist/plugin/init-collection-hooks.js.map +0 -1
- package/dist/plugin/init-global-hooks.d.ts +0 -3
- package/dist/plugin/init-global-hooks.js +0 -83
- package/dist/plugin/init-global-hooks.js.map +0 -1
- package/dist/plugin/init-step-tasks.d.ts +0 -3
- package/dist/plugin/init-step-tasks.js +0 -22
- package/dist/plugin/init-step-tasks.js.map +0 -1
- package/dist/plugin/init-webhook.d.ts +0 -2
- package/dist/plugin/init-webhook.js +0 -163
- package/dist/plugin/init-webhook.js.map +0 -1
- package/dist/plugin/init-workflow-hooks.d.ts +0 -6
- package/dist/plugin/init-workflow-hooks.js +0 -46
- package/dist/plugin/init-workflow-hooks.js.map +0 -1
- package/dist/utils/trigger-helpers.d.ts +0 -60
- package/dist/utils/trigger-helpers.js +0 -130
- package/dist/utils/trigger-helpers.js.map +0 -1
- package/dist/utils/trigger-presets.d.ts +0 -24
- package/dist/utils/trigger-presets.js +0 -177
- package/dist/utils/trigger-presets.js.map +0 -1
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
import type { Field } from 'payload';
|
|
2
|
-
import type { CustomTriggerConfig } from '../plugin/config-types.js';
|
|
3
|
-
interface FieldWithName {
|
|
4
|
-
name: string;
|
|
5
|
-
[key: string]: unknown;
|
|
6
|
-
}
|
|
7
|
-
/**
|
|
8
|
-
* Creates a virtual field for a trigger parameter that stores its value in the parameters JSON field
|
|
9
|
-
*
|
|
10
|
-
* @param field - Standard PayloadCMS field configuration (must be a data field with a name)
|
|
11
|
-
* @param triggerSlug - The slug of the trigger this field belongs to
|
|
12
|
-
* @returns Modified field with virtual storage hooks and proper naming
|
|
13
|
-
*
|
|
14
|
-
* @example
|
|
15
|
-
* ```typescript
|
|
16
|
-
* const myTrigger: CustomTriggerConfig = {
|
|
17
|
-
* slug: 'my-trigger',
|
|
18
|
-
* inputs: [
|
|
19
|
-
* createTriggerField({
|
|
20
|
-
* name: 'webhookUrl',
|
|
21
|
-
* type: 'text',
|
|
22
|
-
* required: true,
|
|
23
|
-
* admin: {
|
|
24
|
-
* description: 'URL to call when triggered'
|
|
25
|
-
* }
|
|
26
|
-
* }, 'my-trigger')
|
|
27
|
-
* ]
|
|
28
|
-
* }
|
|
29
|
-
* ```
|
|
30
|
-
*/
|
|
31
|
-
export declare function createTriggerField(field: FieldWithName, triggerSlug: string): Field;
|
|
32
|
-
/**
|
|
33
|
-
* Creates a custom trigger configuration with the provided fields
|
|
34
|
-
*
|
|
35
|
-
* @param slug - Unique identifier for the trigger
|
|
36
|
-
* @param fields - Array of PayloadCMS fields that will be shown as trigger parameters
|
|
37
|
-
* @returns Complete trigger configuration
|
|
38
|
-
*
|
|
39
|
-
* @example
|
|
40
|
-
* ```typescript
|
|
41
|
-
* const webhookTrigger = createTrigger('webhook', [
|
|
42
|
-
* {
|
|
43
|
-
* name: 'url',
|
|
44
|
-
* type: 'text',
|
|
45
|
-
* required: true,
|
|
46
|
-
* admin: {
|
|
47
|
-
* description: 'Webhook URL'
|
|
48
|
-
* }
|
|
49
|
-
* },
|
|
50
|
-
* {
|
|
51
|
-
* name: 'method',
|
|
52
|
-
* type: 'select',
|
|
53
|
-
* options: ['GET', 'POST', 'PUT', 'DELETE'],
|
|
54
|
-
* defaultValue: 'POST'
|
|
55
|
-
* }
|
|
56
|
-
* ])
|
|
57
|
-
* ```
|
|
58
|
-
*/
|
|
59
|
-
export declare function createTrigger(slug: string, fields: FieldWithName[]): CustomTriggerConfig;
|
|
60
|
-
export {};
|
|
@@ -1,130 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Creates a virtual field for a trigger parameter that stores its value in the parameters JSON field
|
|
3
|
-
*
|
|
4
|
-
* @param field - Standard PayloadCMS field configuration (must be a data field with a name)
|
|
5
|
-
* @param triggerSlug - The slug of the trigger this field belongs to
|
|
6
|
-
* @returns Modified field with virtual storage hooks and proper naming
|
|
7
|
-
*
|
|
8
|
-
* @example
|
|
9
|
-
* ```typescript
|
|
10
|
-
* const myTrigger: CustomTriggerConfig = {
|
|
11
|
-
* slug: 'my-trigger',
|
|
12
|
-
* inputs: [
|
|
13
|
-
* createTriggerField({
|
|
14
|
-
* name: 'webhookUrl',
|
|
15
|
-
* type: 'text',
|
|
16
|
-
* required: true,
|
|
17
|
-
* admin: {
|
|
18
|
-
* description: 'URL to call when triggered'
|
|
19
|
-
* }
|
|
20
|
-
* }, 'my-trigger')
|
|
21
|
-
* ]
|
|
22
|
-
* }
|
|
23
|
-
* ```
|
|
24
|
-
*/ export function createTriggerField(field, triggerSlug) {
|
|
25
|
-
const originalName = field.name;
|
|
26
|
-
if (!originalName) {
|
|
27
|
-
throw new Error('Field must have a name property');
|
|
28
|
-
}
|
|
29
|
-
// Create a unique field name by prefixing with trigger slug
|
|
30
|
-
const uniqueFieldName = `__trigger_${triggerSlug}_${originalName}`;
|
|
31
|
-
const resultField = {
|
|
32
|
-
...field,
|
|
33
|
-
admin: {
|
|
34
|
-
...field.admin || {},
|
|
35
|
-
condition: (data, siblingData)=>{
|
|
36
|
-
// Only show this field when the trigger type matches
|
|
37
|
-
const triggerMatches = siblingData?.type === triggerSlug;
|
|
38
|
-
// If the original field had a condition, combine it with our trigger condition
|
|
39
|
-
const originalCondition = field.admin?.condition;
|
|
40
|
-
if (originalCondition && typeof originalCondition === 'function') {
|
|
41
|
-
return triggerMatches && originalCondition(data, siblingData);
|
|
42
|
-
}
|
|
43
|
-
return triggerMatches;
|
|
44
|
-
}
|
|
45
|
-
},
|
|
46
|
-
hooks: {
|
|
47
|
-
...field.hooks || {},
|
|
48
|
-
afterRead: [
|
|
49
|
-
...field.hooks?.afterRead || [],
|
|
50
|
-
({ siblingData })=>{
|
|
51
|
-
// Read the value from the parameters JSON field
|
|
52
|
-
const parameters = siblingData?.parameters;
|
|
53
|
-
return parameters?.[originalName] ?? field.defaultValue;
|
|
54
|
-
}
|
|
55
|
-
],
|
|
56
|
-
beforeChange: [
|
|
57
|
-
...field.hooks?.beforeChange || [],
|
|
58
|
-
({ siblingData, value })=>{
|
|
59
|
-
// Store the value in the parameters JSON field
|
|
60
|
-
if (!siblingData.parameters) {
|
|
61
|
-
siblingData.parameters = {};
|
|
62
|
-
}
|
|
63
|
-
const parameters = siblingData.parameters;
|
|
64
|
-
parameters[originalName] = value;
|
|
65
|
-
return undefined // Virtual field, don't store directly
|
|
66
|
-
;
|
|
67
|
-
}
|
|
68
|
-
]
|
|
69
|
-
},
|
|
70
|
-
name: uniqueFieldName,
|
|
71
|
-
virtual: true
|
|
72
|
-
};
|
|
73
|
-
// Only add validate if the field supports it (data fields)
|
|
74
|
-
const hasValidation = field.validate || field.required;
|
|
75
|
-
if (hasValidation) {
|
|
76
|
-
resultField.validate = (value, args)=>{
|
|
77
|
-
const parameters = args.siblingData?.parameters;
|
|
78
|
-
const paramValue = value ?? parameters?.[originalName];
|
|
79
|
-
// Check required validation
|
|
80
|
-
const isRequired = field.required;
|
|
81
|
-
if (isRequired && args.siblingData?.type === triggerSlug && !paramValue) {
|
|
82
|
-
const fieldLabel = field.label;
|
|
83
|
-
const adminDesc = field.admin?.description;
|
|
84
|
-
const label = fieldLabel || adminDesc || originalName;
|
|
85
|
-
return `${label} is required for ${triggerSlug}`;
|
|
86
|
-
}
|
|
87
|
-
// Run original validation if present
|
|
88
|
-
const originalValidate = field.validate;
|
|
89
|
-
if (originalValidate && typeof originalValidate === 'function') {
|
|
90
|
-
return originalValidate(paramValue, args);
|
|
91
|
-
}
|
|
92
|
-
return true;
|
|
93
|
-
};
|
|
94
|
-
}
|
|
95
|
-
return resultField;
|
|
96
|
-
}
|
|
97
|
-
/**
|
|
98
|
-
* Creates a custom trigger configuration with the provided fields
|
|
99
|
-
*
|
|
100
|
-
* @param slug - Unique identifier for the trigger
|
|
101
|
-
* @param fields - Array of PayloadCMS fields that will be shown as trigger parameters
|
|
102
|
-
* @returns Complete trigger configuration
|
|
103
|
-
*
|
|
104
|
-
* @example
|
|
105
|
-
* ```typescript
|
|
106
|
-
* const webhookTrigger = createTrigger('webhook', [
|
|
107
|
-
* {
|
|
108
|
-
* name: 'url',
|
|
109
|
-
* type: 'text',
|
|
110
|
-
* required: true,
|
|
111
|
-
* admin: {
|
|
112
|
-
* description: 'Webhook URL'
|
|
113
|
-
* }
|
|
114
|
-
* },
|
|
115
|
-
* {
|
|
116
|
-
* name: 'method',
|
|
117
|
-
* type: 'select',
|
|
118
|
-
* options: ['GET', 'POST', 'PUT', 'DELETE'],
|
|
119
|
-
* defaultValue: 'POST'
|
|
120
|
-
* }
|
|
121
|
-
* ])
|
|
122
|
-
* ```
|
|
123
|
-
*/ export function createTrigger(slug, fields) {
|
|
124
|
-
return {
|
|
125
|
-
slug,
|
|
126
|
-
inputs: fields.map((field)=>createTriggerField(field, slug))
|
|
127
|
-
};
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
//# sourceMappingURL=trigger-helpers.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/utils/trigger-helpers.ts"],"sourcesContent":["import type { Field } from 'payload'\n\nimport type { CustomTriggerConfig } from '../plugin/config-types.js'\n\n// Types for better type safety\ninterface FieldWithName {\n name: string\n [key: string]: unknown\n}\n\ninterface HookContext {\n siblingData: Record<string, unknown>\n value?: unknown\n}\n\ninterface ValidationContext {\n siblingData: Record<string, unknown>\n}\n\n/**\n * Creates a virtual field for a trigger parameter that stores its value in the parameters JSON field\n * \n * @param field - Standard PayloadCMS field configuration (must be a data field with a name)\n * @param triggerSlug - The slug of the trigger this field belongs to\n * @returns Modified field with virtual storage hooks and proper naming\n * \n * @example\n * ```typescript\n * const myTrigger: CustomTriggerConfig = {\n * slug: 'my-trigger',\n * inputs: [\n * createTriggerField({\n * name: 'webhookUrl',\n * type: 'text',\n * required: true,\n * admin: {\n * description: 'URL to call when triggered'\n * }\n * }, 'my-trigger')\n * ]\n * }\n * ```\n */\nexport function createTriggerField(field: FieldWithName, triggerSlug: string): Field {\n const originalName = field.name\n if (!originalName) {\n throw new Error('Field must have a name property')\n }\n\n // Create a unique field name by prefixing with trigger slug\n const uniqueFieldName = `__trigger_${triggerSlug}_${originalName}`\n \n const resultField: Record<string, unknown> = {\n ...field,\n admin: {\n ...(field.admin as Record<string, unknown> || {}),\n condition: (data: unknown, siblingData: Record<string, unknown>) => {\n // Only show this field when the trigger type matches\n const triggerMatches = siblingData?.type === triggerSlug\n \n // If the original field had a condition, combine it with our trigger condition\n const originalCondition = (field.admin as Record<string, unknown>)?.condition\n if (originalCondition && typeof originalCondition === 'function') {\n return triggerMatches && (originalCondition as (data: unknown, siblingData: Record<string, unknown>) => boolean)(data, siblingData)\n }\n \n return triggerMatches\n }\n },\n hooks: {\n ...(field.hooks as Record<string, unknown[]> || {}),\n afterRead: [\n ...((field.hooks as Record<string, unknown[]>)?.afterRead || []),\n ({ siblingData }: HookContext) => {\n // Read the value from the parameters JSON field\n const parameters = siblingData?.parameters as Record<string, unknown>\n return parameters?.[originalName] ?? (field as Record<string, unknown>).defaultValue\n }\n ],\n beforeChange: [\n ...((field.hooks as Record<string, unknown[]>)?.beforeChange || []),\n ({ siblingData, value }: HookContext) => {\n // Store the value in the parameters JSON field\n if (!siblingData.parameters) {\n siblingData.parameters = {}\n }\n const parameters = siblingData.parameters as Record<string, unknown>\n parameters[originalName] = value\n return undefined // Virtual field, don't store directly\n }\n ]\n },\n name: uniqueFieldName,\n virtual: true,\n }\n\n // Only add validate if the field supports it (data fields)\n const hasValidation = (field as Record<string, unknown>).validate || (field as Record<string, unknown>).required\n if (hasValidation) {\n resultField.validate = (value: unknown, args: ValidationContext) => {\n const parameters = args.siblingData?.parameters as Record<string, unknown>\n const paramValue = value ?? parameters?.[originalName]\n \n // Check required validation\n const isRequired = (field as Record<string, unknown>).required\n if (isRequired && args.siblingData?.type === triggerSlug && !paramValue) {\n const fieldLabel = (field as Record<string, unknown>).label as string\n const adminDesc = ((field as Record<string, unknown>).admin as Record<string, unknown>)?.description as string\n const label = fieldLabel || adminDesc || originalName\n return `${label} is required for ${triggerSlug}`\n }\n \n // Run original validation if present\n const originalValidate = (field as Record<string, unknown>).validate\n if (originalValidate && typeof originalValidate === 'function') {\n return (originalValidate as (value: unknown, args: ValidationContext) => boolean | string)(paramValue, args)\n }\n \n return true\n }\n }\n\n return resultField as Field\n}\n\n/**\n * Creates a custom trigger configuration with the provided fields\n * \n * @param slug - Unique identifier for the trigger\n * @param fields - Array of PayloadCMS fields that will be shown as trigger parameters\n * @returns Complete trigger configuration\n * \n * @example\n * ```typescript\n * const webhookTrigger = createTrigger('webhook', [\n * {\n * name: 'url',\n * type: 'text',\n * required: true,\n * admin: {\n * description: 'Webhook URL'\n * }\n * },\n * {\n * name: 'method',\n * type: 'select',\n * options: ['GET', 'POST', 'PUT', 'DELETE'],\n * defaultValue: 'POST'\n * }\n * ])\n * ```\n */\nexport function createTrigger(slug: string, fields: FieldWithName[]): CustomTriggerConfig {\n return {\n slug,\n inputs: fields.map(field => createTriggerField(field, slug))\n }\n}"],"names":["createTriggerField","field","triggerSlug","originalName","name","Error","uniqueFieldName","resultField","admin","condition","data","siblingData","triggerMatches","type","originalCondition","hooks","afterRead","parameters","defaultValue","beforeChange","value","undefined","virtual","hasValidation","validate","required","args","paramValue","isRequired","fieldLabel","label","adminDesc","description","originalValidate","createTrigger","slug","fields","inputs","map"],"mappings":"AAmBA;;;;;;;;;;;;;;;;;;;;;;;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MAAMC,gBAAgB,AAACtB,MAAkCuB,QAAQ,IAAI,AAACvB,MAAkCwB,QAAQ;IAChH,IAAIF,eAAe;QACjBhB,YAAYiB,QAAQ,GAAG,CAACJ,OAAgBM;YACtC,MAAMT,aAAaS,KAAKf,WAAW,EAAEM;YACrC,MAAMU,aAAaP,SAASH,YAAY,CAACd,aAAa;YAEtD,4BAA4B;YAC5B,MAAMyB,aAAa,AAAC3B,MAAkCwB,QAAQ;YAC9D,IAAIG,cAAcF,KAAKf,WAAW,EAAEE,SAASX,eAAe,CAACyB,YAAY;gBACvE,MAAME,aAAa,AAAC5B,MAAkC6B,KAAK;gBAC3D,MAAMC,YAAa,AAAC9B,MAAkCO,KAAK,EAA8BwB;gBACzF,MAAMF,QAAQD,cAAcE,aAAa5B;gBACzC,OAAO,GAAG2B,MAAM,iBAAiB,EAAE5B,aAAa;YAClD;YAEA,qCAAqC;YACrC,MAAM+B,mBAAmB,AAAChC,MAAkCuB,QAAQ;YACpE,IAAIS,oBAAoB,OAAOA,qBAAqB,YAAY;gBAC9D,OAAO,AAACA,iBAAmFN,YAAYD;YACzG;YAEA,OAAO;QACT;IACF;IAEA,OAAOnB;AACT;AAEA;;;;;;;;;;;;;;;;;;;;;;;;;;CA0BC,GACD,OAAO,SAAS2B,cAAcC,IAAY,EAAEC,MAAuB;IACjE,OAAO;QACLD;QACAE,QAAQD,OAAOE,GAAG,CAACrC,CAAAA,QAASD,mBAAmBC,OAAOkC;IACxD;AACF"}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import type { CustomTriggerConfig } from '../plugin/config-types.js';
|
|
2
|
-
/**
|
|
3
|
-
* Preset trigger builders for common patterns
|
|
4
|
-
*/
|
|
5
|
-
/**
|
|
6
|
-
* Create a webhook trigger with common webhook parameters pre-configured
|
|
7
|
-
*/
|
|
8
|
-
export declare function webhookTrigger(slug: string): CustomTriggerConfig;
|
|
9
|
-
/**
|
|
10
|
-
* Create a scheduled/cron trigger with timing parameters pre-configured
|
|
11
|
-
*/
|
|
12
|
-
export declare function cronTrigger(slug: string): CustomTriggerConfig;
|
|
13
|
-
/**
|
|
14
|
-
* Create an event-driven trigger with event filtering parameters
|
|
15
|
-
*/
|
|
16
|
-
export declare function eventTrigger(slug: string): CustomTriggerConfig;
|
|
17
|
-
/**
|
|
18
|
-
* Create a simple manual trigger (no parameters needed)
|
|
19
|
-
*/
|
|
20
|
-
export declare function manualTrigger(slug: string): CustomTriggerConfig;
|
|
21
|
-
/**
|
|
22
|
-
* Create an API trigger for external systems to call
|
|
23
|
-
*/
|
|
24
|
-
export declare function apiTrigger(slug: string): CustomTriggerConfig;
|
|
@@ -1,177 +0,0 @@
|
|
|
1
|
-
import { createTrigger } from './trigger-helpers.js';
|
|
2
|
-
/**
|
|
3
|
-
* Preset trigger builders for common patterns
|
|
4
|
-
*/ /**
|
|
5
|
-
* Create a webhook trigger with common webhook parameters pre-configured
|
|
6
|
-
*/ export function webhookTrigger(slug) {
|
|
7
|
-
return createTrigger(slug, [
|
|
8
|
-
{
|
|
9
|
-
name: 'path',
|
|
10
|
-
type: 'text',
|
|
11
|
-
required: true,
|
|
12
|
-
admin: {
|
|
13
|
-
description: 'URL path for the webhook endpoint (e.g., "my-webhook")'
|
|
14
|
-
},
|
|
15
|
-
validate: (value)=>{
|
|
16
|
-
if (typeof value === 'string' && value.includes(' ')) {
|
|
17
|
-
return 'Webhook path cannot contain spaces';
|
|
18
|
-
}
|
|
19
|
-
return true;
|
|
20
|
-
}
|
|
21
|
-
},
|
|
22
|
-
{
|
|
23
|
-
name: 'secret',
|
|
24
|
-
type: 'text',
|
|
25
|
-
admin: {
|
|
26
|
-
description: 'Secret key for webhook signature validation (optional but recommended)'
|
|
27
|
-
}
|
|
28
|
-
},
|
|
29
|
-
{
|
|
30
|
-
name: 'headers',
|
|
31
|
-
type: 'json',
|
|
32
|
-
admin: {
|
|
33
|
-
description: 'Expected HTTP headers for validation (JSON object)'
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
]);
|
|
37
|
-
}
|
|
38
|
-
/**
|
|
39
|
-
* Create a scheduled/cron trigger with timing parameters pre-configured
|
|
40
|
-
*/ export function cronTrigger(slug) {
|
|
41
|
-
return createTrigger(slug, [
|
|
42
|
-
{
|
|
43
|
-
name: 'expression',
|
|
44
|
-
type: 'text',
|
|
45
|
-
required: true,
|
|
46
|
-
admin: {
|
|
47
|
-
description: 'Cron expression for scheduling (e.g., "0 9 * * 1" for every Monday at 9 AM)',
|
|
48
|
-
placeholder: '0 9 * * 1'
|
|
49
|
-
}
|
|
50
|
-
},
|
|
51
|
-
{
|
|
52
|
-
name: 'timezone',
|
|
53
|
-
type: 'text',
|
|
54
|
-
defaultValue: 'UTC',
|
|
55
|
-
admin: {
|
|
56
|
-
description: 'Timezone for cron execution (e.g., "America/New_York", "Europe/London")',
|
|
57
|
-
placeholder: 'UTC'
|
|
58
|
-
},
|
|
59
|
-
validate: (value)=>{
|
|
60
|
-
if (value) {
|
|
61
|
-
try {
|
|
62
|
-
new Intl.DateTimeFormat('en', {
|
|
63
|
-
timeZone: value
|
|
64
|
-
});
|
|
65
|
-
return true;
|
|
66
|
-
} catch {
|
|
67
|
-
return `Invalid timezone: ${value}. Please use a valid IANA timezone identifier`;
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
return true;
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
]);
|
|
74
|
-
}
|
|
75
|
-
/**
|
|
76
|
-
* Create an event-driven trigger with event filtering parameters
|
|
77
|
-
*/ export function eventTrigger(slug) {
|
|
78
|
-
return createTrigger(slug, [
|
|
79
|
-
{
|
|
80
|
-
name: 'eventTypes',
|
|
81
|
-
type: 'select',
|
|
82
|
-
hasMany: true,
|
|
83
|
-
options: [
|
|
84
|
-
{
|
|
85
|
-
label: 'User Created',
|
|
86
|
-
value: 'user.created'
|
|
87
|
-
},
|
|
88
|
-
{
|
|
89
|
-
label: 'User Updated',
|
|
90
|
-
value: 'user.updated'
|
|
91
|
-
},
|
|
92
|
-
{
|
|
93
|
-
label: 'Document Published',
|
|
94
|
-
value: 'document.published'
|
|
95
|
-
},
|
|
96
|
-
{
|
|
97
|
-
label: 'Payment Completed',
|
|
98
|
-
value: 'payment.completed'
|
|
99
|
-
}
|
|
100
|
-
],
|
|
101
|
-
admin: {
|
|
102
|
-
description: 'Event types that should trigger this workflow'
|
|
103
|
-
}
|
|
104
|
-
},
|
|
105
|
-
{
|
|
106
|
-
name: 'filters',
|
|
107
|
-
type: 'json',
|
|
108
|
-
admin: {
|
|
109
|
-
description: 'JSON filters to apply to event data (e.g., {"status": "active"})'
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
]);
|
|
113
|
-
}
|
|
114
|
-
/**
|
|
115
|
-
* Create a simple manual trigger (no parameters needed)
|
|
116
|
-
*/ export function manualTrigger(slug) {
|
|
117
|
-
return {
|
|
118
|
-
slug,
|
|
119
|
-
inputs: []
|
|
120
|
-
};
|
|
121
|
-
}
|
|
122
|
-
/**
|
|
123
|
-
* Create an API trigger for external systems to call
|
|
124
|
-
*/ export function apiTrigger(slug) {
|
|
125
|
-
return createTrigger(slug, [
|
|
126
|
-
{
|
|
127
|
-
name: 'endpoint',
|
|
128
|
-
type: 'text',
|
|
129
|
-
required: true,
|
|
130
|
-
admin: {
|
|
131
|
-
description: 'API endpoint path (e.g., "/api/triggers/my-trigger")'
|
|
132
|
-
}
|
|
133
|
-
},
|
|
134
|
-
{
|
|
135
|
-
name: 'method',
|
|
136
|
-
type: 'select',
|
|
137
|
-
options: [
|
|
138
|
-
'GET',
|
|
139
|
-
'POST',
|
|
140
|
-
'PUT',
|
|
141
|
-
'PATCH'
|
|
142
|
-
],
|
|
143
|
-
defaultValue: 'POST',
|
|
144
|
-
admin: {
|
|
145
|
-
description: 'HTTP method for the API endpoint'
|
|
146
|
-
}
|
|
147
|
-
},
|
|
148
|
-
{
|
|
149
|
-
name: 'authentication',
|
|
150
|
-
type: 'select',
|
|
151
|
-
options: [
|
|
152
|
-
{
|
|
153
|
-
label: 'None',
|
|
154
|
-
value: 'none'
|
|
155
|
-
},
|
|
156
|
-
{
|
|
157
|
-
label: 'API Key',
|
|
158
|
-
value: 'api-key'
|
|
159
|
-
},
|
|
160
|
-
{
|
|
161
|
-
label: 'Bearer Token',
|
|
162
|
-
value: 'bearer'
|
|
163
|
-
},
|
|
164
|
-
{
|
|
165
|
-
label: 'Basic Auth',
|
|
166
|
-
value: 'basic'
|
|
167
|
-
}
|
|
168
|
-
],
|
|
169
|
-
defaultValue: 'api-key',
|
|
170
|
-
admin: {
|
|
171
|
-
description: 'Authentication method for the API endpoint'
|
|
172
|
-
}
|
|
173
|
-
}
|
|
174
|
-
]);
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
//# sourceMappingURL=trigger-presets.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/utils/trigger-presets.ts"],"sourcesContent":["import { createTrigger } from './trigger-helpers.js'\nimport type { CustomTriggerConfig } from '../plugin/config-types.js'\n\n/**\n * Preset trigger builders for common patterns\n */\n\n/**\n * Create a webhook trigger with common webhook parameters pre-configured\n */\nexport function webhookTrigger(slug: string): CustomTriggerConfig {\n return createTrigger(slug, [\n {\n name: 'path',\n type: 'text',\n required: true,\n admin: {\n description: 'URL path for the webhook endpoint (e.g., \"my-webhook\")'\n },\n validate: (value: any) => {\n if (typeof value === 'string' && value.includes(' ')) {\n return 'Webhook path cannot contain spaces'\n }\n return true\n }\n },\n {\n name: 'secret',\n type: 'text',\n admin: {\n description: 'Secret key for webhook signature validation (optional but recommended)'\n }\n },\n {\n name: 'headers',\n type: 'json',\n admin: {\n description: 'Expected HTTP headers for validation (JSON object)'\n }\n }\n ])\n}\n\n/**\n * Create a scheduled/cron trigger with timing parameters pre-configured\n */\nexport function cronTrigger(slug: string): CustomTriggerConfig {\n return createTrigger(slug, [\n {\n name: 'expression',\n type: 'text',\n required: true,\n admin: {\n description: 'Cron expression for scheduling (e.g., \"0 9 * * 1\" for every Monday at 9 AM)',\n placeholder: '0 9 * * 1'\n }\n },\n {\n name: 'timezone',\n type: 'text',\n defaultValue: 'UTC',\n admin: {\n description: 'Timezone for cron execution (e.g., \"America/New_York\", \"Europe/London\")',\n placeholder: 'UTC'\n },\n validate: (value: any) => {\n if (value) {\n try {\n new Intl.DateTimeFormat('en', { timeZone: value as string })\n return true\n } catch {\n return `Invalid timezone: ${value}. Please use a valid IANA timezone identifier`\n }\n }\n return true\n }\n }\n ])\n}\n\n/**\n * Create an event-driven trigger with event filtering parameters\n */\nexport function eventTrigger(slug: string): CustomTriggerConfig {\n return createTrigger(slug, [\n {\n name: 'eventTypes',\n type: 'select',\n hasMany: true,\n options: [\n { label: 'User Created', value: 'user.created' },\n { label: 'User Updated', value: 'user.updated' },\n { label: 'Document Published', value: 'document.published' },\n { label: 'Payment Completed', value: 'payment.completed' }\n ],\n admin: {\n description: 'Event types that should trigger this workflow'\n }\n },\n {\n name: 'filters',\n type: 'json',\n admin: {\n description: 'JSON filters to apply to event data (e.g., {\"status\": \"active\"})'\n }\n }\n ])\n}\n\n/**\n * Create a simple manual trigger (no parameters needed)\n */\nexport function manualTrigger(slug: string): CustomTriggerConfig {\n return {\n slug,\n inputs: []\n }\n}\n\n/**\n * Create an API trigger for external systems to call\n */\nexport function apiTrigger(slug: string): CustomTriggerConfig {\n return createTrigger(slug, [\n {\n name: 'endpoint',\n type: 'text',\n required: true,\n admin: {\n description: 'API endpoint path (e.g., \"/api/triggers/my-trigger\")'\n }\n },\n {\n name: 'method',\n type: 'select',\n options: ['GET', 'POST', 'PUT', 'PATCH'],\n defaultValue: 'POST',\n admin: {\n description: 'HTTP method for the API endpoint'\n }\n },\n {\n name: 'authentication',\n type: 'select',\n options: [\n { label: 'None', value: 'none' },\n { label: 'API Key', value: 'api-key' },\n { label: 'Bearer Token', value: 'bearer' },\n { label: 'Basic Auth', value: 'basic' }\n ],\n defaultValue: 'api-key',\n admin: {\n description: 'Authentication method for the API endpoint'\n }\n }\n ])\n}"],"names":["createTrigger","webhookTrigger","slug","name","type","required","admin","description","validate","value","includes","cronTrigger","placeholder","defaultValue","Intl","DateTimeFormat","timeZone","eventTrigger","hasMany","options","label","manualTrigger","inputs","apiTrigger"],"mappings":"AAAA,SAASA,aAAa,QAAQ,uBAAsB;AAGpD;;CAEC,GAED;;CAEC,GACD,OAAO,SAASC,eAAeC,IAAY;IACzC,OAAOF,cAAcE,MAAM;QACzB;YACEC,MAAM;YACNC,MAAM;YACNC,UAAU;YACVC,OAAO;gBACLC,aAAa;YACf;YACAC,UAAU,CAACC;gBACT,IAAI,OAAOA,UAAU,YAAYA,MAAMC,QAAQ,CAAC,MAAM;oBACpD,OAAO;gBACT;gBACA,OAAO;YACT;QACF;QACA;YACEP,MAAM;YACNC,MAAM;YACNE,OAAO;gBACLC,aAAa;YACf;QACF;QACA;YACEJ,MAAM;YACNC,MAAM;YACNE,OAAO;gBACLC,aAAa;YACf;QACF;KACD;AACH;AAEA;;CAEC,GACD,OAAO,SAASI,YAAYT,IAAY;IACtC,OAAOF,cAAcE,MAAM;QACzB;YACEC,MAAM;YACNC,MAAM;YACNC,UAAU;YACVC,OAAO;gBACLC,aAAa;gBACbK,aAAa;YACf;QACF;QACA;YACET,MAAM;YACNC,MAAM;YACNS,cAAc;YACdP,OAAO;gBACLC,aAAa;gBACbK,aAAa;YACf;YACAJ,UAAU,CAACC;gBACT,IAAIA,OAAO;oBACT,IAAI;wBACF,IAAIK,KAAKC,cAAc,CAAC,MAAM;4BAAEC,UAAUP;wBAAgB;wBAC1D,OAAO;oBACT,EAAE,OAAM;wBACN,OAAO,CAAC,kBAAkB,EAAEA,MAAM,6CAA6C,CAAC;oBAClF;gBACF;gBACA,OAAO;YACT;QACF;KACD;AACH;AAEA;;CAEC,GACD,OAAO,SAASQ,aAAaf,IAAY;IACvC,OAAOF,cAAcE,MAAM;QACzB;YACEC,MAAM;YACNC,MAAM;YACNc,SAAS;YACTC,SAAS;gBACP;oBAAEC,OAAO;o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