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
package/README.md CHANGED
@@ -1,260 +1,1200 @@
1
1
  # business-as-code
2
2
 
3
- [![npm version](https://img.shields.io/npm/v/business-as-code.svg)](https://www.npmjs.com/package/business-as-code)
4
- [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)
3
+ Primitives for expressing business logic, strategy, and operations as code. Define your entire business model—from vision and goals to products, services, processes, KPIs, OKRs, and financials—in a declarative, type-safe way.
5
4
 
6
- > Define, launch, experiment, iterate, and grow your business entirely in code
5
+ ## Installation
7
6
 
8
- ## Overview
7
+ ```bash
8
+ npm install business-as-code
9
+ ```
9
10
 
10
- `business-as-code` provides a schema-first approach to defining business entities. Write your business model in MDX, YAML, or JSON, and use it across different platforms.
11
+ ## Quick Start
11
12
 
12
- ```
13
- business-as-code (portable schema layer)
14
-
15
- ┌───┴───┐
16
- ↓ ↓
17
- Startups.Studio Platform.do
18
- (AI startups) (Enterprise)
13
+ ```typescript
14
+ import { Business, Product, Goals, kpis, okrs, financials, $ } from 'business-as-code'
15
+
16
+ // Define your business
17
+ const company = Business({
18
+ name: 'Acme Corp',
19
+ mission: 'To make widgets accessible to everyone',
20
+ values: ['Innovation', 'Customer Focus', 'Integrity'],
21
+ })
22
+
23
+ // Define products
24
+ const product = Product({
25
+ name: 'Widget Pro',
26
+ pricingModel: 'subscription',
27
+ price: 99,
28
+ cogs: 20,
29
+ })
30
+
31
+ // Track KPIs
32
+ const metrics = kpis([
33
+ {
34
+ name: 'Monthly Recurring Revenue',
35
+ category: 'financial',
36
+ target: 100000,
37
+ current: 85000,
38
+ },
39
+ ])
40
+
41
+ // Use $ helper for calculations
42
+ console.log($.format(1234.56)) // "$1,234.56"
43
+ console.log($.growth(120, 100)) // 20
44
+ console.log($.margin(100, 60)) // 40
19
45
  ```
20
46
 
21
- This is the **schema definition layer** - it defines what your business entities look like. It works alongside runtime packages like [agents.do](https://agents.do), [workflows.do](https://workflows.do), and [humans.do](https://humans.do) which handle the actual business operations.
47
+ ## Core Concepts
22
48
 
23
- ## Installation
49
+ ### Business Entity
24
50
 
25
- ```bash
26
- npm install business-as-code
27
- # or
28
- pnpm add business-as-code
51
+ Define your company with mission, values, and organizational structure:
52
+
53
+ ```typescript
54
+ const company = Business({
55
+ name: 'Acme Corp',
56
+ description: 'Building the future of widgets',
57
+ industry: 'Technology',
58
+ mission: 'To make widgets accessible to everyone',
59
+ values: ['Innovation', 'Customer Focus', 'Integrity'],
60
+ targetMarket: 'SMB and Enterprise',
61
+ foundedAt: new Date('2020-01-01'),
62
+ teamSize: 50,
63
+ structure: {
64
+ departments: [
65
+ {
66
+ name: 'Engineering',
67
+ head: 'Jane Smith',
68
+ members: ['Alice', 'Bob', 'Charlie'],
69
+ budget: 2000000,
70
+ },
71
+ {
72
+ name: 'Sales',
73
+ head: 'John Doe',
74
+ members: ['David', 'Eve'],
75
+ budget: 1000000,
76
+ },
77
+ ],
78
+ teams: [
79
+ {
80
+ name: 'Platform',
81
+ lead: 'Alice',
82
+ objectives: ['Build scalable infrastructure'],
83
+ },
84
+ ],
85
+ },
86
+ })
87
+
88
+ // Helper functions
89
+ import { getTotalBudget, getTotalTeamSize, getDepartment, validateBusiness } from 'business-as-code'
90
+
91
+ const budget = getTotalBudget(company) // 3000000
92
+ const teamSize = getTotalTeamSize(company) // 5 (from department members)
93
+ const engineering = getDepartment(company, 'Engineering')
29
94
  ```
30
95
 
31
- ## Quick Start
96
+ ### Vision
97
+
98
+ Articulate long-term direction with measurable indicators:
32
99
 
33
- ### Use the Default Business Schema
100
+ ```typescript
101
+ const vision = Vision({
102
+ statement: "To become the world's most trusted widget platform",
103
+ timeframe: '5 years',
104
+ successIndicators: [
105
+ '10M+ active users',
106
+ 'Present in 50+ countries',
107
+ 'Industry-leading NPS score',
108
+ '$1B+ annual revenue',
109
+ ],
110
+ })
34
111
 
35
- The package includes a comprehensive default schema with 40+ business entities across 9 domains:
112
+ // Helper functions
113
+ import { checkIndicator, calculateProgress, validateVision } from 'business-as-code'
114
+
115
+ const progress = calculateProgress(vision, {
116
+ 'active_users': 5000000,
117
+ 'countries': 30,
118
+ })
119
+ ```
120
+
121
+ ### Goals
122
+
123
+ Track strategic and operational objectives with dependencies:
36
124
 
37
125
  ```typescript
38
- import { defaultBusinessSchema, getAllNouns } from 'business-as-code'
126
+ const goals = Goals([
127
+ {
128
+ name: 'Launch MVP',
129
+ description: 'Ship minimum viable product to early customers',
130
+ category: 'strategic',
131
+ targetDate: new Date('2024-06-30'),
132
+ owner: 'Product Team',
133
+ metrics: ['User signups', 'Feature completion rate'],
134
+ status: 'in-progress',
135
+ progress: 65,
136
+ },
137
+ {
138
+ name: 'Achieve Product-Market Fit',
139
+ category: 'strategic',
140
+ targetDate: new Date('2024-12-31'),
141
+ status: 'in-progress',
142
+ progress: 30,
143
+ dependencies: ['Launch MVP'], // Depends on MVP goal
144
+ },
145
+ ])
39
146
 
40
- // Get all nouns from the default business schema
41
- const nouns = getAllNouns(defaultBusinessSchema)
42
- console.log(`${nouns.length} nouns loaded`)
147
+ // Helper functions
148
+ import {
149
+ updateProgress,
150
+ markAtRisk,
151
+ complete,
152
+ isOverdue,
153
+ getGoalsByCategory,
154
+ getGoalsByStatus,
155
+ calculateOverallProgress,
156
+ hasCircularDependencies,
157
+ sortByDependencies,
158
+ } from 'business-as-code'
43
159
 
44
- // Access specific noun schemas directly
45
- import { Customers, Products, Invoices, Projects, Teams } from 'business-as-code'
160
+ const strategic = getGoalsByCategory(goals, 'strategic')
161
+ const inProgress = getGoalsByStatus(goals, 'in-progress')
162
+ const progress = calculateOverallProgress(goals) // Average progress
163
+ const sorted = sortByDependencies(goals) // Topological sort
46
164
  ```
47
165
 
48
- ### Define Custom Business in MDX
166
+ ### Products
49
167
 
50
- MDX provides the most expressive way to define business entities with JSX-like syntax:
168
+ Define product offerings with pricing and roadmap:
51
169
 
52
170
  ```typescript
53
- import { loadFromMDX, mergeSchemas, defaultBusinessSchema } from 'business-as-code'
54
-
55
- const mdx = `
56
- <Business name="My SaaS">
57
- <Noun name="Tenant" group="Admin">
58
- <Name text required />
59
- <Subdomain text unique />
60
- <Plan status="free|pro|enterprise" />
61
- <Owner user />
62
- </Noun>
63
-
64
- <Noun name="Feature" group="Product">
65
- <Name text required />
66
- <Description rich />
67
- <Tier status="free|pro|enterprise" />
68
- <Enabled boolean />
69
- </Noun>
70
- </Business>
71
- `
72
-
73
- const customSchema = await loadFromMDX(mdx)
74
- const fullSchema = mergeSchemas(defaultBusinessSchema, customSchema)
171
+ const product = Product({
172
+ name: 'Widget Pro',
173
+ description: 'Enterprise-grade widget management platform',
174
+ category: 'SaaS',
175
+ targetSegment: 'Enterprise',
176
+ valueProposition: 'Reduce widget management costs by 50%',
177
+ pricingModel: 'subscription', // 'one-time' | 'subscription' | 'usage-based' | 'freemium' | 'tiered'
178
+ price: 99,
179
+ currency: 'USD',
180
+ cogs: 20,
181
+ features: [
182
+ 'Unlimited widgets',
183
+ 'Advanced analytics',
184
+ 'API access',
185
+ '24/7 support',
186
+ ],
187
+ roadmap: [
188
+ {
189
+ name: 'Mobile app',
190
+ description: 'Native iOS and Android apps',
191
+ targetDate: new Date('2024-09-01'),
192
+ priority: 'high',
193
+ status: 'in-progress',
194
+ },
195
+ ],
196
+ })
197
+
198
+ // Helper functions
199
+ import {
200
+ calculateGrossMargin,
201
+ calculateGrossProfit,
202
+ getRoadmapByStatus,
203
+ getRoadmapByPriority,
204
+ getOverdueRoadmapItems,
205
+ addFeature,
206
+ removeFeature,
207
+ } from 'business-as-code'
208
+
209
+ const margin = calculateGrossMargin(product) // 79.8%
210
+ const profit = calculateGrossProfit(product) // 79
211
+ const highPriority = getRoadmapByPriority(product.roadmap!, 'high')
75
212
  ```
76
213
 
77
- ### Define Custom Business in YAML
214
+ ### Services
78
215
 
79
- YAML is ideal for configuration files and version control:
216
+ Define professional services with SLAs:
80
217
 
81
218
  ```typescript
82
- import { loadFromYAML } from 'business-as-code'
83
-
84
- const yaml = `
85
- name: My SaaS
86
- version: 1.0.0
87
-
88
- domains:
89
- admin:
90
- - name: Tenant
91
- titleField: name
92
- fields:
93
- name: text required
94
- subdomain: text unique
95
- plan: status:free|pro|enterprise
96
- owner: ref:users
97
-
98
- product:
99
- - name: Feature
100
- titleField: name
101
- fields:
102
- name: text required
103
- description: rich
104
- tier: status:free|pro|enterprise
105
- enabled: boolean
106
- `
107
-
108
- const schema = loadFromYAML(yaml)
219
+ const service = Service({
220
+ name: 'Widget Consulting',
221
+ description: 'Expert widget implementation and optimization',
222
+ category: 'Consulting',
223
+ targetSegment: 'Enterprise',
224
+ valueProposition: 'Get expert help implementing widgets in 2 weeks',
225
+ pricingModel: 'fixed', // 'hourly' | 'fixed' | 'retainer' | 'value-based'
226
+ price: 5000,
227
+ currency: 'USD',
228
+ deliveryTime: '2 weeks',
229
+ sla: {
230
+ uptime: 99.9,
231
+ responseTime: '< 24 hours',
232
+ supportHours: 'Business hours (9-5 EST)',
233
+ penalties: '10% refund per day of delay',
234
+ },
235
+ })
236
+
237
+ // Helper functions
238
+ import {
239
+ calculateHourlyPrice,
240
+ calculateMonthlyRetainer,
241
+ checkSLAUptime,
242
+ parseDeliveryTimeToDays,
243
+ estimateCompletionDate,
244
+ calculateValueBasedPrice,
245
+ } from 'business-as-code'
246
+
247
+ const hourlyRate = calculateHourlyPrice(service, 40) // hours
248
+ const days = parseDeliveryTimeToDays(service) // 14
249
+ const completion = estimateCompletionDate(service) // Date
109
250
  ```
110
251
 
111
- ### Define Custom Business in JSON
252
+ ### Processes
112
253
 
113
- JSON works well for programmatic generation and API responses:
254
+ Define business processes with steps and metrics:
114
255
 
115
256
  ```typescript
116
- import { loadFromJSON } from 'business-as-code'
117
-
118
- const json = {
119
- name: "My SaaS",
120
- version: "1.0.0",
121
- domains: {
122
- admin: [{
123
- name: "Tenant",
124
- titleField: "name",
125
- fields: {
126
- name: "text required",
127
- subdomain: "text unique",
128
- plan: "status:free|pro|enterprise"
129
- }
130
- }]
131
- }
132
- }
133
-
134
- const schema = loadFromJSON(JSON.stringify(json))
257
+ const process = Process({
258
+ name: 'Customer Onboarding',
259
+ description: 'Process for onboarding new customers',
260
+ category: 'core', // 'core' | 'support' | 'management'
261
+ owner: 'Customer Success Team',
262
+ steps: [
263
+ {
264
+ order: 1,
265
+ name: 'Welcome Email',
266
+ description: 'Send personalized welcome email',
267
+ responsible: 'CS Manager',
268
+ duration: '5 minutes',
269
+ automationLevel: 'automated',
270
+ },
271
+ {
272
+ order: 2,
273
+ name: 'Initial Setup Call',
274
+ description: 'Schedule and conduct setup call',
275
+ responsible: 'CS Rep',
276
+ duration: '30 minutes',
277
+ automationLevel: 'manual',
278
+ },
279
+ ],
280
+ inputs: ['Customer Information', 'Subscription Plan'],
281
+ outputs: ['Configured Account', 'Training Materials'],
282
+ metrics: [
283
+ {
284
+ name: 'Time to First Value',
285
+ target: 7,
286
+ current: 5,
287
+ unit: 'days',
288
+ },
289
+ ],
290
+ })
291
+
292
+ // Helper functions
293
+ import {
294
+ getStepsInOrder,
295
+ getStepsByAutomationLevel,
296
+ calculateTotalDuration,
297
+ formatDuration,
298
+ calculateAutomationPercentage,
299
+ getMetric,
300
+ meetsTarget,
301
+ addStep,
302
+ removeStep,
303
+ } from 'business-as-code'
304
+
305
+ const automated = getStepsByAutomationLevel(process.steps!, 'automated')
306
+ const duration = calculateTotalDuration(process) // Total duration
307
+ const automationPct = calculateAutomationPercentage(process) // 50%
135
308
  ```
136
309
 
137
- ## Domains
138
-
139
- The default business schema includes these domains:
140
-
141
- | Domain | Nouns | Description |
142
- |--------|-------|-------------|
143
- | **Admin** | Users, Orgs, ServiceAccounts | System administration |
144
- | **Business** | Businesses, Goals, Metrics, Teams, Processes | Core business entities |
145
- | **Product** | Products, Services, Offers, Prices, Features | Product catalog |
146
- | **Success** | Customers, Contacts, Subscriptions | Customer success |
147
- | **Sales** | Deals, Quotes, Proposals | Sales pipeline |
148
- | **Marketing** | Leads, Brands, Domains, Competitors | Marketing & branding |
149
- | **Work** | Projects, Tasks, Issues, Workflows, Roles, Agents | Work management |
150
- | **Financial** | Invoices, Payments, Refunds, ChartOfAccounts, JournalEntries | Accounting |
151
- | **Communications** | Channels, Messages, Sequences, Templates, Posts | Messaging |
152
-
153
- ## Field Types
154
-
155
- ### Primitive Types
156
- | Type | Description | Example |
157
- |------|-------------|---------|
158
- | `text` | Single-line text | `name: text` |
159
- | `rich` | Rich text / markdown | `description: rich` |
160
- | `number` | Numeric value | `count: number` |
161
- | `boolean` | True/false checkbox | `isActive: boolean` |
162
- | `date` | Date picker | `createdAt: date` |
163
-
164
- ### Semantic Types (with validation)
165
- | Type | Description | Example |
166
- |------|-------------|---------|
167
- | `email` | Email address | `email: email` |
168
- | `url` | Valid URL | `website: url` |
169
- | `phone` | Phone number | `phone: phone` |
170
- | `slug` | URL-safe slug | `slug: slug` |
171
-
172
- ### Business Types
173
- | Type | Description | Example |
174
- |------|-------------|---------|
175
- | `money` | Currency amount | `price: money` |
176
- | `score` | 0-100 value | `health: score` |
177
- | `status:a\|b\|c` | Select options | `status: status:active\|inactive` |
178
-
179
- ### Relationship Types
180
- | Type | Description | Example |
181
- |------|-------------|---------|
182
- | `ref:collection` | Reference to another noun | `customer: ref:customers` |
183
- | `user` | Reference to users | `owner: user` |
184
-
185
- ### Modifiers
186
- | Modifier | Description | Example |
187
- |----------|-------------|---------|
188
- | `required` | Field must have value | `name: text required` |
189
- | `unique` | Value must be unique | `slug: text unique` |
310
+ ### Workflows
190
311
 
191
- ## API Reference
312
+ Define automated sequences triggered by events:
192
313
 
193
- ### Schema Functions
314
+ ```typescript
315
+ const workflow = Workflow({
316
+ name: 'New Customer Welcome',
317
+ description: 'Automated welcome sequence for new customers',
318
+ trigger: {
319
+ type: 'event', // 'event' | 'schedule' | 'webhook' | 'manual'
320
+ event: 'Customer.created',
321
+ },
322
+ actions: [
323
+ {
324
+ order: 1,
325
+ type: 'send',
326
+ description: 'Send welcome email',
327
+ params: {
328
+ template: 'welcome_email',
329
+ to: '{{customer.email}}',
330
+ },
331
+ },
332
+ {
333
+ order: 2,
334
+ type: 'wait',
335
+ description: 'Wait 24 hours',
336
+ params: { duration: '24h' },
337
+ },
338
+ {
339
+ order: 3,
340
+ type: 'create',
341
+ description: 'Create onboarding task',
342
+ params: {
343
+ type: 'Task',
344
+ title: 'Onboard {{customer.name}}',
345
+ assignee: 'customer_success_team',
346
+ },
347
+ condition: '{{customer.plan}} == "enterprise"',
348
+ },
349
+ ],
350
+ })
351
+
352
+ // Helper functions
353
+ import {
354
+ getActionsInOrder,
355
+ getActionsByType,
356
+ getConditionalActions,
357
+ addAction,
358
+ isEventTrigger,
359
+ isScheduleTrigger,
360
+ parseWaitDuration,
361
+ evaluateCondition,
362
+ fillTemplate,
363
+ } from 'business-as-code'
364
+
365
+ const sendActions = getActionsByType(workflow.actions!, 'send')
366
+ const conditional = getConditionalActions(workflow.actions!)
367
+ ```
368
+
369
+ ### KPIs (Key Performance Indicators)
370
+
371
+ Track critical business metrics:
194
372
 
195
373
  ```typescript
374
+ const kpiList = kpis([
375
+ {
376
+ name: 'Monthly Recurring Revenue',
377
+ description: 'Total predictable revenue per month',
378
+ category: 'financial', // 'financial' | 'customer' | 'operations' | 'people' | 'growth'
379
+ unit: 'USD',
380
+ target: 100000,
381
+ current: 85000,
382
+ frequency: 'monthly',
383
+ dataSource: 'Billing System',
384
+ formula: 'SUM(active_subscriptions.price)',
385
+ },
386
+ {
387
+ name: 'Customer Churn Rate',
388
+ category: 'customer',
389
+ unit: 'percent',
390
+ target: 5,
391
+ current: 3.2,
392
+ frequency: 'monthly',
393
+ },
394
+ {
395
+ name: 'Net Promoter Score',
396
+ category: 'customer',
397
+ unit: 'score',
398
+ target: 50,
399
+ current: 48,
400
+ frequency: 'quarterly',
401
+ },
402
+ ])
403
+
404
+ // Helper functions
196
405
  import {
197
- defaultBusinessSchema, // The complete default schema
198
- getAllNouns, // Get all nouns as flat array
199
- getDomainNouns, // Get nouns for a specific domain
200
- getDomains, // Get list of all domain names
201
- findNounBySlug, // Find a noun by its slug
202
- mergeSchemas, // Merge two schemas together
203
- validateSchema, // Validate a schema structure
204
- createMinimalSchema, // Create empty schema scaffold
406
+ calculateAchievement,
407
+ kpiMeetsTarget,
408
+ updateCurrent,
409
+ getKPIsByCategory,
410
+ getKPIsOnTarget,
411
+ getKPIsOffTarget,
412
+ calculateHealthScore,
413
+ groupByCategory,
414
+ calculateVariance,
415
+ formatValue,
205
416
  } from 'business-as-code'
417
+
418
+ const achievement = calculateAchievement(kpiList[0]) // 85%
419
+ const financial = getKPIsByCategory(kpiList, 'financial')
420
+ const onTarget = getKPIsOnTarget(kpiList)
421
+ const healthScore = calculateHealthScore(kpiList) // Overall health
206
422
  ```
207
423
 
208
- ### Loaders
424
+ ### OKRs (Objectives and Key Results)
425
+
426
+ Set and track ambitious goals:
209
427
 
210
428
  ```typescript
429
+ const okrList = okrs([
430
+ {
431
+ objective: 'Achieve Product-Market Fit',
432
+ description: 'Validate that our product solves a real problem',
433
+ period: 'Q2 2024',
434
+ owner: 'CEO',
435
+ keyResults: [
436
+ {
437
+ description: 'Increase Net Promoter Score',
438
+ metric: 'NPS',
439
+ startValue: 40,
440
+ targetValue: 60,
441
+ currentValue: 52,
442
+ unit: 'score',
443
+ },
444
+ {
445
+ description: 'Reduce monthly churn rate',
446
+ metric: 'Churn Rate',
447
+ startValue: 8,
448
+ targetValue: 4,
449
+ currentValue: 5.5,
450
+ unit: 'percent',
451
+ },
452
+ {
453
+ description: 'Achieve customer retention',
454
+ metric: 'Customers with 3+ months',
455
+ startValue: 50,
456
+ targetValue: 200,
457
+ currentValue: 125,
458
+ unit: 'customers',
459
+ },
460
+ ],
461
+ status: 'on-track',
462
+ confidence: 75,
463
+ },
464
+ ])
465
+
466
+ // Helper functions
211
467
  import {
212
- load, // Auto-detect format and load
213
- loadFromMDX, // Load from MDX source
214
- loadFromYAML, // Load from YAML source
215
- loadFromJSON, // Load from JSON source
216
- loadNoun, // Load a single noun definition
217
- loadNouns, // Load multiple noun definitions
468
+ calculateKeyResultProgress,
469
+ calculateOKRProgress,
470
+ calculateConfidence,
471
+ updateKeyResult,
472
+ isKeyResultOnTrack,
473
+ isOKROnTrack,
474
+ getKeyResultsAtRisk,
475
+ getOKRsByOwner,
476
+ getOKRsByPeriod,
477
+ calculateSuccessRate,
478
+ formatKeyResult,
218
479
  } from 'business-as-code'
480
+
481
+ const progress = calculateOKRProgress(okrList[0]) // Average KR progress
482
+ const atRisk = getKeyResultsAtRisk(okrList[0].keyResults!)
483
+ const q2OKRs = getOKRsByPeriod(okrList, 'Q2 2024')
219
484
  ```
220
485
 
221
- ### Serializers
486
+ ### Financials
487
+
488
+ Calculate financial metrics and statements:
222
489
 
223
490
  ```typescript
491
+ const metrics = financials({
492
+ revenue: 1000000,
493
+ cogs: 300000,
494
+ operatingExpenses: 500000,
495
+ currency: 'USD',
496
+ period: 'monthly',
497
+ })
498
+
499
+ // Automatically calculates:
500
+ // - grossProfit: 700000
501
+ // - grossMargin: 70%
502
+ // - operatingIncome: 200000
503
+ // - operatingMargin: 20%
504
+ // - netIncome: 200000
505
+ // - netMargin: 20%
506
+
507
+ // Helper functions
224
508
  import {
225
- serialize, // Serialize schema to YAML or JSON
226
- toYAML, // Serialize to YAML string
227
- toJSON, // Serialize to JSON string
228
- serializeNoun, // Serialize single noun
229
- nounToYAML, // Noun to YAML
230
- nounToJSON, // Noun to JSON
509
+ calculateGrossMargin,
510
+ calculateOperatingMargin,
511
+ calculateNetMargin,
512
+ calculateEBITDAMargin,
513
+ calculateBurnRate,
514
+ calculateRunway,
515
+ calculateCAC,
516
+ calculateLTV,
517
+ calculateLTVtoCAC,
518
+ calculatePaybackPeriod,
519
+ calculateARR,
520
+ calculateMRR,
521
+ calculateGrowthRate,
522
+ calculateCAGR,
523
+ calculateROI,
524
+ calculateROE,
525
+ calculateROA,
526
+ calculateQuickRatio,
527
+ calculateCurrentRatio,
528
+ calculateDebtToEquity,
529
+ formatCurrency,
530
+ createStatement,
531
+ compareMetrics,
231
532
  } from 'business-as-code'
533
+
534
+ // SaaS metrics
535
+ const mrr = calculateMRR(subscriptions)
536
+ const arr = calculateARR(mrr)
537
+ const ltv = calculateLTV(avgRevenue, churnRate)
538
+ const cac = calculateCAC(marketingSpend, newCustomers)
539
+ const ltvCacRatio = calculateLTVtoCAC(ltv, cac)
540
+
541
+ // Startup metrics
542
+ const burnRate = calculateBurnRate(cashStart, cashEnd, months)
543
+ const runway = calculateRunway(cash, burnRate)
544
+ const growth = calculateGrowthRate(current, previous)
232
545
  ```
233
546
 
547
+ ### $ Helper
548
+
549
+ Convenient helper for common business calculations:
550
+
551
+ ```typescript
552
+ import { $ } from 'business-as-code'
553
+
554
+ // Currency formatting
555
+ $.format(1234.56) // "$1,234.56"
556
+ $.format(1234.56, 'EUR') // "€1,234.56"
557
+
558
+ // Percentages
559
+ $.percent(25, 100) // 25
560
+
561
+ // Growth
562
+ $.growth(120, 100) // 20 (20% growth)
563
+
564
+ // Margins
565
+ $.margin(100, 60) // 40 (40% margin)
566
+
567
+ // ROI
568
+ $.roi(150, 100) // 50 (50% ROI)
569
+
570
+ // Customer metrics
571
+ $.ltv(100, 12, 24) // Lifetime value
572
+ $.cac(10000, 100) // Customer acquisition cost (100)
573
+
574
+ // Startup metrics
575
+ $.burnRate(100000, 70000, 3) // Monthly burn rate (10000)
576
+ $.runway(100000, 10000) // Runway in months (10)
577
+
578
+ // Context management
579
+ $.context // Access business context
580
+ $.log('event', data) // Log business event
581
+ ```
582
+
583
+ ### Context Management
584
+
585
+ Share business context across your application:
586
+
587
+ ```typescript
588
+ import { updateContext, getContext, resetContext } from 'business-as-code'
589
+
590
+ // Set context
591
+ updateContext({
592
+ business: company,
593
+ goals: goals,
594
+ kpis: kpiList,
595
+ financials: metrics,
596
+ })
597
+
598
+ // Access context
599
+ const ctx = getContext()
600
+ console.log(ctx.business?.name)
601
+
602
+ // Reset context
603
+ resetContext()
604
+ ```
605
+
606
+ ## API Reference
607
+
608
+ ### Entity Functions
609
+
610
+ | Function | Description |
611
+ |----------|-------------|
612
+ | `Business(def)` | Create a business entity |
613
+ | `Vision(def)` | Define business vision |
614
+ | `Goals(defs)` | Create goal list |
615
+ | `Goal(def)` | Create single goal |
616
+ | `Product(def)` | Define a product |
617
+ | `Service(def)` | Define a service |
618
+ | `Process(def)` | Define a business process |
619
+ | `Workflow(def)` | Define an automated workflow |
620
+ | `kpis(defs)` | Create KPI list |
621
+ | `kpi(def)` | Create single KPI |
622
+ | `okrs(defs)` | Create OKR list |
623
+ | `okr(def)` | Create single OKR |
624
+ | `financials(data)` | Calculate financial metrics |
625
+
626
+ ### $ Helper Methods
627
+
628
+ | Method | Description |
629
+ |--------|-------------|
630
+ | `$.format(amount, currency?)` | Format as currency |
631
+ | `$.percent(value, total)` | Calculate percentage |
632
+ | `$.growth(current, previous)` | Calculate growth rate |
633
+ | `$.margin(revenue, cost)` | Calculate margin |
634
+ | `$.roi(gain, cost)` | Calculate ROI |
635
+ | `$.ltv(value, frequency, lifetime)` | Customer lifetime value |
636
+ | `$.cac(spend, customers)` | Customer acquisition cost |
637
+ | `$.burnRate(start, end, months)` | Monthly burn rate |
638
+ | `$.runway(cash, burnRate)` | Runway in months |
639
+ | `$.context` | Access business context |
640
+ | `$.log(event, data?)` | Log business event |
641
+
234
642
  ### Types
235
643
 
644
+ All types are fully exported for TypeScript users:
645
+
236
646
  ```typescript
237
647
  import type {
238
- BusinessSchema, // Complete business schema
239
- BusinessDomain, // Domain name type
240
- NounSchema, // Individual noun definition
241
- FieldSchema, // Field definition
242
- FieldType, // Field type union
243
- LoaderOptions, // Options for loaders
244
- LoadResult, // Result from load operations
648
+ BusinessDefinition,
649
+ VisionDefinition,
650
+ GoalDefinition,
651
+ ProductDefinition,
652
+ ServiceDefinition,
653
+ ProcessDefinition,
654
+ WorkflowDefinition,
655
+ KPIDefinition,
656
+ OKRDefinition,
657
+ KeyResult,
658
+ FinancialMetrics,
659
+ FinancialStatement,
660
+ BusinessContext,
661
+ BusinessOperations,
662
+ Currency,
663
+ TimePeriod,
664
+ } from 'business-as-code'
665
+ ```
666
+
667
+ ---
668
+
669
+ ## Entity Abstractions
670
+
671
+ Each entity defines **Properties** (data fields), **Actions** (imperative verbs), and **Events** (past tense state changes). This follows the same Noun pattern used in `digital-tools` and `ai-database`.
672
+
673
+ ### Business
674
+
675
+ Core business entities.
676
+
677
+ #### Properties
678
+
679
+ | Entity | Key Properties |
680
+ |--------|----------------|
681
+ | **Business** | `name`, `legalName`, `type` (startup, smb, enterprise, agency), `stage` (idea, pre-seed, seed, series-a...), `industry`, `mission`, `vision`, `values`, `targetMarket`, `teamSize`, `status` |
682
+ | **Vision** | `statement`, `timeframe`, `targetDate`, `successIndicators`, `progress`, `status` |
683
+ | **Value** | `name`, `description`, `behaviors`, `antiPatterns`, `priority`, `status` |
684
+
685
+ #### Actions & Events
686
+
687
+ | Entity | Actions | Events |
688
+ |--------|---------|--------|
689
+ | **Business** | create, update, launch, pivot, scale, acquire, merge, close, archive | created, updated, launched, pivoted, scaled, acquired, merged, closed, archived |
690
+ | **Vision** | create, update, activate, revise, achieve, abandon, archive | created, updated, activated, revised, achieved, abandoned, archived |
691
+ | **Value** | create, update, prioritize, deprecate, archive | created, updated, prioritized, deprecated, archived |
692
+
693
+ ---
694
+
695
+ ### Organization
696
+
697
+ Organizational hierarchy entities.
698
+
699
+ #### Properties
700
+
701
+ | Entity | Key Properties |
702
+ |--------|----------------|
703
+ | **Organization** | `name`, `type` (functional, divisional, matrix, flat), `fiscalYearStart`, `defaultCurrency`, `departmentCount`, `teamCount`, `positionCount`, `status` |
704
+ | **Department** | `name`, `code`, `type` (engineering, product, design, marketing...), `budget`, `budgetCurrency`, `headcount`, `level`, `status` |
705
+ | **Team** | `name`, `code`, `type` (product, platform, growth...), `methodology` (scrum, kanban...), `capacity`, `headcount`, `slackChannel`, `status` |
706
+ | **Position** | `title`, `code`, `level` (intern, junior, mid, senior, staff...), `track` (ic, management, executive), `employmentType`, `workLocation`, `salaryMin`, `salaryMax`, `fte`, `skills`, `status` |
707
+ | **Role** | `name`, `code`, `type` (executive, manager, lead, contributor...), `permissions`, `capabilities`, `approvalLevel`, `approvalLimit`, `status` |
708
+ | **Worker** | `name`, `email`, `type` (human, agent), `firstName`, `lastName`, `agentId`, `modelId`, `availability`, `capacity`, `status` |
709
+
710
+ #### Actions & Events
711
+
712
+ | Entity | Actions | Events |
713
+ |--------|---------|--------|
714
+ | **Organization** | create, update, restructure, merge, split, archive | created, updated, restructured, merged, split, archived |
715
+ | **Department** | create, update, rename, setBudget, addTeam, removeTeam, setHead, merge, split, dissolve, archive | created, updated, renamed, budgetSet, teamAdded, teamRemoved, headChanged, merged, split, dissolved, archived |
716
+ | **Team** | create, update, rename, setLead, addMember, removeMember, setCapacity, assignProject, unassignProject, archive | created, updated, renamed, leadChanged, memberAdded, memberRemoved, capacityChanged, projectAssigned, projectUnassigned, archived |
717
+ | **Position** | create, update, open, fill, freeze, eliminate, transfer, promote, setCompensation, archive | created, updated, opened, filled, frozen, eliminated, transferred, promoted, compensationChanged, archived |
718
+ | **Role** | create, update, grantPermission, revokePermission, setApprovalLimit, deprecate, archive | created, updated, permissionGranted, permissionRevoked, approvalLimitChanged, deprecated, archived |
719
+ | **Worker** | create, update, onboard, assign, reassign, setAvailability, promote, transfer, offboard, archive | created, updated, onboarded, assigned, reassigned, availabilityChanged, promoted, transferred, offboarded, archived |
720
+
721
+ ---
722
+
723
+ ### Goals
724
+
725
+ Goal tracking entities.
726
+
727
+ #### Properties
728
+
729
+ | Entity | Key Properties |
730
+ |--------|----------------|
731
+ | **Goal** | `name`, `type` (strategic, operational, tactical), `category` (growth, revenue, customer...), `priority`, `startDate`, `targetDate`, `progress`, `confidence`, `successMetrics`, `targetValue`, `currentValue`, `status` |
732
+ | **OKR** | `objective`, `type` (company, department, team, individual), `period`, `progress`, `confidence`, `grade`, `keyResultCount`, `status` |
733
+ | **KeyResult** | `description`, `metric`, `unit`, `startValue`, `targetValue`, `currentValue`, `progress`, `confidence`, `direction` (increase, decrease, maintain), `status` |
734
+ | **KPI** | `name`, `code`, `category` (financial, customer, operations...), `type` (leading, lagging), `unit`, `format`, `targetValue`, `currentValue`, `warningThreshold`, `criticalThreshold`, `direction`, `frequency`, `formula`, `status` |
735
+ | **Metric** | `name`, `category`, `value`, `unit`, `timestamp`, `period`, `source` |
736
+ | **Initiative** | `name`, `type` (project, program, experiment), `priority`, `startDate`, `endDate`, `progress`, `budget`, `spent`, `status` |
737
+
738
+ #### Actions & Events
739
+
740
+ | Entity | Actions | Events |
741
+ |--------|---------|--------|
742
+ | **Goal** | create, update, activate, updateProgress, markAtRisk, complete, cancel, extend, archive | created, updated, activated, progressUpdated, markedAtRisk, completed, cancelled, extended, overdue, archived |
743
+ | **OKR** | create, update, activate, addKeyResult, removeKeyResult, updateProgress, updateConfidence, grade, complete, cancel, archive | created, updated, activated, keyResultAdded, keyResultRemoved, progressUpdated, confidenceUpdated, graded, completed, cancelled, archived |
744
+ | **KeyResult** | create, update, updateValue, updateConfidence, complete, delete | created, updated, valueUpdated, confidenceUpdated, completed, deleted |
745
+ | **KPI** | create, update, measure, setTarget, setThresholds, alert, archive | created, updated, measured, targetSet, thresholdBreached, targetMet, alerted, archived |
746
+ | **Metric** | record, update, delete | recorded, updated, deleted |
747
+ | **Initiative** | create, update, approve, start, pause, resume, complete, cancel, archive | created, updated, approved, started, paused, resumed, completed, cancelled, archived |
748
+
749
+ ---
750
+
751
+ ### Offerings
752
+
753
+ Product and service entities.
754
+
755
+ #### Properties
756
+
757
+ | Entity | Key Properties |
758
+ |--------|----------------|
759
+ | **Product** | `name`, `slug`, `type` (saas, app, platform, api...), `category`, `targetSegment`, `valueProposition`, `pricingModel` (free, freemium, subscription, one-time, usage-based, tiered), `price`, `currency`, `cogs`, `grossMargin`, `stage` (concept, development, alpha, beta, ga...), `status`, `visibility` |
760
+ | **Service** | `name`, `type` (consulting, implementation, support, training...), `pricingModel` (hourly, daily, fixed, retainer, value-based), `hourlyRate`, `deliveryTime`, `deliveryModel`, `slaUptime`, `slaResponseTime`, `inclusions`, `exclusions`, `deliverables`, `status` |
761
+ | **Feature** | `name`, `category`, `type` (core, premium, add-on, beta), `benefit`, `availability`, `enabledByDefault`, `status` |
762
+ | **PricingPlan** | `name`, `tier` (free, starter, pro, business, enterprise), `price`, `currency`, `billingPeriod`, `annualDiscount`, `includedUnits`, `unitPrice`, `usageLimits`, `trialDays`, `highlighted`, `status` |
763
+ | **RoadmapItem** | `name`, `type` (feature, improvement, bug-fix...), `quarter`, `targetDate`, `priority`, `effort`, `impact`, `progress`, `status`, `visibility` |
764
+
765
+ #### Actions & Events
766
+
767
+ | Entity | Actions | Events |
768
+ |--------|---------|--------|
769
+ | **Product** | create, update, launch, pause, resume, updatePricing, addFeature, removeFeature, sunset, archive | created, updated, launched, paused, resumed, pricingUpdated, featureAdded, featureRemoved, sunset, archived |
770
+ | **Service** | create, update, publish, pause, resume, updatePricing, updateSLA, discontinue, archive | created, updated, published, paused, resumed, pricingUpdated, slaUpdated, discontinued, archived |
771
+ | **Feature** | create, update, enable, disable, deprecate, remove | created, updated, enabled, disabled, deprecated, removed |
772
+ | **PricingPlan** | create, update, publish, hide, updatePrice, addFeature, removeFeature, discontinue, archive | created, updated, published, hidden, priceUpdated, featureAdded, featureRemoved, discontinued, archived |
773
+ | **RoadmapItem** | create, update, schedule, start, complete, defer, cancel, archive | created, updated, scheduled, started, completed, deferred, cancelled, archived |
774
+
775
+ ---
776
+
777
+ ### Operations
778
+
779
+ Process and workflow entities.
780
+
781
+ #### Properties
782
+
783
+ | Entity | Key Properties |
784
+ |--------|----------------|
785
+ | **Process** | `name`, `type` (core, support, management), `category`, `triggerType`, `inputs`, `outputs`, `averageDuration`, `sla`, `automationLevel` (manual, semi-automated, automated, autonomous), `automationPercentage`, `version`, `status` |
786
+ | **ProcessStep** | `name`, `order`, `type` (task, decision, approval, notification, wait...), `automationLevel`, `responsible`, `accountable`, `estimatedDuration`, `sla`, `inputs`, `outputs`, `instructions`, `condition` |
787
+ | **Workflow** | `name`, `triggerType` (event, schedule, webhook, manual, api), `triggerEvent`, `triggerSchedule`, `timeout`, `retryPolicy`, `concurrency`, `runCount`, `successCount`, `failureCount`, `lastRunAt`, `status`, `enabled` |
788
+ | **WorkflowAction** | `name`, `order`, `type` (http, email, slack, database, transform, condition, loop, delay, approval, ai), `operation`, `config`, `inputs`, `condition`, `continueOnError`, `retryOnFailure` |
789
+ | **WorkflowRun** | `status` (pending, running, completed, failed, cancelled, waiting), `startedAt`, `completedAt`, `duration`, `currentStep`, `totalSteps`, `triggerData`, `output`, `error`, `attempt` |
790
+ | **Policy** | `name`, `code`, `type` (compliance, operational, security, hr, financial, data), `content`, `rules`, `enforcementLevel`, `effectiveDate`, `reviewDate`, `version`, `status` |
791
+
792
+ #### Actions & Events
793
+
794
+ | Entity | Actions | Events |
795
+ |--------|---------|--------|
796
+ | **Process** | create, update, publish, addStep, removeStep, reorderSteps, automate, deprecate, archive | created, updated, published, stepAdded, stepRemoved, stepsReordered, automated, deprecated, archived |
797
+ | **ProcessStep** | create, update, move, duplicate, delete | created, updated, moved, duplicated, deleted |
798
+ | **Workflow** | create, update, enable, disable, trigger, test, addAction, removeAction, archive | created, updated, enabled, disabled, triggered, completed, failed, archived |
799
+ | **WorkflowAction** | create, update, move, duplicate, delete, test | created, updated, moved, duplicated, deleted, executed, failed |
800
+ | **WorkflowRun** | start, pause, resume, cancel, retry | started, paused, resumed, completed, failed, cancelled, retried |
801
+ | **Policy** | create, update, submit, approve, publish, supersede, archive | created, updated, submitted, approved, published, superseded, archived |
802
+
803
+ ---
804
+
805
+ ### Financials
806
+
807
+ Financial entities.
808
+
809
+ #### Properties
810
+
811
+ | Entity | Key Properties |
812
+ |--------|----------------|
813
+ | **Budget** | `name`, `type` (operating, capital, project, marketing, hiring, r&d), `period`, `startDate`, `endDate`, `amount`, `currency`, `spent`, `committed`, `available`, `utilization`, `status` |
814
+ | **Revenue** | `type` (subscription, one-time, usage, professional-services...), `category`, `source`, `amount`, `currency`, `period`, `date`, `isRecurring`, `recognized`, `recognizedAt`, `deferredAmount`, `segment`, `region` |
815
+ | **Expense** | `description`, `type` (payroll, cogs, marketing, sales, r&d, g&a...), `category`, `amount`, `currency`, `date`, `isRecurring`, `isCapex`, `isDeductible`, `vendor`, `invoiceNumber`, `status` |
816
+ | **Investment** | `name`, `type` (pre-seed, seed, series-a...), `instrumentType` (equity, safe, convertible-note, debt), `amount`, `currency`, `preMoneyValuation`, `postMoneyValuation`, `equityPercentage`, `leadInvestor`, `investors`, `status` |
817
+ | **FinancialPeriod** | `name`, `type` (month, quarter, half-year, year), `startDate`, `endDate`, `revenue`, `cogs`, `grossProfit`, `grossMargin`, `operatingExpenses`, `operatingIncome`, `operatingMargin`, `netIncome`, `ebitda`, `mrr`, `arr`, `nrr`, `grr`, `cac`, `ltv`, `ltvCacRatio`, `churnRate`, `burnRate`, `runway`, `status` |
818
+ | **Forecast** | `name`, `type` (revenue, expense, cash, headcount, arr), `scenario` (base, optimistic, pessimistic, stretch), `startDate`, `endDate`, `granularity`, `values`, `total`, `assumptions`, `growthRate`, `confidenceLevel`, `version`, `status` |
819
+
820
+ #### Actions & Events
821
+
822
+ | Entity | Actions | Events |
823
+ |--------|---------|--------|
824
+ | **Budget** | create, update, submit, approve, allocate, reallocate, freeze, unfreeze, close, archive | created, updated, submitted, approved, allocated, reallocated, frozen, unfrozen, thresholdWarning, overBudget, closed, archived |
825
+ | **Revenue** | record, update, recognize, defer, void | recorded, updated, recognized, deferred, voided |
826
+ | **Expense** | create, update, submit, approve, reject, pay, void | created, updated, submitted, approved, rejected, paid, voided |
827
+ | **Investment** | create, update, negotiate, signTermSheet, close, announce, cancel | created, updated, negotiated, termSheetSigned, closed, announced, cancelled |
828
+ | **FinancialPeriod** | create, update, close, reopen, audit | created, updated, closed, reopened, audited |
829
+ | **Forecast** | create, update, submit, approve, supersede, archive | created, updated, submitted, approved, superseded, archived |
830
+
831
+ ---
832
+
833
+ ### Customers
834
+
835
+ Customer relationship management entities.
836
+
837
+ #### Properties
838
+
839
+ | Entity | Key Properties |
840
+ |--------|----------------|
841
+ | **Customer** | `name`, `type` (individual, company, nonprofit), `stage` (prospect, trial, onboarding, active, at-risk, churned), `industry`, `size`, `annualRevenue`, `employeeCount`, `acquisitionSource`, `acquisitionDate`, `ltv`, `healthScore`, `nps`, `tier`, `status` |
842
+ | **Account** | `name`, `type` (customer, prospect, partner), `industry`, `annualRevenue`, `employeeCount`, `tier`, `owner`, `territory`, `mrr`, `arr`, `healthScore`, `churnRisk`, `expansionPotential`, `status` |
843
+ | **Contact** | `name`, `email`, `phone`, `title`, `role` (decision-maker, influencer, champion, user, blocker), `department`, `isPrimary`, `optInMarketing`, `optInEmail`, `lastContactedDate`, `status` |
844
+ | **Segment** | `name`, `type` (demographic, behavioral, firmographic, technographic, psychographic), `criteria`, `customerCount`, `totalRevenue`, `avgLtv`, `avgHealthScore`, `status` |
845
+ | **Persona** | `name`, `role`, `seniority`, `department`, `goals`, `painPoints`, `motivations`, `objections`, `preferredChannels`, `buyingRole`, `status` |
846
+ | **Interaction** | `type` (call, email, meeting, demo, support, chat, event), `direction` (inbound, outbound), `subject`, `outcome`, `nextSteps`, `date`, `duration`, `sentiment`, `status` |
847
+
848
+ #### Actions & Events
849
+
850
+ | Entity | Actions | Events |
851
+ |--------|---------|--------|
852
+ | **Customer** | create, update, qualify, convert, onboard, upgrade, downgrade, churn, winBack, delete, archive | created, updated, qualified, converted, onboarded, upgraded, downgraded, churned, wonBack, deleted, archived |
853
+ | **Account** | create, update, qualify, assign, reassign, merge, upgrade, downgrade, close, archive | created, updated, qualified, assigned, reassigned, merged, upgraded, downgraded, closed, archived |
854
+ | **Contact** | create, update, verify, enrich, optIn, optOut, merge, delete, archive | created, updated, verified, enriched, optedIn, optedOut, merged, deleted, archived |
855
+ | **Segment** | create, update, refresh, activate, deactivate, archive | created, updated, refreshed, activated, deactivated, archived |
856
+ | **Persona** | create, update, validate, archive | created, updated, validated, archived |
857
+ | **Interaction** | create, update, complete, cancel, followUp | created, updated, completed, cancelled, followedUp |
858
+
859
+ ---
860
+
861
+ ### Sales
862
+
863
+ Sales pipeline and revenue entities.
864
+
865
+ #### Properties
866
+
867
+ | Entity | Key Properties |
868
+ |--------|----------------|
869
+ | **Deal** | `name`, `type` (new-business, expansion, renewal, upsell, cross-sell), `amount`, `currency`, `probability`, `stage`, `expectedCloseDate`, `actualCloseDate`, `daysInStage`, `daysOpen`, `leadSource`, `lossReason`, `competitor`, `forecastCategory`, `status` |
870
+ | **Pipeline** | `name`, `type` (sales, renewal, expansion, partnership), `totalValue`, `weightedValue`, `dealCount`, `avgDealSize`, `avgCycleTime`, `winRate`, `quotaAttainment`, `status` |
871
+ | **Stage** | `name`, `order`, `type` (qualification, discovery, proposal, negotiation, closed), `probability`, `durationDays`, `avgDuration`, `dealCount`, `dealValue`, `exitCriteria`, `status` |
872
+ | **Contract** | `name`, `type` (subscription, service, license, NDA, MSA, SOW), `value`, `currency`, `startDate`, `endDate`, `autoRenew`, `renewalNoticeDays`, `paymentTerms`, `status` |
873
+ | **Subscription** | `type` (monthly, annual, multi-year), `plan`, `mrr`, `arr`, `quantity`, `unitPrice`, `discount`, `startDate`, `renewalDate`, `cancelledDate`, `churnReason`, `status` |
874
+ | **Quote** | `name`, `version`, `amount`, `currency`, `discount`, `validUntil`, `paymentTerms`, `status` (draft, sent, viewed, accepted, rejected, expired) |
875
+ | **Order** | `orderNumber`, `type` (new, renewal, expansion, upgrade, downgrade), `amount`, `currency`, `taxAmount`, `totalAmount`, `status` (draft, pending, confirmed, processing, fulfilled, cancelled) |
876
+ | **Invoice** | `invoiceNumber`, `type` (standard, credit, debit, proforma), `amount`, `taxAmount`, `totalAmount`, `currency`, `dueDate`, `status` (draft, sent, viewed, paid, overdue, void) |
877
+
878
+ #### Actions & Events
879
+
880
+ | Entity | Actions | Events |
881
+ |--------|---------|--------|
882
+ | **Deal** | create, update, qualify, advance, stall, win, lose, reopen, delete, archive | created, updated, qualified, stageChanged, stalled, won, lost, reopened, deleted, archived |
883
+ | **Pipeline** | create, update, refresh, forecast, archive | created, updated, refreshed, forecasted, archived |
884
+ | **Stage** | create, update, reorder, archive | created, updated, reordered, archived |
885
+ | **Contract** | create, update, send, sign, activate, amend, renew, terminate, expire, archive | created, updated, sent, signed, activated, amended, renewed, terminated, expired, archived |
886
+ | **Subscription** | create, update, activate, upgrade, downgrade, pause, resume, cancel, renew, churn | created, updated, activated, upgraded, downgraded, paused, resumed, cancelled, renewed, churned |
887
+ | **Quote** | create, update, send, view, accept, reject, revise, expire, delete | created, updated, sent, viewed, accepted, rejected, revised, expired, deleted |
888
+ | **Order** | create, update, confirm, process, fulfill, cancel, refund | created, updated, confirmed, processing, fulfilled, cancelled, refunded |
889
+ | **Invoice** | create, update, send, view, pay, void, writeOff, remind | created, updated, sent, viewed, paid, voided, writtenOff, reminded |
890
+
891
+ ---
892
+
893
+ ### Marketing
894
+
895
+ Marketing and demand generation entities.
896
+
897
+ #### Properties
898
+
899
+ | Entity | Key Properties |
900
+ |--------|----------------|
901
+ | **Campaign** | `name`, `type` (email, social, content, paid-search, paid-social, event, webinar, direct-mail, ABM), `channel`, `status` (draft, scheduled, active, paused, completed, cancelled), `budget`, `spent`, `impressions`, `clicks`, `ctr`, `conversions`, `conversionRate`, `cpl`, `roi`, `startDate`, `endDate` |
902
+ | **Lead** | `name`, `email`, `company`, `title`, `source`, `status` (new, contacted, qualified, unqualified, nurturing, converted, lost), `score`, `grade`, `temperature` (cold, warm, hot), `mqlDate`, `sqlDate`, `utmSource`, `utmMedium`, `utmCampaign` |
903
+ | **Audience** | `name`, `type` (segment, list, lookalike, retargeting, suppression), `source`, `size`, `refreshFrequency`, `criteria`, `status` |
904
+ | **Content** | `title`, `type` (blog, whitepaper, ebook, case-study, video, webinar, infographic, podcast, social, email), `format`, `topic`, `stage` (awareness, consideration, decision), `author`, `wordCount`, `readTime`, `views`, `downloads`, `status` |
905
+ | **Funnel** | `name`, `type` (marketing, sales, conversion, onboarding), `totalVisitors`, `totalConversions`, `conversionRate`, `avgTimeToConvert`, `dropoffRate`, `status` |
906
+ | **FunnelStage** | `name`, `order`, `type` (awareness, interest, consideration, intent, evaluation, purchase), `visitors`, `conversions`, `conversionRate`, `dropoffRate`, `avgTimeInStage` |
907
+ | **MarketingEvent** | `name`, `type` (conference, webinar, workshop, meetup, trade-show, launch-event, virtual-event), `format` (in-person, virtual, hybrid), `capacity`, `registrations`, `attendance`, `attendanceRate`, `cost`, `costPerAttendee`, `leadsGenerated`, `roi`, `status` |
908
+
909
+ #### Actions & Events
910
+
911
+ | Entity | Actions | Events |
912
+ |--------|---------|--------|
913
+ | **Campaign** | create, update, launch, pause, resume, complete, cancel, clone, analyze | created, updated, launched, paused, resumed, completed, cancelled, cloned, analyzed |
914
+ | **Lead** | create, update, score, grade, qualify, disqualify, nurture, convert, assign, merge | created, updated, scored, graded, qualified, disqualified, nurtured, converted, assigned, merged |
915
+ | **Audience** | create, update, refresh, activate, deactivate, export, archive | created, updated, refreshed, activated, deactivated, exported, archived |
916
+ | **Content** | create, update, publish, unpublish, archive, promote, analyze | created, updated, published, unpublished, archived, promoted, analyzed |
917
+ | **Funnel** | create, update, analyze, optimize, archive | created, updated, analyzed, optimized, archived |
918
+ | **FunnelStage** | create, update, reorder | created, updated, reordered |
919
+ | **MarketingEvent** | create, update, publish, register, unregister, start, end, cancel, archive | created, updated, published, registered, unregistered, started, ended, cancelled, archived |
920
+
921
+ ---
922
+
923
+ ### Partnerships
924
+
925
+ Partner and vendor management entities.
926
+
927
+ #### Properties
928
+
929
+ | Entity | Key Properties |
930
+ |--------|----------------|
931
+ | **Partner** | `name`, `type` (strategic, technology, channel, solution, reseller, referral, OEM), `tier` (platinum, gold, silver, bronze), `status`, `territories`, `specializations`, `certifications`, `revenueShare`, `referralFee`, `totalRevenue`, `totalDeals`, `nda`, `portalAccess`, `enablementComplete` |
932
+ | **Vendor** | `name`, `type` (supplier, contractor, consultant, SaaS, service), `category`, `status`, `paymentTerms`, `contractValue`, `annualSpend`, `riskLevel`, `complianceStatus`, `slaScore`, `qualityScore`, `certifications` |
933
+ | **Affiliate** | `name`, `type` (individual, company, influencer, blogger, publisher), `status`, `affiliateId`, `referralCode`, `commissionRate`, `commissionType`, `totalClicks`, `totalConversions`, `conversionRate`, `totalRevenue`, `totalCommissions`, `tier` |
934
+ | **Partnership** | `name`, `type` (strategic, technology, channel, co-marketing, co-selling, integration, reseller, white-label, OEM), `status`, `objectives`, `revenueShare`, `territories`, `exclusivity`, `targetRevenue`, `actualRevenue`, `healthScore` |
935
+ | **Integration** | `name`, `type` (API, webhook, SDK, embed, SSO, data-sync), `status`, `direction` (inbound, outbound, bidirectional), `authentication`, `syncFrequency`, `lastSyncStatus`, `enabled` |
936
+ | **Reseller** | `name`, `type` (VAR, distributor, MSP, SI, retail), `tier`, `territories`, `verticals`, `products`, `discountLevel`, `margin`, `quota`, `yearToDateSales`, `certifiedReps`, `dealRegistration` |
937
+
938
+ #### Actions & Events
939
+
940
+ | Entity | Actions | Events |
941
+ |--------|---------|--------|
942
+ | **Partner** | create, update, onboard, activate, deactivate, suspend, terminate, upgrade, downgrade, certify, enable, review, renew | created, updated, onboarded, activated, deactivated, suspended, terminated, upgraded, downgraded, certified, enabled, reviewed, renewed |
943
+ | **Vendor** | create, update, evaluate, approve, reject, activate, suspend, terminate, review, audit, renew | created, updated, evaluated, approved, rejected, activated, suspended, terminated, reviewed, audited, renewed |
944
+ | **Affiliate** | create, update, approve, reject, activate, suspend, terminate, upgrade, downgrade, payout, track | created, updated, approved, rejected, activated, suspended, terminated, upgraded, downgraded, paidOut, tracked |
945
+ | **Partnership** | create, update, propose, negotiate, approve, reject, activate, pause, resume, extend, terminate, renew, review | created, updated, proposed, negotiated, approved, rejected, activated, paused, resumed, extended, terminated, renewed, reviewed |
946
+ | **Integration** | create, update, develop, test, deploy, enable, disable, sync, debug, deprecate, version | created, updated, developed, tested, deployed, enabled, disabled, synced, debugged, deprecated, versioned |
947
+ | **Reseller** | create, update, onboard, activate, suspend, terminate, upgrade, downgrade, certify, enable, allocateFunds | created, updated, onboarded, activated, suspended, terminated, upgraded, downgraded, certified, enabled, fundsAllocated |
948
+
949
+ ---
950
+
951
+ ### Legal
952
+
953
+ Legal and compliance entities.
954
+
955
+ #### Properties
956
+
957
+ | Entity | Key Properties |
958
+ |--------|----------------|
959
+ | **Agreement** | `name`, `type` (NDA, MSA, SOW, SLA, DPA, employment, partnership, licensing), `status`, `parties`, `counterparty`, `effectiveDate`, `expirationDate`, `term`, `autoRenew`, `value`, `governingLaw`, `confidentiality`, `nonCompete`, `exclusivity`, `version` |
960
+ | **License** | `name`, `type` (software, content, patent, trademark, API, SDK), `model` (perpetual, subscription, usage-based, seat-based), `status`, `licenseKey`, `product`, `edition`, `seats`, `maxSeats`, `features`, `restrictions`, `territory`, `exclusivity`, `transferable` |
961
+ | **IntellectualProperty** | `name`, `type` (patent, trademark, copyright, trade-secret, design, domain), `status`, `registrationNumber`, `filingDate`, `registrationDate`, `expirationDate`, `jurisdiction`, `classes`, `claims`, `inventors`, `owner`, `value` |
962
+ | **Compliance** | `name`, `type` (regulation, certification, standard, policy, audit), `framework` (SOC2, ISO27001, GDPR, HIPAA, PCI-DSS, SOX, CCPA), `status`, `scope`, `requirements`, `controls`, `certificationDate`, `expirationDate`, `findings`, `complianceScore` |
963
+ | **LegalPolicy** | `name`, `type` (privacy, security, HR, ethics, acceptable-use, data-retention), `status`, `version`, `scope`, `applicableTo`, `effectiveDate`, `reviewDate`, `owner`, `acknowledgmentRequired` |
964
+ | **Trademark** | `name`, `mark`, `type` (word, design, combined, sound, color), `status`, `registrationNumber`, `filingDate`, `registrationDate`, `expirationDate`, `jurisdiction`, `classes`, `goodsServices`, `owner` |
965
+
966
+ #### Actions & Events
967
+
968
+ | Entity | Actions | Events |
969
+ |--------|---------|--------|
970
+ | **Agreement** | create, update, draft, review, negotiate, approve, reject, sign, execute, amend, renew, terminate, expire, archive | created, updated, drafted, reviewed, negotiated, approved, rejected, signed, executed, amended, renewed, terminated, expired, archived |
971
+ | **License** | create, update, issue, activate, suspend, renew, upgrade, downgrade, transfer, revoke, expire | created, updated, issued, activated, suspended, renewed, upgraded, downgraded, transferred, revoked, expired |
972
+ | **IntellectualProperty** | create, update, file, register, publish, grant, maintain, renew, license, assign, abandon, enforce | created, updated, filed, registered, published, granted, maintained, renewed, licensed, assigned, abandoned, enforced |
973
+ | **Compliance** | create, update, assess, audit, certify, remediate, renew, expire, exempt, report | created, updated, assessed, audited, certified, remediated, renewed, expired, exempted, reported |
974
+ | **LegalPolicy** | create, update, draft, review, approve, publish, deprecate, archive, acknowledge, enforce | created, updated, drafted, reviewed, approved, published, deprecated, archived, acknowledged, enforced |
975
+ | **Trademark** | create, update, search, file, register, renew, maintain, license, abandon, cancel, enforce, monitor | created, updated, searched, filed, registered, renewed, maintained, licensed, abandoned, cancelled, enforced, monitored |
976
+
977
+ ---
978
+
979
+ ### Risk
980
+
981
+ Risk management entities.
982
+
983
+ #### Properties
984
+
985
+ | Entity | Key Properties |
986
+ |--------|----------------|
987
+ | **Risk** | `name`, `type` (strategic, operational, financial, compliance, reputational, security, technology), `category`, `status`, `source`, `likelihood`, `impact`, `riskScore`, `riskLevel`, `inherentRiskScore`, `residualRiskScore`, `treatment` (accept, mitigate, transfer, avoid), `financialImpact`, `owner` |
988
+ | **Mitigation** | `name`, `type` (preventive, detective, corrective, compensating), `status`, `priority`, `strategy`, `expectedReduction`, `actualReduction`, `cost`, `owner`, `plannedStartDate`, `plannedEndDate`, `effectiveness`, `progress` |
989
+ | **Incident** | `name`, `type` (security, data-breach, system-outage, operational, compliance, safety, fraud), `status`, `severity`, `priority`, `impact`, `impactedUsers`, `impactedSystems`, `rootCause`, `detectedAt`, `resolvedAt`, `timeToDetect`, `timeToResolve`, `lessonsLearned` |
990
+ | **Control** | `name`, `type` (preventive, detective, corrective, compensating, deterrent), `category` (technical, administrative, physical, operational), `status`, `controlId`, `framework`, `objective`, `frequency`, `automationLevel`, `effectiveness`, `maturity`, `lastTestDate` |
991
+ | **Assessment** | `name`, `type` (risk, security, compliance, vendor, impact, vulnerability, audit), `status`, `scope`, `methodology`, `framework`, `assessor`, `findings`, `criticalFindings`, `overallRating`, `riskScore`, `recommendations` |
992
+ | **Issue** | `name`, `type` (operational, technical, process, compliance, vendor, customer), `status`, `severity`, `priority`, `impact`, `rootCause`, `resolution`, `workaround`, `owner`, `assignee`, `dueDate`, `escalated` |
993
+
994
+ #### Actions & Events
995
+
996
+ | Entity | Actions | Events |
997
+ |--------|---------|--------|
998
+ | **Risk** | create, update, assess, escalate, accept, mitigate, transfer, avoid, review, close, reopen, monitor | created, updated, assessed, escalated, accepted, mitigated, transferred, avoided, reviewed, closed, reopened, monitored |
999
+ | **Mitigation** | create, update, plan, start, implement, verify, complete, fail, defer, cancel | created, updated, planned, started, implemented, verified, completed, failed, deferred, cancelled |
1000
+ | **Incident** | create, update, detect, confirm, escalate, investigate, contain, eradicate, recover, resolve, close, reopen, notify, postMortem | created, updated, detected, confirmed, escalated, investigated, contained, eradicated, recovered, resolved, closed, reopened, notified, postMortemCompleted |
1001
+ | **Control** | create, update, implement, test, review, deprecate, remediate, evidence | created, updated, implemented, tested, reviewed, deprecated, remediated, evidenced |
1002
+ | **Assessment** | create, update, schedule, start, conduct, review, complete, cancel, report, followUp | created, updated, scheduled, started, conducted, reviewed, completed, cancelled, reported, followedUp |
1003
+ | **Issue** | create, update, investigate, escalate, assign, resolve, close, reopen, workaround | created, updated, investigated, escalated, assigned, resolved, closed, reopened, workaroundApplied |
1004
+
1005
+ ---
1006
+
1007
+ ### Projects
1008
+
1009
+ Project management entities.
1010
+
1011
+ #### Properties
1012
+
1013
+ | Entity | Key Properties |
1014
+ |--------|----------------|
1015
+ | **Project** | `name`, `type` (product, internal, client, research, infrastructure), `status`, `phase`, `priority`, `methodology` (agile, scrum, kanban, waterfall), `objectives`, `scope`, `startDate`, `endDate`, `progress`, `health`, `budget`, `spent`, `sponsor`, `owner`, `manager`, `teamSize` |
1016
+ | **Task** | `name`, `type` (task, bug, feature, improvement, research), `status`, `priority`, `resolution`, `estimate`, `timeSpent`, `storyPoints`, `complexity`, `startDate`, `dueDate`, `assignee`, `labels`, `acceptanceCriteria`, `progress` |
1017
+ | **Milestone** | `name`, `type` (phase-gate, release, delivery, review, approval, launch), `status`, `targetDate`, `actualDate`, `progress`, `deliverables`, `criteria`, `owner`, `approver`, `approved` |
1018
+ | **Sprint** | `name`, `number`, `goal`, `status`, `startDate`, `endDate`, `duration`, `capacity`, `commitment`, `completed`, `velocity`, `completionRate`, `carryOver`, `totalTasks`, `completedTasks` |
1019
+ | **Deliverable** | `name`, `type` (document, software, report, design, prototype, training), `status`, `format`, `version`, `dueDate`, `deliveredDate`, `owner`, `acceptanceCriteria`, `accepted`, `progress` |
1020
+ | **Epic** | `name`, `status`, `priority`, `theme`, `businessValue`, `successMetrics`, `acceptanceCriteria`, `startDate`, `targetDate`, `estimate`, `completed`, `progress`, `owner` |
1021
+ | **Story** | `name`, `userStory`, `status`, `priority`, `storyPoints`, `businessValue`, `acceptanceCriteria`, `persona`, `assignee`, `labels`, `components`, `progress` |
1022
+ | **Resource** | `name`, `type` (person, equipment, material, facility, budget), `status`, `role`, `skills`, `capacity`, `allocated`, `available`, `utilizationTarget`, `utilizationActual`, `costRate`, `billableRate` |
1023
+
1024
+ #### Actions & Events
1025
+
1026
+ | Entity | Actions | Events |
1027
+ |--------|---------|--------|
1028
+ | **Project** | create, update, plan, approve, start, pause, resume, complete, cancel, archive, replan, review | created, updated, planned, approved, started, paused, resumed, completed, cancelled, archived, replanned, reviewed |
1029
+ | **Task** | create, update, assign, start, pause, resume, complete, cancel, reopen, block, unblock, estimate, review | created, updated, assigned, started, paused, resumed, completed, cancelled, reopened, blocked, unblocked, estimated, reviewed |
1030
+ | **Milestone** | create, update, start, complete, delay, approve, cancel, review | created, updated, started, completed, delayed, approved, cancelled, reviewed |
1031
+ | **Sprint** | create, update, plan, start, complete, cancel, review, retrospect | created, updated, planned, started, completed, cancelled, reviewed, retrospected |
1032
+ | **Deliverable** | create, update, start, submit, review, approve, reject, revise, deliver, accept | created, updated, started, submitted, reviewed, approved, rejected, revised, delivered, accepted |
1033
+ | **Epic** | create, update, refine, start, complete, cancel, split, prioritize | created, updated, refined, started, completed, cancelled, split, prioritized |
1034
+ | **Story** | create, update, refine, estimate, assign, start, complete, reject, split | created, updated, refined, estimated, assigned, started, completed, rejected, split |
1035
+ | **Resource** | create, update, allocate, deallocate, reassign, book, release | created, updated, allocated, deallocated, reassigned, booked, released |
1036
+
1037
+ ---
1038
+
1039
+ ### Communication
1040
+
1041
+ Communication and collaboration entities.
1042
+
1043
+ #### Properties
1044
+
1045
+ | Entity | Key Properties |
1046
+ |--------|----------------|
1047
+ | **Meeting** | `name`, `type` (one-on-one, team, all-hands, standup, planning, review, retrospective, interview, client), `status`, `recurring`, `recurrencePattern`, `startTime`, `endTime`, `duration`, `location`, `virtualLink`, `platform`, `organizer`, `attendees`, `agenda`, `notes` |
1048
+ | **Decision** | `name`, `type` (strategic, tactical, operational, technical, policy, resource), `status`, `outcome`, `rationale`, `alternatives`, `impact`, `risks`, `benefits`, `decisionMaker`, `proposedDate`, `decidedDate`, `reviewDate`, `reversible` |
1049
+ | **ActionItem** | `name`, `status`, `priority`, `source`, `assignee`, `assignedBy`, `dueDate`, `completedDate`, `context`, `outcome`, `blockers`, `progress` |
1050
+ | **Announcement** | `title`, `content`, `type` (general, product, company, HR, policy, event, milestone, emergency), `status`, `priority`, `audience`, `channels`, `author`, `publishDate`, `acknowledgmentRequired`, `acknowledgmentCount`, `viewCount` |
1051
+ | **Feedback** | `title`, `content`, `type` (feature-request, bug-report, complaint, praise, suggestion, review, NPS), `source`, `status`, `sentiment`, `rating`, `npsScore`, `category`, `priority`, `submitter`, `assignee`, `response` |
1052
+ | **Discussion** | `title`, `content`, `type` (question, proposal, brainstorm, announcement, decision, RFC), `status`, `category`, `author`, `participants`, `replyCount`, `viewCount`, `pinned`, `locked`, `resolved`, `visibility` |
1053
+
1054
+ #### Actions & Events
1055
+
1056
+ | Entity | Actions | Events |
1057
+ |--------|---------|--------|
1058
+ | **Meeting** | create, update, schedule, reschedule, cancel, start, end, summarize, record | created, updated, scheduled, rescheduled, cancelled, started, ended, summarized, recorded |
1059
+ | **Decision** | create, update, propose, review, approve, reject, defer, implement, supersede, archive | created, updated, proposed, reviewed, approved, rejected, deferred, implemented, superseded, archived |
1060
+ | **ActionItem** | create, update, assign, reassign, start, complete, cancel, defer, escalate | created, updated, assigned, reassigned, started, completed, cancelled, deferred, escalated |
1061
+ | **Announcement** | create, update, draft, schedule, publish, recall, archive, acknowledge, feature | created, updated, drafted, scheduled, published, recalled, archived, acknowledged, featured |
1062
+ | **Feedback** | create, update, acknowledge, assign, respond, resolve, decline, archive, merge, upvote | created, updated, acknowledged, assigned, responded, resolved, declined, archived, merged, upvoted |
1063
+ | **Discussion** | create, update, reply, resolve, close, reopen, pin, unpin, lock, unlock, archive | created, updated, replied, resolved, closed, reopened, pinned, unpinned, locked, unlocked, archived |
1064
+
1065
+ ---
1066
+
1067
+ ### Assets
1068
+
1069
+ Asset and inventory management entities.
1070
+
1071
+ #### Properties
1072
+
1073
+ | Entity | Key Properties |
1074
+ |--------|----------------|
1075
+ | **Asset** | `name`, `type` (hardware, software, furniture, vehicle, equipment, real-estate, digital, IP), `category`, `status`, `assetTag`, `serialNumber`, `manufacturer`, `model`, `condition`, `location`, `assignedTo`, `purchaseDate`, `purchasePrice`, `currentValue`, `depreciationMethod`, `warrantyExpiry` |
1076
+ | **Inventory** | `name`, `sku`, `barcode`, `type` (raw-material, work-in-progress, finished-goods, supplies, spare-parts), `category`, `status`, `unitOfMeasure`, `quantityOnHand`, `quantityReserved`, `quantityAvailable`, `reorderPoint`, `reorderQuantity`, `unitCost`, `totalValue`, `location`, `warehouse` |
1077
+ | **Equipment** | `name`, `type` (computer, server, network, printer, phone, machinery, vehicle, tool), `status`, `assetTag`, `serialNumber`, `manufacturer`, `model`, `specifications`, `condition`, `location`, `assignedTo`, `serviceContract`, `lastServiceDate`, `nextServiceDate` |
1078
+ | **Facility** | `name`, `type` (office, warehouse, factory, datacenter, retail, lab, headquarters), `status`, `code`, `address`, `city`, `country`, `squareFootage`, `floors`, `capacity`, `currentOccupancy`, `ownership` (owned, leased, subleased, coworking), `monthlyRent`, `operatingCost`, `manager` |
1079
+ | **Software** | `name`, `type` (SaaS, on-premise, desktop, mobile, embedded, open-source), `category`, `status`, `vendor`, `version`, `edition`, `licenseType`, `licensedUsers`, `activeUsers`, `deploymentType`, `ssoEnabled`, `dataClassification`, `businessCriticality`, `annualCost` |
1080
+ | **DataAsset** | `name`, `type` (database, data-lake, file, API, report, model, dataset, stream), `category`, `status`, `classification` (public, internal, confidential, restricted, PII, PHI), `format`, `schema`, `size`, `recordCount`, `source`, `refreshFrequency`, `owner`, `steward`, `qualityScore` |
1081
+
1082
+ #### Actions & Events
1083
+
1084
+ | Entity | Actions | Events |
1085
+ |--------|---------|--------|
1086
+ | **Asset** | create, update, assign, unassign, transfer, maintain, repair, retire, dispose, audit, reserve, check-in, check-out | created, updated, assigned, unassigned, transferred, maintained, repaired, retired, disposed, audited, reserved, checkedIn, checkedOut |
1087
+ | **Inventory** | create, update, receive, ship, transfer, adjust, count, reserve, unreserve, reorder, discontinue | created, updated, received, shipped, transferred, adjusted, counted, reserved, unreserved, reordered, discontinued |
1088
+ | **Equipment** | create, update, assign, unassign, service, repair, calibrate, retire, dispose, reserve, return | created, updated, assigned, unassigned, serviced, repaired, calibrated, retired, disposed, reserved, returned |
1089
+ | **Facility** | create, update, open, close, renovate, expand, consolidate, audit, inspect | created, updated, opened, closed, renovated, expanded, consolidated, audited, inspected |
1090
+ | **Software** | create, update, deploy, upgrade, downgrade, renew, deprecate, retire, review, integrate | created, updated, deployed, upgraded, downgraded, renewed, deprecated, retired, reviewed, integrated |
1091
+ | **DataAsset** | create, update, refresh, archive, delete, share, restrict, classify, audit, document | created, updated, refreshed, archived, deleted, shared, restricted, classified, audited, documented |
1092
+
1093
+ ---
1094
+
1095
+ ### Market
1096
+
1097
+ Market intelligence entities.
1098
+
1099
+ #### Properties
1100
+
1101
+ | Entity | Key Properties |
1102
+ |--------|----------------|
1103
+ | **Market** | `name`, `type` (geographic, demographic, psychographic, behavioral, industry, vertical), `status`, `region`, `countries`, `size` (TAM), `serviceable` (SAM), `obtainable` (SOM), `growthRate`, `maturity`, `competitiveness`, `marketShare`, `targetShare`, `penetration`, `avgDealSize`, `salesCycle`, `priority` |
1104
+ | **Competitor** | `name`, `type` (direct, indirect, substitute, potential, emerging), `status`, `website`, `founded`, `headquarters`, `employeeCount`, `revenue`, `marketShare`, `positioning`, `targetSegments`, `products`, `pricing`, `strengths`, `weaknesses`, `differentiators`, `threatLevel`, `winRate`, `lossRate` |
1105
+ | **Trend** | `name`, `type` (technology, market, consumer, regulatory, economic, social, environmental), `status`, `category`, `timeframe`, `strength`, `confidence`, `impact`, `impactAreas`, `drivers`, `signals`, `implications`, `opportunities`, `threats`, `relevance`, `actionRequired` |
1106
+ | **Opportunity** | `name`, `type` (market-expansion, product, acquisition, partnership, technology, cost-reduction), `status`, `source`, `potentialValue`, `probability`, `expectedValue`, `investmentRequired`, `roi`, `risks`, `benefits`, `requirements`, `owner`, `windowStart`, `windowEnd`, `priority`, `strategicFit` |
1107
+ | **SWOT** | `name`, `type` (company, product, market, competitor, project), `status`, `subject`, `strengths`, `weaknesses`, `opportunities`, `threats`, `overallAssessment`, `recommendations`, `actionItems`, `author`, `analysisDate`, `validUntil` |
1108
+ | **Industry** | `name`, `code`, `classification` (NAICS, SIC, GICS), `status`, `size`, `growthRate`, `employmentSize`, `majorPlayers`, `concentration`, `barriers`, `regulations`, `technologyDrivers`, `disruptions`, `trends`, `relevance` |
1109
+
1110
+ #### Actions & Events
1111
+
1112
+ | Entity | Actions | Events |
1113
+ |--------|---------|--------|
1114
+ | **Market** | create, update, analyze, enter, expand, exit, prioritize, segment, review | created, updated, analyzed, entered, expanded, exited, prioritized, segmented, reviewed |
1115
+ | **Competitor** | create, update, analyze, monitor, compare, benchmark, track, alert, archive | created, updated, analyzed, monitored, compared, benchmarked, tracked, alerted, archived |
1116
+ | **Trend** | create, update, identify, analyze, monitor, respond, archive, validate, escalate | created, updated, identified, analyzed, monitored, responded, archived, validated, escalated |
1117
+ | **Opportunity** | create, update, identify, evaluate, approve, decline, pursue, capture, abandon, review | created, updated, identified, evaluated, approved, declined, pursued, captured, abandoned, reviewed |
1118
+ | **SWOT** | create, update, conduct, review, approve, archive, share, revisit | created, updated, conducted, reviewed, approved, archived, shared, revisited |
1119
+ | **Industry** | create, update, analyze, monitor, enter, exit, benchmark, report | created, updated, analyzed, monitored, entered, exited, benchmarked, reported |
1120
+
1121
+ ---
1122
+
1123
+ ## Usage
1124
+
1125
+ ```typescript
1126
+ import {
1127
+ // Entity definitions (Noun pattern)
1128
+ Business, Vision, Value, // business
1129
+ Organization, Department, Team, // organization
1130
+ Goal, OKR, KeyResult, KPI, Metric, // goals
1131
+ Product, Service, Feature, PricingPlan, // offerings
1132
+ Process, Workflow, Policy, // operations
1133
+ Budget, Revenue, Expense, Investment, // financials
1134
+ Customer, Account, Contact, Segment, // customers
1135
+ Deal, Pipeline, Contract, Subscription, // sales
1136
+ Campaign, Lead, Audience, Content, Funnel, // marketing
1137
+ Partner, Vendor, Affiliate, Partnership, // partnerships
1138
+ Agreement, License, Compliance, // legal
1139
+ Risk, Mitigation, Incident, Control, // risk
1140
+ Project, Task, Milestone, Sprint, Epic, // projects
1141
+ Meeting, Decision, ActionItem, Feedback, // communication
1142
+ Asset, Inventory, Equipment, Facility, // assets
1143
+ Market, Competitor, Trend, Opportunity, // market
1144
+
1145
+ // All entities by category
1146
+ AllBusinessEntities,
1147
+ BusinessEntityCategories,
1148
+
1149
+ // Flat entity access
1150
+ Entities,
245
1151
  } from 'business-as-code'
1152
+
1153
+ // Access entity definitions
1154
+ console.log(Business.properties) // Property definitions
1155
+ console.log(Business.actions) // Available actions
1156
+ console.log(Business.events) // Possible events
1157
+
1158
+ // All 16 entity categories
1159
+ console.log(AllBusinessEntities.business) // Business, Vision, Value
1160
+ console.log(AllBusinessEntities.organization) // Organization, Department, Team, Position, Role, Worker
1161
+ console.log(AllBusinessEntities.goals) // Goal, OKR, KeyResult, KPI, Metric, Initiative
1162
+ console.log(AllBusinessEntities.offerings) // Product, Service, Feature, PricingPlan, RoadmapItem
1163
+ console.log(AllBusinessEntities.operations) // Process, ProcessStep, Workflow, WorkflowAction, WorkflowRun, Policy
1164
+ console.log(AllBusinessEntities.financials) // Budget, Revenue, Expense, Investment, FinancialPeriod, Forecast
1165
+ console.log(AllBusinessEntities.customers) // Customer, Account, Contact, Segment, Persona, Interaction
1166
+ console.log(AllBusinessEntities.sales) // Deal, Pipeline, Stage, Contract, Subscription, Quote, Order, Invoice
1167
+ console.log(AllBusinessEntities.marketing) // Campaign, Lead, Audience, Content, Funnel, FunnelStage, MarketingEvent
1168
+ console.log(AllBusinessEntities.partnerships) // Partner, Vendor, Affiliate, Partnership, Integration, Reseller
1169
+ console.log(AllBusinessEntities.legal) // Agreement, License, IntellectualProperty, Compliance, LegalPolicy, Trademark
1170
+ console.log(AllBusinessEntities.risk) // Risk, Mitigation, Incident, Control, Assessment, Issue
1171
+ console.log(AllBusinessEntities.projects) // Project, Task, Milestone, Sprint, Deliverable, Epic, Story, Resource
1172
+ console.log(AllBusinessEntities.communication) // Meeting, Decision, ActionItem, Announcement, Feedback, Discussion
1173
+ console.log(AllBusinessEntities.assets) // Asset, Inventory, Equipment, Facility, Software, DataAsset
1174
+ console.log(AllBusinessEntities.market) // Market, Competitor, Trend, Opportunity, SWOT, Industry
246
1175
  ```
247
1176
 
248
- ## Integration
1177
+ ---
1178
+
1179
+ ## Use Cases
1180
+
1181
+ ### Startup Planning
1182
+ Define your business model, track runway, and monitor growth metrics.
1183
+
1184
+ ### Strategic Planning
1185
+ Set OKRs, track goals, and measure progress toward vision.
1186
+
1187
+ ### Financial Modeling
1188
+ Calculate margins, growth rates, and SaaS metrics.
1189
+
1190
+ ### Process Documentation
1191
+ Document business processes with automation levels and metrics.
249
1192
 
250
- `business-as-code` provides the schema layer that integrates with the broader .do ecosystem:
1193
+ ### Dashboard Building
1194
+ Power business dashboards with structured data.
251
1195
 
252
- - **[db.sb](https://db.sb)** - Database runtime that executes these schemas
253
- - **[Startups.Studio](https://startups.studio)** - AI-operated autonomous startups
254
- - **[Platform.do](https://platform.do)** - Enterprise business platform
255
- - **[agents.do](https://agents.do)** - AI agents for business operations
256
- - **[workflows.do](https://workflows.do)** - Business process automation
257
- - **[humans.do](https://humans.do)** - Human role definitions
1196
+ ### AI Agent Integration
1197
+ Entity definitions power AI agents with structured business context.
258
1198
 
259
1199
  ## License
260
1200