business-as-code 0.2.1 → 2.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (190) hide show
  1. package/.turbo/turbo-build.log +5 -0
  2. package/CHANGELOG.md +17 -0
  3. package/IMPLEMENTATION.md +226 -0
  4. package/README.md +1133 -193
  5. package/dist/business.d.ts +62 -0
  6. package/dist/business.d.ts.map +1 -0
  7. package/dist/business.js +109 -0
  8. package/dist/business.js.map +1 -0
  9. package/dist/dollar.d.ts +60 -0
  10. package/dist/dollar.d.ts.map +1 -0
  11. package/dist/dollar.js +107 -0
  12. package/dist/dollar.js.map +1 -0
  13. package/dist/entities/assets.d.ts +21 -0
  14. package/dist/entities/assets.d.ts.map +1 -0
  15. package/dist/entities/assets.js +323 -0
  16. package/dist/entities/assets.js.map +1 -0
  17. package/dist/entities/business.d.ts +36 -0
  18. package/dist/entities/business.d.ts.map +1 -0
  19. package/dist/entities/business.js +370 -0
  20. package/dist/entities/business.js.map +1 -0
  21. package/dist/entities/communication.d.ts +21 -0
  22. package/dist/entities/communication.d.ts.map +1 -0
  23. package/dist/entities/communication.js +255 -0
  24. package/dist/entities/communication.js.map +1 -0
  25. package/dist/entities/customers.d.ts +58 -0
  26. package/dist/entities/customers.d.ts.map +1 -0
  27. package/dist/entities/customers.js +989 -0
  28. package/dist/entities/customers.js.map +1 -0
  29. package/dist/entities/financials.d.ts +59 -0
  30. package/dist/entities/financials.d.ts.map +1 -0
  31. package/dist/entities/financials.js +932 -0
  32. package/dist/entities/financials.js.map +1 -0
  33. package/dist/entities/goals.d.ts +58 -0
  34. package/dist/entities/goals.d.ts.map +1 -0
  35. package/dist/entities/goals.js +800 -0
  36. package/dist/entities/goals.js.map +1 -0
  37. package/dist/entities/index.d.ts +299 -0
  38. package/dist/entities/index.d.ts.map +1 -0
  39. package/dist/entities/index.js +198 -0
  40. package/dist/entities/index.js.map +1 -0
  41. package/dist/entities/legal.d.ts +21 -0
  42. package/dist/entities/legal.d.ts.map +1 -0
  43. package/dist/entities/legal.js +301 -0
  44. package/dist/entities/legal.js.map +1 -0
  45. package/dist/entities/market.d.ts +21 -0
  46. package/dist/entities/market.d.ts.map +1 -0
  47. package/dist/entities/market.js +301 -0
  48. package/dist/entities/market.js.map +1 -0
  49. package/dist/entities/marketing.d.ts +67 -0
  50. package/dist/entities/marketing.d.ts.map +1 -0
  51. package/dist/entities/marketing.js +1157 -0
  52. package/dist/entities/marketing.js.map +1 -0
  53. package/dist/entities/offerings.d.ts +51 -0
  54. package/dist/entities/offerings.d.ts.map +1 -0
  55. package/dist/entities/offerings.js +727 -0
  56. package/dist/entities/offerings.js.map +1 -0
  57. package/dist/entities/operations.d.ts +58 -0
  58. package/dist/entities/operations.d.ts.map +1 -0
  59. package/dist/entities/operations.js +787 -0
  60. package/dist/entities/operations.js.map +1 -0
  61. package/dist/entities/organization.d.ts +57 -0
  62. package/dist/entities/organization.d.ts.map +1 -0
  63. package/dist/entities/organization.js +807 -0
  64. package/dist/entities/organization.js.map +1 -0
  65. package/dist/entities/partnerships.d.ts +21 -0
  66. package/dist/entities/partnerships.d.ts.map +1 -0
  67. package/dist/entities/partnerships.js +300 -0
  68. package/dist/entities/partnerships.js.map +1 -0
  69. package/dist/entities/planning.d.ts +87 -0
  70. package/dist/entities/planning.d.ts.map +1 -0
  71. package/dist/entities/planning.js +271 -0
  72. package/dist/entities/planning.js.map +1 -0
  73. package/dist/entities/projects.d.ts +25 -0
  74. package/dist/entities/projects.d.ts.map +1 -0
  75. package/dist/entities/projects.js +349 -0
  76. package/dist/entities/projects.js.map +1 -0
  77. package/dist/entities/risk.d.ts +21 -0
  78. package/dist/entities/risk.d.ts.map +1 -0
  79. package/dist/entities/risk.js +293 -0
  80. package/dist/entities/risk.js.map +1 -0
  81. package/dist/entities/sales.d.ts +72 -0
  82. package/dist/entities/sales.d.ts.map +1 -0
  83. package/dist/entities/sales.js +1248 -0
  84. package/dist/entities/sales.js.map +1 -0
  85. package/dist/financials.d.ts +130 -0
  86. package/dist/financials.d.ts.map +1 -0
  87. package/dist/financials.js +297 -0
  88. package/dist/financials.js.map +1 -0
  89. package/dist/goals.d.ts +87 -0
  90. package/dist/goals.d.ts.map +1 -0
  91. package/dist/goals.js +215 -0
  92. package/dist/goals.js.map +1 -0
  93. package/dist/index.d.ts +97 -4
  94. package/dist/index.d.ts.map +1 -0
  95. package/dist/index.js +131 -1079
  96. package/dist/index.js.map +1 -1
  97. package/dist/kpis.d.ts +118 -0
  98. package/dist/kpis.d.ts.map +1 -0
  99. package/dist/kpis.js +232 -0
  100. package/dist/kpis.js.map +1 -0
  101. package/dist/metrics.d.ts +448 -0
  102. package/dist/metrics.d.ts.map +1 -0
  103. package/dist/metrics.js +325 -0
  104. package/dist/metrics.js.map +1 -0
  105. package/dist/okrs.d.ts +123 -0
  106. package/dist/okrs.d.ts.map +1 -0
  107. package/dist/okrs.js +269 -0
  108. package/dist/okrs.js.map +1 -0
  109. package/dist/organization.d.ts +585 -0
  110. package/dist/organization.d.ts.map +1 -0
  111. package/dist/organization.js +173 -0
  112. package/dist/organization.js.map +1 -0
  113. package/dist/process.d.ts +112 -0
  114. package/dist/process.d.ts.map +1 -0
  115. package/dist/process.js +241 -0
  116. package/dist/process.js.map +1 -0
  117. package/dist/product.d.ts +85 -0
  118. package/dist/product.d.ts.map +1 -0
  119. package/dist/product.js +145 -0
  120. package/dist/product.js.map +1 -0
  121. package/dist/queries.d.ts +304 -0
  122. package/dist/queries.d.ts.map +1 -0
  123. package/dist/queries.js +415 -0
  124. package/dist/queries.js.map +1 -0
  125. package/dist/roles.d.ts +340 -0
  126. package/dist/roles.d.ts.map +1 -0
  127. package/dist/roles.js +255 -0
  128. package/dist/roles.js.map +1 -0
  129. package/dist/service.d.ts +61 -0
  130. package/dist/service.d.ts.map +1 -0
  131. package/dist/service.js +140 -0
  132. package/dist/service.js.map +1 -0
  133. package/dist/types.d.ts +459 -0
  134. package/dist/types.d.ts.map +1 -0
  135. package/dist/types.js +5 -0
  136. package/dist/types.js.map +1 -0
  137. package/dist/vision.d.ts +38 -0
  138. package/dist/vision.d.ts.map +1 -0
  139. package/dist/vision.js +68 -0
  140. package/dist/vision.js.map +1 -0
  141. package/dist/workflow.d.ts +115 -0
  142. package/dist/workflow.d.ts.map +1 -0
  143. package/dist/workflow.js +247 -0
  144. package/dist/workflow.js.map +1 -0
  145. package/examples/basic-usage.ts +307 -0
  146. package/package.json +19 -60
  147. package/src/business.ts +121 -0
  148. package/src/dollar.ts +132 -0
  149. package/src/entities/assets.ts +332 -0
  150. package/src/entities/business.ts +406 -0
  151. package/src/entities/communication.ts +264 -0
  152. package/src/entities/customers.ts +1072 -0
  153. package/src/entities/financials.ts +1011 -0
  154. package/src/entities/goals.ts +871 -0
  155. package/src/entities/index.ts +383 -0
  156. package/src/entities/legal.ts +310 -0
  157. package/src/entities/market.ts +310 -0
  158. package/src/entities/marketing.ts +1249 -0
  159. package/src/entities/offerings.ts +789 -0
  160. package/src/entities/operations.ts +861 -0
  161. package/src/entities/organization.ts +876 -0
  162. package/src/entities/partnerships.ts +309 -0
  163. package/src/entities/planning.ts +307 -0
  164. package/src/entities/projects.ts +360 -0
  165. package/src/entities/risk.ts +302 -0
  166. package/src/entities/sales.ts +1352 -0
  167. package/src/financials.ts +352 -0
  168. package/src/goals.ts +250 -0
  169. package/src/index.test.ts +336 -0
  170. package/src/index.ts +530 -0
  171. package/src/kpis.ts +275 -0
  172. package/src/metrics.ts +825 -0
  173. package/src/okrs.ts +325 -0
  174. package/src/organization.ts +909 -0
  175. package/src/process.ts +272 -0
  176. package/src/product.ts +178 -0
  177. package/src/queries.ts +767 -0
  178. package/src/roles.ts +686 -0
  179. package/src/service.ts +164 -0
  180. package/src/types.ts +493 -0
  181. package/src/vision.ts +88 -0
  182. package/src/workflow.ts +280 -0
  183. package/tsconfig.json +9 -0
  184. package/dist/loaders/index.d.ts +0 -174
  185. package/dist/loaders/index.js +0 -366
  186. package/dist/loaders/index.js.map +0 -1
  187. package/dist/schema/index.d.ts +0 -146
  188. package/dist/schema/index.js +0 -716
  189. package/dist/schema/index.js.map +0 -1
  190. package/dist/types-CJ9eGS_C.d.ts +0 -86
