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,1072 @@
1
+ /**
2
+ * Customer Entity Types (Nouns)
3
+ *
4
+ * Customer and relationship management: Customer, Account, Contact, Segment, Persona.
5
+ *
6
+ * @packageDocumentation
7
+ */
8
+
9
+ import type { Noun } from 'ai-database'
10
+
11
+ // =============================================================================
12
+ // Customer
13
+ // =============================================================================
14
+
15
+ /**
16
+ * Customer entity
17
+ *
18
+ * Represents a customer (individual or company).
19
+ */
20
+ export const Customer: Noun = {
21
+ singular: 'customer',
22
+ plural: 'customers',
23
+ description: 'A customer (individual or company)',
24
+
25
+ properties: {
26
+ // Identity
27
+ name: {
28
+ type: 'string',
29
+ description: 'Customer name',
30
+ },
31
+ email: {
32
+ type: 'string',
33
+ optional: true,
34
+ description: 'Primary email',
35
+ },
36
+ phone: {
37
+ type: 'string',
38
+ optional: true,
39
+ description: 'Primary phone',
40
+ },
41
+
42
+ // Type
43
+ type: {
44
+ type: 'string',
45
+ description: 'Customer type',
46
+ examples: ['individual', 'company', 'nonprofit', 'government'],
47
+ },
48
+
49
+ // Classification
50
+ tier: {
51
+ type: 'string',
52
+ optional: true,
53
+ description: 'Customer tier',
54
+ examples: ['free', 'starter', 'pro', 'business', 'enterprise', 'strategic'],
55
+ },
56
+ segment: {
57
+ type: 'string',
58
+ optional: true,
59
+ description: 'Customer segment',
60
+ },
61
+ industry: {
62
+ type: 'string',
63
+ optional: true,
64
+ description: 'Industry',
65
+ },
66
+
67
+ // Lifecycle
68
+ stage: {
69
+ type: 'string',
70
+ description: 'Customer lifecycle stage',
71
+ examples: ['prospect', 'trial', 'onboarding', 'active', 'at-risk', 'churned', 'won-back'],
72
+ },
73
+ source: {
74
+ type: 'string',
75
+ optional: true,
76
+ description: 'Acquisition source',
77
+ examples: ['organic', 'paid', 'referral', 'partner', 'outbound', 'event'],
78
+ },
79
+ referredBy: {
80
+ type: 'string',
81
+ optional: true,
82
+ description: 'Referrer ID or name',
83
+ },
84
+
85
+ // Dates
86
+ firstContactAt: {
87
+ type: 'datetime',
88
+ optional: true,
89
+ description: 'First contact date',
90
+ },
91
+ convertedAt: {
92
+ type: 'datetime',
93
+ optional: true,
94
+ description: 'Conversion date',
95
+ },
96
+ churnedAt: {
97
+ type: 'datetime',
98
+ optional: true,
99
+ description: 'Churn date',
100
+ },
101
+
102
+ // Value
103
+ lifetimeValue: {
104
+ type: 'number',
105
+ optional: true,
106
+ description: 'Customer lifetime value',
107
+ },
108
+ mrr: {
109
+ type: 'number',
110
+ optional: true,
111
+ description: 'Monthly recurring revenue',
112
+ },
113
+ arr: {
114
+ type: 'number',
115
+ optional: true,
116
+ description: 'Annual recurring revenue',
117
+ },
118
+ currency: {
119
+ type: 'string',
120
+ optional: true,
121
+ description: 'Currency code',
122
+ },
123
+
124
+ // Health
125
+ healthScore: {
126
+ type: 'number',
127
+ optional: true,
128
+ description: 'Customer health score (0-100)',
129
+ },
130
+ nps: {
131
+ type: 'number',
132
+ optional: true,
133
+ description: 'Net Promoter Score (-100 to 100)',
134
+ },
135
+ lastActivityAt: {
136
+ type: 'datetime',
137
+ optional: true,
138
+ description: 'Last activity date',
139
+ },
140
+
141
+ // Location
142
+ country: {
143
+ type: 'string',
144
+ optional: true,
145
+ description: 'Country',
146
+ },
147
+ region: {
148
+ type: 'string',
149
+ optional: true,
150
+ description: 'Region',
151
+ },
152
+ timezone: {
153
+ type: 'string',
154
+ optional: true,
155
+ description: 'Timezone',
156
+ },
157
+
158
+ // Company info (for B2B)
159
+ companySize: {
160
+ type: 'string',
161
+ optional: true,
162
+ description: 'Company size',
163
+ examples: ['1-10', '11-50', '51-200', '201-500', '501-1000', '1000+'],
164
+ },
165
+ annualRevenue: {
166
+ type: 'number',
167
+ optional: true,
168
+ description: 'Annual revenue',
169
+ },
170
+ website: {
171
+ type: 'url',
172
+ optional: true,
173
+ description: 'Website URL',
174
+ },
175
+
176
+ // Tags
177
+ tags: {
178
+ type: 'string',
179
+ array: true,
180
+ optional: true,
181
+ description: 'Tags',
182
+ },
183
+
184
+ // Status
185
+ status: {
186
+ type: 'string',
187
+ description: 'Customer status',
188
+ examples: ['active', 'inactive', 'suspended', 'deleted'],
189
+ },
190
+ },
191
+
192
+ relationships: {
193
+ account: {
194
+ type: 'Account',
195
+ required: false,
196
+ description: 'Parent account (for B2B)',
197
+ },
198
+ contacts: {
199
+ type: 'Contact[]',
200
+ description: 'Associated contacts',
201
+ },
202
+ owner: {
203
+ type: 'Worker',
204
+ required: false,
205
+ description: 'Account owner/CSM',
206
+ },
207
+ segment: {
208
+ type: 'Segment',
209
+ required: false,
210
+ description: 'Customer segment',
211
+ },
212
+ subscriptions: {
213
+ type: 'Subscription[]',
214
+ description: 'Active subscriptions',
215
+ },
216
+ contracts: {
217
+ type: 'Contract[]',
218
+ description: 'Contracts',
219
+ },
220
+ deals: {
221
+ type: 'Deal[]',
222
+ description: 'Sales deals',
223
+ },
224
+ interactions: {
225
+ type: 'Interaction[]',
226
+ description: 'Interaction history',
227
+ },
228
+ },
229
+
230
+ actions: [
231
+ 'create',
232
+ 'update',
233
+ 'qualify',
234
+ 'convert',
235
+ 'onboard',
236
+ 'upgrade',
237
+ 'downgrade',
238
+ 'renew',
239
+ 'markAtRisk',
240
+ 'churn',
241
+ 'winBack',
242
+ 'merge',
243
+ 'archive',
244
+ ],
245
+
246
+ events: [
247
+ 'created',
248
+ 'updated',
249
+ 'qualified',
250
+ 'converted',
251
+ 'onboarded',
252
+ 'upgraded',
253
+ 'downgraded',
254
+ 'renewed',
255
+ 'markedAtRisk',
256
+ 'churned',
257
+ 'wonBack',
258
+ 'merged',
259
+ 'archived',
260
+ ],
261
+ }
262
+
263
+ // =============================================================================
264
+ // Account
265
+ // =============================================================================
266
+
267
+ /**
268
+ * Account entity
269
+ *
270
+ * Represents a company account (B2B).
271
+ */
272
+ export const Account: Noun = {
273
+ singular: 'account',
274
+ plural: 'accounts',
275
+ description: 'A company account (B2B)',
276
+
277
+ properties: {
278
+ // Identity
279
+ name: {
280
+ type: 'string',
281
+ description: 'Account/company name',
282
+ },
283
+ legalName: {
284
+ type: 'string',
285
+ optional: true,
286
+ description: 'Legal entity name',
287
+ },
288
+ domain: {
289
+ type: 'string',
290
+ optional: true,
291
+ description: 'Primary domain',
292
+ },
293
+ website: {
294
+ type: 'url',
295
+ optional: true,
296
+ description: 'Website URL',
297
+ },
298
+
299
+ // Classification
300
+ type: {
301
+ type: 'string',
302
+ optional: true,
303
+ description: 'Account type',
304
+ examples: ['prospect', 'customer', 'partner', 'competitor'],
305
+ },
306
+ tier: {
307
+ type: 'string',
308
+ optional: true,
309
+ description: 'Account tier',
310
+ examples: ['smb', 'mid-market', 'enterprise', 'strategic'],
311
+ },
312
+ industry: {
313
+ type: 'string',
314
+ optional: true,
315
+ description: 'Industry',
316
+ },
317
+
318
+ // Size
319
+ employees: {
320
+ type: 'number',
321
+ optional: true,
322
+ description: 'Employee count',
323
+ },
324
+ annualRevenue: {
325
+ type: 'number',
326
+ optional: true,
327
+ description: 'Annual revenue',
328
+ },
329
+
330
+ // Location
331
+ headquarters: {
332
+ type: 'string',
333
+ optional: true,
334
+ description: 'Headquarters location',
335
+ },
336
+ country: {
337
+ type: 'string',
338
+ optional: true,
339
+ description: 'Country',
340
+ },
341
+ region: {
342
+ type: 'string',
343
+ optional: true,
344
+ description: 'Region',
345
+ },
346
+
347
+ // Relationship
348
+ parentAccountId: {
349
+ type: 'string',
350
+ optional: true,
351
+ description: 'Parent account (for subsidiaries)',
352
+ },
353
+
354
+ // Value
355
+ totalContractValue: {
356
+ type: 'number',
357
+ optional: true,
358
+ description: 'Total contract value',
359
+ },
360
+ arr: {
361
+ type: 'number',
362
+ optional: true,
363
+ description: 'Annual recurring revenue',
364
+ },
365
+ currency: {
366
+ type: 'string',
367
+ optional: true,
368
+ description: 'Currency code',
369
+ },
370
+
371
+ // Health
372
+ healthScore: {
373
+ type: 'number',
374
+ optional: true,
375
+ description: 'Account health score',
376
+ },
377
+
378
+ // IDs
379
+ crmId: {
380
+ type: 'string',
381
+ optional: true,
382
+ description: 'External CRM ID',
383
+ },
384
+
385
+ // Status
386
+ status: {
387
+ type: 'string',
388
+ description: 'Account status',
389
+ examples: ['active', 'inactive', 'churned', 'archived'],
390
+ },
391
+ },
392
+
393
+ relationships: {
394
+ owner: {
395
+ type: 'Worker',
396
+ required: false,
397
+ description: 'Account owner',
398
+ },
399
+ contacts: {
400
+ type: 'Contact[]',
401
+ description: 'Account contacts',
402
+ },
403
+ customers: {
404
+ type: 'Customer[]',
405
+ description: 'Associated customers',
406
+ },
407
+ deals: {
408
+ type: 'Deal[]',
409
+ description: 'Sales deals',
410
+ },
411
+ contracts: {
412
+ type: 'Contract[]',
413
+ description: 'Contracts',
414
+ },
415
+ parent: {
416
+ type: 'Account',
417
+ required: false,
418
+ description: 'Parent account',
419
+ },
420
+ subsidiaries: {
421
+ type: 'Account[]',
422
+ description: 'Subsidiary accounts',
423
+ },
424
+ },
425
+
426
+ actions: [
427
+ 'create',
428
+ 'update',
429
+ 'merge',
430
+ 'assignOwner',
431
+ 'updateTier',
432
+ 'addContact',
433
+ 'removeContact',
434
+ 'archive',
435
+ ],
436
+
437
+ events: [
438
+ 'created',
439
+ 'updated',
440
+ 'merged',
441
+ 'ownerAssigned',
442
+ 'tierUpdated',
443
+ 'contactAdded',
444
+ 'contactRemoved',
445
+ 'archived',
446
+ ],
447
+ }
448
+
449
+ // =============================================================================
450
+ // Contact
451
+ // =============================================================================
452
+
453
+ /**
454
+ * Contact entity
455
+ *
456
+ * Represents a person/contact at a customer or account.
457
+ */
458
+ export const Contact: Noun = {
459
+ singular: 'contact',
460
+ plural: 'contacts',
461
+ description: 'A person/contact at a customer or account',
462
+
463
+ properties: {
464
+ // Identity
465
+ firstName: {
466
+ type: 'string',
467
+ description: 'First name',
468
+ },
469
+ lastName: {
470
+ type: 'string',
471
+ description: 'Last name',
472
+ },
473
+ email: {
474
+ type: 'string',
475
+ description: 'Email address',
476
+ },
477
+ phone: {
478
+ type: 'string',
479
+ optional: true,
480
+ description: 'Phone number',
481
+ },
482
+
483
+ // Role
484
+ title: {
485
+ type: 'string',
486
+ optional: true,
487
+ description: 'Job title',
488
+ },
489
+ department: {
490
+ type: 'string',
491
+ optional: true,
492
+ description: 'Department',
493
+ },
494
+ role: {
495
+ type: 'string',
496
+ optional: true,
497
+ description: 'Role in buying process',
498
+ examples: ['decision-maker', 'influencer', 'champion', 'blocker', 'end-user', 'economic-buyer', 'technical-buyer'],
499
+ },
500
+ seniority: {
501
+ type: 'string',
502
+ optional: true,
503
+ description: 'Seniority level',
504
+ examples: ['c-level', 'vp', 'director', 'manager', 'individual-contributor'],
505
+ },
506
+
507
+ // Contact preferences
508
+ preferredChannel: {
509
+ type: 'string',
510
+ optional: true,
511
+ description: 'Preferred contact channel',
512
+ examples: ['email', 'phone', 'linkedin', 'slack'],
513
+ },
514
+ timezone: {
515
+ type: 'string',
516
+ optional: true,
517
+ description: 'Timezone',
518
+ },
519
+
520
+ // Social
521
+ linkedinUrl: {
522
+ type: 'url',
523
+ optional: true,
524
+ description: 'LinkedIn URL',
525
+ },
526
+ twitterHandle: {
527
+ type: 'string',
528
+ optional: true,
529
+ description: 'Twitter handle',
530
+ },
531
+
532
+ // Engagement
533
+ lastContactedAt: {
534
+ type: 'datetime',
535
+ optional: true,
536
+ description: 'Last contacted date',
537
+ },
538
+ lastRespondedAt: {
539
+ type: 'datetime',
540
+ optional: true,
541
+ description: 'Last response date',
542
+ },
543
+
544
+ // Opt-in
545
+ marketingOptIn: {
546
+ type: 'boolean',
547
+ optional: true,
548
+ description: 'Marketing opt-in',
549
+ },
550
+ salesOptIn: {
551
+ type: 'boolean',
552
+ optional: true,
553
+ description: 'Sales opt-in',
554
+ },
555
+
556
+ // Tags
557
+ tags: {
558
+ type: 'string',
559
+ array: true,
560
+ optional: true,
561
+ description: 'Tags',
562
+ },
563
+
564
+ // Status
565
+ status: {
566
+ type: 'string',
567
+ description: 'Contact status',
568
+ examples: ['active', 'inactive', 'bounced', 'unsubscribed', 'archived'],
569
+ },
570
+ },
571
+
572
+ relationships: {
573
+ account: {
574
+ type: 'Account',
575
+ required: false,
576
+ description: 'Parent account',
577
+ },
578
+ customer: {
579
+ type: 'Customer',
580
+ required: false,
581
+ description: 'Associated customer',
582
+ },
583
+ owner: {
584
+ type: 'Worker',
585
+ required: false,
586
+ description: 'Contact owner',
587
+ },
588
+ deals: {
589
+ type: 'Deal[]',
590
+ description: 'Associated deals',
591
+ },
592
+ interactions: {
593
+ type: 'Interaction[]',
594
+ description: 'Interaction history',
595
+ },
596
+ },
597
+
598
+ actions: [
599
+ 'create',
600
+ 'update',
601
+ 'merge',
602
+ 'assignOwner',
603
+ 'optIn',
604
+ 'optOut',
605
+ 'markBounced',
606
+ 'archive',
607
+ ],
608
+
609
+ events: [
610
+ 'created',
611
+ 'updated',
612
+ 'merged',
613
+ 'ownerAssigned',
614
+ 'optedIn',
615
+ 'optedOut',
616
+ 'bounced',
617
+ 'archived',
618
+ ],
619
+ }
620
+
621
+ // =============================================================================
622
+ // Segment
623
+ // =============================================================================
624
+
625
+ /**
626
+ * Segment entity
627
+ *
628
+ * Represents a customer segment.
629
+ */
630
+ export const Segment: Noun = {
631
+ singular: 'segment',
632
+ plural: 'segments',
633
+ description: 'A customer segment',
634
+
635
+ properties: {
636
+ // Identity
637
+ name: {
638
+ type: 'string',
639
+ description: 'Segment name',
640
+ },
641
+ description: {
642
+ type: 'string',
643
+ optional: true,
644
+ description: 'Segment description',
645
+ },
646
+
647
+ // Type
648
+ type: {
649
+ type: 'string',
650
+ optional: true,
651
+ description: 'Segment type',
652
+ examples: ['demographic', 'behavioral', 'firmographic', 'technographic', 'psychographic'],
653
+ },
654
+
655
+ // Criteria
656
+ criteria: {
657
+ type: 'json',
658
+ optional: true,
659
+ description: 'Segment criteria/filters',
660
+ },
661
+ criteriaDescription: {
662
+ type: 'string',
663
+ optional: true,
664
+ description: 'Human-readable criteria',
665
+ },
666
+
667
+ // Size
668
+ size: {
669
+ type: 'number',
670
+ optional: true,
671
+ description: 'Number of customers in segment',
672
+ },
673
+
674
+ // Value
675
+ totalRevenue: {
676
+ type: 'number',
677
+ optional: true,
678
+ description: 'Total revenue from segment',
679
+ },
680
+ avgRevenue: {
681
+ type: 'number',
682
+ optional: true,
683
+ description: 'Average revenue per customer',
684
+ },
685
+ avgLTV: {
686
+ type: 'number',
687
+ optional: true,
688
+ description: 'Average lifetime value',
689
+ },
690
+
691
+ // Behavior
692
+ avgChurnRate: {
693
+ type: 'number',
694
+ optional: true,
695
+ description: 'Average churn rate',
696
+ },
697
+ avgNPS: {
698
+ type: 'number',
699
+ optional: true,
700
+ description: 'Average NPS',
701
+ },
702
+
703
+ // Dynamic
704
+ isDynamic: {
705
+ type: 'boolean',
706
+ optional: true,
707
+ description: 'Auto-updates based on criteria',
708
+ },
709
+ lastCalculatedAt: {
710
+ type: 'datetime',
711
+ optional: true,
712
+ description: 'Last calculation time',
713
+ },
714
+
715
+ // Status
716
+ status: {
717
+ type: 'string',
718
+ description: 'Segment status',
719
+ examples: ['active', 'inactive', 'archived'],
720
+ },
721
+ },
722
+
723
+ relationships: {
724
+ customers: {
725
+ type: 'Customer[]',
726
+ description: 'Customers in segment',
727
+ },
728
+ campaigns: {
729
+ type: 'Campaign[]',
730
+ description: 'Targeted campaigns',
731
+ },
732
+ persona: {
733
+ type: 'Persona',
734
+ required: false,
735
+ description: 'Associated persona',
736
+ },
737
+ },
738
+
739
+ actions: [
740
+ 'create',
741
+ 'update',
742
+ 'refresh',
743
+ 'addCustomer',
744
+ 'removeCustomer',
745
+ 'archive',
746
+ ],
747
+
748
+ events: [
749
+ 'created',
750
+ 'updated',
751
+ 'refreshed',
752
+ 'customerAdded',
753
+ 'customerRemoved',
754
+ 'archived',
755
+ ],
756
+ }
757
+
758
+ // =============================================================================
759
+ // Persona
760
+ // =============================================================================
761
+
762
+ /**
763
+ * Persona entity
764
+ *
765
+ * Represents a buyer or user persona.
766
+ */
767
+ export const Persona: Noun = {
768
+ singular: 'persona',
769
+ plural: 'personas',
770
+ description: 'A buyer or user persona',
771
+
772
+ properties: {
773
+ // Identity
774
+ name: {
775
+ type: 'string',
776
+ description: 'Persona name',
777
+ },
778
+ description: {
779
+ type: 'string',
780
+ optional: true,
781
+ description: 'Persona description',
782
+ },
783
+ avatarUrl: {
784
+ type: 'url',
785
+ optional: true,
786
+ description: 'Avatar image URL',
787
+ },
788
+
789
+ // Type
790
+ type: {
791
+ type: 'string',
792
+ optional: true,
793
+ description: 'Persona type',
794
+ examples: ['buyer', 'user', 'influencer', 'decision-maker'],
795
+ },
796
+
797
+ // Demographics
798
+ jobTitle: {
799
+ type: 'string',
800
+ optional: true,
801
+ description: 'Typical job title',
802
+ },
803
+ department: {
804
+ type: 'string',
805
+ optional: true,
806
+ description: 'Typical department',
807
+ },
808
+ seniority: {
809
+ type: 'string',
810
+ optional: true,
811
+ description: 'Seniority level',
812
+ },
813
+ companySize: {
814
+ type: 'string',
815
+ optional: true,
816
+ description: 'Typical company size',
817
+ },
818
+ industry: {
819
+ type: 'string',
820
+ optional: true,
821
+ description: 'Typical industry',
822
+ },
823
+
824
+ // Psychographics
825
+ goals: {
826
+ type: 'string',
827
+ array: true,
828
+ optional: true,
829
+ description: 'Goals and objectives',
830
+ },
831
+ challenges: {
832
+ type: 'string',
833
+ array: true,
834
+ optional: true,
835
+ description: 'Pain points and challenges',
836
+ },
837
+ motivations: {
838
+ type: 'string',
839
+ array: true,
840
+ optional: true,
841
+ description: 'Motivations',
842
+ },
843
+ objections: {
844
+ type: 'string',
845
+ array: true,
846
+ optional: true,
847
+ description: 'Common objections',
848
+ },
849
+
850
+ // Behavior
851
+ preferredChannels: {
852
+ type: 'string',
853
+ array: true,
854
+ optional: true,
855
+ description: 'Preferred communication channels',
856
+ },
857
+ contentPreferences: {
858
+ type: 'string',
859
+ array: true,
860
+ optional: true,
861
+ description: 'Content format preferences',
862
+ },
863
+ buyingProcess: {
864
+ type: 'string',
865
+ optional: true,
866
+ description: 'Typical buying process',
867
+ },
868
+
869
+ // Messaging
870
+ valueProposition: {
871
+ type: 'string',
872
+ optional: true,
873
+ description: 'Value proposition for this persona',
874
+ },
875
+ messagingGuidelines: {
876
+ type: 'string',
877
+ optional: true,
878
+ description: 'Messaging guidelines',
879
+ },
880
+ keywords: {
881
+ type: 'string',
882
+ array: true,
883
+ optional: true,
884
+ description: 'Keywords/phrases that resonate',
885
+ },
886
+
887
+ // Status
888
+ status: {
889
+ type: 'string',
890
+ description: 'Persona status',
891
+ examples: ['active', 'draft', 'archived'],
892
+ },
893
+ },
894
+
895
+ relationships: {
896
+ segments: {
897
+ type: 'Segment[]',
898
+ description: 'Associated segments',
899
+ },
900
+ products: {
901
+ type: 'Product[]',
902
+ description: 'Relevant products',
903
+ },
904
+ content: {
905
+ type: 'Content[]',
906
+ description: 'Content for this persona',
907
+ },
908
+ campaigns: {
909
+ type: 'Campaign[]',
910
+ description: 'Targeted campaigns',
911
+ },
912
+ },
913
+
914
+ actions: [
915
+ 'create',
916
+ 'update',
917
+ 'validate',
918
+ 'archive',
919
+ ],
920
+
921
+ events: [
922
+ 'created',
923
+ 'updated',
924
+ 'validated',
925
+ 'archived',
926
+ ],
927
+ }
928
+
929
+ // =============================================================================
930
+ // Interaction
931
+ // =============================================================================
932
+
933
+ /**
934
+ * Interaction entity
935
+ *
936
+ * Represents a customer interaction/touchpoint.
937
+ */
938
+ export const Interaction: Noun = {
939
+ singular: 'interaction',
940
+ plural: 'interactions',
941
+ description: 'A customer interaction or touchpoint',
942
+
943
+ properties: {
944
+ // Type
945
+ type: {
946
+ type: 'string',
947
+ description: 'Interaction type',
948
+ examples: ['email', 'call', 'meeting', 'chat', 'support-ticket', 'demo', 'webinar', 'event', 'social'],
949
+ },
950
+ direction: {
951
+ type: 'string',
952
+ optional: true,
953
+ description: 'Interaction direction',
954
+ examples: ['inbound', 'outbound'],
955
+ },
956
+
957
+ // Content
958
+ subject: {
959
+ type: 'string',
960
+ optional: true,
961
+ description: 'Subject/title',
962
+ },
963
+ description: {
964
+ type: 'string',
965
+ optional: true,
966
+ description: 'Description/notes',
967
+ },
968
+
969
+ // Timing
970
+ occurredAt: {
971
+ type: 'datetime',
972
+ description: 'When it occurred',
973
+ },
974
+ duration: {
975
+ type: 'number',
976
+ optional: true,
977
+ description: 'Duration in minutes',
978
+ },
979
+
980
+ // Outcome
981
+ outcome: {
982
+ type: 'string',
983
+ optional: true,
984
+ description: 'Interaction outcome',
985
+ examples: ['positive', 'neutral', 'negative', 'no-response'],
986
+ },
987
+ sentiment: {
988
+ type: 'string',
989
+ optional: true,
990
+ description: 'Customer sentiment',
991
+ examples: ['very-positive', 'positive', 'neutral', 'negative', 'very-negative'],
992
+ },
993
+ nextSteps: {
994
+ type: 'string',
995
+ optional: true,
996
+ description: 'Next steps',
997
+ },
998
+
999
+ // Channel
1000
+ channel: {
1001
+ type: 'string',
1002
+ optional: true,
1003
+ description: 'Channel used',
1004
+ },
1005
+
1006
+ // Attribution
1007
+ campaignId: {
1008
+ type: 'string',
1009
+ optional: true,
1010
+ description: 'Associated campaign',
1011
+ },
1012
+ },
1013
+
1014
+ relationships: {
1015
+ customer: {
1016
+ type: 'Customer',
1017
+ required: false,
1018
+ description: 'Customer',
1019
+ },
1020
+ contact: {
1021
+ type: 'Contact',
1022
+ required: false,
1023
+ description: 'Contact',
1024
+ },
1025
+ account: {
1026
+ type: 'Account',
1027
+ required: false,
1028
+ description: 'Account',
1029
+ },
1030
+ createdBy: {
1031
+ type: 'Worker',
1032
+ required: false,
1033
+ description: 'Who logged it',
1034
+ },
1035
+ deal: {
1036
+ type: 'Deal',
1037
+ required: false,
1038
+ description: 'Associated deal',
1039
+ },
1040
+ },
1041
+
1042
+ actions: [
1043
+ 'log',
1044
+ 'update',
1045
+ 'delete',
1046
+ ],
1047
+
1048
+ events: [
1049
+ 'logged',
1050
+ 'updated',
1051
+ 'deleted',
1052
+ ],
1053
+ }
1054
+
1055
+ // =============================================================================
1056
+ // Exports
1057
+ // =============================================================================
1058
+
1059
+ export const CustomerEntities = {
1060
+ Customer,
1061
+ Account,
1062
+ Contact,
1063
+ Segment,
1064
+ Persona,
1065
+ Interaction,
1066
+ }
1067
+
1068
+ export const CustomerCategories = {
1069
+ customers: ['Customer', 'Account', 'Contact'],
1070
+ segmentation: ['Segment', 'Persona'],
1071
+ engagement: ['Interaction'],
1072
+ } as const