@contractspec/example.workflow-system 3.8.9 → 3.8.11
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/dist/approval/approval.enum.js +1 -22
- package/dist/approval/approval.event.js +1 -112
- package/dist/approval/approval.operations.js +1 -369
- package/dist/approval/approval.schema.js +1 -73
- package/dist/approval/index.js +1 -484
- package/dist/browser/approval/approval.enum.js +1 -22
- package/dist/browser/approval/approval.event.js +1 -112
- package/dist/browser/approval/approval.operations.js +1 -369
- package/dist/browser/approval/approval.schema.js +1 -73
- package/dist/browser/approval/index.js +1 -484
- package/dist/browser/docs/index.js +5 -49
- package/dist/browser/docs/workflow-system.docblock.js +5 -49
- package/dist/browser/entities/approval.js +1 -119
- package/dist/browser/entities/index.js +1 -508
- package/dist/browser/entities/instance.js +1 -161
- package/dist/browser/entities/step.js +1 -124
- package/dist/browser/entities/workflow.js +1 -82
- package/dist/browser/example.js +1 -42
- package/dist/browser/handlers/index.js +8 -253
- package/dist/browser/handlers/workflow.handlers.js +8 -253
- package/dist/browser/index.js +13 -3524
- package/dist/browser/instance/index.js +1 -677
- package/dist/browser/instance/instance.enum.js +1 -15
- package/dist/browser/instance/instance.event.js +1 -164
- package/dist/browser/instance/instance.handler.js +1 -356
- package/dist/browser/instance/instance.operations.js +1 -9
- package/dist/browser/instance/instance.schema.js +1 -101
- package/dist/browser/presentations/index.js +1 -109
- package/dist/browser/seeders/index.js +1 -3
- package/dist/browser/shared/demo-scenario.js +1 -213
- package/dist/browser/shared/index.js +1 -3
- package/dist/browser/shared/mock-data.js +1 -11
- package/dist/browser/state-machine/index.js +1 -6
- package/dist/browser/tests/operations.test-spec.js +1 -6
- package/dist/browser/ui/WorkflowDashboard.js +1 -3
- package/dist/browser/ui/WorkflowDashboard.visualizations.js +1 -239
- package/dist/browser/ui/hooks/index.js +1 -3
- package/dist/browser/ui/hooks/useWorkflowList.js +1 -52
- package/dist/browser/ui/index.js +1 -56
- package/dist/browser/ui/renderers/index.js +5 -562
- package/dist/browser/ui/renderers/workflow.markdown.js +5 -562
- package/dist/browser/visualizations/catalog.js +1 -132
- package/dist/browser/visualizations/index.js +1 -133
- package/dist/browser/visualizations/selectors.js +1 -195
- package/dist/browser/workflow/index.js +1 -21
- package/dist/browser/workflow/workflow.enum.js +1 -36
- package/dist/browser/workflow/workflow.event.js +1 -6
- package/dist/browser/workflow/workflow.handler.js +1 -5
- package/dist/browser/workflow/workflow.operations.js +1 -8
- package/dist/browser/workflow/workflow.schema.js +1 -151
- package/dist/browser/workflow-system.capability.js +1 -5
- package/dist/browser/workflow-system.feature.js +1 -3
- package/dist/docs/index.js +5 -49
- package/dist/docs/workflow-system.docblock.js +5 -49
- package/dist/entities/approval.js +1 -119
- package/dist/entities/index.js +1 -508
- package/dist/entities/instance.js +1 -161
- package/dist/entities/step.js +1 -124
- package/dist/entities/workflow.js +1 -82
- package/dist/example.js +1 -42
- package/dist/handlers/index.js +8 -253
- package/dist/handlers/workflow.handlers.js +8 -253
- package/dist/index.js +13 -3524
- package/dist/instance/index.js +1 -677
- package/dist/instance/instance.enum.js +1 -15
- package/dist/instance/instance.event.js +1 -164
- package/dist/instance/instance.handler.js +1 -356
- package/dist/instance/instance.operations.js +1 -9
- package/dist/instance/instance.schema.js +1 -101
- package/dist/presentations/index.js +1 -109
- package/dist/seeders/index.js +1 -3
- package/dist/shared/demo-scenario.js +1 -213
- package/dist/shared/index.js +1 -3
- package/dist/shared/mock-data.js +1 -11
- package/dist/state-machine/index.js +1 -6
- package/dist/tests/operations.test-spec.js +1 -6
- package/dist/ui/WorkflowDashboard.js +1 -3
- package/dist/ui/WorkflowDashboard.visualizations.js +1 -239
- package/dist/ui/hooks/index.js +1 -3
- package/dist/ui/hooks/useWorkflowList.js +1 -52
- package/dist/ui/index.js +1 -56
- package/dist/ui/renderers/index.js +5 -562
- package/dist/ui/renderers/workflow.markdown.js +5 -562
- package/dist/visualizations/catalog.js +1 -132
- package/dist/visualizations/index.js +1 -133
- package/dist/visualizations/selectors.js +1 -195
- package/dist/workflow/index.js +1 -21
- package/dist/workflow/workflow.enum.js +1 -36
- package/dist/workflow/workflow.event.js +1 -6
- package/dist/workflow/workflow.handler.js +1 -5
- package/dist/workflow/workflow.operations.js +1 -8
- package/dist/workflow/workflow.schema.js +1 -151
- package/dist/workflow-system.capability.js +1 -5
- package/dist/workflow-system.feature.js +1 -3
- package/package.json +8 -8
|
@@ -1,677 +1 @@
|
|
|
1
|
-
// src/instance/instance.enum.ts
|
|
2
|
-
import { defineEnum } from "@contractspec/lib.schema";
|
|
3
|
-
var InstanceStatusEnum = defineEnum("InstanceStatus", [
|
|
4
|
-
"PENDING",
|
|
5
|
-
"RUNNING",
|
|
6
|
-
"WAITING",
|
|
7
|
-
"PAUSED",
|
|
8
|
-
"COMPLETED",
|
|
9
|
-
"CANCELLED",
|
|
10
|
-
"FAILED",
|
|
11
|
-
"TIMEOUT"
|
|
12
|
-
]);
|
|
13
|
-
|
|
14
|
-
// src/instance/instance.event.ts
|
|
15
|
-
import { defineEvent } from "@contractspec/lib.contracts-spec";
|
|
16
|
-
import { defineSchemaModel, ScalarTypeEnum } from "@contractspec/lib.schema";
|
|
17
|
-
var InstanceEventPayload = defineSchemaModel({
|
|
18
|
-
name: "InstanceEventPayload",
|
|
19
|
-
description: "Base payload for instance events",
|
|
20
|
-
fields: {
|
|
21
|
-
instanceId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
22
|
-
workflowId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
23
|
-
workflowKey: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
24
|
-
status: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
25
|
-
referenceId: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
|
|
26
|
-
referenceType: {
|
|
27
|
-
type: ScalarTypeEnum.String_unsecure(),
|
|
28
|
-
isOptional: true
|
|
29
|
-
},
|
|
30
|
-
triggeredBy: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
31
|
-
organizationId: {
|
|
32
|
-
type: ScalarTypeEnum.String_unsecure(),
|
|
33
|
-
isOptional: false
|
|
34
|
-
},
|
|
35
|
-
timestamp: { type: ScalarTypeEnum.DateTime(), isOptional: false }
|
|
36
|
-
}
|
|
37
|
-
});
|
|
38
|
-
var StepTransitionPayload = defineSchemaModel({
|
|
39
|
-
name: "StepTransitionEventPayload",
|
|
40
|
-
description: "Payload for step transition events",
|
|
41
|
-
fields: {
|
|
42
|
-
instanceId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
43
|
-
workflowId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
44
|
-
fromStepKey: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
|
|
45
|
-
toStepKey: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
46
|
-
action: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
|
|
47
|
-
executedBy: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
48
|
-
timestamp: { type: ScalarTypeEnum.DateTime(), isOptional: false }
|
|
49
|
-
}
|
|
50
|
-
});
|
|
51
|
-
var InstanceCompletedPayload = defineSchemaModel({
|
|
52
|
-
name: "InstanceCompletedEventPayload",
|
|
53
|
-
description: "Payload when instance completes",
|
|
54
|
-
fields: {
|
|
55
|
-
instanceId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
56
|
-
workflowId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
57
|
-
workflowKey: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
58
|
-
outcome: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
59
|
-
referenceId: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
|
|
60
|
-
referenceType: {
|
|
61
|
-
type: ScalarTypeEnum.String_unsecure(),
|
|
62
|
-
isOptional: true
|
|
63
|
-
},
|
|
64
|
-
duration: { type: ScalarTypeEnum.Int_unsecure(), isOptional: false },
|
|
65
|
-
timestamp: { type: ScalarTypeEnum.DateTime(), isOptional: false }
|
|
66
|
-
}
|
|
67
|
-
});
|
|
68
|
-
var InstanceStartedEvent = defineEvent({
|
|
69
|
-
meta: {
|
|
70
|
-
key: "workflow.instance.started",
|
|
71
|
-
version: "1.0.0",
|
|
72
|
-
description: "A new workflow instance has been started.",
|
|
73
|
-
stability: "stable",
|
|
74
|
-
owners: ["@workflow-team"],
|
|
75
|
-
tags: ["workflow", "instance", "started"]
|
|
76
|
-
},
|
|
77
|
-
payload: InstanceEventPayload
|
|
78
|
-
});
|
|
79
|
-
var StepEnteredEvent = defineEvent({
|
|
80
|
-
meta: {
|
|
81
|
-
key: "workflow.step.entered",
|
|
82
|
-
version: "1.0.0",
|
|
83
|
-
description: "A workflow instance has entered a new step.",
|
|
84
|
-
stability: "stable",
|
|
85
|
-
owners: ["@workflow-team"],
|
|
86
|
-
tags: ["workflow", "step", "entered"]
|
|
87
|
-
},
|
|
88
|
-
payload: StepTransitionPayload
|
|
89
|
-
});
|
|
90
|
-
var StepExitedEvent = defineEvent({
|
|
91
|
-
meta: {
|
|
92
|
-
key: "workflow.step.exited",
|
|
93
|
-
version: "1.0.0",
|
|
94
|
-
description: "A workflow instance has exited a step.",
|
|
95
|
-
stability: "stable",
|
|
96
|
-
owners: ["@workflow-team"],
|
|
97
|
-
tags: ["workflow", "step", "exited"]
|
|
98
|
-
},
|
|
99
|
-
payload: StepTransitionPayload
|
|
100
|
-
});
|
|
101
|
-
var InstanceCompletedEvent = defineEvent({
|
|
102
|
-
meta: {
|
|
103
|
-
key: "workflow.instance.completed",
|
|
104
|
-
version: "1.0.0",
|
|
105
|
-
description: "A workflow instance has completed.",
|
|
106
|
-
stability: "stable",
|
|
107
|
-
owners: ["@workflow-team"],
|
|
108
|
-
tags: ["workflow", "instance", "completed"]
|
|
109
|
-
},
|
|
110
|
-
payload: InstanceCompletedPayload
|
|
111
|
-
});
|
|
112
|
-
var InstanceCancelledEvent = defineEvent({
|
|
113
|
-
meta: {
|
|
114
|
-
key: "workflow.instance.cancelled",
|
|
115
|
-
version: "1.0.0",
|
|
116
|
-
description: "A workflow instance has been cancelled.",
|
|
117
|
-
stability: "stable",
|
|
118
|
-
owners: ["@workflow-team"],
|
|
119
|
-
tags: ["workflow", "instance", "cancelled"]
|
|
120
|
-
},
|
|
121
|
-
payload: InstanceEventPayload
|
|
122
|
-
});
|
|
123
|
-
var InstancePausedEvent = defineEvent({
|
|
124
|
-
meta: {
|
|
125
|
-
key: "workflow.instance.paused",
|
|
126
|
-
version: "1.0.0",
|
|
127
|
-
description: "A workflow instance has been paused.",
|
|
128
|
-
stability: "stable",
|
|
129
|
-
owners: ["@workflow-team"],
|
|
130
|
-
tags: ["workflow", "instance", "paused"]
|
|
131
|
-
},
|
|
132
|
-
payload: InstanceEventPayload
|
|
133
|
-
});
|
|
134
|
-
var InstanceResumedEvent = defineEvent({
|
|
135
|
-
meta: {
|
|
136
|
-
key: "workflow.instance.resumed",
|
|
137
|
-
version: "1.0.0",
|
|
138
|
-
description: "A workflow instance has been resumed.",
|
|
139
|
-
stability: "stable",
|
|
140
|
-
owners: ["@workflow-team"],
|
|
141
|
-
tags: ["workflow", "instance", "resumed"]
|
|
142
|
-
},
|
|
143
|
-
payload: InstanceEventPayload
|
|
144
|
-
});
|
|
145
|
-
var InstanceFailedEvent = defineEvent({
|
|
146
|
-
meta: {
|
|
147
|
-
key: "workflow.instance.failed",
|
|
148
|
-
version: "1.0.0",
|
|
149
|
-
description: "A workflow instance has failed.",
|
|
150
|
-
stability: "stable",
|
|
151
|
-
owners: ["@workflow-team"],
|
|
152
|
-
tags: ["workflow", "instance", "failed"]
|
|
153
|
-
},
|
|
154
|
-
payload: InstanceEventPayload
|
|
155
|
-
});
|
|
156
|
-
var InstanceTimedOutEvent = defineEvent({
|
|
157
|
-
meta: {
|
|
158
|
-
key: "workflow.instance.timedOut",
|
|
159
|
-
version: "1.0.0",
|
|
160
|
-
description: "A workflow instance has timed out.",
|
|
161
|
-
stability: "stable",
|
|
162
|
-
owners: ["@workflow-team"],
|
|
163
|
-
tags: ["workflow", "instance", "timeout"]
|
|
164
|
-
},
|
|
165
|
-
payload: InstanceEventPayload
|
|
166
|
-
});
|
|
167
|
-
|
|
168
|
-
// src/instance/instance.schema.ts
|
|
169
|
-
import { defineSchemaModel as defineSchemaModel2, ScalarTypeEnum as ScalarTypeEnum2 } from "@contractspec/lib.schema";
|
|
170
|
-
var WorkflowInstanceModel = defineSchemaModel2({
|
|
171
|
-
name: "WorkflowInstanceModel",
|
|
172
|
-
description: "A running workflow instance",
|
|
173
|
-
fields: {
|
|
174
|
-
id: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
|
|
175
|
-
workflowDefinitionId: {
|
|
176
|
-
type: ScalarTypeEnum2.String_unsecure(),
|
|
177
|
-
isOptional: false
|
|
178
|
-
},
|
|
179
|
-
referenceId: { type: ScalarTypeEnum2.String_unsecure(), isOptional: true },
|
|
180
|
-
referenceType: {
|
|
181
|
-
type: ScalarTypeEnum2.String_unsecure(),
|
|
182
|
-
isOptional: true
|
|
183
|
-
},
|
|
184
|
-
status: { type: InstanceStatusEnum, isOptional: false },
|
|
185
|
-
currentStepId: {
|
|
186
|
-
type: ScalarTypeEnum2.String_unsecure(),
|
|
187
|
-
isOptional: true
|
|
188
|
-
},
|
|
189
|
-
contextData: { type: ScalarTypeEnum2.JSON(), isOptional: true },
|
|
190
|
-
triggeredBy: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
|
|
191
|
-
organizationId: {
|
|
192
|
-
type: ScalarTypeEnum2.String_unsecure(),
|
|
193
|
-
isOptional: false
|
|
194
|
-
},
|
|
195
|
-
priority: { type: ScalarTypeEnum2.Int_unsecure(), isOptional: false },
|
|
196
|
-
dueAt: { type: ScalarTypeEnum2.DateTime(), isOptional: true },
|
|
197
|
-
outcome: { type: ScalarTypeEnum2.String_unsecure(), isOptional: true },
|
|
198
|
-
resultData: { type: ScalarTypeEnum2.JSON(), isOptional: true },
|
|
199
|
-
errorMessage: {
|
|
200
|
-
type: ScalarTypeEnum2.String_unsecure(),
|
|
201
|
-
isOptional: true
|
|
202
|
-
},
|
|
203
|
-
createdAt: { type: ScalarTypeEnum2.DateTime(), isOptional: false },
|
|
204
|
-
startedAt: { type: ScalarTypeEnum2.DateTime(), isOptional: true },
|
|
205
|
-
completedAt: { type: ScalarTypeEnum2.DateTime(), isOptional: true }
|
|
206
|
-
}
|
|
207
|
-
});
|
|
208
|
-
var StartWorkflowInputModel = defineSchemaModel2({
|
|
209
|
-
name: "StartWorkflowInput",
|
|
210
|
-
description: "Input for starting a workflow",
|
|
211
|
-
fields: {
|
|
212
|
-
workflowKey: { type: ScalarTypeEnum2.NonEmptyString(), isOptional: false },
|
|
213
|
-
contextData: { type: ScalarTypeEnum2.JSON(), isOptional: true },
|
|
214
|
-
referenceId: { type: ScalarTypeEnum2.String_unsecure(), isOptional: true },
|
|
215
|
-
referenceType: {
|
|
216
|
-
type: ScalarTypeEnum2.String_unsecure(),
|
|
217
|
-
isOptional: true
|
|
218
|
-
},
|
|
219
|
-
priority: { type: ScalarTypeEnum2.Int_unsecure(), isOptional: true },
|
|
220
|
-
dueAt: { type: ScalarTypeEnum2.DateTime(), isOptional: true }
|
|
221
|
-
}
|
|
222
|
-
});
|
|
223
|
-
var TransitionInputModel = defineSchemaModel2({
|
|
224
|
-
name: "TransitionInput",
|
|
225
|
-
description: "Input for transitioning a workflow",
|
|
226
|
-
fields: {
|
|
227
|
-
instanceId: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
|
|
228
|
-
action: { type: ScalarTypeEnum2.NonEmptyString(), isOptional: false },
|
|
229
|
-
data: { type: ScalarTypeEnum2.JSON(), isOptional: true },
|
|
230
|
-
comment: { type: ScalarTypeEnum2.String_unsecure(), isOptional: true }
|
|
231
|
-
}
|
|
232
|
-
});
|
|
233
|
-
var TransitionResultModel = defineSchemaModel2({
|
|
234
|
-
name: "TransitionResult",
|
|
235
|
-
description: "Result of a workflow transition",
|
|
236
|
-
fields: {
|
|
237
|
-
success: { type: ScalarTypeEnum2.Boolean(), isOptional: false },
|
|
238
|
-
instance: { type: WorkflowInstanceModel, isOptional: false },
|
|
239
|
-
previousStepKey: {
|
|
240
|
-
type: ScalarTypeEnum2.String_unsecure(),
|
|
241
|
-
isOptional: true
|
|
242
|
-
},
|
|
243
|
-
currentStepKey: {
|
|
244
|
-
type: ScalarTypeEnum2.String_unsecure(),
|
|
245
|
-
isOptional: true
|
|
246
|
-
},
|
|
247
|
-
message: { type: ScalarTypeEnum2.String_unsecure(), isOptional: true }
|
|
248
|
-
}
|
|
249
|
-
});
|
|
250
|
-
|
|
251
|
-
// src/instance/instance.operations.ts
|
|
252
|
-
import {
|
|
253
|
-
defineCommand,
|
|
254
|
-
defineQuery
|
|
255
|
-
} from "@contractspec/lib.contracts-spec/operations";
|
|
256
|
-
import { defineSchemaModel as defineSchemaModel3, ScalarTypeEnum as ScalarTypeEnum3 } from "@contractspec/lib.schema";
|
|
257
|
-
var OWNERS = ["@example.workflow-system"];
|
|
258
|
-
var StartWorkflowContract = defineCommand({
|
|
259
|
-
meta: {
|
|
260
|
-
key: "workflow.instance.start",
|
|
261
|
-
version: "1.0.0",
|
|
262
|
-
stability: "stable",
|
|
263
|
-
owners: [...OWNERS],
|
|
264
|
-
tags: ["workflow", "instance", "start"],
|
|
265
|
-
description: "Start a new workflow instance.",
|
|
266
|
-
goal: "Initiate a workflow for a business process.",
|
|
267
|
-
context: "Order creation, request submission, etc."
|
|
268
|
-
},
|
|
269
|
-
io: {
|
|
270
|
-
input: StartWorkflowInputModel,
|
|
271
|
-
output: WorkflowInstanceModel
|
|
272
|
-
},
|
|
273
|
-
policy: { auth: "user" },
|
|
274
|
-
sideEffects: {
|
|
275
|
-
emits: [
|
|
276
|
-
{
|
|
277
|
-
key: "workflow.instance.started",
|
|
278
|
-
version: "1.0.0",
|
|
279
|
-
when: "Workflow starts",
|
|
280
|
-
payload: WorkflowInstanceModel
|
|
281
|
-
},
|
|
282
|
-
{
|
|
283
|
-
key: "workflow.step.entered",
|
|
284
|
-
version: "1.0.0",
|
|
285
|
-
when: "First step entered",
|
|
286
|
-
payload: WorkflowInstanceModel
|
|
287
|
-
}
|
|
288
|
-
],
|
|
289
|
-
audit: ["workflow.instance.started"]
|
|
290
|
-
},
|
|
291
|
-
acceptance: {
|
|
292
|
-
scenarios: [
|
|
293
|
-
{
|
|
294
|
-
key: "start-workflow-happy-path",
|
|
295
|
-
given: ["Workflow definition exists"],
|
|
296
|
-
when: ["User starts workflow"],
|
|
297
|
-
then: ["Instance is created and started"]
|
|
298
|
-
}
|
|
299
|
-
],
|
|
300
|
-
examples: [
|
|
301
|
-
{
|
|
302
|
-
key: "start-onboarding",
|
|
303
|
-
input: {
|
|
304
|
-
workflowKey: "onboarding-v1",
|
|
305
|
-
context: { employeeId: "emp-123" }
|
|
306
|
-
},
|
|
307
|
-
output: { id: "inst-456", status: "running" }
|
|
308
|
-
}
|
|
309
|
-
]
|
|
310
|
-
}
|
|
311
|
-
});
|
|
312
|
-
var TransitionWorkflowContract = defineCommand({
|
|
313
|
-
meta: {
|
|
314
|
-
key: "workflow.instance.transition",
|
|
315
|
-
version: "1.0.0",
|
|
316
|
-
stability: "stable",
|
|
317
|
-
owners: [...OWNERS],
|
|
318
|
-
tags: ["workflow", "instance", "transition", "state-machine"],
|
|
319
|
-
description: "Transition a workflow instance to the next step.",
|
|
320
|
-
goal: "Move workflow forward based on action.",
|
|
321
|
-
context: "Task completion, approval decisions."
|
|
322
|
-
},
|
|
323
|
-
io: {
|
|
324
|
-
input: TransitionInputModel,
|
|
325
|
-
output: TransitionResultModel
|
|
326
|
-
},
|
|
327
|
-
policy: { auth: "user" },
|
|
328
|
-
sideEffects: {
|
|
329
|
-
emits: [
|
|
330
|
-
{
|
|
331
|
-
key: "workflow.step.exited",
|
|
332
|
-
version: "1.0.0",
|
|
333
|
-
when: "Step is exited",
|
|
334
|
-
payload: WorkflowInstanceModel
|
|
335
|
-
},
|
|
336
|
-
{
|
|
337
|
-
key: "workflow.step.entered",
|
|
338
|
-
version: "1.0.0",
|
|
339
|
-
when: "New step is entered",
|
|
340
|
-
payload: WorkflowInstanceModel
|
|
341
|
-
},
|
|
342
|
-
{
|
|
343
|
-
key: "workflow.instance.completed",
|
|
344
|
-
version: "1.0.0",
|
|
345
|
-
when: "Workflow reaches end",
|
|
346
|
-
payload: WorkflowInstanceModel
|
|
347
|
-
}
|
|
348
|
-
],
|
|
349
|
-
audit: ["workflow.instance.transitioned"]
|
|
350
|
-
},
|
|
351
|
-
acceptance: {
|
|
352
|
-
scenarios: [
|
|
353
|
-
{
|
|
354
|
-
key: "transition-workflow-happy-path",
|
|
355
|
-
given: ["Workflow instance is waiting at step"],
|
|
356
|
-
when: ["User provides input"],
|
|
357
|
-
then: ["Instance moves to next step"]
|
|
358
|
-
}
|
|
359
|
-
],
|
|
360
|
-
examples: [
|
|
361
|
-
{
|
|
362
|
-
key: "complete-task",
|
|
363
|
-
input: {
|
|
364
|
-
instanceId: "inst-456",
|
|
365
|
-
action: "complete",
|
|
366
|
-
data: { approved: true }
|
|
367
|
-
},
|
|
368
|
-
output: { success: true, nextStep: "notify-hr" }
|
|
369
|
-
}
|
|
370
|
-
]
|
|
371
|
-
}
|
|
372
|
-
});
|
|
373
|
-
var PauseWorkflowContract = defineCommand({
|
|
374
|
-
meta: {
|
|
375
|
-
key: "workflow.instance.pause",
|
|
376
|
-
version: "1.0.0",
|
|
377
|
-
stability: "stable",
|
|
378
|
-
owners: [...OWNERS],
|
|
379
|
-
tags: ["workflow", "instance", "pause"],
|
|
380
|
-
description: "Pause a running workflow instance.",
|
|
381
|
-
goal: "Temporarily halt workflow execution.",
|
|
382
|
-
context: "Administrative action, emergency stop."
|
|
383
|
-
},
|
|
384
|
-
io: {
|
|
385
|
-
input: defineSchemaModel3({
|
|
386
|
-
name: "PauseResumeInput",
|
|
387
|
-
fields: {
|
|
388
|
-
instanceId: {
|
|
389
|
-
type: ScalarTypeEnum3.String_unsecure(),
|
|
390
|
-
isOptional: false
|
|
391
|
-
},
|
|
392
|
-
reason: { type: ScalarTypeEnum3.String_unsecure(), isOptional: true }
|
|
393
|
-
}
|
|
394
|
-
}),
|
|
395
|
-
output: WorkflowInstanceModel
|
|
396
|
-
},
|
|
397
|
-
policy: { auth: "user" },
|
|
398
|
-
sideEffects: {
|
|
399
|
-
emits: [
|
|
400
|
-
{
|
|
401
|
-
key: "workflow.instance.paused",
|
|
402
|
-
version: "1.0.0",
|
|
403
|
-
when: "Workflow is paused",
|
|
404
|
-
payload: WorkflowInstanceModel
|
|
405
|
-
}
|
|
406
|
-
],
|
|
407
|
-
audit: ["workflow.instance.paused"]
|
|
408
|
-
},
|
|
409
|
-
acceptance: {
|
|
410
|
-
scenarios: [
|
|
411
|
-
{
|
|
412
|
-
key: "pause-workflow-happy-path",
|
|
413
|
-
given: ["Workflow is running"],
|
|
414
|
-
when: ["Admin pauses workflow"],
|
|
415
|
-
then: ["Instance status becomes PAUSED"]
|
|
416
|
-
}
|
|
417
|
-
],
|
|
418
|
-
examples: [
|
|
419
|
-
{
|
|
420
|
-
key: "pause-maintenance",
|
|
421
|
-
input: { instanceId: "inst-456", reason: "System maintenance" },
|
|
422
|
-
output: { id: "inst-456", status: "paused" }
|
|
423
|
-
}
|
|
424
|
-
]
|
|
425
|
-
}
|
|
426
|
-
});
|
|
427
|
-
var ResumeWorkflowContract = defineCommand({
|
|
428
|
-
meta: {
|
|
429
|
-
key: "workflow.instance.resume",
|
|
430
|
-
version: "1.0.0",
|
|
431
|
-
stability: "stable",
|
|
432
|
-
owners: [...OWNERS],
|
|
433
|
-
tags: ["workflow", "instance", "resume"],
|
|
434
|
-
description: "Resume a paused workflow instance.",
|
|
435
|
-
goal: "Continue workflow execution.",
|
|
436
|
-
context: "Administrative action."
|
|
437
|
-
},
|
|
438
|
-
io: {
|
|
439
|
-
input: defineSchemaModel3({
|
|
440
|
-
name: "PauseResumeInput",
|
|
441
|
-
fields: {
|
|
442
|
-
instanceId: {
|
|
443
|
-
type: ScalarTypeEnum3.String_unsecure(),
|
|
444
|
-
isOptional: false
|
|
445
|
-
},
|
|
446
|
-
reason: { type: ScalarTypeEnum3.String_unsecure(), isOptional: true }
|
|
447
|
-
}
|
|
448
|
-
}),
|
|
449
|
-
output: WorkflowInstanceModel
|
|
450
|
-
},
|
|
451
|
-
policy: { auth: "user" },
|
|
452
|
-
sideEffects: {
|
|
453
|
-
emits: [
|
|
454
|
-
{
|
|
455
|
-
key: "workflow.instance.resumed",
|
|
456
|
-
version: "1.0.0",
|
|
457
|
-
when: "Workflow is resumed",
|
|
458
|
-
payload: WorkflowInstanceModel
|
|
459
|
-
}
|
|
460
|
-
],
|
|
461
|
-
audit: ["workflow.instance.resumed"]
|
|
462
|
-
},
|
|
463
|
-
acceptance: {
|
|
464
|
-
scenarios: [
|
|
465
|
-
{
|
|
466
|
-
key: "resume-workflow-happy-path",
|
|
467
|
-
given: ["Workflow is paused"],
|
|
468
|
-
when: ["Admin resumes workflow"],
|
|
469
|
-
then: ["Instance status becomes RUNNING"]
|
|
470
|
-
}
|
|
471
|
-
],
|
|
472
|
-
examples: [
|
|
473
|
-
{
|
|
474
|
-
key: "resume-normal",
|
|
475
|
-
input: { instanceId: "inst-456", reason: "Issue resolved" },
|
|
476
|
-
output: { id: "inst-456", status: "running" }
|
|
477
|
-
}
|
|
478
|
-
]
|
|
479
|
-
}
|
|
480
|
-
});
|
|
481
|
-
var CancelWorkflowContract = defineCommand({
|
|
482
|
-
meta: {
|
|
483
|
-
key: "workflow.instance.cancel",
|
|
484
|
-
version: "1.0.0",
|
|
485
|
-
stability: "stable",
|
|
486
|
-
owners: [...OWNERS],
|
|
487
|
-
tags: ["workflow", "instance", "cancel"],
|
|
488
|
-
description: "Cancel a workflow instance.",
|
|
489
|
-
goal: "Terminate workflow without completion.",
|
|
490
|
-
context: "User request, system cancellation."
|
|
491
|
-
},
|
|
492
|
-
io: {
|
|
493
|
-
input: defineSchemaModel3({
|
|
494
|
-
name: "CancelWorkflowInput",
|
|
495
|
-
fields: {
|
|
496
|
-
instanceId: {
|
|
497
|
-
type: ScalarTypeEnum3.String_unsecure(),
|
|
498
|
-
isOptional: false
|
|
499
|
-
},
|
|
500
|
-
reason: {
|
|
501
|
-
type: ScalarTypeEnum3.String_unsecure(),
|
|
502
|
-
isOptional: false
|
|
503
|
-
}
|
|
504
|
-
}
|
|
505
|
-
}),
|
|
506
|
-
output: WorkflowInstanceModel
|
|
507
|
-
},
|
|
508
|
-
policy: { auth: "user" },
|
|
509
|
-
sideEffects: {
|
|
510
|
-
emits: [
|
|
511
|
-
{
|
|
512
|
-
key: "workflow.instance.cancelled",
|
|
513
|
-
version: "1.0.0",
|
|
514
|
-
when: "Workflow is cancelled",
|
|
515
|
-
payload: WorkflowInstanceModel
|
|
516
|
-
}
|
|
517
|
-
],
|
|
518
|
-
audit: ["workflow.instance.cancelled"]
|
|
519
|
-
},
|
|
520
|
-
acceptance: {
|
|
521
|
-
scenarios: [
|
|
522
|
-
{
|
|
523
|
-
key: "cancel-workflow-happy-path",
|
|
524
|
-
given: ["Workflow is running"],
|
|
525
|
-
when: ["User cancels workflow"],
|
|
526
|
-
then: ["Instance status becomes CANCELLED"]
|
|
527
|
-
}
|
|
528
|
-
],
|
|
529
|
-
examples: [
|
|
530
|
-
{
|
|
531
|
-
key: "cancel-mistake",
|
|
532
|
-
input: { instanceId: "inst-456", reason: "Created by mistake" },
|
|
533
|
-
output: { id: "inst-456", status: "cancelled" }
|
|
534
|
-
}
|
|
535
|
-
]
|
|
536
|
-
}
|
|
537
|
-
});
|
|
538
|
-
var ListInstancesContract = defineQuery({
|
|
539
|
-
meta: {
|
|
540
|
-
key: "workflow.instance.list",
|
|
541
|
-
version: "1.0.0",
|
|
542
|
-
stability: "stable",
|
|
543
|
-
owners: [...OWNERS],
|
|
544
|
-
tags: ["workflow", "instance", "list"],
|
|
545
|
-
description: "List workflow instances with filtering.",
|
|
546
|
-
goal: "Browse and search running workflows.",
|
|
547
|
-
context: "Dashboard, monitoring."
|
|
548
|
-
},
|
|
549
|
-
io: {
|
|
550
|
-
input: defineSchemaModel3({
|
|
551
|
-
name: "ListInstancesInput",
|
|
552
|
-
fields: {
|
|
553
|
-
workflowKey: {
|
|
554
|
-
type: ScalarTypeEnum3.String_unsecure(),
|
|
555
|
-
isOptional: true
|
|
556
|
-
},
|
|
557
|
-
status: { type: InstanceStatusEnum, isOptional: true },
|
|
558
|
-
referenceType: {
|
|
559
|
-
type: ScalarTypeEnum3.String_unsecure(),
|
|
560
|
-
isOptional: true
|
|
561
|
-
},
|
|
562
|
-
referenceId: {
|
|
563
|
-
type: ScalarTypeEnum3.String_unsecure(),
|
|
564
|
-
isOptional: true
|
|
565
|
-
},
|
|
566
|
-
triggeredBy: {
|
|
567
|
-
type: ScalarTypeEnum3.String_unsecure(),
|
|
568
|
-
isOptional: true
|
|
569
|
-
},
|
|
570
|
-
limit: {
|
|
571
|
-
type: ScalarTypeEnum3.Int_unsecure(),
|
|
572
|
-
isOptional: true,
|
|
573
|
-
defaultValue: 20
|
|
574
|
-
},
|
|
575
|
-
offset: {
|
|
576
|
-
type: ScalarTypeEnum3.Int_unsecure(),
|
|
577
|
-
isOptional: true,
|
|
578
|
-
defaultValue: 0
|
|
579
|
-
}
|
|
580
|
-
}
|
|
581
|
-
}),
|
|
582
|
-
output: defineSchemaModel3({
|
|
583
|
-
name: "ListInstancesOutput",
|
|
584
|
-
fields: {
|
|
585
|
-
instances: {
|
|
586
|
-
type: WorkflowInstanceModel,
|
|
587
|
-
isArray: true,
|
|
588
|
-
isOptional: false
|
|
589
|
-
},
|
|
590
|
-
total: { type: ScalarTypeEnum3.Int_unsecure(), isOptional: false }
|
|
591
|
-
}
|
|
592
|
-
})
|
|
593
|
-
},
|
|
594
|
-
policy: { auth: "user" },
|
|
595
|
-
acceptance: {
|
|
596
|
-
scenarios: [
|
|
597
|
-
{
|
|
598
|
-
key: "list-instances-happy-path",
|
|
599
|
-
given: ["Workflow instances exist"],
|
|
600
|
-
when: ["User lists instances"],
|
|
601
|
-
then: ["List of instances is returned"]
|
|
602
|
-
}
|
|
603
|
-
],
|
|
604
|
-
examples: [
|
|
605
|
-
{
|
|
606
|
-
key: "list-running",
|
|
607
|
-
input: { status: "running", limit: 10 },
|
|
608
|
-
output: { instances: [], total: 5 }
|
|
609
|
-
}
|
|
610
|
-
]
|
|
611
|
-
}
|
|
612
|
-
});
|
|
613
|
-
var GetInstanceContract = defineQuery({
|
|
614
|
-
meta: {
|
|
615
|
-
key: "workflow.instance.get",
|
|
616
|
-
version: "1.0.0",
|
|
617
|
-
stability: "stable",
|
|
618
|
-
owners: [...OWNERS],
|
|
619
|
-
tags: ["workflow", "instance", "get"],
|
|
620
|
-
description: "Get a workflow instance with details.",
|
|
621
|
-
goal: "View workflow instance details.",
|
|
622
|
-
context: "Instance detail view."
|
|
623
|
-
},
|
|
624
|
-
io: {
|
|
625
|
-
input: defineSchemaModel3({
|
|
626
|
-
name: "GetInstanceInput",
|
|
627
|
-
fields: {
|
|
628
|
-
instanceId: {
|
|
629
|
-
type: ScalarTypeEnum3.String_unsecure(),
|
|
630
|
-
isOptional: false
|
|
631
|
-
}
|
|
632
|
-
}
|
|
633
|
-
}),
|
|
634
|
-
output: WorkflowInstanceModel
|
|
635
|
-
},
|
|
636
|
-
policy: { auth: "user" },
|
|
637
|
-
acceptance: {
|
|
638
|
-
scenarios: [
|
|
639
|
-
{
|
|
640
|
-
key: "get-instance-happy-path",
|
|
641
|
-
given: ["Instance exists"],
|
|
642
|
-
when: ["User requests instance details"],
|
|
643
|
-
then: ["Instance details are returned"]
|
|
644
|
-
}
|
|
645
|
-
],
|
|
646
|
-
examples: [
|
|
647
|
-
{
|
|
648
|
-
key: "get-details",
|
|
649
|
-
input: { instanceId: "inst-456" },
|
|
650
|
-
output: { id: "inst-456", workflowKey: "onboarding-v1" }
|
|
651
|
-
}
|
|
652
|
-
]
|
|
653
|
-
}
|
|
654
|
-
});
|
|
655
|
-
export {
|
|
656
|
-
WorkflowInstanceModel,
|
|
657
|
-
TransitionWorkflowContract,
|
|
658
|
-
TransitionResultModel,
|
|
659
|
-
TransitionInputModel,
|
|
660
|
-
StepExitedEvent,
|
|
661
|
-
StepEnteredEvent,
|
|
662
|
-
StartWorkflowInputModel,
|
|
663
|
-
StartWorkflowContract,
|
|
664
|
-
ResumeWorkflowContract,
|
|
665
|
-
PauseWorkflowContract,
|
|
666
|
-
ListInstancesContract,
|
|
667
|
-
InstanceTimedOutEvent,
|
|
668
|
-
InstanceStatusEnum,
|
|
669
|
-
InstanceStartedEvent,
|
|
670
|
-
InstanceResumedEvent,
|
|
671
|
-
InstancePausedEvent,
|
|
672
|
-
InstanceFailedEvent,
|
|
673
|
-
InstanceCompletedEvent,
|
|
674
|
-
InstanceCancelledEvent,
|
|
675
|
-
GetInstanceContract,
|
|
676
|
-
CancelWorkflowContract
|
|
677
|
-
};
|
|
1
|
+
import{defineEnum as X}from"@contractspec/lib.schema";var z=X("InstanceStatus",["PENDING","RUNNING","WAITING","PAUSED","COMPLETED","CANCELLED","FAILED","TIMEOUT"]);import{defineEvent as G}from"@contractspec/lib.contracts-spec";import{defineSchemaModel as D,ScalarTypeEnum as C}from"@contractspec/lib.schema";var j=D({name:"InstanceEventPayload",description:"Base payload for instance events",fields:{instanceId:{type:C.String_unsecure(),isOptional:!1},workflowId:{type:C.String_unsecure(),isOptional:!1},workflowKey:{type:C.String_unsecure(),isOptional:!1},status:{type:C.String_unsecure(),isOptional:!1},referenceId:{type:C.String_unsecure(),isOptional:!0},referenceType:{type:C.String_unsecure(),isOptional:!0},triggeredBy:{type:C.String_unsecure(),isOptional:!1},organizationId:{type:C.String_unsecure(),isOptional:!1},timestamp:{type:C.DateTime(),isOptional:!1}}}),U=D({name:"StepTransitionEventPayload",description:"Payload for step transition events",fields:{instanceId:{type:C.String_unsecure(),isOptional:!1},workflowId:{type:C.String_unsecure(),isOptional:!1},fromStepKey:{type:C.String_unsecure(),isOptional:!0},toStepKey:{type:C.String_unsecure(),isOptional:!1},action:{type:C.String_unsecure(),isOptional:!0},executedBy:{type:C.String_unsecure(),isOptional:!1},timestamp:{type:C.DateTime(),isOptional:!1}}}),Y=D({name:"InstanceCompletedEventPayload",description:"Payload when instance completes",fields:{instanceId:{type:C.String_unsecure(),isOptional:!1},workflowId:{type:C.String_unsecure(),isOptional:!1},workflowKey:{type:C.String_unsecure(),isOptional:!1},outcome:{type:C.String_unsecure(),isOptional:!1},referenceId:{type:C.String_unsecure(),isOptional:!0},referenceType:{type:C.String_unsecure(),isOptional:!0},duration:{type:C.Int_unsecure(),isOptional:!1},timestamp:{type:C.DateTime(),isOptional:!1}}}),Z=G({meta:{key:"workflow.instance.started",version:"1.0.0",description:"A new workflow instance has been started.",stability:"stable",owners:["@workflow-team"],tags:["workflow","instance","started"]},payload:j}),_=G({meta:{key:"workflow.step.entered",version:"1.0.0",description:"A workflow instance has entered a new step.",stability:"stable",owners:["@workflow-team"],tags:["workflow","step","entered"]},payload:U}),$=G({meta:{key:"workflow.step.exited",version:"1.0.0",description:"A workflow instance has exited a step.",stability:"stable",owners:["@workflow-team"],tags:["workflow","step","exited"]},payload:U}),Q=G({meta:{key:"workflow.instance.completed",version:"1.0.0",description:"A workflow instance has completed.",stability:"stable",owners:["@workflow-team"],tags:["workflow","instance","completed"]},payload:Y}),b=G({meta:{key:"workflow.instance.cancelled",version:"1.0.0",description:"A workflow instance has been cancelled.",stability:"stable",owners:["@workflow-team"],tags:["workflow","instance","cancelled"]},payload:j}),v=G({meta:{key:"workflow.instance.paused",version:"1.0.0",description:"A workflow instance has been paused.",stability:"stable",owners:["@workflow-team"],tags:["workflow","instance","paused"]},payload:j}),O=G({meta:{key:"workflow.instance.resumed",version:"1.0.0",description:"A workflow instance has been resumed.",stability:"stable",owners:["@workflow-team"],tags:["workflow","instance","resumed"]},payload:j}),R=G({meta:{key:"workflow.instance.failed",version:"1.0.0",description:"A workflow instance has failed.",stability:"stable",owners:["@workflow-team"],tags:["workflow","instance","failed"]},payload:j}),N=G({meta:{key:"workflow.instance.timedOut",version:"1.0.0",description:"A workflow instance has timed out.",stability:"stable",owners:["@workflow-team"],tags:["workflow","instance","timeout"]},payload:j});import{defineSchemaModel as B,ScalarTypeEnum as x}from"@contractspec/lib.schema";var g=B({name:"WorkflowInstanceModel",description:"A running workflow instance",fields:{id:{type:x.String_unsecure(),isOptional:!1},workflowDefinitionId:{type:x.String_unsecure(),isOptional:!1},referenceId:{type:x.String_unsecure(),isOptional:!0},referenceType:{type:x.String_unsecure(),isOptional:!0},status:{type:z,isOptional:!1},currentStepId:{type:x.String_unsecure(),isOptional:!0},contextData:{type:x.JSON(),isOptional:!0},triggeredBy:{type:x.String_unsecure(),isOptional:!1},organizationId:{type:x.String_unsecure(),isOptional:!1},priority:{type:x.Int_unsecure(),isOptional:!1},dueAt:{type:x.DateTime(),isOptional:!0},outcome:{type:x.String_unsecure(),isOptional:!0},resultData:{type:x.JSON(),isOptional:!0},errorMessage:{type:x.String_unsecure(),isOptional:!0},createdAt:{type:x.DateTime(),isOptional:!1},startedAt:{type:x.DateTime(),isOptional:!0},completedAt:{type:x.DateTime(),isOptional:!0}}}),H=B({name:"StartWorkflowInput",description:"Input for starting a workflow",fields:{workflowKey:{type:x.NonEmptyString(),isOptional:!1},contextData:{type:x.JSON(),isOptional:!0},referenceId:{type:x.String_unsecure(),isOptional:!0},referenceType:{type:x.String_unsecure(),isOptional:!0},priority:{type:x.Int_unsecure(),isOptional:!0},dueAt:{type:x.DateTime(),isOptional:!0}}}),J=B({name:"TransitionInput",description:"Input for transitioning a workflow",fields:{instanceId:{type:x.String_unsecure(),isOptional:!1},action:{type:x.NonEmptyString(),isOptional:!1},data:{type:x.JSON(),isOptional:!0},comment:{type:x.String_unsecure(),isOptional:!0}}}),K=B({name:"TransitionResult",description:"Result of a workflow transition",fields:{success:{type:x.Boolean(),isOptional:!1},instance:{type:g,isOptional:!1},previousStepKey:{type:x.String_unsecure(),isOptional:!0},currentStepKey:{type:x.String_unsecure(),isOptional:!0},message:{type:x.String_unsecure(),isOptional:!0}}});import{defineCommand as A,defineQuery as V}from"@contractspec/lib.contracts-spec/operations";import{defineSchemaModel as q,ScalarTypeEnum as F}from"@contractspec/lib.schema";var L=["@example.workflow-system"],P=A({meta:{key:"workflow.instance.start",version:"1.0.0",stability:"stable",owners:[...L],tags:["workflow","instance","start"],description:"Start a new workflow instance.",goal:"Initiate a workflow for a business process.",context:"Order creation, request submission, etc."},io:{input:H,output:g},policy:{auth:"user"},sideEffects:{emits:[{key:"workflow.instance.started",version:"1.0.0",when:"Workflow starts",payload:g},{key:"workflow.step.entered",version:"1.0.0",when:"First step entered",payload:g}],audit:["workflow.instance.started"]},acceptance:{scenarios:[{key:"start-workflow-happy-path",given:["Workflow definition exists"],when:["User starts workflow"],then:["Instance is created and started"]}],examples:[{key:"start-onboarding",input:{workflowKey:"onboarding-v1",context:{employeeId:"emp-123"}},output:{id:"inst-456",status:"running"}}]}}),k=A({meta:{key:"workflow.instance.transition",version:"1.0.0",stability:"stable",owners:[...L],tags:["workflow","instance","transition","state-machine"],description:"Transition a workflow instance to the next step.",goal:"Move workflow forward based on action.",context:"Task completion, approval decisions."},io:{input:J,output:K},policy:{auth:"user"},sideEffects:{emits:[{key:"workflow.step.exited",version:"1.0.0",when:"Step is exited",payload:g},{key:"workflow.step.entered",version:"1.0.0",when:"New step is entered",payload:g},{key:"workflow.instance.completed",version:"1.0.0",when:"Workflow reaches end",payload:g}],audit:["workflow.instance.transitioned"]},acceptance:{scenarios:[{key:"transition-workflow-happy-path",given:["Workflow instance is waiting at step"],when:["User provides input"],then:["Instance moves to next step"]}],examples:[{key:"complete-task",input:{instanceId:"inst-456",action:"complete",data:{approved:!0}},output:{success:!0,nextStep:"notify-hr"}}]}}),w=A({meta:{key:"workflow.instance.pause",version:"1.0.0",stability:"stable",owners:[...L],tags:["workflow","instance","pause"],description:"Pause a running workflow instance.",goal:"Temporarily halt workflow execution.",context:"Administrative action, emergency stop."},io:{input:q({name:"PauseResumeInput",fields:{instanceId:{type:F.String_unsecure(),isOptional:!1},reason:{type:F.String_unsecure(),isOptional:!0}}}),output:g},policy:{auth:"user"},sideEffects:{emits:[{key:"workflow.instance.paused",version:"1.0.0",when:"Workflow is paused",payload:g}],audit:["workflow.instance.paused"]},acceptance:{scenarios:[{key:"pause-workflow-happy-path",given:["Workflow is running"],when:["Admin pauses workflow"],then:["Instance status becomes PAUSED"]}],examples:[{key:"pause-maintenance",input:{instanceId:"inst-456",reason:"System maintenance"},output:{id:"inst-456",status:"paused"}}]}}),I=A({meta:{key:"workflow.instance.resume",version:"1.0.0",stability:"stable",owners:[...L],tags:["workflow","instance","resume"],description:"Resume a paused workflow instance.",goal:"Continue workflow execution.",context:"Administrative action."},io:{input:q({name:"PauseResumeInput",fields:{instanceId:{type:F.String_unsecure(),isOptional:!1},reason:{type:F.String_unsecure(),isOptional:!0}}}),output:g},policy:{auth:"user"},sideEffects:{emits:[{key:"workflow.instance.resumed",version:"1.0.0",when:"Workflow is resumed",payload:g}],audit:["workflow.instance.resumed"]},acceptance:{scenarios:[{key:"resume-workflow-happy-path",given:["Workflow is paused"],when:["Admin resumes workflow"],then:["Instance status becomes RUNNING"]}],examples:[{key:"resume-normal",input:{instanceId:"inst-456",reason:"Issue resolved"},output:{id:"inst-456",status:"running"}}]}}),W=A({meta:{key:"workflow.instance.cancel",version:"1.0.0",stability:"stable",owners:[...L],tags:["workflow","instance","cancel"],description:"Cancel a workflow instance.",goal:"Terminate workflow without completion.",context:"User request, system cancellation."},io:{input:q({name:"CancelWorkflowInput",fields:{instanceId:{type:F.String_unsecure(),isOptional:!1},reason:{type:F.String_unsecure(),isOptional:!1}}}),output:g},policy:{auth:"user"},sideEffects:{emits:[{key:"workflow.instance.cancelled",version:"1.0.0",when:"Workflow is cancelled",payload:g}],audit:["workflow.instance.cancelled"]},acceptance:{scenarios:[{key:"cancel-workflow-happy-path",given:["Workflow is running"],when:["User cancels workflow"],then:["Instance status becomes CANCELLED"]}],examples:[{key:"cancel-mistake",input:{instanceId:"inst-456",reason:"Created by mistake"},output:{id:"inst-456",status:"cancelled"}}]}}),t=V({meta:{key:"workflow.instance.list",version:"1.0.0",stability:"stable",owners:[...L],tags:["workflow","instance","list"],description:"List workflow instances with filtering.",goal:"Browse and search running workflows.",context:"Dashboard, monitoring."},io:{input:q({name:"ListInstancesInput",fields:{workflowKey:{type:F.String_unsecure(),isOptional:!0},status:{type:z,isOptional:!0},referenceType:{type:F.String_unsecure(),isOptional:!0},referenceId:{type:F.String_unsecure(),isOptional:!0},triggeredBy:{type:F.String_unsecure(),isOptional:!0},limit:{type:F.Int_unsecure(),isOptional:!0,defaultValue:20},offset:{type:F.Int_unsecure(),isOptional:!0,defaultValue:0}}}),output:q({name:"ListInstancesOutput",fields:{instances:{type:g,isArray:!0,isOptional:!1},total:{type:F.Int_unsecure(),isOptional:!1}}})},policy:{auth:"user"},acceptance:{scenarios:[{key:"list-instances-happy-path",given:["Workflow instances exist"],when:["User lists instances"],then:["List of instances is returned"]}],examples:[{key:"list-running",input:{status:"running",limit:10},output:{instances:[],total:5}}]}}),h=V({meta:{key:"workflow.instance.get",version:"1.0.0",stability:"stable",owners:[...L],tags:["workflow","instance","get"],description:"Get a workflow instance with details.",goal:"View workflow instance details.",context:"Instance detail view."},io:{input:q({name:"GetInstanceInput",fields:{instanceId:{type:F.String_unsecure(),isOptional:!1}}}),output:g},policy:{auth:"user"},acceptance:{scenarios:[{key:"get-instance-happy-path",given:["Instance exists"],when:["User requests instance details"],then:["Instance details are returned"]}],examples:[{key:"get-details",input:{instanceId:"inst-456"},output:{id:"inst-456",workflowKey:"onboarding-v1"}}]}});export{g as WorkflowInstanceModel,k as TransitionWorkflowContract,K as TransitionResultModel,J as TransitionInputModel,$ as StepExitedEvent,_ as StepEnteredEvent,H as StartWorkflowInputModel,P as StartWorkflowContract,I as ResumeWorkflowContract,w as PauseWorkflowContract,t as ListInstancesContract,N as InstanceTimedOutEvent,z as InstanceStatusEnum,Z as InstanceStartedEvent,O as InstanceResumedEvent,v as InstancePausedEvent,R as InstanceFailedEvent,Q as InstanceCompletedEvent,b as InstanceCancelledEvent,h as GetInstanceContract,W as CancelWorkflowContract};
|