@@ -0,0 +1,5 @@
1
+
2
+ 
3
+ > business-as-code@2.0.1 build /Users/nathanclevenger/projects/primitives.org.ai/packages/business-as-code
4
+ > tsc
5
+
package/CHANGELOG.md ADDED
@@ -0,0 +1,17 @@
1
+ # business-as-code
2
+
3
+ ## 2.0.2
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies
8
+ - ai-functions@2.0.2
9
+ - ai-database@2.0.2
10
+
11
+ ## 2.0.1
12
+
13
+ ### Patch Changes
14
+
15
+ - Updated dependencies
16
+ - ai-database@2.0.1
17
+ - ai-functions@2.0.1
@@ -0,0 +1,226 @@
1
+ # Business-as-Code Implementation
2
+
3
+ ## Overview
4
+
5
+ The `business-as-code` package provides primitives for expressing business logic and processes as code. It includes comprehensive TypeScript types and functions for defining:
6
+
7
+ - Business entities and organizational structures
8
+ - Vision statements and strategic goals
9
+ - Products and services with pricing models
10
+ - Business processes and workflows
11
+ - Key Performance Indicators (KPIs)
12
+ - Objectives and Key Results (OKRs)
13
+ - Financial metrics and calculations
14
+ - Business operations helper ($)
15
+
16
+ ## Package Structure
17
+
18
+ ```
19
+ src/
20
+ ├── index.ts # Main exports
21
+ ├── types.ts # Core TypeScript types (11KB)
22
+ ├── business.ts # Business entity functions
23
+ ├── vision.ts # Vision statement functions
24
+ ├── goals.ts # Goal management functions
25
+ ├── product.ts # Product definition functions
26
+ ├── service.ts # Service definition functions
27
+ ├── process.ts # Business process functions
28
+ ├── workflow.ts # Workflow automation functions
29
+ ├── kpis.ts # KPI tracking functions
30
+ ├── okrs.ts # OKR management functions
31
+ ├── financials.ts # Financial calculations
32
+ ├── dollar.ts # $ business operations helper
33
+ └── index.test.ts # Comprehensive tests (27 tests)
34
+
35
+ examples/
36
+ └── basic-usage.ts # Complete usage example
37
+
38
+ dist/ # Compiled output (52 files)
39
+ ```
40
+
41
+ ## Implementation Details
42
+
43
+ ### Core Types (types.ts)
44
+
45
+ Defines comprehensive TypeScript interfaces for:
46
+ - `BusinessDefinition` - Complete business entity structure
47
+ - `GoalDefinition` - Strategic and operational goals
48
+ - `ProductDefinition` - Product specifications with roadmap
49
+ - `ServiceDefinition` - Service offerings with SLA
50
+ - `ProcessDefinition` - Business process steps and metrics
51
+ - `WorkflowDefinition` - Automated workflow sequences
52
+ - `KPIDefinition` - Key performance indicators
53
+ - `OKRDefinition` - Objectives and key results
54
+ - `FinancialMetrics` - Financial statements and calculations
55
+ - `BusinessOperations` - $ helper interface
56
+
57
+ ### Main Functions
58
+
59
+ 1. **Business()** - Define business entity
60
+ - Organizational structure with departments and teams
61
+ - Mission, values, and metadata
62
+ - Budget and team size tracking
63
+
64
+ 2. **Vision()** - Define vision statement
65
+ - Strategic direction
66
+ - Success indicators
67
+ - Timeframe tracking
68
+
69
+ 3. **Goals()** - Define and track goals
70
+ - Goal categories (strategic, operational, financial, etc.)
71
+ - Progress tracking (0-100%)
72
+ - Dependency management
73
+ - Status tracking (not-started, in-progress, at-risk, completed)
74
+
75
+ 4. **Product()** - Define products
76
+ - Pricing models (one-time, subscription, usage-based, freemium, tiered)
77
+ - Cost of goods sold (COGS)
78
+ - Product roadmap
79
+ - Gross margin calculations
80
+
81
+ 5. **Service()** - Define services
82
+ - Pricing models (hourly, fixed, retainer, value-based)
83
+ - Service level agreements (SLA)
84
+ - Delivery time estimation
85
+
86
+ 6. **Process()** - Define business processes
87
+ - Process steps with automation levels
88
+ - Duration calculations
89
+ - Automation percentage tracking
90
+ - Process metrics
91
+
92
+ 7. **Workflow()** - Define automated workflows
93
+ - Event, schedule, webhook, and manual triggers
94
+ - Action sequences (send, create, update, delete, notify, call, wait)
95
+ - Conditional execution
96
+ - Template variable substitution
97
+
98
+ 8. **kpis()** - Track key performance indicators
99
+ - Categories (financial, customer, operations, people, growth)
100
+ - Target vs. current value tracking
101
+ - Achievement calculations
102
+ - Health score aggregation
103
+
104
+ 9. **okrs()** - Define OKRs
105
+ - Objective statements
106
+ - Key results with progress tracking
107
+ - Confidence scoring
108
+ - Status management
109
+
110
+ 10. **financials()** - Calculate financial metrics
111
+ - Gross profit and margin
112
+ - Operating income and margin
113
+ - Net income and margin
114
+ - EBITDA and margin
115
+ - Burn rate and runway
116
+ - Customer acquisition cost (CAC)
117
+ - Customer lifetime value (LTV)
118
+ - Return on investment (ROI)
119
+
120
+ 11. **$** - Business operations helper
121
+ - Currency formatting
122
+ - Percentage calculations
123
+ - Growth rate calculations
124
+ - Margin calculations
125
+ - ROI calculations
126
+ - LTV/CAC calculations
127
+ - Burn rate and runway
128
+ - Business context management
129
+
130
+ ## Key Features
131
+
132
+ ### Type Safety
133
+ - Comprehensive TypeScript types
134
+ - Full IntelliSense support
135
+ - Compile-time validation
136
+
137
+ ### Validation
138
+ - Input validation for all functions
139
+ - Error messages for invalid data
140
+ - Circular dependency detection (goals)
141
+ - Constraint checking (budgets, progress, etc.)
142
+
143
+ ### Calculations
144
+ - Financial metrics (margins, ROI, etc.)
145
+ - Progress tracking (goals, OKRs)
146
+ - Time-based calculations (duration, runway)
147
+ - Achievement percentages
148
+
149
+ ### Flexibility
150
+ - Optional fields with sensible defaults
151
+ - Metadata support on all entities
152
+ - Extensible interfaces
153
+ - Multiple pricing models
154
+
155
+ ## Test Coverage
156
+
157
+ 27 comprehensive tests covering:
158
+ - Business entity creation and validation
159
+ - Vision statement validation
160
+ - Goal progress tracking and dependencies
161
+ - Product gross margin calculations
162
+ - Service pricing models
163
+ - Process automation tracking
164
+ - Workflow trigger validation
165
+ - KPI target achievement
166
+ - OKR progress calculations
167
+ - Financial metric calculations
168
+ - $ helper utility functions
169
+
170
+ All tests passing ✓
171
+
172
+ ## Build Output
173
+
174
+ Successfully compiled to:
175
+ - JavaScript (ES modules)
176
+ - TypeScript declarations (.d.ts)
177
+ - Source maps (.js.map, .d.ts.map)
178
+
179
+ Total: 52 files in dist/ directory
180
+
181
+ ## Dependencies
182
+
183
+ - `ai-functions` (workspace:*) - For AI integrations
184
+
185
+ ## Next Steps
186
+
187
+ The package is fully implemented and ready for use. Potential enhancements:
188
+
189
+ 1. Add more financial calculations (DCF, NPV, IRR)
190
+ 2. Add forecasting functions
191
+ 3. Add data visualization helpers
192
+ 4. Add export functions (CSV, Excel, PDF)
193
+ 5. Add time-series analysis for KPIs and financials
194
+ 6. Add goal/OKR templates for common scenarios
195
+ 7. Integration with actual data sources
196
+ 8. Reporting and dashboard generation
197
+
198
+ ## Usage Example
199
+
200
+ See `examples/basic-usage.ts` for a complete working example demonstrating all features.
201
+
202
+ ```typescript
203
+ import { Business, Goals, Product, kpis, okrs, financials, $ } from 'business-as-code'
204
+
205
+ // Define business
206
+ const company = Business({ name: 'Acme Corp', ... })
207
+
208
+ // Track goals
209
+ const goals = Goals([...])
210
+
211
+ // Define products
212
+ const product = Product({ name: 'Widget Pro', price: 99, ... })
213
+
214
+ // Track KPIs
215
+ const kpiList = kpis([...])
216
+
217
+ // Define OKRs
218
+ const okrList = okrs([...])
219
+
220
+ // Calculate financials
221
+ const metrics = financials({ revenue: 1000000, ... })
222
+
223
+ // Use $ helper
224
+ console.log($.format(1234.56)) // "$1,234.56"
225
+ console.log($.growth(120, 100)) // 20
226
+ ```