stash
This commit is contained in:
parent
796fef81be
commit
7df585d774
11 changed files with 246 additions and 72 deletions
|
|
@ -404,6 +404,27 @@ class WorkflowRegistry {
|
|||
// Create and export the default registry instance
|
||||
export const workflowRegistry = new WorkflowRegistry();
|
||||
|
||||
/**
|
||||
* The backend stores WorkflowInstance.payload as an opaque string - it never
|
||||
* parses or understands it as JSON. The frontend is fully responsible for
|
||||
* serializing it before sending and deserializing it after receiving.
|
||||
*/
|
||||
export function serializeWorkflowPayload(workflow) {
|
||||
if (!workflow || !('payload' in workflow)) return workflow;
|
||||
return {...workflow, payload: JSON.stringify(workflow.payload ?? {})};
|
||||
}
|
||||
|
||||
export function deserializeWorkflowPayload(workflow) {
|
||||
if (!workflow) return workflow;
|
||||
let payload = {};
|
||||
try {
|
||||
payload = workflow.payload ? JSON.parse(workflow.payload) : {};
|
||||
} catch (e) {
|
||||
console.error('Failed to parse workflow payload JSON:', e);
|
||||
}
|
||||
return {...workflow, payload};
|
||||
}
|
||||
|
||||
// Export individual classes for direct use
|
||||
export {
|
||||
BaseWorkflow,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue