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,871 @@
1
+ /**
2
+ * Goal Entity Types (Nouns)
3
+ *
4
+ * Goal tracking entities: Goal, OKR, KPI, Metric.
5
+ *
6
+ * @packageDocumentation
7
+ */
8
+
9
+ import type { Noun } from 'ai-database'
10
+
11
+ // =============================================================================
12
+ // Goal
13
+ // =============================================================================
14
+
15
+ /**
16
+ * Goal entity
17
+ *
18
+ * Represents a strategic or operational goal.
19
+ */
20
+ export const Goal: Noun = {
21
+ singular: 'goal',
22
+ plural: 'goals',
23
+ description: 'A strategic or operational goal',
24
+
25
+ properties: {
26
+ // Identity
27
+ name: {
28
+ type: 'string',
29
+ description: 'Goal name/title',
30
+ },
31
+ description: {
32
+ type: 'string',
33
+ optional: true,
34
+ description: 'Goal description',
35
+ },
36
+
37
+ // Classification
38
+ type: {
39
+ type: 'string',
40
+ optional: true,
41
+ description: 'Goal type',
42
+ examples: ['strategic', 'operational', 'tactical'],
43
+ },
44
+ category: {
45
+ type: 'string',
46
+ optional: true,
47
+ description: 'Goal category',
48
+ examples: ['growth', 'revenue', 'customer', 'product', 'operations', 'people', 'financial'],
49
+ },
50
+ priority: {
51
+ type: 'string',
52
+ optional: true,
53
+ description: 'Priority level',
54
+ examples: ['critical', 'high', 'medium', 'low'],
55
+ },
56
+
57
+ // Timeline
58
+ startDate: {
59
+ type: 'date',
60
+ optional: true,
61
+ description: 'Start date',
62
+ },
63
+ targetDate: {
64
+ type: 'date',
65
+ optional: true,
66
+ description: 'Target completion date',
67
+ },
68
+ completedAt: {
69
+ type: 'datetime',
70
+ optional: true,
71
+ description: 'Actual completion time',
72
+ },
73
+
74
+ // Progress
75
+ progress: {
76
+ type: 'number',
77
+ optional: true,
78
+ description: 'Progress percentage (0-100)',
79
+ },
80
+ confidence: {
81
+ type: 'number',
82
+ optional: true,
83
+ description: 'Confidence level (0-100)',
84
+ },
85
+
86
+ // Success Criteria
87
+ successMetrics: {
88
+ type: 'string',
89
+ array: true,
90
+ optional: true,
91
+ description: 'Success metrics',
92
+ },
93
+ targetValue: {
94
+ type: 'number',
95
+ optional: true,
96
+ description: 'Target value for primary metric',
97
+ },
98
+ currentValue: {
99
+ type: 'number',
100
+ optional: true,
101
+ description: 'Current value for primary metric',
102
+ },
103
+ unit: {
104
+ type: 'string',
105
+ optional: true,
106
+ description: 'Metric unit',
107
+ },
108
+
109
+ // Status
110
+ status: {
111
+ type: 'string',
112
+ description: 'Goal status',
113
+ examples: ['draft', 'active', 'on-track', 'at-risk', 'behind', 'completed', 'cancelled'],
114
+ },
115
+ },
116
+
117
+ relationships: {
118
+ owner: {
119
+ type: 'Worker',
120
+ required: false,
121
+ description: 'Goal owner',
122
+ },
123
+ team: {
124
+ type: 'Team',
125
+ required: false,
126
+ description: 'Responsible team',
127
+ },
128
+ department: {
129
+ type: 'Department',
130
+ required: false,
131
+ description: 'Responsible department',
132
+ },
133
+ parent: {
134
+ type: 'Goal',
135
+ required: false,
136
+ description: 'Parent goal',
137
+ },
138
+ children: {
139
+ type: 'Goal[]',
140
+ description: 'Sub-goals',
141
+ },
142
+ dependencies: {
143
+ type: 'Goal[]',
144
+ description: 'Goals this depends on',
145
+ },
146
+ kpis: {
147
+ type: 'KPI[]',
148
+ description: 'Related KPIs',
149
+ },
150
+ },
151
+
152
+ actions: [
153
+ 'create',
154
+ 'update',
155
+ 'activate',
156
+ 'updateProgress',
157
+ 'markAtRisk',
158
+ 'complete',
159
+ 'cancel',
160
+ 'extend',
161
+ 'archive',
162
+ ],
163
+
164
+ events: [
165
+ 'created',
166
+ 'updated',
167
+ 'activated',
168
+ 'progressUpdated',
169
+ 'markedAtRisk',
170
+ 'completed',
171
+ 'cancelled',
172
+ 'extended',
173
+ 'overdue',
174
+ 'archived',
175
+ ],
176
+ }
177
+
178
+ // =============================================================================
179
+ // OKR (Objective and Key Results)
180
+ // =============================================================================
181
+
182
+ /**
183
+ * OKR entity
184
+ *
185
+ * Represents an objective with measurable key results.
186
+ */
187
+ export const OKR: Noun = {
188
+ singular: 'okr',
189
+ plural: 'okrs',
190
+ description: 'An objective with measurable key results',
191
+
192
+ properties: {
193
+ // Objective
194
+ objective: {
195
+ type: 'string',
196
+ description: 'Objective statement',
197
+ },
198
+ description: {
199
+ type: 'string',
200
+ optional: true,
201
+ description: 'Objective description',
202
+ },
203
+
204
+ // Classification
205
+ type: {
206
+ type: 'string',
207
+ optional: true,
208
+ description: 'OKR type',
209
+ examples: ['company', 'department', 'team', 'individual'],
210
+ },
211
+ category: {
212
+ type: 'string',
213
+ optional: true,
214
+ description: 'OKR category',
215
+ examples: ['growth', 'product', 'customer', 'operations', 'people'],
216
+ },
217
+
218
+ // Period
219
+ period: {
220
+ type: 'string',
221
+ optional: true,
222
+ description: 'OKR period (e.g., "Q1 2025", "H1 2025")',
223
+ },
224
+ startDate: {
225
+ type: 'date',
226
+ optional: true,
227
+ description: 'Period start date',
228
+ },
229
+ endDate: {
230
+ type: 'date',
231
+ optional: true,
232
+ description: 'Period end date',
233
+ },
234
+
235
+ // Progress
236
+ progress: {
237
+ type: 'number',
238
+ optional: true,
239
+ description: 'Overall progress (0-100)',
240
+ },
241
+ confidence: {
242
+ type: 'number',
243
+ optional: true,
244
+ description: 'Confidence level (0-1)',
245
+ },
246
+ grade: {
247
+ type: 'number',
248
+ optional: true,
249
+ description: 'Final grade (0-1)',
250
+ },
251
+
252
+ // Key Results count
253
+ keyResultCount: {
254
+ type: 'number',
255
+ optional: true,
256
+ description: 'Number of key results',
257
+ },
258
+ completedKeyResultCount: {
259
+ type: 'number',
260
+ optional: true,
261
+ description: 'Completed key results',
262
+ },
263
+
264
+ // Status
265
+ status: {
266
+ type: 'string',
267
+ description: 'OKR status',
268
+ examples: ['draft', 'active', 'on-track', 'at-risk', 'behind', 'completed', 'cancelled'],
269
+ },
270
+ },
271
+
272
+ relationships: {
273
+ owner: {
274
+ type: 'Worker',
275
+ required: false,
276
+ description: 'OKR owner',
277
+ },
278
+ team: {
279
+ type: 'Team',
280
+ required: false,
281
+ description: 'Responsible team',
282
+ },
283
+ department: {
284
+ type: 'Department',
285
+ required: false,
286
+ description: 'Responsible department',
287
+ },
288
+ parent: {
289
+ type: 'OKR',
290
+ required: false,
291
+ description: 'Parent OKR (alignment)',
292
+ },
293
+ children: {
294
+ type: 'OKR[]',
295
+ description: 'Aligned child OKRs',
296
+ },
297
+ keyResults: {
298
+ type: 'KeyResult[]',
299
+ description: 'Key results',
300
+ },
301
+ },
302
+
303
+ actions: [
304
+ 'create',
305
+ 'update',
306
+ 'activate',
307
+ 'addKeyResult',
308
+ 'removeKeyResult',
309
+ 'updateProgress',
310
+ 'updateConfidence',
311
+ 'grade',
312
+ 'complete',
313
+ 'cancel',
314
+ 'archive',
315
+ ],
316
+
317
+ events: [
318
+ 'created',
319
+ 'updated',
320
+ 'activated',
321
+ 'keyResultAdded',
322
+ 'keyResultRemoved',
323
+ 'progressUpdated',
324
+ 'confidenceUpdated',
325
+ 'graded',
326
+ 'completed',
327
+ 'cancelled',
328
+ 'archived',
329
+ ],
330
+ }
331
+
332
+ // =============================================================================
333
+ // KeyResult
334
+ // =============================================================================
335
+
336
+ /**
337
+ * KeyResult entity
338
+ *
339
+ * Represents a measurable key result within an OKR.
340
+ */
341
+ export const KeyResult: Noun = {
342
+ singular: 'key-result',
343
+ plural: 'key-results',
344
+ description: 'A measurable key result within an OKR',
345
+
346
+ properties: {
347
+ // Description
348
+ description: {
349
+ type: 'string',
350
+ description: 'Key result description',
351
+ },
352
+
353
+ // Metric
354
+ metric: {
355
+ type: 'string',
356
+ description: 'Metric being measured',
357
+ },
358
+ unit: {
359
+ type: 'string',
360
+ optional: true,
361
+ description: 'Unit of measurement',
362
+ },
363
+
364
+ // Values
365
+ startValue: {
366
+ type: 'number',
367
+ optional: true,
368
+ description: 'Starting value',
369
+ },
370
+ targetValue: {
371
+ type: 'number',
372
+ description: 'Target value',
373
+ },
374
+ currentValue: {
375
+ type: 'number',
376
+ optional: true,
377
+ description: 'Current value',
378
+ },
379
+
380
+ // Progress
381
+ progress: {
382
+ type: 'number',
383
+ optional: true,
384
+ description: 'Progress percentage (0-100)',
385
+ },
386
+ confidence: {
387
+ type: 'number',
388
+ optional: true,
389
+ description: 'Confidence level (0-1)',
390
+ },
391
+
392
+ // Type
393
+ direction: {
394
+ type: 'string',
395
+ optional: true,
396
+ description: 'Direction of improvement',
397
+ examples: ['increase', 'decrease', 'maintain'],
398
+ },
399
+ measurementType: {
400
+ type: 'string',
401
+ optional: true,
402
+ description: 'How progress is measured',
403
+ examples: ['percentage', 'absolute', 'binary', 'milestone'],
404
+ },
405
+
406
+ // Status
407
+ status: {
408
+ type: 'string',
409
+ description: 'Key result status',
410
+ examples: ['not-started', 'on-track', 'at-risk', 'behind', 'completed'],
411
+ },
412
+ },
413
+
414
+ relationships: {
415
+ okr: {
416
+ type: 'OKR',
417
+ description: 'Parent OKR',
418
+ },
419
+ owner: {
420
+ type: 'Worker',
421
+ required: false,
422
+ description: 'Key result owner',
423
+ },
424
+ initiatives: {
425
+ type: 'Initiative[]',
426
+ description: 'Supporting initiatives',
427
+ },
428
+ },
429
+
430
+ actions: [
431
+ 'create',
432
+ 'update',
433
+ 'updateValue',
434
+ 'updateConfidence',
435
+ 'complete',
436
+ 'delete',
437
+ ],
438
+
439
+ events: [
440
+ 'created',
441
+ 'updated',
442
+ 'valueUpdated',
443
+ 'confidenceUpdated',
444
+ 'completed',
445
+ 'deleted',
446
+ ],
447
+ }
448
+
449
+ // =============================================================================
450
+ // KPI (Key Performance Indicator)
451
+ // =============================================================================
452
+
453
+ /**
454
+ * KPI entity
455
+ *
456
+ * Represents a key performance indicator.
457
+ */
458
+ export const KPI: Noun = {
459
+ singular: 'kpi',
460
+ plural: 'kpis',
461
+ description: 'A key performance indicator',
462
+
463
+ properties: {
464
+ // Identity
465
+ name: {
466
+ type: 'string',
467
+ description: 'KPI name',
468
+ },
469
+ description: {
470
+ type: 'string',
471
+ optional: true,
472
+ description: 'KPI description',
473
+ },
474
+ code: {
475
+ type: 'string',
476
+ optional: true,
477
+ description: 'KPI code (e.g., "MRR", "NPS")',
478
+ },
479
+
480
+ // Classification
481
+ category: {
482
+ type: 'string',
483
+ optional: true,
484
+ description: 'KPI category',
485
+ examples: ['financial', 'customer', 'operations', 'people', 'product', 'growth'],
486
+ },
487
+ type: {
488
+ type: 'string',
489
+ optional: true,
490
+ description: 'KPI type',
491
+ examples: ['leading', 'lagging'],
492
+ },
493
+
494
+ // Measurement
495
+ unit: {
496
+ type: 'string',
497
+ optional: true,
498
+ description: 'Unit of measurement',
499
+ },
500
+ format: {
501
+ type: 'string',
502
+ optional: true,
503
+ description: 'Display format',
504
+ examples: ['number', 'currency', 'percentage', 'duration'],
505
+ },
506
+ precision: {
507
+ type: 'number',
508
+ optional: true,
509
+ description: 'Decimal precision',
510
+ },
511
+
512
+ // Values
513
+ targetValue: {
514
+ type: 'number',
515
+ optional: true,
516
+ description: 'Target value',
517
+ },
518
+ currentValue: {
519
+ type: 'number',
520
+ optional: true,
521
+ description: 'Current value',
522
+ },
523
+ previousValue: {
524
+ type: 'number',
525
+ optional: true,
526
+ description: 'Previous period value',
527
+ },
528
+ baselineValue: {
529
+ type: 'number',
530
+ optional: true,
531
+ description: 'Baseline value',
532
+ },
533
+
534
+ // Thresholds
535
+ warningThreshold: {
536
+ type: 'number',
537
+ optional: true,
538
+ description: 'Warning threshold',
539
+ },
540
+ criticalThreshold: {
541
+ type: 'number',
542
+ optional: true,
543
+ description: 'Critical threshold',
544
+ },
545
+ direction: {
546
+ type: 'string',
547
+ optional: true,
548
+ description: 'Good direction',
549
+ examples: ['higher-is-better', 'lower-is-better', 'target'],
550
+ },
551
+
552
+ // Tracking
553
+ frequency: {
554
+ type: 'string',
555
+ optional: true,
556
+ description: 'Measurement frequency',
557
+ examples: ['realtime', 'hourly', 'daily', 'weekly', 'monthly', 'quarterly'],
558
+ },
559
+ lastMeasuredAt: {
560
+ type: 'datetime',
561
+ optional: true,
562
+ description: 'Last measurement time',
563
+ },
564
+
565
+ // Calculation
566
+ formula: {
567
+ type: 'string',
568
+ optional: true,
569
+ description: 'Calculation formula',
570
+ },
571
+ dataSource: {
572
+ type: 'string',
573
+ optional: true,
574
+ description: 'Data source',
575
+ },
576
+
577
+ // Status
578
+ status: {
579
+ type: 'string',
580
+ optional: true,
581
+ description: 'KPI status',
582
+ examples: ['on-target', 'warning', 'critical', 'no-data'],
583
+ },
584
+ },
585
+
586
+ relationships: {
587
+ owner: {
588
+ type: 'Worker',
589
+ required: false,
590
+ description: 'KPI owner',
591
+ },
592
+ department: {
593
+ type: 'Department',
594
+ required: false,
595
+ description: 'Responsible department',
596
+ },
597
+ goals: {
598
+ type: 'Goal[]',
599
+ description: 'Related goals',
600
+ },
601
+ dashboard: {
602
+ type: 'Dashboard',
603
+ required: false,
604
+ description: 'Display dashboard',
605
+ },
606
+ history: {
607
+ type: 'KPIValue[]',
608
+ description: 'Historical values',
609
+ },
610
+ },
611
+
612
+ actions: [
613
+ 'create',
614
+ 'update',
615
+ 'measure',
616
+ 'setTarget',
617
+ 'setThresholds',
618
+ 'alert',
619
+ 'archive',
620
+ ],
621
+
622
+ events: [
623
+ 'created',
624
+ 'updated',
625
+ 'measured',
626
+ 'targetSet',
627
+ 'thresholdBreached',
628
+ 'targetMet',
629
+ 'alerted',
630
+ 'archived',
631
+ ],
632
+ }
633
+
634
+ // =============================================================================
635
+ // Metric
636
+ // =============================================================================
637
+
638
+ /**
639
+ * Metric entity
640
+ *
641
+ * Represents a general business metric or measurement.
642
+ */
643
+ export const Metric: Noun = {
644
+ singular: 'metric',
645
+ plural: 'metrics',
646
+ description: 'A general business metric or measurement',
647
+
648
+ properties: {
649
+ // Identity
650
+ name: {
651
+ type: 'string',
652
+ description: 'Metric name',
653
+ },
654
+ description: {
655
+ type: 'string',
656
+ optional: true,
657
+ description: 'Metric description',
658
+ },
659
+
660
+ // Classification
661
+ category: {
662
+ type: 'string',
663
+ optional: true,
664
+ description: 'Metric category',
665
+ },
666
+ tags: {
667
+ type: 'string',
668
+ array: true,
669
+ optional: true,
670
+ description: 'Tags',
671
+ },
672
+
673
+ // Value
674
+ value: {
675
+ type: 'number',
676
+ description: 'Current value',
677
+ },
678
+ unit: {
679
+ type: 'string',
680
+ optional: true,
681
+ description: 'Unit of measurement',
682
+ },
683
+
684
+ // Timestamp
685
+ timestamp: {
686
+ type: 'datetime',
687
+ description: 'Measurement timestamp',
688
+ },
689
+ period: {
690
+ type: 'string',
691
+ optional: true,
692
+ description: 'Measurement period',
693
+ },
694
+
695
+ // Source
696
+ source: {
697
+ type: 'string',
698
+ optional: true,
699
+ description: 'Data source',
700
+ },
701
+ },
702
+
703
+ relationships: {
704
+ kpi: {
705
+ type: 'KPI',
706
+ required: false,
707
+ description: 'Related KPI',
708
+ },
709
+ },
710
+
711
+ actions: [
712
+ 'record',
713
+ 'update',
714
+ 'delete',
715
+ ],
716
+
717
+ events: [
718
+ 'recorded',
719
+ 'updated',
720
+ 'deleted',
721
+ ],
722
+ }
723
+
724
+ // =============================================================================
725
+ // Initiative
726
+ // =============================================================================
727
+
728
+ /**
729
+ * Initiative entity
730
+ *
731
+ * Represents a strategic initiative or project supporting goals.
732
+ */
733
+ export const Initiative: Noun = {
734
+ singular: 'initiative',
735
+ plural: 'initiatives',
736
+ description: 'A strategic initiative or project supporting goals',
737
+
738
+ properties: {
739
+ // Identity
740
+ name: {
741
+ type: 'string',
742
+ description: 'Initiative name',
743
+ },
744
+ description: {
745
+ type: 'string',
746
+ optional: true,
747
+ description: 'Initiative description',
748
+ },
749
+
750
+ // Classification
751
+ type: {
752
+ type: 'string',
753
+ optional: true,
754
+ description: 'Initiative type',
755
+ examples: ['project', 'program', 'experiment', 'improvement'],
756
+ },
757
+ priority: {
758
+ type: 'string',
759
+ optional: true,
760
+ description: 'Priority level',
761
+ examples: ['critical', 'high', 'medium', 'low'],
762
+ },
763
+
764
+ // Timeline
765
+ startDate: {
766
+ type: 'date',
767
+ optional: true,
768
+ description: 'Start date',
769
+ },
770
+ endDate: {
771
+ type: 'date',
772
+ optional: true,
773
+ description: 'End date',
774
+ },
775
+
776
+ // Progress
777
+ progress: {
778
+ type: 'number',
779
+ optional: true,
780
+ description: 'Progress percentage (0-100)',
781
+ },
782
+
783
+ // Resources
784
+ budget: {
785
+ type: 'number',
786
+ optional: true,
787
+ description: 'Allocated budget',
788
+ },
789
+ budgetCurrency: {
790
+ type: 'string',
791
+ optional: true,
792
+ description: 'Budget currency',
793
+ },
794
+ spent: {
795
+ type: 'number',
796
+ optional: true,
797
+ description: 'Amount spent',
798
+ },
799
+
800
+ // Status
801
+ status: {
802
+ type: 'string',
803
+ description: 'Initiative status',
804
+ examples: ['proposed', 'approved', 'in-progress', 'on-hold', 'completed', 'cancelled'],
805
+ },
806
+ },
807
+
808
+ relationships: {
809
+ owner: {
810
+ type: 'Worker',
811
+ required: false,
812
+ description: 'Initiative owner',
813
+ },
814
+ team: {
815
+ type: 'Team',
816
+ required: false,
817
+ description: 'Responsible team',
818
+ },
819
+ goals: {
820
+ type: 'Goal[]',
821
+ description: 'Supported goals',
822
+ },
823
+ keyResults: {
824
+ type: 'KeyResult[]',
825
+ description: 'Supported key results',
826
+ },
827
+ },
828
+
829
+ actions: [
830
+ 'create',
831
+ 'update',
832
+ 'approve',
833
+ 'start',
834
+ 'pause',
835
+ 'resume',
836
+ 'complete',
837
+ 'cancel',
838
+ 'archive',
839
+ ],
840
+
841
+ events: [
842
+ 'created',
843
+ 'updated',
844
+ 'approved',
845
+ 'started',
846
+ 'paused',
847
+ 'resumed',
848
+ 'completed',
849
+ 'cancelled',
850
+ 'archived',
851
+ ],
852
+ }
853
+
854
+ // =============================================================================
855
+ // Exports
856
+ // =============================================================================
857
+
858
+ export const GoalEntities = {
859
+ Goal,
860
+ OKR,
861
+ KeyResult,
862
+ KPI,
863
+ Metric,
864
+ Initiative,
865
+ }
866
+
867
+ export const GoalCategories = {
868
+ objectives: ['Goal', 'OKR', 'KeyResult'],
869
+ measurement: ['KPI', 'Metric'],
870
+ execution: ['Initiative'],
871
+ } as const