@opencrvs/toolkit 2.2.0-rc.90ed9cd → 2.2.0-rc.9dfc125

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 (141) hide show
  1. package/build.sh +2 -12
  2. package/dist/application-config/index.js +5 -6
  3. package/dist/authentication/index.d.ts +1 -0
  4. package/dist/authentication/index.js +16 -5
  5. package/dist/cli.js +875 -193
  6. package/dist/commons/api/router.d.ts +246 -246
  7. package/dist/commons/application-config/index.d.ts +2 -2
  8. package/dist/commons/conditionals/index.d.ts +1 -0
  9. package/dist/commons/conditionals/validate.d.ts +5 -0
  10. package/dist/commons/events/ActionConfig.d.ts +16 -23
  11. package/dist/commons/events/ActionDocument.d.ts +1 -0
  12. package/dist/commons/events/ActionInput.d.ts +4 -4
  13. package/dist/commons/events/CompositeFieldValue.d.ts +5 -1
  14. package/dist/commons/events/CountryConfigQueryInput.d.ts +0 -18
  15. package/dist/commons/events/EventConfig.d.ts +12 -2
  16. package/dist/commons/events/EventIndex.d.ts +2 -6
  17. package/dist/commons/events/EventMetadata.d.ts +0 -1
  18. package/dist/commons/events/FieldConfig.d.ts +1 -1
  19. package/dist/commons/events/FieldTypeMapping.d.ts +6 -6
  20. package/dist/commons/events/Flag.d.ts +1 -7
  21. package/dist/commons/events/PlainDate.d.ts +1 -0
  22. package/dist/commons/events/WorkqueueConfig.d.ts +12 -27
  23. package/dist/commons/events/eventConfigValidation.d.ts +9 -0
  24. package/dist/commons/events/index.d.ts +2 -0
  25. package/dist/commons/events/notificationFormFallback.d.ts +10 -0
  26. package/dist/commons/events/state/flags.d.ts +1 -1
  27. package/dist/commons/events/test.utils.d.ts +3 -0
  28. package/dist/commons/events/utils.d.ts +85 -56
  29. package/dist/conditionals/index.js +2 -3
  30. package/dist/environment/custom-types.d.ts +1 -0
  31. package/dist/environment/custom-types.d.ts.map +1 -1
  32. package/dist/environment/derived-variables.d.ts +12 -4
  33. package/dist/environment/derived-variables.d.ts.map +1 -1
  34. package/dist/environment/derived-variables.js +13 -4
  35. package/dist/environment/questions.d.ts +14 -2
  36. package/dist/environment/questions.d.ts.map +1 -1
  37. package/dist/environment/questions.js +40 -19
  38. package/dist/environment/registry.d.ts +15 -0
  39. package/dist/environment/registry.d.ts.map +1 -0
  40. package/dist/environment/registry.js +112 -0
  41. package/dist/environment/setup-environment.d.ts.map +1 -1
  42. package/dist/environment/setup-environment.js +111 -24
  43. package/dist/environment/templates.d.ts.map +1 -1
  44. package/dist/events/index.js +242 -65
  45. package/dist/migrations/index.d.ts +9 -0
  46. package/dist/migrations/index.d.ts.map +1 -0
  47. package/dist/migrations/index.js +847 -0
  48. package/dist/migrations/move-declaration-to-declare-action.d.ts +38 -0
  49. package/dist/migrations/move-declaration-to-declare-action.d.ts.map +1 -0
  50. package/dist/migrations/move-declaration-to-declare-action.js +377 -0
  51. package/dist/migrations/{add-translations.d.ts → persistent/add-translations.d.ts} +1 -1
  52. package/dist/migrations/persistent/add-translations.d.ts.map +1 -0
  53. package/dist/migrations/{add-translations.js → persistent/add-translations.js} +2 -2
  54. package/dist/migrations/persistent/check-upgrade-path.d.ts +36 -0
  55. package/dist/migrations/persistent/check-upgrade-path.d.ts.map +1 -0
  56. package/dist/migrations/persistent/check-upgrade-path.js +105 -0
  57. package/dist/migrations/persistent/update-toolkit-dependency.d.ts +7 -0
  58. package/dist/migrations/persistent/update-toolkit-dependency.d.ts.map +1 -0
  59. package/dist/migrations/persistent/update-toolkit-dependency.js +77 -0
  60. package/dist/migrations/{v2.2/read-declaration-through-helper.d.ts → read-declaration-through-helper.d.ts} +1 -1
  61. package/dist/migrations/read-declaration-through-helper.d.ts.map +1 -0
  62. package/dist/migrations/{v2.2/read-declaration-through-helper.js → read-declaration-through-helper.js} +1 -1
  63. package/dist/migrations/replace-incomplete-flag.d.ts +26 -0
  64. package/dist/migrations/replace-incomplete-flag.d.ts.map +1 -0
  65. package/dist/migrations/replace-incomplete-flag.js +126 -0
  66. package/dist/notification/index.js +143 -19
  67. package/dist/scopes/index.d.ts +54 -84
  68. package/dist/scopes/index.js +12 -5
  69. package/dist/templates/charts-values/dependencies/values.yaml +1 -1
  70. package/dist/templates/charts-values/opencrvs-services/values.yaml +4 -6
  71. package/dist/templates/charts-values/traefik/values.yaml +2 -0
  72. package/opencrvs-toolkit-2.2.0-rc.9dfc125.tgz +0 -0
  73. package/package.json +2 -2
  74. package/tsconfig.build.tsbuildinfo +1 -1
  75. package/dist/migrations/add-translations.d.ts.map +0 -1
  76. package/dist/migrations/v2.1/add-explicit-correction-flags.d.ts +0 -3
  77. package/dist/migrations/v2.1/add-explicit-correction-flags.d.ts.map +0 -1
  78. package/dist/migrations/v2.1/add-explicit-correction-flags.js +0 -234
  79. package/dist/migrations/v2.1/add-recovery-link-notifications.d.ts +0 -3
  80. package/dist/migrations/v2.1/add-recovery-link-notifications.d.ts.map +0 -1
  81. package/dist/migrations/v2.1/add-recovery-link-notifications.js +0 -511
  82. package/dist/migrations/v2.1/enable-telemetry.d.ts +0 -3
  83. package/dist/migrations/v2.1/enable-telemetry.d.ts.map +0 -1
  84. package/dist/migrations/v2.1/enable-telemetry.js +0 -455
  85. package/dist/migrations/v2.1/index.d.ts +0 -6
  86. package/dist/migrations/v2.1/index.d.ts.map +0 -1
  87. package/dist/migrations/v2.1/index.js +0 -50
  88. package/dist/migrations/v2.1/migrate-infrastructure-to-assets.d.ts +0 -17
  89. package/dist/migrations/v2.1/migrate-infrastructure-to-assets.d.ts.map +0 -1
  90. package/dist/migrations/v2.1/migrate-infrastructure-to-assets.js +0 -348
  91. package/dist/migrations/v2.1/remove-metabase-package-installs.d.ts +0 -2
  92. package/dist/migrations/v2.1/remove-metabase-package-installs.d.ts.map +0 -1
  93. package/dist/migrations/v2.1/remove-metabase-package-installs.js +0 -161
  94. package/dist/migrations/v2.1/remove-sentry.d.ts +0 -3
  95. package/dist/migrations/v2.1/remove-sentry.d.ts.map +0 -1
  96. package/dist/migrations/v2.1/remove-sentry.js +0 -354
  97. package/dist/migrations/v2.1/rename-trigger-paths.d.ts +0 -3
  98. package/dist/migrations/v2.1/rename-trigger-paths.d.ts.map +0 -1
  99. package/dist/migrations/v2.1/rename-trigger-paths.js +0 -216
  100. package/dist/migrations/v2.1/template-files.d.ts +0 -8
  101. package/dist/migrations/v2.1/template-files.d.ts.map +0 -1
  102. package/dist/migrations/v2.1/template-files.js +0 -49
  103. package/dist/migrations/v2.1/upgrade-tilt.d.ts +0 -11
  104. package/dist/migrations/v2.1/upgrade-tilt.d.ts.map +0 -1
  105. package/dist/migrations/v2.1/upgrade-tilt.js +0 -139
  106. package/dist/migrations/v2.2/index.d.ts +0 -6
  107. package/dist/migrations/v2.2/index.d.ts.map +0 -1
  108. package/dist/migrations/v2.2/index.js +0 -456
  109. package/dist/migrations/v2.2/read-declaration-through-helper.d.ts.map +0 -1
  110. package/dist/templates/countryconfig-template/.tiltignore +0 -1
  111. package/dist/templates/countryconfig-template/Dockerfile.assets +0 -7
  112. package/dist/templates/countryconfig-template/Tiltfile +0 -112
  113. package/dist/templates/countryconfig-template/assets/README.md +0 -1
  114. package/dist/templates/countryconfig-template/assets/clear-all-data-dev.sh +0 -61
  115. package/dist/templates/countryconfig-template/assets/deployment/deploy.sh +0 -455
  116. package/dist/templates/countryconfig-template/assets/deployment/reindex.sh +0 -168
  117. package/dist/templates/countryconfig-template/assets/deployment/validate-required-variables-in-compose-files.ts +0 -67
  118. package/dist/templates/countryconfig-template/assets/elasticsearch/reindex.sh +0 -168
  119. package/dist/templates/countryconfig-template/assets/metabase/README.md +0 -34
  120. package/dist/templates/countryconfig-template/assets/metabase/environment-configuration.sql +0 -36
  121. package/dist/templates/countryconfig-template/assets/metabase/initialize-database.sh +0 -46
  122. package/dist/templates/countryconfig-template/assets/metabase/metabase.init.db.sql +0 -27737
  123. package/dist/templates/countryconfig-template/assets/metabase/open-shell.sh +0 -21
  124. package/dist/templates/countryconfig-template/assets/metabase/package.json +0 -13
  125. package/dist/templates/countryconfig-template/assets/metabase/run-dev.sh +0 -108
  126. package/dist/templates/countryconfig-template/assets/metabase/run.sh +0 -120
  127. package/dist/templates/countryconfig-template/assets/metabase/update-database.sh +0 -40
  128. package/dist/templates/countryconfig-template/assets/postgres/setup-analytics.sh +0 -135
  129. package/dist/templates/countryconfig-template/assets/postgres/setup-reference-data.sh +0 -108
  130. package/dist/templates/countryconfig-template/tilt/clear-all-data.ps1 +0 -50
  131. package/dist/templates/countryconfig-template/tilt/clear-all-data.sh +0 -35
  132. package/dist/templates/countryconfig-template/tilt/common.tilt +0 -145
  133. package/dist/templates/countryconfig-template/tilt/examples/dependencies/values.yaml +0 -15
  134. package/dist/templates/countryconfig-template/tilt/examples/opencrvs-services/values.yaml +0 -56
  135. package/dist/templates/countryconfig-template/tilt/examples/traefik/values-minikube.yaml +0 -21
  136. package/dist/templates/countryconfig-template/tilt/examples/traefik/values.yaml +0 -38
  137. package/dist/templates/countryconfig-template/tilt/helm/dependencies/values.yaml +0 -17
  138. package/dist/templates/countryconfig-template/tilt/helm/opencrvs-services/values.yaml +0 -16
  139. package/dist/templates/countryconfig-template/tilt/lib.tilt +0 -95
  140. package/dist/templates/countryconfig-template/tilt/opencrvs.tilt +0 -136
  141. package/opencrvs-toolkit-2.2.0-rc.90ed9cd.tgz +0 -0
