business-as-code 2.1.3 → 2.4.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 (235) hide show
  1. package/.turbo/turbo-build.log +4 -5
  2. package/CHANGELOG.md +53 -0
  3. package/README.md +2 -0
  4. package/dist/dollar.d.ts.map +1 -1
  5. package/dist/dollar.js +2 -2
  6. package/dist/dollar.js.map +1 -1
  7. package/dist/entities/organization.d.ts +4 -0
  8. package/dist/entities/organization.d.ts.map +1 -1
  9. package/dist/entities/organization.js +27 -18
  10. package/dist/entities/organization.js.map +1 -1
  11. package/dist/entities/planning.d.ts +87 -0
  12. package/dist/finance/account.d.ts +44 -0
  13. package/dist/finance/account.d.ts.map +1 -0
  14. package/dist/finance/account.js +6 -0
  15. package/dist/finance/account.js.map +1 -0
  16. package/dist/finance/authority.d.ts +78 -0
  17. package/dist/finance/authority.d.ts.map +1 -0
  18. package/dist/finance/authority.js +27 -0
  19. package/dist/finance/authority.js.map +1 -0
  20. package/dist/finance/card.d.ts +36 -0
  21. package/dist/finance/card.d.ts.map +1 -0
  22. package/dist/finance/card.js +6 -0
  23. package/dist/finance/card.js.map +1 -0
  24. package/dist/finance/identity.d.ts +30 -0
  25. package/dist/finance/identity.d.ts.map +1 -0
  26. package/dist/finance/identity.js +8 -0
  27. package/dist/finance/identity.js.map +1 -0
  28. package/dist/finance/index.d.ts +36 -0
  29. package/dist/finance/index.d.ts.map +1 -0
  30. package/dist/finance/index.js +22 -0
  31. package/dist/finance/index.js.map +1 -0
  32. package/dist/finance/ledger.d.ts +24 -0
  33. package/dist/finance/ledger.d.ts.map +1 -0
  34. package/dist/finance/ledger.js +8 -0
  35. package/dist/finance/ledger.js.map +1 -0
  36. package/dist/finance/merchant.d.ts +129 -0
  37. package/dist/finance/merchant.d.ts.map +1 -0
  38. package/dist/finance/merchant.js +21 -0
  39. package/dist/finance/merchant.js.map +1 -0
  40. package/dist/finance/outcome-contract.d.ts +139 -0
  41. package/dist/finance/outcome-contract.d.ts.map +1 -0
  42. package/dist/finance/outcome-contract.js +27 -0
  43. package/dist/finance/outcome-contract.js.map +1 -0
  44. package/dist/finance/port.d.ts +121 -0
  45. package/dist/finance/port.d.ts.map +1 -0
  46. package/dist/finance/port.js +10 -0
  47. package/dist/finance/port.js.map +1 -0
  48. package/dist/finance/pricing.d.ts +154 -0
  49. package/dist/finance/pricing.d.ts.map +1 -0
  50. package/dist/finance/pricing.js +79 -0
  51. package/dist/finance/pricing.js.map +1 -0
  52. package/dist/finance/proof-predicate.d.ts +92 -0
  53. package/dist/finance/proof-predicate.d.ts.map +1 -0
  54. package/dist/finance/proof-predicate.js +80 -0
  55. package/dist/finance/proof-predicate.js.map +1 -0
  56. package/dist/finance/refund.d.ts +44 -0
  57. package/dist/finance/refund.d.ts.map +1 -0
  58. package/dist/finance/refund.js +41 -0
  59. package/dist/finance/refund.js.map +1 -0
  60. package/dist/finance/sla.d.ts +25 -0
  61. package/dist/finance/sla.d.ts.map +1 -0
  62. package/dist/finance/sla.js +7 -0
  63. package/dist/finance/sla.js.map +1 -0
  64. package/dist/finance/types.d.ts +79 -0
  65. package/dist/finance/types.d.ts.map +1 -0
  66. package/dist/finance/types.js +8 -0
  67. package/dist/{canvas → finance}/types.js.map +1 -1
  68. package/dist/goals.d.ts +19 -0
  69. package/dist/goals.d.ts.map +1 -1
  70. package/dist/goals.js +81 -12
  71. package/dist/goals.js.map +1 -1
  72. package/dist/index.d.ts +12 -8
  73. package/dist/index.d.ts.map +1 -1
  74. package/dist/index.js +19 -7
  75. package/dist/index.js.map +1 -1
  76. package/dist/kpis.d.ts +19 -0
  77. package/dist/kpis.d.ts.map +1 -1
  78. package/dist/kpis.js +71 -6
  79. package/dist/kpis.js.map +1 -1
  80. package/dist/metrics.d.ts.map +1 -1
  81. package/dist/metrics.js +29 -24
  82. package/dist/metrics.js.map +1 -1
  83. package/dist/okrs.d.ts +34 -0
  84. package/dist/okrs.d.ts.map +1 -1
  85. package/dist/okrs.js +135 -13
  86. package/dist/okrs.js.map +1 -1
  87. package/dist/organization.d.ts.map +1 -1
  88. package/dist/organization.js +11 -11
  89. package/dist/organization.js.map +1 -1
  90. package/dist/process.d.ts.map +1 -1
  91. package/dist/process.js +13 -12
  92. package/dist/process.js.map +1 -1
  93. package/dist/product.d.ts.map +1 -1
  94. package/dist/product.js +9 -9
  95. package/dist/product.js.map +1 -1
  96. package/dist/queries.d.ts.map +1 -1
  97. package/dist/queries.js +194 -32
  98. package/dist/queries.js.map +1 -1
  99. package/dist/roles.d.ts +25 -31
  100. package/dist/roles.d.ts.map +1 -1
  101. package/dist/roles.js +37 -10
  102. package/dist/roles.js.map +1 -1
  103. package/dist/workflow.d.ts.map +1 -1
  104. package/dist/workflow.js +13 -12
  105. package/dist/workflow.js.map +1 -1
  106. package/package.json +20 -13
  107. package/src/dollar.ts +5 -2
  108. package/src/entities/organization.ts +31 -18
  109. package/src/finance/account.ts +48 -0
  110. package/src/finance/authority.ts +42 -0
  111. package/src/finance/card.ts +38 -0
  112. package/src/finance/identity.ts +31 -0
  113. package/src/finance/index.ts +117 -0
  114. package/src/finance/ledger.ts +26 -0
  115. package/src/finance/merchant.ts +127 -0
  116. package/src/finance/outcome-contract.ts +157 -0
  117. package/src/finance/port.ts +144 -0
  118. package/src/finance/pricing.ts +197 -0
  119. package/src/finance/proof-predicate.ts +106 -0
  120. package/src/finance/refund.ts +52 -0
  121. package/src/finance/sla.ts +33 -0
  122. package/src/finance/types.ts +75 -0
  123. package/src/goals.ts +78 -12
  124. package/src/index.ts +48 -18
  125. package/src/kpis.ts +62 -8
  126. package/src/metrics.ts +92 -79
  127. package/src/okrs.ts +120 -20
  128. package/src/organization.ts +12 -15
  129. package/src/process.ts +11 -12
  130. package/src/product.ts +8 -9
  131. package/src/queries.ts +238 -75
  132. package/src/roles.ts +62 -61
  133. package/src/workflow.ts +22 -15
  134. package/test/business.test.ts +282 -0
  135. package/test/dollar.test.ts +270 -0
  136. package/test/entities.test.ts +628 -0
  137. package/test/financials.test.ts +539 -0
  138. package/test/goals.test.ts +451 -0
  139. package/{src → test}/index.test.ts +1 -1
  140. package/test/kpis.test.ts +440 -0
  141. package/test/metrics.test.ts +744 -0
  142. package/test/okrs.test.ts +741 -0
  143. package/test/organization.test.ts +548 -0
  144. package/test/process.test.ts +503 -0
  145. package/test/product.test.ts +430 -0
  146. package/test/queries.test.ts +556 -0
  147. package/test/roles.test.ts +546 -0
  148. package/test/service.test.ts +450 -0
  149. package/test/types.test.ts +1141 -0
  150. package/test/vision.test.ts +214 -0
  151. package/test/workflow.test.ts +501 -0
  152. package/vitest.config.ts +47 -0
  153. package/LICENSE +0 -21
  154. package/dist/canvas/activities.d.ts +0 -19
  155. package/dist/canvas/activities.d.ts.map +0 -1
  156. package/dist/canvas/activities.js +0 -20
  157. package/dist/canvas/activities.js.map +0 -1
  158. package/dist/canvas/channels.d.ts +0 -20
  159. package/dist/canvas/channels.d.ts.map +0 -1
  160. package/dist/canvas/channels.js +0 -21
  161. package/dist/canvas/channels.js.map +0 -1
  162. package/dist/canvas/relationships.d.ts +0 -20
  163. package/dist/canvas/relationships.d.ts.map +0 -1
  164. package/dist/canvas/relationships.js +0 -21
  165. package/dist/canvas/relationships.js.map +0 -1
  166. package/dist/canvas/resources.d.ts +0 -20
  167. package/dist/canvas/resources.d.ts.map +0 -1
  168. package/dist/canvas/resources.js +0 -30
  169. package/dist/canvas/resources.js.map +0 -1
  170. package/dist/canvas/revenue.d.ts +0 -22
  171. package/dist/canvas/revenue.d.ts.map +0 -1
  172. package/dist/canvas/revenue.js +0 -30
  173. package/dist/canvas/revenue.js.map +0 -1
  174. package/dist/canvas/segments.d.ts +0 -20
  175. package/dist/canvas/segments.d.ts.map +0 -1
  176. package/dist/canvas/segments.js +0 -28
  177. package/dist/canvas/segments.js.map +0 -1
  178. package/dist/canvas/types.d.ts +0 -232
  179. package/dist/canvas/types.d.ts.map +0 -1
  180. package/dist/canvas/types.js +0 -8
  181. package/dist/canvas/value.d.ts +0 -20
  182. package/dist/canvas/value.d.ts.map +0 -1
  183. package/dist/canvas/value.js +0 -21
  184. package/dist/canvas/value.js.map +0 -1
  185. package/src/business.js +0 -108
  186. package/src/canvas/activities.ts +0 -32
  187. package/src/canvas/canvas.ts +0 -482
  188. package/src/canvas/channels.ts +0 -34
  189. package/src/canvas/costs.ts +0 -43
  190. package/src/canvas/economics.ts +0 -99
  191. package/src/canvas/index.ts +0 -206
  192. package/src/canvas/partnerships.ts +0 -34
  193. package/src/canvas/projections.ts +0 -141
  194. package/src/canvas/relationships.ts +0 -34
  195. package/src/canvas/resources.ts +0 -43
  196. package/src/canvas/revenue.ts +0 -56
  197. package/src/canvas/segments.ts +0 -42
  198. package/src/canvas/types.ts +0 -363
  199. package/src/canvas/value.ts +0 -34
  200. package/src/dollar.js +0 -106
  201. package/src/entities/assets.js +0 -322
  202. package/src/entities/business.js +0 -369
  203. package/src/entities/communication.js +0 -254
  204. package/src/entities/customers.js +0 -988
  205. package/src/entities/financials.js +0 -931
  206. package/src/entities/goals.js +0 -799
  207. package/src/entities/index.js +0 -197
  208. package/src/entities/legal.js +0 -300
  209. package/src/entities/market.js +0 -300
  210. package/src/entities/marketing.js +0 -1156
  211. package/src/entities/offerings.js +0 -726
  212. package/src/entities/operations.js +0 -786
  213. package/src/entities/organization.js +0 -806
  214. package/src/entities/partnerships.js +0 -299
  215. package/src/entities/planning.js +0 -270
  216. package/src/entities/projects.js +0 -348
  217. package/src/entities/risk.js +0 -292
  218. package/src/entities/sales.js +0 -1247
  219. package/src/financials.js +0 -296
  220. package/src/goals.js +0 -214
  221. package/src/index.js +0 -131
  222. package/src/index.test.js +0 -274
  223. package/src/kpis.js +0 -231
  224. package/src/metrics.js +0 -324
  225. package/src/okrs.js +0 -268
  226. package/src/organization.js +0 -172
  227. package/src/process.js +0 -240
  228. package/src/product.js +0 -144
  229. package/src/queries.js +0 -414
  230. package/src/roles.js +0 -254
  231. package/src/service.js +0 -139
  232. package/src/types.js +0 -4
  233. package/src/vision.js +0 -67
  234. package/src/workflow.js +0 -246
  235. package/tests/canvas.test.ts +0 -842
