@c-rex/core 0.1.21 → 0.1.23

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/requests.js CHANGED
@@ -30,7 +30,30 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
30
30
  // src/requests.ts
31
31
  var requests_exports = {};
32
32
  __export(requests_exports, {
33
- CrexApi: () => CrexApi
33
+ CREX_API_CACHE_TAG: () => CREX_API_CACHE_TAG,
34
+ CREX_API_CACHE_VCARD_TAG: () => CREX_API_CACHE_VCARD_TAG,
35
+ CREX_CACHE_SEGMENT_ALL: () => CREX_CACHE_SEGMENT_ALL,
36
+ CREX_CACHE_SEGMENT_METADATA: () => CREX_CACHE_SEGMENT_METADATA,
37
+ CREX_CACHE_SEGMENT_REQUESTS: () => CREX_CACHE_SEGMENT_REQUESTS,
38
+ CREX_CACHE_SEGMENT_TO_TAGS: () => CREX_CACHE_SEGMENT_TO_TAGS,
39
+ CREX_CACHE_SEGMENT_VCARD: () => CREX_CACHE_SEGMENT_VCARD,
40
+ CREX_READMODEL_CACHE_COMPONENTS_TAG: () => CREX_READMODEL_CACHE_COMPONENTS_TAG,
41
+ CREX_READMODEL_CACHE_DOCUMENT_TYPES_TAG: () => CREX_READMODEL_CACHE_DOCUMENT_TYPES_TAG,
42
+ CREX_READMODEL_CACHE_INFORMATION_SUBJECTS_TAG: () => CREX_READMODEL_CACHE_INFORMATION_SUBJECTS_TAG,
43
+ CREX_READMODEL_CACHE_METADATA_TAG: () => CREX_READMODEL_CACHE_METADATA_TAG,
44
+ CREX_READMODEL_CACHE_ORGANIZATION_TAG: () => CREX_READMODEL_CACHE_ORGANIZATION_TAG,
45
+ CREX_READMODEL_CACHE_PARTIES_TAG: () => CREX_READMODEL_CACHE_PARTIES_TAG,
46
+ CREX_READMODEL_CACHE_TAG: () => CREX_READMODEL_CACHE_TAG,
47
+ CREX_READMODEL_CACHE_VCARD_TAG: () => CREX_READMODEL_CACHE_VCARD_TAG,
48
+ CacheClearAuthConfigurationError: () => CacheClearAuthConfigurationError,
49
+ CacheClearAuthUnauthorizedError: () => CacheClearAuthUnauthorizedError,
50
+ CrexApi: () => CrexApi,
51
+ clearProcessLocalRequestCaches: () => clearProcessLocalRequestCaches,
52
+ extractScopesFromJwtPayload: () => extractScopesFromJwtPayload,
53
+ getSupportedCacheSegments: () => getSupportedCacheSegments,
54
+ handleCacheClearPostRequest: () => handleCacheClearPostRequest,
55
+ resolveCacheTagsForSegments: () => resolveCacheTagsForSegments,
56
+ verifyCacheClearBearerToken: () => verifyCacheClearBearerToken
34
57
  });
35
58
  module.exports = __toCommonJS(requests_exports);
36
59
 
@@ -45,6 +68,7 @@ var AdministrativeMetadataModelFields = {
45
68
  descriptions: "descriptions",
46
69
  synonyms: "synonyms",
47
70
  packages: "packages",
71
+ hasInformationUnits: "hasInformationUnits",
48
72
  links: "links"
49
73
  };
50
74
  var AdministrativeMetadataModelFieldsAll = Object.values(AdministrativeMetadataModelFields);
@@ -59,6 +83,24 @@ var AuthStateModelFields = {
59
83
  roles: "roles"
60
84
  };
61
85
  var AuthStateModelFieldsAll = Object.values(AuthStateModelFields);
