business-as-code 2.1.1 → 2.3.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.
Files changed (212) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/README.md +2 -0
  3. package/package.json +7 -4
  4. package/src/dollar.ts +5 -2
  5. package/src/entities/organization.ts +31 -18
  6. package/src/goals.ts +78 -12
  7. package/src/index.ts +48 -18
  8. package/src/kpis.ts +62 -8
  9. package/src/metrics.ts +92 -79
  10. package/src/okrs.ts +120 -20
  11. package/src/organization.ts +12 -15
  12. package/src/process.ts +11 -12
  13. package/src/product.ts +8 -9
  14. package/src/queries.ts +238 -75
  15. package/src/roles.ts +62 -61
  16. package/src/workflow.ts +22 -15
  17. package/test/business.test.ts +282 -0
  18. package/test/dollar.test.ts +270 -0
  19. package/test/entities.test.ts +628 -0
  20. package/test/financials.test.ts +539 -0
  21. package/test/goals.test.ts +451 -0
  22. package/{src → test}/index.test.ts +1 -1
  23. package/test/kpis.test.ts +440 -0
  24. package/test/metrics.test.ts +744 -0
  25. package/test/okrs.test.ts +741 -0
  26. package/test/organization.test.ts +548 -0
  27. package/test/process.test.ts +503 -0
  28. package/test/product.test.ts +430 -0
  29. package/test/queries.test.ts +556 -0
  30. package/test/roles.test.ts +546 -0
  31. package/test/service.test.ts +450 -0
  32. package/test/types.test.ts +1141 -0
  33. package/test/vision.test.ts +214 -0
  34. package/test/workflow.test.ts +501 -0
  35. package/vitest.config.ts +47 -0
  36. package/.turbo/turbo-build.log +0 -5
  37. package/dist/business.d.ts +0 -62
  38. package/dist/business.d.ts.map +0 -1
  39. package/dist/business.js +0 -109
  40. package/dist/business.js.map +0 -1
  41. package/dist/dollar.d.ts +0 -60
  42. package/dist/dollar.d.ts.map +0 -1
  43. package/dist/dollar.js +0 -107
  44. package/dist/dollar.js.map +0 -1
  45. package/dist/entities/assets.d.ts +0 -21
  46. package/dist/entities/assets.d.ts.map +0 -1
  47. package/dist/entities/assets.js +0 -323
  48. package/dist/entities/assets.js.map +0 -1
  49. package/dist/entities/business.d.ts +0 -36
  50. package/dist/entities/business.d.ts.map +0 -1
  51. package/dist/entities/business.js +0 -370
  52. package/dist/entities/business.js.map +0 -1
  53. package/dist/entities/communication.d.ts +0 -21
  54. package/dist/entities/communication.d.ts.map +0 -1
  55. package/dist/entities/communication.js +0 -255
  56. package/dist/entities/communication.js.map +0 -1
  57. package/dist/entities/customers.d.ts +0 -58
  58. package/dist/entities/customers.d.ts.map +0 -1
  59. package/dist/entities/customers.js +0 -989
  60. package/dist/entities/customers.js.map +0 -1
  61. package/dist/entities/financials.d.ts +0 -59
  62. package/dist/entities/financials.d.ts.map +0 -1
  63. package/dist/entities/financials.js +0 -932
  64. package/dist/entities/financials.js.map +0 -1
  65. package/dist/entities/goals.d.ts +0 -58
  66. package/dist/entities/goals.d.ts.map +0 -1
  67. package/dist/entities/goals.js +0 -800
  68. package/dist/entities/goals.js.map +0 -1
  69. package/dist/entities/index.d.ts +0 -299
  70. package/dist/entities/index.d.ts.map +0 -1
  71. package/dist/entities/index.js +0 -198
  72. package/dist/entities/index.js.map +0 -1
  73. package/dist/entities/legal.d.ts +0 -21
  74. package/dist/entities/legal.d.ts.map +0 -1
  75. package/dist/entities/legal.js +0 -301
  76. package/dist/entities/legal.js.map +0 -1
  77. package/dist/entities/market.d.ts +0 -21
  78. package/dist/entities/market.d.ts.map +0 -1
  79. package/dist/entities/market.js +0 -301
  80. package/dist/entities/market.js.map +0 -1
  81. package/dist/entities/marketing.d.ts +0 -67
  82. package/dist/entities/marketing.d.ts.map +0 -1
  83. package/dist/entities/marketing.js +0 -1157
  84. package/dist/entities/marketing.js.map +0 -1
  85. package/dist/entities/offerings.d.ts +0 -51
  86. package/dist/entities/offerings.d.ts.map +0 -1
  87. package/dist/entities/offerings.js +0 -727
  88. package/dist/entities/offerings.js.map +0 -1
  89. package/dist/entities/operations.d.ts +0 -58
  90. package/dist/entities/operations.d.ts.map +0 -1
  91. package/dist/entities/operations.js +0 -787
  92. package/dist/entities/operations.js.map +0 -1
  93. package/dist/entities/organization.d.ts +0 -57
  94. package/dist/entities/organization.d.ts.map +0 -1
  95. package/dist/entities/organization.js +0 -807
  96. package/dist/entities/organization.js.map +0 -1
  97. package/dist/entities/partnerships.d.ts +0 -21
  98. package/dist/entities/partnerships.d.ts.map +0 -1
  99. package/dist/entities/partnerships.js +0 -300
  100. package/dist/entities/partnerships.js.map +0 -1
  101. package/dist/entities/planning.d.ts +0 -87
  102. package/dist/entities/planning.d.ts.map +0 -1
  103. package/dist/entities/planning.js +0 -271
  104. package/dist/entities/planning.js.map +0 -1
  105. package/dist/entities/projects.d.ts +0 -25
  106. package/dist/entities/projects.d.ts.map +0 -1
  107. package/dist/entities/projects.js +0 -349
  108. package/dist/entities/projects.js.map +0 -1
  109. package/dist/entities/risk.d.ts +0 -21
  110. package/dist/entities/risk.d.ts.map +0 -1
  111. package/dist/entities/risk.js +0 -293
  112. package/dist/entities/risk.js.map +0 -1
  113. package/dist/entities/sales.d.ts +0 -72
  114. package/dist/entities/sales.d.ts.map +0 -1
  115. package/dist/entities/sales.js +0 -1248
  116. package/dist/entities/sales.js.map +0 -1
  117. package/dist/financials.d.ts +0 -130
  118. package/dist/financials.d.ts.map +0 -1
  119. package/dist/financials.js +0 -297
  120. package/dist/financials.js.map +0 -1
  121. package/dist/goals.d.ts +0 -87
  122. package/dist/goals.d.ts.map +0 -1
  123. package/dist/goals.js +0 -215
  124. package/dist/goals.js.map +0 -1
  125. package/dist/index.d.ts +0 -97
  126. package/dist/index.d.ts.map +0 -1
  127. package/dist/index.js +0 -132
  128. package/dist/index.js.map +0 -1
  129. package/dist/kpis.d.ts +0 -118
  130. package/dist/kpis.d.ts.map +0 -1
  131. package/dist/kpis.js +0 -232
  132. package/dist/kpis.js.map +0 -1
  133. package/dist/metrics.d.ts +0 -448
  134. package/dist/metrics.d.ts.map +0 -1
  135. package/dist/metrics.js +0 -325
  136. package/dist/metrics.js.map +0 -1
  137. package/dist/okrs.d.ts +0 -123
  138. package/dist/okrs.d.ts.map +0 -1
  139. package/dist/okrs.js +0 -269
  140. package/dist/okrs.js.map +0 -1
  141. package/dist/organization.d.ts +0 -585
  142. package/dist/organization.d.ts.map +0 -1
  143. package/dist/organization.js +0 -173
  144. package/dist/organization.js.map +0 -1
  145. package/dist/process.d.ts +0 -112
  146. package/dist/process.d.ts.map +0 -1
  147. package/dist/process.js +0 -241
  148. package/dist/process.js.map +0 -1
  149. package/dist/product.d.ts +0 -85
  150. package/dist/product.d.ts.map +0 -1
  151. package/dist/product.js +0 -145
  152. package/dist/product.js.map +0 -1
  153. package/dist/queries.d.ts +0 -304
  154. package/dist/queries.d.ts.map +0 -1
  155. package/dist/queries.js +0 -415
  156. package/dist/queries.js.map +0 -1
  157. package/dist/roles.d.ts +0 -340
  158. package/dist/roles.d.ts.map +0 -1
  159. package/dist/roles.js +0 -255
  160. package/dist/roles.js.map +0 -1
  161. package/dist/service.d.ts +0 -61
  162. package/dist/service.d.ts.map +0 -1
  163. package/dist/service.js +0 -140
  164. package/dist/service.js.map +0 -1
  165. package/dist/types.d.ts +0 -459
  166. package/dist/types.d.ts.map +0 -1
  167. package/dist/types.js +0 -5
  168. package/dist/types.js.map +0 -1
  169. package/dist/vision.d.ts +0 -38
  170. package/dist/vision.d.ts.map +0 -1
  171. package/dist/vision.js +0 -68
  172. package/dist/vision.js.map +0 -1
  173. package/dist/workflow.d.ts +0 -115
  174. package/dist/workflow.d.ts.map +0 -1
  175. package/dist/workflow.js +0 -247
  176. package/dist/workflow.js.map +0 -1
  177. package/src/business.js +0 -108
  178. package/src/dollar.js +0 -106
  179. package/src/entities/assets.js +0 -322
  180. package/src/entities/business.js +0 -369
  181. package/src/entities/communication.js +0 -254
  182. package/src/entities/customers.js +0 -988
  183. package/src/entities/financials.js +0 -931
  184. package/src/entities/goals.js +0 -799
  185. package/src/entities/index.js +0 -197
  186. package/src/entities/legal.js +0 -300
  187. package/src/entities/market.js +0 -300
  188. package/src/entities/marketing.js +0 -1156
  189. package/src/entities/offerings.js +0 -726
  190. package/src/entities/operations.js +0 -786
  191. package/src/entities/organization.js +0 -806
  192. package/src/entities/partnerships.js +0 -299
  193. package/src/entities/planning.js +0 -270
  194. package/src/entities/projects.js +0 -348
  195. package/src/entities/risk.js +0 -292
  196. package/src/entities/sales.js +0 -1247
  197. package/src/financials.js +0 -296
  198. package/src/goals.js +0 -214
  199. package/src/index.js +0 -131
  200. package/src/index.test.js +0 -274
  201. package/src/kpis.js +0 -231
  202. package/src/metrics.js +0 -324
  203. package/src/okrs.js +0 -268
  204. package/src/organization.js +0 -172
  205. package/src/process.js +0 -240
  206. package/src/product.js +0 -144
  207. package/src/queries.js +0 -414
  208. package/src/roles.js +0 -254
  209. package/src/service.js +0 -139
  210. package/src/types.js +0 -4
  211. package/src/vision.js +0 -67
  212. package/src/workflow.js +0 -246
package/src/service.js DELETED
@@ -1,139 +0,0 @@
1
- /**
2
- * Service definition and management
3
- */
4
- /**
5
- * Define a service with pricing, SLA, and delivery information
6
- *
7
- * @example
8
- * ```ts
9
- * const service = Service({
10
- * name: 'Widget Consulting',
11
- * description: 'Expert widget implementation and optimization',
12
- * category: 'Consulting',
13
- * targetSegment: 'Enterprise',
14
- * valueProposition: 'Get expert help implementing widgets in 2 weeks',
15
- * pricingModel: 'fixed',
16
- * price: 5000,
17
- * currency: 'USD',
18
- * deliveryTime: '2 weeks',
19
- * sla: {
20
- * uptime: 99.9,
21
- * responseTime: '< 24 hours',
22
- * supportHours: 'Business hours (9-5 EST)',
23
- * penalties: '10% refund per day of delay',
24
- * },
25
- * })
26
- * ```
27
- */
28
- export function Service(definition) {
29
- if (!definition.name) {
30
- throw new Error('Service name is required');
31
- }
32
- return {
33
- ...definition,
34
- pricingModel: definition.pricingModel || 'hourly',
35
- currency: definition.currency || 'USD',
36
- metadata: definition.metadata || {},
37
- };
38
- }
39
- /**
40
- * Calculate service price based on hours (for hourly pricing)
41
- */
42
- export function calculateHourlyPrice(service, hours) {
43
- if (service.pricingModel !== 'hourly' || !service.price) {
44
- throw new Error('Service must use hourly pricing model');
45
- }
46
- return service.price * hours;
47
- }
48
- /**
49
- * Calculate monthly retainer equivalent
50
- */
51
- export function calculateMonthlyRetainer(service, hoursPerMonth) {
52
- if (service.pricingModel !== 'hourly' || !service.price) {
53
- throw new Error('Service must use hourly pricing model');
54
- }
55
- return service.price * hoursPerMonth;
56
- }
57
- /**
58
- * Check if service meets SLA uptime requirement
59
- */
60
- export function checkSLAUptime(service, actualUptime) {
61
- if (!service.sla?.uptime)
62
- return true;
63
- return actualUptime >= service.sla.uptime;
64
- }
65
- /**
66
- * Parse delivery time to days
67
- */
68
- export function parseDeliveryTimeToDays(deliveryTime) {
69
- if (!deliveryTime)
70
- return 0;
71
- const lower = deliveryTime.toLowerCase();
72
- // Parse patterns like "2 weeks", "3 days", "1 month"
73
- const match = lower.match(/(\d+)\s*(day|days|week|weeks|month|months|hour|hours)/);
74
- if (!match)
75
- return 0;
76
- const value = parseInt(match[1] || '0', 10);
77
- const unit = match[2];
78
- switch (unit) {
79
- case 'hour':
80
- case 'hours':
81
- return value / 24;
82
- case 'day':
83
- case 'days':
84
- return value;
85
- case 'week':
86
- case 'weeks':
87
- return value * 7;
88
- case 'month':
89
- case 'months':
90
- return value * 30;
91
- default:
92
- return 0;
93
- }
94
- }
95
- /**
96
- * Estimate service completion date
97
- */
98
- export function estimateCompletionDate(service, startDate) {
99
- const start = startDate || new Date();
100
- const days = parseDeliveryTimeToDays(service.deliveryTime);
101
- const completion = new Date(start);
102
- completion.setDate(completion.getDate() + days);
103
- return completion;
104
- }
105
- /**
106
- * Calculate service value (for value-based pricing)
107
- */
108
- export function calculateValueBasedPrice(service, customerValue, valueSharePercentage) {
109
- if (service.pricingModel !== 'value-based') {
110
- throw new Error('Service must use value-based pricing model');
111
- }
112
- if (valueSharePercentage < 0 || valueSharePercentage > 100) {
113
- throw new Error('Value share percentage must be between 0 and 100');
114
- }
115
- return customerValue * (valueSharePercentage / 100);
116
- }
117
- /**
118
- * Validate service definition
119
- */
120
- export function validateService(service) {
121
- const errors = [];
122
- if (!service.name) {
123
- errors.push('Service name is required');
124
- }
125
- if (service.price && service.price < 0) {
126
- errors.push('Service price cannot be negative');
127
- }
128
- if (service.sla?.uptime && (service.sla.uptime < 0 || service.sla.uptime > 100)) {
129
- errors.push('SLA uptime must be between 0 and 100');
130
- }
131
- if (service.pricingModel &&
132
- !['hourly', 'fixed', 'retainer', 'value-based'].includes(service.pricingModel)) {
133
- errors.push('Invalid pricing model');
134
- }
135
- return {
136
- valid: errors.length === 0,
137
- errors,
138
- };
139
- }
package/src/types.js DELETED
@@ -1,4 +0,0 @@
1
- /**
2
- * Core types for business-as-code primitives
3
- */
4
- export {};
package/src/vision.js DELETED
@@ -1,67 +0,0 @@
1
- /**
2
- * Vision statement definition
3
- */
4
- /**
5
- * Define a business vision statement with timeframe and success indicators
6
- *
7
- * @example
8
- * ```ts
9
- * const vision = Vision({
10
- * statement: 'To become the world\'s most trusted widget platform',
11
- * timeframe: '5 years',
12
- * successIndicators: [
13
- * '10M+ active users',
14
- * 'Present in 50+ countries',
15
- * 'Industry-leading NPS score',
16
- * '$1B+ annual revenue',
17
- * ],
18
- * })
19
- * ```
20
- */
21
- export function Vision(definition) {
22
- // Validate required fields
23
- if (!definition.statement) {
24
- throw new Error('Vision statement is required');
25
- }
26
- // Return validated vision definition
27
- return {
28
- ...definition,
29
- successIndicators: definition.successIndicators || [],
30
- metadata: definition.metadata || {},
31
- };
32
- }
33
- /**
34
- * Check if a success indicator has been achieved
35
- */
36
- export function checkIndicator(vision, indicator, currentMetrics) {
37
- // Simple check - would need more sophisticated parsing in production
38
- return Object.entries(currentMetrics).some(([key, value]) => {
39
- return indicator.toLowerCase().includes(key.toLowerCase()) && Boolean(value);
40
- });
41
- }
42
- /**
43
- * Calculate vision progress based on achieved indicators
44
- */
45
- export function calculateProgress(vision, currentMetrics) {
46
- if (!vision.successIndicators || vision.successIndicators.length === 0) {
47
- return 0;
48
- }
49
- const achieved = vision.successIndicators.filter(indicator => checkIndicator(vision, indicator, currentMetrics)).length;
50
- return (achieved / vision.successIndicators.length) * 100;
51
- }
52
- /**
53
- * Validate vision definition
54
- */
55
- export function validateVision(vision) {
56
- const errors = [];
57
- if (!vision.statement) {
58
- errors.push('Vision statement is required');
59
- }
60
- if (vision.statement && vision.statement.length < 10) {
61
- errors.push('Vision statement should be at least 10 characters');
62
- }
63
- return {
64
- valid: errors.length === 0,
65
- errors,
66
- };
67
- }
package/src/workflow.js DELETED
@@ -1,246 +0,0 @@
1
- /**
2
- * Workflow definition (automation sequences)
3
- */
4
- /**
5
- * Define an automated workflow with triggers and actions
6
- *
7
- * @example
8
- * ```ts
9
- * const workflow = Workflow({
10
- * name: 'New Customer Welcome',
11
- * description: 'Automated welcome sequence for new customers',
12
- * trigger: {
13
- * type: 'event',
14
- * event: 'Customer.created',
15
- * },
16
- * actions: [
17
- * {
18
- * order: 1,
19
- * type: 'send',
20
- * description: 'Send welcome email',
21
- * params: {
22
- * template: 'welcome_email',
23
- * to: '{{customer.email}}',
24
- * },
25
- * },
26
- * {
27
- * order: 2,
28
- * type: 'create',
29
- * description: 'Create onboarding task',
30
- * params: {
31
- * type: 'Task',
32
- * title: 'Onboard {{customer.name}}',
33
- * assignee: 'customer_success_team',
34
- * },
35
- * },
36
- * {
37
- * order: 3,
38
- * type: 'wait',
39
- * description: 'Wait 24 hours',
40
- * params: {
41
- * duration: '24 hours',
42
- * },
43
- * },
44
- * {
45
- * order: 4,
46
- * type: 'notify',
47
- * description: 'Send setup reminder',
48
- * params: {
49
- * channel: 'email',
50
- * message: 'Reminder to complete setup',
51
- * },
52
- * condition: 'customer.setupCompleted === false',
53
- * },
54
- * ],
55
- * })
56
- * ```
57
- */
58
- export function Workflow(definition) {
59
- if (!definition.name) {
60
- throw new Error('Workflow name is required');
61
- }
62
- if (!definition.trigger) {
63
- throw new Error('Workflow trigger is required');
64
- }
65
- return {
66
- ...definition,
67
- actions: definition.actions || [],
68
- metadata: definition.metadata || {},
69
- };
70
- }
71
- /**
72
- * Get actions in execution order
73
- */
74
- export function getActionsInOrder(workflow) {
75
- return [...(workflow.actions || [])].sort((a, b) => a.order - b.order);
76
- }
77
- /**
78
- * Get actions by type
79
- */
80
- export function getActionsByType(workflow, type) {
81
- return workflow.actions?.filter(action => action.type === type) || [];
82
- }
83
- /**
84
- * Get conditional actions
85
- */
86
- export function getConditionalActions(workflow) {
87
- return workflow.actions?.filter(action => action.condition) || [];
88
- }
89
- /**
90
- * Add action to workflow
91
- */
92
- export function addAction(workflow, action) {
93
- return {
94
- ...workflow,
95
- actions: [...(workflow.actions || []), action],
96
- };
97
- }
98
- /**
99
- * Remove action from workflow
100
- */
101
- export function removeAction(workflow, order) {
102
- return {
103
- ...workflow,
104
- actions: workflow.actions?.filter(a => a.order !== order),
105
- };
106
- }
107
- /**
108
- * Update action in workflow
109
- */
110
- export function updateAction(workflow, order, updates) {
111
- const actions = workflow.actions?.map(action => action.order === order ? { ...action, ...updates } : action);
112
- return {
113
- ...workflow,
114
- actions,
115
- };
116
- }
117
- /**
118
- * Check if trigger is event-based
119
- */
120
- export function isEventTrigger(trigger) {
121
- return trigger.type === 'event';
122
- }
123
- /**
124
- * Check if trigger is schedule-based
125
- */
126
- export function isScheduleTrigger(trigger) {
127
- return trigger.type === 'schedule';
128
- }
129
- /**
130
- * Check if trigger is webhook-based
131
- */
132
- export function isWebhookTrigger(trigger) {
133
- return trigger.type === 'webhook';
134
- }
135
- /**
136
- * Parse wait duration to milliseconds
137
- */
138
- export function parseWaitDuration(duration) {
139
- const match = duration.match(/(\d+)\s*(ms|millisecond|milliseconds|s|second|seconds|m|minute|minutes|h|hour|hours|d|day|days)/);
140
- if (!match)
141
- return 0;
142
- const value = parseInt(match[1] || '0', 10);
143
- const unit = match[2];
144
- switch (unit) {
145
- case 'ms':
146
- case 'millisecond':
147
- case 'milliseconds':
148
- return value;
149
- case 's':
150
- case 'second':
151
- case 'seconds':
152
- return value * 1000;
153
- case 'm':
154
- case 'minute':
155
- case 'minutes':
156
- return value * 60 * 1000;
157
- case 'h':
158
- case 'hour':
159
- case 'hours':
160
- return value * 60 * 60 * 1000;
161
- case 'd':
162
- case 'day':
163
- case 'days':
164
- return value * 24 * 60 * 60 * 1000;
165
- default:
166
- return 0;
167
- }
168
- }
169
- /**
170
- * Evaluate condition (simple implementation)
171
- */
172
- export function evaluateCondition(condition, context) {
173
- // This is a simplified implementation
174
- // In production, use a proper expression evaluator
175
- try {
176
- // Replace variable references with actual values
177
- let expression = condition;
178
- for (const [key, value] of Object.entries(context)) {
179
- const regex = new RegExp(`\\b${key}\\b`, 'g');
180
- expression = expression.replace(regex, JSON.stringify(value));
181
- }
182
- // Evaluate the expression (unsafe in production - use a proper evaluator)
183
- return Boolean(eval(expression));
184
- }
185
- catch {
186
- return false;
187
- }
188
- }
189
- /**
190
- * Fill template with context values
191
- */
192
- export function fillTemplate(template, context) {
193
- return template.replace(/\{\{([^}]+)\}\}/g, (_, path) => {
194
- const value = getNestedValue(context, path.trim());
195
- return String(value ?? '');
196
- });
197
- }
198
- /**
199
- * Get nested value from object by path
200
- */
201
- function getNestedValue(obj, path) {
202
- return path.split('.').reduce((acc, part) => acc?.[part], obj);
203
- }
204
- /**
205
- * Validate workflow definition
206
- */
207
- export function validateWorkflow(workflow) {
208
- const errors = [];
209
- if (!workflow.name) {
210
- errors.push('Workflow name is required');
211
- }
212
- if (!workflow.trigger) {
213
- errors.push('Workflow trigger is required');
214
- }
215
- else {
216
- if (workflow.trigger.type === 'event' && !workflow.trigger.event) {
217
- errors.push('Event trigger must specify an event name');
218
- }
219
- if (workflow.trigger.type === 'schedule' && !workflow.trigger.schedule) {
220
- errors.push('Schedule trigger must specify a schedule expression');
221
- }
222
- if (workflow.trigger.type === 'webhook' && !workflow.trigger.webhook) {
223
- errors.push('Webhook trigger must specify a webhook URL');
224
- }
225
- }
226
- if (workflow.actions) {
227
- const orders = new Set();
228
- for (const action of workflow.actions) {
229
- if (!action.type) {
230
- errors.push(`Action at order ${action.order} must have a type`);
231
- }
232
- if (orders.has(action.order)) {
233
- errors.push(`Duplicate action order: ${action.order}`);
234
- }
235
- orders.add(action.order);
236
- // Validate action-specific requirements
237
- if (action.type === 'wait' && !action.params?.duration) {
238
- errors.push(`Wait action at order ${action.order} must specify duration`);
239
- }
240
- }
241
- }
242
- return {
243
- valid: errors.length === 0,
244
- errors,
245
- };
246
- }