Fix JSON circular reference serialization and use PayloadCMS generated types

- Replace duplicate type definitions with PayloadCMS generated types
- Fix workflow context serialization with safeSerialize() method
- Resolve type mismatches (id: string vs number)
- Update all imports to use PayloadWorkflow type
- Ensure workflow runs are created successfully without serialization errors

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2025-09-01 18:02:21 +02:00
parent 964b11c0c9
commit 6397250045
13 changed files with 477 additions and 75 deletions

View File

@@ -217,7 +217,7 @@ export interface Workflow {
/**
* Collection that triggers the workflow
*/
collection?: 'posts' | null;
collectionSlug?: 'posts' | null;
/**
* Collection operation that triggers the workflow
*/
@@ -242,6 +242,10 @@ export interface Workflow {
* Timezone for cron execution (e.g., "America/New_York", "Europe/London"). Defaults to UTC.
*/
timezone?: string | null;
/**
* JSONPath expression that must evaluate to true for this trigger to execute the workflow (e.g., "$.doc.status == 'published'")
*/
condition?: string | null;
id?: string | null;
}[]
| null;
@@ -262,6 +266,10 @@ export interface Workflow {
* Step names that must complete before this step can run
*/
dependencies?: string[] | null;
/**
* JSONPath expression that must evaluate to true for this step to execute (e.g., "$.trigger.doc.status == 'published'")
*/
condition?: string | null;
id?: string | null;
}[]
| null;
@@ -584,13 +592,14 @@ export interface WorkflowsSelect<T extends boolean = true> {
| T
| {
type?: T;
collection?: T;
collectionSlug?: T;
operation?: T;
webhookPath?: T;
global?: T;
globalOperation?: T;
cronExpression?: T;
timezone?: T;
condition?: T;
id?: T;
};
steps?:
@@ -600,6 +609,7 @@ export interface WorkflowsSelect<T extends boolean = true> {
name?: T;
input?: T;
dependencies?: T;
condition?: T;
id?: T;
};
updatedAt?: T;
@@ -741,7 +751,7 @@ export interface TaskCreateDocument {
/**
* The collection slug to create a document in
*/
collection: string;
collectionSlug: string;
/**
* The document data to create
*/