@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,369 +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
-
20
- // src/approval/approval.schema.ts
21
- import { defineSchemaModel, ScalarTypeEnum } from "@contractspec/lib.schema";
22
- var ApprovalRequestModel = defineSchemaModel({
23
- name: "ApprovalRequestModel",
24
- description: "An approval request",
25
- fields: {
26
- id: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
27
- workflowInstanceId: {
28
- type: ScalarTypeEnum.String_unsecure(),
29
- isOptional: false
30
- },
31
- stepExecutionId: {
32
- type: ScalarTypeEnum.String_unsecure(),
33
- isOptional: false
34
- },
35
- approverId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
36
- approverRole: {
37
- type: ScalarTypeEnum.String_unsecure(),
38
- isOptional: true
39
- },
40
- title: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
41
- description: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
42
- status: { type: ApprovalStatusEnum, isOptional: false },
43
- decision: { type: ApprovalDecisionEnum, isOptional: true },
44
- decisionComment: {
45
- type: ScalarTypeEnum.String_unsecure(),
46
- isOptional: true
47
- },
48
- decidedAt: { type: ScalarTypeEnum.DateTime(), isOptional: true },
49
- dueAt: { type: ScalarTypeEnum.DateTime(), isOptional: true },
50
- contextSnapshot: { type: ScalarTypeEnum.JSON(), isOptional: true },
51
- sequenceOrder: { type: ScalarTypeEnum.Int_unsecure(), isOptional: false },
52
- createdAt: { type: ScalarTypeEnum.DateTime(), isOptional: false }
53
- }
54
- });
55
- var ApprovalCommentModel = defineSchemaModel({
56
- name: "ApprovalCommentModel",
57
- description: "A comment on an approval",
58
- fields: {
59
- id: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
60
- approvalRequestId: {
61
- type: ScalarTypeEnum.String_unsecure(),
62
- isOptional: false
63
- },
64
- authorId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
65
- content: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
66
- isInternal: { type: ScalarTypeEnum.Boolean(), isOptional: false },
67
- createdAt: { type: ScalarTypeEnum.DateTime(), isOptional: false }
68
- }
69
- });
70
-
71
- // src/approval/approval.operations.ts
72
- import {
73
- defineCommand,
74
- defineQuery
75
- } from "@contractspec/lib.contracts-spec/operations";
76
- import { defineSchemaModel as defineSchemaModel2, ScalarTypeEnum as ScalarTypeEnum2 } from "@contractspec/lib.schema";
77
- var OWNERS = ["@example.workflow-system"];
78
- var SubmitDecisionContract = defineCommand({
79
- meta: {
80
- key: "workflow.approval.decide",
81
- version: "1.0.0",
82
- stability: "stable",
83
- owners: [...OWNERS],
84
- tags: ["workflow", "approval", "decision"],
85
- description: "Submit an approval decision (approve/reject).",
86
- goal: "Allow approvers to make decisions on requests.",
87
- context: "Approval inbox, workflow detail."
88
- },
89
- io: {
90
- input: defineSchemaModel2({
91
- name: "ApproveRejectInput",
92
- fields: {
93
- requestId: {
94
- type: ScalarTypeEnum2.String_unsecure(),
95
- isOptional: false
96
- },
97
- decision: { type: ApprovalDecisionEnum, isOptional: false },
98
- comment: { type: ScalarTypeEnum2.String_unsecure(), isOptional: true },
99
- data: { type: ScalarTypeEnum2.JSON(), isOptional: true }
100
- }
101
- }),
102
- output: ApprovalRequestModel
103
- },
104
- policy: { auth: "user" },
105
- sideEffects: {
106
- emits: [
107
- {
108
- key: "workflow.approval.decided",
109
- version: "1.0.0",
110
- when: "Decision is made",
111
- payload: ApprovalRequestModel
112
- }
113
- ],
114
- audit: ["workflow.approval.decided"]
115
- },
116
- acceptance: {
117
- scenarios: [
118
- {
119
- key: "approve-request-happy-path",
120
- given: ["Approval request is pending", "User is assignee"],
121
- when: ["User approves request"],
122
- then: ["Request is approved", "ApprovalDecided event is emitted"]
123
- }
124
- ],
125
- examples: [
126
- {
127
- key: "approve-basic",
128
- input: {
129
- requestId: "req-123",
130
- decision: "approve",
131
- comment: "Looks good"
132
- },
133
- output: { id: "req-123", status: "approved" }
134
- }
135
- ]
136
- }
137
- });
138
- var DelegateApprovalContract = defineCommand({
139
- meta: {
140
- key: "workflow.approval.delegate",
141
- version: "1.0.0",
142
- stability: "stable",
143
- owners: [...OWNERS],
144
- tags: ["workflow", "approval", "delegate"],
145
- description: "Delegate an approval request to another user.",
146
- goal: "Allow approvers to pass approval to others.",
147
- context: "Approval inbox."
148
- },
149
- io: {
150
- input: defineSchemaModel2({
151
- name: "DelegateInput",
152
- fields: {
153
- requestId: {
154
- type: ScalarTypeEnum2.String_unsecure(),
155
- isOptional: false
156
- },
157
- delegateTo: {
158
- type: ScalarTypeEnum2.String_unsecure(),
159
- isOptional: false
160
- },
161
- reason: { type: ScalarTypeEnum2.String_unsecure(), isOptional: true }
162
- }
163
- }),
164
- output: ApprovalRequestModel
165
- },
166
- policy: { auth: "user" },
167
- sideEffects: {
168
- emits: [
169
- {
170
- key: "workflow.approval.delegated",
171
- version: "1.0.0",
172
- when: "Approval is delegated",
173
- payload: ApprovalRequestModel
174
- }
175
- ],
176
- audit: ["workflow.approval.delegated"]
177
- },
178
- acceptance: {
179
- scenarios: [
180
- {
181
- key: "delegate-approval-happy-path",
182
- given: ["Approval request is pending", "User is assignee"],
183
- when: ["User delegates to another user"],
184
- then: ["Assignee is updated", "ApprovalDelegated event is emitted"]
185
- }
186
- ],
187
- examples: [
188
- {
189
- key: "delegate-to-manager",
190
- input: {
191
- requestId: "req-123",
192
- delegateTo: "user-456",
193
- reason: "Out of office"
194
- },
195
- output: { id: "req-123", assigneeId: "user-456" }
196
- }
197
- ]
198
- }
199
- });
200
- var AddApprovalCommentContract = defineCommand({
201
- meta: {
202
- key: "workflow.approval.comment.add",
203
- version: "1.0.0",
204
- stability: "stable",
205
- owners: [...OWNERS],
206
- tags: ["workflow", "approval", "comment"],
207
- description: "Add a comment to an approval request.",
208
- goal: "Allow discussion on approval requests.",
209
- context: "Approval detail view."
210
- },
211
- io: {
212
- input: defineSchemaModel2({
213
- name: "AddCommentInput",
214
- fields: {
215
- requestId: {
216
- type: ScalarTypeEnum2.String_unsecure(),
217
- isOptional: false
218
- },
219
- content: { type: ScalarTypeEnum2.NonEmptyString(), isOptional: false },
220
- isInternal: { type: ScalarTypeEnum2.Boolean(), isOptional: true }
221
- }
222
- }),
223
- output: ApprovalCommentModel
224
- },
225
- policy: { auth: "user" },
226
- sideEffects: {
227
- emits: [
228
- {
229
- key: "workflow.approval.comment.added",
230
- version: "1.0.0",
231
- when: "Comment is added",
232
- payload: ApprovalCommentModel
233
- }
234
- ]
235
- },
236
- acceptance: {
237
- scenarios: [
238
- {
239
- key: "add-comment-happy-path",
240
- given: ["Approval request exists"],
241
- when: ["User adds a comment"],
242
- then: ["Comment is added", "CommentAdded event is emitted"]
243
- }
244
- ],
245
- examples: [
246
- {
247
- key: "add-question",
248
- input: {
249
- requestId: "req-123",
250
- content: "Can you clarify budget?",
251
- isInternal: false
252
- },
253
- output: { id: "com-789", content: "Can you clarify budget?" }
254
- }
255
- ]
256
- }
257
- });
258
- var ListMyApprovalsContract = defineQuery({
259
- meta: {
260
- key: "workflow.approval.list.mine",
261
- version: "1.0.0",
262
- stability: "stable",
263
- owners: [...OWNERS],
264
- tags: ["workflow", "approval", "list", "inbox"],
265
- description: "List approval requests assigned to current user.",
266
- goal: "Show pending approvals in user inbox.",
267
- context: "Approval inbox, dashboard widget."
268
- },
269
- io: {
270
- input: defineSchemaModel2({
271
- name: "ListMyApprovalsInput",
272
- fields: {
273
- status: { type: ApprovalStatusEnum, isOptional: true },
274
- limit: {
275
- type: ScalarTypeEnum2.Int_unsecure(),
276
- isOptional: true,
277
- defaultValue: 20
278
- },
279
- offset: {
280
- type: ScalarTypeEnum2.Int_unsecure(),
281
- isOptional: true,
282
- defaultValue: 0
283
- }
284
- }
285
- }),
286
- output: defineSchemaModel2({
287
- name: "ListMyApprovalsOutput",
288
- fields: {
289
- requests: {
290
- type: ApprovalRequestModel,
291
- isArray: true,
292
- isOptional: false
293
- },
294
- total: { type: ScalarTypeEnum2.Int_unsecure(), isOptional: false },
295
- pendingCount: {
296
- type: ScalarTypeEnum2.Int_unsecure(),
297
- isOptional: false
298
- }
299
- }
300
- })
301
- },
302
- policy: { auth: "user" },
303
- acceptance: {
304
- scenarios: [
305
- {
306
- key: "list-approvals-happy-path",
307
- given: ["User has assigned approvals"],
308
- when: ["User lists approvals"],
309
- then: ["List of requests is returned"]
310
- }
311
- ],
312
- examples: [
313
- {
314
- key: "list-pending",
315
- input: { status: "pending", limit: 10 },
316
- output: { requests: [], total: 2, pendingCount: 2 }
317
- }
318
- ]
319
- }
320
- });
321
- var GetApprovalContract = defineQuery({
322
- meta: {
323
- key: "workflow.approval.get",
324
- version: "1.0.0",
325
- stability: "stable",
326
- owners: [...OWNERS],
327
- tags: ["workflow", "approval", "get"],
328
- description: "Get an approval request with details.",
329
- goal: "View approval request details.",
330
- context: "Approval detail view."
331
- },
332
- io: {
333
- input: defineSchemaModel2({
334
- name: "GetApprovalInput",
335
- fields: {
336
- requestId: {
337
- type: ScalarTypeEnum2.String_unsecure(),
338
- isOptional: false
339
- }
340
- }
341
- }),
342
- output: ApprovalRequestModel
343
- },
344
- policy: { auth: "user" },
345
- acceptance: {
346
- scenarios: [
347
- {
348
- key: "get-approval-happy-path",
349
- given: ["Approval request exists"],
350
- when: ["User requests approval details"],
351
- then: ["Approval details are returned"]
352
- }
353
- ],
354
- examples: [
355
- {
356
- key: "get-basic",
357
- input: { requestId: "req-123" },
358
- output: { id: "req-123", status: "pending" }
359
- }
360
- ]
361
- }
362
- });
363
- export {
364
- SubmitDecisionContract,
365
- ListMyApprovalsContract,
366
- GetApprovalContract,
367
- DelegateApprovalContract,
368
- AddApprovalCommentContract
369
- };
1
+ import{defineEnum as H}from"@contractspec/lib.schema";var z=H("ApprovalStatus",["PENDING","APPROVED","REJECTED","DELEGATED","ESCALATED","WITHDRAWN","EXPIRED"]),B=H("ApprovalDecision",["APPROVE","REJECT","REQUEST_CHANGES","DELEGATE","ABSTAIN"]);import{defineSchemaModel as I,ScalarTypeEnum as g}from"@contractspec/lib.schema";var k=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:z,isOptional:!1},decision:{type:B,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}}}),F=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 G,defineQuery as J}from"@contractspec/lib.contracts-spec/operations";import{defineSchemaModel as w,ScalarTypeEnum as j}from"@contractspec/lib.schema";var x=["@example.workflow-system"],$=G({meta:{key:"workflow.approval.decide",version:"1.0.0",stability:"stable",owners:[...x],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:w({name:"ApproveRejectInput",fields:{requestId:{type:j.String_unsecure(),isOptional:!1},decision:{type:B,isOptional:!1},comment:{type:j.String_unsecure(),isOptional:!0},data:{type:j.JSON(),isOptional:!0}}}),output:k},policy:{auth:"user"},sideEffects:{emits:[{key:"workflow.approval.decided",version:"1.0.0",when:"Decision is made",payload:k}],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"}}]}}),D=G({meta:{key:"workflow.approval.delegate",version:"1.0.0",stability:"stable",owners:[...x],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:w({name:"DelegateInput",fields:{requestId:{type:j.String_unsecure(),isOptional:!1},delegateTo:{type:j.String_unsecure(),isOptional:!1},reason:{type:j.String_unsecure(),isOptional:!0}}}),output:k},policy:{auth:"user"},sideEffects:{emits:[{key:"workflow.approval.delegated",version:"1.0.0",when:"Approval is delegated",payload:k}],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=G({meta:{key:"workflow.approval.comment.add",version:"1.0.0",stability:"stable",owners:[...x],tags:["workflow","approval","comment"],description:"Add a comment to an approval request.",goal:"Allow discussion on approval requests.",context:"Approval detail view."},io:{input:w({name:"AddCommentInput",fields:{requestId:{type:j.String_unsecure(),isOptional:!1},content:{type:j.NonEmptyString(),isOptional:!1},isInternal:{type:j.Boolean(),isOptional:!0}}}),output:F},policy:{auth:"user"},sideEffects:{emits:[{key:"workflow.approval.comment.added",version:"1.0.0",when:"Comment is added",payload:F}]},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?"}}]}}),b=J({meta:{key:"workflow.approval.list.mine",version:"1.0.0",stability:"stable",owners:[...x],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:w({name:"ListMyApprovalsInput",fields:{status:{type:z,isOptional:!0},limit:{type:j.Int_unsecure(),isOptional:!0,defaultValue:20},offset:{type:j.Int_unsecure(),isOptional:!0,defaultValue:0}}}),output:w({name:"ListMyApprovalsOutput",fields:{requests:{type:k,isArray:!0,isOptional:!1},total:{type:j.Int_unsecure(),isOptional:!1},pendingCount:{type:j.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}}]}}),C=J({meta:{key:"workflow.approval.get",version:"1.0.0",stability:"stable",owners:[...x],tags:["workflow","approval","get"],description:"Get an approval request with details.",goal:"View approval request details.",context:"Approval detail view."},io:{input:w({name:"GetApprovalInput",fields:{requestId:{type:j.String_unsecure(),isOptional:!1}}}),output:k},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{$ as SubmitDecisionContract,b as ListMyApprovalsContract,C as GetApprovalContract,D as DelegateApprovalContract,Q as AddApprovalCommentContract};
@@ -1,73 +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
-
20
- // src/approval/approval.schema.ts
21
- import { defineSchemaModel, ScalarTypeEnum } from "@contractspec/lib.schema";
22
- var ApprovalRequestModel = defineSchemaModel({
23
- name: "ApprovalRequestModel",
24
- description: "An approval request",
25
- fields: {
26
- id: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
27
- workflowInstanceId: {
28
- type: ScalarTypeEnum.String_unsecure(),
29
- isOptional: false
30
- },
31
- stepExecutionId: {
32
- type: ScalarTypeEnum.String_unsecure(),
33
- isOptional: false
34
- },
35
- approverId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
36
- approverRole: {
37
- type: ScalarTypeEnum.String_unsecure(),
38
- isOptional: true
39
- },
40
- title: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
41
- description: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
42
- status: { type: ApprovalStatusEnum, isOptional: false },
43
- decision: { type: ApprovalDecisionEnum, isOptional: true },
44
- decisionComment: {
45
- type: ScalarTypeEnum.String_unsecure(),
46
- isOptional: true
47
- },
48
- decidedAt: { type: ScalarTypeEnum.DateTime(), isOptional: true },
49
- dueAt: { type: ScalarTypeEnum.DateTime(), isOptional: true },
50
- contextSnapshot: { type: ScalarTypeEnum.JSON(), isOptional: true },
51
- sequenceOrder: { type: ScalarTypeEnum.Int_unsecure(), isOptional: false },
52
- createdAt: { type: ScalarTypeEnum.DateTime(), isOptional: false }
53
- }
54
- });
55
- var ApprovalCommentModel = defineSchemaModel({
56
- name: "ApprovalCommentModel",
57
- description: "A comment on an approval",
58
- fields: {
59
- id: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
60
- approvalRequestId: {
61
- type: ScalarTypeEnum.String_unsecure(),
62
- isOptional: false
63
- },
64
- authorId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
65
- content: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
66
- isInternal: { type: ScalarTypeEnum.Boolean(), isOptional: false },
67
- createdAt: { type: ScalarTypeEnum.DateTime(), isOptional: false }
68
- }
69
- });
70
- export {
71
- ApprovalRequestModel,
72
- ApprovalCommentModel
73
- };
1
+ import{defineEnum as j}from"@contractspec/lib.schema";var k=j("ApprovalStatus",["PENDING","APPROVED","REJECTED","DELEGATED","ESCALATED","WITHDRAWN","EXPIRED"]),q=j("ApprovalDecision",["APPROVE","REJECT","REQUEST_CHANGES","DELEGATE","ABSTAIN"]);import{defineSchemaModel as w,ScalarTypeEnum as g}from"@contractspec/lib.schema";var F=w({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:k,isOptional:!1},decision:{type:q,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}}}),G=w({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}}});export{F as ApprovalRequestModel,G as ApprovalCommentModel};