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/dist/index.js CHANGED
@@ -1,1080 +1,132 @@
1
- // src/schema/domains/admin.ts
2
- var Users = {
3
- slug: "users",
4
- group: "Admin",
5
- titleField: "email",
6
- fields: [
7
- { name: "email", type: "email", required: true, unique: true },
8
- { name: "name", type: "text" },
9
- { name: "avatar", type: "image" },
10
- { name: "role", type: "status", options: ["admin", "user", "viewer"] }
11
- ]
12
- };
13
- var Orgs = {
14
- slug: "orgs",
15
- group: "Admin",
16
- titleField: "name",
17
- fields: [
18
- { name: "name", type: "text", required: true },
19
- { name: "slug", type: "text", required: true, unique: true },
20
- { name: "logo", type: "image" },
21
- { name: "domain", type: "text" }
22
- ]
23
- };
24
- var ServiceAccounts = {
25
- slug: "service-accounts",
26
- group: "Admin",
27
- titleField: "name",
28
- fields: [
29
- { name: "name", type: "text", required: true },
30
- { name: "org", type: "ref", config: { relationTo: "orgs" } },
31
- { name: "apiKey", type: "text", unique: true },
32
- { name: "scopes", type: "array" }
33
- ]
34
- };
35
- var adminNouns = [Users, Orgs, ServiceAccounts];
36
-
37
- // src/schema/domains/business.ts
38
- var Businesses = {
39
- slug: "businesses",
40
- group: "Business",
41
- titleField: "name",
42
- fields: [
43
- { name: "name", type: "text", required: true },
44
- { name: "legalName", type: "text" },
45
- { name: "type", type: "status", options: ["LLC", "Corporation", "Partnership", "Sole Proprietorship", "Nonprofit"] },
46
- { name: "status", type: "status", options: ["Active", "Inactive", "Dissolved"] },
47
- { name: "foundedDate", type: "date" },
48
- { name: "website", type: "url" },
49
- { name: "description", type: "rich" }
50
- ]
51
- };
52
- var Goals = {
53
- slug: "goals",
54
- group: "Business",
55
- titleField: "name",
56
- fields: [
57
- { name: "name", type: "text", required: true },
58
- { name: "business", type: "ref", config: { relationTo: "businesses" } },
59
- { name: "type", type: "status", options: ["Revenue", "Growth", "Retention", "Efficiency", "Quality"] },
60
- { name: "targetValue", type: "number" },
61
- { name: "currentValue", type: "number" },
62
- { name: "unit", type: "text" },
63
- { name: "deadline", type: "date" },
64
- { name: "status", type: "status", options: ["Not Started", "In Progress", "At Risk", "Achieved"] }
65
- ]
66
- };
67
- var Metrics = {
68
- slug: "metrics",
69
- group: "Business",
70
- titleField: "name",
71
- fields: [
72
- { name: "name", type: "text", required: true },
73
- { name: "business", type: "ref", config: { relationTo: "businesses" } },
74
- { name: "type", type: "status", options: ["KPI", "OKR", "North Star", "Health", "Vanity"] },
75
- { name: "value", type: "number" },
76
- { name: "unit", type: "text" },
77
- { name: "frequency", type: "status", options: ["Real-time", "Daily", "Weekly", "Monthly", "Quarterly"] }
78
- ]
79
- };
80
- var Teams = {
81
- slug: "teams",
82
- group: "Business",
83
- titleField: "name",
84
- fields: [
85
- { name: "name", type: "text", required: true },
86
- { name: "business", type: "ref", config: { relationTo: "businesses" } },
87
- { name: "type", type: "status", options: ["Engineering", "Product", "Design", "Marketing", "Sales", "Support", "Operations", "Finance", "HR", "Legal"] },
88
- { name: "description", type: "text" }
89
- ]
90
- };
91
- var Processes = {
92
- slug: "processes",
93
- group: "Business",
94
- titleField: "name",
95
- fields: [
96
- { name: "name", type: "text", required: true },
97
- { name: "business", type: "ref", config: { relationTo: "businesses" } },
98
- { name: "type", type: "status", options: ["Core", "Support", "Management"] },
99
- { name: "owner", type: "ref", config: { relationTo: "teams" } },
100
- { name: "description", type: "rich" },
101
- { name: "status", type: "status", options: ["Draft", "Active", "Deprecated"] }
102
- ]
103
- };
104
- var businessNouns = [Businesses, Goals, Metrics, Teams, Processes];
105
-
106
- // src/schema/domains/product.ts
107
- var Products = {
108
- slug: "products",
109
- group: "Product",
110
- titleField: "name",
111
- fields: [
112
- { name: "name", type: "text", required: true },
113
- { name: "business", type: "ref", config: { relationTo: "businesses" } },
114
- { name: "type", type: "status", options: ["API", "App", "CLI", "SDK", "MCP", "Agent", "Dataset", "DataFeed", "Function", "Database", "Queue", "Storage", "Cache", "Platform"] },
115
- { name: "description", type: "text" },
116
- { name: "isActive", type: "boolean" },
117
- { name: "stripeProductId", type: "text", unique: true }
118
- ]
119
- };
120
- var Services = {
121
- slug: "services",
122
- group: "Product",
123
- titleField: "name",
124
- fields: [
125
- { name: "name", type: "text", required: true },
126
- { name: "business", type: "ref", config: { relationTo: "businesses" } },
127
- { name: "type", type: "status", options: ["Consulting", "Implementation", "Training", "Support", "Managed"] },
128
- { name: "description", type: "text" },
129
- { name: "hourlyRate", type: "money" },
130
- { name: "isActive", type: "boolean" }
131
- ]
132
- };
133
- var Offers = {
134
- slug: "offers",
135
- group: "Product",
136
- titleField: "name",
137
- fields: [
138
- { name: "name", type: "text", required: true },
139
- { name: "products", type: "ref", config: { relationTo: "products", hasMany: true } },
140
- { name: "type", type: "status", options: ["Trial", "Freemium", "Subscription", "One-time", "Usage-based"] },
141
- { name: "description", type: "text" },
142
- { name: "isActive", type: "boolean" }
143
- ]
144
- };
145
- var Prices = {
146
- slug: "prices",
147
- group: "Product",
148
- titleField: "name",
149
- fields: [
150
- { name: "name", type: "text", required: true },
151
- { name: "offer", type: "ref", config: { relationTo: "offers" } },
152
- { name: "amount", type: "money", required: true },
153
- { name: "currency", type: "status", options: ["USD", "EUR", "GBP", "JPY"] },
154
- { name: "interval", type: "status", options: ["once", "day", "week", "month", "year"] },
155
- { name: "stripePriceId", type: "text", unique: true },
156
- { name: "isActive", type: "boolean" }
157
- ]
158
- };
159
- var Features = {
160
- slug: "features",
161
- group: "Product",
162
- titleField: "name",
163
- fields: [
164
- { name: "name", type: "text", required: true },
165
- { name: "product", type: "ref", config: { relationTo: "products" } },
166
- { name: "description", type: "text" },
167
- { name: "type", type: "status", options: ["Core", "Premium", "Enterprise", "Add-on"] },
168
- { name: "status", type: "status", options: ["Planned", "In Development", "Beta", "GA", "Deprecated"] }
169
- ]
170
- };
171
- var productNouns = [Products, Services, Offers, Prices, Features];
172
-
173
- // src/schema/domains/success.ts
174
- var Customers = {
175
- slug: "customers",
176
- group: "Success",
177
- titleField: "name",
178
- fields: [
179
- { name: "name", type: "text", required: true },
180
- { name: "type", type: "status", options: ["Business", "Developer", "Consumer", "Professional"], required: true },
181
- { name: "user", type: "ref", config: { relationTo: "users" } },
182
- { name: "business", type: "ref", config: { relationTo: "businesses" } },
183
- { name: "company", type: "text" },
184
- { name: "email", type: "email" },
185
- { name: "stripeCustomerId", type: "text", unique: true },
186
- { name: "status", type: "status", options: ["Active", "Churned", "Paused"] },
187
- { name: "healthScore", type: "score" }
188
- ]
189
- };
190
- var Contacts = {
191
- slug: "contacts",
192
- group: "Success",
193
- titleField: "name",
194
- fields: [
195
- { name: "name", type: "text", required: true },
196
- { name: "customer", type: "ref", config: { relationTo: "customers" } },
197
- { name: "email", type: "email" },
198
- { name: "phone", type: "text" },
199
- { name: "title", type: "text" },
200
- { name: "role", type: "status", options: ["Decision Maker", "Influencer", "Champion", "End User", "Billing"] },
201
- { name: "isPrimary", type: "boolean" }
202
- ]
203
- };
204
- var Subscriptions = {
205
- slug: "subscriptions",
206
- group: "Success",
207
- titleField: "id",
208
- fields: [
209
- { name: "customer", type: "ref", config: { relationTo: "customers" }, required: true },
210
- { name: "offer", type: "ref", config: { relationTo: "offers" } },
211
- { name: "price", type: "ref", config: { relationTo: "prices" } },
212
- { name: "status", type: "status", options: ["Active", "Past Due", "Canceled", "Paused", "Trialing"] },
213
- { name: "stripeSubscriptionId", type: "text", unique: true },
214
- { name: "currentPeriodStart", type: "date" },
215
- { name: "currentPeriodEnd", type: "date" },
216
- { name: "canceledAt", type: "date" }
217
- ]
218
- };
219
- var successNouns = [Customers, Contacts, Subscriptions];
220
-
221
- // src/schema/domains/sales.ts
222
- var Deals = {
223
- slug: "deals",
224
- group: "Sales",
225
- titleField: "name",
226
- fields: [
227
- { name: "name", type: "text", required: true },
228
- { name: "customer", type: "ref", config: { relationTo: "customers" } },
229
- { name: "contact", type: "ref", config: { relationTo: "contacts" } },
230
- { name: "value", type: "money" },
231
- { name: "stage", type: "status", options: ["Qualification", "Discovery", "Proposal", "Negotiation", "Closed Won", "Closed Lost"] },
232
- { name: "probability", type: "score" },
233
- { name: "expectedCloseDate", type: "date" },
234
- { name: "actualCloseDate", type: "date" },
235
- { name: "lostReason", type: "text" }
236
- ]
237
- };
238
- var Quotes = {
239
- slug: "quotes",
240
- group: "Sales",
241
- titleField: "name",
242
- fields: [
243
- { name: "name", type: "text", required: true },
244
- { name: "deal", type: "ref", config: { relationTo: "deals" } },
245
- { name: "customer", type: "ref", config: { relationTo: "customers" } },
246
- { name: "total", type: "money", required: true },
247
- { name: "status", type: "status", options: ["Draft", "Sent", "Viewed", "Accepted", "Rejected", "Expired"] },
248
- { name: "validUntil", type: "date" },
249
- { name: "terms", type: "rich" }
250
- ]
251
- };
252
- var Proposals = {
253
- slug: "proposals",
254
- group: "Sales",
255
- titleField: "name",
256
- fields: [
257
- { name: "name", type: "text", required: true },
258
- { name: "deal", type: "ref", config: { relationTo: "deals" } },
259
- { name: "customer", type: "ref", config: { relationTo: "customers" } },
260
- { name: "content", type: "rich" },
261
- { name: "status", type: "status", options: ["Draft", "In Review", "Sent", "Accepted", "Rejected"] },
262
- { name: "sentAt", type: "date" }
263
- ]
264
- };
265
- var salesNouns = [Deals, Quotes, Proposals];
266
-
267
- // src/schema/domains/marketing.ts
268
- var Leads = {
269
- slug: "leads",
270
- group: "Marketing",
271
- titleField: "email",
272
- fields: [
273
- { name: "email", type: "email", required: true },
274
- { name: "name", type: "text" },
275
- { name: "company", type: "text" },
276
- { name: "title", type: "text" },
277
- { name: "source", type: "status", options: ["Website", "Referral", "Event", "Ads", "Content", "Outbound", "Partner"] },
278
- { name: "status", type: "status", options: ["New", "Contacted", "Qualified", "Unqualified", "Converted"] },
279
- { name: "score", type: "score" },
280
- { name: "convertedTo", type: "ref", config: { relationTo: "customers" } }
281
- ]
282
- };
283
- var Brands = {
284
- slug: "brands",
285
- group: "Marketing",
286
- titleField: "name",
287
- fields: [
288
- { name: "name", type: "text", required: true },
289
- { name: "business", type: "ref", config: { relationTo: "businesses" } },
290
- { name: "tagline", type: "text" },
291
- { name: "description", type: "rich" },
292
- { name: "logo", type: "image" },
293
- { name: "primaryColor", type: "text" },
294
- { name: "secondaryColor", type: "text" }
295
- ]
296
- };
297
- var Domains = {
298
- slug: "domains",
299
- group: "Marketing",
300
- titleField: "domain",
301
- fields: [
302
- { name: "domain", type: "text", required: true, unique: true },
303
- { name: "business", type: "ref", config: { relationTo: "businesses" } },
304
- { name: "brand", type: "ref", config: { relationTo: "brands" } },
305
- { name: "type", type: "status", options: ["Primary", "Redirect", "Vanity", "Product"] },
306
- { name: "status", type: "status", options: ["Active", "Pending", "Expired"] },
307
- { name: "registrar", type: "text" },
308
- { name: "expiresAt", type: "date" }
309
- ]
310
- };
311
- var Competitors = {
312
- slug: "competitors",
313
- group: "Marketing",
314
- titleField: "name",
315
- fields: [
316
- { name: "name", type: "text", required: true },
317
- { name: "business", type: "ref", config: { relationTo: "businesses" } },
318
- { name: "website", type: "url" },
319
- { name: "description", type: "text" },
320
- { name: "strengths", type: "rich" },
321
- { name: "weaknesses", type: "rich" },
322
- { name: "threat", type: "status", options: ["Low", "Medium", "High", "Critical"] }
323
- ]
324
- };
325
- var marketingNouns = [Leads, Brands, Domains, Competitors];
326
-
327
- // src/schema/domains/work.ts
328
- var Projects = {
329
- slug: "projects",
330
- group: "Work",
331
- titleField: "name",
332
- fields: [
333
- { name: "name", type: "text", required: true },
334
- { name: "business", type: "ref", config: { relationTo: "businesses" } },
335
- { name: "team", type: "ref", config: { relationTo: "teams" } },
336
- { name: "description", type: "rich" },
337
- { name: "status", type: "status", options: ["Planning", "Active", "On Hold", "Completed", "Archived"] },
338
- { name: "startDate", type: "date" },
339
- { name: "targetDate", type: "date" },
340
- { name: "completedDate", type: "date" }
341
- ]
342
- };
343
- var Tasks = {
344
- slug: "tasks",
345
- group: "Work",
346
- titleField: "title",
347
- fields: [
348
- { name: "title", type: "text", required: true },
349
- { name: "project", type: "ref", config: { relationTo: "projects" } },
350
- { name: "assignee", type: "ref", config: { relationTo: "users" } },
351
- { name: "description", type: "rich" },
352
- { name: "status", type: "status", options: ["Backlog", "Todo", "In Progress", "In Review", "Done"] },
353
- { name: "priority", type: "status", options: ["Low", "Medium", "High", "Urgent"] },
354
- { name: "dueDate", type: "date" },
355
- { name: "estimatedHours", type: "number" },
356
- { name: "actualHours", type: "number" }
357
- ]
358
- };
359
- var Issues = {
360
- slug: "issues",
361
- group: "Work",
362
- titleField: "title",
363
- fields: [
364
- { name: "title", type: "text", required: true },
365
- { name: "project", type: "ref", config: { relationTo: "projects" } },
366
- { name: "reporter", type: "ref", config: { relationTo: "users" } },
367
- { name: "assignee", type: "ref", config: { relationTo: "users" } },
368
- { name: "description", type: "rich" },
369
- { name: "type", type: "status", options: ["Bug", "Feature", "Task", "Epic", "Story"] },
370
- { name: "status", type: "status", options: ["Open", "In Progress", "Resolved", "Closed"] },
371
- { name: "priority", type: "status", options: ["Low", "Medium", "High", "Critical"] }
372
- ]
373
- };
374
- var Workflows = {
375
- slug: "workflows",
376
- group: "Work",
377
- titleField: "name",
378
- fields: [
379
- { name: "name", type: "text", required: true },
380
- { name: "business", type: "ref", config: { relationTo: "businesses" } },
381
- { name: "description", type: "text" },
382
- { name: "trigger", type: "status", options: ["Manual", "Schedule", "Event", "Webhook"] },
383
- { name: "status", type: "status", options: ["Draft", "Active", "Paused", "Archived"] }
384
- ]
385
- };
386
- var Roles = {
387
- slug: "roles",
388
- group: "Work",
389
- titleField: "name",
390
- fields: [
391
- { name: "name", type: "text", required: true },
392
- { name: "business", type: "ref", config: { relationTo: "businesses" } },
393
- { name: "team", type: "ref", config: { relationTo: "teams" } },
394
- { name: "description", type: "text" },
395
- { name: "level", type: "status", options: ["Individual Contributor", "Lead", "Manager", "Director", "VP", "C-Level"] }
396
- ]
397
- };
398
- var Agents = {
399
- slug: "agents",
400
- group: "Work",
401
- titleField: "name",
402
- fields: [
403
- { name: "name", type: "text", required: true },
404
- { name: "business", type: "ref", config: { relationTo: "businesses" } },
405
- { name: "role", type: "ref", config: { relationTo: "roles" } },
406
- { name: "type", type: "status", options: ["AI", "Human", "Hybrid"] },
407
- { name: "status", type: "status", options: ["Active", "Paused", "Retired"] },
408
- { name: "capabilities", type: "array" }
409
- ]
410
- };
411
- var workNouns = [Projects, Tasks, Issues, Workflows, Roles, Agents];
412
-
413
- // src/schema/domains/financial.ts
414
- var Invoices = {
415
- slug: "invoices",
416
- group: "Financial",
417
- titleField: "number",
418
- fields: [
419
- { name: "number", type: "text", required: true, unique: true },
420
- { name: "customer", type: "ref", config: { relationTo: "customers" } },
421
- { name: "subscription", type: "ref", config: { relationTo: "subscriptions" } },
422
- { name: "total", type: "money", required: true },
423
- { name: "tax", type: "money" },
424
- { name: "status", type: "status", options: ["Draft", "Sent", "Paid", "Void", "Uncollectible"] },
425
- { name: "dueDate", type: "date" },
426
- { name: "paidAt", type: "date" },
427
- { name: "stripeInvoiceId", type: "text", unique: true }
428
- ]
429
- };
430
- var Payments = {
431
- slug: "payments",
432
- group: "Financial",
433
- titleField: "id",
434
- fields: [
435
- { name: "customer", type: "ref", config: { relationTo: "customers" } },
436
- { name: "invoice", type: "ref", config: { relationTo: "invoices" } },
437
- { name: "amount", type: "money", required: true },
438
- { name: "currency", type: "status", options: ["USD", "EUR", "GBP", "JPY"] },
439
- { name: "status", type: "status", options: ["Pending", "Succeeded", "Failed", "Refunded"] },
440
- { name: "method", type: "status", options: ["Card", "ACH", "Wire", "Check"] },
441
- { name: "stripePaymentId", type: "text", unique: true }
442
- ]
443
- };
444
- var Refunds = {
445
- slug: "refunds",
446
- group: "Financial",
447
- titleField: "id",
448
- fields: [
449
- { name: "payment", type: "ref", config: { relationTo: "payments" }, required: true },
450
- { name: "amount", type: "money", required: true },
451
- { name: "reason", type: "status", options: ["Duplicate", "Fraudulent", "Customer Request", "Product Issue"] },
452
- { name: "status", type: "status", options: ["Pending", "Succeeded", "Failed"] },
453
- { name: "notes", type: "text" }
454
- ]
455
- };
456
- var ChartOfAccounts = {
457
- slug: "chart-of-accounts",
458
- group: "Financial",
459
- titleField: "name",
460
- fields: [
461
- { name: "code", type: "text", required: true, unique: true },
462
- { name: "name", type: "text", required: true },
463
- { name: "type", type: "status", options: ["Asset", "Liability", "Equity", "Revenue", "Expense"], required: true },
464
- { name: "subtype", type: "text" },
465
- { name: "description", type: "text" },
466
- { name: "isActive", type: "boolean" }
467
- ]
468
- };
469
- var JournalEntries = {
470
- slug: "journal-entries",
471
- group: "Financial",
472
- titleField: "reference",
473
- fields: [
474
- { name: "reference", type: "text", required: true },
475
- { name: "date", type: "date", required: true },
476
- { name: "description", type: "text" },
477
- { name: "debitAccount", type: "ref", config: { relationTo: "chart-of-accounts" } },
478
- { name: "creditAccount", type: "ref", config: { relationTo: "chart-of-accounts" } },
479
- { name: "amount", type: "money", required: true },
480
- { name: "status", type: "status", options: ["Draft", "Posted", "Voided"] }
481
- ]
482
- };
483
- var financialNouns = [Invoices, Payments, Refunds, ChartOfAccounts, JournalEntries];
484
-
485
- // src/schema/domains/communications.ts
486
- var Channels = {
487
- slug: "channels",
488
- group: "Communications",
489
- titleField: "name",
490
- fields: [
491
- { name: "name", type: "text", required: true },
492
- { name: "type", type: "status", options: ["Email", "SMS", "Slack", "Discord", "WhatsApp", "In-App", "Push"] },
493
- { name: "business", type: "ref", config: { relationTo: "businesses" } },
494
- { name: "isActive", type: "boolean" },
495
- { name: "config", type: "text" }
496
- ]
497
- };
498
- var Messages = {
499
- slug: "messages",
500
- group: "Communications",
501
- titleField: "subject",
502
- fields: [
503
- { name: "subject", type: "text" },
504
- { name: "body", type: "rich", required: true },
505
- { name: "channel", type: "ref", config: { relationTo: "channels" } },
506
- { name: "from", type: "text" },
507
- { name: "to", type: "text", required: true },
508
- { name: "status", type: "status", options: ["Draft", "Queued", "Sent", "Delivered", "Bounced", "Failed"] },
509
- { name: "sentAt", type: "date" },
510
- { name: "openedAt", type: "date" },
511
- { name: "clickedAt", type: "date" }
512
- ]
513
- };
514
- var Sequences = {
515
- slug: "sequences",
516
- group: "Communications",
517
- titleField: "name",
518
- fields: [
519
- { name: "name", type: "text", required: true },
520
- { name: "business", type: "ref", config: { relationTo: "businesses" } },
521
- { name: "type", type: "status", options: ["Onboarding", "Nurture", "Re-engagement", "Upsell", "Support"] },
522
- { name: "status", type: "status", options: ["Draft", "Active", "Paused", "Archived"] },
523
- { name: "description", type: "text" }
524
- ]
525
- };
526
- var Templates = {
527
- slug: "templates",
528
- group: "Communications",
529
- titleField: "name",
530
- fields: [
531
- { name: "name", type: "text", required: true },
532
- { name: "channel", type: "ref", config: { relationTo: "channels" } },
533
- { name: "subject", type: "text" },
534
- { name: "body", type: "rich", required: true },
535
- { name: "type", type: "status", options: ["Transactional", "Marketing", "System"] },
536
- { name: "isActive", type: "boolean" }
537
- ]
538
- };
539
- var Posts = {
540
- slug: "posts",
541
- group: "Communications",
542
- titleField: "title",
543
- fields: [
544
- { name: "title", type: "text", required: true },
545
- { name: "content", type: "rich", required: true },
546
- { name: "author", type: "ref", config: { relationTo: "users" } },
547
- { name: "business", type: "ref", config: { relationTo: "businesses" } },
548
- { name: "status", type: "status", options: ["Draft", "Scheduled", "Published", "Archived"] },
549
- { name: "publishedAt", type: "date" },
550
- { name: "channels", type: "ref", config: { relationTo: "channels", hasMany: true } }
551
- ]
552
- };
553
- var communicationsNouns = [Channels, Messages, Sequences, Templates, Posts];
554
-
555
- // src/schema/index.ts
556
- var defaultBusinessSchema = {
557
- name: "default",
558
- version: "1.0.0",
559
- description: "Default business schema with all standard domains",
560
- domains: {
561
- admin: adminNouns,
562
- business: businessNouns,
563
- product: productNouns,
564
- success: successNouns,
565
- sales: salesNouns,
566
- marketing: marketingNouns,
567
- work: workNouns,
568
- financial: financialNouns,
569
- communications: communicationsNouns
570
- }
571
- };
572
- function getAllNouns(schema) {
573
- const nouns = [];
574
- for (const domain of Object.values(schema.domains)) {
575
- if (domain) {
576
- nouns.push(...domain);
577
- }
578
- }
579
- return nouns;
580
- }
581
- function getDomainNouns(schema, domain) {
582
- return schema.domains[domain] || [];
583
- }
584
- function findNounBySlug(schema, slug) {
585
- for (const domain of Object.values(schema.domains)) {
586
- if (domain) {
587
- const noun = domain.find((n) => n.slug === slug);
588
- if (noun) return noun;
589
- }
590
- }
591
- return void 0;
592
- }
593
- function getDomains(schema) {
594
- return Object.keys(schema.domains);
595
- }
596
- function mergeSchemas(base, extension) {
597
- const merged = {
598
- name: extension.name || base.name,
599
- version: extension.version || base.version,
600
- description: extension.description || base.description,
601
- domains: { ...base.domains }
602
- };
603
- if (extension.domains) {
604
- for (const [domain, nouns] of Object.entries(extension.domains)) {
605
- if (nouns) {
606
- const existing = merged.domains[domain] || [];
607
- const existingSlugs = new Set(existing.map((n) => n.slug));
608
- const newNouns = nouns.filter((n) => !existingSlugs.has(n.slug));
609
- const overrides = nouns.filter((n) => existingSlugs.has(n.slug));
610
- merged.domains[domain] = [
611
- ...existing.filter((n) => !overrides.find((o) => o.slug === n.slug)),
612
- ...overrides,
613
- ...newNouns
614
- ];
615
- }
616
- }
617
- }
618
- return merged;
619
- }
620
- function createMinimalSchema(domains, options) {
621
- const schema = {
622
- name: options?.name || "minimal",
623
- version: options?.version || "1.0.0",
624
- domains: {}
625
- };
626
- for (const domain of domains) {
627
- schema.domains[domain] = defaultBusinessSchema.domains[domain];
628
- }
629
- return schema;
630
- }
631
- function validateSchema(schema) {
632
- const errors = [];
633
- if (!schema.name) {
634
- errors.push("Schema must have a name");
635
- }
636
- if (!schema.version) {
637
- errors.push("Schema must have a version");
638
- }
639
- const allSlugs = /* @__PURE__ */ new Set();
640
- for (const [domain, nouns] of Object.entries(schema.domains)) {
641
- if (nouns) {
642
- for (const noun of nouns) {
643
- if (!noun.slug) {
644
- errors.push(`Noun in domain '${domain}' is missing a slug`);
645
- } else if (allSlugs.has(noun.slug)) {
646
- errors.push(`Duplicate slug '${noun.slug}' found in domain '${domain}'`);
647
- } else {
648
- allSlugs.add(noun.slug);
649
- }
650
- if (!noun.fields || noun.fields.length === 0) {
651
- errors.push(`Noun '${noun.slug}' has no fields`);
652
- }
653
- }
654
- }
655
- }
656
- return errors;
657
- }
658
-
659
- // src/loaders/mdx.ts
660
- import { parseMDXAsync, extractNodesByName } from "db.sb";
661
- function nodeToNounSchema(node) {
662
- const fields = [];
663
- if (node.children) {
664
- for (const child of node.children) {
665
- if (typeof child === "object" && "__dsl" in child) {
666
- const fieldNode = child;
667
- fields.push({
668
- name: fieldNode.name,
669
- type: fieldNode.type,
670
- required: fieldNode.props.required,
671
- unique: fieldNode.props.unique,
672
- config: fieldNode.props
673
- });
674
- }
675
- }
676
- }
677
- return {
678
- slug: node.props.slug || node.name,
679
- group: node.props.group,
680
- titleField: node.props.titleField || node.props.useAsTitle,
681
- fields
682
- };
683
- }
684
- async function loadFromMDX(source, options = {}) {
685
- const ast = await parseMDXAsync(source, options.context || "app");
686
- const name = ast.props.name || "unnamed";
687
- const version = ast.props.version || "1.0.0";
688
- const description = ast.props.description;
689
- const nounNodes = extractNodesByName(ast, "noun");
690
- const domains = {};
691
- for (const node of nounNodes) {
692
- const noun = nodeToNounSchema(node);
693
- const group = noun.group?.toLowerCase() || "business";
694
- if (!domains[group]) {
695
- domains[group] = [];
696
- }
697
- domains[group].push(noun);
698
- }
699
- return {
700
- name,
701
- version,
702
- description,
703
- domains
704
- };
705
- }
706
- async function loadNounFromMDX(source, options = {}) {
707
- const ast = await parseMDXAsync(source, options.context || "noun");
708
- if (ast.name !== "noun") {
709
- const nounNodes = extractNodesByName(ast, "noun");
710
- if (nounNodes.length === 0) {
711
- throw new Error("No Noun definition found in MDX");
712
- }
713
- return nodeToNounSchema(nounNodes[0]);
714
- }
715
- return nodeToNounSchema(ast);
716
- }
717
- async function loadNounsFromMDX(source, options = {}) {
718
- const ast = await parseMDXAsync(source, options.context || "app");
719
- const nounNodes = extractNodesByName(ast, "noun");
720
- return nounNodes.map(nodeToNounSchema);
721
- }
722
-
723
- // src/loaders/yaml.ts
724
- import YAML from "yaml";
725
- function parseFieldShorthand(name, value) {
726
- if (typeof value === "object") {
727
- return { ...value, name };
728
- }
729
- const parts = value.split(" ");
730
- const field = { name, type: "text" };
731
- for (const part of parts) {
732
- if (part === "required") {
733
- field.required = true;
734
- } else if (part === "unique") {
735
- field.unique = true;
736
- } else if (part.includes(":")) {
737
- const [type, options] = part.split(":");
738
- field.type = type;
739
- if (type === "status" || type === "select") {
740
- field.options = options.split("|");
741
- } else if (type === "ref") {
742
- field.to = options;
743
- }
744
- } else {
745
- field.type = part;
746
- }
747
- }
748
- return field;
749
- }
750
- function parseNoun(data) {
751
- const fields = [];
752
- if (data.fields) {
753
- if (Array.isArray(data.fields)) {
754
- for (const field of data.fields) {
755
- fields.push(field);
756
- }
757
- } else {
758
- for (const [name, value] of Object.entries(data.fields)) {
759
- fields.push(parseFieldShorthand(name, value));
760
- }
761
- }
762
- }
763
- return {
764
- slug: data.slug || data.name?.toLowerCase().replace(/\s+/g, "-"),
765
- group: data.group,
766
- titleField: data.titleField || data.useAsTitle,
767
- fields
768
- };
769
- }
770
- function loadFromYAML(source, _options = {}) {
771
- const data = YAML.parse(source);
772
- const schema = {
773
- name: data.name || "unnamed",
774
- version: data.version || "1.0.0",
775
- description: data.description,
776
- domains: {}
777
- };
778
- if (data.domains) {
779
- for (const [domain, nouns] of Object.entries(data.domains)) {
780
- if (Array.isArray(nouns)) {
781
- schema.domains[domain] = nouns.map(parseNoun);
782
- }
783
- }
784
- }
785
- if (data.nouns) {
786
- for (const nounData of data.nouns) {
787
- const noun = parseNoun(nounData);
788
- const domain = noun.group?.toLowerCase() || "business";
789
- if (!schema.domains[domain]) {
790
- schema.domains[domain] = [];
791
- }
792
- schema.domains[domain].push(noun);
793
- }
794
- }
795
- return schema;
796
- }
797
- function loadNounFromYAML(source, _options = {}) {
798
- const data = YAML.parse(source);
799
- return parseNoun(data);
800
- }
801
- function loadNounsFromYAML(source, _options = {}) {
802
- const data = YAML.parse(source);
803
- if (Array.isArray(data)) {
804
- return data.map(parseNoun);
805
- }
806
- if (data.nouns) {
807
- return data.nouns.map(parseNoun);
808
- }
809
- return [parseNoun(data)];
810
- }
811
- function toYAML(schema) {
812
- return YAML.stringify({
813
- name: schema.name,
814
- version: schema.version,
815
- description: schema.description,
816
- domains: schema.domains
817
- });
818
- }
819
- function nounToYAML(noun) {
820
- return YAML.stringify(noun);
821
- }
822
-
823
- // src/loaders/json.ts
824
- function parseFieldShorthand2(name, value) {
825
- if (typeof value === "object") {
826
- return { ...value, name };
827
- }
828
- const parts = value.split(" ");
829
- const field = { name, type: "text" };
830
- for (const part of parts) {
831
- if (part === "required") {
832
- field.required = true;
833
- } else if (part === "unique") {
834
- field.unique = true;
835
- } else if (part.includes(":")) {
836
- const [type, options] = part.split(":");
837
- field.type = type;
838
- if (type === "status" || type === "select") {
839
- field.options = options.split("|");
840
- } else if (type === "ref") {
841
- field.to = options;
842
- }
843
- } else {
844
- field.type = part;
845
- }
846
- }
847
- return field;
848
- }
849
- function parseNoun2(data) {
850
- const fields = [];
851
- if (data.fields) {
852
- if (Array.isArray(data.fields)) {
853
- for (const field of data.fields) {
854
- fields.push(field);
855
- }
856
- } else {
857
- for (const [name, value] of Object.entries(data.fields)) {
858
- fields.push(parseFieldShorthand2(name, value));
859
- }
860
- }
861
- }
862
- return {
863
- slug: data.slug || data.name?.toLowerCase().replace(/\s+/g, "-"),
864
- group: data.group,
865
- titleField: data.titleField || data.useAsTitle,
866
- fields
867
- };
868
- }
869
- function loadFromJSON(source, _options = {}) {
870
- const data = JSON.parse(source);
871
- const schema = {
872
- name: data.name || "unnamed",
873
- version: data.version || "1.0.0",
874
- description: data.description,
875
- domains: {}
876
- };
877
- if (data.domains) {
878
- for (const [domain, nouns] of Object.entries(data.domains)) {
879
- if (Array.isArray(nouns)) {
880
- schema.domains[domain] = nouns.map(parseNoun2);
881
- }
882
- }
883
- }
884
- if (data.nouns) {
885
- for (const nounData of data.nouns) {
886
- const noun = parseNoun2(nounData);
887
- const domain = noun.group?.toLowerCase() || "business";
888
- if (!schema.domains[domain]) {
889
- schema.domains[domain] = [];
890
- }
891
- schema.domains[domain].push(noun);
892
- }
893
- }
894
- return schema;
895
- }
896
- function loadNounFromJSON(source, _options = {}) {
897
- const data = JSON.parse(source);
898
- return parseNoun2(data);
899
- }
900
- function loadNounsFromJSON(source, _options = {}) {
901
- const data = JSON.parse(source);
902
- if (Array.isArray(data)) {
903
- return data.map(parseNoun2);
904
- }
905
- if (data.nouns) {
906
- return data.nouns.map(parseNoun2);
907
- }
908
- return [parseNoun2(data)];
909
- }
910
- function toJSON(schema, pretty = true) {
911
- return JSON.stringify(
912
- {
913
- name: schema.name,
914
- version: schema.version,
915
- description: schema.description,
916
- domains: schema.domains
917
- },
918
- null,
919
- pretty ? 2 : void 0
920
- );
921
- }
922
- function nounToJSON(noun, pretty = true) {
923
- return JSON.stringify(noun, null, pretty ? 2 : void 0);
924
- }
925
-
926
- // src/loaders/index.ts
927
- function detectFormat(source) {
928
- const trimmed = source.trim();
929
- if (trimmed.startsWith("{") || trimmed.startsWith("[")) {
930
- return "json";
931
- }
932
- if (trimmed.includes("<") && trimmed.includes(">")) {
933
- return "mdx";
934
- }
935
- return "yaml";
936
- }
937
- async function load(source, options = {}) {
938
- const format = options.format || detectFormat(source);
939
- let schema;
940
- switch (format) {
941
- case "mdx":
942
- schema = await loadFromMDX(source, options);
943
- break;
944
- case "yaml":
945
- schema = loadFromYAML(source, options);
946
- break;
947
- case "json":
948
- schema = loadFromJSON(source, options);
949
- break;
950
- default:
951
- throw new Error(`Unsupported format: ${format}`);
952
- }
953
- return {
954
- schema,
955
- format
956
- };
957
- }
958
- async function loadNoun(source, options = {}) {
959
- const format = options.format || detectFormat(source);
960
- switch (format) {
961
- case "mdx":
962
- return loadNounFromMDX(source, options);
963
- case "yaml":
964
- return loadNounFromYAML(source, options);
965
- case "json":
966
- return loadNounFromJSON(source, options);
967
- default:
968
- throw new Error(`Unsupported format: ${format}`);
969
- }
970
- }
971
- async function loadNouns(source, options = {}) {
972
- const format = options.format || detectFormat(source);
973
- switch (format) {
974
- case "mdx":
975
- return loadNounsFromMDX(source, options);
976
- case "yaml":
977
- return loadNounsFromYAML(source, options);
978
- case "json":
979
- return loadNounsFromJSON(source, options);
980
- default:
981
- throw new Error(`Unsupported format: ${format}`);
982
- }
983
- }
984
- function serialize(schema, format = "yaml") {
985
- switch (format) {
986
- case "yaml":
987
- return toYAML(schema);
988
- case "json":
989
- return toJSON(schema);
990
- default:
991
- throw new Error(`Unsupported format: ${format}`);
992
- }
993
- }
994
- function serializeNoun(noun, format = "yaml") {
995
- switch (format) {
996
- case "yaml":
997
- return nounToYAML(noun);
998
- case "json":
999
- return nounToJSON(noun);
1000
- default:
1001
- throw new Error(`Unsupported format: ${format}`);
1002
- }
1003
- }
1004
- export {
1005
- Agents,
1006
- Brands,
1007
- Businesses,
1008
- Channels,
1009
- ChartOfAccounts,
1010
- Competitors,
1011
- Contacts,
1012
- Customers,
1013
- Deals,
1014
- Domains,
1015
- Features,
1016
- Goals,
1017
- Invoices,
1018
- Issues,
1019
- JournalEntries,
1020
- Leads,
1021
- Messages,
1022
- Metrics,
1023
- Offers,
1024
- Orgs,
1025
- Payments,
1026
- Posts,
1027
- Prices,
1028
- Processes,
1029
- Products,
1030
- Projects,
1031
- Proposals,
1032
- Quotes,
1033
- Refunds,
1034
- Roles,
1035
- Sequences,
1036
- ServiceAccounts,
1037
- Services,
1038
- Subscriptions,
1039
- Tasks,
1040
- Teams,
1041
- Templates,
1042
- Users,
1043
- Workflows,
1044
- adminNouns,
1045
- businessNouns,
1046
- communicationsNouns,
1047
- createMinimalSchema,
1048
- defaultBusinessSchema,
1049
- financialNouns,
1050
- findNounBySlug,
1051
- getAllNouns,
1052
- getDomainNouns,
1053
- getDomains,
1054
- load,
1055
- loadFromJSON,
1056
- loadFromMDX,
1057
- loadFromYAML,
1058
- loadNoun,
1059
- loadNounFromJSON,
1060
- loadNounFromMDX,
1061
- loadNounFromYAML,
1062
- loadNouns,
1063
- loadNounsFromJSON,
1064
- loadNounsFromMDX,
1065
- loadNounsFromYAML,
1066
- marketingNouns,
1067
- mergeSchemas,
1068
- nounToJSON,
1069
- nounToYAML,
1070
- productNouns,
1071
- salesNouns,
1072
- serialize,
1073
- serializeNoun,
1074
- successNouns,
1075
- toJSON,
1076
- toYAML,
1077
- validateSchema,
1078
- workNouns
1079
- };
1
+ /**
2
+ * business-as-code - Primitives for expressing business logic and processes as code
3
+ *
4
+ * This package provides primitives for defining business entities, goals, products,
5
+ * services, processes, workflows, KPIs, OKRs, and financial metrics.
6
+ *
7
+ * @example
8
+ * ```ts
9
+ * import { Business, Product, Goals, kpis, okrs, financials, $ } from 'business-as-code'
10
+ *
11
+ * // Define your business
12
+ * const company = Business({
13
+ * name: 'Acme Corp',
14
+ * mission: 'To make widgets accessible to everyone',
15
+ * values: ['Innovation', 'Customer Focus', 'Integrity'],
16
+ * })
17
+ *
18
+ * // Define products
19
+ * const product = Product({
20
+ * name: 'Widget Pro',
21
+ * pricingModel: 'subscription',
22
+ * price: 99,
23
+ * cogs: 20,
24
+ * })
25
+ *
26
+ * // Define goals
27
+ * const goals = Goals([
28
+ * {
29
+ * name: 'Launch MVP',
30
+ * category: 'strategic',
31
+ * status: 'in-progress',
32
+ * progress: 65,
33
+ * },
34
+ * ])
35
+ *
36
+ * // Track KPIs
37
+ * const kpiList = kpis([
38
+ * {
39
+ * name: 'Monthly Recurring Revenue',
40
+ * category: 'financial',
41
+ * target: 100000,
42
+ * current: 85000,
43
+ * },
44
+ * ])
45
+ *
46
+ * // Define OKRs
47
+ * const okrList = okrs([
48
+ * {
49
+ * objective: 'Achieve Product-Market Fit',
50
+ * keyResults: [
51
+ * {
52
+ * description: 'Increase NPS',
53
+ * metric: 'NPS',
54
+ * targetValue: 60,
55
+ * currentValue: 52,
56
+ * },
57
+ * ],
58
+ * },
59
+ * ])
60
+ *
61
+ * // Calculate financials
62
+ * const metrics = financials({
63
+ * revenue: 1000000,
64
+ * cogs: 300000,
65
+ * operatingExpenses: 500000,
66
+ * })
67
+ *
68
+ * // Use $ helper for calculations
69
+ * console.log($.format(1234.56)) // "$1,234.56"
70
+ * console.log($.growth(120, 100)) // 20
71
+ * console.log($.margin(100, 60)) // 40
72
+ * ```
73
+ *
74
+ * @packageDocumentation
75
+ */
76
+ // Export business entity functions
77
+ export { Business, getTotalBudget, getTotalTeamSize, getDepartment, getTeam, validateBusiness, } from './business.js';
78
+ // Export vision functions
79
+ export { Vision, checkIndicator, calculateProgress, validateVision, } from './vision.js';
80
+ // Export goal functions
81
+ export { Goals, Goal, updateProgress, markAtRisk, complete, isOverdue, getGoalsByCategory, getGoalsByStatus, getGoalsByOwner, calculateOverallProgress, hasCircularDependencies, sortByDependencies, validateGoals, } from './goals.js';
82
+ // Export product functions
83
+ export { Product, calculateGrossMargin, calculateGrossProfit, getRoadmapByStatus, getRoadmapByPriority, getOverdueRoadmapItems, updateRoadmapItem, addFeature, removeFeature, validateProduct, } from './product.js';
84
+ // Export service functions
85
+ export { Service, calculateHourlyPrice, calculateMonthlyRetainer, checkSLAUptime, parseDeliveryTimeToDays, estimateCompletionDate, calculateValueBasedPrice, validateService, } from './service.js';
86
+ // Export process functions
87
+ export { Process, getStepsInOrder, getStepsByAutomationLevel, calculateTotalDuration, formatDuration, calculateAutomationPercentage, getMetric, meetsTarget, calculateMetricAchievement, updateMetric, addStep, removeStep, validateProcess, } from './process.js';
88
+ // Export workflow functions
89
+ export { Workflow, getActionsInOrder, getActionsByType, getConditionalActions, addAction, removeAction, updateAction, isEventTrigger, isScheduleTrigger, isWebhookTrigger, parseWaitDuration, evaluateCondition, fillTemplate, validateWorkflow, } from './workflow.js';
90
+ // Export KPI functions
91
+ export { kpis, kpi, calculateAchievement, meetsTarget as kpiMeetsTarget, updateCurrent, updateTarget, getKPIsByCategory, getKPIsByFrequency, getKPIsOnTarget, getKPIsOffTarget, calculateHealthScore, groupByCategory, calculateVariance, calculateVariancePercentage, formatValue, comparePerformance, validateKPIs, } from './kpis.js';
92
+ // Export OKR functions
93
+ export { okrs, okr, calculateKeyResultProgress, calculateOKRProgress, calculateConfidence, updateKeyResult, isKeyResultOnTrack, isOKROnTrack, getKeyResultsOnTrack, getKeyResultsAtRisk, getOKRsByOwner, getOKRsByPeriod, getOKRsByStatus, calculateSuccessRate, formatKeyResult, compareOKRPerformance, validateOKRs, } from './okrs.js';
94
+ // Export financial functions
95
+ export { financials, calculateGrossMargin as calculateFinancialGrossMargin, calculateOperatingMargin, calculateNetMargin, calculateEBITDAMargin, calculateBurnRate, calculateRunway, calculateCAC, calculateLTV, calculateLTVtoCAC, calculatePaybackPeriod, calculateARR, calculateMRR, calculateGrowthRate, calculateCAGR, calculateROI, calculateROE, calculateROA, calculateQuickRatio, calculateCurrentRatio, calculateDebtToEquity, formatCurrency, createStatement, getLineItem, compareMetrics, validateFinancials, } from './financials.js';
96
+ // Export $ helper and context management
97
+ export { $, createBusinessOperations, updateContext, getContext, resetContext, } from './dollar.js';
98
+ export {
99
+ // SaaS Metric Calculation functions (produce structured SaaS metric objects)
100
+ calculateMRR as calculateMRRMetric, calculateARRFromMRR as calculateARRMetric, calculateNRR as calculateNRRMetric, calculateGRR as calculateGRRMetric, calculateCACMetric, calculateLTVMetric, calculateLTVtoCACRatio, calculateQuickRatioMetric, calculateMagicNumberMetric, calculateBurnMultipleMetric, calculateRuleOf40Metric, calculateGrowthRates, calculateChurnMetrics,
101
+ // Time-series aggregation
102
+ aggregateTimeSeries, createMetricPeriod, } from './metrics.js';
103
+ export {
104
+ // Standard definitions
105
+ StandardDimensions, StandardMeasures, CalculatedMetrics,
106
+ // Builders
107
+ query, QueryBuilder, view, ViewBuilder, dashboard, DashboardBuilder,
108
+ // Pre-built queries
109
+ MrrOverview, ArrBySegment, CohortRetention, UnitEconomics, RevenueByChannel, GrowthMetrics,
110
+ // Pre-built dashboards
111
+ ExecutiveDashboard, } from './queries.js';
112
+ export { StandardBusinessRoles, createBusinessRole, hasPermission, canHandleTask, canApproveRequest, canDelegateTask, findRoleForTask, createTaskAssignment, transitionTaskStatus, } from './roles.js';
113
+ export { resolvePermissions, getApprovalChainForRequest, findManager, } from './organization.js';
114
+ // =============================================================================
115
+ // Entity Definitions (Noun pattern with Properties, Actions, Events)
116
+ // =============================================================================
117
+ export {
118
+ // Business
119
+ Business as BusinessEntity, Vision as VisionEntity, Value as ValueEntity, BusinessEntities, BusinessCategories,
120
+ // Organization
121
+ Organization as OrganizationEntity, Department as DepartmentEntity, Team as TeamEntity, Position as PositionEntity, Role as RoleEntity, Worker as WorkerEntity, OrganizationEntities, OrganizationCategories,
122
+ // Goals
123
+ Goal as GoalEntity, OKR as OKREntity, KeyResult as KeyResultEntity, KPI as KPIEntity, Metric as MetricEntity, Initiative as InitiativeEntity, GoalEntities, GoalCategories,
124
+ // Offerings
125
+ Product as ProductEntity, Service as ServiceEntity, Feature as FeatureEntity, PricingPlan as PricingPlanEntity, RoadmapItem as RoadmapItemEntity, OfferingEntities, OfferingCategories,
126
+ // Operations
127
+ Process as ProcessEntity, ProcessStep as ProcessStepEntity, Workflow as WorkflowEntity, WorkflowAction as WorkflowActionEntity, WorkflowRun as WorkflowRunEntity, Policy as PolicyEntity, OperationsEntities, OperationsCategories,
128
+ // Financials
129
+ Budget as BudgetEntity, Revenue as RevenueEntity, Expense as ExpenseEntity, Investment as InvestmentEntity, FinancialPeriod as FinancialPeriodEntity, Forecast as ForecastEntity, FinancialEntities, FinancialCategories,
130
+ // All
131
+ AllBusinessEntities, BusinessEntityCategories, Entities, } from './entities/index.js';
1080
132
  //# sourceMappingURL=index.js.map