business-as-code 0.2.1 → 2.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (190) hide show
  1. package/.turbo/turbo-build.log +5 -0
  2. package/CHANGELOG.md +9 -0
  3. package/IMPLEMENTATION.md +226 -0
  4. package/README.md +1133 -193
  5. package/dist/business.d.ts +62 -0
  6. package/dist/business.d.ts.map +1 -0
  7. package/dist/business.js +109 -0
  8. package/dist/business.js.map +1 -0
  9. package/dist/dollar.d.ts +60 -0
  10. package/dist/dollar.d.ts.map +1 -0
  11. package/dist/dollar.js +107 -0
  12. package/dist/dollar.js.map +1 -0
  13. package/dist/entities/assets.d.ts +21 -0
  14. package/dist/entities/assets.d.ts.map +1 -0
  15. package/dist/entities/assets.js +323 -0
  16. package/dist/entities/assets.js.map +1 -0
  17. package/dist/entities/business.d.ts +36 -0
  18. package/dist/entities/business.d.ts.map +1 -0
  19. package/dist/entities/business.js +370 -0
  20. package/dist/entities/business.js.map +1 -0
  21. package/dist/entities/communication.d.ts +21 -0
  22. package/dist/entities/communication.d.ts.map +1 -0
  23. package/dist/entities/communication.js +255 -0
  24. package/dist/entities/communication.js.map +1 -0
  25. package/dist/entities/customers.d.ts +58 -0
  26. package/dist/entities/customers.d.ts.map +1 -0
  27. package/dist/entities/customers.js +989 -0
  28. package/dist/entities/customers.js.map +1 -0
  29. package/dist/entities/financials.d.ts +59 -0
  30. package/dist/entities/financials.d.ts.map +1 -0
  31. package/dist/entities/financials.js +932 -0
  32. package/dist/entities/financials.js.map +1 -0
  33. package/dist/entities/goals.d.ts +58 -0
  34. package/dist/entities/goals.d.ts.map +1 -0
  35. package/dist/entities/goals.js +800 -0
  36. package/dist/entities/goals.js.map +1 -0
  37. package/dist/entities/index.d.ts +299 -0
  38. package/dist/entities/index.d.ts.map +1 -0
  39. package/dist/entities/index.js +198 -0
  40. package/dist/entities/index.js.map +1 -0
  41. package/dist/entities/legal.d.ts +21 -0
  42. package/dist/entities/legal.d.ts.map +1 -0
  43. package/dist/entities/legal.js +301 -0
  44. package/dist/entities/legal.js.map +1 -0
  45. package/dist/entities/market.d.ts +21 -0
  46. package/dist/entities/market.d.ts.map +1 -0
  47. package/dist/entities/market.js +301 -0
  48. package/dist/entities/market.js.map +1 -0
  49. package/dist/entities/marketing.d.ts +67 -0
  50. package/dist/entities/marketing.d.ts.map +1 -0
  51. package/dist/entities/marketing.js +1157 -0
  52. package/dist/entities/marketing.js.map +1 -0
  53. package/dist/entities/offerings.d.ts +51 -0
  54. package/dist/entities/offerings.d.ts.map +1 -0
  55. package/dist/entities/offerings.js +727 -0
  56. package/dist/entities/offerings.js.map +1 -0
  57. package/dist/entities/operations.d.ts +58 -0
  58. package/dist/entities/operations.d.ts.map +1 -0
  59. package/dist/entities/operations.js +787 -0
  60. package/dist/entities/operations.js.map +1 -0
  61. package/dist/entities/organization.d.ts +57 -0
  62. package/dist/entities/organization.d.ts.map +1 -0
  63. package/dist/entities/organization.js +807 -0
  64. package/dist/entities/organization.js.map +1 -0
  65. package/dist/entities/partnerships.d.ts +21 -0
  66. package/dist/entities/partnerships.d.ts.map +1 -0
  67. package/dist/entities/partnerships.js +300 -0
  68. package/dist/entities/partnerships.js.map +1 -0
  69. package/dist/entities/planning.d.ts +87 -0
  70. package/dist/entities/planning.d.ts.map +1 -0
  71. package/dist/entities/planning.js +271 -0
  72. package/dist/entities/planning.js.map +1 -0
  73. package/dist/entities/projects.d.ts +25 -0
  74. package/dist/entities/projects.d.ts.map +1 -0
  75. package/dist/entities/projects.js +349 -0
  76. package/dist/entities/projects.js.map +1 -0
  77. package/dist/entities/risk.d.ts +21 -0
  78. package/dist/entities/risk.d.ts.map +1 -0
  79. package/dist/entities/risk.js +293 -0
  80. package/dist/entities/risk.js.map +1 -0
  81. package/dist/entities/sales.d.ts +72 -0
  82. package/dist/entities/sales.d.ts.map +1 -0
  83. package/dist/entities/sales.js +1248 -0
  84. package/dist/entities/sales.js.map +1 -0
  85. package/dist/financials.d.ts +130 -0
  86. package/dist/financials.d.ts.map +1 -0
  87. package/dist/financials.js +297 -0
  88. package/dist/financials.js.map +1 -0
  89. package/dist/goals.d.ts +87 -0
  90. package/dist/goals.d.ts.map +1 -0
  91. package/dist/goals.js +215 -0
  92. package/dist/goals.js.map +1 -0
  93. package/dist/index.d.ts +97 -4
  94. package/dist/index.d.ts.map +1 -0
  95. package/dist/index.js +131 -1079
  96. package/dist/index.js.map +1 -1
  97. package/dist/kpis.d.ts +118 -0
  98. package/dist/kpis.d.ts.map +1 -0
  99. package/dist/kpis.js +232 -0
  100. package/dist/kpis.js.map +1 -0
  101. package/dist/metrics.d.ts +448 -0
  102. package/dist/metrics.d.ts.map +1 -0
  103. package/dist/metrics.js +325 -0
  104. package/dist/metrics.js.map +1 -0
  105. package/dist/okrs.d.ts +123 -0
  106. package/dist/okrs.d.ts.map +1 -0
  107. package/dist/okrs.js +269 -0
  108. package/dist/okrs.js.map +1 -0
  109. package/dist/organization.d.ts +585 -0
  110. package/dist/organization.d.ts.map +1 -0
  111. package/dist/organization.js +173 -0
  112. package/dist/organization.js.map +1 -0
  113. package/dist/process.d.ts +112 -0
  114. package/dist/process.d.ts.map +1 -0
  115. package/dist/process.js +241 -0
  116. package/dist/process.js.map +1 -0
  117. package/dist/product.d.ts +85 -0
  118. package/dist/product.d.ts.map +1 -0
  119. package/dist/product.js +145 -0
  120. package/dist/product.js.map +1 -0
  121. package/dist/queries.d.ts +304 -0
  122. package/dist/queries.d.ts.map +1 -0
  123. package/dist/queries.js +415 -0
  124. package/dist/queries.js.map +1 -0
  125. package/dist/roles.d.ts +340 -0
  126. package/dist/roles.d.ts.map +1 -0
  127. package/dist/roles.js +255 -0
  128. package/dist/roles.js.map +1 -0
  129. package/dist/service.d.ts +61 -0
  130. package/dist/service.d.ts.map +1 -0
  131. package/dist/service.js +140 -0
  132. package/dist/service.js.map +1 -0
  133. package/dist/types.d.ts +459 -0
  134. package/dist/types.d.ts.map +1 -0
  135. package/dist/types.js +5 -0
  136. package/dist/types.js.map +1 -0
  137. package/dist/vision.d.ts +38 -0
  138. package/dist/vision.d.ts.map +1 -0
  139. package/dist/vision.js +68 -0
  140. package/dist/vision.js.map +1 -0
  141. package/dist/workflow.d.ts +115 -0
  142. package/dist/workflow.d.ts.map +1 -0
  143. package/dist/workflow.js +247 -0
  144. package/dist/workflow.js.map +1 -0
  145. package/examples/basic-usage.ts +307 -0
  146. package/package.json +19 -60
  147. package/src/business.ts +121 -0
  148. package/src/dollar.ts +132 -0
  149. package/src/entities/assets.ts +332 -0
  150. package/src/entities/business.ts +406 -0
  151. package/src/entities/communication.ts +264 -0
  152. package/src/entities/customers.ts +1072 -0
  153. package/src/entities/financials.ts +1011 -0
  154. package/src/entities/goals.ts +871 -0
  155. package/src/entities/index.ts +383 -0
  156. package/src/entities/legal.ts +310 -0
  157. package/src/entities/market.ts +310 -0
  158. package/src/entities/marketing.ts +1249 -0
  159. package/src/entities/offerings.ts +789 -0
  160. package/src/entities/operations.ts +861 -0
  161. package/src/entities/organization.ts +876 -0
  162. package/src/entities/partnerships.ts +309 -0
  163. package/src/entities/planning.ts +307 -0
  164. package/src/entities/projects.ts +360 -0
  165. package/src/entities/risk.ts +302 -0
  166. package/src/entities/sales.ts +1352 -0
  167. package/src/financials.ts +352 -0
  168. package/src/goals.ts +250 -0
  169. package/src/index.test.ts +336 -0
  170. package/src/index.ts +530 -0
  171. package/src/kpis.ts +275 -0
  172. package/src/metrics.ts +825 -0
  173. package/src/okrs.ts +325 -0
  174. package/src/organization.ts +909 -0
  175. package/src/process.ts +272 -0
  176. package/src/product.ts +178 -0
  177. package/src/queries.ts +767 -0
  178. package/src/roles.ts +686 -0
  179. package/src/service.ts +164 -0
  180. package/src/types.ts +493 -0
  181. package/src/vision.ts +88 -0
  182. package/src/workflow.ts +280 -0
  183. package/tsconfig.json +9 -0
  184. package/dist/loaders/index.d.ts +0 -174
  185. package/dist/loaders/index.js +0 -366
  186. package/dist/loaders/index.js.map +0 -1
  187. package/dist/schema/index.d.ts +0 -146
  188. package/dist/schema/index.js +0 -716
  189. package/dist/schema/index.js.map +0 -1
  190. package/dist/types-CJ9eGS_C.d.ts +0 -86
