@opencrvs/toolkit 2.2.0-rc.ab91cce → 2.2.0-rc.e6591c5

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 (252) hide show
  1. package/build.sh +17 -14
  2. package/dist/application-config/index.js +57 -14
  3. package/dist/authentication/index.d.ts +2 -1
  4. package/dist/authentication/index.js +34 -14
  5. package/dist/cli.js +2631 -377
  6. package/dist/commons/api/router.d.ts +1564 -248
  7. package/dist/commons/application-config/index.d.ts +3 -3
  8. package/dist/commons/conditionals/conditionals.d.ts +7 -7
  9. package/dist/commons/conditionals/index.d.ts +1 -0
  10. package/dist/commons/conditionals/validate.d.ts +6 -1
  11. package/dist/commons/events/ActionConfig.d.ts +68 -21
  12. package/dist/commons/events/ActionDocument.d.ts +89 -0
  13. package/dist/commons/events/ActionInput.d.ts +56 -4
  14. package/dist/commons/events/ActionStatus.d.ts +2 -2
  15. package/dist/commons/events/ActionType.d.ts +13 -1
  16. package/dist/commons/events/AdvancedSearchConfig.d.ts +15 -0
  17. package/dist/commons/events/AuditLog.d.ts +4 -0
  18. package/dist/commons/events/CompositeFieldValue.d.ts +5 -1
  19. package/dist/commons/events/CountryConfigQueryInput.d.ts +192 -18
  20. package/dist/commons/events/Draft.d.ts +36 -1
  21. package/dist/commons/events/EventConfig.d.ts +448 -1
  22. package/dist/commons/events/EventDocument.d.ts +90 -0
  23. package/dist/commons/events/EventIndex.d.ts +44 -6
  24. package/dist/commons/events/EventInput.d.ts +1 -0
  25. package/dist/commons/events/EventMetadata.d.ts +24 -1
  26. package/dist/commons/events/EventStatus.d.ts +1 -0
  27. package/dist/commons/events/FieldConfig.d.ts +11 -1
  28. package/dist/commons/events/FieldTypeMapping.d.ts +17 -17
  29. package/dist/commons/events/Flag.d.ts +1 -7
  30. package/dist/commons/events/PlainDate.d.ts +6 -0
  31. package/dist/commons/events/WorkqueueConfig.d.ts +224 -33
  32. package/dist/commons/events/defineConfig.d.ts +7 -2
  33. package/dist/commons/events/event.d.ts +4 -1
  34. package/dist/commons/events/eventConfigValidation.d.ts +9 -0
  35. package/dist/commons/events/field.d.ts +5 -0
  36. package/dist/commons/events/index.d.ts +3 -0
  37. package/dist/commons/events/locations.d.ts +1 -1
  38. package/dist/commons/events/scopes.d.ts +4 -1
  39. package/dist/commons/events/state/flags.d.ts +1 -1
  40. package/dist/commons/events/state/index.d.ts +11 -2
  41. package/dist/commons/events/state/utils.d.ts +11 -1
  42. package/dist/commons/events/test.utils.d.ts +85 -8
  43. package/dist/commons/events/toNotificationForm.d.ts +17 -0
  44. package/dist/commons/events/utils.d.ts +88 -8
  45. package/dist/commons/users/Role.d.ts +23 -0
  46. package/dist/commons/users/User.d.ts +263 -0
  47. package/dist/commons/users/authentication.d.ts +67 -0
  48. package/dist/commons/users/index.d.ts +5 -0
  49. package/dist/commons/users/roleValidations.d.ts +15 -0
  50. package/dist/commons/users/scopes.d.ts +1402 -0
  51. package/dist/commons/users/userReferences.d.ts +176 -0
  52. package/dist/conditionals/index.js +19 -7
  53. package/dist/configurator/index.d.ts +24 -0
  54. package/dist/configurator/index.d.ts.map +1 -0
  55. package/dist/configurator/index.js +161 -0
  56. package/dist/configurator/layout.d.ts +29 -0
  57. package/dist/configurator/layout.d.ts.map +1 -0
  58. package/dist/configurator/layout.js +78 -0
  59. package/dist/configurator/paths.d.ts +13 -0
  60. package/dist/configurator/paths.d.ts.map +1 -0
  61. package/dist/configurator/paths.js +48 -0
  62. package/dist/configurator/server/environments.d.ts +20 -0
  63. package/dist/configurator/server/environments.d.ts.map +1 -0
  64. package/dist/configurator/server/environments.js +143 -0
  65. package/dist/configurator/server/files.d.ts +11 -0
  66. package/dist/configurator/server/files.d.ts.map +1 -0
  67. package/dist/configurator/server/files.js +67 -0
  68. package/dist/configurator/server/github.d.ts +56 -0
  69. package/dist/configurator/server/github.d.ts.map +1 -0
  70. package/dist/configurator/server/github.js +239 -0
  71. package/dist/configurator/server/plugin.d.ts +39 -0
  72. package/dist/configurator/server/plugin.d.ts.map +1 -0
  73. package/dist/configurator/server/plugin.js +298 -0
  74. package/dist/configurator/server/seal.d.ts +2 -0
  75. package/dist/configurator/server/seal.d.ts.map +1 -0
  76. package/dist/configurator/server/seal.js +36 -0
  77. package/dist/configurator/server/sshKeys.d.ts +5 -0
  78. package/dist/configurator/server/sshKeys.d.ts.map +1 -0
  79. package/dist/configurator/server/sshKeys.js +28 -0
  80. package/dist/configurator/server/start.d.ts +12 -0
  81. package/dist/configurator/server/start.d.ts.map +1 -0
  82. package/dist/configurator/server/start.js +91 -0
  83. package/dist/configurator/testing.d.ts +11 -0
  84. package/dist/configurator/testing.d.ts.map +1 -0
  85. package/dist/configurator/testing.js +74 -0
  86. package/dist/configurator/ui/bindings/bindings.d.ts +35 -0
  87. package/dist/configurator/ui/bindings/bindings.d.ts.map +1 -0
  88. package/dist/configurator/ui/bindings/bindings.js +5 -0
  89. package/dist/configurator/ui/bindings/parsers.d.ts +7 -0
  90. package/dist/configurator/ui/bindings/parsers.d.ts.map +1 -0
  91. package/dist/configurator/ui/bindings/parsers.js +85 -0
  92. package/dist/configurator/ui/form/users.d.ts +11 -0
  93. package/dist/configurator/ui/form/users.d.ts.map +1 -0
  94. package/dist/configurator/ui/form/users.js +33 -0
  95. package/dist/configurator/ui/plan/dependencyHosts.d.ts +2 -0
  96. package/dist/configurator/ui/plan/dependencyHosts.d.ts.map +1 -0
  97. package/dist/configurator/ui/plan/dependencyHosts.js +36 -0
  98. package/dist/configurator/ui/plan/templateValues.d.ts +11 -0
  99. package/dist/configurator/ui/plan/templateValues.d.ts.map +1 -0
  100. package/dist/configurator/ui/plan/templateValues.js +70 -0
  101. package/dist/configurator/workflows.d.ts +54 -0
  102. package/dist/configurator/workflows.d.ts.map +1 -0
  103. package/dist/configurator/workflows.js +161 -0
  104. package/dist/configurator-assets/forms/bindings.yml +265 -0
  105. package/dist/configurator-assets/templates/README.md +18 -0
  106. package/dist/configurator-assets/templates/charts-values/dependencies/values.override.yaml +4 -0
  107. package/dist/configurator-assets/templates/charts-values/dependencies/values.yaml +96 -0
  108. package/dist/configurator-assets/templates/charts-values/opencrvs-services/values.override.yaml +4 -0
  109. package/dist/configurator-assets/templates/charts-values/opencrvs-services/values.yaml +83 -0
  110. package/dist/configurator-assets/templates/charts-values/opentelemetry/values.yaml +102 -0
  111. package/dist/configurator-assets/templates/charts-values/traefik/values.override.yaml +4 -0
  112. package/dist/configurator-assets/templates/charts-values/traefik/values.yaml +130 -0
  113. package/dist/configurator-assets/templates/inventory/inventory.template.yml +98 -0
  114. package/dist/configurator-assets/ui/apple-touch-icon.png +0 -0
  115. package/dist/configurator-assets/ui/assets/index-CaqYFJUk.css +6 -0
  116. package/dist/configurator-assets/ui/assets/index-DU1Y6E0b.js +169 -0
  117. package/dist/configurator-assets/ui/assets/opencrvs-logo-sIjz08HT.svg +1 -0
  118. package/dist/configurator-assets/ui/assets/poppins-400-BwTUGeWf.woff2 +0 -0
  119. package/dist/configurator-assets/ui/assets/poppins-500-CWICHMj6.woff2 +0 -0
  120. package/dist/configurator-assets/ui/assets/poppins-600-DJVo7c07.woff2 +0 -0
  121. package/dist/configurator-assets/ui/assets/poppins-700-g9MkRaG0.woff2 +0 -0
  122. package/dist/configurator-assets/ui/favicon-32x32.png +0 -0
  123. package/dist/configurator-assets/ui/index.html +25 -0
  124. package/dist/environment/custom-types.d.ts +1 -0
  125. package/dist/environment/custom-types.d.ts.map +1 -1
  126. package/dist/environment/derived-variables.d.ts +18 -4
  127. package/dist/environment/derived-variables.d.ts.map +1 -1
  128. package/dist/environment/derived-variables.js +20 -4
  129. package/dist/environment/questions.d.ts +42 -9
  130. package/dist/environment/questions.d.ts.map +1 -1
  131. package/dist/environment/questions.js +71 -48
  132. package/dist/environment/registry.d.ts +15 -0
  133. package/dist/environment/registry.d.ts.map +1 -0
  134. package/dist/environment/registry.js +112 -0
  135. package/dist/environment/setup-environment.d.ts.map +1 -1
  136. package/dist/environment/setup-environment.js +145 -25
  137. package/dist/environment/templates.d.ts.map +1 -1
  138. package/dist/events/index.js +957 -215
  139. package/dist/migrations/add-notify-config.d.ts +40 -0
  140. package/dist/migrations/add-notify-config.d.ts.map +1 -0
  141. package/dist/migrations/add-notify-config.js +249 -0
  142. package/dist/migrations/index.d.ts +9 -0
  143. package/dist/migrations/index.d.ts.map +1 -0
  144. package/dist/migrations/index.js +1306 -0
  145. package/dist/migrations/move-declaration-to-declare-action.d.ts +38 -0
  146. package/dist/migrations/move-declaration-to-declare-action.d.ts.map +1 -0
  147. package/dist/migrations/move-declaration-to-declare-action.js +260 -0
  148. package/dist/migrations/{add-translations.d.ts → persistent/add-translations.d.ts} +1 -1
  149. package/dist/migrations/persistent/add-translations.d.ts.map +1 -0
  150. package/dist/migrations/{add-translations.js → persistent/add-translations.js} +2 -2
  151. package/dist/migrations/persistent/check-upgrade-path.d.ts +36 -0
  152. package/dist/migrations/persistent/check-upgrade-path.d.ts.map +1 -0
  153. package/dist/migrations/persistent/check-upgrade-path.js +105 -0
  154. package/dist/migrations/persistent/update-toolkit-dependency.d.ts +7 -0
  155. package/dist/migrations/persistent/update-toolkit-dependency.d.ts.map +1 -0
  156. package/dist/migrations/persistent/update-toolkit-dependency.js +77 -0
  157. package/dist/migrations/{v2.2/read-declaration-through-helper.d.ts → read-declaration-through-helper.d.ts} +1 -1
  158. package/dist/migrations/read-declaration-through-helper.d.ts.map +1 -0
  159. package/dist/migrations/{v2.2/read-declaration-through-helper.js → read-declaration-through-helper.js} +4 -62
  160. package/dist/migrations/replace-incomplete-flag.d.ts +26 -0
  161. package/dist/migrations/replace-incomplete-flag.d.ts.map +1 -0
  162. package/dist/migrations/replace-incomplete-flag.js +126 -0
  163. package/dist/migrations/resolve-versioned-event-config.d.ts +56 -0
  164. package/dist/migrations/resolve-versioned-event-config.d.ts.map +1 -0
  165. package/dist/migrations/resolve-versioned-event-config.js +353 -0
  166. package/dist/migrations/utils.d.ts +61 -0
  167. package/dist/migrations/utils.d.ts.map +1 -0
  168. package/dist/migrations/utils.js +218 -0
  169. package/dist/notification/index.js +810 -84
  170. package/dist/roles/index.d.ts +2 -0
  171. package/dist/roles/index.d.ts.map +1 -0
  172. package/dist/roles/index.js +730 -0
  173. package/dist/scopes/index.d.ts +83 -100
  174. package/dist/scopes/index.js +29 -13
  175. package/dist/templates/charts-values/dependencies/values.yaml +5 -2
  176. package/dist/templates/charts-values/opencrvs-services/values.yaml +5 -7
  177. package/dist/templates/charts-values/traefik/values.yaml +2 -0
  178. package/dist/verify/endpoints.d.ts +11 -0
  179. package/dist/verify/endpoints.d.ts.map +1 -1
  180. package/dist/verify/endpoints.js +21 -27
  181. package/opencrvs-toolkit-2.2.0-rc.e6591c5.tgz +0 -0
  182. package/package.json +17 -4
  183. package/tsconfig.build.json +11 -1
  184. package/tsconfig.build.tsbuildinfo +1 -1
  185. package/tsconfig.json +15 -6
  186. package/dist/migrations/add-translations.d.ts.map +0 -1
  187. package/dist/migrations/v2.1/add-explicit-correction-flags.d.ts +0 -3
  188. package/dist/migrations/v2.1/add-explicit-correction-flags.d.ts.map +0 -1
  189. package/dist/migrations/v2.1/add-explicit-correction-flags.js +0 -234
  190. package/dist/migrations/v2.1/add-recovery-link-notifications.d.ts +0 -3
  191. package/dist/migrations/v2.1/add-recovery-link-notifications.d.ts.map +0 -1
  192. package/dist/migrations/v2.1/add-recovery-link-notifications.js +0 -511
  193. package/dist/migrations/v2.1/enable-telemetry.d.ts +0 -3
  194. package/dist/migrations/v2.1/enable-telemetry.d.ts.map +0 -1
  195. package/dist/migrations/v2.1/enable-telemetry.js +0 -455
  196. package/dist/migrations/v2.1/index.d.ts +0 -6
  197. package/dist/migrations/v2.1/index.d.ts.map +0 -1
  198. package/dist/migrations/v2.1/index.js +0 -50
  199. package/dist/migrations/v2.1/migrate-infrastructure-to-assets.d.ts +0 -17
  200. package/dist/migrations/v2.1/migrate-infrastructure-to-assets.d.ts.map +0 -1
  201. package/dist/migrations/v2.1/migrate-infrastructure-to-assets.js +0 -348
  202. package/dist/migrations/v2.1/remove-metabase-package-installs.d.ts +0 -2
  203. package/dist/migrations/v2.1/remove-metabase-package-installs.d.ts.map +0 -1
  204. package/dist/migrations/v2.1/remove-metabase-package-installs.js +0 -161
  205. package/dist/migrations/v2.1/remove-sentry.d.ts +0 -3
  206. package/dist/migrations/v2.1/remove-sentry.d.ts.map +0 -1
  207. package/dist/migrations/v2.1/remove-sentry.js +0 -354
  208. package/dist/migrations/v2.1/rename-trigger-paths.d.ts +0 -3
  209. package/dist/migrations/v2.1/rename-trigger-paths.d.ts.map +0 -1
  210. package/dist/migrations/v2.1/rename-trigger-paths.js +0 -216
  211. package/dist/migrations/v2.1/template-files.d.ts +0 -8
  212. package/dist/migrations/v2.1/template-files.d.ts.map +0 -1
  213. package/dist/migrations/v2.1/template-files.js +0 -49
  214. package/dist/migrations/v2.1/upgrade-tilt.d.ts +0 -11
  215. package/dist/migrations/v2.1/upgrade-tilt.d.ts.map +0 -1
  216. package/dist/migrations/v2.1/upgrade-tilt.js +0 -139
  217. package/dist/migrations/v2.2/index.d.ts +0 -6
  218. package/dist/migrations/v2.2/index.d.ts.map +0 -1
  219. package/dist/migrations/v2.2/index.js +0 -456
  220. package/dist/migrations/v2.2/read-declaration-through-helper.d.ts.map +0 -1
  221. package/dist/templates/countryconfig-template/.tiltignore +0 -1
  222. package/dist/templates/countryconfig-template/Dockerfile.assets +0 -7
  223. package/dist/templates/countryconfig-template/Tiltfile +0 -112
  224. package/dist/templates/countryconfig-template/assets/README.md +0 -1
  225. package/dist/templates/countryconfig-template/assets/clear-all-data-dev.sh +0 -61
  226. package/dist/templates/countryconfig-template/assets/deployment/deploy.sh +0 -455
  227. package/dist/templates/countryconfig-template/assets/deployment/reindex.sh +0 -168
  228. package/dist/templates/countryconfig-template/assets/deployment/validate-required-variables-in-compose-files.ts +0 -67
  229. package/dist/templates/countryconfig-template/assets/elasticsearch/reindex.sh +0 -168
  230. package/dist/templates/countryconfig-template/assets/metabase/README.md +0 -34
  231. package/dist/templates/countryconfig-template/assets/metabase/environment-configuration.sql +0 -36
  232. package/dist/templates/countryconfig-template/assets/metabase/initialize-database.sh +0 -46
  233. package/dist/templates/countryconfig-template/assets/metabase/metabase.init.db.sql +0 -27737
  234. package/dist/templates/countryconfig-template/assets/metabase/open-shell.sh +0 -21
  235. package/dist/templates/countryconfig-template/assets/metabase/package.json +0 -13
  236. package/dist/templates/countryconfig-template/assets/metabase/run-dev.sh +0 -108
  237. package/dist/templates/countryconfig-template/assets/metabase/run.sh +0 -120
  238. package/dist/templates/countryconfig-template/assets/metabase/update-database.sh +0 -40
  239. package/dist/templates/countryconfig-template/assets/postgres/setup-analytics.sh +0 -135
  240. package/dist/templates/countryconfig-template/assets/postgres/setup-reference-data.sh +0 -108
  241. package/dist/templates/countryconfig-template/tilt/clear-all-data.ps1 +0 -50
  242. package/dist/templates/countryconfig-template/tilt/clear-all-data.sh +0 -35
  243. package/dist/templates/countryconfig-template/tilt/common.tilt +0 -145
  244. package/dist/templates/countryconfig-template/tilt/examples/dependencies/values.yaml +0 -15
  245. package/dist/templates/countryconfig-template/tilt/examples/opencrvs-services/values.yaml +0 -56
  246. package/dist/templates/countryconfig-template/tilt/examples/traefik/values-minikube.yaml +0 -21
  247. package/dist/templates/countryconfig-template/tilt/examples/traefik/values.yaml +0 -38
  248. package/dist/templates/countryconfig-template/tilt/helm/dependencies/values.yaml +0 -17
  249. package/dist/templates/countryconfig-template/tilt/helm/opencrvs-services/values.yaml +0 -16
  250. package/dist/templates/countryconfig-template/tilt/lib.tilt +0 -95
  251. package/dist/templates/countryconfig-template/tilt/opencrvs.tilt +0 -136
  252. package/opencrvs-toolkit-2.2.0-rc.ab91cce.tgz +0 -0
