business-as-code 2.1.3 → 2.3.0

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 (260) hide show
  1. package/CHANGELOG.md +10 -0
  2. package/README.md +2 -0
  3. package/package.json +16 -13
  4. package/src/dollar.ts +5 -2
  5. package/src/entities/organization.ts +31 -18
  6. package/src/goals.ts +78 -12
  7. package/src/index.ts +48 -18
  8. package/src/kpis.ts +62 -8
  9. package/src/metrics.ts +92 -79
  10. package/src/okrs.ts +120 -20
  11. package/src/organization.ts +12 -15
  12. package/src/process.ts +11 -12
  13. package/src/product.ts +8 -9
  14. package/src/queries.ts +238 -75
  15. package/src/roles.ts +62 -61
  16. package/src/workflow.ts +22 -15
  17. package/test/business.test.ts +282 -0
  18. package/test/dollar.test.ts +270 -0
  19. package/test/entities.test.ts +628 -0
  20. package/test/financials.test.ts +539 -0
  21. package/test/goals.test.ts +451 -0
  22. package/{src → test}/index.test.ts +1 -1
  23. package/test/kpis.test.ts +440 -0
  24. package/test/metrics.test.ts +744 -0
  25. package/test/okrs.test.ts +741 -0
  26. package/test/organization.test.ts +548 -0
  27. package/test/process.test.ts +503 -0
  28. package/test/product.test.ts +430 -0
  29. package/test/queries.test.ts +556 -0
  30. package/test/roles.test.ts +546 -0
  31. package/test/service.test.ts +450 -0
  32. package/test/types.test.ts +1141 -0
  33. package/test/vision.test.ts +214 -0
  34. package/test/workflow.test.ts +501 -0
  35. package/vitest.config.ts +47 -0
  36. package/.turbo/turbo-build.log +0 -5
  37. package/LICENSE +0 -21
  38. package/dist/business.d.ts +0 -62
  39. package/dist/business.d.ts.map +0 -1
  40. package/dist/business.js +0 -109
  41. package/dist/business.js.map +0 -1
  42. package/dist/canvas/activities.d.ts +0 -19
  43. package/dist/canvas/activities.d.ts.map +0 -1
  44. package/dist/canvas/activities.js +0 -20
  45. package/dist/canvas/activities.js.map +0 -1
  46. package/dist/canvas/channels.d.ts +0 -20
  47. package/dist/canvas/channels.d.ts.map +0 -1
  48. package/dist/canvas/channels.js +0 -21
  49. package/dist/canvas/channels.js.map +0 -1
  50. package/dist/canvas/relationships.d.ts +0 -20
  51. package/dist/canvas/relationships.d.ts.map +0 -1
  52. package/dist/canvas/relationships.js +0 -21
  53. package/dist/canvas/relationships.js.map +0 -1
  54. package/dist/canvas/resources.d.ts +0 -20
  55. package/dist/canvas/resources.d.ts.map +0 -1
  56. package/dist/canvas/resources.js +0 -30
  57. package/dist/canvas/resources.js.map +0 -1
  58. package/dist/canvas/revenue.d.ts +0 -22
  59. package/dist/canvas/revenue.d.ts.map +0 -1
  60. package/dist/canvas/revenue.js +0 -30
  61. package/dist/canvas/revenue.js.map +0 -1
  62. package/dist/canvas/segments.d.ts +0 -20
  63. package/dist/canvas/segments.d.ts.map +0 -1
  64. package/dist/canvas/segments.js +0 -28
  65. package/dist/canvas/segments.js.map +0 -1
  66. package/dist/canvas/types.d.ts +0 -232
  67. package/dist/canvas/types.d.ts.map +0 -1
  68. package/dist/canvas/types.js +0 -8
  69. package/dist/canvas/types.js.map +0 -1
  70. package/dist/canvas/value.d.ts +0 -20
  71. package/dist/canvas/value.d.ts.map +0 -1
  72. package/dist/canvas/value.js +0 -21
  73. package/dist/canvas/value.js.map +0 -1
  74. package/dist/dollar.d.ts +0 -60
  75. package/dist/dollar.d.ts.map +0 -1
  76. package/dist/dollar.js +0 -107
  77. package/dist/dollar.js.map +0 -1
  78. package/dist/entities/assets.d.ts +0 -21
  79. package/dist/entities/assets.d.ts.map +0 -1
  80. package/dist/entities/assets.js +0 -323
  81. package/dist/entities/assets.js.map +0 -1
  82. package/dist/entities/business.d.ts +0 -36
  83. package/dist/entities/business.d.ts.map +0 -1
  84. package/dist/entities/business.js +0 -370
  85. package/dist/entities/business.js.map +0 -1
  86. package/dist/entities/communication.d.ts +0 -21
  87. package/dist/entities/communication.d.ts.map +0 -1
  88. package/dist/entities/communication.js +0 -255
  89. package/dist/entities/communication.js.map +0 -1
  90. package/dist/entities/customers.d.ts +0 -58
  91. package/dist/entities/customers.d.ts.map +0 -1
  92. package/dist/entities/customers.js +0 -989
  93. package/dist/entities/customers.js.map +0 -1
  94. package/dist/entities/financials.d.ts +0 -59
  95. package/dist/entities/financials.d.ts.map +0 -1
  96. package/dist/entities/financials.js +0 -932
  97. package/dist/entities/financials.js.map +0 -1
  98. package/dist/entities/goals.d.ts +0 -58
  99. package/dist/entities/goals.d.ts.map +0 -1
  100. package/dist/entities/goals.js +0 -800
  101. package/dist/entities/goals.js.map +0 -1
  102. package/dist/entities/index.d.ts +0 -299
  103. package/dist/entities/index.d.ts.map +0 -1
  104. package/dist/entities/index.js +0 -198
  105. package/dist/entities/index.js.map +0 -1
  106. package/dist/entities/legal.d.ts +0 -21
  107. package/dist/entities/legal.d.ts.map +0 -1
  108. package/dist/entities/legal.js +0 -301
  109. package/dist/entities/legal.js.map +0 -1
  110. package/dist/entities/market.d.ts +0 -21
  111. package/dist/entities/market.d.ts.map +0 -1
  112. package/dist/entities/market.js +0 -301
  113. package/dist/entities/market.js.map +0 -1
  114. package/dist/entities/marketing.d.ts +0 -67
  115. package/dist/entities/marketing.d.ts.map +0 -1
  116. package/dist/entities/marketing.js +0 -1157
  117. package/dist/entities/marketing.js.map +0 -1
  118. package/dist/entities/offerings.d.ts +0 -51
  119. package/dist/entities/offerings.d.ts.map +0 -1
  120. package/dist/entities/offerings.js +0 -727
  121. package/dist/entities/offerings.js.map +0 -1
  122. package/dist/entities/operations.d.ts +0 -58
  123. package/dist/entities/operations.d.ts.map +0 -1
  124. package/dist/entities/operations.js +0 -787
  125. package/dist/entities/operations.js.map +0 -1
  126. package/dist/entities/organization.d.ts +0 -57
  127. package/dist/entities/organization.d.ts.map +0 -1
  128. package/dist/entities/organization.js +0 -807
  129. package/dist/entities/organization.js.map +0 -1
  130. package/dist/entities/partnerships.d.ts +0 -21
  131. package/dist/entities/partnerships.d.ts.map +0 -1
  132. package/dist/entities/partnerships.js +0 -300
  133. package/dist/entities/partnerships.js.map +0 -1
  134. package/dist/entities/planning.d.ts +0 -0
  135. package/dist/entities/planning.d.ts.map +0 -1
  136. package/dist/entities/planning.js +0 -271
  137. package/dist/entities/planning.js.map +0 -1
  138. package/dist/entities/projects.d.ts +0 -25
  139. package/dist/entities/projects.d.ts.map +0 -1
  140. package/dist/entities/projects.js +0 -349
  141. package/dist/entities/projects.js.map +0 -1
  142. package/dist/entities/risk.d.ts +0 -21
  143. package/dist/entities/risk.d.ts.map +0 -1
  144. package/dist/entities/risk.js +0 -293
  145. package/dist/entities/risk.js.map +0 -1
  146. package/dist/entities/sales.d.ts +0 -72
  147. package/dist/entities/sales.d.ts.map +0 -1
  148. package/dist/entities/sales.js +0 -1248
  149. package/dist/entities/sales.js.map +0 -1
  150. package/dist/financials.d.ts +0 -130
  151. package/dist/financials.d.ts.map +0 -1
  152. package/dist/financials.js +0 -297
  153. package/dist/financials.js.map +0 -1
  154. package/dist/goals.d.ts +0 -87
  155. package/dist/goals.d.ts.map +0 -1
  156. package/dist/goals.js +0 -215
  157. package/dist/goals.js.map +0 -1
  158. package/dist/index.d.ts +0 -97
  159. package/dist/index.d.ts.map +0 -1
  160. package/dist/index.js +0 -132
  161. package/dist/index.js.map +0 -1
  162. package/dist/kpis.d.ts +0 -118
  163. package/dist/kpis.d.ts.map +0 -1
  164. package/dist/kpis.js +0 -232
  165. package/dist/kpis.js.map +0 -1
  166. package/dist/metrics.d.ts +0 -448
  167. package/dist/metrics.d.ts.map +0 -1
  168. package/dist/metrics.js +0 -325
  169. package/dist/metrics.js.map +0 -1
  170. package/dist/okrs.d.ts +0 -123
  171. package/dist/okrs.d.ts.map +0 -1
  172. package/dist/okrs.js +0 -269
  173. package/dist/okrs.js.map +0 -1
  174. package/dist/organization.d.ts +0 -585
  175. package/dist/organization.d.ts.map +0 -1
  176. package/dist/organization.js +0 -173
  177. package/dist/organization.js.map +0 -1
  178. package/dist/process.d.ts +0 -112
  179. package/dist/process.d.ts.map +0 -1
  180. package/dist/process.js +0 -241
  181. package/dist/process.js.map +0 -1
  182. package/dist/product.d.ts +0 -85
  183. package/dist/product.d.ts.map +0 -1
  184. package/dist/product.js +0 -145
  185. package/dist/product.js.map +0 -1
  186. package/dist/queries.d.ts +0 -304
  187. package/dist/queries.d.ts.map +0 -1
  188. package/dist/queries.js +0 -415
  189. package/dist/queries.js.map +0 -1
  190. package/dist/roles.d.ts +0 -340
  191. package/dist/roles.d.ts.map +0 -1
  192. package/dist/roles.js +0 -255
  193. package/dist/roles.js.map +0 -1
  194. package/dist/service.d.ts +0 -61
  195. package/dist/service.d.ts.map +0 -1
  196. package/dist/service.js +0 -140
  197. package/dist/service.js.map +0 -1
  198. package/dist/types.d.ts +0 -459
  199. package/dist/types.d.ts.map +0 -1
  200. package/dist/types.js +0 -5
  201. package/dist/types.js.map +0 -1
  202. package/dist/vision.d.ts +0 -38
  203. package/dist/vision.d.ts.map +0 -1
  204. package/dist/vision.js +0 -68
  205. package/dist/vision.js.map +0 -1
  206. package/dist/workflow.d.ts +0 -115
  207. package/dist/workflow.d.ts.map +0 -1
  208. package/dist/workflow.js +0 -247
  209. package/dist/workflow.js.map +0 -1
  210. package/src/business.js +0 -108
  211. package/src/canvas/activities.ts +0 -32
  212. package/src/canvas/canvas.ts +0 -482
  213. package/src/canvas/channels.ts +0 -34
  214. package/src/canvas/costs.ts +0 -43
  215. package/src/canvas/economics.ts +0 -99
  216. package/src/canvas/index.ts +0 -206
  217. package/src/canvas/partnerships.ts +0 -34
  218. package/src/canvas/projections.ts +0 -141
  219. package/src/canvas/relationships.ts +0 -34
  220. package/src/canvas/resources.ts +0 -43
  221. package/src/canvas/revenue.ts +0 -56
  222. package/src/canvas/segments.ts +0 -42
  223. package/src/canvas/types.ts +0 -363
  224. package/src/canvas/value.ts +0 -34
  225. package/src/dollar.js +0 -106
  226. package/src/entities/assets.js +0 -322
  227. package/src/entities/business.js +0 -369
  228. package/src/entities/communication.js +0 -254
  229. package/src/entities/customers.js +0 -988
  230. package/src/entities/financials.js +0 -931
  231. package/src/entities/goals.js +0 -799
  232. package/src/entities/index.js +0 -197
  233. package/src/entities/legal.js +0 -300
  234. package/src/entities/market.js +0 -300
  235. package/src/entities/marketing.js +0 -1156
  236. package/src/entities/offerings.js +0 -726
  237. package/src/entities/operations.js +0 -786
  238. package/src/entities/organization.js +0 -806
  239. package/src/entities/partnerships.js +0 -299
  240. package/src/entities/planning.js +0 -270
  241. package/src/entities/projects.js +0 -348
  242. package/src/entities/risk.js +0 -292
  243. package/src/entities/sales.js +0 -1247
  244. package/src/financials.js +0 -296
  245. package/src/goals.js +0 -214
  246. package/src/index.js +0 -131
  247. package/src/index.test.js +0 -274
  248. package/src/kpis.js +0 -231
  249. package/src/metrics.js +0 -324
  250. package/src/okrs.js +0 -268
  251. package/src/organization.js +0 -172
  252. package/src/process.js +0 -240
  253. package/src/product.js +0 -144
  254. package/src/queries.js +0 -414
  255. package/src/roles.js +0 -254
  256. package/src/service.js +0 -139
  257. package/src/types.js +0 -4
  258. package/src/vision.js +0 -67
  259. package/src/workflow.js +0 -246
  260. package/tests/canvas.test.ts +0 -842
@@ -1,1247 +0,0 @@
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
- };