services-as-software 0.1.0 → 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.
Files changed (78) hide show
  1. package/.turbo/turbo-build.log +5 -0
  2. package/CHANGELOG.md +10 -0
  3. package/README.md +235 -225
  4. package/dist/client.d.ts +25 -0
  5. package/dist/client.d.ts.map +1 -0
  6. package/dist/client.js +103 -0
  7. package/dist/client.js.map +1 -0
  8. package/dist/endpoint.d.ts +102 -0
  9. package/dist/endpoint.d.ts.map +1 -0
  10. package/dist/endpoint.js +96 -0
  11. package/dist/endpoint.js.map +1 -0
  12. package/dist/entities/billing.d.ts +60 -0
  13. package/dist/entities/billing.d.ts.map +1 -0
  14. package/dist/entities/billing.js +954 -0
  15. package/dist/entities/billing.js.map +1 -0
  16. package/dist/entities/customers.d.ts +45 -0
  17. package/dist/entities/customers.d.ts.map +1 -0
  18. package/dist/entities/customers.js +679 -0
  19. package/dist/entities/customers.js.map +1 -0
  20. package/dist/entities/delivery.d.ts +59 -0
  21. package/dist/entities/delivery.d.ts.map +1 -0
  22. package/dist/entities/delivery.js +890 -0
  23. package/dist/entities/delivery.js.map +1 -0
  24. package/dist/entities/index.d.ts +114 -0
  25. package/dist/entities/index.d.ts.map +1 -0
  26. package/dist/entities/index.js +89 -0
  27. package/dist/entities/index.js.map +1 -0
  28. package/dist/entities/operations.d.ts +59 -0
  29. package/dist/entities/operations.d.ts.map +1 -0
  30. package/dist/entities/operations.js +1010 -0
  31. package/dist/entities/operations.js.map +1 -0
  32. package/dist/entities/orchestration.d.ts +52 -0
  33. package/dist/entities/orchestration.d.ts.map +1 -0
  34. package/dist/entities/orchestration.js +883 -0
  35. package/dist/entities/orchestration.js.map +1 -0
  36. package/dist/entities/services.d.ts +50 -0
  37. package/dist/entities/services.d.ts.map +1 -0
  38. package/dist/entities/services.js +805 -0
  39. package/dist/entities/services.js.map +1 -0
  40. package/dist/helpers.d.ts +362 -0
  41. package/dist/helpers.d.ts.map +1 -0
  42. package/dist/helpers.js +400 -0
  43. package/dist/helpers.js.map +1 -0
  44. package/dist/index.d.ts +17 -215
  45. package/dist/index.d.ts.map +1 -0
  46. package/dist/index.js +18 -172
  47. package/dist/index.js.map +1 -0
  48. package/dist/provider.d.ts +85 -0
  49. package/dist/provider.d.ts.map +1 -0
  50. package/dist/provider.js +158 -0
  51. package/dist/provider.js.map +1 -0
  52. package/dist/service.d.ts +43 -0
  53. package/dist/service.d.ts.map +1 -0
  54. package/dist/service.js +206 -0
  55. package/dist/service.js.map +1 -0
  56. package/dist/types.d.ts +469 -0
  57. package/dist/types.d.ts.map +1 -0
  58. package/dist/types.js +5 -0
  59. package/dist/types.js.map +1 -0
  60. package/examples/client-usage.ts +82 -0
  61. package/examples/translation-service.ts +227 -0
  62. package/package.json +24 -38
  63. package/src/client.ts +132 -0
  64. package/src/endpoint.ts +144 -0
  65. package/src/entities/billing.ts +1037 -0
  66. package/src/entities/customers.ts +740 -0
  67. package/src/entities/delivery.ts +974 -0
  68. package/src/entities/index.ts +157 -0
  69. package/src/entities/operations.ts +1099 -0
  70. package/src/entities/orchestration.ts +956 -0
  71. package/src/entities/services.ts +872 -0
  72. package/src/helpers.ts +474 -0
  73. package/src/index.ts +97 -0
  74. package/src/provider.ts +183 -0
  75. package/src/service.test.ts +195 -0
  76. package/src/service.ts +266 -0
  77. package/src/types.ts +543 -0
  78. package/tsconfig.json +9 -0
