@hyperscale0/udl 1.0.0-alpha.4 → 1.0.0-alpha.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/CHANGELOG.md +50 -1
- package/README.md +4 -1
- package/dist/evolution.d.ts +17 -0
- package/dist/evolution.d.ts.map +1 -1
- package/dist/evolution.js +54 -0
- package/dist/evolution.js.map +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/schema.d.ts +207 -0
- package/dist/schema.d.ts.map +1 -1
- package/dist/schema.js +205 -1
- package/dist/schema.js.map +1 -1
- package/dist/validation.d.ts +6 -0
- package/dist/validation.d.ts.map +1 -1
- package/dist/validation.js +323 -14
- package/dist/validation.js.map +1 -1
- package/package.json +1 -1
- package/spec/README.md +8 -5
- package/spec/udl.schema.json +289 -0
- package/src/evolution.ts +99 -0
- package/src/index.ts +4 -0
- package/src/schema.ts +238 -1
- package/src/validation.ts +504 -19
package/dist/schema.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
export declare const UDL_FORMAT_VERSION: 1;
|
|
3
|
+
export declare const udlPublicIntentSchema: z.ZodString;
|
|
3
4
|
declare const udlDeclaredValuePolicySchema: z.ZodEnum<{
|
|
4
5
|
optional: "optional";
|
|
5
6
|
required: "required";
|
|
@@ -171,7 +172,21 @@ declare const udlAggregateConditionSchema: z.ZodObject<{
|
|
|
171
172
|
refField: z.ZodString;
|
|
172
173
|
statuses: z.ZodArray<z.ZodString>;
|
|
173
174
|
}, z.core.$strict>;
|
|
175
|
+
declare const udlPayoutSchema: z.ZodObject<{
|
|
176
|
+
amount: z.ZodString;
|
|
177
|
+
beneficiaryField: z.ZodString;
|
|
178
|
+
beneficiaryPartyField: z.ZodString;
|
|
179
|
+
capture: z.ZodString;
|
|
180
|
+
currencyField: z.ZodString;
|
|
181
|
+
sourceAccountField: z.ZodString;
|
|
182
|
+
speed: z.ZodLiteral<"standard">;
|
|
183
|
+
}, z.core.$strict>;
|
|
184
|
+
declare const udlRequiresSettlementSchema: z.ZodObject<{
|
|
185
|
+
capture: z.ZodString;
|
|
186
|
+
payoutRef: z.ZodString;
|
|
187
|
+
}, z.core.$strict>;
|
|
174
188
|
declare const udlVerbSchema: z.ZodObject<{
|
|
189
|
+
captureInput: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
175
190
|
deadline: z.ZodOptional<z.ZodObject<{
|
|
176
191
|
field: z.ZodString;
|
|
177
192
|
offset: z.ZodOptional<z.ZodString>;
|
|
@@ -181,6 +196,20 @@ declare const udlVerbSchema: z.ZodObject<{
|
|
|
181
196
|
deadlineMs: z.ZodNumber;
|
|
182
197
|
onTimeout: z.ZodLiteral<"decline">;
|
|
183
198
|
}, z.core.$strict>>;
|
|
199
|
+
distribute: z.ZodOptional<z.ZodObject<{
|
|
200
|
+
amountRef: z.ZodString;
|
|
201
|
+
onZero: z.ZodEnum<{
|
|
202
|
+
refuse: "refuse";
|
|
203
|
+
skip_steps: "skip_steps";
|
|
204
|
+
}>;
|
|
205
|
+
pool: z.ZodObject<{
|
|
206
|
+
from: z.ZodLiteral<"parent">;
|
|
207
|
+
path: z.ZodString;
|
|
208
|
+
}, z.core.$strict>;
|
|
209
|
+
refField: z.ZodString;
|
|
210
|
+
statuses: z.ZodArray<z.ZodString>;
|
|
211
|
+
weightField: z.ZodString;
|
|
212
|
+
}, z.core.$strict>>;
|
|
184
213
|
description: z.ZodOptional<z.ZodString>;
|
|
185
214
|
due: z.ZodOptional<z.ZodObject<{
|
|
186
215
|
every: z.ZodOptional<z.ZodObject<{
|
|
@@ -230,6 +259,15 @@ declare const udlVerbSchema: z.ZodObject<{
|
|
|
230
259
|
"internal_transfer.void": "internal_transfer.void";
|
|
231
260
|
}>;
|
|
232
261
|
}, z.core.$strict>>>;
|
|
262
|
+
payout: z.ZodOptional<z.ZodObject<{
|
|
263
|
+
amount: z.ZodString;
|
|
264
|
+
beneficiaryField: z.ZodString;
|
|
265
|
+
beneficiaryPartyField: z.ZodString;
|
|
266
|
+
capture: z.ZodString;
|
|
267
|
+
currencyField: z.ZodString;
|
|
268
|
+
sourceAccountField: z.ZodString;
|
|
269
|
+
speed: z.ZodLiteral<"standard">;
|
|
270
|
+
}, z.core.$strict>>;
|
|
233
271
|
port: z.ZodOptional<z.ZodObject<{
|
|
234
272
|
allowedParties: z.ZodArray<z.ZodEnum<{
|
|
235
273
|
payer: "payer";
|
|
@@ -237,6 +275,7 @@ declare const udlVerbSchema: z.ZodObject<{
|
|
|
237
275
|
subjectHolder: "subjectHolder";
|
|
238
276
|
}>>;
|
|
239
277
|
}, z.core.$strict>>;
|
|
278
|
+
publicIntent: z.ZodOptional<z.ZodString>;
|
|
240
279
|
requiresAggregate: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
241
280
|
check: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
242
281
|
amountField: z.ZodString;
|
|
@@ -274,6 +313,14 @@ declare const udlVerbSchema: z.ZodObject<{
|
|
|
274
313
|
requiresDrainedAccount: z.ZodOptional<z.ZodObject<{
|
|
275
314
|
path: z.ZodString;
|
|
276
315
|
}, z.core.$strict>>;
|
|
316
|
+
requiresExposure: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
317
|
+
amountField: z.ZodString;
|
|
318
|
+
anchorField: z.ZodString;
|
|
319
|
+
capField: z.ZodString;
|
|
320
|
+
capOnAnchor: z.ZodOptional<z.ZodLiteral<true>>;
|
|
321
|
+
childNounId: z.ZodString;
|
|
322
|
+
statuses: z.ZodArray<z.ZodString>;
|
|
323
|
+
}, z.core.$strict>>>;
|
|
277
324
|
requiresRefs: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
278
325
|
bind: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
279
326
|
field: z.ZodString;
|
|
@@ -282,10 +329,34 @@ declare const udlVerbSchema: z.ZodObject<{
|
|
|
282
329
|
statuses: z.ZodArray<z.ZodString>;
|
|
283
330
|
unique: z.ZodOptional<z.ZodLiteral<true>>;
|
|
284
331
|
}, z.core.$strict>>>;
|
|
332
|
+
requiresSettlement: z.ZodOptional<z.ZodObject<{
|
|
333
|
+
capture: z.ZodString;
|
|
334
|
+
payoutRef: z.ZodString;
|
|
335
|
+
}, z.core.$strict>>;
|
|
285
336
|
setsAt: z.ZodOptional<z.ZodObject<{
|
|
286
337
|
field: z.ZodString;
|
|
338
|
+
marker: z.ZodOptional<z.ZodLiteral<true>>;
|
|
287
339
|
offset: z.ZodString;
|
|
288
340
|
}, z.core.$strict>>;
|
|
341
|
+
signedSum: z.ZodOptional<z.ZodObject<{
|
|
342
|
+
amountRef: z.ZodString;
|
|
343
|
+
onNegative: z.ZodLiteral<"refuse">;
|
|
344
|
+
onZero: z.ZodEnum<{
|
|
345
|
+
refuse: "refuse";
|
|
346
|
+
skip_steps: "skip_steps";
|
|
347
|
+
}>;
|
|
348
|
+
sources: z.ZodArray<z.ZodObject<{
|
|
349
|
+
amountField: z.ZodString;
|
|
350
|
+
nounId: z.ZodString;
|
|
351
|
+
refField: z.ZodString;
|
|
352
|
+
sign: z.ZodEnum<{
|
|
353
|
+
add: "add";
|
|
354
|
+
subtract: "subtract";
|
|
355
|
+
}>;
|
|
356
|
+
statuses: z.ZodArray<z.ZodString>;
|
|
357
|
+
subtotalRef: z.ZodString;
|
|
358
|
+
}, z.core.$strict>>;
|
|
359
|
+
}, z.core.$strict>>;
|
|
289
360
|
steps: z.ZodArray<z.ZodObject<{
|
|
290
361
|
bind: z.ZodRecord<z.ZodString, z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
291
362
|
from: z.ZodLiteral<"const">;
|
|
@@ -341,8 +412,18 @@ declare const udlNounSchema: z.ZodObject<{
|
|
|
341
412
|
childStatuses: z.ZodArray<z.ZodString>;
|
|
342
413
|
parentField: z.ZodString;
|
|
343
414
|
}, z.core.$strict>]>>>;
|
|
415
|
+
computedMoneyRefs: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
344
416
|
description: z.ZodOptional<z.ZodString>;
|
|
345
417
|
distinctParties: z.ZodOptional<z.ZodLiteral<true>>;
|
|
418
|
+
derivedAmounts: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
419
|
+
field: z.ZodString;
|
|
420
|
+
rounding: z.ZodLiteral<"floor">;
|
|
421
|
+
rule: z.ZodObject<{
|
|
422
|
+
bps: z.ZodNumber;
|
|
423
|
+
kind: z.ZodLiteral<"percentage_of">;
|
|
424
|
+
}, z.core.$strict>;
|
|
425
|
+
sourceField: z.ZodString;
|
|
426
|
+
}, z.core.$strict>>>;
|
|
346
427
|
fields: z.ZodRecord<z.ZodString, z.ZodRecord<z.ZodString, z.ZodJSONSchema>>;
|
|
347
428
|
id: z.ZodString;
|
|
348
429
|
idPrefix: z.ZodString;
|
|
@@ -385,6 +466,7 @@ declare const udlNounSchema: z.ZodObject<{
|
|
|
385
466
|
states: z.ZodArray<z.ZodString>;
|
|
386
467
|
}, z.core.$strict>>;
|
|
387
468
|
verbs: z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
469
|
+
captureInput: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
388
470
|
deadline: z.ZodOptional<z.ZodObject<{
|
|
389
471
|
field: z.ZodString;
|
|
390
472
|
offset: z.ZodOptional<z.ZodString>;
|
|
@@ -394,6 +476,20 @@ declare const udlNounSchema: z.ZodObject<{
|
|
|
394
476
|
deadlineMs: z.ZodNumber;
|
|
395
477
|
onTimeout: z.ZodLiteral<"decline">;
|
|
396
478
|
}, z.core.$strict>>;
|
|
479
|
+
distribute: z.ZodOptional<z.ZodObject<{
|
|
480
|
+
amountRef: z.ZodString;
|
|
481
|
+
onZero: z.ZodEnum<{
|
|
482
|
+
refuse: "refuse";
|
|
483
|
+
skip_steps: "skip_steps";
|
|
484
|
+
}>;
|
|
485
|
+
pool: z.ZodObject<{
|
|
486
|
+
from: z.ZodLiteral<"parent">;
|
|
487
|
+
path: z.ZodString;
|
|
488
|
+
}, z.core.$strict>;
|
|
489
|
+
refField: z.ZodString;
|
|
490
|
+
statuses: z.ZodArray<z.ZodString>;
|
|
491
|
+
weightField: z.ZodString;
|
|
492
|
+
}, z.core.$strict>>;
|
|
397
493
|
description: z.ZodOptional<z.ZodString>;
|
|
398
494
|
due: z.ZodOptional<z.ZodObject<{
|
|
399
495
|
every: z.ZodOptional<z.ZodObject<{
|
|
@@ -443,6 +539,15 @@ declare const udlNounSchema: z.ZodObject<{
|
|
|
443
539
|
"internal_transfer.void": "internal_transfer.void";
|
|
444
540
|
}>;
|
|
445
541
|
}, z.core.$strict>>>;
|
|
542
|
+
payout: z.ZodOptional<z.ZodObject<{
|
|
543
|
+
amount: z.ZodString;
|
|
544
|
+
beneficiaryField: z.ZodString;
|
|
545
|
+
beneficiaryPartyField: z.ZodString;
|
|
546
|
+
capture: z.ZodString;
|
|
547
|
+
currencyField: z.ZodString;
|
|
548
|
+
sourceAccountField: z.ZodString;
|
|
549
|
+
speed: z.ZodLiteral<"standard">;
|
|
550
|
+
}, z.core.$strict>>;
|
|
446
551
|
port: z.ZodOptional<z.ZodObject<{
|
|
447
552
|
allowedParties: z.ZodArray<z.ZodEnum<{
|
|
448
553
|
payer: "payer";
|
|
@@ -450,6 +555,7 @@ declare const udlNounSchema: z.ZodObject<{
|
|
|
450
555
|
subjectHolder: "subjectHolder";
|
|
451
556
|
}>>;
|
|
452
557
|
}, z.core.$strict>>;
|
|
558
|
+
publicIntent: z.ZodOptional<z.ZodString>;
|
|
453
559
|
requiresAggregate: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
454
560
|
check: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
455
561
|
amountField: z.ZodString;
|
|
@@ -487,6 +593,14 @@ declare const udlNounSchema: z.ZodObject<{
|
|
|
487
593
|
requiresDrainedAccount: z.ZodOptional<z.ZodObject<{
|
|
488
594
|
path: z.ZodString;
|
|
489
595
|
}, z.core.$strict>>;
|
|
596
|
+
requiresExposure: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
597
|
+
amountField: z.ZodString;
|
|
598
|
+
anchorField: z.ZodString;
|
|
599
|
+
capField: z.ZodString;
|
|
600
|
+
capOnAnchor: z.ZodOptional<z.ZodLiteral<true>>;
|
|
601
|
+
childNounId: z.ZodString;
|
|
602
|
+
statuses: z.ZodArray<z.ZodString>;
|
|
603
|
+
}, z.core.$strict>>>;
|
|
490
604
|
requiresRefs: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
491
605
|
bind: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
492
606
|
field: z.ZodString;
|
|
@@ -495,10 +609,34 @@ declare const udlNounSchema: z.ZodObject<{
|
|
|
495
609
|
statuses: z.ZodArray<z.ZodString>;
|
|
496
610
|
unique: z.ZodOptional<z.ZodLiteral<true>>;
|
|
497
611
|
}, z.core.$strict>>>;
|
|
612
|
+
requiresSettlement: z.ZodOptional<z.ZodObject<{
|
|
613
|
+
capture: z.ZodString;
|
|
614
|
+
payoutRef: z.ZodString;
|
|
615
|
+
}, z.core.$strict>>;
|
|
498
616
|
setsAt: z.ZodOptional<z.ZodObject<{
|
|
499
617
|
field: z.ZodString;
|
|
618
|
+
marker: z.ZodOptional<z.ZodLiteral<true>>;
|
|
500
619
|
offset: z.ZodString;
|
|
501
620
|
}, z.core.$strict>>;
|
|
621
|
+
signedSum: z.ZodOptional<z.ZodObject<{
|
|
622
|
+
amountRef: z.ZodString;
|
|
623
|
+
onNegative: z.ZodLiteral<"refuse">;
|
|
624
|
+
onZero: z.ZodEnum<{
|
|
625
|
+
refuse: "refuse";
|
|
626
|
+
skip_steps: "skip_steps";
|
|
627
|
+
}>;
|
|
628
|
+
sources: z.ZodArray<z.ZodObject<{
|
|
629
|
+
amountField: z.ZodString;
|
|
630
|
+
nounId: z.ZodString;
|
|
631
|
+
refField: z.ZodString;
|
|
632
|
+
sign: z.ZodEnum<{
|
|
633
|
+
add: "add";
|
|
634
|
+
subtract: "subtract";
|
|
635
|
+
}>;
|
|
636
|
+
statuses: z.ZodArray<z.ZodString>;
|
|
637
|
+
subtotalRef: z.ZodString;
|
|
638
|
+
}, z.core.$strict>>;
|
|
639
|
+
}, z.core.$strict>>;
|
|
502
640
|
steps: z.ZodArray<z.ZodObject<{
|
|
503
641
|
bind: z.ZodRecord<z.ZodString, z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
504
642
|
from: z.ZodLiteral<"const">;
|
|
@@ -539,8 +677,18 @@ export declare const udlDocumentSchema: z.ZodObject<{
|
|
|
539
677
|
childStatuses: z.ZodArray<z.ZodString>;
|
|
540
678
|
parentField: z.ZodString;
|
|
541
679
|
}, z.core.$strict>]>>>;
|
|
680
|
+
computedMoneyRefs: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
542
681
|
description: z.ZodOptional<z.ZodString>;
|
|
543
682
|
distinctParties: z.ZodOptional<z.ZodLiteral<true>>;
|
|
683
|
+
derivedAmounts: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
684
|
+
field: z.ZodString;
|
|
685
|
+
rounding: z.ZodLiteral<"floor">;
|
|
686
|
+
rule: z.ZodObject<{
|
|
687
|
+
bps: z.ZodNumber;
|
|
688
|
+
kind: z.ZodLiteral<"percentage_of">;
|
|
689
|
+
}, z.core.$strict>;
|
|
690
|
+
sourceField: z.ZodString;
|
|
691
|
+
}, z.core.$strict>>>;
|
|
544
692
|
fields: z.ZodRecord<z.ZodString, z.ZodRecord<z.ZodString, z.ZodJSONSchema>>;
|
|
545
693
|
id: z.ZodString;
|
|
546
694
|
idPrefix: z.ZodString;
|
|
@@ -583,6 +731,7 @@ export declare const udlDocumentSchema: z.ZodObject<{
|
|
|
583
731
|
states: z.ZodArray<z.ZodString>;
|
|
584
732
|
}, z.core.$strict>>;
|
|
585
733
|
verbs: z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
734
|
+
captureInput: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
586
735
|
deadline: z.ZodOptional<z.ZodObject<{
|
|
587
736
|
field: z.ZodString;
|
|
588
737
|
offset: z.ZodOptional<z.ZodString>;
|
|
@@ -592,6 +741,20 @@ export declare const udlDocumentSchema: z.ZodObject<{
|
|
|
592
741
|
deadlineMs: z.ZodNumber;
|
|
593
742
|
onTimeout: z.ZodLiteral<"decline">;
|
|
594
743
|
}, z.core.$strict>>;
|
|
744
|
+
distribute: z.ZodOptional<z.ZodObject<{
|
|
745
|
+
amountRef: z.ZodString;
|
|
746
|
+
onZero: z.ZodEnum<{
|
|
747
|
+
refuse: "refuse";
|
|
748
|
+
skip_steps: "skip_steps";
|
|
749
|
+
}>;
|
|
750
|
+
pool: z.ZodObject<{
|
|
751
|
+
from: z.ZodLiteral<"parent">;
|
|
752
|
+
path: z.ZodString;
|
|
753
|
+
}, z.core.$strict>;
|
|
754
|
+
refField: z.ZodString;
|
|
755
|
+
statuses: z.ZodArray<z.ZodString>;
|
|
756
|
+
weightField: z.ZodString;
|
|
757
|
+
}, z.core.$strict>>;
|
|
595
758
|
description: z.ZodOptional<z.ZodString>;
|
|
596
759
|
due: z.ZodOptional<z.ZodObject<{
|
|
597
760
|
every: z.ZodOptional<z.ZodObject<{
|
|
@@ -641,6 +804,15 @@ export declare const udlDocumentSchema: z.ZodObject<{
|
|
|
641
804
|
"internal_transfer.void": "internal_transfer.void";
|
|
642
805
|
}>;
|
|
643
806
|
}, z.core.$strict>>>;
|
|
807
|
+
payout: z.ZodOptional<z.ZodObject<{
|
|
808
|
+
amount: z.ZodString;
|
|
809
|
+
beneficiaryField: z.ZodString;
|
|
810
|
+
beneficiaryPartyField: z.ZodString;
|
|
811
|
+
capture: z.ZodString;
|
|
812
|
+
currencyField: z.ZodString;
|
|
813
|
+
sourceAccountField: z.ZodString;
|
|
814
|
+
speed: z.ZodLiteral<"standard">;
|
|
815
|
+
}, z.core.$strict>>;
|
|
644
816
|
port: z.ZodOptional<z.ZodObject<{
|
|
645
817
|
allowedParties: z.ZodArray<z.ZodEnum<{
|
|
646
818
|
payer: "payer";
|
|
@@ -648,6 +820,7 @@ export declare const udlDocumentSchema: z.ZodObject<{
|
|
|
648
820
|
subjectHolder: "subjectHolder";
|
|
649
821
|
}>>;
|
|
650
822
|
}, z.core.$strict>>;
|
|
823
|
+
publicIntent: z.ZodOptional<z.ZodString>;
|
|
651
824
|
requiresAggregate: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
652
825
|
check: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
653
826
|
amountField: z.ZodString;
|
|
@@ -685,6 +858,14 @@ export declare const udlDocumentSchema: z.ZodObject<{
|
|
|
685
858
|
requiresDrainedAccount: z.ZodOptional<z.ZodObject<{
|
|
686
859
|
path: z.ZodString;
|
|
687
860
|
}, z.core.$strict>>;
|
|
861
|
+
requiresExposure: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
862
|
+
amountField: z.ZodString;
|
|
863
|
+
anchorField: z.ZodString;
|
|
864
|
+
capField: z.ZodString;
|
|
865
|
+
capOnAnchor: z.ZodOptional<z.ZodLiteral<true>>;
|
|
866
|
+
childNounId: z.ZodString;
|
|
867
|
+
statuses: z.ZodArray<z.ZodString>;
|
|
868
|
+
}, z.core.$strict>>>;
|
|
688
869
|
requiresRefs: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
689
870
|
bind: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
690
871
|
field: z.ZodString;
|
|
@@ -693,10 +874,34 @@ export declare const udlDocumentSchema: z.ZodObject<{
|
|
|
693
874
|
statuses: z.ZodArray<z.ZodString>;
|
|
694
875
|
unique: z.ZodOptional<z.ZodLiteral<true>>;
|
|
695
876
|
}, z.core.$strict>>>;
|
|
877
|
+
requiresSettlement: z.ZodOptional<z.ZodObject<{
|
|
878
|
+
capture: z.ZodString;
|
|
879
|
+
payoutRef: z.ZodString;
|
|
880
|
+
}, z.core.$strict>>;
|
|
696
881
|
setsAt: z.ZodOptional<z.ZodObject<{
|
|
697
882
|
field: z.ZodString;
|
|
883
|
+
marker: z.ZodOptional<z.ZodLiteral<true>>;
|
|
698
884
|
offset: z.ZodString;
|
|
699
885
|
}, z.core.$strict>>;
|
|
886
|
+
signedSum: z.ZodOptional<z.ZodObject<{
|
|
887
|
+
amountRef: z.ZodString;
|
|
888
|
+
onNegative: z.ZodLiteral<"refuse">;
|
|
889
|
+
onZero: z.ZodEnum<{
|
|
890
|
+
refuse: "refuse";
|
|
891
|
+
skip_steps: "skip_steps";
|
|
892
|
+
}>;
|
|
893
|
+
sources: z.ZodArray<z.ZodObject<{
|
|
894
|
+
amountField: z.ZodString;
|
|
895
|
+
nounId: z.ZodString;
|
|
896
|
+
refField: z.ZodString;
|
|
897
|
+
sign: z.ZodEnum<{
|
|
898
|
+
add: "add";
|
|
899
|
+
subtract: "subtract";
|
|
900
|
+
}>;
|
|
901
|
+
statuses: z.ZodArray<z.ZodString>;
|
|
902
|
+
subtotalRef: z.ZodString;
|
|
903
|
+
}, z.core.$strict>>;
|
|
904
|
+
}, z.core.$strict>>;
|
|
700
905
|
steps: z.ZodArray<z.ZodObject<{
|
|
701
906
|
bind: z.ZodRecord<z.ZodString, z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
702
907
|
from: z.ZodLiteral<"const">;
|
|
@@ -749,6 +954,8 @@ export type UdlLifecycleTransition = z.infer<typeof udlLifecycleTransitionSchema
|
|
|
749
954
|
export type UdlNoun = z.infer<typeof udlNounSchema>;
|
|
750
955
|
export type UdlNounSubject = z.infer<typeof udlNounSubjectSchema>;
|
|
751
956
|
export type UdlMove = z.infer<typeof udlMoveSchema>;
|
|
957
|
+
export type UdlPayout = z.infer<typeof udlPayoutSchema>;
|
|
958
|
+
export type UdlRequiresSettlement = z.infer<typeof udlRequiresSettlementSchema>;
|
|
752
959
|
export type UdlStep = z.infer<typeof udlStepSchema>;
|
|
753
960
|
export type UdlSubject = z.infer<typeof udlSubjectSchema>;
|
|
754
961
|
export type UdlUnwind = z.infer<typeof udlUnwindSchema>;
|
package/dist/schema.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../src/schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,eAAO,MAAM,kBAAkB,EAAG,CAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../src/schema.ts"],"names":[],"mappings":"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"}
|
package/dist/schema.js
CHANGED
|
@@ -14,12 +14,18 @@ const udlVerbNameSchema = z
|
|
|
14
14
|
const udlFieldNameSchema = z
|
|
15
15
|
.string()
|
|
16
16
|
.regex(camelCasePattern, "must be a camelCase field name");
|
|
17
|
+
export const udlPublicIntentSchema = z
|
|
18
|
+
.string()
|
|
19
|
+
.regex(camelCasePattern, "must be a camelCase public intent name");
|
|
17
20
|
const nonEmptyTextSchema = z
|
|
18
21
|
.string()
|
|
19
22
|
.refine((value) => value.trim().length > 0, "must not be blank");
|
|
20
23
|
const fieldPathSchema = z
|
|
21
24
|
.string()
|
|
22
25
|
.regex(fieldPathPattern, "must be a dot-separated camelCase field path");
|
|
26
|
+
const instanceValuePathSchema = z
|
|
27
|
+
.string()
|
|
28
|
+
.regex(/^(?:fields|refs)\.[a-z][A-Za-z0-9]*$/, "must name one declared fields.* or refs.* value");
|
|
23
29
|
const jsonObjectSchema = z.record(z.string(), z.json());
|
|
24
30
|
const stringMapSchema = z.record(nonEmptyTextSchema, nonEmptyTextSchema);
|
|
25
31
|
const udlDeclaredValuePolicySchema = z.enum(["required", "optional", "none"]);
|
|
@@ -117,6 +123,7 @@ const udlDeadlineSchema = z.strictObject({
|
|
|
117
123
|
});
|
|
118
124
|
const udlSetsAtSchema = z.strictObject({
|
|
119
125
|
field: udlFieldNameSchema,
|
|
126
|
+
marker: z.literal(true).optional(),
|
|
120
127
|
offset: nonEmptyTextSchema,
|
|
121
128
|
});
|
|
122
129
|
const udlUnwindPenaltySchema = z.strictObject({
|
|
@@ -186,6 +193,14 @@ const udlAggregateConditionSchema = z.strictObject({
|
|
|
186
193
|
refField: udlFieldNameSchema,
|
|
187
194
|
statuses: z.array(udlSnakeCaseSchema).min(1),
|
|
188
195
|
});
|
|
196
|
+
const udlExposureRequirementSchema = z.strictObject({
|
|
197
|
+
amountField: udlFieldNameSchema,
|
|
198
|
+
anchorField: udlFieldNameSchema,
|
|
199
|
+
capField: udlFieldNameSchema,
|
|
200
|
+
capOnAnchor: z.literal(true).optional(),
|
|
201
|
+
childNounId: udlSnakeCaseSchema,
|
|
202
|
+
statuses: z.array(udlSnakeCaseSchema).min(1),
|
|
203
|
+
});
|
|
189
204
|
// The tenant-backend decision port: the verb's caller asserts the acting
|
|
190
205
|
// party, checked at admission against the noun's party bindings for the
|
|
191
206
|
// allowed roles.
|
|
@@ -194,6 +209,44 @@ const udlPortSchema = z.strictObject({
|
|
|
194
209
|
.array(z.enum(["payer", "beneficiary", "subjectHolder"]))
|
|
195
210
|
.min(1),
|
|
196
211
|
});
|
|
212
|
+
const udlPayoutSchema = z.strictObject({
|
|
213
|
+
amount: instanceValuePathSchema,
|
|
214
|
+
beneficiaryField: udlFieldNameSchema,
|
|
215
|
+
beneficiaryPartyField: udlFieldNameSchema,
|
|
216
|
+
capture: udlFieldNameSchema,
|
|
217
|
+
currencyField: udlFieldNameSchema,
|
|
218
|
+
sourceAccountField: udlFieldNameSchema,
|
|
219
|
+
speed: z.literal("standard"),
|
|
220
|
+
});
|
|
221
|
+
const udlRequiresSettlementSchema = z.strictObject({
|
|
222
|
+
capture: udlFieldNameSchema,
|
|
223
|
+
payoutRef: udlFieldNameSchema,
|
|
224
|
+
});
|
|
225
|
+
const udlSignedSumSourceSchema = z.strictObject({
|
|
226
|
+
amountField: udlFieldNameSchema,
|
|
227
|
+
nounId: udlSnakeCaseSchema,
|
|
228
|
+
refField: udlFieldNameSchema,
|
|
229
|
+
sign: z.enum(["add", "subtract"]),
|
|
230
|
+
statuses: z.array(udlSnakeCaseSchema).min(1),
|
|
231
|
+
subtotalRef: udlFieldNameSchema,
|
|
232
|
+
});
|
|
233
|
+
const udlSignedSumSchema = z.strictObject({
|
|
234
|
+
amountRef: udlFieldNameSchema,
|
|
235
|
+
onNegative: z.literal("refuse"),
|
|
236
|
+
onZero: z.enum(["refuse", "skip_steps"]),
|
|
237
|
+
sources: z.array(udlSignedSumSourceSchema).min(1),
|
|
238
|
+
});
|
|
239
|
+
const udlDistributeSchema = z.strictObject({
|
|
240
|
+
amountRef: udlFieldNameSchema,
|
|
241
|
+
onZero: z.enum(["refuse", "skip_steps"]),
|
|
242
|
+
pool: z.strictObject({
|
|
243
|
+
from: z.literal("parent"),
|
|
244
|
+
path: fieldPathSchema,
|
|
245
|
+
}),
|
|
246
|
+
refField: udlFieldNameSchema,
|
|
247
|
+
statuses: z.array(udlSnakeCaseSchema).min(1),
|
|
248
|
+
weightField: udlFieldNameSchema,
|
|
249
|
+
});
|
|
197
250
|
// A same-instance conservation law: the piece fields (money, minor units)
|
|
198
251
|
// must sum exactly to the total field; admission refuses a create whose
|
|
199
252
|
// pieces diverge.
|
|
@@ -201,9 +254,20 @@ const udlPartitionSchema = z.strictObject({
|
|
|
201
254
|
pieceFields: z.array(udlFieldNameSchema).min(2),
|
|
202
255
|
totalField: udlFieldNameSchema,
|
|
203
256
|
});
|
|
257
|
+
const udlDerivedAmountSchema = z.strictObject({
|
|
258
|
+
field: udlFieldNameSchema,
|
|
259
|
+
rounding: z.literal("floor"),
|
|
260
|
+
rule: z.strictObject({
|
|
261
|
+
bps: z.number().int().min(1).max(9_999),
|
|
262
|
+
kind: z.literal("percentage_of"),
|
|
263
|
+
}),
|
|
264
|
+
sourceField: udlFieldNameSchema,
|
|
265
|
+
});
|
|
204
266
|
const udlVerbSchema = z.strictObject({
|
|
267
|
+
captureInput: z.record(udlFieldNameSchema, udlFieldNameSchema).optional(),
|
|
205
268
|
deadline: udlDeadlineSchema.optional(),
|
|
206
269
|
decision: udlDecisionSchema.optional(),
|
|
270
|
+
distribute: udlDistributeSchema.optional(),
|
|
207
271
|
description: nonEmptyTextSchema.optional(),
|
|
208
272
|
due: udlDueSchema.optional(),
|
|
209
273
|
earnable: z.boolean().optional(),
|
|
@@ -211,11 +275,18 @@ const udlVerbSchema = z.strictObject({
|
|
|
211
275
|
examples: z.array(udlExampleSchema).min(1).optional(),
|
|
212
276
|
input: jsonObjectSchema.optional(),
|
|
213
277
|
moves: z.array(udlMoveSchema).default([]),
|
|
278
|
+
payout: udlPayoutSchema.optional(),
|
|
214
279
|
port: udlPortSchema.optional(),
|
|
280
|
+
publicIntent: udlPublicIntentSchema
|
|
281
|
+
.optional()
|
|
282
|
+
.describe("Author-approved public intent name; the containing verb key remains the lifecycle and execution identity"),
|
|
215
283
|
requiresAggregate: z.array(udlAggregateConditionSchema).min(1).optional(),
|
|
216
284
|
requiresDrainedAccount: z.strictObject({ path: fieldPathSchema }).optional(),
|
|
285
|
+
requiresExposure: z.array(udlExposureRequirementSchema).min(1).optional(),
|
|
217
286
|
requiresRefs: z.array(udlGateSchema).min(1).optional(),
|
|
287
|
+
requiresSettlement: udlRequiresSettlementSchema.optional(),
|
|
218
288
|
setsAt: udlSetsAtSchema.optional(),
|
|
289
|
+
signedSum: udlSignedSumSchema.optional(),
|
|
219
290
|
steps: z.array(udlStepSchema),
|
|
220
291
|
summary: nonEmptyTextSchema,
|
|
221
292
|
});
|
|
@@ -246,8 +317,10 @@ const udlAggregateSchema = z.union([
|
|
|
246
317
|
]);
|
|
247
318
|
const udlNounSchema = z.strictObject({
|
|
248
319
|
aggregateInvariants: z.array(udlAggregateSchema).min(1).optional(),
|
|
320
|
+
computedMoneyRefs: z.array(udlFieldNameSchema).min(1).optional(),
|
|
249
321
|
description: nonEmptyTextSchema.optional(),
|
|
250
322
|
distinctParties: z.literal(true).optional(),
|
|
323
|
+
derivedAmounts: z.array(udlDerivedAmountSchema).min(1).max(4).optional(),
|
|
251
324
|
fields: z.record(udlFieldNameSchema, jsonObjectSchema),
|
|
252
325
|
id: udlSnakeCaseSchema,
|
|
253
326
|
idPrefix: z
|
|
@@ -270,7 +343,7 @@ const udlNounSchema = z.strictObject({
|
|
|
270
343
|
update: udlUpdatePolicySchema.optional(),
|
|
271
344
|
verbs: z.record(udlVerbNameSchema, udlVerbSchema),
|
|
272
345
|
});
|
|
273
|
-
|
|
346
|
+
const udlDocumentShapeSchema = z.strictObject({
|
|
274
347
|
nouns: z.array(udlNounSchema).min(1),
|
|
275
348
|
product: udlSnakeCaseSchema,
|
|
276
349
|
subjects: z.array(udlSubjectSchema),
|
|
@@ -278,4 +351,135 @@ export const udlDocumentSchema = z.strictObject({
|
|
|
278
351
|
udl: z.literal(UDL_FORMAT_VERSION),
|
|
279
352
|
version: z.number().int().positive(),
|
|
280
353
|
});
|
|
354
|
+
const moneyPatterns = new Set(["^[1-9][0-9]{0,17}$", "^(0|[1-9][0-9]{0,17})$"]);
|
|
355
|
+
function isMoneyField(schema) {
|
|
356
|
+
return (typeof schema?.pattern === "string" && moneyPatterns.has(schema.pattern));
|
|
357
|
+
}
|
|
358
|
+
function referenceTargets(schema, nouns) {
|
|
359
|
+
if (schema.type !== "string" || typeof schema.pattern !== "string")
|
|
360
|
+
return [];
|
|
361
|
+
// Parse the scoped-ID pattern. Executing an author regex here would bypass
|
|
362
|
+
// the semantic validator's branch and quantifier budgets.
|
|
363
|
+
const match = /^\^([a-z]{2,8})_\(sandbox\|live\)_\[a-z0-9\]\{8,64\}\$$/.exec(schema.pattern);
|
|
364
|
+
if (!match)
|
|
365
|
+
return [];
|
|
366
|
+
const prefix = match[1];
|
|
367
|
+
const probe = `${prefix}_sandbox_0123456789abcdef`;
|
|
368
|
+
if (typeof schema.const === "string" && schema.const !== probe)
|
|
369
|
+
return [];
|
|
370
|
+
if (Array.isArray(schema.enum) && !schema.enum.includes(probe))
|
|
371
|
+
return [];
|
|
372
|
+
if (typeof schema.minLength === "number" && probe.length < schema.minLength) {
|
|
373
|
+
return [];
|
|
374
|
+
}
|
|
375
|
+
if (typeof schema.maxLength === "number" && probe.length > schema.maxLength) {
|
|
376
|
+
return [];
|
|
377
|
+
}
|
|
378
|
+
return nouns.filter((noun) => noun.idPrefix === prefix);
|
|
379
|
+
}
|
|
380
|
+
function declaredMoneyRefKeys(noun) {
|
|
381
|
+
return new Set([
|
|
382
|
+
...(noun.computedMoneyRefs ?? []),
|
|
383
|
+
...Object.values(noun.verbs).flatMap((verb) => [
|
|
384
|
+
...(verb.signedSum
|
|
385
|
+
? [
|
|
386
|
+
verb.signedSum.amountRef,
|
|
387
|
+
...verb.signedSum.sources.map((source) => source.subtotalRef),
|
|
388
|
+
]
|
|
389
|
+
: []),
|
|
390
|
+
...(verb.distribute ? [verb.distribute.amountRef] : []),
|
|
391
|
+
]),
|
|
392
|
+
...(noun.unwind ? ["unwindRefund", "unwindPenalty"] : []),
|
|
393
|
+
]);
|
|
394
|
+
}
|
|
395
|
+
export const udlDocumentSchema = udlDocumentShapeSchema.superRefine((document, context) => {
|
|
396
|
+
document.nouns.forEach((noun, nounIndex) => {
|
|
397
|
+
noun.derivedAmounts?.forEach((amount, amountIndex) => {
|
|
398
|
+
const base = [
|
|
399
|
+
"nouns",
|
|
400
|
+
nounIndex,
|
|
401
|
+
"derivedAmounts",
|
|
402
|
+
amountIndex,
|
|
403
|
+
];
|
|
404
|
+
if (!isMoneyField(noun.fields[amount.field])) {
|
|
405
|
+
context.addIssue({
|
|
406
|
+
code: "custom",
|
|
407
|
+
message: `derived amount target ${amount.field} must be a declared money field`,
|
|
408
|
+
path: [...base, "field"],
|
|
409
|
+
});
|
|
410
|
+
}
|
|
411
|
+
if (!isMoneyField(noun.fields[amount.sourceField])) {
|
|
412
|
+
context.addIssue({
|
|
413
|
+
code: "custom",
|
|
414
|
+
message: `derived amount source ${amount.sourceField} must be a declared money field`,
|
|
415
|
+
path: [...base, "sourceField"],
|
|
416
|
+
});
|
|
417
|
+
}
|
|
418
|
+
if (amount.field === amount.sourceField) {
|
|
419
|
+
context.addIssue({
|
|
420
|
+
code: "custom",
|
|
421
|
+
message: "a derived amount cannot derive from itself",
|
|
422
|
+
path: [...base, "sourceField"],
|
|
423
|
+
});
|
|
424
|
+
}
|
|
425
|
+
});
|
|
426
|
+
Object.entries(noun.verbs).forEach(([verbName, verb]) => {
|
|
427
|
+
const distribute = verb.distribute;
|
|
428
|
+
if (!distribute)
|
|
429
|
+
return;
|
|
430
|
+
const base = [
|
|
431
|
+
"nouns",
|
|
432
|
+
nounIndex,
|
|
433
|
+
"verbs",
|
|
434
|
+
verbName,
|
|
435
|
+
"distribute",
|
|
436
|
+
];
|
|
437
|
+
const refSchema = noun.fields[distribute.refField];
|
|
438
|
+
const parents = refSchema
|
|
439
|
+
? referenceTargets(refSchema, document.nouns)
|
|
440
|
+
: [];
|
|
441
|
+
if (parents.length !== 1) {
|
|
442
|
+
context.addIssue({
|
|
443
|
+
code: "custom",
|
|
444
|
+
message: `distribute refField ${distribute.refField} must identify exactly one parent noun`,
|
|
445
|
+
path: [...base, "refField"],
|
|
446
|
+
});
|
|
447
|
+
}
|
|
448
|
+
if (!isMoneyField(noun.fields[distribute.weightField])) {
|
|
449
|
+
context.addIssue({
|
|
450
|
+
code: "custom",
|
|
451
|
+
message: `distribute weightField ${distribute.weightField} must be a declared money field`,
|
|
452
|
+
path: [...base, "weightField"],
|
|
453
|
+
});
|
|
454
|
+
}
|
|
455
|
+
distribute.statuses.forEach((status, statusIndex) => {
|
|
456
|
+
if (noun.lifecycle.states.includes(status))
|
|
457
|
+
return;
|
|
458
|
+
context.addIssue({
|
|
459
|
+
code: "custom",
|
|
460
|
+
message: `distribute status ${status} is not declared by ${noun.id}`,
|
|
461
|
+
path: [...base, "statuses", statusIndex],
|
|
462
|
+
});
|
|
463
|
+
});
|
|
464
|
+
const parent = parents[0];
|
|
465
|
+
if (!parent)
|
|
466
|
+
return;
|
|
467
|
+
const poolMatch = /^(fields|refs)\.([a-z][A-Za-z0-9]*)$/.exec(distribute.pool.path);
|
|
468
|
+
const root = poolMatch?.[1];
|
|
469
|
+
const key = poolMatch?.[2];
|
|
470
|
+
const poolDeclared = root === "fields"
|
|
471
|
+
? isMoneyField(parent.fields[key ?? ""])
|
|
472
|
+
: root === "refs"
|
|
473
|
+
? declaredMoneyRefKeys(parent).has(key ?? "")
|
|
474
|
+
: false;
|
|
475
|
+
if (!poolDeclared) {
|
|
476
|
+
context.addIssue({
|
|
477
|
+
code: "custom",
|
|
478
|
+
message: `distribute pool ${distribute.pool.path} must be a declared money field or ref of ${parent.id}`,
|
|
479
|
+
path: [...base, "pool", "path"],
|
|
480
|
+
});
|
|
481
|
+
}
|
|
482
|
+
});
|
|
483
|
+
});
|
|
484
|
+
});
|
|
281
485
|
//# sourceMappingURL=schema.js.map
|