@sphereon/ssi-sdk.pd-manager 0.33.0 → 0.33.1-feature.vcdm2.tsup.18

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/dist/index.cjs ADDED
@@ -0,0 +1,1351 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
9
+ var __commonJS = (cb, mod) => function __require() {
10
+ return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
11
+ };
12
+ var __export = (target, all) => {
13
+ for (var name in all)
14
+ __defProp(target, name, { get: all[name], enumerable: true });
15
+ };
16
+ var __copyProps = (to, from, except, desc) => {
17
+ if (from && typeof from === "object" || typeof from === "function") {
18
+ for (let key of __getOwnPropNames(from))
19
+ if (!__hasOwnProp.call(to, key) && key !== except)
20
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
21
+ }
22
+ return to;
23
+ };
24
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
25
+ // If the importer is in node compatibility mode or this is not an ESM
26
+ // file that has been converted to a CommonJS file using a Babel-
27
+ // compatible transform (i.e. "__esModule" has not been set), then set
28
+ // "default" to the CommonJS "module.exports" for node compatibility.
29
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
30
+ mod
31
+ ));
32
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
33
+
34
+ // plugin.schema.json
35
+ var require_plugin_schema = __commonJS({
36
+ "plugin.schema.json"(exports2, module2) {
37
+ module2.exports = {
38
+ IPDManager: {
39
+ components: {
40
+ schemas: {
41
+ DeleteDefinitionItemArgs: {
42
+ type: "object",
43
+ properties: {
44
+ itemId: {
45
+ type: "string"
46
+ }
47
+ },
48
+ required: [
49
+ "itemId"
50
+ ]
51
+ },
52
+ DeleteDefinitionItemsArgs: {
53
+ $ref: "#/components/schemas/GetDefinitionItemsArgs"
54
+ },
55
+ GetDefinitionItemsArgs: {
56
+ type: "object",
57
+ properties: {
58
+ filter: {
59
+ $ref: "#/components/schemas/FindDefinitionArgs"
60
+ },
61
+ opts: {
62
+ $ref: "#/components/schemas/FetchOptions"
63
+ }
64
+ }
65
+ },
66
+ FindDefinitionArgs: {
67
+ type: "array",
68
+ items: {
69
+ $ref: "#/components/schemas/PresentationDefinitionItemFilter"
70
+ }
71
+ },
72
+ PresentationDefinitionItemFilter: {
73
+ type: "object",
74
+ properties: {
75
+ id: {
76
+ type: "string"
77
+ },
78
+ definitionId: {
79
+ type: "string"
80
+ },
81
+ tenantId: {
82
+ type: "string"
83
+ },
84
+ version: {
85
+ type: "string"
86
+ },
87
+ name: {
88
+ type: "string"
89
+ },
90
+ purpose: {
91
+ type: "string"
92
+ },
93
+ createdAt: {
94
+ type: "string",
95
+ format: "date-time"
96
+ },
97
+ lastUpdatedAt: {
98
+ type: "string",
99
+ format: "date-time"
100
+ }
101
+ }
102
+ },
103
+ FetchOptions: {
104
+ type: "object",
105
+ properties: {
106
+ showVersionHistory: {
107
+ type: "boolean"
108
+ }
109
+ }
110
+ },
111
+ GetDefinitionItemArgs: {
112
+ type: "object",
113
+ properties: {
114
+ itemId: {
115
+ type: "string"
116
+ }
117
+ },
118
+ required: [
119
+ "itemId"
120
+ ]
121
+ },
122
+ PresentationDefinitionItem: {
123
+ type: "object",
124
+ properties: {
125
+ id: {
126
+ type: "string"
127
+ },
128
+ definitionId: {
129
+ type: "string"
130
+ },
131
+ tenantId: {
132
+ type: "string"
133
+ },
134
+ version: {
135
+ type: "string"
136
+ },
137
+ name: {
138
+ type: "string"
139
+ },
140
+ purpose: {
141
+ type: "string"
142
+ },
143
+ definitionPayload: {
144
+ $ref: "#/components/schemas/IPresentationDefinition"
145
+ },
146
+ dcqlPayload: {
147
+ $ref: "#/components/schemas/DcqlQueryREST"
148
+ },
149
+ createdAt: {
150
+ type: "string",
151
+ format: "date-time"
152
+ },
153
+ lastUpdatedAt: {
154
+ type: "string",
155
+ format: "date-time"
156
+ }
157
+ },
158
+ required: [
159
+ "id",
160
+ "definitionId",
161
+ "version",
162
+ "definitionPayload",
163
+ "createdAt",
164
+ "lastUpdatedAt"
165
+ ]
166
+ },
167
+ IPresentationDefinition: {
168
+ anyOf: [
169
+ {
170
+ $ref: "#/components/schemas/PresentationDefinitionV1"
171
+ },
172
+ {
173
+ $ref: "#/components/schemas/PresentationDefinitionV2"
174
+ }
175
+ ]
176
+ },
177
+ PresentationDefinitionV1: {
178
+ type: "object",
179
+ properties: {
180
+ id: {
181
+ type: "string"
182
+ },
183
+ name: {
184
+ type: "string"
185
+ },
186
+ purpose: {
187
+ type: "string"
188
+ },
189
+ format: {
190
+ $ref: "#/components/schemas/Format"
191
+ },
192
+ submission_requirements: {
193
+ type: "array",
194
+ items: {
195
+ $ref: "#/components/schemas/SubmissionRequirement"
196
+ }
197
+ },
198
+ input_descriptors: {
199
+ type: "array",
200
+ items: {
201
+ $ref: "#/components/schemas/InputDescriptorV1"
202
+ }
203
+ }
204
+ },
205
+ required: [
206
+ "id",
207
+ "input_descriptors"
208
+ ]
209
+ },
210
+ Format: {
211
+ type: "object",
212
+ properties: {
213
+ jwt: {
214
+ $ref: "#/components/schemas/JwtObject"
215
+ },
216
+ jwt_vc: {
217
+ $ref: "#/components/schemas/JwtObject"
218
+ },
219
+ jwt_vc_json: {
220
+ $ref: "#/components/schemas/JwtObject"
221
+ },
222
+ jwt_vp: {
223
+ $ref: "#/components/schemas/JwtObject"
224
+ },
225
+ jwt_vp_json: {
226
+ $ref: "#/components/schemas/JwtObject"
227
+ },
228
+ ldp: {
229
+ $ref: "#/components/schemas/LdpObject"
230
+ },
231
+ ldp_vc: {
232
+ $ref: "#/components/schemas/LdpObject"
233
+ },
234
+ ldp_vp: {
235
+ $ref: "#/components/schemas/LdpObject"
236
+ },
237
+ di: {
238
+ $ref: "#/components/schemas/DiObject"
239
+ },
240
+ di_vc: {
241
+ $ref: "#/components/schemas/DiObject"
242
+ },
243
+ di_vp: {
244
+ $ref: "#/components/schemas/DiObject"
245
+ },
246
+ "vc+sd-jwt": {
247
+ $ref: "#/components/schemas/SdJwtObject"
248
+ },
249
+ mso_mdoc: {
250
+ $ref: "#/components/schemas/MsoMdocObject"
251
+ }
252
+ }
253
+ },
254
+ JwtObject: {
255
+ type: "object",
256
+ properties: {
257
+ alg: {
258
+ type: "array",
259
+ items: {
260
+ type: "string"
261
+ }
262
+ }
263
+ },
264
+ required: [
265
+ "alg"
266
+ ]
267
+ },
268
+ LdpObject: {
269
+ type: "object",
270
+ properties: {
271
+ proof_type: {
272
+ type: "array",
273
+ items: {
274
+ type: "string"
275
+ }
276
+ }
277
+ },
278
+ required: [
279
+ "proof_type"
280
+ ]
281
+ },
282
+ DiObject: {
283
+ type: "object",
284
+ properties: {
285
+ proof_type: {
286
+ type: "array",
287
+ items: {
288
+ type: "string"
289
+ }
290
+ },
291
+ cryptosuite: {
292
+ type: "array",
293
+ items: {
294
+ type: "string"
295
+ }
296
+ }
297
+ },
298
+ required: [
299
+ "proof_type",
300
+ "cryptosuite"
301
+ ]
302
+ },
303
+ SdJwtObject: {
304
+ type: "object",
305
+ properties: {
306
+ "sd-jwt_alg_values": {
307
+ type: "array",
308
+ items: {
309
+ type: "string"
310
+ }
311
+ },
312
+ "kb-jwt_alg_values": {
313
+ type: "array",
314
+ items: {
315
+ type: "string"
316
+ }
317
+ }
318
+ }
319
+ },
320
+ MsoMdocObject: {
321
+ type: "object",
322
+ properties: {
323
+ alg: {
324
+ type: "array",
325
+ items: {
326
+ type: "string"
327
+ }
328
+ }
329
+ },
330
+ required: [
331
+ "alg"
332
+ ]
333
+ },
334
+ SubmissionRequirement: {
335
+ type: "object",
336
+ properties: {
337
+ name: {
338
+ type: "string"
339
+ },
340
+ purpose: {
341
+ type: "string"
342
+ },
343
+ rule: {
344
+ $ref: "#/components/schemas/Rules"
345
+ },
346
+ count: {
347
+ type: "number"
348
+ },
349
+ min: {
350
+ type: "number"
351
+ },
352
+ max: {
353
+ type: "number"
354
+ },
355
+ from: {
356
+ type: "string"
357
+ },
358
+ from_nested: {
359
+ type: "array",
360
+ items: {
361
+ $ref: "#/components/schemas/SubmissionRequirement"
362
+ }
363
+ }
364
+ },
365
+ required: [
366
+ "rule"
367
+ ]
368
+ },
369
+ Rules: {
370
+ type: "string",
371
+ enum: [
372
+ "all",
373
+ "pick"
374
+ ]
375
+ },
376
+ InputDescriptorV1: {
377
+ type: "object",
378
+ properties: {
379
+ id: {
380
+ type: "string"
381
+ },
382
+ name: {
383
+ type: "string"
384
+ },
385
+ purpose: {
386
+ type: "string"
387
+ },
388
+ group: {
389
+ type: "array",
390
+ items: {
391
+ type: "string"
392
+ }
393
+ },
394
+ schema: {
395
+ type: "array",
396
+ items: {
397
+ $ref: "#/components/schemas/Schema"
398
+ }
399
+ },
400
+ issuance: {
401
+ type: "array",
402
+ items: {
403
+ $ref: "#/components/schemas/Issuance"
404
+ }
405
+ },
406
+ constraints: {
407
+ $ref: "#/components/schemas/ConstraintsV1"
408
+ }
409
+ },
410
+ required: [
411
+ "id",
412
+ "schema"
413
+ ]
414
+ },
415
+ Schema: {
416
+ type: "object",
417
+ properties: {
418
+ uri: {
419
+ type: "string"
420
+ },
421
+ required: {
422
+ type: "boolean"
423
+ }
424
+ },
425
+ required: [
426
+ "uri"
427
+ ]
428
+ },
429
+ Issuance: {
430
+ type: "object",
431
+ properties: {
432
+ manifest: {
433
+ type: "string"
434
+ }
435
+ },
436
+ additionalProperties: {}
437
+ },
438
+ ConstraintsV1: {
439
+ type: "object",
440
+ properties: {
441
+ limit_disclosure: {
442
+ $ref: "#/components/schemas/Optionality"
443
+ },
444
+ statuses: {
445
+ $ref: "#/components/schemas/Statuses"
446
+ },
447
+ fields: {
448
+ type: "array",
449
+ items: {
450
+ $ref: "#/components/schemas/FieldV1"
451
+ }
452
+ },
453
+ subject_is_issuer: {
454
+ $ref: "#/components/schemas/Optionality"
455
+ },
456
+ is_holder: {
457
+ type: "array",
458
+ items: {
459
+ $ref: "#/components/schemas/HolderSubject"
460
+ }
461
+ },
462
+ same_subject: {
463
+ type: "array",
464
+ items: {
465
+ $ref: "#/components/schemas/HolderSubject"
466
+ }
467
+ }
468
+ }
469
+ },
470
+ Optionality: {
471
+ type: "string",
472
+ enum: [
473
+ "required",
474
+ "preferred"
475
+ ]
476
+ },
477
+ Statuses: {
478
+ type: "object",
479
+ properties: {
480
+ active: {
481
+ $ref: "#/components/schemas/PdStatus"
482
+ },
483
+ suspended: {
484
+ $ref: "#/components/schemas/PdStatus"
485
+ },
486
+ revoked: {
487
+ $ref: "#/components/schemas/PdStatus"
488
+ }
489
+ }
490
+ },
491
+ PdStatus: {
492
+ type: "object",
493
+ properties: {
494
+ directive: {
495
+ $ref: "#/components/schemas/Directives"
496
+ }
497
+ }
498
+ },
499
+ Directives: {
500
+ type: "string",
501
+ enum: [
502
+ "required",
503
+ "allowed",
504
+ "disallowed"
505
+ ]
506
+ },
507
+ FieldV1: {
508
+ type: "object",
509
+ properties: {
510
+ id: {
511
+ type: "string"
512
+ },
513
+ path: {
514
+ type: "array",
515
+ items: {
516
+ type: "string"
517
+ }
518
+ },
519
+ purpose: {
520
+ type: "string"
521
+ },
522
+ filter: {
523
+ $ref: "#/components/schemas/FilterV1"
524
+ },
525
+ predicate: {
526
+ $ref: "#/components/schemas/Optionality"
527
+ }
528
+ },
529
+ required: [
530
+ "path"
531
+ ]
532
+ },
533
+ FilterV1: {
534
+ type: "object",
535
+ properties: {
536
+ const: {
537
+ $ref: "#/components/schemas/OneOfNumberStringBoolean"
538
+ },
539
+ enum: {
540
+ type: "array",
541
+ items: {
542
+ $ref: "#/components/schemas/OneOfNumberStringBoolean"
543
+ }
544
+ },
545
+ exclusiveMinimum: {
546
+ $ref: "#/components/schemas/OneOfNumberString"
547
+ },
548
+ exclusiveMaximum: {
549
+ $ref: "#/components/schemas/OneOfNumberString"
550
+ },
551
+ format: {
552
+ type: "string"
553
+ },
554
+ minLength: {
555
+ type: "number"
556
+ },
557
+ maxLength: {
558
+ type: "number"
559
+ },
560
+ minimum: {
561
+ $ref: "#/components/schemas/OneOfNumberString"
562
+ },
563
+ maximum: {
564
+ $ref: "#/components/schemas/OneOfNumberString"
565
+ },
566
+ not: {
567
+ type: "object"
568
+ },
569
+ pattern: {
570
+ type: "string"
571
+ },
572
+ type: {
573
+ type: "string"
574
+ }
575
+ }
576
+ },
577
+ OneOfNumberStringBoolean: {
578
+ type: [
579
+ "boolean",
580
+ "number",
581
+ "string"
582
+ ]
583
+ },
584
+ OneOfNumberString: {
585
+ type: [
586
+ "number",
587
+ "string"
588
+ ]
589
+ },
590
+ HolderSubject: {
591
+ type: "object",
592
+ properties: {
593
+ field_id: {
594
+ type: "array",
595
+ items: {
596
+ type: "string"
597
+ }
598
+ },
599
+ directive: {
600
+ $ref: "#/components/schemas/Optionality"
601
+ }
602
+ },
603
+ required: [
604
+ "field_id",
605
+ "directive"
606
+ ]
607
+ },
608
+ PresentationDefinitionV2: {
609
+ type: "object",
610
+ properties: {
611
+ id: {
612
+ type: "string"
613
+ },
614
+ name: {
615
+ type: "string"
616
+ },
617
+ purpose: {
618
+ type: "string"
619
+ },
620
+ format: {
621
+ $ref: "#/components/schemas/Format"
622
+ },
623
+ submission_requirements: {
624
+ type: "array",
625
+ items: {
626
+ $ref: "#/components/schemas/SubmissionRequirement"
627
+ }
628
+ },
629
+ input_descriptors: {
630
+ type: "array",
631
+ items: {
632
+ $ref: "#/components/schemas/InputDescriptorV2"
633
+ }
634
+ },
635
+ frame: {
636
+ type: "object"
637
+ }
638
+ },
639
+ required: [
640
+ "id",
641
+ "input_descriptors"
642
+ ]
643
+ },
644
+ InputDescriptorV2: {
645
+ type: "object",
646
+ properties: {
647
+ id: {
648
+ type: "string"
649
+ },
650
+ name: {
651
+ type: "string"
652
+ },
653
+ purpose: {
654
+ type: "string"
655
+ },
656
+ format: {
657
+ $ref: "#/components/schemas/Format"
658
+ },
659
+ group: {
660
+ type: "array",
661
+ items: {
662
+ type: "string"
663
+ }
664
+ },
665
+ issuance: {
666
+ type: "array",
667
+ items: {
668
+ $ref: "#/components/schemas/Issuance"
669
+ }
670
+ },
671
+ constraints: {
672
+ $ref: "#/components/schemas/ConstraintsV2"
673
+ }
674
+ },
675
+ required: [
676
+ "id",
677
+ "constraints"
678
+ ]
679
+ },
680
+ ConstraintsV2: {
681
+ type: "object",
682
+ properties: {
683
+ limit_disclosure: {
684
+ $ref: "#/components/schemas/Optionality"
685
+ },
686
+ statuses: {
687
+ $ref: "#/components/schemas/Statuses"
688
+ },
689
+ fields: {
690
+ type: "array",
691
+ items: {
692
+ $ref: "#/components/schemas/FieldV2"
693
+ }
694
+ },
695
+ subject_is_issuer: {
696
+ $ref: "#/components/schemas/Optionality"
697
+ },
698
+ is_holder: {
699
+ type: "array",
700
+ items: {
701
+ $ref: "#/components/schemas/HolderSubject"
702
+ }
703
+ },
704
+ same_subject: {
705
+ type: "array",
706
+ items: {
707
+ $ref: "#/components/schemas/HolderSubject"
708
+ }
709
+ }
710
+ }
711
+ },
712
+ FieldV2: {
713
+ type: "object",
714
+ properties: {
715
+ id: {
716
+ type: "string"
717
+ },
718
+ path: {
719
+ type: "array",
720
+ items: {
721
+ type: "string"
722
+ }
723
+ },
724
+ purpose: {
725
+ type: "string"
726
+ },
727
+ filter: {
728
+ $ref: "#/components/schemas/FilterV2"
729
+ },
730
+ predicate: {
731
+ $ref: "#/components/schemas/Optionality"
732
+ },
733
+ intent_to_retain: {
734
+ type: "boolean"
735
+ },
736
+ name: {
737
+ type: "string"
738
+ },
739
+ optional: {
740
+ type: "boolean"
741
+ }
742
+ },
743
+ required: [
744
+ "path"
745
+ ]
746
+ },
747
+ FilterV2: {
748
+ type: "object",
749
+ properties: {
750
+ const: {
751
+ $ref: "#/components/schemas/OneOfNumberStringBoolean"
752
+ },
753
+ enum: {
754
+ type: "array",
755
+ items: {
756
+ $ref: "#/components/schemas/OneOfNumberStringBoolean"
757
+ }
758
+ },
759
+ exclusiveMinimum: {
760
+ $ref: "#/components/schemas/OneOfNumberString"
761
+ },
762
+ exclusiveMaximum: {
763
+ $ref: "#/components/schemas/OneOfNumberString"
764
+ },
765
+ format: {
766
+ type: "string"
767
+ },
768
+ formatMaximum: {
769
+ type: "string"
770
+ },
771
+ formatMinimum: {
772
+ type: "string"
773
+ },
774
+ formatExclusiveMaximum: {
775
+ type: "string"
776
+ },
777
+ formatExclusiveMinimum: {
778
+ type: "string"
779
+ },
780
+ minLength: {
781
+ type: "number"
782
+ },
783
+ maxLength: {
784
+ type: "number"
785
+ },
786
+ minimum: {
787
+ $ref: "#/components/schemas/OneOfNumberString"
788
+ },
789
+ maximum: {
790
+ $ref: "#/components/schemas/OneOfNumberString"
791
+ },
792
+ not: {
793
+ type: "object"
794
+ },
795
+ pattern: {
796
+ type: "string"
797
+ },
798
+ type: {
799
+ type: "string"
800
+ },
801
+ contains: {
802
+ $ref: "#/components/schemas/FilterV2"
803
+ },
804
+ items: {
805
+ $ref: "#/components/schemas/FilterV2Items"
806
+ }
807
+ }
808
+ },
809
+ FilterV2Items: {
810
+ type: "object",
811
+ properties: {
812
+ const: {
813
+ $ref: "#/components/schemas/OneOfNumberStringBoolean"
814
+ },
815
+ enum: {
816
+ type: "array",
817
+ items: {
818
+ $ref: "#/components/schemas/OneOfNumberStringBoolean"
819
+ }
820
+ },
821
+ exclusiveMinimum: {
822
+ $ref: "#/components/schemas/OneOfNumberString"
823
+ },
824
+ exclusiveMaximum: {
825
+ $ref: "#/components/schemas/OneOfNumberString"
826
+ },
827
+ format: {
828
+ type: "string"
829
+ },
830
+ formatMaximum: {
831
+ type: "string"
832
+ },
833
+ formatMinimum: {
834
+ type: "string"
835
+ },
836
+ formatExclusiveMaximum: {
837
+ type: "string"
838
+ },
839
+ formatExclusiveMinimum: {
840
+ type: "string"
841
+ },
842
+ minLength: {
843
+ type: "number"
844
+ },
845
+ maxLength: {
846
+ type: "number"
847
+ },
848
+ minimum: {
849
+ $ref: "#/components/schemas/OneOfNumberString"
850
+ },
851
+ maximum: {
852
+ $ref: "#/components/schemas/OneOfNumberString"
853
+ },
854
+ not: {
855
+ type: "object"
856
+ },
857
+ pattern: {
858
+ type: "string"
859
+ },
860
+ type: {
861
+ type: "string"
862
+ },
863
+ contains: {
864
+ $ref: "#/components/schemas/FilterV2"
865
+ },
866
+ items: {
867
+ $ref: "#/components/schemas/FilterV2Items"
868
+ }
869
+ }
870
+ },
871
+ DcqlQueryREST: {
872
+ type: "object",
873
+ properties: {
874
+ credentials: {
875
+ type: "array",
876
+ items: {
877
+ $ref: "#/components/schemas/DcqlCredentialQuery"
878
+ }
879
+ }
880
+ },
881
+ required: [
882
+ "credentials"
883
+ ]
884
+ },
885
+ DcqlCredentialQuery: {
886
+ type: "object",
887
+ properties: {
888
+ id: {
889
+ type: "string"
890
+ },
891
+ format: {
892
+ type: "string"
893
+ },
894
+ alg: {
895
+ type: "array",
896
+ items: {
897
+ type: "string"
898
+ }
899
+ },
900
+ claims: {
901
+ type: "array",
902
+ items: {
903
+ $ref: "#/components/schemas/DcqlClaim"
904
+ }
905
+ },
906
+ meta: {
907
+ type: "object"
908
+ }
909
+ },
910
+ required: [
911
+ "id",
912
+ "format",
913
+ "claims"
914
+ ]
915
+ },
916
+ DcqlClaim: {
917
+ type: "object",
918
+ properties: {
919
+ namespace: {
920
+ type: "string"
921
+ },
922
+ claim_name: {
923
+ type: "string"
924
+ },
925
+ filter: {
926
+ $ref: "#/components/schemas/DcqlFilter"
927
+ }
928
+ },
929
+ required: [
930
+ "namespace",
931
+ "claim_name"
932
+ ]
933
+ },
934
+ DcqlFilter: {
935
+ type: "object",
936
+ properties: {
937
+ type: {
938
+ type: "string",
939
+ enum: [
940
+ "string",
941
+ "number",
942
+ "boolean"
943
+ ]
944
+ },
945
+ pattern: {
946
+ type: "string"
947
+ },
948
+ minimum: {
949
+ type: "number"
950
+ },
951
+ maximum: {
952
+ type: "number"
953
+ }
954
+ },
955
+ required: [
956
+ "type"
957
+ ]
958
+ },
959
+ HasDefinitionItemArgs: {
960
+ $ref: "#/components/schemas/GetDefinitionItemArgs"
961
+ },
962
+ HasDefinitionItemsArgs: {
963
+ $ref: "#/components/schemas/GetDefinitionItemsArgs"
964
+ },
965
+ PersistDefinitionArgs: {
966
+ type: "object",
967
+ properties: {
968
+ definitionItem: {
969
+ $ref: "#/components/schemas/PersistPresentationDefinitionItem"
970
+ },
971
+ opts: {
972
+ $ref: "#/components/schemas/PersistOptions"
973
+ }
974
+ },
975
+ required: [
976
+ "definitionItem"
977
+ ]
978
+ },
979
+ PersistPresentationDefinitionItem: {
980
+ type: "object",
981
+ properties: {
982
+ id: {
983
+ type: "string"
984
+ },
985
+ definitionId: {
986
+ type: "string"
987
+ },
988
+ version: {
989
+ type: "string"
990
+ },
991
+ tenantId: {
992
+ type: "string"
993
+ },
994
+ name: {
995
+ type: "string"
996
+ },
997
+ purpose: {
998
+ type: "string"
999
+ },
1000
+ definitionPayload: {
1001
+ $ref: "#/components/schemas/IPresentationDefinition"
1002
+ },
1003
+ dcqlPayload: {
1004
+ $ref: "#/components/schemas/DcqlQueryREST"
1005
+ }
1006
+ },
1007
+ required: [
1008
+ "definitionPayload"
1009
+ ]
1010
+ },
1011
+ PersistOptions: {
1012
+ type: "object",
1013
+ properties: {
1014
+ versionControlMode: {
1015
+ $ref: "#/components/schemas/VersionControlMode"
1016
+ },
1017
+ versionIncrementReleaseType: {
1018
+ $ref: "#/components/schemas/ReleaseType"
1019
+ }
1020
+ }
1021
+ },
1022
+ VersionControlMode: {
1023
+ type: "string",
1024
+ enum: [
1025
+ "AutoIncrement",
1026
+ "Manual",
1027
+ "Overwrite",
1028
+ "OverwriteLatest"
1029
+ ]
1030
+ },
1031
+ ReleaseType: {
1032
+ type: "string",
1033
+ enum: [
1034
+ "major",
1035
+ "premajor",
1036
+ "minor",
1037
+ "preminor",
1038
+ "patch",
1039
+ "prepatch",
1040
+ "prerelease"
1041
+ ]
1042
+ }
1043
+ },
1044
+ methods: {
1045
+ pdmDeleteDefinition: {
1046
+ description: "Delete a single presentation definition records by primary key",
1047
+ arguments: {
1048
+ $ref: "#/components/schemas/DeleteDefinitionItemArgs"
1049
+ },
1050
+ returnType: {
1051
+ type: "boolean"
1052
+ }
1053
+ },
1054
+ pdmDeleteDefinitions: {
1055
+ description: "Delete multiple presentation definitions records using filters",
1056
+ arguments: {
1057
+ $ref: "#/components/schemas/DeleteDefinitionItemsArgs"
1058
+ },
1059
+ returnType: {
1060
+ type: "number"
1061
+ }
1062
+ },
1063
+ pdmGetDefinition: {
1064
+ description: "Get a single presentation definition records by primary key",
1065
+ arguments: {
1066
+ $ref: "#/components/schemas/GetDefinitionItemArgs"
1067
+ },
1068
+ returnType: {
1069
+ $ref: "#/components/schemas/PresentationDefinitionItem"
1070
+ }
1071
+ },
1072
+ pdmGetDefinitions: {
1073
+ description: "Find one or more presentation definition records using filters",
1074
+ arguments: {
1075
+ $ref: "#/components/schemas/GetDefinitionItemsArgs"
1076
+ },
1077
+ returnType: {
1078
+ type: "array",
1079
+ items: {
1080
+ $ref: "#/components/schemas/PresentationDefinitionItem"
1081
+ }
1082
+ }
1083
+ },
1084
+ pdmHasDefinition: {
1085
+ description: "Checks whether a presentation definition record exists by primary key",
1086
+ arguments: {
1087
+ $ref: "#/components/schemas/HasDefinitionItemArgs"
1088
+ },
1089
+ returnType: {
1090
+ type: "boolean"
1091
+ }
1092
+ },
1093
+ pdmHasDefinitions: {
1094
+ description: "Checks whether one or more presentation definition records exist using filters",
1095
+ arguments: {
1096
+ $ref: "#/components/schemas/HasDefinitionItemsArgs"
1097
+ },
1098
+ returnType: {
1099
+ type: "boolean"
1100
+ }
1101
+ },
1102
+ pdmPersistDefinition: {
1103
+ description: "Check in a presentation definition. It has version control logic which will add or update presentation definition records and has settings for automatic version numbering.",
1104
+ arguments: {
1105
+ $ref: "#/components/schemas/PersistDefinitionArgs"
1106
+ },
1107
+ returnType: {
1108
+ $ref: "#/components/schemas/PresentationDefinitionItem"
1109
+ }
1110
+ }
1111
+ }
1112
+ }
1113
+ }
1114
+ };
1115
+ }
1116
+ });
1117
+
1118
+ // src/index.ts
1119
+ var index_exports = {};
1120
+ __export(index_exports, {
1121
+ PDManager: () => PDManager,
1122
+ ReleaseType: () => import_semver.ReleaseType,
1123
+ pdManagerMethods: () => pdManagerMethods,
1124
+ schema: () => schema
1125
+ });
1126
+ module.exports = __toCommonJS(index_exports);
1127
+
1128
+ // src/agent/PDManager.ts
1129
+ var import_ssi_sdk = require("@sphereon/ssi-sdk.data-store");
1130
+ var import_preload = __toESM(require("semver/preload"), 1);
1131
+ var pdManagerMethods = [
1132
+ "pdmHasDefinition",
1133
+ "pdmHasGetDefinitions",
1134
+ "pdmGetDefinition",
1135
+ "pdmGetDefinitions",
1136
+ "pdmPersistDefinition",
1137
+ "pdmDeleteDefinition",
1138
+ "pdmDeleteDefinitions"
1139
+ ];
1140
+ var PDManager = class {
1141
+ static {
1142
+ __name(this, "PDManager");
1143
+ }
1144
+ schema = schema.IPDManager;
1145
+ methods = {
1146
+ pdmPersistDefinition: this.pdmPersistDefinition.bind(this),
1147
+ pdmHasDefinition: this.pdmHasDefinition.bind(this),
1148
+ pdmHasDefinitions: this.pdmHasDefinitions.bind(this),
1149
+ pdmGetDefinition: this.pdmGetDefinition.bind(this),
1150
+ pdmGetDefinitions: this.pdmGetDefinitions.bind(this),
1151
+ pdmDeleteDefinition: this.pdmDeleteDefinition.bind(this),
1152
+ pdmDeleteDefinitions: this.pdmDeleteDefinitions.bind(this)
1153
+ };
1154
+ store;
1155
+ constructor(options) {
1156
+ this.store = options.store;
1157
+ }
1158
+ /** {@inheritDoc IPDManager.pdmHasDefinition} */
1159
+ async pdmHasDefinition(args) {
1160
+ const { itemId } = args;
1161
+ return this.store.hasDefinition({
1162
+ itemId
1163
+ });
1164
+ }
1165
+ /** {@inheritDoc IPDManager.pdmHasDefinitions} */
1166
+ async pdmHasDefinitions(args) {
1167
+ const { filter } = args;
1168
+ return this.store.hasDefinitions({
1169
+ filter
1170
+ });
1171
+ }
1172
+ /** {@inheritDoc IPDManager.pdmGetDefinition} */
1173
+ async pdmGetDefinition(args) {
1174
+ const { itemId } = args;
1175
+ return this.store.getDefinition({
1176
+ itemId
1177
+ });
1178
+ }
1179
+ /** {@inheritDoc IPDManager.pdmGetDefinitions} */
1180
+ async pdmGetDefinitions(args) {
1181
+ const { filter, opts } = args;
1182
+ const allDefinitions = await this.store.getDefinitions({
1183
+ filter
1184
+ });
1185
+ let definitions = [];
1186
+ if (opts == void 0 || opts.showVersionHistory !== true) {
1187
+ const groupedByDefinitionId = allDefinitions.reduce((acc, entity) => {
1188
+ if (!acc[entity.definitionId]) {
1189
+ acc[entity.definitionId] = [];
1190
+ }
1191
+ acc[entity.definitionId].push(entity);
1192
+ return acc;
1193
+ }, {});
1194
+ definitions = Object.values(groupedByDefinitionId).map((entities) => entities.reduce((highestVersionItem, baseItem) => {
1195
+ const baseVersion = this.normalizeToSemverVersionFormat(baseItem.version);
1196
+ const highestVersion = this.normalizeToSemverVersionFormat(highestVersionItem.version);
1197
+ return import_preload.default.gt(baseVersion, highestVersion) ? baseItem : highestVersionItem;
1198
+ }));
1199
+ } else {
1200
+ definitions = allDefinitions;
1201
+ }
1202
+ return definitions;
1203
+ }
1204
+ /** {@inheritDoc IPDManager.pdmDeleteDefinition} */
1205
+ async pdmDeleteDefinition(args) {
1206
+ return this.store.deleteDefinition(args).then((value) => true);
1207
+ }
1208
+ /** {@inheritDoc IPDManager.pdmDeleteDefinitions} */
1209
+ async pdmDeleteDefinitions(args) {
1210
+ return this.store.deleteDefinitions(args);
1211
+ }
1212
+ /** {@inheritDoc IPDManager.pdmPersistDefinition} */
1213
+ async pdmPersistDefinition(args) {
1214
+ const { definitionItem, opts } = args;
1215
+ const { versionControlMode, versionIncrementReleaseType } = opts ?? {
1216
+ versionControlMode: "AutoIncrement"
1217
+ };
1218
+ const { version, tenantId } = definitionItem;
1219
+ const definitionId = definitionItem.definitionId ?? definitionItem.definitionPayload.id;
1220
+ let { id } = definitionItem;
1221
+ if (id !== void 0 && versionControlMode !== "Overwrite") {
1222
+ id = void 0;
1223
+ }
1224
+ const nonPersistedDefinitionItem = {
1225
+ ...definitionItem,
1226
+ definitionId,
1227
+ version: version ?? "1"
1228
+ };
1229
+ const existing = await this.store.getDefinitions({
1230
+ filter: [
1231
+ {
1232
+ id,
1233
+ definitionId,
1234
+ tenantId,
1235
+ version
1236
+ }
1237
+ ]
1238
+ });
1239
+ const existingItem = existing[0];
1240
+ const allDefinitions = await this.store.getDefinitions({
1241
+ filter: [
1242
+ {
1243
+ definitionId,
1244
+ tenantId
1245
+ }
1246
+ ]
1247
+ });
1248
+ allDefinitions.sort((a, b) => import_preload.default.compare(this.normalizeToSemverVersionFormat(a.version), this.normalizeToSemverVersionFormat(b.version)));
1249
+ const trulyLatestVersionItem = allDefinitions[allDefinitions.length - 1];
1250
+ let latestVersionItem = trulyLatestVersionItem;
1251
+ if (existingItem && version) {
1252
+ latestVersionItem = trulyLatestVersionItem ?? existingItem;
1253
+ }
1254
+ const isPayloadModified = !existingItem || !(0, import_ssi_sdk.isPresentationDefinitionEqual)(existingItem, definitionItem);
1255
+ if (!isPayloadModified) return existingItem;
1256
+ switch (versionControlMode) {
1257
+ case "Overwrite":
1258
+ return this.handleOverwriteMode(existingItem, nonPersistedDefinitionItem, version);
1259
+ case "OverwriteLatest":
1260
+ return this.handleOverwriteLatestMode(latestVersionItem, nonPersistedDefinitionItem);
1261
+ case "Manual":
1262
+ return this.handleManualMode(existingItem, nonPersistedDefinitionItem, tenantId, version);
1263
+ case "AutoIncrement":
1264
+ return this.handleAutoIncrementMode(latestVersionItem, nonPersistedDefinitionItem, versionIncrementReleaseType ?? "major");
1265
+ default:
1266
+ throw new Error(`Unknown version control mode: ${versionControlMode}`);
1267
+ }
1268
+ }
1269
+ async handleOverwriteMode(existingItem, definitionItem, version) {
1270
+ if (existingItem) {
1271
+ existingItem.definitionId = definitionItem.definitionId;
1272
+ existingItem.version = version ?? existingItem.version ?? "1";
1273
+ existingItem.tenantId = definitionItem.tenantId;
1274
+ existingItem.name = definitionItem.definitionPayload.name ?? definitionItem.name;
1275
+ existingItem.purpose = definitionItem.definitionPayload.purpose ?? definitionItem.purpose;
1276
+ existingItem.definitionPayload = definitionItem.definitionPayload;
1277
+ return await this.store.updateDefinition(existingItem);
1278
+ } else {
1279
+ return await this.store.addDefinition(definitionItem);
1280
+ }
1281
+ }
1282
+ async handleOverwriteLatestMode(latestVersionItem, definitionItem) {
1283
+ if (latestVersionItem) {
1284
+ latestVersionItem.definitionId = definitionItem.definitionId;
1285
+ latestVersionItem.tenantId = definitionItem.tenantId;
1286
+ latestVersionItem.name = definitionItem.name;
1287
+ latestVersionItem.purpose = definitionItem.purpose;
1288
+ latestVersionItem.definitionPayload = definitionItem.definitionPayload;
1289
+ return await this.store.updateDefinition(latestVersionItem);
1290
+ } else {
1291
+ return await this.store.addDefinition(definitionItem);
1292
+ }
1293
+ }
1294
+ async handleManualMode(existingItem, definitionItem, tenantId, version) {
1295
+ if (existingItem && !(0, import_ssi_sdk.isPresentationDefinitionEqual)(existingItem, definitionItem)) {
1296
+ throw Error(`Cannot update definition ${definitionItem.definitionId} for tenant ${tenantId} version ${version} because definition exists and manual version control is enabled.`);
1297
+ } else {
1298
+ return await this.store.addDefinition(definitionItem);
1299
+ }
1300
+ }
1301
+ async handleAutoIncrementMode(latestVersionItem, definitionItem, releaseType) {
1302
+ const defaultVersion = "1";
1303
+ let currentVersion = latestVersionItem?.version ?? definitionItem.version ?? defaultVersion;
1304
+ let resultVersion;
1305
+ if (!latestVersionItem) {
1306
+ resultVersion = currentVersion;
1307
+ } else {
1308
+ let [baseVersion, preReleaseSuffix] = currentVersion.split(/-(.+)/);
1309
+ let normalizedBaseVersion = import_preload.default.coerce(baseVersion)?.version ?? `${defaultVersion}.0.0`;
1310
+ let preReleaseIdentifier = preReleaseSuffix ? preReleaseSuffix.match(/^[a-zA-Z]+/)?.[0] : void 0;
1311
+ let fullVersionToIncrement = preReleaseIdentifier ? `${normalizedBaseVersion}-${preReleaseSuffix}` : normalizedBaseVersion;
1312
+ let incrementedVersion = import_preload.default.inc(fullVersionToIncrement, releaseType, preReleaseIdentifier);
1313
+ if (!incrementedVersion) {
1314
+ throw new Error(`Could not increment ${releaseType} version on ${currentVersion} ${preReleaseSuffix}`);
1315
+ }
1316
+ let [incrementedBaseVersion, incrementedSuffix] = incrementedVersion.split(/-(.+)/);
1317
+ let originalParts = baseVersion.split(".");
1318
+ let newParts = incrementedBaseVersion.split(".");
1319
+ while (newParts.length > originalParts.length) {
1320
+ newParts.pop();
1321
+ }
1322
+ resultVersion = newParts.join(".");
1323
+ if (incrementedSuffix) {
1324
+ resultVersion += `-${incrementedSuffix}`;
1325
+ }
1326
+ }
1327
+ definitionItem.version = resultVersion;
1328
+ return await this.store.addDefinition(definitionItem);
1329
+ }
1330
+ normalizeToSemverVersionFormat(version) {
1331
+ const defaultVersion = "1.0.0";
1332
+ let [baseVersion, preReleaseSuffix] = version.split(/-(.+)/);
1333
+ let normalizedBaseVersion = import_preload.default.coerce(baseVersion)?.version ?? defaultVersion;
1334
+ if (preReleaseSuffix) {
1335
+ normalizedBaseVersion += `-${preReleaseSuffix}`;
1336
+ }
1337
+ return normalizedBaseVersion;
1338
+ }
1339
+ };
1340
+
1341
+ // src/index.ts
1342
+ var import_semver = require("semver");
1343
+ var schema = require_plugin_schema();
1344
+ // Annotate the CommonJS export names for ESM import in node:
1345
+ 0 && (module.exports = {
1346
+ PDManager,
1347
+ ReleaseType,
1348
+ pdManagerMethods,
1349
+ schema
1350
+ });
1351
+ //# sourceMappingURL=index.cjs.map