business-as-code 0.0.2 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,716 @@
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
+ export {
659
+ Agents,
660
+ Brands,
661
+ Businesses,
662
+ Channels,
663
+ ChartOfAccounts,
664
+ Competitors,
665
+ Contacts,
666
+ Customers,
667
+ Deals,
668
+ Domains,
669
+ Features,
670
+ Goals,
671
+ Invoices,
672
+ Issues,
673
+ JournalEntries,
674
+ Leads,
675
+ Messages,
676
+ Metrics,
677
+ Offers,
678
+ Orgs,
679
+ Payments,
680
+ Posts,
681
+ Prices,
682
+ Processes,
683
+ Products,
684
+ Projects,
685
+ Proposals,
686
+ Quotes,
687
+ Refunds,
688
+ Roles,
689
+ Sequences,
690
+ ServiceAccounts,
691
+ Services,
692
+ Subscriptions,
693
+ Tasks,
694
+ Teams,
695
+ Templates,
696
+ Users,
697
+ Workflows,
698
+ adminNouns,
699
+ businessNouns,
700
+ communicationsNouns,
701
+ createMinimalSchema,
702
+ defaultBusinessSchema,
703
+ financialNouns,
704
+ findNounBySlug,
705
+ getAllNouns,
706
+ getDomainNouns,
707
+ getDomains,
708
+ marketingNouns,
709
+ mergeSchemas,
710
+ productNouns,
711
+ salesNouns,
712
+ successNouns,
713
+ validateSchema,
714
+ workNouns
715
+ };
716
+ //# sourceMappingURL=index.js.map