@@ -0,0 +1,309 @@
1
+ import type { Noun } from 'ai-database'
2
+
3
+ /**
4
+ * Partnership & Vendor Entities
5
+ * Partner, Vendor, Affiliate, Partnership, Reseller, Integration
6
+ */
7
+
8
+ export const Partner: Noun = {
9
+ singular: 'partner',
10
+ plural: 'partners',
11
+ description: 'A business partner that collaborates with the organization',
12
+ properties: {
13
+ name: { type: 'string', description: 'Partner organization name' },
14
+ type: { type: 'string', description: 'Type of partner', examples: ['strategic', 'technology', 'channel', 'solution', 'implementation', 'consulting', 'reseller', 'referral', 'OEM'] },
15
+ tier: { type: 'string', description: 'Partner tier level', examples: ['platinum', 'gold', 'silver', 'bronze', 'registered'] },
16
+ status: { type: 'string', description: 'Partnership status', examples: ['prospect', 'onboarding', 'active', 'inactive', 'suspended', 'terminated'] },
17
+ description: { type: 'string', description: 'Partner description' },
18
+ website: { type: 'string', description: 'Partner website URL' },
19
+ logo: { type: 'string', description: 'Partner logo URL' },
20
+ industry: { type: 'string', description: 'Partner industry' },
21
+ size: { type: 'string', description: 'Partner company size', examples: ['startup', 'small', 'medium', 'enterprise'] },
22
+ region: { type: 'string', description: 'Primary region of operation' },
23
+ territories: { type: 'string[]', description: 'Geographic territories covered' },
24
+ specializations: { type: 'string[]', description: 'Areas of specialization', examples: ['cloud', 'security', 'data', 'AI', 'mobile', 'e-commerce'] },
25
+ certifications: { type: 'string[]', description: 'Partner certifications held' },
26
+ primaryContact: { type: 'string', description: 'Primary contact person' },
27
+ email: { type: 'string', description: 'Primary contact email' },
28
+ phone: { type: 'string', description: 'Primary contact phone' },
29
+ partnerManager: { type: 'string', description: 'Internal partner manager' },
30
+ startDate: { type: 'date', description: 'Partnership start date' },
31
+ renewalDate: { type: 'date', description: 'Next renewal date' },
32
+ revenueShare: { type: 'number', description: 'Revenue share percentage' },
33
+ referralFee: { type: 'number', description: 'Referral fee percentage' },
34
+ totalRevenue: { type: 'number', description: 'Total revenue generated' },
35
+ totalDeals: { type: 'number', description: 'Total deals closed' },
36
+ lastActivityDate: { type: 'date', description: 'Date of last activity' },
37
+ nda: { type: 'boolean', description: 'NDA in place' },
38
+ ndaDate: { type: 'date', description: 'NDA signed date' },
39
+ portalAccess: { type: 'boolean', description: 'Has partner portal access' },
40
+ enablementComplete: { type: 'boolean', description: 'Enablement training completed' },
41
+ score: { type: 'number', description: 'Partner performance score', optional: true },
42
+ notes: { type: 'string', description: 'Internal notes', optional: true },
43
+ tags: { type: 'string[]', description: 'Partner tags' },
44
+ metadata: { type: 'object', description: 'Additional metadata', optional: true },
45
+ },
46
+ relationships: {
47
+ partnership: { type: 'partnership', description: 'Active partnership agreement', backref: 'partner' },
48
+ deals: { type: 'deal[]', description: 'Deals sourced by partner', backref: 'partner' },
49
+ leads: { type: 'lead[]', description: 'Leads referred by partner', backref: 'partner' },
50
+ contacts: { type: 'contact[]', description: 'Partner contacts', backref: 'partner' },
51
+ integrations: { type: 'integration[]', description: 'Technical integrations', backref: 'partner' },
52
+ },
53
+ actions: ['create', 'update', 'onboard', 'activate', 'deactivate', 'suspend', 'terminate', 'upgrade', 'downgrade', 'certify', 'enable', 'review', 'renew'],
54
+ events: ['created', 'updated', 'onboarded', 'activated', 'deactivated', 'suspended', 'terminated', 'upgraded', 'downgraded', 'certified', 'enabled', 'reviewed', 'renewed'],
55
+ }
56
+
57
+ export const Vendor: Noun = {
58
+ singular: 'vendor',
59
+ plural: 'vendors',
60
+ description: 'An external supplier or service provider',
61
+ properties: {
62
+ name: { type: 'string', description: 'Vendor name' },
63
+ type: { type: 'string', description: 'Type of vendor', examples: ['supplier', 'contractor', 'consultant', 'SaaS', 'service', 'manufacturer'] },
64
+ category: { type: 'string', description: 'Vendor category', examples: ['technology', 'operations', 'marketing', 'HR', 'legal', 'finance', 'facilities'] },
65
+ status: { type: 'string', description: 'Vendor status', examples: ['prospect', 'evaluating', 'approved', 'active', 'preferred', 'suspended', 'terminated'] },
66
+ website: { type: 'string', description: 'Vendor website' },
67
+ description: { type: 'string', description: 'Vendor description' },
68
+ primaryContact: { type: 'string', description: 'Primary contact name' },
69
+ email: { type: 'string', description: 'Contact email' },
70
+ phone: { type: 'string', description: 'Contact phone' },
71
+ address: { type: 'string', description: 'Vendor address' },
72
+ country: { type: 'string', description: 'Country of operation' },
73
+ taxId: { type: 'string', description: 'Tax identification number' },
74
+ paymentTerms: { type: 'string', description: 'Payment terms', examples: ['net-15', 'net-30', 'net-60', 'net-90', 'on-receipt'] },
75
+ currency: { type: 'string', description: 'Preferred currency' },
76
+ bankDetails: { type: 'object', description: 'Banking information', optional: true },
77
+ contractValue: { type: 'number', description: 'Total contract value' },
78
+ annualSpend: { type: 'number', description: 'Annual spend amount' },
79
+ startDate: { type: 'date', description: 'Relationship start date' },
80
+ contractEndDate: { type: 'date', description: 'Current contract end date' },
81
+ lastOrderDate: { type: 'date', description: 'Last order date' },
82
+ riskLevel: { type: 'string', description: 'Risk assessment', examples: ['low', 'medium', 'high', 'critical'] },
83
+ complianceStatus: { type: 'string', description: 'Compliance status', examples: ['compliant', 'pending', 'non-compliant', 'exempt'] },
84
+ slaScore: { type: 'number', description: 'SLA performance score' },
85
+ qualityScore: { type: 'number', description: 'Quality rating score' },
86
+ certifications: { type: 'string[]', description: 'Vendor certifications', examples: ['SOC2', 'ISO27001', 'GDPR', 'HIPAA'] },
87
+ insuranceCoverage: { type: 'boolean', description: 'Has insurance coverage' },
88
+ insuranceExpiry: { type: 'date', description: 'Insurance expiry date', optional: true },
89
+ notes: { type: 'string', description: 'Internal notes', optional: true },
90
+ tags: { type: 'string[]', description: 'Vendor tags' },
91
+ metadata: { type: 'object', description: 'Additional metadata', optional: true },
92
+ },
93
+ relationships: {
94
+ contracts: { type: 'contract[]', description: 'Vendor contracts', backref: 'vendor' },
95
+ orders: { type: 'order[]', description: 'Purchase orders', backref: 'vendor' },
96
+ invoices: { type: 'invoice[]', description: 'Vendor invoices', backref: 'vendor' },
97
+ contacts: { type: 'contact[]', description: 'Vendor contacts', backref: 'vendor' },
98
+ expenses: { type: 'expense[]', description: 'Related expenses', backref: 'vendor' },
99
+ },
100
+ actions: ['create', 'update', 'evaluate', 'approve', 'reject', 'activate', 'suspend', 'terminate', 'review', 'audit', 'renew'],
101
+ events: ['created', 'updated', 'evaluated', 'approved', 'rejected', 'activated', 'suspended', 'terminated', 'reviewed', 'audited', 'renewed'],
102
+ }
103
+
104
+ export const Affiliate: Noun = {
105
+ singular: 'affiliate',
106
+ plural: 'affiliates',
107
+ description: 'An affiliate partner who promotes products for commission',
108
+ properties: {
109
+ name: { type: 'string', description: 'Affiliate name' },
110
+ type: { type: 'string', description: 'Type of affiliate', examples: ['individual', 'company', 'influencer', 'blogger', 'publisher', 'network'] },
111
+ status: { type: 'string', description: 'Affiliate status', examples: ['applied', 'pending', 'approved', 'active', 'suspended', 'terminated'] },
112
+ email: { type: 'string', description: 'Contact email' },
113
+ website: { type: 'string', description: 'Affiliate website or channel' },
114
+ platform: { type: 'string', description: 'Primary platform', examples: ['blog', 'youtube', 'instagram', 'tiktok', 'twitter', 'podcast', 'newsletter'] },
115
+ audienceSize: { type: 'number', description: 'Estimated audience size' },
116
+ niche: { type: 'string', description: 'Content niche or focus area' },
117
+ country: { type: 'string', description: 'Country of operation' },
118
+ affiliateId: { type: 'string', description: 'Unique affiliate identifier' },
119
+ referralCode: { type: 'string', description: 'Unique referral code' },
120
+ trackingLink: { type: 'string', description: 'Affiliate tracking link' },
121
+ commissionRate: { type: 'number', description: 'Commission percentage' },
122
+ commissionType: { type: 'string', description: 'Commission type', examples: ['percentage', 'flat-rate', 'tiered', 'recurring'] },
123
+ cookieDuration: { type: 'number', description: 'Cookie duration in days' },
124
+ payoutThreshold: { type: 'number', description: 'Minimum payout amount' },
125
+ payoutMethod: { type: 'string', description: 'Preferred payout method', examples: ['paypal', 'bank-transfer', 'check', 'crypto', 'gift-card'] },
126
+ payoutDetails: { type: 'object', description: 'Payout account details', optional: true },
127
+ totalClicks: { type: 'number', description: 'Total clicks generated' },
128
+ totalConversions: { type: 'number', description: 'Total conversions' },
129
+ conversionRate: { type: 'number', description: 'Conversion rate' },
130
+ totalRevenue: { type: 'number', description: 'Total revenue generated' },
131
+ totalCommissions: { type: 'number', description: 'Total commissions earned' },
132
+ pendingCommissions: { type: 'number', description: 'Pending commission amount' },
133
+ paidCommissions: { type: 'number', description: 'Total paid commissions' },
134
+ lastReferralDate: { type: 'date', description: 'Date of last referral' },
135
+ lastPayoutDate: { type: 'date', description: 'Date of last payout' },
136
+ joinDate: { type: 'date', description: 'Date joined program' },
137
+ tier: { type: 'string', description: 'Affiliate tier', examples: ['bronze', 'silver', 'gold', 'platinum', 'diamond'] },
138
+ promotionalMaterials: { type: 'boolean', description: 'Has access to promo materials' },
139
+ customLandingPage: { type: 'boolean', description: 'Has custom landing page' },
140
+ notes: { type: 'string', description: 'Internal notes', optional: true },
141
+ tags: { type: 'string[]', description: 'Affiliate tags' },
142
+ metadata: { type: 'object', description: 'Additional metadata', optional: true },
143
+ },
144
+ relationships: {
145
+ referrals: { type: 'lead[]', description: 'Referred leads', backref: 'affiliate' },
146
+ conversions: { type: 'deal[]', description: 'Converted deals', backref: 'affiliate' },
147
+ payouts: { type: 'expense[]', description: 'Commission payouts', backref: 'affiliate' },
148
+ campaigns: { type: 'campaign[]', description: 'Promotional campaigns', backref: 'affiliate' },
149
+ },
150
+ actions: ['create', 'update', 'approve', 'reject', 'activate', 'suspend', 'terminate', 'upgrade', 'downgrade', 'payout', 'track'],
151
+ events: ['created', 'updated', 'approved', 'rejected', 'activated', 'suspended', 'terminated', 'upgraded', 'downgraded', 'paidOut', 'tracked'],
152
+ }
153
+
154
+ export const Partnership: Noun = {
155
+ singular: 'partnership',
156
+ plural: 'partnerships',
157
+ description: 'A formal partnership agreement between organizations',
158
+ properties: {
159
+ name: { type: 'string', description: 'Partnership name' },
160
+ type: { type: 'string', description: 'Type of partnership', examples: ['strategic', 'technology', 'channel', 'co-marketing', 'co-selling', 'integration', 'reseller', 'white-label', 'OEM'] },
161
+ status: { type: 'string', description: 'Partnership status', examples: ['proposed', 'negotiating', 'pending-approval', 'active', 'on-hold', 'expired', 'terminated'] },
162
+ description: { type: 'string', description: 'Partnership description' },
163
+ objectives: { type: 'string[]', description: 'Partnership objectives' },
164
+ startDate: { type: 'date', description: 'Partnership start date' },
165
+ endDate: { type: 'date', description: 'Partnership end date' },
166
+ autoRenew: { type: 'boolean', description: 'Auto-renewal enabled' },
167
+ renewalNoticeDays: { type: 'number', description: 'Days notice required for non-renewal' },
168
+ revenueShare: { type: 'number', description: 'Revenue share percentage' },
169
+ referralFee: { type: 'number', description: 'Referral fee amount or percentage' },
170
+ minimumCommitment: { type: 'number', description: 'Minimum annual commitment' },
171
+ exclusivity: { type: 'boolean', description: 'Exclusive partnership' },
172
+ exclusivityTerms: { type: 'string', description: 'Exclusivity terms', optional: true },
173
+ territories: { type: 'string[]', description: 'Geographic territories' },
174
+ products: { type: 'string[]', description: 'Products covered' },
175
+ useCase: { type: 'string', description: 'Primary use case or focus' },
176
+ targetRevenue: { type: 'number', description: 'Target revenue goal' },
177
+ actualRevenue: { type: 'number', description: 'Actual revenue achieved' },
178
+ targetDeals: { type: 'number', description: 'Target number of deals' },
179
+ actualDeals: { type: 'number', description: 'Actual deals closed' },
180
+ ndaRequired: { type: 'boolean', description: 'NDA required' },
181
+ ndaSigned: { type: 'boolean', description: 'NDA signed' },
182
+ contractSigned: { type: 'boolean', description: 'Contract signed' },
183
+ jointMarketingBudget: { type: 'number', description: 'Joint marketing budget', optional: true },
184
+ coMarketingApproved: { type: 'boolean', description: 'Co-marketing approved' },
185
+ integrationRequired: { type: 'boolean', description: 'Technical integration required' },
186
+ integrationComplete: { type: 'boolean', description: 'Integration completed' },
187
+ internalOwner: { type: 'string', description: 'Internal partnership owner' },
188
+ partnerOwner: { type: 'string', description: 'Partner side owner' },
189
+ executiveSponsor: { type: 'string', description: 'Executive sponsor' },
190
+ healthScore: { type: 'number', description: 'Partnership health score' },
191
+ lastReviewDate: { type: 'date', description: 'Last partnership review' },
192
+ nextReviewDate: { type: 'date', description: 'Next scheduled review' },
193
+ notes: { type: 'string', description: 'Internal notes', optional: true },
194
+ tags: { type: 'string[]', description: 'Partnership tags' },
195
+ metadata: { type: 'object', description: 'Additional metadata', optional: true },
196
+ },
197
+ relationships: {
198
+ partner: { type: 'partner', description: 'Partner organization', backref: 'partnerships', required: true },
199
+ contract: { type: 'contract', description: 'Partnership contract', backref: 'partnership' },
200
+ deals: { type: 'deal[]', description: 'Partnership deals', backref: 'partnership' },
201
+ campaigns: { type: 'campaign[]', description: 'Joint campaigns', backref: 'partnership' },
202
+ integrations: { type: 'integration[]', description: 'Technical integrations', backref: 'partnership' },
203
+ milestones: { type: 'milestone[]', description: 'Partnership milestones', backref: 'partnership' },
204
+ },
205
+ actions: ['create', 'update', 'propose', 'negotiate', 'approve', 'reject', 'activate', 'pause', 'resume', 'extend', 'terminate', 'renew', 'review'],
206
+ events: ['created', 'updated', 'proposed', 'negotiated', 'approved', 'rejected', 'activated', 'paused', 'resumed', 'extended', 'terminated', 'renewed', 'reviewed'],
207
+ }
208
+
209
+ export const Integration: Noun = {
210
+ singular: 'integration',
211
+ plural: 'integrations',
212
+ description: 'A technical integration with a partner or third-party system',
213
+ properties: {
214
+ name: { type: 'string', description: 'Integration name' },
215
+ type: { type: 'string', description: 'Type of integration', examples: ['API', 'webhook', 'SDK', 'embed', 'SSO', 'data-sync', 'marketplace'] },
216
+ status: { type: 'string', description: 'Integration status', examples: ['planning', 'development', 'testing', 'staging', 'live', 'deprecated', 'disabled'] },
217
+ description: { type: 'string', description: 'Integration description' },
218
+ direction: { type: 'string', description: 'Data flow direction', examples: ['inbound', 'outbound', 'bidirectional'] },
219
+ category: { type: 'string', description: 'Integration category', examples: ['CRM', 'ERP', 'marketing', 'analytics', 'payment', 'communication', 'productivity'] },
220
+ authentication: { type: 'string', description: 'Authentication method', examples: ['API-key', 'OAuth2', 'JWT', 'basic', 'certificate', 'SAML'] },
221
+ endpoint: { type: 'string', description: 'API endpoint or URL' },
222
+ version: { type: 'string', description: 'Integration version' },
223
+ documentation: { type: 'string', description: 'Documentation URL' },
224
+ syncFrequency: { type: 'string', description: 'Data sync frequency', examples: ['real-time', 'hourly', 'daily', 'weekly', 'on-demand'] },
225
+ dataMapping: { type: 'object', description: 'Field mapping configuration', optional: true },
226
+ rateLimits: { type: 'object', description: 'Rate limiting configuration', optional: true },
227
+ lastSyncDate: { type: 'date', description: 'Last successful sync' },
228
+ lastSyncStatus: { type: 'string', description: 'Last sync status', examples: ['success', 'partial', 'failed'] },
229
+ errorCount: { type: 'number', description: 'Recent error count' },
230
+ recordsProcessed: { type: 'number', description: 'Total records processed' },
231
+ enabled: { type: 'boolean', description: 'Integration enabled' },
232
+ sandboxAvailable: { type: 'boolean', description: 'Sandbox environment available' },
233
+ productionReady: { type: 'boolean', description: 'Ready for production' },
234
+ maintainer: { type: 'string', description: 'Internal maintainer' },
235
+ supportContact: { type: 'string', description: 'Support contact' },
236
+ launchDate: { type: 'date', description: 'Integration launch date' },
237
+ deprecationDate: { type: 'date', description: 'Planned deprecation date', optional: true },
238
+ notes: { type: 'string', description: 'Internal notes', optional: true },
239
+ tags: { type: 'string[]', description: 'Integration tags' },
240
+ metadata: { type: 'object', description: 'Additional metadata', optional: true },
241
+ },
242
+ relationships: {
243
+ partner: { type: 'partner', description: 'Integration partner', backref: 'integrations' },
244
+ partnership: { type: 'partnership', description: 'Related partnership', backref: 'integrations' },
245
+ product: { type: 'product', description: 'Product integrated', backref: 'integrations' },
246
+ },
247
+ actions: ['create', 'update', 'develop', 'test', 'deploy', 'enable', 'disable', 'sync', 'debug', 'deprecate', 'version'],
248
+ events: ['created', 'updated', 'developed', 'tested', 'deployed', 'enabled', 'disabled', 'synced', 'debugged', 'deprecated', 'versioned'],
249
+ }
250
+
251
+ export const Reseller: Noun = {
252
+ singular: 'reseller',
253
+ plural: 'resellers',
254
+ description: 'A reseller partner who sells products on behalf of the organization',
255
+ properties: {
256
+ name: { type: 'string', description: 'Reseller name' },
257
+ type: { type: 'string', description: 'Type of reseller', examples: ['VAR', 'distributor', 'MSP', 'SI', 'retail', 'online'] },
258
+ tier: { type: 'string', description: 'Reseller tier', examples: ['authorized', 'premier', 'elite', 'master'] },
259
+ status: { type: 'string', description: 'Reseller status', examples: ['prospect', 'onboarding', 'active', 'suspended', 'terminated'] },
260
+ region: { type: 'string', description: 'Primary region' },
261
+ territories: { type: 'string[]', description: 'Authorized territories' },
262
+ verticals: { type: 'string[]', description: 'Industry verticals' },
263
+ products: { type: 'string[]', description: 'Authorized products' },
264
+ discountLevel: { type: 'number', description: 'Discount percentage from list price' },
265
+ margin: { type: 'number', description: 'Expected margin percentage' },
266
+ minimumOrder: { type: 'number', description: 'Minimum order value' },
267
+ creditLimit: { type: 'number', description: 'Credit limit' },
268
+ paymentTerms: { type: 'string', description: 'Payment terms' },
269
+ quota: { type: 'number', description: 'Annual sales quota' },
270
+ yearToDateSales: { type: 'number', description: 'Year to date sales' },
271
+ totalSales: { type: 'number', description: 'Total lifetime sales' },
272
+ dealCount: { type: 'number', description: 'Total deals closed' },
273
+ averageDealSize: { type: 'number', description: 'Average deal size' },
274
+ certifiedReps: { type: 'number', description: 'Number of certified sales reps' },
275
+ technicalCerts: { type: 'number', description: 'Number of technical certifications' },
276
+ enablementComplete: { type: 'boolean', description: 'Enablement training completed' },
277
+ portalAccess: { type: 'boolean', description: 'Has reseller portal access' },
278
+ dealRegistration: { type: 'boolean', description: 'Can register deals' },
279
+ coopFunds: { type: 'number', description: 'Co-op marketing funds available' },
280
+ mdf: { type: 'number', description: 'Market development funds' },
281
+ lastOrderDate: { type: 'date', description: 'Last order date' },
282
+ startDate: { type: 'date', description: 'Partnership start date' },
283
+ renewalDate: { type: 'date', description: 'Next renewal date' },
284
+ notes: { type: 'string', description: 'Internal notes', optional: true },
285
+ tags: { type: 'string[]', description: 'Reseller tags' },
286
+ metadata: { type: 'object', description: 'Additional metadata', optional: true },
287
+ },
288
+ relationships: {
289
+ partner: { type: 'partner', description: 'Parent partner record', backref: 'reseller' },
290
+ deals: { type: 'deal[]', description: 'Reseller deals', backref: 'reseller' },
291
+ orders: { type: 'order[]', description: 'Purchase orders', backref: 'reseller' },
292
+ customers: { type: 'customer[]', description: 'End customers', backref: 'reseller' },
293
+ contacts: { type: 'contact[]', description: 'Reseller contacts', backref: 'reseller' },
294
+ },
295
+ actions: ['create', 'update', 'onboard', 'activate', 'suspend', 'terminate', 'upgrade', 'downgrade', 'certify', 'enable', 'allocateFunds'],
296
+ events: ['created', 'updated', 'onboarded', 'activated', 'suspended', 'terminated', 'upgraded', 'downgraded', 'certified', 'enabled', 'fundsAllocated'],
297
+ }
298
+
299
+ // Export all partnership entities
300
+ export const PartnershipEntities = {
301
+ Partner,
302
+ Vendor,
303
+ Affiliate,
304
+ Partnership,
305
+ Integration,
306
+ Reseller,
307
+ }
308
+
309
+ export default PartnershipEntities
@@ -0,0 +1,307 @@
1
+ import type { Noun } from 'ai-database'
2
+
3
+ /**
4
+ * Planning Entities
5
+ * Issue, Plan - Planning-focused abstractions for tracking work
6
+ *
7
+ * These complement the execution-focused Task in digital-tasks
8
+ * and the project management entities in projects.ts
9
+ *
10
+ * Key distinction:
11
+ * - Task (digital-tasks): Function execution with workers, queues, runtime
12
+ * - Task (projects.ts): Project management work item
13
+ * - Issue (planning.ts): Planning-focused with design, acceptance criteria, notes
14
+ */
15
+
16
+ /**
17
+ * WorkItem - A planning-focused work item (ticket/issue)
18
+ *
19
+ * Models the full lifecycle of work from ideation through completion:
20
+ * - What: title, description
21
+ * - Why: context, business value
22
+ * - How: design (implementation approach)
23
+ * - Done: acceptance criteria
24
+ * - Context: notes (session handoff, progress tracking)
25
+ *
26
+ * This abstraction is backend-agnostic and can be implemented by:
27
+ * - beads (SQLite) - maps to beads Issue
28
+ * - Linear - maps to Linear Issue
29
+ * - GitHub Issues
30
+ * - Jira - maps to Jira Issue/Ticket
31
+ * - etc.
32
+ *
33
+ * Note: Distinct from entities/risk.ts Issue which represents
34
+ * operational/business issues (problems requiring resolution).
35
+ * WorkItem represents planned development work.
36
+ */
37
+ export const WorkItem: Noun = {
38
+ singular: 'workItem',
39
+ plural: 'workItems',
40
+ description: 'A planning-focused work item with design and acceptance criteria',
41
+ properties: {
42
+ // Identity
43
+ id: { type: 'string', description: 'Unique issue ID' },
44
+ title: { type: 'string', description: 'Issue title (concise, action-oriented)' },
45
+
46
+ // What & Why
47
+ description: { type: 'string', description: 'Problem statement - WHY this matters (immutable once set)' },
48
+
49
+ // How
50
+ design: { type: 'string', description: 'Implementation approach - HOW to build (can evolve during work)' },
51
+
52
+ // Done
53
+ acceptanceCriteria: { type: 'string', description: 'Definition of done - WHAT success looks like (markdown checklist)' },
54
+
55
+ // Context
56
+ notes: { type: 'string', description: 'Session context - COMPLETED/IN_PROGRESS/NEXT format for handoff' },
57
+
58
+ // Status
59
+ status: {
60
+ type: 'string',
61
+ description: 'Issue status',
62
+ examples: ['open', 'in_progress', 'blocked', 'closed'],
63
+ },
64
+ priority: {
65
+ type: 'number',
66
+ description: 'Priority level (0=critical, 1=high, 2=normal, 3=low)',
67
+ },
68
+ issueType: {
69
+ type: 'string',
70
+ description: 'Type of issue',
71
+ examples: ['task', 'bug', 'feature', 'epic', 'chore'],
72
+ },
73
+
74
+ // Assignment
75
+ assignee: { type: 'string', description: 'Assigned person or agent', optional: true },
76
+
77
+ // Timing
78
+ createdAt: { type: 'datetime', description: 'When created' },
79
+ updatedAt: { type: 'datetime', description: 'When last updated' },
80
+ closedAt: { type: 'datetime', description: 'When closed', optional: true },
81
+ closeReason: { type: 'string', description: 'Why issue was closed', optional: true },
82
+
83
+ // Estimation
84
+ estimatedMinutes: { type: 'number', description: 'Estimated time in minutes', optional: true },
85
+
86
+ // External references
87
+ externalRef: { type: 'string', description: 'External system reference (PR, commit, etc.)', optional: true },
88
+
89
+ // Compaction (for long-running issues)
90
+ compactionLevel: { type: 'number', description: 'How many times compressed', optional: true },
91
+
92
+ // Metadata
93
+ labels: { type: 'string[]', description: 'Issue labels/tags' },
94
+ metadata: { type: 'object', description: 'Additional metadata', optional: true },
95
+ },
96
+ relationships: {
97
+ // Hierarchy
98
+ parent: { type: 'workItem', description: 'Parent work item (for epics)', backref: 'children' },
99
+ children: { type: 'workItem[]', description: 'Child work items', backref: 'parent' },
100
+
101
+ // Dependencies
102
+ blockedBy: { type: 'workItem[]', description: 'Work items blocking this one', backref: 'blocks' },
103
+ blocks: { type: 'workItem[]', description: 'Work items this one blocks', backref: 'blockedBy' },
104
+ relatedTo: { type: 'workItem[]', description: 'Related work items (soft link)', backref: 'relatedTo' },
105
+ discoveredFrom: { type: 'workItem', description: 'Work item this was discovered from (provenance)', backref: 'discovered' },
106
+ discovered: { type: 'workItem[]', description: 'Work items discovered while working on this', backref: 'discoveredFrom' },
107
+
108
+ // Project context
109
+ project: { type: 'project', description: 'Parent project', backref: 'workItems' },
110
+
111
+ // Plan context
112
+ plan: { type: 'plan', description: 'Parent plan', backref: 'workItems' },
113
+
114
+ // Comments
115
+ comments: { type: 'comment[]', description: 'Work item comments', backref: 'workItem' },
116
+
117
+ // Events
118
+ events: { type: 'event[]', description: 'Work item events (audit trail)', backref: 'workItem' },
119
+ },
120
+ actions: [
121
+ 'create',
122
+ 'update',
123
+ 'assign',
124
+ 'start',
125
+ 'block',
126
+ 'unblock',
127
+ 'close',
128
+ 'reopen',
129
+ 'comment',
130
+ 'link',
131
+ 'unlink',
132
+ ],
133
+ events: [
134
+ 'created',
135
+ 'updated',
136
+ 'assigned',
137
+ 'started',
138
+ 'blocked',
139
+ 'unblocked',
140
+ 'closed',
141
+ 'reopened',
142
+ 'commented',
143
+ 'linked',
144
+ 'unlinked',
145
+ ],
146
+ }
147
+
148
+ /**
149
+ * Comment - A comment on an issue
150
+ */
151
+ export const Comment: Noun = {
152
+ singular: 'comment',
153
+ plural: 'comments',
154
+ description: 'A comment on an issue',
155
+ properties: {
156
+ id: { type: 'string', description: 'Comment ID' },
157
+ text: { type: 'string', description: 'Comment text (markdown)' },
158
+ author: { type: 'string', description: 'Comment author' },
159
+ createdAt: { type: 'datetime', description: 'When created' },
160
+ },
161
+ relationships: {
162
+ workItem: { type: 'workItem', description: 'Parent work item', backref: 'comments', required: true },
163
+ },
164
+ actions: ['create', 'update', 'delete'],
165
+ events: ['created', 'updated', 'deleted'],
166
+ }
167
+
168
+ /**
169
+ * Event - An audit trail event on an issue
170
+ */
171
+ export const Event: Noun = {
172
+ singular: 'event',
173
+ plural: 'events',
174
+ description: 'An audit trail event for issue changes',
175
+ properties: {
176
+ id: { type: 'string', description: 'Event ID' },
177
+ eventType: {
178
+ type: 'string',
179
+ description: 'Type of event',
180
+ examples: [
181
+ 'created',
182
+ 'status_changed',
183
+ 'priority_changed',
184
+ 'assigned',
185
+ 'unassigned',
186
+ 'dependency_added',
187
+ 'dependency_removed',
188
+ 'label_added',
189
+ 'label_removed',
190
+ 'commented',
191
+ ],
192
+ },
193
+ actor: { type: 'string', description: 'Who triggered the event' },
194
+ oldValue: { type: 'string', description: 'Previous value', optional: true },
195
+ newValue: { type: 'string', description: 'New value', optional: true },
196
+ comment: { type: 'string', description: 'Optional comment on the change', optional: true },
197
+ createdAt: { type: 'datetime', description: 'When event occurred' },
198
+ },
199
+ relationships: {
200
+ workItem: { type: 'workItem', description: 'Parent work item', backref: 'events', required: true },
201
+ },
202
+ actions: ['create'],
203
+ events: ['created'],
204
+ }
205
+
206
+ /**
207
+ * WorkItemComment - Alias for Comment (for clarity)
208
+ */
209
+ export const WorkItemComment = Comment
210
+
211
+ /**
212
+ * WorkItemEvent - Alias for Event (for clarity)
213
+ */
214
+ export const WorkItemEvent = Event
215
+
216
+ /**
217
+ * Plan - A high-level planning document that generates issues
218
+ *
219
+ * Bridges Strategy → Plan → Issues → Tasks
220
+ *
221
+ * A Plan captures:
222
+ * - Goals and objectives
223
+ * - Constraints and assumptions
224
+ * - Design decisions
225
+ * - Issue breakdown
226
+ */
227
+ export const Plan: Noun = {
228
+ singular: 'plan',
229
+ plural: 'plans',
230
+ description: 'A high-level planning document that generates issues',
231
+ properties: {
232
+ id: { type: 'string', description: 'Plan ID' },
233
+ title: { type: 'string', description: 'Plan title' },
234
+ description: { type: 'string', description: 'What this plan aims to achieve' },
235
+
236
+ // Goals
237
+ objectives: { type: 'string[]', description: 'Plan objectives' },
238
+ successCriteria: { type: 'string[]', description: 'How we know the plan succeeded' },
239
+
240
+ // Constraints
241
+ constraints: { type: 'string[]', description: 'Constraints to work within' },
242
+ assumptions: { type: 'string[]', description: 'Assumptions made' },
243
+ risks: { type: 'string[]', description: 'Identified risks' },
244
+
245
+ // Design
246
+ approach: { type: 'string', description: 'Overall approach (markdown)' },
247
+ decisions: { type: 'string[]', description: 'Key decisions made' },
248
+ tradeoffs: { type: 'string[]', description: 'Trade-offs considered' },
249
+
250
+ // Status
251
+ status: {
252
+ type: 'string',
253
+ description: 'Plan status',
254
+ examples: ['draft', 'review', 'approved', 'in_progress', 'completed', 'abandoned'],
255
+ },
256
+
257
+ // Timing
258
+ createdAt: { type: 'datetime', description: 'When created' },
259
+ updatedAt: { type: 'datetime', description: 'When last updated' },
260
+ approvedAt: { type: 'datetime', description: 'When approved', optional: true },
261
+ approvedBy: { type: 'string', description: 'Who approved', optional: true },
262
+
263
+ // Metadata
264
+ tags: { type: 'string[]', description: 'Plan tags' },
265
+ metadata: { type: 'object', description: 'Additional metadata', optional: true },
266
+ },
267
+ relationships: {
268
+ // Work items generated from this plan
269
+ workItems: { type: 'workItem[]', description: 'Work items generated from this plan', backref: 'plan' },
270
+
271
+ // Project context
272
+ project: { type: 'project', description: 'Parent project', backref: 'plans' },
273
+
274
+ // Author
275
+ author: { type: 'resource', description: 'Plan author', backref: 'plans' },
276
+ },
277
+ actions: ['create', 'update', 'submit', 'approve', 'reject', 'start', 'complete', 'abandon'],
278
+ events: ['created', 'updated', 'submitted', 'approved', 'rejected', 'started', 'completed', 'abandoned'],
279
+ }
280
+
281
+ /**
282
+ * Dependency types for issue relationships
283
+ */
284
+ export const DependencyTypes = {
285
+ /** Hard blocker - issue A blocks issue B from starting */
286
+ blocks: 'blocks',
287
+ /** Soft link - issues are related but not blocking */
288
+ related: 'related',
289
+ /** Hierarchical - epic/subtask relationship */
290
+ parentChild: 'parent-child',
291
+ /** Provenance - issue B discovered while working on A */
292
+ discoveredFrom: 'discovered-from',
293
+ } as const
294
+
295
+ export type DependencyType = (typeof DependencyTypes)[keyof typeof DependencyTypes]
296
+
297
+ // Export all planning entities
298
+ export const PlanningEntities = {
299
+ WorkItem,
300
+ WorkItemComment,
301
+ WorkItemEvent,
302
+ Comment,
303
+ Event,
304
+ Plan,
305
+ }
306
+
307
+ export default PlanningEntities