business-as-code 0.2.1 → 2.0.1

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 (190) hide show
  1. package/.turbo/turbo-build.log +5 -0
  2. package/CHANGELOG.md +9 -0
  3. package/IMPLEMENTATION.md +226 -0
  4. package/README.md +1133 -193
  5. package/dist/business.d.ts +62 -0
  6. package/dist/business.d.ts.map +1 -0
  7. package/dist/business.js +109 -0
  8. package/dist/business.js.map +1 -0
  9. package/dist/dollar.d.ts +60 -0
  10. package/dist/dollar.d.ts.map +1 -0
  11. package/dist/dollar.js +107 -0
  12. package/dist/dollar.js.map +1 -0
  13. package/dist/entities/assets.d.ts +21 -0
  14. package/dist/entities/assets.d.ts.map +1 -0
  15. package/dist/entities/assets.js +323 -0
  16. package/dist/entities/assets.js.map +1 -0
  17. package/dist/entities/business.d.ts +36 -0
  18. package/dist/entities/business.d.ts.map +1 -0
  19. package/dist/entities/business.js +370 -0
  20. package/dist/entities/business.js.map +1 -0
  21. package/dist/entities/communication.d.ts +21 -0
  22. package/dist/entities/communication.d.ts.map +1 -0
  23. package/dist/entities/communication.js +255 -0
  24. package/dist/entities/communication.js.map +1 -0
  25. package/dist/entities/customers.d.ts +58 -0
  26. package/dist/entities/customers.d.ts.map +1 -0
  27. package/dist/entities/customers.js +989 -0
  28. package/dist/entities/customers.js.map +1 -0
  29. package/dist/entities/financials.d.ts +59 -0
  30. package/dist/entities/financials.d.ts.map +1 -0
  31. package/dist/entities/financials.js +932 -0
  32. package/dist/entities/financials.js.map +1 -0
  33. package/dist/entities/goals.d.ts +58 -0
  34. package/dist/entities/goals.d.ts.map +1 -0
  35. package/dist/entities/goals.js +800 -0
  36. package/dist/entities/goals.js.map +1 -0
  37. package/dist/entities/index.d.ts +299 -0
  38. package/dist/entities/index.d.ts.map +1 -0
  39. package/dist/entities/index.js +198 -0
  40. package/dist/entities/index.js.map +1 -0
  41. package/dist/entities/legal.d.ts +21 -0
  42. package/dist/entities/legal.d.ts.map +1 -0
  43. package/dist/entities/legal.js +301 -0
  44. package/dist/entities/legal.js.map +1 -0
  45. package/dist/entities/market.d.ts +21 -0
  46. package/dist/entities/market.d.ts.map +1 -0
  47. package/dist/entities/market.js +301 -0
  48. package/dist/entities/market.js.map +1 -0
  49. package/dist/entities/marketing.d.ts +67 -0
  50. package/dist/entities/marketing.d.ts.map +1 -0
  51. package/dist/entities/marketing.js +1157 -0
  52. package/dist/entities/marketing.js.map +1 -0
  53. package/dist/entities/offerings.d.ts +51 -0
  54. package/dist/entities/offerings.d.ts.map +1 -0
  55. package/dist/entities/offerings.js +727 -0
  56. package/dist/entities/offerings.js.map +1 -0
  57. package/dist/entities/operations.d.ts +58 -0
  58. package/dist/entities/operations.d.ts.map +1 -0
  59. package/dist/entities/operations.js +787 -0
  60. package/dist/entities/operations.js.map +1 -0
  61. package/dist/entities/organization.d.ts +57 -0
  62. package/dist/entities/organization.d.ts.map +1 -0
  63. package/dist/entities/organization.js +807 -0
  64. package/dist/entities/organization.js.map +1 -0
  65. package/dist/entities/partnerships.d.ts +21 -0
  66. package/dist/entities/partnerships.d.ts.map +1 -0
  67. package/dist/entities/partnerships.js +300 -0
  68. package/dist/entities/partnerships.js.map +1 -0
  69. package/dist/entities/planning.d.ts +87 -0
  70. package/dist/entities/planning.d.ts.map +1 -0
  71. package/dist/entities/planning.js +271 -0
  72. package/dist/entities/planning.js.map +1 -0
  73. package/dist/entities/projects.d.ts +25 -0
  74. package/dist/entities/projects.d.ts.map +1 -0
  75. package/dist/entities/projects.js +349 -0
  76. package/dist/entities/projects.js.map +1 -0
  77. package/dist/entities/risk.d.ts +21 -0
  78. package/dist/entities/risk.d.ts.map +1 -0
  79. package/dist/entities/risk.js +293 -0
  80. package/dist/entities/risk.js.map +1 -0
  81. package/dist/entities/sales.d.ts +72 -0
  82. package/dist/entities/sales.d.ts.map +1 -0
  83. package/dist/entities/sales.js +1248 -0
  84. package/dist/entities/sales.js.map +1 -0
  85. package/dist/financials.d.ts +130 -0
  86. package/dist/financials.d.ts.map +1 -0
  87. package/dist/financials.js +297 -0
  88. package/dist/financials.js.map +1 -0
  89. package/dist/goals.d.ts +87 -0
  90. package/dist/goals.d.ts.map +1 -0
  91. package/dist/goals.js +215 -0
  92. package/dist/goals.js.map +1 -0
  93. package/dist/index.d.ts +97 -4
  94. package/dist/index.d.ts.map +1 -0
  95. package/dist/index.js +131 -1079
  96. package/dist/index.js.map +1 -1
  97. package/dist/kpis.d.ts +118 -0
  98. package/dist/kpis.d.ts.map +1 -0
  99. package/dist/kpis.js +232 -0
  100. package/dist/kpis.js.map +1 -0
  101. package/dist/metrics.d.ts +448 -0
  102. package/dist/metrics.d.ts.map +1 -0
  103. package/dist/metrics.js +325 -0
  104. package/dist/metrics.js.map +1 -0
  105. package/dist/okrs.d.ts +123 -0
  106. package/dist/okrs.d.ts.map +1 -0
  107. package/dist/okrs.js +269 -0
  108. package/dist/okrs.js.map +1 -0
  109. package/dist/organization.d.ts +585 -0
  110. package/dist/organization.d.ts.map +1 -0
  111. package/dist/organization.js +173 -0
  112. package/dist/organization.js.map +1 -0
  113. package/dist/process.d.ts +112 -0
  114. package/dist/process.d.ts.map +1 -0
  115. package/dist/process.js +241 -0
  116. package/dist/process.js.map +1 -0
  117. package/dist/product.d.ts +85 -0
  118. package/dist/product.d.ts.map +1 -0
  119. package/dist/product.js +145 -0
  120. package/dist/product.js.map +1 -0
  121. package/dist/queries.d.ts +304 -0
  122. package/dist/queries.d.ts.map +1 -0
  123. package/dist/queries.js +415 -0
  124. package/dist/queries.js.map +1 -0
  125. package/dist/roles.d.ts +340 -0
  126. package/dist/roles.d.ts.map +1 -0
  127. package/dist/roles.js +255 -0
  128. package/dist/roles.js.map +1 -0
  129. package/dist/service.d.ts +61 -0
  130. package/dist/service.d.ts.map +1 -0
  131. package/dist/service.js +140 -0
  132. package/dist/service.js.map +1 -0
  133. package/dist/types.d.ts +459 -0
  134. package/dist/types.d.ts.map +1 -0
  135. package/dist/types.js +5 -0
  136. package/dist/types.js.map +1 -0
  137. package/dist/vision.d.ts +38 -0
  138. package/dist/vision.d.ts.map +1 -0
  139. package/dist/vision.js +68 -0
  140. package/dist/vision.js.map +1 -0
  141. package/dist/workflow.d.ts +115 -0
  142. package/dist/workflow.d.ts.map +1 -0
  143. package/dist/workflow.js +247 -0
  144. package/dist/workflow.js.map +1 -0
  145. package/examples/basic-usage.ts +307 -0
  146. package/package.json +19 -60
  147. package/src/business.ts +121 -0
  148. package/src/dollar.ts +132 -0
  149. package/src/entities/assets.ts +332 -0
  150. package/src/entities/business.ts +406 -0
  151. package/src/entities/communication.ts +264 -0
  152. package/src/entities/customers.ts +1072 -0
  153. package/src/entities/financials.ts +1011 -0
  154. package/src/entities/goals.ts +871 -0
  155. package/src/entities/index.ts +383 -0
  156. package/src/entities/legal.ts +310 -0
  157. package/src/entities/market.ts +310 -0
  158. package/src/entities/marketing.ts +1249 -0
  159. package/src/entities/offerings.ts +789 -0
  160. package/src/entities/operations.ts +861 -0
  161. package/src/entities/organization.ts +876 -0
  162. package/src/entities/partnerships.ts +309 -0
  163. package/src/entities/planning.ts +307 -0
  164. package/src/entities/projects.ts +360 -0
  165. package/src/entities/risk.ts +302 -0
  166. package/src/entities/sales.ts +1352 -0
  167. package/src/financials.ts +352 -0
  168. package/src/goals.ts +250 -0
  169. package/src/index.test.ts +336 -0
  170. package/src/index.ts +530 -0
  171. package/src/kpis.ts +275 -0
  172. package/src/metrics.ts +825 -0
  173. package/src/okrs.ts +325 -0
  174. package/src/organization.ts +909 -0
  175. package/src/process.ts +272 -0
  176. package/src/product.ts +178 -0
  177. package/src/queries.ts +767 -0
  178. package/src/roles.ts +686 -0
  179. package/src/service.ts +164 -0
  180. package/src/types.ts +493 -0
  181. package/src/vision.ts +88 -0
  182. package/src/workflow.ts +280 -0
  183. package/tsconfig.json +9 -0
  184. package/dist/loaders/index.d.ts +0 -174
  185. package/dist/loaders/index.js +0 -366
  186. package/dist/loaders/index.js.map +0 -1
  187. package/dist/schema/index.d.ts +0 -146
  188. package/dist/schema/index.js +0 -716
  189. package/dist/schema/index.js.map +0 -1
  190. package/dist/types-CJ9eGS_C.d.ts +0 -86