@@ -0,0 +1,872 @@
1
+ /**
2
+ * Service Entity Types (Nouns)
3
+ *
4
+ * Core service entities: ProductizedService, ServiceOffering, ServicePlan, ServiceInstance, ServiceExecution
5
+ *
6
+ * @packageDocumentation
7
+ */
8
+
9
+ import type { Noun } from 'ai-database'
10
+
11
+ // =============================================================================
12
+ // ProductizedService
13
+ // =============================================================================
14
+
15
+ /**
16
+ * ProductizedService entity
17
+ *
18
+ * A service packaged and delivered as software.
19
+ */
20
+ export const ProductizedService: Noun = {
21
+ singular: 'productized-service',
22
+ plural: 'productized-services',
23
+ description: 'A service packaged and delivered as software',
24
+
25
+ properties: {
26
+ // Identity
27
+ name: {
28
+ type: 'string',
29
+ description: 'Service name',
30
+ },
31
+ slug: {
32
+ type: 'string',
33
+ optional: true,
34
+ description: 'URL-friendly identifier',
35
+ },
36
+ description: {
37
+ type: 'string',
38
+ optional: true,
39
+ description: 'Service description',
40
+ },
41
+ tagline: {
42
+ type: 'string',
43
+ optional: true,
44
+ description: 'Short marketing tagline',
45
+ },
46
+
47
+ // Classification
48
+ type: {
49
+ type: 'string',
50
+ description: 'Service type',
51
+ examples: ['consulting', 'implementation', 'support', 'managed', 'creative', 'technical', 'ai-powered'],
52
+ },
53
+ category: {
54
+ type: 'string',
55
+ optional: true,
56
+ description: 'Service category',
57
+ },
58
+ domain: {
59
+ type: 'string',
60
+ optional: true,
61
+ description: 'Business domain',
62
+ },
63
+
64
+ // Delivery Model
65
+ deliveryModel: {
66
+ type: 'string',
67
+ description: 'How service is delivered',
68
+ examples: ['autonomous', 'assisted', 'supervised', 'manual', 'hybrid'],
69
+ },
70
+ automationLevel: {
71
+ type: 'number',
72
+ optional: true,
73
+ description: 'Automation percentage (0-100)',
74
+ },
75
+
76
+ // Autonomy
77
+ autonomyLevel: {
78
+ type: 'number',
79
+ optional: true,
80
+ description: 'AI autonomy level (1-5)',
81
+ },
82
+ confidenceThreshold: {
83
+ type: 'number',
84
+ optional: true,
85
+ description: 'Min confidence for auto-completion (0-1)',
86
+ },
87
+ escalationPolicy: {
88
+ type: 'string',
89
+ optional: true,
90
+ description: 'When to escalate to humans',
91
+ examples: ['immediate', 'queue', 'scheduled', 'manual', 'never'],
92
+ },
93
+
94
+ // Scope
95
+ inclusions: {
96
+ type: 'string',
97
+ array: true,
98
+ optional: true,
99
+ description: 'What is included',
100
+ },
101
+ exclusions: {
102
+ type: 'string',
103
+ array: true,
104
+ optional: true,
105
+ description: 'What is excluded',
106
+ },
107
+ deliverables: {
108
+ type: 'string',
109
+ array: true,
110
+ optional: true,
111
+ description: 'Service deliverables',
112
+ },
113
+
114
+ // Timing
115
+ estimatedDuration: {
116
+ type: 'string',
117
+ optional: true,
118
+ description: 'Estimated delivery time',
119
+ },
120
+ turnaroundTime: {
121
+ type: 'string',
122
+ optional: true,
123
+ description: 'Standard turnaround time',
124
+ examples: ['instant', 'minutes', 'hours', 'days', 'weeks'],
125
+ },
126
+
127
+ // Capacity
128
+ capacityModel: {
129
+ type: 'string',
130
+ optional: true,
131
+ description: 'Capacity model',
132
+ examples: ['unlimited', 'limited', 'queue-based', 'appointment'],
133
+ },
134
+ maxConcurrent: {
135
+ type: 'number',
136
+ optional: true,
137
+ description: 'Max concurrent executions',
138
+ },
139
+
140
+ // Pricing
141
+ pricingModel: {
142
+ type: 'string',
143
+ optional: true,
144
+ description: 'Pricing model',
145
+ examples: ['fixed', 'per-use', 'subscription', 'tiered', 'custom'],
146
+ },
147
+ basePrice: {
148
+ type: 'number',
149
+ optional: true,
150
+ description: 'Base price',
151
+ },
152
+ currency: {
153
+ type: 'string',
154
+ optional: true,
155
+ description: 'Currency code',
156
+ },
157
+
158
+ // Status
159
+ status: {
160
+ type: 'string',
161
+ description: 'Service status',
162
+ examples: ['draft', 'active', 'paused', 'deprecated', 'archived'],
163
+ },
164
+ visibility: {
165
+ type: 'string',
166
+ optional: true,
167
+ description: 'Visibility',
168
+ examples: ['public', 'private', 'invite-only', 'beta'],
169
+ },
170
+ },
171
+
172
+ relationships: {
173
+ provider: {
174
+ type: 'Organization',
175
+ required: false,
176
+ description: 'Service provider',
177
+ },
178
+ plans: {
179
+ type: 'ServicePlan[]',
180
+ description: 'Pricing plans',
181
+ },
182
+ offerings: {
183
+ type: 'ServiceOffering[]',
184
+ description: 'Service offerings/tiers',
185
+ },
186
+ agent: {
187
+ type: 'AgentDelivery',
188
+ required: false,
189
+ description: 'AI agent for delivery',
190
+ },
191
+ sla: {
192
+ type: 'SLA',
193
+ required: false,
194
+ description: 'Service level agreement',
195
+ },
196
+ workflows: {
197
+ type: 'ServiceWorkflow[]',
198
+ description: 'Service workflows',
199
+ },
200
+ },
201
+
202
+ actions: [
203
+ 'create',
204
+ 'update',
205
+ 'publish',
206
+ 'pause',
207
+ 'resume',
208
+ 'execute',
209
+ 'escalate',
210
+ 'complete',
211
+ 'deprecate',
212
+ 'archive',
213
+ ],
214
+
215
+ events: [
216
+ 'created',
217
+ 'updated',
218
+ 'published',
219
+ 'paused',
220
+ 'resumed',
221
+ 'executed',
222
+ 'escalated',
223
+ 'completed',
224
+ 'deprecated',
225
+ 'archived',
226
+ ],
227
+ }
228
+
229
+ // =============================================================================
230
+ // ServiceOffering
231
+ // =============================================================================
232
+
233
+ /**
234
+ * ServiceOffering entity
235
+ *
236
+ * A specific offering or tier of a service.
237
+ */
238
+ export const ServiceOffering: Noun = {
239
+ singular: 'service-offering',
240
+ plural: 'service-offerings',
241
+ description: 'A specific offering or tier of a productized service',
242
+
243
+ properties: {
244
+ // Identity
245
+ name: {
246
+ type: 'string',
247
+ description: 'Offering name',
248
+ },
249
+ slug: {
250
+ type: 'string',
251
+ optional: true,
252
+ description: 'URL-friendly identifier',
253
+ },
254
+ description: {
255
+ type: 'string',
256
+ optional: true,
257
+ description: 'Offering description',
258
+ },
259
+
260
+ // Tier
261
+ tier: {
262
+ type: 'string',
263
+ description: 'Offering tier',
264
+ examples: ['basic', 'standard', 'premium', 'enterprise', 'custom'],
265
+ },
266
+ displayOrder: {
267
+ type: 'number',
268
+ optional: true,
269
+ description: 'Display order',
270
+ },
271
+ highlighted: {
272
+ type: 'boolean',
273
+ optional: true,
274
+ description: 'Featured/highlighted offering',
275
+ },
276
+
277
+ // Scope
278
+ scope: {
279
+ type: 'string',
280
+ optional: true,
281
+ description: 'Scope of work',
282
+ },
283
+ inclusions: {
284
+ type: 'string',
285
+ array: true,
286
+ optional: true,
287
+ description: 'What is included',
288
+ },
289
+ limitations: {
290
+ type: 'string',
291
+ array: true,
292
+ optional: true,
293
+ description: 'Limitations',
294
+ },
295
+
296
+ // Delivery
297
+ deliveryTime: {
298
+ type: 'string',
299
+ optional: true,
300
+ description: 'Delivery time',
301
+ },
302
+ revisions: {
303
+ type: 'number',
304
+ optional: true,
305
+ description: 'Number of revisions included',
306
+ },
307
+ supportLevel: {
308
+ type: 'string',
309
+ optional: true,
310
+ description: 'Support level',
311
+ examples: ['email', 'priority', 'dedicated', '24/7'],
312
+ },
313
+
314
+ // Pricing
315
+ price: {
316
+ type: 'number',
317
+ description: 'Price',
318
+ },
319
+ currency: {
320
+ type: 'string',
321
+ optional: true,
322
+ description: 'Currency code',
323
+ },
324
+ billingType: {
325
+ type: 'string',
326
+ optional: true,
327
+ description: 'Billing type',
328
+ examples: ['one-time', 'recurring', 'usage-based'],
329
+ },
330
+
331
+ // Availability
332
+ availability: {
333
+ type: 'string',
334
+ optional: true,
335
+ description: 'Availability',
336
+ examples: ['always', 'limited', 'by-appointment', 'seasonal'],
337
+ },
338
+ maxOrders: {
339
+ type: 'number',
340
+ optional: true,
341
+ description: 'Max orders per period',
342
+ },
343
+
344
+ // Status
345
+ status: {
346
+ type: 'string',
347
+ description: 'Offering status',
348
+ examples: ['active', 'inactive', 'sold-out', 'discontinued'],
349
+ },
350
+ },
351
+
352
+ relationships: {
353
+ service: {
354
+ type: 'ProductizedService',
355
+ description: 'Parent service',
356
+ },
357
+ orders: {
358
+ type: 'ServiceOrder[]',
359
+ description: 'Orders for this offering',
360
+ },
361
+ },
362
+
363
+ actions: [
364
+ 'create',
365
+ 'update',
366
+ 'activate',
367
+ 'deactivate',
368
+ 'updatePricing',
369
+ 'discontinue',
370
+ ],
371
+
372
+ events: [
373
+ 'created',
374
+ 'updated',
375
+ 'activated',
376
+ 'deactivated',
377
+ 'pricingUpdated',
378
+ 'discontinued',
379
+ ],
380
+ }
381
+
382
+ // =============================================================================
383
+ // ServicePlan
384
+ // =============================================================================
385
+
386
+ /**
387
+ * ServicePlan entity
388
+ *
389
+ * A subscription plan for a service.
390
+ */
391
+ export const ServicePlan: Noun = {
392
+ singular: 'service-plan',
393
+ plural: 'service-plans',
394
+ description: 'A subscription plan for a productized service',
395
+
396
+ properties: {
397
+ // Identity
398
+ name: {
399
+ type: 'string',
400
+ description: 'Plan name',
401
+ },
402
+ slug: {
403
+ type: 'string',
404
+ optional: true,
405
+ description: 'URL-friendly identifier',
406
+ },
407
+ description: {
408
+ type: 'string',
409
+ optional: true,
410
+ description: 'Plan description',
411
+ },
412
+
413
+ // Tier
414
+ tier: {
415
+ type: 'string',
416
+ description: 'Plan tier',
417
+ examples: ['free', 'starter', 'pro', 'business', 'enterprise'],
418
+ },
419
+ displayOrder: {
420
+ type: 'number',
421
+ optional: true,
422
+ description: 'Display order',
423
+ },
424
+ highlighted: {
425
+ type: 'boolean',
426
+ optional: true,
427
+ description: 'Featured plan',
428
+ },
429
+
430
+ // Pricing
431
+ price: {
432
+ type: 'number',
433
+ description: 'Plan price',
434
+ },
435
+ currency: {
436
+ type: 'string',
437
+ optional: true,
438
+ description: 'Currency code',
439
+ },
440
+ billingInterval: {
441
+ type: 'string',
442
+ description: 'Billing interval',
443
+ examples: ['monthly', 'quarterly', 'yearly'],
444
+ },
445
+ annualDiscount: {
446
+ type: 'number',
447
+ optional: true,
448
+ description: 'Annual discount percentage',
449
+ },
450
+
451
+ // Entitlements
452
+ entitlements: {
453
+ type: 'string',
454
+ array: true,
455
+ optional: true,
456
+ description: 'Plan entitlements',
457
+ },
458
+ features: {
459
+ type: 'string',
460
+ array: true,
461
+ optional: true,
462
+ description: 'Included features',
463
+ },
464
+
465
+ // Limits
466
+ limits: {
467
+ type: 'json',
468
+ optional: true,
469
+ description: 'Usage limits',
470
+ },
471
+ executionsPerMonth: {
472
+ type: 'number',
473
+ optional: true,
474
+ description: 'Executions per month',
475
+ },
476
+ supportHours: {
477
+ type: 'number',
478
+ optional: true,
479
+ description: 'Support hours included',
480
+ },
481
+
482
+ // Overage
483
+ overagePrice: {
484
+ type: 'number',
485
+ optional: true,
486
+ description: 'Price per overage unit',
487
+ },
488
+ overageEnabled: {
489
+ type: 'boolean',
490
+ optional: true,
491
+ description: 'Allow overage',
492
+ },
493
+
494
+ // Trial
495
+ trialDays: {
496
+ type: 'number',
497
+ optional: true,
498
+ description: 'Trial period days',
499
+ },
500
+ trialRequiresCard: {
501
+ type: 'boolean',
502
+ optional: true,
503
+ description: 'Trial requires payment method',
504
+ },
505
+
506
+ // Status
507
+ status: {
508
+ type: 'string',
509
+ description: 'Plan status',
510
+ examples: ['active', 'hidden', 'discontinued', 'legacy'],
511
+ },
512
+ },
513
+
514
+ relationships: {
515
+ service: {
516
+ type: 'ProductizedService',
517
+ description: 'Parent service',
518
+ },
519
+ subscriptions: {
520
+ type: 'ServiceSubscription[]',
521
+ description: 'Active subscriptions',
522
+ },
523
+ },
524
+
525
+ actions: [
526
+ 'create',
527
+ 'update',
528
+ 'activate',
529
+ 'hide',
530
+ 'updatePricing',
531
+ 'discontinue',
532
+ ],
533
+
534
+ events: [
535
+ 'created',
536
+ 'updated',
537
+ 'activated',
538
+ 'hidden',
539
+ 'pricingUpdated',
540
+ 'discontinued',
541
+ ],
542
+ }
543
+
544
+ // =============================================================================
545
+ // ServiceInstance
546
+ // =============================================================================
547
+
548
+ /**
549
+ * ServiceInstance entity
550
+ *
551
+ * A running instance of a service for a customer.
552
+ */
553
+ export const ServiceInstance: Noun = {
554
+ singular: 'service-instance',
555
+ plural: 'service-instances',
556
+ description: 'A running instance of a service for a customer',
557
+
558
+ properties: {
559
+ // Identity
560
+ id: {
561
+ type: 'string',
562
+ description: 'Instance ID',
563
+ },
564
+ name: {
565
+ type: 'string',
566
+ optional: true,
567
+ description: 'Instance name',
568
+ },
569
+
570
+ // Configuration
571
+ config: {
572
+ type: 'json',
573
+ optional: true,
574
+ description: 'Instance configuration',
575
+ },
576
+ environment: {
577
+ type: 'string',
578
+ optional: true,
579
+ description: 'Environment',
580
+ examples: ['production', 'staging', 'development'],
581
+ },
582
+
583
+ // Resources
584
+ resourceAllocation: {
585
+ type: 'json',
586
+ optional: true,
587
+ description: 'Allocated resources',
588
+ },
589
+
590
+ // State
591
+ state: {
592
+ type: 'json',
593
+ optional: true,
594
+ description: 'Instance state',
595
+ },
596
+ lastActivityAt: {
597
+ type: 'date',
598
+ optional: true,
599
+ description: 'Last activity timestamp',
600
+ },
601
+
602
+ // Dates
603
+ provisionedAt: {
604
+ type: 'date',
605
+ optional: true,
606
+ description: 'Provisioning date',
607
+ },
608
+ expiresAt: {
609
+ type: 'date',
610
+ optional: true,
611
+ description: 'Expiration date',
612
+ },
613
+
614
+ // Status
615
+ status: {
616
+ type: 'string',
617
+ description: 'Instance status',
618
+ examples: ['provisioning', 'running', 'paused', 'stopped', 'terminated', 'failed'],
619
+ },
620
+ healthStatus: {
621
+ type: 'string',
622
+ optional: true,
623
+ description: 'Health status',
624
+ examples: ['healthy', 'degraded', 'unhealthy', 'unknown'],
625
+ },
626
+ },
627
+
628
+ relationships: {
629
+ service: {
630
+ type: 'ProductizedService',
631
+ description: 'Service type',
632
+ },
633
+ customer: {
634
+ type: 'ServiceCustomer',
635
+ description: 'Customer',
636
+ },
637
+ subscription: {
638
+ type: 'ServiceSubscription',
639
+ required: false,
640
+ description: 'Associated subscription',
641
+ },
642
+ executions: {
643
+ type: 'ServiceExecution[]',
644
+ description: 'Execution history',
645
+ },
646
+ },
647
+
648
+ actions: [
649
+ 'provision',
650
+ 'configure',
651
+ 'start',
652
+ 'stop',
653
+ 'pause',
654
+ 'resume',
655
+ 'scale',
656
+ 'terminate',
657
+ ],
658
+
659
+ events: [
660
+ 'provisioned',
661
+ 'configured',
662
+ 'started',
663
+ 'stopped',
664
+ 'paused',
665
+ 'resumed',
666
+ 'scaled',
667
+ 'terminated',
668
+ ],
669
+ }
670
+
671
+ // =============================================================================
672
+ // ServiceExecution
673
+ // =============================================================================
674
+
675
+ /**
676
+ * ServiceExecution entity
677
+ *
678
+ * A single execution or run of a service.
679
+ */
680
+ export const ServiceExecution: Noun = {
681
+ singular: 'service-execution',
682
+ plural: 'service-executions',
683
+ description: 'A single execution or run of a service',
684
+
685
+ properties: {
686
+ // Identity
687
+ id: {
688
+ type: 'string',
689
+ description: 'Execution ID',
690
+ },
691
+ requestId: {
692
+ type: 'string',
693
+ optional: true,
694
+ description: 'Request trace ID',
695
+ },
696
+
697
+ // Input/Output
698
+ input: {
699
+ type: 'json',
700
+ optional: true,
701
+ description: 'Execution input',
702
+ },
703
+ output: {
704
+ type: 'json',
705
+ optional: true,
706
+ description: 'Execution output',
707
+ },
708
+ context: {
709
+ type: 'json',
710
+ optional: true,
711
+ description: 'Execution context',
712
+ },
713
+
714
+ // Execution Details
715
+ executionType: {
716
+ type: 'string',
717
+ optional: true,
718
+ description: 'Type of execution',
719
+ examples: ['sync', 'async', 'batch', 'scheduled', 'triggered'],
720
+ },
721
+ trigger: {
722
+ type: 'string',
723
+ optional: true,
724
+ description: 'What triggered execution',
725
+ examples: ['api', 'schedule', 'webhook', 'manual', 'event'],
726
+ },
727
+
728
+ // AI Details
729
+ agentUsed: {
730
+ type: 'boolean',
731
+ optional: true,
732
+ description: 'AI agent was used',
733
+ },
734
+ confidence: {
735
+ type: 'number',
736
+ optional: true,
737
+ description: 'AI confidence score (0-1)',
738
+ },
739
+ humanReviewRequired: {
740
+ type: 'boolean',
741
+ optional: true,
742
+ description: 'Human review needed',
743
+ },
744
+ humanReviewed: {
745
+ type: 'boolean',
746
+ optional: true,
747
+ description: 'Was reviewed by human',
748
+ },
749
+
750
+ // Timing
751
+ startedAt: {
752
+ type: 'date',
753
+ optional: true,
754
+ description: 'Start time',
755
+ },
756
+ completedAt: {
757
+ type: 'date',
758
+ optional: true,
759
+ description: 'Completion time',
760
+ },
761
+ durationMs: {
762
+ type: 'number',
763
+ optional: true,
764
+ description: 'Duration in milliseconds',
765
+ },
766
+
767
+ // Resources
768
+ tokensUsed: {
769
+ type: 'number',
770
+ optional: true,
771
+ description: 'AI tokens consumed',
772
+ },
773
+ computeUnits: {
774
+ type: 'number',
775
+ optional: true,
776
+ description: 'Compute units used',
777
+ },
778
+ cost: {
779
+ type: 'number',
780
+ optional: true,
781
+ description: 'Execution cost',
782
+ },
783
+
784
+ // Errors
785
+ error: {
786
+ type: 'string',
787
+ optional: true,
788
+ description: 'Error message if failed',
789
+ },
790
+ errorCode: {
791
+ type: 'string',
792
+ optional: true,
793
+ description: 'Error code',
794
+ },
795
+ retryCount: {
796
+ type: 'number',
797
+ optional: true,
798
+ description: 'Number of retries',
799
+ },
800
+
801
+ // Status
802
+ status: {
803
+ type: 'string',
804
+ description: 'Execution status',
805
+ examples: ['pending', 'running', 'completed', 'failed', 'cancelled', 'timeout', 'escalated'],
806
+ },
807
+ },
808
+
809
+ relationships: {
810
+ instance: {
811
+ type: 'ServiceInstance',
812
+ required: false,
813
+ description: 'Service instance',
814
+ },
815
+ service: {
816
+ type: 'ProductizedService',
817
+ description: 'Service',
818
+ },
819
+ customer: {
820
+ type: 'ServiceCustomer',
821
+ description: 'Customer',
822
+ },
823
+ workflow: {
824
+ type: 'ServiceWorkflow',
825
+ required: false,
826
+ description: 'Workflow executed',
827
+ },
828
+ tasks: {
829
+ type: 'ServiceTask[]',
830
+ description: 'Tasks in this execution',
831
+ },
832
+ },
833
+
834
+ actions: [
835
+ 'start',
836
+ 'pause',
837
+ 'resume',
838
+ 'cancel',
839
+ 'retry',
840
+ 'escalate',
841
+ 'complete',
842
+ 'fail',
843
+ ],
844
+
845
+ events: [
846
+ 'started',
847
+ 'paused',
848
+ 'resumed',
849
+ 'cancelled',
850
+ 'retried',
851
+ 'escalated',
852
+ 'completed',
853
+ 'failed',
854
+ ],
855
+ }
856
+
857
+ // =============================================================================
858
+ // Exports
859
+ // =============================================================================
860
+
861
+ export const ServiceEntities = {
862
+ ProductizedService,
863
+ ServiceOffering,
864
+ ServicePlan,
865
+ ServiceInstance,
866
+ ServiceExecution,
867
+ }
868
+
869
+ export const ServiceCategories = {
870
+ core: ['ProductizedService', 'ServiceOffering', 'ServicePlan'],
871
+ runtime: ['ServiceInstance', 'ServiceExecution'],
872
+ } as const