@contractspec/example.workflow-system 3.8.8 → 3.8.10

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 (95) hide show
  1. package/dist/approval/approval.enum.js +1 -22
  2. package/dist/approval/approval.event.js +1 -112
  3. package/dist/approval/approval.operations.js +1 -369
  4. package/dist/approval/approval.schema.js +1 -73
  5. package/dist/approval/index.js +1 -484
  6. package/dist/browser/approval/approval.enum.js +1 -22
  7. package/dist/browser/approval/approval.event.js +1 -112
  8. package/dist/browser/approval/approval.operations.js +1 -369
  9. package/dist/browser/approval/approval.schema.js +1 -73
  10. package/dist/browser/approval/index.js +1 -484
  11. package/dist/browser/docs/index.js +5 -49
  12. package/dist/browser/docs/workflow-system.docblock.js +5 -49
  13. package/dist/browser/entities/approval.js +1 -119
  14. package/dist/browser/entities/index.js +1 -508
  15. package/dist/browser/entities/instance.js +1 -161
  16. package/dist/browser/entities/step.js +1 -124
  17. package/dist/browser/entities/workflow.js +1 -82
  18. package/dist/browser/example.js +1 -42
  19. package/dist/browser/handlers/index.js +8 -253
  20. package/dist/browser/handlers/workflow.handlers.js +8 -253
  21. package/dist/browser/index.js +13 -3524
  22. package/dist/browser/instance/index.js +1 -677
  23. package/dist/browser/instance/instance.enum.js +1 -15
  24. package/dist/browser/instance/instance.event.js +1 -164
  25. package/dist/browser/instance/instance.handler.js +1 -356
  26. package/dist/browser/instance/instance.operations.js +1 -9
  27. package/dist/browser/instance/instance.schema.js +1 -101
  28. package/dist/browser/presentations/index.js +1 -109
  29. package/dist/browser/seeders/index.js +1 -3
  30. package/dist/browser/shared/demo-scenario.js +1 -213
  31. package/dist/browser/shared/index.js +1 -3
  32. package/dist/browser/shared/mock-data.js +1 -11
  33. package/dist/browser/state-machine/index.js +1 -6
  34. package/dist/browser/tests/operations.test-spec.js +1 -6
  35. package/dist/browser/ui/WorkflowDashboard.js +1 -3
  36. package/dist/browser/ui/WorkflowDashboard.visualizations.js +1 -239
  37. package/dist/browser/ui/hooks/index.js +1 -3
  38. package/dist/browser/ui/hooks/useWorkflowList.js +1 -52
  39. package/dist/browser/ui/index.js +1 -56
  40. package/dist/browser/ui/renderers/index.js +5 -562
  41. package/dist/browser/ui/renderers/workflow.markdown.js +5 -562
  42. package/dist/browser/visualizations/catalog.js +1 -132
  43. package/dist/browser/visualizations/index.js +1 -133
  44. package/dist/browser/visualizations/selectors.js +1 -195
  45. package/dist/browser/workflow/index.js +1 -21
  46. package/dist/browser/workflow/workflow.enum.js +1 -36
  47. package/dist/browser/workflow/workflow.event.js +1 -6
  48. package/dist/browser/workflow/workflow.handler.js +1 -5
  49. package/dist/browser/workflow/workflow.operations.js +1 -8
  50. package/dist/browser/workflow/workflow.schema.js +1 -151
  51. package/dist/browser/workflow-system.capability.js +1 -5
  52. package/dist/browser/workflow-system.feature.js +1 -3
  53. package/dist/docs/index.js +5 -49
  54. package/dist/docs/workflow-system.docblock.js +5 -49
  55. package/dist/entities/approval.js +1 -119
  56. package/dist/entities/index.js +1 -508
  57. package/dist/entities/instance.js +1 -161
  58. package/dist/entities/step.js +1 -124
  59. package/dist/entities/workflow.js +1 -82
  60. package/dist/example.js +1 -42
  61. package/dist/handlers/index.js +8 -253
  62. package/dist/handlers/workflow.handlers.js +8 -253
  63. package/dist/index.js +13 -3524
  64. package/dist/instance/index.js +1 -677
  65. package/dist/instance/instance.enum.js +1 -15
  66. package/dist/instance/instance.event.js +1 -164
  67. package/dist/instance/instance.handler.js +1 -356
  68. package/dist/instance/instance.operations.js +1 -9
  69. package/dist/instance/instance.schema.js +1 -101
  70. package/dist/presentations/index.js +1 -109
  71. package/dist/seeders/index.js +1 -3
  72. package/dist/shared/demo-scenario.js +1 -213
  73. package/dist/shared/index.js +1 -3
  74. package/dist/shared/mock-data.js +1 -11
  75. package/dist/state-machine/index.js +1 -6
  76. package/dist/tests/operations.test-spec.js +1 -6
  77. package/dist/ui/WorkflowDashboard.js +1 -3
  78. package/dist/ui/WorkflowDashboard.visualizations.js +1 -239
  79. package/dist/ui/hooks/index.js +1 -3
  80. package/dist/ui/hooks/useWorkflowList.js +1 -52
  81. package/dist/ui/index.js +1 -56
  82. package/dist/ui/renderers/index.js +5 -562
  83. package/dist/ui/renderers/workflow.markdown.js +5 -562
  84. package/dist/visualizations/catalog.js +1 -132
  85. package/dist/visualizations/index.js +1 -133
  86. package/dist/visualizations/selectors.js +1 -195
  87. package/dist/workflow/index.js +1 -21
  88. package/dist/workflow/workflow.enum.js +1 -36
  89. package/dist/workflow/workflow.event.js +1 -6
  90. package/dist/workflow/workflow.handler.js +1 -5
  91. package/dist/workflow/workflow.operations.js +1 -8
  92. package/dist/workflow/workflow.schema.js +1 -151
  93. package/dist/workflow-system.capability.js +1 -5
  94. package/dist/workflow-system.feature.js +1 -3
  95. package/package.json +11 -11
