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,1249 @@
1
+ /**
2
+ * Marketing Entity Types (Nouns)
3
+ *
4
+ * Marketing and demand generation: Campaign, Lead, Audience, Channel, Content, Funnel, Event.
5
+ *
6
+ * @packageDocumentation
7
+ */
8
+
9
+ import type { Noun } from 'ai-database'
10
+
11
+ // =============================================================================
12
+ // Campaign
13
+ // =============================================================================
14
+
15
+ /**
16
+ * Campaign entity
17
+ *
18
+ * Represents a marketing campaign.
19
+ */
20
+ export const Campaign: Noun = {
21
+ singular: 'campaign',
22
+ plural: 'campaigns',
23
+ description: 'A marketing campaign',
24
+
25
+ properties: {
26
+ // Identity
27
+ name: {
28
+ type: 'string',
29
+ description: 'Campaign name',
30
+ },
31
+ description: {
32
+ type: 'string',
33
+ optional: true,
34
+ description: 'Campaign description',
35
+ },
36
+ slug: {
37
+ type: 'string',
38
+ optional: true,
39
+ description: 'URL slug',
40
+ },
41
+
42
+ // Type
43
+ type: {
44
+ type: 'string',
45
+ description: 'Campaign type',
46
+ examples: ['email', 'paid-ads', 'content', 'social', 'event', 'webinar', 'product-launch', 'referral', 'abm', 'outbound'],
47
+ },
48
+ channel: {
49
+ type: 'string',
50
+ optional: true,
51
+ description: 'Primary channel',
52
+ examples: ['email', 'google-ads', 'facebook', 'linkedin', 'twitter', 'youtube', 'podcast', 'blog', 'seo'],
53
+ },
54
+
55
+ // Objective
56
+ objective: {
57
+ type: 'string',
58
+ optional: true,
59
+ description: 'Campaign objective',
60
+ examples: ['awareness', 'consideration', 'conversion', 'retention', 'expansion'],
61
+ },
62
+ goals: {
63
+ type: 'string',
64
+ array: true,
65
+ optional: true,
66
+ description: 'Campaign goals',
67
+ },
68
+
69
+ // Timeline
70
+ startDate: {
71
+ type: 'date',
72
+ optional: true,
73
+ description: 'Start date',
74
+ },
75
+ endDate: {
76
+ type: 'date',
77
+ optional: true,
78
+ description: 'End date',
79
+ },
80
+
81
+ // Budget
82
+ budget: {
83
+ type: 'number',
84
+ optional: true,
85
+ description: 'Campaign budget',
86
+ },
87
+ spent: {
88
+ type: 'number',
89
+ optional: true,
90
+ description: 'Amount spent',
91
+ },
92
+ currency: {
93
+ type: 'string',
94
+ optional: true,
95
+ description: 'Currency code',
96
+ },
97
+
98
+ // Targeting
99
+ targetPersonas: {
100
+ type: 'string',
101
+ array: true,
102
+ optional: true,
103
+ description: 'Target personas',
104
+ },
105
+ targetSegments: {
106
+ type: 'string',
107
+ array: true,
108
+ optional: true,
109
+ description: 'Target segments',
110
+ },
111
+ targetGeo: {
112
+ type: 'string',
113
+ array: true,
114
+ optional: true,
115
+ description: 'Target geographies',
116
+ },
117
+
118
+ // Performance
119
+ impressions: {
120
+ type: 'number',
121
+ optional: true,
122
+ description: 'Total impressions',
123
+ },
124
+ clicks: {
125
+ type: 'number',
126
+ optional: true,
127
+ description: 'Total clicks',
128
+ },
129
+ ctr: {
130
+ type: 'number',
131
+ optional: true,
132
+ description: 'Click-through rate',
133
+ },
134
+ leads: {
135
+ type: 'number',
136
+ optional: true,
137
+ description: 'Leads generated',
138
+ },
139
+ conversions: {
140
+ type: 'number',
141
+ optional: true,
142
+ description: 'Conversions',
143
+ },
144
+ revenue: {
145
+ type: 'number',
146
+ optional: true,
147
+ description: 'Revenue attributed',
148
+ },
149
+ roi: {
150
+ type: 'number',
151
+ optional: true,
152
+ description: 'Return on investment',
153
+ },
154
+ cpl: {
155
+ type: 'number',
156
+ optional: true,
157
+ description: 'Cost per lead',
158
+ },
159
+ cac: {
160
+ type: 'number',
161
+ optional: true,
162
+ description: 'Customer acquisition cost',
163
+ },
164
+
165
+ // UTM
166
+ utmSource: {
167
+ type: 'string',
168
+ optional: true,
169
+ description: 'UTM source',
170
+ },
171
+ utmMedium: {
172
+ type: 'string',
173
+ optional: true,
174
+ description: 'UTM medium',
175
+ },
176
+ utmCampaign: {
177
+ type: 'string',
178
+ optional: true,
179
+ description: 'UTM campaign',
180
+ },
181
+
182
+ // Status
183
+ status: {
184
+ type: 'string',
185
+ description: 'Campaign status',
186
+ examples: ['draft', 'scheduled', 'active', 'paused', 'completed', 'cancelled'],
187
+ },
188
+ },
189
+
190
+ relationships: {
191
+ owner: {
192
+ type: 'Worker',
193
+ required: false,
194
+ description: 'Campaign owner',
195
+ },
196
+ team: {
197
+ type: 'Team',
198
+ required: false,
199
+ description: 'Marketing team',
200
+ },
201
+ audiences: {
202
+ type: 'Audience[]',
203
+ description: 'Target audiences',
204
+ },
205
+ content: {
206
+ type: 'Content[]',
207
+ description: 'Campaign content',
208
+ },
209
+ leads: {
210
+ type: 'Lead[]',
211
+ description: 'Generated leads',
212
+ },
213
+ events: {
214
+ type: 'MarketingEvent[]',
215
+ description: 'Associated events',
216
+ },
217
+ },
218
+
219
+ actions: [
220
+ 'create',
221
+ 'update',
222
+ 'schedule',
223
+ 'launch',
224
+ 'pause',
225
+ 'resume',
226
+ 'complete',
227
+ 'cancel',
228
+ 'duplicate',
229
+ 'archive',
230
+ ],
231
+
232
+ events: [
233
+ 'created',
234
+ 'updated',
235
+ 'scheduled',
236
+ 'launched',
237
+ 'paused',
238
+ 'resumed',
239
+ 'completed',
240
+ 'cancelled',
241
+ 'duplicated',
242
+ 'archived',
243
+ ],
244
+ }
245
+
246
+ // =============================================================================
247
+ // Lead
248
+ // =============================================================================
249
+
250
+ /**
251
+ * Lead entity
252
+ *
253
+ * Represents a marketing lead.
254
+ */
255
+ export const Lead: Noun = {
256
+ singular: 'lead',
257
+ plural: 'leads',
258
+ description: 'A marketing lead',
259
+
260
+ properties: {
261
+ // Identity
262
+ email: {
263
+ type: 'string',
264
+ description: 'Email address',
265
+ },
266
+ firstName: {
267
+ type: 'string',
268
+ optional: true,
269
+ description: 'First name',
270
+ },
271
+ lastName: {
272
+ type: 'string',
273
+ optional: true,
274
+ description: 'Last name',
275
+ },
276
+ phone: {
277
+ type: 'string',
278
+ optional: true,
279
+ description: 'Phone number',
280
+ },
281
+
282
+ // Company
283
+ company: {
284
+ type: 'string',
285
+ optional: true,
286
+ description: 'Company name',
287
+ },
288
+ title: {
289
+ type: 'string',
290
+ optional: true,
291
+ description: 'Job title',
292
+ },
293
+ industry: {
294
+ type: 'string',
295
+ optional: true,
296
+ description: 'Industry',
297
+ },
298
+ companySize: {
299
+ type: 'string',
300
+ optional: true,
301
+ description: 'Company size',
302
+ },
303
+ website: {
304
+ type: 'url',
305
+ optional: true,
306
+ description: 'Website URL',
307
+ },
308
+
309
+ // Source
310
+ source: {
311
+ type: 'string',
312
+ description: 'Lead source',
313
+ examples: ['organic', 'paid', 'referral', 'partner', 'event', 'webinar', 'content', 'outbound', 'social'],
314
+ },
315
+ medium: {
316
+ type: 'string',
317
+ optional: true,
318
+ description: 'Source medium',
319
+ },
320
+ campaignId: {
321
+ type: 'string',
322
+ optional: true,
323
+ description: 'Source campaign',
324
+ },
325
+ referrer: {
326
+ type: 'string',
327
+ optional: true,
328
+ description: 'Referrer URL',
329
+ },
330
+ landingPage: {
331
+ type: 'string',
332
+ optional: true,
333
+ description: 'Landing page URL',
334
+ },
335
+
336
+ // UTM
337
+ utmSource: {
338
+ type: 'string',
339
+ optional: true,
340
+ description: 'UTM source',
341
+ },
342
+ utmMedium: {
343
+ type: 'string',
344
+ optional: true,
345
+ description: 'UTM medium',
346
+ },
347
+ utmCampaign: {
348
+ type: 'string',
349
+ optional: true,
350
+ description: 'UTM campaign',
351
+ },
352
+ utmTerm: {
353
+ type: 'string',
354
+ optional: true,
355
+ description: 'UTM term',
356
+ },
357
+ utmContent: {
358
+ type: 'string',
359
+ optional: true,
360
+ description: 'UTM content',
361
+ },
362
+
363
+ // Scoring
364
+ score: {
365
+ type: 'number',
366
+ optional: true,
367
+ description: 'Lead score',
368
+ },
369
+ grade: {
370
+ type: 'string',
371
+ optional: true,
372
+ description: 'Lead grade',
373
+ examples: ['A', 'B', 'C', 'D', 'F'],
374
+ },
375
+ fit: {
376
+ type: 'string',
377
+ optional: true,
378
+ description: 'Fit score',
379
+ examples: ['ideal', 'good', 'moderate', 'poor'],
380
+ },
381
+ intent: {
382
+ type: 'string',
383
+ optional: true,
384
+ description: 'Intent level',
385
+ examples: ['high', 'medium', 'low'],
386
+ },
387
+
388
+ // Lifecycle
389
+ stage: {
390
+ type: 'string',
391
+ description: 'Lead stage',
392
+ examples: ['new', 'engaged', 'mql', 'sql', 'opportunity', 'customer', 'disqualified'],
393
+ },
394
+ qualifiedAt: {
395
+ type: 'datetime',
396
+ optional: true,
397
+ description: 'MQL date',
398
+ },
399
+ convertedAt: {
400
+ type: 'datetime',
401
+ optional: true,
402
+ description: 'Conversion date',
403
+ },
404
+
405
+ // Location
406
+ country: {
407
+ type: 'string',
408
+ optional: true,
409
+ description: 'Country',
410
+ },
411
+ region: {
412
+ type: 'string',
413
+ optional: true,
414
+ description: 'Region',
415
+ },
416
+ city: {
417
+ type: 'string',
418
+ optional: true,
419
+ description: 'City',
420
+ },
421
+ timezone: {
422
+ type: 'string',
423
+ optional: true,
424
+ description: 'Timezone',
425
+ },
426
+
427
+ // Consent
428
+ marketingConsent: {
429
+ type: 'boolean',
430
+ optional: true,
431
+ description: 'Marketing consent',
432
+ },
433
+ consentDate: {
434
+ type: 'datetime',
435
+ optional: true,
436
+ description: 'Consent date',
437
+ },
438
+
439
+ // Tags
440
+ tags: {
441
+ type: 'string',
442
+ array: true,
443
+ optional: true,
444
+ description: 'Tags',
445
+ },
446
+
447
+ // Status
448
+ status: {
449
+ type: 'string',
450
+ description: 'Lead status',
451
+ examples: ['active', 'nurturing', 'converted', 'disqualified', 'unsubscribed'],
452
+ },
453
+ },
454
+
455
+ relationships: {
456
+ campaign: {
457
+ type: 'Campaign',
458
+ required: false,
459
+ description: 'Source campaign',
460
+ },
461
+ owner: {
462
+ type: 'Worker',
463
+ required: false,
464
+ description: 'Lead owner',
465
+ },
466
+ customer: {
467
+ type: 'Customer',
468
+ required: false,
469
+ description: 'Converted customer',
470
+ },
471
+ deal: {
472
+ type: 'Deal',
473
+ required: false,
474
+ description: 'Associated deal',
475
+ },
476
+ audiences: {
477
+ type: 'Audience[]',
478
+ description: 'Member of audiences',
479
+ },
480
+ interactions: {
481
+ type: 'Interaction[]',
482
+ description: 'Interactions',
483
+ },
484
+ },
485
+
486
+ actions: [
487
+ 'create',
488
+ 'update',
489
+ 'score',
490
+ 'qualify',
491
+ 'assignOwner',
492
+ 'nurture',
493
+ 'convert',
494
+ 'disqualify',
495
+ 'merge',
496
+ 'archive',
497
+ ],
498
+
499
+ events: [
500
+ 'created',
501
+ 'updated',
502
+ 'scored',
503
+ 'qualified',
504
+ 'ownerAssigned',
505
+ 'nurtured',
506
+ 'converted',
507
+ 'disqualified',
508
+ 'merged',
509
+ 'unsubscribed',
510
+ 'archived',
511
+ ],
512
+ }
513
+
514
+ // =============================================================================
515
+ // Audience
516
+ // =============================================================================
517
+
518
+ /**
519
+ * Audience entity
520
+ *
521
+ * Represents a marketing audience.
522
+ */
523
+ export const Audience: Noun = {
524
+ singular: 'audience',
525
+ plural: 'audiences',
526
+ description: 'A marketing audience',
527
+
528
+ properties: {
529
+ // Identity
530
+ name: {
531
+ type: 'string',
532
+ description: 'Audience name',
533
+ },
534
+ description: {
535
+ type: 'string',
536
+ optional: true,
537
+ description: 'Audience description',
538
+ },
539
+
540
+ // Type
541
+ type: {
542
+ type: 'string',
543
+ description: 'Audience type',
544
+ examples: ['static', 'dynamic', 'lookalike', 'retargeting', 'suppression'],
545
+ },
546
+ source: {
547
+ type: 'string',
548
+ optional: true,
549
+ description: 'Audience source',
550
+ examples: ['crm', 'website', 'import', 'integration', 'ad-platform'],
551
+ },
552
+
553
+ // Criteria
554
+ criteria: {
555
+ type: 'json',
556
+ optional: true,
557
+ description: 'Audience criteria/filters',
558
+ },
559
+ criteriaDescription: {
560
+ type: 'string',
561
+ optional: true,
562
+ description: 'Human-readable criteria',
563
+ },
564
+
565
+ // Size
566
+ size: {
567
+ type: 'number',
568
+ optional: true,
569
+ description: 'Audience size',
570
+ },
571
+ lastSyncedAt: {
572
+ type: 'datetime',
573
+ optional: true,
574
+ description: 'Last sync time',
575
+ },
576
+
577
+ // Sync
578
+ syncToFacebook: {
579
+ type: 'boolean',
580
+ optional: true,
581
+ description: 'Sync to Facebook',
582
+ },
583
+ syncToGoogle: {
584
+ type: 'boolean',
585
+ optional: true,
586
+ description: 'Sync to Google',
587
+ },
588
+ syncToLinkedIn: {
589
+ type: 'boolean',
590
+ optional: true,
591
+ description: 'Sync to LinkedIn',
592
+ },
593
+
594
+ // Status
595
+ status: {
596
+ type: 'string',
597
+ description: 'Audience status',
598
+ examples: ['active', 'building', 'inactive', 'archived'],
599
+ },
600
+ },
601
+
602
+ relationships: {
603
+ campaigns: {
604
+ type: 'Campaign[]',
605
+ description: 'Campaigns using this audience',
606
+ },
607
+ leads: {
608
+ type: 'Lead[]',
609
+ description: 'Leads in audience',
610
+ },
611
+ customers: {
612
+ type: 'Customer[]',
613
+ description: 'Customers in audience',
614
+ },
615
+ segment: {
616
+ type: 'Segment',
617
+ required: false,
618
+ description: 'Based on segment',
619
+ },
620
+ },
621
+
622
+ actions: [
623
+ 'create',
624
+ 'update',
625
+ 'refresh',
626
+ 'sync',
627
+ 'addMember',
628
+ 'removeMember',
629
+ 'archive',
630
+ ],
631
+
632
+ events: [
633
+ 'created',
634
+ 'updated',
635
+ 'refreshed',
636
+ 'synced',
637
+ 'memberAdded',
638
+ 'memberRemoved',
639
+ 'archived',
640
+ ],
641
+ }
642
+
643
+ // =============================================================================
644
+ // Content
645
+ // =============================================================================
646
+
647
+ /**
648
+ * Content entity
649
+ *
650
+ * Represents marketing content.
651
+ */
652
+ export const Content: Noun = {
653
+ singular: 'content',
654
+ plural: 'contents',
655
+ description: 'Marketing content',
656
+
657
+ properties: {
658
+ // Identity
659
+ title: {
660
+ type: 'string',
661
+ description: 'Content title',
662
+ },
663
+ slug: {
664
+ type: 'string',
665
+ optional: true,
666
+ description: 'URL slug',
667
+ },
668
+ description: {
669
+ type: 'string',
670
+ optional: true,
671
+ description: 'Content description',
672
+ },
673
+
674
+ // Type
675
+ type: {
676
+ type: 'string',
677
+ description: 'Content type',
678
+ examples: ['blog-post', 'ebook', 'whitepaper', 'case-study', 'video', 'webinar', 'podcast', 'infographic', 'template', 'guide', 'landing-page', 'email'],
679
+ },
680
+ format: {
681
+ type: 'string',
682
+ optional: true,
683
+ description: 'Content format',
684
+ examples: ['text', 'video', 'audio', 'image', 'pdf', 'interactive'],
685
+ },
686
+
687
+ // Body
688
+ body: {
689
+ type: 'markdown',
690
+ optional: true,
691
+ description: 'Content body',
692
+ },
693
+ excerpt: {
694
+ type: 'string',
695
+ optional: true,
696
+ description: 'Content excerpt',
697
+ },
698
+
699
+ // Media
700
+ featuredImage: {
701
+ type: 'url',
702
+ optional: true,
703
+ description: 'Featured image URL',
704
+ },
705
+ mediaUrl: {
706
+ type: 'url',
707
+ optional: true,
708
+ description: 'Media URL (video, audio, etc.)',
709
+ },
710
+
711
+ // SEO
712
+ metaTitle: {
713
+ type: 'string',
714
+ optional: true,
715
+ description: 'Meta title',
716
+ },
717
+ metaDescription: {
718
+ type: 'string',
719
+ optional: true,
720
+ description: 'Meta description',
721
+ },
722
+ keywords: {
723
+ type: 'string',
724
+ array: true,
725
+ optional: true,
726
+ description: 'Target keywords',
727
+ },
728
+
729
+ // Targeting
730
+ targetPersonas: {
731
+ type: 'string',
732
+ array: true,
733
+ optional: true,
734
+ description: 'Target personas',
735
+ },
736
+ funnelStage: {
737
+ type: 'string',
738
+ optional: true,
739
+ description: 'Funnel stage',
740
+ examples: ['awareness', 'consideration', 'decision', 'retention'],
741
+ },
742
+
743
+ // Publishing
744
+ publishedAt: {
745
+ type: 'datetime',
746
+ optional: true,
747
+ description: 'Publish date',
748
+ },
749
+ expiresAt: {
750
+ type: 'datetime',
751
+ optional: true,
752
+ description: 'Expiration date',
753
+ },
754
+
755
+ // Performance
756
+ views: {
757
+ type: 'number',
758
+ optional: true,
759
+ description: 'Total views',
760
+ },
761
+ uniqueViews: {
762
+ type: 'number',
763
+ optional: true,
764
+ description: 'Unique views',
765
+ },
766
+ downloads: {
767
+ type: 'number',
768
+ optional: true,
769
+ description: 'Downloads (for gated content)',
770
+ },
771
+ shares: {
772
+ type: 'number',
773
+ optional: true,
774
+ description: 'Social shares',
775
+ },
776
+ avgTimeOnPage: {
777
+ type: 'number',
778
+ optional: true,
779
+ description: 'Average time on page (seconds)',
780
+ },
781
+
782
+ // Gating
783
+ isGated: {
784
+ type: 'boolean',
785
+ optional: true,
786
+ description: 'Requires form fill',
787
+ },
788
+
789
+ // Tags
790
+ tags: {
791
+ type: 'string',
792
+ array: true,
793
+ optional: true,
794
+ description: 'Tags',
795
+ },
796
+ categories: {
797
+ type: 'string',
798
+ array: true,
799
+ optional: true,
800
+ description: 'Categories',
801
+ },
802
+
803
+ // Status
804
+ status: {
805
+ type: 'string',
806
+ description: 'Content status',
807
+ examples: ['draft', 'review', 'scheduled', 'published', 'archived'],
808
+ },
809
+ },
810
+
811
+ relationships: {
812
+ author: {
813
+ type: 'Worker',
814
+ required: false,
815
+ description: 'Content author',
816
+ },
817
+ campaigns: {
818
+ type: 'Campaign[]',
819
+ description: 'Associated campaigns',
820
+ },
821
+ personas: {
822
+ type: 'Persona[]',
823
+ description: 'Target personas',
824
+ },
825
+ },
826
+
827
+ actions: [
828
+ 'create',
829
+ 'update',
830
+ 'submit',
831
+ 'approve',
832
+ 'schedule',
833
+ 'publish',
834
+ 'unpublish',
835
+ 'duplicate',
836
+ 'archive',
837
+ ],
838
+
839
+ events: [
840
+ 'created',
841
+ 'updated',
842
+ 'submitted',
843
+ 'approved',
844
+ 'scheduled',
845
+ 'published',
846
+ 'unpublished',
847
+ 'duplicated',
848
+ 'archived',
849
+ ],
850
+ }
851
+
852
+ // =============================================================================
853
+ // Funnel
854
+ // =============================================================================
855
+
856
+ /**
857
+ * Funnel entity
858
+ *
859
+ * Represents a marketing/sales funnel.
860
+ */
861
+ export const Funnel: Noun = {
862
+ singular: 'funnel',
863
+ plural: 'funnels',
864
+ description: 'A marketing or sales funnel',
865
+
866
+ properties: {
867
+ // Identity
868
+ name: {
869
+ type: 'string',
870
+ description: 'Funnel name',
871
+ },
872
+ description: {
873
+ type: 'string',
874
+ optional: true,
875
+ description: 'Funnel description',
876
+ },
877
+
878
+ // Type
879
+ type: {
880
+ type: 'string',
881
+ optional: true,
882
+ description: 'Funnel type',
883
+ examples: ['marketing', 'sales', 'product', 'onboarding', 'conversion'],
884
+ },
885
+
886
+ // Metrics (top-level)
887
+ totalEntries: {
888
+ type: 'number',
889
+ optional: true,
890
+ description: 'Total funnel entries',
891
+ },
892
+ totalConversions: {
893
+ type: 'number',
894
+ optional: true,
895
+ description: 'Total conversions',
896
+ },
897
+ conversionRate: {
898
+ type: 'number',
899
+ optional: true,
900
+ description: 'Overall conversion rate',
901
+ },
902
+ avgTimeToConvert: {
903
+ type: 'number',
904
+ optional: true,
905
+ description: 'Average time to convert (hours)',
906
+ },
907
+
908
+ // Status
909
+ status: {
910
+ type: 'string',
911
+ description: 'Funnel status',
912
+ examples: ['active', 'inactive', 'archived'],
913
+ },
914
+ },
915
+
916
+ relationships: {
917
+ stages: {
918
+ type: 'FunnelStage[]',
919
+ description: 'Funnel stages',
920
+ },
921
+ campaigns: {
922
+ type: 'Campaign[]',
923
+ description: 'Associated campaigns',
924
+ },
925
+ },
926
+
927
+ actions: [
928
+ 'create',
929
+ 'update',
930
+ 'addStage',
931
+ 'removeStage',
932
+ 'reorderStages',
933
+ 'archive',
934
+ ],
935
+
936
+ events: [
937
+ 'created',
938
+ 'updated',
939
+ 'stageAdded',
940
+ 'stageRemoved',
941
+ 'stagesReordered',
942
+ 'archived',
943
+ ],
944
+ }
945
+
946
+ // =============================================================================
947
+ // FunnelStage
948
+ // =============================================================================
949
+
950
+ /**
951
+ * FunnelStage entity
952
+ *
953
+ * Represents a stage in a funnel.
954
+ */
955
+ export const FunnelStage: Noun = {
956
+ singular: 'funnel-stage',
957
+ plural: 'funnel-stages',
958
+ description: 'A stage in a marketing/sales funnel',
959
+
960
+ properties: {
961
+ // Identity
962
+ name: {
963
+ type: 'string',
964
+ description: 'Stage name',
965
+ },
966
+ description: {
967
+ type: 'string',
968
+ optional: true,
969
+ description: 'Stage description',
970
+ },
971
+
972
+ // Order
973
+ order: {
974
+ type: 'number',
975
+ description: 'Stage order',
976
+ },
977
+
978
+ // Metrics
979
+ entries: {
980
+ type: 'number',
981
+ optional: true,
982
+ description: 'Entries to this stage',
983
+ },
984
+ exits: {
985
+ type: 'number',
986
+ optional: true,
987
+ description: 'Exits from this stage',
988
+ },
989
+ conversionRate: {
990
+ type: 'number',
991
+ optional: true,
992
+ description: 'Conversion to next stage',
993
+ },
994
+ dropoffRate: {
995
+ type: 'number',
996
+ optional: true,
997
+ description: 'Drop-off rate',
998
+ },
999
+ avgTimeInStage: {
1000
+ type: 'number',
1001
+ optional: true,
1002
+ description: 'Average time in stage (hours)',
1003
+ },
1004
+
1005
+ // Goals
1006
+ targetConversionRate: {
1007
+ type: 'number',
1008
+ optional: true,
1009
+ description: 'Target conversion rate',
1010
+ },
1011
+ },
1012
+
1013
+ relationships: {
1014
+ funnel: {
1015
+ type: 'Funnel',
1016
+ description: 'Parent funnel',
1017
+ },
1018
+ },
1019
+
1020
+ actions: [
1021
+ 'create',
1022
+ 'update',
1023
+ 'move',
1024
+ 'delete',
1025
+ ],
1026
+
1027
+ events: [
1028
+ 'created',
1029
+ 'updated',
1030
+ 'moved',
1031
+ 'deleted',
1032
+ ],
1033
+ }
1034
+
1035
+ // =============================================================================
1036
+ // MarketingEvent
1037
+ // =============================================================================
1038
+
1039
+ /**
1040
+ * MarketingEvent entity
1041
+ *
1042
+ * Represents a marketing event (webinar, conference, meetup).
1043
+ */
1044
+ export const MarketingEvent: Noun = {
1045
+ singular: 'marketing-event',
1046
+ plural: 'marketing-events',
1047
+ description: 'A marketing event (webinar, conference, meetup)',
1048
+
1049
+ properties: {
1050
+ // Identity
1051
+ name: {
1052
+ type: 'string',
1053
+ description: 'Event name',
1054
+ },
1055
+ description: {
1056
+ type: 'string',
1057
+ optional: true,
1058
+ description: 'Event description',
1059
+ },
1060
+ slug: {
1061
+ type: 'string',
1062
+ optional: true,
1063
+ description: 'URL slug',
1064
+ },
1065
+
1066
+ // Type
1067
+ type: {
1068
+ type: 'string',
1069
+ description: 'Event type',
1070
+ examples: ['webinar', 'conference', 'meetup', 'workshop', 'demo-day', 'trade-show', 'virtual-event', 'hybrid'],
1071
+ },
1072
+ format: {
1073
+ type: 'string',
1074
+ optional: true,
1075
+ description: 'Event format',
1076
+ examples: ['in-person', 'virtual', 'hybrid'],
1077
+ },
1078
+
1079
+ // Schedule
1080
+ startDate: {
1081
+ type: 'datetime',
1082
+ description: 'Start date/time',
1083
+ },
1084
+ endDate: {
1085
+ type: 'datetime',
1086
+ optional: true,
1087
+ description: 'End date/time',
1088
+ },
1089
+ timezone: {
1090
+ type: 'string',
1091
+ optional: true,
1092
+ description: 'Timezone',
1093
+ },
1094
+ duration: {
1095
+ type: 'number',
1096
+ optional: true,
1097
+ description: 'Duration in minutes',
1098
+ },
1099
+
1100
+ // Location
1101
+ location: {
1102
+ type: 'string',
1103
+ optional: true,
1104
+ description: 'Physical location',
1105
+ },
1106
+ virtualUrl: {
1107
+ type: 'url',
1108
+ optional: true,
1109
+ description: 'Virtual event URL',
1110
+ },
1111
+
1112
+ // Capacity
1113
+ capacity: {
1114
+ type: 'number',
1115
+ optional: true,
1116
+ description: 'Max capacity',
1117
+ },
1118
+ registrations: {
1119
+ type: 'number',
1120
+ optional: true,
1121
+ description: 'Total registrations',
1122
+ },
1123
+ attendees: {
1124
+ type: 'number',
1125
+ optional: true,
1126
+ description: 'Actual attendees',
1127
+ },
1128
+ attendanceRate: {
1129
+ type: 'number',
1130
+ optional: true,
1131
+ description: 'Attendance rate',
1132
+ },
1133
+
1134
+ // Budget
1135
+ budget: {
1136
+ type: 'number',
1137
+ optional: true,
1138
+ description: 'Event budget',
1139
+ },
1140
+ actualCost: {
1141
+ type: 'number',
1142
+ optional: true,
1143
+ description: 'Actual cost',
1144
+ },
1145
+ currency: {
1146
+ type: 'string',
1147
+ optional: true,
1148
+ description: 'Currency code',
1149
+ },
1150
+
1151
+ // Results
1152
+ leadsGenerated: {
1153
+ type: 'number',
1154
+ optional: true,
1155
+ description: 'Leads generated',
1156
+ },
1157
+ pipelineGenerated: {
1158
+ type: 'number',
1159
+ optional: true,
1160
+ description: 'Pipeline generated',
1161
+ },
1162
+ revenueAttributed: {
1163
+ type: 'number',
1164
+ optional: true,
1165
+ description: 'Revenue attributed',
1166
+ },
1167
+
1168
+ // Recording
1169
+ recordingUrl: {
1170
+ type: 'url',
1171
+ optional: true,
1172
+ description: 'Recording URL',
1173
+ },
1174
+
1175
+ // Status
1176
+ status: {
1177
+ type: 'string',
1178
+ description: 'Event status',
1179
+ examples: ['draft', 'scheduled', 'registration-open', 'live', 'completed', 'cancelled'],
1180
+ },
1181
+ },
1182
+
1183
+ relationships: {
1184
+ campaign: {
1185
+ type: 'Campaign',
1186
+ required: false,
1187
+ description: 'Parent campaign',
1188
+ },
1189
+ owner: {
1190
+ type: 'Worker',
1191
+ required: false,
1192
+ description: 'Event owner',
1193
+ },
1194
+ speakers: {
1195
+ type: 'Worker[]',
1196
+ description: 'Speakers',
1197
+ },
1198
+ registrants: {
1199
+ type: 'Lead[]',
1200
+ description: 'Registrants',
1201
+ },
1202
+ },
1203
+
1204
+ actions: [
1205
+ 'create',
1206
+ 'update',
1207
+ 'schedule',
1208
+ 'openRegistration',
1209
+ 'closeRegistration',
1210
+ 'start',
1211
+ 'end',
1212
+ 'cancel',
1213
+ 'archive',
1214
+ ],
1215
+
1216
+ events: [
1217
+ 'created',
1218
+ 'updated',
1219
+ 'scheduled',
1220
+ 'registrationOpened',
1221
+ 'registrationClosed',
1222
+ 'started',
1223
+ 'ended',
1224
+ 'cancelled',
1225
+ 'archived',
1226
+ ],
1227
+ }
1228
+
1229
+ // =============================================================================
1230
+ // Exports
1231
+ // =============================================================================
1232
+
1233
+ export const MarketingEntities = {
1234
+ Campaign,
1235
+ Lead,
1236
+ Audience,
1237
+ Content,
1238
+ Funnel,
1239
+ FunnelStage,
1240
+ MarketingEvent,
1241
+ }
1242
+
1243
+ export const MarketingCategories = {
1244
+ campaigns: ['Campaign'],
1245
+ leads: ['Lead', 'Audience'],
1246
+ content: ['Content'],
1247
+ funnels: ['Funnel', 'FunnelStage'],
1248
+ events: ['MarketingEvent'],
1249
+ } as const