business-as-code 0.2.1 → 2.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.turbo/turbo-build.log +5 -0
- package/CHANGELOG.md +9 -0
- package/IMPLEMENTATION.md +226 -0
- package/README.md +1133 -193
- package/dist/business.d.ts +62 -0
- package/dist/business.d.ts.map +1 -0
- package/dist/business.js +109 -0
- package/dist/business.js.map +1 -0
- package/dist/dollar.d.ts +60 -0
- package/dist/dollar.d.ts.map +1 -0
- package/dist/dollar.js +107 -0
- package/dist/dollar.js.map +1 -0
- package/dist/entities/assets.d.ts +21 -0
- package/dist/entities/assets.d.ts.map +1 -0
- package/dist/entities/assets.js +323 -0
- package/dist/entities/assets.js.map +1 -0
- package/dist/entities/business.d.ts +36 -0
- package/dist/entities/business.d.ts.map +1 -0
- package/dist/entities/business.js +370 -0
- package/dist/entities/business.js.map +1 -0
- package/dist/entities/communication.d.ts +21 -0
- package/dist/entities/communication.d.ts.map +1 -0
- package/dist/entities/communication.js +255 -0
- package/dist/entities/communication.js.map +1 -0
- package/dist/entities/customers.d.ts +58 -0
- package/dist/entities/customers.d.ts.map +1 -0
- package/dist/entities/customers.js +989 -0
- package/dist/entities/customers.js.map +1 -0
- package/dist/entities/financials.d.ts +59 -0
- package/dist/entities/financials.d.ts.map +1 -0
- package/dist/entities/financials.js +932 -0
- package/dist/entities/financials.js.map +1 -0
- package/dist/entities/goals.d.ts +58 -0
- package/dist/entities/goals.d.ts.map +1 -0
- package/dist/entities/goals.js +800 -0
- package/dist/entities/goals.js.map +1 -0
- package/dist/entities/index.d.ts +299 -0
- package/dist/entities/index.d.ts.map +1 -0
- package/dist/entities/index.js +198 -0
- package/dist/entities/index.js.map +1 -0
- package/dist/entities/legal.d.ts +21 -0
- package/dist/entities/legal.d.ts.map +1 -0
- package/dist/entities/legal.js +301 -0
- package/dist/entities/legal.js.map +1 -0
- package/dist/entities/market.d.ts +21 -0
- package/dist/entities/market.d.ts.map +1 -0
- package/dist/entities/market.js +301 -0
- package/dist/entities/market.js.map +1 -0
- package/dist/entities/marketing.d.ts +67 -0
- package/dist/entities/marketing.d.ts.map +1 -0
- package/dist/entities/marketing.js +1157 -0
- package/dist/entities/marketing.js.map +1 -0
- package/dist/entities/offerings.d.ts +51 -0
- package/dist/entities/offerings.d.ts.map +1 -0
- package/dist/entities/offerings.js +727 -0
- package/dist/entities/offerings.js.map +1 -0
- package/dist/entities/operations.d.ts +58 -0
- package/dist/entities/operations.d.ts.map +1 -0
- package/dist/entities/operations.js +787 -0
- package/dist/entities/operations.js.map +1 -0
- package/dist/entities/organization.d.ts +57 -0
- package/dist/entities/organization.d.ts.map +1 -0
- package/dist/entities/organization.js +807 -0
- package/dist/entities/organization.js.map +1 -0
- package/dist/entities/partnerships.d.ts +21 -0
- package/dist/entities/partnerships.d.ts.map +1 -0
- package/dist/entities/partnerships.js +300 -0
- package/dist/entities/partnerships.js.map +1 -0
- package/dist/entities/planning.d.ts +87 -0
- package/dist/entities/planning.d.ts.map +1 -0
- package/dist/entities/planning.js +271 -0
- package/dist/entities/planning.js.map +1 -0
- package/dist/entities/projects.d.ts +25 -0
- package/dist/entities/projects.d.ts.map +1 -0
- package/dist/entities/projects.js +349 -0
- package/dist/entities/projects.js.map +1 -0
- package/dist/entities/risk.d.ts +21 -0
- package/dist/entities/risk.d.ts.map +1 -0
- package/dist/entities/risk.js +293 -0
- package/dist/entities/risk.js.map +1 -0
- package/dist/entities/sales.d.ts +72 -0
- package/dist/entities/sales.d.ts.map +1 -0
- package/dist/entities/sales.js +1248 -0
- package/dist/entities/sales.js.map +1 -0
- package/dist/financials.d.ts +130 -0
- package/dist/financials.d.ts.map +1 -0
- package/dist/financials.js +297 -0
- package/dist/financials.js.map +1 -0
- package/dist/goals.d.ts +87 -0
- package/dist/goals.d.ts.map +1 -0
- package/dist/goals.js +215 -0
- package/dist/goals.js.map +1 -0
- package/dist/index.d.ts +97 -4
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +131 -1079
- package/dist/index.js.map +1 -1
- package/dist/kpis.d.ts +118 -0
- package/dist/kpis.d.ts.map +1 -0
- package/dist/kpis.js +232 -0
- package/dist/kpis.js.map +1 -0
- package/dist/metrics.d.ts +448 -0
- package/dist/metrics.d.ts.map +1 -0
- package/dist/metrics.js +325 -0
- package/dist/metrics.js.map +1 -0
- package/dist/okrs.d.ts +123 -0
- package/dist/okrs.d.ts.map +1 -0
- package/dist/okrs.js +269 -0
- package/dist/okrs.js.map +1 -0
- package/dist/organization.d.ts +585 -0
- package/dist/organization.d.ts.map +1 -0
- package/dist/organization.js +173 -0
- package/dist/organization.js.map +1 -0
- package/dist/process.d.ts +112 -0
- package/dist/process.d.ts.map +1 -0
- package/dist/process.js +241 -0
- package/dist/process.js.map +1 -0
- package/dist/product.d.ts +85 -0
- package/dist/product.d.ts.map +1 -0
- package/dist/product.js +145 -0
- package/dist/product.js.map +1 -0
- package/dist/queries.d.ts +304 -0
- package/dist/queries.d.ts.map +1 -0
- package/dist/queries.js +415 -0
- package/dist/queries.js.map +1 -0
- package/dist/roles.d.ts +340 -0
- package/dist/roles.d.ts.map +1 -0
- package/dist/roles.js +255 -0
- package/dist/roles.js.map +1 -0
- package/dist/service.d.ts +61 -0
- package/dist/service.d.ts.map +1 -0
- package/dist/service.js +140 -0
- package/dist/service.js.map +1 -0
- package/dist/types.d.ts +459 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +5 -0
- package/dist/types.js.map +1 -0
- package/dist/vision.d.ts +38 -0
- package/dist/vision.d.ts.map +1 -0
- package/dist/vision.js +68 -0
- package/dist/vision.js.map +1 -0
- package/dist/workflow.d.ts +115 -0
- package/dist/workflow.d.ts.map +1 -0
- package/dist/workflow.js +247 -0
- package/dist/workflow.js.map +1 -0
- package/examples/basic-usage.ts +307 -0
- package/package.json +19 -60
- package/src/business.ts +121 -0
- package/src/dollar.ts +132 -0
- package/src/entities/assets.ts +332 -0
- package/src/entities/business.ts +406 -0
- package/src/entities/communication.ts +264 -0
- package/src/entities/customers.ts +1072 -0
- package/src/entities/financials.ts +1011 -0
- package/src/entities/goals.ts +871 -0
- package/src/entities/index.ts +383 -0
- package/src/entities/legal.ts +310 -0
- package/src/entities/market.ts +310 -0
- package/src/entities/marketing.ts +1249 -0
- package/src/entities/offerings.ts +789 -0
- package/src/entities/operations.ts +861 -0
- package/src/entities/organization.ts +876 -0
- package/src/entities/partnerships.ts +309 -0
- package/src/entities/planning.ts +307 -0
- package/src/entities/projects.ts +360 -0
- package/src/entities/risk.ts +302 -0
- package/src/entities/sales.ts +1352 -0
- package/src/financials.ts +352 -0
- package/src/goals.ts +250 -0
- package/src/index.test.ts +336 -0
- package/src/index.ts +530 -0
- package/src/kpis.ts +275 -0
- package/src/metrics.ts +825 -0
- package/src/okrs.ts +325 -0
- package/src/organization.ts +909 -0
- package/src/process.ts +272 -0
- package/src/product.ts +178 -0
- package/src/queries.ts +767 -0
- package/src/roles.ts +686 -0
- package/src/service.ts +164 -0
- package/src/types.ts +493 -0
- package/src/vision.ts +88 -0
- package/src/workflow.ts +280 -0
- package/tsconfig.json +9 -0
- package/dist/loaders/index.d.ts +0 -174
- package/dist/loaders/index.js +0 -366
- package/dist/loaders/index.js.map +0 -1
- package/dist/schema/index.d.ts +0 -146
- package/dist/schema/index.js +0 -716
- package/dist/schema/index.js.map +0 -1
- package/dist/types-CJ9eGS_C.d.ts +0 -86
package/src/vision.ts
ADDED
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Vision statement definition
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import type { VisionDefinition } from './types.js'
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Define a business vision statement with timeframe and success indicators
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```ts
|
|
12
|
+
* const vision = Vision({
|
|
13
|
+
* statement: 'To become the world\'s most trusted widget platform',
|
|
14
|
+
* timeframe: '5 years',
|
|
15
|
+
* successIndicators: [
|
|
16
|
+
* '10M+ active users',
|
|
17
|
+
* 'Present in 50+ countries',
|
|
18
|
+
* 'Industry-leading NPS score',
|
|
19
|
+
* '$1B+ annual revenue',
|
|
20
|
+
* ],
|
|
21
|
+
* })
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
export function Vision(definition: VisionDefinition): VisionDefinition {
|
|
25
|
+
// Validate required fields
|
|
26
|
+
if (!definition.statement) {
|
|
27
|
+
throw new Error('Vision statement is required')
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
// Return validated vision definition
|
|
31
|
+
return {
|
|
32
|
+
...definition,
|
|
33
|
+
successIndicators: definition.successIndicators || [],
|
|
34
|
+
metadata: definition.metadata || {},
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Check if a success indicator has been achieved
|
|
40
|
+
*/
|
|
41
|
+
export function checkIndicator(
|
|
42
|
+
vision: VisionDefinition,
|
|
43
|
+
indicator: string,
|
|
44
|
+
currentMetrics: Record<string, number | boolean>
|
|
45
|
+
): boolean {
|
|
46
|
+
// Simple check - would need more sophisticated parsing in production
|
|
47
|
+
return Object.entries(currentMetrics).some(([key, value]) => {
|
|
48
|
+
return indicator.toLowerCase().includes(key.toLowerCase()) && Boolean(value)
|
|
49
|
+
})
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Calculate vision progress based on achieved indicators
|
|
54
|
+
*/
|
|
55
|
+
export function calculateProgress(
|
|
56
|
+
vision: VisionDefinition,
|
|
57
|
+
currentMetrics: Record<string, number | boolean>
|
|
58
|
+
): number {
|
|
59
|
+
if (!vision.successIndicators || vision.successIndicators.length === 0) {
|
|
60
|
+
return 0
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
const achieved = vision.successIndicators.filter(indicator =>
|
|
64
|
+
checkIndicator(vision, indicator, currentMetrics)
|
|
65
|
+
).length
|
|
66
|
+
|
|
67
|
+
return (achieved / vision.successIndicators.length) * 100
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Validate vision definition
|
|
72
|
+
*/
|
|
73
|
+
export function validateVision(vision: VisionDefinition): { valid: boolean; errors: string[] } {
|
|
74
|
+
const errors: string[] = []
|
|
75
|
+
|
|
76
|
+
if (!vision.statement) {
|
|
77
|
+
errors.push('Vision statement is required')
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
if (vision.statement && vision.statement.length < 10) {
|
|
81
|
+
errors.push('Vision statement should be at least 10 characters')
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
return {
|
|
85
|
+
valid: errors.length === 0,
|
|
86
|
+
errors,
|
|
87
|
+
}
|
|
88
|
+
}
|
package/src/workflow.ts
ADDED
|
@@ -0,0 +1,280 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Workflow definition (automation sequences)
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import type { WorkflowDefinition, WorkflowAction, WorkflowTrigger } from './types.js'
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Define an automated workflow with triggers and actions
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```ts
|
|
12
|
+
* const workflow = Workflow({
|
|
13
|
+
* name: 'New Customer Welcome',
|
|
14
|
+
* description: 'Automated welcome sequence for new customers',
|
|
15
|
+
* trigger: {
|
|
16
|
+
* type: 'event',
|
|
17
|
+
* event: 'Customer.created',
|
|
18
|
+
* },
|
|
19
|
+
* actions: [
|
|
20
|
+
* {
|
|
21
|
+
* order: 1,
|
|
22
|
+
* type: 'send',
|
|
23
|
+
* description: 'Send welcome email',
|
|
24
|
+
* params: {
|
|
25
|
+
* template: 'welcome_email',
|
|
26
|
+
* to: '{{customer.email}}',
|
|
27
|
+
* },
|
|
28
|
+
* },
|
|
29
|
+
* {
|
|
30
|
+
* order: 2,
|
|
31
|
+
* type: 'create',
|
|
32
|
+
* description: 'Create onboarding task',
|
|
33
|
+
* params: {
|
|
34
|
+
* type: 'Task',
|
|
35
|
+
* title: 'Onboard {{customer.name}}',
|
|
36
|
+
* assignee: 'customer_success_team',
|
|
37
|
+
* },
|
|
38
|
+
* },
|
|
39
|
+
* {
|
|
40
|
+
* order: 3,
|
|
41
|
+
* type: 'wait',
|
|
42
|
+
* description: 'Wait 24 hours',
|
|
43
|
+
* params: {
|
|
44
|
+
* duration: '24 hours',
|
|
45
|
+
* },
|
|
46
|
+
* },
|
|
47
|
+
* {
|
|
48
|
+
* order: 4,
|
|
49
|
+
* type: 'notify',
|
|
50
|
+
* description: 'Send setup reminder',
|
|
51
|
+
* params: {
|
|
52
|
+
* channel: 'email',
|
|
53
|
+
* message: 'Reminder to complete setup',
|
|
54
|
+
* },
|
|
55
|
+
* condition: 'customer.setupCompleted === false',
|
|
56
|
+
* },
|
|
57
|
+
* ],
|
|
58
|
+
* })
|
|
59
|
+
* ```
|
|
60
|
+
*/
|
|
61
|
+
export function Workflow(definition: WorkflowDefinition): WorkflowDefinition {
|
|
62
|
+
if (!definition.name) {
|
|
63
|
+
throw new Error('Workflow name is required')
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
if (!definition.trigger) {
|
|
67
|
+
throw new Error('Workflow trigger is required')
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
return {
|
|
71
|
+
...definition,
|
|
72
|
+
actions: definition.actions || [],
|
|
73
|
+
metadata: definition.metadata || {},
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Get actions in execution order
|
|
79
|
+
*/
|
|
80
|
+
export function getActionsInOrder(workflow: WorkflowDefinition): WorkflowAction[] {
|
|
81
|
+
return [...(workflow.actions || [])].sort((a, b) => a.order - b.order)
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* Get actions by type
|
|
86
|
+
*/
|
|
87
|
+
export function getActionsByType(
|
|
88
|
+
workflow: WorkflowDefinition,
|
|
89
|
+
type: WorkflowAction['type']
|
|
90
|
+
): WorkflowAction[] {
|
|
91
|
+
return workflow.actions?.filter(action => action.type === type) || []
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* Get conditional actions
|
|
96
|
+
*/
|
|
97
|
+
export function getConditionalActions(workflow: WorkflowDefinition): WorkflowAction[] {
|
|
98
|
+
return workflow.actions?.filter(action => action.condition) || []
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* Add action to workflow
|
|
103
|
+
*/
|
|
104
|
+
export function addAction(workflow: WorkflowDefinition, action: WorkflowAction): WorkflowDefinition {
|
|
105
|
+
return {
|
|
106
|
+
...workflow,
|
|
107
|
+
actions: [...(workflow.actions || []), action],
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* Remove action from workflow
|
|
113
|
+
*/
|
|
114
|
+
export function removeAction(workflow: WorkflowDefinition, order: number): WorkflowDefinition {
|
|
115
|
+
return {
|
|
116
|
+
...workflow,
|
|
117
|
+
actions: workflow.actions?.filter(a => a.order !== order),
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* Update action in workflow
|
|
123
|
+
*/
|
|
124
|
+
export function updateAction(
|
|
125
|
+
workflow: WorkflowDefinition,
|
|
126
|
+
order: number,
|
|
127
|
+
updates: Partial<WorkflowAction>
|
|
128
|
+
): WorkflowDefinition {
|
|
129
|
+
const actions = workflow.actions?.map(action =>
|
|
130
|
+
action.order === order ? { ...action, ...updates } : action
|
|
131
|
+
)
|
|
132
|
+
|
|
133
|
+
return {
|
|
134
|
+
...workflow,
|
|
135
|
+
actions,
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
/**
|
|
140
|
+
* Check if trigger is event-based
|
|
141
|
+
*/
|
|
142
|
+
export function isEventTrigger(trigger: WorkflowTrigger): boolean {
|
|
143
|
+
return trigger.type === 'event'
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
/**
|
|
147
|
+
* Check if trigger is schedule-based
|
|
148
|
+
*/
|
|
149
|
+
export function isScheduleTrigger(trigger: WorkflowTrigger): boolean {
|
|
150
|
+
return trigger.type === 'schedule'
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
/**
|
|
154
|
+
* Check if trigger is webhook-based
|
|
155
|
+
*/
|
|
156
|
+
export function isWebhookTrigger(trigger: WorkflowTrigger): boolean {
|
|
157
|
+
return trigger.type === 'webhook'
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* Parse wait duration to milliseconds
|
|
162
|
+
*/
|
|
163
|
+
export function parseWaitDuration(duration: string): number {
|
|
164
|
+
const match = duration.match(/(\d+)\s*(ms|millisecond|milliseconds|s|second|seconds|m|minute|minutes|h|hour|hours|d|day|days)/)
|
|
165
|
+
if (!match) return 0
|
|
166
|
+
|
|
167
|
+
const value = parseInt(match[1] || '0', 10)
|
|
168
|
+
const unit = match[2]
|
|
169
|
+
|
|
170
|
+
switch (unit) {
|
|
171
|
+
case 'ms':
|
|
172
|
+
case 'millisecond':
|
|
173
|
+
case 'milliseconds':
|
|
174
|
+
return value
|
|
175
|
+
case 's':
|
|
176
|
+
case 'second':
|
|
177
|
+
case 'seconds':
|
|
178
|
+
return value * 1000
|
|
179
|
+
case 'm':
|
|
180
|
+
case 'minute':
|
|
181
|
+
case 'minutes':
|
|
182
|
+
return value * 60 * 1000
|
|
183
|
+
case 'h':
|
|
184
|
+
case 'hour':
|
|
185
|
+
case 'hours':
|
|
186
|
+
return value * 60 * 60 * 1000
|
|
187
|
+
case 'd':
|
|
188
|
+
case 'day':
|
|
189
|
+
case 'days':
|
|
190
|
+
return value * 24 * 60 * 60 * 1000
|
|
191
|
+
default:
|
|
192
|
+
return 0
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
/**
|
|
197
|
+
* Evaluate condition (simple implementation)
|
|
198
|
+
*/
|
|
199
|
+
export function evaluateCondition(condition: string, context: Record<string, unknown>): boolean {
|
|
200
|
+
// This is a simplified implementation
|
|
201
|
+
// In production, use a proper expression evaluator
|
|
202
|
+
try {
|
|
203
|
+
// Replace variable references with actual values
|
|
204
|
+
let expression = condition
|
|
205
|
+
for (const [key, value] of Object.entries(context)) {
|
|
206
|
+
const regex = new RegExp(`\\b${key}\\b`, 'g')
|
|
207
|
+
expression = expression.replace(regex, JSON.stringify(value))
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
// Evaluate the expression (unsafe in production - use a proper evaluator)
|
|
211
|
+
return Boolean(eval(expression))
|
|
212
|
+
} catch {
|
|
213
|
+
return false
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
/**
|
|
218
|
+
* Fill template with context values
|
|
219
|
+
*/
|
|
220
|
+
export function fillTemplate(template: string, context: Record<string, unknown>): string {
|
|
221
|
+
return template.replace(/\{\{([^}]+)\}\}/g, (_, path) => {
|
|
222
|
+
const value = getNestedValue(context, path.trim())
|
|
223
|
+
return String(value ?? '')
|
|
224
|
+
})
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
/**
|
|
228
|
+
* Get nested value from object by path
|
|
229
|
+
*/
|
|
230
|
+
function getNestedValue(obj: Record<string, unknown>, path: string): unknown {
|
|
231
|
+
return path.split('.').reduce((acc: any, part) => acc?.[part], obj)
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
/**
|
|
235
|
+
* Validate workflow definition
|
|
236
|
+
*/
|
|
237
|
+
export function validateWorkflow(workflow: WorkflowDefinition): { valid: boolean; errors: string[] } {
|
|
238
|
+
const errors: string[] = []
|
|
239
|
+
|
|
240
|
+
if (!workflow.name) {
|
|
241
|
+
errors.push('Workflow name is required')
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
if (!workflow.trigger) {
|
|
245
|
+
errors.push('Workflow trigger is required')
|
|
246
|
+
} else {
|
|
247
|
+
if (workflow.trigger.type === 'event' && !workflow.trigger.event) {
|
|
248
|
+
errors.push('Event trigger must specify an event name')
|
|
249
|
+
}
|
|
250
|
+
if (workflow.trigger.type === 'schedule' && !workflow.trigger.schedule) {
|
|
251
|
+
errors.push('Schedule trigger must specify a schedule expression')
|
|
252
|
+
}
|
|
253
|
+
if (workflow.trigger.type === 'webhook' && !workflow.trigger.webhook) {
|
|
254
|
+
errors.push('Webhook trigger must specify a webhook URL')
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
if (workflow.actions) {
|
|
259
|
+
const orders = new Set<number>()
|
|
260
|
+
for (const action of workflow.actions) {
|
|
261
|
+
if (!action.type) {
|
|
262
|
+
errors.push(`Action at order ${action.order} must have a type`)
|
|
263
|
+
}
|
|
264
|
+
if (orders.has(action.order)) {
|
|
265
|
+
errors.push(`Duplicate action order: ${action.order}`)
|
|
266
|
+
}
|
|
267
|
+
orders.add(action.order)
|
|
268
|
+
|
|
269
|
+
// Validate action-specific requirements
|
|
270
|
+
if (action.type === 'wait' && !action.params?.duration) {
|
|
271
|
+
errors.push(`Wait action at order ${action.order} must specify duration`)
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
return {
|
|
277
|
+
valid: errors.length === 0,
|
|
278
|
+
errors,
|
|
279
|
+
}
|
|
280
|
+
}
|
package/tsconfig.json
ADDED
package/dist/loaders/index.d.ts
DELETED
|
@@ -1,174 +0,0 @@
|
|
|
1
|
-
import { L as LoaderOptions, B as BusinessSchema, c as LoadResult } from '../types-CJ9eGS_C.js';
|
|
2
|
-
import { NounSchema } from 'db.sb';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* MDX Loader
|
|
6
|
-
*
|
|
7
|
-
* Load business schemas from MDX files using the DSL parser from db.sb
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* Load a business schema from MDX source
|
|
12
|
-
*
|
|
13
|
-
* @example
|
|
14
|
-
* ```typescript
|
|
15
|
-
* const mdx = `
|
|
16
|
-
* <Business name="My Startup">
|
|
17
|
-
* <Noun name="Customer" group="Success">
|
|
18
|
-
* <Name text required />
|
|
19
|
-
* <Email />
|
|
20
|
-
* <Status status="active|inactive|churned" />
|
|
21
|
-
* </Noun>
|
|
22
|
-
* </Business>
|
|
23
|
-
* `
|
|
24
|
-
* const schema = await loadFromMDX(mdx)
|
|
25
|
-
* ```
|
|
26
|
-
*/
|
|
27
|
-
declare function loadFromMDX(source: string, options?: LoaderOptions): Promise<BusinessSchema>;
|
|
28
|
-
/**
|
|
29
|
-
* Load a single noun definition from MDX
|
|
30
|
-
*
|
|
31
|
-
* @example
|
|
32
|
-
* ```typescript
|
|
33
|
-
* const mdx = `
|
|
34
|
-
* <Noun name="Customer" group="Success">
|
|
35
|
-
* <Name text required />
|
|
36
|
-
* <Email />
|
|
37
|
-
* </Noun>
|
|
38
|
-
* `
|
|
39
|
-
* const noun = await loadNounFromMDX(mdx)
|
|
40
|
-
* ```
|
|
41
|
-
*/
|
|
42
|
-
declare function loadNounFromMDX(source: string, options?: LoaderOptions): Promise<NounSchema>;
|
|
43
|
-
/**
|
|
44
|
-
* Load multiple noun definitions from MDX
|
|
45
|
-
*/
|
|
46
|
-
declare function loadNounsFromMDX(source: string, options?: LoaderOptions): Promise<NounSchema[]>;
|
|
47
|
-
|
|
48
|
-
/**
|
|
49
|
-
* YAML Loader
|
|
50
|
-
*
|
|
51
|
-
* Load business schemas from YAML files
|
|
52
|
-
*/
|
|
53
|
-
|
|
54
|
-
/**
|
|
55
|
-
* Load a business schema from YAML source
|
|
56
|
-
*
|
|
57
|
-
* @example
|
|
58
|
-
* ```yaml
|
|
59
|
-
* name: My Startup
|
|
60
|
-
* version: 1.0.0
|
|
61
|
-
*
|
|
62
|
-
* domains:
|
|
63
|
-
* success:
|
|
64
|
-
* - name: Customer
|
|
65
|
-
* titleField: name
|
|
66
|
-
* fields:
|
|
67
|
-
* name: text required
|
|
68
|
-
* email: email
|
|
69
|
-
* status: status:active|inactive|churned
|
|
70
|
-
* healthScore: score
|
|
71
|
-
* ```
|
|
72
|
-
*/
|
|
73
|
-
declare function loadFromYAML(source: string, _options?: LoaderOptions): BusinessSchema;
|
|
74
|
-
/**
|
|
75
|
-
* Load a single noun from YAML
|
|
76
|
-
*/
|
|
77
|
-
declare function loadNounFromYAML(source: string, _options?: LoaderOptions): NounSchema;
|
|
78
|
-
/**
|
|
79
|
-
* Load multiple nouns from YAML
|
|
80
|
-
*/
|
|
81
|
-
declare function loadNounsFromYAML(source: string, _options?: LoaderOptions): NounSchema[];
|
|
82
|
-
/**
|
|
83
|
-
* Serialize a business schema to YAML
|
|
84
|
-
*/
|
|
85
|
-
declare function toYAML(schema: BusinessSchema): string;
|
|
86
|
-
/**
|
|
87
|
-
* Serialize a noun to YAML
|
|
88
|
-
*/
|
|
89
|
-
declare function nounToYAML(noun: NounSchema): string;
|
|
90
|
-
|
|
91
|
-
/**
|
|
92
|
-
* JSON Loader
|
|
93
|
-
*
|
|
94
|
-
* Load business schemas from JSON files
|
|
95
|
-
*/
|
|
96
|
-
|
|
97
|
-
/**
|
|
98
|
-
* Load a business schema from JSON source
|
|
99
|
-
*
|
|
100
|
-
* @example
|
|
101
|
-
* ```json
|
|
102
|
-
* {
|
|
103
|
-
* "name": "My Startup",
|
|
104
|
-
* "version": "1.0.0",
|
|
105
|
-
* "domains": {
|
|
106
|
-
* "success": [
|
|
107
|
-
* {
|
|
108
|
-
* "name": "Customer",
|
|
109
|
-
* "titleField": "name",
|
|
110
|
-
* "fields": {
|
|
111
|
-
* "name": "text required",
|
|
112
|
-
* "email": "email",
|
|
113
|
-
* "status": "status:active|inactive|churned"
|
|
114
|
-
* }
|
|
115
|
-
* }
|
|
116
|
-
* ]
|
|
117
|
-
* }
|
|
118
|
-
* }
|
|
119
|
-
* ```
|
|
120
|
-
*/
|
|
121
|
-
declare function loadFromJSON(source: string, _options?: LoaderOptions): BusinessSchema;
|
|
122
|
-
/**
|
|
123
|
-
* Load a single noun from JSON
|
|
124
|
-
*/
|
|
125
|
-
declare function loadNounFromJSON(source: string, _options?: LoaderOptions): NounSchema;
|
|
126
|
-
/**
|
|
127
|
-
* Load multiple nouns from JSON
|
|
128
|
-
*/
|
|
129
|
-
declare function loadNounsFromJSON(source: string, _options?: LoaderOptions): NounSchema[];
|
|
130
|
-
/**
|
|
131
|
-
* Serialize a business schema to JSON
|
|
132
|
-
*/
|
|
133
|
-
declare function toJSON(schema: BusinessSchema, pretty?: boolean): string;
|
|
134
|
-
/**
|
|
135
|
-
* Serialize a noun to JSON
|
|
136
|
-
*/
|
|
137
|
-
declare function nounToJSON(noun: NounSchema, pretty?: boolean): string;
|
|
138
|
-
|
|
139
|
-
/**
|
|
140
|
-
* Loaders Module
|
|
141
|
-
*
|
|
142
|
-
* Load business schemas from various formats (MDX, YAML, JSON)
|
|
143
|
-
*/
|
|
144
|
-
|
|
145
|
-
/**
|
|
146
|
-
* Load a business schema from any supported format
|
|
147
|
-
*
|
|
148
|
-
* Automatically detects the format from the source content.
|
|
149
|
-
*/
|
|
150
|
-
declare function load(source: string, options?: LoaderOptions & {
|
|
151
|
-
format?: 'mdx' | 'yaml' | 'json';
|
|
152
|
-
}): Promise<LoadResult>;
|
|
153
|
-
/**
|
|
154
|
-
* Load a single noun from any supported format
|
|
155
|
-
*/
|
|
156
|
-
declare function loadNoun(source: string, options?: LoaderOptions & {
|
|
157
|
-
format?: 'mdx' | 'yaml' | 'json';
|
|
158
|
-
}): Promise<NounSchema>;
|
|
159
|
-
/**
|
|
160
|
-
* Load multiple nouns from any supported format
|
|
161
|
-
*/
|
|
162
|
-
declare function loadNouns(source: string, options?: LoaderOptions & {
|
|
163
|
-
format?: 'mdx' | 'yaml' | 'json';
|
|
164
|
-
}): Promise<NounSchema[]>;
|
|
165
|
-
/**
|
|
166
|
-
* Serialize a business schema to a specific format
|
|
167
|
-
*/
|
|
168
|
-
declare function serialize(schema: BusinessSchema, format?: 'yaml' | 'json'): string;
|
|
169
|
-
/**
|
|
170
|
-
* Serialize a noun to a specific format
|
|
171
|
-
*/
|
|
172
|
-
declare function serializeNoun(noun: NounSchema, format?: 'yaml' | 'json'): string;
|
|
173
|
-
|
|
174
|
-
export { load, loadFromJSON, loadFromMDX, loadFromYAML, loadNoun, loadNounFromJSON, loadNounFromMDX, loadNounFromYAML, loadNouns, loadNounsFromJSON, loadNounsFromMDX, loadNounsFromYAML, nounToJSON, nounToYAML, serialize, serializeNoun, toJSON, toYAML };
|