@@ -1,206 +0,0 @@
1
- /**
2
- * Business Model Canvas
3
- *
4
- * A complete implementation of the Business Model Canvas framework
5
- * with types, builder functions, unit economics, and financial projections.
6
- *
7
- * The Business Model Canvas has 9 building blocks:
8
- * 1. Customer Segments - Who are your customers?
9
- * 2. Value Propositions - What value do you deliver?
10
- * 3. Channels - How do you reach customers?
11
- * 4. Customer Relationships - How do you interact with customers?
12
- * 5. Revenue Streams - How do you make money?
13
- * 6. Key Resources - What do you need to operate?
14
- * 7. Key Activities - What do you do?
15
- * 8. Key Partnerships - Who helps you?
16
- * 9. Cost Structure - What are your costs?
17
- *
18
- * @example
19
- * ```ts
20
- * import {
21
- * createCanvas,
22
- * createCustomerSegment,
23
- * createValueProposition,
24
- * createRevenueStream,
25
- * calculateUnitEconomics,
26
- * generateCanvasSummary,
27
- * } from 'business-as-code/canvas'
28
- *
29
- * const canvas = createCanvas({
30
- * name: 'My SaaS Business',
31
- * customerSegments: [
32
- * createCustomerSegment({ name: 'Enterprise', type: 'segmented', size: 10000 }),
33
- * ],
34
- * valuePropositions: [
35
- * createValueProposition({ name: 'AI Automation', benefits: ['Speed', 'Accuracy'] }),
36
- * ],
37
- * // ... other building blocks
38
- * })
39
- *
40
- * const summary = generateCanvasSummary(canvas)
41
- * console.log(summary.projectedAnnualRevenue)
42
- * ```
43
- *
44
- * @packageDocumentation
45
- */
46
-
47
- // =============================================================================
48
- // Types
49
- // =============================================================================
50
-
51
- export type {
52
- // Customer Segments
53
- CustomerSegment,
54
- CustomerSegmentType,
55
-
56
- // Value Propositions
57
- ValueProposition,
58
- ValueType,
59
-
60
- // Channels
61
- Channel,
62
- ChannelType,
63
- ChannelPhase,
64
-
65
- // Customer Relationships
66
- CustomerRelationship,
67
- RelationshipType,
68
-
69
- // Revenue Streams
70
- RevenueStream,
71
- RevenueType,
72
- PricingModel,
73
- PricingTier,
74
-
75
- // Key Resources
76
- KeyResource,
77
- ResourceType,
78
-
79
- // Key Activities
80
- KeyActivity,
81
- ActivityCategory,
82
-
83
- // Key Partnerships
84
- KeyPartnership,
85
- PartnershipType,
86
-
87
- // Cost Structure
88
- CostItem,
89
- CostCategory,
90
-
91
- // Canvas
92
- BusinessModelCanvas,
93
- CanvasValidation,
94
- CanvasSummary,
95
- CanvasStrengthAnalysis,
96
- CanvasGaps,
97
-
98
- // Unit Economics
99
- UnitEconomics,
100
- LTVInput,
101
- CACInput,
102
- UnitEconomicsInput,
103
- Margins,
104
- MarginsInput,
105
-
106
- // Financial Projections
107
- FinancialProjection,
108
- RevenueProjection,
109
- CostProjection,
110
- ProfitabilityProjection,
111
- MonthlyRevenue,
112
- MonthlyCost,
113
- MonthlyProfitability,
114
- RevenueProjectionInput,
115
- CostProjectionInput,
116
- ProfitabilityProjectionInput,
117
- } from './types.js'
118
-
119
- // =============================================================================
120
- // Customer Segments
121
- // =============================================================================
122
-
123
- export { createCustomerSegment, type CreateCustomerSegmentInput } from './segments.js'
124
-
125
- // =============================================================================
126
- // Value Propositions
127
- // =============================================================================
128
-
129
- export { createValueProposition, type CreateValuePropositionInput } from './value.js'
130
-
131
- // =============================================================================
132
- // Channels
133
- // =============================================================================
134
-
135
- export { createChannel, type CreateChannelInput } from './channels.js'
136
-
137
- // =============================================================================
138
- // Customer Relationships
139
- // =============================================================================
140
-
141
- export { createCustomerRelationship, type CreateCustomerRelationshipInput } from './relationships.js'
142
-
143
- // =============================================================================
144
- // Revenue Streams
145
- // =============================================================================
146
-
147
- export { createRevenueStream, type CreateRevenueStreamInput } from './revenue.js'
148
-
149
- // =============================================================================
150
- // Key Resources
151
- // =============================================================================
152
-
153
- export { createKeyResource, type CreateKeyResourceInput } from './resources.js'
154
-
155
- // =============================================================================
156
- // Key Activities
157
- // =============================================================================
158
-
159
- export { createKeyActivity, type CreateKeyActivityInput } from './activities.js'
160
-
161
- // =============================================================================
162
- // Key Partnerships
163
- // =============================================================================
164
-
165
- export { createKeyPartnership, type CreateKeyPartnershipInput } from './partnerships.js'
166
-
167
- // =============================================================================
168
- // Cost Structure
169
- // =============================================================================
170
-
171
- export { createCostItem, type CreateCostItemInput } from './costs.js'
172
-
173
- // =============================================================================
174
- // Unit Economics
175
- // =============================================================================
176
-
177
- export {
178
- calculateLTV,
179
- calculateCAC,
180
- calculateUnitEconomics,
181
- calculateMargins,
182
- } from './economics.js'
183
-
184
- // =============================================================================
185
- // Financial Projections
186
- // =============================================================================
187
-
188
- export {
189
- projectRevenue,
190
- projectCosts,
191
- projectProfitability,
192
- createProjection,
193
- } from './projections.js'
194
-
195
- // =============================================================================
196
- // Canvas Operations
197
- // =============================================================================
198
-
199
- export {
200
- createCanvas,
201
- validateCanvas,
202
- generateCanvasSummary,
203
- analyzeCanvasStrength,
204
- identifyCanvasGaps,
205
- type CreateCanvasInput,
206
- } from './canvas.js'
@@ -1,34 +0,0 @@
1
- /**
2
- * Key Partnerships
3
- *
4
- * Functions for creating and working with key partnerships.
5
- */
6
-
7
- import type { KeyPartnership, PartnershipType } from './types.js'
8
-
9
- export interface CreateKeyPartnershipInput {
10
- name: string
11
- type: PartnershipType
12
- purpose?: string
13
- benefits?: string[]
14
- contractValue?: number
15
- contractTerm?: number
16
- sharedActivities?: string[]
17
- }
18
-
19
- /**
20
- * Create a key partnership
21
- */
22
- export function createKeyPartnership(input: CreateKeyPartnershipInput): KeyPartnership {
23
- const { name, type, purpose, benefits, contractValue, contractTerm, sharedActivities } = input
24
-
25
- return {
26
- name,
27
- type,
28
- purpose,
29
- benefits,
30
- contractValue,
31
- contractTerm,
32
- sharedActivities,
33
- }
34
- }
@@ -1,141 +0,0 @@
1
- /**
2
- * Financial Projections
3
- *
4
- * Functions for projecting revenue, costs, and profitability.
5
- */
6
-
7
- import type {
8
- RevenueProjection,
9
- CostProjection,
10
- ProfitabilityProjection,
11
- MonthlyRevenue,
12
- MonthlyCost,
13
- MonthlyProfitability,
14
- RevenueProjectionInput,
15
- CostProjectionInput,
16
- ProfitabilityProjectionInput,
17
- FinancialProjection,
18
- } from './types.js'
19
-
20
- /**
21
- * Project revenue growth
22
- */
23
- export function projectRevenue(input: RevenueProjectionInput): RevenueProjection {
24
- const { startingMRR, monthlyGrowthRate, months } = input
25
-
26
- const monthlyData: MonthlyRevenue[] = []
27
- let currentMRR = startingMRR
28
-
29
- for (let i = 0; i < months; i++) {
30
- if (i > 0) {
31
- currentMRR = currentMRR * (1 + monthlyGrowthRate)
32
- }
33
-
34
- monthlyData.push({
35
- month: i + 1,
36
- mrr: currentMRR,
37
- arr: currentMRR * 12,
38
- })
39
- }
40
-
41
- const lastMonth = monthlyData[monthlyData.length - 1]
42
-
43
- return {
44
- months: monthlyData,
45
- endingMRR: lastMonth?.mrr ?? 0,
46
- endingARR: lastMonth?.arr ?? 0,
47
- }
48
- }
49
-
50
- /**
51
- * Project costs
52
- *
53
- * Note: fixedCosts is the monthly fixed cost amount
54
- */
55
- export function projectCosts(input: CostProjectionInput): CostProjection {
56
- const { fixedCosts, variableCostPerUser, startingUsers, monthlyUserGrowth, months } = input
57
-
58
- const monthlyData: MonthlyCost[] = []
59
- let currentUsers = startingUsers
60
- let totalCosts = 0
61
-
62
- for (let i = 0; i < months; i++) {
63
- if (i > 0) {
64
- currentUsers = currentUsers * (1 + monthlyUserGrowth)
65
- }
66
-
67
- const variableCosts = currentUsers * variableCostPerUser
68
- const total = fixedCosts + variableCosts
69
-
70
- totalCosts += total
71
-
72
- monthlyData.push({
73
- month: i + 1,
74
- fixedCosts,
75
- variableCosts,
76
- totalCost: total,
77
- })
78
- }
79
-
80
- return {
81
- months: monthlyData,
82
- totalCosts,
83
- }
84
- }
85
-
86
- /**
87
- * Project profitability
88
- */
89
- export function projectProfitability(input: ProfitabilityProjectionInput): ProfitabilityProjection {
90
- const { startingMRR, monthlyGrowthRate, fixedCosts, grossMargin, months } = input
91
-
92
- const monthlyData: MonthlyProfitability[] = []
93
- let currentMRR = startingMRR
94
- let cumulativeProfit = 0
95
- let breakEvenMonth: number | undefined
96
-
97
- for (let i = 0; i < months; i++) {
98
- if (i > 0) {
99
- currentMRR = currentMRR * (1 + monthlyGrowthRate)
100
- }
101
-
102
- const revenue = currentMRR
103
- const grossProfit = revenue * grossMargin
104
- const monthlyFixedCosts = fixedCosts / 12
105
- const profit = grossProfit - monthlyFixedCosts
106
- cumulativeProfit += profit
107
-
108
- if (breakEvenMonth === undefined && cumulativeProfit >= 0) {
109
- breakEvenMonth = i + 1
110
- }
111
-
112
- monthlyData.push({
113
- month: i + 1,
114
- revenue,
115
- costs: monthlyFixedCosts,
116
- profit,
117
- cumulativeProfit,
118
- })
119
- }
120
-
121
- return {
122
- months: monthlyData,
123
- breakEvenMonth,
124
- totalProfit: cumulativeProfit,
125
- }
126
- }
127
-
128
- /**
129
- * Create a comprehensive financial projection
130
- */
131
- export function createProjection(
132
- revenueInput: RevenueProjectionInput,
133
- costInput: CostProjectionInput,
134
- profitInput: ProfitabilityProjectionInput
135
- ): FinancialProjection {
136
- return {
137
- revenue: projectRevenue(revenueInput),
138
- costs: projectCosts(costInput),
139
- profitability: projectProfitability(profitInput),
140
- }
141
- }
@@ -1,34 +0,0 @@
1
- /**
2
- * Customer Relationships
3
- *
4
- * Functions for creating and working with customer relationships.
5
- */
6
-
7
- import type { CustomerRelationship, RelationshipType } from './types.js'
8
-
9
- export interface CreateCustomerRelationshipInput {
10
- name: string
11
- type: RelationshipType
12
- segment?: string
13
- touchFrequency?: string
14
- automationLevel?: number
15
- supportChannels?: string[]
16
- platforms?: string[]
17
- }
18
-
19
- /**
20
- * Create a customer relationship
21
- */
22
- export function createCustomerRelationship(input: CreateCustomerRelationshipInput): CustomerRelationship {
23
- const { name, type, segment, touchFrequency, automationLevel, supportChannels, platforms } = input
24
-
25
- return {
26
- name,
27
- type,
28
- segment,
29
- touchFrequency,
30
- automationLevel,
31
- supportChannels,
32
- platforms,
33
- }
34
- }
@@ -1,43 +0,0 @@
1
- /**
2
- * Key Resources
3
- *
4
- * Functions for creating and working with key resources.
5
- */
6
-
7
- import type { KeyResource, ResourceType } from './types.js'
8
-
9
- export interface CreateKeyResourceInput {
10
- name: string
11
- type: ResourceType
12
- cost?: number
13
- depreciation?: string
14
- protectionType?: string
15
- headcount?: number
16
- averageCost?: number
17
- }
18
-
19
- /**
20
- * Create a key resource
21
- */
22
- export function createKeyResource(input: CreateKeyResourceInput): KeyResource {
23
- const { name, type, cost, depreciation, protectionType, headcount, averageCost } = input
24
-
25
- // Calculate total cost for human resources
26
- let totalCost: number | undefined
27
- if (headcount !== undefined && averageCost !== undefined) {
28
- totalCost = headcount * averageCost
29
- } else if (cost !== undefined) {
30
- totalCost = cost
31
- }
32
-
33
- return {
34
- name,
35
- type,
36
- cost,
37
- depreciation,
38
- protectionType,
39
- headcount,
40
- averageCost,
41
- totalCost,
42
- }
43
- }
@@ -1,56 +0,0 @@
1
- /**
2
- * Revenue Streams
3
- *
4
- * Functions for creating and working with revenue streams.
5
- */
6
-
7
- import type { RevenueStream, RevenueType, PricingModel, PricingTier } from './types.js'
8
-
9
- export interface CreateRevenueStreamInput {
10
- name: string
11
- type: RevenueType
12
- pricingModel: PricingModel
13
- price?: number
14
- billingCycle?: 'monthly' | 'quarterly' | 'annual'
15
- pricePerUnit?: number
16
- unitName?: string
17
- tiers?: PricingTier[]
18
- activeCustomers?: number
19
- }
20
-
21
- /**
22
- * Create a revenue stream
23
- */
24
- export function createRevenueStream(input: CreateRevenueStreamInput): RevenueStream {
25
- const {
26
- name,
27
- type,
28
- pricingModel,
29
- price,
30
- billingCycle,
31
- pricePerUnit,
32
- unitName,
33
- tiers,
34
- activeCustomers,
35
- } = input
36
-
37
- // Calculate annual revenue if we have the required fields
38
- let annualRevenue: number | undefined
39
- if (price !== undefined && activeCustomers !== undefined) {
40
- const multiplier = billingCycle === 'annual' ? 1 : billingCycle === 'quarterly' ? 4 : 12
41
- annualRevenue = price * multiplier * activeCustomers
42
- }
43
-
44
- return {
45
- name,
46
- type,
47
- pricingModel,
48
- price,
49
- billingCycle,
50
- pricePerUnit,
51
- unitName,
52
- tiers,
53
- activeCustomers,
54
- annualRevenue,
55
- }
56
- }
@@ -1,42 +0,0 @@
1
- /**
2
- * Customer Segments
3
- *
4
- * Functions for creating and working with customer segments.
5
- */
6
-
7
- import type { CustomerSegment, CustomerSegmentType } from './types.js'
8
-
9
- export interface CreateCustomerSegmentInput {
10
- name: string
11
- description?: string
12
- type: CustomerSegmentType
13
- characteristics?: string[]
14
- size?: number
15
- revenuePerCustomer?: number
16
- expectedPenetration?: number
17
- }
18
-
19
- /**
20
- * Create a customer segment
21
- */
22
- export function createCustomerSegment(input: CreateCustomerSegmentInput): CustomerSegment {
23
- const { name, description, type, characteristics, size, revenuePerCustomer, expectedPenetration } = input
24
-
25
- // Calculate potential if we have the required fields
26
- let potential: number | undefined
27
- if (size !== undefined && revenuePerCustomer !== undefined) {
28
- const penetration = expectedPenetration ?? 1
29
- potential = size * revenuePerCustomer * penetration
30
- }
31
-
32
- return {
33
- name,
34
- description,
35
- type,
36
- characteristics,
37
- size,
38
- revenuePerCustomer,
39
- expectedPenetration,
40
- potential,
41
- }
42
- }