@timeax/digital-service-engine 0.2.3 → 0.2.5

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@timeax/digital-service-engine",
3
- "version": "0.2.3",
3
+ "version": "0.2.5",
4
4
  "description": "Headless service props builder + minimal React Flow workspace.",
5
5
  "type": "module",
6
6
  "exports": {
@@ -29,10 +29,11 @@
29
29
  "import": "./dist/workspace/index.js",
30
30
  "require": "./dist/workspace/index.cjs"
31
31
  },
32
- "./json/service-props": "./schema/service-props.schema.json",
33
- "./json/editor-snapshot": "./schema/editor-snapshot.schema.json",
34
- "./json/policies": "./schema/policies.schema.json"
35
- },
32
+ "./json/service-props": "./schema/service-props.schema.json",
33
+ "./json/editor-snapshot": "./schema/editor-snapshot.schema.json",
34
+ "./json/order-snapshot": "./schema/order-snapshot.schema.json",
35
+ "./json/policies": "./schema/policies.schema.json"
36
+ },
36
37
  "types": "./dist/schema/index.d.ts",
37
38
  "files": [
38
39
  "dist/",
@@ -41,6 +41,12 @@
41
41
  }
42
42
  }
43
43
  },
44
+ "orderKinds": {
45
+ "type": "object",
46
+ "additionalProperties": {
47
+ "type": "string"
48
+ }
49
+ },
44
50
  "filters": {
45
51
  "type": "array",
46
52
  "items": {
@@ -0,0 +1,667 @@
1
+ {
2
+ "$schema": "http://json-schema.org/draft-07/schema#",
3
+ "$ref": "#/definitions/OrderSnapshot",
4
+ "definitions": {
5
+ "OrderSnapshot": {
6
+ "type": "object",
7
+ "properties": {
8
+ "version": {
9
+ "type": "string",
10
+ "const": "1"
11
+ },
12
+ "mode": {
13
+ "type": "string",
14
+ "enum": [
15
+ "prod",
16
+ "dev"
17
+ ]
18
+ },
19
+ "builtAt": {
20
+ "type": "string"
21
+ },
22
+ "selection": {
23
+ "type": "object",
24
+ "properties": {
25
+ "tag": {
26
+ "type": "string"
27
+ },
28
+ "buttons": {
29
+ "type": "array",
30
+ "items": {
31
+ "type": "string"
32
+ }
33
+ },
34
+ "fields": {
35
+ "type": "array",
36
+ "items": {
37
+ "type": "object",
38
+ "properties": {
39
+ "id": {
40
+ "type": "string"
41
+ },
42
+ "type": {
43
+ "type": "string"
44
+ },
45
+ "selectedOptions": {
46
+ "type": "array",
47
+ "items": {
48
+ "type": "string"
49
+ }
50
+ }
51
+ },
52
+ "required": [
53
+ "id",
54
+ "type"
55
+ ]
56
+ }
57
+ }
58
+ },
59
+ "required": [
60
+ "tag",
61
+ "buttons",
62
+ "fields"
63
+ ]
64
+ },
65
+ "inputs": {
66
+ "type": "object",
67
+ "properties": {
68
+ "form": {
69
+ "type": "object",
70
+ "additionalProperties": {
71
+ "anyOf": [
72
+ {
73
+ "$ref": "#/definitions/Scalar"
74
+ },
75
+ {
76
+ "type": "array",
77
+ "items": {
78
+ "$ref": "#/definitions/Scalar"
79
+ }
80
+ }
81
+ ]
82
+ }
83
+ },
84
+ "selections": {
85
+ "type": "object",
86
+ "additionalProperties": {
87
+ "type": "array",
88
+ "items": {
89
+ "type": "string"
90
+ }
91
+ }
92
+ }
93
+ },
94
+ "required": [
95
+ "form",
96
+ "selections"
97
+ ]
98
+ },
99
+ "quantity": {
100
+ "type": "number"
101
+ },
102
+ "quantitySource": {
103
+ "type": "object",
104
+ "properties": {
105
+ "kind": {
106
+ "type": "string",
107
+ "enum": [
108
+ "field",
109
+ "tag",
110
+ "option",
111
+ "default"
112
+ ]
113
+ },
114
+ "id": {
115
+ "type": "string"
116
+ },
117
+ "rule": {
118
+ "$ref": "#/definitions/QuantityRule"
119
+ },
120
+ "defaultedFromHost": {
121
+ "type": "boolean"
122
+ }
123
+ },
124
+ "required": [
125
+ "kind"
126
+ ]
127
+ },
128
+ "min": {
129
+ "type": "number"
130
+ },
131
+ "max": {
132
+ "type": "number"
133
+ },
134
+ "orderKind": {
135
+ "type": [
136
+ "string",
137
+ "null"
138
+ ]
139
+ },
140
+ "orderKindSource": {
141
+ "anyOf": [
142
+ {
143
+ "$ref": "#/definitions/OrderKindSource"
144
+ },
145
+ {
146
+ "type": "null"
147
+ }
148
+ ]
149
+ },
150
+ "services": {
151
+ "type": "array",
152
+ "items": {
153
+ "type": [
154
+ "string",
155
+ "number"
156
+ ]
157
+ }
158
+ },
159
+ "serviceMap": {
160
+ "type": "object",
161
+ "additionalProperties": {
162
+ "type": "array",
163
+ "items": {
164
+ "type": [
165
+ "string",
166
+ "number"
167
+ ]
168
+ }
169
+ }
170
+ },
171
+ "fallbacks": {
172
+ "$ref": "#/definitions/ServiceFallbacks"
173
+ },
174
+ "utilities": {
175
+ "type": "array",
176
+ "items": {
177
+ "$ref": "#/definitions/UtilityLineItem"
178
+ }
179
+ },
180
+ "warnings": {
181
+ "type": "object",
182
+ "properties": {
183
+ "utility": {
184
+ "type": "array",
185
+ "items": {
186
+ "type": "object",
187
+ "properties": {
188
+ "nodeId": {
189
+ "type": "string"
190
+ },
191
+ "reason": {
192
+ "type": "string"
193
+ }
194
+ },
195
+ "required": [
196
+ "nodeId",
197
+ "reason"
198
+ ]
199
+ }
200
+ },
201
+ "fallbacks": {
202
+ "type": "array",
203
+ "items": {
204
+ "$ref": "#/definitions/FallbackDiagnostics"
205
+ }
206
+ }
207
+ }
208
+ },
209
+ "meta": {
210
+ "type": "object",
211
+ "properties": {
212
+ "schema_version": {
213
+ "type": "string"
214
+ },
215
+ "workspaceId": {
216
+ "type": "string"
217
+ },
218
+ "builder": {
219
+ "type": "object",
220
+ "properties": {
221
+ "commit": {
222
+ "type": "string"
223
+ }
224
+ }
225
+ },
226
+ "context": {
227
+ "$ref": "#/definitions/SnapshotContext"
228
+ }
229
+ }
230
+ }
231
+ },
232
+ "required": [
233
+ "version",
234
+ "mode",
235
+ "builtAt",
236
+ "selection",
237
+ "inputs",
238
+ "quantity",
239
+ "quantitySource",
240
+ "min",
241
+ "max",
242
+ "services",
243
+ "serviceMap"
244
+ ]
245
+ },
246
+ "Scalar": {
247
+ "anyOf": [
248
+ {
249
+ "type": "string"
250
+ },
251
+ {
252
+ "type": "number"
253
+ },
254
+ {
255
+ "type": "boolean"
256
+ },
257
+ {
258
+ "$ref": "#/definitions/ButtonValue"
259
+ },
260
+ {
261
+ "type": "null"
262
+ }
263
+ ]
264
+ },
265
+ "ButtonValue": {
266
+ "type": "object",
267
+ "properties": {
268
+ "id": {
269
+ "type": "string"
270
+ },
271
+ "value": {
272
+ "type": [
273
+ "string",
274
+ "number"
275
+ ]
276
+ },
277
+ "service_id": {
278
+ "$ref": "#/definitions/ServiceIdRef"
279
+ },
280
+ "pricing_role": {
281
+ "type": "string",
282
+ "enum": [
283
+ "base",
284
+ "utility"
285
+ ]
286
+ },
287
+ "meta": {
288
+ "type": "object",
289
+ "properties": {
290
+ "quantityDefault": {
291
+ "type": "number"
292
+ },
293
+ "utility": {
294
+ "type": "object",
295
+ "properties": {
296
+ "rate": {
297
+ "type": "number"
298
+ },
299
+ "mode": {
300
+ "type": "string",
301
+ "enum": [
302
+ "flat",
303
+ "per_quantity",
304
+ "per_value",
305
+ "percent"
306
+ ]
307
+ },
308
+ "valueBy": {
309
+ "type": "string",
310
+ "enum": [
311
+ "value",
312
+ "length"
313
+ ]
314
+ },
315
+ "percentBase": {
316
+ "type": "string",
317
+ "enum": [
318
+ "service_total",
319
+ "base_service",
320
+ "all"
321
+ ]
322
+ },
323
+ "label": {
324
+ "type": "string"
325
+ }
326
+ },
327
+ "required": [
328
+ "rate",
329
+ "mode"
330
+ ]
331
+ }
332
+ }
333
+ }
334
+ },
335
+ "required": [
336
+ "id",
337
+ "value"
338
+ ]
339
+ },
340
+ "ServiceIdRef": {
341
+ "$ref": "#/definitions/IdType"
342
+ },
343
+ "IdType": {
344
+ "type": [
345
+ "string",
346
+ "number"
347
+ ]
348
+ },
349
+ "QuantityRule": {
350
+ "type": "object",
351
+ "properties": {
352
+ "valueBy": {
353
+ "type": "string",
354
+ "enum": [
355
+ "value",
356
+ "length",
357
+ "eval"
358
+ ]
359
+ },
360
+ "code": {
361
+ "type": "string"
362
+ },
363
+ "multiply": {
364
+ "type": "number"
365
+ },
366
+ "clamp": {
367
+ "type": "object",
368
+ "properties": {
369
+ "min": {
370
+ "type": "number"
371
+ },
372
+ "max": {
373
+ "type": "number"
374
+ }
375
+ }
376
+ },
377
+ "fallback": {
378
+ "type": "number"
379
+ }
380
+ },
381
+ "required": [
382
+ "valueBy"
383
+ ]
384
+ },
385
+ "OrderKindSource": {
386
+ "type": "object",
387
+ "properties": {
388
+ "nodeId": {
389
+ "type": "string"
390
+ },
391
+ "nodeKind": {
392
+ "type": "string",
393
+ "enum": [
394
+ "tag",
395
+ "field",
396
+ "option"
397
+ ]
398
+ }
399
+ },
400
+ "required": [
401
+ "nodeId",
402
+ "nodeKind"
403
+ ]
404
+ },
405
+ "ServiceFallbacks": {
406
+ "$ref": "#/definitions/ServiceFallback"
407
+ },
408
+ "ServiceFallback": {
409
+ "type": "object",
410
+ "properties": {
411
+ "nodes": {
412
+ "type": "object",
413
+ "additionalProperties": {
414
+ "type": "array",
415
+ "items": {
416
+ "$ref": "#/definitions/ServiceIdRef"
417
+ }
418
+ },
419
+ "description": "Node-scoped fallbacks: prefer these when that node’s primary service fails"
420
+ },
421
+ "global": {
422
+ "type": "object",
423
+ "additionalProperties": {
424
+ "type": "array",
425
+ "items": {
426
+ "$ref": "#/definitions/ServiceIdRef"
427
+ }
428
+ },
429
+ "description": "Primary→fallback list used when no node-scoped entry is present"
430
+ }
431
+ }
432
+ },
433
+ "UtilityLineItem": {
434
+ "type": "object",
435
+ "properties": {
436
+ "nodeId": {
437
+ "type": "string"
438
+ },
439
+ "mode": {
440
+ "$ref": "#/definitions/UtilityMode"
441
+ },
442
+ "rate": {
443
+ "type": "number"
444
+ },
445
+ "percentBase": {
446
+ "type": "string",
447
+ "enum": [
448
+ "service_total",
449
+ "base_service",
450
+ "all"
451
+ ]
452
+ },
453
+ "label": {
454
+ "type": "string"
455
+ },
456
+ "inputs": {
457
+ "type": "object",
458
+ "properties": {
459
+ "quantity": {
460
+ "type": "number"
461
+ },
462
+ "value": {
463
+ "anyOf": [
464
+ {
465
+ "$ref": "#/definitions/Scalar"
466
+ },
467
+ {
468
+ "type": "array",
469
+ "items": {
470
+ "$ref": "#/definitions/Scalar"
471
+ }
472
+ }
473
+ ]
474
+ },
475
+ "valueBy": {
476
+ "type": "string",
477
+ "enum": [
478
+ "value",
479
+ "length"
480
+ ]
481
+ }
482
+ },
483
+ "required": [
484
+ "quantity"
485
+ ]
486
+ }
487
+ },
488
+ "required": [
489
+ "nodeId",
490
+ "mode",
491
+ "rate",
492
+ "inputs"
493
+ ]
494
+ },
495
+ "UtilityMode": {
496
+ "type": "string",
497
+ "enum": [
498
+ "flat",
499
+ "per_quantity",
500
+ "per_value",
501
+ "percent"
502
+ ]
503
+ },
504
+ "FallbackDiagnostics": {
505
+ "type": "object",
506
+ "properties": {
507
+ "scope": {
508
+ "type": "string",
509
+ "enum": [
510
+ "node",
511
+ "global"
512
+ ]
513
+ },
514
+ "nodeId": {
515
+ "type": "string"
516
+ },
517
+ "primary": {
518
+ "type": [
519
+ "string",
520
+ "number"
521
+ ]
522
+ },
523
+ "candidate": {
524
+ "type": [
525
+ "string",
526
+ "number"
527
+ ]
528
+ },
529
+ "reasons": {
530
+ "type": "array",
531
+ "items": {
532
+ "type": "string",
533
+ "enum": [
534
+ "rate_violation",
535
+ "constraint_mismatch",
536
+ "unknown_service",
537
+ "ambiguous_context"
538
+ ]
539
+ }
540
+ }
541
+ },
542
+ "required": [
543
+ "scope",
544
+ "primary",
545
+ "candidate",
546
+ "reasons"
547
+ ]
548
+ },
549
+ "SnapshotContext": {
550
+ "type": "object",
551
+ "properties": {
552
+ "tag": {
553
+ "type": "string",
554
+ "description": "The single active tag id for this order"
555
+ },
556
+ "constraints": {
557
+ "type": "object",
558
+ "properties": {
559
+ "refill": {
560
+ "type": "boolean"
561
+ },
562
+ "cancel": {
563
+ "type": "boolean"
564
+ },
565
+ "dripfeed": {
566
+ "type": "boolean"
567
+ }
568
+ },
569
+ "description": "Effective (post-propagation) constraints on that tag"
570
+ },
571
+ "nodeContexts": {
572
+ "type": "object",
573
+ "additionalProperties": {
574
+ "type": [
575
+ "string",
576
+ "null"
577
+ ]
578
+ },
579
+ "description": "Per-node evaluation context:\n- For the active tag node itself: the same tag id.\n- For an option node: parent's field.bind_id must include this tag to be applicable; otherwise null.\n- For a field node (optional to include later): same rule as option, derived from field.bind_id."
580
+ },
581
+ "policy": {
582
+ "type": "object",
583
+ "properties": {
584
+ "ratePolicy": {
585
+ "anyOf": [
586
+ {
587
+ "type": "object",
588
+ "properties": {
589
+ "kind": {
590
+ "type": "string",
591
+ "const": "eq_primary"
592
+ }
593
+ },
594
+ "required": [
595
+ "kind"
596
+ ]
597
+ },
598
+ {
599
+ "type": "object",
600
+ "properties": {
601
+ "kind": {
602
+ "type": "string",
603
+ "const": "lte_primary"
604
+ },
605
+ "pct": {
606
+ "type": "number"
607
+ }
608
+ },
609
+ "required": [
610
+ "kind",
611
+ "pct"
612
+ ]
613
+ },
614
+ {
615
+ "type": "object",
616
+ "properties": {
617
+ "kind": {
618
+ "type": "string",
619
+ "const": "within_pct"
620
+ },
621
+ "pct": {
622
+ "type": "number"
623
+ }
624
+ },
625
+ "required": [
626
+ "kind",
627
+ "pct"
628
+ ]
629
+ },
630
+ {
631
+ "type": "object",
632
+ "properties": {
633
+ "kind": {
634
+ "type": "string",
635
+ "const": "at_least_pct_lower"
636
+ },
637
+ "pct": {
638
+ "type": "number"
639
+ }
640
+ },
641
+ "required": [
642
+ "kind",
643
+ "pct"
644
+ ]
645
+ }
646
+ ]
647
+ },
648
+ "requireConstraintFit": {
649
+ "type": "boolean"
650
+ }
651
+ },
652
+ "required": [
653
+ "ratePolicy",
654
+ "requireConstraintFit"
655
+ ],
656
+ "description": "Client pruning policy used (so server can mirror/compare)."
657
+ }
658
+ },
659
+ "required": [
660
+ "tag",
661
+ "constraints",
662
+ "nodeContexts",
663
+ "policy"
664
+ ]
665
+ }
666
+ }
667
+ }
@@ -14,6 +14,12 @@
14
14
  }
15
15
  }
16
16
  },
17
+ "orderKinds": {
18
+ "type": "object",
19
+ "additionalProperties": {
20
+ "type": "string"
21
+ }
22
+ },
17
23
  "filters": {
18
24
  "type": "array",
19
25
  "items": {