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.
- package/.turbo/turbo-build.log +5 -0
- package/CHANGELOG.md +17 -0
- package/IMPLEMENTATION.md +226 -0
- package/README.md +1133 -193
- package/dist/business.d.ts +62 -0
- package/dist/business.d.ts.map +1 -0
- package/dist/business.js +109 -0
- package/dist/business.js.map +1 -0
- package/dist/dollar.d.ts +60 -0
- package/dist/dollar.d.ts.map +1 -0
- package/dist/dollar.js +107 -0
- package/dist/dollar.js.map +1 -0
- package/dist/entities/assets.d.ts +21 -0
- package/dist/entities/assets.d.ts.map +1 -0
- package/dist/entities/assets.js +323 -0
- package/dist/entities/assets.js.map +1 -0
- package/dist/entities/business.d.ts +36 -0
- package/dist/entities/business.d.ts.map +1 -0
- package/dist/entities/business.js +370 -0
- package/dist/entities/business.js.map +1 -0
- package/dist/entities/communication.d.ts +21 -0
- package/dist/entities/communication.d.ts.map +1 -0
- package/dist/entities/communication.js +255 -0
- package/dist/entities/communication.js.map +1 -0
- package/dist/entities/customers.d.ts +58 -0
- package/dist/entities/customers.d.ts.map +1 -0
- package/dist/entities/customers.js +989 -0
- package/dist/entities/customers.js.map +1 -0
- package/dist/entities/financials.d.ts +59 -0
- package/dist/entities/financials.d.ts.map +1 -0
- package/dist/entities/financials.js +932 -0
- package/dist/entities/financials.js.map +1 -0
- package/dist/entities/goals.d.ts +58 -0
- package/dist/entities/goals.d.ts.map +1 -0
- package/dist/entities/goals.js +800 -0
- package/dist/entities/goals.js.map +1 -0
- package/dist/entities/index.d.ts +299 -0
- package/dist/entities/index.d.ts.map +1 -0
- package/dist/entities/index.js +198 -0
- package/dist/entities/index.js.map +1 -0
- package/dist/entities/legal.d.ts +21 -0
- package/dist/entities/legal.d.ts.map +1 -0
- package/dist/entities/legal.js +301 -0
- package/dist/entities/legal.js.map +1 -0
- package/dist/entities/market.d.ts +21 -0
- package/dist/entities/market.d.ts.map +1 -0
- package/dist/entities/market.js +301 -0
- package/dist/entities/market.js.map +1 -0
- package/dist/entities/marketing.d.ts +67 -0
- package/dist/entities/marketing.d.ts.map +1 -0
- package/dist/entities/marketing.js +1157 -0
- package/dist/entities/marketing.js.map +1 -0
- package/dist/entities/offerings.d.ts +51 -0
- package/dist/entities/offerings.d.ts.map +1 -0
- package/dist/entities/offerings.js +727 -0
- package/dist/entities/offerings.js.map +1 -0
- package/dist/entities/operations.d.ts +58 -0
- package/dist/entities/operations.d.ts.map +1 -0
- package/dist/entities/operations.js +787 -0
- package/dist/entities/operations.js.map +1 -0
- package/dist/entities/organization.d.ts +57 -0
- package/dist/entities/organization.d.ts.map +1 -0
- package/dist/entities/organization.js +807 -0
- package/dist/entities/organization.js.map +1 -0
- package/dist/entities/partnerships.d.ts +21 -0
- package/dist/entities/partnerships.d.ts.map +1 -0
- package/dist/entities/partnerships.js +300 -0
- package/dist/entities/partnerships.js.map +1 -0
- package/dist/entities/planning.d.ts +87 -0
- package/dist/entities/planning.d.ts.map +1 -0
- package/dist/entities/planning.js +271 -0
- package/dist/entities/planning.js.map +1 -0
- package/dist/entities/projects.d.ts +25 -0
- package/dist/entities/projects.d.ts.map +1 -0
- package/dist/entities/projects.js +349 -0
- package/dist/entities/projects.js.map +1 -0
- package/dist/entities/risk.d.ts +21 -0
- package/dist/entities/risk.d.ts.map +1 -0
- package/dist/entities/risk.js +293 -0
- package/dist/entities/risk.js.map +1 -0
- package/dist/entities/sales.d.ts +72 -0
- package/dist/entities/sales.d.ts.map +1 -0
- package/dist/entities/sales.js +1248 -0
- package/dist/entities/sales.js.map +1 -0
- package/dist/financials.d.ts +130 -0
- package/dist/financials.d.ts.map +1 -0
- package/dist/financials.js +297 -0
- package/dist/financials.js.map +1 -0
- package/dist/goals.d.ts +87 -0
- package/dist/goals.d.ts.map +1 -0
- package/dist/goals.js +215 -0
- package/dist/goals.js.map +1 -0
- package/dist/index.d.ts +97 -4
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +131 -1079
- package/dist/index.js.map +1 -1
- package/dist/kpis.d.ts +118 -0
- package/dist/kpis.d.ts.map +1 -0
- package/dist/kpis.js +232 -0
- package/dist/kpis.js.map +1 -0
- package/dist/metrics.d.ts +448 -0
- package/dist/metrics.d.ts.map +1 -0
- package/dist/metrics.js +325 -0
- package/dist/metrics.js.map +1 -0
- package/dist/okrs.d.ts +123 -0
- package/dist/okrs.d.ts.map +1 -0
- package/dist/okrs.js +269 -0
- package/dist/okrs.js.map +1 -0
- package/dist/organization.d.ts +585 -0
- package/dist/organization.d.ts.map +1 -0
- package/dist/organization.js +173 -0
- package/dist/organization.js.map +1 -0
- package/dist/process.d.ts +112 -0
- package/dist/process.d.ts.map +1 -0
- package/dist/process.js +241 -0
- package/dist/process.js.map +1 -0
- package/dist/product.d.ts +85 -0
- package/dist/product.d.ts.map +1 -0
- package/dist/product.js +145 -0
- package/dist/product.js.map +1 -0
- package/dist/queries.d.ts +304 -0
- package/dist/queries.d.ts.map +1 -0
- package/dist/queries.js +415 -0
- package/dist/queries.js.map +1 -0
- package/dist/roles.d.ts +340 -0
- package/dist/roles.d.ts.map +1 -0
- package/dist/roles.js +255 -0
- package/dist/roles.js.map +1 -0
- package/dist/service.d.ts +61 -0
- package/dist/service.d.ts.map +1 -0
- package/dist/service.js +140 -0
- package/dist/service.js.map +1 -0
- package/dist/types.d.ts +459 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +5 -0
- package/dist/types.js.map +1 -0
- package/dist/vision.d.ts +38 -0
- package/dist/vision.d.ts.map +1 -0
- package/dist/vision.js +68 -0
- package/dist/vision.js.map +1 -0
- package/dist/workflow.d.ts +115 -0
- package/dist/workflow.d.ts.map +1 -0
- package/dist/workflow.js +247 -0
- package/dist/workflow.js.map +1 -0
- package/examples/basic-usage.ts +307 -0
- package/package.json +19 -60
- package/src/business.ts +121 -0
- package/src/dollar.ts +132 -0
- package/src/entities/assets.ts +332 -0
- package/src/entities/business.ts +406 -0
- package/src/entities/communication.ts +264 -0
- package/src/entities/customers.ts +1072 -0
- package/src/entities/financials.ts +1011 -0
- package/src/entities/goals.ts +871 -0
- package/src/entities/index.ts +383 -0
- package/src/entities/legal.ts +310 -0
- package/src/entities/market.ts +310 -0
- package/src/entities/marketing.ts +1249 -0
- package/src/entities/offerings.ts +789 -0
- package/src/entities/operations.ts +861 -0
- package/src/entities/organization.ts +876 -0
- package/src/entities/partnerships.ts +309 -0
- package/src/entities/planning.ts +307 -0
- package/src/entities/projects.ts +360 -0
- package/src/entities/risk.ts +302 -0
- package/src/entities/sales.ts +1352 -0
- package/src/financials.ts +352 -0
- package/src/goals.ts +250 -0
- package/src/index.test.ts +336 -0
- package/src/index.ts +530 -0
- package/src/kpis.ts +275 -0
- package/src/metrics.ts +825 -0
- package/src/okrs.ts +325 -0
- package/src/organization.ts +909 -0
- package/src/process.ts +272 -0
- package/src/product.ts +178 -0
- package/src/queries.ts +767 -0
- package/src/roles.ts +686 -0
- package/src/service.ts +164 -0
- package/src/types.ts +493 -0
- package/src/vision.ts +88 -0
- package/src/workflow.ts +280 -0
- package/tsconfig.json +9 -0
- package/dist/loaders/index.d.ts +0 -174
- package/dist/loaders/index.js +0 -366
- package/dist/loaders/index.js.map +0 -1
- package/dist/schema/index.d.ts +0 -146
- package/dist/schema/index.js +0 -716
- package/dist/schema/index.js.map +0 -1
- package/dist/types-CJ9eGS_C.d.ts +0 -86
package/CHANGELOG.md
ADDED
|
@@ -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
|
+
```
|