@opencrvs/toolkit 2.0.1 → 2.1.0-beta.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (167) hide show
  1. package/README.md +18 -12
  2. package/build.sh +14 -5
  3. package/create-countryconfig/index.js +313 -129
  4. package/create-countryconfig/node_modules/.bin/degit +21 -0
  5. package/create-countryconfig/package.json +5 -2
  6. package/dist/application-config/index.js +367 -278
  7. package/dist/authentication/index.d.ts +67 -0
  8. package/dist/authentication/index.d.ts.map +1 -0
  9. package/dist/authentication/index.js +754 -0
  10. package/dist/cli.js +4320 -4790
  11. package/dist/commons/api/router.d.ts +4120 -2982
  12. package/dist/commons/application-config/index.d.ts +6 -6
  13. package/dist/commons/conditionals/conditionals.d.ts +32 -323
  14. package/dist/commons/conditionals/validate.d.ts +16 -5
  15. package/dist/commons/events/ActionConfig.d.ts +302 -67
  16. package/dist/commons/events/ActionDocument.d.ts +159 -121
  17. package/dist/commons/events/ActionInput.d.ts +30 -10
  18. package/dist/commons/events/ActionStatus.d.ts +14 -0
  19. package/dist/commons/events/ActionType.d.ts +63 -58
  20. package/dist/commons/events/AdvancedSearchConfig.d.ts +537 -495
  21. package/dist/commons/events/AuditLog.d.ts +189 -40
  22. package/dist/commons/events/CompositeFieldValue.d.ts +4 -4
  23. package/dist/commons/events/Conditional.d.ts +3 -3
  24. package/dist/commons/events/CountryConfigQueryInput.d.ts +603 -561
  25. package/dist/commons/events/Draft.d.ts +38 -36
  26. package/dist/commons/events/DynamicFieldValue.d.ts +9 -9
  27. package/dist/commons/events/EventConfig.d.ts +8 -3
  28. package/dist/commons/events/EventDocument.d.ts +537 -47
  29. package/dist/commons/events/EventIndex.d.ts +61 -59
  30. package/dist/commons/events/EventMetadata.d.ts +59 -43
  31. package/dist/commons/events/EventStatus.d.ts +19 -0
  32. package/dist/commons/events/FieldConfig.d.ts +431 -380
  33. package/dist/commons/events/FieldType.d.ts +51 -51
  34. package/dist/commons/events/FieldTypeMapping.d.ts +86 -86
  35. package/dist/commons/events/FieldValue.d.ts +14 -14
  36. package/dist/commons/events/Flag.d.ts +57 -15
  37. package/dist/commons/events/PlainDate.d.ts +8 -0
  38. package/dist/commons/events/SummaryConfig.d.ts +249 -0
  39. package/dist/commons/events/TemplateConfig.d.ts +1 -1
  40. package/dist/commons/events/WorkqueueColumnConfig.d.ts +40 -40
  41. package/dist/commons/events/WorkqueueConfig.d.ts +835 -790
  42. package/dist/commons/events/deduplication.d.ts +1 -1
  43. package/dist/commons/events/event.d.ts +14 -2
  44. package/dist/commons/events/field.d.ts +69 -198
  45. package/dist/commons/events/index.d.ts +1 -0
  46. package/dist/commons/events/locationPayloads.d.ts +95 -0
  47. package/dist/commons/events/locations.d.ts +248 -14
  48. package/dist/commons/events/mocks.test.utils.d.ts +48 -4
  49. package/dist/commons/events/scopes.d.ts +5 -4
  50. package/dist/commons/events/state/index.d.ts +23 -15
  51. package/dist/commons/events/state/utils.d.ts +15 -6
  52. package/dist/commons/events/test.utils.d.ts +68 -42
  53. package/dist/commons/events/utils.d.ts +143 -110
  54. package/dist/commons/notification/UserNotifications.d.ts +38 -18
  55. package/dist/commons/notification/dispatch.d.ts +10 -0
  56. package/dist/commons/notification/index.d.ts +1 -0
  57. package/dist/conditionals/index.js +340 -63
  58. package/dist/csv.d.ts +25 -0
  59. package/dist/csv.d.ts.map +1 -0
  60. package/dist/csv.js +120 -0
  61. package/dist/environment/custom-types.d.ts +33 -0
  62. package/dist/environment/custom-types.d.ts.map +1 -0
  63. package/dist/environment/custom-types.js +12 -0
  64. package/dist/environment/derived-variables.d.ts +122 -0
  65. package/dist/environment/derived-variables.d.ts.map +1 -0
  66. package/dist/environment/derived-variables.js +155 -0
  67. package/dist/environment/editor-questions.d.ts +4 -0
  68. package/dist/environment/editor-questions.d.ts.map +1 -0
  69. package/dist/environment/editor-questions.js +67 -0
  70. package/dist/environment/git.d.ts +5 -0
  71. package/dist/environment/git.d.ts.map +1 -0
  72. package/dist/environment/git.js +38 -0
  73. package/dist/environment/github.d.ts +26 -0
  74. package/dist/environment/github.d.ts.map +1 -0
  75. package/dist/environment/github.js +247 -0
  76. package/dist/environment/index.d.ts +6 -0
  77. package/dist/environment/index.d.ts.map +1 -0
  78. package/dist/environment/index.js +81 -0
  79. package/dist/environment/logger.d.ts +18 -0
  80. package/dist/environment/logger.d.ts.map +1 -0
  81. package/dist/environment/logger.js +25 -0
  82. package/dist/environment/manage-users.d.ts +11 -0
  83. package/dist/environment/manage-users.d.ts.map +1 -0
  84. package/dist/environment/manage-users.js +507 -0
  85. package/dist/environment/paths.d.ts +7 -0
  86. package/dist/environment/paths.d.ts.map +1 -0
  87. package/dist/environment/paths.js +72 -0
  88. package/dist/environment/questions-helper.d.ts +15 -0
  89. package/dist/environment/questions-helper.d.ts.map +1 -0
  90. package/dist/environment/questions-helper.js +70 -0
  91. package/dist/environment/questions.d.ts +200 -0
  92. package/dist/environment/questions.d.ts.map +1 -0
  93. package/dist/environment/questions.js +418 -0
  94. package/dist/environment/setup-environment.d.ts +2 -0
  95. package/dist/environment/setup-environment.d.ts.map +1 -0
  96. package/dist/environment/setup-environment.js +793 -0
  97. package/dist/environment/ssh-keygen.d.ts +5 -0
  98. package/dist/environment/ssh-keygen.d.ts.map +1 -0
  99. package/dist/environment/ssh-keygen.js +21 -0
  100. package/dist/environment/swarm-to-k8s.d.ts +2 -0
  101. package/dist/environment/swarm-to-k8s.d.ts.map +1 -0
  102. package/dist/environment/swarm-to-k8s.js +183 -0
  103. package/dist/environment/templates.d.ts +26 -0
  104. package/dist/environment/templates.d.ts.map +1 -0
  105. package/dist/environment/templates.js +159 -0
  106. package/dist/environment/update-workflows.d.ts +2 -0
  107. package/dist/environment/update-workflows.d.ts.map +1 -0
  108. package/dist/environment/update-workflows.js +195 -0
  109. package/dist/environment/upgrade.d.ts +2 -0
  110. package/dist/environment/upgrade.d.ts.map +1 -0
  111. package/dist/environment/upgrade.js +82 -0
  112. package/dist/environment/users.d.ts +2 -0
  113. package/dist/environment/users.d.ts.map +1 -0
  114. package/dist/environment/users.js +120 -0
  115. package/dist/environment/utils.d.ts +6 -0
  116. package/dist/environment/utils.d.ts.map +1 -0
  117. package/dist/environment/utils.js +83 -0
  118. package/dist/events/deduplication.d.ts +1 -1
  119. package/dist/events/index.js +8107 -7388
  120. package/dist/migrations/v2.0/checkout-upstream-files.d.ts +2 -2
  121. package/dist/migrations/v2.0/checkout-upstream-files.d.ts.map +1 -1
  122. package/dist/migrations/v2.0/checkout-upstream-files.js +2 -2
  123. package/dist/migrations/v2.0/convert-config-files-to-ts.js +17 -7
  124. package/dist/migrations/v2.0/index.js +88 -5143
  125. package/dist/migrations/v2.0/migrate-application-config-url.js +4 -3
  126. package/dist/migrations/v2.0/remove-hearth-migrations.js +17 -7
  127. package/dist/migrations/v2.1/add-explicit-correction-flags.d.ts +3 -0
  128. package/dist/migrations/v2.1/add-explicit-correction-flags.d.ts.map +1 -0
  129. package/dist/migrations/v2.1/add-explicit-correction-flags.js +234 -0
  130. package/dist/migrations/v2.1/add-recovery-link-notifications.d.ts +3 -0
  131. package/dist/migrations/v2.1/add-recovery-link-notifications.d.ts.map +1 -0
  132. package/dist/migrations/v2.1/add-recovery-link-notifications.js +511 -0
  133. package/dist/migrations/v2.1/add-translations.d.ts +9 -0
  134. package/dist/migrations/v2.1/add-translations.d.ts.map +1 -0
  135. package/dist/migrations/v2.1/add-translations.js +213 -0
  136. package/dist/migrations/v2.1/enable-telemetry.d.ts +3 -0
  137. package/dist/migrations/v2.1/enable-telemetry.d.ts.map +1 -0
  138. package/dist/migrations/v2.1/enable-telemetry.js +438 -0
  139. package/dist/migrations/v2.1/index.d.ts +6 -0
  140. package/dist/migrations/v2.1/index.d.ts.map +1 -0
  141. package/dist/migrations/v2.1/index.js +1276 -0
  142. package/dist/notification/index.js +2011 -1446
  143. package/dist/scopes/index.d.ts +550 -161
  144. package/dist/scopes/index.js +341 -63
  145. package/dist/telemetry/index.d.ts +45 -0
  146. package/dist/telemetry/index.d.ts.map +1 -0
  147. package/dist/telemetry/index.js +39 -0
  148. package/dist/templates/charts-values/dependencies/values.override.yaml +4 -0
  149. package/dist/templates/charts-values/dependencies/values.yaml +82 -0
  150. package/dist/templates/charts-values/opencrvs-services/values.override.yaml +4 -0
  151. package/dist/templates/charts-values/opencrvs-services/values.yaml +78 -0
  152. package/dist/templates/charts-values/opentelemetry/values.yaml +95 -0
  153. package/dist/templates/charts-values/traefik/values.override.yaml +4 -0
  154. package/dist/templates/charts-values/traefik/values.yaml +129 -0
  155. package/dist/templates/inventory/inventory.template.yml +98 -0
  156. package/dist/translations/check.d.ts +21 -0
  157. package/dist/translations/check.d.ts.map +1 -0
  158. package/dist/translations/check.js +132 -0
  159. package/dist/verify/endpoints.d.ts.map +1 -1
  160. package/dist/verify/endpoints.js +26 -26
  161. package/opencrvs-toolkit-2.1.0-beta.2.tgz +0 -0
  162. package/package.json +25 -6
  163. package/tsconfig.build.json +11 -0
  164. package/tsconfig.build.tsbuildinfo +1 -0
  165. package/tsconfig.json +3 -0
  166. package/opencrvs-toolkit-2.0.1.tgz +0 -0
  167. package/tsconfig.tsbuildinfo +0 -1