@@ -0,0 +1,861 @@
1
+ /**
2
+ * Operations Entity Types (Nouns)
3
+ *
4
+ * Business operations: Process, Workflow, Procedure, Policy.
5
+ *
6
+ * @packageDocumentation
7
+ */
8
+
9
+ import type { Noun } from 'ai-database'
10
+
11
+ // =============================================================================
12
+ // Process
13
+ // =============================================================================
14
+
15
+ /**
16
+ * Process entity
17
+ *
18
+ * Represents a business process with defined steps.
19
+ */
20
+ export const Process: Noun = {
21
+ singular: 'process',
22
+ plural: 'processes',
23
+ description: 'A business process with defined steps',
24
+
25
+ properties: {
26
+ // Identity
27
+ name: {
28
+ type: 'string',
29
+ description: 'Process name',
30
+ },
31
+ slug: {
32
+ type: 'string',
33
+ optional: true,
34
+ description: 'URL-friendly identifier',
35
+ },
36
+ description: {
37
+ type: 'string',
38
+ optional: true,
39
+ description: 'Process description',
40
+ },
41
+
42
+ // Classification
43
+ type: {
44
+ type: 'string',
45
+ optional: true,
46
+ description: 'Process type',
47
+ examples: ['core', 'support', 'management'],
48
+ },
49
+ category: {
50
+ type: 'string',
51
+ optional: true,
52
+ description: 'Process category',
53
+ examples: ['sales', 'marketing', 'operations', 'finance', 'hr', 'engineering', 'support'],
54
+ },
55
+
56
+ // Flow
57
+ triggerType: {
58
+ type: 'string',
59
+ optional: true,
60
+ description: 'How process is triggered',
61
+ examples: ['manual', 'event', 'schedule', 'condition'],
62
+ },
63
+ triggerDescription: {
64
+ type: 'string',
65
+ optional: true,
66
+ description: 'Trigger description',
67
+ },
68
+
69
+ // IO
70
+ inputs: {
71
+ type: 'string',
72
+ array: true,
73
+ optional: true,
74
+ description: 'Required inputs',
75
+ },
76
+ outputs: {
77
+ type: 'string',
78
+ array: true,
79
+ optional: true,
80
+ description: 'Expected outputs',
81
+ },
82
+
83
+ // Metrics
84
+ averageDuration: {
85
+ type: 'string',
86
+ optional: true,
87
+ description: 'Average completion time',
88
+ },
89
+ sla: {
90
+ type: 'string',
91
+ optional: true,
92
+ description: 'SLA target',
93
+ },
94
+
95
+ // Automation
96
+ automationLevel: {
97
+ type: 'string',
98
+ optional: true,
99
+ description: 'Automation level',
100
+ examples: ['manual', 'semi-automated', 'automated', 'autonomous'],
101
+ },
102
+ automationPercentage: {
103
+ type: 'number',
104
+ optional: true,
105
+ description: 'Percentage automated (0-100)',
106
+ },
107
+
108
+ // Versioning
109
+ version: {
110
+ type: 'string',
111
+ optional: true,
112
+ description: 'Process version',
113
+ },
114
+
115
+ // Status
116
+ status: {
117
+ type: 'string',
118
+ description: 'Process status',
119
+ examples: ['draft', 'active', 'deprecated', 'archived'],
120
+ },
121
+ },
122
+
123
+ relationships: {
124
+ owner: {
125
+ type: 'Worker',
126
+ required: false,
127
+ description: 'Process owner',
128
+ },
129
+ department: {
130
+ type: 'Department',
131
+ required: false,
132
+ description: 'Owning department',
133
+ },
134
+ steps: {
135
+ type: 'ProcessStep[]',
136
+ description: 'Process steps',
137
+ },
138
+ workflows: {
139
+ type: 'Workflow[]',
140
+ description: 'Implementing workflows',
141
+ },
142
+ metrics: {
143
+ type: 'KPI[]',
144
+ description: 'Process metrics',
145
+ },
146
+ },
147
+
148
+ actions: [
149
+ 'create',
150
+ 'update',
151
+ 'publish',
152
+ 'addStep',
153
+ 'removeStep',
154
+ 'reorderSteps',
155
+ 'automate',
156
+ 'deprecate',
157
+ 'archive',
158
+ ],
159
+
160
+ events: [
161
+ 'created',
162
+ 'updated',
163
+ 'published',
164
+ 'stepAdded',
165
+ 'stepRemoved',
166
+ 'stepsReordered',
167
+ 'automated',
168
+ 'deprecated',
169
+ 'archived',
170
+ ],
171
+ }
172
+
173
+ // =============================================================================
174
+ // ProcessStep
175
+ // =============================================================================
176
+
177
+ /**
178
+ * ProcessStep entity
179
+ *
180
+ * Represents a step within a business process.
181
+ */
182
+ export const ProcessStep: Noun = {
183
+ singular: 'process-step',
184
+ plural: 'process-steps',
185
+ description: 'A step within a business process',
186
+
187
+ properties: {
188
+ // Identity
189
+ name: {
190
+ type: 'string',
191
+ description: 'Step name',
192
+ },
193
+ description: {
194
+ type: 'string',
195
+ optional: true,
196
+ description: 'Step description',
197
+ },
198
+
199
+ // Order
200
+ order: {
201
+ type: 'number',
202
+ description: 'Step order',
203
+ },
204
+
205
+ // Execution
206
+ type: {
207
+ type: 'string',
208
+ optional: true,
209
+ description: 'Step type',
210
+ examples: ['task', 'decision', 'approval', 'notification', 'wait', 'parallel', 'subprocess'],
211
+ },
212
+ automationLevel: {
213
+ type: 'string',
214
+ optional: true,
215
+ description: 'Automation level',
216
+ examples: ['manual', 'semi-automated', 'automated'],
217
+ },
218
+
219
+ // Assignment
220
+ responsible: {
221
+ type: 'string',
222
+ optional: true,
223
+ description: 'Responsible role or person',
224
+ },
225
+ accountable: {
226
+ type: 'string',
227
+ optional: true,
228
+ description: 'Accountable role or person',
229
+ },
230
+
231
+ // Time
232
+ estimatedDuration: {
233
+ type: 'string',
234
+ optional: true,
235
+ description: 'Estimated duration',
236
+ },
237
+ sla: {
238
+ type: 'string',
239
+ optional: true,
240
+ description: 'SLA for this step',
241
+ },
242
+
243
+ // IO
244
+ inputs: {
245
+ type: 'string',
246
+ array: true,
247
+ optional: true,
248
+ description: 'Required inputs',
249
+ },
250
+ outputs: {
251
+ type: 'string',
252
+ array: true,
253
+ optional: true,
254
+ description: 'Expected outputs',
255
+ },
256
+
257
+ // Instructions
258
+ instructions: {
259
+ type: 'markdown',
260
+ optional: true,
261
+ description: 'Step instructions',
262
+ },
263
+
264
+ // Conditions
265
+ condition: {
266
+ type: 'string',
267
+ optional: true,
268
+ description: 'Condition for step execution',
269
+ },
270
+ },
271
+
272
+ relationships: {
273
+ process: {
274
+ type: 'Process',
275
+ description: 'Parent process',
276
+ },
277
+ nextStep: {
278
+ type: 'ProcessStep',
279
+ required: false,
280
+ description: 'Next step',
281
+ },
282
+ alternatives: {
283
+ type: 'ProcessStep[]',
284
+ description: 'Alternative next steps (for decisions)',
285
+ },
286
+ },
287
+
288
+ actions: [
289
+ 'create',
290
+ 'update',
291
+ 'move',
292
+ 'duplicate',
293
+ 'delete',
294
+ ],
295
+
296
+ events: [
297
+ 'created',
298
+ 'updated',
299
+ 'moved',
300
+ 'duplicated',
301
+ 'deleted',
302
+ ],
303
+ }
304
+
305
+ // =============================================================================
306
+ // Workflow
307
+ // =============================================================================
308
+
309
+ /**
310
+ * Workflow entity
311
+ *
312
+ * Represents an automated workflow.
313
+ */
314
+ export const Workflow: Noun = {
315
+ singular: 'workflow',
316
+ plural: 'workflows',
317
+ description: 'An automated workflow',
318
+
319
+ properties: {
320
+ // Identity
321
+ name: {
322
+ type: 'string',
323
+ description: 'Workflow name',
324
+ },
325
+ slug: {
326
+ type: 'string',
327
+ optional: true,
328
+ description: 'URL-friendly identifier',
329
+ },
330
+ description: {
331
+ type: 'string',
332
+ optional: true,
333
+ description: 'Workflow description',
334
+ },
335
+
336
+ // Trigger
337
+ triggerType: {
338
+ type: 'string',
339
+ description: 'Trigger type',
340
+ examples: ['event', 'schedule', 'webhook', 'manual', 'api'],
341
+ },
342
+ triggerEvent: {
343
+ type: 'string',
344
+ optional: true,
345
+ description: 'Trigger event name',
346
+ },
347
+ triggerSchedule: {
348
+ type: 'string',
349
+ optional: true,
350
+ description: 'Cron schedule',
351
+ },
352
+ triggerWebhook: {
353
+ type: 'url',
354
+ optional: true,
355
+ description: 'Webhook URL',
356
+ },
357
+ triggerCondition: {
358
+ type: 'string',
359
+ optional: true,
360
+ description: 'Trigger condition',
361
+ },
362
+
363
+ // Execution
364
+ timeout: {
365
+ type: 'number',
366
+ optional: true,
367
+ description: 'Timeout in seconds',
368
+ },
369
+ retryPolicy: {
370
+ type: 'json',
371
+ optional: true,
372
+ description: 'Retry policy',
373
+ },
374
+ concurrency: {
375
+ type: 'number',
376
+ optional: true,
377
+ description: 'Max concurrent executions',
378
+ },
379
+
380
+ // Stats
381
+ runCount: {
382
+ type: 'number',
383
+ optional: true,
384
+ description: 'Total run count',
385
+ },
386
+ successCount: {
387
+ type: 'number',
388
+ optional: true,
389
+ description: 'Successful runs',
390
+ },
391
+ failureCount: {
392
+ type: 'number',
393
+ optional: true,
394
+ description: 'Failed runs',
395
+ },
396
+ lastRunAt: {
397
+ type: 'datetime',
398
+ optional: true,
399
+ description: 'Last run time',
400
+ },
401
+ lastRunStatus: {
402
+ type: 'string',
403
+ optional: true,
404
+ description: 'Last run status',
405
+ },
406
+
407
+ // Status
408
+ status: {
409
+ type: 'string',
410
+ description: 'Workflow status',
411
+ examples: ['draft', 'active', 'paused', 'error', 'archived'],
412
+ },
413
+ enabled: {
414
+ type: 'boolean',
415
+ optional: true,
416
+ description: 'Is enabled',
417
+ },
418
+ },
419
+
420
+ relationships: {
421
+ owner: {
422
+ type: 'Worker',
423
+ required: false,
424
+ description: 'Workflow owner',
425
+ },
426
+ team: {
427
+ type: 'Team',
428
+ required: false,
429
+ description: 'Owning team',
430
+ },
431
+ process: {
432
+ type: 'Process',
433
+ required: false,
434
+ description: 'Parent process',
435
+ },
436
+ actions: {
437
+ type: 'WorkflowAction[]',
438
+ description: 'Workflow actions',
439
+ },
440
+ runs: {
441
+ type: 'WorkflowRun[]',
442
+ description: 'Execution history',
443
+ },
444
+ },
445
+
446
+ actions: [
447
+ 'create',
448
+ 'update',
449
+ 'enable',
450
+ 'disable',
451
+ 'trigger',
452
+ 'test',
453
+ 'addAction',
454
+ 'removeAction',
455
+ 'archive',
456
+ ],
457
+
458
+ events: [
459
+ 'created',
460
+ 'updated',
461
+ 'enabled',
462
+ 'disabled',
463
+ 'triggered',
464
+ 'completed',
465
+ 'failed',
466
+ 'archived',
467
+ ],
468
+ }
469
+
470
+ // =============================================================================
471
+ // WorkflowAction
472
+ // =============================================================================
473
+
474
+ /**
475
+ * WorkflowAction entity
476
+ *
477
+ * Represents an action step within a workflow.
478
+ */
479
+ export const WorkflowAction: Noun = {
480
+ singular: 'workflow-action',
481
+ plural: 'workflow-actions',
482
+ description: 'An action step within a workflow',
483
+
484
+ properties: {
485
+ // Identity
486
+ name: {
487
+ type: 'string',
488
+ optional: true,
489
+ description: 'Action name',
490
+ },
491
+
492
+ // Order
493
+ order: {
494
+ type: 'number',
495
+ description: 'Action order',
496
+ },
497
+
498
+ // Type
499
+ type: {
500
+ type: 'string',
501
+ description: 'Action type',
502
+ examples: ['http', 'email', 'slack', 'database', 'transform', 'condition', 'loop', 'delay', 'approval', 'ai'],
503
+ },
504
+ operation: {
505
+ type: 'string',
506
+ optional: true,
507
+ description: 'Operation to perform',
508
+ },
509
+
510
+ // Configuration
511
+ config: {
512
+ type: 'json',
513
+ optional: true,
514
+ description: 'Action configuration',
515
+ },
516
+ inputs: {
517
+ type: 'json',
518
+ optional: true,
519
+ description: 'Input mappings',
520
+ },
521
+
522
+ // Conditions
523
+ condition: {
524
+ type: 'string',
525
+ optional: true,
526
+ description: 'Execution condition',
527
+ },
528
+
529
+ // Error handling
530
+ continueOnError: {
531
+ type: 'boolean',
532
+ optional: true,
533
+ description: 'Continue on error',
534
+ },
535
+ retryOnFailure: {
536
+ type: 'boolean',
537
+ optional: true,
538
+ description: 'Retry on failure',
539
+ },
540
+ maxRetries: {
541
+ type: 'number',
542
+ optional: true,
543
+ description: 'Max retry attempts',
544
+ },
545
+ },
546
+
547
+ relationships: {
548
+ workflow: {
549
+ type: 'Workflow',
550
+ description: 'Parent workflow',
551
+ },
552
+ nextAction: {
553
+ type: 'WorkflowAction',
554
+ required: false,
555
+ description: 'Next action',
556
+ },
557
+ },
558
+
559
+ actions: [
560
+ 'create',
561
+ 'update',
562
+ 'move',
563
+ 'duplicate',
564
+ 'delete',
565
+ 'test',
566
+ ],
567
+
568
+ events: [
569
+ 'created',
570
+ 'updated',
571
+ 'moved',
572
+ 'duplicated',
573
+ 'deleted',
574
+ 'executed',
575
+ 'failed',
576
+ ],
577
+ }
578
+
579
+ // =============================================================================
580
+ // WorkflowRun
581
+ // =============================================================================
582
+
583
+ /**
584
+ * WorkflowRun entity
585
+ *
586
+ * Represents a workflow execution instance.
587
+ */
588
+ export const WorkflowRun: Noun = {
589
+ singular: 'workflow-run',
590
+ plural: 'workflow-runs',
591
+ description: 'A workflow execution instance',
592
+
593
+ properties: {
594
+ // Status
595
+ status: {
596
+ type: 'string',
597
+ description: 'Run status',
598
+ examples: ['pending', 'running', 'completed', 'failed', 'cancelled', 'waiting'],
599
+ },
600
+
601
+ // Timing
602
+ startedAt: {
603
+ type: 'datetime',
604
+ optional: true,
605
+ description: 'Start time',
606
+ },
607
+ completedAt: {
608
+ type: 'datetime',
609
+ optional: true,
610
+ description: 'Completion time',
611
+ },
612
+ duration: {
613
+ type: 'number',
614
+ optional: true,
615
+ description: 'Duration in milliseconds',
616
+ },
617
+
618
+ // Progress
619
+ currentStep: {
620
+ type: 'number',
621
+ optional: true,
622
+ description: 'Current step number',
623
+ },
624
+ totalSteps: {
625
+ type: 'number',
626
+ optional: true,
627
+ description: 'Total steps',
628
+ },
629
+
630
+ // IO
631
+ triggerData: {
632
+ type: 'json',
633
+ optional: true,
634
+ description: 'Trigger input data',
635
+ },
636
+ output: {
637
+ type: 'json',
638
+ optional: true,
639
+ description: 'Final output',
640
+ },
641
+
642
+ // Error
643
+ error: {
644
+ type: 'string',
645
+ optional: true,
646
+ description: 'Error message',
647
+ },
648
+ errorStep: {
649
+ type: 'number',
650
+ optional: true,
651
+ description: 'Step that failed',
652
+ },
653
+
654
+ // Retry
655
+ attempt: {
656
+ type: 'number',
657
+ optional: true,
658
+ description: 'Attempt number',
659
+ },
660
+ },
661
+
662
+ relationships: {
663
+ workflow: {
664
+ type: 'Workflow',
665
+ description: 'Parent workflow',
666
+ },
667
+ triggeredBy: {
668
+ type: 'Worker',
669
+ required: false,
670
+ description: 'Who triggered the run',
671
+ },
672
+ stepResults: {
673
+ type: 'WorkflowStepResult[]',
674
+ description: 'Step execution results',
675
+ },
676
+ },
677
+
678
+ actions: [
679
+ 'start',
680
+ 'pause',
681
+ 'resume',
682
+ 'cancel',
683
+ 'retry',
684
+ ],
685
+
686
+ events: [
687
+ 'started',
688
+ 'paused',
689
+ 'resumed',
690
+ 'completed',
691
+ 'failed',
692
+ 'cancelled',
693
+ 'retried',
694
+ ],
695
+ }
696
+
697
+ // =============================================================================
698
+ // Policy
699
+ // =============================================================================
700
+
701
+ /**
702
+ * Policy entity
703
+ *
704
+ * Represents a business policy or rule.
705
+ */
706
+ export const Policy: Noun = {
707
+ singular: 'policy',
708
+ plural: 'policies',
709
+ description: 'A business policy or rule',
710
+
711
+ properties: {
712
+ // Identity
713
+ name: {
714
+ type: 'string',
715
+ description: 'Policy name',
716
+ },
717
+ code: {
718
+ type: 'string',
719
+ optional: true,
720
+ description: 'Policy code',
721
+ },
722
+ description: {
723
+ type: 'string',
724
+ optional: true,
725
+ description: 'Policy description',
726
+ },
727
+
728
+ // Classification
729
+ type: {
730
+ type: 'string',
731
+ optional: true,
732
+ description: 'Policy type',
733
+ examples: ['compliance', 'operational', 'security', 'hr', 'financial', 'data'],
734
+ },
735
+ category: {
736
+ type: 'string',
737
+ optional: true,
738
+ description: 'Policy category',
739
+ },
740
+
741
+ // Content
742
+ content: {
743
+ type: 'markdown',
744
+ optional: true,
745
+ description: 'Policy content',
746
+ },
747
+ rules: {
748
+ type: 'string',
749
+ array: true,
750
+ optional: true,
751
+ description: 'Policy rules',
752
+ },
753
+
754
+ // Enforcement
755
+ enforcementLevel: {
756
+ type: 'string',
757
+ optional: true,
758
+ description: 'Enforcement level',
759
+ examples: ['mandatory', 'recommended', 'optional'],
760
+ },
761
+ violations: {
762
+ type: 'string',
763
+ array: true,
764
+ optional: true,
765
+ description: 'Violation consequences',
766
+ },
767
+
768
+ // Dates
769
+ effectiveDate: {
770
+ type: 'date',
771
+ optional: true,
772
+ description: 'Effective date',
773
+ },
774
+ reviewDate: {
775
+ type: 'date',
776
+ optional: true,
777
+ description: 'Next review date',
778
+ },
779
+ expirationDate: {
780
+ type: 'date',
781
+ optional: true,
782
+ description: 'Expiration date',
783
+ },
784
+
785
+ // Versioning
786
+ version: {
787
+ type: 'string',
788
+ optional: true,
789
+ description: 'Policy version',
790
+ },
791
+
792
+ // Status
793
+ status: {
794
+ type: 'string',
795
+ description: 'Policy status',
796
+ examples: ['draft', 'review', 'active', 'superseded', 'archived'],
797
+ },
798
+ },
799
+
800
+ relationships: {
801
+ owner: {
802
+ type: 'Worker',
803
+ required: false,
804
+ description: 'Policy owner',
805
+ },
806
+ department: {
807
+ type: 'Department',
808
+ required: false,
809
+ description: 'Owning department',
810
+ },
811
+ supersedes: {
812
+ type: 'Policy',
813
+ required: false,
814
+ description: 'Previous version superseded',
815
+ },
816
+ supersededBy: {
817
+ type: 'Policy',
818
+ required: false,
819
+ description: 'New version that supersedes this',
820
+ },
821
+ },
822
+
823
+ actions: [
824
+ 'create',
825
+ 'update',
826
+ 'submit',
827
+ 'approve',
828
+ 'publish',
829
+ 'supersede',
830
+ 'archive',
831
+ ],
832
+
833
+ events: [
834
+ 'created',
835
+ 'updated',
836
+ 'submitted',
837
+ 'approved',
838
+ 'published',
839
+ 'superseded',
840
+ 'archived',
841
+ ],
842
+ }
843
+
844
+ // =============================================================================
845
+ // Exports
846
+ // =============================================================================
847
+
848
+ export const OperationsEntities = {
849
+ Process,
850
+ ProcessStep,
851
+ Workflow,
852
+ WorkflowAction,
853
+ WorkflowRun,
854
+ Policy,
855
+ }
856
+
857
+ export const OperationsCategories = {
858
+ processes: ['Process', 'ProcessStep'],
859
+ automation: ['Workflow', 'WorkflowAction', 'WorkflowRun'],
860
+ governance: ['Policy'],
861
+ } as const