@contractspec/example.workflow-system 1.44.0 → 1.45.0

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.
Files changed (35) hide show
  1. package/dist/approval/approval.event.js +4 -4
  2. package/dist/approval/approval.event.js.map +1 -1
  3. package/dist/approval/approval.operations.d.ts +3 -3
  4. package/dist/approval/approval.operations.js +8 -8
  5. package/dist/approval/approval.operations.js.map +1 -1
  6. package/dist/example.d.ts +3 -36
  7. package/dist/example.d.ts.map +1 -1
  8. package/dist/example.js +16 -11
  9. package/dist/example.js.map +1 -1
  10. package/dist/instance/instance.event.d.ts +86 -86
  11. package/dist/instance/instance.event.js +9 -9
  12. package/dist/instance/instance.event.js.map +1 -1
  13. package/dist/instance/instance.operations.d.ts +260 -260
  14. package/dist/instance/instance.operations.js +15 -15
  15. package/dist/instance/instance.operations.js.map +1 -1
  16. package/dist/instance/instance.schema.d.ts +54 -54
  17. package/dist/presentations/index.js +11 -11
  18. package/dist/presentations/index.js.map +1 -1
  19. package/dist/shared/types.d.ts +1 -1
  20. package/dist/state-machine/index.d.ts +2 -2
  21. package/dist/state-machine/index.js.map +1 -1
  22. package/dist/workflow/workflow.event.d.ts +3 -3
  23. package/dist/workflow/workflow.event.js +5 -5
  24. package/dist/workflow/workflow.event.js.map +1 -1
  25. package/dist/workflow/workflow.handler.js +1 -1
  26. package/dist/workflow/workflow.handler.js.map +1 -1
  27. package/dist/workflow/workflow.operations.d.ts +12 -12
  28. package/dist/workflow/workflow.operations.js +10 -10
  29. package/dist/workflow/workflow.operations.js.map +1 -1
  30. package/dist/workflow/workflow.schema.d.ts +1 -1
  31. package/dist/workflow/workflow.schema.js +1 -1
  32. package/dist/workflow/workflow.schema.js.map +1 -1
  33. package/dist/workflow-system.feature.js +71 -71
  34. package/dist/workflow-system.feature.js.map +1 -1
  35. package/package.json +11 -11
