@contractspec/example.workflow-system 3.7.5 → 3.7.7
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/README.md +69 -119
- package/dist/approval/approval.event.js +1 -1
- package/dist/approval/approval.handler.d.ts +1 -1
- package/dist/approval/index.d.ts +4 -4
- package/dist/approval/index.js +1 -1
- package/dist/browser/approval/approval.event.js +1 -1
- package/dist/browser/approval/index.js +1 -1
- package/dist/browser/entities/index.js +166 -166
- package/dist/browser/index.js +1800 -1802
- package/dist/browser/instance/index.js +210 -210
- package/dist/browser/instance/instance.event.js +1 -1
- package/dist/browser/ui/hooks/index.js +1 -1
- package/dist/browser/ui/hooks/useWorkflowList.js +1 -1
- package/dist/browser/ui/index.js +1 -1
- package/dist/entities/index.d.ts +53 -53
- package/dist/entities/index.js +166 -166
- package/dist/index.d.ts +5 -5
- package/dist/index.js +1800 -1802
- package/dist/instance/index.d.ts +3 -3
- package/dist/instance/index.js +210 -210
- package/dist/instance/instance.event.js +1 -1
- package/dist/instance/instance.handler.d.ts +1 -1
- package/dist/shared/index.d.ts +1 -1
- package/dist/shared/mock-data.d.ts +1 -1
- package/dist/ui/hooks/index.js +1 -1
- package/dist/ui/hooks/useWorkflowList.js +1 -1
- package/dist/ui/index.d.ts +1 -1
- package/dist/ui/index.js +1 -1
- package/dist/workflow/index.d.ts +4 -4
- package/dist/workflow/workflow.handler.d.ts +1 -1
- package/package.json +10 -10
|
@@ -112,82 +112,160 @@ var ApprovalCommentEntity = defineEntity({
|
|
|
112
112
|
indexes: [index.on(["approvalRequestId", "createdAt"])]
|
|
113
113
|
});
|
|
114
114
|
|
|
115
|
-
// src/entities/
|
|
115
|
+
// src/entities/instance.ts
|
|
116
116
|
import {
|
|
117
117
|
defineEntity as defineEntity2,
|
|
118
118
|
defineEntityEnum as defineEntityEnum2,
|
|
119
119
|
field as field2,
|
|
120
120
|
index as index2
|
|
121
121
|
} from "@contractspec/lib.schema";
|
|
122
|
-
var
|
|
123
|
-
name: "
|
|
124
|
-
values: [
|
|
122
|
+
var InstanceStatusEnum = defineEntityEnum2({
|
|
123
|
+
name: "InstanceStatus",
|
|
124
|
+
values: [
|
|
125
|
+
"PENDING",
|
|
126
|
+
"RUNNING",
|
|
127
|
+
"WAITING",
|
|
128
|
+
"PAUSED",
|
|
129
|
+
"COMPLETED",
|
|
130
|
+
"CANCELLED",
|
|
131
|
+
"FAILED",
|
|
132
|
+
"TIMEOUT"
|
|
133
|
+
],
|
|
125
134
|
schema: "workflow",
|
|
126
|
-
description: "Status of a workflow
|
|
135
|
+
description: "Status of a workflow instance."
|
|
127
136
|
});
|
|
128
|
-
var
|
|
129
|
-
name: "
|
|
130
|
-
values: [
|
|
137
|
+
var StepExecutionStatusEnum = defineEntityEnum2({
|
|
138
|
+
name: "StepExecutionStatus",
|
|
139
|
+
values: [
|
|
140
|
+
"PENDING",
|
|
141
|
+
"ACTIVE",
|
|
142
|
+
"COMPLETED",
|
|
143
|
+
"SKIPPED",
|
|
144
|
+
"FAILED",
|
|
145
|
+
"TIMEOUT"
|
|
146
|
+
],
|
|
131
147
|
schema: "workflow",
|
|
132
|
-
description: "
|
|
148
|
+
description: "Status of a step execution."
|
|
133
149
|
});
|
|
134
|
-
var
|
|
135
|
-
name: "
|
|
136
|
-
description: "A
|
|
150
|
+
var WorkflowInstanceEntity = defineEntity2({
|
|
151
|
+
name: "WorkflowInstance",
|
|
152
|
+
description: "A running instance of a workflow definition.",
|
|
137
153
|
schema: "workflow",
|
|
138
|
-
map: "
|
|
154
|
+
map: "workflow_instance",
|
|
139
155
|
fields: {
|
|
140
|
-
id: field2.id({ description: "Unique
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
156
|
+
id: field2.id({ description: "Unique instance ID" }),
|
|
157
|
+
workflowDefinitionId: field2.foreignKey(),
|
|
158
|
+
referenceId: field2.string({
|
|
159
|
+
isOptional: true,
|
|
160
|
+
description: "External reference (e.g., order ID)"
|
|
144
161
|
}),
|
|
145
|
-
|
|
162
|
+
referenceType: field2.string({
|
|
146
163
|
isOptional: true,
|
|
147
|
-
description:
|
|
164
|
+
description: 'Type of reference (e.g., "Order")'
|
|
148
165
|
}),
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
166
|
+
status: field2.enum("InstanceStatus", { default: "PENDING" }),
|
|
167
|
+
currentStepId: field2.string({
|
|
168
|
+
isOptional: true,
|
|
169
|
+
description: "Current step being executed"
|
|
170
|
+
}),
|
|
171
|
+
contextData: field2.json({ description: "Data context for this instance" }),
|
|
172
|
+
triggeredBy: field2.foreignKey({
|
|
173
|
+
description: "User who triggered the workflow"
|
|
152
174
|
}),
|
|
153
|
-
|
|
154
|
-
triggerType: field2.enum("WorkflowTriggerType", { default: "MANUAL" }),
|
|
155
|
-
triggerConfig: field2.json({
|
|
175
|
+
triggerSource: field2.string({
|
|
156
176
|
isOptional: true,
|
|
157
|
-
description: "
|
|
177
|
+
description: 'Source of trigger (e.g., "api", "ui")'
|
|
178
|
+
}),
|
|
179
|
+
organizationId: field2.foreignKey(),
|
|
180
|
+
priority: field2.int({
|
|
181
|
+
default: 0,
|
|
182
|
+
description: "Processing priority (higher = more urgent)"
|
|
158
183
|
}),
|
|
159
|
-
|
|
184
|
+
dueAt: field2.dateTime({
|
|
160
185
|
isOptional: true,
|
|
161
|
-
description: "
|
|
186
|
+
description: "When this instance should complete"
|
|
162
187
|
}),
|
|
163
|
-
|
|
188
|
+
outcome: field2.string({
|
|
164
189
|
isOptional: true,
|
|
165
|
-
description:
|
|
190
|
+
description: 'Final outcome (e.g., "approved", "rejected")'
|
|
166
191
|
}),
|
|
167
|
-
|
|
192
|
+
resultData: field2.json({
|
|
168
193
|
isOptional: true,
|
|
169
|
-
description: "
|
|
194
|
+
description: "Final result data"
|
|
170
195
|
}),
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
description: "User who created this workflow"
|
|
196
|
+
errorMessage: field2.string({
|
|
197
|
+
isOptional: true,
|
|
198
|
+
description: "Error message if failed"
|
|
175
199
|
}),
|
|
176
200
|
createdAt: field2.createdAt(),
|
|
177
201
|
updatedAt: field2.updatedAt(),
|
|
178
|
-
|
|
202
|
+
startedAt: field2.dateTime({ isOptional: true }),
|
|
203
|
+
completedAt: field2.dateTime({ isOptional: true }),
|
|
204
|
+
workflowDefinition: field2.belongsTo("WorkflowDefinition", ["workflowDefinitionId"], ["id"]),
|
|
205
|
+
currentStep: field2.belongsTo("WorkflowStep", ["currentStepId"], ["id"]),
|
|
206
|
+
stepExecutions: field2.hasMany("StepExecution"),
|
|
207
|
+
approvalRequests: field2.hasMany("ApprovalRequest")
|
|
208
|
+
},
|
|
209
|
+
indexes: [
|
|
210
|
+
index2.on(["organizationId", "status"]),
|
|
211
|
+
index2.on(["workflowDefinitionId", "status"]),
|
|
212
|
+
index2.on(["referenceType", "referenceId"]),
|
|
213
|
+
index2.on(["triggeredBy", "status"]),
|
|
214
|
+
index2.on(["status", "dueAt"]),
|
|
215
|
+
index2.on(["createdAt"])
|
|
216
|
+
],
|
|
217
|
+
enums: [InstanceStatusEnum]
|
|
218
|
+
});
|
|
219
|
+
var StepExecutionEntity = defineEntity2({
|
|
220
|
+
name: "StepExecution",
|
|
221
|
+
description: "Execution record of a step within a workflow instance.",
|
|
222
|
+
schema: "workflow",
|
|
223
|
+
map: "step_execution",
|
|
224
|
+
fields: {
|
|
225
|
+
id: field2.id({ description: "Unique execution ID" }),
|
|
226
|
+
workflowInstanceId: field2.foreignKey(),
|
|
227
|
+
workflowStepId: field2.foreignKey(),
|
|
228
|
+
status: field2.enum("StepExecutionStatus", { default: "PENDING" }),
|
|
229
|
+
executionOrder: field2.int({
|
|
230
|
+
default: 0,
|
|
231
|
+
description: "Order of execution within instance"
|
|
232
|
+
}),
|
|
233
|
+
inputData: field2.json({
|
|
179
234
|
isOptional: true,
|
|
180
|
-
description: "
|
|
235
|
+
description: "Data when entering step"
|
|
236
|
+
}),
|
|
237
|
+
outputData: field2.json({
|
|
238
|
+
isOptional: true,
|
|
239
|
+
description: "Data when exiting step"
|
|
240
|
+
}),
|
|
241
|
+
actionTaken: field2.string({
|
|
242
|
+
isOptional: true,
|
|
243
|
+
description: 'Action that caused transition (e.g., "approve")'
|
|
181
244
|
}),
|
|
182
|
-
|
|
183
|
-
|
|
245
|
+
transitionedTo: field2.string({
|
|
246
|
+
isOptional: true,
|
|
247
|
+
description: "Step key transitioned to"
|
|
248
|
+
}),
|
|
249
|
+
executedBy: field2.string({
|
|
250
|
+
isOptional: true,
|
|
251
|
+
description: "User who completed this step"
|
|
252
|
+
}),
|
|
253
|
+
errorMessage: field2.string({ isOptional: true }),
|
|
254
|
+
errorDetails: field2.json({ isOptional: true }),
|
|
255
|
+
retryCount: field2.int({ default: 0 }),
|
|
256
|
+
createdAt: field2.createdAt(),
|
|
257
|
+
updatedAt: field2.updatedAt(),
|
|
258
|
+
startedAt: field2.dateTime({ isOptional: true }),
|
|
259
|
+
completedAt: field2.dateTime({ isOptional: true }),
|
|
260
|
+
workflowInstance: field2.belongsTo("WorkflowInstance", ["workflowInstanceId"], ["id"], { onDelete: "Cascade" }),
|
|
261
|
+
workflowStep: field2.belongsTo("WorkflowStep", ["workflowStepId"], ["id"])
|
|
184
262
|
},
|
|
185
263
|
indexes: [
|
|
186
|
-
index2.
|
|
187
|
-
index2.on(["
|
|
188
|
-
index2.on(["
|
|
264
|
+
index2.on(["workflowInstanceId", "executionOrder"]),
|
|
265
|
+
index2.on(["workflowInstanceId", "workflowStepId"]),
|
|
266
|
+
index2.on(["status"])
|
|
189
267
|
],
|
|
190
|
-
enums: [
|
|
268
|
+
enums: [StepExecutionStatusEnum]
|
|
191
269
|
});
|
|
192
270
|
|
|
193
271
|
// src/entities/step.ts
|
|
@@ -310,160 +388,82 @@ var WorkflowStepEntity = defineEntity3({
|
|
|
310
388
|
enums: [StepTypeEnum, ApprovalModeEnum]
|
|
311
389
|
});
|
|
312
390
|
|
|
313
|
-
// src/entities/
|
|
391
|
+
// src/entities/workflow.ts
|
|
314
392
|
import {
|
|
315
393
|
defineEntity as defineEntity4,
|
|
316
394
|
defineEntityEnum as defineEntityEnum4,
|
|
317
395
|
field as field4,
|
|
318
396
|
index as index4
|
|
319
397
|
} from "@contractspec/lib.schema";
|
|
320
|
-
var
|
|
321
|
-
name: "
|
|
322
|
-
values: [
|
|
323
|
-
"PENDING",
|
|
324
|
-
"RUNNING",
|
|
325
|
-
"WAITING",
|
|
326
|
-
"PAUSED",
|
|
327
|
-
"COMPLETED",
|
|
328
|
-
"CANCELLED",
|
|
329
|
-
"FAILED",
|
|
330
|
-
"TIMEOUT"
|
|
331
|
-
],
|
|
398
|
+
var WorkflowStatusEnum = defineEntityEnum4({
|
|
399
|
+
name: "WorkflowStatus",
|
|
400
|
+
values: ["DRAFT", "ACTIVE", "DEPRECATED", "ARCHIVED"],
|
|
332
401
|
schema: "workflow",
|
|
333
|
-
description: "Status of a workflow
|
|
402
|
+
description: "Status of a workflow definition."
|
|
334
403
|
});
|
|
335
|
-
var
|
|
336
|
-
name: "
|
|
337
|
-
values: [
|
|
338
|
-
"PENDING",
|
|
339
|
-
"ACTIVE",
|
|
340
|
-
"COMPLETED",
|
|
341
|
-
"SKIPPED",
|
|
342
|
-
"FAILED",
|
|
343
|
-
"TIMEOUT"
|
|
344
|
-
],
|
|
404
|
+
var WorkflowTriggerTypeEnum = defineEntityEnum4({
|
|
405
|
+
name: "WorkflowTriggerType",
|
|
406
|
+
values: ["MANUAL", "EVENT", "SCHEDULED", "API"],
|
|
345
407
|
schema: "workflow",
|
|
346
|
-
description: "
|
|
408
|
+
description: "What triggers workflow instantiation."
|
|
347
409
|
});
|
|
348
|
-
var
|
|
349
|
-
name: "
|
|
350
|
-
description: "A
|
|
410
|
+
var WorkflowDefinitionEntity = defineEntity4({
|
|
411
|
+
name: "WorkflowDefinition",
|
|
412
|
+
description: "A workflow blueprint that defines the process structure.",
|
|
351
413
|
schema: "workflow",
|
|
352
|
-
map: "
|
|
414
|
+
map: "workflow_definition",
|
|
353
415
|
fields: {
|
|
354
|
-
id: field4.id({ description: "Unique
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
description: "External reference (e.g., order ID)"
|
|
359
|
-
}),
|
|
360
|
-
referenceType: field4.string({
|
|
361
|
-
isOptional: true,
|
|
362
|
-
description: 'Type of reference (e.g., "Order")'
|
|
416
|
+
id: field4.id({ description: "Unique workflow definition ID" }),
|
|
417
|
+
name: field4.string({ description: "Human-readable workflow name" }),
|
|
418
|
+
key: field4.string({
|
|
419
|
+
description: 'Unique key for referencing (e.g., "purchase_approval")'
|
|
363
420
|
}),
|
|
364
|
-
|
|
365
|
-
currentStepId: field4.string({
|
|
421
|
+
description: field4.string({
|
|
366
422
|
isOptional: true,
|
|
367
|
-
description: "
|
|
423
|
+
description: "Detailed description"
|
|
368
424
|
}),
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
description: "
|
|
425
|
+
version: field4.int({
|
|
426
|
+
default: 1,
|
|
427
|
+
description: "Version number for versioning definitions"
|
|
372
428
|
}),
|
|
373
|
-
|
|
429
|
+
status: field4.enum("WorkflowStatus", { default: "DRAFT" }),
|
|
430
|
+
triggerType: field4.enum("WorkflowTriggerType", { default: "MANUAL" }),
|
|
431
|
+
triggerConfig: field4.json({
|
|
374
432
|
isOptional: true,
|
|
375
|
-
description:
|
|
376
|
-
}),
|
|
377
|
-
organizationId: field4.foreignKey(),
|
|
378
|
-
priority: field4.int({
|
|
379
|
-
default: 0,
|
|
380
|
-
description: "Processing priority (higher = more urgent)"
|
|
433
|
+
description: "Trigger-specific configuration"
|
|
381
434
|
}),
|
|
382
|
-
|
|
435
|
+
initialStepId: field4.string({
|
|
383
436
|
isOptional: true,
|
|
384
|
-
description: "
|
|
437
|
+
description: "First step when workflow starts"
|
|
385
438
|
}),
|
|
386
|
-
|
|
439
|
+
featureFlagKey: field4.string({
|
|
387
440
|
isOptional: true,
|
|
388
|
-
description:
|
|
441
|
+
description: "Feature flag to control availability"
|
|
389
442
|
}),
|
|
390
|
-
|
|
443
|
+
settings: field4.json({
|
|
391
444
|
isOptional: true,
|
|
392
|
-
description: "
|
|
445
|
+
description: "Workflow-wide settings"
|
|
393
446
|
}),
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
447
|
+
metadata: field4.json({ isOptional: true, description: "Custom metadata" }),
|
|
448
|
+
organizationId: field4.foreignKey({ description: "Owning organization" }),
|
|
449
|
+
createdBy: field4.foreignKey({
|
|
450
|
+
description: "User who created this workflow"
|
|
397
451
|
}),
|
|
398
452
|
createdAt: field4.createdAt(),
|
|
399
453
|
updatedAt: field4.updatedAt(),
|
|
400
|
-
|
|
401
|
-
completedAt: field4.dateTime({ isOptional: true }),
|
|
402
|
-
workflowDefinition: field4.belongsTo("WorkflowDefinition", ["workflowDefinitionId"], ["id"]),
|
|
403
|
-
currentStep: field4.belongsTo("WorkflowStep", ["currentStepId"], ["id"]),
|
|
404
|
-
stepExecutions: field4.hasMany("StepExecution"),
|
|
405
|
-
approvalRequests: field4.hasMany("ApprovalRequest")
|
|
406
|
-
},
|
|
407
|
-
indexes: [
|
|
408
|
-
index4.on(["organizationId", "status"]),
|
|
409
|
-
index4.on(["workflowDefinitionId", "status"]),
|
|
410
|
-
index4.on(["referenceType", "referenceId"]),
|
|
411
|
-
index4.on(["triggeredBy", "status"]),
|
|
412
|
-
index4.on(["status", "dueAt"]),
|
|
413
|
-
index4.on(["createdAt"])
|
|
414
|
-
],
|
|
415
|
-
enums: [InstanceStatusEnum]
|
|
416
|
-
});
|
|
417
|
-
var StepExecutionEntity = defineEntity4({
|
|
418
|
-
name: "StepExecution",
|
|
419
|
-
description: "Execution record of a step within a workflow instance.",
|
|
420
|
-
schema: "workflow",
|
|
421
|
-
map: "step_execution",
|
|
422
|
-
fields: {
|
|
423
|
-
id: field4.id({ description: "Unique execution ID" }),
|
|
424
|
-
workflowInstanceId: field4.foreignKey(),
|
|
425
|
-
workflowStepId: field4.foreignKey(),
|
|
426
|
-
status: field4.enum("StepExecutionStatus", { default: "PENDING" }),
|
|
427
|
-
executionOrder: field4.int({
|
|
428
|
-
default: 0,
|
|
429
|
-
description: "Order of execution within instance"
|
|
430
|
-
}),
|
|
431
|
-
inputData: field4.json({
|
|
432
|
-
isOptional: true,
|
|
433
|
-
description: "Data when entering step"
|
|
434
|
-
}),
|
|
435
|
-
outputData: field4.json({
|
|
436
|
-
isOptional: true,
|
|
437
|
-
description: "Data when exiting step"
|
|
438
|
-
}),
|
|
439
|
-
actionTaken: field4.string({
|
|
454
|
+
publishedAt: field4.dateTime({
|
|
440
455
|
isOptional: true,
|
|
441
|
-
description:
|
|
442
|
-
}),
|
|
443
|
-
transitionedTo: field4.string({
|
|
444
|
-
isOptional: true,
|
|
445
|
-
description: "Step key transitioned to"
|
|
446
|
-
}),
|
|
447
|
-
executedBy: field4.string({
|
|
448
|
-
isOptional: true,
|
|
449
|
-
description: "User who completed this step"
|
|
456
|
+
description: "When workflow was activated"
|
|
450
457
|
}),
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
retryCount: field4.int({ default: 0 }),
|
|
454
|
-
createdAt: field4.createdAt(),
|
|
455
|
-
updatedAt: field4.updatedAt(),
|
|
456
|
-
startedAt: field4.dateTime({ isOptional: true }),
|
|
457
|
-
completedAt: field4.dateTime({ isOptional: true }),
|
|
458
|
-
workflowInstance: field4.belongsTo("WorkflowInstance", ["workflowInstanceId"], ["id"], { onDelete: "Cascade" }),
|
|
459
|
-
workflowStep: field4.belongsTo("WorkflowStep", ["workflowStepId"], ["id"])
|
|
458
|
+
steps: field4.hasMany("WorkflowStep"),
|
|
459
|
+
instances: field4.hasMany("WorkflowInstance")
|
|
460
460
|
},
|
|
461
461
|
indexes: [
|
|
462
|
-
index4.
|
|
463
|
-
index4.on(["
|
|
464
|
-
index4.on(["
|
|
462
|
+
index4.unique(["organizationId", "key", "version"]),
|
|
463
|
+
index4.on(["organizationId", "status"]),
|
|
464
|
+
index4.on(["key", "version"])
|
|
465
465
|
],
|
|
466
|
-
enums: [
|
|
466
|
+
enums: [WorkflowStatusEnum, WorkflowTriggerTypeEnum]
|
|
467
467
|
});
|
|
468
468
|
// src/entities/index.ts
|
|
469
469
|
var workflowSystemEntities = [
|