@@ -88,6 +88,7 @@ __export(events_exports, {
88
88
  CustomFieldValue: () => CustomFieldValue,
89
89
  CustomFlag: () => CustomFlag,
90
90
  DEFAULT_DATE_OF_EVENT_PROPERTY: () => DEFAULT_DATE_OF_EVENT_PROPERTY,
91
+ DEFAULT_EFFECTIVE_FROM: () => DEFAULT_EFFECTIVE_FROM,
91
92
  DEFAULT_PLACE_OF_EVENT_PROPERTY: () => DEFAULT_PLACE_OF_EVENT_PROPERTY,
92
93
  DOCUMENT_DELETE_SCOPES: () => DOCUMENT_DELETE_SCOPES,
93
94
  DataEntry: () => DataEntry,
@@ -117,7 +118,7 @@ __export(events_exports, {
117
118
  EmailField: () => EmailField,
118
119
  EmailValue: () => EmailValue,
119
120
  EnableConditional: () => EnableConditional,
120
- EventConfig: () => EventConfig,
121
+ EventConfig: () => EventConfig2,
121
122
  EventDocument: () => EventDocument,
122
123
  EventDocumentOnlyLastAction: () => EventDocumentOnlyLastAction,
123
124
  EventFieldConfigSchema: () => EventFieldConfigSchema,
@@ -161,6 +162,7 @@ __export(events_exports, {
161
162
  HiddenFieldValue: () => HiddenFieldValue,
162
163
  HttpFieldUpdateValue: () => HttpFieldUpdateValue,
163
164
  HttpFieldValue: () => HttpFieldValue,
165
+ INITIAL_EVENT_CONFIG_VERSION_ID: () => INITIAL_EVENT_CONFIG_VERSION_ID,
164
166
  IdReaderFieldValue: () => IdReaderFieldValue,
165
167
  ImageMimeType: () => ImageMimeType,
166
168
  InactiveOfficeError: () => InactiveOfficeError,
@@ -180,6 +182,7 @@ __export(events_exports, {
180
182
  NameFieldUpdateValue: () => NameFieldUpdateValue,
181
183
  NameFieldValue: () => NameFieldValue,
182
184
  NonEmptyTextValue: () => NonEmptyTextValue,
185
+ NoneOfStatus: () => NoneOfStatus,
183
186
  NotifyActionInput: () => NotifyActionInput,
184
187
  NumberFieldValue: () => NumberFieldValue,
185
188
  NumberWithUnitFieldUpdateValue: () => NumberWithUnitFieldUpdateValue,
@@ -203,10 +206,13 @@ __export(events_exports, {
203
206
  RegisterAction: () => RegisterAction,
204
207
  RegisterActionInput: () => RegisterActionInput,
205
208
  RegistrationCreationMetadata: () => RegistrationCreationMetadata,
209
+ ReinstateRegistrationActionInput: () => ReinstateRegistrationActionInput,
206
210
  RejectCorrectionActionInput: () => RejectCorrectionActionInput,
207
211
  RejectDeclarationActionInput: () => RejectDeclarationActionInput,
208
212
  RejectedCorrectionAction: () => RejectedCorrectionAction,
213
+ RemoteDraft: () => RemoteDraft,
209
214
  RequestCorrectionActionInput: () => RequestCorrectionActionInput,
215
+ RevokeRegistrationActionInput: () => RevokeRegistrationActionInput,
210
216
  SearchQuery: () => SearchQuery,
211
217
  SearchQueryParams: () => SearchQueryParams,
212
218
  SeededLocationVersions: () => SeededLocationVersions,
@@ -244,6 +250,7 @@ __export(events_exports, {
244
250
  VerificationActionConfig: () => VerificationActionConfig,
245
251
  VerificationPageConfig: () => VerificationPageConfig,
246
252
  VerificationStatusValue: () => VerificationStatusValue,
253
+ VersionedEventConfig: () => VersionedEventConfig2,
247
254
  WithdrawAdministrativeAreaVersionPayload: () => WithdrawAdministrativeAreaVersionPayload,
248
255
  WithdrawLocationVersionPayload: () => WithdrawLocationVersionPayload,
249
256
  Within: () => Within,
@@ -273,6 +280,7 @@ __export(events_exports, {
273
280
  areConditionsMet: () => areConditionsMet,
274
281
  buildClientFunctionContext: () => buildClientFunctionContext,
275
282
  buildFormState: () => buildFormState,
283
+ byEffectiveFrom: () => byEffectiveFrom,
276
284
  canAccessEventWithScope: () => canAccessEventWithScope,
277
285
  canAccessOtherUserWithScopes: () => canAccessOtherUserWithScopes,
278
286
  canAccessUserWithScope: () => canAccessUserWithScope,
@@ -310,6 +318,8 @@ __export(events_exports, {
310
318
  filterActionsByFlags: () => filterActionsByFlags,
311
319
  findActiveDraftForEvent: () => findActiveDraftForEvent,
312
320
  findAllFields: () => findAllFields,
321
+ findConfigVersion: () => findConfigVersion,
322
+ findEventConfigForRecord: () => findEventConfigForRecord,
313
323
  findLastAssignmentAction: () => findLastAssignmentAction,
314
324
  findPendingCorrectionAction: () => findPendingCorrectionAction,
315
325
  findRecordActionPages: () => findRecordActionPages,
@@ -318,6 +328,7 @@ __export(events_exports, {
318
328
  flattenFormState: () => flattenFormState,
319
329
  generateActionDeclarationInput: () => generateActionDeclarationInput,
320
330
  generateActionDocument: () => generateActionDocument,
331
+ generateActionDocuments: () => generateActionDocuments,
321
332
  generateActionDuplicateDeclarationInput: () => generateActionDuplicateDeclarationInput,
322
333
  generateEventConfig: () => generateEventConfig,
323
334
  generateEventDocument: () => generateEventDocument,
@@ -336,6 +347,7 @@ __export(events_exports, {
336
347
  getActionAnnotation: () => getActionAnnotation,
337
348
  getActionAnnotationFields: () => getActionAnnotationFields,
338
349
  getActionConfig: () => getActionConfig,
350
+ getActionForm: () => getActionForm,
339
351
  getActionFormFields: () => getActionFormFields,
340
352
  getActionReview: () => getActionReview,
341
353
  getActionReviewFields: () => getActionReviewFields,
@@ -349,35 +361,45 @@ __export(events_exports, {
349
361
  getCompleteActionAnnotation: () => getCompleteActionAnnotation,
350
362
  getCompleteActionContent: () => getCompleteActionContent,
351
363
  getCompleteActionDeclaration: () => getCompleteActionDeclaration,
364
+ getConfigVersion: () => getConfigVersion,
352
365
  getCurrentEventState: () => getCurrentEventState,
353
366
  getCustomActionFields: () => getCustomActionFields,
354
367
  getDeclaration: () => getDeclaration,
355
368
  getDeclarationAfterEachAction: () => getDeclarationAfterEachAction,
356
369
  getDeclarationFieldById: () => getDeclarationFieldById,
357
370
  getDeclarationFields: () => getDeclarationFields,
371
+ getDeclarationFieldsOfAllVersions: () => getDeclarationFieldsOfAllVersions,
358
372
  getDeclarationPages: () => getDeclarationPages,
359
373
  getDeclarationWithPendingAction: () => getDeclarationWithPendingAction,
360
374
  getEventConfigById: () => getEventConfigById,
375
+ getEventConfigForRecord: () => getEventConfigForRecord,
376
+ getEventConfigOfVersion: () => getEventConfigOfVersion,
361
377
  getEventFlags: () => getEventFlags,
362
378
  getEventValidatorContext: () => getEventValidatorContext,
379
+ getEventWithCompleteAcceptedActions: () => getEventWithCompleteAcceptedActions,
363
380
  getFilePathsFromEvent: () => getFilePathsFromEvent,
364
381
  getLeafAdministrativeAreaIds: () => getLeafAdministrativeAreaIds,
365
382
  getLocationHierarchy: () => getLocationHierarchy,
366
383
  getMixedPath: () => getMixedPath,
384
+ getNotificationFields: () => getNotificationFields,
385
+ getNotificationForm: () => getNotificationForm,
367
386
  getPendingAction: () => getPendingAction,
368
387
  getPrintCertificatePages: () => getPrintCertificatePages,
369
388
  getRandomDate: () => getRandomDate,
370
389
  getStatusFromActions: () => getStatusFromActions,
371
390
  getValidatorsForField: () => getValidatorsForField,
391
+ getVersionsInEffect: () => getVersionsInEffect,
372
392
  getVisibleVerificationPageIds: () => getVisibleVerificationPageIds,
373
393
  hasActiveExternalIdOnOrAfter: () => hasActiveExternalIdOnOrAfter,
374
394
  hasAnyOfScopes: () => hasAnyOfScopes,
375
395
  isActionAvailable: () => isActionAvailable,
376
396
  isActionConfigType: () => isActionConfigType,
397
+ isActionDocument: () => isActionDocument,
377
398
  isActionEnabled: () => isActionEnabled,
378
399
  isActionInScope: () => isActionInScope,
379
400
  isActionVisible: () => isActionVisible,
380
401
  isAddressFieldType: () => isAddressFieldType,
402
+ isAddressFieldValue: () => isAddressFieldValue,
381
403
  isAdministrativeAreaFieldType: () => isAdministrativeAreaFieldType,
382
404
  isAgeFieldType: () => isAgeFieldType,
383
405
  isAutocompleteFieldType: () => isAutocompleteFieldType,
@@ -392,6 +414,7 @@ __export(events_exports, {
392
414
  isDateFieldType: () => isDateFieldType,
393
415
  isDateRangeFieldType: () => isDateRangeFieldType,
394
416
  isDividerFieldType: () => isDividerFieldType,
417
+ isDomesticAddressFieldValue: () => isDomesticAddressFieldValue,
395
418
  isEmailFieldType: () => isEmailFieldType,
396
419
  isEventFieldReference: () => isEventFieldReference,
397
420
  isFacilityFieldType: () => isFacilityFieldType,
@@ -405,7 +428,9 @@ __export(events_exports, {
405
428
  isFieldValueWithoutTemplates: () => isFieldValueWithoutTemplates,
406
429
  isFieldVisible: () => isFieldVisible,
407
430
  isFileFieldType: () => isFileFieldType,
431
+ isFileFieldValue: () => isFileFieldValue,
408
432
  isFileFieldWithOptionType: () => isFileFieldWithOptionType,
433
+ isFileFieldWithOptionValue: () => isFileFieldWithOptionValue,
409
434
  isHeadingFieldType: () => isHeadingFieldType,
410
435
  isHiddenFieldType: () => isHiddenFieldType,
411
436
  isHttpFieldType: () => isHttpFieldType,
@@ -426,6 +451,7 @@ __export(events_exports, {
426
451
  isPageVisible: () => isPageVisible,
427
452
  isParagraphFieldType: () => isParagraphFieldType,
428
453
  isPhoneFieldType: () => isPhoneFieldType,
454
+ isPlainDate: () => isPlainDate,
429
455
  isPotentialDuplicate: () => isPotentialDuplicate,
430
456
  isPrintButtonFieldType: () => isPrintButtonFieldType,
431
457
  isQrReaderFieldType: () => isQrReaderFieldType,
@@ -462,6 +488,10 @@ __export(events_exports, {
462
488
  plainDateToLocalDate: () => plainDateToLocalDate,
463
489
  precompileActionSchemas: () => precompileActionSchemas,
464
490
  resolveDateOfEvent: () => resolveDateOfEvent,
491
+ resolveEffectiveVersion: () => resolveEffectiveVersion,
492
+ resolveEventConfig: () => resolveEventConfig,
493
+ resolveEventConfigInTimeZone: () => resolveEventConfigInTimeZone,
494
+ resolveEventConfigOnDate: () => resolveEventConfigOnDate,
465
495
  resolveEventCustomFlags: () => resolveEventCustomFlags,
466
496
  resolvePath: () => resolvePath,
467
497
  resolvePlaceOfEvent: () => resolvePlaceOfEvent,
@@ -474,11 +504,18 @@ __export(events_exports, {
474
504
  timePeriodToDateRange: () => timePeriodToDateRange,
475
505
  toClientAdministrativeArea: () => toClientAdministrativeArea,
476
506
  toClientLocation: () => toClientLocation,
507
+ toEventConfig: () => toEventConfig,
508
+ toNotificationForm: () => toNotificationForm,
509
+ toNotificationReview: () => toNotificationReview,
477
510
  toPlainDate: () => toPlainDate,
511
+ toPlainDateInTimeZone: () => toPlainDateInTimeZone,
512
+ toVersionedEventConfig: () => toVersionedEventConfig,
478
513
  todayISO: () => todayISO,
479
514
  user: () => user,
480
515
  userCanAccessEventWithScopes: () => userCanAccessEventWithScopes,
481
516
  validate: () => validate,
517
+ validateEachVersion: () => validateEachVersion,
518
+ validateEventConfig: () => validateEventConfig,
482
519
  validateFieldInput: () => validateFieldInput,
483
520
  validateValue: () => validateValue,
484
521
  window: () => window2,
@@ -487,14 +524,17 @@ __export(events_exports, {
487
524
  });
488
525
  module.exports = __toCommonJS(events_exports);
489
526
 
527
+ // ../commons/src/events/index.ts
528
+ var import_compile = require("zod/compile");
529
+
490
530
  // ../commons/src/events/AuditLog.ts
491
531
  var z9 = __toESM(require("zod/v4"));
492
532
 
493
- // ../commons/src/authentication.ts
533
+ // ../commons/src/users/authentication.ts
494
534
  var import_jwt_decode = __toESM(require("jwt-decode"));
495
535
  var z8 = __toESM(require("zod/v4"));
496
536
 
497
- // ../commons/src/scopes.ts
537
+ // ../commons/src/users/scopes.ts
498
538
  var z7 = __toESM(require("zod/v4"));
499
539
  var qs = __toESM(require("qs"));
500
540
 
@@ -505,6 +545,12 @@ var UUID = z.uuid().brand("UUID");
505
545
  function getUUID() {
506
546
  return (0, import_uuid.v4)();
507
547
  }
548
+ function isUUID(id) {
549
+ return UUID.validate(id);
550
+ }
551
+ function maybeUuid(value) {
552
+ return isUUID(value) ? value : void 0;
553
+ }
508
554
 
509
555
  // ../commons/src/events/ActionType.ts
510
556
  var z2 = __toESM(require("zod/v4"));
@@ -530,6 +576,8 @@ var ActionType = {
530
576
  REQUEST_CORRECTION: "REQUEST_CORRECTION",
531
577
  REJECT_CORRECTION: "REJECT_CORRECTION",
532
578
  APPROVE_CORRECTION: "APPROVE_CORRECTION",
579
+ REVOKE_REGISTRATION: "REVOKE_REGISTRATION",
580
+ REINSTATE_REGISTRATION: "REINSTATE_REGISTRATION",
533
581
  // General actions
534
582
  READ: "READ",
535
583
  ASSIGN: "ASSIGN",
@@ -549,6 +597,8 @@ var ConfirmableActions = [
549
597
  ActionType.REQUEST_CORRECTION,
550
598
  ActionType.APPROVE_CORRECTION,
551
599
  ActionType.REJECT_CORRECTION,
600
+ ActionType.REVOKE_REGISTRATION,
601
+ ActionType.REINSTATE_REGISTRATION,
552
602
  ActionType.CUSTOM
553
603
  ];
554
604
  var ActionTypes = z2.enum([
@@ -568,13 +618,17 @@ var ActionTypes = z2.enum([
568
618
  "REQUEST_CORRECTION",
569
619
  "REJECT_CORRECTION",
570
620
  "APPROVE_CORRECTION",
621
+ "REVOKE_REGISTRATION",
622
+ "REINSTATE_REGISTRATION",
571
623
  "READ",
572
624
  "ASSIGN",
573
625
  "UNASSIGN",
574
626
  "CUSTOM"
575
627
  ]);
576
628
  var ClientSpecificAction = {
577
- REVIEW_CORRECTION_REQUEST: "REVIEW_CORRECTION_REQUEST"
629
+ REVIEW_CORRECTION_REQUEST: "REVIEW_CORRECTION_REQUEST",
630
+ /** Opens the user's declare or notify draft of the event in its own flow */
631
+ CONTINUE_DRAFT: "CONTINUE_DRAFT"
578
632
  };
579
633
  var declarationActionValues = [
580
634
  ActionTypes.enum.DECLARE,
@@ -609,7 +663,9 @@ var WorkqueueActionType = ActionTypes.extract([
609
663
  ActionType.ARCHIVE,
610
664
  ActionType.UNARCHIVE,
611
665
  ActionType.PRINT_CERTIFICATE,
612
- ActionType.REQUEST_CORRECTION
666
+ ActionType.REQUEST_CORRECTION,
667
+ ActionType.REVOKE_REGISTRATION,
668
+ ActionType.REINSTATE_REGISTRATION
613
669
  ]);
614
670
  var META_ACTIONS = [
615
671
  ActionType.ASSIGN,
@@ -628,7 +684,7 @@ var ActionStatus = {
628
684
  };
629
685
 
630
686
  // ../commons/src/events/Flag.ts
631
- var z5 = __toESM(require("zod/v4"));
687
+ var z5 = __toESM(require("zod"));
632
688
 
633
689
  // ../commons/src/events/TranslationConfig.ts
634
690
  var z3 = __toESM(require("zod/v4"));
@@ -697,7 +753,6 @@ var FieldConditional = z4.discriminatedUnion("type", [
697
753
 
698
754
  // ../commons/src/events/Flag.ts
699
755
  var InherentFlags = {
700
- INCOMPLETE: "incomplete",
701
756
  REJECTED: "rejected",
702
757
  CORRECTION_REQUESTED: "correction-requested",
703
758
  POTENTIAL_DUPLICATE: "potential-duplicate",
@@ -725,7 +780,7 @@ var CustomFlag = z5.string().refine((val) => !Object.values(InherentFlags).inclu
725
780
  message: `Custom flag cannot be one of the inherent flags: ${Object.values(
726
781
  InherentFlags
727
782
  ).join(", ")}`
728
- }).refine((val) => !ActionFlag.safeParse(val).success, {
783
+ }).refine((val) => !ActionFlag.validate(val), {
729
784
  message: "Custom flag cannot match the ActionFlag pattern (ActionType:ActionStatus)."
730
785
  }).describe("Custom flag identifier defined by the country config.");
731
786
  var Flag = ActionFlag.or(z5.enum(InherentFlags)).or(CustomFlag);
@@ -764,10 +819,11 @@ var EventStatus = z6.enum([
764
819
  "NOTIFIED",
765
820
  "DECLARED",
766
821
  "REGISTERED",
822
+ "REVOKED",
767
823
  "ARCHIVED"
768
824
  ]);
769
825
 
770
- // ../commons/src/scopes.ts
826
+ // ../commons/src/users/scopes.ts
771
827
  var JurisdictionFilter = z7.enum(["administrativeArea", "location", "all"]).describe(
772
828
  "Filters based on user jurisdiction relative to their office location in hierarchy."
773
829
  );
@@ -787,6 +843,8 @@ var RecordScopeTypeV2 = z7.enum([
787
843
  "record.print-certified-copies",
788
844
  "record.request-correction",
789
845
  "record.correct",
846
+ "record.revoke-registration",
847
+ "record.reinstate-registration",
790
848
  "record.unassign-others",
791
849
  "record.custom-action",
792
850
  "record.action.accept",
@@ -913,6 +971,8 @@ var ScopesWithFullOptions = RecordScopeTypeV2.extract([
913
971
  "record.read",
914
972
  "record.request-correction",
915
973
  "record.correct",
974
+ "record.revoke-registration",
975
+ "record.reinstate-registration",
916
976
  "record.unassign-others",
917
977
  "record.review-duplicates"
918
978
  ]);
@@ -1095,7 +1155,7 @@ function getAcceptedScopesByType({
1095
1155
  }).filter((scope) => scope !== null);
1096
1156
  }
1097
1157
 
1098
- // ../commons/src/authentication.ts
1158
+ // ../commons/src/users/authentication.ts
1099
1159
  var TokenUserType = z8.enum(["user", "system"]);
1100
1160
  var TokenWithBearer = z8.string().regex(/^Bearer\s/);
1101
1161
 
@@ -1157,6 +1217,8 @@ var EventActionEntrySchema = AuditLogEntryBase.extend({
1157
1217
  "event.actions.correction.request.request",
1158
1218
  "event.actions.correction.approve.request",
1159
1219
  "event.actions.correction.reject.request",
1220
+ "event.actions.revoke_registration.request",
1221
+ "event.actions.reinstate_registration.request",
1160
1222
  "event.actions.mark_as_duplicate.request",
1161
1223
  "event.actions.mark_as_not_duplicate.request"
1162
1224
  ]),
@@ -1491,7 +1553,7 @@ var z14 = __toESM(require("zod/v4"));
1491
1553
  // ../commons/src/documents.ts
1492
1554
  var z11 = __toESM(require("zod/v4"));
1493
1555
  var FullDocumentUrl = z11.string().brand("FullDocumentUrl").describe(
1494
- "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"
1556
+ "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"
1495
1557
  );
1496
1558
  var FullDocumentPath = z11.string().overwrite((val) => val.startsWith("/") ? val : `/${val}`).meta({ effectType: "input", type: "string" }).describe(
1497
1559
  "A full absolute path with bucket name, starting from the root of the S3 server, /bucket-name/document-id.jpg"
@@ -1501,7 +1563,7 @@ var DocumentPath = z11.string().brand("DocumentPath").describe(
1501
1563
  );
1502
1564
 
1503
1565
  // ../commons/src/events/CompositeFieldValue.ts
1504
- var z12 = __toESM(require("zod/v4"));
1566
+ var z12 = __toESM(require("zod"));
1505
1567
  var GeographicalArea = {
1506
1568
  URBAN: "URBAN",
1507
1569
  RURAL: "RURAL"
@@ -1515,6 +1577,9 @@ var FileFieldValue = z12.object({
1515
1577
  originalFilename: z12.string(),
1516
1578
  type: z12.string()
1517
1579
  });
1580
+ function isFileFieldValue(value) {
1581
+ return FileFieldValue.validate(value);
1582
+ }
1518
1583
  var NameFieldValue = z12.object({
1519
1584
  firstname: z12.string(),
1520
1585
  surname: z12.string(),
@@ -1539,6 +1604,9 @@ var DomesticAddressFieldValue = BaseAddressFieldValue.extend({
1539
1604
  addressType: z12.literal(AddressType.DOMESTIC),
1540
1605
  administrativeArea: z12.string().uuid()
1541
1606
  });
1607
+ function isDomesticAddressFieldValue(value) {
1608
+ return DomesticAddressFieldValue.validate(value);
1609
+ }
1542
1610
  var InternationalAddressFieldValue = BaseAddressFieldValue.extend({
1543
1611
  addressType: z12.literal(AddressType.INTERNATIONAL)
1544
1612
  });
@@ -1546,6 +1614,9 @@ var AddressFieldValue = z12.discriminatedUnion("addressType", [
1546
1614
  DomesticAddressFieldValue,
1547
1615
  InternationalAddressFieldValue
1548
1616
  ]);
1617
+ function isAddressFieldValue(value) {
1618
+ return AddressFieldValue.validate(value);
1619
+ }
1549
1620
  var DomesticAddressUpdateFieldValue = BaseAddressFieldUpdateValue.extend({
1550
1621
  addressType: z12.literal(AddressType.DOMESTIC),
1551
1622
  administrativeArea: z12.string().uuid().nullish()
@@ -1567,6 +1638,9 @@ var FileFieldValueWithOption = z12.object({
1567
1638
  option: z12.string()
1568
1639
  });
1569
1640
  var FileFieldWithOptionValue = z12.array(FileFieldValueWithOption);
1641
+ function isFileFieldWithOptionValue(value) {
1642
+ return FileFieldWithOptionValue.validate(value);
1643
+ }
1570
1644
  var HttpFieldValue = z12.object({
1571
1645
  loading: z12.boolean(),
1572
1646
  error: z12.object({ statusCode: z12.number(), message: z12.string() }).nullish(),
@@ -1602,9 +1676,30 @@ var CustomFieldValue = z12.unknown().brand("CustomFieldValue");
1602
1676
  // ../commons/src/events/PlainDate.ts
1603
1677
  var import_zod = require("zod");
1604
1678
  var PlainDate = import_zod.z.string().date().brand("PlainDate").describe("Date in the format YYYY-MM-DD");
1679
+ var isPlainDate = (date) => PlainDate.validate(date);
1605
1680
  function toPlainDate(dateTime) {
1606
1681
  return dateTime.split("T")[0];
1607
1682
  }
1683
+ var dateFormats = /* @__PURE__ */ new Map();
1684
+ function getDateFormat(timeZone) {
1685
+ let format2 = dateFormats.get(timeZone);
1686
+ if (!format2) {
1687
+ format2 = new Intl.DateTimeFormat("en-US", {
1688
+ timeZone,
1689
+ year: "numeric",
1690
+ month: "2-digit",
1691
+ day: "2-digit"
1692
+ });
1693
+ dateFormats.set(timeZone, format2);
1694
+ }
1695
+ return format2;
1696
+ }
1697
+ function toPlainDateInTimeZone(date, timeZone) {
1698
+ const parts = Object.fromEntries(
1699
+ getDateFormat(timeZone).formatToParts(date).map(({ type, value }) => [type, value])
1700
+ );
1701
+ return `${parts.year}-${parts.month}-${parts.day}`;
1702
+ }
1608
1703
  function plainDateToLocalDate(date) {
1609
1704
  const [year, month, day] = date.split("-").map(Number);
1610
1705
  return new Date(year, month - 1, day);
@@ -1717,7 +1812,7 @@ function safeUnion(schemas) {
1717
1812
  );
1718
1813
  return z14.any().superRefine((val, ctx) => {
1719
1814
  for (const schema of sortedSchemas) {
1720
- if (schema.safeParse(val).success) {
1815
+ if (schema.validate(val)) {
1721
1816
  return;
1722
1817
  }
1723
1818
  }
@@ -1911,6 +2006,16 @@ var UnarchiveAction = ActionBase.extend(
1911
2006
  type: z16.literal(ActionType.UNARCHIVE)
1912
2007
  }).shape
1913
2008
  );
2009
+ var RevokeRegistrationAction = ActionBase.extend(
2010
+ z16.object({
2011
+ type: z16.literal(ActionType.REVOKE_REGISTRATION)
2012
+ }).shape
2013
+ );
2014
+ var ReinstateRegistrationAction = ActionBase.extend(
2015
+ z16.object({
2016
+ type: z16.literal(ActionType.REINSTATE_REGISTRATION)
2017
+ }).shape
2018
+ );
1914
2019
  var CreatedAction = ActionBase.extend(
1915
2020
  z16.object({
1916
2021
  type: z16.literal(ActionType.CREATE)
@@ -1979,6 +2084,8 @@ var ActionDocument = z16.discriminatedUnion("type", [
1979
2084
  MarkAsDuplicateAction.meta({ id: "MarkAsDuplicateAction" }),
1980
2085
  ArchiveAction.meta({ id: "ArchiveAction" }),
1981
2086
  UnarchiveAction.meta({ id: "UnarchiveAction" }),
2087
+ RevokeRegistrationAction.meta({ id: "RevokeRegistrationAction" }),
2088
+ ReinstateRegistrationAction.meta({ id: "ReinstateRegistrationAction" }),
1982
2089
  NotifiedAction.meta({ id: "NotifiedAction" }),
1983
2090
  RegisterAction.meta({ id: "RegisterAction" }),
1984
2091
  DeclareAction.meta({ id: "DeclareAction" }),
@@ -1994,6 +2101,7 @@ var ActionDocument = z16.discriminatedUnion("type", [
1994
2101
  ]).meta({
1995
2102
  id: "ActionDocument"
1996
2103
  });
2104
+ var isActionDocument = (a) => ActionDocument.validate(a);
1997
2105
  var AsyncRejectActionDocument = ActionBase.omit({
1998
2106
  declaration: true,
1999
2107
  annotation: true
@@ -2027,11 +2135,15 @@ var RegistrationCreationMetadata = ActionCreationMetadata.extend({
2027
2135
  var LegalStatuses = z17.object({
2028
2136
  [EventStatus.enum.NOTIFIED]: ActionCreationMetadata.nullish(),
2029
2137
  [EventStatus.enum.DECLARED]: ActionCreationMetadata.nullish(),
2030
- [EventStatus.enum.REGISTERED]: RegistrationCreationMetadata.nullish()
2138
+ [EventStatus.enum.REGISTERED]: RegistrationCreationMetadata.nullish(),
2139
+ [EventStatus.enum.REVOKED]: ActionCreationMetadata.nullish()
2031
2140
  });
2032
2141
  var EventMetadata = z17.object({
2033
2142
  id: UUID,
2034
2143
  type: z17.string().describe("The type of event, such as birth, death, or marriage."),
2144
+ configVersionId: z17.string().describe(
2145
+ "Id of the event configuration version the record was created under. Records created before versioning have 'initial'."
2146
+ ),
2035
2147
  status: EventStatus,
2036
2148
  legalStatuses: LegalStatuses.describe(
2037
2149
  "Metadata related to the legal registration of the event, such as who registered it and when."
@@ -2229,6 +2341,12 @@ var AnyOfStatus = import_v4.z.object({
2229
2341
  }).meta({
2230
2342
  id: "AnyOfStatus"
2231
2343
  });
2344
+ var NoneOfStatus = import_v4.z.object({
2345
+ type: import_v4.z.literal("noneOf"),
2346
+ terms: import_v4.z.array(EventStatus)
2347
+ }).meta({
2348
+ id: "NoneOfStatus"
2349
+ });
2232
2350
  var Range = import_v4.z.object({
2233
2351
  type: import_v4.z.literal("range"),
2234
2352
  gte: import_v4.z.string(),
@@ -2269,7 +2387,7 @@ var QueryInput = import_v4.z.lazy(
2269
2387
  var QueryExpression = import_v4.z.object({
2270
2388
  id: import_v4.z.optional(import_v4.z.string()),
2271
2389
  eventType: import_v4.z.string(),
2272
- status: import_v4.z.optional(import_v4.z.union([AnyOfStatus, ExactStatus])),
2390
+ status: import_v4.z.optional(import_v4.z.union([AnyOfStatus, NoneOfStatus, ExactStatus])),
2273
2391
  createdAt: import_v4.z.optional(DateCondition),
2274
2392
  updatedAt: import_v4.z.optional(DateCondition),
2275
2393
  "legalStatuses.DECLARED.createdAtLocation": import_v4.z.optional(Within).nullable(),
@@ -2278,6 +2396,7 @@ var QueryExpression = import_v4.z.object({
2278
2396
  "legalStatuses.REGISTERED.createdAtLocation": import_v4.z.optional(Within).nullable(),
2279
2397
  "legalStatuses.REGISTERED.createdByRole": import_v4.z.optional(AnyOf),
2280
2398
  "legalStatuses.REGISTERED.registrationNumber": import_v4.z.optional(Exact),
2399
+ "legalStatuses.REVOKED.createdAtLocation": import_v4.z.optional(Within).nullable(),
2281
2400
  createdAtLocation: import_v4.z.optional(import_v4.z.union([Within, Exact])),
2282
2401
  updatedAtLocation: import_v4.z.optional(import_v4.z.union([Within, Exact])),
2283
2402
  assignedTo: import_v4.z.optional(Exact),
@@ -3478,6 +3597,12 @@ var ReadActionConfig = ActionConfigBase.extend(
3478
3597
  var NotifyConfig = ActionConfigBase.extend(
3479
3598
  z25.object({
3480
3599
  type: z25.literal(ActionType.NOTIFY),
3600
+ notificationForm: DeclarationFormConfig.describe(
3601
+ "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."
3602
+ ),
3603
+ review: DeclarationReviewConfig.describe(
3604
+ "Review page configuration for the notify action. Values of its fields are stored as the NOTIFY action annotation."
3605
+ ),
3481
3606
  form: actionConfirmationForm
3482
3607
  }).shape
3483
3608
  );
@@ -3561,6 +3686,18 @@ var UnarchiveConfig = ActionConfigBase.extend(
3561
3686
  type: z25.literal(ActionType.UNARCHIVE)
3562
3687
  }).shape
3563
3688
  );
3689
+ var RevokeRegistrationConfig = ActionConfigBase.extend(
3690
+ z25.object({
3691
+ type: z25.literal(ActionType.REVOKE_REGISTRATION),
3692
+ form: actionConfirmationForm
3693
+ }).shape
3694
+ );
3695
+ var ReinstateRegistrationConfig = ActionConfigBase.extend(
3696
+ z25.object({
3697
+ type: z25.literal(ActionType.REINSTATE_REGISTRATION),
3698
+ form: actionConfirmationForm
3699
+ }).shape
3700
+ );
3564
3701
  var EditActionConfig = ActionConfigBase.extend(
3565
3702
  z25.object({
3566
3703
  type: z25.literal(ActionType.EDIT),
@@ -3647,11 +3784,11 @@ var ActionConfig = z25.discriminatedUnion("type", [
3647
3784
  }),
3648
3785
  NotifyConfig.meta({
3649
3786
  id: "NotifyActionConfig",
3650
- description: "Configuration for the notify action. When present, NOTIFY uses this config independently from DECLARE. When absent, NOTIFY falls back to the DeclareActionConfig."
3787
+ description: "Configuration for the notify action: the notification form and its review page. An event without a NOTIFY action cannot be notified."
3651
3788
  }),
3652
3789
  DeclareConfig.meta({
3653
3790
  id: "DeclareActionConfig",
3654
- description: "Configuration for the declare action. Includes review-page fields. NOTIFY falls back to this config when no dedicated NotifyActionConfig is provided."
3791
+ description: "Configuration for the declare action. Includes the declaration form and review-page fields."
3655
3792
  }),
3656
3793
  DuplicateDetectedConfig.meta({
3657
3794
  id: "DuplicateDetectedActionConfig",
@@ -3701,6 +3838,14 @@ var ActionConfig = z25.discriminatedUnion("type", [
3701
3838
  id: "UnarchiveActionConfig",
3702
3839
  description: "Configuration for unarchiving a record."
3703
3840
  }),
3841
+ RevokeRegistrationConfig.meta({
3842
+ id: "RevokeRegistrationActionConfig",
3843
+ description: "Configuration for revoking a registered record."
3844
+ }),
3845
+ ReinstateRegistrationConfig.meta({
3846
+ id: "ReinstateRegistrationActionConfig",
3847
+ description: "Configuration for reinstating a revoked record back to registered."
3848
+ }),
3704
3849
  CustomActionConfig.meta({
3705
3850
  id: "CustomActionConfig",
3706
3851
  description: "Configuration for a country-defined custom action. An event may include any number of these."
@@ -3907,7 +4052,7 @@ var ReferenceField = BaseField2.extend({
3907
4052
  var Field = BaseField2.extend({
3908
4053
  id: z29.string().describe("Identifier of the summary field."),
3909
4054
  value: TranslationConfig.describe(
3910
- 'Field value template supports variables from configuration (e.g. "{informant.phoneNo} {informant.email}") and EventMetadata (e.g. "{event.legalStatuses.REGISTERED.acceptedAt, date, ::dd MMMM yyyy}").'
4055
+ 'Field value template supports variables from configuration (e.g. "{informant.phoneNo} {informant.email}") and EventMetadata (e.g. "{event.legalStatuses.REGISTERED.acceptedAt, date, ::dd MMMM yyyy}"). "{event.configVersionLabel}" gives the label of the configuration version that the record was created under.'
3911
4056
  ),
3912
4057
  label: TranslationConfig
3913
4058
  }).describe("Custom field defined for the summary view.");
@@ -4002,7 +4147,10 @@ var SearchQueryParams = z30.object({
4002
4147
  }).catchall(FieldValue);
4003
4148
  var FieldConfigSchema = BaseField3.extend({
4004
4149
  fieldId: z30.string(),
4005
- fieldType: z30.literal("field")
4150
+ fieldType: z30.literal("field"),
4151
+ defaultValue: z30.union([z30.boolean(), z30.string(), z30.number()]).optional().describe(
4152
+ `Value the field opens with in advanced search. Omitted or true uses the declaration form's defaultValue, false opens the field empty, and any other value opens it with that value. Only text, number and date fields take a value; every other field type, and date fields searched as a range, only accept true or false.`
4153
+ )
4006
4154
  });
4007
4155
  var EventFieldIdInput = z30.enum([
4008
4156
  "trackingId",
@@ -4051,6 +4199,41 @@ var AdvancedSearchConfig = z30.object({
4051
4199
  description: "Configuration of one advanced search tab. Each tab has a title and a list of searchable fields \u2014 either declaration fields (via `field()`) or event metadata (via `event()`)."
4052
4200
  });
4053
4201
 
4202
+ // ../commons/src/utils.ts
4203
+ var z31 = __toESM(require("zod/v4"));
4204
+ var _ = __toESM(require("lodash"));
4205
+ function getOrThrow(x, message) {
4206
+ if (x === void 0 || x === null) {
4207
+ throw new Error(message);
4208
+ }
4209
+ return x;
4210
+ }
4211
+ function joinValues(values, separator = " ") {
4212
+ return values.filter((value) => !!value).join(separator).trim();
4213
+ }
4214
+ var FullNameV1 = z31.array(
4215
+ z31.object({
4216
+ use: z31.string(),
4217
+ family: z31.string(),
4218
+ given: z31.array(z31.string())
4219
+ })
4220
+ );
4221
+ function omitKeyDeep(obj, keyToRemove) {
4222
+ if (Array.isArray(obj)) {
4223
+ return obj.map((item) => omitKeyDeep(item, keyToRemove));
4224
+ }
4225
+ if (obj === null || typeof obj !== "object") {
4226
+ return obj;
4227
+ }
4228
+ const newObj = {};
4229
+ for (const key of Object.keys(obj)) {
4230
+ if (key !== keyToRemove) {
4231
+ newObj[key] = omitKeyDeep(obj[key], keyToRemove);
4232
+ }
4233
+ }
4234
+ return newObj;
4235
+ }
4236
+
4054
4237
  // ../commons/src/events/utils.ts
4055
4238
  var import_lodash4 = require("lodash");
4056
4239
 
@@ -4061,15 +4244,15 @@ var z34 = __toESM(require("zod/v4"));
4061
4244
  var import_date_fns2 = require("date-fns");
4062
4245
 
4063
4246
  // ../commons/src/events/FieldTypeMapping.ts
4064
- var z32 = __toESM(require("zod/v4"));
4247
+ var z33 = __toESM(require("zod/v4"));
4065
4248
 
4066
4249
  // ../commons/src/events/DynamicFieldValue.ts
4067
- var z31 = __toESM(require("zod/v4"));
4250
+ var z32 = __toESM(require("zod/v4"));
4068
4251
  function getDynamicNameValue(field3) {
4069
4252
  const nameConfiguration = field3.configuration?.name;
4070
4253
  const firstnameRequired = nameConfiguration?.firstname?.required ?? field3.required;
4071
4254
  const surnameRequired = nameConfiguration?.surname?.required ?? field3.required;
4072
- return z31.object({
4255
+ return z32.object({
4073
4256
  firstname: firstnameRequired ? NonEmptyTextValue : TextValue,
4074
4257
  surname: surnameRequired ? NonEmptyTextValue : TextValue,
4075
4258
  middlename: nameConfiguration?.middlename?.required ? NonEmptyTextValue : TextValue.optional()
@@ -4100,7 +4283,7 @@ function mapFieldTypeToZod(field3, actionType) {
4100
4283
  let schema;
4101
4284
  switch (field3.type) {
4102
4285
  case FieldType.FIELD_GROUP: {
4103
- schema = z32.object(
4286
+ schema = z33.object(
4104
4287
  field3.fields.reduce((acc, subfield) => {
4105
4288
  acc[subfield.id] = mapFieldTypeToZod(subfield, actionType);
4106
4289
  return acc;
@@ -4424,41 +4607,6 @@ var isNonInteractiveFieldType = (field3) => {
4424
4607
  // ../commons/src/events/state/index.ts
4425
4608
  var import_lodash3 = require("lodash");
4426
4609
 
4427
- // ../commons/src/utils.ts
4428
- var z33 = __toESM(require("zod/v4"));
4429
- var _ = __toESM(require("lodash"));
4430
- function getOrThrow(x, message) {
4431
- if (x === void 0 || x === null) {
4432
- throw new Error(message);
4433
- }
4434
- return x;
4435
- }
4436
- function joinValues(values, separator = " ") {
4437
- return values.filter((value) => !!value).join(separator).trim();
4438
- }
4439
- var FullNameV1 = z33.array(
4440
- z33.object({
4441
- use: z33.string(),
4442
- family: z33.string(),
4443
- given: z33.array(z33.string())
4444
- })
4445
- );
4446
- function omitKeyDeep(obj, keyToRemove) {
4447
- if (Array.isArray(obj)) {
4448
- return obj.map((item) => omitKeyDeep(item, keyToRemove));
4449
- }
4450
- if (obj === null || typeof obj !== "object") {
4451
- return obj;
4452
- }
4453
- const newObj = {};
4454
- for (const key of Object.keys(obj)) {
4455
- if (key !== keyToRemove) {
4456
- newObj[key] = omitKeyDeep(obj[key], keyToRemove);
4457
- }
4458
- }
4459
- return newObj;
4460
- }
4461
-
4462
4610
  // ../commons/src/events/state/utils.ts
4463
4611
  var import_lodash = require("lodash");
4464
4612
  function getActionRequests(actionType, actions) {
@@ -4512,6 +4660,8 @@ var updateActions = new Set(
4512
4660
  ActionType.REQUEST_CORRECTION,
4513
4661
  ActionType.APPROVE_CORRECTION,
4514
4662
  ActionType.REJECT_CORRECTION,
4663
+ ActionType.REVOKE_REGISTRATION,
4664
+ ActionType.REINSTATE_REGISTRATION,
4515
4665
  ActionType.CUSTOM
4516
4666
  ]).options
4517
4667
  );
@@ -4538,7 +4688,7 @@ function getActionUpdateMetadata(actions) {
4538
4688
  (0, import_lodash.pick)(createAction, metadataFields)
4539
4689
  );
4540
4690
  }
4541
- function getLegalStatuses(actions) {
4691
+ function getLegalStatuses(actions, status2) {
4542
4692
  return {
4543
4693
  [EventStatus.enum.NOTIFIED]: getDeclarationActionCreationMetadata(
4544
4694
  ActionType.NOTIFY,
@@ -4551,7 +4701,12 @@ function getLegalStatuses(actions) {
4551
4701
  [EventStatus.enum.REGISTERED]: getDeclarationActionCreationMetadata(
4552
4702
  ActionType.REGISTER,
4553
4703
  actions
4554
- )
4704
+ ),
4705
+ // A later reinstate does not remove the revoke action, so only report it while the record is still revoked.
4706
+ [EventStatus.enum.REVOKED]: status2 === EventStatus.enum.REVOKED ? getDeclarationActionCreationMetadata(
4707
+ ActionType.REVOKE_REGISTRATION,
4708
+ actions
4709
+ ) : null
4555
4710
  };
4556
4711
  }
4557
4712
 
@@ -4628,15 +4783,6 @@ var INHERENT_FLAG_RULES = [
4628
4783
  setOn: [ActionType.REQUEST_CORRECTION],
4629
4784
  resetOn: [ActionType.APPROVE_CORRECTION, ActionType.REJECT_CORRECTION]
4630
4785
  },
4631
- {
4632
- // INCOMPLETE mirrors the NOTIFIED status: set by NOTIFY, cleared by any
4633
- // other status-changing action (see getStatusFromActions). ARCHIVE/UNARCHIVE
4634
- // are deliberately excluded so the flag freezes across an archive/unarchive
4635
- // round trip and comes back exactly as it was.
4636
- flag: InherentFlags.INCOMPLETE,
4637
- setOn: [ActionType.NOTIFY],
4638
- resetOn: [ActionType.CREATE, ActionType.DECLARE, ActionType.REGISTER]
4639
- },
4640
4786
  {
4641
4787
  flag: InherentFlags.REJECTED,
4642
4788
  setOn: [ActionType.REJECT],
@@ -5421,6 +5567,10 @@ function getStatusFromActions(actions) {
5421
5567
  return EventStatus.enum.REGISTERED;
5422
5568
  case ActionType.NOTIFY:
5423
5569
  return EventStatus.enum.NOTIFIED;
5570
+ case ActionType.REVOKE_REGISTRATION:
5571
+ return EventStatus.enum.REVOKED;
5572
+ case ActionType.REINSTATE_REGISTRATION:
5573
+ return EventStatus.enum.REGISTERED;
5424
5574
  // Already filtered out above; listed here only to satisfy exhaustiveness.
5425
5575
  case ActionType.ARCHIVE:
5426
5576
  case ActionType.UNARCHIVE:
@@ -5480,35 +5630,24 @@ function resolveDateOfEvent(eventIndex, declaration, config) {
5480
5630
  if (!config.dateOfEvent) {
5481
5631
  return extractDateString(eventIndex[DEFAULT_DATE_OF_EVENT_PROPERTY]);
5482
5632
  }
5483
- const parsedDate = isFieldReference(config.dateOfEvent) ? ZodDate.safeParse(declaration[config.dateOfEvent.$$field]) : ZodDateTime.safeParse(
5484
- getMixedPath(eventIndex, config.dateOfEvent.$$event)
5633
+ if (isFieldReference(config.dateOfEvent)) {
5634
+ const fieldDate = declaration[config.dateOfEvent.$$field];
5635
+ return ZodDate.validate(fieldDate) ? extractDateString(fieldDate) : void 0;
5636
+ }
5637
+ const eventDate = getMixedPath(
5638
+ eventIndex,
5639
+ config.dateOfEvent.$$event
5485
5640
  );
5486
- return parsedDate.success ? extractDateString(parsedDate.data) : void 0;
5641
+ return ZodDateTime.validate(eventDate) ? extractDateString(eventDate) : void 0;
5487
5642
  }
5488
5643
  var DEFAULT_PLACE_OF_EVENT_PROPERTY = "createdAtLocation";
5489
- function getParsedUUID(value, oldValue) {
5490
- const parsed = UUID.safeParse(value);
5491
- return parsed.success ? parsed.data : oldValue;
5492
- }
5493
5644
  function resolvePlaceOfEvent(eventMetadata, declaration, config) {
5494
- let placeOfEvent = getParsedUUID(
5645
+ let placeOfEvent = maybeUuid(
5495
5646
  eventMetadata[DEFAULT_PLACE_OF_EVENT_PROPERTY]
5496
5647
  );
5497
5648
  if (config.placeOfEvent) {
5498
- const addressFieldValue = AddressFieldValue.safeParse(
5499
- declaration[config.placeOfEvent.$$field]
5500
- );
5501
- if (addressFieldValue.success && addressFieldValue.data.addressType === AddressType.DOMESTIC && addressFieldValue.data.administrativeArea) {
5502
- placeOfEvent = getParsedUUID(
5503
- addressFieldValue.data.administrativeArea,
5504
- placeOfEvent
5505
- );
5506
- } else {
5507
- placeOfEvent = getParsedUUID(
5508
- declaration[config.placeOfEvent.$$field],
5509
- placeOfEvent
5510
- );
5511
- }
5649
+ const addressFieldValue = declaration[config.placeOfEvent.$$field];
5650
+ placeOfEvent = isDomesticAddressFieldValue(addressFieldValue) ? maybeUuid(addressFieldValue.administrativeArea) ?? placeOfEvent : maybeUuid(declaration[config.placeOfEvent.$$field]) ?? placeOfEvent;
5512
5651
  }
5513
5652
  return placeOfEvent;
5514
5653
  }
@@ -5538,7 +5677,7 @@ function getCurrentEventState(event2, config) {
5538
5677
  const acceptedActionMetadata = getActionUpdateMetadata(acceptedActions);
5539
5678
  const declaration = aggregateActionDeclarations(event2);
5540
5679
  const status2 = getStatusFromActions(sortedActions);
5541
- const legalStatuses = getLegalStatuses(sortedActions);
5680
+ const legalStatuses = getLegalStatuses(sortedActions, status2);
5542
5681
  const base = deepDropNulls({
5543
5682
  id: event2.id,
5544
5683
  type: event2.type,
@@ -5554,6 +5693,7 @@ function getCurrentEventState(event2, config) {
5554
5693
  updatedAtLocation: requestActionMetadata.createdAtLocation,
5555
5694
  declaration,
5556
5695
  trackingId: event2.trackingId,
5696
+ configVersionId: event2.configVersionId,
5557
5697
  updatedByUserRole: requestActionMetadata.createdByRole,
5558
5698
  placeOfEvent: resolvePlaceOfEvent(
5559
5699
  { createdAtLocation: creationAction.createdAtLocation },
@@ -5712,7 +5852,9 @@ function buildClientFunctionContext(input) {
5712
5852
  // eslint-disable-next-line @typescript-eslint/no-use-before-define
5713
5853
  $online: isOnline(),
5714
5854
  $user: input.validatorContext?.user,
5715
- $event: input.validatorContext?.event?.document,
5855
+ $event: input.validatorContext?.event?.document ? getEventWithCompleteAcceptedActions(
5856
+ input.validatorContext.event.document
5857
+ ) : void 0,
5716
5858
  $leafAdminStructureLocationIds: input.validatorContext?.leafAdminStructureLocationIds ?? [],
5717
5859
  user: input.systemVariables?.user,
5718
5860
  $window: input.systemVariables?.$window,
@@ -5793,7 +5935,7 @@ function precompileActionSchemas(eventConfigurations) {
5793
5935
  }
5794
5936
  }
5795
5937
  function isAgeValue(value) {
5796
- return typeof value === "object" && value !== null && "age" in value && typeof value.age === "number";
5938
+ return AgeValue.validate(value);
5797
5939
  }
5798
5940
  function mergeWithBaseFormState(values, context) {
5799
5941
  return { ...context.baseFormState, ...values };
@@ -5823,15 +5965,13 @@ function validate(schema, data) {
5823
5965
  return [key, value];
5824
5966
  }
5825
5967
  const age = value.age;
5826
- const maybeAsOfDate = PlainDate.safeParse(data.$form[value.asOfDateRef]);
5968
+ const asOf = data.$form[value.asOfDateRef];
5969
+ const asOfDate = isPlainDate(asOf) ? asOf : PlainDate.parse(data.$now);
5827
5970
  return [
5828
5971
  key,
5829
5972
  {
5830
5973
  age,
5831
- dob: ageToDate(
5832
- age,
5833
- maybeAsOfDate.success ? maybeAsOfDate.data : PlainDate.parse(data.$now)
5834
- )
5974
+ dob: ageToDate(age, asOfDate)
5835
5975
  }
5836
5976
  ];
5837
5977
  });
@@ -5994,6 +6134,11 @@ var errorMessages = {
5994
6134
  description: "Error message when field is not expected",
5995
6135
  id: "error.unexpectedField"
5996
6136
  },
6137
+ notInNotifyForm: {
6138
+ defaultMessage: "Field is not part of the notify form. Notify-only data belongs in annotation",
6139
+ description: "Error message when a notify declaration contains a field outside the notify form",
6140
+ id: "error.notInNotifyForm"
6141
+ },
5997
6142
  correctionNotAllowed: {
5998
6143
  defaultMessage: "Correction not allowed for field",
5999
6144
  description: "Error message when correction is not allowed for field",
@@ -6230,6 +6375,40 @@ function getDeclarationPages(configuration) {
6230
6375
  function getDeclarationFields(configuration) {
6231
6376
  return getDeclarationPages(configuration).flatMap(({ fields }) => fields);
6232
6377
  }
6378
+ function getDeclarationFieldsOfAllVersions(config) {
6379
+ const oldestFirst = [...config.versions].sort(byEffectiveFrom);
6380
+ const fieldsById = new Map(
6381
+ oldestFirst.flatMap(
6382
+ (version) => getDeclarationFields(toEventConfig(config, version)).map(
6383
+ (field3) => [field3.id, field3]
6384
+ )
6385
+ )
6386
+ );
6387
+ return [...fieldsById.values()];
6388
+ }
6389
+ function findNotificationForm(configuration) {
6390
+ const notifyAction = configuration.actions.find(
6391
+ (action) => action.type === ActionType.NOTIFY
6392
+ );
6393
+ return notifyAction?.type === ActionType.NOTIFY ? notifyAction.notificationForm : void 0;
6394
+ }
6395
+ function getNotificationForm(configuration) {
6396
+ const notificationForm = findNotificationForm(configuration);
6397
+ if (!notificationForm) {
6398
+ throw new Error(
6399
+ `Event '${configuration.id}' has no ${ActionType.NOTIFY} action.`
6400
+ );
6401
+ }
6402
+ return notificationForm;
6403
+ }
6404
+ function getNotificationFields(configuration) {
6405
+ return getNotificationForm(configuration).pages.flatMap(
6406
+ ({ fields }) => fields
6407
+ );
6408
+ }
6409
+ function getActionForm(configuration, actionType) {
6410
+ return actionType === ActionType.NOTIFY ? getNotificationForm(configuration) : getDeclaration(configuration);
6411
+ }
6233
6412
  function isActionConfigType(type) {
6234
6413
  return actionConfigTypes.has(type);
6235
6414
  }
@@ -6238,9 +6417,6 @@ function getActionConfig({
6238
6417
  actionType,
6239
6418
  customActionType
6240
6419
  }) {
6241
- if (actionType === ActionType.NOTIFY) {
6242
- return eventConfiguration.actions.find((a) => a.type === ActionType.NOTIFY) ?? eventConfiguration.actions.find((a) => a.type === ActionType.DECLARE);
6243
- }
6244
6420
  return eventConfiguration.actions.find((a) => {
6245
6421
  if (a.type === ActionType.CUSTOM && customActionType) {
6246
6422
  return a.customActionType === customActionType;
@@ -6488,11 +6664,12 @@ function flattenFieldReference(ref) {
6488
6664
  return [ref.$$field, ...ref.$$subfield];
6489
6665
  }
6490
6666
  function isWriteAction(actionType) {
6491
- return writeActions.safeParse(actionType).success;
6667
+ return writeActions.validate(actionType);
6492
6668
  }
6493
6669
  var findAllFields = (config) => {
6494
6670
  return (0, import_lodash4.flattenDeep)([
6495
6671
  ...getDeclarationFields(config),
6672
+ ...findNotificationForm(config)?.pages.flatMap(({ fields }) => fields) ?? [],
6496
6673
  ...getAllAnnotationFields(config)
6497
6674
  ]);
6498
6675
  };
@@ -6515,10 +6692,10 @@ function getMixedPath(obj, path, defaultValue) {
6515
6692
  return (0, import_lodash4.isNil)(result) ? defaultValue : result;
6516
6693
  }
6517
6694
  function getEventConfigById(eventConfigs, id) {
6518
- const eventConfig = eventConfigs.find(
6519
- (eventConfiguration) => eventConfiguration.id === id
6695
+ return getOrThrow(
6696
+ eventConfigs.find((eventConfiguration) => eventConfiguration.id === id),
6697
+ `No configuration found for event type: ${id}`
6520
6698
  );
6521
- return getOrThrow(eventConfig, `Event config for ${id} not found`);
6522
6699
  }
6523
6700
  function timePeriodToDateRange(value) {
6524
6701
  let startDate;
@@ -6628,12 +6805,41 @@ function getCompleteActionDeclaration(declaration, event2, action) {
6628
6805
  }
6629
6806
  return deepMerge(declaration, action.declaration);
6630
6807
  }
6631
- function getAcceptedActions(event2) {
6632
- return event2.actions.filter(isAcceptedAction).map((action) => ({
6808
+ function completeAcceptedAction(event2, action) {
6809
+ return {
6633
6810
  ...action,
6634
6811
  declaration: getCompleteActionDeclaration({}, event2, action),
6635
6812
  annotation: getCompleteActionAnnotation(event2, action)
6636
- }));
6813
+ };
6814
+ }
6815
+ function getAcceptedActions(event2) {
6816
+ return event2.actions.filter(isAcceptedAction).map((action) => completeAcceptedAction(event2, action));
6817
+ }
6818
+ function getEventWithCompleteAcceptedActions(event2) {
6819
+ return {
6820
+ ...event2,
6821
+ actions: event2.actions.map((action) => {
6822
+ if (!isAcceptedAction(action) || !action.originalActionId) {
6823
+ return action;
6824
+ }
6825
+ const requestedAction = event2.actions.find(
6826
+ ({ id }) => id === action.originalActionId
6827
+ );
6828
+ if (requestedAction?.status !== ActionStatus.Requested) {
6829
+ return action;
6830
+ }
6831
+ const content = getCompleteActionContent(event2, action);
6832
+ return {
6833
+ ...completeAcceptedAction(event2, action),
6834
+ // Who requested the action, as getActionUpdateMetadata resolves it.
6835
+ createdBy: requestedAction.createdBy,
6836
+ createdByRole: requestedAction.createdByRole,
6837
+ createdByUserType: requestedAction.createdByUserType,
6838
+ createdAtLocation: requestedAction.createdAtLocation,
6839
+ ...content ? { content } : {}
6840
+ };
6841
+ })
6842
+ };
6637
6843
  }
6638
6844
  var EXCLUDED_ACTIONS = [
6639
6845
  ActionType.REQUEST_CORRECTION,
@@ -6732,6 +6938,20 @@ function dropSecuredDeclarationFields(eventConfig, eventIndex, validatorContext)
6732
6938
  }
6733
6939
 
6734
6940
  // ../commons/src/events/eventConfigValidation.ts
6941
+ var SEARCH_DEFAULT_VALUE_FIELD_TYPES = [
6942
+ FieldType.TEXT,
6943
+ FieldType.TEXTAREA,
6944
+ FieldType.EMAIL,
6945
+ FieldType.PHONE,
6946
+ FieldType.ID,
6947
+ FieldType.SELECT,
6948
+ FieldType.RADIO_GROUP,
6949
+ FieldType.COUNTRY,
6950
+ FieldType.LOCATION,
6951
+ FieldType.ADMINISTRATIVE_AREA,
6952
+ FieldType.NUMBER,
6953
+ FieldType.DATE
6954
+ ];
6735
6955
  function validateAdvancedSearchConfig(event2, ctx) {
6736
6956
  const allFields = findAllFields(event2);
6737
6957
  const fieldIds = allFields.map((field3) => field3.id);
@@ -6763,6 +6983,56 @@ function validateAdvancedSearchConfig(event2, ctx) {
6763
6983
  path: ["advancedSearch"]
6764
6984
  });
6765
6985
  }
6986
+ event2.advancedSearch.forEach((section, sectionIndex) => {
6987
+ section.fields.forEach((searchField, fieldIndex) => {
6988
+ if (searchField.fieldType !== "field" || searchField.defaultValue === void 0) {
6989
+ return;
6990
+ }
6991
+ const path = [
6992
+ "advancedSearch",
6993
+ sectionIndex,
6994
+ "fields",
6995
+ fieldIndex,
6996
+ "defaultValue"
6997
+ ];
6998
+ if (searchField.config.searchFields && searchField.config.searchFields.length > 0) {
6999
+ ctx.addIssue({
7000
+ code: "custom",
7001
+ message: `Advanced search field ${searchField.fieldId} searches across several form fields, so it does not support a defaultValue.`,
7002
+ path
7003
+ });
7004
+ return;
7005
+ }
7006
+ if (typeof searchField.defaultValue === "boolean") {
7007
+ return;
7008
+ }
7009
+ const formField = allFields.find(({ id }) => id === searchField.fieldId);
7010
+ if (!formField) {
7011
+ return;
7012
+ }
7013
+ if (!SEARCH_DEFAULT_VALUE_FIELD_TYPES.some(
7014
+ (type) => type === formField.type
7015
+ )) {
7016
+ ctx.addIssue({
7017
+ code: "custom",
7018
+ message: `Advanced search field ${searchField.fieldId} is a ${formField.type} field, which does not support a defaultValue value, only true or false. Field types that support a defaultValue value: ${SEARCH_DEFAULT_VALUE_FIELD_TYPES.join(", ")}.`,
7019
+ path
7020
+ });
7021
+ } else if (formField.type === FieldType.DATE && searchField.config.type === "range") {
7022
+ ctx.addIssue({
7023
+ code: "custom",
7024
+ message: `Advanced search field ${searchField.fieldId} is searched as a date range, so its defaultValue can only be true or false.`,
7025
+ path
7026
+ });
7027
+ } else if (!mapFieldTypeToZod(formField).safeParse(searchField.defaultValue).success) {
7028
+ ctx.addIssue({
7029
+ code: "custom",
7030
+ message: `Advanced search field ${searchField.fieldId} has defaultValue "${searchField.defaultValue}", which is not a valid ${formField.type} value.`,
7031
+ path
7032
+ });
7033
+ }
7034
+ });
7035
+ });
6766
7036
  }
6767
7037
  function validateDateOfEvent(event2, ctx) {
6768
7038
  if (event2.dateOfEvent && isFieldReference(event2.dateOfEvent)) {
@@ -6886,15 +7156,65 @@ function validateDeclarationGivenExactlyOnce(config, ctx) {
6886
7156
  });
6887
7157
  }
6888
7158
  }
7159
+ function validateNotificationForm(event2, ctx) {
7160
+ const declarationFields = getDeclarationPages(event2).flatMap(
7161
+ (page) => page.fields.map((field3) => ({ field: field3, pageId: page.id }))
7162
+ );
7163
+ event2.actions.forEach((action, actionIndex) => {
7164
+ if (action.type !== ActionType.NOTIFY) {
7165
+ return;
7166
+ }
7167
+ action.notificationForm.pages.forEach((page, pageIndex) => {
7168
+ page.fields.forEach((field3, fieldIndex) => {
7169
+ const path = [
7170
+ "actions",
7171
+ actionIndex,
7172
+ "notificationForm",
7173
+ "pages",
7174
+ pageIndex,
7175
+ "fields",
7176
+ fieldIndex
7177
+ ];
7178
+ const matchingFields = declarationFields.filter(
7179
+ (declarationField) => declarationField.field.id === field3.id
7180
+ );
7181
+ if (matchingFields.length === 0) {
7182
+ ctx.addIssue({
7183
+ code: "custom",
7184
+ 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.`,
7185
+ path
7186
+ });
7187
+ return;
7188
+ }
7189
+ if (!matchingFields.some(
7190
+ (declarationField) => declarationField.field.type === field3.type
7191
+ )) {
7192
+ const [declarationField] = matchingFields;
7193
+ ctx.addIssue({
7194
+ code: "custom",
7195
+ 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}.`,
7196
+ path
7197
+ });
7198
+ }
7199
+ });
7200
+ });
7201
+ });
7202
+ }
6889
7203
 
6890
7204
  // ../commons/src/events/EventConfig.ts
6891
7205
  var EventFieldReference = z35.object({ $$event: EventMetadataDateFieldIdInput }).describe(
6892
7206
  "Reference to a field defined in the event metadata, using the field id."
6893
7207
  );
6894
- var _EventConfigBase = z35.object({
7208
+ var eventLevelFields = {
6895
7209
  id: z35.string().describe(
6896
7210
  'Machine-readable identifier of the event (e.g. "birth", "death").'
6897
7211
  ),
7212
+ label: TranslationConfig.describe("Human-readable label for the event type."),
7213
+ advancedSearch: z35.array(AdvancedSearchConfig).optional().default([]).describe(
7214
+ "Configuration of fields available in the advanced search feature."
7215
+ )
7216
+ };
7217
+ var versionFields = {
6898
7218
  dateOfEvent: FieldReference.or(EventFieldReference).optional().describe(
6899
7219
  "Reference to the field capturing the date of the event (e.g. date of birth). Defaults to the event creation date if unspecified."
6900
7220
  ),
@@ -6910,18 +7230,12 @@ var _EventConfigBase = z35.object({
6910
7230
  summary: SummaryConfig.describe(
6911
7231
  "Summary information displayed in the event overview."
6912
7232
  ),
6913
- label: TranslationConfig.describe(
6914
- "Human-readable label for the event type."
6915
- ),
6916
7233
  actions: z35.array(ActionConfig).describe(
6917
7234
  "Configuration of core and custom actions associated with the event."
6918
7235
  ),
6919
7236
  actionOrder: z35.array(z35.string()).optional().describe(
6920
7237
  "Order of actions in the action menu. Use either the action type for core actions or the customActionType for custom actions."
6921
7238
  ),
6922
- advancedSearch: z35.array(AdvancedSearchConfig).optional().default([]).describe(
6923
- "Configuration of fields available in the advanced search feature."
6924
- ),
6925
7239
  flags: z35.array(FlagConfig).optional().default([]).describe(
6926
7240
  "Configuration of custom flags associated with the actions of this event type."
6927
7241
  ),
@@ -6931,20 +7245,180 @@ var _EventConfigBase = z35.object({
6931
7245
  icon: z35.partialRecord(AvailableIcons, Conditional).optional().describe(
6932
7246
  'Maps an icon name to a conditional. The icon of the first entry (in definition order) whose conditional matches the event is used when rendering it (e.g. in the "iconWithName"/"iconWithNameEvent" workqueue columns). Falls back to the default status-based icon when unset or when no conditional matches.'
6933
7247
  )
6934
- });
6935
- var EventConfig = _EventConfigBase.superRefine((event2, ctx) => {
7248
+ };
7249
+ var _EventConfigBase = z35.object({ ...eventLevelFields, ...versionFields });
7250
+ function validateEventConfig(event2, ctx) {
6936
7251
  if (!validateExactlyOneDeclareAction(event2, ctx)) {
6937
7252
  return;
6938
7253
  }
7254
+ validateNotificationForm(event2, ctx);
6939
7255
  validateAdvancedSearchConfig(event2, ctx);
6940
7256
  validateDateOfEvent(event2, ctx);
6941
7257
  validatePlaceOfEvent(event2, ctx);
6942
7258
  validateActionFlags(event2, ctx);
6943
7259
  validateActionOrder(event2, ctx);
6944
- }).meta({
7260
+ }
7261
+ var EventConfig2 = _EventConfigBase.superRefine(validateEventConfig).meta({
6945
7262
  id: "EventConfig",
6946
7263
  description: "Configuration defining an event type registered in OpenCRVS (for example birth or death)."
6947
7264
  });
7265
+ var INITIAL_EVENT_CONFIG_VERSION_ID = "initial";
7266
+ var DEFAULT_EFFECTIVE_FROM = "0001-01-01";
7267
+ var _EventConfigVersion = z35.object({
7268
+ id: z35.string().describe(
7269
+ 'Identifier of the version, unique within the event (e.g. "birth-v2").'
7270
+ ),
7271
+ label: TranslationConfig.describe(
7272
+ 'Name of the version, which the UI shows wherever it names the version. For example, "{event.configVersionLabel}" in the event summary.'
7273
+ ),
7274
+ effectiveFrom: z35.iso.date().default(DEFAULT_EFFECTIVE_FROM).describe(
7275
+ `Date (YYYY-MM-DD) from which this version is effective. A version without one is effective from the beginning of time ('${DEFAULT_EFFECTIVE_FROM}').`
7276
+ ),
7277
+ ...versionFields
7278
+ });
7279
+ var resolvedConfigs = /* @__PURE__ */ new WeakMap();
7280
+ function toEventConfig(config, version) {
7281
+ let resolvedVersions = resolvedConfigs.get(config);
7282
+ if (!resolvedVersions) {
7283
+ resolvedVersions = /* @__PURE__ */ new WeakMap();
7284
+ resolvedConfigs.set(config, resolvedVersions);
7285
+ }
7286
+ const cached = resolvedVersions.get(version);
7287
+ if (cached) {
7288
+ return cached;
7289
+ }
7290
+ const {
7291
+ id: _id,
7292
+ label: _label,
7293
+ effectiveFrom: _effectiveFrom,
7294
+ ...fields
7295
+ } = version;
7296
+ const resolved = {
7297
+ ...fields,
7298
+ id: config.id,
7299
+ label: config.label,
7300
+ advancedSearch: config.advancedSearch
7301
+ };
7302
+ resolvedVersions.set(version, resolved);
7303
+ return resolved;
7304
+ }
7305
+ function findConfigVersion(config, versionId) {
7306
+ return config.versions.find(({ id }) => id === versionId);
7307
+ }
7308
+ function getConfigVersion(config, versionId) {
7309
+ return getOrThrow(
7310
+ findConfigVersion(config, versionId),
7311
+ `Event '${config.id}' has no version '${versionId}'`
7312
+ );
7313
+ }
7314
+ function getEventConfigOfVersion(config, versionId) {
7315
+ return toEventConfig(config, getConfigVersion(config, versionId));
7316
+ }
7317
+ function byEffectiveFrom(a, b) {
7318
+ return a.effectiveFrom.localeCompare(b.effectiveFrom);
7319
+ }
7320
+ function getVersionsInEffectOn(config, date) {
7321
+ return config.versions.filter(({ effectiveFrom }) => effectiveFrom <= date).sort(byEffectiveFrom);
7322
+ }
7323
+ function findVersionInEffectOn(config, date) {
7324
+ return getVersionsInEffectOn(config, date).at(-1);
7325
+ }
7326
+ function getVersionsInEffect(config, now2, timeZone) {
7327
+ return getVersionsInEffectOn(config, toPlainDateInTimeZone(now2, timeZone));
7328
+ }
7329
+ function resolveEffectiveVersion(config, now2, timeZone) {
7330
+ return findVersionInEffectOn(config, toPlainDateInTimeZone(now2, timeZone));
7331
+ }
7332
+ function findEventConfigForRecord(config, record8) {
7333
+ const version = findConfigVersion(config, record8.configVersionId);
7334
+ return version && toEventConfig(config, version);
7335
+ }
7336
+ function getEventConfigForRecord(config, record8) {
7337
+ return getEventConfigOfVersion(config, record8.configVersionId);
7338
+ }
7339
+ function resolveEventConfigOnDate(config, date) {
7340
+ return toEventConfig(
7341
+ config,
7342
+ getOrThrow(
7343
+ findVersionInEffectOn(config, date),
7344
+ `Event '${config.id}' has no version in effect on ${date}`
7345
+ )
7346
+ );
7347
+ }
7348
+ function resolveEventConfigInTimeZone(config, timeZone, now2 = /* @__PURE__ */ new Date()) {
7349
+ return resolveEventConfigOnDate(config, toPlainDateInTimeZone(now2, timeZone));
7350
+ }
7351
+ function resolveEventConfig(config) {
7352
+ return resolveEventConfigInTimeZone(config, "UTC");
7353
+ }
7354
+ function validateVersionList(config, ctx) {
7355
+ const ids = /* @__PURE__ */ new Set();
7356
+ const versionIdByEffectiveFrom = /* @__PURE__ */ new Map();
7357
+ config.versions.forEach((version, index) => {
7358
+ if (ids.has(version.id)) {
7359
+ ctx.addIssue({
7360
+ code: "custom",
7361
+ message: `Event '${config.id}' has more than one version with id '${version.id}'. Each version must have a different id.`,
7362
+ path: ["versions", index, "id"]
7363
+ });
7364
+ }
7365
+ ids.add(version.id);
7366
+ const sameEffectiveFromId = versionIdByEffectiveFrom.get(
7367
+ version.effectiveFrom
7368
+ );
7369
+ if (sameEffectiveFromId !== void 0) {
7370
+ const versionIds = `'${sameEffectiveFromId}', '${version.id}'`;
7371
+ ctx.addIssue({
7372
+ code: "custom",
7373
+ message: version.effectiveFrom !== DEFAULT_EFFECTIVE_FROM ? `Event '${config.id}' has more than one version with \`effectiveFrom\` '${version.effectiveFrom}' (${versionIds}). Each version must have a different \`effectiveFrom\`.` : `Event '${config.id}' has more than one version without \`effectiveFrom\` (${versionIds}). At most one version may omit it.`,
7374
+ path: ["versions", index, "effectiveFrom"]
7375
+ });
7376
+ } else {
7377
+ versionIdByEffectiveFrom.set(version.effectiveFrom, version.id);
7378
+ }
7379
+ });
7380
+ }
7381
+ function validateEachVersion(ctx, events, validate2) {
7382
+ const reported = /* @__PURE__ */ new Set();
7383
+ events.forEach((event2, index) => {
7384
+ const addIssue = (issue) => {
7385
+ if (typeof issue === "string") {
7386
+ ctx.addIssue({
7387
+ code: "custom",
7388
+ message: issue,
7389
+ path: ["versions", index]
7390
+ });
7391
+ return;
7392
+ }
7393
+ const [field3] = issue.path ?? [];
7394
+ const isEventLevel = typeof field3 === "string" && field3 in eventLevelFields;
7395
+ const path = isEventLevel ? issue.path ?? [] : ["versions", index, ...issue.path ?? []];
7396
+ const key = JSON.stringify([path, issue.message]);
7397
+ if (reported.has(key)) {
7398
+ return;
7399
+ }
7400
+ reported.add(key);
7401
+ ctx.addIssue({ ...issue, path });
7402
+ };
7403
+ validate2(event2, { value: event2, addIssue });
7404
+ });
7405
+ }
7406
+ var VersionedEventConfig2 = z35.object({
7407
+ ...eventLevelFields,
7408
+ versions: z35.array(_EventConfigVersion).min(1).describe(
7409
+ `Versions of the event configuration, each effective from its \`effectiveFrom\`. An event configured without versions has a single version, with id '${INITIAL_EVENT_CONFIG_VERSION_ID}' and \`effectiveFrom\` '${DEFAULT_EFFECTIVE_FROM}'.`
7410
+ )
7411
+ }).superRefine((config, ctx) => {
7412
+ validateVersionList(config, ctx);
7413
+ validateEachVersion(
7414
+ ctx,
7415
+ config.versions.map((version) => toEventConfig(config, version)),
7416
+ validateEventConfig
7417
+ );
7418
+ }).meta({
7419
+ id: "VersionedEventConfig",
7420
+ description: "Configuration of an event type registered in OpenCRVS (for example birth or death), with every version of it."
7421
+ });
6948
7422
 
6949
7423
  // ../commons/src/events/EventConfigInput.ts
6950
7424
  var defineDeclarationForm = (form) => DeclarationFormConfig.parse(form);
@@ -7017,7 +7491,7 @@ function createSearchConfig(baseField) {
7017
7491
 
7018
7492
  // ../commons/src/event-config/event-configuration.ts
7019
7493
  function isNonSearchableEventMetadataTimeFieldId(fieldId) {
7020
- return !EventFieldIdInput.safeParse(fieldId).success;
7494
+ return !EventFieldIdInput.validate(fieldId);
7021
7495
  }
7022
7496
  function createEventFieldConfig(fieldId) {
7023
7497
  const baseField = {
@@ -7044,7 +7518,10 @@ function eventFn(fieldId) {
7044
7518
  }
7045
7519
  var event = Object.assign(eventFn, {
7046
7520
  /**
7047
- * Checks if the event contains a specific action type.
7521
+ * Checks if the event contains a specific accepted action type.
7522
+ * Only Accepted actions are matched: a confirmable action is stored as a
7523
+ * Requested and an Accepted action, and a pending or rejected request must
7524
+ * not count as the action having happened.
7048
7525
  * Can be used directly as a conditional or chained with additional methods.
7049
7526
  * @param action - The action type to check for.
7050
7527
  */
@@ -7062,9 +7539,12 @@ var event = Object.assign(eventFn, {
7062
7539
  properties: {
7063
7540
  type: {
7064
7541
  const: action
7542
+ },
7543
+ status: {
7544
+ const: ActionStatus.Accepted
7065
7545
  }
7066
7546
  },
7067
- required: ["type"]
7547
+ required: ["type", "status"]
7068
7548
  }
7069
7549
  }
7070
7550
  },
@@ -7075,9 +7555,10 @@ var event = Object.assign(eventFn, {
7075
7555
  });
7076
7556
  const buildActionConstraints = (additionalFields) => {
7077
7557
  const actionProperties = {
7078
- type: { const: action }
7558
+ type: { const: action },
7559
+ status: { const: ActionStatus.Accepted }
7079
7560
  };
7080
- const requiredFields = ["type"];
7561
+ const requiredFields = ["type", "status"];
7081
7562
  if (additionalFields) {
7082
7563
  Object.entries(additionalFields).forEach(([key, value]) => {
7083
7564
  actionProperties[key] = { const: value };
@@ -7199,7 +7680,7 @@ var SerializableWithin = z37.object({
7199
7680
  });
7200
7681
  var SerializedQueryExpression = z37.object({
7201
7682
  eventType: z37.string(),
7202
- status: z37.optional(z37.union([AnyOfStatus, ExactStatus])),
7683
+ status: z37.optional(z37.union([AnyOfStatus, NoneOfStatus, ExactStatus])),
7203
7684
  createdAt: z37.optional(DateCondition),
7204
7685
  updatedAt: z37.optional(DateCondition),
7205
7686
  "legalStatuses.DECLARED.createdAtLocation": z37.optional(SerializableWithin),
@@ -7208,6 +7689,7 @@ var SerializedQueryExpression = z37.object({
7208
7689
  "legalStatuses.REGISTERED.createdAtLocation": z37.optional(SerializableWithin),
7209
7690
  "legalStatuses.REGISTERED.createdByRole": z37.optional(AnyOf),
7210
7691
  "legalStatuses.REGISTERED.registrationNumber": z37.optional(Exact),
7692
+ "legalStatuses.REVOKED.createdAtLocation": z37.optional(SerializableWithin),
7211
7693
  createdAtLocation: z37.optional(
7212
7694
  z37.union([SerializableWithin, SerializableExact])
7213
7695
  ),
@@ -7368,6 +7850,12 @@ var RegisterActionInput = BaseActionInput.extend(
7368
7850
  var NotifyActionInput = BaseActionInput.extend(
7369
7851
  z39.object({
7370
7852
  type: z39.literal(ActionType.NOTIFY).default(ActionType.NOTIFY),
7853
+ declaration: BaseActionInput.shape.declaration.describe(
7854
+ "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."
7855
+ ),
7856
+ annotation: BaseActionInput.shape.annotation.describe(
7857
+ "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."
7858
+ ),
7371
7859
  // For normal users, the createdAtLocation is resolved on the backend from the user's primaryOfficeId.
7372
7860
  createdAtLocation: UUID.nullish().describe(
7373
7861
  "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."
@@ -7440,6 +7928,16 @@ var UnarchiveActionInput = BaseActionInput.extend(
7440
7928
  type: z39.literal(ActionType.UNARCHIVE).default(ActionType.UNARCHIVE)
7441
7929
  }).shape
7442
7930
  );
7931
+ var RevokeRegistrationActionInput = BaseActionInput.extend(
7932
+ z39.object({
7933
+ type: z39.literal(ActionType.REVOKE_REGISTRATION).default(ActionType.REVOKE_REGISTRATION)
7934
+ }).shape
7935
+ );
7936
+ var ReinstateRegistrationActionInput = BaseActionInput.extend(
7937
+ z39.object({
7938
+ type: z39.literal(ActionType.REINSTATE_REGISTRATION).default(ActionType.REINSTATE_REGISTRATION)
7939
+ }).shape
7940
+ );
7443
7941
  var AssignActionInput = BaseActionInput.extend(
7444
7942
  z39.object({
7445
7943
  type: z39.literal(ActionType.ASSIGN),
@@ -7502,6 +8000,12 @@ var ActionInput = z39.discriminatedUnion("type", [
7502
8000
  }),
7503
8001
  ArchiveActionInput.meta({ id: "ArchiveActionInput" }),
7504
8002
  UnarchiveActionInput.meta({ id: "UnarchiveActionInput" }),
8003
+ RevokeRegistrationActionInput.meta({
8004
+ id: "RevokeRegistrationActionInput"
8005
+ }),
8006
+ ReinstateRegistrationActionInput.meta({
8007
+ id: "ReinstateRegistrationActionInput"
8008
+ }),
7505
8009
  AssignActionInput.meta({ id: "AssignActionInput" }),
7506
8010
  UnassignActionInput.meta({ id: "UnassignActionInput" }),
7507
8011
  PrintCertificateActionInput.meta({ id: "PrintCertificateActionInput" }),
@@ -7535,17 +8039,19 @@ var DraftInput = BaseActionInput.omit({ waitFor: true }).extend({
7535
8039
  /*
7536
8040
  * A draft can name a file that no action references. Such a file stays until
7537
8041
  * the record is deleted or the record's next action sweeps its prefix.
7538
- * DECLARE is available only where one of those is still coming: a created
7539
- * record, which can still be deleted, and a record part way through an edit,
7540
- * which is about to be declared or registered.
8042
+ * Drafts are therefore saved only on a created record, which can still be deleted.
8043
+ * The server refuses them on any other record.
7541
8044
  */
7542
- type: z40.literal(ActionTypes.enum.DECLARE),
8045
+ type: z40.enum([ActionTypes.enum.DECLARE, ActionTypes.enum.NOTIFY]),
7543
8046
  status: z40.enum([
7544
8047
  ActionStatus.Requested,
7545
8048
  ActionStatus.Accepted,
7546
8049
  ActionStatus.Rejected
7547
8050
  ])
7548
8051
  });
8052
+ var RemoteDraft = Draft.extend({
8053
+ action: Draft.shape.action.extend({ type: DraftInput.shape.type })
8054
+ });
7549
8055
 
7550
8056
  // ../commons/src/events/EventInput.ts
7551
8057
  var z41 = __toESM(require("zod/v4"));
@@ -7555,6 +8061,9 @@ var EventInput = z41.object({
7555
8061
  type: z41.string(),
7556
8062
  createdAtLocation: UUID.nullish().describe(
7557
8063
  "Location where the event occurred. Required for system users."
8064
+ ),
8065
+ configVersionId: z41.string().optional().describe(
8066
+ "Id of the event configuration version the client created the record under, e.g. while offline. Must be configured and not take effect in the future. Defaults to the version in effect when the server receives the record."
7558
8067
  )
7559
8068
  }).meta({ default: { transactionId: (0, import_uuid11.v4)(), type: "birth" } });
7560
8069
 
@@ -7570,6 +8079,9 @@ var EventDocument = z42.object({
7570
8079
  actions: z42.array(Action).describe("Ordered list of actions associated with the event."),
7571
8080
  trackingId: z42.string().describe(
7572
8081
  "System-generated tracking identifier used to look up the event."
8082
+ ),
8083
+ configVersionId: z42.string().describe(
8084
+ "Id of the event configuration version the record was created under. Every action on the record uses that version. Records created before versioning have 'initial'."
7573
8085
  )
7574
8086
  }).meta({ id: "EventDocument" });
7575
8087
  var EventDocumentOnlyLastAction = EventDocument.extend({
@@ -7589,18 +8101,103 @@ function moveDeclarationToDeclareAction({
7589
8101
  }
7590
8102
  return {
7591
8103
  ...config,
7592
- actions: config.actions.map(
7593
- (action) => action.type === ActionType.DECLARE && declaration ? { ...action, declaration } : action
7594
- )
8104
+ actions: config.actions.map((action) => {
8105
+ if (action.type !== ActionType.DECLARE) {
8106
+ return action;
8107
+ }
8108
+ const declarationOfAction = action.declaration ?? declaration;
8109
+ if (!declarationOfAction) {
8110
+ throw new Error(`Event '${config.id}' does not define \`declaration\`.`);
8111
+ }
8112
+ return { ...action, declaration: declarationOfAction };
8113
+ })
7595
8114
  };
7596
8115
  }
8116
+ var VERSIONED_EVENT_FIELDS = [
8117
+ "id",
8118
+ "label",
8119
+ "advancedSearch",
8120
+ "versions"
8121
+ ];
8122
+ function validateNoVersionFieldsAtTopLevel(config, ctx) {
8123
+ Object.keys(config).filter((key) => !VERSIONED_EVENT_FIELDS.includes(key)).forEach((key) => {
8124
+ ctx.addIssue({
8125
+ code: "custom",
8126
+ message: `Event '${config.id}' defines \`versions\`, so \`${key}\` must be defined on each version, not at the top level.`,
8127
+ path: [key]
8128
+ });
8129
+ });
8130
+ }
8131
+ function toVersionedInput(config) {
8132
+ if ("versions" in config) {
8133
+ return config;
8134
+ }
8135
+ const { id, label, advancedSearch, ...version } = moveDeclarationToDeclareAction(config);
8136
+ return {
8137
+ id,
8138
+ label,
8139
+ advancedSearch,
8140
+ versions: [{ ...version, id: INITIAL_EVENT_CONFIG_VERSION_ID, label }]
8141
+ };
8142
+ }
8143
+ var WESTERNMOST_TIME_ZONE = "Etc/GMT+12";
8144
+ function validateVersionInEffectToday(config, ctx) {
8145
+ const today = toPlainDateInTimeZone(/* @__PURE__ */ new Date(), WESTERNMOST_TIME_ZONE);
8146
+ const isAnyVersionInEffect = config.versions.some(
8147
+ ({ effectiveFrom }) => effectiveFrom <= today
8148
+ );
8149
+ if (!isAnyVersionInEffect) {
8150
+ ctx.addIssue({
8151
+ code: "custom",
8152
+ message: `Event '${config.id}' has no version in effect today (${today}, UTC\u221212, the last time zone to begin the day). At least one version must omit \`effectiveFrom\` or take effect on or before that date.`,
8153
+ path: ["versions"]
8154
+ });
8155
+ }
8156
+ }
7597
8157
  var EventConfigDefinition = z43.custom().superRefine((config, ctx) => {
7598
- if (validateExactlyOneDeclareAction(config, ctx)) {
7599
- validateDeclarationGivenExactlyOnce(config, ctx);
8158
+ if ("versions" in config) {
8159
+ validateNoVersionFieldsAtTopLevel(config, ctx);
8160
+ return;
7600
8161
  }
7601
- }).transform(moveDeclarationToDeclareAction).pipe(EventConfig);
8162
+ const eventCtx = { ...ctx, value: config };
8163
+ if (validateExactlyOneDeclareAction(config, eventCtx)) {
8164
+ validateDeclarationGivenExactlyOnce(config, eventCtx);
8165
+ }
8166
+ }).transform(toVersionedInput).pipe(VersionedEventConfig2).superRefine(validateVersionInEffectToday);
7602
8167
  var defineConfig = (config) => EventConfigDefinition.parse(config);
7603
8168
 
8169
+ // ../commons/src/events/toNotificationForm.ts
8170
+ function toOptionalField(field3) {
8171
+ const { validation: _validation, ...rest } = field3;
8172
+ if (rest.type === FieldType.FIELD_GROUP && "fields" in rest) {
8173
+ return {
8174
+ ...rest,
8175
+ required: false,
8176
+ fields: rest.fields.map(toOptionalField)
8177
+ };
8178
+ }
8179
+ return { ...rest, required: false };
8180
+ }
8181
+ function toNotificationForm(declaration) {
8182
+ return {
8183
+ ...declaration,
8184
+ pages: declaration.pages.map((page) => ({
8185
+ ...page,
8186
+ fields: page.fields.map(
8187
+ toOptionalField
8188
+ )
8189
+ }))
8190
+ };
8191
+ }
8192
+ function toNotificationReview(review) {
8193
+ return {
8194
+ ...review,
8195
+ fields: review.fields.map(
8196
+ toOptionalField
8197
+ )
8198
+ };
8199
+ }
8200
+
7604
8201
  // ../commons/src/events/transactions.ts
7605
8202
  function generateTransactionId() {
7606
8203
  return getUUID();
@@ -8857,7 +9454,7 @@ var TENNIS_CLUB_DECLARATION_FORM = defineDeclarationForm({
8857
9454
  });
8858
9455
 
8859
9456
  // ../commons/src/fixtures/tennis-club-membership-event.ts
8860
- var tennisClubMembershipEvent = defineConfig({
9457
+ var versionedTennisClubMembershipEvent = defineConfig({
8861
9458
  id: TENNIS_CLUB_MEMBERSHIP,
8862
9459
  declaration: TENNIS_CLUB_DECLARATION_FORM,
8863
9460
  label: {
@@ -8916,6 +9513,8 @@ var tennisClubMembershipEvent = defineConfig({
8916
9513
  description: "This is shown as the action name anywhere the user can trigger the action from",
8917
9514
  id: "event.tennis-club-membership.action.notify.label"
8918
9515
  },
9516
+ notificationForm: toNotificationForm(TENNIS_CLUB_DECLARATION_FORM),
9517
+ review: toNotificationReview(TENNIS_CLUB_DECLARATION_REVIEW),
8919
9518
  flags: [
8920
9519
  {
8921
9520
  id: "health-worker-notified",
@@ -9212,9 +9811,12 @@ var tennisClubMembershipEvent = defineConfig({
9212
9811
  }
9213
9812
  ]
9214
9813
  });
9814
+ var tennisClubMembershipEvent = resolveEventConfig(
9815
+ versionedTennisClubMembershipEvent
9816
+ );
9215
9817
 
9216
9818
  // ../commons/src/fixtures/football-club-membership-event.ts
9217
- var footballClubMembershipEvent = defineConfig({
9819
+ var versionedFootballClubMembershipEvent = defineConfig({
9218
9820
  id: "FOOTBALL_CLUB_MEMBERSHIP",
9219
9821
  label: {
9220
9822
  defaultMessage: "Football club membership application",
@@ -9537,6 +10139,9 @@ var footballClubMembershipEvent = defineConfig({
9537
10139
  ],
9538
10140
  declaration: TENNIS_CLUB_DECLARATION_FORM
9539
10141
  });
10142
+ var footballClubMembershipEvent = resolveEventConfig(
10143
+ versionedFootballClubMembershipEvent
10144
+ );
9540
10145
 
9541
10146
  // ../commons/src/fixtures/library-membership-event.ts
9542
10147
  var libraryMembershipForm = defineDeclarationForm({
@@ -9580,7 +10185,7 @@ var libraryMembershipForm = defineDeclarationForm({
9580
10185
  }
9581
10186
  ]
9582
10187
  });
9583
- var libraryMembershipEvent = defineConfig({
10188
+ var versionedLibraryMembershipEvent = defineConfig({
9584
10189
  id: "library-membership",
9585
10190
  label: {
9586
10191
  defaultMessage: "Library membership application",
@@ -9613,6 +10218,9 @@ var libraryMembershipEvent = defineConfig({
9613
10218
  ],
9614
10219
  declaration: libraryMembershipForm
9615
10220
  });
10221
+ var libraryMembershipEvent = resolveEventConfig(
10222
+ versionedLibraryMembershipEvent
10223
+ );
9616
10224
 
9617
10225
  // ../commons/src/fixtures/child-onboarding-event.ts
9618
10226
  function generateTranslationConfig(message) {
@@ -9826,7 +10434,7 @@ var CHILD_ONBOARDING_DECLARATION_FORM = defineDeclarationForm({
9826
10434
  label: generateTranslationConfig("Birth decalration form"),
9827
10435
  pages: [child, mother]
9828
10436
  });
9829
- var ChildOnboardingEvent = defineConfig({
10437
+ var versionedChildOnboardingEvent = defineConfig({
9830
10438
  id: CHILD_ONBOARDING_EVENT,
9831
10439
  title: generateTranslationConfig(
9832
10440
  "{child.name.firstname} {child.name.surname}"
@@ -9854,6 +10462,9 @@ var ChildOnboardingEvent = defineConfig({
9854
10462
  ],
9855
10463
  advancedSearch: []
9856
10464
  });
10465
+ var ChildOnboardingEvent = resolveEventConfig(
10466
+ versionedChildOnboardingEvent
10467
+ );
9857
10468
 
9858
10469
  // ../commons/src/fixtures/digital-identity-issuance-event.ts
9859
10470
  var PRINT_DIGITAL_ID_CERTIFICATE_FORM = defineActionForm({
@@ -10042,7 +10653,7 @@ var digitalIdentityForm = defineDeclarationForm({
10042
10653
  }
10043
10654
  ]
10044
10655
  });
10045
- var digitalIdentityEvent = defineConfig({
10656
+ var versionedDigitalIdentityEvent = defineConfig({
10046
10657
  id: "digital-identity",
10047
10658
  label: {
10048
10659
  defaultMessage: "Digital identity issuance",
@@ -10084,6 +10695,9 @@ var digitalIdentityEvent = defineConfig({
10084
10695
  ],
10085
10696
  declaration: digitalIdentityForm
10086
10697
  });
10698
+ var digitalIdentityEvent = resolveEventConfig(
10699
+ versionedDigitalIdentityEvent
10700
+ );
10087
10701
 
10088
10702
  // ../commons/src/events/test.utils.ts
10089
10703
  var z45 = __toESM(require("zod/v4"));
@@ -10383,8 +10997,8 @@ function userCanAccessEventWithScopes(event2, scopes, user2, customActionType) {
10383
10997
  }
10384
10998
  function getAdministrativeAreaHierarchy(administrativeAreaId, administrativeAreas) {
10385
10999
  const collectedLocations = [];
10386
- const parsedAdministrativeAreaId = administrativeAreaId && UUID.safeParse(administrativeAreaId).data;
10387
- let current = parsedAdministrativeAreaId ? administrativeAreas.get(parsedAdministrativeAreaId) : null;
11000
+ const maybeAdministrativeAreaId = maybeUuid(administrativeAreaId);
11001
+ let current = maybeAdministrativeAreaId ? administrativeAreas.get(maybeAdministrativeAreaId) : null;
10388
11002
  while (current) {
10389
11003
  collectedLocations.push(current);
10390
11004
  if (!current.parentId) {
@@ -10984,11 +11598,10 @@ function fieldConfigsToActionPayload(fields, rng, administrativeHierarchy) {
10984
11598
  );
10985
11599
  }
10986
11600
  function generateActionDeclarationInput(configuration, action, rng, overrides, administrativeHierarchy) {
10987
- const parsed = DeclarationUpdateActions.safeParse(action);
10988
11601
  if ((0, import_lodash5.isEmpty)(overrides) && typeof overrides === "object") {
10989
11602
  return {};
10990
11603
  }
10991
- if (parsed.success) {
11604
+ if (DeclarationUpdateActions.validate(action)) {
10992
11605
  const fields = getDeclarationFields(configuration);
10993
11606
  const declarationConfig = getDeclaration(configuration);
10994
11607
  const declaration = fieldConfigsToActionPayload(
@@ -11113,7 +11726,8 @@ function eventPayloadGenerator(rng, configuration = tennisClubMembershipEvent) {
11113
11726
  ...input
11114
11727
  }),
11115
11728
  /**
11116
- * Notify allows sending incomplete data. Think it as 'partial declare' for now.
11729
+ * NOTIFY submits the values of the notification form, and the record can stay incomplete.
11730
+ * When `declaration` is not given, string values are left out of the generated declaration to make it incomplete.
11117
11731
  */
11118
11732
  notify: (eventId, input = {}) => {
11119
11733
  let declaration = input.declaration;
@@ -11179,6 +11793,22 @@ function eventPayloadGenerator(rng, configuration = tennisClubMembershipEvent) {
11179
11793
  eventId,
11180
11794
  ...input
11181
11795
  }),
11796
+ revokeRegistration: (eventId, input = {}) => ({
11797
+ type: ActionType.REVOKE_REGISTRATION,
11798
+ transactionId: input.transactionId ?? getUUID(),
11799
+ declaration: {},
11800
+ annotation: {},
11801
+ eventId,
11802
+ ...input
11803
+ }),
11804
+ reinstateRegistration: (eventId, input = {}) => ({
11805
+ type: ActionType.REINSTATE_REGISTRATION,
11806
+ transactionId: input.transactionId ?? getUUID(),
11807
+ declaration: {},
11808
+ annotation: {},
11809
+ eventId,
11810
+ ...input
11811
+ }),
11182
11812
  reject: (eventId, input = {}) => ({
11183
11813
  type: ActionType.REJECT,
11184
11814
  transactionId: input.transactionId ?? getUUID(),
@@ -11347,12 +11977,14 @@ function generateActionDocument({
11347
11977
  case ActionType.REGISTER:
11348
11978
  case ActionType.REQUEST_CORRECTION:
11349
11979
  case ActionType.UNARCHIVE:
11980
+ case ActionType.REVOKE_REGISTRATION:
11981
+ case ActionType.REINSTATE_REGISTRATION:
11350
11982
  return { ...actionBase, type: action };
11351
11983
  case ActionType.EDIT:
11352
11984
  return {
11985
+ content: { comment: "Test comment" },
11353
11986
  ...actionBase,
11354
- type: action,
11355
- content: { comment: "Test comment" }
11987
+ type: action
11356
11988
  };
11357
11989
  case ActionType.CUSTOM:
11358
11990
  return {
@@ -11371,9 +12003,9 @@ function generateActionDocument({
11371
12003
  };
11372
12004
  }
11373
12005
  case ActionType.ARCHIVE:
11374
- return { ...actionBase, type: action, content: { reason: "Archive" } };
12006
+ return { content: { reason: "Archive" }, ...actionBase, type: action };
11375
12007
  case ActionType.REJECT:
11376
- return { ...actionBase, type: action, content: { reason: "Reject" } };
12008
+ return { content: { reason: "Reject" }, ...actionBase, type: action };
11377
12009
  case ActionType.PRINT_CERTIFICATE: {
11378
12010
  const printActionDefaults = defaults;
11379
12011
  return {
@@ -11383,13 +12015,13 @@ function generateActionDocument({
11383
12015
  };
11384
12016
  }
11385
12017
  case ActionType.APPROVE_CORRECTION:
11386
- return { ...actionBase, requestId: getUUID(), type: action };
12018
+ return { requestId: getUUID(), ...actionBase, type: action };
11387
12019
  case ActionType.REJECT_CORRECTION:
11388
12020
  return {
11389
- ...actionBase,
11390
12021
  requestId: getUUID(),
11391
- type: action,
11392
- content: { reason: "Correction rejection" }
12022
+ content: { reason: "Correction rejection" },
12023
+ ...actionBase,
12024
+ type: action
11393
12025
  };
11394
12026
  case ActionType.DUPLICATE_DETECTED: {
11395
12027
  const duplicateActionDefaults = defaults;
@@ -11406,6 +12038,65 @@ function generateActionDocument({
11406
12038
  throw new Error(`Unsupported action type: ${action}`);
11407
12039
  }
11408
12040
  }
12041
+ function isConfirmableAction(type) {
12042
+ return ConfirmableActions.some((confirmable) => confirmable === type);
12043
+ }
12044
+ function generateActionDocuments({
12045
+ confirmation,
12046
+ ...args
12047
+ }) {
12048
+ const actionDocument = generateActionDocument(args);
12049
+ if (!isConfirmableAction(actionDocument.type)) {
12050
+ return [actionDocument];
12051
+ }
12052
+ if (args.defaults?.status !== void 0) {
12053
+ throw new Error(
12054
+ `generateActionDocuments: set the status of ${actionDocument.type} with confirmation.status, not defaults.status`
12055
+ );
12056
+ }
12057
+ const status2 = confirmation?.status ?? ActionStatus.Accepted;
12058
+ if (status2 === ActionStatus.Requested) {
12059
+ if (confirmation?.defaults) {
12060
+ throw new Error(
12061
+ "generateActionDocuments: confirmation.defaults have no confirming action to apply to while the request is pending"
12062
+ );
12063
+ }
12064
+ return [{ ...actionDocument, status: ActionStatus.Requested }];
12065
+ }
12066
+ const requestedAction = {
12067
+ ...actionDocument,
12068
+ id: getUUID(),
12069
+ status: ActionStatus.Requested
12070
+ };
12071
+ const confirmingAction = {
12072
+ ...actionDocument,
12073
+ originalActionId: requestedAction.id,
12074
+ createdAt: new Date(
12075
+ new Date(actionDocument.createdAt).getTime() + 1
12076
+ ).toISOString(),
12077
+ ...confirmation?.defaults
12078
+ };
12079
+ if (status2 === ActionStatus.Rejected) {
12080
+ const { declaration, annotation, ...rejectedAction } = confirmingAction;
12081
+ return [
12082
+ requestedAction,
12083
+ {
12084
+ ...rejectedAction,
12085
+ type: actionDocument.type,
12086
+ status: ActionStatus.Rejected
12087
+ }
12088
+ ];
12089
+ }
12090
+ return [
12091
+ requestedAction,
12092
+ {
12093
+ ...confirmingAction,
12094
+ status: ActionStatus.Accepted,
12095
+ declaration: {},
12096
+ annotation: {}
12097
+ }
12098
+ ];
12099
+ }
11409
12100
  function generateRandomDatetime(rng, start, end) {
11410
12101
  const range = end.getTime() - start.getTime();
11411
12102
  const offset = Math.floor(rng() * range);
@@ -11424,9 +12115,20 @@ function generateEventDocument({
11424
12115
  }) {
11425
12116
  return {
11426
12117
  trackingId: generateTrackingId(rng),
12118
+ configVersionId: INITIAL_EVENT_CONFIG_VERSION_ID,
11427
12119
  type: configuration.id,
11428
- actions: actions.map(
11429
- (action, i) => generateActionDocument({
12120
+ actions: actions.flatMap((action, i) => {
12121
+ const createdAt = (0, import_date_fns4.addDays)(
12122
+ new Date(
12123
+ generateRandomDatetime(
12124
+ rng,
12125
+ new Date(2025, 0, 1),
12126
+ new Date(2025, 11, 31)
12127
+ )
12128
+ ),
12129
+ i
12130
+ );
12131
+ return generateActionDocuments({
11430
12132
  configuration,
11431
12133
  action: action.type,
11432
12134
  defaults: {
@@ -11434,20 +12136,11 @@ function generateEventDocument({
11434
12136
  createdAtLocation: action.user?.primaryOfficeId,
11435
12137
  assignedTo: action.user?.assignedTo,
11436
12138
  createdByRole: action.user?.role,
11437
- createdAt: (0, import_date_fns4.addDays)(
11438
- new Date(
11439
- generateRandomDatetime(
11440
- rng,
11441
- new Date(2025, 0, 1),
11442
- new Date(2025, 11, 31)
11443
- )
11444
- ),
11445
- i
11446
- ).toISOString()
12139
+ createdAt: createdAt.toISOString()
11447
12140
  },
11448
12141
  declarationOverrides: action.declarationOverrides
11449
- })
11450
- ),
12142
+ });
12143
+ }),
11451
12144
  // Offset is needed so the createdAt timestamps for events, actions and drafts make logical sense in storybook tests.
11452
12145
  // @TODO: This should be fixed in the future.
11453
12146
  createdAt: new Date(Date.now() - 1e3).toISOString(),
@@ -11474,6 +12167,7 @@ function generateEventDraftDocument({
11474
12167
  transactionId: getUUID(),
11475
12168
  action: {
11476
12169
  ...action,
12170
+ type: actionType,
11477
12171
  declaration: {
11478
12172
  ...action.declaration,
11479
12173
  ...declaration
@@ -11516,6 +12210,7 @@ var eventQueryDataGenerator = (overrides = {}, seed = 1) => {
11516
12210
  return {
11517
12211
  id: overrides.id ?? generateUuid(rng),
11518
12212
  type: overrides.type ?? TENNIS_CLUB_MEMBERSHIP,
12213
+ configVersionId: overrides.configVersionId ?? INITIAL_EVENT_CONFIG_VERSION_ID,
11519
12214
  status: overrides.status ?? pickRandom(rng, EventStatus.options),
11520
12215
  createdAt: overrides.createdAt ?? createdAt,
11521
12216
  createdByUserType: overrides.createdByUserType ?? "user",
@@ -11561,52 +12256,60 @@ var generateEventConfig = ({
11561
12256
  dateOfEventId,
11562
12257
  actions = []
11563
12258
  }) => {
11564
- return defineConfig({
11565
- id,
11566
- label: generateTranslationConfig2(id),
11567
- title: generateTranslationConfig2(`${id} Event`),
11568
- summary: {
11569
- fields: []
11570
- },
11571
- placeOfEvent: placeOfEventId ? { $$field: placeOfEventId } : void 0,
11572
- dateOfEvent: dateOfEventId ? { $$field: dateOfEventId } : void 0,
11573
- declaration: {
11574
- label: generateTranslationConfig2(`${id} Declaration`),
11575
- pages: [
11576
- {
11577
- id: "page1",
11578
- title: generateTranslationConfig2("Page 1"),
11579
- fields
11580
- }
11581
- ]
11582
- },
11583
- actions: [
11584
- {
11585
- type: ActionType.READ,
11586
- label: generateTranslationConfig2("Read"),
11587
- review: {
11588
- title: generateTranslationConfig2("Review Read Action"),
11589
- fields: []
11590
- }
12259
+ return resolveEventConfig(
12260
+ defineConfig({
12261
+ id,
12262
+ label: generateTranslationConfig2(id),
12263
+ title: generateTranslationConfig2(`${id} Event`),
12264
+ summary: {
12265
+ fields: []
11591
12266
  },
11592
- {
11593
- type: ActionType.DECLARE,
11594
- label: generateTranslationConfig2("Declare"),
11595
- review: {
11596
- title: generateTranslationConfig2("Review Declare Action"),
11597
- fields: []
11598
- }
12267
+ placeOfEvent: placeOfEventId ? { $$field: placeOfEventId } : void 0,
12268
+ dateOfEvent: dateOfEventId ? { $$field: dateOfEventId } : void 0,
12269
+ declaration: {
12270
+ label: generateTranslationConfig2(`${id} Declaration`),
12271
+ pages: [
12272
+ {
12273
+ id: "page1",
12274
+ title: generateTranslationConfig2("Page 1"),
12275
+ fields
12276
+ }
12277
+ ]
11599
12278
  },
11600
- ...actions
11601
- ]
11602
- });
12279
+ actions: [
12280
+ {
12281
+ type: ActionType.READ,
12282
+ label: generateTranslationConfig2("Read"),
12283
+ review: {
12284
+ title: generateTranslationConfig2("Review Read Action"),
12285
+ fields: []
12286
+ }
12287
+ },
12288
+ {
12289
+ type: ActionType.DECLARE,
12290
+ label: generateTranslationConfig2("Declare"),
12291
+ review: {
12292
+ title: generateTranslationConfig2("Review Declare Action"),
12293
+ fields: []
12294
+ }
12295
+ },
12296
+ ...actions
12297
+ ]
12298
+ })
12299
+ );
11603
12300
  };
11604
12301
  function withDeclaration(configuration, declaration) {
11605
12302
  return {
11606
12303
  ...configuration,
11607
- actions: configuration.actions.map(
11608
- (action) => action.type === ActionType.DECLARE ? { ...action, declaration } : action
11609
- )
12304
+ actions: configuration.actions.map((action) => {
12305
+ if (action.type === ActionType.DECLARE) {
12306
+ return { ...action, declaration };
12307
+ }
12308
+ if (action.type === ActionType.NOTIFY) {
12309
+ return { ...action, notificationForm: toNotificationForm(declaration) };
12310
+ }
12311
+ return action;
12312
+ })
11610
12313
  };
11611
12314
  }
11612
12315
  function getLeafAdministrativeAreaIds(administrativeAreas) {
@@ -11657,6 +12360,26 @@ function generateTestValidatorContext(userRole2, eventWithConfig) {
11657
12360
  event: getEventValidatorContext(event2, eventConfig)
11658
12361
  };
11659
12362
  }
12363
+ function toVersionedEventConfig({
12364
+ id,
12365
+ label,
12366
+ advancedSearch,
12367
+ ...version
12368
+ }) {
12369
+ return {
12370
+ id,
12371
+ label,
12372
+ advancedSearch,
12373
+ versions: [
12374
+ {
12375
+ ...version,
12376
+ id: INITIAL_EVENT_CONFIG_VERSION_ID,
12377
+ label,
12378
+ effectiveFrom: DEFAULT_EFFECTIVE_FROM
12379
+ }
12380
+ ]
12381
+ };
12382
+ }
11660
12383
 
11661
12384
  // ../commons/src/events/TemplateConfig.ts
11662
12385
  var window2 = () => ({
@@ -11670,7 +12393,7 @@ function isTemplateVariable(value) {
11670
12393
  return typeof value === "string" && value.startsWith("$");
11671
12394
  }
11672
12395
  function isFieldValue(value) {
11673
- return FieldValue.safeParse(value).success;
12396
+ return FieldValue.validate(value);
11674
12397
  }
11675
12398
  function isFieldValueWithoutTemplates(value) {
11676
12399
  if (isTemplateVariable(value)) {
@@ -11713,8 +12436,12 @@ var ACTION_SCOPE_MAP = {
11713
12436
  "record.correct"
11714
12437
  ],
11715
12438
  [ClientSpecificAction.REVIEW_CORRECTION_REQUEST]: ["record.correct"],
12439
+ // Not granted by a scope: the client checks the draft's own action instead
12440
+ [ClientSpecificAction.CONTINUE_DRAFT]: [],
11716
12441
  [ActionType.REJECT_CORRECTION]: ["record.correct"],
11717
12442
  [ActionType.APPROVE_CORRECTION]: ["record.correct"],
12443
+ [ActionType.REVOKE_REGISTRATION]: ["record.revoke-registration"],
12444
+ [ActionType.REINSTATE_REGISTRATION]: ["record.reinstate-registration"],
11718
12445
  [ActionType.MARK_AS_DUPLICATE]: ["record.review-duplicates"],
11719
12446
  [ActionType.MARK_AS_NOT_DUPLICATE]: ["record.review-duplicates"],
11720
12447
  [ActionType.ARCHIVE]: ["record.archive"],
@@ -11737,6 +12464,8 @@ var DOCUMENT_DELETE_SCOPES = [
11737
12464
  "record.print-certified-copies",
11738
12465
  "record.request-correction",
11739
12466
  "record.correct",
12467
+ "record.revoke-registration",
12468
+ "record.reinstate-registration",
11740
12469
  "record.review-duplicates",
11741
12470
  "record.archive",
11742
12471
  "record.unarchive",
@@ -11876,6 +12605,10 @@ function deserializeQueryExpression(expression, user2) {
11876
12605
  expression["legalStatuses.REGISTERED.createdAtLocation"].location,
11877
12606
  user2
11878
12607
  ) : void 0;
12608
+ const revokedLocation = expression["legalStatuses.REVOKED.createdAtLocation"] ? userDeserializer(
12609
+ expression["legalStatuses.REVOKED.createdAtLocation"].location,
12610
+ user2
12611
+ ) : void 0;
11879
12612
  return {
11880
12613
  ...expression,
11881
12614
  assignedTo: expression.assignedTo && isDefined(assignedTo) ? { ...expression.assignedTo, term: assignedTo } : void 0,
@@ -11894,6 +12627,10 @@ function deserializeQueryExpression(expression, user2) {
11894
12627
  ["legalStatuses.REGISTERED.createdAtLocation"]: expression["legalStatuses.REGISTERED.createdAtLocation"] && isDefined(registeredLocation) ? {
11895
12628
  ...expression["legalStatuses.REGISTERED.createdAtLocation"],
11896
12629
  location: registeredLocation
12630
+ } : void 0,
12631
+ ["legalStatuses.REVOKED.createdAtLocation"]: expression["legalStatuses.REVOKED.createdAtLocation"] && isDefined(revokedLocation) ? {
12632
+ ...expression["legalStatuses.REVOKED.createdAtLocation"],
12633
+ location: revokedLocation
11897
12634
  } : void 0
11898
12635
  };
11899
12636
  }
@@ -11940,7 +12677,12 @@ var AVAILABLE_ACTIONS_BY_EVENT_STATUS = {
11940
12677
  ActionType.APPROVE_CORRECTION,
11941
12678
  ActionType.REJECT_CORRECTION,
11942
12679
  ActionType.CUSTOM,
11943
- ClientSpecificAction.REVIEW_CORRECTION_REQUEST
12680
+ ClientSpecificAction.REVIEW_CORRECTION_REQUEST,
12681
+ ActionType.REVOKE_REGISTRATION
12682
+ ],
12683
+ [EventStatus.enum.REVOKED]: [
12684
+ ActionType.READ,
12685
+ ActionType.REINSTATE_REGISTRATION
11944
12686
  ],
11945
12687
  [EventStatus.enum.ARCHIVED]: [
11946
12688
  ActionType.READ,
@@ -11954,6 +12696,8 @@ var ACTION_FILTERS = {
11954
12696
  [ClientSpecificAction.REVIEW_CORRECTION_REQUEST]: (flags) => flags.includes(InherentFlags.CORRECTION_REQUESTED) && !flags.some((flag2) => flag2.endsWith(":requested")),
11955
12697
  [ActionType.APPROVE_CORRECTION]: (flags) => flags.includes(InherentFlags.CORRECTION_REQUESTED) && !flags.some((flag2) => flag2.endsWith(":requested")),
11956
12698
  [ActionType.REJECT_CORRECTION]: (flags) => flags.includes(InherentFlags.CORRECTION_REQUESTED) && !flags.some((flag2) => flag2.endsWith(":requested")),
12699
+ [ActionType.REVOKE_REGISTRATION]: (flags) => !flags.includes(InherentFlags.CORRECTION_REQUESTED) && !flags.some((flag2) => flag2.endsWith(":requested")),
12700
+ [ActionType.REINSTATE_REGISTRATION]: (flags) => !flags.some((flag2) => flag2.endsWith(":requested")),
11957
12701
  [ActionType.MARK_AS_DUPLICATE]: (flags) => flags.includes(InherentFlags.POTENTIAL_DUPLICATE) && !flags.some((flag2) => flag2.endsWith(":requested")),
11958
12702
  [ActionType.EDIT]: (flags) => !flags.includes(InherentFlags.POTENTIAL_DUPLICATE) && !flags.some((flag2) => flag2.endsWith(":requested")),
11959
12703
  [ActionType.REGISTER]: (flags) => !flags.includes(InherentFlags.POTENTIAL_DUPLICATE) && !flags.some((flag2) => flag2.endsWith(":requested")),
@@ -12003,13 +12747,11 @@ function getFilePathsFromEvent(event2) {
12003
12747
  ...declarationValues,
12004
12748
  ...annotationValues
12005
12749
  ].flatMap((value) => {
12006
- const fileParsed = FileFieldValue.safeParse(value);
12007
- if (fileParsed.success) {
12008
- return [fileParsed.data.path];
12750
+ if (isFileFieldValue(value)) {
12751
+ return [value.path];
12009
12752
  }
12010
- const fileOptionParsed = FileFieldWithOptionValue.safeParse(value);
12011
- if (fileOptionParsed.success) {
12012
- return fileOptionParsed.data.map((val) => val.path);
12753
+ if (isFileFieldWithOptionValue(value)) {
12754
+ return value.map((val) => val.path);
12013
12755
  }
12014
12756
  return [];
12015
12757
  });