business-as-code 2.1.3 → 2.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (260) hide show
  1. package/CHANGELOG.md +10 -0
  2. package/README.md +2 -0
  3. package/package.json +16 -13
  4. package/src/dollar.ts +5 -2
  5. package/src/entities/organization.ts +31 -18
  6. package/src/goals.ts +78 -12
  7. package/src/index.ts +48 -18
  8. package/src/kpis.ts +62 -8
  9. package/src/metrics.ts +92 -79
  10. package/src/okrs.ts +120 -20
  11. package/src/organization.ts +12 -15
  12. package/src/process.ts +11 -12
  13. package/src/product.ts +8 -9
  14. package/src/queries.ts +238 -75
  15. package/src/roles.ts +62 -61
  16. package/src/workflow.ts +22 -15
  17. package/test/business.test.ts +282 -0
  18. package/test/dollar.test.ts +270 -0
  19. package/test/entities.test.ts +628 -0
  20. package/test/financials.test.ts +539 -0
  21. package/test/goals.test.ts +451 -0
  22. package/{src → test}/index.test.ts +1 -1
  23. package/test/kpis.test.ts +440 -0
  24. package/test/metrics.test.ts +744 -0
  25. package/test/okrs.test.ts +741 -0
  26. package/test/organization.test.ts +548 -0
  27. package/test/process.test.ts +503 -0
  28. package/test/product.test.ts +430 -0
  29. package/test/queries.test.ts +556 -0
  30. package/test/roles.test.ts +546 -0
  31. package/test/service.test.ts +450 -0
  32. package/test/types.test.ts +1141 -0
  33. package/test/vision.test.ts +214 -0
  34. package/test/workflow.test.ts +501 -0
  35. package/vitest.config.ts +47 -0
  36. package/.turbo/turbo-build.log +0 -5
  37. package/LICENSE +0 -21
  38. package/dist/business.d.ts +0 -62
  39. package/dist/business.d.ts.map +0 -1
  40. package/dist/business.js +0 -109
  41. package/dist/business.js.map +0 -1
  42. package/dist/canvas/activities.d.ts +0 -19
  43. package/dist/canvas/activities.d.ts.map +0 -1
  44. package/dist/canvas/activities.js +0 -20
  45. package/dist/canvas/activities.js.map +0 -1
  46. package/dist/canvas/channels.d.ts +0 -20
  47. package/dist/canvas/channels.d.ts.map +0 -1
  48. package/dist/canvas/channels.js +0 -21
  49. package/dist/canvas/channels.js.map +0 -1
  50. package/dist/canvas/relationships.d.ts +0 -20
  51. package/dist/canvas/relationships.d.ts.map +0 -1
  52. package/dist/canvas/relationships.js +0 -21
  53. package/dist/canvas/relationships.js.map +0 -1
  54. package/dist/canvas/resources.d.ts +0 -20
  55. package/dist/canvas/resources.d.ts.map +0 -1
  56. package/dist/canvas/resources.js +0 -30
  57. package/dist/canvas/resources.js.map +0 -1
  58. package/dist/canvas/revenue.d.ts +0 -22
  59. package/dist/canvas/revenue.d.ts.map +0 -1
  60. package/dist/canvas/revenue.js +0 -30
  61. package/dist/canvas/revenue.js.map +0 -1
  62. package/dist/canvas/segments.d.ts +0 -20
  63. package/dist/canvas/segments.d.ts.map +0 -1
  64. package/dist/canvas/segments.js +0 -28
  65. package/dist/canvas/segments.js.map +0 -1
  66. package/dist/canvas/types.d.ts +0 -232
  67. package/dist/canvas/types.d.ts.map +0 -1
  68. package/dist/canvas/types.js +0 -8
  69. package/dist/canvas/types.js.map +0 -1
  70. package/dist/canvas/value.d.ts +0 -20
  71. package/dist/canvas/value.d.ts.map +0 -1
  72. package/dist/canvas/value.js +0 -21
  73. package/dist/canvas/value.js.map +0 -1
  74. package/dist/dollar.d.ts +0 -60
  75. package/dist/dollar.d.ts.map +0 -1
  76. package/dist/dollar.js +0 -107
  77. package/dist/dollar.js.map +0 -1
  78. package/dist/entities/assets.d.ts +0 -21
  79. package/dist/entities/assets.d.ts.map +0 -1
  80. package/dist/entities/assets.js +0 -323
  81. package/dist/entities/assets.js.map +0 -1
  82. package/dist/entities/business.d.ts +0 -36
  83. package/dist/entities/business.d.ts.map +0 -1
  84. package/dist/entities/business.js +0 -370
  85. package/dist/entities/business.js.map +0 -1
  86. package/dist/entities/communication.d.ts +0 -21
  87. package/dist/entities/communication.d.ts.map +0 -1
  88. package/dist/entities/communication.js +0 -255
  89. package/dist/entities/communication.js.map +0 -1
  90. package/dist/entities/customers.d.ts +0 -58
  91. package/dist/entities/customers.d.ts.map +0 -1
  92. package/dist/entities/customers.js +0 -989
  93. package/dist/entities/customers.js.map +0 -1
  94. package/dist/entities/financials.d.ts +0 -59
  95. package/dist/entities/financials.d.ts.map +0 -1
  96. package/dist/entities/financials.js +0 -932
  97. package/dist/entities/financials.js.map +0 -1
  98. package/dist/entities/goals.d.ts +0 -58
  99. package/dist/entities/goals.d.ts.map +0 -1
  100. package/dist/entities/goals.js +0 -800
  101. package/dist/entities/goals.js.map +0 -1
  102. package/dist/entities/index.d.ts +0 -299
  103. package/dist/entities/index.d.ts.map +0 -1
  104. package/dist/entities/index.js +0 -198
  105. package/dist/entities/index.js.map +0 -1
  106. package/dist/entities/legal.d.ts +0 -21
  107. package/dist/entities/legal.d.ts.map +0 -1
  108. package/dist/entities/legal.js +0 -301
  109. package/dist/entities/legal.js.map +0 -1
  110. package/dist/entities/market.d.ts +0 -21
  111. package/dist/entities/market.d.ts.map +0 -1
  112. package/dist/entities/market.js +0 -301
  113. package/dist/entities/market.js.map +0 -1
  114. package/dist/entities/marketing.d.ts +0 -67
  115. package/dist/entities/marketing.d.ts.map +0 -1
  116. package/dist/entities/marketing.js +0 -1157
  117. package/dist/entities/marketing.js.map +0 -1
  118. package/dist/entities/offerings.d.ts +0 -51
  119. package/dist/entities/offerings.d.ts.map +0 -1
  120. package/dist/entities/offerings.js +0 -727
  121. package/dist/entities/offerings.js.map +0 -1
  122. package/dist/entities/operations.d.ts +0 -58
  123. package/dist/entities/operations.d.ts.map +0 -1
  124. package/dist/entities/operations.js +0 -787
  125. package/dist/entities/operations.js.map +0 -1
  126. package/dist/entities/organization.d.ts +0 -57
  127. package/dist/entities/organization.d.ts.map +0 -1
  128. package/dist/entities/organization.js +0 -807
  129. package/dist/entities/organization.js.map +0 -1
  130. package/dist/entities/partnerships.d.ts +0 -21
  131. package/dist/entities/partnerships.d.ts.map +0 -1
  132. package/dist/entities/partnerships.js +0 -300
  133. package/dist/entities/partnerships.js.map +0 -1
  134. package/dist/entities/planning.d.ts +0 -0
  135. package/dist/entities/planning.d.ts.map +0 -1
  136. package/dist/entities/planning.js +0 -271
  137. package/dist/entities/planning.js.map +0 -1
  138. package/dist/entities/projects.d.ts +0 -25
  139. package/dist/entities/projects.d.ts.map +0 -1
  140. package/dist/entities/projects.js +0 -349
  141. package/dist/entities/projects.js.map +0 -1
  142. package/dist/entities/risk.d.ts +0 -21
  143. package/dist/entities/risk.d.ts.map +0 -1
  144. package/dist/entities/risk.js +0 -293
  145. package/dist/entities/risk.js.map +0 -1
  146. package/dist/entities/sales.d.ts +0 -72
  147. package/dist/entities/sales.d.ts.map +0 -1
  148. package/dist/entities/sales.js +0 -1248
  149. package/dist/entities/sales.js.map +0 -1
  150. package/dist/financials.d.ts +0 -130
  151. package/dist/financials.d.ts.map +0 -1
  152. package/dist/financials.js +0 -297
  153. package/dist/financials.js.map +0 -1
  154. package/dist/goals.d.ts +0 -87
  155. package/dist/goals.d.ts.map +0 -1
  156. package/dist/goals.js +0 -215
  157. package/dist/goals.js.map +0 -1
  158. package/dist/index.d.ts +0 -97
  159. package/dist/index.d.ts.map +0 -1
  160. package/dist/index.js +0 -132
  161. package/dist/index.js.map +0 -1
  162. package/dist/kpis.d.ts +0 -118
  163. package/dist/kpis.d.ts.map +0 -1
  164. package/dist/kpis.js +0 -232
  165. package/dist/kpis.js.map +0 -1
  166. package/dist/metrics.d.ts +0 -448
  167. package/dist/metrics.d.ts.map +0 -1
  168. package/dist/metrics.js +0 -325
  169. package/dist/metrics.js.map +0 -1
  170. package/dist/okrs.d.ts +0 -123
  171. package/dist/okrs.d.ts.map +0 -1
  172. package/dist/okrs.js +0 -269
  173. package/dist/okrs.js.map +0 -1
  174. package/dist/organization.d.ts +0 -585
  175. package/dist/organization.d.ts.map +0 -1
  176. package/dist/organization.js +0 -173
  177. package/dist/organization.js.map +0 -1
  178. package/dist/process.d.ts +0 -112
  179. package/dist/process.d.ts.map +0 -1
  180. package/dist/process.js +0 -241
  181. package/dist/process.js.map +0 -1
  182. package/dist/product.d.ts +0 -85
  183. package/dist/product.d.ts.map +0 -1
  184. package/dist/product.js +0 -145
  185. package/dist/product.js.map +0 -1
  186. package/dist/queries.d.ts +0 -304
  187. package/dist/queries.d.ts.map +0 -1
  188. package/dist/queries.js +0 -415
  189. package/dist/queries.js.map +0 -1
  190. package/dist/roles.d.ts +0 -340
  191. package/dist/roles.d.ts.map +0 -1
  192. package/dist/roles.js +0 -255
  193. package/dist/roles.js.map +0 -1
  194. package/dist/service.d.ts +0 -61
  195. package/dist/service.d.ts.map +0 -1
  196. package/dist/service.js +0 -140
  197. package/dist/service.js.map +0 -1
  198. package/dist/types.d.ts +0 -459
  199. package/dist/types.d.ts.map +0 -1
  200. package/dist/types.js +0 -5
  201. package/dist/types.js.map +0 -1
  202. package/dist/vision.d.ts +0 -38
  203. package/dist/vision.d.ts.map +0 -1
  204. package/dist/vision.js +0 -68
  205. package/dist/vision.js.map +0 -1
  206. package/dist/workflow.d.ts +0 -115
  207. package/dist/workflow.d.ts.map +0 -1
  208. package/dist/workflow.js +0 -247
  209. package/dist/workflow.js.map +0 -1
  210. package/src/business.js +0 -108
  211. package/src/canvas/activities.ts +0 -32
  212. package/src/canvas/canvas.ts +0 -482
  213. package/src/canvas/channels.ts +0 -34
  214. package/src/canvas/costs.ts +0 -43
  215. package/src/canvas/economics.ts +0 -99
  216. package/src/canvas/index.ts +0 -206
  217. package/src/canvas/partnerships.ts +0 -34
  218. package/src/canvas/projections.ts +0 -141
  219. package/src/canvas/relationships.ts +0 -34
  220. package/src/canvas/resources.ts +0 -43
  221. package/src/canvas/revenue.ts +0 -56
  222. package/src/canvas/segments.ts +0 -42
  223. package/src/canvas/types.ts +0 -363
  224. package/src/canvas/value.ts +0 -34
  225. package/src/dollar.js +0 -106
  226. package/src/entities/assets.js +0 -322
  227. package/src/entities/business.js +0 -369
  228. package/src/entities/communication.js +0 -254
  229. package/src/entities/customers.js +0 -988
  230. package/src/entities/financials.js +0 -931
  231. package/src/entities/goals.js +0 -799
  232. package/src/entities/index.js +0 -197
  233. package/src/entities/legal.js +0 -300
  234. package/src/entities/market.js +0 -300
  235. package/src/entities/marketing.js +0 -1156
  236. package/src/entities/offerings.js +0 -726
  237. package/src/entities/operations.js +0 -786
  238. package/src/entities/organization.js +0 -806
  239. package/src/entities/partnerships.js +0 -299
  240. package/src/entities/planning.js +0 -270
  241. package/src/entities/projects.js +0 -348
  242. package/src/entities/risk.js +0 -292
  243. package/src/entities/sales.js +0 -1247
  244. package/src/financials.js +0 -296
  245. package/src/goals.js +0 -214
  246. package/src/index.js +0 -131
  247. package/src/index.test.js +0 -274
  248. package/src/kpis.js +0 -231
  249. package/src/metrics.js +0 -324
  250. package/src/okrs.js +0 -268
  251. package/src/organization.js +0 -172
  252. package/src/process.js +0 -240
  253. package/src/product.js +0 -144
  254. package/src/queries.js +0 -414
  255. package/src/roles.js +0 -254
  256. package/src/service.js +0 -139
  257. package/src/types.js +0 -4
  258. package/src/vision.js +0 -67
  259. package/src/workflow.js +0 -246
  260. package/tests/canvas.test.ts +0 -842