@@ -1,485 +1,2 @@
1
1
  // @bun
2
- // src/approval/approval.enum.ts
3
- import { defineEnum } from "@contractspec/lib.schema";
4
- var ApprovalStatusEnum = defineEnum("ApprovalStatus", [
5
- "PENDING",
6
- "APPROVED",
7
- "REJECTED",
8
- "DELEGATED",
9
- "ESCALATED",
10
- "WITHDRAWN",
11
- "EXPIRED"
12
- ]);
13
- var ApprovalDecisionEnum = defineEnum("ApprovalDecision", [
14
- "APPROVE",
15
- "REJECT",
16
- "REQUEST_CHANGES",
17
- "DELEGATE",
18
- "ABSTAIN"
19
- ]);
20
-
21
- // src/approval/approval.event.ts
22
- import { defineEvent } from "@contractspec/lib.contracts-spec";
23
- import { defineSchemaModel, ScalarTypeEnum } from "@contractspec/lib.schema";
24
- var ApprovalRequestedPayload = defineSchemaModel({
25
- name: "ApprovalRequestedEventPayload",
26
- description: "Payload when approval is requested",
27
- fields: {
28
- requestId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
29
- instanceId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
30
- workflowKey: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
31
- approverId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
32
- approverRole: {
33
- type: ScalarTypeEnum.String_unsecure(),
34
- isOptional: true
35
- },
36
- title: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
37
- dueAt: { type: ScalarTypeEnum.DateTime(), isOptional: true },
38
- timestamp: { type: ScalarTypeEnum.DateTime(), isOptional: false }
39
- }
40
- });
41
- var ApprovalDecidedPayload = defineSchemaModel({
42
- name: "ApprovalDecidedEventPayload",
43
- description: "Payload when approval decision is made",
44
- fields: {
45
- requestId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
46
- instanceId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
47
- decision: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
48
- decidedBy: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
49
- comment: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
50
- timestamp: { type: ScalarTypeEnum.DateTime(), isOptional: false }
51
- }
52
- });
53
- var ApprovalDelegatedPayload = defineSchemaModel({
54
- name: "ApprovalDelegatedEventPayload",
55
- description: "Payload when approval is delegated",
56
- fields: {
57
- requestId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
58
- instanceId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
59
- fromUserId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
60
- toUserId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
61
- reason: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
62
- timestamp: { type: ScalarTypeEnum.DateTime(), isOptional: false }
63
- }
64
- });
65
- var ApprovalEscalatedPayload = defineSchemaModel({
66
- name: "ApprovalEscalatedEventPayload",
67
- description: "Payload when approval is escalated",
68
- fields: {
69
- requestId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
70
- instanceId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
71
- escalationLevel: {
72
- type: ScalarTypeEnum.Int_unsecure(),
73
- isOptional: false
74
- },
75
- escalatedTo: {
76
- type: ScalarTypeEnum.String_unsecure(),
77
- isOptional: false
78
- },
79
- reason: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
80
- timestamp: { type: ScalarTypeEnum.DateTime(), isOptional: false }
81
- }
82
- });
83
- var ApprovalRequestedEvent = defineEvent({
84
- meta: {
85
- key: "workflow.approval.requested",
86
- version: "1.0.0",
87
- description: "An approval has been requested.",
88
- stability: "stable",
89
- owners: ["@workflow-team"],
90
- tags: ["workflow", "approval", "requested"]
91
- },
92
- payload: ApprovalRequestedPayload
93
- });
94
- var ApprovalDecidedEvent = defineEvent({
95
- meta: {
96
- key: "workflow.approval.decided",
97
- version: "1.0.0",
98
- description: "An approval decision has been made.",
99
- stability: "stable",
100
- owners: ["@workflow-team"],
101
- tags: ["workflow", "approval", "decided"]
102
- },
103
- payload: ApprovalDecidedPayload
104
- });
105
- var ApprovalDelegatedEvent = defineEvent({
106
- meta: {
107
- key: "workflow.approval.delegated",
108
- version: "1.0.0",
109
- description: "An approval has been delegated.",
110
- stability: "stable",
111
- owners: ["@workflow-team"],
112
- tags: ["workflow", "approval", "delegated"]
113
- },
114
- payload: ApprovalDelegatedPayload
115
- });
116
- var ApprovalEscalatedEvent = defineEvent({
117
- meta: {
118
- key: "workflow.approval.escalated",
119
- version: "1.0.0",
120
- description: "An approval has been escalated.",
121
- stability: "stable",
122
- owners: ["@workflow-team"],
123
- tags: ["workflow", "approval", "escalated"]
124
- },
125
- payload: ApprovalEscalatedPayload
126
- });
127
-
128
- // src/approval/approval.schema.ts
129
- import { defineSchemaModel as defineSchemaModel2, ScalarTypeEnum as ScalarTypeEnum2 } from "@contractspec/lib.schema";
130
- var ApprovalRequestModel = defineSchemaModel2({
131
- name: "ApprovalRequestModel",
132
- description: "An approval request",
133
- fields: {
134
- id: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
135
- workflowInstanceId: {
136
- type: ScalarTypeEnum2.String_unsecure(),
137
- isOptional: false
138
- },
139
- stepExecutionId: {
140
- type: ScalarTypeEnum2.String_unsecure(),
141
- isOptional: false
142
- },
143
- approverId: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
144
- approverRole: {
145
- type: ScalarTypeEnum2.String_unsecure(),
146
- isOptional: true
147
- },
148
- title: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
149
- description: { type: ScalarTypeEnum2.String_unsecure(), isOptional: true },
150
- status: { type: ApprovalStatusEnum, isOptional: false },
151
- decision: { type: ApprovalDecisionEnum, isOptional: true },
152
- decisionComment: {
153
- type: ScalarTypeEnum2.String_unsecure(),
154
- isOptional: true
155
- },
156
- decidedAt: { type: ScalarTypeEnum2.DateTime(), isOptional: true },
157
- dueAt: { type: ScalarTypeEnum2.DateTime(), isOptional: true },
158
- contextSnapshot: { type: ScalarTypeEnum2.JSON(), isOptional: true },
159
- sequenceOrder: { type: ScalarTypeEnum2.Int_unsecure(), isOptional: false },
160
- createdAt: { type: ScalarTypeEnum2.DateTime(), isOptional: false }
161
- }
162
- });
163
- var ApprovalCommentModel = defineSchemaModel2({
164
- name: "ApprovalCommentModel",
165
- description: "A comment on an approval",
166
- fields: {
167
- id: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
168
- approvalRequestId: {
169
- type: ScalarTypeEnum2.String_unsecure(),
170
- isOptional: false
171
- },
172
- authorId: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
173
- content: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
174
- isInternal: { type: ScalarTypeEnum2.Boolean(), isOptional: false },
175
- createdAt: { type: ScalarTypeEnum2.DateTime(), isOptional: false }
176
- }
177
- });
178
-
179
- // src/approval/approval.operations.ts
180
- import {
181
- defineCommand,
182
- defineQuery
183
- } from "@contractspec/lib.contracts-spec/operations";
184
- import { defineSchemaModel as defineSchemaModel3, ScalarTypeEnum as ScalarTypeEnum3 } from "@contractspec/lib.schema";
185
- var OWNERS = ["@example.workflow-system"];
186
- var SubmitDecisionContract = defineCommand({
187
- meta: {
188
- key: "workflow.approval.decide",
189
- version: "1.0.0",
190
- stability: "stable",
191
- owners: [...OWNERS],
192
- tags: ["workflow", "approval", "decision"],
193
- description: "Submit an approval decision (approve/reject).",
194
- goal: "Allow approvers to make decisions on requests.",
195
- context: "Approval inbox, workflow detail."
196
- },
197
- io: {
198
- input: defineSchemaModel3({
199
- name: "ApproveRejectInput",
200
- fields: {
201
- requestId: {
202
- type: ScalarTypeEnum3.String_unsecure(),
203
- isOptional: false
204
- },
205
- decision: { type: ApprovalDecisionEnum, isOptional: false },
206
- comment: { type: ScalarTypeEnum3.String_unsecure(), isOptional: true },
207
- data: { type: ScalarTypeEnum3.JSON(), isOptional: true }
208
- }
209
- }),
210
- output: ApprovalRequestModel
211
- },
212
- policy: { auth: "user" },
213
- sideEffects: {
214
- emits: [
215
- {
216
- key: "workflow.approval.decided",
217
- version: "1.0.0",
218
- when: "Decision is made",
219
- payload: ApprovalRequestModel
220
- }
221
- ],
222
- audit: ["workflow.approval.decided"]
223
- },
224
- acceptance: {
225
- scenarios: [
226
- {
227
- key: "approve-request-happy-path",
228
- given: ["Approval request is pending", "User is assignee"],
229
- when: ["User approves request"],
230
- then: ["Request is approved", "ApprovalDecided event is emitted"]
231
- }
232
- ],
233
- examples: [
234
- {
235
- key: "approve-basic",
236
- input: {
237
- requestId: "req-123",
238
- decision: "approve",
239
- comment: "Looks good"
240
- },
241
- output: { id: "req-123", status: "approved" }
242
- }
243
- ]
244
- }
245
- });
246
- var DelegateApprovalContract = defineCommand({
247
- meta: {
248
- key: "workflow.approval.delegate",
249
- version: "1.0.0",
250
- stability: "stable",
251
- owners: [...OWNERS],
252
- tags: ["workflow", "approval", "delegate"],
253
- description: "Delegate an approval request to another user.",
254
- goal: "Allow approvers to pass approval to others.",
255
- context: "Approval inbox."
256
- },
257
- io: {
258
- input: defineSchemaModel3({
259
- name: "DelegateInput",
260
- fields: {
261
- requestId: {
262
- type: ScalarTypeEnum3.String_unsecure(),
263
- isOptional: false
264
- },
265
- delegateTo: {
266
- type: ScalarTypeEnum3.String_unsecure(),
267
- isOptional: false
268
- },
269
- reason: { type: ScalarTypeEnum3.String_unsecure(), isOptional: true }
270
- }
271
- }),
272
- output: ApprovalRequestModel
273
- },
274
- policy: { auth: "user" },
275
- sideEffects: {
276
- emits: [
277
- {
278
- key: "workflow.approval.delegated",
279
- version: "1.0.0",
280
- when: "Approval is delegated",
281
- payload: ApprovalRequestModel
282
- }
283
- ],
284
- audit: ["workflow.approval.delegated"]
285
- },
286
- acceptance: {
287
- scenarios: [
288
- {
289
- key: "delegate-approval-happy-path",
290
- given: ["Approval request is pending", "User is assignee"],
291
- when: ["User delegates to another user"],
292
- then: ["Assignee is updated", "ApprovalDelegated event is emitted"]
293
- }
294
- ],
295
- examples: [
296
- {
297
- key: "delegate-to-manager",
298
- input: {
299
- requestId: "req-123",
300
- delegateTo: "user-456",
301
- reason: "Out of office"
302
- },
303
- output: { id: "req-123", assigneeId: "user-456" }
304
- }
305
- ]
306
- }
307
- });
308
- var AddApprovalCommentContract = defineCommand({
309
- meta: {
310
- key: "workflow.approval.comment.add",
311
- version: "1.0.0",
312
- stability: "stable",
313
- owners: [...OWNERS],
314
- tags: ["workflow", "approval", "comment"],
315
- description: "Add a comment to an approval request.",
316
- goal: "Allow discussion on approval requests.",
317
- context: "Approval detail view."
318
- },
319
- io: {
320
- input: defineSchemaModel3({
321
- name: "AddCommentInput",
322
- fields: {
323
- requestId: {
324
- type: ScalarTypeEnum3.String_unsecure(),
325
- isOptional: false
326
- },
327
- content: { type: ScalarTypeEnum3.NonEmptyString(), isOptional: false },
328
- isInternal: { type: ScalarTypeEnum3.Boolean(), isOptional: true }
329
- }
330
- }),
331
- output: ApprovalCommentModel
332
- },
333
- policy: { auth: "user" },
334
- sideEffects: {
335
- emits: [
336
- {
337
- key: "workflow.approval.comment.added",
338
- version: "1.0.0",
339
- when: "Comment is added",
340
- payload: ApprovalCommentModel
341
- }
342
- ]
343
- },
344
- acceptance: {
345
- scenarios: [
346
- {
347
- key: "add-comment-happy-path",
348
- given: ["Approval request exists"],
349
- when: ["User adds a comment"],
350
- then: ["Comment is added", "CommentAdded event is emitted"]
351
- }
352
- ],
353
- examples: [
354
- {
355
- key: "add-question",
356
- input: {
357
- requestId: "req-123",
358
- content: "Can you clarify budget?",
359
- isInternal: false
360
- },
361
- output: { id: "com-789", content: "Can you clarify budget?" }
362
- }
363
- ]
364
- }
365
- });
366
- var ListMyApprovalsContract = defineQuery({
367
- meta: {
368
- key: "workflow.approval.list.mine",
369
- version: "1.0.0",
370
- stability: "stable",
371
- owners: [...OWNERS],
372
- tags: ["workflow", "approval", "list", "inbox"],
373
- description: "List approval requests assigned to current user.",
374
- goal: "Show pending approvals in user inbox.",
375
- context: "Approval inbox, dashboard widget."
376
- },
377
- io: {
378
- input: defineSchemaModel3({
379
- name: "ListMyApprovalsInput",
380
- fields: {
381
- status: { type: ApprovalStatusEnum, isOptional: true },
382
- limit: {
383
- type: ScalarTypeEnum3.Int_unsecure(),
384
- isOptional: true,
385
- defaultValue: 20
386
- },
387
- offset: {
388
- type: ScalarTypeEnum3.Int_unsecure(),
389
- isOptional: true,
390
- defaultValue: 0
391
- }
392
- }
393
- }),
394
- output: defineSchemaModel3({
395
- name: "ListMyApprovalsOutput",
396
- fields: {
397
- requests: {
398
- type: ApprovalRequestModel,
399
- isArray: true,
400
- isOptional: false
401
- },
402
- total: { type: ScalarTypeEnum3.Int_unsecure(), isOptional: false },
403
- pendingCount: {
404
- type: ScalarTypeEnum3.Int_unsecure(),
405
- isOptional: false
406
- }
407
- }
408
- })
409
- },
410
- policy: { auth: "user" },
411
- acceptance: {
412
- scenarios: [
413
- {
414
- key: "list-approvals-happy-path",
415
- given: ["User has assigned approvals"],
416
- when: ["User lists approvals"],
417
- then: ["List of requests is returned"]
418
- }
419
- ],
420
- examples: [
421
- {
422
- key: "list-pending",
423
- input: { status: "pending", limit: 10 },
424
- output: { requests: [], total: 2, pendingCount: 2 }
425
- }
426
- ]
427
- }
428
- });
429
- var GetApprovalContract = defineQuery({
430
- meta: {
431
- key: "workflow.approval.get",
432
- version: "1.0.0",
433
- stability: "stable",
434
- owners: [...OWNERS],
435
- tags: ["workflow", "approval", "get"],
436
- description: "Get an approval request with details.",
437
- goal: "View approval request details.",
438
- context: "Approval detail view."
439
- },
440
- io: {
441
- input: defineSchemaModel3({
442
- name: "GetApprovalInput",
443
- fields: {
444
- requestId: {
445
- type: ScalarTypeEnum3.String_unsecure(),
446
- isOptional: false
447
- }
448
- }
449
- }),
450
- output: ApprovalRequestModel
451
- },
452
- policy: { auth: "user" },
453
- acceptance: {
454
- scenarios: [
455
- {
456
- key: "get-approval-happy-path",
457
- given: ["Approval request exists"],
458
- when: ["User requests approval details"],
459
- then: ["Approval details are returned"]
460
- }
461
- ],
462
- examples: [
463
- {
464
- key: "get-basic",
465
- input: { requestId: "req-123" },
466
- output: { id: "req-123", status: "pending" }
467
- }
468
- ]
469
- }
470
- });
471
- export {
472
- SubmitDecisionContract,
473
- ListMyApprovalsContract,
474
- GetApprovalContract,
475
- DelegateApprovalContract,
476
- ApprovalStatusEnum,
477
- ApprovalRequestedEvent,
478
- ApprovalRequestModel,
479
- ApprovalEscalatedEvent,
480
- ApprovalDelegatedEvent,
481
- ApprovalDecisionEnum,
482
- ApprovalDecidedEvent,
483
- ApprovalCommentModel,
484
- AddApprovalCommentContract
485
- };
2
+ import{defineEnum as H}from"@contractspec/lib.schema";var L=H("ApprovalStatus",["PENDING","APPROVED","REJECTED","DELEGATED","ESCALATED","WITHDRAWN","EXPIRED"]),j=H("ApprovalDecision",["APPROVE","REJECT","REQUEST_CHANGES","DELEGATE","ABSTAIN"]);import{defineEvent as w}from"@contractspec/lib.contracts-spec";import{defineSchemaModel as z,ScalarTypeEnum as x}from"@contractspec/lib.schema";var K=z({name:"ApprovalRequestedEventPayload",description:"Payload when approval is requested",fields:{requestId:{type:x.String_unsecure(),isOptional:!1},instanceId:{type:x.String_unsecure(),isOptional:!1},workflowKey:{type:x.String_unsecure(),isOptional:!1},approverId:{type:x.String_unsecure(),isOptional:!1},approverRole:{type:x.String_unsecure(),isOptional:!0},title:{type:x.String_unsecure(),isOptional:!1},dueAt:{type:x.DateTime(),isOptional:!0},timestamp:{type:x.DateTime(),isOptional:!1}}}),U=z({name:"ApprovalDecidedEventPayload",description:"Payload when approval decision is made",fields:{requestId:{type:x.String_unsecure(),isOptional:!1},instanceId:{type:x.String_unsecure(),isOptional:!1},decision:{type:x.String_unsecure(),isOptional:!1},decidedBy:{type:x.String_unsecure(),isOptional:!1},comment:{type:x.String_unsecure(),isOptional:!0},timestamp:{type:x.DateTime(),isOptional:!1}}}),V=z({name:"ApprovalDelegatedEventPayload",description:"Payload when approval is delegated",fields:{requestId:{type:x.String_unsecure(),isOptional:!1},instanceId:{type:x.String_unsecure(),isOptional:!1},fromUserId:{type:x.String_unsecure(),isOptional:!1},toUserId:{type:x.String_unsecure(),isOptional:!1},reason:{type:x.String_unsecure(),isOptional:!0},timestamp:{type:x.DateTime(),isOptional:!1}}}),X=z({name:"ApprovalEscalatedEventPayload",description:"Payload when approval is escalated",fields:{requestId:{type:x.String_unsecure(),isOptional:!1},instanceId:{type:x.String_unsecure(),isOptional:!1},escalationLevel:{type:x.Int_unsecure(),isOptional:!1},escalatedTo:{type:x.String_unsecure(),isOptional:!1},reason:{type:x.String_unsecure(),isOptional:!1},timestamp:{type:x.DateTime(),isOptional:!1}}}),Y=w({meta:{key:"workflow.approval.requested",version:"1.0.0",description:"An approval has been requested.",stability:"stable",owners:["@workflow-team"],tags:["workflow","approval","requested"]},payload:K}),Z=w({meta:{key:"workflow.approval.decided",version:"1.0.0",description:"An approval decision has been made.",stability:"stable",owners:["@workflow-team"],tags:["workflow","approval","decided"]},payload:U}),_=w({meta:{key:"workflow.approval.delegated",version:"1.0.0",description:"An approval has been delegated.",stability:"stable",owners:["@workflow-team"],tags:["workflow","approval","delegated"]},payload:V}),$=w({meta:{key:"workflow.approval.escalated",version:"1.0.0",description:"An approval has been escalated.",stability:"stable",owners:["@workflow-team"],tags:["workflow","approval","escalated"]},payload:X});import{defineSchemaModel as I,ScalarTypeEnum as g}from"@contractspec/lib.schema";var D=I({name:"ApprovalRequestModel",description:"An approval request",fields:{id:{type:g.String_unsecure(),isOptional:!1},workflowInstanceId:{type:g.String_unsecure(),isOptional:!1},stepExecutionId:{type:g.String_unsecure(),isOptional:!1},approverId:{type:g.String_unsecure(),isOptional:!1},approverRole:{type:g.String_unsecure(),isOptional:!0},title:{type:g.String_unsecure(),isOptional:!1},description:{type:g.String_unsecure(),isOptional:!0},status:{type:L,isOptional:!1},decision:{type:j,isOptional:!0},decisionComment:{type:g.String_unsecure(),isOptional:!0},decidedAt:{type:g.DateTime(),isOptional:!0},dueAt:{type:g.DateTime(),isOptional:!0},contextSnapshot:{type:g.JSON(),isOptional:!0},sequenceOrder:{type:g.Int_unsecure(),isOptional:!1},createdAt:{type:g.DateTime(),isOptional:!1}}}),B=I({name:"ApprovalCommentModel",description:"A comment on an approval",fields:{id:{type:g.String_unsecure(),isOptional:!1},approvalRequestId:{type:g.String_unsecure(),isOptional:!1},authorId:{type:g.String_unsecure(),isOptional:!1},content:{type:g.String_unsecure(),isOptional:!1},isInternal:{type:g.Boolean(),isOptional:!1},createdAt:{type:g.DateTime(),isOptional:!1}}});import{defineCommand as F,defineQuery as J}from"@contractspec/lib.contracts-spec/operations";import{defineSchemaModel as G,ScalarTypeEnum as C}from"@contractspec/lib.schema";var k=["@example.workflow-system"],Q=F({meta:{key:"workflow.approval.decide",version:"1.0.0",stability:"stable",owners:[...k],tags:["workflow","approval","decision"],description:"Submit an approval decision (approve/reject).",goal:"Allow approvers to make decisions on requests.",context:"Approval inbox, workflow detail."},io:{input:G({name:"ApproveRejectInput",fields:{requestId:{type:C.String_unsecure(),isOptional:!1},decision:{type:j,isOptional:!1},comment:{type:C.String_unsecure(),isOptional:!0},data:{type:C.JSON(),isOptional:!0}}}),output:D},policy:{auth:"user"},sideEffects:{emits:[{key:"workflow.approval.decided",version:"1.0.0",when:"Decision is made",payload:D}],audit:["workflow.approval.decided"]},acceptance:{scenarios:[{key:"approve-request-happy-path",given:["Approval request is pending","User is assignee"],when:["User approves request"],then:["Request is approved","ApprovalDecided event is emitted"]}],examples:[{key:"approve-basic",input:{requestId:"req-123",decision:"approve",comment:"Looks good"},output:{id:"req-123",status:"approved"}}]}}),A=F({meta:{key:"workflow.approval.delegate",version:"1.0.0",stability:"stable",owners:[...k],tags:["workflow","approval","delegate"],description:"Delegate an approval request to another user.",goal:"Allow approvers to pass approval to others.",context:"Approval inbox."},io:{input:G({name:"DelegateInput",fields:{requestId:{type:C.String_unsecure(),isOptional:!1},delegateTo:{type:C.String_unsecure(),isOptional:!1},reason:{type:C.String_unsecure(),isOptional:!0}}}),output:D},policy:{auth:"user"},sideEffects:{emits:[{key:"workflow.approval.delegated",version:"1.0.0",when:"Approval is delegated",payload:D}],audit:["workflow.approval.delegated"]},acceptance:{scenarios:[{key:"delegate-approval-happy-path",given:["Approval request is pending","User is assignee"],when:["User delegates to another user"],then:["Assignee is updated","ApprovalDelegated event is emitted"]}],examples:[{key:"delegate-to-manager",input:{requestId:"req-123",delegateTo:"user-456",reason:"Out of office"},output:{id:"req-123",assigneeId:"user-456"}}]}}),q=F({meta:{key:"workflow.approval.comment.add",version:"1.0.0",stability:"stable",owners:[...k],tags:["workflow","approval","comment"],description:"Add a comment to an approval request.",goal:"Allow discussion on approval requests.",context:"Approval detail view."},io:{input:G({name:"AddCommentInput",fields:{requestId:{type:C.String_unsecure(),isOptional:!1},content:{type:C.NonEmptyString(),isOptional:!1},isInternal:{type:C.Boolean(),isOptional:!0}}}),output:B},policy:{auth:"user"},sideEffects:{emits:[{key:"workflow.approval.comment.added",version:"1.0.0",when:"Comment is added",payload:B}]},acceptance:{scenarios:[{key:"add-comment-happy-path",given:["Approval request exists"],when:["User adds a comment"],then:["Comment is added","CommentAdded event is emitted"]}],examples:[{key:"add-question",input:{requestId:"req-123",content:"Can you clarify budget?",isInternal:!1},output:{id:"com-789",content:"Can you clarify budget?"}}]}}),P=J({meta:{key:"workflow.approval.list.mine",version:"1.0.0",stability:"stable",owners:[...k],tags:["workflow","approval","list","inbox"],description:"List approval requests assigned to current user.",goal:"Show pending approvals in user inbox.",context:"Approval inbox, dashboard widget."},io:{input:G({name:"ListMyApprovalsInput",fields:{status:{type:L,isOptional:!0},limit:{type:C.Int_unsecure(),isOptional:!0,defaultValue:20},offset:{type:C.Int_unsecure(),isOptional:!0,defaultValue:0}}}),output:G({name:"ListMyApprovalsOutput",fields:{requests:{type:D,isArray:!0,isOptional:!1},total:{type:C.Int_unsecure(),isOptional:!1},pendingCount:{type:C.Int_unsecure(),isOptional:!1}}})},policy:{auth:"user"},acceptance:{scenarios:[{key:"list-approvals-happy-path",given:["User has assigned approvals"],when:["User lists approvals"],then:["List of requests is returned"]}],examples:[{key:"list-pending",input:{status:"pending",limit:10},output:{requests:[],total:2,pendingCount:2}}]}}),b=J({meta:{key:"workflow.approval.get",version:"1.0.0",stability:"stable",owners:[...k],tags:["workflow","approval","get"],description:"Get an approval request with details.",goal:"View approval request details.",context:"Approval detail view."},io:{input:G({name:"GetApprovalInput",fields:{requestId:{type:C.String_unsecure(),isOptional:!1}}}),output:D},policy:{auth:"user"},acceptance:{scenarios:[{key:"get-approval-happy-path",given:["Approval request exists"],when:["User requests approval details"],then:["Approval details are returned"]}],examples:[{key:"get-basic",input:{requestId:"req-123"},output:{id:"req-123",status:"pending"}}]}});export{Q as SubmitDecisionContract,P as ListMyApprovalsContract,b as GetApprovalContract,A as DelegateApprovalContract,L as ApprovalStatusEnum,Y as ApprovalRequestedEvent,D as ApprovalRequestModel,$ as ApprovalEscalatedEvent,_ as ApprovalDelegatedEvent,j as ApprovalDecisionEnum,Z as ApprovalDecidedEvent,B as ApprovalCommentModel,q as AddApprovalCommentContract};
@@ -1,22 +1 @@
1
- // src/approval/approval.enum.ts
2
- import { defineEnum } from "@contractspec/lib.schema";
3
- var ApprovalStatusEnum = defineEnum("ApprovalStatus", [
4
- "PENDING",
5
- "APPROVED",
6
- "REJECTED",
7
- "DELEGATED",
8
- "ESCALATED",
9
- "WITHDRAWN",
10
- "EXPIRED"
11
- ]);
12
- var ApprovalDecisionEnum = defineEnum("ApprovalDecision", [
13
- "APPROVE",
14
- "REJECT",
15
- "REQUEST_CHANGES",
16
- "DELEGATE",
17
- "ABSTAIN"
18
- ]);
19
- export {
20
- ApprovalStatusEnum,
21
- ApprovalDecisionEnum
22
- };
1
+ import{defineEnum as g}from"@contractspec/lib.schema";var k=g("ApprovalStatus",["PENDING","APPROVED","REJECTED","DELEGATED","ESCALATED","WITHDRAWN","EXPIRED"]),q=g("ApprovalDecision",["APPROVE","REJECT","REQUEST_CHANGES","DELEGATE","ABSTAIN"]);export{k as ApprovalStatusEnum,q as ApprovalDecisionEnum};
@@ -1,112 +1 @@
1
- // src/approval/approval.event.ts
2
- import { defineEvent } from "@contractspec/lib.contracts-spec";
3
- import { defineSchemaModel, ScalarTypeEnum } from "@contractspec/lib.schema";
4
- var ApprovalRequestedPayload = defineSchemaModel({
5
- name: "ApprovalRequestedEventPayload",
6
- description: "Payload when approval is requested",
7
- fields: {
8
- requestId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
9
- instanceId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
10
- workflowKey: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
11
- approverId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
12
- approverRole: {
13
- type: ScalarTypeEnum.String_unsecure(),
14
- isOptional: true
15
- },
16
- title: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
17
- dueAt: { type: ScalarTypeEnum.DateTime(), isOptional: true },
18
- timestamp: { type: ScalarTypeEnum.DateTime(), isOptional: false }
19
- }
20
- });
21
- var ApprovalDecidedPayload = defineSchemaModel({
22
- name: "ApprovalDecidedEventPayload",
23
- description: "Payload when approval decision is made",
24
- fields: {
25
- requestId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
26
- instanceId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
27
- decision: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
28
- decidedBy: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
29
- comment: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
30
- timestamp: { type: ScalarTypeEnum.DateTime(), isOptional: false }
31
- }
32
- });
33
- var ApprovalDelegatedPayload = defineSchemaModel({
34
- name: "ApprovalDelegatedEventPayload",
35
- description: "Payload when approval is delegated",
36
- fields: {
37
- requestId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
38
- instanceId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
39
- fromUserId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
40
- toUserId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
41
- reason: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
42
- timestamp: { type: ScalarTypeEnum.DateTime(), isOptional: false }
43
- }
44
- });
45
- var ApprovalEscalatedPayload = defineSchemaModel({
46
- name: "ApprovalEscalatedEventPayload",
47
- description: "Payload when approval is escalated",
48
- fields: {
49
- requestId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
50
- instanceId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
51
- escalationLevel: {
52
- type: ScalarTypeEnum.Int_unsecure(),
53
- isOptional: false
54
- },
55
- escalatedTo: {
56
- type: ScalarTypeEnum.String_unsecure(),
57
- isOptional: false
58
- },
59
- reason: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
60
- timestamp: { type: ScalarTypeEnum.DateTime(), isOptional: false }
61
- }
62
- });
63
- var ApprovalRequestedEvent = defineEvent({
64
- meta: {
65
- key: "workflow.approval.requested",
66
- version: "1.0.0",
67
- description: "An approval has been requested.",
68
- stability: "stable",
69
- owners: ["@workflow-team"],
70
- tags: ["workflow", "approval", "requested"]
71
- },
72
- payload: ApprovalRequestedPayload
73
- });
74
- var ApprovalDecidedEvent = defineEvent({
75
- meta: {
76
- key: "workflow.approval.decided",
77
- version: "1.0.0",
78
- description: "An approval decision has been made.",
79
- stability: "stable",
80
- owners: ["@workflow-team"],
81
- tags: ["workflow", "approval", "decided"]
82
- },
83
- payload: ApprovalDecidedPayload
84
- });
85
- var ApprovalDelegatedEvent = defineEvent({
86
- meta: {
87
- key: "workflow.approval.delegated",
88
- version: "1.0.0",
89
- description: "An approval has been delegated.",
90
- stability: "stable",
91
- owners: ["@workflow-team"],
92
- tags: ["workflow", "approval", "delegated"]
93
- },
94
- payload: ApprovalDelegatedPayload
95
- });
96
- var ApprovalEscalatedEvent = defineEvent({
97
- meta: {
98
- key: "workflow.approval.escalated",
99
- version: "1.0.0",
100
- description: "An approval has been escalated.",
101
- stability: "stable",
102
- owners: ["@workflow-team"],
103
- tags: ["workflow", "approval", "escalated"]
104
- },
105
- payload: ApprovalEscalatedPayload
106
- });
107
- export {
108
- ApprovalRequestedEvent,
109
- ApprovalEscalatedEvent,
110
- ApprovalDelegatedEvent,
111
- ApprovalDecidedEvent
112
- };
1
+ import{defineEvent as k}from"@contractspec/lib.contracts-spec";import{defineSchemaModel as w,ScalarTypeEnum as j}from"@contractspec/lib.schema";var x=w({name:"ApprovalRequestedEventPayload",description:"Payload when approval is requested",fields:{requestId:{type:j.String_unsecure(),isOptional:!1},instanceId:{type:j.String_unsecure(),isOptional:!1},workflowKey:{type:j.String_unsecure(),isOptional:!1},approverId:{type:j.String_unsecure(),isOptional:!1},approverRole:{type:j.String_unsecure(),isOptional:!0},title:{type:j.String_unsecure(),isOptional:!1},dueAt:{type:j.DateTime(),isOptional:!0},timestamp:{type:j.DateTime(),isOptional:!1}}}),z=w({name:"ApprovalDecidedEventPayload",description:"Payload when approval decision is made",fields:{requestId:{type:j.String_unsecure(),isOptional:!1},instanceId:{type:j.String_unsecure(),isOptional:!1},decision:{type:j.String_unsecure(),isOptional:!1},decidedBy:{type:j.String_unsecure(),isOptional:!1},comment:{type:j.String_unsecure(),isOptional:!0},timestamp:{type:j.DateTime(),isOptional:!1}}}),B=w({name:"ApprovalDelegatedEventPayload",description:"Payload when approval is delegated",fields:{requestId:{type:j.String_unsecure(),isOptional:!1},instanceId:{type:j.String_unsecure(),isOptional:!1},fromUserId:{type:j.String_unsecure(),isOptional:!1},toUserId:{type:j.String_unsecure(),isOptional:!1},reason:{type:j.String_unsecure(),isOptional:!0},timestamp:{type:j.DateTime(),isOptional:!1}}}),C=w({name:"ApprovalEscalatedEventPayload",description:"Payload when approval is escalated",fields:{requestId:{type:j.String_unsecure(),isOptional:!1},instanceId:{type:j.String_unsecure(),isOptional:!1},escalationLevel:{type:j.Int_unsecure(),isOptional:!1},escalatedTo:{type:j.String_unsecure(),isOptional:!1},reason:{type:j.String_unsecure(),isOptional:!1},timestamp:{type:j.DateTime(),isOptional:!1}}}),H=k({meta:{key:"workflow.approval.requested",version:"1.0.0",description:"An approval has been requested.",stability:"stable",owners:["@workflow-team"],tags:["workflow","approval","requested"]},payload:x}),I=k({meta:{key:"workflow.approval.decided",version:"1.0.0",description:"An approval decision has been made.",stability:"stable",owners:["@workflow-team"],tags:["workflow","approval","decided"]},payload:z}),J=k({meta:{key:"workflow.approval.delegated",version:"1.0.0",description:"An approval has been delegated.",stability:"stable",owners:["@workflow-team"],tags:["workflow","approval","delegated"]},payload:B}),K=k({meta:{key:"workflow.approval.escalated",version:"1.0.0",description:"An approval has been escalated.",stability:"stable",owners:["@workflow-team"],tags:["workflow","approval","escalated"]},payload:C});export{H as ApprovalRequestedEvent,K as ApprovalEscalatedEvent,J as ApprovalDelegatedEvent,I as ApprovalDecidedEvent};