86
+ var CategoryModelFields = {
87
+ id: "id",
88
+ shortId: "shortId",
89
+ score: "score",
90
+ class: "class",
91
+ labels: "labels",
92
+ comments: "comments",
93
+ descriptions: "descriptions",
94
+ synonyms: "synonyms",
95
+ packages: "packages",
96
+ hasInformationUnits: "hasInformationUnits",
97
+ links: "links",
98
+ parents: "parents",
99
+ ancestors: "ancestors",
100
+ ancestorsOrSelf: "ancestorsOrSelf",
101
+ categories: "categories"
102
+ };
103
+ var CategoryModelFieldsAll = Object.values(CategoryModelFields);
62
104
  var ComponentModelFields = {
63
105
  id: "id",
64
106
  shortId: "shortId",
@@ -69,6 +111,7 @@ var ComponentModelFields = {
69
111
  descriptions: "descriptions",
70
112
  synonyms: "synonyms",
71
113
  packages: "packages",
114
+ hasInformationUnits: "hasInformationUnits",
72
115
  links: "links",
73
116
  productGraphic: "productGraphic",
74
117
  titles: "titles",
@@ -92,6 +135,7 @@ var ContentLifeCycleStatusModelFields = {
92
135
  descriptions: "descriptions",
93
136
  synonyms: "synonyms",
94
137
  packages: "packages",
138
+ hasInformationUnits: "hasInformationUnits",
95
139
  links: "links",
96
140
  dateOfEffect: "dateOfEffect",
97
141
  dateOfExpiry: "dateOfExpiry",
@@ -111,6 +155,7 @@ var ContentLifeCycleStatusValueModelFields = {
111
155
  descriptions: "descriptions",
112
156
  synonyms: "synonyms",
113
157
  packages: "packages",
158
+ hasInformationUnits: "hasInformationUnits",
114
159
  links: "links"
115
160
  };
116
161
  var ContentLifeCycleStatusValueModelFieldsAll = Object.values(ContentLifeCycleStatusValueModelFields);
@@ -124,6 +169,7 @@ var DirectoryNodeModelFields = {
124
169
  descriptions: "descriptions",
125
170
  synonyms: "synonyms",
126
171
  packages: "packages",
172
+ hasInformationUnits: "hasInformationUnits",
127
173
  links: "links",
128
174
  structureType: "structureType",
129
175
  parents: "parents",
@@ -143,6 +189,7 @@ var DirectoryNodeTypeModelFields = {
143
189
  descriptions: "descriptions",
144
190
  synonyms: "synonyms",
145
191
  packages: "packages",
192
+ hasInformationUnits: "hasInformationUnits",
146
193
  links: "links"
147
194
  };
148
195
  var DirectoryNodeTypeModelFieldsAll = Object.values(DirectoryNodeTypeModelFields);
@@ -156,6 +203,7 @@ var DocumentModelFields = {
156
203
  descriptions: "descriptions",
157
204
  synonyms: "synonyms",
158
205
  packages: "packages",
206
+ hasInformationUnits: "hasInformationUnits",
159
207
  links: "links",
160
208
  revision: "revision",
161
209
  created: "created",
@@ -197,6 +245,7 @@ var DocumentTypeModelFields = {
197
245
  descriptions: "descriptions",
198
246
  synonyms: "synonyms",
199
247
  packages: "packages",
248
+ hasInformationUnits: "hasInformationUnits",
200
249
  links: "links"
201
250
  };
202
251
  var DocumentTypeModelFieldsAll = Object.values(DocumentTypeModelFields);
@@ -210,6 +259,7 @@ var DocumentationMetadataModelFields = {
210
259
  descriptions: "descriptions",
211
260
  synonyms: "synonyms",
212
261
  packages: "packages",
262
+ hasInformationUnits: "hasInformationUnits",
213
263
  links: "links"
214
264
  };
215
265
  var DocumentationMetadataModelFieldsAll = Object.values(DocumentationMetadataModelFields);
@@ -222,7 +272,8 @@ var DomainEntityModelFields = {
222
272
  comments: "comments",
223
273
  descriptions: "descriptions",
224
274
  synonyms: "synonyms",
225
- packages: "packages"
275
+ packages: "packages",
276
+ hasInformationUnits: "hasInformationUnits"
226
277
  };
227
278
  var DomainEntityModelFieldsAll = Object.values(DomainEntityModelFields);
228
279
  var EventModelFields = {
@@ -235,6 +286,7 @@ var EventModelFields = {
235
286
  descriptions: "descriptions",
236
287
  synonyms: "synonyms",
237
288
  packages: "packages",
289
+ hasInformationUnits: "hasInformationUnits",
238
290
  links: "links",
239
291
  eventCode: "eventCode",
240
292
  eventType: "eventType"
@@ -250,6 +302,7 @@ var ExternalProductGraphicModelFields = {
250
302
  descriptions: "descriptions",
251
303
  synonyms: "synonyms",
252
304
  packages: "packages",
305
+ hasInformationUnits: "hasInformationUnits",
253
306
  links: "links",
254
307
  revision: "revision",
255
308
  created: "created",
@@ -302,6 +355,7 @@ var FragmentModelFields = {
302
355
  descriptions: "descriptions",
303
356
  synonyms: "synonyms",
304
357
  packages: "packages",
358
+ hasInformationUnits: "hasInformationUnits",
305
359
  links: "links",
306
360
  revision: "revision",
307
361
  created: "created",
@@ -343,6 +397,7 @@ var FunctionalMetadataModelFields = {
343
397
  descriptions: "descriptions",
344
398
  synonyms: "synonyms",
345
399
  packages: "packages",
400
+ hasInformationUnits: "hasInformationUnits",
346
401
  links: "links"
347
402
  };
348
403
  var FunctionalMetadataModelFieldsAll = Object.values(FunctionalMetadataModelFields);
@@ -356,6 +411,7 @@ var IdentityDomainModelFields = {
356
411
  descriptions: "descriptions",
357
412
  synonyms: "synonyms",
358
413
  packages: "packages",
414
+ hasInformationUnits: "hasInformationUnits",
359
415
  links: "links",
360
416
  parties: "parties"
361
417
  };
@@ -370,6 +426,7 @@ var IdentityModelFields = {
370
426
  descriptions: "descriptions",
371
427
  synonyms: "synonyms",
372
428
  packages: "packages",
429
+ hasInformationUnits: "hasInformationUnits",
373
430
  links: "links",
374
431
  identifier: "identifier",
375
432
  identityDomain: "identityDomain"
@@ -385,6 +442,7 @@ var InformationObjectModelFields = {
385
442
  descriptions: "descriptions",
386
443
  synonyms: "synonyms",
387
444
  packages: "packages",
445
+ hasInformationUnits: "hasInformationUnits",
388
446
  links: "links",
389
447
  identities: "identities"
390
448
  };
@@ -399,6 +457,7 @@ var InformationSubjectCollectionModelFields = {
399
457
  descriptions: "descriptions",
400
458
  synonyms: "synonyms",
401
459
  packages: "packages",
460
+ hasInformationUnits: "hasInformationUnits",
402
461
  links: "links"
403
462
  };
404
463
  var InformationSubjectCollectionModelFieldsAll = Object.values(InformationSubjectCollectionModelFields);
@@ -412,6 +471,7 @@ var InformationSubjectConformityModelFields = {
412
471
  descriptions: "descriptions",
413
472
  synonyms: "synonyms",
414
473
  packages: "packages",
474
+ hasInformationUnits: "hasInformationUnits",
415
475
  links: "links"
416
476
  };
417
477
  var InformationSubjectConformityModelFieldsAll = Object.values(InformationSubjectConformityModelFields);
@@ -425,6 +485,7 @@ var InformationSubjectFormalityModelFields = {
425
485
  descriptions: "descriptions",
426
486
  synonyms: "synonyms",
427
487
  packages: "packages",
488
+ hasInformationUnits: "hasInformationUnits",
428
489
  links: "links"
429
490
  };
430
491
  var InformationSubjectFormalityModelFieldsAll = Object.values(InformationSubjectFormalityModelFields);
@@ -438,6 +499,7 @@ var InformationSubjectFunctionalityModelFields = {
438
499
  descriptions: "descriptions",
439
500
  synonyms: "synonyms",
440
501
  packages: "packages",
502
+ hasInformationUnits: "hasInformationUnits",
441
503
  links: "links"
442
504
  };
443
505
  var InformationSubjectFunctionalityModelFieldsAll = Object.values(InformationSubjectFunctionalityModelFields);
@@ -451,6 +513,7 @@ var InformationSubjectModelFields = {
451
513
  descriptions: "descriptions",
452
514
  synonyms: "synonyms",
453
515
  packages: "packages",
516
+ hasInformationUnits: "hasInformationUnits",
454
517
  links: "links"
455
518
  };
456
519
  var InformationSubjectModelFieldsAll = Object.values(InformationSubjectModelFields);
@@ -464,6 +527,7 @@ var InformationSubjectProcessModelFields = {
464
527
  descriptions: "descriptions",
465
528
  synonyms: "synonyms",
466
529
  packages: "packages",
530
+ hasInformationUnits: "hasInformationUnits",
467
531
  links: "links"
468
532
  };
469
533
  var InformationSubjectProcessModelFieldsAll = Object.values(InformationSubjectProcessModelFields);
@@ -477,6 +541,7 @@ var InformationSubjectSafetyModelFields = {
477
541
  descriptions: "descriptions",
478
542
  synonyms: "synonyms",
479
543
  packages: "packages",
544
+ hasInformationUnits: "hasInformationUnits",
480
545
  links: "links"
481
546
  };
482
547
  var InformationSubjectSafetyModelFieldsAll = Object.values(InformationSubjectSafetyModelFields);
@@ -490,6 +555,7 @@ var InformationSubjectSafetyWarningMessageModelFields = {
490
555
  descriptions: "descriptions",
491
556
  synonyms: "synonyms",
492
557
  packages: "packages",
558
+ hasInformationUnits: "hasInformationUnits",
493
559
  links: "links"
494
560
  };
495
561
  var InformationSubjectSafetyWarningMessageModelFieldsAll = Object.values(InformationSubjectSafetyWarningMessageModelFields);
@@ -503,6 +569,7 @@ var InformationSubjectTechnicalDataModelFields = {
503
569
  descriptions: "descriptions",
504
570
  synonyms: "synonyms",
505
571
  packages: "packages",
572
+ hasInformationUnits: "hasInformationUnits",
506
573
  links: "links"
507
574
  };
508
575
  var InformationSubjectTechnicalDataModelFieldsAll = Object.values(InformationSubjectTechnicalDataModelFields);
@@ -516,6 +583,7 @@ var InformationSubjectTechnicalOverviewModelFields = {
516
583
  descriptions: "descriptions",
517
584
  synonyms: "synonyms",
518
585
  packages: "packages",
586
+ hasInformationUnits: "hasInformationUnits",
519
587
  links: "links"
520
588
  };
521
589
  var InformationSubjectTechnicalOverviewModelFieldsAll = Object.values(InformationSubjectTechnicalOverviewModelFields);
@@ -529,6 +597,7 @@ var InformationTypeModelFields = {
529
597
  descriptions: "descriptions",
530
598
  synonyms: "synonyms",
531
599
  packages: "packages",
600
+ hasInformationUnits: "hasInformationUnits",
532
601
  links: "links"
533
602
  };
534
603
  var InformationTypeModelFieldsAll = Object.values(InformationTypeModelFields);
@@ -542,6 +611,7 @@ var InformationUnitModelFields = {
542
611
  descriptions: "descriptions",
543
612
  synonyms: "synonyms",
544
613
  packages: "packages",
614
+ hasInformationUnits: "hasInformationUnits",
545
615
  links: "links",
546
616
  revision: "revision",
547
617
  created: "created",
@@ -582,7 +652,8 @@ var OwlClassModelFields = {
582
652
  comments: "comments",
583
653
  descriptions: "descriptions",
584
654
  synonyms: "synonyms",
585
- packages: "packages"
655
+ packages: "packages",
656
+ hasInformationUnits: "hasInformationUnits"
586
657
  };
587
658
  var OwlClassModelFieldsAll = Object.values(OwlClassModelFields);
588
659
  var PackageModelFields = {
@@ -595,6 +666,7 @@ var PackageModelFields = {
595
666
  descriptions: "descriptions",
596
667
  synonyms: "synonyms",
597
668
  packages: "packages",
669
+ hasInformationUnits: "hasInformationUnits",
598
670
  links: "links",
599
671
  revision: "revision",
600
672
  created: "created",
@@ -639,6 +711,7 @@ var PartyModelFields = {
639
711
  descriptions: "descriptions",
640
712
  synonyms: "synonyms",
641
713
  packages: "packages",
714
+ hasInformationUnits: "hasInformationUnits",
642
715
  links: "links",
643
716
  partyRole: "partyRole",
644
717
  vcard: "vcard"
@@ -654,6 +727,7 @@ var PartyRoleModelFields = {
654
727
  descriptions: "descriptions",
655
728
  synonyms: "synonyms",
656
729
  packages: "packages",
730
+ hasInformationUnits: "hasInformationUnits",
657
731
  links: "links"
658
732
  };
659
733
  var PartyRoleModelFieldsAll = Object.values(PartyRoleModelFields);
@@ -667,6 +741,7 @@ var PlanningDownTimeModelFields = {
667
741
  descriptions: "descriptions",
668
742
  synonyms: "synonyms",
669
743
  packages: "packages",
744
+ hasInformationUnits: "hasInformationUnits",
670
745
  links: "links",
671
746
  duration: "duration"
672
747
  };
@@ -681,6 +756,7 @@ var PlanningMaintenanceIntervalModelFields = {
681
756
  descriptions: "descriptions",
682
757
  synonyms: "synonyms",
683
758
  packages: "packages",
759
+ hasInformationUnits: "hasInformationUnits",
684
760
  links: "links",
685
761
  duration: "duration",
686
762
  frequency: "frequency"
@@ -696,6 +772,7 @@ var PlanningSetupTimeModelFields = {
696
772
  descriptions: "descriptions",
697
773
  synonyms: "synonyms",
698
774
  packages: "packages",
775
+ hasInformationUnits: "hasInformationUnits",
699
776
  links: "links",
700
777
  duration: "duration"
701
778
  };
@@ -710,6 +787,7 @@ var PlanningTimeModelFields = {
710
787
  descriptions: "descriptions",
711
788
  synonyms: "synonyms",
712
789
  packages: "packages",
790
+ hasInformationUnits: "hasInformationUnits",
713
791
  links: "links",
714
792
  duration: "duration"
715
793
  };
@@ -724,6 +802,7 @@ var PlanningWorkingTimeModelFields = {
724
802
  descriptions: "descriptions",
725
803
  synonyms: "synonyms",
726
804
  packages: "packages",
805
+ hasInformationUnits: "hasInformationUnits",
727
806
  links: "links",
728
807
  duration: "duration"
729
808
  };
@@ -738,6 +817,7 @@ var ProductFeatureModelFields = {
738
817
  descriptions: "descriptions",
739
818
  synonyms: "synonyms",
740
819
  packages: "packages",
820
+ hasInformationUnits: "hasInformationUnits",
741
821
  links: "links"
742
822
  };
743
823
  var ProductFeatureModelFieldsAll = Object.values(ProductFeatureModelFields);
@@ -751,6 +831,7 @@ var ProductFunctionModelFields = {
751
831
  descriptions: "descriptions",
752
832
  synonyms: "synonyms",
753
833
  packages: "packages",
834
+ hasInformationUnits: "hasInformationUnits",
754
835
  links: "links"
755
836
  };
756
837
  var ProductFunctionModelFieldsAll = Object.values(ProductFunctionModelFields);
@@ -764,6 +845,7 @@ var ProductLcpAfterUseModelFields = {
764
845
  descriptions: "descriptions",
765
846
  synonyms: "synonyms",
766
847
  packages: "packages",
848
+ hasInformationUnits: "hasInformationUnits",
767
849
  links: "links"
768
850
  };
769
851
  var ProductLcpAfterUseModelFieldsAll = Object.values(ProductLcpAfterUseModelFields);
@@ -777,6 +859,7 @@ var ProductLcpDesignAndRealizationModelFields = {
777
859
  descriptions: "descriptions",
778
860
  synonyms: "synonyms",
779
861
  packages: "packages",
862
+ hasInformationUnits: "hasInformationUnits",
780
863
  links: "links"
781
864
  };
782
865
  var ProductLcpDesignAndRealizationModelFieldsAll = Object.values(ProductLcpDesignAndRealizationModelFields);
@@ -790,6 +873,7 @@ var ProductLcpPuttingToUseModelFields = {
790
873
  descriptions: "descriptions",
791
874
  synonyms: "synonyms",
792
875
  packages: "packages",
876
+ hasInformationUnits: "hasInformationUnits",
793
877
  links: "links"
794
878
  };
795
879
  var ProductLcpPuttingToUseModelFieldsAll = Object.values(ProductLcpPuttingToUseModelFields);
@@ -803,6 +887,7 @@ var ProductLcpUseModelFields = {
803
887
  descriptions: "descriptions",
804
888
  synonyms: "synonyms",
805
889
  packages: "packages",
890
+ hasInformationUnits: "hasInformationUnits",
806
891
  links: "links"
807
892
  };
808
893
  var ProductLcpUseModelFieldsAll = Object.values(ProductLcpUseModelFields);
@@ -816,6 +901,7 @@ var ProductLifeCyclePhaseModelFields = {
816
901
  descriptions: "descriptions",
817
902
  synonyms: "synonyms",
818
903
  packages: "packages",
904
+ hasInformationUnits: "hasInformationUnits",
819
905
  links: "links"
820
906
  };
821
907
  var ProductLifeCyclePhaseModelFieldsAll = Object.values(ProductLifeCyclePhaseModelFields);
@@ -829,6 +915,7 @@ var ProductMetadataModelFields = {
829
915
  descriptions: "descriptions",
830
916
  synonyms: "synonyms",
831
917
  packages: "packages",
918
+ hasInformationUnits: "hasInformationUnits",
832
919
  links: "links"
833
920
  };
834
921
  var ProductMetadataModelFieldsAll = Object.values(ProductMetadataModelFields);
@@ -842,6 +929,7 @@ var ProductPropertyModelFields = {
842
929
  descriptions: "descriptions",
843
930
  synonyms: "synonyms",
844
931
  packages: "packages",
932
+ hasInformationUnits: "hasInformationUnits",
845
933
  links: "links"
846
934
  };
847
935
  var ProductPropertyModelFieldsAll = Object.values(ProductPropertyModelFields);
@@ -855,6 +943,7 @@ var ProductVariantModelFields = {
855
943
  descriptions: "descriptions",
856
944
  synonyms: "synonyms",
857
945
  packages: "packages",
946
+ hasInformationUnits: "hasInformationUnits",
858
947
  links: "links",
859
948
  identities: "identities",
860
949
  parties: "parties"
@@ -870,6 +959,7 @@ var QualificationModelFields = {
870
959
  descriptions: "descriptions",
871
960
  synonyms: "synonyms",
872
961
  packages: "packages",
962
+ hasInformationUnits: "hasInformationUnits",
873
963
  links: "links"
874
964
  };
875
965
  var QualificationModelFieldsAll = Object.values(QualificationModelFields);
@@ -883,6 +973,7 @@ var QualificationRoleModelFields = {
883
973
  descriptions: "descriptions",
884
974
  synonyms: "synonyms",
885
975
  packages: "packages",
976
+ hasInformationUnits: "hasInformationUnits",
886
977
  links: "links"
887
978
  };
888
979
  var QualificationRoleModelFieldsAll = Object.values(QualificationRoleModelFields);
@@ -896,6 +987,7 @@ var QualificationSkillLevelModelFields = {
896
987
  descriptions: "descriptions",
897
988
  synonyms: "synonyms",
898
989
  packages: "packages",
990
+ hasInformationUnits: "hasInformationUnits",
899
991
  links: "links"
900
992
  };
901
993
  var QualificationSkillLevelModelFieldsAll = Object.values(QualificationSkillLevelModelFields);
@@ -909,6 +1001,7 @@ var RenditionModelFields = {
909
1001
  descriptions: "descriptions",
910
1002
  synonyms: "synonyms",
911
1003
  packages: "packages",
1004
+ hasInformationUnits: "hasInformationUnits",
912
1005
  links: "links",
913
1006
  source: "source",
914
1007
  format: "format",
@@ -926,7 +1019,8 @@ var RenditionSelectorModelFields = {
926
1019
  comments: "comments",
927
1020
  descriptions: "descriptions",
928
1021
  synonyms: "synonyms",
929
- packages: "packages"
1022
+ packages: "packages",
1023
+ hasInformationUnits: "hasInformationUnits"
930
1024
  };
931
1025
  var RenditionSelectorModelFieldsAll = Object.values(RenditionSelectorModelFields);
932
1026
  var SupplyConsumableModelFields = {
@@ -939,6 +1033,7 @@ var SupplyConsumableModelFields = {
939
1033
  descriptions: "descriptions",
940
1034
  synonyms: "synonyms",
941
1035
  packages: "packages",
1036
+ hasInformationUnits: "hasInformationUnits",
942
1037
  links: "links"
943
1038
  };
944
1039
  var SupplyConsumableModelFieldsAll = Object.values(SupplyConsumableModelFields);
@@ -952,6 +1047,7 @@ var SupplyHardwareToolModelFields = {
952
1047
  descriptions: "descriptions",
953
1048
  synonyms: "synonyms",
954
1049
  packages: "packages",
1050
+ hasInformationUnits: "hasInformationUnits",
955
1051
  links: "links"
956
1052
  };
957
1053
  var SupplyHardwareToolModelFieldsAll = Object.values(SupplyHardwareToolModelFields);
@@ -965,6 +1061,7 @@ var SupplyLubricantModelFields = {
965
1061
  descriptions: "descriptions",
966
1062
  synonyms: "synonyms",
967
1063
  packages: "packages",
1064
+ hasInformationUnits: "hasInformationUnits",
968
1065
  links: "links"
969
1066
  };
970
1067
  var SupplyLubricantModelFieldsAll = Object.values(SupplyLubricantModelFields);
@@ -978,6 +1075,7 @@ var SupplyModelFields = {
978
1075
  descriptions: "descriptions",
979
1076
  synonyms: "synonyms",
980
1077
  packages: "packages",
1078
+ hasInformationUnits: "hasInformationUnits",
981
1079
  links: "links"
982
1080
  };
983
1081
  var SupplyModelFieldsAll = Object.values(SupplyModelFields);
@@ -991,6 +1089,7 @@ var SupplyOperatingModelFields = {
991
1089
  descriptions: "descriptions",
992
1090
  synonyms: "synonyms",
993
1091
  packages: "packages",
1092
+ hasInformationUnits: "hasInformationUnits",
994
1093
  links: "links"
995
1094
  };
996
1095
  var SupplyOperatingModelFieldsAll = Object.values(SupplyOperatingModelFields);
@@ -1004,6 +1103,7 @@ var SupplySparePartModelFields = {
1004
1103
  descriptions: "descriptions",
1005
1104
  synonyms: "synonyms",
1006
1105
  packages: "packages",
1106
+ hasInformationUnits: "hasInformationUnits",
1007
1107
  links: "links"
1008
1108
  };
1009
1109
  var SupplySparePartModelFieldsAll = Object.values(SupplySparePartModelFields);
@@ -1017,6 +1117,7 @@ var TopicModelFields = {
1017
1117
  descriptions: "descriptions",
1018
1118
  synonyms: "synonyms",
1019
1119
  packages: "packages",
1120
+ hasInformationUnits: "hasInformationUnits",
1020
1121
  links: "links",
1021
1122
  revision: "revision",
1022
1123
  created: "created",
@@ -1058,6 +1159,7 @@ var TopicTypeConceptModelFields = {
1058
1159
  descriptions: "descriptions",
1059
1160
  synonyms: "synonyms",
1060
1161
  packages: "packages",
1162
+ hasInformationUnits: "hasInformationUnits",
1061
1163
  links: "links"
1062
1164
  };
1063
1165
  var TopicTypeConceptModelFieldsAll = Object.values(TopicTypeConceptModelFields);
@@ -1071,6 +1173,7 @@ var TopicTypeFormModelFields = {
1071
1173
  descriptions: "descriptions",
1072
1174
  synonyms: "synonyms",
1073
1175
  packages: "packages",
1176
+ hasInformationUnits: "hasInformationUnits",
1074
1177
  links: "links"
1075
1178
  };
1076
1179
  var TopicTypeFormModelFieldsAll = Object.values(TopicTypeFormModelFields);
@@ -1084,6 +1187,7 @@ var TopicTypeLearningModelFields = {
1084
1187
  descriptions: "descriptions",
1085
1188
  synonyms: "synonyms",
1086
1189
  packages: "packages",
1190
+ hasInformationUnits: "hasInformationUnits",
1087
1191
  links: "links"
1088
1192
  };
1089
1193
  var TopicTypeLearningModelFieldsAll = Object.values(TopicTypeLearningModelFields);
@@ -1097,6 +1201,7 @@ var TopicTypeModelFields = {
1097
1201
  descriptions: "descriptions",
1098
1202
  synonyms: "synonyms",
1099
1203
  packages: "packages",
1204
+ hasInformationUnits: "hasInformationUnits",
1100
1205
  links: "links"
1101
1206
  };
1102
1207
  var TopicTypeModelFieldsAll = Object.values(TopicTypeModelFields);
@@ -1110,6 +1215,7 @@ var TopicTypeReferenceModelFields = {
1110
1215
  descriptions: "descriptions",
1111
1216
  synonyms: "synonyms",
1112
1217
  packages: "packages",
1218
+ hasInformationUnits: "hasInformationUnits",
1113
1219
  links: "links"
1114
1220
  };
1115
1221
  var TopicTypeReferenceModelFieldsAll = Object.values(TopicTypeReferenceModelFields);
@@ -1123,6 +1229,7 @@ var TopicTypeTaskModelFields = {
1123
1229
  descriptions: "descriptions",
1124
1230
  synonyms: "synonyms",
1125
1231
  packages: "packages",
1232
+ hasInformationUnits: "hasInformationUnits",
1126
1233
  links: "links"
1127
1234
  };
1128
1235
  var TopicTypeTaskModelFieldsAll = Object.values(TopicTypeTaskModelFields);
@@ -1136,6 +1243,7 @@ var TopicTypeTroubleShootingModelFields = {
1136
1243
  descriptions: "descriptions",
1137
1244
  synonyms: "synonyms",
1138
1245
  packages: "packages",
1246
+ hasInformationUnits: "hasInformationUnits",
1139
1247
  links: "links"
1140
1248
  };
1141
1249
  var TopicTypeTroubleShootingModelFieldsAll = Object.values(TopicTypeTroubleShootingModelFields);
@@ -1149,6 +1257,7 @@ var VCardCalendarModelFields = {
1149
1257
  descriptions: "descriptions",
1150
1258
  synonyms: "synonyms",
1151
1259
  packages: "packages",
1260
+ hasInformationUnits: "hasInformationUnits",
1152
1261
  source: "source"
1153
1262
  };
1154
1263
  var VCardCalendarModelFieldsAll = Object.values(VCardCalendarModelFields);
@@ -1162,6 +1271,7 @@ var VCardGroupModelFields = {
1162
1271
  descriptions: "descriptions",
1163
1272
  synonyms: "synonyms",
1164
1273
  packages: "packages",
1274
+ hasInformationUnits: "hasInformationUnits",
1165
1275
  links: "links",
1166
1276
  fullName: "fullName",
1167
1277
  photos: "photos",
@@ -1183,6 +1293,7 @@ var VCardImageModelFields = {
1183
1293
  descriptions: "descriptions",
1184
1294
  synonyms: "synonyms",
1185
1295
  packages: "packages",
1296
+ hasInformationUnits: "hasInformationUnits",
1186
1297
  classes: "classes",
1187
1298
  value: "value",
1188
1299
  source: "source"
@@ -1198,6 +1309,7 @@ var VCardIndividualModelFields = {
1198
1309
  descriptions: "descriptions",
1199
1310
  synonyms: "synonyms",
1200
1311
  packages: "packages",
1312
+ hasInformationUnits: "hasInformationUnits",
1201
1313
  links: "links",
1202
1314
  fullName: "fullName",
1203
1315
  photos: "photos",
@@ -1216,6 +1328,7 @@ var VCardInfoModelFields = {
1216
1328
  shortId: "shortId",
1217
1329
  score: "score",
1218
1330
  classes: "classes",
1331
+ types: "types",
1219
1332
  value: "value",
1220
1333
  countryName: "countryName",
1221
1334
  locality: "locality",
@@ -1233,6 +1346,7 @@ var VCardLocationModelFields = {
1233
1346
  descriptions: "descriptions",
1234
1347
  synonyms: "synonyms",
1235
1348
  packages: "packages",
1349
+ hasInformationUnits: "hasInformationUnits",
1236
1350
  links: "links",
1237
1351
  fullName: "fullName",
1238
1352
  photos: "photos",
@@ -1254,6 +1368,7 @@ var VCardModelFields = {
1254
1368
  descriptions: "descriptions",
1255
1369
  synonyms: "synonyms",
1256
1370
  packages: "packages",
1371
+ hasInformationUnits: "hasInformationUnits",
1257
1372
  links: "links",
1258
1373
  fullName: "fullName",
1259
1374
  photos: "photos",
@@ -1274,6 +1389,7 @@ var VCardOrganizationModelFields = {
1274
1389
  descriptions: "descriptions",
1275
1390
  synonyms: "synonyms",
1276
1391
  packages: "packages",
1392
+ hasInformationUnits: "hasInformationUnits",
1277
1393
  links: "links",
1278
1394
  fullName: "fullName",
1279
1395
  photos: "photos",
@@ -1304,15 +1420,24 @@ var CREX_TOKEN_HEADER_KEY = "crex-token";
1304
1420
 
1305
1421
  // src/requests.ts
1306
1422
  var import_headers2 = require("next/headers");
1423
+ var import_cache = require("next/cache");
1424
+ var import_server = require("next/server");
1425
+ var import_fs3 = require("fs");
1426
+ var import_path = require("path");
1307
1427
 
1308
1428
  // src/logger.ts
1309
1429
  var import_winston = __toESM(require("winston"));
1310
1430
 
1311
1431
  // src/transports/matomo.ts
1312
1432
  var import_winston_transport = __toESM(require("winston-transport"));
1433
+ var import_axios = __toESM(require("axios"));
1434
+ var import_https = __toESM(require("https"));
1435
+ var import_fs = require("fs");
1313
1436
  var MatomoTransport = class extends import_winston_transport.default {
1314
- matomoTransport;
1315
1437
  configs;
1438
+ endpointUrl;
1439
+ httpsAgent;
1440
+ enabled;
1316
1441
  /**
1317
1442
  * Creates a new instance of MatomoTransport.
1318
1443
  *
@@ -1323,8 +1448,18 @@ var MatomoTransport = class extends import_winston_transport.default {
1323
1448
  level: configs.logs.matomo.minimumLevel,
1324
1449
  silent: configs.logs.matomo.silent
1325
1450
  });
1326
- this.matomoTransport = new import_winston_transport.default();
1327
1451
  this.configs = configs;
1452
+ const rawHost = configs.logs.matomo.hostname?.trim();
1453
+ this.enabled = !!rawHost;
1454
+ const normalizedHost = rawHost ? rawHost.replace(/^https?:\/\//i, "") : "";
1455
+ const hasPort = typeof configs.logs.matomo.port === "number" && configs.logs.matomo.port > 0;
1456
+ this.endpointUrl = this.enabled ? `https://${normalizedHost}${hasPort ? `:${configs.logs.matomo.port}` : ""}/matomo.php` : "";
1457
+ const rejectUnauthorized = process.env.LOG_MATOMO_TLS_REJECT_UNAUTHORIZED !== "false";
1458
+ const caFile = process.env.LOG_MATOMO_TLS_CA_FILE?.trim();
1459
+ this.httpsAgent = new import_https.default.Agent({
1460
+ rejectUnauthorized,
1461
+ ca: caFile ? (0, import_fs.readFileSync)(caFile) : void 0
1462
+ });
1328
1463
  }
1329
1464
  /**
1330
1465
  * Logs a message to Matomo if the message category is included in the configured categories.
@@ -1334,18 +1469,67 @@ var MatomoTransport = class extends import_winston_transport.default {
1334
1469
  */
1335
1470
  log(info, callback) {
1336
1471
  const matomoCategory = this.configs.logs.matomo.categoriesLevel;
1337
- if (matomoCategory.includes(info.category) || matomoCategory.includes(ALL)) {
1338
- this.matomoTransport.log(info, callback);
1472
+ const category = info.category ?? "Scenario";
1473
+ if (!info.category || matomoCategory.includes(info.category) || matomoCategory.includes(ALL)) {
1474
+ if (!this.enabled) {
1475
+ callback();
1476
+ return;
1477
+ }
1478
+ const siteId = this.configs.logs.matomo.siteId ?? 1;
1479
+ const tokenAuth = this.configs.logs.matomo.tokenAuth;
1480
+ const requestParams = new URLSearchParams({
1481
+ idsite: String(siteId),
1482
+ rec: "1",
1483
+ apiv: "1",
1484
+ action_name: info.message,
1485
+ e_c: category,
1486
+ e_a: info.level,
1487
+ e_n: info.message.slice(0, 120),
1488
+ url: process.env.NEXT_PUBLIC_API_URL || process.env.NEXT_URL || this.configs.baseUrl,
1489
+ rand: `${Date.now()}`,
1490
+ cdh: "0",
1491
+ cdm: "0",
1492
+ cds: "0"
1493
+ });
1494
+ if (tokenAuth && tokenAuth.trim().length > 0) {
1495
+ requestParams.append("token_auth", tokenAuth.trim());
1496
+ }
1497
+ void import_axios.default.post(this.endpointUrl, requestParams.toString(), {
1498
+ timeout: 4e3,
1499
+ httpsAgent: this.httpsAgent,
1500
+ headers: {
1501
+ "Content-Type": "application/x-www-form-urlencoded"
1502
+ }
1503
+ }).catch((error) => {
1504
+ const message = error instanceof Error ? error.message : String(error);
1505
+ console.error(`[MatomoTransport] Failed to post log to ${this.endpointUrl}: ${message}`);
1506
+ });
1507
+ callback();
1508
+ return;
1339
1509
  }
1510
+ callback();
1340
1511
  }
1341
1512
  };
1342
1513
 
1343
1514
  // src/transports/graylog.ts
1344
1515
  var import_winston_transport2 = __toESM(require("winston-transport"));
1345
- var import_winston_graylog2 = __toESM(require("winston-graylog2"));
1516
+ var import_axios2 = __toESM(require("axios"));
1517
+ var import_https2 = __toESM(require("https"));
1518
+ var import_fs2 = require("fs");
1346
1519
  var GraylogTransport = class extends import_winston_transport2.default {
1347
- graylogTransport;
1348
1520
  configs;
1521
+ endpointUrl;
1522
+ httpsAgent;
1523
+ levelToSyslog = {
1524
+ critical: 2,
1525
+ error: 3,
1526
+ warning: 4,
1527
+ info: 6,
1528
+ debug: 7
1529
+ };
1530
+ resolveDomain() {
1531
+ return process.env.NEXT_PUBLIC_API_URL?.trim() || process.env.NEXT_URL?.trim() || this.configs.baseUrl;
1532
+ }
1349
1533
  /**
1350
1534
  * Creates a new instance of GraylogTransport.
1351
1535
  *
@@ -1355,20 +1539,18 @@ var GraylogTransport = class extends import_winston_transport2.default {
1355
1539
  if (!configs.logs.graylog.hostname || configs.logs.graylog.port === void 0) {
1356
1540
  throw new Error("Graylog hostname and port must be defined");
1357
1541
  }
1542
+ const normalizedHost = configs.logs.graylog.hostname.replace(/^https?:\/\//i, "");
1358
1543
  super({
1359
1544
  level: configs.logs.graylog.minimumLevel,
1360
1545
  silent: configs.logs.graylog.silent
1361
1546
  });
1362
1547
  this.configs = configs;
1363
- this.graylogTransport = new import_winston_graylog2.default({
1364
- name: configs.logs.graylog.app,
1365
- silent: configs.logs.graylog.silent,
1366
- handleExceptions: false,
1367
- graylog: {
1368
- servers: [
1369
- { host: configs.logs.graylog.hostname, port: configs.logs.graylog.port }
1370
- ]
1371
- }
1548
+ this.endpointUrl = `https://${normalizedHost}:${configs.logs.graylog.port}/gelf`;
1549
+ const rejectUnauthorized = process.env.LOG_GRAYLOG_TLS_REJECT_UNAUTHORIZED !== "false";
1550
+ const caFile = process.env.LOG_GRAYLOG_TLS_CA_FILE?.trim();
1551
+ this.httpsAgent = new import_https2.default.Agent({
1552
+ rejectUnauthorized,
1553
+ ca: caFile ? (0, import_fs2.readFileSync)(caFile) : void 0
1372
1554
  });
1373
1555
  }
1374
1556
  /**
@@ -1379,9 +1561,40 @@ var GraylogTransport = class extends import_winston_transport2.default {
1379
1561
  */
1380
1562
  log(info, callback) {
1381
1563
  const graylogCategory = this.configs.logs.graylog.categoriesLevel;
1382
- if (graylogCategory.includes(info.category) || graylogCategory.includes(ALL)) {
1383
- this.graylogTransport.log(info, callback);
1564
+ if (!info.category || graylogCategory.includes(info.category) || graylogCategory.includes(ALL)) {
1565
+ const timestamp = /* @__PURE__ */ new Date();
1566
+ const level = String(info.level).toLowerCase();
1567
+ const syslogLevel = this.levelToSyslog[level] ?? 6;
1568
+ const category = info.category ?? "Scenario";
1569
+ void import_axios2.default.post(this.endpointUrl, {
1570
+ // GELF-compatible core fields
1571
+ version: "1.1",
1572
+ host: this.configs.logs.graylog.app,
1573
+ short_message: info.message,
1574
+ full_message: info.message,
1575
+ timestamp: timestamp.getTime() / 1e3,
1576
+ level: syslogLevel,
1577
+ facility: this.configs.logs.graylog.app,
1578
+ // Legacy/classic compatibility fields
1579
+ message: info.message,
1580
+ stringLevel: level,
1581
+ category,
1582
+ Application: this.configs.logs.graylog.app,
1583
+ Domain: this.resolveDomain()
1584
+ }, {
1585
+ timeout: 4e3,
1586
+ httpsAgent: this.httpsAgent,
1587
+ headers: {
1588
+ "Content-Type": "application/json"
1589
+ }
1590
+ }).catch((error) => {
1591
+ const message = error instanceof Error ? error.message : String(error);
1592
+ console.error(`[GraylogTransport] Failed to post log to ${this.endpointUrl}: ${message}`);
1593
+ });
1594
+ callback();
1595
+ return;
1384
1596
  }
1597
+ callback();
1385
1598
  }
1386
1599
  };
1387
1600
 
@@ -1428,6 +1641,23 @@ var generateWarnings = (vars) => {
1428
1641
  });
1429
1642
  return warnings;
1430
1643
  };
1644
+ var normalizeGraylogHostname = (rawHostname) => {
1645
+ if (!rawHostname) return void 0;
1646
+ const trimmed = rawHostname.trim();
1647
+ if (trimmed.length === 0) return void 0;
1648
+ if (trimmed.includes("://")) {
1649
+ try {
1650
+ return new URL(trimmed).hostname;
1651
+ } catch {
1652
+ return trimmed;
1653
+ }
1654
+ }
1655
+ const firstColon = trimmed.indexOf(":");
1656
+ if (firstColon > -1 && !trimmed.includes("]")) {
1657
+ return trimmed.slice(0, firstColon);
1658
+ }
1659
+ return trimmed;
1660
+ };
1431
1661
  var createUserOIDCConfig = () => {
1432
1662
  const warnings = [];
1433
1663
  const userDefaults = {
@@ -1531,17 +1761,17 @@ var createGraylogLoggerConfig = (projectName) => {
1531
1761
  app: `NextJs-Project-${projectName}`,
1532
1762
  minimumLevel: "info",
1533
1763
  silent: false,
1534
- hostname: "https://log.c-rex.net",
1764
+ hostname: "log.c-rex.net",
1535
1765
  port: 12202,
1536
1766
  categoriesLevel: ["NoLicense", "Scenario", "Document", "Search", "Notification", "History", "UserProfile"]
1537
1767
  };
1538
1768
  const graylogEnvs = {
1539
1769
  app: process.env.LOG_GRAYLOG_APP_NAME,
1540
1770
  silent: process.env.LOG_GRAYLOG_SILENT == void 0 ? void 0 : process.env.LOG_GRAYLOG_SILENT == "true",
1541
- hostname: process.env.LOG_GRAYLOG_HOSTNAME,
1771
+ hostname: normalizeGraylogHostname(process.env.LOG_GRAYLOG_HOSTNAME),
1542
1772
  port: process.env.LOG_GRAYLOG_PORT == void 0 ? void 0 : Number(process.env.LOG_GRAYLOG_PORT),
1543
1773
  minimumLevel: process.env.LOG_GRAYLOG_LEVEL,
1544
- categoriesLevel: process.env.LOG_GRAYLOG_CATEGORIES == void 0 ? void 0 : process.env.LOG_GRAYLOG_CATEGORIES.split(",")
1774
+ categoriesLevel: process.env.LOG_GRAYLOG_CATEGORIES == void 0 ? void 0 : process.env.LOG_GRAYLOG_CATEGORIES.split(",").map((entry) => entry.trim()).filter((entry) => entry.length > 0)
1545
1775
  };
1546
1776
  const graylog = mergeConfigs(graylogDefaults, graylogEnvs);
1547
1777
  if (graylog.silent == false) {
@@ -1569,21 +1799,26 @@ var createMatomoLoggerConfig = (projectName) => {
1569
1799
  silent: true,
1570
1800
  hostname: "",
1571
1801
  port: 0,
1802
+ siteId: 1,
1803
+ tokenAuth: void 0,
1572
1804
  categoriesLevel: ["NoLicense", "Scenario", "Document", "Search", "Notification", "History", "UserProfile"]
1573
1805
  };
1574
1806
  const matomoEnvs = {
1575
1807
  app: process.env.LOG_MATOMO_APP_NAME,
1576
1808
  silent: process.env.LOG_MATOMO_SILENT == void 0 ? void 0 : process.env.LOG_MATOMO_SILENT == "true",
1577
- hostname: process.env.LOG_MATOMO_HOSTNAME,
1809
+ hostname: normalizeGraylogHostname(process.env.LOG_MATOMO_HOSTNAME),
1578
1810
  port: process.env.LOG_MATOMO_PORT == void 0 ? void 0 : Number(process.env.LOG_MATOMO_PORT),
1811
+ siteId: process.env.LOG_MATOMO_SITE_ID == void 0 ? void 0 : Number(process.env.LOG_MATOMO_SITE_ID),
1812
+ tokenAuth: process.env.LOG_MATOMO_TOKEN_AUTH,
1579
1813
  minimumLevel: process.env.LOG_MATOMO_LEVEL,
1580
- categoriesLevel: process.env.LOG_MATOMO_CATEGORIES == void 0 ? void 0 : process.env.LOG_MATOMO_CATEGORIES.split(",")
1814
+ categoriesLevel: process.env.LOG_MATOMO_CATEGORIES == void 0 ? void 0 : process.env.LOG_MATOMO_CATEGORIES.split(",").map((entry) => entry.trim()).filter((entry) => entry.length > 0)
1581
1815
  };
1582
1816
  const matomo = mergeConfigs(matomoDefaults, matomoEnvs);
1583
1817
  const matomoSilentVars = [
1584
1818
  { key: "LOG_MATOMO_SILENT", value: process.env.LOG_MATOMO_SILENT },
1585
1819
  { key: "LOG_MATOMO_HOSTNAME", value: process.env.LOG_MATOMO_HOSTNAME },
1586
- { key: "LOG_MATOMO_PORT", value: process.env.LOG_MATOMO_PORT }
1820
+ { key: "LOG_MATOMO_PORT", value: process.env.LOG_MATOMO_PORT },
1821
+ { key: "LOG_MATOMO_SITE_ID", value: process.env.LOG_MATOMO_SITE_ID }
1587
1822
  ];
1588
1823
  matomoSilentVars.forEach((variable) => {
1589
1824
  if (variable.value === void 0) {
@@ -1775,7 +2010,11 @@ var CrexLogger = class {
1775
2010
  await this.initLogger();
1776
2011
  const timestamp = (/* @__PURE__ */ new Date()).toISOString();
1777
2012
  const newMessage = `[${timestamp}] ${message}`;
1778
- this.logger.log(level, newMessage, category);
2013
+ this.logger.log({
2014
+ level,
2015
+ message: newMessage,
2016
+ category
2017
+ });
1779
2018
  }
1780
2019
  /**
1781
2020
  * Creates a new Winston logger instance with configured transports.
@@ -1824,10 +2063,405 @@ var getToken = async () => {
1824
2063
  };
1825
2064
 
1826
2065
  // src/requests.ts
2066
+ var import_jose = require("jose");
2067
+ var AREA_PREFIX_PATTERN = /^(ids|iirds|iirdsmch|rdf|vcard|crex)\/v1\//i;
2068
+ var CREX_API_CACHE_TAG = "crex-api";
2069
+ var CREX_API_CACHE_VCARD_TAG = "crex-api:vcard";
2070
+ var CREX_READMODEL_CACHE_TAG = "crex-readmodel";
2071
+ var CREX_READMODEL_CACHE_VCARD_TAG = "crex-readmodel:vcard";
2072
+ var CREX_READMODEL_CACHE_METADATA_TAG = "crex-readmodel:metadata";
2073
+ var CREX_READMODEL_CACHE_ORGANIZATION_TAG = "crex-readmodel:organization";
2074
+ var CREX_READMODEL_CACHE_INFORMATION_SUBJECTS_TAG = "crex-readmodel:information-subjects";
2075
+ var CREX_READMODEL_CACHE_DOCUMENT_TYPES_TAG = "crex-readmodel:document-types";
2076
+ var CREX_READMODEL_CACHE_COMPONENTS_TAG = "crex-readmodel:components";
2077
+ var CREX_READMODEL_CACHE_PARTIES_TAG = "crex-readmodel:parties";
2078
+ var CREX_CACHE_SEGMENT_ALL = "all";
2079
+ var CREX_CACHE_SEGMENT_METADATA = "metadata";
2080
+ var CREX_CACHE_SEGMENT_VCARD = "vcard";
2081
+ var CREX_CACHE_SEGMENT_REQUESTS = "requests";
2082
+ var CREX_CACHE_SEGMENT_TO_TAGS = {
2083
+ [CREX_CACHE_SEGMENT_VCARD]: [
2084
+ CREX_API_CACHE_VCARD_TAG,
2085
+ CREX_READMODEL_CACHE_VCARD_TAG,
2086
+ CREX_READMODEL_CACHE_ORGANIZATION_TAG
2087
+ ],
2088
+ [CREX_CACHE_SEGMENT_METADATA]: [
2089
+ CREX_READMODEL_CACHE_METADATA_TAG,
2090
+ CREX_READMODEL_CACHE_TAG
2091
+ ],
2092
+ [CREX_CACHE_SEGMENT_REQUESTS]: [
2093
+ CREX_API_CACHE_TAG,
2094
+ CREX_API_CACHE_VCARD_TAG
2095
+ ],
2096
+ [CREX_CACHE_SEGMENT_ALL]: [
2097
+ CREX_API_CACHE_TAG,
2098
+ CREX_API_CACHE_VCARD_TAG,
2099
+ CREX_READMODEL_CACHE_TAG,
2100
+ CREX_READMODEL_CACHE_VCARD_TAG,
2101
+ CREX_READMODEL_CACHE_METADATA_TAG,
2102
+ CREX_READMODEL_CACHE_ORGANIZATION_TAG
2103
+ ]
2104
+ };
2105
+ var resolveCacheTagsForSegments = (segments) => {
2106
+ const resolved = /* @__PURE__ */ new Set();
2107
+ for (const rawSegment of segments) {
2108
+ const normalized = rawSegment.trim().toLowerCase();
2109
+ const mappedTags = CREX_CACHE_SEGMENT_TO_TAGS[normalized];
2110
+ if (!mappedTags) continue;
2111
+ mappedTags.forEach((tag) => resolved.add(tag));
2112
+ }
2113
+ return Array.from(resolved);
2114
+ };
2115
+ var getSupportedCacheSegments = () => [
2116
+ CREX_CACHE_SEGMENT_ALL,
2117
+ CREX_CACHE_SEGMENT_METADATA,
2118
+ CREX_CACHE_SEGMENT_VCARD,
2119
+ CREX_CACHE_SEGMENT_REQUESTS
2120
+ ];
2121
+ var CacheClearAuthUnauthorizedError = class extends Error {
2122
+ constructor(message) {
2123
+ super(message);
2124
+ this.name = "CacheClearAuthUnauthorizedError";
2125
+ }
2126
+ };
2127
+ var CacheClearAuthConfigurationError = class extends Error {
2128
+ constructor(message) {
2129
+ super(message);
2130
+ this.name = "CacheClearAuthConfigurationError";
2131
+ }
2132
+ };
2133
+ var CACHE_CLEAR_JWT_DISCOVERY_PATH = "/.well-known/openid-configuration";
2134
+ var cacheClearIssuerDiscoveryCache = /* @__PURE__ */ new Map();
2135
+ var cacheClearIssuerJwksCache = /* @__PURE__ */ new Map();
2136
+ var trimTrailingSlashes = (value) => value.replace(/\/+$/, "");
2137
+ var normalizeIssuerForClaimValidation = (rawIssuer) => {
2138
+ const trimmed = rawIssuer.trim();
2139
+ if (!trimmed) return "";
2140
+ const normalized = trimTrailingSlashes(trimmed);
2141
+ const lowered = normalized.toLowerCase();
2142
+ const loweredSuffix = CACHE_CLEAR_JWT_DISCOVERY_PATH.toLowerCase();
2143
+ if (lowered.endsWith(loweredSuffix)) {
2144
+ return normalized.slice(0, normalized.length - CACHE_CLEAR_JWT_DISCOVERY_PATH.length);
2145
+ }
2146
+ return normalized;
2147
+ };
2148
+ var resolveCacheClearJwtConfig = () => {
2149
+ const sdk = new CrexSDK();
2150
+ let configIssuer = "";
2151
+ let configAudience = "";
2152
+ try {
2153
+ const serverConfig = sdk.getServerConfig();
2154
+ configIssuer = serverConfig.OIDC.user.issuer || serverConfig.OIDC.client.issuer || "";
2155
+ configAudience = serverConfig.OIDC.user.id || serverConfig.OIDC.client.id || "";
2156
+ } catch {
2157
+ }
2158
+ const issuer = normalizeIssuerForClaimValidation(
2159
+ process.env.CREX_CACHE_CLEAR_JWT_ISSUER || process.env.OIDC_ISSUER || configIssuer
2160
+ );
2161
+ const audience = (process.env.CREX_CACHE_CLEAR_JWT_AUDIENCE || process.env.CREX_IDS_CLIENT_ID || configAudience).trim();
2162
+ if (!issuer || !audience) {
2163
+ throw new CacheClearAuthConfigurationError(
2164
+ "JWT validation is not configured. Set OIDC_ISSUER and CREX_IDS_CLIENT_ID (or explicit cache-clear overrides)."
2165
+ );
2166
+ }
2167
+ return { issuer, audience };
2168
+ };
2169
+ var getCacheClearIssuerJwksUri = async (issuer) => {
2170
+ const cached = cacheClearIssuerDiscoveryCache.get(issuer);
2171
+ if (cached) return (await cached).jwksUri;
2172
+ const discoveryPromise = (async () => {
2173
+ const response = await fetch(`${issuer}${CACHE_CLEAR_JWT_DISCOVERY_PATH}`, {
2174
+ cache: "no-store"
2175
+ });
2176
+ if (!response.ok) {
2177
+ throw new CacheClearAuthConfigurationError(
2178
+ `OIDC discovery failed for cache-clear authorization: HTTP ${response.status}`
2179
+ );
2180
+ }
2181
+ const payload = await response.json();
2182
+ const jwksUri = payload.jwks_uri?.trim();
2183
+ if (!jwksUri) {
2184
+ throw new CacheClearAuthConfigurationError(
2185
+ "OIDC discovery payload for cache-clear authorization has no jwks_uri"
2186
+ );
2187
+ }
2188
+ return { jwksUri };
2189
+ })();
2190
+ cacheClearIssuerDiscoveryCache.set(issuer, discoveryPromise);
2191
+ try {
2192
+ return (await discoveryPromise).jwksUri;
2193
+ } catch (error) {
2194
+ cacheClearIssuerDiscoveryCache.delete(issuer);
2195
+ throw error;
2196
+ }
2197
+ };
2198
+ var getCacheClearIssuerJwks = async (issuer) => {
2199
+ const cached = cacheClearIssuerJwksCache.get(issuer);
2200
+ if (cached) return cached;
2201
+ const jwksUri = await getCacheClearIssuerJwksUri(issuer);
2202
+ const jwks = (0, import_jose.createRemoteJWKSet)(new URL(jwksUri));
2203
+ cacheClearIssuerJwksCache.set(issuer, jwks);
2204
+ return jwks;
2205
+ };
2206
+ var verifyCacheClearBearerToken = async (token) => {
2207
+ if (!token) {
2208
+ throw new CacheClearAuthUnauthorizedError("missing bearer token");
2209
+ }
2210
+ const { issuer, audience } = resolveCacheClearJwtConfig();
2211
+ const jwks = await getCacheClearIssuerJwks(issuer);
2212
+ try {
2213
+ const verified = await (0, import_jose.jwtVerify)(token, jwks, {
2214
+ issuer,
2215
+ audience
2216
+ });
2217
+ return verified.payload;
2218
+ } catch (error) {
2219
+ if (error instanceof import_jose.errors.JWTInvalid || error instanceof import_jose.errors.JOSEError) {
2220
+ throw new CacheClearAuthUnauthorizedError(
2221
+ error.message || "invalid jwt"
2222
+ );
2223
+ }
2224
+ throw error;
2225
+ }
2226
+ };
2227
+ var extractScopesFromJwtPayload = (payload) => {
2228
+ if (!payload) return [];
2229
+ const rawValues = [payload.scope, payload["crex-scope"], payload.crex_scope];
2230
+ const scopes = [];
2231
+ for (const rawValue of rawValues) {
2232
+ if (typeof rawValue === "string") {
2233
+ scopes.push(...rawValue.split(/\s+/).filter(Boolean));
2234
+ continue;
2235
+ }
2236
+ if (Array.isArray(rawValue)) {
2237
+ scopes.push(
2238
+ ...rawValue.filter((item) => typeof item === "string" && item.trim().length > 0)
2239
+ );
2240
+ }
2241
+ }
2242
+ return Array.from(new Set(scopes));
2243
+ };
2244
+ var CACHE_CLEAR_ALLOWED_ADMIN_SCOPE = "crex_sysadmin";
2245
+ var handleCacheClearPostRequest = async (req) => {
2246
+ const traceId = req.headers.get("x-request-id") || req.headers.get("x-correlation-id") || "n/a";
2247
+ const authHeader = req.headers.get("authorization") || "";
2248
+ const bearerToken = authHeader.startsWith("Bearer ") ? authHeader.slice("Bearer ".length).trim() : "";
2249
+ let scopes = [];
2250
+ try {
2251
+ const jwtPayload = await verifyCacheClearBearerToken(bearerToken);
2252
+ scopes = extractScopesFromJwtPayload(jwtPayload);
2253
+ } catch (error) {
2254
+ if (error instanceof CacheClearAuthUnauthorizedError) {
2255
+ console.warn("[cache-clear] unauthorized-invalid-jwt", {
2256
+ traceId,
2257
+ reason: error instanceof Error ? error.message : "jwt validation failed"
2258
+ });
2259
+ return import_server.NextResponse.json({ error: "unauthorized" }, { status: 401 });
2260
+ }
2261
+ if (error instanceof CacheClearAuthConfigurationError) {
2262
+ console.error("[cache-clear] auth-validation-error", {
2263
+ traceId,
2264
+ reason: error.message
2265
+ });
2266
+ return import_server.NextResponse.json({ error: "cache-clear auth misconfigured" }, { status: 500 });
2267
+ }
2268
+ console.error("[cache-clear] auth-validation-error", {
2269
+ traceId,
2270
+ reason: error instanceof Error ? error.message : "unknown error"
2271
+ });
2272
+ return import_server.NextResponse.json({ error: "internal error" }, { status: 500 });
2273
+ }
2274
+ if (!scopes.includes(CACHE_CLEAR_ALLOWED_ADMIN_SCOPE)) {
2275
+ console.warn("[cache-clear] forbidden", {
2276
+ traceId,
2277
+ scopeCount: scopes.length
2278
+ });
2279
+ return import_server.NextResponse.json({ error: "forbidden" }, { status: 403 });
2280
+ }
2281
+ const payload = await req.json().catch(() => ({}));
2282
+ const requestedSegments = payload.segments || [CREX_CACHE_SEGMENT_ALL];
2283
+ const tagsToClear = new Set(resolveCacheTagsForSegments(requestedSegments));
2284
+ for (const key of payload.keys || []) {
2285
+ const normalizedKey = key.trim();
2286
+ if (normalizedKey.length > 0) {
2287
+ tagsToClear.add(normalizedKey);
2288
+ }
2289
+ }
2290
+ if (tagsToClear.size === 0) {
2291
+ console.warn("[cache-clear] no-tags", {
2292
+ traceId,
2293
+ requestedSegments,
2294
+ keyCount: (payload.keys || []).length
2295
+ });
2296
+ return import_server.NextResponse.json(
2297
+ { error: "no cache segments/keys to clear" },
2298
+ { status: 400 }
2299
+ );
2300
+ }
2301
+ tagsToClear.forEach((tag) => (0, import_cache.revalidateTag)(tag));
2302
+ clearProcessLocalRequestCaches();
2303
+ console.info("[cache-clear] revalidated", {
2304
+ traceId,
2305
+ requestedSegments,
2306
+ clearedTagCount: tagsToClear.size,
2307
+ clearedTags: Array.from(tagsToClear)
2308
+ });
2309
+ return import_server.NextResponse.json({
2310
+ ok: true,
2311
+ clearedTags: Array.from(tagsToClear),
2312
+ appliedSegments: requestedSegments,
2313
+ supportedSegments: getSupportedCacheSegments()
2314
+ });
2315
+ };
2316
+ var DEBUG_TIMINGS = process.env.CREX_DEBUG_TIMINGS === "true";
2317
+ var DISABLE_FETCH_CACHE = process.env.CREX_DISABLE_FETCH_CACHE === "true";
2318
+ var TIMING_LOG_FILE = process.env.CREX_TIMING_LOG_FILE;
2319
+ var DEFAULT_REQUESTS_REVALIDATE_SECONDS = 15 * 60;
2320
+ var DEFAULT_VCARD_REVALIDATE_SECONDS = 6 * 60 * 60;
2321
+ var readPositiveInt = (rawValue, fallback) => {
2322
+ const parsed = Number(rawValue);
2323
+ if (!Number.isFinite(parsed) || parsed <= 0) return fallback;
2324
+ return Math.floor(parsed);
2325
+ };
2326
+ var REQUESTS_REVALIDATE_SECONDS = readPositiveInt(
2327
+ process.env.CREX_CACHE_REVALIDATE_REQUESTS_SECONDS,
2328
+ DEFAULT_REQUESTS_REVALIDATE_SECONDS
2329
+ );
2330
+ var VCARD_REVALIDATE_SECONDS = readPositiveInt(
2331
+ process.env.CREX_CACHE_REVALIDATE_VCARD_SECONDS,
2332
+ DEFAULT_VCARD_REVALIDATE_SECONDS
2333
+ );
2334
+ var cachedOidcToken = null;
2335
+ var inFlightOidcTokenPromise = null;
2336
+ var OIDC_TOKEN_EXPIRY_SAFETY_SECONDS = 30;
2337
+ var getCacheTagsForUrl = (url) => {
2338
+ const normalized = url.toLowerCase();
2339
+ const tags = [CREX_API_CACHE_TAG];
2340
+ if (normalized.includes("/vcard/v1/")) {
2341
+ tags.push(CREX_API_CACHE_VCARD_TAG);
2342
+ }
2343
+ return tags;
2344
+ };
2345
+ var INFLIGHT_GET_REQUESTS = /* @__PURE__ */ new Map();
2346
+ var GET_MICROCACHE_TTL_MS = readPositiveInt(
2347
+ process.env.CREX_GET_MICROCACHE_TTL_MS,
2348
+ 1e4
2349
+ );
2350
+ var GET_MICROCACHE_MAX_ENTRIES = readPositiveInt(
2351
+ process.env.CREX_GET_MICROCACHE_MAX_ENTRIES,
2352
+ 1e3
2353
+ );
2354
+ var GET_MICROCACHE_PRUNE_INTERVAL_MS = readPositiveInt(
2355
+ process.env.CREX_GET_MICROCACHE_PRUNE_INTERVAL_MS,
2356
+ 3e4
2357
+ );
2358
+ var GET_MICROCACHE_METRICS_EVERY_N_EVENTS = readPositiveInt(
2359
+ process.env.CREX_GET_MICROCACHE_METRICS_EVERY_N_EVENTS,
2360
+ 250
2361
+ );
2362
+ var GET_RESPONSE_MICROCACHE = /* @__PURE__ */ new Map();
2363
+ var getMicrocacheLastPruneEpochMs = 0;
2364
+ var getMicrocacheStats = {
2365
+ hits: 0,
2366
+ misses: 0,
2367
+ sets: 0,
2368
+ expiredPruned: 0,
2369
+ lruEvicted: 0,
2370
+ events: 0
2371
+ };
2372
+ var clearProcessLocalRequestCaches = () => {
2373
+ INFLIGHT_GET_REQUESTS.clear();
2374
+ GET_RESPONSE_MICROCACHE.clear();
2375
+ getMicrocacheLastPruneEpochMs = 0;
2376
+ getMicrocacheStats.hits = 0;
2377
+ getMicrocacheStats.misses = 0;
2378
+ getMicrocacheStats.sets = 0;
2379
+ getMicrocacheStats.expiredPruned = 0;
2380
+ getMicrocacheStats.lruEvicted = 0;
2381
+ getMicrocacheStats.events = 0;
2382
+ };
2383
+ var maybePruneExpiredMicrocacheEntries = (nowEpochMs) => {
2384
+ if (nowEpochMs - getMicrocacheLastPruneEpochMs < GET_MICROCACHE_PRUNE_INTERVAL_MS) return;
2385
+ getMicrocacheLastPruneEpochMs = nowEpochMs;
2386
+ for (const [key, entry] of GET_RESPONSE_MICROCACHE.entries()) {
2387
+ if (entry.expiresAtEpochMs <= nowEpochMs) {
2388
+ GET_RESPONSE_MICROCACHE.delete(key);
2389
+ getMicrocacheStats.expiredPruned += 1;
2390
+ }
2391
+ }
2392
+ };
2393
+ var enforceMicrocacheMaxSize = () => {
2394
+ while (GET_RESPONSE_MICROCACHE.size > GET_MICROCACHE_MAX_ENTRIES) {
2395
+ const oldestKey = GET_RESPONSE_MICROCACHE.keys().next().value;
2396
+ if (!oldestKey) return;
2397
+ GET_RESPONSE_MICROCACHE.delete(oldestKey);
2398
+ getMicrocacheStats.lruEvicted += 1;
2399
+ }
2400
+ };
2401
+ var cloneForMicrocache = (value) => {
2402
+ try {
2403
+ if (typeof structuredClone === "function") {
2404
+ return structuredClone(value);
2405
+ }
2406
+ } catch {
2407
+ }
2408
+ return JSON.parse(JSON.stringify(value));
2409
+ };
2410
+ var GET_RETRY_ATTEMPTS = readPositiveInt(
2411
+ process.env.CREX_GET_RETRY_ATTEMPTS,
2412
+ 2
2413
+ );
2414
+ var GET_RETRY_DELAY_MS = readPositiveInt(
2415
+ process.env.CREX_GET_RETRY_DELAY_MS,
2416
+ 150
2417
+ );
2418
+ var sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
2419
+ var extractNodeErrorCodes = (error) => {
2420
+ const maybeError = error;
2421
+ const codes = /* @__PURE__ */ new Set();
2422
+ if (maybeError?.code) codes.add(maybeError.code);
2423
+ if (maybeError?.cause?.code) codes.add(maybeError.cause.code);
2424
+ if (Array.isArray(maybeError?.cause?.errors)) {
2425
+ maybeError.cause.errors.forEach((inner) => {
2426
+ if (inner?.code) codes.add(inner.code);
2427
+ });
2428
+ }
2429
+ return Array.from(codes);
2430
+ };
2431
+ var isTransientNetworkFetchError = (error) => {
2432
+ const codes = extractNodeErrorCodes(error);
2433
+ return codes.some((code) => code === "ETIMEDOUT" || code === "ENETUNREACH" || code === "ECONNRESET");
2434
+ };
1827
2435
  var CrexApi = class {
1828
2436
  customerConfig;
1829
2437
  baseUrl;
1830
2438
  logger;
2439
+ debugTiming(message) {
2440
+ if (!DEBUG_TIMINGS) return;
2441
+ const line = `[CrexApi][Timing] ${message}`;
2442
+ if (TIMING_LOG_FILE) {
2443
+ try {
2444
+ (0, import_fs3.mkdirSync)((0, import_path.dirname)(TIMING_LOG_FILE), { recursive: true });
2445
+ (0, import_fs3.appendFileSync)(TIMING_LOG_FILE, `${(/* @__PURE__ */ new Date()).toISOString()} ${line}
2446
+ `, "utf8");
2447
+ } catch {
2448
+ console.info(line);
2449
+ }
2450
+ return;
2451
+ }
2452
+ console.info(line);
2453
+ }
2454
+ resolveLogCategory(url) {
2455
+ const normalized = url.toLowerCase();
2456
+ if (normalized.includes("/search")) return "Search";
2457
+ if (normalized.includes("/notification")) return "Notification";
2458
+ if (normalized.includes("/history")) return "History";
2459
+ if (normalized.includes("/vcard/")) return "UserProfile";
2460
+ if (normalized.includes("/informationunits") || normalized.includes("/documents") || normalized.includes("/topics") || normalized.includes("/fragments") || normalized.includes("/packages")) {
2461
+ return "Document";
2462
+ }
2463
+ return "Scenario";
2464
+ }
1831
2465
  /**
1832
2466
  * Initializes the API client if it hasn't been initialized yet.
1833
2467
  * Loads customer configuration and initializes the logger.
@@ -1847,21 +2481,62 @@ var CrexApi = class {
1847
2481
  this.baseUrl = this.customerConfig.baseUrl;
1848
2482
  }
1849
2483
  }
1850
- async manageToken() {
2484
+ async manageToken(options) {
2485
+ const startedAt = Date.now();
1851
2486
  try {
2487
+ if (options?.authToken && options.authToken.trim().length > 0) {
2488
+ this.debugTiming(`manageToken source=explicit durationMs=${Date.now() - startedAt}`);
2489
+ return options.authToken;
2490
+ }
1852
2491
  let token = "";
1853
- const hasToken = (0, import_headers2.cookies)().get(CREX_TOKEN_HEADER_KEY);
2492
+ const allowCookieLookup = options?.skipCookieTokenLookup !== true;
2493
+ let hasToken;
2494
+ if (allowCookieLookup) {
2495
+ try {
2496
+ hasToken = (0, import_headers2.cookies)().get(CREX_TOKEN_HEADER_KEY);
2497
+ } catch {
2498
+ hasToken = void 0;
2499
+ }
2500
+ }
1854
2501
  if (hasToken == void 0 || hasToken.value === null) {
1855
- const { token: tokenResult } = await getToken();
1856
- if (tokenResult.length === 0) throw new Error("Token is undefined");
1857
- token = tokenResult;
2502
+ const nowSeconds = Math.floor(Date.now() / 1e3);
2503
+ const isCachedTokenValid = Boolean(
2504
+ cachedOidcToken?.token && cachedOidcToken.expiresAtEpochSeconds > nowSeconds + OIDC_TOKEN_EXPIRY_SAFETY_SECONDS
2505
+ );
2506
+ if (isCachedTokenValid && cachedOidcToken) {
2507
+ token = cachedOidcToken.token;
2508
+ } else {
2509
+ if (!inFlightOidcTokenPromise) {
2510
+ inFlightOidcTokenPromise = (async () => {
2511
+ const { token: tokenResult, expiresAt } = await getToken();
2512
+ if (!tokenResult || tokenResult.length === 0 || !expiresAt) {
2513
+ return null;
2514
+ }
2515
+ return {
2516
+ token: tokenResult,
2517
+ expiresAtEpochSeconds: expiresAt
2518
+ };
2519
+ })().finally(() => {
2520
+ inFlightOidcTokenPromise = null;
2521
+ });
2522
+ }
2523
+ const resolvedToken = await inFlightOidcTokenPromise;
2524
+ if (!resolvedToken?.token) throw new Error("Token is undefined");
2525
+ cachedOidcToken = resolvedToken;
2526
+ token = resolvedToken.token;
2527
+ }
2528
+ this.debugTiming(`manageToken source=oidc durationMs=${Date.now() - startedAt}`);
1858
2529
  } else {
1859
- token = hasToken.value;
2530
+ token = hasToken.value || "";
2531
+ if (token.length === 0) throw new Error("Token is undefined");
2532
+ this.debugTiming(`manageToken source=cookie durationMs=${Date.now() - startedAt}`);
1860
2533
  }
1861
2534
  return token;
1862
2535
  } catch (error) {
2536
+ this.debugTiming(`manageToken source=error durationMs=${Date.now() - startedAt}`);
1863
2537
  this.logger.log({
1864
2538
  level: "error",
2539
+ category: "Scenario",
1865
2540
  message: `CrexAPI.manageToken error: ${error}`
1866
2541
  });
1867
2542
  throw error;
@@ -1876,7 +2551,11 @@ var CrexApi = class {
1876
2551
  * @returns The full URL with query string
1877
2552
  */
1878
2553
  buildUrl(url, params) {
1879
- const fullUrl = new URL(url, this.baseUrl);
2554
+ const normalizedUrl = url.replace(/^\/+/, "");
2555
+ const isAbsoluteUrl = /^https?:\/\//i.test(normalizedUrl);
2556
+ const apiRoot = this.getApiRootUrl();
2557
+ const shouldResolveAgainstApiRoot = AREA_PREFIX_PATTERN.test(normalizedUrl);
2558
+ const fullUrl = isAbsoluteUrl ? new URL(normalizedUrl) : new URL(normalizedUrl, shouldResolveAgainstApiRoot ? apiRoot : this.baseUrl);
1880
2559
  if (params) {
1881
2560
  Object.entries(params).forEach(([key, value]) => {
1882
2561
  if (value !== void 0) {
@@ -1890,6 +2569,16 @@ var CrexApi = class {
1890
2569
  }
1891
2570
  return fullUrl.toString();
1892
2571
  }
2572
+ getApiRootUrl() {
2573
+ const parsed = new URL(this.baseUrl);
2574
+ const marker = "/ids/api/";
2575
+ const markerIndex = parsed.pathname.toLowerCase().indexOf(marker);
2576
+ if (markerIndex < 0) {
2577
+ return this.baseUrl;
2578
+ }
2579
+ const apiRootPath = parsed.pathname.slice(0, markerIndex + marker.length);
2580
+ return `${parsed.origin}${apiRootPath}`;
2581
+ }
1893
2582
  /**
1894
2583
  * Executes an API request with caching, authentication, and retry logic.
1895
2584
  *
@@ -1907,8 +2596,12 @@ var CrexApi = class {
1907
2596
  method,
1908
2597
  params,
1909
2598
  body,
1910
- headers = {}
2599
+ headers = {},
2600
+ skipCookieTokenLookup,
2601
+ authToken
1911
2602
  }) {
2603
+ const startedAt = Date.now();
2604
+ const normalizedMethod = method.toUpperCase();
1912
2605
  try {
1913
2606
  await this.initAPI();
1914
2607
  const requestHeaders = {
@@ -1916,25 +2609,128 @@ var CrexApi = class {
1916
2609
  ...headers
1917
2610
  };
1918
2611
  if (this.customerConfig.OIDC.client.enabled) {
1919
- const token = await this.manageToken();
2612
+ const token = await this.manageToken({ skipCookieTokenLookup, authToken });
1920
2613
  requestHeaders["Authorization"] = `Bearer ${token}`;
1921
2614
  }
1922
2615
  const fullUrl = this.buildUrl(url, params);
1923
- const response = await fetch(fullUrl, {
1924
- cache: "force-cache",
1925
- method,
2616
+ const category = this.resolveLogCategory(fullUrl);
2617
+ const requestInit = {
2618
+ method: normalizedMethod,
1926
2619
  headers: requestHeaders,
1927
2620
  body: body ? JSON.stringify(body) : void 0
1928
- });
1929
- if (!response.ok) {
1930
- console.log(fullUrl);
1931
- throw new Error(`HTTP error! status: ${response.status}`);
2621
+ };
2622
+ if (DISABLE_FETCH_CACHE) {
2623
+ requestInit.cache = "no-store";
2624
+ } else {
2625
+ const cacheTags = getCacheTagsForUrl(fullUrl);
2626
+ const revalidateSeconds = fullUrl.toLowerCase().includes("/vcard/v1/") ? VCARD_REVALIDATE_SECONDS : REQUESTS_REVALIDATE_SECONDS;
2627
+ requestInit.cache = "force-cache";
2628
+ requestInit.next = {
2629
+ tags: cacheTags,
2630
+ revalidate: revalidateSeconds
2631
+ };
2632
+ }
2633
+ const executeRequest = async () => {
2634
+ const maxAttempts = normalizedMethod === "GET" ? Math.max(1, GET_RETRY_ATTEMPTS) : 1;
2635
+ let lastError = void 0;
2636
+ for (let attempt = 1; attempt <= maxAttempts; attempt += 1) {
2637
+ try {
2638
+ this.debugTiming(`execute start method=${normalizedMethod} url=${fullUrl} attempt=${attempt}/${maxAttempts}`);
2639
+ const response = await fetch(fullUrl, requestInit);
2640
+ if (!response.ok) {
2641
+ const responseText = await response.clone().text().catch(() => "");
2642
+ this.logger.log({
2643
+ level: "error",
2644
+ category,
2645
+ message: `CrexAPI.execute error: ${fullUrl} - HTTP ${response.status}${responseText ? ` - ${responseText.slice(0, 300)}` : ""}`
2646
+ });
2647
+ console.error(`[CrexApi] Request failed: ${response.status} ${response.statusText} - ${fullUrl}`);
2648
+ throw new Error(`HTTP error! status: ${response.status}`);
2649
+ }
2650
+ this.logger.log({
2651
+ level: "debug",
2652
+ category,
2653
+ message: `CrexAPI.execute success: ${fullUrl}`
2654
+ });
2655
+ this.debugTiming(`execute success method=${normalizedMethod} url=${fullUrl} status=${response.status} durationMs=${Date.now() - startedAt} attempt=${attempt}/${maxAttempts}`);
2656
+ return await response.json();
2657
+ } catch (error) {
2658
+ lastError = error;
2659
+ if (normalizedMethod !== "GET" || attempt >= maxAttempts || !isTransientNetworkFetchError(error)) {
2660
+ throw error;
2661
+ }
2662
+ const delay = GET_RETRY_DELAY_MS * attempt;
2663
+ this.logger.log({
2664
+ level: "info",
2665
+ category,
2666
+ message: `CrexAPI.execute retrying transient GET error: ${fullUrl} attempt=${attempt}/${maxAttempts} delayMs=${delay}`
2667
+ });
2668
+ await sleep(delay);
2669
+ }
2670
+ }
2671
+ throw lastError instanceof Error ? lastError : new Error("Request failed");
2672
+ };
2673
+ const canDedupe = normalizedMethod === "GET";
2674
+ const dedupeKey = canDedupe ? `${normalizedMethod}:${fullUrl}:${requestHeaders["Authorization"] || ""}` : void 0;
2675
+ if (canDedupe && dedupeKey) {
2676
+ const nowEpochMs = Date.now();
2677
+ maybePruneExpiredMicrocacheEntries(nowEpochMs);
2678
+ const microCached = GET_RESPONSE_MICROCACHE.get(dedupeKey);
2679
+ if (microCached && microCached.expiresAtEpochMs > nowEpochMs) {
2680
+ microCached.lastAccessEpochMs = nowEpochMs;
2681
+ GET_RESPONSE_MICROCACHE.delete(dedupeKey);
2682
+ GET_RESPONSE_MICROCACHE.set(dedupeKey, microCached);
2683
+ getMicrocacheStats.hits += 1;
2684
+ getMicrocacheStats.events += 1;
2685
+ if (getMicrocacheStats.events % GET_MICROCACHE_METRICS_EVERY_N_EVENTS === 0) {
2686
+ this.debugTiming(
2687
+ `microcache stats hits=${getMicrocacheStats.hits} misses=${getMicrocacheStats.misses} sets=${getMicrocacheStats.sets} expiredPruned=${getMicrocacheStats.expiredPruned} lruEvicted=${getMicrocacheStats.lruEvicted} size=${GET_RESPONSE_MICROCACHE.size}`
2688
+ );
2689
+ }
2690
+ this.debugTiming(`execute microcache hit method=${normalizedMethod} url=${fullUrl}`);
2691
+ return cloneForMicrocache(microCached.value);
2692
+ }
2693
+ getMicrocacheStats.misses += 1;
2694
+ getMicrocacheStats.events += 1;
2695
+ if (getMicrocacheStats.events % GET_MICROCACHE_METRICS_EVERY_N_EVENTS === 0) {
2696
+ this.debugTiming(
2697
+ `microcache stats hits=${getMicrocacheStats.hits} misses=${getMicrocacheStats.misses} sets=${getMicrocacheStats.sets} expiredPruned=${getMicrocacheStats.expiredPruned} lruEvicted=${getMicrocacheStats.lruEvicted} size=${GET_RESPONSE_MICROCACHE.size}`
2698
+ );
2699
+ }
2700
+ const existing = INFLIGHT_GET_REQUESTS.get(dedupeKey);
2701
+ if (existing) return await existing;
2702
+ const inFlight = executeRequest().then((result) => {
2703
+ const writeNowEpochMs = Date.now();
2704
+ maybePruneExpiredMicrocacheEntries(writeNowEpochMs);
2705
+ if (GET_RESPONSE_MICROCACHE.has(dedupeKey)) {
2706
+ GET_RESPONSE_MICROCACHE.delete(dedupeKey);
2707
+ }
2708
+ GET_RESPONSE_MICROCACHE.set(dedupeKey, {
2709
+ expiresAtEpochMs: writeNowEpochMs + GET_MICROCACHE_TTL_MS,
2710
+ value: cloneForMicrocache(result),
2711
+ lastAccessEpochMs: writeNowEpochMs
2712
+ });
2713
+ enforceMicrocacheMaxSize();
2714
+ getMicrocacheStats.sets += 1;
2715
+ getMicrocacheStats.events += 1;
2716
+ if (getMicrocacheStats.events % GET_MICROCACHE_METRICS_EVERY_N_EVENTS === 0) {
2717
+ this.debugTiming(
2718
+ `microcache stats hits=${getMicrocacheStats.hits} misses=${getMicrocacheStats.misses} sets=${getMicrocacheStats.sets} expiredPruned=${getMicrocacheStats.expiredPruned} lruEvicted=${getMicrocacheStats.lruEvicted} size=${GET_RESPONSE_MICROCACHE.size}`
2719
+ );
2720
+ }
2721
+ return result;
2722
+ }).finally(() => {
2723
+ INFLIGHT_GET_REQUESTS.delete(dedupeKey);
2724
+ });
2725
+ INFLIGHT_GET_REQUESTS.set(dedupeKey, inFlight);
2726
+ return await inFlight;
1932
2727
  }
1933
- const data = await response.json();
1934
- return data;
2728
+ return await executeRequest();
1935
2729
  } catch (error) {
2730
+ this.debugTiming(`execute error method=${normalizedMethod} url=${url} durationMs=${Date.now() - startedAt}`);
1936
2731
  this.logger.log({
1937
2732
  level: "error",
2733
+ category: this.resolveLogCategory(url),
1938
2734
  message: `CrexAPI.execute error: ${error}`
1939
2735
  });
1940
2736
  throw error;
@@ -1943,6 +2739,29 @@ var CrexApi = class {
1943
2739
  };
1944
2740
  // Annotate the CommonJS export names for ESM import in node:
1945
2741
  0 && (module.exports = {
1946
- CrexApi
2742
+ CREX_API_CACHE_TAG,
2743
+ CREX_API_CACHE_VCARD_TAG,
2744
+ CREX_CACHE_SEGMENT_ALL,
2745
+ CREX_CACHE_SEGMENT_METADATA,
2746
+ CREX_CACHE_SEGMENT_REQUESTS,
2747
+ CREX_CACHE_SEGMENT_TO_TAGS,
2748
+ CREX_CACHE_SEGMENT_VCARD,
2749
+ CREX_READMODEL_CACHE_COMPONENTS_TAG,
2750
+ CREX_READMODEL_CACHE_DOCUMENT_TYPES_TAG,
2751
+ CREX_READMODEL_CACHE_INFORMATION_SUBJECTS_TAG,
2752
+ CREX_READMODEL_CACHE_METADATA_TAG,
2753
+ CREX_READMODEL_CACHE_ORGANIZATION_TAG,
2754
+ CREX_READMODEL_CACHE_PARTIES_TAG,
2755
+ CREX_READMODEL_CACHE_TAG,
2756
+ CREX_READMODEL_CACHE_VCARD_TAG,
2757
+ CacheClearAuthConfigurationError,
2758
+ CacheClearAuthUnauthorizedError,
2759
+ CrexApi,
2760
+ clearProcessLocalRequestCaches,
2761
+ extractScopesFromJwtPayload,
2762
+ getSupportedCacheSegments,
2763
+ handleCacheClearPostRequest,
2764
+ resolveCacheTagsForSegments,
2765
+ verifyCacheClearBearerToken
1947
2766
  });
1948
2767
  //# sourceMappingURL=requests.js.map