@@ -1,842 +0,0 @@
1
- /**
2
- * Business Model Canvas Tests
3
- *
4
- * Phase 1: RED - All tests should FAIL initially
5
- *
6
- * Tests cover the 9 building blocks of the Business Model Canvas:
7
- * 1. Customer Segments
8
- * 2. Value Propositions
9
- * 3. Channels
10
- * 4. Customer Relationships
11
- * 5. Revenue Streams
12
- * 6. Key Resources
13
- * 7. Key Activities
14
- * 8. Key Partnerships
15
- * 9. Cost Structure
16
- *
17
- * Plus: Canvas generation, unit economics, and AI analysis
18
- */
19
-
20
- import { describe, it, expect } from 'vitest'
21
-
22
- // Import from the canvas module (doesn't exist yet - will fail)
23
- import {
24
- // Core Canvas
25
- BusinessModelCanvas,
26
- createCanvas,
27
- validateCanvas,
28
-
29
- // Customer Segments
30
- CustomerSegment,
31
- createCustomerSegment,
32
-
33
- // Value Propositions
34
- ValueProposition,
35
- createValueProposition,
36
-
37
- // Channels
38
- Channel,
39
- createChannel,
40
-
41
- // Customer Relationships
42
- CustomerRelationship,
43
- createCustomerRelationship,
44
-
45
- // Revenue Streams
46
- RevenueStream,
47
- createRevenueStream,
48
-
49
- // Key Resources
50
- KeyResource,
51
- createKeyResource,
52
-
53
- // Key Activities
54
- KeyActivity,
55
- createKeyActivity,
56
-
57
- // Key Partnerships
58
- KeyPartnership,
59
- createKeyPartnership,
60
-
61
- // Cost Structure
62
- CostItem,
63
- createCostItem,
64
-
65
- // Unit Economics
66
- UnitEconomics,
67
- calculateUnitEconomics,
68
- calculateLTV,
69
- calculateCAC,
70
- calculateMargins,
71
-
72
- // Financial Projections
73
- FinancialProjection,
74
- createProjection,
75
- projectRevenue,
76
- projectCosts,
77
- projectProfitability,
78
-
79
- // Canvas Generation & Analysis
80
- generateCanvasSummary,
81
- analyzeCanvasStrength,
82
- identifyCanvasGaps,
83
- } from '../src/canvas/index.js'
84
-
85
- // =============================================================================
86
- // CUSTOMER SEGMENTS (3 tests)
87
- // =============================================================================
88
-
89
- describe('Customer Segments', () => {
90
- it('should create a customer segment with required fields', () => {
91
- const segment = createCustomerSegment({
92
- name: 'Enterprise',
93
- description: 'Large enterprises with 1000+ employees',
94
- type: 'mass-market',
95
- })
96
-
97
- expect(segment.name).toBe('Enterprise')
98
- expect(segment.description).toBe('Large enterprises with 1000+ employees')
99
- expect(segment.type).toBe('mass-market')
100
- })
101
-
102
- it('should support different segment types', () => {
103
- const niche = createCustomerSegment({
104
- name: 'Crypto Startups',
105
- type: 'niche',
106
- characteristics: ['high-growth', 'tech-savvy', 'risk-tolerant'],
107
- })
108
-
109
- const segmented = createCustomerSegment({
110
- name: 'SMB',
111
- type: 'segmented',
112
- size: 50000,
113
- revenuePerCustomer: 500,
114
- })
115
-
116
- expect(niche.type).toBe('niche')
117
- expect(niche.characteristics).toContain('high-growth')
118
- expect(segmented.size).toBe(50000)
119
- expect(segmented.revenuePerCustomer).toBe(500)
120
- })
121
-
122
- it('should calculate segment potential', () => {
123
- const segment = createCustomerSegment({
124
- name: 'Enterprise',
125
- size: 10000,
126
- revenuePerCustomer: 50000,
127
- expectedPenetration: 0.05,
128
- })
129
-
130
- // 10000 * 50000 * 0.05 = 25,000,000
131
- expect(segment.potential).toBe(25000000)
132
- })
133
- })
134
-
135
- // =============================================================================
136
- // VALUE PROPOSITIONS (3 tests)
137
- // =============================================================================
138
-
139
- describe('Value Propositions', () => {
140
- it('should create a value proposition', () => {
141
- const prop = createValueProposition({
142
- name: 'AI-Powered Automation',
143
- description: 'Reduce manual work by 80% with AI',
144
- benefits: ['Time savings', 'Cost reduction', 'Error elimination'],
145
- targetSegments: ['Enterprise', 'SMB'],
146
- })
147
-
148
- expect(prop.name).toBe('AI-Powered Automation')
149
- expect(prop.benefits).toHaveLength(3)
150
- expect(prop.targetSegments).toContain('Enterprise')
151
- })
152
-
153
- it('should support different value types', () => {
154
- const newness = createValueProposition({
155
- name: 'Revolutionary Tech',
156
- valueType: 'newness',
157
- })
158
-
159
- const performance = createValueProposition({
160
- name: '10x Faster',
161
- valueType: 'performance',
162
- quantifiedValue: '10x speed improvement',
163
- })
164
-
165
- const costReduction = createValueProposition({
166
- name: 'Save 50%',
167
- valueType: 'cost-reduction',
168
- quantifiedValue: '50% cost savings',
169
- })
170
-
171
- expect(newness.valueType).toBe('newness')
172
- expect(performance.valueType).toBe('performance')
173
- expect(costReduction.quantifiedValue).toBe('50% cost savings')
174
- })
175
-
176
- it('should link value propositions to segments', () => {
177
- const prop = createValueProposition({
178
- name: 'Enterprise Security',
179
- targetSegments: ['Enterprise'],
180
- segmentFit: {
181
- 'Enterprise': 0.95,
182
- 'SMB': 0.6,
183
- },
184
- })
185
-
186
- expect(prop.segmentFit?.['Enterprise']).toBe(0.95)
187
- expect(prop.segmentFit?.['SMB']).toBe(0.6)
188
- })
189
- })
190
-
191
- // =============================================================================
192
- // CHANNELS (2 tests)
193
- // =============================================================================
194
-
195
- describe('Channels', () => {
196
- it('should create channels with phases', () => {
197
- const channel = createChannel({
198
- name: 'Direct Sales',
199
- type: 'direct',
200
- phases: ['awareness', 'evaluation', 'purchase', 'delivery', 'support'],
201
- costPerAcquisition: 5000,
202
- })
203
-
204
- expect(channel.name).toBe('Direct Sales')
205
- expect(channel.type).toBe('direct')
206
- expect(channel.phases).toContain('purchase')
207
- expect(channel.costPerAcquisition).toBe(5000)
208
- })
209
-
210
- it('should support different channel types', () => {
211
- const partner = createChannel({
212
- name: 'Partner Network',
213
- type: 'partner',
214
- partnerType: 'reseller',
215
- revenueShare: 0.2,
216
- })
217
-
218
- const digital = createChannel({
219
- name: 'Self-Serve',
220
- type: 'digital',
221
- conversionRate: 0.03,
222
- })
223
-
224
- expect(partner.type).toBe('partner')
225
- expect(partner.revenueShare).toBe(0.2)
226
- expect(digital.conversionRate).toBe(0.03)
227
- })
228
- })
229
-
230
- // =============================================================================
231
- // CUSTOMER RELATIONSHIPS (2 tests)
232
- // =============================================================================
233
-
234
- describe('Customer Relationships', () => {
235
- it('should create relationship types', () => {
236
- const relationship = createCustomerRelationship({
237
- name: 'Dedicated Account Management',
238
- type: 'dedicated-assistance',
239
- segment: 'Enterprise',
240
- touchFrequency: 'weekly',
241
- })
242
-
243
- expect(relationship.name).toBe('Dedicated Account Management')
244
- expect(relationship.type).toBe('dedicated-assistance')
245
- expect(relationship.segment).toBe('Enterprise')
246
- })
247
-
248
- it('should support automated relationships', () => {
249
- const automated = createCustomerRelationship({
250
- name: 'Self-Service Portal',
251
- type: 'automated',
252
- automationLevel: 0.9,
253
- supportChannels: ['chat', 'email', 'docs'],
254
- })
255
-
256
- const community = createCustomerRelationship({
257
- name: 'User Community',
258
- type: 'community',
259
- platforms: ['discord', 'forum'],
260
- })
261
-
262
- expect(automated.automationLevel).toBe(0.9)
263
- expect(community.type).toBe('community')
264
- expect(community.platforms).toContain('discord')
265
- })
266
- })
267
-
268
- // =============================================================================
269
- // REVENUE STREAMS (3 tests)
270
- // =============================================================================
271
-
272
- describe('Revenue Streams', () => {
273
- it('should create revenue streams', () => {
274
- const subscription = createRevenueStream({
275
- name: 'SaaS Subscription',
276
- type: 'recurring',
277
- pricingModel: 'subscription',
278
- price: 99,
279
- billingCycle: 'monthly',
280
- })
281
-
282
- expect(subscription.name).toBe('SaaS Subscription')
283
- expect(subscription.type).toBe('recurring')
284
- expect(subscription.price).toBe(99)
285
- expect(subscription.billingCycle).toBe('monthly')
286
- })
287
-
288
- it('should support different pricing mechanisms', () => {
289
- const usageBased = createRevenueStream({
290
- name: 'API Calls',
291
- type: 'recurring',
292
- pricingModel: 'usage-based',
293
- pricePerUnit: 0.001,
294
- unitName: 'API call',
295
- })
296
-
297
- const tiered = createRevenueStream({
298
- name: 'Plans',
299
- type: 'recurring',
300
- pricingModel: 'tiered',
301
- tiers: [
302
- { name: 'Starter', price: 29 },
303
- { name: 'Pro', price: 99 },
304
- { name: 'Enterprise', price: 499 },
305
- ],
306
- })
307
-
308
- expect(usageBased.pricePerUnit).toBe(0.001)
309
- expect(tiered.tiers).toHaveLength(3)
310
- expect(tiered.tiers?.[1]?.price).toBe(99)
311
- })
312
-
313
- it('should calculate annual revenue', () => {
314
- const stream = createRevenueStream({
315
- name: 'SaaS',
316
- type: 'recurring',
317
- pricingModel: 'subscription',
318
- price: 100,
319
- billingCycle: 'monthly',
320
- activeCustomers: 1000,
321
- })
322
-
323
- // 100 * 12 * 1000 = 1,200,000
324
- expect(stream.annualRevenue).toBe(1200000)
325
- })
326
- })
327
-
328
- // =============================================================================
329
- // KEY RESOURCES (2 tests)
330
- // =============================================================================
331
-
332
- describe('Key Resources', () => {
333
- it('should create different resource types', () => {
334
- const physical = createKeyResource({
335
- name: 'Data Centers',
336
- type: 'physical',
337
- cost: 500000,
338
- depreciation: 'monthly',
339
- })
340
-
341
- const intellectual = createKeyResource({
342
- name: 'AI Models',
343
- type: 'intellectual',
344
- protectionType: 'trade-secret',
345
- })
346
-
347
- const human = createKeyResource({
348
- name: 'Engineering Team',
349
- type: 'human',
350
- headcount: 50,
351
- averageCost: 150000,
352
- })
353
-
354
- expect(physical.type).toBe('physical')
355
- expect(intellectual.protectionType).toBe('trade-secret')
356
- expect(human.headcount).toBe(50)
357
- })
358
-
359
- it('should calculate total resource cost', () => {
360
- const resource = createKeyResource({
361
- name: 'Engineering Team',
362
- type: 'human',
363
- headcount: 10,
364
- averageCost: 200000,
365
- })
366
-
367
- // 10 * 200000 = 2,000,000
368
- expect(resource.totalCost).toBe(2000000)
369
- })
370
- })
371
-
372
- // =============================================================================
373
- // KEY ACTIVITIES (2 tests)
374
- // =============================================================================
375
-
376
- describe('Key Activities', () => {
377
- it('should create key activities', () => {
378
- const activity = createKeyActivity({
379
- name: 'Product Development',
380
- category: 'production',
381
- description: 'Building and improving the core product',
382
- resources: ['Engineering Team', 'AI Models'],
383
- })
384
-
385
- expect(activity.name).toBe('Product Development')
386
- expect(activity.category).toBe('production')
387
- expect(activity.resources).toContain('Engineering Team')
388
- })
389
-
390
- it('should support different activity categories', () => {
391
- const problemSolving = createKeyActivity({
392
- name: 'Customer Success',
393
- category: 'problem-solving',
394
- metrics: ['NPS', 'CSAT', 'Churn Rate'],
395
- })
396
-
397
- const platform = createKeyActivity({
398
- name: 'Platform Operations',
399
- category: 'platform',
400
- uptime: 0.999,
401
- })
402
-
403
- expect(problemSolving.category).toBe('problem-solving')
404
- expect(problemSolving.metrics).toContain('NPS')
405
- expect(platform.uptime).toBe(0.999)
406
- })
407
- })
408
-
409
- // =============================================================================
410
- // KEY PARTNERSHIPS (2 tests)
411
- // =============================================================================
412
-
413
- describe('Key Partnerships', () => {
414
- it('should create partnerships', () => {
415
- const partnership = createKeyPartnership({
416
- name: 'AWS',
417
- type: 'strategic-alliance',
418
- purpose: 'Cloud infrastructure and marketplace distribution',
419
- benefits: ['Infrastructure', 'Distribution', 'Credibility'],
420
- })
421
-
422
- expect(partnership.name).toBe('AWS')
423
- expect(partnership.type).toBe('strategic-alliance')
424
- expect(partnership.benefits).toContain('Distribution')
425
- })
426
-
427
- it('should support different partnership types', () => {
428
- const supplier = createKeyPartnership({
429
- name: 'Data Provider',
430
- type: 'buyer-supplier',
431
- contractValue: 100000,
432
- contractTerm: 12,
433
- })
434
-
435
- const coopetition = createKeyPartnership({
436
- name: 'Industry Competitor',
437
- type: 'coopetition',
438
- sharedActivities: ['Standards', 'Lobbying'],
439
- })
440
-
441
- expect(supplier.type).toBe('buyer-supplier')
442
- expect(supplier.contractValue).toBe(100000)
443
- expect(coopetition.sharedActivities).toContain('Standards')
444
- })
445
- })
446
-
447
- // =============================================================================
448
- // COST STRUCTURE (3 tests)
449
- // =============================================================================
450
-
451
- describe('Cost Structure', () => {
452
- it('should create cost items', () => {
453
- const cost = createCostItem({
454
- name: 'Engineering Salaries',
455
- category: 'fixed',
456
- amount: 2000000,
457
- period: 'annual',
458
- })
459
-
460
- expect(cost.name).toBe('Engineering Salaries')
461
- expect(cost.category).toBe('fixed')
462
- expect(cost.amount).toBe(2000000)
463
- })
464
-
465
- it('should support variable costs', () => {
466
- const hosting = createCostItem({
467
- name: 'Cloud Hosting',
468
- category: 'variable',
469
- unitCost: 0.10,
470
- unitName: 'active user',
471
- volumeEstimate: 100000,
472
- })
473
-
474
- // 0.10 * 100000 = 10,000
475
- expect(hosting.estimatedTotal).toBe(10000)
476
- })
477
-
478
- it('should categorize costs by type', () => {
479
- const costs = [
480
- createCostItem({ name: 'Salaries', category: 'fixed', amount: 1000000 }),
481
- createCostItem({ name: 'Marketing', category: 'fixed', amount: 200000 }),
482
- createCostItem({ name: 'Hosting', category: 'variable', unitCost: 0.1, volumeEstimate: 100000 }),
483
- ]
484
-
485
- const fixed = costs.filter(c => c.category === 'fixed')
486
- const variable = costs.filter(c => c.category === 'variable')
487
-
488
- expect(fixed).toHaveLength(2)
489
- expect(variable).toHaveLength(1)
490
- })
491
- })
492
-
493
- // =============================================================================
494
- // UNIT ECONOMICS (3 tests)
495
- // =============================================================================
496
-
497
- describe('Unit Economics', () => {
498
- it('should calculate LTV', () => {
499
- const ltv = calculateLTV({
500
- averageRevenuePerUser: 100,
501
- grossMargin: 0.7,
502
- churnRate: 0.05,
503
- })
504
-
505
- // LTV = ARPU * Gross Margin / Churn Rate
506
- // 100 * 0.7 / 0.05 = 1400
507
- expect(ltv).toBe(1400)
508
- })
509
-
510
- it('should calculate CAC', () => {
511
- const cac = calculateCAC({
512
- marketingSpend: 50000,
513
- salesSpend: 100000,
514
- newCustomers: 500,
515
- })
516
-
517
- // (50000 + 100000) / 500 = 300
518
- expect(cac).toBe(300)
519
- })
520
-
521
- it('should calculate comprehensive unit economics', () => {
522
- const economics = calculateUnitEconomics({
523
- averageRevenuePerUser: 100,
524
- grossMargin: 0.7,
525
- churnRate: 0.05,
526
- marketingSpend: 50000,
527
- salesSpend: 100000,
528
- newCustomers: 500,
529
- })
530
-
531
- expect(economics.ltv).toBe(1400)
532
- expect(economics.cac).toBe(300)
533
- expect(economics.ltvCacRatio).toBeCloseTo(4.67, 1)
534
- expect(economics.paybackMonths).toBeCloseTo(4.29, 1) // CAC / (ARPU * Gross Margin)
535
- })
536
- })
537
-
538
- // =============================================================================
539
- // MARGINS (2 tests)
540
- // =============================================================================
541
-
542
- describe('Margins', () => {
543
- it('should calculate gross margin', () => {
544
- const margins = calculateMargins({
545
- revenue: 1000000,
546
- cogs: 300000,
547
- operatingExpenses: 500000,
548
- })
549
-
550
- expect(margins.grossMargin).toBe(0.7) // (1000000 - 300000) / 1000000
551
- expect(margins.grossProfit).toBe(700000)
552
- })
553
-
554
- it('should calculate operating and net margins', () => {
555
- const margins = calculateMargins({
556
- revenue: 1000000,
557
- cogs: 300000,
558
- operatingExpenses: 500000,
559
- taxes: 40000,
560
- })
561
-
562
- expect(margins.operatingMargin).toBe(0.2) // (1000000 - 300000 - 500000) / 1000000
563
- expect(margins.operatingIncome).toBe(200000)
564
- expect(margins.netMargin).toBe(0.16) // (200000 - 40000) / 1000000
565
- expect(margins.netIncome).toBe(160000)
566
- })
567
- })
568
-
569
- // =============================================================================
570
- // FINANCIAL PROJECTIONS (3 tests)
571
- // =============================================================================
572
-
573
- describe('Financial Projections', () => {
574
- it('should project revenue growth', () => {
575
- const projection = projectRevenue({
576
- startingMRR: 100000,
577
- monthlyGrowthRate: 0.1,
578
- months: 12,
579
- })
580
-
581
- expect(projection.months).toHaveLength(12)
582
- expect(projection.months[0]?.mrr).toBe(100000)
583
- expect(projection.months[11]?.mrr).toBeCloseTo(285311, -2) // 100000 * 1.1^11
584
- expect(projection.endingARR).toBeCloseTo(3423733, -2) // 285311 * 12
585
- })
586
-
587
- it('should project costs', () => {
588
- const projection = projectCosts({
589
- fixedCosts: 500000,
590
- variableCostPerUser: 10,
591
- startingUsers: 1000,
592
- monthlyUserGrowth: 0.1,
593
- months: 12,
594
- })
595
-
596
- expect(projection.months).toHaveLength(12)
597
- expect(projection.months[0]?.totalCost).toBeCloseTo(510000) // 500000 + 1000*10
598
- expect(projection.months[11]?.totalCost).toBeCloseTo(528531, -2) // 500000 + 2853*10
599
- })
600
-
601
- it('should project profitability', () => {
602
- const projection = projectProfitability({
603
- startingMRR: 100000,
604
- monthlyGrowthRate: 0.1,
605
- fixedCosts: 80000,
606
- grossMargin: 0.7,
607
- months: 24,
608
- })
609
-
610
- expect(projection.months).toHaveLength(24)
611
- expect(projection.breakEvenMonth).toBeDefined()
612
- expect(projection.totalProfit).toBeGreaterThan(0)
613
- })
614
- })
615
-
616
- // =============================================================================
617
- // CANVAS GENERATION (3 tests)
618
- // =============================================================================
619
-
620
- describe('Business Model Canvas', () => {
621
- it('should create a complete canvas', () => {
622
- const canvas = createCanvas({
623
- name: 'SaaS Startup',
624
- customerSegments: [
625
- createCustomerSegment({ name: 'Enterprise', type: 'segmented' }),
626
- createCustomerSegment({ name: 'SMB', type: 'mass-market' }),
627
- ],
628
- valuePropositions: [
629
- createValueProposition({ name: 'AI Automation', valueType: 'performance' }),
630
- ],
631
- channels: [
632
- createChannel({ name: 'Direct Sales', type: 'direct' }),
633
- createChannel({ name: 'Self-Serve', type: 'digital' }),
634
- ],
635
- customerRelationships: [
636
- createCustomerRelationship({ name: 'Account Management', type: 'dedicated-assistance' }),
637
- ],
638
- revenueStreams: [
639
- createRevenueStream({ name: 'Subscription', type: 'recurring', pricingModel: 'subscription' }),
640
- ],
641
- keyResources: [
642
- createKeyResource({ name: 'AI Models', type: 'intellectual' }),
643
- createKeyResource({ name: 'Engineering', type: 'human' }),
644
- ],
645
- keyActivities: [
646
- createKeyActivity({ name: 'Product Dev', category: 'production' }),
647
- ],
648
- keyPartnerships: [
649
- createKeyPartnership({ name: 'AWS', type: 'strategic-alliance' }),
650
- ],
651
- costStructure: [
652
- createCostItem({ name: 'Engineering', category: 'fixed', amount: 2000000 }),
653
- ],
654
- })
655
-
656
- expect(canvas.name).toBe('SaaS Startup')
657
- expect(canvas.customerSegments).toHaveLength(2)
658
- expect(canvas.valuePropositions).toHaveLength(1)
659
- expect(canvas.channels).toHaveLength(2)
660
- expect(canvas.revenueStreams).toHaveLength(1)
661
- expect(canvas.keyResources).toHaveLength(2)
662
- })
663
-
664
- it('should validate canvas completeness', () => {
665
- const incomplete = createCanvas({
666
- name: 'Incomplete',
667
- customerSegments: [],
668
- valuePropositions: [],
669
- channels: [],
670
- customerRelationships: [],
671
- revenueStreams: [],
672
- keyResources: [],
673
- keyActivities: [],
674
- keyPartnerships: [],
675
- costStructure: [],
676
- })
677
-
678
- const validation = validateCanvas(incomplete)
679
-
680
- expect(validation.isComplete).toBe(false)
681
- expect(validation.missingBlocks).toContain('customerSegments')
682
- expect(validation.missingBlocks).toContain('valuePropositions')
683
- expect(validation.missingBlocks).toContain('revenueStreams')
684
- })
685
-
686
- it('should generate canvas summary', () => {
687
- const canvas = createCanvas({
688
- name: 'Test Business',
689
- customerSegments: [
690
- createCustomerSegment({ name: 'Enterprise', size: 10000, revenuePerCustomer: 10000 }),
691
- ],
692
- valuePropositions: [
693
- createValueProposition({ name: 'Value', benefits: ['Speed', 'Cost'] }),
694
- ],
695
- channels: [createChannel({ name: 'Direct', type: 'direct' })],
696
- customerRelationships: [createCustomerRelationship({ name: 'Support', type: 'automated' })],
697
- revenueStreams: [
698
- createRevenueStream({ name: 'Sub', type: 'recurring', pricingModel: 'subscription', price: 100, activeCustomers: 1000 }),
699
- ],
700
- keyResources: [createKeyResource({ name: 'Tech', type: 'intellectual' })],
701
- keyActivities: [createKeyActivity({ name: 'Dev', category: 'production' })],
702
- keyPartnerships: [createKeyPartnership({ name: 'Partner', type: 'strategic-alliance' })],
703
- costStructure: [createCostItem({ name: 'Ops', category: 'fixed', amount: 500000 })],
704
- })
705
-
706
- const summary = generateCanvasSummary(canvas)
707
-
708
- expect(summary.totalAddressableMarket).toBe(100000000) // 10000 * 10000
709
- expect(summary.projectedAnnualRevenue).toBe(1200000) // 100 * 12 * 1000
710
- expect(summary.totalAnnualCosts).toBe(500000)
711
- expect(summary.projectedProfit).toBe(700000)
712
- })
713
- })
714
-
715
- // =============================================================================
716
- // CANVAS ANALYSIS (2 tests)
717
- // =============================================================================
718
-
719
- describe('Canvas Analysis', () => {
720
- it('should analyze canvas strength', () => {
721
- const canvas = createCanvas({
722
- name: 'Strong Business',
723
- customerSegments: [
724
- createCustomerSegment({ name: 'Enterprise', size: 10000, revenuePerCustomer: 50000 }),
725
- ],
726
- valuePropositions: [
727
- createValueProposition({ name: 'Unique Value', valueType: 'newness', benefits: ['A', 'B', 'C'] }),
728
- ],
729
- channels: [
730
- createChannel({ name: 'Sales', type: 'direct', costPerAcquisition: 1000 }),
731
- createChannel({ name: 'Marketing', type: 'digital', costPerAcquisition: 100 }),
732
- ],
733
- customerRelationships: [createCustomerRelationship({ name: 'AM', type: 'dedicated-assistance' })],
734
- revenueStreams: [
735
- createRevenueStream({ name: 'Sub', type: 'recurring', pricingModel: 'subscription', price: 1000 }),
736
- ],
737
- keyResources: [
738
- createKeyResource({ name: 'IP', type: 'intellectual' }),
739
- createKeyResource({ name: 'Team', type: 'human', headcount: 20 }),
740
- ],
741
- keyActivities: [createKeyActivity({ name: 'R&D', category: 'production' })],
742
- keyPartnerships: [createKeyPartnership({ name: 'Tech Partner', type: 'strategic-alliance' })],
743
- costStructure: [createCostItem({ name: 'Ops', category: 'fixed', amount: 1000000 })],
744
- })
745
-
746
- const analysis = analyzeCanvasStrength(canvas)
747
-
748
- expect(analysis.overallScore).toBeGreaterThan(0)
749
- expect(analysis.overallScore).toBeLessThanOrEqual(100)
750
- expect(analysis.strengths).toBeDefined()
751
- expect(analysis.weaknesses).toBeDefined()
752
- expect(analysis.blockScores).toHaveProperty('customerSegments')
753
- expect(analysis.blockScores).toHaveProperty('valuePropositions')
754
- })
755
-
756
- it('should identify canvas gaps', () => {
757
- const canvas = createCanvas({
758
- name: 'Gaps Business',
759
- customerSegments: [createCustomerSegment({ name: 'Unknown', type: 'mass-market' })],
760
- valuePropositions: [], // Gap: no value props
761
- channels: [createChannel({ name: 'None', type: 'direct' })],
762
- customerRelationships: [], // Gap: no relationships
763
- revenueStreams: [createRevenueStream({ name: 'Revenue', type: 'one-time', pricingModel: 'fixed' })],
764
- keyResources: [], // Gap: no resources
765
- keyActivities: [createKeyActivity({ name: 'Activity', category: 'production' })],
766
- keyPartnerships: [], // Gap: no partnerships
767
- costStructure: [createCostItem({ name: 'Cost', category: 'fixed', amount: 100000 })],
768
- })
769
-
770
- const gaps = identifyCanvasGaps(canvas)
771
-
772
- expect(gaps.criticalGaps).toContain('valuePropositions')
773
- expect(gaps.warnings).toBeDefined()
774
- expect(gaps.recommendations).toBeDefined()
775
- expect(gaps.recommendations.length).toBeGreaterThan(0)
776
- })
777
- })
778
-
779
- // =============================================================================
780
- // TYPE DEFINITIONS (verify TypeScript types work)
781
- // =============================================================================
782
-
783
- describe('Type Definitions', () => {
784
- it('should export proper TypeScript types', () => {
785
- // These should compile without errors
786
- const segment: CustomerSegment = {
787
- name: 'Test',
788
- type: 'mass-market',
789
- }
790
-
791
- const value: ValueProposition = {
792
- name: 'Test',
793
- benefits: [],
794
- }
795
-
796
- const channel: Channel = {
797
- name: 'Test',
798
- type: 'direct',
799
- }
800
-
801
- const relationship: CustomerRelationship = {
802
- name: 'Test',
803
- type: 'automated',
804
- }
805
-
806
- const revenue: RevenueStream = {
807
- name: 'Test',
808
- type: 'recurring',
809
- pricingModel: 'subscription',
810
- }
811
-
812
- const resource: KeyResource = {
813
- name: 'Test',
814
- type: 'intellectual',
815
- }
816
-
817
- const activity: KeyActivity = {
818
- name: 'Test',
819
- category: 'production',
820
- }
821
-
822
- const partnership: KeyPartnership = {
823
- name: 'Test',
824
- type: 'strategic-alliance',
825
- }
826
-
827
- const cost: CostItem = {
828
- name: 'Test',
829
- category: 'fixed',
830
- }
831
-
832
- expect(segment).toBeDefined()
833
- expect(value).toBeDefined()
834
- expect(channel).toBeDefined()
835
- expect(relationship).toBeDefined()
836
- expect(revenue).toBeDefined()
837
- expect(resource).toBeDefined()
838
- expect(activity).toBeDefined()
839
- expect(partnership).toBeDefined()
840
- expect(cost).toBeDefined()
841
- })
842
- })