@@ -42,7 +42,7 @@ __export(application_config_exports, {
42
42
  module.exports = __toCommonJS(application_config_exports);
43
43
 
44
44
  // ../commons/src/application-config.ts
45
- var z20 = __toESM(require("zod/v4"));
45
+ var z21 = __toESM(require("zod/v4"));
46
46
 
47
47
  // ../commons/src/events/FieldConfig.ts
48
48
  var import_v43 = __toESM(require("zod/v4"));
@@ -497,10 +497,10 @@ var SerializedUserField = z9.object({
497
497
  var import_v4 = require("zod/v4");
498
498
 
499
499
  // ../commons/src/events/EventMetadata.ts
500
- var z15 = __toESM(require("zod/v4"));
500
+ var z16 = __toESM(require("zod/v4"));
501
501
 
502
502
  // ../commons/src/events/ActionDocument.ts
503
- var z13 = __toESM(require("zod/v4"));
503
+ var z15 = __toESM(require("zod/v4"));
504
504
 
505
505
  // ../commons/src/events/ActionType.ts
506
506
  var z10 = __toESM(require("zod/v4"));
@@ -520,6 +520,7 @@ var ActionType = {
520
520
  MARK_AS_DUPLICATE: "MARK_AS_DUPLICATE",
521
521
  MARK_AS_NOT_DUPLICATE: "MARK_AS_NOT_DUPLICATE",
522
522
  ARCHIVE: "ARCHIVE",
523
+ UNARCHIVE: "UNARCHIVE",
523
524
  // Record actions
524
525
  PRINT_CERTIFICATE: "PRINT_CERTIFICATE",
525
526
  REQUEST_CORRECTION: "REQUEST_CORRECTION",
@@ -539,6 +540,7 @@ var ConfirmableActions = [
539
540
  ActionType.REGISTER,
540
541
  ActionType.REJECT,
541
542
  ActionType.ARCHIVE,
543
+ ActionType.UNARCHIVE,
542
544
  ActionType.PRINT_CERTIFICATE,
543
545
  ActionType.REQUEST_CORRECTION,
544
546
  ActionType.APPROVE_CORRECTION,
@@ -557,6 +559,7 @@ var ActionTypes = z10.enum([
557
559
  "MARK_AS_DUPLICATE",
558
560
  "MARK_AS_NOT_DUPLICATE",
559
561
  "ARCHIVE",
562
+ "UNARCHIVE",
560
563
  "PRINT_CERTIFICATE",
561
564
  "REQUEST_CORRECTION",
562
565
  "REJECT_CORRECTION",
@@ -597,6 +600,7 @@ var WorkqueueActionType = ActionTypes.extract([
597
600
  ActionType.REJECT,
598
601
  ActionType.MARK_AS_DUPLICATE,
599
602
  ActionType.ARCHIVE,
603
+ ActionType.UNARCHIVE,
600
604
  ActionType.PRINT_CERTIFICATE,
601
605
  ActionType.REQUEST_CORRECTION
602
606
  ]);
@@ -608,16 +612,98 @@ var META_ACTIONS = [
608
612
 
609
613
  // ../commons/src/authentication.ts
610
614
  var import_jwt_decode = __toESM(require("jwt-decode"));
611
- var z12 = __toESM(require("zod/v4"));
615
+ var z14 = __toESM(require("zod/v4"));
612
616
 
613
617
  // ../commons/src/scopes.ts
614
- var z11 = __toESM(require("zod/v4"));
618
+ var z13 = __toESM(require("zod/v4"));
615
619
  var qs = __toESM(require("qs"));
616
- var JurisdictionFilter = z11.enum(["administrativeArea", "location", "all"]).describe(
620
+
621
+ // ../commons/src/events/ActionStatus.ts
622
+ var ActionStatus = {
623
+ Requested: "Requested",
624
+ Accepted: "Accepted",
625
+ Rejected: "Rejected"
626
+ };
627
+
628
+ // ../commons/src/events/Flag.ts
629
+ var z11 = __toESM(require("zod/v4"));
630
+ var InherentFlags = {
631
+ INCOMPLETE: "incomplete",
632
+ REJECTED: "rejected",
633
+ CORRECTION_REQUESTED: "correction-requested",
634
+ POTENTIAL_DUPLICATE: "potential-duplicate",
635
+ /**
636
+ * This flag is set by the Edit-action and removed after the declaration or registration.
637
+ * A record should never stay with the EDIT_IN_PROGRESS flag, since it should always be declared or registered right after.
638
+ *
639
+ * We only use this flag to determine that a NOTIFY, DECLARE or REGISTER action is allowed next.
640
+ */
641
+ EDIT_IN_PROGRESS: "edit-in-progress"
642
+ };
643
+ var actionFlagPattern;
644
+ function getActionFlagPattern() {
645
+ actionFlagPattern ??= new RegExp(
646
+ `^(${Object.values(ActionType).join("|").toLowerCase()}):(${Object.values(
647
+ ActionStatus
648
+ ).join("|").toLowerCase()})$`
649
+ );
650
+ return actionFlagPattern;
651
+ }
652
+ var ActionFlag = z11.string().refine((value) => getActionFlagPattern().test(value), {
653
+ message: "Flag must be in the format ActionType:ActionStatus (lowerCase)"
654
+ });
655
+ var CustomFlag = z11.string().refine((val) => !Object.values(InherentFlags).includes(val), {
656
+ message: `Custom flag cannot be one of the inherent flags: ${Object.values(
657
+ InherentFlags
658
+ ).join(", ")}`
659
+ }).refine((val) => !ActionFlag.safeParse(val).success, {
660
+ message: "Custom flag cannot match the ActionFlag pattern (ActionType:ActionStatus)."
661
+ }).describe("Custom flag identifier defined by the country config.");
662
+ var Flag = ActionFlag.or(z11.enum(InherentFlags)).or(CustomFlag);
663
+ var ContainsFlags = z11.object({
664
+ anyOf: z11.array(Flag).optional(),
665
+ noneOf: z11.array(Flag).optional(),
666
+ allOf: z11.array(Flag).optional()
667
+ }).meta({
668
+ id: "ContainsFlags"
669
+ });
670
+ var FlagConfig = z11.object({
671
+ id: CustomFlag,
672
+ requiresAction: z11.boolean().describe(
673
+ "Indicates if this flag expects an action to be performed to be cleared."
674
+ ),
675
+ label: TranslationConfig.describe("Human readable label of the flag.")
676
+ }).meta({
677
+ id: "FlagConfig",
678
+ description: "Configuration for a custom flag that can be added to or removed from records by event actions."
679
+ });
680
+ var ActionFlagConfig = z11.object({
681
+ id: Flag,
682
+ operation: z11.enum(["add", "remove"]).describe("Operation to perform on the flag."),
683
+ conditional: Conditional.optional().describe(
684
+ "When conditional is met, the operation is performed on the flag. If not provided, the operation is performed unconditionally."
685
+ )
686
+ }).meta({
687
+ id: "ActionFlagConfig",
688
+ description: "Add or remove operation applied to a flag when the parent action is accepted. Optionally gated by a conditional."
689
+ });
690
+
691
+ // ../commons/src/events/EventStatus.ts
692
+ var z12 = __toESM(require("zod/v4"));
693
+ var EventStatus = z12.enum([
694
+ "CREATED",
695
+ "NOTIFIED",
696
+ "DECLARED",
697
+ "REGISTERED",
698
+ "ARCHIVED"
699
+ ]);
700
+
701
+ // ../commons/src/scopes.ts
702
+ var JurisdictionFilter = z13.enum(["administrativeArea", "location", "all"]).describe(
617
703
  "Filters based on user jurisdiction relative to their office location in hierarchy."
618
704
  );
619
- var UserFilter = z11.enum(["user"]).describe("Filters based on the user. Limits to self.");
620
- var RecordScopeTypeV2 = z11.enum([
705
+ var UserFilter = z13.enum(["user"]).describe("Filters based on the user. Limits to self.");
706
+ var RecordScopeTypeV2 = z13.enum([
621
707
  "record.search",
622
708
  "record.create",
623
709
  "record.read",
@@ -626,6 +712,7 @@ var RecordScopeTypeV2 = z11.enum([
626
712
  "record.edit",
627
713
  "record.reject",
628
714
  "record.archive",
715
+ "record.unarchive",
629
716
  "record.review-duplicates",
630
717
  "record.register",
631
718
  "record.print-certified-copies",
@@ -634,14 +721,20 @@ var RecordScopeTypeV2 = z11.enum([
634
721
  "record.unassign-others",
635
722
  "record.custom-action"
636
723
  ]);
637
- var PlainScopeType = z11.enum([
724
+ var PlainScopeType = z13.enum([
638
725
  // Misc. system scopes
639
726
  "bypassratelimit",
640
727
  "record.reindex",
641
728
  "user.data-seeding",
642
729
  "integration.create",
730
+ // Reading an integration's audit log. Deliberately separate from
731
+ // 'integration.create' so read-only oversight can be granted on its own, and
732
+ // deliberately option-less: system clients have no office and no
733
+ // administrative area, so jurisdiction options would have nothing to bind to.
734
+ "integration.audit.read",
643
735
  "record.import",
644
736
  "config.update-all",
737
+ "location.edit",
645
738
  "attachment.upload",
646
739
  "profile.electronic-signature",
647
740
  "user.read-only-my-audit",
@@ -653,72 +746,85 @@ var PlainScopeType = z11.enum([
653
746
  "record.confirm-registration",
654
747
  "record.reject-registration"
655
748
  ]);
656
- var scopeByEvent = z11.preprocess(
749
+ var scopeByEvent = z13.preprocess(
657
750
  (val) => val === void 0 ? void 0 : [val].flat(),
658
- z11.array(z11.string()).optional()
751
+ z13.array(z13.string()).optional()
659
752
  ).describe("Event type, e.g. birth, death");
660
- var userRole = z11.preprocess(
753
+ var scopeByStatus = z13.preprocess(
754
+ (val) => val === void 0 ? void 0 : [val].flat(),
755
+ z13.array(EventStatus).optional()
756
+ ).describe(
757
+ "Restricts the scope to records currently in one of these statuses."
758
+ );
759
+ var userRole = z13.preprocess(
661
760
  (val) => val === void 0 ? void 0 : [val].flat(),
662
- z11.array(z11.string()).optional()
761
+ z13.array(z13.string()).optional()
663
762
  ).describe("User role, e.g. admin, field agent");
664
- var scopeOptionsPlaceEvent = z11.object({
763
+ var scopeOptionsPlaceEvent = z13.object({
665
764
  event: scopeByEvent,
666
765
  placeOfEvent: JurisdictionFilter.optional(),
667
766
  createdBy: UserFilter.optional(),
668
767
  createdIn: JurisdictionFilter.optional()
669
768
  }).describe("Options applicable to all record scopes.");
670
- var scopeOptionsDeclared = scopeOptionsPlaceEvent.extend({
769
+ var scopeOptionsDeclaredOrNotified = scopeOptionsPlaceEvent.extend({
770
+ notifiedIn: JurisdictionFilter.optional(),
771
+ notifiedBy: UserFilter.optional(),
671
772
  declaredIn: JurisdictionFilter.optional(),
672
- declaredBy: UserFilter.optional()
773
+ declaredBy: UserFilter.optional(),
774
+ status: scopeByStatus
673
775
  }).describe("Options applicable to actions that may take place after DECLARE");
674
- var AllRecordScopeOptions = scopeOptionsDeclared.extend({
776
+ var AllRecordScopeOptions = scopeOptionsDeclaredOrNotified.extend({
675
777
  registeredIn: JurisdictionFilter.optional(),
676
- registeredBy: UserFilter.optional()
778
+ registeredBy: UserFilter.optional(),
779
+ flags: ContainsFlags.optional()
677
780
  }).describe(
678
781
  "Options applicable to actions that may take place after REGISTER, with full filtering capabilities."
679
782
  );
680
783
  var CustomActionScopeOptions = AllRecordScopeOptions.extend({
681
- customActionTypes: z11.preprocess(
784
+ customActionTypes: z13.preprocess(
682
785
  (val) => val === void 0 ? void 0 : [val].flat(),
683
- z11.array(z11.string()).optional()
786
+ z13.array(z13.string()).optional()
684
787
  ).describe("Allowed custom action types")
685
788
  });
686
- var AccessLevelOptions = z11.object({
789
+ var AccessLevelOptions = z13.object({
687
790
  accessLevel: JurisdictionFilter.optional()
688
791
  });
689
792
  var AllUserScopeOptions = AccessLevelOptions.extend({
690
793
  role: userRole.optional()
691
794
  });
692
- var WorkqueueOrDashboardOptions = z11.object({
693
- ids: z11.preprocess(
795
+ var WorkqueueOrDashboardOptions = z13.object({
796
+ ids: z13.preprocess(
694
797
  (val) => val === void 0 ? void 0 : [val].flat(),
695
- z11.array(z11.string())
798
+ z13.array(z13.string())
696
799
  ).describe("Must contain a list of workqueue or dashboard ids.")
697
800
  });
698
- var AllScopeOptions = z11.object({
801
+ var AllScopeOptions = z13.object({
699
802
  ...AllRecordScopeOptions.shape,
700
803
  ...AccessLevelOptions.shape,
701
804
  ...AllUserScopeOptions.shape,
702
805
  ...WorkqueueOrDashboardOptions.shape
703
806
  });
704
807
  var ScopeOptionKey = AllScopeOptions.keyof();
705
- var ResolvedScopeOptionsPlaceEvent = z11.object({
808
+ var ResolvedScopeOptionsPlaceEvent = z13.object({
706
809
  event: scopeByEvent,
707
810
  placeOfEvent: UUID.nullish(),
708
- createdBy: z11.string().optional(),
811
+ createdBy: z13.string().optional(),
709
812
  createdIn: UUID.nullish()
710
813
  }).describe(
711
814
  "Resolved options applicable to all record scopes, with location ID instead of jurisdiction filter."
712
815
  );
713
816
  var ResolvedScopeOptionsDeclared = ResolvedScopeOptionsPlaceEvent.extend({
817
+ notifiedIn: UUID.nullish(),
818
+ notifiedBy: z13.string().optional(),
714
819
  declaredIn: UUID.nullish(),
715
- declaredBy: z11.string().optional()
820
+ declaredBy: z13.string().optional()
716
821
  }).describe(
717
822
  "Resolved options applicable to actions that may take place after DECLARE, with location ID and user ID instead of filters."
718
823
  );
719
824
  var ResolvedScopeOptionsFull = ResolvedScopeOptionsDeclared.extend({
720
825
  registeredIn: UUID.nullish(),
721
- registeredBy: z11.string().optional()
826
+ registeredBy: z13.string().optional(),
827
+ flags: ContainsFlags.optional()
722
828
  }).describe(
723
829
  "Resolved options applicable to actions that may take place after REGISTER, with full filtering capabilities and location/user IDs instead of filters."
724
830
  );
@@ -731,7 +837,7 @@ var ScopesWithDeclaredOptions = RecordScopeTypeV2.extract([
731
837
  "record.edit",
732
838
  "record.reject",
733
839
  "record.archive",
734
- "record.review-duplicates",
840
+ "record.unarchive",
735
841
  "record.register"
736
842
  ]);
737
843
  var ScopesWithFullOptions = RecordScopeTypeV2.extract([
@@ -739,41 +845,42 @@ var ScopesWithFullOptions = RecordScopeTypeV2.extract([
739
845
  "record.read",
740
846
  "record.request-correction",
741
847
  "record.correct",
742
- "record.unassign-others"
848
+ "record.unassign-others",
849
+ "record.review-duplicates"
743
850
  ]);
744
851
  var ScopeOptionsPrintCertifiedCopies = AllRecordScopeOptions.extend({
745
- templates: z11.preprocess(
852
+ templates: z13.preprocess(
746
853
  (val) => val === void 0 ? void 0 : [val].flat(),
747
- z11.array(z11.string()).optional()
854
+ z13.array(z13.string()).optional()
748
855
  ).describe(
749
856
  "Template IDs for certified copies. Controls which certificate templates are returned to the client via the config service. Certificate printing is a client-side operation \u2014 this option is not validated when the printCertificate action is submitted."
750
857
  )
751
858
  });
752
- var RecordScopeV2 = z11.discriminatedUnion("type", [
753
- z11.object({
859
+ var RecordScopeV2 = z13.discriminatedUnion("type", [
860
+ z13.object({
754
861
  type: ScopesWithPlaceEventOptions,
755
862
  options: scopeOptionsPlaceEvent.optional()
756
863
  }),
757
- z11.object({
864
+ z13.object({
758
865
  type: ScopesWithDeclaredOptions,
759
- options: scopeOptionsDeclared.optional()
866
+ options: scopeOptionsDeclaredOrNotified.optional()
760
867
  }),
761
- z11.object({
868
+ z13.object({
762
869
  type: ScopesWithFullOptions,
763
870
  options: AllRecordScopeOptions.optional()
764
871
  }),
765
- z11.object({
766
- type: z11.literal("record.custom-action"),
872
+ z13.object({
873
+ type: z13.literal("record.custom-action"),
767
874
  options: CustomActionScopeOptions.optional()
768
875
  }),
769
- z11.object({
770
- type: z11.literal("record.print-certified-copies"),
876
+ z13.object({
877
+ type: z13.literal("record.print-certified-copies"),
771
878
  options: ScopeOptionsPrintCertifiedCopies.optional()
772
879
  })
773
880
  ]).describe(
774
881
  "Scopes used to check user's permission to perform actions on a record."
775
882
  );
776
- var SystemScopeType = z11.enum([
883
+ var SystemScopeType = z13.enum([
777
884
  "organisation.read-locations",
778
885
  "user.read",
779
886
  "user.create",
@@ -787,93 +894,89 @@ var UserScopeType = SystemScopeType.extract([
787
894
  "user.search"
788
895
  ]);
789
896
  var ScopesWithRoleOption = UserScopeType.extract(["user.edit", "user.create"]);
790
- var UserScopeV2 = z11.discriminatedUnion("type", [
791
- z11.object({
897
+ var UserScopeV2 = z13.discriminatedUnion("type", [
898
+ z13.object({
792
899
  type: ScopesWithRoleOption,
793
900
  options: AllUserScopeOptions.optional()
794
901
  }),
795
- z11.object({
902
+ z13.object({
796
903
  type: UserScopeType.extract(["user.read", "user.search"]),
797
904
  options: AccessLevelOptions.optional()
798
905
  })
799
906
  ]);
800
- var ResolvedRecordScopeV2 = z11.discriminatedUnion("type", [
801
- z11.object({
907
+ var ResolvedRecordScopeV2 = z13.discriminatedUnion("type", [
908
+ z13.object({
802
909
  type: ScopesWithPlaceEventOptions,
803
910
  options: ResolvedScopeOptionsPlaceEvent.optional()
804
911
  }),
805
- z11.object({
912
+ z13.object({
806
913
  type: ScopesWithDeclaredOptions,
807
914
  options: ResolvedScopeOptionsDeclared.optional()
808
915
  }),
809
- z11.object({
916
+ z13.object({
810
917
  type: ScopesWithFullOptions,
811
918
  options: ResolvedScopeOptionsFull.optional()
812
919
  }),
813
- z11.object({
814
- type: z11.literal("record.print-certified-copies"),
920
+ z13.object({
921
+ type: z13.literal("record.print-certified-copies"),
815
922
  options: ResolvedScopeOptionsFull.extend({
816
- templates: z11.array(z11.string()).optional()
923
+ templates: z13.array(z13.string()).optional()
817
924
  }).optional()
818
925
  })
819
926
  ]).describe("Resolved scope with location/user IDs instead of filters.");
820
- var Scope = z11.discriminatedUnion("type", [
821
- z11.object({ type: PlainScopeType }),
927
+ var Scope = z13.discriminatedUnion("type", [
928
+ z13.object({ type: PlainScopeType }),
822
929
  ...RecordScopeV2.options,
823
930
  ...UserScopeV2.options,
824
- z11.object({
825
- type: z11.literal("organisation.read-locations"),
931
+ z13.object({
932
+ type: z13.literal("organisation.read-locations"),
826
933
  options: AccessLevelOptions.optional()
827
934
  }),
828
- z11.object({
829
- type: z11.literal("workqueue"),
935
+ z13.object({
936
+ type: z13.literal("workqueue"),
830
937
  options: WorkqueueOrDashboardOptions
831
938
  }),
832
- z11.object({
833
- type: z11.literal("dashboard.view"),
939
+ z13.object({
940
+ type: z13.literal("dashboard.view"),
834
941
  options: WorkqueueOrDashboardOptions
835
942
  })
836
943
  ]);
837
- var ScopeType = z11.enum([
944
+ var ScopeType = z13.enum([
838
945
  ...SystemScopeType.options,
839
946
  ...RecordScopeTypeV2.options,
840
947
  ...PlainScopeType.options,
841
948
  "workqueue",
842
949
  "dashboard.view"
843
950
  ]);
844
- var EncodedScope = z11.string().brand("EncodedScope");
951
+ var EncodedScope = z13.string().brand("EncodedScope");
845
952
  var DEFAULT_SCOPE_OPTIONS = {
846
953
  placeOfEvent: JurisdictionFilter.enum.all,
847
954
  accessLevel: JurisdictionFilter.enum.all,
848
- registeredIn: JurisdictionFilter.enum.all,
849
- declaredIn: JurisdictionFilter.enum.all
955
+ notifiedIn: JurisdictionFilter.enum.all,
956
+ declaredIn: JurisdictionFilter.enum.all,
957
+ registeredIn: JurisdictionFilter.enum.all
850
958
  };
851
959
 
852
960
  // ../commons/src/authentication.ts
853
- var TokenUserType = z12.enum(["user", "system"]);
854
- var TokenWithBearer = z12.string().regex(/^Bearer\s/);
961
+ var TokenUserType = z14.enum(["user", "system"]);
962
+ var TokenWithBearer = z14.string().regex(/^Bearer\s/);
855
963
 
856
964
  // ../commons/src/events/ActionDocument.ts
857
- var ActionUpdate = z13.record(z13.string(), FieldUpdateValue).describe(
965
+ var ActionUpdate = z15.record(z15.string(), FieldUpdateValue).describe(
858
966
  "Record of field-level changes made by an action. Supports partial updates and nullable values."
859
967
  );
860
- var EventState = z13.record(z13.string(), FieldValue).describe(
968
+ var EventState = z15.record(z15.string(), FieldValue).describe(
861
969
  "Aggregate representation of event data after all actions have been applied, with all updates consolidated and null values removed."
862
970
  );
863
- var ActionStatus = {
864
- Requested: "Requested",
865
- Accepted: "Accepted",
866
- Rejected: "Rejected"
867
- };
868
- var ActionBase = z13.object({
971
+ var ActionBase = z15.object({
869
972
  id: UUID.describe("Unique identifier of the action."),
870
- transactionId: z13.string().describe("Unique identifier of the transaction."),
973
+ transactionId: z15.string().describe("Unique identifier of the transaction."),
871
974
  createdByUserType: TokenUserType.describe(
872
975
  "Indicates whether the action was created by a human-user or by a system-user."
873
976
  ),
874
- createdAt: z13.string().datetime().describe("Timestamp indicating when the action was created."),
875
- createdBy: z13.string().describe("Identifier of the user who created the action."),
876
- createdByRole: z13.string().optional().describe("Role of the user who created the action."),
977
+ createdAt: z15.string().datetime().describe("Timestamp indicating when the action was created."),
978
+ createdBy: z15.string().describe("Identifier of the user who created the action."),
979
+ createdByRole: z15.string().optional().describe("Role of the user who created the action."),
877
980
  createdBySignature: DocumentPath.nullish().describe(
878
981
  "Reference to the signature of the user who created the action."
879
982
  ),
@@ -885,7 +988,7 @@ var ActionBase = z13.object({
885
988
  "Declaration data defined by the ActionConfig. Supports partial updates."
886
989
  ),
887
990
  annotation: ActionUpdate.optional().nullable().describe("Action-specific metadata used to annotate the event."),
888
- status: z13.enum([
991
+ status: z15.enum([
889
992
  ActionStatus.Requested,
890
993
  ActionStatus.Accepted,
891
994
  ActionStatus.Rejected
@@ -897,139 +1000,150 @@ var ActionBase = z13.object({
897
1000
  )
898
1001
  });
899
1002
  var AssignedAction = ActionBase.extend(
900
- z13.object({
901
- type: z13.literal(ActionType.ASSIGN),
902
- assignedTo: z13.string().describe("Identifier of the user to whom the action is assigned.")
1003
+ z15.object({
1004
+ type: z15.literal(ActionType.ASSIGN),
1005
+ assignedTo: z15.string().describe("Identifier of the user to whom the action is assigned.")
903
1006
  // TODO move into 'content' property
904
1007
  }).shape
905
1008
  );
906
1009
  var UnassignedAction = ActionBase.extend(
907
- z13.object({
908
- type: z13.literal(ActionType.UNASSIGN)
1010
+ z15.object({
1011
+ type: z15.literal(ActionType.UNASSIGN)
909
1012
  }).shape
910
1013
  );
911
1014
  var RegisterAction = ActionBase.extend(
912
- z13.object({
913
- type: z13.literal(ActionType.REGISTER),
914
- registrationNumber: z13.string().optional().describe(
1015
+ z15.object({
1016
+ type: z15.literal(ActionType.REGISTER),
1017
+ registrationNumber: z15.string().optional().describe(
915
1018
  "Registration number of the event. Always present for accepted registrations."
916
1019
  )
917
1020
  // TODO move into 'content' property
918
1021
  }).shape
919
1022
  );
920
1023
  var DeclareAction = ActionBase.extend(
921
- z13.object({
922
- type: z13.literal(ActionType.DECLARE)
1024
+ z15.object({
1025
+ type: z15.literal(ActionType.DECLARE)
923
1026
  }).shape
924
1027
  );
925
- var ReasonContent = z13.object({
926
- reason: z13.string().min(1, { error: "Message cannot be empty" }).describe(
1028
+ var ReasonContent = z15.object({
1029
+ reason: z15.string().min(1, { error: "Message cannot be empty" }).describe(
927
1030
  "Message describing the reason for rejecting or archiving the event."
928
1031
  )
929
1032
  });
930
1033
  var RejectAction = ActionBase.extend(
931
- z13.object({
932
- type: z13.literal(ActionType.REJECT),
1034
+ z15.object({
1035
+ type: z15.literal(ActionType.REJECT),
933
1036
  content: ReasonContent
934
1037
  }).shape
935
1038
  );
936
- var PotentialDuplicate = z13.object({
1039
+ var PotentialDuplicate = z15.object({
937
1040
  id: UUID,
938
- trackingId: z13.string()
1041
+ trackingId: z15.string()
939
1042
  });
940
1043
  var DuplicateDetectedAction = ActionBase.extend(
941
- z13.object({
942
- type: z13.literal(ActionType.DUPLICATE_DETECTED),
943
- content: z13.object({
944
- duplicates: z13.array(PotentialDuplicate)
1044
+ z15.object({
1045
+ type: z15.literal(ActionType.DUPLICATE_DETECTED),
1046
+ content: z15.object({
1047
+ duplicates: z15.array(PotentialDuplicate)
945
1048
  })
946
1049
  }).shape
947
1050
  );
948
1051
  var MarkNotDuplicateAction = ActionBase.extend(
949
- z13.object({
950
- type: z13.literal(ActionType.MARK_AS_NOT_DUPLICATE)
1052
+ z15.object({
1053
+ type: z15.literal(ActionType.MARK_AS_NOT_DUPLICATE)
951
1054
  }).shape
952
1055
  );
953
1056
  var MarkAsDuplicateAction = ActionBase.extend(
954
- z13.object({
955
- type: z13.literal(ActionType.MARK_AS_DUPLICATE),
956
- content: z13.object({
1057
+ z15.object({
1058
+ type: z15.literal(ActionType.MARK_AS_DUPLICATE),
1059
+ content: z15.object({
957
1060
  duplicateOf: UUID
958
1061
  }).optional()
959
1062
  }).shape
960
1063
  );
961
1064
  var ArchiveAction = ActionBase.extend(
962
- z13.object({
963
- type: z13.literal(ActionType.ARCHIVE),
964
- content: ReasonContent
1065
+ z15.object({
1066
+ type: z15.literal(ActionType.ARCHIVE),
1067
+ /**
1068
+ * Archiving does not collect a reason on its own. Only the
1069
+ * "mark as duplicate" flow archives with a reason attached.
1070
+ */
1071
+ content: ReasonContent.optional()
1072
+ }).shape
1073
+ );
1074
+ var UnarchiveAction = ActionBase.extend(
1075
+ z15.object({
1076
+ type: z15.literal(ActionType.UNARCHIVE)
965
1077
  }).shape
966
1078
  );
967
1079
  var CreatedAction = ActionBase.extend(
968
- z13.object({
969
- type: z13.literal(ActionType.CREATE)
1080
+ z15.object({
1081
+ type: z15.literal(ActionType.CREATE)
970
1082
  }).shape
971
1083
  );
972
1084
  var NotifiedAction = ActionBase.extend(
973
- z13.object({
974
- type: z13.literal(ActionType.NOTIFY)
1085
+ z15.object({
1086
+ type: z15.literal(ActionType.NOTIFY)
975
1087
  }).shape
976
1088
  );
977
1089
  var EditAction = ActionBase.extend(
978
- z13.object({
979
- type: z13.literal(ActionType.EDIT),
980
- content: z13.object({
981
- comment: z13.string().describe("Comment for the edit action.").optional()
982
- })
1090
+ z15.object({
1091
+ type: z15.literal(ActionType.EDIT),
1092
+ /** @deprecated New Edit-actions should no longer contain content. This is kept for old 2.0 edits. */
1093
+ content: z15.object({
1094
+ comment: z15.string().describe("Comment for the edit action.").optional()
1095
+ }).optional()
983
1096
  }).shape
984
1097
  );
985
- var PrintContent = z13.object({
986
- templateId: z13.string().optional()
1098
+ var PrintContent = z15.object({
1099
+ templateId: z15.string().optional()
987
1100
  });
988
1101
  var PrintCertificateAction = ActionBase.extend(
989
- z13.object({
990
- type: z13.literal(ActionType.PRINT_CERTIFICATE),
1102
+ z15.object({
1103
+ type: z15.literal(ActionType.PRINT_CERTIFICATE),
991
1104
  content: PrintContent.optional().nullable()
992
1105
  }).shape
993
1106
  );
994
1107
  var RequestedCorrectionAction = ActionBase.extend(
995
- z13.object({
996
- type: z13.literal(ActionType.REQUEST_CORRECTION)
1108
+ z15.object({
1109
+ type: z15.literal(ActionType.REQUEST_CORRECTION)
997
1110
  }).shape
998
1111
  );
999
1112
  var ApprovedCorrectionAction = ActionBase.extend(
1000
- z13.object({
1001
- type: z13.literal(ActionType.APPROVE_CORRECTION),
1002
- requestId: z13.string(),
1113
+ z15.object({
1114
+ type: z15.literal(ActionType.APPROVE_CORRECTION),
1115
+ requestId: z15.string(),
1003
1116
  // TODO move into 'content' property
1004
- content: z13.object({ immediateCorrection: z13.boolean().optional() }).optional()
1117
+ content: z15.object({ immediateCorrection: z15.boolean().optional() }).optional()
1005
1118
  }).shape
1006
1119
  );
1007
1120
  var RejectedCorrectionAction = ActionBase.extend(
1008
- z13.object({
1009
- type: z13.literal(ActionType.REJECT_CORRECTION),
1010
- requestId: z13.string(),
1121
+ z15.object({
1122
+ type: z15.literal(ActionType.REJECT_CORRECTION),
1123
+ requestId: z15.string(),
1011
1124
  // TODO move into 'content' property
1012
1125
  content: ReasonContent
1013
1126
  }).shape
1014
1127
  );
1015
1128
  var ReadAction = ActionBase.extend(
1016
- z13.object({
1017
- type: z13.literal(ActionType.READ)
1129
+ z15.object({
1130
+ type: z15.literal(ActionType.READ)
1018
1131
  }).shape
1019
1132
  );
1020
1133
  var CustomAction = ActionBase.merge(
1021
- z13.object({
1022
- type: z13.literal(ActionType.CUSTOM),
1023
- customActionType: z13.string()
1134
+ z15.object({
1135
+ type: z15.literal(ActionType.CUSTOM),
1136
+ customActionType: z15.string()
1024
1137
  })
1025
1138
  );
1026
- var ActionDocument = z13.discriminatedUnion("type", [
1139
+ var ActionDocument = z15.discriminatedUnion("type", [
1027
1140
  CreatedAction.meta({ id: "CreatedAction" }),
1028
1141
  RejectAction.meta({ id: "RejectAction" }),
1029
1142
  DuplicateDetectedAction.meta({ id: "DuplicateDetectedAction" }),
1030
1143
  MarkNotDuplicateAction.meta({ id: "MarkNotDuplicateAction" }),
1031
1144
  MarkAsDuplicateAction.meta({ id: "MarkAsDuplicateAction" }),
1032
1145
  ArchiveAction.meta({ id: "ArchiveAction" }),
1146
+ UnarchiveAction.meta({ id: "UnarchiveAction" }),
1033
1147
  NotifiedAction.meta({ id: "NotifiedAction" }),
1034
1148
  RegisterAction.meta({ id: "RegisterAction" }),
1035
1149
  DeclareAction.meta({ id: "DeclareAction" }),
@@ -1049,108 +1163,50 @@ var AsyncRejectActionDocument = ActionBase.omit({
1049
1163
  declaration: true,
1050
1164
  annotation: true
1051
1165
  }).extend(
1052
- z13.object({
1053
- type: z13.enum(ConfirmableActions),
1054
- status: z13.literal(ActionStatus.Rejected)
1166
+ z15.object({
1167
+ type: z15.enum(ConfirmableActions),
1168
+ status: z15.literal(ActionStatus.Rejected)
1055
1169
  }).shape
1056
1170
  );
1057
- var Action = z13.union([ActionDocument, AsyncRejectActionDocument]);
1058
-
1059
- // ../commons/src/events/Flag.ts
1060
- var z14 = __toESM(require("zod/v4"));
1061
- var InherentFlags = {
1062
- INCOMPLETE: "incomplete",
1063
- REJECTED: "rejected",
1064
- CORRECTION_REQUESTED: "correction-requested",
1065
- POTENTIAL_DUPLICATE: "potential-duplicate",
1066
- /**
1067
- * This flag is set by the Edit-action and removed after the declaration or registration.
1068
- * A record should never stay with the EDIT_IN_PROGRESS flag, since it should always be declared or registered right after.
1069
- *
1070
- * We only use this flag to determine that a NOTIFY, DECLARE or REGISTER action is allowed next.
1071
- */
1072
- EDIT_IN_PROGRESS: "edit-in-progress"
1073
- };
1074
- var ActionFlag = z14.string().regex(
1075
- new RegExp(
1076
- `^(${Object.values(ActionType).join("|").toLowerCase()}):(${Object.values(
1077
- ActionStatus
1078
- ).join("|").toLowerCase()})$`
1079
- ),
1080
- "Flag must be in the format ActionType:ActionStatus (lowerCase)"
1081
- );
1082
- var CustomFlag = z14.string().refine((val) => !Object.values(InherentFlags).includes(val), {
1083
- message: `Custom flag cannot be one of the inherent flags: ${Object.values(
1084
- InherentFlags
1085
- ).join(", ")}`
1086
- }).refine((val) => !ActionFlag.safeParse(val).success, {
1087
- message: "Custom flag cannot match the ActionFlag pattern (ActionType:ActionStatus)."
1088
- }).describe("Custom flag identifier defined by the country config.");
1089
- var Flag = ActionFlag.or(z14.enum(InherentFlags)).or(CustomFlag);
1090
- var FlagConfig = z14.object({
1091
- id: CustomFlag,
1092
- requiresAction: z14.boolean().describe(
1093
- "Indicates if this flag expects an action to be performed to be cleared."
1094
- ),
1095
- label: TranslationConfig.describe("Human readable label of the flag.")
1096
- }).meta({
1097
- id: "FlagConfig",
1098
- description: "Configuration for a custom flag that can be added to or removed from records by event actions."
1099
- });
1100
- var ActionFlagConfig = z14.object({
1101
- id: Flag,
1102
- operation: z14.enum(["add", "remove"]).describe("Operation to perform on the flag."),
1103
- conditional: Conditional.optional().describe(
1104
- "When conditional is met, the operation is performed on the flag. If not provided, the operation is performed unconditionally."
1105
- )
1106
- }).meta({
1107
- id: "ActionFlagConfig",
1108
- description: "Add or remove operation applied to a flag when the parent action is accepted. Optionally gated by a conditional."
1109
- });
1171
+ var Action = z15.union([ActionDocument, AsyncRejectActionDocument]);
1110
1172
 
1111
1173
  // ../commons/src/events/EventMetadata.ts
1112
- var EventStatus = z15.enum([
1113
- "CREATED",
1114
- "NOTIFIED",
1115
- "DECLARED",
1116
- "REGISTERED",
1117
- "ARCHIVED"
1118
- ]);
1119
- var ZodDate = z15.iso.date();
1120
- var ZodDateTime = z15.string().datetime();
1121
- var ActionCreationMetadata = z15.object({
1122
- createdAt: z15.iso.datetime().describe("The timestamp when the action request was created."),
1123
- createdBy: z15.string().describe("ID of the user who created the action request."),
1174
+ var ZodDate = z16.iso.date();
1175
+ var ZodDateTime = z16.string().datetime();
1176
+ var ActionCreationMetadata = z16.object({
1177
+ createdAt: z16.iso.datetime().describe("The timestamp when the action request was created."),
1178
+ createdBy: z16.string().describe("ID of the user who created the action request."),
1124
1179
  // @TODO: createdAtLocation should be non-nullable in the future once all action requests have this field populated.
1125
1180
  createdAtLocation: UUID.nullish().describe(
1126
1181
  "Location of the user who created the action request."
1127
1182
  ),
1128
- createdByUserType: z15.enum(["user", "system"]).nullish().describe("Whether the user is a normal user or a system."),
1129
- acceptedAt: z15.iso.datetime().describe("Timestamp when the action request was accepted."),
1130
- createdByRole: z15.string().optional().describe("Role of the user at the time of action request creation.")
1183
+ createdByUserType: z16.enum(["user", "system"]).nullish().describe("Whether the user is a normal user or a system."),
1184
+ acceptedAt: z16.iso.datetime().describe("Timestamp when the action request was accepted."),
1185
+ createdByRole: z16.string().optional().describe("Role of the user at the time of action request creation.")
1131
1186
  });
1132
1187
  var RegistrationCreationMetadata = ActionCreationMetadata.extend({
1133
- registrationNumber: z15.string().describe(
1188
+ registrationNumber: z16.string().describe(
1134
1189
  "Registration number of the event. Always present for accepted registrations."
1135
1190
  )
1136
1191
  });
1137
- var LegalStatuses = z15.object({
1192
+ var LegalStatuses = z16.object({
1193
+ [EventStatus.enum.NOTIFIED]: ActionCreationMetadata.nullish(),
1138
1194
  [EventStatus.enum.DECLARED]: ActionCreationMetadata.nullish(),
1139
1195
  [EventStatus.enum.REGISTERED]: RegistrationCreationMetadata.nullish()
1140
1196
  });
1141
- var EventMetadata = z15.object({
1197
+ var EventMetadata = z16.object({
1142
1198
  id: UUID,
1143
- type: z15.string().describe("The type of event, such as birth, death, or marriage."),
1199
+ type: z16.string().describe("The type of event, such as birth, death, or marriage."),
1144
1200
  status: EventStatus,
1145
1201
  legalStatuses: LegalStatuses.describe(
1146
1202
  "Metadata related to the legal registration of the event, such as who registered it and when."
1147
1203
  ),
1148
- createdAt: z15.iso.datetime().describe("The timestamp when the event was first created and saved."),
1204
+ createdAt: z16.iso.datetime().describe("The timestamp when the event was first created and saved."),
1149
1205
  dateOfEvent: ZodDate.nullish(),
1150
1206
  placeOfEvent: UUID.nullish(),
1151
- createdBy: z15.string().describe("ID of the user who created the event."),
1152
- createdByUserType: z15.enum(["user", "system"]).nullish().describe("Whether the user is a normal user or a system."),
1153
- updatedByUserRole: z15.string().nullish().describe("Role of the user who last changed the status."),
1207
+ createdBy: z16.string().describe("ID of the user who created the event."),
1208
+ createdByUserType: z16.enum(["user", "system"]).nullish().describe("Whether the user is a normal user or a system."),
1209
+ updatedByUserRole: z16.string().nullish().describe("Role of the user who last changed the status."),
1154
1210
  // @TODO: createdAtLocation should be non-nullable in the future once all action requests have this field populated.
1155
1211
  createdAtLocation: UUID.nullish().describe(
1156
1212
  "Location of the user who created the event."
@@ -1158,18 +1214,18 @@ var EventMetadata = z15.object({
1158
1214
  updatedAtLocation: UUID.nullish().describe(
1159
1215
  "Location of the user who last changed the status."
1160
1216
  ),
1161
- updatedAt: z15.iso.datetime().describe(
1217
+ updatedAt: z16.iso.datetime().describe(
1162
1218
  "Timestamp of the most recent *accepted* status change. Possibly 3rd party update, if action is validation asynchronously."
1163
1219
  ),
1164
- assignedTo: z15.string().nullish().describe("ID of the user currently assigned to the event."),
1165
- updatedBy: z15.string().nullish().describe("ID of the user who last changed the status."),
1166
- trackingId: z15.string().describe(
1220
+ assignedTo: z16.string().nullish().describe("ID of the user currently assigned to the event."),
1221
+ updatedBy: z16.string().nullish().describe("ID of the user who last changed the status."),
1222
+ trackingId: z16.string().describe(
1167
1223
  "System-generated tracking ID used by informants or registrars to look up the event."
1168
1224
  ),
1169
- potentialDuplicates: z15.array(PotentialDuplicate).describe(
1225
+ potentialDuplicates: z16.array(PotentialDuplicate).describe(
1170
1226
  "List of event IDs and their tracking IDs that this event could be a duplicate of."
1171
1227
  ),
1172
- flags: z15.array(Flag)
1228
+ flags: z16.array(Flag)
1173
1229
  });
1174
1230
  var EventMetadataKeysArray = [
1175
1231
  "id",
@@ -1190,18 +1246,22 @@ var EventMetadataKeysArray = [
1190
1246
  "legalStatuses",
1191
1247
  "flags"
1192
1248
  ];
1193
- var EventMetadataKeys = z15.enum(EventMetadataKeysArray);
1194
- var EventMetadataDateFieldIdInput = z15.enum([
1249
+ var EventMetadataKeys = z16.enum(EventMetadataKeysArray);
1250
+ var EventMetadataDateFieldIdInput = z16.enum([
1195
1251
  "createdAt",
1196
1252
  "updatedAt",
1253
+ "legalStatuses.NOTIFIED.createdAt",
1254
+ "legalStatuses.NOTIFIED.acceptedAt",
1197
1255
  "legalStatuses.DECLARED.createdAt",
1198
1256
  "legalStatuses.DECLARED.acceptedAt",
1199
1257
  "legalStatuses.REGISTERED.createdAt",
1200
1258
  "legalStatuses.REGISTERED.acceptedAt"
1201
1259
  ]);
1202
- var EventMetadataDateFieldId = z15.enum([
1260
+ var EventMetadataDateFieldId = z16.enum([
1203
1261
  "event.createdAt",
1204
1262
  "event.updatedAt",
1263
+ "event.legalStatuses.NOTIFIED.createdAt",
1264
+ "event.legalStatuses.NOTIFIED.acceptedAt",
1205
1265
  "event.legalStatuses.DECLARED.createdAt",
1206
1266
  "event.legalStatuses.DECLARED.acceptedAt",
1207
1267
  "event.legalStatuses.REGISTERED.createdAt",
@@ -1262,12 +1322,6 @@ var Range = import_v4.z.object({
1262
1322
  }).meta({
1263
1323
  id: "Range"
1264
1324
  });
1265
- var ContainsFlags = import_v4.z.object({
1266
- anyOf: import_v4.z.array(Flag).optional(),
1267
- noneOf: import_v4.z.array(Flag).optional()
1268
- }).meta({
1269
- id: "ContainsFlags"
1270
- });
1271
1325
  var Within = import_v4.z.object({ type: import_v4.z.literal("within"), location: import_v4.z.string() }).meta({
1272
1326
  id: "Within"
1273
1327
  });
@@ -1462,8 +1516,8 @@ var BaseField = import_v43.default.object({
1462
1516
  conditionals: import_v43.default.array(FieldConditional).default([]).optional().describe(
1463
1517
  "Conditions determining when the field is shown or enabled. By default, the field is always shown and enabled."
1464
1518
  ),
1465
- secured: import_v43.default.boolean().default(false).optional().describe(
1466
- "Indicates whether the field is secured. Secured fields are not indexed for search and are only visible when explicitly assigned."
1519
+ secured: import_v43.default.union([import_v43.default.boolean(), Conditional]).default(false).optional().describe(
1520
+ "Indicates whether the field is secured, either always (boolean) or conditionally, evaluated against the event (a JSONSchema conditional, e.g. flag('sealed')). Secured fields are not indexed for search and are only visible when explicitly assigned."
1467
1521
  ),
1468
1522
  placeholder: TranslationConfig.optional(),
1469
1523
  validation: import_v43.default.array(ValidationConfig).default([]).optional().describe("Additional validation rules applied to the field."),
@@ -1861,7 +1915,13 @@ var AdministrativeAreaField = BaseField.extend({
1861
1915
  configuration: import_v43.default.object({
1862
1916
  partOf: FieldReference.optional().describe("Parent location"),
1863
1917
  type: AdministrativeAreas,
1864
- allowedLocations: AllowedLocations
1918
+ allowedLocations: AllowedLocations,
1919
+ activeOnly: import_v43.default.boolean().optional().describe(
1920
+ "Offer only locations that are active at the resolved anchor date (today, or the date of event when anchorToDateOfEvent is set); inactive or not-yet-effective versions are excluded."
1921
+ ),
1922
+ anchorToDateOfEvent: import_v43.default.boolean().optional().describe(
1923
+ "Resolve selectable/displayed versions against the event's date of event (falling back to the record's creation date when empty) instead of today. Does not by itself exclude inactive versions; combine with activeOnly for that."
1924
+ )
1865
1925
  }).describe("Administrative area options")
1866
1926
  }).meta({
1867
1927
  description: "Administrative area input field",
@@ -1872,7 +1932,13 @@ var LocationInput = BaseField.extend({
1872
1932
  defaultValue: import_v43.default.union([NonEmptyTextValue, SerializedUserField, ComputedDefaultValue]).optional(),
1873
1933
  configuration: import_v43.default.object({
1874
1934
  locationTypes: import_v43.default.array(import_v43.default.string()).optional().describe("Types of the locations that are available for selection."),
1875
- allowedLocations: AllowedLocations
1935
+ allowedLocations: AllowedLocations,
1936
+ activeOnly: import_v43.default.boolean().optional().describe(
1937
+ "Offer only locations that are active at the resolved anchor date (today, or the date of event when anchorToDateOfEvent is set); inactive or not-yet-effective versions are excluded."
1938
+ ),
1939
+ anchorToDateOfEvent: import_v43.default.boolean().optional().describe(
1940
+ "Resolve selectable/displayed versions against the event's date of event (falling back to the record's creation date when empty) instead of today. Does not by itself exclude inactive versions; combine with activeOnly for that."
1941
+ )
1876
1942
  }).optional()
1877
1943
  }).meta({
1878
1944
  description: "A field for selecting a location",
@@ -1898,12 +1964,20 @@ var FileUploadWithOptions = BaseField.extend({
1898
1964
  var Facility = BaseField.extend({
1899
1965
  type: import_v43.default.literal(FieldType.FACILITY),
1900
1966
  defaultValue: NonEmptyTextValue.or(ComputedDefaultValue).optional(),
1901
- configuration: import_v43.default.object({ allowedLocations: AllowedLocations }).optional()
1967
+ configuration: import_v43.default.object({
1968
+ allowedLocations: AllowedLocations,
1969
+ activeOnly: import_v43.default.boolean().optional(),
1970
+ anchorToDateOfEvent: import_v43.default.boolean().optional()
1971
+ }).optional()
1902
1972
  }).describe("Input field for a facility");
1903
1973
  var Office = BaseField.extend({
1904
1974
  type: import_v43.default.literal(FieldType.OFFICE),
1905
1975
  defaultValue: NonEmptyTextValue.or(ComputedDefaultValue).optional(),
1906
- configuration: import_v43.default.object({ allowedLocations: AllowedLocations }).optional()
1976
+ configuration: import_v43.default.object({
1977
+ allowedLocations: AllowedLocations,
1978
+ activeOnly: import_v43.default.boolean().optional(),
1979
+ anchorToDateOfEvent: import_v43.default.boolean().optional()
1980
+ }).optional()
1907
1981
  }).describe("Input field for an office");
1908
1982
  var DefaultAddressFieldValue = DomesticAddressFieldValue.extend({
1909
1983
  administrativeArea: import_v43.default.union([UUID, SerializedUserField]).optional()
@@ -1936,7 +2010,13 @@ var Address = BaseField.extend({
1936
2010
  parent: FieldReference.optional()
1937
2011
  })
1938
2012
  ).optional(),
1939
- allowedLocations: AllowedLocations
2013
+ allowedLocations: AllowedLocations,
2014
+ activeOnly: import_v43.default.boolean().optional().describe(
2015
+ "Offer only admin areas that are active at the resolved anchor date (today, or the date of event when anchorToDateOfEvent is set); inactive or not-yet-effective versions are excluded. Propagated to the embedded admin-area selectors."
2016
+ ),
2017
+ anchorToDateOfEvent: import_v43.default.boolean().optional().describe(
2018
+ "Resolve selectable/displayed versions against the event's date of event (falling back to the record's creation date when empty) instead of today. Does not by itself exclude inactive versions; combine with activeOnly for that. Propagated to the embedded admin-area selectors."
2019
+ )
1940
2020
  }).optional(),
1941
2021
  defaultValue: DefaultAddressFieldValue.or(ComputedDefaultValue).optional()
1942
2022
  }).meta({
@@ -1991,10 +2071,19 @@ var ButtonField = BaseField.extend({
1991
2071
  description: "A generic button that can be used to trigger an action",
1992
2072
  id: "ButtonField"
1993
2073
  });
2074
+ var FieldGroupConfiguration = import_v43.default.object({
2075
+ separator: import_v43.default.string().optional().describe(
2076
+ 'Joins the subfield values when the group is rendered as output, e.g. ", ". Defaults to one subfield per line.'
2077
+ ),
2078
+ hideEmptyFields: import_v43.default.boolean().default(false).optional().describe(
2079
+ "Leaves subfields without a value out of the output. Pair it with a separator so the separator does not double up around the gaps."
2080
+ )
2081
+ });
1994
2082
  var FieldGroup = BaseField.extend({
1995
2083
  type: import_v43.default.literal(FieldType.FIELD_GROUP),
1996
2084
  // eslint-disable-next-line @typescript-eslint/no-use-before-define
1997
- fields: import_v43.default.lazy(() => import_v43.default.array(FieldConfig))
2085
+ fields: import_v43.default.lazy(() => import_v43.default.array(FieldConfig)),
2086
+ configuration: FieldGroupConfiguration.optional()
1998
2087
  }).meta({
1999
2088
  description: "A group of fields that are displayed together",
2000
2089
  id: "FieldGroup"
@@ -2237,7 +2326,7 @@ var AnyFileField = import_v43.default.discriminatedUnion("type", [
2237
2326
  ]);
2238
2327
 
2239
2328
  // ../commons/src/application-config.ts
2240
- var SearchCriteria = z20.enum([
2329
+ var SearchCriteria = z21.enum([
2241
2330
  "TRACKING_ID",
2242
2331
  "REGISTRATION_NUMBER",
2243
2332
  "NATIONAL_ID",
@@ -2245,69 +2334,69 @@ var SearchCriteria = z20.enum([
2245
2334
  "PHONE_NUMBER",
2246
2335
  "EMAIL"
2247
2336
  ]);
2248
- var ApplicationConfig = z20.object({
2249
- APPLICATION_NAME: z20.string(),
2250
- COUNTRY_LOGO: z20.object({
2251
- fileName: z20.string(),
2252
- file: z20.string()
2337
+ var ApplicationConfig = z21.object({
2338
+ APPLICATION_NAME: z21.string(),
2339
+ COUNTRY_LOGO: z21.object({
2340
+ fileName: z21.string(),
2341
+ file: z21.string()
2253
2342
  }),
2254
- SYSTEM_IANA_TIMEZONE: z20.string(),
2255
- CURRENCY: z20.object({
2256
- languagesAndCountry: z20.array(z20.string()),
2257
- isoCode: z20.string()
2343
+ SYSTEM_IANA_TIMEZONE: z21.string(),
2344
+ CURRENCY: z21.object({
2345
+ languagesAndCountry: z21.array(z21.string()),
2346
+ isoCode: z21.string()
2258
2347
  }),
2259
- ADMIN_STRUCTURE: z20.array(
2260
- z20.object({
2261
- id: z20.string(),
2348
+ ADMIN_STRUCTURE: z21.array(
2349
+ z21.object({
2350
+ id: z21.string(),
2262
2351
  label: TranslationConfig
2263
2352
  })
2264
2353
  ),
2265
- PHONE_NUMBER_PATTERN: z20.string().or(z20.instanceof(RegExp)),
2266
- USER_NOTIFICATION_DELIVERY_METHOD: z20.enum(["email", "sms"]),
2267
- INFORMANT_NOTIFICATION_DELIVERY_METHOD: z20.enum(["email", "sms"]),
2354
+ PHONE_NUMBER_PATTERN: z21.string().or(z21.instanceof(RegExp)),
2355
+ USER_NOTIFICATION_DELIVERY_METHOD: z21.enum(["email", "sms"]),
2356
+ INFORMANT_NOTIFICATION_DELIVERY_METHOD: z21.enum(["email", "sms"]),
2268
2357
  SEARCH_DEFAULT_CRITERIA: SearchCriteria.optional().default("TRACKING_ID"),
2269
- ADDITIONAL_USER_FIELDS: z20.array(FieldConfig).optional().default([])
2358
+ ADDITIONAL_USER_FIELDS: z21.array(FieldConfig).optional().default([])
2270
2359
  });
2271
2360
  var defineApplicationConfig = (config) => {
2272
2361
  return ApplicationConfig.parse(config);
2273
2362
  };
2274
- var BackgroundConfig = z20.object({
2275
- backgroundColor: z20.string().optional(),
2276
- backgroundImage: z20.string().optional(),
2277
- imageFit: z20.string().optional()
2363
+ var BackgroundConfig = z21.object({
2364
+ backgroundColor: z21.string().optional(),
2365
+ backgroundImage: z21.string().optional(),
2366
+ imageFit: z21.string().optional()
2278
2367
  }).refine(
2279
2368
  (data) => !!(data.backgroundColor || data.backgroundImage),
2280
2369
  "backgroundColor and backgroundImage cannot be empty at the same time"
2281
2370
  );
2282
- var LoginConfig = z20.object({
2283
- COUNTRY: z20.string(),
2284
- LANGUAGES: z20.array(z20.string()),
2285
- USER_NOTIFICATION_DELIVERY_METHOD: z20.enum(["email", "sms"]),
2286
- INFORMANT_NOTIFICATION_DELIVERY_METHOD: z20.enum(["email", "sms"]),
2287
- PHONE_NUMBER_PATTERN: z20.string().or(z20.instanceof(RegExp)),
2371
+ var LoginConfig = z21.object({
2372
+ COUNTRY: z21.string(),
2373
+ LANGUAGES: z21.array(z21.string()),
2374
+ USER_NOTIFICATION_DELIVERY_METHOD: z21.enum(["email", "sms"]),
2375
+ INFORMANT_NOTIFICATION_DELIVERY_METHOD: z21.enum(["email", "sms"]),
2376
+ PHONE_NUMBER_PATTERN: z21.string().or(z21.instanceof(RegExp)),
2288
2377
  LOGIN_BACKGROUND: BackgroundConfig,
2289
- SENTRY: z20.string().optional()
2378
+ SENTRY: z21.string().optional()
2290
2379
  });
2291
2380
  var defineLoginConfig = (config) => {
2292
2381
  return LoginConfig.parse(config);
2293
2382
  };
2294
- var ClientConfig = z20.object({
2295
- COUNTRY: z20.string(),
2296
- LANGUAGES: z20.array(z20.string()),
2297
- SENTRY: z20.string().optional(),
2298
- LOGIN_URL: z20.string().optional(),
2383
+ var ClientConfig = z21.object({
2384
+ COUNTRY: z21.string(),
2385
+ LANGUAGES: z21.array(z21.string()),
2386
+ SENTRY: z21.string().optional(),
2387
+ LOGIN_URL: z21.string().optional(),
2299
2388
  REGISTER_BACKGROUND: BackgroundConfig,
2300
- DASHBOARDS: z20.array(
2301
- z20.object({
2302
- id: z20.string(),
2389
+ DASHBOARDS: z21.array(
2390
+ z21.object({
2391
+ id: z21.string(),
2303
2392
  title: TranslationConfig,
2304
- url: z20.string(),
2305
- context: z20.object({
2306
- auth: z20.literal("REQUEST_AUTH_TOKEN")
2393
+ url: z21.string(),
2394
+ context: z21.object({
2395
+ auth: z21.literal("REQUEST_AUTH_TOKEN")
2307
2396
  }).optional()
2308
2397
  })
2309
2398
  ),
2310
- FEATURES: z20.object({ V2_EVENTS: z20.boolean().optional().default(true) }).optional().default({ V2_EVENTS: true })
2399
+ FEATURES: z21.object({ V2_EVENTS: z21.boolean().optional().default(true) }).optional().default({ V2_EVENTS: true })
2311
2400
  });
2312
2401
  var defineClientConfig = (config) => {
2313
2402
  return ClientConfig.parse(config);