business-as-code 0.2.1 → 2.0.2

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 +17 -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,1248 @@
1
+ /**
2
+ * Sales Entity Types (Nouns)
3
+ *
4
+ * Sales and revenue: Deal, Pipeline, Stage, Contract, Subscription, Order, Quote.
5
+ *
6
+ * @packageDocumentation
7
+ */
8
+ // =============================================================================
9
+ // Deal (Opportunity)
10
+ // =============================================================================
11
+ /**
12
+ * Deal entity
13
+ *
14
+ * Represents a sales opportunity/deal.
15
+ */
16
+ export const Deal = {
17
+ singular: 'deal',
18
+ plural: 'deals',
19
+ description: 'A sales opportunity or deal',
20
+ properties: {
21
+ // Identity
22
+ name: {
23
+ type: 'string',
24
+ description: 'Deal name',
25
+ },
26
+ description: {
27
+ type: 'string',
28
+ optional: true,
29
+ description: 'Deal description',
30
+ },
31
+ // Value
32
+ amount: {
33
+ type: 'number',
34
+ optional: true,
35
+ description: 'Deal amount',
36
+ },
37
+ currency: {
38
+ type: 'string',
39
+ optional: true,
40
+ description: 'Currency code',
41
+ },
42
+ recurringAmount: {
43
+ type: 'number',
44
+ optional: true,
45
+ description: 'Recurring amount (MRR/ARR)',
46
+ },
47
+ oneTimeAmount: {
48
+ type: 'number',
49
+ optional: true,
50
+ description: 'One-time amount',
51
+ },
52
+ // Pipeline
53
+ stage: {
54
+ type: 'string',
55
+ description: 'Current stage',
56
+ examples: ['lead', 'qualified', 'discovery', 'demo', 'proposal', 'negotiation', 'closed-won', 'closed-lost'],
57
+ },
58
+ probability: {
59
+ type: 'number',
60
+ optional: true,
61
+ description: 'Win probability (0-100)',
62
+ },
63
+ weightedAmount: {
64
+ type: 'number',
65
+ optional: true,
66
+ description: 'Weighted deal value',
67
+ },
68
+ // Type
69
+ type: {
70
+ type: 'string',
71
+ optional: true,
72
+ description: 'Deal type',
73
+ examples: ['new-business', 'expansion', 'renewal', 'upsell', 'cross-sell'],
74
+ },
75
+ // Timeline
76
+ expectedCloseDate: {
77
+ type: 'date',
78
+ optional: true,
79
+ description: 'Expected close date',
80
+ },
81
+ actualCloseDate: {
82
+ type: 'date',
83
+ optional: true,
84
+ description: 'Actual close date',
85
+ },
86
+ createdAt: {
87
+ type: 'datetime',
88
+ optional: true,
89
+ description: 'Created date',
90
+ },
91
+ lastActivityAt: {
92
+ type: 'datetime',
93
+ optional: true,
94
+ description: 'Last activity date',
95
+ },
96
+ // Source
97
+ source: {
98
+ type: 'string',
99
+ optional: true,
100
+ description: 'Lead source',
101
+ examples: ['inbound', 'outbound', 'referral', 'partner', 'marketing', 'event'],
102
+ },
103
+ campaignId: {
104
+ type: 'string',
105
+ optional: true,
106
+ description: 'Source campaign',
107
+ },
108
+ // Competition
109
+ competitors: {
110
+ type: 'string',
111
+ array: true,
112
+ optional: true,
113
+ description: 'Competitors in deal',
114
+ },
115
+ // Loss reason
116
+ lossReason: {
117
+ type: 'string',
118
+ optional: true,
119
+ description: 'Reason for loss',
120
+ examples: ['price', 'features', 'competitor', 'timing', 'budget', 'no-decision', 'champion-left'],
121
+ },
122
+ lossNotes: {
123
+ type: 'string',
124
+ optional: true,
125
+ description: 'Loss details',
126
+ },
127
+ // Forecast
128
+ forecastCategory: {
129
+ type: 'string',
130
+ optional: true,
131
+ description: 'Forecast category',
132
+ examples: ['pipeline', 'best-case', 'commit', 'closed'],
133
+ },
134
+ // Priority
135
+ priority: {
136
+ type: 'string',
137
+ optional: true,
138
+ description: 'Deal priority',
139
+ examples: ['critical', 'high', 'medium', 'low'],
140
+ },
141
+ // Status
142
+ status: {
143
+ type: 'string',
144
+ description: 'Deal status',
145
+ examples: ['open', 'won', 'lost', 'archived'],
146
+ },
147
+ },
148
+ relationships: {
149
+ customer: {
150
+ type: 'Customer',
151
+ required: false,
152
+ description: 'Customer',
153
+ },
154
+ account: {
155
+ type: 'Account',
156
+ required: false,
157
+ description: 'Account',
158
+ },
159
+ contacts: {
160
+ type: 'Contact[]',
161
+ description: 'Deal contacts',
162
+ },
163
+ owner: {
164
+ type: 'Worker',
165
+ required: false,
166
+ description: 'Deal owner',
167
+ },
168
+ pipeline: {
169
+ type: 'Pipeline',
170
+ required: false,
171
+ description: 'Pipeline',
172
+ },
173
+ products: {
174
+ type: 'Product[]',
175
+ description: 'Products in deal',
176
+ },
177
+ quotes: {
178
+ type: 'Quote[]',
179
+ description: 'Quotes',
180
+ },
181
+ contract: {
182
+ type: 'Contract',
183
+ required: false,
184
+ description: 'Resulting contract',
185
+ },
186
+ interactions: {
187
+ type: 'Interaction[]',
188
+ description: 'Deal activities',
189
+ },
190
+ },
191
+ actions: [
192
+ 'create',
193
+ 'update',
194
+ 'qualify',
195
+ 'advance',
196
+ 'setStage',
197
+ 'assignOwner',
198
+ 'addProduct',
199
+ 'removeProduct',
200
+ 'createQuote',
201
+ 'win',
202
+ 'lose',
203
+ 'reopen',
204
+ 'archive',
205
+ ],
206
+ events: [
207
+ 'created',
208
+ 'updated',
209
+ 'qualified',
210
+ 'stageChanged',
211
+ 'ownerAssigned',
212
+ 'productAdded',
213
+ 'productRemoved',
214
+ 'quoteCreated',
215
+ 'won',
216
+ 'lost',
217
+ 'reopened',
218
+ 'archived',
219
+ ],
220
+ };
221
+ // =============================================================================
222
+ // Pipeline
223
+ // =============================================================================
224
+ /**
225
+ * Pipeline entity
226
+ *
227
+ * Represents a sales pipeline.
228
+ */
229
+ export const Pipeline = {
230
+ singular: 'pipeline',
231
+ plural: 'pipelines',
232
+ description: 'A sales pipeline',
233
+ properties: {
234
+ // Identity
235
+ name: {
236
+ type: 'string',
237
+ description: 'Pipeline name',
238
+ },
239
+ description: {
240
+ type: 'string',
241
+ optional: true,
242
+ description: 'Pipeline description',
243
+ },
244
+ // Type
245
+ type: {
246
+ type: 'string',
247
+ optional: true,
248
+ description: 'Pipeline type',
249
+ examples: ['sales', 'renewal', 'expansion', 'partnership'],
250
+ },
251
+ // Default
252
+ isDefault: {
253
+ type: 'boolean',
254
+ optional: true,
255
+ description: 'Is default pipeline',
256
+ },
257
+ // Metrics
258
+ dealCount: {
259
+ type: 'number',
260
+ optional: true,
261
+ description: 'Number of deals',
262
+ },
263
+ totalValue: {
264
+ type: 'number',
265
+ optional: true,
266
+ description: 'Total pipeline value',
267
+ },
268
+ weightedValue: {
269
+ type: 'number',
270
+ optional: true,
271
+ description: 'Weighted pipeline value',
272
+ },
273
+ avgDealSize: {
274
+ type: 'number',
275
+ optional: true,
276
+ description: 'Average deal size',
277
+ },
278
+ avgCycleTime: {
279
+ type: 'number',
280
+ optional: true,
281
+ description: 'Average cycle time (days)',
282
+ },
283
+ winRate: {
284
+ type: 'number',
285
+ optional: true,
286
+ description: 'Win rate percentage',
287
+ },
288
+ currency: {
289
+ type: 'string',
290
+ optional: true,
291
+ description: 'Currency code',
292
+ },
293
+ // Status
294
+ status: {
295
+ type: 'string',
296
+ description: 'Pipeline status',
297
+ examples: ['active', 'inactive', 'archived'],
298
+ },
299
+ },
300
+ relationships: {
301
+ stages: {
302
+ type: 'Stage[]',
303
+ description: 'Pipeline stages',
304
+ },
305
+ deals: {
306
+ type: 'Deal[]',
307
+ description: 'Deals in pipeline',
308
+ },
309
+ team: {
310
+ type: 'Team',
311
+ required: false,
312
+ description: 'Sales team',
313
+ },
314
+ },
315
+ actions: [
316
+ 'create',
317
+ 'update',
318
+ 'addStage',
319
+ 'removeStage',
320
+ 'reorderStages',
321
+ 'setDefault',
322
+ 'archive',
323
+ ],
324
+ events: [
325
+ 'created',
326
+ 'updated',
327
+ 'stageAdded',
328
+ 'stageRemoved',
329
+ 'stagesReordered',
330
+ 'defaultSet',
331
+ 'archived',
332
+ ],
333
+ };
334
+ // =============================================================================
335
+ // Stage
336
+ // =============================================================================
337
+ /**
338
+ * Stage entity
339
+ *
340
+ * Represents a stage in a sales pipeline.
341
+ */
342
+ export const Stage = {
343
+ singular: 'stage',
344
+ plural: 'stages',
345
+ description: 'A stage in a sales pipeline',
346
+ properties: {
347
+ // Identity
348
+ name: {
349
+ type: 'string',
350
+ description: 'Stage name',
351
+ },
352
+ description: {
353
+ type: 'string',
354
+ optional: true,
355
+ description: 'Stage description',
356
+ },
357
+ // Order
358
+ order: {
359
+ type: 'number',
360
+ description: 'Stage order',
361
+ },
362
+ // Probability
363
+ probability: {
364
+ type: 'number',
365
+ optional: true,
366
+ description: 'Win probability at this stage',
367
+ },
368
+ // Type
369
+ type: {
370
+ type: 'string',
371
+ optional: true,
372
+ description: 'Stage type',
373
+ examples: ['open', 'won', 'lost'],
374
+ },
375
+ // Requirements
376
+ requirements: {
377
+ type: 'string',
378
+ array: true,
379
+ optional: true,
380
+ description: 'Requirements to enter stage',
381
+ },
382
+ exitCriteria: {
383
+ type: 'string',
384
+ array: true,
385
+ optional: true,
386
+ description: 'Criteria to exit stage',
387
+ },
388
+ // Metrics
389
+ dealCount: {
390
+ type: 'number',
391
+ optional: true,
392
+ description: 'Deals in this stage',
393
+ },
394
+ avgTimeInStage: {
395
+ type: 'number',
396
+ optional: true,
397
+ description: 'Average days in stage',
398
+ },
399
+ conversionRate: {
400
+ type: 'number',
401
+ optional: true,
402
+ description: 'Conversion to next stage',
403
+ },
404
+ // Automation
405
+ rottenAfterDays: {
406
+ type: 'number',
407
+ optional: true,
408
+ description: 'Days until deal is considered stale',
409
+ },
410
+ },
411
+ relationships: {
412
+ pipeline: {
413
+ type: 'Pipeline',
414
+ description: 'Parent pipeline',
415
+ },
416
+ deals: {
417
+ type: 'Deal[]',
418
+ description: 'Deals in this stage',
419
+ },
420
+ },
421
+ actions: [
422
+ 'create',
423
+ 'update',
424
+ 'move',
425
+ 'delete',
426
+ ],
427
+ events: [
428
+ 'created',
429
+ 'updated',
430
+ 'moved',
431
+ 'deleted',
432
+ ],
433
+ };
434
+ // =============================================================================
435
+ // Contract
436
+ // =============================================================================
437
+ /**
438
+ * Contract entity
439
+ *
440
+ * Represents a sales/service contract.
441
+ */
442
+ export const Contract = {
443
+ singular: 'contract',
444
+ plural: 'contracts',
445
+ description: 'A sales or service contract',
446
+ properties: {
447
+ // Identity
448
+ name: {
449
+ type: 'string',
450
+ description: 'Contract name',
451
+ },
452
+ number: {
453
+ type: 'string',
454
+ optional: true,
455
+ description: 'Contract number',
456
+ },
457
+ description: {
458
+ type: 'string',
459
+ optional: true,
460
+ description: 'Contract description',
461
+ },
462
+ // Type
463
+ type: {
464
+ type: 'string',
465
+ description: 'Contract type',
466
+ examples: ['subscription', 'service', 'license', 'maintenance', 'support', 'msa', 'sow'],
467
+ },
468
+ // Value
469
+ totalValue: {
470
+ type: 'number',
471
+ optional: true,
472
+ description: 'Total contract value',
473
+ },
474
+ recurringValue: {
475
+ type: 'number',
476
+ optional: true,
477
+ description: 'Recurring value (ARR)',
478
+ },
479
+ currency: {
480
+ type: 'string',
481
+ optional: true,
482
+ description: 'Currency code',
483
+ },
484
+ // Term
485
+ startDate: {
486
+ type: 'date',
487
+ description: 'Start date',
488
+ },
489
+ endDate: {
490
+ type: 'date',
491
+ optional: true,
492
+ description: 'End date',
493
+ },
494
+ term: {
495
+ type: 'number',
496
+ optional: true,
497
+ description: 'Term in months',
498
+ },
499
+ autoRenew: {
500
+ type: 'boolean',
501
+ optional: true,
502
+ description: 'Auto-renew enabled',
503
+ },
504
+ renewalNoticeDays: {
505
+ type: 'number',
506
+ optional: true,
507
+ description: 'Days notice for renewal',
508
+ },
509
+ // Billing
510
+ billingFrequency: {
511
+ type: 'string',
512
+ optional: true,
513
+ description: 'Billing frequency',
514
+ examples: ['monthly', 'quarterly', 'annually', 'one-time'],
515
+ },
516
+ paymentTerms: {
517
+ type: 'string',
518
+ optional: true,
519
+ description: 'Payment terms',
520
+ examples: ['net-15', 'net-30', 'net-45', 'net-60', 'due-on-receipt'],
521
+ },
522
+ // Documents
523
+ documentUrl: {
524
+ type: 'url',
525
+ optional: true,
526
+ description: 'Contract document URL',
527
+ },
528
+ signedDate: {
529
+ type: 'date',
530
+ optional: true,
531
+ description: 'Date signed',
532
+ },
533
+ // Status
534
+ status: {
535
+ type: 'string',
536
+ description: 'Contract status',
537
+ examples: ['draft', 'pending-signature', 'active', 'expiring', 'expired', 'renewed', 'terminated', 'cancelled'],
538
+ },
539
+ },
540
+ relationships: {
541
+ customer: {
542
+ type: 'Customer',
543
+ required: false,
544
+ description: 'Customer',
545
+ },
546
+ account: {
547
+ type: 'Account',
548
+ required: false,
549
+ description: 'Account',
550
+ },
551
+ deal: {
552
+ type: 'Deal',
553
+ required: false,
554
+ description: 'Source deal',
555
+ },
556
+ owner: {
557
+ type: 'Worker',
558
+ required: false,
559
+ description: 'Contract owner',
560
+ },
561
+ subscriptions: {
562
+ type: 'Subscription[]',
563
+ description: 'Contract subscriptions',
564
+ },
565
+ lineItems: {
566
+ type: 'ContractLineItem[]',
567
+ description: 'Contract line items',
568
+ },
569
+ renewedFrom: {
570
+ type: 'Contract',
571
+ required: false,
572
+ description: 'Previous contract (if renewal)',
573
+ },
574
+ renewedTo: {
575
+ type: 'Contract',
576
+ required: false,
577
+ description: 'Renewal contract',
578
+ },
579
+ },
580
+ actions: [
581
+ 'create',
582
+ 'update',
583
+ 'send',
584
+ 'sign',
585
+ 'activate',
586
+ 'amend',
587
+ 'renew',
588
+ 'terminate',
589
+ 'cancel',
590
+ 'archive',
591
+ ],
592
+ events: [
593
+ 'created',
594
+ 'updated',
595
+ 'sent',
596
+ 'signed',
597
+ 'activated',
598
+ 'amended',
599
+ 'renewed',
600
+ 'expiring',
601
+ 'expired',
602
+ 'terminated',
603
+ 'cancelled',
604
+ 'archived',
605
+ ],
606
+ };
607
+ // =============================================================================
608
+ // Subscription
609
+ // =============================================================================
610
+ /**
611
+ * Subscription entity
612
+ *
613
+ * Represents a customer subscription.
614
+ */
615
+ export const Subscription = {
616
+ singular: 'subscription',
617
+ plural: 'subscriptions',
618
+ description: 'A customer subscription',
619
+ properties: {
620
+ // Value
621
+ mrr: {
622
+ type: 'number',
623
+ optional: true,
624
+ description: 'Monthly recurring revenue',
625
+ },
626
+ arr: {
627
+ type: 'number',
628
+ optional: true,
629
+ description: 'Annual recurring revenue',
630
+ },
631
+ quantity: {
632
+ type: 'number',
633
+ optional: true,
634
+ description: 'Quantity/seats',
635
+ },
636
+ unitPrice: {
637
+ type: 'number',
638
+ optional: true,
639
+ description: 'Price per unit',
640
+ },
641
+ currency: {
642
+ type: 'string',
643
+ optional: true,
644
+ description: 'Currency code',
645
+ },
646
+ // Plan
647
+ planId: {
648
+ type: 'string',
649
+ optional: true,
650
+ description: 'Plan ID',
651
+ },
652
+ planName: {
653
+ type: 'string',
654
+ optional: true,
655
+ description: 'Plan name',
656
+ },
657
+ // Billing
658
+ billingPeriod: {
659
+ type: 'string',
660
+ optional: true,
661
+ description: 'Billing period',
662
+ examples: ['monthly', 'quarterly', 'annually'],
663
+ },
664
+ billingAnchor: {
665
+ type: 'number',
666
+ optional: true,
667
+ description: 'Billing anchor day',
668
+ },
669
+ currentPeriodStart: {
670
+ type: 'date',
671
+ optional: true,
672
+ description: 'Current period start',
673
+ },
674
+ currentPeriodEnd: {
675
+ type: 'date',
676
+ optional: true,
677
+ description: 'Current period end',
678
+ },
679
+ // Dates
680
+ startDate: {
681
+ type: 'date',
682
+ description: 'Start date',
683
+ },
684
+ endDate: {
685
+ type: 'date',
686
+ optional: true,
687
+ description: 'End date',
688
+ },
689
+ cancelledAt: {
690
+ type: 'datetime',
691
+ optional: true,
692
+ description: 'Cancellation date',
693
+ },
694
+ cancelAtPeriodEnd: {
695
+ type: 'boolean',
696
+ optional: true,
697
+ description: 'Cancel at period end',
698
+ },
699
+ // Trial
700
+ trialStart: {
701
+ type: 'date',
702
+ optional: true,
703
+ description: 'Trial start date',
704
+ },
705
+ trialEnd: {
706
+ type: 'date',
707
+ optional: true,
708
+ description: 'Trial end date',
709
+ },
710
+ // Discount
711
+ discountPercent: {
712
+ type: 'number',
713
+ optional: true,
714
+ description: 'Discount percentage',
715
+ },
716
+ discountAmount: {
717
+ type: 'number',
718
+ optional: true,
719
+ description: 'Discount amount',
720
+ },
721
+ // External
722
+ stripeSubscriptionId: {
723
+ type: 'string',
724
+ optional: true,
725
+ description: 'Stripe subscription ID',
726
+ },
727
+ // Status
728
+ status: {
729
+ type: 'string',
730
+ description: 'Subscription status',
731
+ examples: ['trialing', 'active', 'past-due', 'paused', 'cancelled', 'expired'],
732
+ },
733
+ },
734
+ relationships: {
735
+ customer: {
736
+ type: 'Customer',
737
+ description: 'Customer',
738
+ },
739
+ product: {
740
+ type: 'Product',
741
+ required: false,
742
+ description: 'Product',
743
+ },
744
+ pricingPlan: {
745
+ type: 'PricingPlan',
746
+ required: false,
747
+ description: 'Pricing plan',
748
+ },
749
+ contract: {
750
+ type: 'Contract',
751
+ required: false,
752
+ description: 'Associated contract',
753
+ },
754
+ invoices: {
755
+ type: 'Invoice[]',
756
+ description: 'Invoices',
757
+ },
758
+ },
759
+ actions: [
760
+ 'create',
761
+ 'update',
762
+ 'activate',
763
+ 'upgrade',
764
+ 'downgrade',
765
+ 'addQuantity',
766
+ 'removeQuantity',
767
+ 'pause',
768
+ 'resume',
769
+ 'cancel',
770
+ 'reactivate',
771
+ ],
772
+ events: [
773
+ 'created',
774
+ 'updated',
775
+ 'activated',
776
+ 'upgraded',
777
+ 'downgraded',
778
+ 'quantityChanged',
779
+ 'paused',
780
+ 'resumed',
781
+ 'cancelled',
782
+ 'reactivated',
783
+ 'renewed',
784
+ 'expired',
785
+ ],
786
+ };
787
+ // =============================================================================
788
+ // Quote
789
+ // =============================================================================
790
+ /**
791
+ * Quote entity
792
+ *
793
+ * Represents a sales quote/proposal.
794
+ */
795
+ export const Quote = {
796
+ singular: 'quote',
797
+ plural: 'quotes',
798
+ description: 'A sales quote or proposal',
799
+ properties: {
800
+ // Identity
801
+ number: {
802
+ type: 'string',
803
+ description: 'Quote number',
804
+ },
805
+ name: {
806
+ type: 'string',
807
+ optional: true,
808
+ description: 'Quote name',
809
+ },
810
+ // Value
811
+ subtotal: {
812
+ type: 'number',
813
+ optional: true,
814
+ description: 'Subtotal',
815
+ },
816
+ discount: {
817
+ type: 'number',
818
+ optional: true,
819
+ description: 'Discount amount',
820
+ },
821
+ discountPercent: {
822
+ type: 'number',
823
+ optional: true,
824
+ description: 'Discount percentage',
825
+ },
826
+ tax: {
827
+ type: 'number',
828
+ optional: true,
829
+ description: 'Tax amount',
830
+ },
831
+ total: {
832
+ type: 'number',
833
+ description: 'Total amount',
834
+ },
835
+ currency: {
836
+ type: 'string',
837
+ optional: true,
838
+ description: 'Currency code',
839
+ },
840
+ // Recurring
841
+ mrr: {
842
+ type: 'number',
843
+ optional: true,
844
+ description: 'Monthly recurring',
845
+ },
846
+ arr: {
847
+ type: 'number',
848
+ optional: true,
849
+ description: 'Annual recurring',
850
+ },
851
+ // Validity
852
+ validFrom: {
853
+ type: 'date',
854
+ optional: true,
855
+ description: 'Valid from date',
856
+ },
857
+ validUntil: {
858
+ type: 'date',
859
+ optional: true,
860
+ description: 'Valid until date',
861
+ },
862
+ // Terms
863
+ terms: {
864
+ type: 'string',
865
+ optional: true,
866
+ description: 'Terms and conditions',
867
+ },
868
+ notes: {
869
+ type: 'string',
870
+ optional: true,
871
+ description: 'Notes',
872
+ },
873
+ // Documents
874
+ documentUrl: {
875
+ type: 'url',
876
+ optional: true,
877
+ description: 'Quote document URL',
878
+ },
879
+ // Status
880
+ status: {
881
+ type: 'string',
882
+ description: 'Quote status',
883
+ examples: ['draft', 'sent', 'viewed', 'accepted', 'rejected', 'expired', 'superseded'],
884
+ },
885
+ },
886
+ relationships: {
887
+ deal: {
888
+ type: 'Deal',
889
+ required: false,
890
+ description: 'Associated deal',
891
+ },
892
+ customer: {
893
+ type: 'Customer',
894
+ required: false,
895
+ description: 'Customer',
896
+ },
897
+ account: {
898
+ type: 'Account',
899
+ required: false,
900
+ description: 'Account',
901
+ },
902
+ contact: {
903
+ type: 'Contact',
904
+ required: false,
905
+ description: 'Primary contact',
906
+ },
907
+ createdBy: {
908
+ type: 'Worker',
909
+ required: false,
910
+ description: 'Created by',
911
+ },
912
+ lineItems: {
913
+ type: 'QuoteLineItem[]',
914
+ description: 'Quote line items',
915
+ },
916
+ },
917
+ actions: [
918
+ 'create',
919
+ 'update',
920
+ 'send',
921
+ 'accept',
922
+ 'reject',
923
+ 'expire',
924
+ 'duplicate',
925
+ 'convertToOrder',
926
+ 'archive',
927
+ ],
928
+ events: [
929
+ 'created',
930
+ 'updated',
931
+ 'sent',
932
+ 'viewed',
933
+ 'accepted',
934
+ 'rejected',
935
+ 'expired',
936
+ 'duplicated',
937
+ 'converted',
938
+ 'archived',
939
+ ],
940
+ };
941
+ // =============================================================================
942
+ // Order
943
+ // =============================================================================
944
+ /**
945
+ * Order entity
946
+ *
947
+ * Represents a sales order.
948
+ */
949
+ export const Order = {
950
+ singular: 'order',
951
+ plural: 'orders',
952
+ description: 'A sales order',
953
+ properties: {
954
+ // Identity
955
+ number: {
956
+ type: 'string',
957
+ description: 'Order number',
958
+ },
959
+ // Value
960
+ subtotal: {
961
+ type: 'number',
962
+ optional: true,
963
+ description: 'Subtotal',
964
+ },
965
+ discount: {
966
+ type: 'number',
967
+ optional: true,
968
+ description: 'Discount amount',
969
+ },
970
+ tax: {
971
+ type: 'number',
972
+ optional: true,
973
+ description: 'Tax amount',
974
+ },
975
+ shipping: {
976
+ type: 'number',
977
+ optional: true,
978
+ description: 'Shipping amount',
979
+ },
980
+ total: {
981
+ type: 'number',
982
+ description: 'Total amount',
983
+ },
984
+ currency: {
985
+ type: 'string',
986
+ optional: true,
987
+ description: 'Currency code',
988
+ },
989
+ // Dates
990
+ orderedAt: {
991
+ type: 'datetime',
992
+ description: 'Order date',
993
+ },
994
+ fulfilledAt: {
995
+ type: 'datetime',
996
+ optional: true,
997
+ description: 'Fulfillment date',
998
+ },
999
+ // Billing
1000
+ billingAddress: {
1001
+ type: 'json',
1002
+ optional: true,
1003
+ description: 'Billing address',
1004
+ },
1005
+ shippingAddress: {
1006
+ type: 'json',
1007
+ optional: true,
1008
+ description: 'Shipping address',
1009
+ },
1010
+ // Payment
1011
+ paymentStatus: {
1012
+ type: 'string',
1013
+ optional: true,
1014
+ description: 'Payment status',
1015
+ examples: ['pending', 'paid', 'partial', 'refunded', 'failed'],
1016
+ },
1017
+ paymentMethod: {
1018
+ type: 'string',
1019
+ optional: true,
1020
+ description: 'Payment method',
1021
+ },
1022
+ // Fulfillment
1023
+ fulfillmentStatus: {
1024
+ type: 'string',
1025
+ optional: true,
1026
+ description: 'Fulfillment status',
1027
+ examples: ['unfulfilled', 'partial', 'fulfilled', 'shipped', 'delivered'],
1028
+ },
1029
+ // Notes
1030
+ notes: {
1031
+ type: 'string',
1032
+ optional: true,
1033
+ description: 'Order notes',
1034
+ },
1035
+ // Status
1036
+ status: {
1037
+ type: 'string',
1038
+ description: 'Order status',
1039
+ examples: ['pending', 'confirmed', 'processing', 'completed', 'cancelled', 'refunded'],
1040
+ },
1041
+ },
1042
+ relationships: {
1043
+ customer: {
1044
+ type: 'Customer',
1045
+ description: 'Customer',
1046
+ },
1047
+ quote: {
1048
+ type: 'Quote',
1049
+ required: false,
1050
+ description: 'Source quote',
1051
+ },
1052
+ lineItems: {
1053
+ type: 'OrderLineItem[]',
1054
+ description: 'Order line items',
1055
+ },
1056
+ invoices: {
1057
+ type: 'Invoice[]',
1058
+ description: 'Invoices',
1059
+ },
1060
+ },
1061
+ actions: [
1062
+ 'create',
1063
+ 'update',
1064
+ 'confirm',
1065
+ 'fulfill',
1066
+ 'ship',
1067
+ 'deliver',
1068
+ 'cancel',
1069
+ 'refund',
1070
+ ],
1071
+ events: [
1072
+ 'created',
1073
+ 'updated',
1074
+ 'confirmed',
1075
+ 'fulfilled',
1076
+ 'shipped',
1077
+ 'delivered',
1078
+ 'cancelled',
1079
+ 'refunded',
1080
+ ],
1081
+ };
1082
+ // =============================================================================
1083
+ // Invoice
1084
+ // =============================================================================
1085
+ /**
1086
+ * Invoice entity
1087
+ *
1088
+ * Represents an invoice.
1089
+ */
1090
+ export const Invoice = {
1091
+ singular: 'invoice',
1092
+ plural: 'invoices',
1093
+ description: 'An invoice',
1094
+ properties: {
1095
+ // Identity
1096
+ number: {
1097
+ type: 'string',
1098
+ description: 'Invoice number',
1099
+ },
1100
+ // Value
1101
+ subtotal: {
1102
+ type: 'number',
1103
+ optional: true,
1104
+ description: 'Subtotal',
1105
+ },
1106
+ discount: {
1107
+ type: 'number',
1108
+ optional: true,
1109
+ description: 'Discount amount',
1110
+ },
1111
+ tax: {
1112
+ type: 'number',
1113
+ optional: true,
1114
+ description: 'Tax amount',
1115
+ },
1116
+ total: {
1117
+ type: 'number',
1118
+ description: 'Total amount',
1119
+ },
1120
+ amountDue: {
1121
+ type: 'number',
1122
+ optional: true,
1123
+ description: 'Amount due',
1124
+ },
1125
+ amountPaid: {
1126
+ type: 'number',
1127
+ optional: true,
1128
+ description: 'Amount paid',
1129
+ },
1130
+ currency: {
1131
+ type: 'string',
1132
+ optional: true,
1133
+ description: 'Currency code',
1134
+ },
1135
+ // Dates
1136
+ issueDate: {
1137
+ type: 'date',
1138
+ description: 'Issue date',
1139
+ },
1140
+ dueDate: {
1141
+ type: 'date',
1142
+ optional: true,
1143
+ description: 'Due date',
1144
+ },
1145
+ paidAt: {
1146
+ type: 'datetime',
1147
+ optional: true,
1148
+ description: 'Payment date',
1149
+ },
1150
+ // Payment
1151
+ paymentTerms: {
1152
+ type: 'string',
1153
+ optional: true,
1154
+ description: 'Payment terms',
1155
+ },
1156
+ paymentMethod: {
1157
+ type: 'string',
1158
+ optional: true,
1159
+ description: 'Payment method',
1160
+ },
1161
+ // Documents
1162
+ documentUrl: {
1163
+ type: 'url',
1164
+ optional: true,
1165
+ description: 'Invoice document URL',
1166
+ },
1167
+ // External
1168
+ stripeInvoiceId: {
1169
+ type: 'string',
1170
+ optional: true,
1171
+ description: 'Stripe invoice ID',
1172
+ },
1173
+ // Status
1174
+ status: {
1175
+ type: 'string',
1176
+ description: 'Invoice status',
1177
+ examples: ['draft', 'sent', 'paid', 'partial', 'overdue', 'void', 'uncollectible'],
1178
+ },
1179
+ },
1180
+ relationships: {
1181
+ customer: {
1182
+ type: 'Customer',
1183
+ description: 'Customer',
1184
+ },
1185
+ subscription: {
1186
+ type: 'Subscription',
1187
+ required: false,
1188
+ description: 'Subscription',
1189
+ },
1190
+ order: {
1191
+ type: 'Order',
1192
+ required: false,
1193
+ description: 'Order',
1194
+ },
1195
+ contract: {
1196
+ type: 'Contract',
1197
+ required: false,
1198
+ description: 'Contract',
1199
+ },
1200
+ lineItems: {
1201
+ type: 'InvoiceLineItem[]',
1202
+ description: 'Invoice line items',
1203
+ },
1204
+ payments: {
1205
+ type: 'Payment[]',
1206
+ description: 'Payments',
1207
+ },
1208
+ },
1209
+ actions: [
1210
+ 'create',
1211
+ 'update',
1212
+ 'send',
1213
+ 'recordPayment',
1214
+ 'markPaid',
1215
+ 'void',
1216
+ 'writeOff',
1217
+ ],
1218
+ events: [
1219
+ 'created',
1220
+ 'updated',
1221
+ 'sent',
1222
+ 'viewed',
1223
+ 'paid',
1224
+ 'partialPayment',
1225
+ 'overdue',
1226
+ 'voided',
1227
+ 'writtenOff',
1228
+ ],
1229
+ };
1230
+ // =============================================================================
1231
+ // Exports
1232
+ // =============================================================================
1233
+ export const SalesEntities = {
1234
+ Deal,
1235
+ Pipeline,
1236
+ Stage,
1237
+ Contract,
1238
+ Subscription,
1239
+ Quote,
1240
+ Order,
1241
+ Invoice,
1242
+ };
1243
+ export const SalesCategories = {
1244
+ pipeline: ['Deal', 'Pipeline', 'Stage'],
1245
+ agreements: ['Contract', 'Subscription'],
1246
+ transactions: ['Quote', 'Order', 'Invoice'],
1247
+ };
1248
+ //# sourceMappingURL=sales.js.map