WIP: Refactor triggers to TriggerConfig pattern

- Convert webhook, global, and cron triggers to use TriggerConfig pattern like collectionTrigger
- Simplify trigger slug names (remove '-trigger' suffix)
- Update validation to use new slug names
- Add perfectionist/sort-exports rule disable
- Note: Workflow.ts integration still needs fixes for type compatibility
This commit is contained in:
2025-09-10 13:48:26 +02:00
parent 9a3b94ef60
commit b18e2eaf49
9 changed files with 208 additions and 225 deletions

View File

@@ -1,4 +1,6 @@
import type {Field, TaskConfig} from "payload"
import type {TaskConfig} from "payload"
import type {Trigger} from "../triggers/types.js"
export type CollectionTriggerConfigCrud = {
create?: true
@@ -9,10 +11,7 @@ export type CollectionTriggerConfigCrud = {
export type CollectionTriggerConfig = CollectionTriggerConfigCrud | true
export type CustomTriggerConfig = {
inputs?: Field[]
slug: string,
}
export type TriggerConfig = <T extends string>(config: WorkflowsPluginConfig<T>) => Trigger
export type WorkflowsPluginConfig<TSlug extends string> = {
collectionTriggers: {
@@ -20,6 +19,6 @@ export type WorkflowsPluginConfig<TSlug extends string> = {
}
enabled?: boolean
steps: TaskConfig<string>[],
triggers?: CustomTriggerConfig[]
triggers?: TriggerConfig[]
webhookPrefix?: string
}