@opencrvs/toolkit 2.2.0-rc.ac299dc → 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.
- package/build.sh +17 -14
- package/dist/application-config/index.js +21 -11
- package/dist/authentication/index.d.ts +2 -1
- package/dist/authentication/index.js +20 -13
- package/dist/cli.js +2631 -377
- package/dist/commons/api/router.d.ts +263 -250
- package/dist/commons/application-config/index.d.ts +3 -3
- package/dist/commons/conditionals/conditionals.d.ts +4 -4
- package/dist/commons/conditionals/index.d.ts +1 -0
- package/dist/commons/conditionals/validate.d.ts +6 -1
- package/dist/commons/events/ActionConfig.d.ts +16 -23
- package/dist/commons/events/ActionDocument.d.ts +1 -0
- package/dist/commons/events/ActionInput.d.ts +4 -4
- package/dist/commons/events/ActionStatus.d.ts +2 -2
- package/dist/commons/events/ActionType.d.ts +2 -0
- package/dist/commons/events/AdvancedSearchConfig.d.ts +3 -6
- package/dist/commons/events/CompositeFieldValue.d.ts +5 -1
- package/dist/commons/events/CountryConfigQueryInput.d.ts +0 -18
- package/dist/commons/events/Draft.d.ts +34 -1
- package/dist/commons/events/EventConfig.d.ts +448 -1
- package/dist/commons/events/EventDocument.d.ts +2 -0
- package/dist/commons/events/EventIndex.d.ts +3 -6
- package/dist/commons/events/EventInput.d.ts +1 -0
- package/dist/commons/events/EventMetadata.d.ts +1 -1
- package/dist/commons/events/FieldConfig.d.ts +1 -1
- package/dist/commons/events/FieldTypeMapping.d.ts +17 -17
- package/dist/commons/events/Flag.d.ts +1 -7
- package/dist/commons/events/PlainDate.d.ts +6 -0
- package/dist/commons/events/WorkqueueConfig.d.ts +12 -27
- package/dist/commons/events/defineConfig.d.ts +7 -2
- package/dist/commons/events/event.d.ts +4 -1
- package/dist/commons/events/eventConfigValidation.d.ts +9 -0
- package/dist/commons/events/field.d.ts +5 -5
- package/dist/commons/events/index.d.ts +3 -0
- package/dist/commons/events/locations.d.ts +1 -1
- package/dist/commons/events/scopes.d.ts +2 -1
- package/dist/commons/events/state/flags.d.ts +1 -1
- package/dist/commons/events/state/index.d.ts +1 -0
- package/dist/commons/events/test.utils.d.ts +62 -7
- package/dist/commons/events/toNotificationForm.d.ts +17 -0
- package/dist/commons/events/utils.d.ts +59 -7
- package/dist/commons/users/Role.d.ts +23 -0
- package/dist/commons/users/User.d.ts +263 -0
- package/dist/commons/users/authentication.d.ts +67 -0
- package/dist/commons/users/index.d.ts +5 -0
- package/dist/commons/users/roleValidations.d.ts +15 -0
- package/dist/commons/users/scopes.d.ts +1402 -0
- package/dist/commons/users/userReferences.d.ts +176 -0
- package/dist/conditionals/index.js +5 -6
- package/dist/configurator/index.d.ts +24 -0
- package/dist/configurator/index.d.ts.map +1 -0
- package/dist/configurator/index.js +161 -0
- package/dist/configurator/layout.d.ts +29 -0
- package/dist/configurator/layout.d.ts.map +1 -0
- package/dist/configurator/layout.js +78 -0
- package/dist/configurator/paths.d.ts +13 -0
- package/dist/configurator/paths.d.ts.map +1 -0
- package/dist/configurator/paths.js +48 -0
- package/dist/configurator/server/environments.d.ts +20 -0
- package/dist/configurator/server/environments.d.ts.map +1 -0
- package/dist/configurator/server/environments.js +143 -0
- package/dist/configurator/server/files.d.ts +11 -0
- package/dist/configurator/server/files.d.ts.map +1 -0
- package/dist/configurator/server/files.js +67 -0
- package/dist/configurator/server/github.d.ts +56 -0
- package/dist/configurator/server/github.d.ts.map +1 -0
- package/dist/configurator/server/github.js +239 -0
- package/dist/configurator/server/plugin.d.ts +39 -0
- package/dist/configurator/server/plugin.d.ts.map +1 -0
- package/dist/configurator/server/plugin.js +298 -0
- package/dist/configurator/server/seal.d.ts +2 -0
- package/dist/configurator/server/seal.d.ts.map +1 -0
- package/dist/configurator/server/seal.js +36 -0
- package/dist/configurator/server/sshKeys.d.ts +5 -0
- package/dist/configurator/server/sshKeys.d.ts.map +1 -0
- package/dist/configurator/server/sshKeys.js +28 -0
- package/dist/configurator/server/start.d.ts +12 -0
- package/dist/configurator/server/start.d.ts.map +1 -0
- package/dist/configurator/server/start.js +91 -0
- package/dist/configurator/testing.d.ts +11 -0
- package/dist/configurator/testing.d.ts.map +1 -0
- package/dist/configurator/testing.js +74 -0
- package/dist/configurator/ui/bindings/bindings.d.ts +35 -0
- package/dist/configurator/ui/bindings/bindings.d.ts.map +1 -0
- package/dist/configurator/ui/bindings/bindings.js +5 -0
- package/dist/configurator/ui/bindings/parsers.d.ts +7 -0
- package/dist/configurator/ui/bindings/parsers.d.ts.map +1 -0
- package/dist/configurator/ui/bindings/parsers.js +85 -0
- package/dist/configurator/ui/form/users.d.ts +11 -0
- package/dist/configurator/ui/form/users.d.ts.map +1 -0
- package/dist/configurator/ui/form/users.js +33 -0
- package/dist/configurator/ui/plan/dependencyHosts.d.ts +2 -0
- package/dist/configurator/ui/plan/dependencyHosts.d.ts.map +1 -0
- package/dist/configurator/ui/plan/dependencyHosts.js +36 -0
- package/dist/configurator/ui/plan/templateValues.d.ts +11 -0
- package/dist/configurator/ui/plan/templateValues.d.ts.map +1 -0
- package/dist/configurator/ui/plan/templateValues.js +70 -0
- package/dist/configurator/workflows.d.ts +54 -0
- package/dist/configurator/workflows.d.ts.map +1 -0
- package/dist/configurator/workflows.js +161 -0
- package/dist/configurator-assets/forms/bindings.yml +265 -0
- package/dist/configurator-assets/templates/README.md +18 -0
- package/dist/configurator-assets/templates/charts-values/dependencies/values.override.yaml +4 -0
- package/dist/configurator-assets/templates/charts-values/dependencies/values.yaml +96 -0
- package/dist/configurator-assets/templates/charts-values/opencrvs-services/values.override.yaml +4 -0
- package/dist/configurator-assets/templates/charts-values/opencrvs-services/values.yaml +83 -0
- package/dist/configurator-assets/templates/charts-values/opentelemetry/values.yaml +102 -0
- package/dist/configurator-assets/templates/charts-values/traefik/values.override.yaml +4 -0
- package/dist/configurator-assets/templates/charts-values/traefik/values.yaml +130 -0
- package/dist/configurator-assets/templates/inventory/inventory.template.yml +98 -0
- package/dist/configurator-assets/ui/apple-touch-icon.png +0 -0
- package/dist/configurator-assets/ui/assets/index-CaqYFJUk.css +6 -0
- package/dist/configurator-assets/ui/assets/index-DU1Y6E0b.js +169 -0
- package/dist/configurator-assets/ui/assets/opencrvs-logo-sIjz08HT.svg +1 -0
- package/dist/configurator-assets/ui/assets/poppins-400-BwTUGeWf.woff2 +0 -0
- package/dist/configurator-assets/ui/assets/poppins-500-CWICHMj6.woff2 +0 -0
- package/dist/configurator-assets/ui/assets/poppins-600-DJVo7c07.woff2 +0 -0
- package/dist/configurator-assets/ui/assets/poppins-700-g9MkRaG0.woff2 +0 -0
- package/dist/configurator-assets/ui/favicon-32x32.png +0 -0
- package/dist/configurator-assets/ui/index.html +25 -0
- package/dist/environment/custom-types.d.ts +1 -0
- package/dist/environment/custom-types.d.ts.map +1 -1
- package/dist/environment/derived-variables.d.ts +18 -4
- package/dist/environment/derived-variables.d.ts.map +1 -1
- package/dist/environment/derived-variables.js +20 -4
- package/dist/environment/questions.d.ts +42 -9
- package/dist/environment/questions.d.ts.map +1 -1
- package/dist/environment/questions.js +71 -48
- package/dist/environment/registry.d.ts +15 -0
- package/dist/environment/registry.d.ts.map +1 -0
- package/dist/environment/registry.js +112 -0
- package/dist/environment/setup-environment.d.ts.map +1 -1
- package/dist/environment/setup-environment.js +145 -25
- package/dist/environment/templates.d.ts.map +1 -1
- package/dist/events/index.js +826 -210
- package/dist/migrations/add-notify-config.d.ts +40 -0
- package/dist/migrations/add-notify-config.d.ts.map +1 -0
- package/dist/migrations/add-notify-config.js +249 -0
- package/dist/migrations/index.d.ts +9 -0
- package/dist/migrations/index.d.ts.map +1 -0
- package/dist/migrations/index.js +1306 -0
- package/dist/migrations/move-declaration-to-declare-action.d.ts +38 -0
- package/dist/migrations/move-declaration-to-declare-action.d.ts.map +1 -0
- package/dist/migrations/move-declaration-to-declare-action.js +260 -0
- package/dist/migrations/{add-translations.d.ts → persistent/add-translations.d.ts} +1 -1
- package/dist/migrations/persistent/add-translations.d.ts.map +1 -0
- package/dist/migrations/{add-translations.js → persistent/add-translations.js} +2 -2
- package/dist/migrations/persistent/check-upgrade-path.d.ts +36 -0
- package/dist/migrations/persistent/check-upgrade-path.d.ts.map +1 -0
- package/dist/migrations/persistent/check-upgrade-path.js +105 -0
- package/dist/migrations/persistent/update-toolkit-dependency.d.ts +7 -0
- package/dist/migrations/persistent/update-toolkit-dependency.d.ts.map +1 -0
- package/dist/migrations/persistent/update-toolkit-dependency.js +77 -0
- package/dist/migrations/{v2.2/read-declaration-through-helper.d.ts → read-declaration-through-helper.d.ts} +1 -1
- package/dist/migrations/read-declaration-through-helper.d.ts.map +1 -0
- package/dist/migrations/{v2.2/read-declaration-through-helper.js → read-declaration-through-helper.js} +4 -62
- package/dist/migrations/replace-incomplete-flag.d.ts +26 -0
- package/dist/migrations/replace-incomplete-flag.d.ts.map +1 -0
- package/dist/migrations/replace-incomplete-flag.js +126 -0
- package/dist/migrations/resolve-versioned-event-config.d.ts +56 -0
- package/dist/migrations/resolve-versioned-event-config.d.ts.map +1 -0
- package/dist/migrations/resolve-versioned-event-config.js +353 -0
- package/dist/migrations/utils.d.ts +61 -0
- package/dist/migrations/utils.d.ts.map +1 -0
- package/dist/migrations/utils.js +218 -0
- package/dist/notification/index.js +722 -82
- package/dist/roles/index.d.ts +2 -0
- package/dist/roles/index.d.ts.map +1 -0
- package/dist/roles/index.js +730 -0
- package/dist/scopes/index.d.ts +54 -94
- package/dist/scopes/index.js +15 -12
- package/dist/templates/charts-values/dependencies/values.yaml +5 -2
- package/dist/templates/charts-values/opencrvs-services/values.yaml +5 -7
- package/dist/templates/charts-values/traefik/values.yaml +2 -0
- package/dist/verify/endpoints.d.ts +11 -0
- package/dist/verify/endpoints.d.ts.map +1 -1
- package/dist/verify/endpoints.js +21 -27
- package/opencrvs-toolkit-2.2.0-rc.e6591c5.tgz +0 -0
- package/package.json +17 -4
- package/tsconfig.build.json +11 -1
- package/tsconfig.build.tsbuildinfo +1 -1
- package/tsconfig.json +15 -6
- package/dist/migrations/add-translations.d.ts.map +0 -1
- package/dist/migrations/v2.1/add-explicit-correction-flags.d.ts +0 -3
- package/dist/migrations/v2.1/add-explicit-correction-flags.d.ts.map +0 -1
- package/dist/migrations/v2.1/add-explicit-correction-flags.js +0 -234
- package/dist/migrations/v2.1/add-recovery-link-notifications.d.ts +0 -3
- package/dist/migrations/v2.1/add-recovery-link-notifications.d.ts.map +0 -1
- package/dist/migrations/v2.1/add-recovery-link-notifications.js +0 -511
- package/dist/migrations/v2.1/enable-telemetry.d.ts +0 -3
- package/dist/migrations/v2.1/enable-telemetry.d.ts.map +0 -1
- package/dist/migrations/v2.1/enable-telemetry.js +0 -455
- package/dist/migrations/v2.1/index.d.ts +0 -6
- package/dist/migrations/v2.1/index.d.ts.map +0 -1
- package/dist/migrations/v2.1/index.js +0 -50
- package/dist/migrations/v2.1/migrate-infrastructure-to-assets.d.ts +0 -17
- package/dist/migrations/v2.1/migrate-infrastructure-to-assets.d.ts.map +0 -1
- package/dist/migrations/v2.1/migrate-infrastructure-to-assets.js +0 -348
- package/dist/migrations/v2.1/remove-metabase-package-installs.d.ts +0 -2
- package/dist/migrations/v2.1/remove-metabase-package-installs.d.ts.map +0 -1
- package/dist/migrations/v2.1/remove-metabase-package-installs.js +0 -161
- package/dist/migrations/v2.1/remove-sentry.d.ts +0 -3
- package/dist/migrations/v2.1/remove-sentry.d.ts.map +0 -1
- package/dist/migrations/v2.1/remove-sentry.js +0 -354
- package/dist/migrations/v2.1/rename-trigger-paths.d.ts +0 -3
- package/dist/migrations/v2.1/rename-trigger-paths.d.ts.map +0 -1
- package/dist/migrations/v2.1/rename-trigger-paths.js +0 -216
- package/dist/migrations/v2.1/template-files.d.ts +0 -8
- package/dist/migrations/v2.1/template-files.d.ts.map +0 -1
- package/dist/migrations/v2.1/template-files.js +0 -49
- package/dist/migrations/v2.1/upgrade-tilt.d.ts +0 -11
- package/dist/migrations/v2.1/upgrade-tilt.d.ts.map +0 -1
- package/dist/migrations/v2.1/upgrade-tilt.js +0 -139
- package/dist/migrations/v2.2/index.d.ts +0 -6
- package/dist/migrations/v2.2/index.d.ts.map +0 -1
- package/dist/migrations/v2.2/index.js +0 -456
- package/dist/migrations/v2.2/read-declaration-through-helper.d.ts.map +0 -1
- package/dist/templates/countryconfig-template/.tiltignore +0 -1
- package/dist/templates/countryconfig-template/Dockerfile.assets +0 -7
- package/dist/templates/countryconfig-template/Tiltfile +0 -112
- package/dist/templates/countryconfig-template/assets/README.md +0 -1
- package/dist/templates/countryconfig-template/assets/clear-all-data-dev.sh +0 -61
- package/dist/templates/countryconfig-template/assets/deployment/deploy.sh +0 -455
- package/dist/templates/countryconfig-template/assets/deployment/reindex.sh +0 -168
- package/dist/templates/countryconfig-template/assets/deployment/validate-required-variables-in-compose-files.ts +0 -67
- package/dist/templates/countryconfig-template/assets/elasticsearch/reindex.sh +0 -168
- package/dist/templates/countryconfig-template/assets/metabase/README.md +0 -34
- package/dist/templates/countryconfig-template/assets/metabase/environment-configuration.sql +0 -36
- package/dist/templates/countryconfig-template/assets/metabase/initialize-database.sh +0 -46
- package/dist/templates/countryconfig-template/assets/metabase/metabase.init.db.sql +0 -27737
- package/dist/templates/countryconfig-template/assets/metabase/open-shell.sh +0 -21
- package/dist/templates/countryconfig-template/assets/metabase/package.json +0 -13
- package/dist/templates/countryconfig-template/assets/metabase/run-dev.sh +0 -108
- package/dist/templates/countryconfig-template/assets/metabase/run.sh +0 -120
- package/dist/templates/countryconfig-template/assets/metabase/update-database.sh +0 -40
- package/dist/templates/countryconfig-template/assets/postgres/setup-analytics.sh +0 -135
- package/dist/templates/countryconfig-template/assets/postgres/setup-reference-data.sh +0 -108
- package/dist/templates/countryconfig-template/tilt/clear-all-data.ps1 +0 -50
- package/dist/templates/countryconfig-template/tilt/clear-all-data.sh +0 -35
- package/dist/templates/countryconfig-template/tilt/common.tilt +0 -145
- package/dist/templates/countryconfig-template/tilt/examples/dependencies/values.yaml +0 -15
- package/dist/templates/countryconfig-template/tilt/examples/opencrvs-services/values.yaml +0 -56
- package/dist/templates/countryconfig-template/tilt/examples/traefik/values-minikube.yaml +0 -21
- package/dist/templates/countryconfig-template/tilt/examples/traefik/values.yaml +0 -38
- package/dist/templates/countryconfig-template/tilt/helm/dependencies/values.yaml +0 -17
- package/dist/templates/countryconfig-template/tilt/helm/opencrvs-services/values.yaml +0 -16
- package/dist/templates/countryconfig-template/tilt/lib.tilt +0 -95
- package/dist/templates/countryconfig-template/tilt/opencrvs.tilt +0 -136
- package/opencrvs-toolkit-2.2.0-rc.ac299dc.tgz +0 -0
package/dist/events/index.js
CHANGED
|
@@ -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: () =>
|
|
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,
|
|
@@ -208,6 +210,7 @@ __export(events_exports, {
|
|
|
208
210
|
RejectCorrectionActionInput: () => RejectCorrectionActionInput,
|
|
209
211
|
RejectDeclarationActionInput: () => RejectDeclarationActionInput,
|
|
210
212
|
RejectedCorrectionAction: () => RejectedCorrectionAction,
|
|
213
|
+
RemoteDraft: () => RemoteDraft,
|
|
211
214
|
RequestCorrectionActionInput: () => RequestCorrectionActionInput,
|
|
212
215
|
RevokeRegistrationActionInput: () => RevokeRegistrationActionInput,
|
|
213
216
|
SearchQuery: () => SearchQuery,
|
|
@@ -247,6 +250,7 @@ __export(events_exports, {
|
|
|
247
250
|
VerificationActionConfig: () => VerificationActionConfig,
|
|
248
251
|
VerificationPageConfig: () => VerificationPageConfig,
|
|
249
252
|
VerificationStatusValue: () => VerificationStatusValue,
|
|
253
|
+
VersionedEventConfig: () => VersionedEventConfig2,
|
|
250
254
|
WithdrawAdministrativeAreaVersionPayload: () => WithdrawAdministrativeAreaVersionPayload,
|
|
251
255
|
WithdrawLocationVersionPayload: () => WithdrawLocationVersionPayload,
|
|
252
256
|
Within: () => Within,
|
|
@@ -276,6 +280,7 @@ __export(events_exports, {
|
|
|
276
280
|
areConditionsMet: () => areConditionsMet,
|
|
277
281
|
buildClientFunctionContext: () => buildClientFunctionContext,
|
|
278
282
|
buildFormState: () => buildFormState,
|
|
283
|
+
byEffectiveFrom: () => byEffectiveFrom,
|
|
279
284
|
canAccessEventWithScope: () => canAccessEventWithScope,
|
|
280
285
|
canAccessOtherUserWithScopes: () => canAccessOtherUserWithScopes,
|
|
281
286
|
canAccessUserWithScope: () => canAccessUserWithScope,
|
|
@@ -313,6 +318,8 @@ __export(events_exports, {
|
|
|
313
318
|
filterActionsByFlags: () => filterActionsByFlags,
|
|
314
319
|
findActiveDraftForEvent: () => findActiveDraftForEvent,
|
|
315
320
|
findAllFields: () => findAllFields,
|
|
321
|
+
findConfigVersion: () => findConfigVersion,
|
|
322
|
+
findEventConfigForRecord: () => findEventConfigForRecord,
|
|
316
323
|
findLastAssignmentAction: () => findLastAssignmentAction,
|
|
317
324
|
findPendingCorrectionAction: () => findPendingCorrectionAction,
|
|
318
325
|
findRecordActionPages: () => findRecordActionPages,
|
|
@@ -321,6 +328,7 @@ __export(events_exports, {
|
|
|
321
328
|
flattenFormState: () => flattenFormState,
|
|
322
329
|
generateActionDeclarationInput: () => generateActionDeclarationInput,
|
|
323
330
|
generateActionDocument: () => generateActionDocument,
|
|
331
|
+
generateActionDocuments: () => generateActionDocuments,
|
|
324
332
|
generateActionDuplicateDeclarationInput: () => generateActionDuplicateDeclarationInput,
|
|
325
333
|
generateEventConfig: () => generateEventConfig,
|
|
326
334
|
generateEventDocument: () => generateEventDocument,
|
|
@@ -339,6 +347,7 @@ __export(events_exports, {
|
|
|
339
347
|
getActionAnnotation: () => getActionAnnotation,
|
|
340
348
|
getActionAnnotationFields: () => getActionAnnotationFields,
|
|
341
349
|
getActionConfig: () => getActionConfig,
|
|
350
|
+
getActionForm: () => getActionForm,
|
|
342
351
|
getActionFormFields: () => getActionFormFields,
|
|
343
352
|
getActionReview: () => getActionReview,
|
|
344
353
|
getActionReviewFields: () => getActionReviewFields,
|
|
@@ -352,35 +361,45 @@ __export(events_exports, {
|
|
|
352
361
|
getCompleteActionAnnotation: () => getCompleteActionAnnotation,
|
|
353
362
|
getCompleteActionContent: () => getCompleteActionContent,
|
|
354
363
|
getCompleteActionDeclaration: () => getCompleteActionDeclaration,
|
|
364
|
+
getConfigVersion: () => getConfigVersion,
|
|
355
365
|
getCurrentEventState: () => getCurrentEventState,
|
|
356
366
|
getCustomActionFields: () => getCustomActionFields,
|
|
357
367
|
getDeclaration: () => getDeclaration,
|
|
358
368
|
getDeclarationAfterEachAction: () => getDeclarationAfterEachAction,
|
|
359
369
|
getDeclarationFieldById: () => getDeclarationFieldById,
|
|
360
370
|
getDeclarationFields: () => getDeclarationFields,
|
|
371
|
+
getDeclarationFieldsOfAllVersions: () => getDeclarationFieldsOfAllVersions,
|
|
361
372
|
getDeclarationPages: () => getDeclarationPages,
|
|
362
373
|
getDeclarationWithPendingAction: () => getDeclarationWithPendingAction,
|
|
363
374
|
getEventConfigById: () => getEventConfigById,
|
|
375
|
+
getEventConfigForRecord: () => getEventConfigForRecord,
|
|
376
|
+
getEventConfigOfVersion: () => getEventConfigOfVersion,
|
|
364
377
|
getEventFlags: () => getEventFlags,
|
|
365
378
|
getEventValidatorContext: () => getEventValidatorContext,
|
|
379
|
+
getEventWithCompleteAcceptedActions: () => getEventWithCompleteAcceptedActions,
|
|
366
380
|
getFilePathsFromEvent: () => getFilePathsFromEvent,
|
|
367
381
|
getLeafAdministrativeAreaIds: () => getLeafAdministrativeAreaIds,
|
|
368
382
|
getLocationHierarchy: () => getLocationHierarchy,
|
|
369
383
|
getMixedPath: () => getMixedPath,
|
|
384
|
+
getNotificationFields: () => getNotificationFields,
|
|
385
|
+
getNotificationForm: () => getNotificationForm,
|
|
370
386
|
getPendingAction: () => getPendingAction,
|
|
371
387
|
getPrintCertificatePages: () => getPrintCertificatePages,
|
|
372
388
|
getRandomDate: () => getRandomDate,
|
|
373
389
|
getStatusFromActions: () => getStatusFromActions,
|
|
374
390
|
getValidatorsForField: () => getValidatorsForField,
|
|
391
|
+
getVersionsInEffect: () => getVersionsInEffect,
|
|
375
392
|
getVisibleVerificationPageIds: () => getVisibleVerificationPageIds,
|
|
376
393
|
hasActiveExternalIdOnOrAfter: () => hasActiveExternalIdOnOrAfter,
|
|
377
394
|
hasAnyOfScopes: () => hasAnyOfScopes,
|
|
378
395
|
isActionAvailable: () => isActionAvailable,
|
|
379
396
|
isActionConfigType: () => isActionConfigType,
|
|
397
|
+
isActionDocument: () => isActionDocument,
|
|
380
398
|
isActionEnabled: () => isActionEnabled,
|
|
381
399
|
isActionInScope: () => isActionInScope,
|
|
382
400
|
isActionVisible: () => isActionVisible,
|
|
383
401
|
isAddressFieldType: () => isAddressFieldType,
|
|
402
|
+
isAddressFieldValue: () => isAddressFieldValue,
|
|
384
403
|
isAdministrativeAreaFieldType: () => isAdministrativeAreaFieldType,
|
|
385
404
|
isAgeFieldType: () => isAgeFieldType,
|
|
386
405
|
isAutocompleteFieldType: () => isAutocompleteFieldType,
|
|
@@ -395,6 +414,7 @@ __export(events_exports, {
|
|
|
395
414
|
isDateFieldType: () => isDateFieldType,
|
|
396
415
|
isDateRangeFieldType: () => isDateRangeFieldType,
|
|
397
416
|
isDividerFieldType: () => isDividerFieldType,
|
|
417
|
+
isDomesticAddressFieldValue: () => isDomesticAddressFieldValue,
|
|
398
418
|
isEmailFieldType: () => isEmailFieldType,
|
|
399
419
|
isEventFieldReference: () => isEventFieldReference,
|
|
400
420
|
isFacilityFieldType: () => isFacilityFieldType,
|
|
@@ -408,7 +428,9 @@ __export(events_exports, {
|
|
|
408
428
|
isFieldValueWithoutTemplates: () => isFieldValueWithoutTemplates,
|
|
409
429
|
isFieldVisible: () => isFieldVisible,
|
|
410
430
|
isFileFieldType: () => isFileFieldType,
|
|
431
|
+
isFileFieldValue: () => isFileFieldValue,
|
|
411
432
|
isFileFieldWithOptionType: () => isFileFieldWithOptionType,
|
|
433
|
+
isFileFieldWithOptionValue: () => isFileFieldWithOptionValue,
|
|
412
434
|
isHeadingFieldType: () => isHeadingFieldType,
|
|
413
435
|
isHiddenFieldType: () => isHiddenFieldType,
|
|
414
436
|
isHttpFieldType: () => isHttpFieldType,
|
|
@@ -429,6 +451,7 @@ __export(events_exports, {
|
|
|
429
451
|
isPageVisible: () => isPageVisible,
|
|
430
452
|
isParagraphFieldType: () => isParagraphFieldType,
|
|
431
453
|
isPhoneFieldType: () => isPhoneFieldType,
|
|
454
|
+
isPlainDate: () => isPlainDate,
|
|
432
455
|
isPotentialDuplicate: () => isPotentialDuplicate,
|
|
433
456
|
isPrintButtonFieldType: () => isPrintButtonFieldType,
|
|
434
457
|
isQrReaderFieldType: () => isQrReaderFieldType,
|
|
@@ -465,6 +488,10 @@ __export(events_exports, {
|
|
|
465
488
|
plainDateToLocalDate: () => plainDateToLocalDate,
|
|
466
489
|
precompileActionSchemas: () => precompileActionSchemas,
|
|
467
490
|
resolveDateOfEvent: () => resolveDateOfEvent,
|
|
491
|
+
resolveEffectiveVersion: () => resolveEffectiveVersion,
|
|
492
|
+
resolveEventConfig: () => resolveEventConfig,
|
|
493
|
+
resolveEventConfigInTimeZone: () => resolveEventConfigInTimeZone,
|
|
494
|
+
resolveEventConfigOnDate: () => resolveEventConfigOnDate,
|
|
468
495
|
resolveEventCustomFlags: () => resolveEventCustomFlags,
|
|
469
496
|
resolvePath: () => resolvePath,
|
|
470
497
|
resolvePlaceOfEvent: () => resolvePlaceOfEvent,
|
|
@@ -477,11 +504,18 @@ __export(events_exports, {
|
|
|
477
504
|
timePeriodToDateRange: () => timePeriodToDateRange,
|
|
478
505
|
toClientAdministrativeArea: () => toClientAdministrativeArea,
|
|
479
506
|
toClientLocation: () => toClientLocation,
|
|
507
|
+
toEventConfig: () => toEventConfig,
|
|
508
|
+
toNotificationForm: () => toNotificationForm,
|
|
509
|
+
toNotificationReview: () => toNotificationReview,
|
|
480
510
|
toPlainDate: () => toPlainDate,
|
|
511
|
+
toPlainDateInTimeZone: () => toPlainDateInTimeZone,
|
|
512
|
+
toVersionedEventConfig: () => toVersionedEventConfig,
|
|
481
513
|
todayISO: () => todayISO,
|
|
482
514
|
user: () => user,
|
|
483
515
|
userCanAccessEventWithScopes: () => userCanAccessEventWithScopes,
|
|
484
516
|
validate: () => validate,
|
|
517
|
+
validateEachVersion: () => validateEachVersion,
|
|
518
|
+
validateEventConfig: () => validateEventConfig,
|
|
485
519
|
validateFieldInput: () => validateFieldInput,
|
|
486
520
|
validateValue: () => validateValue,
|
|
487
521
|
window: () => window2,
|
|
@@ -490,14 +524,17 @@ __export(events_exports, {
|
|
|
490
524
|
});
|
|
491
525
|
module.exports = __toCommonJS(events_exports);
|
|
492
526
|
|
|
527
|
+
// ../commons/src/events/index.ts
|
|
528
|
+
var import_compile = require("zod/compile");
|
|
529
|
+
|
|
493
530
|
// ../commons/src/events/AuditLog.ts
|
|
494
531
|
var z9 = __toESM(require("zod/v4"));
|
|
495
532
|
|
|
496
|
-
// ../commons/src/authentication.ts
|
|
533
|
+
// ../commons/src/users/authentication.ts
|
|
497
534
|
var import_jwt_decode = __toESM(require("jwt-decode"));
|
|
498
535
|
var z8 = __toESM(require("zod/v4"));
|
|
499
536
|
|
|
500
|
-
// ../commons/src/scopes.ts
|
|
537
|
+
// ../commons/src/users/scopes.ts
|
|
501
538
|
var z7 = __toESM(require("zod/v4"));
|
|
502
539
|
var qs = __toESM(require("qs"));
|
|
503
540
|
|
|
@@ -508,6 +545,12 @@ var UUID = z.uuid().brand("UUID");
|
|
|
508
545
|
function getUUID() {
|
|
509
546
|
return (0, import_uuid.v4)();
|
|
510
547
|
}
|
|
548
|
+
function isUUID(id) {
|
|
549
|
+
return UUID.validate(id);
|
|
550
|
+
}
|
|
551
|
+
function maybeUuid(value) {
|
|
552
|
+
return isUUID(value) ? value : void 0;
|
|
553
|
+
}
|
|
511
554
|
|
|
512
555
|
// ../commons/src/events/ActionType.ts
|
|
513
556
|
var z2 = __toESM(require("zod/v4"));
|
|
@@ -583,7 +626,9 @@ var ActionTypes = z2.enum([
|
|
|
583
626
|
"CUSTOM"
|
|
584
627
|
]);
|
|
585
628
|
var ClientSpecificAction = {
|
|
586
|
-
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"
|
|
587
632
|
};
|
|
588
633
|
var declarationActionValues = [
|
|
589
634
|
ActionTypes.enum.DECLARE,
|
|
@@ -639,7 +684,7 @@ var ActionStatus = {
|
|
|
639
684
|
};
|
|
640
685
|
|
|
641
686
|
// ../commons/src/events/Flag.ts
|
|
642
|
-
var z5 = __toESM(require("zod
|
|
687
|
+
var z5 = __toESM(require("zod"));
|
|
643
688
|
|
|
644
689
|
// ../commons/src/events/TranslationConfig.ts
|
|
645
690
|
var z3 = __toESM(require("zod/v4"));
|
|
@@ -708,7 +753,6 @@ var FieldConditional = z4.discriminatedUnion("type", [
|
|
|
708
753
|
|
|
709
754
|
// ../commons/src/events/Flag.ts
|
|
710
755
|
var InherentFlags = {
|
|
711
|
-
INCOMPLETE: "incomplete",
|
|
712
756
|
REJECTED: "rejected",
|
|
713
757
|
CORRECTION_REQUESTED: "correction-requested",
|
|
714
758
|
POTENTIAL_DUPLICATE: "potential-duplicate",
|
|
@@ -736,7 +780,7 @@ var CustomFlag = z5.string().refine((val) => !Object.values(InherentFlags).inclu
|
|
|
736
780
|
message: `Custom flag cannot be one of the inherent flags: ${Object.values(
|
|
737
781
|
InherentFlags
|
|
738
782
|
).join(", ")}`
|
|
739
|
-
}).refine((val) => !ActionFlag.
|
|
783
|
+
}).refine((val) => !ActionFlag.validate(val), {
|
|
740
784
|
message: "Custom flag cannot match the ActionFlag pattern (ActionType:ActionStatus)."
|
|
741
785
|
}).describe("Custom flag identifier defined by the country config.");
|
|
742
786
|
var Flag = ActionFlag.or(z5.enum(InherentFlags)).or(CustomFlag);
|
|
@@ -779,7 +823,7 @@ var EventStatus = z6.enum([
|
|
|
779
823
|
"ARCHIVED"
|
|
780
824
|
]);
|
|
781
825
|
|
|
782
|
-
// ../commons/src/scopes.ts
|
|
826
|
+
// ../commons/src/users/scopes.ts
|
|
783
827
|
var JurisdictionFilter = z7.enum(["administrativeArea", "location", "all"]).describe(
|
|
784
828
|
"Filters based on user jurisdiction relative to their office location in hierarchy."
|
|
785
829
|
);
|
|
@@ -1111,7 +1155,7 @@ function getAcceptedScopesByType({
|
|
|
1111
1155
|
}).filter((scope) => scope !== null);
|
|
1112
1156
|
}
|
|
1113
1157
|
|
|
1114
|
-
// ../commons/src/authentication.ts
|
|
1158
|
+
// ../commons/src/users/authentication.ts
|
|
1115
1159
|
var TokenUserType = z8.enum(["user", "system"]);
|
|
1116
1160
|
var TokenWithBearer = z8.string().regex(/^Bearer\s/);
|
|
1117
1161
|
|
|
@@ -1509,7 +1553,7 @@ var z14 = __toESM(require("zod/v4"));
|
|
|
1509
1553
|
// ../commons/src/documents.ts
|
|
1510
1554
|
var z11 = __toESM(require("zod/v4"));
|
|
1511
1555
|
var FullDocumentUrl = z11.string().brand("FullDocumentUrl").describe(
|
|
1512
|
-
"A full url with protocol, host, bucket name, starting from the root of the S3 server, https://
|
|
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"
|
|
1513
1557
|
);
|
|
1514
1558
|
var FullDocumentPath = z11.string().overwrite((val) => val.startsWith("/") ? val : `/${val}`).meta({ effectType: "input", type: "string" }).describe(
|
|
1515
1559
|
"A full absolute path with bucket name, starting from the root of the S3 server, /bucket-name/document-id.jpg"
|
|
@@ -1519,7 +1563,7 @@ var DocumentPath = z11.string().brand("DocumentPath").describe(
|
|
|
1519
1563
|
);
|
|
1520
1564
|
|
|
1521
1565
|
// ../commons/src/events/CompositeFieldValue.ts
|
|
1522
|
-
var z12 = __toESM(require("zod
|
|
1566
|
+
var z12 = __toESM(require("zod"));
|
|
1523
1567
|
var GeographicalArea = {
|
|
1524
1568
|
URBAN: "URBAN",
|
|
1525
1569
|
RURAL: "RURAL"
|
|
@@ -1533,6 +1577,9 @@ var FileFieldValue = z12.object({
|
|
|
1533
1577
|
originalFilename: z12.string(),
|
|
1534
1578
|
type: z12.string()
|
|
1535
1579
|
});
|
|
1580
|
+
function isFileFieldValue(value) {
|
|
1581
|
+
return FileFieldValue.validate(value);
|
|
1582
|
+
}
|
|
1536
1583
|
var NameFieldValue = z12.object({
|
|
1537
1584
|
firstname: z12.string(),
|
|
1538
1585
|
surname: z12.string(),
|
|
@@ -1557,6 +1604,9 @@ var DomesticAddressFieldValue = BaseAddressFieldValue.extend({
|
|
|
1557
1604
|
addressType: z12.literal(AddressType.DOMESTIC),
|
|
1558
1605
|
administrativeArea: z12.string().uuid()
|
|
1559
1606
|
});
|
|
1607
|
+
function isDomesticAddressFieldValue(value) {
|
|
1608
|
+
return DomesticAddressFieldValue.validate(value);
|
|
1609
|
+
}
|
|
1560
1610
|
var InternationalAddressFieldValue = BaseAddressFieldValue.extend({
|
|
1561
1611
|
addressType: z12.literal(AddressType.INTERNATIONAL)
|
|
1562
1612
|
});
|
|
@@ -1564,6 +1614,9 @@ var AddressFieldValue = z12.discriminatedUnion("addressType", [
|
|
|
1564
1614
|
DomesticAddressFieldValue,
|
|
1565
1615
|
InternationalAddressFieldValue
|
|
1566
1616
|
]);
|
|
1617
|
+
function isAddressFieldValue(value) {
|
|
1618
|
+
return AddressFieldValue.validate(value);
|
|
1619
|
+
}
|
|
1567
1620
|
var DomesticAddressUpdateFieldValue = BaseAddressFieldUpdateValue.extend({
|
|
1568
1621
|
addressType: z12.literal(AddressType.DOMESTIC),
|
|
1569
1622
|
administrativeArea: z12.string().uuid().nullish()
|
|
@@ -1585,6 +1638,9 @@ var FileFieldValueWithOption = z12.object({
|
|
|
1585
1638
|
option: z12.string()
|
|
1586
1639
|
});
|
|
1587
1640
|
var FileFieldWithOptionValue = z12.array(FileFieldValueWithOption);
|
|
1641
|
+
function isFileFieldWithOptionValue(value) {
|
|
1642
|
+
return FileFieldWithOptionValue.validate(value);
|
|
1643
|
+
}
|
|
1588
1644
|
var HttpFieldValue = z12.object({
|
|
1589
1645
|
loading: z12.boolean(),
|
|
1590
1646
|
error: z12.object({ statusCode: z12.number(), message: z12.string() }).nullish(),
|
|
@@ -1620,9 +1676,30 @@ var CustomFieldValue = z12.unknown().brand("CustomFieldValue");
|
|
|
1620
1676
|
// ../commons/src/events/PlainDate.ts
|
|
1621
1677
|
var import_zod = require("zod");
|
|
1622
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);
|
|
1623
1680
|
function toPlainDate(dateTime) {
|
|
1624
1681
|
return dateTime.split("T")[0];
|
|
1625
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
|
+
}
|
|
1626
1703
|
function plainDateToLocalDate(date) {
|
|
1627
1704
|
const [year, month, day] = date.split("-").map(Number);
|
|
1628
1705
|
return new Date(year, month - 1, day);
|
|
@@ -1735,7 +1812,7 @@ function safeUnion(schemas) {
|
|
|
1735
1812
|
);
|
|
1736
1813
|
return z14.any().superRefine((val, ctx) => {
|
|
1737
1814
|
for (const schema of sortedSchemas) {
|
|
1738
|
-
if (schema.
|
|
1815
|
+
if (schema.validate(val)) {
|
|
1739
1816
|
return;
|
|
1740
1817
|
}
|
|
1741
1818
|
}
|
|
@@ -2024,6 +2101,7 @@ var ActionDocument = z16.discriminatedUnion("type", [
|
|
|
2024
2101
|
]).meta({
|
|
2025
2102
|
id: "ActionDocument"
|
|
2026
2103
|
});
|
|
2104
|
+
var isActionDocument = (a) => ActionDocument.validate(a);
|
|
2027
2105
|
var AsyncRejectActionDocument = ActionBase.omit({
|
|
2028
2106
|
declaration: true,
|
|
2029
2107
|
annotation: true
|
|
@@ -2063,6 +2141,9 @@ var LegalStatuses = z17.object({
|
|
|
2063
2141
|
var EventMetadata = z17.object({
|
|
2064
2142
|
id: UUID,
|
|
2065
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
|
+
),
|
|
2066
2147
|
status: EventStatus,
|
|
2067
2148
|
legalStatuses: LegalStatuses.describe(
|
|
2068
2149
|
"Metadata related to the legal registration of the event, such as who registered it and when."
|
|
@@ -3516,6 +3597,12 @@ var ReadActionConfig = ActionConfigBase.extend(
|
|
|
3516
3597
|
var NotifyConfig = ActionConfigBase.extend(
|
|
3517
3598
|
z25.object({
|
|
3518
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
|
+
),
|
|
3519
3606
|
form: actionConfirmationForm
|
|
3520
3607
|
}).shape
|
|
3521
3608
|
);
|
|
@@ -3697,11 +3784,11 @@ var ActionConfig = z25.discriminatedUnion("type", [
|
|
|
3697
3784
|
}),
|
|
3698
3785
|
NotifyConfig.meta({
|
|
3699
3786
|
id: "NotifyActionConfig",
|
|
3700
|
-
description: "Configuration for the notify action
|
|
3787
|
+
description: "Configuration for the notify action: the notification form and its review page. An event without a NOTIFY action cannot be notified."
|
|
3701
3788
|
}),
|
|
3702
3789
|
DeclareConfig.meta({
|
|
3703
3790
|
id: "DeclareActionConfig",
|
|
3704
|
-
description: "Configuration for the declare action. Includes review-page fields.
|
|
3791
|
+
description: "Configuration for the declare action. Includes the declaration form and review-page fields."
|
|
3705
3792
|
}),
|
|
3706
3793
|
DuplicateDetectedConfig.meta({
|
|
3707
3794
|
id: "DuplicateDetectedActionConfig",
|
|
@@ -3965,7 +4052,7 @@ var ReferenceField = BaseField2.extend({
|
|
|
3965
4052
|
var Field = BaseField2.extend({
|
|
3966
4053
|
id: z29.string().describe("Identifier of the summary field."),
|
|
3967
4054
|
value: TranslationConfig.describe(
|
|
3968
|
-
'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.'
|
|
3969
4056
|
),
|
|
3970
4057
|
label: TranslationConfig
|
|
3971
4058
|
}).describe("Custom field defined for the summary view.");
|
|
@@ -4051,9 +4138,6 @@ var BaseField3 = z30.object({
|
|
|
4051
4138
|
),
|
|
4052
4139
|
allowedLocations: JurisdictionReference.optional().describe(
|
|
4053
4140
|
`Override the allowedLocations for a location field in advanced search. Use this when the declaration form's allowedLocations references a scope (e.g. record.create) that search-only users don't have \u2014 specify record.search scope instead.`
|
|
4054
|
-
),
|
|
4055
|
-
useFormDefaultValue: z30.boolean().optional().describe(
|
|
4056
|
-
`Set to false to open the field empty in advanced search instead of pre-filled with the declaration form's defaultValue.`
|
|
4057
4141
|
)
|
|
4058
4142
|
});
|
|
4059
4143
|
var SearchQueryParams = z30.object({
|
|
@@ -4063,7 +4147,10 @@ var SearchQueryParams = z30.object({
|
|
|
4063
4147
|
}).catchall(FieldValue);
|
|
4064
4148
|
var FieldConfigSchema = BaseField3.extend({
|
|
4065
4149
|
fieldId: z30.string(),
|
|
4066
|
-
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
|
+
)
|
|
4067
4154
|
});
|
|
4068
4155
|
var EventFieldIdInput = z30.enum([
|
|
4069
4156
|
"trackingId",
|
|
@@ -4112,6 +4199,41 @@ var AdvancedSearchConfig = z30.object({
|
|
|
4112
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()`)."
|
|
4113
4200
|
});
|
|
4114
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
|
+
|
|
4115
4237
|
// ../commons/src/events/utils.ts
|
|
4116
4238
|
var import_lodash4 = require("lodash");
|
|
4117
4239
|
|
|
@@ -4122,15 +4244,15 @@ var z34 = __toESM(require("zod/v4"));
|
|
|
4122
4244
|
var import_date_fns2 = require("date-fns");
|
|
4123
4245
|
|
|
4124
4246
|
// ../commons/src/events/FieldTypeMapping.ts
|
|
4125
|
-
var
|
|
4247
|
+
var z33 = __toESM(require("zod/v4"));
|
|
4126
4248
|
|
|
4127
4249
|
// ../commons/src/events/DynamicFieldValue.ts
|
|
4128
|
-
var
|
|
4250
|
+
var z32 = __toESM(require("zod/v4"));
|
|
4129
4251
|
function getDynamicNameValue(field3) {
|
|
4130
4252
|
const nameConfiguration = field3.configuration?.name;
|
|
4131
4253
|
const firstnameRequired = nameConfiguration?.firstname?.required ?? field3.required;
|
|
4132
4254
|
const surnameRequired = nameConfiguration?.surname?.required ?? field3.required;
|
|
4133
|
-
return
|
|
4255
|
+
return z32.object({
|
|
4134
4256
|
firstname: firstnameRequired ? NonEmptyTextValue : TextValue,
|
|
4135
4257
|
surname: surnameRequired ? NonEmptyTextValue : TextValue,
|
|
4136
4258
|
middlename: nameConfiguration?.middlename?.required ? NonEmptyTextValue : TextValue.optional()
|
|
@@ -4161,7 +4283,7 @@ function mapFieldTypeToZod(field3, actionType) {
|
|
|
4161
4283
|
let schema;
|
|
4162
4284
|
switch (field3.type) {
|
|
4163
4285
|
case FieldType.FIELD_GROUP: {
|
|
4164
|
-
schema =
|
|
4286
|
+
schema = z33.object(
|
|
4165
4287
|
field3.fields.reduce((acc, subfield) => {
|
|
4166
4288
|
acc[subfield.id] = mapFieldTypeToZod(subfield, actionType);
|
|
4167
4289
|
return acc;
|
|
@@ -4485,41 +4607,6 @@ var isNonInteractiveFieldType = (field3) => {
|
|
|
4485
4607
|
// ../commons/src/events/state/index.ts
|
|
4486
4608
|
var import_lodash3 = require("lodash");
|
|
4487
4609
|
|
|
4488
|
-
// ../commons/src/utils.ts
|
|
4489
|
-
var z33 = __toESM(require("zod/v4"));
|
|
4490
|
-
var _ = __toESM(require("lodash"));
|
|
4491
|
-
function getOrThrow(x, message) {
|
|
4492
|
-
if (x === void 0 || x === null) {
|
|
4493
|
-
throw new Error(message);
|
|
4494
|
-
}
|
|
4495
|
-
return x;
|
|
4496
|
-
}
|
|
4497
|
-
function joinValues(values, separator = " ") {
|
|
4498
|
-
return values.filter((value) => !!value).join(separator).trim();
|
|
4499
|
-
}
|
|
4500
|
-
var FullNameV1 = z33.array(
|
|
4501
|
-
z33.object({
|
|
4502
|
-
use: z33.string(),
|
|
4503
|
-
family: z33.string(),
|
|
4504
|
-
given: z33.array(z33.string())
|
|
4505
|
-
})
|
|
4506
|
-
);
|
|
4507
|
-
function omitKeyDeep(obj, keyToRemove) {
|
|
4508
|
-
if (Array.isArray(obj)) {
|
|
4509
|
-
return obj.map((item) => omitKeyDeep(item, keyToRemove));
|
|
4510
|
-
}
|
|
4511
|
-
if (obj === null || typeof obj !== "object") {
|
|
4512
|
-
return obj;
|
|
4513
|
-
}
|
|
4514
|
-
const newObj = {};
|
|
4515
|
-
for (const key of Object.keys(obj)) {
|
|
4516
|
-
if (key !== keyToRemove) {
|
|
4517
|
-
newObj[key] = omitKeyDeep(obj[key], keyToRemove);
|
|
4518
|
-
}
|
|
4519
|
-
}
|
|
4520
|
-
return newObj;
|
|
4521
|
-
}
|
|
4522
|
-
|
|
4523
4610
|
// ../commons/src/events/state/utils.ts
|
|
4524
4611
|
var import_lodash = require("lodash");
|
|
4525
4612
|
function getActionRequests(actionType, actions) {
|
|
@@ -4696,15 +4783,6 @@ var INHERENT_FLAG_RULES = [
|
|
|
4696
4783
|
setOn: [ActionType.REQUEST_CORRECTION],
|
|
4697
4784
|
resetOn: [ActionType.APPROVE_CORRECTION, ActionType.REJECT_CORRECTION]
|
|
4698
4785
|
},
|
|
4699
|
-
{
|
|
4700
|
-
// INCOMPLETE mirrors the NOTIFIED status: set by NOTIFY, cleared by any
|
|
4701
|
-
// other status-changing action (see getStatusFromActions). ARCHIVE/UNARCHIVE
|
|
4702
|
-
// are deliberately excluded so the flag freezes across an archive/unarchive
|
|
4703
|
-
// round trip and comes back exactly as it was.
|
|
4704
|
-
flag: InherentFlags.INCOMPLETE,
|
|
4705
|
-
setOn: [ActionType.NOTIFY],
|
|
4706
|
-
resetOn: [ActionType.CREATE, ActionType.DECLARE, ActionType.REGISTER]
|
|
4707
|
-
},
|
|
4708
4786
|
{
|
|
4709
4787
|
flag: InherentFlags.REJECTED,
|
|
4710
4788
|
setOn: [ActionType.REJECT],
|
|
@@ -5552,35 +5630,24 @@ function resolveDateOfEvent(eventIndex, declaration, config) {
|
|
|
5552
5630
|
if (!config.dateOfEvent) {
|
|
5553
5631
|
return extractDateString(eventIndex[DEFAULT_DATE_OF_EVENT_PROPERTY]);
|
|
5554
5632
|
}
|
|
5555
|
-
|
|
5556
|
-
|
|
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
|
|
5557
5640
|
);
|
|
5558
|
-
return
|
|
5641
|
+
return ZodDateTime.validate(eventDate) ? extractDateString(eventDate) : void 0;
|
|
5559
5642
|
}
|
|
5560
5643
|
var DEFAULT_PLACE_OF_EVENT_PROPERTY = "createdAtLocation";
|
|
5561
|
-
function getParsedUUID(value, oldValue) {
|
|
5562
|
-
const parsed = UUID.safeParse(value);
|
|
5563
|
-
return parsed.success ? parsed.data : oldValue;
|
|
5564
|
-
}
|
|
5565
5644
|
function resolvePlaceOfEvent(eventMetadata, declaration, config) {
|
|
5566
|
-
let placeOfEvent =
|
|
5645
|
+
let placeOfEvent = maybeUuid(
|
|
5567
5646
|
eventMetadata[DEFAULT_PLACE_OF_EVENT_PROPERTY]
|
|
5568
5647
|
);
|
|
5569
5648
|
if (config.placeOfEvent) {
|
|
5570
|
-
const addressFieldValue =
|
|
5571
|
-
|
|
5572
|
-
);
|
|
5573
|
-
if (addressFieldValue.success && addressFieldValue.data.addressType === AddressType.DOMESTIC && addressFieldValue.data.administrativeArea) {
|
|
5574
|
-
placeOfEvent = getParsedUUID(
|
|
5575
|
-
addressFieldValue.data.administrativeArea,
|
|
5576
|
-
placeOfEvent
|
|
5577
|
-
);
|
|
5578
|
-
} else {
|
|
5579
|
-
placeOfEvent = getParsedUUID(
|
|
5580
|
-
declaration[config.placeOfEvent.$$field],
|
|
5581
|
-
placeOfEvent
|
|
5582
|
-
);
|
|
5583
|
-
}
|
|
5649
|
+
const addressFieldValue = declaration[config.placeOfEvent.$$field];
|
|
5650
|
+
placeOfEvent = isDomesticAddressFieldValue(addressFieldValue) ? maybeUuid(addressFieldValue.administrativeArea) ?? placeOfEvent : maybeUuid(declaration[config.placeOfEvent.$$field]) ?? placeOfEvent;
|
|
5584
5651
|
}
|
|
5585
5652
|
return placeOfEvent;
|
|
5586
5653
|
}
|
|
@@ -5626,6 +5693,7 @@ function getCurrentEventState(event2, config) {
|
|
|
5626
5693
|
updatedAtLocation: requestActionMetadata.createdAtLocation,
|
|
5627
5694
|
declaration,
|
|
5628
5695
|
trackingId: event2.trackingId,
|
|
5696
|
+
configVersionId: event2.configVersionId,
|
|
5629
5697
|
updatedByUserRole: requestActionMetadata.createdByRole,
|
|
5630
5698
|
placeOfEvent: resolvePlaceOfEvent(
|
|
5631
5699
|
{ createdAtLocation: creationAction.createdAtLocation },
|
|
@@ -5784,7 +5852,9 @@ function buildClientFunctionContext(input) {
|
|
|
5784
5852
|
// eslint-disable-next-line @typescript-eslint/no-use-before-define
|
|
5785
5853
|
$online: isOnline(),
|
|
5786
5854
|
$user: input.validatorContext?.user,
|
|
5787
|
-
$event: input.validatorContext?.event?.document
|
|
5855
|
+
$event: input.validatorContext?.event?.document ? getEventWithCompleteAcceptedActions(
|
|
5856
|
+
input.validatorContext.event.document
|
|
5857
|
+
) : void 0,
|
|
5788
5858
|
$leafAdminStructureLocationIds: input.validatorContext?.leafAdminStructureLocationIds ?? [],
|
|
5789
5859
|
user: input.systemVariables?.user,
|
|
5790
5860
|
$window: input.systemVariables?.$window,
|
|
@@ -5865,7 +5935,7 @@ function precompileActionSchemas(eventConfigurations) {
|
|
|
5865
5935
|
}
|
|
5866
5936
|
}
|
|
5867
5937
|
function isAgeValue(value) {
|
|
5868
|
-
return
|
|
5938
|
+
return AgeValue.validate(value);
|
|
5869
5939
|
}
|
|
5870
5940
|
function mergeWithBaseFormState(values, context) {
|
|
5871
5941
|
return { ...context.baseFormState, ...values };
|
|
@@ -5895,15 +5965,13 @@ function validate(schema, data) {
|
|
|
5895
5965
|
return [key, value];
|
|
5896
5966
|
}
|
|
5897
5967
|
const age = value.age;
|
|
5898
|
-
const
|
|
5968
|
+
const asOf = data.$form[value.asOfDateRef];
|
|
5969
|
+
const asOfDate = isPlainDate(asOf) ? asOf : PlainDate.parse(data.$now);
|
|
5899
5970
|
return [
|
|
5900
5971
|
key,
|
|
5901
5972
|
{
|
|
5902
5973
|
age,
|
|
5903
|
-
dob: ageToDate(
|
|
5904
|
-
age,
|
|
5905
|
-
maybeAsOfDate.success ? maybeAsOfDate.data : PlainDate.parse(data.$now)
|
|
5906
|
-
)
|
|
5974
|
+
dob: ageToDate(age, asOfDate)
|
|
5907
5975
|
}
|
|
5908
5976
|
];
|
|
5909
5977
|
});
|
|
@@ -6066,6 +6134,11 @@ var errorMessages = {
|
|
|
6066
6134
|
description: "Error message when field is not expected",
|
|
6067
6135
|
id: "error.unexpectedField"
|
|
6068
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
|
+
},
|
|
6069
6142
|
correctionNotAllowed: {
|
|
6070
6143
|
defaultMessage: "Correction not allowed for field",
|
|
6071
6144
|
description: "Error message when correction is not allowed for field",
|
|
@@ -6302,6 +6375,40 @@ function getDeclarationPages(configuration) {
|
|
|
6302
6375
|
function getDeclarationFields(configuration) {
|
|
6303
6376
|
return getDeclarationPages(configuration).flatMap(({ fields }) => fields);
|
|
6304
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
|
+
}
|
|
6305
6412
|
function isActionConfigType(type) {
|
|
6306
6413
|
return actionConfigTypes.has(type);
|
|
6307
6414
|
}
|
|
@@ -6310,9 +6417,6 @@ function getActionConfig({
|
|
|
6310
6417
|
actionType,
|
|
6311
6418
|
customActionType
|
|
6312
6419
|
}) {
|
|
6313
|
-
if (actionType === ActionType.NOTIFY) {
|
|
6314
|
-
return eventConfiguration.actions.find((a) => a.type === ActionType.NOTIFY) ?? eventConfiguration.actions.find((a) => a.type === ActionType.DECLARE);
|
|
6315
|
-
}
|
|
6316
6420
|
return eventConfiguration.actions.find((a) => {
|
|
6317
6421
|
if (a.type === ActionType.CUSTOM && customActionType) {
|
|
6318
6422
|
return a.customActionType === customActionType;
|
|
@@ -6560,11 +6664,12 @@ function flattenFieldReference(ref) {
|
|
|
6560
6664
|
return [ref.$$field, ...ref.$$subfield];
|
|
6561
6665
|
}
|
|
6562
6666
|
function isWriteAction(actionType) {
|
|
6563
|
-
return writeActions.
|
|
6667
|
+
return writeActions.validate(actionType);
|
|
6564
6668
|
}
|
|
6565
6669
|
var findAllFields = (config) => {
|
|
6566
6670
|
return (0, import_lodash4.flattenDeep)([
|
|
6567
6671
|
...getDeclarationFields(config),
|
|
6672
|
+
...findNotificationForm(config)?.pages.flatMap(({ fields }) => fields) ?? [],
|
|
6568
6673
|
...getAllAnnotationFields(config)
|
|
6569
6674
|
]);
|
|
6570
6675
|
};
|
|
@@ -6587,10 +6692,10 @@ function getMixedPath(obj, path, defaultValue) {
|
|
|
6587
6692
|
return (0, import_lodash4.isNil)(result) ? defaultValue : result;
|
|
6588
6693
|
}
|
|
6589
6694
|
function getEventConfigById(eventConfigs, id) {
|
|
6590
|
-
|
|
6591
|
-
(eventConfiguration) => eventConfiguration.id === id
|
|
6695
|
+
return getOrThrow(
|
|
6696
|
+
eventConfigs.find((eventConfiguration) => eventConfiguration.id === id),
|
|
6697
|
+
`No configuration found for event type: ${id}`
|
|
6592
6698
|
);
|
|
6593
|
-
return getOrThrow(eventConfig, `Event config for ${id} not found`);
|
|
6594
6699
|
}
|
|
6595
6700
|
function timePeriodToDateRange(value) {
|
|
6596
6701
|
let startDate;
|
|
@@ -6700,12 +6805,41 @@ function getCompleteActionDeclaration(declaration, event2, action) {
|
|
|
6700
6805
|
}
|
|
6701
6806
|
return deepMerge(declaration, action.declaration);
|
|
6702
6807
|
}
|
|
6703
|
-
function
|
|
6704
|
-
return
|
|
6808
|
+
function completeAcceptedAction(event2, action) {
|
|
6809
|
+
return {
|
|
6705
6810
|
...action,
|
|
6706
6811
|
declaration: getCompleteActionDeclaration({}, event2, action),
|
|
6707
6812
|
annotation: getCompleteActionAnnotation(event2, action)
|
|
6708
|
-
}
|
|
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
|
+
};
|
|
6709
6843
|
}
|
|
6710
6844
|
var EXCLUDED_ACTIONS = [
|
|
6711
6845
|
ActionType.REQUEST_CORRECTION,
|
|
@@ -6804,6 +6938,20 @@ function dropSecuredDeclarationFields(eventConfig, eventIndex, validatorContext)
|
|
|
6804
6938
|
}
|
|
6805
6939
|
|
|
6806
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
|
+
];
|
|
6807
6955
|
function validateAdvancedSearchConfig(event2, ctx) {
|
|
6808
6956
|
const allFields = findAllFields(event2);
|
|
6809
6957
|
const fieldIds = allFields.map((field3) => field3.id);
|
|
@@ -6835,6 +6983,56 @@ function validateAdvancedSearchConfig(event2, ctx) {
|
|
|
6835
6983
|
path: ["advancedSearch"]
|
|
6836
6984
|
});
|
|
6837
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
|
+
});
|
|
6838
7036
|
}
|
|
6839
7037
|
function validateDateOfEvent(event2, ctx) {
|
|
6840
7038
|
if (event2.dateOfEvent && isFieldReference(event2.dateOfEvent)) {
|
|
@@ -6958,15 +7156,65 @@ function validateDeclarationGivenExactlyOnce(config, ctx) {
|
|
|
6958
7156
|
});
|
|
6959
7157
|
}
|
|
6960
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
|
+
}
|
|
6961
7203
|
|
|
6962
7204
|
// ../commons/src/events/EventConfig.ts
|
|
6963
7205
|
var EventFieldReference = z35.object({ $$event: EventMetadataDateFieldIdInput }).describe(
|
|
6964
7206
|
"Reference to a field defined in the event metadata, using the field id."
|
|
6965
7207
|
);
|
|
6966
|
-
var
|
|
7208
|
+
var eventLevelFields = {
|
|
6967
7209
|
id: z35.string().describe(
|
|
6968
7210
|
'Machine-readable identifier of the event (e.g. "birth", "death").'
|
|
6969
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 = {
|
|
6970
7218
|
dateOfEvent: FieldReference.or(EventFieldReference).optional().describe(
|
|
6971
7219
|
"Reference to the field capturing the date of the event (e.g. date of birth). Defaults to the event creation date if unspecified."
|
|
6972
7220
|
),
|
|
@@ -6982,18 +7230,12 @@ var _EventConfigBase = z35.object({
|
|
|
6982
7230
|
summary: SummaryConfig.describe(
|
|
6983
7231
|
"Summary information displayed in the event overview."
|
|
6984
7232
|
),
|
|
6985
|
-
label: TranslationConfig.describe(
|
|
6986
|
-
"Human-readable label for the event type."
|
|
6987
|
-
),
|
|
6988
7233
|
actions: z35.array(ActionConfig).describe(
|
|
6989
7234
|
"Configuration of core and custom actions associated with the event."
|
|
6990
7235
|
),
|
|
6991
7236
|
actionOrder: z35.array(z35.string()).optional().describe(
|
|
6992
7237
|
"Order of actions in the action menu. Use either the action type for core actions or the customActionType for custom actions."
|
|
6993
7238
|
),
|
|
6994
|
-
advancedSearch: z35.array(AdvancedSearchConfig).optional().default([]).describe(
|
|
6995
|
-
"Configuration of fields available in the advanced search feature."
|
|
6996
|
-
),
|
|
6997
7239
|
flags: z35.array(FlagConfig).optional().default([]).describe(
|
|
6998
7240
|
"Configuration of custom flags associated with the actions of this event type."
|
|
6999
7241
|
),
|
|
@@ -7003,20 +7245,180 @@ var _EventConfigBase = z35.object({
|
|
|
7003
7245
|
icon: z35.partialRecord(AvailableIcons, Conditional).optional().describe(
|
|
7004
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.'
|
|
7005
7247
|
)
|
|
7006
|
-
}
|
|
7007
|
-
var
|
|
7248
|
+
};
|
|
7249
|
+
var _EventConfigBase = z35.object({ ...eventLevelFields, ...versionFields });
|
|
7250
|
+
function validateEventConfig(event2, ctx) {
|
|
7008
7251
|
if (!validateExactlyOneDeclareAction(event2, ctx)) {
|
|
7009
7252
|
return;
|
|
7010
7253
|
}
|
|
7254
|
+
validateNotificationForm(event2, ctx);
|
|
7011
7255
|
validateAdvancedSearchConfig(event2, ctx);
|
|
7012
7256
|
validateDateOfEvent(event2, ctx);
|
|
7013
7257
|
validatePlaceOfEvent(event2, ctx);
|
|
7014
7258
|
validateActionFlags(event2, ctx);
|
|
7015
7259
|
validateActionOrder(event2, ctx);
|
|
7016
|
-
}
|
|
7260
|
+
}
|
|
7261
|
+
var EventConfig2 = _EventConfigBase.superRefine(validateEventConfig).meta({
|
|
7017
7262
|
id: "EventConfig",
|
|
7018
7263
|
description: "Configuration defining an event type registered in OpenCRVS (for example birth or death)."
|
|
7019
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
|
+
});
|
|
7020
7422
|
|
|
7021
7423
|
// ../commons/src/events/EventConfigInput.ts
|
|
7022
7424
|
var defineDeclarationForm = (form) => DeclarationFormConfig.parse(form);
|
|
@@ -7089,7 +7491,7 @@ function createSearchConfig(baseField) {
|
|
|
7089
7491
|
|
|
7090
7492
|
// ../commons/src/event-config/event-configuration.ts
|
|
7091
7493
|
function isNonSearchableEventMetadataTimeFieldId(fieldId) {
|
|
7092
|
-
return !EventFieldIdInput.
|
|
7494
|
+
return !EventFieldIdInput.validate(fieldId);
|
|
7093
7495
|
}
|
|
7094
7496
|
function createEventFieldConfig(fieldId) {
|
|
7095
7497
|
const baseField = {
|
|
@@ -7116,7 +7518,10 @@ function eventFn(fieldId) {
|
|
|
7116
7518
|
}
|
|
7117
7519
|
var event = Object.assign(eventFn, {
|
|
7118
7520
|
/**
|
|
7119
|
-
* 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.
|
|
7120
7525
|
* Can be used directly as a conditional or chained with additional methods.
|
|
7121
7526
|
* @param action - The action type to check for.
|
|
7122
7527
|
*/
|
|
@@ -7134,9 +7539,12 @@ var event = Object.assign(eventFn, {
|
|
|
7134
7539
|
properties: {
|
|
7135
7540
|
type: {
|
|
7136
7541
|
const: action
|
|
7542
|
+
},
|
|
7543
|
+
status: {
|
|
7544
|
+
const: ActionStatus.Accepted
|
|
7137
7545
|
}
|
|
7138
7546
|
},
|
|
7139
|
-
required: ["type"]
|
|
7547
|
+
required: ["type", "status"]
|
|
7140
7548
|
}
|
|
7141
7549
|
}
|
|
7142
7550
|
},
|
|
@@ -7147,9 +7555,10 @@ var event = Object.assign(eventFn, {
|
|
|
7147
7555
|
});
|
|
7148
7556
|
const buildActionConstraints = (additionalFields) => {
|
|
7149
7557
|
const actionProperties = {
|
|
7150
|
-
type: { const: action }
|
|
7558
|
+
type: { const: action },
|
|
7559
|
+
status: { const: ActionStatus.Accepted }
|
|
7151
7560
|
};
|
|
7152
|
-
const requiredFields = ["type"];
|
|
7561
|
+
const requiredFields = ["type", "status"];
|
|
7153
7562
|
if (additionalFields) {
|
|
7154
7563
|
Object.entries(additionalFields).forEach(([key, value]) => {
|
|
7155
7564
|
actionProperties[key] = { const: value };
|
|
@@ -7441,6 +7850,12 @@ var RegisterActionInput = BaseActionInput.extend(
|
|
|
7441
7850
|
var NotifyActionInput = BaseActionInput.extend(
|
|
7442
7851
|
z39.object({
|
|
7443
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
|
+
),
|
|
7444
7859
|
// For normal users, the createdAtLocation is resolved on the backend from the user's primaryOfficeId.
|
|
7445
7860
|
createdAtLocation: UUID.nullish().describe(
|
|
7446
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."
|
|
@@ -7624,17 +8039,19 @@ var DraftInput = BaseActionInput.omit({ waitFor: true }).extend({
|
|
|
7624
8039
|
/*
|
|
7625
8040
|
* A draft can name a file that no action references. Such a file stays until
|
|
7626
8041
|
* the record is deleted or the record's next action sweeps its prefix.
|
|
7627
|
-
*
|
|
7628
|
-
*
|
|
7629
|
-
* 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.
|
|
7630
8044
|
*/
|
|
7631
|
-
type: z40.
|
|
8045
|
+
type: z40.enum([ActionTypes.enum.DECLARE, ActionTypes.enum.NOTIFY]),
|
|
7632
8046
|
status: z40.enum([
|
|
7633
8047
|
ActionStatus.Requested,
|
|
7634
8048
|
ActionStatus.Accepted,
|
|
7635
8049
|
ActionStatus.Rejected
|
|
7636
8050
|
])
|
|
7637
8051
|
});
|
|
8052
|
+
var RemoteDraft = Draft.extend({
|
|
8053
|
+
action: Draft.shape.action.extend({ type: DraftInput.shape.type })
|
|
8054
|
+
});
|
|
7638
8055
|
|
|
7639
8056
|
// ../commons/src/events/EventInput.ts
|
|
7640
8057
|
var z41 = __toESM(require("zod/v4"));
|
|
@@ -7644,6 +8061,9 @@ var EventInput = z41.object({
|
|
|
7644
8061
|
type: z41.string(),
|
|
7645
8062
|
createdAtLocation: UUID.nullish().describe(
|
|
7646
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."
|
|
7647
8067
|
)
|
|
7648
8068
|
}).meta({ default: { transactionId: (0, import_uuid11.v4)(), type: "birth" } });
|
|
7649
8069
|
|
|
@@ -7659,6 +8079,9 @@ var EventDocument = z42.object({
|
|
|
7659
8079
|
actions: z42.array(Action).describe("Ordered list of actions associated with the event."),
|
|
7660
8080
|
trackingId: z42.string().describe(
|
|
7661
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'."
|
|
7662
8085
|
)
|
|
7663
8086
|
}).meta({ id: "EventDocument" });
|
|
7664
8087
|
var EventDocumentOnlyLastAction = EventDocument.extend({
|
|
@@ -7678,18 +8101,103 @@ function moveDeclarationToDeclareAction({
|
|
|
7678
8101
|
}
|
|
7679
8102
|
return {
|
|
7680
8103
|
...config,
|
|
7681
|
-
actions: config.actions.map(
|
|
7682
|
-
(action
|
|
7683
|
-
|
|
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
|
+
})
|
|
7684
8114
|
};
|
|
7685
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
|
+
}
|
|
7686
8157
|
var EventConfigDefinition = z43.custom().superRefine((config, ctx) => {
|
|
7687
|
-
if (
|
|
7688
|
-
|
|
8158
|
+
if ("versions" in config) {
|
|
8159
|
+
validateNoVersionFieldsAtTopLevel(config, ctx);
|
|
8160
|
+
return;
|
|
8161
|
+
}
|
|
8162
|
+
const eventCtx = { ...ctx, value: config };
|
|
8163
|
+
if (validateExactlyOneDeclareAction(config, eventCtx)) {
|
|
8164
|
+
validateDeclarationGivenExactlyOnce(config, eventCtx);
|
|
7689
8165
|
}
|
|
7690
|
-
}).transform(
|
|
8166
|
+
}).transform(toVersionedInput).pipe(VersionedEventConfig2).superRefine(validateVersionInEffectToday);
|
|
7691
8167
|
var defineConfig = (config) => EventConfigDefinition.parse(config);
|
|
7692
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
|
+
|
|
7693
8201
|
// ../commons/src/events/transactions.ts
|
|
7694
8202
|
function generateTransactionId() {
|
|
7695
8203
|
return getUUID();
|
|
@@ -8946,7 +9454,7 @@ var TENNIS_CLUB_DECLARATION_FORM = defineDeclarationForm({
|
|
|
8946
9454
|
});
|
|
8947
9455
|
|
|
8948
9456
|
// ../commons/src/fixtures/tennis-club-membership-event.ts
|
|
8949
|
-
var
|
|
9457
|
+
var versionedTennisClubMembershipEvent = defineConfig({
|
|
8950
9458
|
id: TENNIS_CLUB_MEMBERSHIP,
|
|
8951
9459
|
declaration: TENNIS_CLUB_DECLARATION_FORM,
|
|
8952
9460
|
label: {
|
|
@@ -9005,6 +9513,8 @@ var tennisClubMembershipEvent = defineConfig({
|
|
|
9005
9513
|
description: "This is shown as the action name anywhere the user can trigger the action from",
|
|
9006
9514
|
id: "event.tennis-club-membership.action.notify.label"
|
|
9007
9515
|
},
|
|
9516
|
+
notificationForm: toNotificationForm(TENNIS_CLUB_DECLARATION_FORM),
|
|
9517
|
+
review: toNotificationReview(TENNIS_CLUB_DECLARATION_REVIEW),
|
|
9008
9518
|
flags: [
|
|
9009
9519
|
{
|
|
9010
9520
|
id: "health-worker-notified",
|
|
@@ -9301,9 +9811,12 @@ var tennisClubMembershipEvent = defineConfig({
|
|
|
9301
9811
|
}
|
|
9302
9812
|
]
|
|
9303
9813
|
});
|
|
9814
|
+
var tennisClubMembershipEvent = resolveEventConfig(
|
|
9815
|
+
versionedTennisClubMembershipEvent
|
|
9816
|
+
);
|
|
9304
9817
|
|
|
9305
9818
|
// ../commons/src/fixtures/football-club-membership-event.ts
|
|
9306
|
-
var
|
|
9819
|
+
var versionedFootballClubMembershipEvent = defineConfig({
|
|
9307
9820
|
id: "FOOTBALL_CLUB_MEMBERSHIP",
|
|
9308
9821
|
label: {
|
|
9309
9822
|
defaultMessage: "Football club membership application",
|
|
@@ -9626,6 +10139,9 @@ var footballClubMembershipEvent = defineConfig({
|
|
|
9626
10139
|
],
|
|
9627
10140
|
declaration: TENNIS_CLUB_DECLARATION_FORM
|
|
9628
10141
|
});
|
|
10142
|
+
var footballClubMembershipEvent = resolveEventConfig(
|
|
10143
|
+
versionedFootballClubMembershipEvent
|
|
10144
|
+
);
|
|
9629
10145
|
|
|
9630
10146
|
// ../commons/src/fixtures/library-membership-event.ts
|
|
9631
10147
|
var libraryMembershipForm = defineDeclarationForm({
|
|
@@ -9669,7 +10185,7 @@ var libraryMembershipForm = defineDeclarationForm({
|
|
|
9669
10185
|
}
|
|
9670
10186
|
]
|
|
9671
10187
|
});
|
|
9672
|
-
var
|
|
10188
|
+
var versionedLibraryMembershipEvent = defineConfig({
|
|
9673
10189
|
id: "library-membership",
|
|
9674
10190
|
label: {
|
|
9675
10191
|
defaultMessage: "Library membership application",
|
|
@@ -9702,6 +10218,9 @@ var libraryMembershipEvent = defineConfig({
|
|
|
9702
10218
|
],
|
|
9703
10219
|
declaration: libraryMembershipForm
|
|
9704
10220
|
});
|
|
10221
|
+
var libraryMembershipEvent = resolveEventConfig(
|
|
10222
|
+
versionedLibraryMembershipEvent
|
|
10223
|
+
);
|
|
9705
10224
|
|
|
9706
10225
|
// ../commons/src/fixtures/child-onboarding-event.ts
|
|
9707
10226
|
function generateTranslationConfig(message) {
|
|
@@ -9915,7 +10434,7 @@ var CHILD_ONBOARDING_DECLARATION_FORM = defineDeclarationForm({
|
|
|
9915
10434
|
label: generateTranslationConfig("Birth decalration form"),
|
|
9916
10435
|
pages: [child, mother]
|
|
9917
10436
|
});
|
|
9918
|
-
var
|
|
10437
|
+
var versionedChildOnboardingEvent = defineConfig({
|
|
9919
10438
|
id: CHILD_ONBOARDING_EVENT,
|
|
9920
10439
|
title: generateTranslationConfig(
|
|
9921
10440
|
"{child.name.firstname} {child.name.surname}"
|
|
@@ -9943,6 +10462,9 @@ var ChildOnboardingEvent = defineConfig({
|
|
|
9943
10462
|
],
|
|
9944
10463
|
advancedSearch: []
|
|
9945
10464
|
});
|
|
10465
|
+
var ChildOnboardingEvent = resolveEventConfig(
|
|
10466
|
+
versionedChildOnboardingEvent
|
|
10467
|
+
);
|
|
9946
10468
|
|
|
9947
10469
|
// ../commons/src/fixtures/digital-identity-issuance-event.ts
|
|
9948
10470
|
var PRINT_DIGITAL_ID_CERTIFICATE_FORM = defineActionForm({
|
|
@@ -10131,7 +10653,7 @@ var digitalIdentityForm = defineDeclarationForm({
|
|
|
10131
10653
|
}
|
|
10132
10654
|
]
|
|
10133
10655
|
});
|
|
10134
|
-
var
|
|
10656
|
+
var versionedDigitalIdentityEvent = defineConfig({
|
|
10135
10657
|
id: "digital-identity",
|
|
10136
10658
|
label: {
|
|
10137
10659
|
defaultMessage: "Digital identity issuance",
|
|
@@ -10173,6 +10695,9 @@ var digitalIdentityEvent = defineConfig({
|
|
|
10173
10695
|
],
|
|
10174
10696
|
declaration: digitalIdentityForm
|
|
10175
10697
|
});
|
|
10698
|
+
var digitalIdentityEvent = resolveEventConfig(
|
|
10699
|
+
versionedDigitalIdentityEvent
|
|
10700
|
+
);
|
|
10176
10701
|
|
|
10177
10702
|
// ../commons/src/events/test.utils.ts
|
|
10178
10703
|
var z45 = __toESM(require("zod/v4"));
|
|
@@ -10472,8 +10997,8 @@ function userCanAccessEventWithScopes(event2, scopes, user2, customActionType) {
|
|
|
10472
10997
|
}
|
|
10473
10998
|
function getAdministrativeAreaHierarchy(administrativeAreaId, administrativeAreas) {
|
|
10474
10999
|
const collectedLocations = [];
|
|
10475
|
-
const
|
|
10476
|
-
let current =
|
|
11000
|
+
const maybeAdministrativeAreaId = maybeUuid(administrativeAreaId);
|
|
11001
|
+
let current = maybeAdministrativeAreaId ? administrativeAreas.get(maybeAdministrativeAreaId) : null;
|
|
10477
11002
|
while (current) {
|
|
10478
11003
|
collectedLocations.push(current);
|
|
10479
11004
|
if (!current.parentId) {
|
|
@@ -11073,11 +11598,10 @@ function fieldConfigsToActionPayload(fields, rng, administrativeHierarchy) {
|
|
|
11073
11598
|
);
|
|
11074
11599
|
}
|
|
11075
11600
|
function generateActionDeclarationInput(configuration, action, rng, overrides, administrativeHierarchy) {
|
|
11076
|
-
const parsed = DeclarationUpdateActions.safeParse(action);
|
|
11077
11601
|
if ((0, import_lodash5.isEmpty)(overrides) && typeof overrides === "object") {
|
|
11078
11602
|
return {};
|
|
11079
11603
|
}
|
|
11080
|
-
if (
|
|
11604
|
+
if (DeclarationUpdateActions.validate(action)) {
|
|
11081
11605
|
const fields = getDeclarationFields(configuration);
|
|
11082
11606
|
const declarationConfig = getDeclaration(configuration);
|
|
11083
11607
|
const declaration = fieldConfigsToActionPayload(
|
|
@@ -11202,7 +11726,8 @@ function eventPayloadGenerator(rng, configuration = tennisClubMembershipEvent) {
|
|
|
11202
11726
|
...input
|
|
11203
11727
|
}),
|
|
11204
11728
|
/**
|
|
11205
|
-
*
|
|
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.
|
|
11206
11731
|
*/
|
|
11207
11732
|
notify: (eventId, input = {}) => {
|
|
11208
11733
|
let declaration = input.declaration;
|
|
@@ -11457,9 +11982,9 @@ function generateActionDocument({
|
|
|
11457
11982
|
return { ...actionBase, type: action };
|
|
11458
11983
|
case ActionType.EDIT:
|
|
11459
11984
|
return {
|
|
11985
|
+
content: { comment: "Test comment" },
|
|
11460
11986
|
...actionBase,
|
|
11461
|
-
type: action
|
|
11462
|
-
content: { comment: "Test comment" }
|
|
11987
|
+
type: action
|
|
11463
11988
|
};
|
|
11464
11989
|
case ActionType.CUSTOM:
|
|
11465
11990
|
return {
|
|
@@ -11478,9 +12003,9 @@ function generateActionDocument({
|
|
|
11478
12003
|
};
|
|
11479
12004
|
}
|
|
11480
12005
|
case ActionType.ARCHIVE:
|
|
11481
|
-
return {
|
|
12006
|
+
return { content: { reason: "Archive" }, ...actionBase, type: action };
|
|
11482
12007
|
case ActionType.REJECT:
|
|
11483
|
-
return {
|
|
12008
|
+
return { content: { reason: "Reject" }, ...actionBase, type: action };
|
|
11484
12009
|
case ActionType.PRINT_CERTIFICATE: {
|
|
11485
12010
|
const printActionDefaults = defaults;
|
|
11486
12011
|
return {
|
|
@@ -11490,13 +12015,13 @@ function generateActionDocument({
|
|
|
11490
12015
|
};
|
|
11491
12016
|
}
|
|
11492
12017
|
case ActionType.APPROVE_CORRECTION:
|
|
11493
|
-
return {
|
|
12018
|
+
return { requestId: getUUID(), ...actionBase, type: action };
|
|
11494
12019
|
case ActionType.REJECT_CORRECTION:
|
|
11495
12020
|
return {
|
|
11496
|
-
...actionBase,
|
|
11497
12021
|
requestId: getUUID(),
|
|
11498
|
-
|
|
11499
|
-
|
|
12022
|
+
content: { reason: "Correction rejection" },
|
|
12023
|
+
...actionBase,
|
|
12024
|
+
type: action
|
|
11500
12025
|
};
|
|
11501
12026
|
case ActionType.DUPLICATE_DETECTED: {
|
|
11502
12027
|
const duplicateActionDefaults = defaults;
|
|
@@ -11513,6 +12038,65 @@ function generateActionDocument({
|
|
|
11513
12038
|
throw new Error(`Unsupported action type: ${action}`);
|
|
11514
12039
|
}
|
|
11515
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
|
+
}
|
|
11516
12100
|
function generateRandomDatetime(rng, start, end) {
|
|
11517
12101
|
const range = end.getTime() - start.getTime();
|
|
11518
12102
|
const offset = Math.floor(rng() * range);
|
|
@@ -11531,9 +12115,20 @@ function generateEventDocument({
|
|
|
11531
12115
|
}) {
|
|
11532
12116
|
return {
|
|
11533
12117
|
trackingId: generateTrackingId(rng),
|
|
12118
|
+
configVersionId: INITIAL_EVENT_CONFIG_VERSION_ID,
|
|
11534
12119
|
type: configuration.id,
|
|
11535
|
-
actions: actions.
|
|
11536
|
-
(
|
|
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({
|
|
11537
12132
|
configuration,
|
|
11538
12133
|
action: action.type,
|
|
11539
12134
|
defaults: {
|
|
@@ -11541,20 +12136,11 @@ function generateEventDocument({
|
|
|
11541
12136
|
createdAtLocation: action.user?.primaryOfficeId,
|
|
11542
12137
|
assignedTo: action.user?.assignedTo,
|
|
11543
12138
|
createdByRole: action.user?.role,
|
|
11544
|
-
createdAt: (
|
|
11545
|
-
new Date(
|
|
11546
|
-
generateRandomDatetime(
|
|
11547
|
-
rng,
|
|
11548
|
-
new Date(2025, 0, 1),
|
|
11549
|
-
new Date(2025, 11, 31)
|
|
11550
|
-
)
|
|
11551
|
-
),
|
|
11552
|
-
i
|
|
11553
|
-
).toISOString()
|
|
12139
|
+
createdAt: createdAt.toISOString()
|
|
11554
12140
|
},
|
|
11555
12141
|
declarationOverrides: action.declarationOverrides
|
|
11556
|
-
})
|
|
11557
|
-
),
|
|
12142
|
+
});
|
|
12143
|
+
}),
|
|
11558
12144
|
// Offset is needed so the createdAt timestamps for events, actions and drafts make logical sense in storybook tests.
|
|
11559
12145
|
// @TODO: This should be fixed in the future.
|
|
11560
12146
|
createdAt: new Date(Date.now() - 1e3).toISOString(),
|
|
@@ -11581,6 +12167,7 @@ function generateEventDraftDocument({
|
|
|
11581
12167
|
transactionId: getUUID(),
|
|
11582
12168
|
action: {
|
|
11583
12169
|
...action,
|
|
12170
|
+
type: actionType,
|
|
11584
12171
|
declaration: {
|
|
11585
12172
|
...action.declaration,
|
|
11586
12173
|
...declaration
|
|
@@ -11623,6 +12210,7 @@ var eventQueryDataGenerator = (overrides = {}, seed = 1) => {
|
|
|
11623
12210
|
return {
|
|
11624
12211
|
id: overrides.id ?? generateUuid(rng),
|
|
11625
12212
|
type: overrides.type ?? TENNIS_CLUB_MEMBERSHIP,
|
|
12213
|
+
configVersionId: overrides.configVersionId ?? INITIAL_EVENT_CONFIG_VERSION_ID,
|
|
11626
12214
|
status: overrides.status ?? pickRandom(rng, EventStatus.options),
|
|
11627
12215
|
createdAt: overrides.createdAt ?? createdAt,
|
|
11628
12216
|
createdByUserType: overrides.createdByUserType ?? "user",
|
|
@@ -11668,52 +12256,60 @@ var generateEventConfig = ({
|
|
|
11668
12256
|
dateOfEventId,
|
|
11669
12257
|
actions = []
|
|
11670
12258
|
}) => {
|
|
11671
|
-
return
|
|
11672
|
-
|
|
11673
|
-
|
|
11674
|
-
|
|
11675
|
-
|
|
11676
|
-
|
|
11677
|
-
|
|
11678
|
-
placeOfEvent: placeOfEventId ? { $$field: placeOfEventId } : void 0,
|
|
11679
|
-
dateOfEvent: dateOfEventId ? { $$field: dateOfEventId } : void 0,
|
|
11680
|
-
declaration: {
|
|
11681
|
-
label: generateTranslationConfig2(`${id} Declaration`),
|
|
11682
|
-
pages: [
|
|
11683
|
-
{
|
|
11684
|
-
id: "page1",
|
|
11685
|
-
title: generateTranslationConfig2("Page 1"),
|
|
11686
|
-
fields
|
|
11687
|
-
}
|
|
11688
|
-
]
|
|
11689
|
-
},
|
|
11690
|
-
actions: [
|
|
11691
|
-
{
|
|
11692
|
-
type: ActionType.READ,
|
|
11693
|
-
label: generateTranslationConfig2("Read"),
|
|
11694
|
-
review: {
|
|
11695
|
-
title: generateTranslationConfig2("Review Read Action"),
|
|
11696
|
-
fields: []
|
|
11697
|
-
}
|
|
12259
|
+
return resolveEventConfig(
|
|
12260
|
+
defineConfig({
|
|
12261
|
+
id,
|
|
12262
|
+
label: generateTranslationConfig2(id),
|
|
12263
|
+
title: generateTranslationConfig2(`${id} Event`),
|
|
12264
|
+
summary: {
|
|
12265
|
+
fields: []
|
|
11698
12266
|
},
|
|
11699
|
-
{
|
|
11700
|
-
|
|
11701
|
-
|
|
11702
|
-
|
|
11703
|
-
|
|
11704
|
-
|
|
11705
|
-
|
|
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
|
+
]
|
|
11706
12278
|
},
|
|
11707
|
-
|
|
11708
|
-
|
|
11709
|
-
|
|
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
|
+
);
|
|
11710
12300
|
};
|
|
11711
12301
|
function withDeclaration(configuration, declaration) {
|
|
11712
12302
|
return {
|
|
11713
12303
|
...configuration,
|
|
11714
|
-
actions: configuration.actions.map(
|
|
11715
|
-
(action
|
|
11716
|
-
|
|
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
|
+
})
|
|
11717
12313
|
};
|
|
11718
12314
|
}
|
|
11719
12315
|
function getLeafAdministrativeAreaIds(administrativeAreas) {
|
|
@@ -11764,6 +12360,26 @@ function generateTestValidatorContext(userRole2, eventWithConfig) {
|
|
|
11764
12360
|
event: getEventValidatorContext(event2, eventConfig)
|
|
11765
12361
|
};
|
|
11766
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
|
+
}
|
|
11767
12383
|
|
|
11768
12384
|
// ../commons/src/events/TemplateConfig.ts
|
|
11769
12385
|
var window2 = () => ({
|
|
@@ -11777,7 +12393,7 @@ function isTemplateVariable(value) {
|
|
|
11777
12393
|
return typeof value === "string" && value.startsWith("$");
|
|
11778
12394
|
}
|
|
11779
12395
|
function isFieldValue(value) {
|
|
11780
|
-
return FieldValue.
|
|
12396
|
+
return FieldValue.validate(value);
|
|
11781
12397
|
}
|
|
11782
12398
|
function isFieldValueWithoutTemplates(value) {
|
|
11783
12399
|
if (isTemplateVariable(value)) {
|
|
@@ -11820,6 +12436,8 @@ var ACTION_SCOPE_MAP = {
|
|
|
11820
12436
|
"record.correct"
|
|
11821
12437
|
],
|
|
11822
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]: [],
|
|
11823
12441
|
[ActionType.REJECT_CORRECTION]: ["record.correct"],
|
|
11824
12442
|
[ActionType.APPROVE_CORRECTION]: ["record.correct"],
|
|
11825
12443
|
[ActionType.REVOKE_REGISTRATION]: ["record.revoke-registration"],
|
|
@@ -12129,13 +12747,11 @@ function getFilePathsFromEvent(event2) {
|
|
|
12129
12747
|
...declarationValues,
|
|
12130
12748
|
...annotationValues
|
|
12131
12749
|
].flatMap((value) => {
|
|
12132
|
-
|
|
12133
|
-
|
|
12134
|
-
return [fileParsed.data.path];
|
|
12750
|
+
if (isFileFieldValue(value)) {
|
|
12751
|
+
return [value.path];
|
|
12135
12752
|
}
|
|
12136
|
-
|
|
12137
|
-
|
|
12138
|
-
return fileOptionParsed.data.map((val) => val.path);
|
|
12753
|
+
if (isFileFieldWithOptionValue(value)) {
|
|
12754
|
+
return value.map((val) => val.path);
|
|
12139
12755
|
}
|
|
12140
12756
|
return [];
|
|
12141
12757
|
});
|