@contractspec/example.workflow-system 3.8.9 → 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.
- 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,484 +1 @@
|
|
|
1
|
-
|
|
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.event.ts
|
|
21
|
-
import { defineEvent } from "@contractspec/lib.contracts-spec";
|
|
22
|
-
import { defineSchemaModel, ScalarTypeEnum } from "@contractspec/lib.schema";
|
|
23
|
-
var ApprovalRequestedPayload = defineSchemaModel({
|
|
24
|
-
name: "ApprovalRequestedEventPayload",
|
|
25
|
-
description: "Payload when approval is requested",
|
|
26
|
-
fields: {
|
|
27
|
-
requestId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
28
|
-
instanceId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
29
|
-
workflowKey: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
30
|
-
approverId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
31
|
-
approverRole: {
|
|
32
|
-
type: ScalarTypeEnum.String_unsecure(),
|
|
33
|
-
isOptional: true
|
|
34
|
-
},
|
|
35
|
-
title: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
36
|
-
dueAt: { type: ScalarTypeEnum.DateTime(), isOptional: true },
|
|
37
|
-
timestamp: { type: ScalarTypeEnum.DateTime(), isOptional: false }
|
|
38
|
-
}
|
|
39
|
-
});
|
|
40
|
-
var ApprovalDecidedPayload = defineSchemaModel({
|
|
41
|
-
name: "ApprovalDecidedEventPayload",
|
|
42
|
-
description: "Payload when approval decision is made",
|
|
43
|
-
fields: {
|
|
44
|
-
requestId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
45
|
-
instanceId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
46
|
-
decision: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
47
|
-
decidedBy: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
48
|
-
comment: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
|
|
49
|
-
timestamp: { type: ScalarTypeEnum.DateTime(), isOptional: false }
|
|
50
|
-
}
|
|
51
|
-
});
|
|
52
|
-
var ApprovalDelegatedPayload = defineSchemaModel({
|
|
53
|
-
name: "ApprovalDelegatedEventPayload",
|
|
54
|
-
description: "Payload when approval is delegated",
|
|
55
|
-
fields: {
|
|
56
|
-
requestId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
57
|
-
instanceId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
58
|
-
fromUserId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
59
|
-
toUserId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
60
|
-
reason: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
|
|
61
|
-
timestamp: { type: ScalarTypeEnum.DateTime(), isOptional: false }
|
|
62
|
-
}
|
|
63
|
-
});
|
|
64
|
-
var ApprovalEscalatedPayload = defineSchemaModel({
|
|
65
|
-
name: "ApprovalEscalatedEventPayload",
|
|
66
|
-
description: "Payload when approval is escalated",
|
|
67
|
-
fields: {
|
|
68
|
-
requestId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
69
|
-
instanceId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
70
|
-
escalationLevel: {
|
|
71
|
-
type: ScalarTypeEnum.Int_unsecure(),
|
|
72
|
-
isOptional: false
|
|
73
|
-
},
|
|
74
|
-
escalatedTo: {
|
|
75
|
-
type: ScalarTypeEnum.String_unsecure(),
|
|
76
|
-
isOptional: false
|
|
77
|
-
},
|
|
78
|
-
reason: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
79
|
-
timestamp: { type: ScalarTypeEnum.DateTime(), isOptional: false }
|
|
80
|
-
}
|
|
81
|
-
});
|
|
82
|
-
var ApprovalRequestedEvent = defineEvent({
|
|
83
|
-
meta: {
|
|
84
|
-
key: "workflow.approval.requested",
|
|
85
|
-
version: "1.0.0",
|
|
86
|
-
description: "An approval has been requested.",
|
|
87
|
-
stability: "stable",
|
|
88
|
-
owners: ["@workflow-team"],
|
|
89
|
-
tags: ["workflow", "approval", "requested"]
|
|
90
|
-
},
|
|
91
|
-
payload: ApprovalRequestedPayload
|
|
92
|
-
});
|
|
93
|
-
var ApprovalDecidedEvent = defineEvent({
|
|
94
|
-
meta: {
|
|
95
|
-
key: "workflow.approval.decided",
|
|
96
|
-
version: "1.0.0",
|
|
97
|
-
description: "An approval decision has been made.",
|
|
98
|
-
stability: "stable",
|
|
99
|
-
owners: ["@workflow-team"],
|
|
100
|
-
tags: ["workflow", "approval", "decided"]
|
|
101
|
-
},
|
|
102
|
-
payload: ApprovalDecidedPayload
|
|
103
|
-
});
|
|
104
|
-
var ApprovalDelegatedEvent = defineEvent({
|
|
105
|
-
meta: {
|
|
106
|
-
key: "workflow.approval.delegated",
|
|
107
|
-
version: "1.0.0",
|
|
108
|
-
description: "An approval has been delegated.",
|
|
109
|
-
stability: "stable",
|
|
110
|
-
owners: ["@workflow-team"],
|
|
111
|
-
tags: ["workflow", "approval", "delegated"]
|
|
112
|
-
},
|
|
113
|
-
payload: ApprovalDelegatedPayload
|
|
114
|
-
});
|
|
115
|
-
var ApprovalEscalatedEvent = defineEvent({
|
|
116
|
-
meta: {
|
|
117
|
-
key: "workflow.approval.escalated",
|
|
118
|
-
version: "1.0.0",
|
|
119
|
-
description: "An approval has been escalated.",
|
|
120
|
-
stability: "stable",
|
|
121
|
-
owners: ["@workflow-team"],
|
|
122
|
-
tags: ["workflow", "approval", "escalated"]
|
|
123
|
-
},
|
|
124
|
-
payload: ApprovalEscalatedPayload
|
|
125
|
-
});
|
|
126
|
-
|
|
127
|
-
// src/approval/approval.schema.ts
|
|
128
|
-
import { defineSchemaModel as defineSchemaModel2, ScalarTypeEnum as ScalarTypeEnum2 } from "@contractspec/lib.schema";
|
|
129
|
-
var ApprovalRequestModel = defineSchemaModel2({
|
|
130
|
-
name: "ApprovalRequestModel",
|
|
131
|
-
description: "An approval request",
|
|
132
|
-
fields: {
|
|
133
|
-
id: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
|
|
134
|
-
workflowInstanceId: {
|
|
135
|
-
type: ScalarTypeEnum2.String_unsecure(),
|
|
136
|
-
isOptional: false
|
|
137
|
-
},
|
|
138
|
-
stepExecutionId: {
|
|
139
|
-
type: ScalarTypeEnum2.String_unsecure(),
|
|
140
|
-
isOptional: false
|
|
141
|
-
},
|
|
142
|
-
approverId: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
|
|
143
|
-
approverRole: {
|
|
144
|
-
type: ScalarTypeEnum2.String_unsecure(),
|
|
145
|
-
isOptional: true
|
|
146
|
-
},
|
|
147
|
-
title: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
|
|
148
|
-
description: { type: ScalarTypeEnum2.String_unsecure(), isOptional: true },
|
|
149
|
-
status: { type: ApprovalStatusEnum, isOptional: false },
|
|
150
|
-
decision: { type: ApprovalDecisionEnum, isOptional: true },
|
|
151
|
-
decisionComment: {
|
|
152
|
-
type: ScalarTypeEnum2.String_unsecure(),
|
|
153
|
-
isOptional: true
|
|
154
|
-
},
|
|
155
|
-
decidedAt: { type: ScalarTypeEnum2.DateTime(), isOptional: true },
|
|
156
|
-
dueAt: { type: ScalarTypeEnum2.DateTime(), isOptional: true },
|
|
157
|
-
contextSnapshot: { type: ScalarTypeEnum2.JSON(), isOptional: true },
|
|
158
|
-
sequenceOrder: { type: ScalarTypeEnum2.Int_unsecure(), isOptional: false },
|
|
159
|
-
createdAt: { type: ScalarTypeEnum2.DateTime(), isOptional: false }
|
|
160
|
-
}
|
|
161
|
-
});
|
|
162
|
-
var ApprovalCommentModel = defineSchemaModel2({
|
|
163
|
-
name: "ApprovalCommentModel",
|
|
164
|
-
description: "A comment on an approval",
|
|
165
|
-
fields: {
|
|
166
|
-
id: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
|
|
167
|
-
approvalRequestId: {
|
|
168
|
-
type: ScalarTypeEnum2.String_unsecure(),
|
|
169
|
-
isOptional: false
|
|
170
|
-
},
|
|
171
|
-
authorId: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
|
|
172
|
-
content: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
|
|
173
|
-
isInternal: { type: ScalarTypeEnum2.Boolean(), isOptional: false },
|
|
174
|
-
createdAt: { type: ScalarTypeEnum2.DateTime(), isOptional: false }
|
|
175
|
-
}
|
|
176
|
-
});
|
|
177
|
-
|
|
178
|
-
// src/approval/approval.operations.ts
|
|
179
|
-
import {
|
|
180
|
-
defineCommand,
|
|
181
|
-
defineQuery
|
|
182
|
-
} from "@contractspec/lib.contracts-spec/operations";
|
|
183
|
-
import { defineSchemaModel as defineSchemaModel3, ScalarTypeEnum as ScalarTypeEnum3 } from "@contractspec/lib.schema";
|
|
184
|
-
var OWNERS = ["@example.workflow-system"];
|
|
185
|
-
var SubmitDecisionContract = defineCommand({
|
|
186
|
-
meta: {
|
|
187
|
-
key: "workflow.approval.decide",
|
|
188
|
-
version: "1.0.0",
|
|
189
|
-
stability: "stable",
|
|
190
|
-
owners: [...OWNERS],
|
|
191
|
-
tags: ["workflow", "approval", "decision"],
|
|
192
|
-
description: "Submit an approval decision (approve/reject).",
|
|
193
|
-
goal: "Allow approvers to make decisions on requests.",
|
|
194
|
-
context: "Approval inbox, workflow detail."
|
|
195
|
-
},
|
|
196
|
-
io: {
|
|
197
|
-
input: defineSchemaModel3({
|
|
198
|
-
name: "ApproveRejectInput",
|
|
199
|
-
fields: {
|
|
200
|
-
requestId: {
|
|
201
|
-
type: ScalarTypeEnum3.String_unsecure(),
|
|
202
|
-
isOptional: false
|
|
203
|
-
},
|
|
204
|
-
decision: { type: ApprovalDecisionEnum, isOptional: false },
|
|
205
|
-
comment: { type: ScalarTypeEnum3.String_unsecure(), isOptional: true },
|
|
206
|
-
data: { type: ScalarTypeEnum3.JSON(), isOptional: true }
|
|
207
|
-
}
|
|
208
|
-
}),
|
|
209
|
-
output: ApprovalRequestModel
|
|
210
|
-
},
|
|
211
|
-
policy: { auth: "user" },
|
|
212
|
-
sideEffects: {
|
|
213
|
-
emits: [
|
|
214
|
-
{
|
|
215
|
-
key: "workflow.approval.decided",
|
|
216
|
-
version: "1.0.0",
|
|
217
|
-
when: "Decision is made",
|
|
218
|
-
payload: ApprovalRequestModel
|
|
219
|
-
}
|
|
220
|
-
],
|
|
221
|
-
audit: ["workflow.approval.decided"]
|
|
222
|
-
},
|
|
223
|
-
acceptance: {
|
|
224
|
-
scenarios: [
|
|
225
|
-
{
|
|
226
|
-
key: "approve-request-happy-path",
|
|
227
|
-
given: ["Approval request is pending", "User is assignee"],
|
|
228
|
-
when: ["User approves request"],
|
|
229
|
-
then: ["Request is approved", "ApprovalDecided event is emitted"]
|
|
230
|
-
}
|
|
231
|
-
],
|
|
232
|
-
examples: [
|
|
233
|
-
{
|
|
234
|
-
key: "approve-basic",
|
|
235
|
-
input: {
|
|
236
|
-
requestId: "req-123",
|
|
237
|
-
decision: "approve",
|
|
238
|
-
comment: "Looks good"
|
|
239
|
-
},
|
|
240
|
-
output: { id: "req-123", status: "approved" }
|
|
241
|
-
}
|
|
242
|
-
]
|
|
243
|
-
}
|
|
244
|
-
});
|
|
245
|
-
var DelegateApprovalContract = defineCommand({
|
|
246
|
-
meta: {
|
|
247
|
-
key: "workflow.approval.delegate",
|
|
248
|
-
version: "1.0.0",
|
|
249
|
-
stability: "stable",
|
|
250
|
-
owners: [...OWNERS],
|
|
251
|
-
tags: ["workflow", "approval", "delegate"],
|
|
252
|
-
description: "Delegate an approval request to another user.",
|
|
253
|
-
goal: "Allow approvers to pass approval to others.",
|
|
254
|
-
context: "Approval inbox."
|
|
255
|
-
},
|
|
256
|
-
io: {
|
|
257
|
-
input: defineSchemaModel3({
|
|
258
|
-
name: "DelegateInput",
|
|
259
|
-
fields: {
|
|
260
|
-
requestId: {
|
|
261
|
-
type: ScalarTypeEnum3.String_unsecure(),
|
|
262
|
-
isOptional: false
|
|
263
|
-
},
|
|
264
|
-
delegateTo: {
|
|
265
|
-
type: ScalarTypeEnum3.String_unsecure(),
|
|
266
|
-
isOptional: false
|
|
267
|
-
},
|
|
268
|
-
reason: { type: ScalarTypeEnum3.String_unsecure(), isOptional: true }
|
|
269
|
-
}
|
|
270
|
-
}),
|
|
271
|
-
output: ApprovalRequestModel
|
|
272
|
-
},
|
|
273
|
-
policy: { auth: "user" },
|
|
274
|
-
sideEffects: {
|
|
275
|
-
emits: [
|
|
276
|
-
{
|
|
277
|
-
key: "workflow.approval.delegated",
|
|
278
|
-
version: "1.0.0",
|
|
279
|
-
when: "Approval is delegated",
|
|
280
|
-
payload: ApprovalRequestModel
|
|
281
|
-
}
|
|
282
|
-
],
|
|
283
|
-
audit: ["workflow.approval.delegated"]
|
|
284
|
-
},
|
|
285
|
-
acceptance: {
|
|
286
|
-
scenarios: [
|
|
287
|
-
{
|
|
288
|
-
key: "delegate-approval-happy-path",
|
|
289
|
-
given: ["Approval request is pending", "User is assignee"],
|
|
290
|
-
when: ["User delegates to another user"],
|
|
291
|
-
then: ["Assignee is updated", "ApprovalDelegated event is emitted"]
|
|
292
|
-
}
|
|
293
|
-
],
|
|
294
|
-
examples: [
|
|
295
|
-
{
|
|
296
|
-
key: "delegate-to-manager",
|
|
297
|
-
input: {
|
|
298
|
-
requestId: "req-123",
|
|
299
|
-
delegateTo: "user-456",
|
|
300
|
-
reason: "Out of office"
|
|
301
|
-
},
|
|
302
|
-
output: { id: "req-123", assigneeId: "user-456" }
|
|
303
|
-
}
|
|
304
|
-
]
|
|
305
|
-
}
|
|
306
|
-
});
|
|
307
|
-
var AddApprovalCommentContract = defineCommand({
|
|
308
|
-
meta: {
|
|
309
|
-
key: "workflow.approval.comment.add",
|
|
310
|
-
version: "1.0.0",
|
|
311
|
-
stability: "stable",
|
|
312
|
-
owners: [...OWNERS],
|
|
313
|
-
tags: ["workflow", "approval", "comment"],
|
|
314
|
-
description: "Add a comment to an approval request.",
|
|
315
|
-
goal: "Allow discussion on approval requests.",
|
|
316
|
-
context: "Approval detail view."
|
|
317
|
-
},
|
|
318
|
-
io: {
|
|
319
|
-
input: defineSchemaModel3({
|
|
320
|
-
name: "AddCommentInput",
|
|
321
|
-
fields: {
|
|
322
|
-
requestId: {
|
|
323
|
-
type: ScalarTypeEnum3.String_unsecure(),
|
|
324
|
-
isOptional: false
|
|
325
|
-
},
|
|
326
|
-
content: { type: ScalarTypeEnum3.NonEmptyString(), isOptional: false },
|
|
327
|
-
isInternal: { type: ScalarTypeEnum3.Boolean(), isOptional: true }
|
|
328
|
-
}
|
|
329
|
-
}),
|
|
330
|
-
output: ApprovalCommentModel
|
|
331
|
-
},
|
|
332
|
-
policy: { auth: "user" },
|
|
333
|
-
sideEffects: {
|
|
334
|
-
emits: [
|
|
335
|
-
{
|
|
336
|
-
key: "workflow.approval.comment.added",
|
|
337
|
-
version: "1.0.0",
|
|
338
|
-
when: "Comment is added",
|
|
339
|
-
payload: ApprovalCommentModel
|
|
340
|
-
}
|
|
341
|
-
]
|
|
342
|
-
},
|
|
343
|
-
acceptance: {
|
|
344
|
-
scenarios: [
|
|
345
|
-
{
|
|
346
|
-
key: "add-comment-happy-path",
|
|
347
|
-
given: ["Approval request exists"],
|
|
348
|
-
when: ["User adds a comment"],
|
|
349
|
-
then: ["Comment is added", "CommentAdded event is emitted"]
|
|
350
|
-
}
|
|
351
|
-
],
|
|
352
|
-
examples: [
|
|
353
|
-
{
|
|
354
|
-
key: "add-question",
|
|
355
|
-
input: {
|
|
356
|
-
requestId: "req-123",
|
|
357
|
-
content: "Can you clarify budget?",
|
|
358
|
-
isInternal: false
|
|
359
|
-
},
|
|
360
|
-
output: { id: "com-789", content: "Can you clarify budget?" }
|
|
361
|
-
}
|
|
362
|
-
]
|
|
363
|
-
}
|
|
364
|
-
});
|
|
365
|
-
var ListMyApprovalsContract = defineQuery({
|
|
366
|
-
meta: {
|
|
367
|
-
key: "workflow.approval.list.mine",
|
|
368
|
-
version: "1.0.0",
|
|
369
|
-
stability: "stable",
|
|
370
|
-
owners: [...OWNERS],
|
|
371
|
-
tags: ["workflow", "approval", "list", "inbox"],
|
|
372
|
-
description: "List approval requests assigned to current user.",
|
|
373
|
-
goal: "Show pending approvals in user inbox.",
|
|
374
|
-
context: "Approval inbox, dashboard widget."
|
|
375
|
-
},
|
|
376
|
-
io: {
|
|
377
|
-
input: defineSchemaModel3({
|
|
378
|
-
name: "ListMyApprovalsInput",
|
|
379
|
-
fields: {
|
|
380
|
-
status: { type: ApprovalStatusEnum, isOptional: true },
|
|
381
|
-
limit: {
|
|
382
|
-
type: ScalarTypeEnum3.Int_unsecure(),
|
|
383
|
-
isOptional: true,
|
|
384
|
-
defaultValue: 20
|
|
385
|
-
},
|
|
386
|
-
offset: {
|
|
387
|
-
type: ScalarTypeEnum3.Int_unsecure(),
|
|
388
|
-
isOptional: true,
|
|
389
|
-
defaultValue: 0
|
|
390
|
-
}
|
|
391
|
-
}
|
|
392
|
-
}),
|
|
393
|
-
output: defineSchemaModel3({
|
|
394
|
-
name: "ListMyApprovalsOutput",
|
|
395
|
-
fields: {
|
|
396
|
-
requests: {
|
|
397
|
-
type: ApprovalRequestModel,
|
|
398
|
-
isArray: true,
|
|
399
|
-
isOptional: false
|
|
400
|
-
},
|
|
401
|
-
total: { type: ScalarTypeEnum3.Int_unsecure(), isOptional: false },
|
|
402
|
-
pendingCount: {
|
|
403
|
-
type: ScalarTypeEnum3.Int_unsecure(),
|
|
404
|
-
isOptional: false
|
|
405
|
-
}
|
|
406
|
-
}
|
|
407
|
-
})
|
|
408
|
-
},
|
|
409
|
-
policy: { auth: "user" },
|
|
410
|
-
acceptance: {
|
|
411
|
-
scenarios: [
|
|
412
|
-
{
|
|
413
|
-
key: "list-approvals-happy-path",
|
|
414
|
-
given: ["User has assigned approvals"],
|
|
415
|
-
when: ["User lists approvals"],
|
|
416
|
-
then: ["List of requests is returned"]
|
|
417
|
-
}
|
|
418
|
-
],
|
|
419
|
-
examples: [
|
|
420
|
-
{
|
|
421
|
-
key: "list-pending",
|
|
422
|
-
input: { status: "pending", limit: 10 },
|
|
423
|
-
output: { requests: [], total: 2, pendingCount: 2 }
|
|
424
|
-
}
|
|
425
|
-
]
|
|
426
|
-
}
|
|
427
|
-
});
|
|
428
|
-
var GetApprovalContract = defineQuery({
|
|
429
|
-
meta: {
|
|
430
|
-
key: "workflow.approval.get",
|
|
431
|
-
version: "1.0.0",
|
|
432
|
-
stability: "stable",
|
|
433
|
-
owners: [...OWNERS],
|
|
434
|
-
tags: ["workflow", "approval", "get"],
|
|
435
|
-
description: "Get an approval request with details.",
|
|
436
|
-
goal: "View approval request details.",
|
|
437
|
-
context: "Approval detail view."
|
|
438
|
-
},
|
|
439
|
-
io: {
|
|
440
|
-
input: defineSchemaModel3({
|
|
441
|
-
name: "GetApprovalInput",
|
|
442
|
-
fields: {
|
|
443
|
-
requestId: {
|
|
444
|
-
type: ScalarTypeEnum3.String_unsecure(),
|
|
445
|
-
isOptional: false
|
|
446
|
-
}
|
|
447
|
-
}
|
|
448
|
-
}),
|
|
449
|
-
output: ApprovalRequestModel
|
|
450
|
-
},
|
|
451
|
-
policy: { auth: "user" },
|
|
452
|
-
acceptance: {
|
|
453
|
-
scenarios: [
|
|
454
|
-
{
|
|
455
|
-
key: "get-approval-happy-path",
|
|
456
|
-
given: ["Approval request exists"],
|
|
457
|
-
when: ["User requests approval details"],
|
|
458
|
-
then: ["Approval details are returned"]
|
|
459
|
-
}
|
|
460
|
-
],
|
|
461
|
-
examples: [
|
|
462
|
-
{
|
|
463
|
-
key: "get-basic",
|
|
464
|
-
input: { requestId: "req-123" },
|
|
465
|
-
output: { id: "req-123", status: "pending" }
|
|
466
|
-
}
|
|
467
|
-
]
|
|
468
|
-
}
|
|
469
|
-
});
|
|
470
|
-
export {
|
|
471
|
-
SubmitDecisionContract,
|
|
472
|
-
ListMyApprovalsContract,
|
|
473
|
-
GetApprovalContract,
|
|
474
|
-
DelegateApprovalContract,
|
|
475
|
-
ApprovalStatusEnum,
|
|
476
|
-
ApprovalRequestedEvent,
|
|
477
|
-
ApprovalRequestModel,
|
|
478
|
-
ApprovalEscalatedEvent,
|
|
479
|
-
ApprovalDelegatedEvent,
|
|
480
|
-
ApprovalDecisionEnum,
|
|
481
|
-
ApprovalDecidedEvent,
|
|
482
|
-
ApprovalCommentModel,
|
|
483
|
-
AddApprovalCommentContract
|
|
484
|
-
};
|
|
1
|
+
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,15 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
import { registerDocBlocks } from "@contractspec/lib.contracts-spec/docs";
|
|
3
|
-
var workflowSystemDocBlocks = [
|
|
4
|
-
{
|
|
5
|
-
id: "docs.examples.workflow-system",
|
|
6
|
-
title: "Workflow / Approval System",
|
|
7
|
-
summary: "Reference app showing state-machine driven approvals with RBAC, audit trail, notifications, and jobs.",
|
|
8
|
-
kind: "reference",
|
|
9
|
-
visibility: "public",
|
|
10
|
-
route: "/docs/examples/workflow-system",
|
|
11
|
-
tags: ["workflow", "approval", "state-machine", "rbac"],
|
|
12
|
-
body: `## Entities
|
|
1
|
+
import{registerDocBlocks as h}from"@contractspec/lib.contracts-spec/docs";var j=[{id:"docs.examples.workflow-system",title:"Workflow / Approval System",summary:"Reference app showing state-machine driven approvals with RBAC, audit trail, notifications, and jobs.",kind:"reference",visibility:"public",route:"/docs/examples/workflow-system",tags:["workflow","approval","state-machine","rbac"],body:`## Entities
|
|
13
2
|
|
|
14
3
|
- WorkflowDefinition, WorkflowStep, WorkflowInstance, Approval.
|
|
15
4
|
- State machine expressed in \`src/state-machine\` with allowed transitions and role gates.
|
|
@@ -33,17 +22,7 @@ var workflowSystemDocBlocks = [
|
|
|
33
22
|
|
|
34
23
|
- Keep transitions declarative to enable safe regeneration; role guards live in spec.
|
|
35
24
|
- Use Notification Center for approval requests and outcomes; attach files via Files module if needed.
|
|
36
|
-
`
|
|
37
|
-
},
|
|
38
|
-
{
|
|
39
|
-
id: "docs.examples.workflow-system.goal",
|
|
40
|
-
title: "Workflow System — Goal",
|
|
41
|
-
summary: "Why the workflow/approval template exists and outcomes it targets.",
|
|
42
|
-
kind: "goal",
|
|
43
|
-
visibility: "public",
|
|
44
|
-
route: "/docs/examples/workflow-system/goal",
|
|
45
|
-
tags: ["workflow", "goal"],
|
|
46
|
-
body: `## Why it matters
|
|
25
|
+
`},{id:"docs.examples.workflow-system.goal",title:"Workflow System — Goal",summary:"Why the workflow/approval template exists and outcomes it targets.",kind:"goal",visibility:"public",route:"/docs/examples/workflow-system/goal",tags:["workflow","goal"],body:`## Why it matters
|
|
47
26
|
- Provides a regenerable, role-gated approval engine using declarative state machines.
|
|
48
27
|
- Keeps workflow rules consistent across UI/API/events with auditability.
|
|
49
28
|
|
|
@@ -53,17 +32,7 @@ var workflowSystemDocBlocks = [
|
|
|
53
32
|
|
|
54
33
|
## Success criteria
|
|
55
34
|
- State changes are declarative and regenerate cleanly.
|
|
56
|
-
- Every transition emits auditable events and respects RBAC guards.`
|
|
57
|
-
},
|
|
58
|
-
{
|
|
59
|
-
id: "docs.examples.workflow-system.usage",
|
|
60
|
-
title: "Workflow System — Usage",
|
|
61
|
-
summary: "How to configure workflows, transitions, and regenerate safely.",
|
|
62
|
-
kind: "usage",
|
|
63
|
-
visibility: "public",
|
|
64
|
-
route: "/docs/examples/workflow-system/usage",
|
|
65
|
-
tags: ["workflow", "usage"],
|
|
66
|
-
body: `## Setup
|
|
35
|
+
- Every transition emits auditable events and respects RBAC guards.`},{id:"docs.examples.workflow-system.usage",title:"Workflow System — Usage",summary:"How to configure workflows, transitions, and regenerate safely.",kind:"usage",visibility:"public",route:"/docs/examples/workflow-system/usage",tags:["workflow","usage"],body:`## Setup
|
|
67
36
|
1) Define WorkflowDefinition steps and allowed transitions with role gates in spec.
|
|
68
37
|
2) Seed sample workflows/instances (if provided) or create via UI; enable reminders via Jobs.
|
|
69
38
|
|
|
@@ -75,17 +44,7 @@ var workflowSystemDocBlocks = [
|
|
|
75
44
|
## Guardrails
|
|
76
45
|
- Emit events for every transition; log to Audit Trail.
|
|
77
46
|
- Use Notifications for approvals/rejections; schedule reminders for pending steps.
|
|
78
|
-
- Keep transitions declarative; avoid imperative branching in handlers.`
|
|
79
|
-
},
|
|
80
|
-
{
|
|
81
|
-
id: "docs.examples.workflow-system.constraints",
|
|
82
|
-
title: "Workflow System — Constraints & Safety",
|
|
83
|
-
summary: "Internal guardrails for state machines, RBAC, and regeneration semantics.",
|
|
84
|
-
kind: "reference",
|
|
85
|
-
visibility: "internal",
|
|
86
|
-
route: "/docs/examples/workflow-system/constraints",
|
|
87
|
-
tags: ["workflow", "constraints", "internal"],
|
|
88
|
-
body: `## Constraints
|
|
47
|
+
- Keep transitions declarative; avoid imperative branching in handlers.`},{id:"docs.examples.workflow-system.constraints",title:"Workflow System — Constraints & Safety",summary:"Internal guardrails for state machines, RBAC, and regeneration semantics.",kind:"reference",visibility:"internal",route:"/docs/examples/workflow-system/constraints",tags:["workflow","constraints","internal"],body:`## Constraints
|
|
89
48
|
- State machine (steps/transitions) must stay declarative in spec; no hidden code paths.
|
|
90
49
|
- Events to emit: instance.started, step.completed/rejected, instance.finished.
|
|
91
50
|
- Regeneration must not change approval logic without explicit spec diff.
|
|
@@ -97,7 +56,4 @@ var workflowSystemDocBlocks = [
|
|
|
97
56
|
## Verification
|
|
98
57
|
- Add fixtures for transition changes and role gates.
|
|
99
58
|
- Validate reminders (Jobs) stay aligned with pending states after regeneration.
|
|
100
|
-
- Use Feature Flags for new transitions/escalation rules; default safe/off.`
|
|
101
|
-
}
|
|
102
|
-
];
|
|
103
|
-
registerDocBlocks(workflowSystemDocBlocks);
|
|
59
|
+
- Use Feature Flags for new transitions/escalation rules; default safe/off.`}];h(j);
|
|
@@ -1,15 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
import { registerDocBlocks } from "@contractspec/lib.contracts-spec/docs";
|
|
3
|
-
var workflowSystemDocBlocks = [
|
|
4
|
-
{
|
|
5
|
-
id: "docs.examples.workflow-system",
|
|
6
|
-
title: "Workflow / Approval System",
|
|
7
|
-
summary: "Reference app showing state-machine driven approvals with RBAC, audit trail, notifications, and jobs.",
|
|
8
|
-
kind: "reference",
|
|
9
|
-
visibility: "public",
|
|
10
|
-
route: "/docs/examples/workflow-system",
|
|
11
|
-
tags: ["workflow", "approval", "state-machine", "rbac"],
|
|
12
|
-
body: `## Entities
|
|
1
|
+
import{registerDocBlocks as h}from"@contractspec/lib.contracts-spec/docs";var j=[{id:"docs.examples.workflow-system",title:"Workflow / Approval System",summary:"Reference app showing state-machine driven approvals with RBAC, audit trail, notifications, and jobs.",kind:"reference",visibility:"public",route:"/docs/examples/workflow-system",tags:["workflow","approval","state-machine","rbac"],body:`## Entities
|
|
13
2
|
|
|
14
3
|
- WorkflowDefinition, WorkflowStep, WorkflowInstance, Approval.
|
|
15
4
|
- State machine expressed in \`src/state-machine\` with allowed transitions and role gates.
|
|
@@ -33,17 +22,7 @@ var workflowSystemDocBlocks = [
|
|
|
33
22
|
|
|
34
23
|
- Keep transitions declarative to enable safe regeneration; role guards live in spec.
|
|
35
24
|
- Use Notification Center for approval requests and outcomes; attach files via Files module if needed.
|
|
36
|
-
`
|
|
37
|
-
},
|
|
38
|
-
{
|
|
39
|
-
id: "docs.examples.workflow-system.goal",
|
|
40
|
-
title: "Workflow System — Goal",
|
|
41
|
-
summary: "Why the workflow/approval template exists and outcomes it targets.",
|
|
42
|
-
kind: "goal",
|
|
43
|
-
visibility: "public",
|
|
44
|
-
route: "/docs/examples/workflow-system/goal",
|
|
45
|
-
tags: ["workflow", "goal"],
|
|
46
|
-
body: `## Why it matters
|
|
25
|
+
`},{id:"docs.examples.workflow-system.goal",title:"Workflow System — Goal",summary:"Why the workflow/approval template exists and outcomes it targets.",kind:"goal",visibility:"public",route:"/docs/examples/workflow-system/goal",tags:["workflow","goal"],body:`## Why it matters
|
|
47
26
|
- Provides a regenerable, role-gated approval engine using declarative state machines.
|
|
48
27
|
- Keeps workflow rules consistent across UI/API/events with auditability.
|
|
49
28
|
|
|
@@ -53,17 +32,7 @@ var workflowSystemDocBlocks = [
|
|
|
53
32
|
|
|
54
33
|
## Success criteria
|
|
55
34
|
- State changes are declarative and regenerate cleanly.
|
|
56
|
-
- Every transition emits auditable events and respects RBAC guards.`
|
|
57
|
-
},
|
|
58
|
-
{
|
|
59
|
-
id: "docs.examples.workflow-system.usage",
|
|
60
|
-
title: "Workflow System — Usage",
|
|
61
|
-
summary: "How to configure workflows, transitions, and regenerate safely.",
|
|
62
|
-
kind: "usage",
|
|
63
|
-
visibility: "public",
|
|
64
|
-
route: "/docs/examples/workflow-system/usage",
|
|
65
|
-
tags: ["workflow", "usage"],
|
|
66
|
-
body: `## Setup
|
|
35
|
+
- Every transition emits auditable events and respects RBAC guards.`},{id:"docs.examples.workflow-system.usage",title:"Workflow System — Usage",summary:"How to configure workflows, transitions, and regenerate safely.",kind:"usage",visibility:"public",route:"/docs/examples/workflow-system/usage",tags:["workflow","usage"],body:`## Setup
|
|
67
36
|
1) Define WorkflowDefinition steps and allowed transitions with role gates in spec.
|
|
68
37
|
2) Seed sample workflows/instances (if provided) or create via UI; enable reminders via Jobs.
|
|
69
38
|
|
|
@@ -75,17 +44,7 @@ var workflowSystemDocBlocks = [
|
|
|
75
44
|
## Guardrails
|
|
76
45
|
- Emit events for every transition; log to Audit Trail.
|
|
77
46
|
- Use Notifications for approvals/rejections; schedule reminders for pending steps.
|
|
78
|
-
- Keep transitions declarative; avoid imperative branching in handlers.`
|
|
79
|
-
},
|
|
80
|
-
{
|
|
81
|
-
id: "docs.examples.workflow-system.constraints",
|
|
82
|
-
title: "Workflow System — Constraints & Safety",
|
|
83
|
-
summary: "Internal guardrails for state machines, RBAC, and regeneration semantics.",
|
|
84
|
-
kind: "reference",
|
|
85
|
-
visibility: "internal",
|
|
86
|
-
route: "/docs/examples/workflow-system/constraints",
|
|
87
|
-
tags: ["workflow", "constraints", "internal"],
|
|
88
|
-
body: `## Constraints
|
|
47
|
+
- Keep transitions declarative; avoid imperative branching in handlers.`},{id:"docs.examples.workflow-system.constraints",title:"Workflow System — Constraints & Safety",summary:"Internal guardrails for state machines, RBAC, and regeneration semantics.",kind:"reference",visibility:"internal",route:"/docs/examples/workflow-system/constraints",tags:["workflow","constraints","internal"],body:`## Constraints
|
|
89
48
|
- State machine (steps/transitions) must stay declarative in spec; no hidden code paths.
|
|
90
49
|
- Events to emit: instance.started, step.completed/rejected, instance.finished.
|
|
91
50
|
- Regeneration must not change approval logic without explicit spec diff.
|
|
@@ -97,7 +56,4 @@ var workflowSystemDocBlocks = [
|
|
|
97
56
|
## Verification
|
|
98
57
|
- Add fixtures for transition changes and role gates.
|
|
99
58
|
- Validate reminders (Jobs) stay aligned with pending states after regeneration.
|
|
100
|
-
- Use Feature Flags for new transitions/escalation rules; default safe/off.`
|
|
101
|
-
}
|
|
102
|
-
];
|
|
103
|
-
registerDocBlocks(workflowSystemDocBlocks);
|
|
59
|
+
- Use Feature Flags for new transitions/escalation rules; default safe/off.`}];h(j);
|