@@ -7,7 +7,7 @@ interface WorkflowDefinitionRecord {
7
7
  key: string;
8
8
  name: string;
9
9
  description?: string;
10
- version: number;
10
+ version: string;
11
11
  status: 'DRAFT' | 'ACTIVE' | 'DEPRECATED' | 'ARCHIVED';
12
12
  triggerType: 'MANUAL' | 'EVENT' | 'SCHEDULED' | 'API';
13
13
  initialStepId?: string;
@@ -43,7 +43,7 @@ interface StateMachineStep {
43
43
  interface StateMachineDefinition {
44
44
  key: string;
45
45
  name: string;
46
- version: number;
46
+ version: string;
47
47
  initialStepKey: string;
48
48
  steps: Record<string, StateMachineStep>;
49
49
  }
@@ -127,7 +127,7 @@ declare function createStateMachineEngine(): IStateMachineEngine;
127
127
  declare function buildStateMachineDefinition(workflow: {
128
128
  key: string;
129
129
  name: string;
130
- version: number;
130
+ version: string;
131
131
  initialStepId: string | null;
132
132
  }, steps: {
133
133
  key: string;
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["newStatus: StateMachineState['status']","stepMap: Record<string, StateMachineStep>"],"sources":["../../src/state-machine/index.ts"],"sourcesContent":["/**\n * Workflow State Machine Engine\n *\n * Provides state machine logic for workflow transitions.\n * This is a spec-level abstraction that defines the interface\n * for workflow state transitions.\n */\n\n// ============ Types ============\n\n/**\n * Represents a transition definition in a workflow step.\n */\nexport interface TransitionDefinition {\n /** The action that triggers this transition (e.g., \"approve\", \"reject\") */\n action: string;\n /** The target step key to transition to */\n targetStepKey: string;\n /** Optional condition expression for conditional transitions */\n condition?: string;\n /** Optional guard roles - only users with these roles can take this action */\n allowedRoles?: string[];\n}\n\n/**\n * Step definition for state machine.\n */\nexport interface StateMachineStep {\n key: string;\n name: string;\n type:\n | 'START'\n | 'APPROVAL'\n | 'TASK'\n | 'CONDITION'\n | 'PARALLEL'\n | 'WAIT'\n | 'ACTION'\n | 'END';\n /** Map of action -> transition definition */\n transitions: Record<string, string | TransitionDefinition>;\n /** For approval steps: how approvals are handled */\n approvalMode?: 'ANY' | 'ALL' | 'MAJORITY' | 'SEQUENTIAL';\n /** Roles that can approve/act on this step */\n allowedRoles?: string[];\n /** Timeout in seconds */\n timeoutSeconds?: number;\n /** Condition expression for CONDITION type */\n conditionExpression?: string;\n}\n\n/**\n * Workflow state machine definition.\n */\nexport interface StateMachineDefinition {\n key: string;\n name: string;\n version: number;\n initialStepKey: string;\n steps: Record<string, StateMachineStep>;\n}\n\n/**\n * Current state of an instance.\n */\nexport interface StateMachineState {\n currentStepKey: string;\n status:\n | 'PENDING'\n | 'RUNNING'\n | 'WAITING'\n | 'PAUSED'\n | 'COMPLETED'\n | 'CANCELLED'\n | 'FAILED'\n | 'TIMEOUT';\n contextData: Record<string, unknown>;\n history: {\n stepKey: string;\n action: string;\n timestamp: Date;\n executedBy: string;\n }[];\n}\n\n/**\n * Result of a transition attempt.\n */\nexport interface TransitionResult {\n success: boolean;\n previousStepKey: string;\n currentStepKey: string | null;\n status: StateMachineState['status'];\n error?: string;\n}\n\n/**\n * Context for transition validation.\n */\nexport interface TransitionContext {\n userId: string;\n userRoles: string[];\n data?: Record<string, unknown>;\n}\n\n// ============ State Machine Engine ============\n\n/**\n * State machine engine interface.\n * Implementation should be provided at runtime.\n */\nexport interface IStateMachineEngine {\n /**\n * Validate that a transition is allowed.\n */\n canTransition(\n definition: StateMachineDefinition,\n state: StateMachineState,\n action: string,\n context: TransitionContext\n ): { allowed: boolean; reason?: string };\n\n /**\n * Get available actions for the current step.\n */\n getAvailableActions(\n definition: StateMachineDefinition,\n state: StateMachineState,\n context: TransitionContext\n ): string[];\n\n /**\n * Execute a transition.\n */\n transition(\n definition: StateMachineDefinition,\n state: StateMachineState,\n action: string,\n context: TransitionContext\n ): TransitionResult;\n\n /**\n * Evaluate a condition expression.\n */\n evaluateCondition(\n expression: string,\n contextData: Record<string, unknown>\n ): boolean;\n}\n\n/**\n * Basic state machine engine implementation.\n * This is a reference implementation for spec validation.\n */\nexport class BasicStateMachineEngine implements IStateMachineEngine {\n canTransition(\n definition: StateMachineDefinition,\n state: StateMachineState,\n action: string,\n context: TransitionContext\n ): { allowed: boolean; reason?: string } {\n // Check if state allows transitions\n if (state.status !== 'RUNNING' && state.status !== 'WAITING') {\n return {\n allowed: false,\n reason: `Workflow is ${state.status}, cannot transition`,\n };\n }\n\n const currentStep = definition.steps[state.currentStepKey];\n if (!currentStep) {\n return {\n allowed: false,\n reason: `Step ${state.currentStepKey} not found`,\n };\n }\n\n // Check if action exists for this step\n const transition = currentStep.transitions[action];\n if (!transition) {\n return {\n allowed: false,\n reason: `Action ${action} not available in step ${state.currentStepKey}`,\n };\n }\n\n // Check role-based access\n if (currentStep.allowedRoles && currentStep.allowedRoles.length > 0) {\n const hasRole = currentStep.allowedRoles.some((role) =>\n context.userRoles.includes(role)\n );\n if (!hasRole) {\n return {\n allowed: false,\n reason: `User lacks required role for this action`,\n };\n }\n }\n\n // Check transition-specific roles if defined\n if (\n typeof transition === 'object' &&\n transition.allowedRoles &&\n transition.allowedRoles.length > 0\n ) {\n const hasRole = transition.allowedRoles.some((role) =>\n context.userRoles.includes(role)\n );\n if (!hasRole) {\n return {\n allowed: false,\n reason: `User lacks required role for action ${action}`,\n };\n }\n }\n\n return { allowed: true };\n }\n\n getAvailableActions(\n definition: StateMachineDefinition,\n state: StateMachineState,\n context: TransitionContext\n ): string[] {\n if (state.status !== 'RUNNING' && state.status !== 'WAITING') {\n return [];\n }\n\n const currentStep = definition.steps[state.currentStepKey];\n if (!currentStep) {\n return [];\n }\n\n return Object.keys(currentStep.transitions).filter((action) => {\n const result = this.canTransition(definition, state, action, context);\n return result.allowed;\n });\n }\n\n transition(\n definition: StateMachineDefinition,\n state: StateMachineState,\n action: string,\n context: TransitionContext\n ): TransitionResult {\n const validation = this.canTransition(definition, state, action, context);\n if (!validation.allowed) {\n return {\n success: false,\n previousStepKey: state.currentStepKey,\n currentStepKey: state.currentStepKey,\n status: state.status,\n error: validation.reason,\n };\n }\n\n const currentStep = definition.steps[state.currentStepKey];\n if (!currentStep) {\n return {\n success: false,\n previousStepKey: state.currentStepKey,\n currentStepKey: state.currentStepKey,\n status: state.status,\n error: `Current step ${state.currentStepKey} not found`,\n };\n }\n const transition = currentStep.transitions[action];\n if (!transition) {\n return {\n success: false,\n previousStepKey: state.currentStepKey,\n currentStepKey: state.currentStepKey,\n status: state.status,\n error: `Transition for action ${action} not found`,\n };\n }\n const targetStepKey =\n typeof transition === 'string' ? transition : transition.targetStepKey;\n const targetStep = definition.steps[targetStepKey];\n\n if (!targetStep) {\n return {\n success: false,\n previousStepKey: state.currentStepKey,\n currentStepKey: state.currentStepKey,\n status: state.status,\n error: `Target step ${targetStepKey} not found`,\n };\n }\n\n // Determine new status\n let newStatus: StateMachineState['status'] = 'RUNNING';\n if (targetStep.type === 'END') {\n newStatus = 'COMPLETED';\n } else if (targetStep.type === 'APPROVAL' || targetStep.type === 'WAIT') {\n newStatus = 'WAITING';\n }\n\n return {\n success: true,\n previousStepKey: state.currentStepKey,\n currentStepKey: targetStepKey,\n status: newStatus,\n };\n }\n\n evaluateCondition(\n expression: string,\n contextData: Record<string, unknown>\n ): boolean {\n // Basic condition evaluation\n // In production, this should use a proper expression language\n try {\n // Simple property checks like \"amount > 1000\"\n const match = expression.match(\n /^(\\w+)\\s*(>=|<=|>|<|===|!==|==|!=)\\s*(.+)$/\n );\n if (match) {\n const [, prop, operator, value] = match;\n if (!prop || !operator || value === undefined) {\n return false;\n }\n const propValue = contextData[prop];\n const compareValue = JSON.parse(value);\n\n switch (operator) {\n case '>':\n return Number(propValue) > Number(compareValue);\n case '<':\n return Number(propValue) < Number(compareValue);\n case '>=':\n return Number(propValue) >= Number(compareValue);\n case '<=':\n return Number(propValue) <= Number(compareValue);\n case '===':\n case '==':\n return propValue === compareValue;\n case '!==':\n case '!=':\n return propValue !== compareValue;\n }\n }\n\n // Check for boolean property\n if (expression in contextData) {\n return Boolean(contextData[expression]);\n }\n\n return false;\n } catch {\n return false;\n }\n }\n}\n\n/**\n * Create a new state machine engine instance.\n */\nexport function createStateMachineEngine(): IStateMachineEngine {\n return new BasicStateMachineEngine();\n}\n\n// ============ Utility Functions ============\n\n/**\n * Build a state machine definition from workflow entities.\n */\nexport function buildStateMachineDefinition(\n workflow: {\n key: string;\n name: string;\n version: number;\n initialStepId: string | null;\n },\n steps: {\n key: string;\n name: string;\n type: string;\n transitions: Record<string, string | TransitionDefinition>;\n approvalMode?: string;\n approverRoles?: string[];\n timeoutSeconds?: number;\n conditionExpression?: string;\n }[]\n): StateMachineDefinition {\n const stepMap: Record<string, StateMachineStep> = {};\n\n for (const step of steps) {\n stepMap[step.key] = {\n key: step.key,\n name: step.name,\n type: step.type as StateMachineStep['type'],\n transitions: step.transitions,\n approvalMode: step.approvalMode as StateMachineStep['approvalMode'],\n allowedRoles: step.approverRoles,\n timeoutSeconds: step.timeoutSeconds,\n conditionExpression: step.conditionExpression,\n };\n }\n\n // Find initial step\n const startStep = steps.find((s) => s.type === 'START');\n const initialStepKey = startStep?.key ?? steps[0]?.key ?? '';\n\n return {\n key: workflow.key,\n name: workflow.name,\n version: workflow.version,\n initialStepKey,\n steps: stepMap,\n };\n}\n\n/**\n * Create initial state for a new workflow instance.\n */\nexport function createInitialState(\n definition: StateMachineDefinition,\n contextData: Record<string, unknown> = {}\n): StateMachineState {\n return {\n currentStepKey: definition.initialStepKey,\n status: 'RUNNING',\n contextData,\n history: [],\n };\n}\n"],"mappings":";;;;;AA0JA,IAAa,0BAAb,MAAoE;CAClE,cACE,YACA,OACA,QACA,SACuC;AAEvC,MAAI,MAAM,WAAW,aAAa,MAAM,WAAW,UACjD,QAAO;GACL,SAAS;GACT,QAAQ,eAAe,MAAM,OAAO;GACrC;EAGH,MAAM,cAAc,WAAW,MAAM,MAAM;AAC3C,MAAI,CAAC,YACH,QAAO;GACL,SAAS;GACT,QAAQ,QAAQ,MAAM,eAAe;GACtC;EAIH,MAAM,aAAa,YAAY,YAAY;AAC3C,MAAI,CAAC,WACH,QAAO;GACL,SAAS;GACT,QAAQ,UAAU,OAAO,yBAAyB,MAAM;GACzD;AAIH,MAAI,YAAY,gBAAgB,YAAY,aAAa,SAAS,GAIhE;OAAI,CA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K;EACrB,qBAAqB,KAAK;EAC3B;CAKH,MAAM,iBADY,MAAM,MAAM,MAAM,EAAE,SAAS,QAAQ,EACrB,OAAO,MAAM,IAAI,OAAO;AAE1D,QAAO;EACL,KAAK,SAAS;EACd,MAAM,SAAS;EACf,SAAS,SAAS;EAClB;EACA,OAAO;EACR;;;;;AAMH,SAAgB,mBACd,YACA,cAAuC,EAAE,EACtB;AACnB,QAAO;EACL,gBAAgB,WAAW;EAC3B,QAAQ;EACR;EACA,SAAS,EAAE;EACZ"}
1
+ {"version":3,"file":"index.js","names":["newStatus: StateMachineState['status']","stepMap: Record<string, StateMachineStep>"],"sources":["../../src/state-machine/index.ts"],"sourcesContent":["/**\n * Workflow State Machine Engine\n *\n * Provides state machine logic for workflow transitions.\n * This is a spec-level abstraction that defines the interface\n * for workflow state transitions.\n */\n\n// ============ Types ============\n\n/**\n * Represents a transition definition in a workflow step.\n */\nexport interface TransitionDefinition {\n /** The action that triggers this transition (e.g., \"approve\", \"reject\") */\n action: string;\n /** The target step key to transition to */\n targetStepKey: string;\n /** Optional condition expression for conditional transitions */\n condition?: string;\n /** Optional guard roles - only users with these roles can take this action */\n allowedRoles?: string[];\n}\n\n/**\n * Step definition for state machine.\n */\nexport interface StateMachineStep {\n key: string;\n name: string;\n type:\n | 'START'\n | 'APPROVAL'\n | 'TASK'\n | 'CONDITION'\n | 'PARALLEL'\n | 'WAIT'\n | 'ACTION'\n | 'END';\n /** Map of action -> transition definition */\n transitions: Record<string, string | TransitionDefinition>;\n /** For approval steps: how approvals are handled */\n approvalMode?: 'ANY' | 'ALL' | 'MAJORITY' | 'SEQUENTIAL';\n /** Roles that can approve/act on this step */\n allowedRoles?: string[];\n /** Timeout in seconds */\n timeoutSeconds?: number;\n /** Condition expression for CONDITION type */\n conditionExpression?: string;\n}\n\n/**\n * Workflow state machine definition.\n */\nexport interface StateMachineDefinition {\n key: string;\n name: string;\n version: string;\n initialStepKey: string;\n steps: Record<string, StateMachineStep>;\n}\n\n/**\n * Current state of an instance.\n */\nexport interface StateMachineState {\n currentStepKey: string;\n status:\n | 'PENDING'\n | 'RUNNING'\n | 'WAITING'\n | 'PAUSED'\n | 'COMPLETED'\n | 'CANCELLED'\n | 'FAILED'\n | 'TIMEOUT';\n contextData: Record<string, unknown>;\n history: {\n stepKey: string;\n action: string;\n timestamp: Date;\n executedBy: string;\n }[];\n}\n\n/**\n * Result of a transition attempt.\n */\nexport interface TransitionResult {\n success: boolean;\n previousStepKey: string;\n currentStepKey: string | null;\n status: StateMachineState['status'];\n error?: string;\n}\n\n/**\n * Context for transition validation.\n */\nexport interface TransitionContext {\n userId: string;\n userRoles: string[];\n data?: Record<string, unknown>;\n}\n\n// ============ State Machine Engine ============\n\n/**\n * State machine engine interface.\n * Implementation should be provided at runtime.\n */\nexport interface IStateMachineEngine {\n /**\n * Validate that a transition is allowed.\n */\n canTransition(\n definition: StateMachineDefinition,\n state: StateMachineState,\n action: string,\n context: TransitionContext\n ): { allowed: boolean; reason?: string };\n\n /**\n * Get available actions for the current step.\n */\n getAvailableActions(\n definition: StateMachineDefinition,\n state: StateMachineState,\n context: TransitionContext\n ): string[];\n\n /**\n * Execute a transition.\n */\n transition(\n definition: StateMachineDefinition,\n state: StateMachineState,\n action: string,\n context: TransitionContext\n ): TransitionResult;\n\n /**\n * Evaluate a condition expression.\n */\n evaluateCondition(\n expression: string,\n contextData: Record<string, unknown>\n ): boolean;\n}\n\n/**\n * Basic state machine engine implementation.\n * This is a reference implementation for spec validation.\n */\nexport class BasicStateMachineEngine implements IStateMachineEngine {\n canTransition(\n definition: StateMachineDefinition,\n state: StateMachineState,\n action: string,\n context: TransitionContext\n ): { allowed: boolean; reason?: string } {\n // Check if state allows transitions\n if (state.status !== 'RUNNING' && state.status !== 'WAITING') {\n return {\n allowed: false,\n reason: `Workflow is ${state.status}, cannot transition`,\n };\n }\n\n const currentStep = definition.steps[state.currentStepKey];\n if (!currentStep) {\n return {\n allowed: false,\n reason: `Step ${state.currentStepKey} not found`,\n };\n }\n\n // Check if action exists for this step\n const transition = currentStep.transitions[action];\n if (!transition) {\n return {\n allowed: false,\n reason: `Action ${action} not available in step ${state.currentStepKey}`,\n };\n }\n\n // Check role-based access\n if (currentStep.allowedRoles && currentStep.allowedRoles.length > 0) {\n const hasRole = currentStep.allowedRoles.some((role) =>\n context.userRoles.includes(role)\n );\n if (!hasRole) {\n return {\n allowed: false,\n reason: `User lacks required role for this action`,\n };\n }\n }\n\n // Check transition-specific roles if defined\n if (\n typeof transition === 'object' &&\n transition.allowedRoles &&\n transition.allowedRoles.length > 0\n ) {\n const hasRole = transition.allowedRoles.some((role) =>\n context.userRoles.includes(role)\n );\n if (!hasRole) {\n return {\n allowed: false,\n reason: `User lacks required role for action ${action}`,\n };\n }\n }\n\n return { allowed: true };\n }\n\n getAvailableActions(\n definition: StateMachineDefinition,\n state: StateMachineState,\n context: TransitionContext\n ): string[] {\n if (state.status !== 'RUNNING' && state.status !== 'WAITING') {\n return [];\n }\n\n const currentStep = definition.steps[state.currentStepKey];\n if (!currentStep) {\n return [];\n }\n\n return Object.keys(currentStep.transitions).filter((action) => {\n const result = this.canTransition(definition, state, action, context);\n return result.allowed;\n });\n }\n\n transition(\n definition: StateMachineDefinition,\n state: StateMachineState,\n action: string,\n context: TransitionContext\n ): TransitionResult {\n const validation = this.canTransition(definition, state, action, context);\n if (!validation.allowed) {\n return {\n success: false,\n previousStepKey: state.currentStepKey,\n currentStepKey: state.currentStepKey,\n status: state.status,\n error: validation.reason,\n };\n }\n\n const currentStep = definition.steps[state.currentStepKey];\n if (!currentStep) {\n return {\n success: false,\n previousStepKey: state.currentStepKey,\n currentStepKey: state.currentStepKey,\n status: state.status,\n error: `Current step ${state.currentStepKey} not found`,\n };\n }\n const transition = currentStep.transitions[action];\n if (!transition) {\n return {\n success: false,\n previousStepKey: state.currentStepKey,\n currentStepKey: state.currentStepKey,\n status: state.status,\n error: `Transition for action ${action} not found`,\n };\n }\n const targetStepKey =\n typeof transition === 'string' ? transition : transition.targetStepKey;\n const targetStep = definition.steps[targetStepKey];\n\n if (!targetStep) {\n return {\n success: false,\n previousStepKey: state.currentStepKey,\n currentStepKey: state.currentStepKey,\n status: state.status,\n error: `Target step ${targetStepKey} not found`,\n };\n }\n\n // Determine new status\n let newStatus: StateMachineState['status'] = 'RUNNING';\n if (targetStep.type === 'END') {\n newStatus = 'COMPLETED';\n } else if (targetStep.type === 'APPROVAL' || targetStep.type === 'WAIT') {\n newStatus = 'WAITING';\n }\n\n return {\n success: true,\n previousStepKey: state.currentStepKey,\n currentStepKey: targetStepKey,\n status: newStatus,\n };\n }\n\n evaluateCondition(\n expression: string,\n contextData: Record<string, unknown>\n ): boolean {\n // Basic condition evaluation\n // In production, this should use a proper expression language\n try {\n // Simple property checks like \"amount > 1000\"\n const match = expression.match(\n /^(\\w+)\\s*(>=|<=|>|<|===|!==|==|!=)\\s*(.+)$/\n );\n if (match) {\n const [, prop, operator, value] = match;\n if (!prop || !operator || value === undefined) {\n return false;\n }\n const propValue = contextData[prop];\n const compareValue = JSON.parse(value);\n\n switch (operator) {\n case '>':\n return Number(propValue) > Number(compareValue);\n case '<':\n return Number(propValue) < Number(compareValue);\n case '>=':\n return Number(propValue) >= Number(compareValue);\n case '<=':\n return Number(propValue) <= Number(compareValue);\n case '===':\n case '==':\n return propValue === compareValue;\n case '!==':\n case '!=':\n return propValue !== compareValue;\n }\n }\n\n // Check for boolean property\n if (expression in contextData) {\n return Boolean(contextData[expression]);\n }\n\n return false;\n } catch {\n return false;\n }\n }\n}\n\n/**\n * Create a new state machine engine instance.\n */\nexport function createStateMachineEngine(): IStateMachineEngine {\n return new BasicStateMachineEngine();\n}\n\n// ============ Utility Functions ============\n\n/**\n * Build a state machine definition from workflow entities.\n */\nexport function buildStateMachineDefinition(\n workflow: {\n key: string;\n name: string;\n version: string;\n initialStepId: string | null;\n },\n steps: {\n key: string;\n name: string;\n type: string;\n transitions: Record<string, string | TransitionDefinition>;\n approvalMode?: string;\n approverRoles?: string[];\n timeoutSeconds?: number;\n conditionExpression?: string;\n }[]\n): StateMachineDefinition {\n const stepMap: Record<string, StateMachineStep> = {};\n\n for (const step of steps) {\n stepMap[step.key] = {\n key: step.key,\n name: step.name,\n type: step.type as StateMachineStep['type'],\n transitions: step.transitions,\n approvalMode: step.approvalMode as StateMachineStep['approvalMode'],\n allowedRoles: step.approverRoles,\n timeoutSeconds: step.timeoutSeconds,\n conditionExpression: step.conditionExpression,\n };\n }\n\n // Find initial step\n const startStep = steps.find((s) => s.type === 'START');\n const initialStepKey = startStep?.key ?? steps[0]?.key ?? '';\n\n return {\n key: workflow.key,\n name: workflow.name,\n version: workflow.version,\n initialStepKey,\n steps: stepMap,\n };\n}\n\n/**\n * Create initial state for a new workflow instance.\n */\nexport function createInitialState(\n definition: StateMachineDefinition,\n contextData: Record<string, unknown> = {}\n): StateMachineState {\n return {\n currentStepKey: definition.initialStepKey,\n status: 'RUNNING',\n contextData,\n history: [],\n };\n}\n"],"mappings":";;;;;AA0JA,IAAa,0BAAb,MAAoE;CAClE,cACE,YACA,OACA,QACA,SACuC;AAEvC,MAAI,MAAM,WAAW,aAAa,MAAM,WAAW,UACjD,QAAO;GACL,SAAS;GACT,QAAQ,eAAe,MAAM,OAAO;GACrC;EAGH,MAAM,cAAc,WAAW,MAAM,MAAM;AAC3C,MAAI,CAAC,YACH,QAAO;GACL,SAAS;GACT,QAAQ,QAAQ,MAAM,eAAe;GACtC;EAIH,MAAM,aAAa,YAAY,YAAY;AAC3C,MAAI,CAAC,WACH,QAAO;GACL,SAAS;GACT,QAAQ,UAAU,OAAO,yBAAyB,MAAM;GACzD;AAIH,MAAI,YAAY,gBAAgB,YAAY,aAAa,SAAS,GAIhE;OAAI,CAHY,YAAY,aAAa,MAAM,SAC7C,QAAQ,UAAU,SAAS,KAAK,CACjC,CAEC,QAAO;IACL,SAAS;IACT,QAAQ;IACT;;AAKL,MACE,OAAO,eAAe,YACtB,WAAW,gBACX,WAAW,aAAa,SAAS,GAKjC;OAA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S,SAAS;EAClB;EACA,OAAO;EACR;;;;;AAMH,SAAgB,mBACd,YACA,cAAuC,EAAE,EACtB;AACnB,QAAO;EACL,gBAAgB,WAAW;EAC3B,QAAQ;EACR;EACA,SAAS,EAAE;EACZ"}
@@ -19,7 +19,7 @@ declare const WorkflowCreatedEvent: _contractspec_lib_contracts24.EventSpec<_con
19
19
  isOptional: false;
20
20
  };
21
21
  version: {
22
- type: _contractspec_lib_schema905.FieldType<number, number>;
22
+ type: _contractspec_lib_schema905.FieldType<string, string>;
23
23
  isOptional: false;
24
24
  };
25
25
  organizationId: {
@@ -52,7 +52,7 @@ declare const WorkflowUpdatedEvent: _contractspec_lib_contracts24.EventSpec<_con
52
52
  isOptional: false;
53
53
  };
54
54
  version: {
55
- type: _contractspec_lib_schema905.FieldType<number, number>;
55
+ type: _contractspec_lib_schema905.FieldType<string, string>;
56
56
  isOptional: false;
57
57
  };
58
58
  organizationId: {
@@ -85,7 +85,7 @@ declare const WorkflowPublishedEvent: _contractspec_lib_contracts24.EventSpec<_c
85
85
  isOptional: false;
86
86
  };
87
87
  version: {
88
- type: _contractspec_lib_schema905.FieldType<number, number>;
88
+ type: _contractspec_lib_schema905.FieldType<string, string>;
89
89
  isOptional: false;
90
90
  };
91
91
  organizationId: {
@@ -22,7 +22,7 @@ const WorkflowDefinitionPayload = defineSchemaModel$1({
22
22
  isOptional: false
23
23
  },
24
24
  version: {
25
- type: ScalarTypeEnum.Int_unsecure(),
25
+ type: ScalarTypeEnum.String_unsecure(),
26
26
  isOptional: false
27
27
  },
28
28
  organizationId: {
@@ -78,7 +78,7 @@ const StepAddedPayload = defineSchemaModel$1({
78
78
  const WorkflowCreatedEvent = defineEvent({
79
79
  meta: {
80
80
  key: "workflow.definition.created",
81
- version: 1,
81
+ version: "1.0.0",
82
82
  description: "A new workflow definition has been created.",
83
83
  stability: "stable",
84
84
  owners: ["@workflow-team"],
@@ -96,7 +96,7 @@ const WorkflowCreatedEvent = defineEvent({
96
96
  const WorkflowUpdatedEvent = defineEvent({
97
97
  meta: {
98
98
  key: "workflow.definition.updated",
99
- version: 1,
99
+ version: "1.0.0",
100
100
  description: "A workflow definition has been updated.",
101
101
  stability: "stable",
102
102
  owners: ["@workflow-team"],
@@ -114,7 +114,7 @@ const WorkflowUpdatedEvent = defineEvent({
114
114
  const WorkflowPublishedEvent = defineEvent({
115
115
  meta: {
116
116
  key: "workflow.definition.published",
117
- version: 1,
117
+ version: "1.0.0",
118
118
  description: "A workflow definition has been published and is now active.",
119
119
  stability: "stable",
120
120
  owners: ["@workflow-team"],
@@ -132,7 +132,7 @@ const WorkflowPublishedEvent = defineEvent({
132
132
  const StepAddedEvent = defineEvent({
133
133
  meta: {
134
134
  key: "workflow.step.added",
135
- version: 1,
135
+ version: "1.0.0",
136
136
  description: "A step has been added to a workflow definition.",
137
137
  stability: "stable",
138
138
  owners: ["@workflow-team"],
@@ -1 +1 @@
1
- {"version":3,"file":"workflow.event.js","names":["defineSchemaModel"],"sources":["../../src/workflow/workflow.event.ts"],"sourcesContent":["import { defineEvent, defineSchemaModel } from '@contractspec/lib.contracts';\nimport { ScalarTypeEnum } from '@contractspec/lib.schema';\n\n/**\n * Payload for workflow definition events.\n */\nconst WorkflowDefinitionPayload = defineSchemaModel({\n name: 'WorkflowDefinitionEventPayload',\n description: 'Payload for workflow definition events',\n fields: {\n workflowId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },\n key: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },\n name: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },\n version: { type: ScalarTypeEnum.Int_unsecure(), isOptional: false },\n organizationId: {\n type: ScalarTypeEnum.String_unsecure(),\n isOptional: false,\n },\n createdBy: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },\n timestamp: { type: ScalarTypeEnum.DateTime(), isOptional: false },\n },\n});\n\n/**\n * Payload when a step is added.\n */\nconst StepAddedPayload = defineSchemaModel({\n name: 'StepAddedEventPayload',\n description: 'Payload when a step is added',\n fields: {\n stepId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },\n workflowId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },\n stepKey: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },\n stepType: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },\n position: { type: ScalarTypeEnum.Int_unsecure(), isOptional: false },\n timestamp: { type: ScalarTypeEnum.DateTime(), isOptional: false },\n },\n});\n\n/**\n * WorkflowCreatedEvent - A new workflow definition has been created.\n */\nexport const WorkflowCreatedEvent = defineEvent({\n meta: {\n key: 'workflow.definition.created',\n version: 1,\n description: 'A new workflow definition has been created.',\n stability: 'stable',\n owners: ['@workflow-team'],\n tags: ['workflow', 'definition', 'created'],\n },\n payload: WorkflowDefinitionPayload,\n});\n\n/**\n * WorkflowUpdatedEvent - A workflow definition has been updated.\n */\nexport const WorkflowUpdatedEvent = defineEvent({\n meta: {\n key: 'workflow.definition.updated',\n version: 1,\n description: 'A workflow definition has been updated.',\n stability: 'stable',\n owners: ['@workflow-team'],\n tags: ['workflow', 'definition', 'updated'],\n },\n payload: WorkflowDefinitionPayload,\n});\n\n/**\n * WorkflowPublishedEvent - A workflow definition has been published.\n */\nexport const WorkflowPublishedEvent = defineEvent({\n meta: {\n key: 'workflow.definition.published',\n version: 1,\n description: 'A workflow definition has been published and is now active.',\n stability: 'stable',\n owners: ['@workflow-team'],\n tags: ['workflow', 'definition', 'published'],\n },\n payload: WorkflowDefinitionPayload,\n});\n\n/**\n * StepAddedEvent - A step has been added to a workflow definition.\n */\nexport const StepAddedEvent = defineEvent({\n meta: {\n key: 'workflow.step.added',\n version: 1,\n description: 'A step has been added to a workflow definition.',\n stability: 'stable',\n owners: ['@workflow-team'],\n tags: ['workflow', 'step', 'added'],\n },\n payload: StepAddedPayload,\n});\n"],"mappings":";;;;;;;AAMA,MAAM,4BAA4BA,oBAAkB;CAClD,MAAM;CACN,aAAa;CACb,QAAQ;EACN,YAAY;GAAE,MAAM,eAAe,iBAAiB;G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W;EACX,QAAQ,CAAC,iBAAiB;EAC1B,MAAM;GAAC;GAAY;GAAc;GAAY;EAC9C;CACD,SAAS;CACV,CAAC;;;;AAKF,MAAa,iBAAiB,YAAY;CACxC,MAAM;EACJ,KAAK;EACL,SAAS;EACT,aAAa;EACb,WAAW;EACX,QAAQ,CAAC,iBAAiB;EAC1B,MAAM;GAAC;GAAY;GAAQ;GAAQ;EACpC;CACD,SAAS;CACV,CAAC"}
1
+ {"version":3,"file":"workflow.event.js","names":["defineSchemaModel"],"sources":["../../src/workflow/workflow.event.ts"],"sourcesContent":["import { defineEvent, defineSchemaModel } from '@contractspec/lib.contracts';\nimport { ScalarTypeEnum } from '@contractspec/lib.schema';\n\n/**\n * Payload for workflow definition events.\n */\nconst WorkflowDefinitionPayload = defineSchemaModel({\n name: 'WorkflowDefinitionEventPayload',\n description: 'Payload for workflow definition events',\n fields: {\n workflowId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },\n key: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },\n name: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },\n version: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },\n organizationId: {\n type: ScalarTypeEnum.String_unsecure(),\n isOptional: false,\n },\n createdBy: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },\n timestamp: { type: ScalarTypeEnum.DateTime(), isOptional: false },\n },\n});\n\n/**\n * Payload when a step is added.\n */\nconst StepAddedPayload = defineSchemaModel({\n name: 'StepAddedEventPayload',\n description: 'Payload when a step is added',\n fields: {\n stepId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },\n workflowId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },\n stepKey: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },\n stepType: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },\n position: { type: ScalarTypeEnum.Int_unsecure(), isOptional: false },\n timestamp: { type: ScalarTypeEnum.DateTime(), isOptional: false },\n },\n});\n\n/**\n * WorkflowCreatedEvent - A new workflow definition has been created.\n */\nexport const WorkflowCreatedEvent = defineEvent({\n meta: {\n key: 'workflow.definition.created',\n version: '1.0.0',\n description: 'A new workflow definition has been created.',\n stability: 'stable',\n owners: ['@workflow-team'],\n tags: ['workflow', 'definition', 'created'],\n },\n payload: WorkflowDefinitionPayload,\n});\n\n/**\n * WorkflowUpdatedEvent - A workflow definition has been updated.\n */\nexport const WorkflowUpdatedEvent = defineEvent({\n meta: {\n key: 'workflow.definition.updated',\n version: '1.0.0',\n description: 'A workflow definition has been updated.',\n stability: 'stable',\n owners: ['@workflow-team'],\n tags: ['workflow', 'definition', 'updated'],\n },\n payload: WorkflowDefinitionPayload,\n});\n\n/**\n * WorkflowPublishedEvent - A workflow definition has been published.\n */\nexport const WorkflowPublishedEvent = defineEvent({\n meta: {\n key: 'workflow.definition.published',\n version: '1.0.0',\n description: 'A workflow definition has been published and is now active.',\n stability: 'stable',\n owners: ['@workflow-team'],\n tags: ['workflow', 'definition', 'published'],\n },\n payload: WorkflowDefinitionPayload,\n});\n\n/**\n * StepAddedEvent - A step has been added to a workflow definition.\n */\nexport const StepAddedEvent = defineEvent({\n meta: {\n key: 'workflow.step.added',\n version: '1.0.0',\n description: 'A step has been added to a workflow definition.',\n stability: 'stable',\n owners: ['@workflow-team'],\n tags: ['workflow', 'step', 'added'],\n },\n payload: StepAddedPayload,\n});\n"],"mappings":";;;;;;;AAMA,MAAM,4BAA4BA,oBAAkB;CAClD,MAAM;CACN,aAAa;CACb,QAAQ;EACN,YAAY;GAAE,MAAM,eAAe,iBAAiB;GAAE,YAAY;GAAO;EACzE,KAAK;GAAE,MAAM,eAAe,iBAAiB;GAAE,YAAY;GAAO;EAClE,MAAM;GAAE,MAAM,eAAe,iBAAiB;GAAE,YAAY;GAAO;EACnE,SAAS;GAAE,MAAM,eAAe,iBAAiB;GAAE,YAAY;GAAO;EACtE,gBAAgB;GACd,MAAM,eAAe,iBAAiB;GACtC,YAAY;GACb;EACD,WAAW;GAAE,MAAM,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;CACV,CAAC"}
@@ -9,7 +9,7 @@ async function handleCreateWorkflow(input, context) {
9
9
  key: input.key,
10
10
  name: input.name,
11
11
  description: input.description,
12
- version: 1,
12
+ version: "1.0.0",
13
13
  status: "DRAFT",
14
14
  triggerType: input.triggerType ?? "MANUAL",
15
15
  featureFlagKey: input.featureFlagKey,
@@ -1 +1 @@
1
- {"version":3,"file":"workflow.handler.js","names":["workflow: WorkflowDefinitionRecord","step: WorkflowStepRecord"],"sources":["../../src/workflow/workflow.handler.ts"],"sourcesContent":["/**\n * Workflow definition handlers.\n */\n\nimport type {\n WorkflowDefinitionRecord,\n WorkflowStepRecord,\n HandlerContext,\n} from '../shared/types';\nimport { mockDataStore } from '../shared/mock-data';\n\nexport async function handleCreateWorkflow(\n input: {\n name: string;\n key: string;\n description?: string;\n triggerType?: 'MANUAL' | 'EVENT' | 'SCHEDULED' | 'API';\n featureFlagKey?: string;\n },\n context: HandlerContext\n): Promise<WorkflowDefinitionRecord> {\n const id = `wf_${Date.now()}`;\n const now = new Date();\n\n const workflow: WorkflowDefinitionRecord = {\n id,\n key: input.key,\n name: input.name,\n description: input.description,\n version: 1,\n status: 'DRAFT',\n triggerType: input.triggerType ?? 'MANUAL',\n featureFlagKey: input.featureFlagKey,\n organizationId: context.organizationId,\n createdBy: context.userId,\n createdAt: now,\n updatedAt: now,\n };\n\n mockDataStore.workflows.set(id, workflow);\n return workflow;\n}\n\nexport async function handleAddStep(\n input: {\n workflowId: string;\n key: string;\n name: string;\n description?: string;\n type:\n | 'START'\n | 'APPROVAL'\n | 'TASK'\n | 'CONDITION'\n | 'PARALLEL'\n | 'WAIT'\n | 'ACTION'\n | 'END';\n position?: number;\n transitions: Record<string, string>;\n approvalMode?: 'ANY' | 'ALL' | 'MAJORITY' | 'SEQUENTIAL';\n approverRoles?: string[];\n timeoutSeconds?: number;\n },\n _context: HandlerContext\n): Promise<WorkflowStepRecord> {\n const id = `step_${Date.now()}`;\n const now = new Date();\n\n // Calculate position\n const existingSteps = Array.from(mockDataStore.steps.values()).filter(\n (s) => s.workflowDefinitionId === input.workflowId\n );\n const position = input.position ?? existingSteps.length;\n\n const step: WorkflowStepRecord = {\n id,\n workflowDefinitionId: input.workflowId,\n key: input.key,\n name: input.name,\n description: input.description,\n type: input.type,\n position,\n transitions: input.transitions,\n approvalMode: input.approvalMode,\n approverRoles: input.approverRoles ?? [],\n timeoutSeconds: input.timeoutSeconds,\n createdAt: now,\n updatedAt: now,\n };\n\n mockDataStore.steps.set(id, step);\n\n // Update workflow with initial step if this is the first step\n if (existingSteps.length === 0 || input.type === 'START') {\n const workflow = mockDataStore.workflows.get(input.workflowId);\n if (workflow) {\n workflow.initialStepId = id;\n workflow.updatedAt = now;\n }\n }\n\n return step;\n}\n\nexport async function handlePublishWorkflow(\n input: { workflowId: string },\n _context: HandlerContext\n): Promise<WorkflowDefinitionRecord> {\n const workflow = mockDataStore.workflows.get(input.workflowId);\n if (!workflow) {\n throw new Error(`Workflow ${input.workflowId} not found`);\n }\n\n const now = new Date();\n workflow.status = 'ACTIVE';\n workflow.publishedAt = now;\n workflow.updatedAt = now;\n\n return workflow;\n}\n"],"mappings":";;;AAWA,eAAsB,qBACpB,OAOA,SACmC;CACnC,MAAM,KAAK,MAAM,KAAK,KAAK;CAC3B,MAAM,sBAAM,IAAI,MAAM;CAEtB,MAAMA,WAAqC;EACzC;EACA,KAAK,MAAM;EACX,MAAM,MAAM;EACZ,aAAa,MAAM;EACnB,SAAS;EACT,QAAQ;EACR,aAAa,MAAM,eAAe;EAClC,gBAAgB,MAAM;EACtB,gBAAgB,QAAQ;EACxB,WAAW,QAAQ;EACnB,WAAW;EACX,WAAW;EACZ;AAED,eAAc,UAAU,IAAI,IAAI,SAAS;AACzC,QAAO;;AAGT,eAAsB,cACpB,OAoBA,UAC6B;CAC7B,MAAM,KAAK,QAAQ,KAAK,KAAK;CAC7B,MAAM,sBAAM,IAAI,MAAM;CAGtB,MAAM,gBAAgB,MAAM,KAAK,cAAc,MAAM,QAAQ,CAAC,CAAC,QAC5D,MAAM,EAAE,yBAAyB,MAAM,WACzC;CACD,MAAM,WAAW,MAAM,YAAY,cAAc;CAEjD,MAAMC,OAA2B;EAC/B;EACA,sBAAsB,MAAM;EAC5B,KAAK,MAAM;EACX,MAAM,MAAM;EACZ,aAAa,MAAM;EACnB,MAAM,MAAM;EACZ;EACA,aAAa,MAAM;EACnB,cAAc,MAAM;EACpB,eAAe,MAAM,iBAAiB,EAAE;EACxC,gBAAgB,MAAM;EACtB,WAAW;EACX,WAAW;EACZ;AAED,eAAc,MAAM,IAAI,IAAI,KAAK;AAGjC,KAAI,cAAc,WAAW,KAAK,MAAM,SAAS,SAAS;EACxD,MAAM,WAAW,cAAc,UAAU,IAAI,MAAM,WAAW;AAC9D,MAAI,UAAU;AACZ,YAAS,gBAAgB;AACzB,YAAS,YAAY;;;AAIzB,QAAO;;AAGT,eAAsB,sBACpB,OACA,UACmC;CACnC,MAAM,WAAW,cAAc,UAAU,IAAI,MAAM,WAAW;AAC9D,KAAI,CAAC,SACH,OAAM,IAAI,MAAM,YAAY,MAAM,WAAW,YAAY;CAG3D,MAAM,sBAAM,IAAI,MAAM;AACtB,UAAS,SAAS;AAClB,UAAS,cAAc;AACvB,UAAS,YAAY;AAErB,QAAO"}
1
+ {"version":3,"file":"workflow.handler.js","names":["workflow: WorkflowDefinitionRecord","step: WorkflowStepRecord"],"sources":["../../src/workflow/workflow.handler.ts"],"sourcesContent":["/**\n * Workflow definition handlers.\n */\n\nimport type {\n WorkflowDefinitionRecord,\n WorkflowStepRecord,\n HandlerContext,\n} from '../shared/types';\nimport { mockDataStore } from '../shared/mock-data';\n\nexport async function handleCreateWorkflow(\n input: {\n name: string;\n key: string;\n description?: string;\n triggerType?: 'MANUAL' | 'EVENT' | 'SCHEDULED' | 'API';\n featureFlagKey?: string;\n },\n context: HandlerContext\n): Promise<WorkflowDefinitionRecord> {\n const id = `wf_${Date.now()}`;\n const now = new Date();\n\n const workflow: WorkflowDefinitionRecord = {\n id,\n key: input.key,\n name: input.name,\n description: input.description,\n version: '1.0.0',\n status: 'DRAFT',\n triggerType: input.triggerType ?? 'MANUAL',\n featureFlagKey: input.featureFlagKey,\n organizationId: context.organizationId,\n createdBy: context.userId,\n createdAt: now,\n updatedAt: now,\n };\n\n mockDataStore.workflows.set(id, workflow);\n return workflow;\n}\n\nexport async function handleAddStep(\n input: {\n workflowId: string;\n key: string;\n name: string;\n description?: string;\n type:\n | 'START'\n | 'APPROVAL'\n | 'TASK'\n | 'CONDITION'\n | 'PARALLEL'\n | 'WAIT'\n | 'ACTION'\n | 'END';\n position?: number;\n transitions: Record<string, string>;\n approvalMode?: 'ANY' | 'ALL' | 'MAJORITY' | 'SEQUENTIAL';\n approverRoles?: string[];\n timeoutSeconds?: number;\n },\n _context: HandlerContext\n): Promise<WorkflowStepRecord> {\n const id = `step_${Date.now()}`;\n const now = new Date();\n\n // Calculate position\n const existingSteps = Array.from(mockDataStore.steps.values()).filter(\n (s) => s.workflowDefinitionId === input.workflowId\n );\n const position = input.position ?? existingSteps.length;\n\n const step: WorkflowStepRecord = {\n id,\n workflowDefinitionId: input.workflowId,\n key: input.key,\n name: input.name,\n description: input.description,\n type: input.type,\n position,\n transitions: input.transitions,\n approvalMode: input.approvalMode,\n approverRoles: input.approverRoles ?? [],\n timeoutSeconds: input.timeoutSeconds,\n createdAt: now,\n updatedAt: now,\n };\n\n mockDataStore.steps.set(id, step);\n\n // Update workflow with initial step if this is the first step\n if (existingSteps.length === 0 || input.type === 'START') {\n const workflow = mockDataStore.workflows.get(input.workflowId);\n if (workflow) {\n workflow.initialStepId = id;\n workflow.updatedAt = now;\n }\n }\n\n return step;\n}\n\nexport async function handlePublishWorkflow(\n input: { workflowId: string },\n _context: HandlerContext\n): Promise<WorkflowDefinitionRecord> {\n const workflow = mockDataStore.workflows.get(input.workflowId);\n if (!workflow) {\n throw new Error(`Workflow ${input.workflowId} not found`);\n }\n\n const now = new Date();\n workflow.status = 'ACTIVE';\n workflow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MAAM,YAAY,MAAM,WAAW,YAAY;CAG3D,MAAM,sBAAM,IAAI,MAAM;AACtB,UAAS,SAAS;AAClB,UAAS,cAAc;AACvB,UAAS,YAAY;AAErB,QAAO"}
@@ -52,7 +52,7 @@ declare const CreateWorkflowContract: _contractspec_lib_contracts28.OperationSpe
52
52
  isOptional: true;
53
53
  };
54
54
  version: {
55
- type: _contractspec_lib_schema936.FieldType<number, number>;
55
+ type: _contractspec_lib_schema936.FieldType<string, string>;
56
56
  isOptional: false;
57
57
  };
58
58
  status: {
@@ -128,7 +128,7 @@ declare const CreateWorkflowContract: _contractspec_lib_contracts28.OperationSpe
128
128
  };
129
129
  }>, {
130
130
  key: string;
131
- version: number;
131
+ version: string;
132
132
  when: string;
133
133
  payload: _contractspec_lib_schema936.SchemaModel<{
134
134
  id: {
@@ -148,7 +148,7 @@ declare const CreateWorkflowContract: _contractspec_lib_contracts28.OperationSpe
148
148
  isOptional: true;
149
149
  };
150
150
  version: {
151
- type: _contractspec_lib_schema936.FieldType<number, number>;
151
+ type: _contractspec_lib_schema936.FieldType<string, string>;
152
152
  isOptional: false;
153
153
  };
154
154
  status: {
@@ -274,7 +274,7 @@ declare const UpdateWorkflowContract: _contractspec_lib_contracts28.OperationSpe
274
274
  isOptional: true;
275
275
  };
276
276
  version: {
277
- type: _contractspec_lib_schema936.FieldType<number, number>;
277
+ type: _contractspec_lib_schema936.FieldType<string, string>;
278
278
  isOptional: false;
279
279
  };
280
280
  status: {
@@ -350,7 +350,7 @@ declare const UpdateWorkflowContract: _contractspec_lib_contracts28.OperationSpe
350
350
  };
351
351
  }>, {
352
352
  key: string;
353
- version: number;
353
+ version: string;
354
354
  when: string;
355
355
  payload: _contractspec_lib_schema936.SchemaModel<{
356
356
  id: {
@@ -370,7 +370,7 @@ declare const UpdateWorkflowContract: _contractspec_lib_contracts28.OperationSpe
370
370
  isOptional: true;
371
371
  };
372
372
  version: {
373
- type: _contractspec_lib_schema936.FieldType<number, number>;
373
+ type: _contractspec_lib_schema936.FieldType<string, string>;
374
374
  isOptional: false;
375
375
  };
376
376
  status: {
@@ -540,7 +540,7 @@ declare const AddStepContract: _contractspec_lib_contracts28.OperationSpec<_cont
540
540
  };
541
541
  }>, {
542
542
  key: string;
543
- version: number;
543
+ version: string;
544
544
  when: string;
545
545
  payload: _contractspec_lib_schema936.SchemaModel<{
546
546
  id: {
@@ -608,7 +608,7 @@ declare const PublishWorkflowContract: _contractspec_lib_contracts28.OperationSp
608
608
  isOptional: true;
609
609
  };
610
610
  version: {
611
- type: _contractspec_lib_schema936.FieldType<number, number>;
611
+ type: _contractspec_lib_schema936.FieldType<string, string>;
612
612
  isOptional: false;
613
613
  };
614
614
  status: {
@@ -684,7 +684,7 @@ declare const PublishWorkflowContract: _contractspec_lib_contracts28.OperationSp
684
684
  };
685
685
  }>, {
686
686
  key: string;
687
- version: number;
687
+ version: string;
688
688
  when: string;
689
689
  payload: _contractspec_lib_schema936.SchemaModel<{
690
690
  id: {
@@ -704,7 +704,7 @@ declare const PublishWorkflowContract: _contractspec_lib_contracts28.OperationSp
704
704
  isOptional: true;
705
705
  };
706
706
  version: {
707
- type: _contractspec_lib_schema936.FieldType<number, number>;
707
+ type: _contractspec_lib_schema936.FieldType<string, string>;
708
708
  isOptional: false;
709
709
  };
710
710
  status: {
@@ -822,7 +822,7 @@ declare const ListWorkflowsContract: _contractspec_lib_contracts28.OperationSpec
822
822
  isOptional: true;
823
823
  };
824
824
  version: {
825
- type: _contractspec_lib_schema936.FieldType<number, number>;
825
+ type: _contractspec_lib_schema936.FieldType<string, string>;
826
826
  isOptional: false;
827
827
  };
828
828
  status: {
@@ -931,7 +931,7 @@ declare const GetWorkflowContract: _contractspec_lib_contracts28.OperationSpec<_
931
931
  isOptional: true;
932
932
  };
933
933
  version: {
934
- type: _contractspec_lib_schema936.FieldType<number, number>;
934
+ type: _contractspec_lib_schema936.FieldType<string, string>;
935
935
  isOptional: false;
936
936
  };
937
937
  status: {
@@ -11,7 +11,7 @@ const OWNERS = ["@example.workflow-system"];
11
11
  const CreateWorkflowContract = defineCommand({
12
12
  meta: {
13
13
  key: "workflow.definition.create",
14
- version: 1,
14
+ version: "1.0.0",
15
15
  stability: "stable",
16
16
  owners: [...OWNERS],
17
17
  tags: [
@@ -31,7 +31,7 @@ const CreateWorkflowContract = defineCommand({
31
31
  sideEffects: {
32
32
  emits: [{
33
33
  key: "workflow.definition.created",
34
- version: 1,
34
+ version: "1.0.0",
35
35
  when: "Workflow is created",
36
36
  payload: WorkflowDefinitionModel
37
37
  }],
@@ -64,7 +64,7 @@ const CreateWorkflowContract = defineCommand({
64
64
  const UpdateWorkflowContract = defineCommand({
65
65
  meta: {
66
66
  key: "workflow.definition.update",
67
- version: 1,
67
+ version: "1.0.0",
68
68
  stability: "stable",
69
69
  owners: [...OWNERS],
70
70
  tags: [
@@ -84,7 +84,7 @@ const UpdateWorkflowContract = defineCommand({
84
84
  sideEffects: {
85
85
  emits: [{
86
86
  key: "workflow.definition.updated",
87
- version: 1,
87
+ version: "1.0.0",
88
88
  when: "Workflow is updated",
89
89
  payload: WorkflowDefinitionModel
90
90
  }],
@@ -116,7 +116,7 @@ const UpdateWorkflowContract = defineCommand({
116
116
  const AddStepContract = defineCommand({
117
117
  meta: {
118
118
  key: "workflow.step.add",
119
- version: 1,
119
+ version: "1.0.0",
120
120
  stability: "stable",
121
121
  owners: [...OWNERS],
122
122
  tags: [
@@ -136,7 +136,7 @@ const AddStepContract = defineCommand({
136
136
  sideEffects: {
137
137
  emits: [{
138
138
  key: "workflow.step.added",
139
- version: 1,
139
+ version: "1.0.0",
140
140
  when: "Step is added",
141
141
  payload: WorkflowStepModel
142
142
  }],
@@ -169,7 +169,7 @@ const AddStepContract = defineCommand({
169
169
  const PublishWorkflowContract = defineCommand({
170
170
  meta: {
171
171
  key: "workflow.definition.publish",
172
- version: 1,
172
+ version: "1.0.0",
173
173
  stability: "stable",
174
174
  owners: [...OWNERS],
175
175
  tags: [
@@ -195,7 +195,7 @@ const PublishWorkflowContract = defineCommand({
195
195
  sideEffects: {
196
196
  emits: [{
197
197
  key: "workflow.definition.published",
198
- version: 1,
198
+ version: "1.0.0",
199
199
  when: "Workflow is published",
200
200
  payload: WorkflowDefinitionModel
201
201
  }],
@@ -224,7 +224,7 @@ const PublishWorkflowContract = defineCommand({
224
224
  const ListWorkflowsContract = defineQuery({
225
225
  meta: {
226
226
  key: "workflow.definition.list",
227
- version: 1,
227
+ version: "1.0.0",
228
228
  stability: "stable",
229
229
  owners: [...OWNERS],
230
230
  tags: [
@@ -299,7 +299,7 @@ const ListWorkflowsContract = defineQuery({
299
299
  const GetWorkflowContract = defineQuery({
300
300
  meta: {
301
301
  key: "workflow.definition.get",
302
- version: 1,
302
+ version: "1.0.0",
303
303
  stability: "stable",
304
304
  owners: [...OWNERS],
305
305
  tags: [
@@ -1 +1 @@
1
- {"version":3,"file":"workflow.operations.js","names":[],"sources":["../../src/workflow/workflow.operations.ts"],"sourcesContent":["import {\n defineCommand,\n defineQuery,\n} from '@contractspec/lib.contracts/operations';\nimport { defineSchemaModel, ScalarTypeEnum } from '@contractspec/lib.schema';\nimport { WorkflowStatusEnum } from './workflow.enum';\nimport {\n AddStepInputModel,\n CreateWorkflowInputModel,\n UpdateWorkflowInputModel,\n WorkflowDefinitionModel,\n WorkflowStepModel,\n} from './workflow.schema';\n\nconst OWNERS = ['@example.workflow-system'] as const;\n\n/**\n * Create a new workflow definition.\n */\nexport const CreateWorkflowContract = defineCommand({\n meta: {\n key: 'workflow.definition.create',\n version: 1,\n stability: 'stable',\n owners: [...OWNERS],\n tags: ['workflow', 'definition', 'create'],\n description: 'Create a new workflow definition.',\n goal: 'Allow users to define new workflow blueprints.',\n context: 'Workflow designer, admin panel.',\n },\n io: {\n input: CreateWorkflowInputModel,\n output: WorkflowDefinitionModel,\n },\n policy: { auth: 'user' },\n sideEffects: {\n emits: [\n {\n key: 'workflow.definition.created',\n version: 1,\n when: 'Workflow is created',\n payload: WorkflowDefinitionModel,\n },\n ],\n audit: ['workflow.definition.created'],\n },\n acceptance: {\n scenarios: [\n {\n key: 'create-workflow-happy-path',\n given: ['User is admin'],\n when: ['User creates new workflow definition'],\n then: [\n 'Definition is created',\n 'WorkflowDefinitionCreated event is emitted',\n ],\n },\n ],\n examples: [\n {\n key: 'create-onboarding',\n input: {\n key: 'onboarding-v1',\n name: 'Employee Onboarding',\n version: '1.0.0',\n },\n output: { id: 'def-123', status: 'draft' },\n },\n ],\n },\n});\n\n/**\n * Update an existing workflow definition.\n */\nexport const UpdateWorkflowContract = defineCommand({\n meta: {\n key: 'workflow.definition.update',\n version: 1,\n stability: 'stable',\n owners: [...OWNERS],\n tags: ['workflow', 'definition', 'update'],\n description: 'Update an existing workflow definition.',\n goal: 'Allow users to modify workflow blueprints.',\n context: 'Workflow designer.',\n },\n io: {\n input: UpdateWorkflowInputModel,\n output: WorkflowDefinitionModel,\n },\n policy: { auth: 'user' },\n sideEffects: {\n emits: [\n {\n key: 'workflow.definition.updated',\n version: 1,\n when: 'Workflow is updated',\n payload: WorkflowDefinitionModel,\n },\n ],\n audit: ['workflow.definition.updated'],\n },\n acceptance: {\n scenarios: [\n {\n key: 'update-workflow-happy-path',\n given: ['Workflow definition exists'],\n when: ['User updates definition'],\n then: [\n 'Definition is updated',\n 'WorkflowDefinitionUpdated event is emitted',\n ],\n },\n ],\n examples: [\n {\n key: 'update-name',\n input: { workflowId: 'def-123', name: 'New Employee Onboarding' },\n output: { id: 'def-123', name: 'New Employee Onboarding' },\n },\n ],\n },\n});\n\n/**\n * Add a step to a workflow definition.\n */\nexport const AddStepContract = defineCommand({\n meta: {\n key: 'workflow.step.add',\n version: 1,\n stability: 'stable',\n owners: [...OWNERS],\n tags: ['workflow', 'step', 'add'],\n description: 'Add a step to a workflow definition.',\n goal: 'Build workflow structure step by step.',\n context: 'Workflow designer.',\n },\n io: {\n input: AddStepInputModel,\n output: WorkflowStepModel,\n },\n policy: { auth: 'user' },\n sideEffects: {\n emits: [\n {\n key: 'workflow.step.added',\n version: 1,\n when: 'Step is added',\n payload: WorkflowStepModel,\n },\n ],\n audit: ['workflow.step.added'],\n },\n acceptance: {\n scenarios: [\n {\n key: 'add-step-happy-path',\n given: ['Workflow definition exists'],\n when: ['User adds a step'],\n then: ['Step is added', 'StepAdded event is emitted'],\n },\n ],\n examples: [\n {\n key: 'add-approval-step',\n input: {\n workflowId: 'def-123',\n stepKey: 'approve-contract',\n type: 'approval',\n },\n output: { id: 'step-456', key: 'approve-contract' },\n },\n ],\n },\n});\n\n/**\n * Publish a workflow definition (make it active).\n */\nexport const PublishWorkflowContract = defineCommand({\n meta: {\n key: 'workflow.definition.publish',\n version: 1,\n stability: 'stable',\n owners: [...OWNERS],\n tags: ['workflow', 'definition', 'publish'],\n description: 'Publish a workflow definition to make it available for use.',\n goal: 'Activate workflow for production use.',\n context: 'Workflow designer, deployment.',\n },\n io: {\n input: defineSchemaModel({\n name: 'PublishWorkflowInput',\n fields: {\n workflowId: {\n type: ScalarTypeEnum.String_unsecure(),\n isOptional: false,\n },\n },\n }),\n output: WorkflowDefinitionModel,\n },\n policy: { auth: 'user' },\n sideEffects: {\n emits: [\n {\n key: 'workflow.definition.published',\n version: 1,\n when: 'Workflow is published',\n payload: WorkflowDefinitionModel,\n },\n ],\n audit: ['workflow.definition.published'],\n },\n acceptance: {\n scenarios: [\n {\n key: 'publish-workflow-happy-path',\n given: ['Workflow definition is valid'],\n when: ['User publishes workflow'],\n then: ['Workflow becomes active', 'WorkflowPublished event is emitted'],\n },\n ],\n examples: [\n {\n key: 'publish-onboarding',\n input: { workflowId: 'def-123' },\n output: { id: 'def-123', status: 'published' },\n },\n ],\n },\n});\n\n/**\n * List workflow definitions.\n */\nexport const ListWorkflowsContract = defineQuery({\n meta: {\n key: 'workflow.definition.list',\n version: 1,\n stability: 'stable',\n owners: [...OWNERS],\n tags: ['workflow', 'definition', 'list'],\n description: 'List workflow definitions with filtering.',\n goal: 'Browse and search available workflows.',\n context: 'Workflow list, search.',\n },\n io: {\n input: defineSchemaModel({\n name: 'ListWorkflowsInput',\n fields: {\n status: { type: WorkflowStatusEnum, isOptional: true },\n search: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },\n limit: {\n type: ScalarTypeEnum.Int_unsecure(),\n isOptional: true,\n defaultValue: 20,\n },\n offset: {\n type: ScalarTypeEnum.Int_unsecure(),\n isOptional: true,\n defaultValue: 0,\n },\n },\n }),\n output: defineSchemaModel({\n name: 'ListWorkflowsOutput',\n fields: {\n workflows: {\n type: WorkflowDefinitionModel,\n isArray: true,\n isOptional: false,\n },\n total: { type: ScalarTypeEnum.Int_unsecure(), isOptional: false },\n },\n }),\n },\n policy: { auth: 'user' },\n acceptance: {\n scenarios: [\n {\n key: 'list-workflows-happy-path',\n given: ['Workflow definitions exist'],\n when: ['User lists workflows'],\n then: ['List of workflows is returned'],\n },\n ],\n examples: [\n {\n key: 'list-all',\n input: { limit: 10 },\n output: { workflows: [], total: 5 },\n },\n ],\n },\n});\n\n/**\n * Get a single workflow definition with steps.\n */\nexport const GetWorkflowContract = defineQuery({\n meta: {\n key: 'workflow.definition.get',\n version: 1,\n stability: 'stable',\n owners: [...OWNERS],\n tags: ['workflow', 'definition', 'get'],\n description: 'Get a workflow definition with all steps.',\n goal: 'View workflow details.',\n context: 'Workflow designer, detail view.',\n },\n io: {\n input: defineSchemaModel({\n name: 'GetWorkflowInput',\n fields: {\n workflowId: {\n type: ScalarTypeEnum.String_unsecure(),\n isOptional: false,\n },\n },\n }),\n output: WorkflowDefinitionModel,\n },\n policy: { auth: 'user' },\n acceptance: {\n scenarios: [\n {\n key: 'get-workflow-happy-path',\n given: ['Workflow definition exists'],\n when: ['User requests workflow details'],\n then: ['Workflow details are returned'],\n },\n ],\n examples: [\n {\n key: 'get-details',\n input: { workflowId: 'def-123' },\n output: { id: 'def-123', name: 'Employee Onboarding' },\n },\n ],\n },\n});\n"],"mappings":";;;;;;AAcA,MAAM,SAAS,CAAC,2BAA2B;;;;AAK3C,MAAa,yBAAyB,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;GAAM;EACvC,aAAa;EACb,MAAM;EACN,SAAS;EACV;CACD,IAAI;EACF,OAAO,kBAAkB;GACvB,MAAM;GACN,QAAQ,EACN,YAAY;IACV,MAAM,eAAe,iBAAiB;IACtC,YAAY;IACb,EACF;GACF,CAAC;EACF,QAAQ;EACT;CACD,QAAQ,EAAE,MAAM,QAAQ;CACxB,YAAY;EACV,WAAW,CACT;GACE,KAAK;GACL,OAAO,CAAC,6BAA6B;GACrC,MAAM,CAAC,iCAAiC;GACxC,MAAM,CAAC,gCAAgC;GACxC,CACF;EACD,UAAU,CACR;GACE,KAAK;GACL,OAAO,EAAE,YAAY,WAAW;GAChC,QAAQ;IAAE,IAAI;IAAW,MAAM;IAAuB;GACvD,CACF;EACF;CACF,CAAC"}
1
+ {"version":3,"file":"workflow.operations.js","names":[],"sources":["../../src/workflow/workflow.operations.ts"],"sourcesContent":["import {\n defineCommand,\n defineQuery,\n} from '@contractspec/lib.contracts/operations';\nimport { defineSchemaModel, ScalarTypeEnum } from '@contractspec/lib.schema';\nimport { WorkflowStatusEnum } from './workflow.enum';\nimport {\n AddStepInputModel,\n CreateWorkflowInputModel,\n UpdateWorkflowInputModel,\n WorkflowDefinitionModel,\n WorkflowStepModel,\n} from './workflow.schema';\n\nconst OWNERS = ['@example.workflow-system'] as const;\n\n/**\n * Create a new workflow definition.\n */\nexport const CreateWorkflowContract = defineCommand({\n meta: {\n key: 'workflow.definition.create',\n version: '1.0.0',\n stability: 'stable',\n owners: [...OWNERS],\n tags: ['workflow', 'definition', 'create'],\n description: 'Create a new workflow definition.',\n goal: 'Allow users to define new workflow blueprints.',\n context: 'Workflow designer, admin panel.',\n },\n io: {\n input: CreateWorkflowInputModel,\n output: WorkflowDefinitionModel,\n },\n policy: { auth: 'user' },\n sideEffects: {\n emits: [\n {\n key: 'workflow.definition.created',\n version: '1.0.0',\n when: 'Workflow is created',\n payload: WorkflowDefinitionModel,\n },\n ],\n audit: ['workflow.definition.created'],\n },\n acceptance: {\n scenarios: [\n {\n key: 'create-workflow-happy-path',\n given: ['User is admin'],\n when: ['User creates new workflow definition'],\n then: [\n 'Definition is created',\n 'WorkflowDefinitionCreated event is emitted',\n ],\n },\n ],\n examples: [\n {\n key: 'create-onboarding',\n input: {\n key: 'onboarding-v1',\n name: 'Employee Onboarding',\n version: '1.0.0',\n },\n output: { id: 'def-123', status: 'draft' },\n },\n ],\n },\n});\n\n/**\n * Update an existing workflow definition.\n */\nexport const UpdateWorkflowContract = defineCommand({\n meta: {\n key: 'workflow.definition.update',\n version: '1.0.0',\n stability: 'stable',\n owners: [...OWNERS],\n tags: ['workflow', 'definition', 'update'],\n description: 'Update an existing workflow definition.',\n goal: 'Allow users to modify workflow blueprints.',\n context: 'Workflow designer.',\n },\n io: {\n input: UpdateWorkflowInputModel,\n output: WorkflowDefinitionModel,\n },\n policy: { auth: 'user' },\n sideEffects: {\n emits: [\n {\n key: 'workflow.definition.updated',\n version: '1.0.0',\n when: 'Workflow is updated',\n payload: WorkflowDefinitionModel,\n },\n ],\n audit: ['workflow.definition.updated'],\n },\n acceptance: {\n scenarios: [\n {\n key: 'update-workflow-happy-path',\n given: ['Workflow definition exists'],\n when: ['User updates definition'],\n then: [\n 'Definition is updated',\n 'WorkflowDefinitionUpdated event is emitted',\n ],\n },\n ],\n examples: [\n {\n key: 'update-name',\n input: { workflowId: 'def-123', name: 'New Employee Onboarding' },\n output: { id: 'def-123', name: 'New Employee Onboarding' },\n },\n ],\n },\n});\n\n/**\n * Add a step to a workflow definition.\n */\nexport const AddStepContract = defineCommand({\n meta: {\n key: 'workflow.step.add',\n version: '1.0.0',\n stability: 'stable',\n owners: [...OWNERS],\n tags: ['workflow', 'step', 'add'],\n description: 'Add a step to a workflow definition.',\n goal: 'Build workflow structure step by step.',\n context: 'Workflow designer.',\n },\n io: {\n input: AddStepInputModel,\n output: WorkflowStepModel,\n },\n policy: { auth: 'user' },\n sideEffects: {\n emits: [\n {\n key: 'workflow.step.added',\n version: '1.0.0',\n when: 'Step is added',\n payload: WorkflowStepModel,\n },\n ],\n audit: ['workflow.step.added'],\n },\n acceptance: {\n scenarios: [\n {\n key: 'add-step-happy-path',\n given: ['Workflow definition exists'],\n when: ['User adds a step'],\n then: ['Step is added', 'StepAdded event is emitted'],\n },\n ],\n examples: [\n {\n key: 'add-approval-step',\n input: {\n workflowId: 'def-123',\n stepKey: 'approve-contract',\n type: 'approval',\n },\n output: { id: 'step-456', key: 'approve-contract' },\n },\n ],\n },\n});\n\n/**\n * Publish a workflow definition (make it active).\n */\nexport const PublishWorkflowContract = defineCommand({\n meta: {\n key: 'workflow.definition.publish',\n version: '1.0.0',\n stability: 'stable',\n owners: [...OWNERS],\n tags: ['workflow', 'definition', 'publish'],\n description: 'Publish a workflow definition to make it available for use.',\n goal: 'Activate workflow for production use.',\n context: 'Workflow designer, deployment.',\n },\n io: {\n input: defineSchemaModel({\n name: 'PublishWorkflowInput',\n fields: {\n workflowId: {\n type: ScalarTypeEnum.String_unsecure(),\n isOptional: false,\n },\n },\n }),\n output: WorkflowDefinitionModel,\n },\n policy: { auth: 'user' },\n sideEffects: {\n emits: [\n {\n key: 'workflow.definition.published',\n version: '1.0.0',\n when: 'Workflow is published',\n payload: WorkflowDefinitionModel,\n },\n ],\n audit: ['workflow.definition.published'],\n },\n acceptance: {\n scenarios: [\n {\n key: 'publish-workflow-happy-path',\n given: ['Workflow definition is valid'],\n when: ['User publishes workflow'],\n then: ['Workflow becomes active', 'WorkflowPublished event is emitted'],\n },\n ],\n examples: [\n {\n key: 'publish-onboarding',\n input: { workflowId: 'def-123' },\n output: { id: 'def-123', status: 'published' },\n },\n ],\n },\n});\n\n/**\n * List workflow definitions.\n */\nexport const ListWorkflowsContract = defineQuery({\n meta: {\n key: 'workflow.definition.list',\n version: '1.0.0',\n stability: 'stable',\n owners: [...OWNERS],\n tags: ['workflow', 'definition', 'list'],\n description: 'List workflow definitions with filtering.',\n goal: 'Browse and search available workflows.',\n context: 'Workflow list, search.',\n },\n io: {\n input: defineSchemaModel({\n name: 'ListWorkflowsInput',\n fields: {\n status: { type: WorkflowStatusEnum, isOptional: true },\n search: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },\n limit: {\n type: ScalarTypeEnum.Int_unsecure(),\n isOptional: true,\n defaultValue: 20,\n },\n offset: {\n type: ScalarTypeEnum.Int_unsecure(),\n isOptional: true,\n defaultValue: 0,\n },\n },\n }),\n output: defineSchemaModel({\n name: 'ListWorkflowsOutput',\n fields: {\n workflows: {\n type: WorkflowDefinitionModel,\n isArray: true,\n isOptional: false,\n },\n total: { type: ScalarTypeEnum.Int_unsecure(), isOptional: false },\n },\n }),\n },\n policy: { auth: 'user' },\n acceptance: {\n scenarios: [\n {\n key: 'list-workflows-happy-path',\n given: ['Workflow definitions exist'],\n when: ['User lists workflows'],\n then: ['List of workflows is returned'],\n },\n ],\n examples: [\n {\n key: 'list-all',\n input: { limit: 10 },\n output: { workflows: [], total: 5 },\n },\n ],\n },\n});\n\n/**\n * Get a single workflow definition with steps.\n */\nexport const GetWorkflowContract = defineQuery({\n meta: {\n key: 'workflow.definition.get',\n version: '1.0.0',\n stability: 'stable',\n owners: [...OWNERS],\n tags: ['workflow', 'definition', 'get'],\n description: 'Get a workflow definition with all steps.',\n goal: 'View workflow details.',\n context: 'Workflow designer, detail view.',\n },\n io: {\n input: defineSchemaModel({\n name: 'GetWorkflowInput',\n fields: {\n workflowId: {\n type: ScalarTypeEnum.String_unsecure(),\n isOptional: false,\n },\n },\n }),\n output: WorkflowDefinitionModel,\n },\n policy: { auth: 'user' },\n acceptance: {\n scenarios: [\n {\n key: 'get-workflow-happy-path',\n given: ['Workflow definition exists'],\n when: ['User requests workflow details'],\n then: ['Workflow details are returned'],\n },\n ],\n examples: [\n {\n key: 'get-details',\n input: { workflowId: 'def-123' },\n output: { id: 'def-123', name: 'Employee Onboarding' },\n },\n ],\n },\n});\n"],"mappings":";;;;;;AAcA,MAAM,SAAS,CAAC,2BAA2B;;;;AAK3C,MAAa,yBAAyB,cAA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AM;EACvC,aAAa;EACb,MAAM;EACN,SAAS;EACV;CACD,IAAI;EACF,OAAO,kBAAkB;GACvB,MAAM;GACN,QAAQ,EACN,YAAY;IACV,MAAM,eAAe,iBAAiB;IACtC,YAAY;IACb,EACF;GACF,CAAC;EACF,QAAQ;EACT;CACD,QAAQ,EAAE,MAAM,QAAQ;CACxB,YAAY;EACV,WAAW,CACT;GACE,KAAK;GACL,OAAO,CAAC,6BAA6B;GACrC,MAAM,CAAC,iCAAiC;GACxC,MAAM,CAAC,gCAAgC;GACxC,CACF;EACD,UAAU,CACR;GACE,KAAK;GACL,OAAO,EAAE,YAAY,WAAW;GAChC,QAAQ;IAAE,IAAI;IAAW,MAAM;IAAuB;GACvD,CACF;EACF;CACF,CAAC"}
@@ -64,7 +64,7 @@ declare const WorkflowDefinitionModel: _contractspec_lib_schema0.SchemaModel<{
64
64
  isOptional: true;
65
65
  };
66
66
  version: {
67
- type: _contractspec_lib_schema0.FieldType<number, number>;
67
+ type: _contractspec_lib_schema0.FieldType<string, string>;
68
68
  isOptional: false;
69
69
  };
70
70
  status: {
@@ -72,7 +72,7 @@ const WorkflowDefinitionModel = defineSchemaModel({
72
72
  isOptional: true
73
73
  },
74
74
  version: {
75
- type: ScalarTypeEnum.Int_unsecure(),
75
+ type: ScalarTypeEnum.String_unsecure(),
76
76
  isOptional: false
77
77
  },
78
78
  status: {
@@ -1 +1 @@
1
- {"version":3,"file":"workflow.schema.js","names":[],"sources":["../../src/workflow/workflow.schema.ts"],"sourcesContent":["import { defineSchemaModel, ScalarTypeEnum } from '@contractspec/lib.schema';\nimport {\n WorkflowStatusEnum,\n TriggerTypeEnum,\n StepTypeEnum,\n ApprovalModeEnum,\n} from './workflow.enum';\n\n/**\n * A step in a workflow definition.\n */\nexport const WorkflowStepModel = defineSchemaModel({\n name: 'WorkflowStepModel',\n description: 'A step in a workflow definition',\n fields: {\n id: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },\n key: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },\n name: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },\n description: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },\n type: { type: StepTypeEnum, isOptional: false },\n position: { type: ScalarTypeEnum.Int_unsecure(), isOptional: false },\n transitions: { type: ScalarTypeEnum.JSON(), isOptional: false },\n approvalMode: { type: ApprovalModeEnum, isOptional: true },\n approverRoles: {\n type: ScalarTypeEnum.String_unsecure(),\n isArray: true,\n isOptional: true,\n },\n },\n});\n\n/**\n * A workflow definition.\n */\nexport const WorkflowDefinitionModel = defineSchemaModel({\n name: 'WorkflowDefinitionModel',\n description: 'A workflow definition',\n fields: {\n id: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },\n name: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },\n key: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },\n description: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },\n version: { type: ScalarTypeEnum.Int_unsecure(), isOptional: false },\n status: { type: WorkflowStatusEnum, isOptional: false },\n triggerType: { type: TriggerTypeEnum, isOptional: false },\n initialStepId: {\n type: ScalarTypeEnum.String_unsecure(),\n isOptional: true,\n },\n featureFlagKey: {\n type: ScalarTypeEnum.String_unsecure(),\n isOptional: true,\n },\n organizationId: {\n type: ScalarTypeEnum.String_unsecure(),\n isOptional: false,\n },\n createdAt: { type: ScalarTypeEnum.DateTime(), isOptional: false },\n updatedAt: { type: ScalarTypeEnum.DateTime(), isOptional: false },\n steps: { type: WorkflowStepModel, isArray: true, isOptional: true },\n },\n});\n\n/**\n * Input for creating a workflow definition.\n */\nexport const CreateWorkflowInputModel = defineSchemaModel({\n name: 'CreateWorkflowInput',\n description: 'Input for creating a workflow definition',\n fields: {\n name: { type: ScalarTypeEnum.NonEmptyString(), isOptional: false },\n key: { type: ScalarTypeEnum.NonEmptyString(), isOptional: false },\n description: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },\n triggerType: { type: TriggerTypeEnum, isOptional: true },\n triggerConfig: { type: ScalarTypeEnum.JSON(), isOptional: true },\n featureFlagKey: {\n type: ScalarTypeEnum.String_unsecure(),\n isOptional: true,\n },\n settings: { type: ScalarTypeEnum.JSON(), isOptional: true },\n },\n});\n\n/**\n * Input for updating a workflow definition.\n */\nexport const UpdateWorkflowInputModel = defineSchemaModel({\n name: 'UpdateWorkflowInput',\n description: 'Input for updating a workflow definition',\n fields: {\n workflowId: {\n type: ScalarTypeEnum.String_unsecure(),\n isOptional: false,\n },\n name: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },\n description: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },\n triggerType: { type: TriggerTypeEnum, isOptional: true },\n triggerConfig: { type: ScalarTypeEnum.JSON(), isOptional: true },\n featureFlagKey: {\n type: ScalarTypeEnum.String_unsecure(),\n isOptional: true,\n },\n settings: { type: ScalarTypeEnum.JSON(), isOptional: true },\n },\n});\n\n/**\n * Input for adding a step to a workflow.\n */\nexport const AddStepInputModel = defineSchemaModel({\n name: 'AddStepInput',\n description: 'Input for adding a step to a workflow',\n fields: {\n workflowId: {\n type: ScalarTypeEnum.String_unsecure(),\n isOptional: false,\n },\n key: { type: ScalarTypeEnum.NonEmptyString(), isOptional: false },\n name: { type: ScalarTypeEnum.NonEmptyString(), isOptional: false },\n description: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },\n type: { type: StepTypeEnum, isOptional: false },\n position: { type: ScalarTypeEnum.Int_unsecure(), isOptional: true },\n transitions: { type: ScalarTypeEnum.JSON(), isOptional: false },\n approvalMode: { type: ApprovalModeEnum, isOptional: true },\n approverRoles: {\n type: ScalarTypeEnum.String_unsecure(),\n isArray: true,\n isOptional: true,\n },\n approverUserIds: {\n type: ScalarTypeEnum.String_unsecure(),\n isArray: true,\n isOptional: true,\n },\n timeoutSeconds: { type: ScalarTypeEnum.Int_unsecure(), isOptional: true },\n slaSeconds: { type: ScalarTypeEnum.Int_unsecure(), isOptional: true },\n },\n});\n"],"mappings":";;;;;;;AAWA,MAAa,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;GAAE,YAAY;GAAO;EAClE,aAAa;GAAE,MAAM,eAAe,iBAAiB;GAAE,YAAY;GAAM;EACzE,MAAM;GAAE,MAAM;GAAc,YAAY;GAAO;EAC/C,UAAU;GAAE,MAAM,eAAe,cAAc;GAAE,YAAY;GAAM;EACnE,aAAa;GAAE,MAAM,eAAe,MAAM;GAAE,YAAY;GAAO;EAC/D,cAAc;GAAE,MAAM;GAAkB,YAAY;GAAM;EAC1D,eAAe;GACb,MAAM,eAAe,iBAAiB;GACtC,SAAS;GACT,YAAY;GACb;EACD,iBAAiB;GACf,MAAM,eAAe,iBAAiB;GACtC,SAAS;GACT,YAAY;GACb;EACD,gBAAgB;GAAE,MAAM,eAAe,cAAc;GAAE,YAAY;GAAM;EACzE,YAAY;GAAE,MAAM,eAAe,cAAc;GAAE,YAAY;GAAM;EACtE;CACF,CAAC"}
1
+ {"version":3,"file":"workflow.schema.js","names":[],"sources":["../../src/workflow/workflow.schema.ts"],"sourcesContent":["import { defineSchemaModel, ScalarTypeEnum } from '@contractspec/lib.schema';\nimport {\n WorkflowStatusEnum,\n TriggerTypeEnum,\n StepTypeEnum,\n ApprovalModeEnum,\n} from './workflow.enum';\n\n/**\n * A step in a workflow definition.\n */\nexport const WorkflowStepModel = defineSchemaModel({\n name: 'WorkflowStepModel',\n description: 'A step in a workflow definition',\n fields: {\n id: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },\n key: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },\n name: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },\n description: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },\n type: { type: StepTypeEnum, isOptional: false },\n position: { type: ScalarTypeEnum.Int_unsecure(), isOptional: false },\n transitions: { type: ScalarTypeEnum.JSON(), isOptional: false },\n approvalMode: { type: ApprovalModeEnum, isOptional: true },\n approverRoles: {\n type: ScalarTypeEnum.String_unsecure(),\n isArray: true,\n isOptional: true,\n },\n },\n});\n\n/**\n * A workflow definition.\n */\nexport const WorkflowDefinitionModel = defineSchemaModel({\n name: 'WorkflowDefinitionModel',\n description: 'A workflow definition',\n fields: {\n id: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },\n name: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },\n key: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },\n description: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },\n version: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },\n status: { type: WorkflowStatusEnum, isOptional: false },\n triggerType: { type: TriggerTypeEnum, isOptional: false },\n initialStepId: {\n type: ScalarTypeEnum.String_unsecure(),\n isOptional: true,\n },\n featureFlagKey: {\n type: ScalarTypeEnum.String_unsecure(),\n isOptional: true,\n },\n organizationId: {\n type: ScalarTypeEnum.String_unsecure(),\n isOptional: false,\n },\n createdAt: { type: ScalarTypeEnum.DateTime(), isOptional: false },\n updatedAt: { type: ScalarTypeEnum.DateTime(), isOptional: false },\n steps: { type: WorkflowStepModel, isArray: true, isOptional: true },\n },\n});\n\n/**\n * Input for creating a workflow definition.\n */\nexport const CreateWorkflowInputModel = defineSchemaModel({\n name: 'CreateWorkflowInput',\n description: 'Input for creating a workflow definition',\n fields: {\n name: { type: ScalarTypeEnum.NonEmptyString(), isOptional: false },\n key: { type: ScalarTypeEnum.NonEmptyString(), isOptional: false },\n description: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },\n triggerType: { type: TriggerTypeEnum, isOptional: true },\n triggerConfig: { type: ScalarTypeEnum.JSON(), isOptional: true },\n featureFlagKey: {\n type: ScalarTypeEnum.String_unsecure(),\n isOptional: true,\n },\n settings: { type: ScalarTypeEnum.JSON(), isOptional: true },\n },\n});\n\n/**\n * Input for updating a workflow definition.\n */\nexport const UpdateWorkflowInputModel = defineSchemaModel({\n name: 'UpdateWorkflowInput',\n description: 'Input for updating a workflow definition',\n fields: {\n workflowId: {\n type: ScalarTypeEnum.String_unsecure(),\n isOptional: false,\n },\n name: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },\n description: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },\n triggerType: { type: TriggerTypeEnum, isOptional: true },\n triggerConfig: { type: ScalarTypeEnum.JSON(), isOptional: true },\n featureFlagKey: {\n type: ScalarTypeEnum.String_unsecure(),\n isOptional: true,\n },\n settings: { type: ScalarTypeEnum.JSON(), isOptional: true },\n },\n});\n\n/**\n * Input for adding a step to a workflow.\n */\nexport const AddStepInputModel = defineSchemaModel({\n name: 'AddStepInput',\n description: 'Input for adding a step to a workflow',\n fields: {\n workflowId: {\n type: ScalarTypeEnum.String_unsecure(),\n isOptional: false,\n },\n key: { type: ScalarTypeEnum.NonEmptyString(), isOptional: false },\n name: { type: ScalarTypeEnum.NonEmptyString(), isOptional: false },\n description: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },\n type: { type: StepTypeEnum, isOptional: false },\n position: { type: ScalarTypeEnum.Int_unsecure(), isOptional: true },\n transitions: { type: ScalarTypeEnum.JSON(), isOptional: false },\n approvalMode: { type: ApprovalModeEnum, isOptional: true },\n approverRoles: {\n type: ScalarTypeEnum.String_unsecure(),\n isArray: true,\n isOptional: true,\n },\n approverUserIds: {\n type: ScalarTypeEnum.String_unsecure(),\n isArray: true,\n isOptional: true,\n },\n timeoutSeconds: { type: ScalarTypeEnum.Int_unsecure(), isOptional: true },\n slaSeconds: { type: ScalarTypeEnum.Int_unsecure(), isOptional: true },\n },\n});\n"],"mappings":";;;;;;;AAWA,MAAa,oBAAoB,kBAAkB;CACjD,MAAM;CACN,aAAa;CACb,QAAQ;EACN,IAAI;GAAE,MAAM,eAAe,iBAAiB;GAAE,YAAY;GAAO;EACjE,KAAK;GAAE,MAAM,eAAe,iBAAiB;GAAE,YAAY;GAAO;EAClE,MAAM;GAAE,MAAM,eAAe,iBAAiB;GAAE,YAAY;GAAO;EACnE,aAAa;GAAE,MAAM,eAAe,iBAAiB;GAAE,YAAY;GAAM;EACzE,MAAM;GAAE,MAAM;GAAc,YAAY;GAAO;EAC/C,UAAU;GA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