@@ -339,6 +339,7 @@ __export(events_exports, {
339
339
  getActionAnnotation: () => getActionAnnotation,
340
340
  getActionAnnotationFields: () => getActionAnnotationFields,
341
341
  getActionConfig: () => getActionConfig,
342
+ getActionForm: () => getActionForm,
342
343
  getActionFormFields: () => getActionFormFields,
343
344
  getActionReview: () => getActionReview,
344
345
  getActionReviewFields: () => getActionReviewFields,
@@ -367,6 +368,8 @@ __export(events_exports, {
367
368
  getLeafAdministrativeAreaIds: () => getLeafAdministrativeAreaIds,
368
369
  getLocationHierarchy: () => getLocationHierarchy,
369
370
  getMixedPath: () => getMixedPath,
371
+ getNotificationFields: () => getNotificationFields,
372
+ getNotificationForm: () => getNotificationForm,
370
373
  getPendingAction: () => getPendingAction,
371
374
  getPrintCertificatePages: () => getPrintCertificatePages,
372
375
  getRandomDate: () => getRandomDate,
@@ -377,10 +380,12 @@ __export(events_exports, {
377
380
  hasAnyOfScopes: () => hasAnyOfScopes,
378
381
  isActionAvailable: () => isActionAvailable,
379
382
  isActionConfigType: () => isActionConfigType,
383
+ isActionDocument: () => isActionDocument,
380
384
  isActionEnabled: () => isActionEnabled,
381
385
  isActionInScope: () => isActionInScope,
382
386
  isActionVisible: () => isActionVisible,
383
387
  isAddressFieldType: () => isAddressFieldType,
388
+ isAddressFieldValue: () => isAddressFieldValue,
384
389
  isAdministrativeAreaFieldType: () => isAdministrativeAreaFieldType,
385
390
  isAgeFieldType: () => isAgeFieldType,
386
391
  isAutocompleteFieldType: () => isAutocompleteFieldType,
@@ -395,6 +400,7 @@ __export(events_exports, {
395
400
  isDateFieldType: () => isDateFieldType,
396
401
  isDateRangeFieldType: () => isDateRangeFieldType,
397
402
  isDividerFieldType: () => isDividerFieldType,
403
+ isDomesticAddressFieldValue: () => isDomesticAddressFieldValue,
398
404
  isEmailFieldType: () => isEmailFieldType,
399
405
  isEventFieldReference: () => isEventFieldReference,
400
406
  isFacilityFieldType: () => isFacilityFieldType,
@@ -408,7 +414,9 @@ __export(events_exports, {
408
414
  isFieldValueWithoutTemplates: () => isFieldValueWithoutTemplates,
409
415
  isFieldVisible: () => isFieldVisible,
410
416
  isFileFieldType: () => isFileFieldType,
417
+ isFileFieldValue: () => isFileFieldValue,
411
418
  isFileFieldWithOptionType: () => isFileFieldWithOptionType,
419
+ isFileFieldWithOptionValue: () => isFileFieldWithOptionValue,
412
420
  isHeadingFieldType: () => isHeadingFieldType,
413
421
  isHiddenFieldType: () => isHiddenFieldType,
414
422
  isHttpFieldType: () => isHttpFieldType,
@@ -429,6 +437,7 @@ __export(events_exports, {
429
437
  isPageVisible: () => isPageVisible,
430
438
  isParagraphFieldType: () => isParagraphFieldType,
431
439
  isPhoneFieldType: () => isPhoneFieldType,
440
+ isPlainDate: () => isPlainDate,
432
441
  isPotentialDuplicate: () => isPotentialDuplicate,
433
442
  isPrintButtonFieldType: () => isPrintButtonFieldType,
434
443
  isQrReaderFieldType: () => isQrReaderFieldType,
@@ -490,6 +499,9 @@ __export(events_exports, {
490
499
  });
491
500
  module.exports = __toCommonJS(events_exports);
492
501
 
502
+ // ../commons/src/events/index.ts
503
+ var import_compile = require("zod/compile");
504
+
493
505
  // ../commons/src/events/AuditLog.ts
494
506
  var z9 = __toESM(require("zod/v4"));
495
507
 
@@ -508,6 +520,12 @@ var UUID = z.uuid().brand("UUID");
508
520
  function getUUID() {
509
521
  return (0, import_uuid.v4)();
510
522
  }
523
+ function isUUID(id) {
524
+ return UUID.validate(id);
525
+ }
526
+ function maybeUuid(value) {
527
+ return isUUID(value) ? value : void 0;
528
+ }
511
529
 
512
530
  // ../commons/src/events/ActionType.ts
513
531
  var z2 = __toESM(require("zod/v4"));
@@ -639,7 +657,7 @@ var ActionStatus = {
639
657
  };
640
658
 
641
659
  // ../commons/src/events/Flag.ts
642
- var z5 = __toESM(require("zod/v4"));
660
+ var z5 = __toESM(require("zod"));
643
661
 
644
662
  // ../commons/src/events/TranslationConfig.ts
645
663
  var z3 = __toESM(require("zod/v4"));
@@ -708,7 +726,6 @@ var FieldConditional = z4.discriminatedUnion("type", [
708
726
 
709
727
  // ../commons/src/events/Flag.ts
710
728
  var InherentFlags = {
711
- INCOMPLETE: "incomplete",
712
729
  REJECTED: "rejected",
713
730
  CORRECTION_REQUESTED: "correction-requested",
714
731
  POTENTIAL_DUPLICATE: "potential-duplicate",
@@ -736,7 +753,7 @@ var CustomFlag = z5.string().refine((val) => !Object.values(InherentFlags).inclu
736
753
  message: `Custom flag cannot be one of the inherent flags: ${Object.values(
737
754
  InherentFlags
738
755
  ).join(", ")}`
739
- }).refine((val) => !ActionFlag.safeParse(val).success, {
756
+ }).refine((val) => !ActionFlag.validate(val), {
740
757
  message: "Custom flag cannot match the ActionFlag pattern (ActionType:ActionStatus)."
741
758
  }).describe("Custom flag identifier defined by the country config.");
742
759
  var Flag = ActionFlag.or(z5.enum(InherentFlags)).or(CustomFlag);
@@ -1509,7 +1526,7 @@ var z14 = __toESM(require("zod/v4"));
1509
1526
  // ../commons/src/documents.ts
1510
1527
  var z11 = __toESM(require("zod/v4"));
1511
1528
  var FullDocumentUrl = z11.string().brand("FullDocumentUrl").describe(
1512
- "A full url with protocol, host, bucket name, starting from the root of the S3 server, https://minio.opencrvs.com/bucket-name/document-id.jpg"
1529
+ "A full url with protocol, host, bucket name, starting from the root of the S3 server, https://s3.opencrvs.com/bucket-name/document-id.jpg"
1513
1530
  );
1514
1531
  var FullDocumentPath = z11.string().overwrite((val) => val.startsWith("/") ? val : `/${val}`).meta({ effectType: "input", type: "string" }).describe(
1515
1532
  "A full absolute path with bucket name, starting from the root of the S3 server, /bucket-name/document-id.jpg"
@@ -1519,7 +1536,7 @@ var DocumentPath = z11.string().brand("DocumentPath").describe(
1519
1536
  );
1520
1537
 
1521
1538
  // ../commons/src/events/CompositeFieldValue.ts
1522
- var z12 = __toESM(require("zod/v4"));
1539
+ var z12 = __toESM(require("zod"));
1523
1540
  var GeographicalArea = {
1524
1541
  URBAN: "URBAN",
1525
1542
  RURAL: "RURAL"
@@ -1533,6 +1550,9 @@ var FileFieldValue = z12.object({
1533
1550
  originalFilename: z12.string(),
1534
1551
  type: z12.string()
1535
1552
  });
1553
+ function isFileFieldValue(value) {
1554
+ return FileFieldValue.validate(value);
1555
+ }
1536
1556
  var NameFieldValue = z12.object({
1537
1557
  firstname: z12.string(),
1538
1558
  surname: z12.string(),
@@ -1557,6 +1577,9 @@ var DomesticAddressFieldValue = BaseAddressFieldValue.extend({
1557
1577
  addressType: z12.literal(AddressType.DOMESTIC),
1558
1578
  administrativeArea: z12.string().uuid()
1559
1579
  });
1580
+ function isDomesticAddressFieldValue(value) {
1581
+ return DomesticAddressFieldValue.validate(value);
1582
+ }
1560
1583
  var InternationalAddressFieldValue = BaseAddressFieldValue.extend({
1561
1584
  addressType: z12.literal(AddressType.INTERNATIONAL)
1562
1585
  });
@@ -1564,6 +1587,9 @@ var AddressFieldValue = z12.discriminatedUnion("addressType", [
1564
1587
  DomesticAddressFieldValue,
1565
1588
  InternationalAddressFieldValue
1566
1589
  ]);
1590
+ function isAddressFieldValue(value) {
1591
+ return AddressFieldValue.validate(value);
1592
+ }
1567
1593
  var DomesticAddressUpdateFieldValue = BaseAddressFieldUpdateValue.extend({
1568
1594
  addressType: z12.literal(AddressType.DOMESTIC),
1569
1595
  administrativeArea: z12.string().uuid().nullish()
@@ -1585,6 +1611,9 @@ var FileFieldValueWithOption = z12.object({
1585
1611
  option: z12.string()
1586
1612
  });
1587
1613
  var FileFieldWithOptionValue = z12.array(FileFieldValueWithOption);
1614
+ function isFileFieldWithOptionValue(value) {
1615
+ return FileFieldWithOptionValue.validate(value);
1616
+ }
1588
1617
  var HttpFieldValue = z12.object({
1589
1618
  loading: z12.boolean(),
1590
1619
  error: z12.object({ statusCode: z12.number(), message: z12.string() }).nullish(),
@@ -1620,6 +1649,7 @@ var CustomFieldValue = z12.unknown().brand("CustomFieldValue");
1620
1649
  // ../commons/src/events/PlainDate.ts
1621
1650
  var import_zod = require("zod");
1622
1651
  var PlainDate = import_zod.z.string().date().brand("PlainDate").describe("Date in the format YYYY-MM-DD");
1652
+ var isPlainDate = (date) => PlainDate.validate(date);
1623
1653
  function toPlainDate(dateTime) {
1624
1654
  return dateTime.split("T")[0];
1625
1655
  }
@@ -1735,7 +1765,7 @@ function safeUnion(schemas) {
1735
1765
  );
1736
1766
  return z14.any().superRefine((val, ctx) => {
1737
1767
  for (const schema of sortedSchemas) {
1738
- if (schema.safeParse(val).success) {
1768
+ if (schema.validate(val)) {
1739
1769
  return;
1740
1770
  }
1741
1771
  }
@@ -2024,6 +2054,7 @@ var ActionDocument = z16.discriminatedUnion("type", [
2024
2054
  ]).meta({
2025
2055
  id: "ActionDocument"
2026
2056
  });
2057
+ var isActionDocument = (a) => ActionDocument.validate(a);
2027
2058
  var AsyncRejectActionDocument = ActionBase.omit({
2028
2059
  declaration: true,
2029
2060
  annotation: true
@@ -3516,6 +3547,12 @@ var ReadActionConfig = ActionConfigBase.extend(
3516
3547
  var NotifyConfig = ActionConfigBase.extend(
3517
3548
  z25.object({
3518
3549
  type: z25.literal(ActionType.NOTIFY),
3550
+ notificationForm: DeclarationFormConfig.optional().describe(
3551
+ "Notification form configuration. Its fields must be a subset of the declaration form fields, with matching types. The values submitted on the notification form pre-fill the declaration. If not defined, the declare action's declaration is used (with all fields optional)."
3552
+ ),
3553
+ review: DeclarationReviewConfig.describe(
3554
+ "Review page configuration for the notify action. Values of its fields are stored as the NOTIFY action annotation. If not defined, defineConfig generates it from the declare action's review (with all fields optional)."
3555
+ ),
3519
3556
  form: actionConfirmationForm
3520
3557
  }).shape
3521
3558
  );
@@ -3697,11 +3734,11 @@ var ActionConfig = z25.discriminatedUnion("type", [
3697
3734
  }),
3698
3735
  NotifyConfig.meta({
3699
3736
  id: "NotifyActionConfig",
3700
- description: "Configuration for the notify action. When present, NOTIFY uses this config independently from DECLARE. When absent, NOTIFY falls back to the DeclareActionConfig."
3737
+ description: "Configuration for the notify action, including the notification form and its review page. When undefined, it is generated using the DeclareActionConfig."
3701
3738
  }),
3702
3739
  DeclareConfig.meta({
3703
3740
  id: "DeclareActionConfig",
3704
- description: "Configuration for the declare action. Includes review-page fields. NOTIFY falls back to this config when no dedicated NotifyActionConfig is provided."
3741
+ description: "Configuration for the declare action. Includes the declaration form and review-page fields."
3705
3742
  }),
3706
3743
  DuplicateDetectedConfig.meta({
3707
3744
  id: "DuplicateDetectedActionConfig",
@@ -4693,15 +4730,6 @@ var INHERENT_FLAG_RULES = [
4693
4730
  setOn: [ActionType.REQUEST_CORRECTION],
4694
4731
  resetOn: [ActionType.APPROVE_CORRECTION, ActionType.REJECT_CORRECTION]
4695
4732
  },
4696
- {
4697
- // INCOMPLETE mirrors the NOTIFIED status: set by NOTIFY, cleared by any
4698
- // other status-changing action (see getStatusFromActions). ARCHIVE/UNARCHIVE
4699
- // are deliberately excluded so the flag freezes across an archive/unarchive
4700
- // round trip and comes back exactly as it was.
4701
- flag: InherentFlags.INCOMPLETE,
4702
- setOn: [ActionType.NOTIFY],
4703
- resetOn: [ActionType.CREATE, ActionType.DECLARE, ActionType.REGISTER]
4704
- },
4705
4733
  {
4706
4734
  flag: InherentFlags.REJECTED,
4707
4735
  setOn: [ActionType.REJECT],
@@ -5549,35 +5577,24 @@ function resolveDateOfEvent(eventIndex, declaration, config) {
5549
5577
  if (!config.dateOfEvent) {
5550
5578
  return extractDateString(eventIndex[DEFAULT_DATE_OF_EVENT_PROPERTY]);
5551
5579
  }
5552
- const parsedDate = isFieldReference(config.dateOfEvent) ? ZodDate.safeParse(declaration[config.dateOfEvent.$$field]) : ZodDateTime.safeParse(
5553
- getMixedPath(eventIndex, config.dateOfEvent.$$event)
5580
+ if (isFieldReference(config.dateOfEvent)) {
5581
+ const fieldDate = declaration[config.dateOfEvent.$$field];
5582
+ return ZodDate.validate(fieldDate) ? extractDateString(fieldDate) : void 0;
5583
+ }
5584
+ const eventDate = getMixedPath(
5585
+ eventIndex,
5586
+ config.dateOfEvent.$$event
5554
5587
  );
5555
- return parsedDate.success ? extractDateString(parsedDate.data) : void 0;
5588
+ return ZodDateTime.validate(eventDate) ? extractDateString(eventDate) : void 0;
5556
5589
  }
5557
5590
  var DEFAULT_PLACE_OF_EVENT_PROPERTY = "createdAtLocation";
5558
- function getParsedUUID(value, oldValue) {
5559
- const parsed = UUID.safeParse(value);
5560
- return parsed.success ? parsed.data : oldValue;
5561
- }
5562
5591
  function resolvePlaceOfEvent(eventMetadata, declaration, config) {
5563
- let placeOfEvent = getParsedUUID(
5592
+ let placeOfEvent = maybeUuid(
5564
5593
  eventMetadata[DEFAULT_PLACE_OF_EVENT_PROPERTY]
5565
5594
  );
5566
5595
  if (config.placeOfEvent) {
5567
- const addressFieldValue = AddressFieldValue.safeParse(
5568
- declaration[config.placeOfEvent.$$field]
5569
- );
5570
- if (addressFieldValue.success && addressFieldValue.data.addressType === AddressType.DOMESTIC && addressFieldValue.data.administrativeArea) {
5571
- placeOfEvent = getParsedUUID(
5572
- addressFieldValue.data.administrativeArea,
5573
- placeOfEvent
5574
- );
5575
- } else {
5576
- placeOfEvent = getParsedUUID(
5577
- declaration[config.placeOfEvent.$$field],
5578
- placeOfEvent
5579
- );
5580
- }
5596
+ const addressFieldValue = declaration[config.placeOfEvent.$$field];
5597
+ placeOfEvent = isDomesticAddressFieldValue(addressFieldValue) ? maybeUuid(addressFieldValue.administrativeArea) ?? placeOfEvent : maybeUuid(declaration[config.placeOfEvent.$$field]) ?? placeOfEvent;
5581
5598
  }
5582
5599
  return placeOfEvent;
5583
5600
  }
@@ -5862,7 +5879,7 @@ function precompileActionSchemas(eventConfigurations) {
5862
5879
  }
5863
5880
  }
5864
5881
  function isAgeValue(value) {
5865
- return typeof value === "object" && value !== null && "age" in value && typeof value.age === "number";
5882
+ return AgeValue.validate(value);
5866
5883
  }
5867
5884
  function mergeWithBaseFormState(values, context) {
5868
5885
  return { ...context.baseFormState, ...values };
@@ -5892,15 +5909,13 @@ function validate(schema, data) {
5892
5909
  return [key, value];
5893
5910
  }
5894
5911
  const age = value.age;
5895
- const maybeAsOfDate = PlainDate.safeParse(data.$form[value.asOfDateRef]);
5912
+ const asOf = data.$form[value.asOfDateRef];
5913
+ const asOfDate = isPlainDate(asOf) ? asOf : PlainDate.parse(data.$now);
5896
5914
  return [
5897
5915
  key,
5898
5916
  {
5899
5917
  age,
5900
- dob: ageToDate(
5901
- age,
5902
- maybeAsOfDate.success ? maybeAsOfDate.data : PlainDate.parse(data.$now)
5903
- )
5918
+ dob: ageToDate(age, asOfDate)
5904
5919
  }
5905
5920
  ];
5906
5921
  });
@@ -6063,6 +6078,11 @@ var errorMessages = {
6063
6078
  description: "Error message when field is not expected",
6064
6079
  id: "error.unexpectedField"
6065
6080
  },
6081
+ notInNotifyForm: {
6082
+ defaultMessage: "Field is not part of the notify form. Notify-only data belongs in annotation",
6083
+ description: "Error message when a notify declaration contains a field outside the notify form",
6084
+ id: "error.notInNotifyForm"
6085
+ },
6066
6086
  correctionNotAllowed: {
6067
6087
  defaultMessage: "Correction not allowed for field",
6068
6088
  description: "Error message when correction is not allowed for field",
@@ -6276,6 +6296,34 @@ function areCertificateConditionsMet(conditions, values) {
6276
6296
  });
6277
6297
  }
6278
6298
 
6299
+ // ../commons/src/events/notificationFormFallback.ts
6300
+ function toOptionalField(field3) {
6301
+ const { validation: _validation, ...rest } = field3;
6302
+ if (rest.type === FieldType.FIELD_GROUP && "fields" in rest) {
6303
+ return {
6304
+ ...rest,
6305
+ required: false,
6306
+ fields: rest.fields.map(toOptionalField)
6307
+ };
6308
+ }
6309
+ return { ...rest, required: false };
6310
+ }
6311
+ function deriveNotificationForm(declaration) {
6312
+ return {
6313
+ ...declaration,
6314
+ pages: declaration.pages.map((page) => ({
6315
+ ...page,
6316
+ fields: page.fields.map(toOptionalField)
6317
+ }))
6318
+ };
6319
+ }
6320
+ function generateNotifyReview(declareReview) {
6321
+ return {
6322
+ ...declareReview,
6323
+ fields: declareReview.fields.map(toOptionalField)
6324
+ };
6325
+ }
6326
+
6279
6327
  // ../commons/src/events/utils.ts
6280
6328
  var import_date_fns3 = require("date-fns");
6281
6329
  function ageToDate(age, asOfDate) {
@@ -6299,6 +6347,34 @@ function getDeclarationPages(configuration) {
6299
6347
  function getDeclarationFields(configuration) {
6300
6348
  return getDeclarationPages(configuration).flatMap(({ fields }) => fields);
6301
6349
  }
6350
+ function getConfiguredNotificationForm(configuration) {
6351
+ const notifyAction = configuration.actions.find(
6352
+ (action) => action.type === ActionType.NOTIFY
6353
+ );
6354
+ return notifyAction?.type === ActionType.NOTIFY ? notifyAction.notificationForm : void 0;
6355
+ }
6356
+ var derivedNotificationForms = /* @__PURE__ */ new WeakMap();
6357
+ function getNotificationForm(configuration) {
6358
+ const configured = getConfiguredNotificationForm(configuration);
6359
+ if (configured) {
6360
+ return configured;
6361
+ }
6362
+ const cached = derivedNotificationForms.get(configuration);
6363
+ if (cached) {
6364
+ return cached;
6365
+ }
6366
+ const derived = deriveNotificationForm(getDeclaration(configuration));
6367
+ derivedNotificationForms.set(configuration, derived);
6368
+ return derived;
6369
+ }
6370
+ function getNotificationFields(configuration) {
6371
+ return getNotificationForm(configuration).pages.flatMap(
6372
+ ({ fields }) => fields
6373
+ );
6374
+ }
6375
+ function getActionForm(configuration, actionType) {
6376
+ return actionType === ActionType.NOTIFY ? getNotificationForm(configuration) : getDeclaration(configuration);
6377
+ }
6302
6378
  function isActionConfigType(type) {
6303
6379
  return actionConfigTypes.has(type);
6304
6380
  }
@@ -6307,9 +6383,6 @@ function getActionConfig({
6307
6383
  actionType,
6308
6384
  customActionType
6309
6385
  }) {
6310
- if (actionType === ActionType.NOTIFY) {
6311
- return eventConfiguration.actions.find((a) => a.type === ActionType.NOTIFY) ?? eventConfiguration.actions.find((a) => a.type === ActionType.DECLARE);
6312
- }
6313
6386
  return eventConfiguration.actions.find((a) => {
6314
6387
  if (a.type === ActionType.CUSTOM && customActionType) {
6315
6388
  return a.customActionType === customActionType;
@@ -6557,11 +6630,15 @@ function flattenFieldReference(ref) {
6557
6630
  return [ref.$$field, ...ref.$$subfield];
6558
6631
  }
6559
6632
  function isWriteAction(actionType) {
6560
- return writeActions.safeParse(actionType).success;
6633
+ return writeActions.validate(actionType);
6561
6634
  }
6562
6635
  var findAllFields = (config) => {
6563
6636
  return (0, import_lodash4.flattenDeep)([
6564
6637
  ...getDeclarationFields(config),
6638
+ // Only a configured notification form: a derived one repeats the declaration fields.
6639
+ ...getConfiguredNotificationForm(config)?.pages.flatMap(
6640
+ ({ fields }) => fields
6641
+ ) ?? [],
6565
6642
  ...getAllAnnotationFields(config)
6566
6643
  ]);
6567
6644
  };
@@ -6955,6 +7032,50 @@ function validateDeclarationGivenExactlyOnce(config, ctx) {
6955
7032
  });
6956
7033
  }
6957
7034
  }
7035
+ function validateNotificationForm(event2, ctx) {
7036
+ const declarationFields = getDeclarationPages(event2).flatMap(
7037
+ (page) => page.fields.map((field3) => ({ field: field3, pageId: page.id }))
7038
+ );
7039
+ event2.actions.forEach((action, actionIndex) => {
7040
+ if (action.type !== ActionType.NOTIFY || !action.notificationForm) {
7041
+ return;
7042
+ }
7043
+ action.notificationForm.pages.forEach((page, pageIndex) => {
7044
+ page.fields.forEach((field3, fieldIndex) => {
7045
+ const path = [
7046
+ "actions",
7047
+ actionIndex,
7048
+ "notificationForm",
7049
+ "pages",
7050
+ pageIndex,
7051
+ "fields",
7052
+ fieldIndex
7053
+ ];
7054
+ const matchingFields = declarationFields.filter(
7055
+ (declarationField) => declarationField.field.id === field3.id
7056
+ );
7057
+ if (matchingFields.length === 0) {
7058
+ ctx.addIssue({
7059
+ code: "custom",
7060
+ message: `Notification form field '${field3.id}' does not exist in the declaration form of event '${event2.id}'. Notification form fields must also be defined in the ${ActionType.DECLARE} action's declaration.`,
7061
+ path
7062
+ });
7063
+ return;
7064
+ }
7065
+ if (!matchingFields.some(
7066
+ (declarationField) => declarationField.field.type === field3.type
7067
+ )) {
7068
+ const [declarationField] = matchingFields;
7069
+ ctx.addIssue({
7070
+ code: "custom",
7071
+ message: `Notification form field '${field3.id}' on page '${page.id}' is of type ${field3.type}, but the declaration form field with the same id in event '${event2.id}' (${ActionType.DECLARE} declaration, page '${declarationField.pageId}') is of type ${declarationField.field.type}.`,
7072
+ path
7073
+ });
7074
+ }
7075
+ });
7076
+ });
7077
+ });
7078
+ }
6958
7079
 
6959
7080
  // ../commons/src/events/EventConfig.ts
6960
7081
  var EventFieldReference = z35.object({ $$event: EventMetadataDateFieldIdInput }).describe(
@@ -7005,6 +7126,7 @@ var EventConfig = _EventConfigBase.superRefine((event2, ctx) => {
7005
7126
  if (!validateExactlyOneDeclareAction(event2, ctx)) {
7006
7127
  return;
7007
7128
  }
7129
+ validateNotificationForm(event2, ctx);
7008
7130
  validateAdvancedSearchConfig(event2, ctx);
7009
7131
  validateDateOfEvent(event2, ctx);
7010
7132
  validatePlaceOfEvent(event2, ctx);
@@ -7086,7 +7208,7 @@ function createSearchConfig(baseField) {
7086
7208
 
7087
7209
  // ../commons/src/event-config/event-configuration.ts
7088
7210
  function isNonSearchableEventMetadataTimeFieldId(fieldId) {
7089
- return !EventFieldIdInput.safeParse(fieldId).success;
7211
+ return !EventFieldIdInput.validate(fieldId);
7090
7212
  }
7091
7213
  function createEventFieldConfig(fieldId) {
7092
7214
  const baseField = {
@@ -7438,6 +7560,12 @@ var RegisterActionInput = BaseActionInput.extend(
7438
7560
  var NotifyActionInput = BaseActionInput.extend(
7439
7561
  z39.object({
7440
7562
  type: z39.literal(ActionType.NOTIFY).default(ActionType.NOTIFY),
7563
+ declaration: BaseActionInput.shape.declaration.describe(
7564
+ "Values for fields of the notification form, keyed by field id. Fields outside the notification form are rejected. Only these values become part of the record declaration, so any id that needs to be searchable must be a declaration field."
7565
+ ),
7566
+ annotation: BaseActionInput.shape.annotation.describe(
7567
+ "Values for notify-only fields (NOTIFY review and form fields), keyed by field id. These are stored on the NOTIFY action, not in the record declaration."
7568
+ ),
7441
7569
  // For normal users, the createdAtLocation is resolved on the backend from the user's primaryOfficeId.
7442
7570
  createdAtLocation: UUID.nullish().describe(
7443
7571
  "A valid office location ID. This is required for system users performing actions. The provided location must be a leaf-location, i.e. it must not have any children locations."
@@ -7680,11 +7808,56 @@ function moveDeclarationToDeclareAction({
7680
7808
  )
7681
7809
  };
7682
7810
  }
7811
+ function generateNotificationFormFallback(config) {
7812
+ const declareAction = config.actions.find(
7813
+ (action) => action.type === ActionType.DECLARE
7814
+ );
7815
+ const notifyAction = config.actions.find(
7816
+ (action) => action.type === ActionType.NOTIFY
7817
+ );
7818
+ if (!notifyAction?.notificationForm) {
7819
+ console.warn(
7820
+ `Event '${config.id}' has no ${ActionType.NOTIFY} form. Using the ${ActionType.DECLARE} form with all fields optional. Configure \`actions[${ActionType.NOTIFY}].notificationForm\`. This fallback will be removed in a future release.`
7821
+ );
7822
+ }
7823
+ if (notifyAction?.review) {
7824
+ return config;
7825
+ }
7826
+ if (!declareAction?.declaration) {
7827
+ throw new Error(
7828
+ `Event '${config.id}' has no ${ActionType.DECLARE} form. Configure \`actions[${ActionType.DECLARE}].declaration\`.`
7829
+ );
7830
+ }
7831
+ const review = generateNotifyReview(declareAction.review);
7832
+ if (notifyAction) {
7833
+ return {
7834
+ ...config,
7835
+ actions: config.actions.map(
7836
+ (action) => action === notifyAction ? { ...notifyAction, review } : action
7837
+ )
7838
+ };
7839
+ }
7840
+ const notifyFromDeclare = {
7841
+ type: ActionType.NOTIFY,
7842
+ label: declareAction.label,
7843
+ icon: declareAction.icon,
7844
+ conditionals: declareAction.conditionals,
7845
+ flags: declareAction.flags,
7846
+ supportingCopy: declareAction.dialogCopy?.notify,
7847
+ review
7848
+ };
7849
+ return {
7850
+ ...config,
7851
+ actions: config.actions.flatMap(
7852
+ (action) => action === declareAction ? [notifyFromDeclare, action] : [action]
7853
+ )
7854
+ };
7855
+ }
7683
7856
  var EventConfigDefinition = z43.custom().superRefine((config, ctx) => {
7684
7857
  if (validateExactlyOneDeclareAction(config, ctx)) {
7685
7858
  validateDeclarationGivenExactlyOnce(config, ctx);
7686
7859
  }
7687
- }).transform(moveDeclarationToDeclareAction).pipe(EventConfig);
7860
+ }).transform(moveDeclarationToDeclareAction).transform(generateNotificationFormFallback).pipe(EventConfig);
7688
7861
  var defineConfig = (config) => EventConfigDefinition.parse(config);
7689
7862
 
7690
7863
  // ../commons/src/events/transactions.ts
@@ -10469,8 +10642,8 @@ function userCanAccessEventWithScopes(event2, scopes, user2, customActionType) {
10469
10642
  }
10470
10643
  function getAdministrativeAreaHierarchy(administrativeAreaId, administrativeAreas) {
10471
10644
  const collectedLocations = [];
10472
- const parsedAdministrativeAreaId = administrativeAreaId && UUID.safeParse(administrativeAreaId).data;
10473
- let current = parsedAdministrativeAreaId ? administrativeAreas.get(parsedAdministrativeAreaId) : null;
10645
+ const maybeAdministrativeAreaId = maybeUuid(administrativeAreaId);
10646
+ let current = maybeAdministrativeAreaId ? administrativeAreas.get(maybeAdministrativeAreaId) : null;
10474
10647
  while (current) {
10475
10648
  collectedLocations.push(current);
10476
10649
  if (!current.parentId) {
@@ -11070,11 +11243,10 @@ function fieldConfigsToActionPayload(fields, rng, administrativeHierarchy) {
11070
11243
  );
11071
11244
  }
11072
11245
  function generateActionDeclarationInput(configuration, action, rng, overrides, administrativeHierarchy) {
11073
- const parsed = DeclarationUpdateActions.safeParse(action);
11074
11246
  if ((0, import_lodash5.isEmpty)(overrides) && typeof overrides === "object") {
11075
11247
  return {};
11076
11248
  }
11077
- if (parsed.success) {
11249
+ if (DeclarationUpdateActions.validate(action)) {
11078
11250
  const fields = getDeclarationFields(configuration);
11079
11251
  const declarationConfig = getDeclaration(configuration);
11080
11252
  const declaration = fieldConfigsToActionPayload(
@@ -11708,9 +11880,16 @@ var generateEventConfig = ({
11708
11880
  function withDeclaration(configuration, declaration) {
11709
11881
  return {
11710
11882
  ...configuration,
11711
- actions: configuration.actions.map(
11712
- (action) => action.type === ActionType.DECLARE ? { ...action, declaration } : action
11713
- )
11883
+ actions: configuration.actions.map((action) => {
11884
+ if (action.type === ActionType.DECLARE) {
11885
+ return { ...action, declaration };
11886
+ }
11887
+ if (action.type === ActionType.NOTIFY) {
11888
+ const { notificationForm: _notificationForm, ...notifyAction } = action;
11889
+ return notifyAction;
11890
+ }
11891
+ return action;
11892
+ })
11714
11893
  };
11715
11894
  }
11716
11895
  function getLeafAdministrativeAreaIds(administrativeAreas) {
@@ -11774,7 +11953,7 @@ function isTemplateVariable(value) {
11774
11953
  return typeof value === "string" && value.startsWith("$");
11775
11954
  }
11776
11955
  function isFieldValue(value) {
11777
- return FieldValue.safeParse(value).success;
11956
+ return FieldValue.validate(value);
11778
11957
  }
11779
11958
  function isFieldValueWithoutTemplates(value) {
11780
11959
  if (isTemplateVariable(value)) {
@@ -12126,13 +12305,11 @@ function getFilePathsFromEvent(event2) {
12126
12305
  ...declarationValues,
12127
12306
  ...annotationValues
12128
12307
  ].flatMap((value) => {
12129
- const fileParsed = FileFieldValue.safeParse(value);
12130
- if (fileParsed.success) {
12131
- return [fileParsed.data.path];
12308
+ if (isFileFieldValue(value)) {
12309
+ return [value.path];
12132
12310
  }
12133
- const fileOptionParsed = FileFieldWithOptionValue.safeParse(value);
12134
- if (fileOptionParsed.success) {
12135
- return fileOptionParsed.data.map((val) => val.path);
12311
+ if (isFileFieldWithOptionValue(value)) {
12312
+ return value.map((val) => val.path);
12136
12313
  }
12137
12314
  return [];
12138
12315
  });
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Run the upgrade process for the country config in the current working
3
+ * directory.
4
+ *
5
+ * @param toolkitVersion the version of the toolkit running the upgrade, e.g.
6
+ * `2.2.0` or `2.2.0-rc.1`. The country config is upgraded to its major.minor.
7
+ */
8
+ export declare function runUpgrade(toolkitVersion: string): Promise<void>;
9
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/migrations/index.ts"],"names":[],"mappings":"AAgBA;;;;;;GAMG;AACH,wBAAsB,UAAU,CAAC,cAAc,EAAE,MAAM,iBAStD"}