@opencrvs/toolkit 2.1.2 → 2.2.0-rc.19ec10b
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 +9 -14
- package/create-countryconfig/package.json +1 -1
- package/dist/application-config/index.js +57 -14
- package/dist/authentication/index.d.ts +2 -1
- package/dist/authentication/index.js +34 -14
- package/dist/cli.js +1491 -2020
- package/dist/commons/api/router.d.ts +1564 -248
- package/dist/commons/application-config/index.d.ts +3 -3
- package/dist/commons/conditionals/conditionals.d.ts +58 -7
- 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 +146 -20
- package/dist/commons/events/ActionDocument.d.ts +89 -0
- package/dist/commons/events/ActionInput.d.ts +56 -4
- package/dist/commons/events/ActionStatus.d.ts +2 -2
- package/dist/commons/events/ActionType.d.ts +13 -1
- package/dist/commons/events/AdvancedSearchConfig.d.ts +15 -0
- package/dist/commons/events/AuditLog.d.ts +4 -0
- package/dist/commons/events/CompositeFieldValue.d.ts +5 -1
- package/dist/commons/events/CountryConfigQueryInput.d.ts +192 -18
- package/dist/commons/events/Draft.d.ts +36 -1
- package/dist/commons/events/EventConfig.d.ts +473 -6
- package/dist/commons/events/EventDocument.d.ts +90 -0
- package/dist/commons/events/EventIndex.d.ts +44 -6
- package/dist/commons/events/EventInput.d.ts +1 -0
- package/dist/commons/events/EventMetadata.d.ts +24 -1
- package/dist/commons/events/EventStatus.d.ts +1 -0
- package/dist/commons/events/FieldConfig.d.ts +11 -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 +224 -33
- package/dist/commons/events/defineConfig.d.ts +7 -2
- package/dist/commons/events/event.d.ts +20 -1
- package/dist/commons/events/eventConfigValidation.d.ts +26 -1
- package/dist/commons/events/field.d.ts +37 -0
- 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 +4 -1
- package/dist/commons/events/state/flags.d.ts +1 -1
- package/dist/commons/events/state/index.d.ts +11 -2
- package/dist/commons/events/state/utils.d.ts +11 -1
- package/dist/commons/events/test.utils.d.ts +89 -7
- package/dist/commons/events/toNotificationForm.d.ts +17 -0
- package/dist/commons/events/utils.d.ts +90 -10
- 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 +29 -9
- 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 +24 -4
- package/dist/environment/derived-variables.d.ts.map +1 -1
- package/dist/environment/derived-variables.js +27 -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 +165 -35
- package/dist/environment/templates.d.ts.map +1 -1
- package/dist/events/index.js +2050 -1156
- 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/{v2.1 → persistent}/add-translations.d.ts +7 -1
- package/dist/migrations/persistent/add-translations.d.ts.map +1 -0
- package/dist/migrations/{v2.1 → persistent}/add-translations.js +14 -12
- 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/read-declaration-through-helper.d.ts +39 -0
- package/dist/migrations/read-declaration-through-helper.d.ts.map +1 -0
- package/dist/migrations/read-declaration-through-helper.js +199 -0
- 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 +1081 -209
- 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 +83 -100
- package/dist/scopes/index.js +29 -13
- package/dist/templates/charts-values/dependencies/values.yaml +6 -3
- package/dist/templates/charts-values/opencrvs-services/values.yaml +5 -10
- package/dist/templates/charts-values/traefik/values.yaml +4 -3
- 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.19ec10b.tgz +0 -0
- package/package.json +5 -3
- package/tsconfig.build.tsbuildinfo +1 -1
- package/tsconfig.json +3 -5
- 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/add-translations.d.ts.map +0 -1
- 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 -2170
- package/dist/migrations/v2.1/migrate-infrastructure-to-assets.d.ts +0 -14
- 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 -8
- package/dist/migrations/v2.1/upgrade-tilt.d.ts.map +0 -1
- package/dist/migrations/v2.1/upgrade-tilt.js +0 -139
- 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.1.2.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,
|
|
@@ -180,6 +182,7 @@ __export(events_exports, {
|
|
|
180
182
|
NameFieldUpdateValue: () => NameFieldUpdateValue,
|
|
181
183
|
NameFieldValue: () => NameFieldValue,
|
|
182
184
|
NonEmptyTextValue: () => NonEmptyTextValue,
|
|
185
|
+
NoneOfStatus: () => NoneOfStatus,
|
|
183
186
|
NotifyActionInput: () => NotifyActionInput,
|
|
184
187
|
NumberFieldValue: () => NumberFieldValue,
|
|
185
188
|
NumberWithUnitFieldUpdateValue: () => NumberWithUnitFieldUpdateValue,
|
|
@@ -203,10 +206,13 @@ __export(events_exports, {
|
|
|
203
206
|
RegisterAction: () => RegisterAction,
|
|
204
207
|
RegisterActionInput: () => RegisterActionInput,
|
|
205
208
|
RegistrationCreationMetadata: () => RegistrationCreationMetadata,
|
|
209
|
+
ReinstateRegistrationActionInput: () => ReinstateRegistrationActionInput,
|
|
206
210
|
RejectCorrectionActionInput: () => RejectCorrectionActionInput,
|
|
207
211
|
RejectDeclarationActionInput: () => RejectDeclarationActionInput,
|
|
208
212
|
RejectedCorrectionAction: () => RejectedCorrectionAction,
|
|
213
|
+
RemoteDraft: () => RemoteDraft,
|
|
209
214
|
RequestCorrectionActionInput: () => RequestCorrectionActionInput,
|
|
215
|
+
RevokeRegistrationActionInput: () => RevokeRegistrationActionInput,
|
|
210
216
|
SearchQuery: () => SearchQuery,
|
|
211
217
|
SearchQueryParams: () => SearchQueryParams,
|
|
212
218
|
SeededLocationVersions: () => SeededLocationVersions,
|
|
@@ -244,6 +250,7 @@ __export(events_exports, {
|
|
|
244
250
|
VerificationActionConfig: () => VerificationActionConfig,
|
|
245
251
|
VerificationPageConfig: () => VerificationPageConfig,
|
|
246
252
|
VerificationStatusValue: () => VerificationStatusValue,
|
|
253
|
+
VersionedEventConfig: () => VersionedEventConfig2,
|
|
247
254
|
WithdrawAdministrativeAreaVersionPayload: () => WithdrawAdministrativeAreaVersionPayload,
|
|
248
255
|
WithdrawLocationVersionPayload: () => WithdrawLocationVersionPayload,
|
|
249
256
|
Within: () => Within,
|
|
@@ -273,6 +280,7 @@ __export(events_exports, {
|
|
|
273
280
|
areConditionsMet: () => areConditionsMet,
|
|
274
281
|
buildClientFunctionContext: () => buildClientFunctionContext,
|
|
275
282
|
buildFormState: () => buildFormState,
|
|
283
|
+
byEffectiveFrom: () => byEffectiveFrom,
|
|
276
284
|
canAccessEventWithScope: () => canAccessEventWithScope,
|
|
277
285
|
canAccessOtherUserWithScopes: () => canAccessOtherUserWithScopes,
|
|
278
286
|
canAccessUserWithScope: () => canAccessUserWithScope,
|
|
@@ -310,6 +318,8 @@ __export(events_exports, {
|
|
|
310
318
|
filterActionsByFlags: () => filterActionsByFlags,
|
|
311
319
|
findActiveDraftForEvent: () => findActiveDraftForEvent,
|
|
312
320
|
findAllFields: () => findAllFields,
|
|
321
|
+
findConfigVersion: () => findConfigVersion,
|
|
322
|
+
findEventConfigForRecord: () => findEventConfigForRecord,
|
|
313
323
|
findLastAssignmentAction: () => findLastAssignmentAction,
|
|
314
324
|
findPendingCorrectionAction: () => findPendingCorrectionAction,
|
|
315
325
|
findRecordActionPages: () => findRecordActionPages,
|
|
@@ -318,6 +328,7 @@ __export(events_exports, {
|
|
|
318
328
|
flattenFormState: () => flattenFormState,
|
|
319
329
|
generateActionDeclarationInput: () => generateActionDeclarationInput,
|
|
320
330
|
generateActionDocument: () => generateActionDocument,
|
|
331
|
+
generateActionDocuments: () => generateActionDocuments,
|
|
321
332
|
generateActionDuplicateDeclarationInput: () => generateActionDuplicateDeclarationInput,
|
|
322
333
|
generateEventConfig: () => generateEventConfig,
|
|
323
334
|
generateEventDocument: () => generateEventDocument,
|
|
@@ -336,6 +347,7 @@ __export(events_exports, {
|
|
|
336
347
|
getActionAnnotation: () => getActionAnnotation,
|
|
337
348
|
getActionAnnotationFields: () => getActionAnnotationFields,
|
|
338
349
|
getActionConfig: () => getActionConfig,
|
|
350
|
+
getActionForm: () => getActionForm,
|
|
339
351
|
getActionFormFields: () => getActionFormFields,
|
|
340
352
|
getActionReview: () => getActionReview,
|
|
341
353
|
getActionReviewFields: () => getActionReviewFields,
|
|
@@ -349,35 +361,46 @@ __export(events_exports, {
|
|
|
349
361
|
getCompleteActionAnnotation: () => getCompleteActionAnnotation,
|
|
350
362
|
getCompleteActionContent: () => getCompleteActionContent,
|
|
351
363
|
getCompleteActionDeclaration: () => getCompleteActionDeclaration,
|
|
364
|
+
getConfigVersion: () => getConfigVersion,
|
|
352
365
|
getCurrentEventState: () => getCurrentEventState,
|
|
353
366
|
getCustomActionFields: () => getCustomActionFields,
|
|
354
367
|
getDeclaration: () => getDeclaration,
|
|
355
368
|
getDeclarationAfterEachAction: () => getDeclarationAfterEachAction,
|
|
356
369
|
getDeclarationFieldById: () => getDeclarationFieldById,
|
|
357
370
|
getDeclarationFields: () => getDeclarationFields,
|
|
371
|
+
getDeclarationFieldsOfAllVersions: () => getDeclarationFieldsOfAllVersions,
|
|
358
372
|
getDeclarationPages: () => getDeclarationPages,
|
|
359
373
|
getDeclarationWithPendingAction: () => getDeclarationWithPendingAction,
|
|
360
374
|
getEventConfigById: () => getEventConfigById,
|
|
375
|
+
getEventConfigForRecord: () => getEventConfigForRecord,
|
|
376
|
+
getEventConfigOfVersion: () => getEventConfigOfVersion,
|
|
361
377
|
getEventFlags: () => getEventFlags,
|
|
362
378
|
getEventValidatorContext: () => getEventValidatorContext,
|
|
379
|
+
getEventWithCompleteAcceptedActions: () => getEventWithCompleteAcceptedActions,
|
|
363
380
|
getFilePathsFromEvent: () => getFilePathsFromEvent,
|
|
364
381
|
getLeafAdministrativeAreaIds: () => getLeafAdministrativeAreaIds,
|
|
365
382
|
getLocationHierarchy: () => getLocationHierarchy,
|
|
366
383
|
getMixedPath: () => getMixedPath,
|
|
384
|
+
getNotificationFields: () => getNotificationFields,
|
|
385
|
+
getNotificationForm: () => getNotificationForm,
|
|
367
386
|
getPendingAction: () => getPendingAction,
|
|
368
387
|
getPrintCertificatePages: () => getPrintCertificatePages,
|
|
369
388
|
getRandomDate: () => getRandomDate,
|
|
370
389
|
getStatusFromActions: () => getStatusFromActions,
|
|
371
390
|
getValidatorsForField: () => getValidatorsForField,
|
|
391
|
+
getVersionsInEffect: () => getVersionsInEffect,
|
|
372
392
|
getVisibleVerificationPageIds: () => getVisibleVerificationPageIds,
|
|
373
393
|
hasActiveExternalIdOnOrAfter: () => hasActiveExternalIdOnOrAfter,
|
|
374
394
|
hasAnyOfScopes: () => hasAnyOfScopes,
|
|
375
395
|
isActionAvailable: () => isActionAvailable,
|
|
376
396
|
isActionConfigType: () => isActionConfigType,
|
|
397
|
+
isActionDateReference: () => isActionDateReference,
|
|
398
|
+
isActionDocument: () => isActionDocument,
|
|
377
399
|
isActionEnabled: () => isActionEnabled,
|
|
378
400
|
isActionInScope: () => isActionInScope,
|
|
379
401
|
isActionVisible: () => isActionVisible,
|
|
380
402
|
isAddressFieldType: () => isAddressFieldType,
|
|
403
|
+
isAddressFieldValue: () => isAddressFieldValue,
|
|
381
404
|
isAdministrativeAreaFieldType: () => isAdministrativeAreaFieldType,
|
|
382
405
|
isAgeFieldType: () => isAgeFieldType,
|
|
383
406
|
isAutocompleteFieldType: () => isAutocompleteFieldType,
|
|
@@ -392,6 +415,7 @@ __export(events_exports, {
|
|
|
392
415
|
isDateFieldType: () => isDateFieldType,
|
|
393
416
|
isDateRangeFieldType: () => isDateRangeFieldType,
|
|
394
417
|
isDividerFieldType: () => isDividerFieldType,
|
|
418
|
+
isDomesticAddressFieldValue: () => isDomesticAddressFieldValue,
|
|
395
419
|
isEmailFieldType: () => isEmailFieldType,
|
|
396
420
|
isEventFieldReference: () => isEventFieldReference,
|
|
397
421
|
isFacilityFieldType: () => isFacilityFieldType,
|
|
@@ -405,7 +429,9 @@ __export(events_exports, {
|
|
|
405
429
|
isFieldValueWithoutTemplates: () => isFieldValueWithoutTemplates,
|
|
406
430
|
isFieldVisible: () => isFieldVisible,
|
|
407
431
|
isFileFieldType: () => isFileFieldType,
|
|
432
|
+
isFileFieldValue: () => isFileFieldValue,
|
|
408
433
|
isFileFieldWithOptionType: () => isFileFieldWithOptionType,
|
|
434
|
+
isFileFieldWithOptionValue: () => isFileFieldWithOptionValue,
|
|
409
435
|
isHeadingFieldType: () => isHeadingFieldType,
|
|
410
436
|
isHiddenFieldType: () => isHiddenFieldType,
|
|
411
437
|
isHttpFieldType: () => isHttpFieldType,
|
|
@@ -426,6 +452,7 @@ __export(events_exports, {
|
|
|
426
452
|
isPageVisible: () => isPageVisible,
|
|
427
453
|
isParagraphFieldType: () => isParagraphFieldType,
|
|
428
454
|
isPhoneFieldType: () => isPhoneFieldType,
|
|
455
|
+
isPlainDate: () => isPlainDate,
|
|
429
456
|
isPotentialDuplicate: () => isPotentialDuplicate,
|
|
430
457
|
isPrintButtonFieldType: () => isPrintButtonFieldType,
|
|
431
458
|
isQrReaderFieldType: () => isQrReaderFieldType,
|
|
@@ -462,6 +489,10 @@ __export(events_exports, {
|
|
|
462
489
|
plainDateToLocalDate: () => plainDateToLocalDate,
|
|
463
490
|
precompileActionSchemas: () => precompileActionSchemas,
|
|
464
491
|
resolveDateOfEvent: () => resolveDateOfEvent,
|
|
492
|
+
resolveEffectiveVersion: () => resolveEffectiveVersion,
|
|
493
|
+
resolveEventConfig: () => resolveEventConfig,
|
|
494
|
+
resolveEventConfigInTimeZone: () => resolveEventConfigInTimeZone,
|
|
495
|
+
resolveEventConfigOnDate: () => resolveEventConfigOnDate,
|
|
465
496
|
resolveEventCustomFlags: () => resolveEventCustomFlags,
|
|
466
497
|
resolvePath: () => resolvePath,
|
|
467
498
|
resolvePlaceOfEvent: () => resolvePlaceOfEvent,
|
|
@@ -474,26 +505,37 @@ __export(events_exports, {
|
|
|
474
505
|
timePeriodToDateRange: () => timePeriodToDateRange,
|
|
475
506
|
toClientAdministrativeArea: () => toClientAdministrativeArea,
|
|
476
507
|
toClientLocation: () => toClientLocation,
|
|
508
|
+
toEventConfig: () => toEventConfig,
|
|
509
|
+
toNotificationForm: () => toNotificationForm,
|
|
510
|
+
toNotificationReview: () => toNotificationReview,
|
|
477
511
|
toPlainDate: () => toPlainDate,
|
|
512
|
+
toPlainDateInTimeZone: () => toPlainDateInTimeZone,
|
|
513
|
+
toVersionedEventConfig: () => toVersionedEventConfig,
|
|
478
514
|
todayISO: () => todayISO,
|
|
479
515
|
user: () => user,
|
|
480
516
|
userCanAccessEventWithScopes: () => userCanAccessEventWithScopes,
|
|
481
517
|
validate: () => validate,
|
|
518
|
+
validateEachVersion: () => validateEachVersion,
|
|
519
|
+
validateEventConfig: () => validateEventConfig,
|
|
482
520
|
validateFieldInput: () => validateFieldInput,
|
|
483
521
|
validateValue: () => validateValue,
|
|
484
522
|
window: () => window2,
|
|
523
|
+
withDeclaration: () => withDeclaration,
|
|
485
524
|
writeActions: () => writeActions
|
|
486
525
|
});
|
|
487
526
|
module.exports = __toCommonJS(events_exports);
|
|
488
527
|
|
|
528
|
+
// ../commons/src/events/index.ts
|
|
529
|
+
var import_compile = require("zod/compile");
|
|
530
|
+
|
|
489
531
|
// ../commons/src/events/AuditLog.ts
|
|
490
532
|
var z9 = __toESM(require("zod/v4"));
|
|
491
533
|
|
|
492
|
-
// ../commons/src/authentication.ts
|
|
534
|
+
// ../commons/src/users/authentication.ts
|
|
493
535
|
var import_jwt_decode = __toESM(require("jwt-decode"));
|
|
494
536
|
var z8 = __toESM(require("zod/v4"));
|
|
495
537
|
|
|
496
|
-
// ../commons/src/scopes.ts
|
|
538
|
+
// ../commons/src/users/scopes.ts
|
|
497
539
|
var z7 = __toESM(require("zod/v4"));
|
|
498
540
|
var qs = __toESM(require("qs"));
|
|
499
541
|
|
|
@@ -504,6 +546,12 @@ var UUID = z.uuid().brand("UUID");
|
|
|
504
546
|
function getUUID() {
|
|
505
547
|
return (0, import_uuid.v4)();
|
|
506
548
|
}
|
|
549
|
+
function isUUID(id) {
|
|
550
|
+
return UUID.validate(id);
|
|
551
|
+
}
|
|
552
|
+
function maybeUuid(value) {
|
|
553
|
+
return isUUID(value) ? value : void 0;
|
|
554
|
+
}
|
|
507
555
|
|
|
508
556
|
// ../commons/src/events/ActionType.ts
|
|
509
557
|
var z2 = __toESM(require("zod/v4"));
|
|
@@ -529,6 +577,8 @@ var ActionType = {
|
|
|
529
577
|
REQUEST_CORRECTION: "REQUEST_CORRECTION",
|
|
530
578
|
REJECT_CORRECTION: "REJECT_CORRECTION",
|
|
531
579
|
APPROVE_CORRECTION: "APPROVE_CORRECTION",
|
|
580
|
+
REVOKE_REGISTRATION: "REVOKE_REGISTRATION",
|
|
581
|
+
REINSTATE_REGISTRATION: "REINSTATE_REGISTRATION",
|
|
532
582
|
// General actions
|
|
533
583
|
READ: "READ",
|
|
534
584
|
ASSIGN: "ASSIGN",
|
|
@@ -548,6 +598,8 @@ var ConfirmableActions = [
|
|
|
548
598
|
ActionType.REQUEST_CORRECTION,
|
|
549
599
|
ActionType.APPROVE_CORRECTION,
|
|
550
600
|
ActionType.REJECT_CORRECTION,
|
|
601
|
+
ActionType.REVOKE_REGISTRATION,
|
|
602
|
+
ActionType.REINSTATE_REGISTRATION,
|
|
551
603
|
ActionType.CUSTOM
|
|
552
604
|
];
|
|
553
605
|
var ActionTypes = z2.enum([
|
|
@@ -567,13 +619,17 @@ var ActionTypes = z2.enum([
|
|
|
567
619
|
"REQUEST_CORRECTION",
|
|
568
620
|
"REJECT_CORRECTION",
|
|
569
621
|
"APPROVE_CORRECTION",
|
|
622
|
+
"REVOKE_REGISTRATION",
|
|
623
|
+
"REINSTATE_REGISTRATION",
|
|
570
624
|
"READ",
|
|
571
625
|
"ASSIGN",
|
|
572
626
|
"UNASSIGN",
|
|
573
627
|
"CUSTOM"
|
|
574
628
|
]);
|
|
575
629
|
var ClientSpecificAction = {
|
|
576
|
-
REVIEW_CORRECTION_REQUEST: "REVIEW_CORRECTION_REQUEST"
|
|
630
|
+
REVIEW_CORRECTION_REQUEST: "REVIEW_CORRECTION_REQUEST",
|
|
631
|
+
/** Opens the user's declare or notify draft of the event in its own flow */
|
|
632
|
+
CONTINUE_DRAFT: "CONTINUE_DRAFT"
|
|
577
633
|
};
|
|
578
634
|
var declarationActionValues = [
|
|
579
635
|
ActionTypes.enum.DECLARE,
|
|
@@ -608,7 +664,9 @@ var WorkqueueActionType = ActionTypes.extract([
|
|
|
608
664
|
ActionType.ARCHIVE,
|
|
609
665
|
ActionType.UNARCHIVE,
|
|
610
666
|
ActionType.PRINT_CERTIFICATE,
|
|
611
|
-
ActionType.REQUEST_CORRECTION
|
|
667
|
+
ActionType.REQUEST_CORRECTION,
|
|
668
|
+
ActionType.REVOKE_REGISTRATION,
|
|
669
|
+
ActionType.REINSTATE_REGISTRATION
|
|
612
670
|
]);
|
|
613
671
|
var META_ACTIONS = [
|
|
614
672
|
ActionType.ASSIGN,
|
|
@@ -627,7 +685,7 @@ var ActionStatus = {
|
|
|
627
685
|
};
|
|
628
686
|
|
|
629
687
|
// ../commons/src/events/Flag.ts
|
|
630
|
-
var z5 = __toESM(require("zod
|
|
688
|
+
var z5 = __toESM(require("zod"));
|
|
631
689
|
|
|
632
690
|
// ../commons/src/events/TranslationConfig.ts
|
|
633
691
|
var z3 = __toESM(require("zod/v4"));
|
|
@@ -696,7 +754,6 @@ var FieldConditional = z4.discriminatedUnion("type", [
|
|
|
696
754
|
|
|
697
755
|
// ../commons/src/events/Flag.ts
|
|
698
756
|
var InherentFlags = {
|
|
699
|
-
INCOMPLETE: "incomplete",
|
|
700
757
|
REJECTED: "rejected",
|
|
701
758
|
CORRECTION_REQUESTED: "correction-requested",
|
|
702
759
|
POTENTIAL_DUPLICATE: "potential-duplicate",
|
|
@@ -724,7 +781,7 @@ var CustomFlag = z5.string().refine((val) => !Object.values(InherentFlags).inclu
|
|
|
724
781
|
message: `Custom flag cannot be one of the inherent flags: ${Object.values(
|
|
725
782
|
InherentFlags
|
|
726
783
|
).join(", ")}`
|
|
727
|
-
}).refine((val) => !ActionFlag.
|
|
784
|
+
}).refine((val) => !ActionFlag.validate(val), {
|
|
728
785
|
message: "Custom flag cannot match the ActionFlag pattern (ActionType:ActionStatus)."
|
|
729
786
|
}).describe("Custom flag identifier defined by the country config.");
|
|
730
787
|
var Flag = ActionFlag.or(z5.enum(InherentFlags)).or(CustomFlag);
|
|
@@ -763,10 +820,11 @@ var EventStatus = z6.enum([
|
|
|
763
820
|
"NOTIFIED",
|
|
764
821
|
"DECLARED",
|
|
765
822
|
"REGISTERED",
|
|
823
|
+
"REVOKED",
|
|
766
824
|
"ARCHIVED"
|
|
767
825
|
]);
|
|
768
826
|
|
|
769
|
-
// ../commons/src/scopes.ts
|
|
827
|
+
// ../commons/src/users/scopes.ts
|
|
770
828
|
var JurisdictionFilter = z7.enum(["administrativeArea", "location", "all"]).describe(
|
|
771
829
|
"Filters based on user jurisdiction relative to their office location in hierarchy."
|
|
772
830
|
);
|
|
@@ -786,6 +844,8 @@ var RecordScopeTypeV2 = z7.enum([
|
|
|
786
844
|
"record.print-certified-copies",
|
|
787
845
|
"record.request-correction",
|
|
788
846
|
"record.correct",
|
|
847
|
+
"record.revoke-registration",
|
|
848
|
+
"record.reinstate-registration",
|
|
789
849
|
"record.unassign-others",
|
|
790
850
|
"record.custom-action",
|
|
791
851
|
"record.action.accept",
|
|
@@ -912,6 +972,8 @@ var ScopesWithFullOptions = RecordScopeTypeV2.extract([
|
|
|
912
972
|
"record.read",
|
|
913
973
|
"record.request-correction",
|
|
914
974
|
"record.correct",
|
|
975
|
+
"record.revoke-registration",
|
|
976
|
+
"record.reinstate-registration",
|
|
915
977
|
"record.unassign-others",
|
|
916
978
|
"record.review-duplicates"
|
|
917
979
|
]);
|
|
@@ -1094,7 +1156,7 @@ function getAcceptedScopesByType({
|
|
|
1094
1156
|
}).filter((scope) => scope !== null);
|
|
1095
1157
|
}
|
|
1096
1158
|
|
|
1097
|
-
// ../commons/src/authentication.ts
|
|
1159
|
+
// ../commons/src/users/authentication.ts
|
|
1098
1160
|
var TokenUserType = z8.enum(["user", "system"]);
|
|
1099
1161
|
var TokenWithBearer = z8.string().regex(/^Bearer\s/);
|
|
1100
1162
|
|
|
@@ -1156,6 +1218,8 @@ var EventActionEntrySchema = AuditLogEntryBase.extend({
|
|
|
1156
1218
|
"event.actions.correction.request.request",
|
|
1157
1219
|
"event.actions.correction.approve.request",
|
|
1158
1220
|
"event.actions.correction.reject.request",
|
|
1221
|
+
"event.actions.revoke_registration.request",
|
|
1222
|
+
"event.actions.reinstate_registration.request",
|
|
1159
1223
|
"event.actions.mark_as_duplicate.request",
|
|
1160
1224
|
"event.actions.mark_as_not_duplicate.request"
|
|
1161
1225
|
]),
|
|
@@ -1490,7 +1554,7 @@ var z14 = __toESM(require("zod/v4"));
|
|
|
1490
1554
|
// ../commons/src/documents.ts
|
|
1491
1555
|
var z11 = __toESM(require("zod/v4"));
|
|
1492
1556
|
var FullDocumentUrl = z11.string().brand("FullDocumentUrl").describe(
|
|
1493
|
-
"A full url with protocol, host, bucket name, starting from the root of the S3 server, https://
|
|
1557
|
+
"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"
|
|
1494
1558
|
);
|
|
1495
1559
|
var FullDocumentPath = z11.string().overwrite((val) => val.startsWith("/") ? val : `/${val}`).meta({ effectType: "input", type: "string" }).describe(
|
|
1496
1560
|
"A full absolute path with bucket name, starting from the root of the S3 server, /bucket-name/document-id.jpg"
|
|
@@ -1500,7 +1564,7 @@ var DocumentPath = z11.string().brand("DocumentPath").describe(
|
|
|
1500
1564
|
);
|
|
1501
1565
|
|
|
1502
1566
|
// ../commons/src/events/CompositeFieldValue.ts
|
|
1503
|
-
var z12 = __toESM(require("zod
|
|
1567
|
+
var z12 = __toESM(require("zod"));
|
|
1504
1568
|
var GeographicalArea = {
|
|
1505
1569
|
URBAN: "URBAN",
|
|
1506
1570
|
RURAL: "RURAL"
|
|
@@ -1514,6 +1578,9 @@ var FileFieldValue = z12.object({
|
|
|
1514
1578
|
originalFilename: z12.string(),
|
|
1515
1579
|
type: z12.string()
|
|
1516
1580
|
});
|
|
1581
|
+
function isFileFieldValue(value) {
|
|
1582
|
+
return FileFieldValue.validate(value);
|
|
1583
|
+
}
|
|
1517
1584
|
var NameFieldValue = z12.object({
|
|
1518
1585
|
firstname: z12.string(),
|
|
1519
1586
|
surname: z12.string(),
|
|
@@ -1538,6 +1605,9 @@ var DomesticAddressFieldValue = BaseAddressFieldValue.extend({
|
|
|
1538
1605
|
addressType: z12.literal(AddressType.DOMESTIC),
|
|
1539
1606
|
administrativeArea: z12.string().uuid()
|
|
1540
1607
|
});
|
|
1608
|
+
function isDomesticAddressFieldValue(value) {
|
|
1609
|
+
return DomesticAddressFieldValue.validate(value);
|
|
1610
|
+
}
|
|
1541
1611
|
var InternationalAddressFieldValue = BaseAddressFieldValue.extend({
|
|
1542
1612
|
addressType: z12.literal(AddressType.INTERNATIONAL)
|
|
1543
1613
|
});
|
|
@@ -1545,6 +1615,9 @@ var AddressFieldValue = z12.discriminatedUnion("addressType", [
|
|
|
1545
1615
|
DomesticAddressFieldValue,
|
|
1546
1616
|
InternationalAddressFieldValue
|
|
1547
1617
|
]);
|
|
1618
|
+
function isAddressFieldValue(value) {
|
|
1619
|
+
return AddressFieldValue.validate(value);
|
|
1620
|
+
}
|
|
1548
1621
|
var DomesticAddressUpdateFieldValue = BaseAddressFieldUpdateValue.extend({
|
|
1549
1622
|
addressType: z12.literal(AddressType.DOMESTIC),
|
|
1550
1623
|
administrativeArea: z12.string().uuid().nullish()
|
|
@@ -1566,6 +1639,9 @@ var FileFieldValueWithOption = z12.object({
|
|
|
1566
1639
|
option: z12.string()
|
|
1567
1640
|
});
|
|
1568
1641
|
var FileFieldWithOptionValue = z12.array(FileFieldValueWithOption);
|
|
1642
|
+
function isFileFieldWithOptionValue(value) {
|
|
1643
|
+
return FileFieldWithOptionValue.validate(value);
|
|
1644
|
+
}
|
|
1569
1645
|
var HttpFieldValue = z12.object({
|
|
1570
1646
|
loading: z12.boolean(),
|
|
1571
1647
|
error: z12.object({ statusCode: z12.number(), message: z12.string() }).nullish(),
|
|
@@ -1601,9 +1677,30 @@ var CustomFieldValue = z12.unknown().brand("CustomFieldValue");
|
|
|
1601
1677
|
// ../commons/src/events/PlainDate.ts
|
|
1602
1678
|
var import_zod = require("zod");
|
|
1603
1679
|
var PlainDate = import_zod.z.string().date().brand("PlainDate").describe("Date in the format YYYY-MM-DD");
|
|
1680
|
+
var isPlainDate = (date) => PlainDate.validate(date);
|
|
1604
1681
|
function toPlainDate(dateTime) {
|
|
1605
1682
|
return dateTime.split("T")[0];
|
|
1606
1683
|
}
|
|
1684
|
+
var dateFormats = /* @__PURE__ */ new Map();
|
|
1685
|
+
function getDateFormat(timeZone) {
|
|
1686
|
+
let format2 = dateFormats.get(timeZone);
|
|
1687
|
+
if (!format2) {
|
|
1688
|
+
format2 = new Intl.DateTimeFormat("en-US", {
|
|
1689
|
+
timeZone,
|
|
1690
|
+
year: "numeric",
|
|
1691
|
+
month: "2-digit",
|
|
1692
|
+
day: "2-digit"
|
|
1693
|
+
});
|
|
1694
|
+
dateFormats.set(timeZone, format2);
|
|
1695
|
+
}
|
|
1696
|
+
return format2;
|
|
1697
|
+
}
|
|
1698
|
+
function toPlainDateInTimeZone(date, timeZone) {
|
|
1699
|
+
const parts = Object.fromEntries(
|
|
1700
|
+
getDateFormat(timeZone).formatToParts(date).map(({ type, value }) => [type, value])
|
|
1701
|
+
);
|
|
1702
|
+
return `${parts.year}-${parts.month}-${parts.day}`;
|
|
1703
|
+
}
|
|
1607
1704
|
function plainDateToLocalDate(date) {
|
|
1608
1705
|
const [year, month, day] = date.split("-").map(Number);
|
|
1609
1706
|
return new Date(year, month - 1, day);
|
|
@@ -1716,7 +1813,7 @@ function safeUnion(schemas) {
|
|
|
1716
1813
|
);
|
|
1717
1814
|
return z14.any().superRefine((val, ctx) => {
|
|
1718
1815
|
for (const schema of sortedSchemas) {
|
|
1719
|
-
if (schema.
|
|
1816
|
+
if (schema.validate(val)) {
|
|
1720
1817
|
return;
|
|
1721
1818
|
}
|
|
1722
1819
|
}
|
|
@@ -1910,6 +2007,16 @@ var UnarchiveAction = ActionBase.extend(
|
|
|
1910
2007
|
type: z16.literal(ActionType.UNARCHIVE)
|
|
1911
2008
|
}).shape
|
|
1912
2009
|
);
|
|
2010
|
+
var RevokeRegistrationAction = ActionBase.extend(
|
|
2011
|
+
z16.object({
|
|
2012
|
+
type: z16.literal(ActionType.REVOKE_REGISTRATION)
|
|
2013
|
+
}).shape
|
|
2014
|
+
);
|
|
2015
|
+
var ReinstateRegistrationAction = ActionBase.extend(
|
|
2016
|
+
z16.object({
|
|
2017
|
+
type: z16.literal(ActionType.REINSTATE_REGISTRATION)
|
|
2018
|
+
}).shape
|
|
2019
|
+
);
|
|
1913
2020
|
var CreatedAction = ActionBase.extend(
|
|
1914
2021
|
z16.object({
|
|
1915
2022
|
type: z16.literal(ActionType.CREATE)
|
|
@@ -1978,6 +2085,8 @@ var ActionDocument = z16.discriminatedUnion("type", [
|
|
|
1978
2085
|
MarkAsDuplicateAction.meta({ id: "MarkAsDuplicateAction" }),
|
|
1979
2086
|
ArchiveAction.meta({ id: "ArchiveAction" }),
|
|
1980
2087
|
UnarchiveAction.meta({ id: "UnarchiveAction" }),
|
|
2088
|
+
RevokeRegistrationAction.meta({ id: "RevokeRegistrationAction" }),
|
|
2089
|
+
ReinstateRegistrationAction.meta({ id: "ReinstateRegistrationAction" }),
|
|
1981
2090
|
NotifiedAction.meta({ id: "NotifiedAction" }),
|
|
1982
2091
|
RegisterAction.meta({ id: "RegisterAction" }),
|
|
1983
2092
|
DeclareAction.meta({ id: "DeclareAction" }),
|
|
@@ -1993,6 +2102,7 @@ var ActionDocument = z16.discriminatedUnion("type", [
|
|
|
1993
2102
|
]).meta({
|
|
1994
2103
|
id: "ActionDocument"
|
|
1995
2104
|
});
|
|
2105
|
+
var isActionDocument = (a) => ActionDocument.validate(a);
|
|
1996
2106
|
var AsyncRejectActionDocument = ActionBase.omit({
|
|
1997
2107
|
declaration: true,
|
|
1998
2108
|
annotation: true
|
|
@@ -2026,11 +2136,15 @@ var RegistrationCreationMetadata = ActionCreationMetadata.extend({
|
|
|
2026
2136
|
var LegalStatuses = z17.object({
|
|
2027
2137
|
[EventStatus.enum.NOTIFIED]: ActionCreationMetadata.nullish(),
|
|
2028
2138
|
[EventStatus.enum.DECLARED]: ActionCreationMetadata.nullish(),
|
|
2029
|
-
[EventStatus.enum.REGISTERED]: RegistrationCreationMetadata.nullish()
|
|
2139
|
+
[EventStatus.enum.REGISTERED]: RegistrationCreationMetadata.nullish(),
|
|
2140
|
+
[EventStatus.enum.REVOKED]: ActionCreationMetadata.nullish()
|
|
2030
2141
|
});
|
|
2031
2142
|
var EventMetadata = z17.object({
|
|
2032
2143
|
id: UUID,
|
|
2033
2144
|
type: z17.string().describe("The type of event, such as birth, death, or marriage."),
|
|
2145
|
+
configVersionId: z17.string().describe(
|
|
2146
|
+
"Id of the event configuration version the record was created under. Records created before versioning have 'initial'."
|
|
2147
|
+
),
|
|
2034
2148
|
status: EventStatus,
|
|
2035
2149
|
legalStatuses: LegalStatuses.describe(
|
|
2036
2150
|
"Metadata related to the legal registration of the event, such as who registered it and when."
|
|
@@ -2228,6 +2342,12 @@ var AnyOfStatus = import_v4.z.object({
|
|
|
2228
2342
|
}).meta({
|
|
2229
2343
|
id: "AnyOfStatus"
|
|
2230
2344
|
});
|
|
2345
|
+
var NoneOfStatus = import_v4.z.object({
|
|
2346
|
+
type: import_v4.z.literal("noneOf"),
|
|
2347
|
+
terms: import_v4.z.array(EventStatus)
|
|
2348
|
+
}).meta({
|
|
2349
|
+
id: "NoneOfStatus"
|
|
2350
|
+
});
|
|
2231
2351
|
var Range = import_v4.z.object({
|
|
2232
2352
|
type: import_v4.z.literal("range"),
|
|
2233
2353
|
gte: import_v4.z.string(),
|
|
@@ -2268,7 +2388,7 @@ var QueryInput = import_v4.z.lazy(
|
|
|
2268
2388
|
var QueryExpression = import_v4.z.object({
|
|
2269
2389
|
id: import_v4.z.optional(import_v4.z.string()),
|
|
2270
2390
|
eventType: import_v4.z.string(),
|
|
2271
|
-
status: import_v4.z.optional(import_v4.z.union([AnyOfStatus, ExactStatus])),
|
|
2391
|
+
status: import_v4.z.optional(import_v4.z.union([AnyOfStatus, NoneOfStatus, ExactStatus])),
|
|
2272
2392
|
createdAt: import_v4.z.optional(DateCondition),
|
|
2273
2393
|
updatedAt: import_v4.z.optional(DateCondition),
|
|
2274
2394
|
"legalStatuses.DECLARED.createdAtLocation": import_v4.z.optional(Within).nullable(),
|
|
@@ -2277,6 +2397,7 @@ var QueryExpression = import_v4.z.object({
|
|
|
2277
2397
|
"legalStatuses.REGISTERED.createdAtLocation": import_v4.z.optional(Within).nullable(),
|
|
2278
2398
|
"legalStatuses.REGISTERED.createdByRole": import_v4.z.optional(AnyOf),
|
|
2279
2399
|
"legalStatuses.REGISTERED.registrationNumber": import_v4.z.optional(Exact),
|
|
2400
|
+
"legalStatuses.REVOKED.createdAtLocation": import_v4.z.optional(Within).nullable(),
|
|
2280
2401
|
createdAtLocation: import_v4.z.optional(import_v4.z.union([Within, Exact])),
|
|
2281
2402
|
updatedAtLocation: import_v4.z.optional(import_v4.z.union([Within, Exact])),
|
|
2282
2403
|
assignedTo: import_v4.z.optional(Exact),
|
|
@@ -3477,6 +3598,12 @@ var ReadActionConfig = ActionConfigBase.extend(
|
|
|
3477
3598
|
var NotifyConfig = ActionConfigBase.extend(
|
|
3478
3599
|
z25.object({
|
|
3479
3600
|
type: z25.literal(ActionType.NOTIFY),
|
|
3601
|
+
notificationForm: DeclarationFormConfig.describe(
|
|
3602
|
+
"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."
|
|
3603
|
+
),
|
|
3604
|
+
review: DeclarationReviewConfig.describe(
|
|
3605
|
+
"Review page configuration for the notify action. Values of its fields are stored as the NOTIFY action annotation."
|
|
3606
|
+
),
|
|
3480
3607
|
form: actionConfirmationForm
|
|
3481
3608
|
}).shape
|
|
3482
3609
|
);
|
|
@@ -3529,6 +3656,9 @@ var DeleteConfig = ActionConfigBase.extend(
|
|
|
3529
3656
|
var DeclareConfig = DeclarationActionBase.extend(
|
|
3530
3657
|
z25.object({
|
|
3531
3658
|
type: z25.literal(ActionType.DECLARE),
|
|
3659
|
+
declaration: DeclarationFormConfig.describe(
|
|
3660
|
+
"Configuration of the form used to gather event data."
|
|
3661
|
+
),
|
|
3532
3662
|
review: DeclarationReviewConfig.describe(
|
|
3533
3663
|
"Configuration of the review page fields."
|
|
3534
3664
|
),
|
|
@@ -3557,6 +3687,18 @@ var UnarchiveConfig = ActionConfigBase.extend(
|
|
|
3557
3687
|
type: z25.literal(ActionType.UNARCHIVE)
|
|
3558
3688
|
}).shape
|
|
3559
3689
|
);
|
|
3690
|
+
var RevokeRegistrationConfig = ActionConfigBase.extend(
|
|
3691
|
+
z25.object({
|
|
3692
|
+
type: z25.literal(ActionType.REVOKE_REGISTRATION),
|
|
3693
|
+
form: actionConfirmationForm
|
|
3694
|
+
}).shape
|
|
3695
|
+
);
|
|
3696
|
+
var ReinstateRegistrationConfig = ActionConfigBase.extend(
|
|
3697
|
+
z25.object({
|
|
3698
|
+
type: z25.literal(ActionType.REINSTATE_REGISTRATION),
|
|
3699
|
+
form: actionConfirmationForm
|
|
3700
|
+
}).shape
|
|
3701
|
+
);
|
|
3560
3702
|
var EditActionConfig = ActionConfigBase.extend(
|
|
3561
3703
|
z25.object({
|
|
3562
3704
|
type: z25.literal(ActionType.EDIT),
|
|
@@ -3643,11 +3785,11 @@ var ActionConfig = z25.discriminatedUnion("type", [
|
|
|
3643
3785
|
}),
|
|
3644
3786
|
NotifyConfig.meta({
|
|
3645
3787
|
id: "NotifyActionConfig",
|
|
3646
|
-
description: "Configuration for the notify action
|
|
3788
|
+
description: "Configuration for the notify action: the notification form and its review page. An event without a NOTIFY action cannot be notified."
|
|
3647
3789
|
}),
|
|
3648
3790
|
DeclareConfig.meta({
|
|
3649
3791
|
id: "DeclareActionConfig",
|
|
3650
|
-
description: "Configuration for the declare action. Includes review-page fields.
|
|
3792
|
+
description: "Configuration for the declare action. Includes the declaration form and review-page fields."
|
|
3651
3793
|
}),
|
|
3652
3794
|
DuplicateDetectedConfig.meta({
|
|
3653
3795
|
id: "DuplicateDetectedActionConfig",
|
|
@@ -3697,6 +3839,14 @@ var ActionConfig = z25.discriminatedUnion("type", [
|
|
|
3697
3839
|
id: "UnarchiveActionConfig",
|
|
3698
3840
|
description: "Configuration for unarchiving a record."
|
|
3699
3841
|
}),
|
|
3842
|
+
RevokeRegistrationConfig.meta({
|
|
3843
|
+
id: "RevokeRegistrationActionConfig",
|
|
3844
|
+
description: "Configuration for revoking a registered record."
|
|
3845
|
+
}),
|
|
3846
|
+
ReinstateRegistrationConfig.meta({
|
|
3847
|
+
id: "ReinstateRegistrationActionConfig",
|
|
3848
|
+
description: "Configuration for reinstating a revoked record back to registered."
|
|
3849
|
+
}),
|
|
3700
3850
|
CustomActionConfig.meta({
|
|
3701
3851
|
id: "CustomActionConfig",
|
|
3702
3852
|
description: "Configuration for a country-defined custom action. An event may include any number of these."
|
|
@@ -3903,7 +4053,7 @@ var ReferenceField = BaseField2.extend({
|
|
|
3903
4053
|
var Field = BaseField2.extend({
|
|
3904
4054
|
id: z29.string().describe("Identifier of the summary field."),
|
|
3905
4055
|
value: TranslationConfig.describe(
|
|
3906
|
-
'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}").'
|
|
4056
|
+
'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.'
|
|
3907
4057
|
),
|
|
3908
4058
|
label: TranslationConfig
|
|
3909
4059
|
}).describe("Custom field defined for the summary view.");
|
|
@@ -3998,7 +4148,10 @@ var SearchQueryParams = z30.object({
|
|
|
3998
4148
|
}).catchall(FieldValue);
|
|
3999
4149
|
var FieldConfigSchema = BaseField3.extend({
|
|
4000
4150
|
fieldId: z30.string(),
|
|
4001
|
-
fieldType: z30.literal("field")
|
|
4151
|
+
fieldType: z30.literal("field"),
|
|
4152
|
+
defaultValue: z30.union([z30.boolean(), z30.string(), z30.number()]).optional().describe(
|
|
4153
|
+
`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.`
|
|
4154
|
+
)
|
|
4002
4155
|
});
|
|
4003
4156
|
var EventFieldIdInput = z30.enum([
|
|
4004
4157
|
"trackingId",
|
|
@@ -4047,6 +4200,41 @@ var AdvancedSearchConfig = z30.object({
|
|
|
4047
4200
|
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()`)."
|
|
4048
4201
|
});
|
|
4049
4202
|
|
|
4203
|
+
// ../commons/src/utils.ts
|
|
4204
|
+
var z31 = __toESM(require("zod/v4"));
|
|
4205
|
+
var _ = __toESM(require("lodash"));
|
|
4206
|
+
function getOrThrow(x, message) {
|
|
4207
|
+
if (x === void 0 || x === null) {
|
|
4208
|
+
throw new Error(message);
|
|
4209
|
+
}
|
|
4210
|
+
return x;
|
|
4211
|
+
}
|
|
4212
|
+
function joinValues(values, separator = " ") {
|
|
4213
|
+
return values.filter((value) => !!value).join(separator).trim();
|
|
4214
|
+
}
|
|
4215
|
+
var FullNameV1 = z31.array(
|
|
4216
|
+
z31.object({
|
|
4217
|
+
use: z31.string(),
|
|
4218
|
+
family: z31.string(),
|
|
4219
|
+
given: z31.array(z31.string())
|
|
4220
|
+
})
|
|
4221
|
+
);
|
|
4222
|
+
function omitKeyDeep(obj, keyToRemove) {
|
|
4223
|
+
if (Array.isArray(obj)) {
|
|
4224
|
+
return obj.map((item) => omitKeyDeep(item, keyToRemove));
|
|
4225
|
+
}
|
|
4226
|
+
if (obj === null || typeof obj !== "object") {
|
|
4227
|
+
return obj;
|
|
4228
|
+
}
|
|
4229
|
+
const newObj = {};
|
|
4230
|
+
for (const key of Object.keys(obj)) {
|
|
4231
|
+
if (key !== keyToRemove) {
|
|
4232
|
+
newObj[key] = omitKeyDeep(obj[key], keyToRemove);
|
|
4233
|
+
}
|
|
4234
|
+
}
|
|
4235
|
+
return newObj;
|
|
4236
|
+
}
|
|
4237
|
+
|
|
4050
4238
|
// ../commons/src/events/utils.ts
|
|
4051
4239
|
var import_lodash4 = require("lodash");
|
|
4052
4240
|
|
|
@@ -4056,954 +4244,275 @@ var import_ajv_formats = __toESM(require("ajv-formats"));
|
|
|
4056
4244
|
var z34 = __toESM(require("zod/v4"));
|
|
4057
4245
|
var import_date_fns2 = require("date-fns");
|
|
4058
4246
|
|
|
4059
|
-
// ../commons/src/
|
|
4060
|
-
var
|
|
4061
|
-
|
|
4062
|
-
|
|
4063
|
-
|
|
4064
|
-
|
|
4065
|
-
|
|
4066
|
-
|
|
4067
|
-
|
|
4068
|
-
|
|
4069
|
-
|
|
4070
|
-
|
|
4071
|
-
|
|
4247
|
+
// ../commons/src/conditionals/conditionals.ts
|
|
4248
|
+
var objectHash = __toESM(require("object-hash"));
|
|
4249
|
+
function defineConditional(schema) {
|
|
4250
|
+
const schemaWithooutIDRef = omitKeyDeep(schema, "$id");
|
|
4251
|
+
return {
|
|
4252
|
+
$id: `https://opencrvs.org/conditionals/${objectHash.sha1(schemaWithooutIDRef)}`,
|
|
4253
|
+
...schemaWithooutIDRef
|
|
4254
|
+
};
|
|
4255
|
+
}
|
|
4256
|
+
function defineFormConditional(schema) {
|
|
4257
|
+
const schemaWithForm = {
|
|
4258
|
+
type: "object",
|
|
4259
|
+
properties: {
|
|
4260
|
+
$form: schema
|
|
4261
|
+
},
|
|
4262
|
+
required: ["$form"]
|
|
4263
|
+
};
|
|
4264
|
+
return defineConditional(schemaWithForm);
|
|
4265
|
+
}
|
|
4266
|
+
function alwaysTrue() {
|
|
4267
|
+
return {};
|
|
4268
|
+
}
|
|
4269
|
+
function and(...conditions) {
|
|
4270
|
+
return defineConditional({
|
|
4271
|
+
type: "object",
|
|
4272
|
+
allOf: conditions,
|
|
4273
|
+
required: []
|
|
4072
4274
|
});
|
|
4073
4275
|
}
|
|
4074
|
-
function
|
|
4075
|
-
|
|
4076
|
-
|
|
4077
|
-
|
|
4078
|
-
|
|
4079
|
-
return true;
|
|
4080
|
-
}
|
|
4081
|
-
const submittedKeys = Object.keys(arg.streetLevelDetails ?? {});
|
|
4082
|
-
const invalidKeys = submittedKeys.filter((k) => !configIds.includes(k));
|
|
4083
|
-
if (invalidKeys.length) {
|
|
4084
|
-
console.log(
|
|
4085
|
-
"Invalid streetLevelDetails: unknown keys",
|
|
4086
|
-
JSON.stringify(invalidKeys, null, 2)
|
|
4087
|
-
);
|
|
4088
|
-
return false;
|
|
4089
|
-
}
|
|
4090
|
-
return true;
|
|
4276
|
+
function or(...conditions) {
|
|
4277
|
+
return defineConditional({
|
|
4278
|
+
type: "object",
|
|
4279
|
+
anyOf: conditions,
|
|
4280
|
+
required: []
|
|
4091
4281
|
});
|
|
4092
4282
|
}
|
|
4093
|
-
|
|
4094
|
-
|
|
4095
|
-
|
|
4096
|
-
|
|
4097
|
-
|
|
4098
|
-
|
|
4099
|
-
schema = z32.object(
|
|
4100
|
-
field3.fields.reduce((acc, subfield) => {
|
|
4101
|
-
acc[subfield.id] = mapFieldTypeToZod(subfield, actionType);
|
|
4102
|
-
return acc;
|
|
4103
|
-
}, {})
|
|
4104
|
-
);
|
|
4105
|
-
break;
|
|
4106
|
-
}
|
|
4107
|
-
case FieldType.DATE:
|
|
4108
|
-
schema = PlainDate;
|
|
4109
|
-
break;
|
|
4110
|
-
case FieldType.AGE:
|
|
4111
|
-
schema = AgeValue;
|
|
4112
|
-
break;
|
|
4113
|
-
case FieldType.TIME:
|
|
4114
|
-
schema = TimeValue;
|
|
4115
|
-
break;
|
|
4116
|
-
case FieldType.EMAIL:
|
|
4117
|
-
schema = EmailValue;
|
|
4118
|
-
break;
|
|
4119
|
-
case FieldType.DATE_RANGE:
|
|
4120
|
-
schema = DateRangeFieldValue;
|
|
4121
|
-
break;
|
|
4122
|
-
case FieldType.SELECT_DATE_RANGE:
|
|
4123
|
-
schema = SelectDateRangeValue;
|
|
4124
|
-
break;
|
|
4125
|
-
case FieldType.TEXT:
|
|
4126
|
-
case FieldType.TEXTAREA:
|
|
4127
|
-
case FieldType.DIVIDER:
|
|
4128
|
-
case FieldType.BULLET_LIST:
|
|
4129
|
-
case FieldType.PAGE_HEADER:
|
|
4130
|
-
case FieldType.LOCATION:
|
|
4131
|
-
case FieldType.SELECT:
|
|
4132
|
-
case FieldType.COUNTRY:
|
|
4133
|
-
case FieldType.RADIO_GROUP:
|
|
4134
|
-
case FieldType.PARAGRAPH:
|
|
4135
|
-
case FieldType.HEADING:
|
|
4136
|
-
case FieldType.IMAGE_VIEW:
|
|
4137
|
-
case FieldType.ADMINISTRATIVE_AREA:
|
|
4138
|
-
case FieldType.FACILITY:
|
|
4139
|
-
case FieldType.OFFICE:
|
|
4140
|
-
case FieldType.PHONE:
|
|
4141
|
-
case FieldType.LINK_BUTTON:
|
|
4142
|
-
case FieldType.VERIFICATION_STATUS:
|
|
4143
|
-
case FieldType.ID:
|
|
4144
|
-
case FieldType.LOADER:
|
|
4145
|
-
case FieldType.ALPHA_HIDDEN:
|
|
4146
|
-
case FieldType.USER_ROLE:
|
|
4147
|
-
schema = field3.required ? NonEmptyTextValue : TextValue;
|
|
4148
|
-
break;
|
|
4149
|
-
case FieldType.NUMBER:
|
|
4150
|
-
schema = NumberFieldValue;
|
|
4151
|
-
break;
|
|
4152
|
-
case FieldType.NUMBER_WITH_UNIT:
|
|
4153
|
-
schema = field3.required ? NumberWithUnitFieldValue : NumberWithUnitFieldUpdateValue;
|
|
4154
|
-
break;
|
|
4155
|
-
case FieldType.CHECKBOX:
|
|
4156
|
-
schema = CheckboxFieldValue;
|
|
4157
|
-
break;
|
|
4158
|
-
case FieldType.SIGNATURE:
|
|
4159
|
-
case FieldType.FILE:
|
|
4160
|
-
schema = FileFieldValue;
|
|
4161
|
-
break;
|
|
4162
|
-
case FieldType.FILE_WITH_OPTIONS:
|
|
4163
|
-
schema = field3.required ? FileFieldWithOptionValue.min(1) : FileFieldWithOptionValue;
|
|
4164
|
-
break;
|
|
4165
|
-
case FieldType.ADDRESS:
|
|
4166
|
-
schema = getDynamicAddressFieldValue(field3);
|
|
4167
|
-
break;
|
|
4168
|
-
case FieldType.DATA:
|
|
4169
|
-
schema = DataFieldValue;
|
|
4170
|
-
break;
|
|
4171
|
-
case FieldType.NAME:
|
|
4172
|
-
schema = actionType === ActionType.NOTIFY ? NameFieldUpdateValue : getDynamicNameValue(field3);
|
|
4173
|
-
break;
|
|
4174
|
-
case FieldType.BUTTON:
|
|
4175
|
-
schema = ButtonFieldValue;
|
|
4176
|
-
break;
|
|
4177
|
-
case FieldType.ALPHA_PRINT_BUTTON:
|
|
4178
|
-
schema = TextValue;
|
|
4179
|
-
break;
|
|
4180
|
-
case FieldType.AUTOCOMPLETE:
|
|
4181
|
-
schema = AutocompleteValue;
|
|
4182
|
-
break;
|
|
4183
|
-
case FieldType.HTTP:
|
|
4184
|
-
case FieldType.SEARCH:
|
|
4185
|
-
schema = HttpFieldUpdateValue;
|
|
4186
|
-
break;
|
|
4187
|
-
case FieldType.QUERY_PARAM_READER:
|
|
4188
|
-
schema = QueryParamReaderFieldUpdateValue;
|
|
4189
|
-
break;
|
|
4190
|
-
case FieldType.QR_READER:
|
|
4191
|
-
schema = QrReaderFieldValue;
|
|
4192
|
-
break;
|
|
4193
|
-
case FieldType.ID_READER:
|
|
4194
|
-
schema = IdReaderFieldValue;
|
|
4195
|
-
break;
|
|
4196
|
-
case FieldType._EXPERIMENTAL_CUSTOM:
|
|
4197
|
-
schema = CustomFieldValue;
|
|
4198
|
-
break;
|
|
4199
|
-
}
|
|
4200
|
-
return field3.required ? schema : schema.nullish();
|
|
4283
|
+
function not(condition) {
|
|
4284
|
+
return defineConditional({
|
|
4285
|
+
type: "object",
|
|
4286
|
+
not: condition,
|
|
4287
|
+
required: []
|
|
4288
|
+
});
|
|
4201
4289
|
}
|
|
4202
|
-
function
|
|
4203
|
-
|
|
4204
|
-
case FieldType.FIELD_GROUP:
|
|
4205
|
-
const nestedEmpty = field3.fields.reduce(
|
|
4206
|
-
(acc, subfield) => ({
|
|
4207
|
-
...acc,
|
|
4208
|
-
[subfield.id]: mapFieldTypeToEmptyValue(subfield)
|
|
4209
|
-
}),
|
|
4210
|
-
{}
|
|
4211
|
-
);
|
|
4212
|
-
return nestedEmpty;
|
|
4213
|
-
case FieldType.DIVIDER:
|
|
4214
|
-
case FieldType.TEXT:
|
|
4215
|
-
case FieldType.TEXTAREA:
|
|
4216
|
-
case FieldType.BULLET_LIST:
|
|
4217
|
-
case FieldType.PAGE_HEADER:
|
|
4218
|
-
case FieldType.LOCATION:
|
|
4219
|
-
case FieldType.SELECT:
|
|
4220
|
-
case FieldType.COUNTRY:
|
|
4221
|
-
case FieldType.RADIO_GROUP:
|
|
4222
|
-
case FieldType.PARAGRAPH:
|
|
4223
|
-
case FieldType.HEADING:
|
|
4224
|
-
case FieldType.IMAGE_VIEW:
|
|
4225
|
-
case FieldType.ADMINISTRATIVE_AREA:
|
|
4226
|
-
case FieldType.FACILITY:
|
|
4227
|
-
case FieldType.OFFICE:
|
|
4228
|
-
case FieldType.NUMBER:
|
|
4229
|
-
case FieldType.NUMBER_WITH_UNIT:
|
|
4230
|
-
case FieldType.EMAIL:
|
|
4231
|
-
case FieldType.DATE:
|
|
4232
|
-
case FieldType.AGE:
|
|
4233
|
-
case FieldType.TIME:
|
|
4234
|
-
case FieldType.CHECKBOX:
|
|
4235
|
-
case FieldType.DATE_RANGE:
|
|
4236
|
-
case FieldType.SELECT_DATE_RANGE:
|
|
4237
|
-
case FieldType.DATA:
|
|
4238
|
-
case FieldType.NAME:
|
|
4239
|
-
case FieldType.PHONE:
|
|
4240
|
-
case FieldType.BUTTON:
|
|
4241
|
-
case FieldType.ALPHA_PRINT_BUTTON:
|
|
4242
|
-
case FieldType.HTTP:
|
|
4243
|
-
case FieldType.AUTOCOMPLETE:
|
|
4244
|
-
case FieldType.SEARCH:
|
|
4245
|
-
case FieldType.LINK_BUTTON:
|
|
4246
|
-
case FieldType.QUERY_PARAM_READER:
|
|
4247
|
-
case FieldType.ID:
|
|
4248
|
-
case FieldType.VERIFICATION_STATUS:
|
|
4249
|
-
case FieldType.QR_READER:
|
|
4250
|
-
case FieldType.ID_READER:
|
|
4251
|
-
case FieldType.LOADER:
|
|
4252
|
-
case FieldType.ALPHA_HIDDEN:
|
|
4253
|
-
case FieldType.USER_ROLE:
|
|
4254
|
-
return null;
|
|
4255
|
-
case FieldType.ADDRESS:
|
|
4256
|
-
return {
|
|
4257
|
-
country: "",
|
|
4258
|
-
addressType: AddressType.DOMESTIC,
|
|
4259
|
-
administrativeArea: "",
|
|
4260
|
-
streetLevelDetails: {}
|
|
4261
|
-
};
|
|
4262
|
-
case FieldType.SIGNATURE:
|
|
4263
|
-
case FieldType.FILE:
|
|
4264
|
-
return {
|
|
4265
|
-
path: "",
|
|
4266
|
-
originalFilename: "",
|
|
4267
|
-
type: ""
|
|
4268
|
-
};
|
|
4269
|
-
case FieldType.FILE_WITH_OPTIONS:
|
|
4270
|
-
return [];
|
|
4271
|
-
case FieldType._EXPERIMENTAL_CUSTOM:
|
|
4272
|
-
return void 0;
|
|
4273
|
-
}
|
|
4290
|
+
function never2() {
|
|
4291
|
+
return not(alwaysTrue());
|
|
4274
4292
|
}
|
|
4275
|
-
|
|
4276
|
-
return
|
|
4277
|
-
};
|
|
4278
|
-
var isHeadingFieldType = (field3) => {
|
|
4279
|
-
return field3.config.type === FieldType.HEADING;
|
|
4280
|
-
};
|
|
4281
|
-
var isImageViewFieldType = (field3) => {
|
|
4282
|
-
return field3.config.type === FieldType.IMAGE_VIEW;
|
|
4283
|
-
};
|
|
4284
|
-
var isDateFieldType = (field3) => {
|
|
4285
|
-
return field3.config.type === FieldType.DATE;
|
|
4286
|
-
};
|
|
4287
|
-
var isAgeFieldType = (field3) => {
|
|
4288
|
-
return field3.config.type === FieldType.AGE;
|
|
4289
|
-
};
|
|
4290
|
-
var isTimeFieldType = (field3) => {
|
|
4291
|
-
return field3.config.type === FieldType.TIME;
|
|
4292
|
-
};
|
|
4293
|
-
var isDateRangeFieldType = (field3) => {
|
|
4294
|
-
return field3.config.type === FieldType.DATE_RANGE;
|
|
4295
|
-
};
|
|
4296
|
-
var isSelectDateRangeFieldType = (field3) => {
|
|
4297
|
-
return field3.config.type === FieldType.SELECT_DATE_RANGE;
|
|
4298
|
-
};
|
|
4299
|
-
var isPageHeaderFieldType = (field3) => {
|
|
4300
|
-
return field3.config.type === FieldType.PAGE_HEADER;
|
|
4301
|
-
};
|
|
4302
|
-
var isTextFieldType = (field3) => {
|
|
4303
|
-
return field3.config.type === FieldType.TEXT;
|
|
4304
|
-
};
|
|
4305
|
-
var isNumberFieldType = (field3) => {
|
|
4306
|
-
return field3.config.type === FieldType.NUMBER;
|
|
4307
|
-
};
|
|
4308
|
-
var isNumberWithUnitFieldType = (field3) => {
|
|
4309
|
-
return field3.config.type === FieldType.NUMBER_WITH_UNIT;
|
|
4310
|
-
};
|
|
4311
|
-
var isNameFieldType = (field3) => {
|
|
4312
|
-
return field3.config.type === FieldType.NAME;
|
|
4313
|
-
};
|
|
4314
|
-
var isPhoneFieldType = (field3) => {
|
|
4315
|
-
return field3.config.type === FieldType.PHONE;
|
|
4316
|
-
};
|
|
4317
|
-
var isIdFieldType = (field3) => {
|
|
4318
|
-
return field3.config.type === FieldType.ID;
|
|
4319
|
-
};
|
|
4320
|
-
var isTextAreaFieldType = (field3) => {
|
|
4321
|
-
return field3.config.type === FieldType.TEXTAREA;
|
|
4322
|
-
};
|
|
4323
|
-
var isSignatureFieldType = (field3) => {
|
|
4324
|
-
return field3.config.type === FieldType.SIGNATURE;
|
|
4325
|
-
};
|
|
4326
|
-
var isEmailFieldType = (field3) => {
|
|
4327
|
-
return field3.config.type === FieldType.EMAIL;
|
|
4328
|
-
};
|
|
4329
|
-
var isFileFieldType = (field3) => {
|
|
4330
|
-
return field3.config.type === FieldType.FILE;
|
|
4331
|
-
};
|
|
4332
|
-
var isFileFieldWithOptionType = (field3) => {
|
|
4333
|
-
return field3.config.type === FieldType.FILE_WITH_OPTIONS;
|
|
4334
|
-
};
|
|
4335
|
-
var isBulletListFieldType = (field3) => {
|
|
4336
|
-
return field3.config.type === FieldType.BULLET_LIST;
|
|
4337
|
-
};
|
|
4338
|
-
var isSelectFieldType = (field3) => {
|
|
4339
|
-
return field3.config.type === FieldType.SELECT;
|
|
4340
|
-
};
|
|
4341
|
-
var isAddressFieldType = (field3) => {
|
|
4342
|
-
return field3.config.type === FieldType.ADDRESS;
|
|
4343
|
-
};
|
|
4344
|
-
var isCountryFieldType = (field3) => {
|
|
4345
|
-
return field3.config.type === FieldType.COUNTRY;
|
|
4346
|
-
};
|
|
4347
|
-
var isCheckboxFieldType = (field3) => {
|
|
4348
|
-
return field3.config.type === FieldType.CHECKBOX;
|
|
4349
|
-
};
|
|
4350
|
-
var isRadioGroupFieldType = (field3) => {
|
|
4351
|
-
return field3.config.type === FieldType.RADIO_GROUP;
|
|
4352
|
-
};
|
|
4353
|
-
var isFieldGroupFieldType = (field3) => {
|
|
4354
|
-
return field3.config.type === FieldType.FIELD_GROUP;
|
|
4355
|
-
};
|
|
4356
|
-
var isLocationFieldType = (field3) => {
|
|
4357
|
-
return field3.config.type === FieldType.LOCATION;
|
|
4358
|
-
};
|
|
4359
|
-
var isDividerFieldType = (field3) => {
|
|
4360
|
-
return field3.config.type === FieldType.DIVIDER;
|
|
4361
|
-
};
|
|
4362
|
-
var isAdministrativeAreaFieldType = (field3) => {
|
|
4363
|
-
return field3.config.type === FieldType.ADMINISTRATIVE_AREA;
|
|
4364
|
-
};
|
|
4365
|
-
var isFacilityFieldType = (field3) => {
|
|
4366
|
-
return field3.config.type === FieldType.FACILITY;
|
|
4367
|
-
};
|
|
4368
|
-
var isOfficeFieldType = (field3) => {
|
|
4369
|
-
return field3.config.type === FieldType.OFFICE;
|
|
4370
|
-
};
|
|
4371
|
-
var isDataFieldType = (field3) => {
|
|
4372
|
-
return field3.config.type === FieldType.DATA;
|
|
4373
|
-
};
|
|
4374
|
-
var isButtonFieldType = (field3) => {
|
|
4375
|
-
return field3.config.type === FieldType.BUTTON;
|
|
4376
|
-
};
|
|
4377
|
-
var isPrintButtonFieldType = (field3) => {
|
|
4378
|
-
return field3.config.type === FieldType.ALPHA_PRINT_BUTTON;
|
|
4379
|
-
};
|
|
4380
|
-
var isHttpFieldType = (field3) => {
|
|
4381
|
-
return field3.config.type === FieldType.HTTP;
|
|
4382
|
-
};
|
|
4383
|
-
var isAutocompleteFieldType = (field3) => {
|
|
4384
|
-
return field3.config.type === FieldType.AUTOCOMPLETE;
|
|
4385
|
-
};
|
|
4386
|
-
var isSearchFieldType = (field3) => {
|
|
4387
|
-
return field3.config.type === FieldType.SEARCH;
|
|
4388
|
-
};
|
|
4389
|
-
var isLinkButtonFieldType = (field3) => {
|
|
4390
|
-
return field3.config.type === FieldType.LINK_BUTTON;
|
|
4391
|
-
};
|
|
4392
|
-
var isVerificationStatusType = (field3) => {
|
|
4393
|
-
return field3.config.type === FieldType.VERIFICATION_STATUS;
|
|
4394
|
-
};
|
|
4395
|
-
var isQueryParamReaderFieldType = (field3) => {
|
|
4396
|
-
return field3.config.type === FieldType.QUERY_PARAM_READER;
|
|
4397
|
-
};
|
|
4398
|
-
var isQrReaderFieldType = (field3) => {
|
|
4399
|
-
return field3.config.type === FieldType.QR_READER;
|
|
4400
|
-
};
|
|
4401
|
-
var isIdReaderFieldType = (field3) => {
|
|
4402
|
-
return field3.config.type === FieldType.ID_READER;
|
|
4403
|
-
};
|
|
4404
|
-
var isLoaderFieldType = (field3) => {
|
|
4405
|
-
return field3.config.type === FieldType.LOADER;
|
|
4406
|
-
};
|
|
4407
|
-
var isCustomFieldType = (field3) => {
|
|
4408
|
-
return field3.config.type === FieldType._EXPERIMENTAL_CUSTOM;
|
|
4409
|
-
};
|
|
4410
|
-
var isUserRoleFieldType = (field3) => {
|
|
4411
|
-
return field3.config.type === FieldType.USER_ROLE;
|
|
4412
|
-
};
|
|
4413
|
-
var isHiddenFieldType = (field3) => {
|
|
4414
|
-
return field3.config.type === FieldType.ALPHA_HIDDEN;
|
|
4415
|
-
};
|
|
4416
|
-
var isNonInteractiveFieldType = (field3) => {
|
|
4417
|
-
return field3.type === FieldType.DIVIDER || field3.type === FieldType.PAGE_HEADER || field3.type === FieldType.PARAGRAPH || field3.type === FieldType.HEADING || field3.type === FieldType.BULLET_LIST || field3.type === FieldType.DATA || field3.type === FieldType.ALPHA_PRINT_BUTTON || field3.type === FieldType.LINK_BUTTON || field3.type === FieldType.LOADER;
|
|
4418
|
-
};
|
|
4419
|
-
|
|
4420
|
-
// ../commons/src/events/state/index.ts
|
|
4421
|
-
var import_lodash3 = require("lodash");
|
|
4422
|
-
|
|
4423
|
-
// ../commons/src/utils.ts
|
|
4424
|
-
var z33 = __toESM(require("zod/v4"));
|
|
4425
|
-
var _ = __toESM(require("lodash"));
|
|
4426
|
-
function getOrThrow(x, message) {
|
|
4427
|
-
if (x === void 0 || x === null) {
|
|
4428
|
-
throw new Error(message);
|
|
4429
|
-
}
|
|
4430
|
-
return x;
|
|
4293
|
+
function always() {
|
|
4294
|
+
return defineConditional(alwaysTrue());
|
|
4431
4295
|
}
|
|
4432
|
-
function
|
|
4433
|
-
return
|
|
4296
|
+
function jsonFieldPath(field3) {
|
|
4297
|
+
return [field3.$$field, ...field3.$$subfield].join("/");
|
|
4434
4298
|
}
|
|
4435
|
-
|
|
4436
|
-
|
|
4437
|
-
|
|
4438
|
-
family: z33.string(),
|
|
4439
|
-
given: z33.array(z33.string())
|
|
4440
|
-
})
|
|
4441
|
-
);
|
|
4442
|
-
function omitKeyDeep(obj, keyToRemove) {
|
|
4443
|
-
if (Array.isArray(obj)) {
|
|
4444
|
-
return obj.map((item) => omitKeyDeep(item, keyToRemove));
|
|
4445
|
-
}
|
|
4446
|
-
if (obj === null || typeof obj !== "object") {
|
|
4447
|
-
return obj;
|
|
4448
|
-
}
|
|
4449
|
-
const newObj = {};
|
|
4450
|
-
for (const key of Object.keys(obj)) {
|
|
4451
|
-
if (key !== keyToRemove) {
|
|
4452
|
-
newObj[key] = omitKeyDeep(obj[key], keyToRemove);
|
|
4453
|
-
}
|
|
4299
|
+
function wrapToPath(condition, path) {
|
|
4300
|
+
if (path.length === 0) {
|
|
4301
|
+
return condition;
|
|
4454
4302
|
}
|
|
4455
|
-
return
|
|
4303
|
+
return path.reduceRight((conditionNow, part) => {
|
|
4304
|
+
return {
|
|
4305
|
+
type: "object",
|
|
4306
|
+
properties: {
|
|
4307
|
+
[part]: conditionNow
|
|
4308
|
+
},
|
|
4309
|
+
required: [part]
|
|
4310
|
+
};
|
|
4311
|
+
}, condition);
|
|
4456
4312
|
}
|
|
4457
|
-
|
|
4458
|
-
|
|
4459
|
-
|
|
4460
|
-
function getActionRequests(actionType, actions) {
|
|
4461
|
-
const filtered = actions.filter((action) => action.type === actionType).reverse();
|
|
4462
|
-
const accept = filtered.find(
|
|
4463
|
-
(action) => action.status === ActionStatus.Accepted
|
|
4464
|
-
);
|
|
4465
|
-
const request = filtered.find(
|
|
4466
|
-
(action) => action.status === ActionStatus.Requested
|
|
4467
|
-
);
|
|
4468
|
-
const reject = filtered.find(
|
|
4469
|
-
(action) => action.status === ActionStatus.Rejected
|
|
4470
|
-
);
|
|
4471
|
-
return {
|
|
4472
|
-
reject,
|
|
4473
|
-
accept,
|
|
4474
|
-
request
|
|
4475
|
-
};
|
|
4476
|
-
}
|
|
4477
|
-
function getDeclarationActionCreationMetadata(actionType, actions) {
|
|
4478
|
-
const { accept: acceptAction, request: requestAction } = getActionRequests(
|
|
4479
|
-
actionType,
|
|
4480
|
-
actions
|
|
4481
|
-
);
|
|
4482
|
-
if (!acceptAction) {
|
|
4483
|
-
return null;
|
|
4313
|
+
function wrapToPathOptional(condition, path) {
|
|
4314
|
+
if (path.length === 0) {
|
|
4315
|
+
return condition;
|
|
4484
4316
|
}
|
|
4485
|
-
|
|
4486
|
-
|
|
4487
|
-
|
|
4488
|
-
|
|
4489
|
-
|
|
4490
|
-
|
|
4491
|
-
createdAtLocation: requestAction?.createdAtLocation ?? acceptAction.createdAtLocation,
|
|
4492
|
-
acceptedAt: acceptAction.createdAt,
|
|
4493
|
-
createdByRole: requestAction?.createdByRole ?? acceptAction.createdByRole,
|
|
4494
|
-
registrationNumber
|
|
4495
|
-
};
|
|
4317
|
+
return path.reduceRight((conditionNow, part) => {
|
|
4318
|
+
return {
|
|
4319
|
+
type: "object",
|
|
4320
|
+
properties: { [part]: conditionNow }
|
|
4321
|
+
};
|
|
4322
|
+
}, condition);
|
|
4496
4323
|
}
|
|
4497
|
-
var
|
|
4498
|
-
|
|
4499
|
-
|
|
4500
|
-
|
|
4501
|
-
|
|
4502
|
-
|
|
4503
|
-
|
|
4504
|
-
|
|
4505
|
-
|
|
4506
|
-
|
|
4507
|
-
|
|
4508
|
-
|
|
4509
|
-
|
|
4510
|
-
|
|
4511
|
-
|
|
4512
|
-
|
|
4513
|
-
|
|
4514
|
-
|
|
4515
|
-
const createAction = getOrThrow(
|
|
4516
|
-
actions.find((action) => action.type === ActionType.CREATE),
|
|
4517
|
-
`Event has no ${ActionType.CREATE} action`
|
|
4518
|
-
);
|
|
4519
|
-
const metadataFields = [
|
|
4520
|
-
"createdAt",
|
|
4521
|
-
"createdBy",
|
|
4522
|
-
"createdByUserType",
|
|
4523
|
-
"createdAtLocation",
|
|
4524
|
-
"createdByRole"
|
|
4525
|
-
];
|
|
4526
|
-
return actions.filter(({ type }) => updateActions.has(type)).reduce(
|
|
4527
|
-
(_2, action) => {
|
|
4528
|
-
if (action.originalActionId) {
|
|
4529
|
-
const originalAction = actions.find(({ id }) => id === action.originalActionId) ?? action;
|
|
4530
|
-
return (0, import_lodash.pick)(originalAction, metadataFields);
|
|
4324
|
+
var now = Object.assign(todayDateTimeValueSerializer, {});
|
|
4325
|
+
var user = Object.assign(userSerializer, {
|
|
4326
|
+
...userReferenceFunctions,
|
|
4327
|
+
hasScope: (scope) => defineConditional({
|
|
4328
|
+
type: "object",
|
|
4329
|
+
properties: {
|
|
4330
|
+
$user: {
|
|
4331
|
+
type: "object",
|
|
4332
|
+
required: ["scope"],
|
|
4333
|
+
properties: {
|
|
4334
|
+
scope: {
|
|
4335
|
+
type: "array",
|
|
4336
|
+
contains: {
|
|
4337
|
+
type: "string",
|
|
4338
|
+
const: scope
|
|
4339
|
+
}
|
|
4340
|
+
}
|
|
4341
|
+
}
|
|
4531
4342
|
}
|
|
4532
|
-
return (0, import_lodash.pick)(action, metadataFields);
|
|
4533
4343
|
},
|
|
4534
|
-
|
|
4535
|
-
)
|
|
4344
|
+
required: ["$user"]
|
|
4345
|
+
}),
|
|
4346
|
+
hasRole: (role) => defineConditional({
|
|
4347
|
+
type: "object",
|
|
4348
|
+
properties: {
|
|
4349
|
+
$user: {
|
|
4350
|
+
type: "object",
|
|
4351
|
+
required: ["role"],
|
|
4352
|
+
properties: {
|
|
4353
|
+
role: {
|
|
4354
|
+
type: "string",
|
|
4355
|
+
const: role
|
|
4356
|
+
}
|
|
4357
|
+
}
|
|
4358
|
+
}
|
|
4359
|
+
},
|
|
4360
|
+
required: ["$user"]
|
|
4361
|
+
}),
|
|
4362
|
+
isOnline: () => defineConditional({
|
|
4363
|
+
type: "object",
|
|
4364
|
+
properties: {
|
|
4365
|
+
$online: {
|
|
4366
|
+
type: "boolean",
|
|
4367
|
+
const: true
|
|
4368
|
+
}
|
|
4369
|
+
},
|
|
4370
|
+
required: ["$online"]
|
|
4371
|
+
}),
|
|
4372
|
+
locationLevel: (adminLevelId) => ({
|
|
4373
|
+
$user: { $location: adminLevelId }
|
|
4374
|
+
})
|
|
4375
|
+
});
|
|
4376
|
+
function isFieldReference(value) {
|
|
4377
|
+
return typeof value === "object" && value !== null && "$$field" in value;
|
|
4378
|
+
}
|
|
4379
|
+
function isEventFieldReference(value) {
|
|
4380
|
+
return typeof value === "object" && value !== null && "$$event" in value;
|
|
4536
4381
|
}
|
|
4537
|
-
function
|
|
4382
|
+
function isActionDateReference(value) {
|
|
4383
|
+
return typeof value === "object" && value !== null && "$action" in value;
|
|
4384
|
+
}
|
|
4385
|
+
function getDateRangeToFieldReference(field3, comparedField, clause) {
|
|
4538
4386
|
return {
|
|
4539
|
-
|
|
4540
|
-
|
|
4541
|
-
|
|
4542
|
-
|
|
4543
|
-
|
|
4544
|
-
|
|
4545
|
-
|
|
4546
|
-
|
|
4547
|
-
|
|
4548
|
-
|
|
4549
|
-
|
|
4550
|
-
|
|
4387
|
+
type: "object",
|
|
4388
|
+
properties: {
|
|
4389
|
+
[field3.$$field]: wrapToPath(
|
|
4390
|
+
{
|
|
4391
|
+
type: "string",
|
|
4392
|
+
format: "date",
|
|
4393
|
+
[clause]: {
|
|
4394
|
+
$data: `${field3.$$subfield.length + 1}/${jsonFieldPath(comparedField)}`
|
|
4395
|
+
}
|
|
4396
|
+
},
|
|
4397
|
+
field3.$$subfield
|
|
4398
|
+
),
|
|
4399
|
+
[comparedField.$$field]: wrapToPath(
|
|
4400
|
+
{ type: "string", format: "date" },
|
|
4401
|
+
comparedField.$$subfield
|
|
4402
|
+
)
|
|
4403
|
+
},
|
|
4404
|
+
required: [field3.$$field]
|
|
4551
4405
|
};
|
|
4552
4406
|
}
|
|
4553
|
-
|
|
4554
|
-
|
|
4555
|
-
|
|
4556
|
-
|
|
4557
|
-
|
|
4558
|
-
|
|
4559
|
-
|
|
4560
|
-
|
|
4561
|
-
|
|
4562
|
-
|
|
4563
|
-
|
|
4564
|
-
|
|
4565
|
-
|
|
4566
|
-
|
|
4567
|
-
|
|
4568
|
-
|
|
4569
|
-
|
|
4407
|
+
function getDayRangeToFieldReference(field3, comparedField, days, clause) {
|
|
4408
|
+
return {
|
|
4409
|
+
type: "object",
|
|
4410
|
+
properties: {
|
|
4411
|
+
[field3.$$field]: wrapToPath(
|
|
4412
|
+
{
|
|
4413
|
+
type: "string",
|
|
4414
|
+
format: "date",
|
|
4415
|
+
daysFromDate: {
|
|
4416
|
+
referenceDate: {
|
|
4417
|
+
$data: `${field3.$$subfield.length + 1}/${jsonFieldPath(
|
|
4418
|
+
comparedField
|
|
4419
|
+
)}`
|
|
4420
|
+
},
|
|
4421
|
+
clause,
|
|
4422
|
+
days
|
|
4423
|
+
}
|
|
4424
|
+
},
|
|
4425
|
+
field3.$$subfield
|
|
4426
|
+
),
|
|
4427
|
+
[comparedField.$$field]: wrapToPath(
|
|
4428
|
+
{ type: "string", format: "date" },
|
|
4429
|
+
comparedField.$$subfield
|
|
4430
|
+
)
|
|
4431
|
+
},
|
|
4432
|
+
required: [field3.$$field]
|
|
4433
|
+
};
|
|
4570
4434
|
}
|
|
4571
|
-
function
|
|
4572
|
-
|
|
4573
|
-
|
|
4574
|
-
|
|
4575
|
-
|
|
4576
|
-
|
|
4577
|
-
|
|
4578
|
-
|
|
4579
|
-
|
|
4580
|
-
|
|
4435
|
+
function defineComparison(field3, value, keyword) {
|
|
4436
|
+
if (isFieldReference(value)) {
|
|
4437
|
+
const comparedField = value;
|
|
4438
|
+
return defineFormConditional({
|
|
4439
|
+
type: "object",
|
|
4440
|
+
properties: {
|
|
4441
|
+
[field3.$$field]: wrapToPath(
|
|
4442
|
+
{
|
|
4443
|
+
type: ["number"],
|
|
4444
|
+
[keyword]: {
|
|
4445
|
+
$data: `${field3.$$subfield.length + 1}/${jsonFieldPath(comparedField)}`
|
|
4446
|
+
}
|
|
4447
|
+
},
|
|
4448
|
+
field3.$$subfield
|
|
4449
|
+
),
|
|
4450
|
+
[comparedField.$$field]: wrapToPath(
|
|
4451
|
+
{ type: "number" },
|
|
4452
|
+
comparedField.$$subfield
|
|
4453
|
+
)
|
|
4454
|
+
},
|
|
4455
|
+
required: [field3.$$field]
|
|
4456
|
+
});
|
|
4457
|
+
}
|
|
4458
|
+
return defineFormConditional({
|
|
4459
|
+
type: "object",
|
|
4460
|
+
properties: {
|
|
4461
|
+
[field3.$$field]: wrapToPath(
|
|
4462
|
+
{ type: "number", [keyword]: value },
|
|
4463
|
+
field3.$$subfield
|
|
4464
|
+
)
|
|
4465
|
+
},
|
|
4466
|
+
required: [field3.$$field]
|
|
4467
|
+
});
|
|
4581
4468
|
}
|
|
4582
|
-
function
|
|
4583
|
-
|
|
4584
|
-
return validate(conditional, {
|
|
4585
|
-
$form: form,
|
|
4586
|
-
$now: now2,
|
|
4587
|
-
$online: true,
|
|
4588
|
-
$user: {
|
|
4589
|
-
sub: "",
|
|
4590
|
-
exp: "",
|
|
4591
|
-
role: action.createdByRole,
|
|
4592
|
-
algorithm: "",
|
|
4593
|
-
scope: [],
|
|
4594
|
-
userType: action.createdByUserType
|
|
4595
|
-
}
|
|
4596
|
-
});
|
|
4597
|
-
}
|
|
4598
|
-
function actionConfigRemovesFlag(action, flagId, actionsUpToAndIncluding, event2, eventConfiguration) {
|
|
4599
|
-
if (!isActionConfigType(action.type)) {
|
|
4600
|
-
return false;
|
|
4601
|
-
}
|
|
4602
|
-
const actionConfig = getActionConfig({
|
|
4603
|
-
eventConfiguration,
|
|
4604
|
-
actionType: action.type,
|
|
4605
|
-
customActionType: "customActionType" in action ? action.customActionType : void 0
|
|
4606
|
-
});
|
|
4607
|
-
const removeOperations = (actionConfig?.flags ?? []).filter(
|
|
4608
|
-
({ id, operation }) => id === flagId && operation === "remove"
|
|
4609
|
-
);
|
|
4610
|
-
if (removeOperations.length === 0) {
|
|
4611
|
-
return false;
|
|
4612
|
-
}
|
|
4613
|
-
const eventUpToThisAction = { ...event2, actions: actionsUpToAndIncluding };
|
|
4614
|
-
const declaration = aggregateActionDeclarations(eventUpToThisAction);
|
|
4615
|
-
const annotation = aggregateActionAnnotations(eventUpToThisAction);
|
|
4616
|
-
const form = { ...declaration, ...annotation };
|
|
4617
|
-
return removeOperations.some(
|
|
4618
|
-
({ conditional }) => conditional ? isFlagConditionMet(conditional, form, action) : true
|
|
4619
|
-
);
|
|
4620
|
-
}
|
|
4621
|
-
var INHERENT_FLAG_RULES = [
|
|
4622
|
-
{
|
|
4623
|
-
flag: InherentFlags.CORRECTION_REQUESTED,
|
|
4624
|
-
setOn: [ActionType.REQUEST_CORRECTION],
|
|
4625
|
-
resetOn: [ActionType.APPROVE_CORRECTION, ActionType.REJECT_CORRECTION]
|
|
4626
|
-
},
|
|
4627
|
-
{
|
|
4628
|
-
// INCOMPLETE mirrors the NOTIFIED status: set by NOTIFY, cleared by any
|
|
4629
|
-
// other status-changing action (see getStatusFromActions). ARCHIVE/UNARCHIVE
|
|
4630
|
-
// are deliberately excluded so the flag freezes across an archive/unarchive
|
|
4631
|
-
// round trip and comes back exactly as it was.
|
|
4632
|
-
flag: InherentFlags.INCOMPLETE,
|
|
4633
|
-
setOn: [ActionType.NOTIFY],
|
|
4634
|
-
resetOn: [ActionType.CREATE, ActionType.DECLARE, ActionType.REGISTER]
|
|
4635
|
-
},
|
|
4636
|
-
{
|
|
4637
|
-
flag: InherentFlags.REJECTED,
|
|
4638
|
-
setOn: [ActionType.REJECT],
|
|
4639
|
-
resetOn: [
|
|
4640
|
-
ActionType.NOTIFY,
|
|
4641
|
-
ActionType.DECLARE,
|
|
4642
|
-
ActionType.EDIT,
|
|
4643
|
-
ActionType.REGISTER
|
|
4644
|
-
]
|
|
4645
|
-
},
|
|
4646
|
-
{
|
|
4647
|
-
flag: InherentFlags.POTENTIAL_DUPLICATE,
|
|
4648
|
-
setOn: [ActionType.DUPLICATE_DETECTED],
|
|
4649
|
-
resetOn: [ActionType.MARK_AS_DUPLICATE, ActionType.MARK_AS_NOT_DUPLICATE]
|
|
4650
|
-
},
|
|
4651
|
-
{
|
|
4652
|
-
flag: InherentFlags.EDIT_IN_PROGRESS,
|
|
4653
|
-
setOn: [ActionType.EDIT],
|
|
4654
|
-
resetOnAnyOtherAction: true
|
|
4655
|
-
}
|
|
4656
|
-
];
|
|
4657
|
-
function resolveInherentFlag(rule, acceptedActions, event2, eventConfiguration) {
|
|
4658
|
-
return acceptedActions.reduce((present, action, idx) => {
|
|
4659
|
-
if (rule.setOn.includes(action.type)) {
|
|
4660
|
-
return true;
|
|
4661
|
-
}
|
|
4662
|
-
if (rule.resetOnAnyOtherAction || (rule.resetOn ?? []).includes(action.type)) {
|
|
4663
|
-
return false;
|
|
4664
|
-
}
|
|
4665
|
-
if (actionConfigRemovesFlag(
|
|
4666
|
-
action,
|
|
4667
|
-
rule.flag,
|
|
4668
|
-
acceptedActions.slice(0, idx + 1),
|
|
4669
|
-
event2,
|
|
4670
|
-
eventConfiguration
|
|
4671
|
-
)) {
|
|
4672
|
-
return false;
|
|
4673
|
-
}
|
|
4674
|
-
return present;
|
|
4675
|
-
}, false);
|
|
4676
|
-
}
|
|
4677
|
-
function resolveEventCustomFlags(event2, eventConfiguration) {
|
|
4678
|
-
const actions = getAcceptedActions(event2).filter(({ type }) => !isMetaAction(type)).sort((a, b) => a.createdAt.localeCompare(b.createdAt));
|
|
4679
|
-
const declarations = getDeclarationAfterEachAction({ ...event2, actions });
|
|
4680
|
-
let annotation = {};
|
|
4681
|
-
return actions.reduce((acc, action, idx) => {
|
|
4682
|
-
if (action.annotation) {
|
|
4683
|
-
annotation = deepMerge(annotation, action.annotation);
|
|
4684
|
-
}
|
|
4685
|
-
let actionConfig;
|
|
4686
|
-
if (isActionConfigType(action.type)) {
|
|
4687
|
-
actionConfig = getActionConfig({
|
|
4688
|
-
eventConfiguration,
|
|
4689
|
-
actionType: action.type,
|
|
4690
|
-
customActionType: "customActionType" in action ? action.customActionType : void 0
|
|
4691
|
-
});
|
|
4692
|
-
}
|
|
4693
|
-
if (!actionConfig) {
|
|
4694
|
-
return acc;
|
|
4695
|
-
}
|
|
4696
|
-
const form = { ...declarations[idx], ...annotation };
|
|
4697
|
-
const flagsWithMetConditions = (actionConfig.flags ?? []).filter(
|
|
4698
|
-
({ conditional }) => (
|
|
4699
|
-
// If conditional is not provided, the flag is resolved
|
|
4700
|
-
conditional ? isFlagConditionMet(conditional, form, action) : true
|
|
4701
|
-
)
|
|
4702
|
-
);
|
|
4703
|
-
const addedFlags = flagsWithMetConditions.filter(({ operation }) => operation === "add").map(({ id }) => id);
|
|
4704
|
-
const removedFlags = flagsWithMetConditions.filter(({ operation }) => operation === "remove").map(({ id }) => id);
|
|
4705
|
-
const flags = [...acc, ...addedFlags].filter(
|
|
4706
|
-
(flagId) => !removedFlags.includes(flagId)
|
|
4707
|
-
);
|
|
4708
|
-
return (0, import_lodash2.uniq)(flags);
|
|
4709
|
-
}, []);
|
|
4710
|
-
}
|
|
4711
|
-
function getActionStatusFlags(sortedActions) {
|
|
4712
|
-
const actionStatus = sortedActions.reduce(
|
|
4713
|
-
(actionStatuses, { type, status: status2 }) => ({
|
|
4714
|
-
...actionStatuses,
|
|
4715
|
-
[type]: status2
|
|
4716
|
-
}),
|
|
4717
|
-
{}
|
|
4718
|
-
);
|
|
4719
|
-
return Object.entries(actionStatus).filter(([, status2]) => status2 !== ActionStatus.Accepted).map(([type, status2]) => {
|
|
4720
|
-
const flag2 = joinValues([type, status2], ":").toLowerCase();
|
|
4721
|
-
return flag2;
|
|
4722
|
-
});
|
|
4723
|
-
}
|
|
4724
|
-
function getInherentFlags(sortedActions, event2, eventConfiguration) {
|
|
4725
|
-
const acceptedActions = sortedActions.filter(
|
|
4726
|
-
({ status: status2 }) => status2 === ActionStatus.Accepted
|
|
4727
|
-
);
|
|
4728
|
-
return INHERENT_FLAG_RULES.filter(
|
|
4729
|
-
(rule) => resolveInherentFlag(rule, acceptedActions, event2, eventConfiguration)
|
|
4730
|
-
).map(({ flag: flag2 }) => flag2);
|
|
4731
|
-
}
|
|
4732
|
-
function getEventFlags(event2, config) {
|
|
4733
|
-
const sortedActions = event2.actions.filter(({ type }) => !isMetaAction(type)).sort((a, b) => a.createdAt.localeCompare(b.createdAt));
|
|
4734
|
-
return [
|
|
4735
|
-
...getActionStatusFlags(sortedActions),
|
|
4736
|
-
...getInherentFlags(sortedActions, event2, config),
|
|
4737
|
-
...resolveEventCustomFlags(event2, config)
|
|
4738
|
-
];
|
|
4739
|
-
}
|
|
4740
|
-
|
|
4741
|
-
// ../commons/src/conditionals/conditionals.ts
|
|
4742
|
-
var objectHash = __toESM(require("object-hash"));
|
|
4743
|
-
function defineConditional(schema) {
|
|
4744
|
-
const schemaWithooutIDRef = omitKeyDeep(schema, "$id");
|
|
4745
|
-
return {
|
|
4746
|
-
$id: `https://opencrvs.org/conditionals/${objectHash.sha1(schemaWithooutIDRef)}`,
|
|
4747
|
-
...schemaWithooutIDRef
|
|
4748
|
-
};
|
|
4749
|
-
}
|
|
4750
|
-
function defineFormConditional(schema) {
|
|
4751
|
-
const schemaWithForm = {
|
|
4469
|
+
function flag(flagvalue) {
|
|
4470
|
+
return defineConditional({
|
|
4752
4471
|
type: "object",
|
|
4753
4472
|
properties: {
|
|
4754
|
-
$
|
|
4473
|
+
$flags: {
|
|
4474
|
+
type: "array",
|
|
4475
|
+
contains: {
|
|
4476
|
+
type: "string",
|
|
4477
|
+
const: flagvalue
|
|
4478
|
+
}
|
|
4479
|
+
}
|
|
4755
4480
|
},
|
|
4756
|
-
required: ["$
|
|
4757
|
-
};
|
|
4758
|
-
return defineConditional(schemaWithForm);
|
|
4759
|
-
}
|
|
4760
|
-
function alwaysTrue() {
|
|
4761
|
-
return {};
|
|
4762
|
-
}
|
|
4763
|
-
function and(...conditions) {
|
|
4764
|
-
return defineConditional({
|
|
4765
|
-
type: "object",
|
|
4766
|
-
allOf: conditions,
|
|
4767
|
-
required: []
|
|
4481
|
+
required: ["$flags"]
|
|
4768
4482
|
});
|
|
4769
4483
|
}
|
|
4770
|
-
function
|
|
4484
|
+
function status(statusValue) {
|
|
4771
4485
|
return defineConditional({
|
|
4772
4486
|
type: "object",
|
|
4773
|
-
|
|
4774
|
-
|
|
4487
|
+
properties: {
|
|
4488
|
+
$status: {
|
|
4489
|
+
type: "string",
|
|
4490
|
+
const: statusValue
|
|
4491
|
+
}
|
|
4492
|
+
},
|
|
4493
|
+
required: ["$status"]
|
|
4775
4494
|
});
|
|
4776
4495
|
}
|
|
4777
|
-
function
|
|
4778
|
-
|
|
4496
|
+
function createFieldConditionals(fieldId) {
|
|
4497
|
+
const getDayRange = (field3, days, clause, referenceDate) => ({
|
|
4779
4498
|
type: "object",
|
|
4780
|
-
|
|
4781
|
-
|
|
4499
|
+
properties: {
|
|
4500
|
+
[field3.$$field]: wrapToPath(
|
|
4501
|
+
{
|
|
4502
|
+
type: "string",
|
|
4503
|
+
format: "date",
|
|
4504
|
+
daysFromDate: {
|
|
4505
|
+
days,
|
|
4506
|
+
clause,
|
|
4507
|
+
referenceDate
|
|
4508
|
+
}
|
|
4509
|
+
},
|
|
4510
|
+
field3.$$subfield
|
|
4511
|
+
)
|
|
4512
|
+
},
|
|
4513
|
+
required: [field3.$$field]
|
|
4782
4514
|
});
|
|
4783
|
-
|
|
4784
|
-
function never2() {
|
|
4785
|
-
return not(alwaysTrue());
|
|
4786
|
-
}
|
|
4787
|
-
function always() {
|
|
4788
|
-
return defineConditional(alwaysTrue());
|
|
4789
|
-
}
|
|
4790
|
-
function jsonFieldPath(field3) {
|
|
4791
|
-
return [field3.$$field, ...field3.$$subfield].join("/");
|
|
4792
|
-
}
|
|
4793
|
-
function wrapToPath(condition, path) {
|
|
4794
|
-
if (path.length === 0) {
|
|
4795
|
-
return condition;
|
|
4796
|
-
}
|
|
4797
|
-
return path.reduceRight((conditionNow, part) => {
|
|
4798
|
-
return {
|
|
4799
|
-
type: "object",
|
|
4800
|
-
properties: {
|
|
4801
|
-
[part]: conditionNow
|
|
4802
|
-
},
|
|
4803
|
-
required: [part]
|
|
4804
|
-
};
|
|
4805
|
-
}, condition);
|
|
4806
|
-
}
|
|
4807
|
-
function wrapToPathOptional(condition, path) {
|
|
4808
|
-
if (path.length === 0) {
|
|
4809
|
-
return condition;
|
|
4810
|
-
}
|
|
4811
|
-
return path.reduceRight((conditionNow, part) => {
|
|
4812
|
-
return {
|
|
4813
|
-
type: "object",
|
|
4814
|
-
properties: { [part]: conditionNow }
|
|
4815
|
-
};
|
|
4816
|
-
}, condition);
|
|
4817
|
-
}
|
|
4818
|
-
var now = Object.assign(todayDateTimeValueSerializer, {});
|
|
4819
|
-
var user = Object.assign(userSerializer, {
|
|
4820
|
-
...userReferenceFunctions,
|
|
4821
|
-
hasScope: (scope) => defineConditional({
|
|
4822
|
-
type: "object",
|
|
4823
|
-
properties: {
|
|
4824
|
-
$user: {
|
|
4825
|
-
type: "object",
|
|
4826
|
-
required: ["scope"],
|
|
4827
|
-
properties: {
|
|
4828
|
-
scope: {
|
|
4829
|
-
type: "array",
|
|
4830
|
-
contains: {
|
|
4831
|
-
type: "string",
|
|
4832
|
-
const: scope
|
|
4833
|
-
}
|
|
4834
|
-
}
|
|
4835
|
-
}
|
|
4836
|
-
}
|
|
4837
|
-
},
|
|
4838
|
-
required: ["$user"]
|
|
4839
|
-
}),
|
|
4840
|
-
hasRole: (role) => defineConditional({
|
|
4841
|
-
type: "object",
|
|
4842
|
-
properties: {
|
|
4843
|
-
$user: {
|
|
4844
|
-
type: "object",
|
|
4845
|
-
required: ["role"],
|
|
4846
|
-
properties: {
|
|
4847
|
-
role: {
|
|
4848
|
-
type: "string",
|
|
4849
|
-
const: role
|
|
4850
|
-
}
|
|
4851
|
-
}
|
|
4852
|
-
}
|
|
4853
|
-
},
|
|
4854
|
-
required: ["$user"]
|
|
4855
|
-
}),
|
|
4856
|
-
isOnline: () => defineConditional({
|
|
4857
|
-
type: "object",
|
|
4858
|
-
properties: {
|
|
4859
|
-
$online: {
|
|
4860
|
-
type: "boolean",
|
|
4861
|
-
const: true
|
|
4862
|
-
}
|
|
4863
|
-
},
|
|
4864
|
-
required: ["$online"]
|
|
4865
|
-
}),
|
|
4866
|
-
locationLevel: (adminLevelId) => ({
|
|
4867
|
-
$user: { $location: adminLevelId }
|
|
4868
|
-
})
|
|
4869
|
-
});
|
|
4870
|
-
function isFieldReference(value) {
|
|
4871
|
-
return typeof value === "object" && value !== null && "$$field" in value;
|
|
4872
|
-
}
|
|
4873
|
-
function isEventFieldReference(value) {
|
|
4874
|
-
return typeof value === "object" && value !== null && "$$event" in value;
|
|
4875
|
-
}
|
|
4876
|
-
function getDateRangeToFieldReference(field3, comparedField, clause) {
|
|
4877
|
-
return {
|
|
4878
|
-
type: "object",
|
|
4879
|
-
properties: {
|
|
4880
|
-
[field3.$$field]: wrapToPath(
|
|
4881
|
-
{
|
|
4882
|
-
type: "string",
|
|
4883
|
-
format: "date",
|
|
4884
|
-
[clause]: {
|
|
4885
|
-
$data: `${field3.$$subfield.length + 1}/${jsonFieldPath(comparedField)}`
|
|
4886
|
-
}
|
|
4887
|
-
},
|
|
4888
|
-
field3.$$subfield
|
|
4889
|
-
),
|
|
4890
|
-
[comparedField.$$field]: wrapToPath(
|
|
4891
|
-
{ type: "string", format: "date" },
|
|
4892
|
-
comparedField.$$subfield
|
|
4893
|
-
)
|
|
4894
|
-
},
|
|
4895
|
-
required: [field3.$$field]
|
|
4896
|
-
};
|
|
4897
|
-
}
|
|
4898
|
-
function getDayRangeToFieldReference(field3, comparedField, days, clause) {
|
|
4899
|
-
return {
|
|
4900
|
-
type: "object",
|
|
4901
|
-
properties: {
|
|
4902
|
-
[field3.$$field]: wrapToPath(
|
|
4903
|
-
{
|
|
4904
|
-
type: "string",
|
|
4905
|
-
format: "date",
|
|
4906
|
-
daysFromDate: {
|
|
4907
|
-
referenceDate: {
|
|
4908
|
-
$data: `${field3.$$subfield.length + 1}/${jsonFieldPath(
|
|
4909
|
-
comparedField
|
|
4910
|
-
)}`
|
|
4911
|
-
},
|
|
4912
|
-
clause,
|
|
4913
|
-
days
|
|
4914
|
-
}
|
|
4915
|
-
},
|
|
4916
|
-
field3.$$subfield
|
|
4917
|
-
),
|
|
4918
|
-
[comparedField.$$field]: wrapToPath(
|
|
4919
|
-
{ type: "string", format: "date" },
|
|
4920
|
-
comparedField.$$subfield
|
|
4921
|
-
)
|
|
4922
|
-
},
|
|
4923
|
-
required: [field3.$$field]
|
|
4924
|
-
};
|
|
4925
|
-
}
|
|
4926
|
-
function defineComparison(field3, value, keyword) {
|
|
4927
|
-
if (isFieldReference(value)) {
|
|
4928
|
-
const comparedField = value;
|
|
4929
|
-
return defineFormConditional({
|
|
4930
|
-
type: "object",
|
|
4931
|
-
properties: {
|
|
4932
|
-
[field3.$$field]: wrapToPath(
|
|
4933
|
-
{
|
|
4934
|
-
type: ["number"],
|
|
4935
|
-
[keyword]: {
|
|
4936
|
-
$data: `${field3.$$subfield.length + 1}/${jsonFieldPath(comparedField)}`
|
|
4937
|
-
}
|
|
4938
|
-
},
|
|
4939
|
-
field3.$$subfield
|
|
4940
|
-
),
|
|
4941
|
-
[comparedField.$$field]: wrapToPath(
|
|
4942
|
-
{ type: "number" },
|
|
4943
|
-
comparedField.$$subfield
|
|
4944
|
-
)
|
|
4945
|
-
},
|
|
4946
|
-
required: [field3.$$field]
|
|
4947
|
-
});
|
|
4948
|
-
}
|
|
4949
|
-
return defineFormConditional({
|
|
4950
|
-
type: "object",
|
|
4951
|
-
properties: {
|
|
4952
|
-
[field3.$$field]: wrapToPath(
|
|
4953
|
-
{ type: "number", [keyword]: value },
|
|
4954
|
-
field3.$$subfield
|
|
4955
|
-
)
|
|
4956
|
-
},
|
|
4957
|
-
required: [field3.$$field]
|
|
4958
|
-
});
|
|
4959
|
-
}
|
|
4960
|
-
function flag(flagvalue) {
|
|
4961
|
-
return defineConditional({
|
|
4962
|
-
type: "object",
|
|
4963
|
-
properties: {
|
|
4964
|
-
$flags: {
|
|
4965
|
-
type: "array",
|
|
4966
|
-
contains: {
|
|
4967
|
-
type: "string",
|
|
4968
|
-
const: flagvalue
|
|
4969
|
-
}
|
|
4970
|
-
}
|
|
4971
|
-
},
|
|
4972
|
-
required: ["$flags"]
|
|
4973
|
-
});
|
|
4974
|
-
}
|
|
4975
|
-
function status(statusValue) {
|
|
4976
|
-
return defineConditional({
|
|
4977
|
-
type: "object",
|
|
4978
|
-
properties: {
|
|
4979
|
-
$status: {
|
|
4980
|
-
type: "string",
|
|
4981
|
-
const: statusValue
|
|
4982
|
-
}
|
|
4983
|
-
},
|
|
4984
|
-
required: ["$status"]
|
|
4985
|
-
});
|
|
4986
|
-
}
|
|
4987
|
-
function createFieldConditionals(fieldId) {
|
|
4988
|
-
const getDayRange = (field3, days, clause, referenceDate) => ({
|
|
4989
|
-
type: "object",
|
|
4990
|
-
properties: {
|
|
4991
|
-
[field3.$$field]: wrapToPath(
|
|
4992
|
-
{
|
|
4993
|
-
type: "string",
|
|
4994
|
-
format: "date",
|
|
4995
|
-
daysFromDate: {
|
|
4996
|
-
days,
|
|
4997
|
-
clause,
|
|
4998
|
-
referenceDate
|
|
4999
|
-
}
|
|
5000
|
-
},
|
|
5001
|
-
field3.$$subfield
|
|
5002
|
-
)
|
|
5003
|
-
},
|
|
5004
|
-
required: [field3.$$field]
|
|
5005
|
-
});
|
|
5006
|
-
const getDateRange = (field3, date, clause) => ({
|
|
4515
|
+
const getDateRange = (field3, date, clause) => ({
|
|
5007
4516
|
type: "object",
|
|
5008
4517
|
properties: {
|
|
5009
4518
|
[field3.$$field]: wrapToPath(
|
|
@@ -5060,7 +4569,9 @@ function createFieldConditionals(fieldId) {
|
|
|
5060
4569
|
},
|
|
5061
4570
|
fromNow: () => {
|
|
5062
4571
|
return defineFormConditional(getDayRange(this, days, "after"));
|
|
5063
|
-
}
|
|
4572
|
+
},
|
|
4573
|
+
beforeAction: (action) => defineFormConditional(getDayRange(this, -days, "after", action)),
|
|
4574
|
+
afterAction: (action) => defineFormConditional(getDayRange(this, days, "after", action))
|
|
5064
4575
|
}),
|
|
5065
4576
|
date: (date) => {
|
|
5066
4577
|
if (isFieldReference(date)) {
|
|
@@ -5101,7 +4612,9 @@ function createFieldConditionals(fieldId) {
|
|
|
5101
4612
|
},
|
|
5102
4613
|
fromNow: () => {
|
|
5103
4614
|
return defineFormConditional(getDayRange(this, -days, "before"));
|
|
5104
|
-
}
|
|
4615
|
+
},
|
|
4616
|
+
beforeAction: (action) => defineFormConditional(getDayRange(this, -days, "before", action)),
|
|
4617
|
+
afterAction: (action) => defineFormConditional(getDayRange(this, days, "before", action))
|
|
5105
4618
|
}),
|
|
5106
4619
|
date: (date) => {
|
|
5107
4620
|
if (isFieldReference(date)) {
|
|
@@ -5358,31 +4871,678 @@ function createFieldConditionals(fieldId) {
|
|
|
5358
4871
|
),
|
|
5359
4872
|
required: [fieldId]
|
|
5360
4873
|
});
|
|
5361
|
-
},
|
|
5362
|
-
/**
|
|
5363
|
-
* Custom client-side evaluation. Returns a {@link FieldReference} descriptor
|
|
5364
|
-
* that can be used as the `value` property or a DATA component entry.
|
|
5365
|
-
* The function receives the referenced field's value as the first argument and
|
|
5366
|
-
* the full form context as the second; its return value replaces the field reference.
|
|
5367
|
-
* The function is serialised and executed just-in-time on the client only.
|
|
5368
|
-
* External references (e.g. lodash) are not available inside the function body.
|
|
5369
|
-
*
|
|
5370
|
-
* For computing a default value without referencing a specific field, use
|
|
5371
|
-
* `evaluate(fn)` in the `defaultValue` property instead.
|
|
5372
|
-
*
|
|
5373
|
-
* @example
|
|
5374
|
-
* field('a').customClientEvaluation((aValue, ctx) =>
|
|
5375
|
-
* Number(aValue) + Number(ctx.$form.b)
|
|
5376
|
-
* )
|
|
5377
|
-
*/
|
|
5378
|
-
customClientEvaluation(computationFn) {
|
|
5379
|
-
return {
|
|
5380
|
-
$$code: computationFn.toString(),
|
|
5381
|
-
$$field: fieldId,
|
|
5382
|
-
$$subfield: this.$$subfield
|
|
5383
|
-
};
|
|
4874
|
+
},
|
|
4875
|
+
/**
|
|
4876
|
+
* Custom client-side evaluation. Returns a {@link FieldReference} descriptor
|
|
4877
|
+
* that can be used as the `value` property or a DATA component entry.
|
|
4878
|
+
* The function receives the referenced field's value as the first argument and
|
|
4879
|
+
* the full form context as the second; its return value replaces the field reference.
|
|
4880
|
+
* The function is serialised and executed just-in-time on the client only.
|
|
4881
|
+
* External references (e.g. lodash) are not available inside the function body.
|
|
4882
|
+
*
|
|
4883
|
+
* For computing a default value without referencing a specific field, use
|
|
4884
|
+
* `evaluate(fn)` in the `defaultValue` property instead.
|
|
4885
|
+
*
|
|
4886
|
+
* @example
|
|
4887
|
+
* field('a').customClientEvaluation((aValue, ctx) =>
|
|
4888
|
+
* Number(aValue) + Number(ctx.$form.b)
|
|
4889
|
+
* )
|
|
4890
|
+
*/
|
|
4891
|
+
customClientEvaluation(computationFn) {
|
|
4892
|
+
return {
|
|
4893
|
+
$$code: computationFn.toString(),
|
|
4894
|
+
$$field: fieldId,
|
|
4895
|
+
$$subfield: this.$$subfield
|
|
4896
|
+
};
|
|
4897
|
+
}
|
|
4898
|
+
};
|
|
4899
|
+
}
|
|
4900
|
+
|
|
4901
|
+
// ../commons/src/events/FieldTypeMapping.ts
|
|
4902
|
+
var z33 = __toESM(require("zod/v4"));
|
|
4903
|
+
|
|
4904
|
+
// ../commons/src/events/DynamicFieldValue.ts
|
|
4905
|
+
var z32 = __toESM(require("zod/v4"));
|
|
4906
|
+
function getDynamicNameValue(field3) {
|
|
4907
|
+
const nameConfiguration = field3.configuration?.name;
|
|
4908
|
+
const firstnameRequired = nameConfiguration?.firstname?.required ?? field3.required;
|
|
4909
|
+
const surnameRequired = nameConfiguration?.surname?.required ?? field3.required;
|
|
4910
|
+
return z32.object({
|
|
4911
|
+
firstname: firstnameRequired ? NonEmptyTextValue : TextValue,
|
|
4912
|
+
surname: surnameRequired ? NonEmptyTextValue : TextValue,
|
|
4913
|
+
middlename: nameConfiguration?.middlename?.required ? NonEmptyTextValue : TextValue.optional()
|
|
4914
|
+
});
|
|
4915
|
+
}
|
|
4916
|
+
function getDynamicAddressFieldValue(field3) {
|
|
4917
|
+
const schema = field3.required ? AddressFieldValue : AddressFieldUpdateValue;
|
|
4918
|
+
const configIds = field3.configuration?.streetAddressForm?.map((a) => a.id) ?? [];
|
|
4919
|
+
return schema.refine((arg) => {
|
|
4920
|
+
if (!arg) {
|
|
4921
|
+
return true;
|
|
4922
|
+
}
|
|
4923
|
+
const submittedKeys = Object.keys(arg.streetLevelDetails ?? {});
|
|
4924
|
+
const invalidKeys = submittedKeys.filter((k) => !configIds.includes(k));
|
|
4925
|
+
if (invalidKeys.length) {
|
|
4926
|
+
console.log(
|
|
4927
|
+
"Invalid streetLevelDetails: unknown keys",
|
|
4928
|
+
JSON.stringify(invalidKeys, null, 2)
|
|
4929
|
+
);
|
|
4930
|
+
return false;
|
|
4931
|
+
}
|
|
4932
|
+
return true;
|
|
4933
|
+
});
|
|
4934
|
+
}
|
|
4935
|
+
|
|
4936
|
+
// ../commons/src/events/FieldTypeMapping.ts
|
|
4937
|
+
function mapFieldTypeToZod(field3, actionType) {
|
|
4938
|
+
let schema;
|
|
4939
|
+
switch (field3.type) {
|
|
4940
|
+
case FieldType.FIELD_GROUP: {
|
|
4941
|
+
schema = z33.object(
|
|
4942
|
+
field3.fields.reduce((acc, subfield) => {
|
|
4943
|
+
acc[subfield.id] = mapFieldTypeToZod(subfield, actionType);
|
|
4944
|
+
return acc;
|
|
4945
|
+
}, {})
|
|
4946
|
+
);
|
|
4947
|
+
break;
|
|
4948
|
+
}
|
|
4949
|
+
case FieldType.DATE:
|
|
4950
|
+
schema = PlainDate;
|
|
4951
|
+
break;
|
|
4952
|
+
case FieldType.AGE:
|
|
4953
|
+
schema = AgeValue;
|
|
4954
|
+
break;
|
|
4955
|
+
case FieldType.TIME:
|
|
4956
|
+
schema = TimeValue;
|
|
4957
|
+
break;
|
|
4958
|
+
case FieldType.EMAIL:
|
|
4959
|
+
schema = EmailValue;
|
|
4960
|
+
break;
|
|
4961
|
+
case FieldType.DATE_RANGE:
|
|
4962
|
+
schema = DateRangeFieldValue;
|
|
4963
|
+
break;
|
|
4964
|
+
case FieldType.SELECT_DATE_RANGE:
|
|
4965
|
+
schema = SelectDateRangeValue;
|
|
4966
|
+
break;
|
|
4967
|
+
case FieldType.TEXT:
|
|
4968
|
+
case FieldType.TEXTAREA:
|
|
4969
|
+
case FieldType.DIVIDER:
|
|
4970
|
+
case FieldType.BULLET_LIST:
|
|
4971
|
+
case FieldType.PAGE_HEADER:
|
|
4972
|
+
case FieldType.LOCATION:
|
|
4973
|
+
case FieldType.SELECT:
|
|
4974
|
+
case FieldType.COUNTRY:
|
|
4975
|
+
case FieldType.RADIO_GROUP:
|
|
4976
|
+
case FieldType.PARAGRAPH:
|
|
4977
|
+
case FieldType.HEADING:
|
|
4978
|
+
case FieldType.IMAGE_VIEW:
|
|
4979
|
+
case FieldType.ADMINISTRATIVE_AREA:
|
|
4980
|
+
case FieldType.FACILITY:
|
|
4981
|
+
case FieldType.OFFICE:
|
|
4982
|
+
case FieldType.PHONE:
|
|
4983
|
+
case FieldType.LINK_BUTTON:
|
|
4984
|
+
case FieldType.VERIFICATION_STATUS:
|
|
4985
|
+
case FieldType.ID:
|
|
4986
|
+
case FieldType.LOADER:
|
|
4987
|
+
case FieldType.ALPHA_HIDDEN:
|
|
4988
|
+
case FieldType.USER_ROLE:
|
|
4989
|
+
schema = field3.required ? NonEmptyTextValue : TextValue;
|
|
4990
|
+
break;
|
|
4991
|
+
case FieldType.NUMBER:
|
|
4992
|
+
schema = NumberFieldValue;
|
|
4993
|
+
break;
|
|
4994
|
+
case FieldType.NUMBER_WITH_UNIT:
|
|
4995
|
+
schema = field3.required ? NumberWithUnitFieldValue : NumberWithUnitFieldUpdateValue;
|
|
4996
|
+
break;
|
|
4997
|
+
case FieldType.CHECKBOX:
|
|
4998
|
+
schema = CheckboxFieldValue;
|
|
4999
|
+
break;
|
|
5000
|
+
case FieldType.SIGNATURE:
|
|
5001
|
+
case FieldType.FILE:
|
|
5002
|
+
schema = FileFieldValue;
|
|
5003
|
+
break;
|
|
5004
|
+
case FieldType.FILE_WITH_OPTIONS:
|
|
5005
|
+
schema = field3.required ? FileFieldWithOptionValue.min(1) : FileFieldWithOptionValue;
|
|
5006
|
+
break;
|
|
5007
|
+
case FieldType.ADDRESS:
|
|
5008
|
+
schema = getDynamicAddressFieldValue(field3);
|
|
5009
|
+
break;
|
|
5010
|
+
case FieldType.DATA:
|
|
5011
|
+
schema = DataFieldValue;
|
|
5012
|
+
break;
|
|
5013
|
+
case FieldType.NAME:
|
|
5014
|
+
schema = actionType === ActionType.NOTIFY ? NameFieldUpdateValue : getDynamicNameValue(field3);
|
|
5015
|
+
break;
|
|
5016
|
+
case FieldType.BUTTON:
|
|
5017
|
+
schema = ButtonFieldValue;
|
|
5018
|
+
break;
|
|
5019
|
+
case FieldType.ALPHA_PRINT_BUTTON:
|
|
5020
|
+
schema = TextValue;
|
|
5021
|
+
break;
|
|
5022
|
+
case FieldType.AUTOCOMPLETE:
|
|
5023
|
+
schema = AutocompleteValue;
|
|
5024
|
+
break;
|
|
5025
|
+
case FieldType.HTTP:
|
|
5026
|
+
case FieldType.SEARCH:
|
|
5027
|
+
schema = HttpFieldUpdateValue;
|
|
5028
|
+
break;
|
|
5029
|
+
case FieldType.QUERY_PARAM_READER:
|
|
5030
|
+
schema = QueryParamReaderFieldUpdateValue;
|
|
5031
|
+
break;
|
|
5032
|
+
case FieldType.QR_READER:
|
|
5033
|
+
schema = QrReaderFieldValue;
|
|
5034
|
+
break;
|
|
5035
|
+
case FieldType.ID_READER:
|
|
5036
|
+
schema = IdReaderFieldValue;
|
|
5037
|
+
break;
|
|
5038
|
+
case FieldType._EXPERIMENTAL_CUSTOM:
|
|
5039
|
+
schema = CustomFieldValue;
|
|
5040
|
+
break;
|
|
5041
|
+
}
|
|
5042
|
+
return field3.required ? schema : schema.nullish();
|
|
5043
|
+
}
|
|
5044
|
+
function mapFieldTypeToEmptyValue(field3) {
|
|
5045
|
+
switch (field3.type) {
|
|
5046
|
+
case FieldType.FIELD_GROUP:
|
|
5047
|
+
const nestedEmpty = field3.fields.reduce(
|
|
5048
|
+
(acc, subfield) => ({
|
|
5049
|
+
...acc,
|
|
5050
|
+
[subfield.id]: mapFieldTypeToEmptyValue(subfield)
|
|
5051
|
+
}),
|
|
5052
|
+
{}
|
|
5053
|
+
);
|
|
5054
|
+
return nestedEmpty;
|
|
5055
|
+
case FieldType.DIVIDER:
|
|
5056
|
+
case FieldType.TEXT:
|
|
5057
|
+
case FieldType.TEXTAREA:
|
|
5058
|
+
case FieldType.BULLET_LIST:
|
|
5059
|
+
case FieldType.PAGE_HEADER:
|
|
5060
|
+
case FieldType.LOCATION:
|
|
5061
|
+
case FieldType.SELECT:
|
|
5062
|
+
case FieldType.COUNTRY:
|
|
5063
|
+
case FieldType.RADIO_GROUP:
|
|
5064
|
+
case FieldType.PARAGRAPH:
|
|
5065
|
+
case FieldType.HEADING:
|
|
5066
|
+
case FieldType.IMAGE_VIEW:
|
|
5067
|
+
case FieldType.ADMINISTRATIVE_AREA:
|
|
5068
|
+
case FieldType.FACILITY:
|
|
5069
|
+
case FieldType.OFFICE:
|
|
5070
|
+
case FieldType.NUMBER:
|
|
5071
|
+
case FieldType.NUMBER_WITH_UNIT:
|
|
5072
|
+
case FieldType.EMAIL:
|
|
5073
|
+
case FieldType.DATE:
|
|
5074
|
+
case FieldType.AGE:
|
|
5075
|
+
case FieldType.TIME:
|
|
5076
|
+
case FieldType.CHECKBOX:
|
|
5077
|
+
case FieldType.DATE_RANGE:
|
|
5078
|
+
case FieldType.SELECT_DATE_RANGE:
|
|
5079
|
+
case FieldType.DATA:
|
|
5080
|
+
case FieldType.NAME:
|
|
5081
|
+
case FieldType.PHONE:
|
|
5082
|
+
case FieldType.BUTTON:
|
|
5083
|
+
case FieldType.ALPHA_PRINT_BUTTON:
|
|
5084
|
+
case FieldType.HTTP:
|
|
5085
|
+
case FieldType.AUTOCOMPLETE:
|
|
5086
|
+
case FieldType.SEARCH:
|
|
5087
|
+
case FieldType.LINK_BUTTON:
|
|
5088
|
+
case FieldType.QUERY_PARAM_READER:
|
|
5089
|
+
case FieldType.ID:
|
|
5090
|
+
case FieldType.VERIFICATION_STATUS:
|
|
5091
|
+
case FieldType.QR_READER:
|
|
5092
|
+
case FieldType.ID_READER:
|
|
5093
|
+
case FieldType.LOADER:
|
|
5094
|
+
case FieldType.ALPHA_HIDDEN:
|
|
5095
|
+
case FieldType.USER_ROLE:
|
|
5096
|
+
return null;
|
|
5097
|
+
case FieldType.ADDRESS:
|
|
5098
|
+
return {
|
|
5099
|
+
country: "",
|
|
5100
|
+
addressType: AddressType.DOMESTIC,
|
|
5101
|
+
administrativeArea: "",
|
|
5102
|
+
streetLevelDetails: {}
|
|
5103
|
+
};
|
|
5104
|
+
case FieldType.SIGNATURE:
|
|
5105
|
+
case FieldType.FILE:
|
|
5106
|
+
return {
|
|
5107
|
+
path: "",
|
|
5108
|
+
originalFilename: "",
|
|
5109
|
+
type: ""
|
|
5110
|
+
};
|
|
5111
|
+
case FieldType.FILE_WITH_OPTIONS:
|
|
5112
|
+
return [];
|
|
5113
|
+
case FieldType._EXPERIMENTAL_CUSTOM:
|
|
5114
|
+
return void 0;
|
|
5115
|
+
}
|
|
5116
|
+
}
|
|
5117
|
+
var isParagraphFieldType = (field3) => {
|
|
5118
|
+
return field3.config.type === FieldType.PARAGRAPH;
|
|
5119
|
+
};
|
|
5120
|
+
var isHeadingFieldType = (field3) => {
|
|
5121
|
+
return field3.config.type === FieldType.HEADING;
|
|
5122
|
+
};
|
|
5123
|
+
var isImageViewFieldType = (field3) => {
|
|
5124
|
+
return field3.config.type === FieldType.IMAGE_VIEW;
|
|
5125
|
+
};
|
|
5126
|
+
var isDateFieldType = (field3) => {
|
|
5127
|
+
return field3.config.type === FieldType.DATE;
|
|
5128
|
+
};
|
|
5129
|
+
var isAgeFieldType = (field3) => {
|
|
5130
|
+
return field3.config.type === FieldType.AGE;
|
|
5131
|
+
};
|
|
5132
|
+
var isTimeFieldType = (field3) => {
|
|
5133
|
+
return field3.config.type === FieldType.TIME;
|
|
5134
|
+
};
|
|
5135
|
+
var isDateRangeFieldType = (field3) => {
|
|
5136
|
+
return field3.config.type === FieldType.DATE_RANGE;
|
|
5137
|
+
};
|
|
5138
|
+
var isSelectDateRangeFieldType = (field3) => {
|
|
5139
|
+
return field3.config.type === FieldType.SELECT_DATE_RANGE;
|
|
5140
|
+
};
|
|
5141
|
+
var isPageHeaderFieldType = (field3) => {
|
|
5142
|
+
return field3.config.type === FieldType.PAGE_HEADER;
|
|
5143
|
+
};
|
|
5144
|
+
var isTextFieldType = (field3) => {
|
|
5145
|
+
return field3.config.type === FieldType.TEXT;
|
|
5146
|
+
};
|
|
5147
|
+
var isNumberFieldType = (field3) => {
|
|
5148
|
+
return field3.config.type === FieldType.NUMBER;
|
|
5149
|
+
};
|
|
5150
|
+
var isNumberWithUnitFieldType = (field3) => {
|
|
5151
|
+
return field3.config.type === FieldType.NUMBER_WITH_UNIT;
|
|
5152
|
+
};
|
|
5153
|
+
var isNameFieldType = (field3) => {
|
|
5154
|
+
return field3.config.type === FieldType.NAME;
|
|
5155
|
+
};
|
|
5156
|
+
var isPhoneFieldType = (field3) => {
|
|
5157
|
+
return field3.config.type === FieldType.PHONE;
|
|
5158
|
+
};
|
|
5159
|
+
var isIdFieldType = (field3) => {
|
|
5160
|
+
return field3.config.type === FieldType.ID;
|
|
5161
|
+
};
|
|
5162
|
+
var isTextAreaFieldType = (field3) => {
|
|
5163
|
+
return field3.config.type === FieldType.TEXTAREA;
|
|
5164
|
+
};
|
|
5165
|
+
var isSignatureFieldType = (field3) => {
|
|
5166
|
+
return field3.config.type === FieldType.SIGNATURE;
|
|
5167
|
+
};
|
|
5168
|
+
var isEmailFieldType = (field3) => {
|
|
5169
|
+
return field3.config.type === FieldType.EMAIL;
|
|
5170
|
+
};
|
|
5171
|
+
var isFileFieldType = (field3) => {
|
|
5172
|
+
return field3.config.type === FieldType.FILE;
|
|
5173
|
+
};
|
|
5174
|
+
var isFileFieldWithOptionType = (field3) => {
|
|
5175
|
+
return field3.config.type === FieldType.FILE_WITH_OPTIONS;
|
|
5176
|
+
};
|
|
5177
|
+
var isBulletListFieldType = (field3) => {
|
|
5178
|
+
return field3.config.type === FieldType.BULLET_LIST;
|
|
5179
|
+
};
|
|
5180
|
+
var isSelectFieldType = (field3) => {
|
|
5181
|
+
return field3.config.type === FieldType.SELECT;
|
|
5182
|
+
};
|
|
5183
|
+
var isAddressFieldType = (field3) => {
|
|
5184
|
+
return field3.config.type === FieldType.ADDRESS;
|
|
5185
|
+
};
|
|
5186
|
+
var isCountryFieldType = (field3) => {
|
|
5187
|
+
return field3.config.type === FieldType.COUNTRY;
|
|
5188
|
+
};
|
|
5189
|
+
var isCheckboxFieldType = (field3) => {
|
|
5190
|
+
return field3.config.type === FieldType.CHECKBOX;
|
|
5191
|
+
};
|
|
5192
|
+
var isRadioGroupFieldType = (field3) => {
|
|
5193
|
+
return field3.config.type === FieldType.RADIO_GROUP;
|
|
5194
|
+
};
|
|
5195
|
+
var isFieldGroupFieldType = (field3) => {
|
|
5196
|
+
return field3.config.type === FieldType.FIELD_GROUP;
|
|
5197
|
+
};
|
|
5198
|
+
var isLocationFieldType = (field3) => {
|
|
5199
|
+
return field3.config.type === FieldType.LOCATION;
|
|
5200
|
+
};
|
|
5201
|
+
var isDividerFieldType = (field3) => {
|
|
5202
|
+
return field3.config.type === FieldType.DIVIDER;
|
|
5203
|
+
};
|
|
5204
|
+
var isAdministrativeAreaFieldType = (field3) => {
|
|
5205
|
+
return field3.config.type === FieldType.ADMINISTRATIVE_AREA;
|
|
5206
|
+
};
|
|
5207
|
+
var isFacilityFieldType = (field3) => {
|
|
5208
|
+
return field3.config.type === FieldType.FACILITY;
|
|
5209
|
+
};
|
|
5210
|
+
var isOfficeFieldType = (field3) => {
|
|
5211
|
+
return field3.config.type === FieldType.OFFICE;
|
|
5212
|
+
};
|
|
5213
|
+
var isDataFieldType = (field3) => {
|
|
5214
|
+
return field3.config.type === FieldType.DATA;
|
|
5215
|
+
};
|
|
5216
|
+
var isButtonFieldType = (field3) => {
|
|
5217
|
+
return field3.config.type === FieldType.BUTTON;
|
|
5218
|
+
};
|
|
5219
|
+
var isPrintButtonFieldType = (field3) => {
|
|
5220
|
+
return field3.config.type === FieldType.ALPHA_PRINT_BUTTON;
|
|
5221
|
+
};
|
|
5222
|
+
var isHttpFieldType = (field3) => {
|
|
5223
|
+
return field3.config.type === FieldType.HTTP;
|
|
5224
|
+
};
|
|
5225
|
+
var isAutocompleteFieldType = (field3) => {
|
|
5226
|
+
return field3.config.type === FieldType.AUTOCOMPLETE;
|
|
5227
|
+
};
|
|
5228
|
+
var isSearchFieldType = (field3) => {
|
|
5229
|
+
return field3.config.type === FieldType.SEARCH;
|
|
5230
|
+
};
|
|
5231
|
+
var isLinkButtonFieldType = (field3) => {
|
|
5232
|
+
return field3.config.type === FieldType.LINK_BUTTON;
|
|
5233
|
+
};
|
|
5234
|
+
var isVerificationStatusType = (field3) => {
|
|
5235
|
+
return field3.config.type === FieldType.VERIFICATION_STATUS;
|
|
5236
|
+
};
|
|
5237
|
+
var isQueryParamReaderFieldType = (field3) => {
|
|
5238
|
+
return field3.config.type === FieldType.QUERY_PARAM_READER;
|
|
5239
|
+
};
|
|
5240
|
+
var isQrReaderFieldType = (field3) => {
|
|
5241
|
+
return field3.config.type === FieldType.QR_READER;
|
|
5242
|
+
};
|
|
5243
|
+
var isIdReaderFieldType = (field3) => {
|
|
5244
|
+
return field3.config.type === FieldType.ID_READER;
|
|
5245
|
+
};
|
|
5246
|
+
var isLoaderFieldType = (field3) => {
|
|
5247
|
+
return field3.config.type === FieldType.LOADER;
|
|
5248
|
+
};
|
|
5249
|
+
var isCustomFieldType = (field3) => {
|
|
5250
|
+
return field3.config.type === FieldType._EXPERIMENTAL_CUSTOM;
|
|
5251
|
+
};
|
|
5252
|
+
var isUserRoleFieldType = (field3) => {
|
|
5253
|
+
return field3.config.type === FieldType.USER_ROLE;
|
|
5254
|
+
};
|
|
5255
|
+
var isHiddenFieldType = (field3) => {
|
|
5256
|
+
return field3.config.type === FieldType.ALPHA_HIDDEN;
|
|
5257
|
+
};
|
|
5258
|
+
var isNonInteractiveFieldType = (field3) => {
|
|
5259
|
+
return field3.type === FieldType.DIVIDER || field3.type === FieldType.PAGE_HEADER || field3.type === FieldType.PARAGRAPH || field3.type === FieldType.HEADING || field3.type === FieldType.BULLET_LIST || field3.type === FieldType.DATA || field3.type === FieldType.ALPHA_PRINT_BUTTON || field3.type === FieldType.LINK_BUTTON || field3.type === FieldType.LOADER;
|
|
5260
|
+
};
|
|
5261
|
+
|
|
5262
|
+
// ../commons/src/events/state/index.ts
|
|
5263
|
+
var import_lodash3 = require("lodash");
|
|
5264
|
+
|
|
5265
|
+
// ../commons/src/events/state/utils.ts
|
|
5266
|
+
var import_lodash = require("lodash");
|
|
5267
|
+
function getActionRequests(actionType, actions) {
|
|
5268
|
+
const filtered = actions.filter((action) => action.type === actionType).reverse();
|
|
5269
|
+
const accept = filtered.find(
|
|
5270
|
+
(action) => action.status === ActionStatus.Accepted
|
|
5271
|
+
);
|
|
5272
|
+
const request = filtered.find(
|
|
5273
|
+
(action) => action.status === ActionStatus.Requested
|
|
5274
|
+
);
|
|
5275
|
+
const reject = filtered.find(
|
|
5276
|
+
(action) => action.status === ActionStatus.Rejected
|
|
5277
|
+
);
|
|
5278
|
+
return {
|
|
5279
|
+
reject,
|
|
5280
|
+
accept,
|
|
5281
|
+
request
|
|
5282
|
+
};
|
|
5283
|
+
}
|
|
5284
|
+
function getDeclarationActionCreationMetadata(actionType, actions) {
|
|
5285
|
+
const { accept: acceptAction, request: requestAction } = getActionRequests(
|
|
5286
|
+
actionType,
|
|
5287
|
+
actions
|
|
5288
|
+
);
|
|
5289
|
+
if (!acceptAction) {
|
|
5290
|
+
return null;
|
|
5291
|
+
}
|
|
5292
|
+
const registrationNumber = acceptAction.type === ActionType.REGISTER ? acceptAction.registrationNumber : null;
|
|
5293
|
+
return {
|
|
5294
|
+
// When 3rd party API returns 200 OK, we assume that the request was accepted, and persist single 'accepted' action.
|
|
5295
|
+
createdAt: requestAction?.createdAt ?? acceptAction.createdAt,
|
|
5296
|
+
createdBy: requestAction?.createdBy ?? acceptAction.createdBy,
|
|
5297
|
+
createdByUserType: requestAction?.createdByUserType ?? acceptAction.createdByUserType,
|
|
5298
|
+
createdAtLocation: requestAction?.createdAtLocation ?? acceptAction.createdAtLocation,
|
|
5299
|
+
acceptedAt: acceptAction.createdAt,
|
|
5300
|
+
createdByRole: requestAction?.createdByRole ?? acceptAction.createdByRole,
|
|
5301
|
+
registrationNumber
|
|
5302
|
+
};
|
|
5303
|
+
}
|
|
5304
|
+
var updateActions = new Set(
|
|
5305
|
+
ActionTypes.extract([
|
|
5306
|
+
ActionType.CREATE,
|
|
5307
|
+
ActionType.NOTIFY,
|
|
5308
|
+
ActionType.EDIT,
|
|
5309
|
+
ActionType.DECLARE,
|
|
5310
|
+
ActionType.REGISTER,
|
|
5311
|
+
ActionType.REJECT,
|
|
5312
|
+
ActionType.ARCHIVE,
|
|
5313
|
+
ActionType.UNARCHIVE,
|
|
5314
|
+
ActionType.PRINT_CERTIFICATE,
|
|
5315
|
+
ActionType.REQUEST_CORRECTION,
|
|
5316
|
+
ActionType.APPROVE_CORRECTION,
|
|
5317
|
+
ActionType.REJECT_CORRECTION,
|
|
5318
|
+
ActionType.REVOKE_REGISTRATION,
|
|
5319
|
+
ActionType.REINSTATE_REGISTRATION,
|
|
5320
|
+
ActionType.CUSTOM
|
|
5321
|
+
]).options
|
|
5322
|
+
);
|
|
5323
|
+
function getActionUpdateMetadata(actions) {
|
|
5324
|
+
const createAction = getOrThrow(
|
|
5325
|
+
actions.find((action) => action.type === ActionType.CREATE),
|
|
5326
|
+
`Event has no ${ActionType.CREATE} action`
|
|
5327
|
+
);
|
|
5328
|
+
const metadataFields = [
|
|
5329
|
+
"createdAt",
|
|
5330
|
+
"createdBy",
|
|
5331
|
+
"createdByUserType",
|
|
5332
|
+
"createdAtLocation",
|
|
5333
|
+
"createdByRole"
|
|
5334
|
+
];
|
|
5335
|
+
return actions.filter(({ type }) => updateActions.has(type)).reduce(
|
|
5336
|
+
(_2, action) => {
|
|
5337
|
+
if (action.originalActionId) {
|
|
5338
|
+
const originalAction = actions.find(({ id }) => id === action.originalActionId) ?? action;
|
|
5339
|
+
return (0, import_lodash.pick)(originalAction, metadataFields);
|
|
5340
|
+
}
|
|
5341
|
+
return (0, import_lodash.pick)(action, metadataFields);
|
|
5342
|
+
},
|
|
5343
|
+
(0, import_lodash.pick)(createAction, metadataFields)
|
|
5344
|
+
);
|
|
5345
|
+
}
|
|
5346
|
+
function getLegalStatuses(actions, status2) {
|
|
5347
|
+
return {
|
|
5348
|
+
[EventStatus.enum.NOTIFIED]: getDeclarationActionCreationMetadata(
|
|
5349
|
+
ActionType.NOTIFY,
|
|
5350
|
+
actions
|
|
5351
|
+
),
|
|
5352
|
+
[EventStatus.enum.DECLARED]: getDeclarationActionCreationMetadata(
|
|
5353
|
+
ActionType.DECLARE,
|
|
5354
|
+
actions
|
|
5355
|
+
),
|
|
5356
|
+
[EventStatus.enum.REGISTERED]: getDeclarationActionCreationMetadata(
|
|
5357
|
+
ActionType.REGISTER,
|
|
5358
|
+
actions
|
|
5359
|
+
),
|
|
5360
|
+
// A later reinstate does not remove the revoke action, so only report it while the record is still revoked.
|
|
5361
|
+
[EventStatus.enum.REVOKED]: status2 === EventStatus.enum.REVOKED ? getDeclarationActionCreationMetadata(
|
|
5362
|
+
ActionType.REVOKE_REGISTRATION,
|
|
5363
|
+
actions
|
|
5364
|
+
) : null
|
|
5365
|
+
};
|
|
5366
|
+
}
|
|
5367
|
+
|
|
5368
|
+
// ../commons/src/events/state/flags.ts
|
|
5369
|
+
var import_lodash2 = require("lodash");
|
|
5370
|
+
var import_date_fns = require("date-fns");
|
|
5371
|
+
function findPendingCorrectionAction(writeActions2) {
|
|
5372
|
+
let correctionRequestAction;
|
|
5373
|
+
for (let i = writeActions2.length - 1; i >= 0; i--) {
|
|
5374
|
+
const action = writeActions2[i];
|
|
5375
|
+
if (action.type === ActionType.APPROVE_CORRECTION || action.type === ActionType.REJECT_CORRECTION) {
|
|
5376
|
+
break;
|
|
5377
|
+
}
|
|
5378
|
+
if (action.type === ActionType.REQUEST_CORRECTION) {
|
|
5379
|
+
correctionRequestAction = action;
|
|
5380
|
+
break;
|
|
5381
|
+
}
|
|
5382
|
+
}
|
|
5383
|
+
return correctionRequestAction;
|
|
5384
|
+
}
|
|
5385
|
+
function isPotentialDuplicate(actions) {
|
|
5386
|
+
return actions.reduce((prev, { type }) => {
|
|
5387
|
+
if (type === ActionType.DUPLICATE_DETECTED) {
|
|
5388
|
+
return true;
|
|
5389
|
+
}
|
|
5390
|
+
if (type === ActionType.MARK_AS_NOT_DUPLICATE || type === ActionType.MARK_AS_DUPLICATE) {
|
|
5391
|
+
return false;
|
|
5392
|
+
}
|
|
5393
|
+
return prev;
|
|
5394
|
+
}, false);
|
|
5395
|
+
}
|
|
5396
|
+
function isFlagConditionMet(conditional, form, action, event2) {
|
|
5397
|
+
const now2 = (0, import_date_fns.isValid)((0, import_date_fns.parseISO)(action.createdAt)) ? (0, import_date_fns.formatISO)((0, import_date_fns.parseISO)(action.createdAt), { representation: "date" }) : (0, import_date_fns.formatISO)(/* @__PURE__ */ new Date(), { representation: "date" });
|
|
5398
|
+
return validate(conditional, {
|
|
5399
|
+
$form: form,
|
|
5400
|
+
$now: now2,
|
|
5401
|
+
$online: true,
|
|
5402
|
+
$event: event2,
|
|
5403
|
+
$user: {
|
|
5404
|
+
sub: "",
|
|
5405
|
+
exp: "",
|
|
5406
|
+
role: action.createdByRole,
|
|
5407
|
+
algorithm: "",
|
|
5408
|
+
scope: [],
|
|
5409
|
+
userType: action.createdByUserType
|
|
5410
|
+
}
|
|
5411
|
+
});
|
|
5412
|
+
}
|
|
5413
|
+
function actionConfigRemovesFlag(action, flagId, actionsUpToAndIncluding, event2, eventConfiguration) {
|
|
5414
|
+
if (!isActionConfigType(action.type)) {
|
|
5415
|
+
return false;
|
|
5416
|
+
}
|
|
5417
|
+
const actionConfig = getActionConfig({
|
|
5418
|
+
eventConfiguration,
|
|
5419
|
+
actionType: action.type,
|
|
5420
|
+
customActionType: "customActionType" in action ? action.customActionType : void 0
|
|
5421
|
+
});
|
|
5422
|
+
const removeOperations = (actionConfig?.flags ?? []).filter(
|
|
5423
|
+
({ id, operation }) => id === flagId && operation === "remove"
|
|
5424
|
+
);
|
|
5425
|
+
if (removeOperations.length === 0) {
|
|
5426
|
+
return false;
|
|
5427
|
+
}
|
|
5428
|
+
const eventUpToThisAction = { ...event2, actions: actionsUpToAndIncluding };
|
|
5429
|
+
const declaration = aggregateActionDeclarations(eventUpToThisAction);
|
|
5430
|
+
const annotation = aggregateActionAnnotations(eventUpToThisAction);
|
|
5431
|
+
const form = { ...declaration, ...annotation };
|
|
5432
|
+
return removeOperations.some(
|
|
5433
|
+
({ conditional }) => conditional ? isFlagConditionMet(conditional, form, action, eventUpToThisAction) : true
|
|
5434
|
+
);
|
|
5435
|
+
}
|
|
5436
|
+
var INHERENT_FLAG_RULES = [
|
|
5437
|
+
{
|
|
5438
|
+
flag: InherentFlags.CORRECTION_REQUESTED,
|
|
5439
|
+
setOn: [ActionType.REQUEST_CORRECTION],
|
|
5440
|
+
resetOn: [ActionType.APPROVE_CORRECTION, ActionType.REJECT_CORRECTION]
|
|
5441
|
+
},
|
|
5442
|
+
{
|
|
5443
|
+
flag: InherentFlags.REJECTED,
|
|
5444
|
+
setOn: [ActionType.REJECT],
|
|
5445
|
+
resetOn: [
|
|
5446
|
+
ActionType.NOTIFY,
|
|
5447
|
+
ActionType.DECLARE,
|
|
5448
|
+
ActionType.EDIT,
|
|
5449
|
+
ActionType.REGISTER
|
|
5450
|
+
]
|
|
5451
|
+
},
|
|
5452
|
+
{
|
|
5453
|
+
flag: InherentFlags.POTENTIAL_DUPLICATE,
|
|
5454
|
+
setOn: [ActionType.DUPLICATE_DETECTED],
|
|
5455
|
+
resetOn: [ActionType.MARK_AS_DUPLICATE, ActionType.MARK_AS_NOT_DUPLICATE]
|
|
5456
|
+
},
|
|
5457
|
+
{
|
|
5458
|
+
flag: InherentFlags.EDIT_IN_PROGRESS,
|
|
5459
|
+
setOn: [ActionType.EDIT],
|
|
5460
|
+
resetOnAnyOtherAction: true
|
|
5461
|
+
}
|
|
5462
|
+
];
|
|
5463
|
+
function resolveInherentFlag(rule, acceptedActions, event2, eventConfiguration) {
|
|
5464
|
+
return acceptedActions.reduce((present, action, idx) => {
|
|
5465
|
+
if (rule.setOn.includes(action.type)) {
|
|
5466
|
+
return true;
|
|
5467
|
+
}
|
|
5468
|
+
if (rule.resetOnAnyOtherAction || (rule.resetOn ?? []).includes(action.type)) {
|
|
5469
|
+
return false;
|
|
5470
|
+
}
|
|
5471
|
+
if (actionConfigRemovesFlag(
|
|
5472
|
+
action,
|
|
5473
|
+
rule.flag,
|
|
5474
|
+
acceptedActions.slice(0, idx + 1),
|
|
5475
|
+
event2,
|
|
5476
|
+
eventConfiguration
|
|
5477
|
+
)) {
|
|
5478
|
+
return false;
|
|
5479
|
+
}
|
|
5480
|
+
return present;
|
|
5481
|
+
}, false);
|
|
5482
|
+
}
|
|
5483
|
+
function resolveEventCustomFlags(event2, eventConfiguration) {
|
|
5484
|
+
const actions = getAcceptedActions(event2).filter(({ type }) => !isMetaAction(type)).sort((a, b) => a.createdAt.localeCompare(b.createdAt));
|
|
5485
|
+
const declarations = getDeclarationAfterEachAction({ ...event2, actions });
|
|
5486
|
+
let annotation = {};
|
|
5487
|
+
return actions.reduce((acc, action, idx) => {
|
|
5488
|
+
if (action.annotation) {
|
|
5489
|
+
annotation = deepMerge(annotation, action.annotation);
|
|
5490
|
+
}
|
|
5491
|
+
let actionConfig;
|
|
5492
|
+
if (isActionConfigType(action.type)) {
|
|
5493
|
+
actionConfig = getActionConfig({
|
|
5494
|
+
eventConfiguration,
|
|
5495
|
+
actionType: action.type,
|
|
5496
|
+
customActionType: "customActionType" in action ? action.customActionType : void 0
|
|
5497
|
+
});
|
|
5384
5498
|
}
|
|
5385
|
-
|
|
5499
|
+
if (!actionConfig) {
|
|
5500
|
+
return acc;
|
|
5501
|
+
}
|
|
5502
|
+
const form = { ...declarations[idx], ...annotation };
|
|
5503
|
+
const eventUpToThisAction = { ...event2, actions: actions.slice(0, idx + 1) };
|
|
5504
|
+
const flagsWithMetConditions = (actionConfig.flags ?? []).filter(
|
|
5505
|
+
({ conditional }) => (
|
|
5506
|
+
// If conditional is not provided, the flag is resolved
|
|
5507
|
+
conditional ? isFlagConditionMet(conditional, form, action, eventUpToThisAction) : true
|
|
5508
|
+
)
|
|
5509
|
+
);
|
|
5510
|
+
const addedFlags = flagsWithMetConditions.filter(({ operation }) => operation === "add").map(({ id }) => id);
|
|
5511
|
+
const removedFlags = flagsWithMetConditions.filter(({ operation }) => operation === "remove").map(({ id }) => id);
|
|
5512
|
+
const flags = [...acc, ...addedFlags].filter(
|
|
5513
|
+
(flagId) => !removedFlags.includes(flagId)
|
|
5514
|
+
);
|
|
5515
|
+
return (0, import_lodash2.uniq)(flags);
|
|
5516
|
+
}, []);
|
|
5517
|
+
}
|
|
5518
|
+
function getActionStatusFlags(sortedActions) {
|
|
5519
|
+
const actionStatus = sortedActions.reduce(
|
|
5520
|
+
(actionStatuses, { type, status: status2 }) => ({
|
|
5521
|
+
...actionStatuses,
|
|
5522
|
+
[type]: status2
|
|
5523
|
+
}),
|
|
5524
|
+
{}
|
|
5525
|
+
);
|
|
5526
|
+
return Object.entries(actionStatus).filter(([, status2]) => status2 !== ActionStatus.Accepted).map(([type, status2]) => {
|
|
5527
|
+
const flag2 = joinValues([type, status2], ":").toLowerCase();
|
|
5528
|
+
return flag2;
|
|
5529
|
+
});
|
|
5530
|
+
}
|
|
5531
|
+
function getInherentFlags(sortedActions, event2, eventConfiguration) {
|
|
5532
|
+
const acceptedActions = sortedActions.filter(
|
|
5533
|
+
({ status: status2 }) => status2 === ActionStatus.Accepted
|
|
5534
|
+
);
|
|
5535
|
+
return INHERENT_FLAG_RULES.filter(
|
|
5536
|
+
(rule) => resolveInherentFlag(rule, acceptedActions, event2, eventConfiguration)
|
|
5537
|
+
).map(({ flag: flag2 }) => flag2);
|
|
5538
|
+
}
|
|
5539
|
+
function getEventFlags(event2, config) {
|
|
5540
|
+
const sortedActions = event2.actions.filter(({ type }) => !isMetaAction(type)).sort((a, b) => a.createdAt.localeCompare(b.createdAt));
|
|
5541
|
+
return [
|
|
5542
|
+
...getActionStatusFlags(sortedActions),
|
|
5543
|
+
...getInherentFlags(sortedActions, event2, config),
|
|
5544
|
+
...resolveEventCustomFlags(event2, config)
|
|
5545
|
+
];
|
|
5386
5546
|
}
|
|
5387
5547
|
|
|
5388
5548
|
// ../commons/src/events/state/index.ts
|
|
@@ -5417,6 +5577,10 @@ function getStatusFromActions(actions) {
|
|
|
5417
5577
|
return EventStatus.enum.REGISTERED;
|
|
5418
5578
|
case ActionType.NOTIFY:
|
|
5419
5579
|
return EventStatus.enum.NOTIFIED;
|
|
5580
|
+
case ActionType.REVOKE_REGISTRATION:
|
|
5581
|
+
return EventStatus.enum.REVOKED;
|
|
5582
|
+
case ActionType.REINSTATE_REGISTRATION:
|
|
5583
|
+
return EventStatus.enum.REGISTERED;
|
|
5420
5584
|
// Already filtered out above; listed here only to satisfy exhaustiveness.
|
|
5421
5585
|
case ActionType.ARCHIVE:
|
|
5422
5586
|
case ActionType.UNARCHIVE:
|
|
@@ -5476,35 +5640,24 @@ function resolveDateOfEvent(eventIndex, declaration, config) {
|
|
|
5476
5640
|
if (!config.dateOfEvent) {
|
|
5477
5641
|
return extractDateString(eventIndex[DEFAULT_DATE_OF_EVENT_PROPERTY]);
|
|
5478
5642
|
}
|
|
5479
|
-
|
|
5480
|
-
|
|
5643
|
+
if (isFieldReference(config.dateOfEvent)) {
|
|
5644
|
+
const fieldDate = declaration[config.dateOfEvent.$$field];
|
|
5645
|
+
return ZodDate.validate(fieldDate) ? extractDateString(fieldDate) : void 0;
|
|
5646
|
+
}
|
|
5647
|
+
const eventDate = getMixedPath(
|
|
5648
|
+
eventIndex,
|
|
5649
|
+
config.dateOfEvent.$$event
|
|
5481
5650
|
);
|
|
5482
|
-
return
|
|
5651
|
+
return ZodDateTime.validate(eventDate) ? extractDateString(eventDate) : void 0;
|
|
5483
5652
|
}
|
|
5484
5653
|
var DEFAULT_PLACE_OF_EVENT_PROPERTY = "createdAtLocation";
|
|
5485
|
-
function getParsedUUID(value, oldValue) {
|
|
5486
|
-
const parsed = UUID.safeParse(value);
|
|
5487
|
-
return parsed.success ? parsed.data : oldValue;
|
|
5488
|
-
}
|
|
5489
5654
|
function resolvePlaceOfEvent(eventMetadata, declaration, config) {
|
|
5490
|
-
let placeOfEvent =
|
|
5655
|
+
let placeOfEvent = maybeUuid(
|
|
5491
5656
|
eventMetadata[DEFAULT_PLACE_OF_EVENT_PROPERTY]
|
|
5492
5657
|
);
|
|
5493
5658
|
if (config.placeOfEvent) {
|
|
5494
|
-
const addressFieldValue =
|
|
5495
|
-
|
|
5496
|
-
);
|
|
5497
|
-
if (addressFieldValue.success && addressFieldValue.data.addressType === AddressType.DOMESTIC && addressFieldValue.data.administrativeArea) {
|
|
5498
|
-
placeOfEvent = getParsedUUID(
|
|
5499
|
-
addressFieldValue.data.administrativeArea,
|
|
5500
|
-
placeOfEvent
|
|
5501
|
-
);
|
|
5502
|
-
} else {
|
|
5503
|
-
placeOfEvent = getParsedUUID(
|
|
5504
|
-
declaration[config.placeOfEvent.$$field],
|
|
5505
|
-
placeOfEvent
|
|
5506
|
-
);
|
|
5507
|
-
}
|
|
5659
|
+
const addressFieldValue = declaration[config.placeOfEvent.$$field];
|
|
5660
|
+
placeOfEvent = isDomesticAddressFieldValue(addressFieldValue) ? maybeUuid(addressFieldValue.administrativeArea) ?? placeOfEvent : maybeUuid(declaration[config.placeOfEvent.$$field]) ?? placeOfEvent;
|
|
5508
5661
|
}
|
|
5509
5662
|
return placeOfEvent;
|
|
5510
5663
|
}
|
|
@@ -5534,7 +5687,7 @@ function getCurrentEventState(event2, config) {
|
|
|
5534
5687
|
const acceptedActionMetadata = getActionUpdateMetadata(acceptedActions);
|
|
5535
5688
|
const declaration = aggregateActionDeclarations(event2);
|
|
5536
5689
|
const status2 = getStatusFromActions(sortedActions);
|
|
5537
|
-
const legalStatuses = getLegalStatuses(sortedActions);
|
|
5690
|
+
const legalStatuses = getLegalStatuses(sortedActions, status2);
|
|
5538
5691
|
const base = deepDropNulls({
|
|
5539
5692
|
id: event2.id,
|
|
5540
5693
|
type: event2.type,
|
|
@@ -5550,6 +5703,7 @@ function getCurrentEventState(event2, config) {
|
|
|
5550
5703
|
updatedAtLocation: requestActionMetadata.createdAtLocation,
|
|
5551
5704
|
declaration,
|
|
5552
5705
|
trackingId: event2.trackingId,
|
|
5706
|
+
configVersionId: event2.configVersionId,
|
|
5553
5707
|
updatedByUserRole: requestActionMetadata.createdByRole,
|
|
5554
5708
|
placeOfEvent: resolvePlaceOfEvent(
|
|
5555
5709
|
{ createdAtLocation: creationAction.createdAtLocation },
|
|
@@ -5687,6 +5841,15 @@ function resolveDataPath(rootData, dataPath, instancePath) {
|
|
|
5687
5841
|
}
|
|
5688
5842
|
return current;
|
|
5689
5843
|
}
|
|
5844
|
+
function resolveActionDate(event2, { match, occurrence }) {
|
|
5845
|
+
const dates = (event2?.actions ?? []).filter(({ status: status2 }) => status2 === ActionStatus.Accepted).filter(
|
|
5846
|
+
(action) => match.some(
|
|
5847
|
+
({ type, customActionType }) => action.type === type && (!customActionType || "customActionType" in action && action.customActionType === customActionType)
|
|
5848
|
+
)
|
|
5849
|
+
).map(({ createdAt }) => createdAt).sort();
|
|
5850
|
+
const date = occurrence === "first" ? dates[0] : dates[dates.length - 1];
|
|
5851
|
+
return date && (0, import_date_fns2.formatISO)((0, import_date_fns2.parseISO)(date), { representation: "date" });
|
|
5852
|
+
}
|
|
5690
5853
|
function todayISO() {
|
|
5691
5854
|
return (0, import_date_fns2.formatISO)(/* @__PURE__ */ new Date(), { representation: "date" });
|
|
5692
5855
|
}
|
|
@@ -5708,7 +5871,9 @@ function buildClientFunctionContext(input) {
|
|
|
5708
5871
|
// eslint-disable-next-line @typescript-eslint/no-use-before-define
|
|
5709
5872
|
$online: isOnline(),
|
|
5710
5873
|
$user: input.validatorContext?.user,
|
|
5711
|
-
$event: input.validatorContext?.event?.document
|
|
5874
|
+
$event: input.validatorContext?.event?.document ? getEventWithCompleteAcceptedActions(
|
|
5875
|
+
input.validatorContext.event.document
|
|
5876
|
+
) : void 0,
|
|
5712
5877
|
$leafAdminStructureLocationIds: input.validatorContext?.leafAdminStructureLocationIds ?? [],
|
|
5713
5878
|
user: input.systemVariables?.user,
|
|
5714
5879
|
$window: input.systemVariables?.$window,
|
|
@@ -5738,6 +5903,10 @@ ajv.addKeyword({
|
|
|
5738
5903
|
return false;
|
|
5739
5904
|
}
|
|
5740
5905
|
let referenceDate = schema.referenceDate;
|
|
5906
|
+
if (isActionDateReference(referenceDate)) {
|
|
5907
|
+
const rootData = dataContext.rootData;
|
|
5908
|
+
referenceDate = resolveActionDate(rootData.$event, referenceDate.$action);
|
|
5909
|
+
}
|
|
5741
5910
|
if (referenceDate && typeof referenceDate === "object" && "$data" in referenceDate) {
|
|
5742
5911
|
referenceDate = resolveDataPath(
|
|
5743
5912
|
dataContext.rootData,
|
|
@@ -5789,7 +5958,7 @@ function precompileActionSchemas(eventConfigurations) {
|
|
|
5789
5958
|
}
|
|
5790
5959
|
}
|
|
5791
5960
|
function isAgeValue(value) {
|
|
5792
|
-
return
|
|
5961
|
+
return AgeValue.validate(value);
|
|
5793
5962
|
}
|
|
5794
5963
|
function mergeWithBaseFormState(values, context) {
|
|
5795
5964
|
return { ...context.baseFormState, ...values };
|
|
@@ -5819,15 +5988,13 @@ function validate(schema, data) {
|
|
|
5819
5988
|
return [key, value];
|
|
5820
5989
|
}
|
|
5821
5990
|
const age = value.age;
|
|
5822
|
-
const
|
|
5991
|
+
const asOf = data.$form[value.asOfDateRef];
|
|
5992
|
+
const asOfDate = isPlainDate(asOf) ? asOf : PlainDate.parse(data.$now);
|
|
5823
5993
|
return [
|
|
5824
5994
|
key,
|
|
5825
5995
|
{
|
|
5826
5996
|
age,
|
|
5827
|
-
dob: ageToDate(
|
|
5828
|
-
age,
|
|
5829
|
-
maybeAsOfDate.success ? maybeAsOfDate.data : PlainDate.parse(data.$now)
|
|
5830
|
-
)
|
|
5997
|
+
dob: ageToDate(age, asOfDate)
|
|
5831
5998
|
}
|
|
5832
5999
|
];
|
|
5833
6000
|
});
|
|
@@ -5990,6 +6157,11 @@ var errorMessages = {
|
|
|
5990
6157
|
description: "Error message when field is not expected",
|
|
5991
6158
|
id: "error.unexpectedField"
|
|
5992
6159
|
},
|
|
6160
|
+
notInNotifyForm: {
|
|
6161
|
+
defaultMessage: "Field is not part of the notify form. Notify-only data belongs in annotation",
|
|
6162
|
+
description: "Error message when a notify declaration contains a field outside the notify form",
|
|
6163
|
+
id: "error.notInNotifyForm"
|
|
6164
|
+
},
|
|
5993
6165
|
correctionNotAllowed: {
|
|
5994
6166
|
defaultMessage: "Correction not allowed for field",
|
|
5995
6167
|
description: "Error message when correction is not allowed for field",
|
|
@@ -6209,14 +6381,56 @@ function ageToDate(age, asOfDate) {
|
|
|
6209
6381
|
const date = plainDateToLocalDate(asOfDate);
|
|
6210
6382
|
return PlainDate.parse((0, import_date_fns3.format)((0, import_date_fns3.subYears)(date, age), "yyyy-MM-dd"));
|
|
6211
6383
|
}
|
|
6212
|
-
function
|
|
6213
|
-
|
|
6384
|
+
function getDeclaration(configuration) {
|
|
6385
|
+
const declareAction = configuration.actions.find(
|
|
6386
|
+
(action) => action.type === ActionType.DECLARE
|
|
6387
|
+
);
|
|
6388
|
+
if (!declareAction) {
|
|
6389
|
+
throw new Error(
|
|
6390
|
+
`Event '${configuration.id}' has no ${ActionType.DECLARE} action to read the declaration from`
|
|
6391
|
+
);
|
|
6392
|
+
}
|
|
6393
|
+
return declareAction.declaration;
|
|
6214
6394
|
}
|
|
6215
6395
|
function getDeclarationPages(configuration) {
|
|
6216
|
-
return configuration.
|
|
6396
|
+
return getDeclaration(configuration).pages;
|
|
6217
6397
|
}
|
|
6218
|
-
function
|
|
6219
|
-
return configuration.
|
|
6398
|
+
function getDeclarationFields(configuration) {
|
|
6399
|
+
return getDeclarationPages(configuration).flatMap(({ fields }) => fields);
|
|
6400
|
+
}
|
|
6401
|
+
function getDeclarationFieldsOfAllVersions(config) {
|
|
6402
|
+
const oldestFirst = [...config.versions].sort(byEffectiveFrom);
|
|
6403
|
+
const fieldsById = new Map(
|
|
6404
|
+
oldestFirst.flatMap(
|
|
6405
|
+
(version) => getDeclarationFields(toEventConfig(config, version)).map(
|
|
6406
|
+
(field3) => [field3.id, field3]
|
|
6407
|
+
)
|
|
6408
|
+
)
|
|
6409
|
+
);
|
|
6410
|
+
return [...fieldsById.values()];
|
|
6411
|
+
}
|
|
6412
|
+
function findNotificationForm(configuration) {
|
|
6413
|
+
const notifyAction = configuration.actions.find(
|
|
6414
|
+
(action) => action.type === ActionType.NOTIFY
|
|
6415
|
+
);
|
|
6416
|
+
return notifyAction?.type === ActionType.NOTIFY ? notifyAction.notificationForm : void 0;
|
|
6417
|
+
}
|
|
6418
|
+
function getNotificationForm(configuration) {
|
|
6419
|
+
const notificationForm = findNotificationForm(configuration);
|
|
6420
|
+
if (!notificationForm) {
|
|
6421
|
+
throw new Error(
|
|
6422
|
+
`Event '${configuration.id}' has no ${ActionType.NOTIFY} action.`
|
|
6423
|
+
);
|
|
6424
|
+
}
|
|
6425
|
+
return notificationForm;
|
|
6426
|
+
}
|
|
6427
|
+
function getNotificationFields(configuration) {
|
|
6428
|
+
return getNotificationForm(configuration).pages.flatMap(
|
|
6429
|
+
({ fields }) => fields
|
|
6430
|
+
);
|
|
6431
|
+
}
|
|
6432
|
+
function getActionForm(configuration, actionType) {
|
|
6433
|
+
return actionType === ActionType.NOTIFY ? getNotificationForm(configuration) : getDeclaration(configuration);
|
|
6220
6434
|
}
|
|
6221
6435
|
function isActionConfigType(type) {
|
|
6222
6436
|
return actionConfigTypes.has(type);
|
|
@@ -6226,9 +6440,6 @@ function getActionConfig({
|
|
|
6226
6440
|
actionType,
|
|
6227
6441
|
customActionType
|
|
6228
6442
|
}) {
|
|
6229
|
-
if (actionType === ActionType.NOTIFY) {
|
|
6230
|
-
return eventConfiguration.actions.find((a) => a.type === ActionType.NOTIFY) ?? eventConfiguration.actions.find((a) => a.type === ActionType.DECLARE);
|
|
6231
|
-
}
|
|
6232
6443
|
return eventConfiguration.actions.find((a) => {
|
|
6233
6444
|
if (a.type === ActionType.CUSTOM && customActionType) {
|
|
6234
6445
|
return a.customActionType === customActionType;
|
|
@@ -6476,11 +6687,12 @@ function flattenFieldReference(ref) {
|
|
|
6476
6687
|
return [ref.$$field, ...ref.$$subfield];
|
|
6477
6688
|
}
|
|
6478
6689
|
function isWriteAction(actionType) {
|
|
6479
|
-
return writeActions.
|
|
6690
|
+
return writeActions.validate(actionType);
|
|
6480
6691
|
}
|
|
6481
6692
|
var findAllFields = (config) => {
|
|
6482
6693
|
return (0, import_lodash4.flattenDeep)([
|
|
6483
6694
|
...getDeclarationFields(config),
|
|
6695
|
+
...findNotificationForm(config)?.pages.flatMap(({ fields }) => fields) ?? [],
|
|
6484
6696
|
...getAllAnnotationFields(config)
|
|
6485
6697
|
]);
|
|
6486
6698
|
};
|
|
@@ -6503,10 +6715,10 @@ function getMixedPath(obj, path, defaultValue) {
|
|
|
6503
6715
|
return (0, import_lodash4.isNil)(result) ? defaultValue : result;
|
|
6504
6716
|
}
|
|
6505
6717
|
function getEventConfigById(eventConfigs, id) {
|
|
6506
|
-
|
|
6507
|
-
(eventConfiguration) => eventConfiguration.id === id
|
|
6718
|
+
return getOrThrow(
|
|
6719
|
+
eventConfigs.find((eventConfiguration) => eventConfiguration.id === id),
|
|
6720
|
+
`No configuration found for event type: ${id}`
|
|
6508
6721
|
);
|
|
6509
|
-
return getOrThrow(eventConfig, `Event config for ${id} not found`);
|
|
6510
6722
|
}
|
|
6511
6723
|
function timePeriodToDateRange(value) {
|
|
6512
6724
|
let startDate;
|
|
@@ -6616,12 +6828,41 @@ function getCompleteActionDeclaration(declaration, event2, action) {
|
|
|
6616
6828
|
}
|
|
6617
6829
|
return deepMerge(declaration, action.declaration);
|
|
6618
6830
|
}
|
|
6619
|
-
function
|
|
6620
|
-
return
|
|
6831
|
+
function completeAcceptedAction(event2, action) {
|
|
6832
|
+
return {
|
|
6621
6833
|
...action,
|
|
6622
6834
|
declaration: getCompleteActionDeclaration({}, event2, action),
|
|
6623
6835
|
annotation: getCompleteActionAnnotation(event2, action)
|
|
6624
|
-
}
|
|
6836
|
+
};
|
|
6837
|
+
}
|
|
6838
|
+
function getAcceptedActions(event2) {
|
|
6839
|
+
return event2.actions.filter(isAcceptedAction).map((action) => completeAcceptedAction(event2, action));
|
|
6840
|
+
}
|
|
6841
|
+
function getEventWithCompleteAcceptedActions(event2) {
|
|
6842
|
+
return {
|
|
6843
|
+
...event2,
|
|
6844
|
+
actions: event2.actions.map((action) => {
|
|
6845
|
+
if (!isAcceptedAction(action) || !action.originalActionId) {
|
|
6846
|
+
return action;
|
|
6847
|
+
}
|
|
6848
|
+
const requestedAction = event2.actions.find(
|
|
6849
|
+
({ id }) => id === action.originalActionId
|
|
6850
|
+
);
|
|
6851
|
+
if (requestedAction?.status !== ActionStatus.Requested) {
|
|
6852
|
+
return action;
|
|
6853
|
+
}
|
|
6854
|
+
const content = getCompleteActionContent(event2, action);
|
|
6855
|
+
return {
|
|
6856
|
+
...completeAcceptedAction(event2, action),
|
|
6857
|
+
// Who requested the action, as getActionUpdateMetadata resolves it.
|
|
6858
|
+
createdBy: requestedAction.createdBy,
|
|
6859
|
+
createdByRole: requestedAction.createdByRole,
|
|
6860
|
+
createdByUserType: requestedAction.createdByUserType,
|
|
6861
|
+
createdAtLocation: requestedAction.createdAtLocation,
|
|
6862
|
+
...content ? { content } : {}
|
|
6863
|
+
};
|
|
6864
|
+
})
|
|
6865
|
+
};
|
|
6625
6866
|
}
|
|
6626
6867
|
var EXCLUDED_ACTIONS = [
|
|
6627
6868
|
ActionType.REQUEST_CORRECTION,
|
|
@@ -6720,6 +6961,20 @@ function dropSecuredDeclarationFields(eventConfig, eventIndex, validatorContext)
|
|
|
6720
6961
|
}
|
|
6721
6962
|
|
|
6722
6963
|
// ../commons/src/events/eventConfigValidation.ts
|
|
6964
|
+
var SEARCH_DEFAULT_VALUE_FIELD_TYPES = [
|
|
6965
|
+
FieldType.TEXT,
|
|
6966
|
+
FieldType.TEXTAREA,
|
|
6967
|
+
FieldType.EMAIL,
|
|
6968
|
+
FieldType.PHONE,
|
|
6969
|
+
FieldType.ID,
|
|
6970
|
+
FieldType.SELECT,
|
|
6971
|
+
FieldType.RADIO_GROUP,
|
|
6972
|
+
FieldType.COUNTRY,
|
|
6973
|
+
FieldType.LOCATION,
|
|
6974
|
+
FieldType.ADMINISTRATIVE_AREA,
|
|
6975
|
+
FieldType.NUMBER,
|
|
6976
|
+
FieldType.DATE
|
|
6977
|
+
];
|
|
6723
6978
|
function validateAdvancedSearchConfig(event2, ctx) {
|
|
6724
6979
|
const allFields = findAllFields(event2);
|
|
6725
6980
|
const fieldIds = allFields.map((field3) => field3.id);
|
|
@@ -6751,6 +7006,56 @@ function validateAdvancedSearchConfig(event2, ctx) {
|
|
|
6751
7006
|
path: ["advancedSearch"]
|
|
6752
7007
|
});
|
|
6753
7008
|
}
|
|
7009
|
+
event2.advancedSearch.forEach((section, sectionIndex) => {
|
|
7010
|
+
section.fields.forEach((searchField, fieldIndex) => {
|
|
7011
|
+
if (searchField.fieldType !== "field" || searchField.defaultValue === void 0) {
|
|
7012
|
+
return;
|
|
7013
|
+
}
|
|
7014
|
+
const path = [
|
|
7015
|
+
"advancedSearch",
|
|
7016
|
+
sectionIndex,
|
|
7017
|
+
"fields",
|
|
7018
|
+
fieldIndex,
|
|
7019
|
+
"defaultValue"
|
|
7020
|
+
];
|
|
7021
|
+
if (searchField.config.searchFields && searchField.config.searchFields.length > 0) {
|
|
7022
|
+
ctx.addIssue({
|
|
7023
|
+
code: "custom",
|
|
7024
|
+
message: `Advanced search field ${searchField.fieldId} searches across several form fields, so it does not support a defaultValue.`,
|
|
7025
|
+
path
|
|
7026
|
+
});
|
|
7027
|
+
return;
|
|
7028
|
+
}
|
|
7029
|
+
if (typeof searchField.defaultValue === "boolean") {
|
|
7030
|
+
return;
|
|
7031
|
+
}
|
|
7032
|
+
const formField = allFields.find(({ id }) => id === searchField.fieldId);
|
|
7033
|
+
if (!formField) {
|
|
7034
|
+
return;
|
|
7035
|
+
}
|
|
7036
|
+
if (!SEARCH_DEFAULT_VALUE_FIELD_TYPES.some(
|
|
7037
|
+
(type) => type === formField.type
|
|
7038
|
+
)) {
|
|
7039
|
+
ctx.addIssue({
|
|
7040
|
+
code: "custom",
|
|
7041
|
+
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(", ")}.`,
|
|
7042
|
+
path
|
|
7043
|
+
});
|
|
7044
|
+
} else if (formField.type === FieldType.DATE && searchField.config.type === "range") {
|
|
7045
|
+
ctx.addIssue({
|
|
7046
|
+
code: "custom",
|
|
7047
|
+
message: `Advanced search field ${searchField.fieldId} is searched as a date range, so its defaultValue can only be true or false.`,
|
|
7048
|
+
path
|
|
7049
|
+
});
|
|
7050
|
+
} else if (!mapFieldTypeToZod(formField).safeParse(searchField.defaultValue).success) {
|
|
7051
|
+
ctx.addIssue({
|
|
7052
|
+
code: "custom",
|
|
7053
|
+
message: `Advanced search field ${searchField.fieldId} has defaultValue "${searchField.defaultValue}", which is not a valid ${formField.type} value.`,
|
|
7054
|
+
path
|
|
7055
|
+
});
|
|
7056
|
+
}
|
|
7057
|
+
});
|
|
7058
|
+
});
|
|
6754
7059
|
}
|
|
6755
7060
|
function validateDateOfEvent(event2, ctx) {
|
|
6756
7061
|
if (event2.dateOfEvent && isFieldReference(event2.dateOfEvent)) {
|
|
@@ -6837,15 +7142,102 @@ function validateActionOrder(event2, ctx) {
|
|
|
6837
7142
|
}
|
|
6838
7143
|
}
|
|
6839
7144
|
}
|
|
7145
|
+
function validateExactlyOneDeclareAction(event2, ctx) {
|
|
7146
|
+
const declareActionCount = event2.actions.filter(
|
|
7147
|
+
(action) => action.type === ActionType.DECLARE
|
|
7148
|
+
).length;
|
|
7149
|
+
if (declareActionCount !== 1) {
|
|
7150
|
+
ctx.addIssue({
|
|
7151
|
+
code: "custom",
|
|
7152
|
+
message: `Event must have exactly one ${ActionType.DECLARE} action. Found ${declareActionCount} for event ${event2.id}`,
|
|
7153
|
+
path: ["actions"]
|
|
7154
|
+
});
|
|
7155
|
+
return false;
|
|
7156
|
+
}
|
|
7157
|
+
return true;
|
|
7158
|
+
}
|
|
7159
|
+
function validateDeclarationGivenExactlyOnce(config, ctx) {
|
|
7160
|
+
const declareActionIndex = config.actions.findIndex(
|
|
7161
|
+
(action) => action.type === ActionType.DECLARE
|
|
7162
|
+
);
|
|
7163
|
+
const declareAction = config.actions[declareActionIndex];
|
|
7164
|
+
const onDeclareAction = declareAction.type === ActionType.DECLARE && !!declareAction.declaration;
|
|
7165
|
+
const onTopLevel = !!config.declaration;
|
|
7166
|
+
const declareActionPath = `actions[${declareActionIndex}].declaration`;
|
|
7167
|
+
if (onTopLevel && onDeclareAction) {
|
|
7168
|
+
ctx.addIssue({
|
|
7169
|
+
code: "custom",
|
|
7170
|
+
message: `Event '${config.id}' defines \`declaration\` both at the top level and on the ${ActionType.DECLARE} action (\`${declareActionPath}\`). Define it in only one of these places.`,
|
|
7171
|
+
path: ["declaration"]
|
|
7172
|
+
});
|
|
7173
|
+
}
|
|
7174
|
+
if (!onTopLevel && !onDeclareAction) {
|
|
7175
|
+
ctx.addIssue({
|
|
7176
|
+
code: "custom",
|
|
7177
|
+
message: `Event '${config.id}' does not define \`declaration\`. Define it either at the top level or on the ${ActionType.DECLARE} action (\`${declareActionPath}\`).`,
|
|
7178
|
+
path: ["declaration"]
|
|
7179
|
+
});
|
|
7180
|
+
}
|
|
7181
|
+
}
|
|
7182
|
+
function validateNotificationForm(event2, ctx) {
|
|
7183
|
+
const declarationFields = getDeclarationPages(event2).flatMap(
|
|
7184
|
+
(page) => page.fields.map((field3) => ({ field: field3, pageId: page.id }))
|
|
7185
|
+
);
|
|
7186
|
+
event2.actions.forEach((action, actionIndex) => {
|
|
7187
|
+
if (action.type !== ActionType.NOTIFY) {
|
|
7188
|
+
return;
|
|
7189
|
+
}
|
|
7190
|
+
action.notificationForm.pages.forEach((page, pageIndex) => {
|
|
7191
|
+
page.fields.forEach((field3, fieldIndex) => {
|
|
7192
|
+
const path = [
|
|
7193
|
+
"actions",
|
|
7194
|
+
actionIndex,
|
|
7195
|
+
"notificationForm",
|
|
7196
|
+
"pages",
|
|
7197
|
+
pageIndex,
|
|
7198
|
+
"fields",
|
|
7199
|
+
fieldIndex
|
|
7200
|
+
];
|
|
7201
|
+
const matchingFields = declarationFields.filter(
|
|
7202
|
+
(declarationField) => declarationField.field.id === field3.id
|
|
7203
|
+
);
|
|
7204
|
+
if (matchingFields.length === 0) {
|
|
7205
|
+
ctx.addIssue({
|
|
7206
|
+
code: "custom",
|
|
7207
|
+
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.`,
|
|
7208
|
+
path
|
|
7209
|
+
});
|
|
7210
|
+
return;
|
|
7211
|
+
}
|
|
7212
|
+
if (!matchingFields.some(
|
|
7213
|
+
(declarationField) => declarationField.field.type === field3.type
|
|
7214
|
+
)) {
|
|
7215
|
+
const [declarationField] = matchingFields;
|
|
7216
|
+
ctx.addIssue({
|
|
7217
|
+
code: "custom",
|
|
7218
|
+
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}.`,
|
|
7219
|
+
path
|
|
7220
|
+
});
|
|
7221
|
+
}
|
|
7222
|
+
});
|
|
7223
|
+
});
|
|
7224
|
+
});
|
|
7225
|
+
}
|
|
6840
7226
|
|
|
6841
7227
|
// ../commons/src/events/EventConfig.ts
|
|
6842
7228
|
var EventFieldReference = z35.object({ $$event: EventMetadataDateFieldIdInput }).describe(
|
|
6843
7229
|
"Reference to a field defined in the event metadata, using the field id."
|
|
6844
7230
|
);
|
|
6845
|
-
var
|
|
7231
|
+
var eventLevelFields = {
|
|
6846
7232
|
id: z35.string().describe(
|
|
6847
7233
|
'Machine-readable identifier of the event (e.g. "birth", "death").'
|
|
6848
7234
|
),
|
|
7235
|
+
label: TranslationConfig.describe("Human-readable label for the event type."),
|
|
7236
|
+
advancedSearch: z35.array(AdvancedSearchConfig).optional().default([]).describe(
|
|
7237
|
+
"Configuration of fields available in the advanced search feature."
|
|
7238
|
+
)
|
|
7239
|
+
};
|
|
7240
|
+
var versionFields = {
|
|
6849
7241
|
dateOfEvent: FieldReference.or(EventFieldReference).optional().describe(
|
|
6850
7242
|
"Reference to the field capturing the date of the event (e.g. date of birth). Defaults to the event creation date if unspecified."
|
|
6851
7243
|
),
|
|
@@ -6861,19 +7253,12 @@ var _EventConfigBase = z35.object({
|
|
|
6861
7253
|
summary: SummaryConfig.describe(
|
|
6862
7254
|
"Summary information displayed in the event overview."
|
|
6863
7255
|
),
|
|
6864
|
-
label: TranslationConfig.describe("Human-readable label for the event type."),
|
|
6865
7256
|
actions: z35.array(ActionConfig).describe(
|
|
6866
7257
|
"Configuration of core and custom actions associated with the event."
|
|
6867
7258
|
),
|
|
6868
7259
|
actionOrder: z35.array(z35.string()).optional().describe(
|
|
6869
7260
|
"Order of actions in the action menu. Use either the action type for core actions or the customActionType for custom actions."
|
|
6870
7261
|
),
|
|
6871
|
-
declaration: DeclarationFormConfig.describe(
|
|
6872
|
-
"Configuration of the form used to gather event data."
|
|
6873
|
-
),
|
|
6874
|
-
advancedSearch: z35.array(AdvancedSearchConfig).optional().default([]).describe(
|
|
6875
|
-
"Configuration of fields available in the advanced search feature."
|
|
6876
|
-
),
|
|
6877
7262
|
flags: z35.array(FlagConfig).optional().default([]).describe(
|
|
6878
7263
|
"Configuration of custom flags associated with the actions of this event type."
|
|
6879
7264
|
),
|
|
@@ -6883,17 +7268,180 @@ var _EventConfigBase = z35.object({
|
|
|
6883
7268
|
icon: z35.partialRecord(AvailableIcons, Conditional).optional().describe(
|
|
6884
7269
|
'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.'
|
|
6885
7270
|
)
|
|
6886
|
-
}
|
|
6887
|
-
var
|
|
7271
|
+
};
|
|
7272
|
+
var _EventConfigBase = z35.object({ ...eventLevelFields, ...versionFields });
|
|
7273
|
+
function validateEventConfig(event2, ctx) {
|
|
7274
|
+
if (!validateExactlyOneDeclareAction(event2, ctx)) {
|
|
7275
|
+
return;
|
|
7276
|
+
}
|
|
7277
|
+
validateNotificationForm(event2, ctx);
|
|
6888
7278
|
validateAdvancedSearchConfig(event2, ctx);
|
|
6889
7279
|
validateDateOfEvent(event2, ctx);
|
|
6890
7280
|
validatePlaceOfEvent(event2, ctx);
|
|
6891
7281
|
validateActionFlags(event2, ctx);
|
|
6892
7282
|
validateActionOrder(event2, ctx);
|
|
6893
|
-
}
|
|
7283
|
+
}
|
|
7284
|
+
var EventConfig2 = _EventConfigBase.superRefine(validateEventConfig).meta({
|
|
6894
7285
|
id: "EventConfig",
|
|
6895
7286
|
description: "Configuration defining an event type registered in OpenCRVS (for example birth or death)."
|
|
6896
7287
|
});
|
|
7288
|
+
var INITIAL_EVENT_CONFIG_VERSION_ID = "initial";
|
|
7289
|
+
var DEFAULT_EFFECTIVE_FROM = "0001-01-01";
|
|
7290
|
+
var _EventConfigVersion = z35.object({
|
|
7291
|
+
id: z35.string().describe(
|
|
7292
|
+
'Identifier of the version, unique within the event (e.g. "birth-v2").'
|
|
7293
|
+
),
|
|
7294
|
+
label: TranslationConfig.describe(
|
|
7295
|
+
'Name of the version, which the UI shows wherever it names the version. For example, "{event.configVersionLabel}" in the event summary.'
|
|
7296
|
+
),
|
|
7297
|
+
effectiveFrom: z35.iso.date().default(DEFAULT_EFFECTIVE_FROM).describe(
|
|
7298
|
+
`Date (YYYY-MM-DD) from which this version is effective. A version without one is effective from the beginning of time ('${DEFAULT_EFFECTIVE_FROM}').`
|
|
7299
|
+
),
|
|
7300
|
+
...versionFields
|
|
7301
|
+
});
|
|
7302
|
+
var resolvedConfigs = /* @__PURE__ */ new WeakMap();
|
|
7303
|
+
function toEventConfig(config, version) {
|
|
7304
|
+
let resolvedVersions = resolvedConfigs.get(config);
|
|
7305
|
+
if (!resolvedVersions) {
|
|
7306
|
+
resolvedVersions = /* @__PURE__ */ new WeakMap();
|
|
7307
|
+
resolvedConfigs.set(config, resolvedVersions);
|
|
7308
|
+
}
|
|
7309
|
+
const cached = resolvedVersions.get(version);
|
|
7310
|
+
if (cached) {
|
|
7311
|
+
return cached;
|
|
7312
|
+
}
|
|
7313
|
+
const {
|
|
7314
|
+
id: _id,
|
|
7315
|
+
label: _label,
|
|
7316
|
+
effectiveFrom: _effectiveFrom,
|
|
7317
|
+
...fields
|
|
7318
|
+
} = version;
|
|
7319
|
+
const resolved = {
|
|
7320
|
+
...fields,
|
|
7321
|
+
id: config.id,
|
|
7322
|
+
label: config.label,
|
|
7323
|
+
advancedSearch: config.advancedSearch
|
|
7324
|
+
};
|
|
7325
|
+
resolvedVersions.set(version, resolved);
|
|
7326
|
+
return resolved;
|
|
7327
|
+
}
|
|
7328
|
+
function findConfigVersion(config, versionId) {
|
|
7329
|
+
return config.versions.find(({ id }) => id === versionId);
|
|
7330
|
+
}
|
|
7331
|
+
function getConfigVersion(config, versionId) {
|
|
7332
|
+
return getOrThrow(
|
|
7333
|
+
findConfigVersion(config, versionId),
|
|
7334
|
+
`Event '${config.id}' has no version '${versionId}'`
|
|
7335
|
+
);
|
|
7336
|
+
}
|
|
7337
|
+
function getEventConfigOfVersion(config, versionId) {
|
|
7338
|
+
return toEventConfig(config, getConfigVersion(config, versionId));
|
|
7339
|
+
}
|
|
7340
|
+
function byEffectiveFrom(a, b) {
|
|
7341
|
+
return a.effectiveFrom.localeCompare(b.effectiveFrom);
|
|
7342
|
+
}
|
|
7343
|
+
function getVersionsInEffectOn(config, date) {
|
|
7344
|
+
return config.versions.filter(({ effectiveFrom }) => effectiveFrom <= date).sort(byEffectiveFrom);
|
|
7345
|
+
}
|
|
7346
|
+
function findVersionInEffectOn(config, date) {
|
|
7347
|
+
return getVersionsInEffectOn(config, date).at(-1);
|
|
7348
|
+
}
|
|
7349
|
+
function getVersionsInEffect(config, now2, timeZone) {
|
|
7350
|
+
return getVersionsInEffectOn(config, toPlainDateInTimeZone(now2, timeZone));
|
|
7351
|
+
}
|
|
7352
|
+
function resolveEffectiveVersion(config, now2, timeZone) {
|
|
7353
|
+
return findVersionInEffectOn(config, toPlainDateInTimeZone(now2, timeZone));
|
|
7354
|
+
}
|
|
7355
|
+
function findEventConfigForRecord(config, record8) {
|
|
7356
|
+
const version = findConfigVersion(config, record8.configVersionId);
|
|
7357
|
+
return version && toEventConfig(config, version);
|
|
7358
|
+
}
|
|
7359
|
+
function getEventConfigForRecord(config, record8) {
|
|
7360
|
+
return getEventConfigOfVersion(config, record8.configVersionId);
|
|
7361
|
+
}
|
|
7362
|
+
function resolveEventConfigOnDate(config, date) {
|
|
7363
|
+
return toEventConfig(
|
|
7364
|
+
config,
|
|
7365
|
+
getOrThrow(
|
|
7366
|
+
findVersionInEffectOn(config, date),
|
|
7367
|
+
`Event '${config.id}' has no version in effect on ${date}`
|
|
7368
|
+
)
|
|
7369
|
+
);
|
|
7370
|
+
}
|
|
7371
|
+
function resolveEventConfigInTimeZone(config, timeZone, now2 = /* @__PURE__ */ new Date()) {
|
|
7372
|
+
return resolveEventConfigOnDate(config, toPlainDateInTimeZone(now2, timeZone));
|
|
7373
|
+
}
|
|
7374
|
+
function resolveEventConfig(config) {
|
|
7375
|
+
return resolveEventConfigInTimeZone(config, "UTC");
|
|
7376
|
+
}
|
|
7377
|
+
function validateVersionList(config, ctx) {
|
|
7378
|
+
const ids = /* @__PURE__ */ new Set();
|
|
7379
|
+
const versionIdByEffectiveFrom = /* @__PURE__ */ new Map();
|
|
7380
|
+
config.versions.forEach((version, index) => {
|
|
7381
|
+
if (ids.has(version.id)) {
|
|
7382
|
+
ctx.addIssue({
|
|
7383
|
+
code: "custom",
|
|
7384
|
+
message: `Event '${config.id}' has more than one version with id '${version.id}'. Each version must have a different id.`,
|
|
7385
|
+
path: ["versions", index, "id"]
|
|
7386
|
+
});
|
|
7387
|
+
}
|
|
7388
|
+
ids.add(version.id);
|
|
7389
|
+
const sameEffectiveFromId = versionIdByEffectiveFrom.get(
|
|
7390
|
+
version.effectiveFrom
|
|
7391
|
+
);
|
|
7392
|
+
if (sameEffectiveFromId !== void 0) {
|
|
7393
|
+
const versionIds = `'${sameEffectiveFromId}', '${version.id}'`;
|
|
7394
|
+
ctx.addIssue({
|
|
7395
|
+
code: "custom",
|
|
7396
|
+
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.`,
|
|
7397
|
+
path: ["versions", index, "effectiveFrom"]
|
|
7398
|
+
});
|
|
7399
|
+
} else {
|
|
7400
|
+
versionIdByEffectiveFrom.set(version.effectiveFrom, version.id);
|
|
7401
|
+
}
|
|
7402
|
+
});
|
|
7403
|
+
}
|
|
7404
|
+
function validateEachVersion(ctx, events, validate2) {
|
|
7405
|
+
const reported = /* @__PURE__ */ new Set();
|
|
7406
|
+
events.forEach((event2, index) => {
|
|
7407
|
+
const addIssue = (issue) => {
|
|
7408
|
+
if (typeof issue === "string") {
|
|
7409
|
+
ctx.addIssue({
|
|
7410
|
+
code: "custom",
|
|
7411
|
+
message: issue,
|
|
7412
|
+
path: ["versions", index]
|
|
7413
|
+
});
|
|
7414
|
+
return;
|
|
7415
|
+
}
|
|
7416
|
+
const [field3] = issue.path ?? [];
|
|
7417
|
+
const isEventLevel = typeof field3 === "string" && field3 in eventLevelFields;
|
|
7418
|
+
const path = isEventLevel ? issue.path ?? [] : ["versions", index, ...issue.path ?? []];
|
|
7419
|
+
const key = JSON.stringify([path, issue.message]);
|
|
7420
|
+
if (reported.has(key)) {
|
|
7421
|
+
return;
|
|
7422
|
+
}
|
|
7423
|
+
reported.add(key);
|
|
7424
|
+
ctx.addIssue({ ...issue, path });
|
|
7425
|
+
};
|
|
7426
|
+
validate2(event2, { value: event2, addIssue });
|
|
7427
|
+
});
|
|
7428
|
+
}
|
|
7429
|
+
var VersionedEventConfig2 = z35.object({
|
|
7430
|
+
...eventLevelFields,
|
|
7431
|
+
versions: z35.array(_EventConfigVersion).min(1).describe(
|
|
7432
|
+
`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}'.`
|
|
7433
|
+
)
|
|
7434
|
+
}).superRefine((config, ctx) => {
|
|
7435
|
+
validateVersionList(config, ctx);
|
|
7436
|
+
validateEachVersion(
|
|
7437
|
+
ctx,
|
|
7438
|
+
config.versions.map((version) => toEventConfig(config, version)),
|
|
7439
|
+
validateEventConfig
|
|
7440
|
+
);
|
|
7441
|
+
}).meta({
|
|
7442
|
+
id: "VersionedEventConfig",
|
|
7443
|
+
description: "Configuration of an event type registered in OpenCRVS (for example birth or death), with every version of it."
|
|
7444
|
+
});
|
|
6897
7445
|
|
|
6898
7446
|
// ../commons/src/events/EventConfigInput.ts
|
|
6899
7447
|
var defineDeclarationForm = (form) => DeclarationFormConfig.parse(form);
|
|
@@ -6966,7 +7514,7 @@ function createSearchConfig(baseField) {
|
|
|
6966
7514
|
|
|
6967
7515
|
// ../commons/src/event-config/event-configuration.ts
|
|
6968
7516
|
function isNonSearchableEventMetadataTimeFieldId(fieldId) {
|
|
6969
|
-
return !EventFieldIdInput.
|
|
7517
|
+
return !EventFieldIdInput.validate(fieldId);
|
|
6970
7518
|
}
|
|
6971
7519
|
function createEventFieldConfig(fieldId) {
|
|
6972
7520
|
const baseField = {
|
|
@@ -6991,9 +7539,20 @@ function createEventFieldConfig(fieldId) {
|
|
|
6991
7539
|
function eventFn(fieldId) {
|
|
6992
7540
|
return createEventFieldConfig(fieldId);
|
|
6993
7541
|
}
|
|
7542
|
+
function actionDateReference(match, occurrence) {
|
|
7543
|
+
return {
|
|
7544
|
+
$action: {
|
|
7545
|
+
match: match.map((m) => typeof m === "string" ? { type: m } : m),
|
|
7546
|
+
occurrence
|
|
7547
|
+
}
|
|
7548
|
+
};
|
|
7549
|
+
}
|
|
6994
7550
|
var event = Object.assign(eventFn, {
|
|
6995
7551
|
/**
|
|
6996
|
-
* Checks if the event contains a specific action type.
|
|
7552
|
+
* Checks if the event contains a specific accepted action type.
|
|
7553
|
+
* Only Accepted actions are matched: a confirmable action is stored as a
|
|
7554
|
+
* Requested and an Accepted action, and a pending or rejected request must
|
|
7555
|
+
* not count as the action having happened.
|
|
6997
7556
|
* Can be used directly as a conditional or chained with additional methods.
|
|
6998
7557
|
* @param action - The action type to check for.
|
|
6999
7558
|
*/
|
|
@@ -7011,9 +7570,12 @@ var event = Object.assign(eventFn, {
|
|
|
7011
7570
|
properties: {
|
|
7012
7571
|
type: {
|
|
7013
7572
|
const: action
|
|
7573
|
+
},
|
|
7574
|
+
status: {
|
|
7575
|
+
const: ActionStatus.Accepted
|
|
7014
7576
|
}
|
|
7015
7577
|
},
|
|
7016
|
-
required: ["type"]
|
|
7578
|
+
required: ["type", "status"]
|
|
7017
7579
|
}
|
|
7018
7580
|
}
|
|
7019
7581
|
},
|
|
@@ -7024,9 +7586,10 @@ var event = Object.assign(eventFn, {
|
|
|
7024
7586
|
});
|
|
7025
7587
|
const buildActionConstraints = (additionalFields) => {
|
|
7026
7588
|
const actionProperties = {
|
|
7027
|
-
type: { const: action }
|
|
7589
|
+
type: { const: action },
|
|
7590
|
+
status: { const: ActionStatus.Accepted }
|
|
7028
7591
|
};
|
|
7029
|
-
const requiredFields = ["type"];
|
|
7592
|
+
const requiredFields = ["type", "status"];
|
|
7030
7593
|
if (additionalFields) {
|
|
7031
7594
|
Object.entries(additionalFields).forEach(([key, value]) => {
|
|
7032
7595
|
actionProperties[key] = { const: value };
|
|
@@ -7100,6 +7663,16 @@ var event = Object.assign(eventFn, {
|
|
|
7100
7663
|
$event: field3
|
|
7101
7664
|
};
|
|
7102
7665
|
},
|
|
7666
|
+
/**
|
|
7667
|
+
* References the date of the first action matching any of the given types,
|
|
7668
|
+
* e.g. `field('child.dob').isAfter().days(30).beforeAction(event.firstAction(ActionType.DECLARE))`.
|
|
7669
|
+
* Until a matching action exists, the comparison uses $now.
|
|
7670
|
+
*/
|
|
7671
|
+
firstAction: (first, ...rest) => actionDateReference([first, ...rest], "first"),
|
|
7672
|
+
/**
|
|
7673
|
+
* Like {@link event.firstAction}, but references the most recent matching action.
|
|
7674
|
+
*/
|
|
7675
|
+
lastAction: (first, ...rest) => actionDateReference([first, ...rest], "last"),
|
|
7103
7676
|
/**
|
|
7104
7677
|
* Checks if the event currently has the given status.
|
|
7105
7678
|
* @param eventStatus - The status to check for.
|
|
@@ -7148,7 +7721,7 @@ var SerializableWithin = z37.object({
|
|
|
7148
7721
|
});
|
|
7149
7722
|
var SerializedQueryExpression = z37.object({
|
|
7150
7723
|
eventType: z37.string(),
|
|
7151
|
-
status: z37.optional(z37.union([AnyOfStatus, ExactStatus])),
|
|
7724
|
+
status: z37.optional(z37.union([AnyOfStatus, NoneOfStatus, ExactStatus])),
|
|
7152
7725
|
createdAt: z37.optional(DateCondition),
|
|
7153
7726
|
updatedAt: z37.optional(DateCondition),
|
|
7154
7727
|
"legalStatuses.DECLARED.createdAtLocation": z37.optional(SerializableWithin),
|
|
@@ -7157,6 +7730,7 @@ var SerializedQueryExpression = z37.object({
|
|
|
7157
7730
|
"legalStatuses.REGISTERED.createdAtLocation": z37.optional(SerializableWithin),
|
|
7158
7731
|
"legalStatuses.REGISTERED.createdByRole": z37.optional(AnyOf),
|
|
7159
7732
|
"legalStatuses.REGISTERED.registrationNumber": z37.optional(Exact),
|
|
7733
|
+
"legalStatuses.REVOKED.createdAtLocation": z37.optional(SerializableWithin),
|
|
7160
7734
|
createdAtLocation: z37.optional(
|
|
7161
7735
|
z37.union([SerializableWithin, SerializableExact])
|
|
7162
7736
|
),
|
|
@@ -7317,6 +7891,12 @@ var RegisterActionInput = BaseActionInput.extend(
|
|
|
7317
7891
|
var NotifyActionInput = BaseActionInput.extend(
|
|
7318
7892
|
z39.object({
|
|
7319
7893
|
type: z39.literal(ActionType.NOTIFY).default(ActionType.NOTIFY),
|
|
7894
|
+
declaration: BaseActionInput.shape.declaration.describe(
|
|
7895
|
+
"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."
|
|
7896
|
+
),
|
|
7897
|
+
annotation: BaseActionInput.shape.annotation.describe(
|
|
7898
|
+
"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."
|
|
7899
|
+
),
|
|
7320
7900
|
// For normal users, the createdAtLocation is resolved on the backend from the user's primaryOfficeId.
|
|
7321
7901
|
createdAtLocation: UUID.nullish().describe(
|
|
7322
7902
|
"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."
|
|
@@ -7389,6 +7969,16 @@ var UnarchiveActionInput = BaseActionInput.extend(
|
|
|
7389
7969
|
type: z39.literal(ActionType.UNARCHIVE).default(ActionType.UNARCHIVE)
|
|
7390
7970
|
}).shape
|
|
7391
7971
|
);
|
|
7972
|
+
var RevokeRegistrationActionInput = BaseActionInput.extend(
|
|
7973
|
+
z39.object({
|
|
7974
|
+
type: z39.literal(ActionType.REVOKE_REGISTRATION).default(ActionType.REVOKE_REGISTRATION)
|
|
7975
|
+
}).shape
|
|
7976
|
+
);
|
|
7977
|
+
var ReinstateRegistrationActionInput = BaseActionInput.extend(
|
|
7978
|
+
z39.object({
|
|
7979
|
+
type: z39.literal(ActionType.REINSTATE_REGISTRATION).default(ActionType.REINSTATE_REGISTRATION)
|
|
7980
|
+
}).shape
|
|
7981
|
+
);
|
|
7392
7982
|
var AssignActionInput = BaseActionInput.extend(
|
|
7393
7983
|
z39.object({
|
|
7394
7984
|
type: z39.literal(ActionType.ASSIGN),
|
|
@@ -7451,6 +8041,12 @@ var ActionInput = z39.discriminatedUnion("type", [
|
|
|
7451
8041
|
}),
|
|
7452
8042
|
ArchiveActionInput.meta({ id: "ArchiveActionInput" }),
|
|
7453
8043
|
UnarchiveActionInput.meta({ id: "UnarchiveActionInput" }),
|
|
8044
|
+
RevokeRegistrationActionInput.meta({
|
|
8045
|
+
id: "RevokeRegistrationActionInput"
|
|
8046
|
+
}),
|
|
8047
|
+
ReinstateRegistrationActionInput.meta({
|
|
8048
|
+
id: "ReinstateRegistrationActionInput"
|
|
8049
|
+
}),
|
|
7454
8050
|
AssignActionInput.meta({ id: "AssignActionInput" }),
|
|
7455
8051
|
UnassignActionInput.meta({ id: "UnassignActionInput" }),
|
|
7456
8052
|
PrintCertificateActionInput.meta({ id: "PrintCertificateActionInput" }),
|
|
@@ -7484,17 +8080,19 @@ var DraftInput = BaseActionInput.omit({ waitFor: true }).extend({
|
|
|
7484
8080
|
/*
|
|
7485
8081
|
* A draft can name a file that no action references. Such a file stays until
|
|
7486
8082
|
* the record is deleted or the record's next action sweeps its prefix.
|
|
7487
|
-
*
|
|
7488
|
-
*
|
|
7489
|
-
* which is about to be declared or registered.
|
|
8083
|
+
* Drafts are therefore saved only on a created record, which can still be deleted.
|
|
8084
|
+
* The server refuses them on any other record.
|
|
7490
8085
|
*/
|
|
7491
|
-
type: z40.
|
|
8086
|
+
type: z40.enum([ActionTypes.enum.DECLARE, ActionTypes.enum.NOTIFY]),
|
|
7492
8087
|
status: z40.enum([
|
|
7493
8088
|
ActionStatus.Requested,
|
|
7494
8089
|
ActionStatus.Accepted,
|
|
7495
8090
|
ActionStatus.Rejected
|
|
7496
8091
|
])
|
|
7497
8092
|
});
|
|
8093
|
+
var RemoteDraft = Draft.extend({
|
|
8094
|
+
action: Draft.shape.action.extend({ type: DraftInput.shape.type })
|
|
8095
|
+
});
|
|
7498
8096
|
|
|
7499
8097
|
// ../commons/src/events/EventInput.ts
|
|
7500
8098
|
var z41 = __toESM(require("zod/v4"));
|
|
@@ -7504,6 +8102,9 @@ var EventInput = z41.object({
|
|
|
7504
8102
|
type: z41.string(),
|
|
7505
8103
|
createdAtLocation: UUID.nullish().describe(
|
|
7506
8104
|
"Location where the event occurred. Required for system users."
|
|
8105
|
+
),
|
|
8106
|
+
configVersionId: z41.string().optional().describe(
|
|
8107
|
+
"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."
|
|
7507
8108
|
)
|
|
7508
8109
|
}).meta({ default: { transactionId: (0, import_uuid11.v4)(), type: "birth" } });
|
|
7509
8110
|
|
|
@@ -7519,6 +8120,9 @@ var EventDocument = z42.object({
|
|
|
7519
8120
|
actions: z42.array(Action).describe("Ordered list of actions associated with the event."),
|
|
7520
8121
|
trackingId: z42.string().describe(
|
|
7521
8122
|
"System-generated tracking identifier used to look up the event."
|
|
8123
|
+
),
|
|
8124
|
+
configVersionId: z42.string().describe(
|
|
8125
|
+
"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'."
|
|
7522
8126
|
)
|
|
7523
8127
|
}).meta({ id: "EventDocument" });
|
|
7524
8128
|
var EventDocumentOnlyLastAction = EventDocument.extend({
|
|
@@ -7526,10 +8130,114 @@ var EventDocumentOnlyLastAction = EventDocument.extend({
|
|
|
7526
8130
|
}).brand("EventDocumentOnlyLastAction");
|
|
7527
8131
|
|
|
7528
8132
|
// ../commons/src/events/defineConfig.ts
|
|
7529
|
-
var
|
|
7530
|
-
|
|
7531
|
-
|
|
7532
|
-
|
|
8133
|
+
var z43 = __toESM(require("zod/v4"));
|
|
8134
|
+
function moveDeclarationToDeclareAction({
|
|
8135
|
+
declaration,
|
|
8136
|
+
...config
|
|
8137
|
+
}) {
|
|
8138
|
+
if (declaration) {
|
|
8139
|
+
console.warn(
|
|
8140
|
+
`Event '${config.id}' defines \`declaration\` at the top level, which is deprecated and will be removed in a future release. Define it on the ${ActionType.DECLARE} action instead.`
|
|
8141
|
+
);
|
|
8142
|
+
}
|
|
8143
|
+
return {
|
|
8144
|
+
...config,
|
|
8145
|
+
actions: config.actions.map((action) => {
|
|
8146
|
+
if (action.type !== ActionType.DECLARE) {
|
|
8147
|
+
return action;
|
|
8148
|
+
}
|
|
8149
|
+
const declarationOfAction = action.declaration ?? declaration;
|
|
8150
|
+
if (!declarationOfAction) {
|
|
8151
|
+
throw new Error(`Event '${config.id}' does not define \`declaration\`.`);
|
|
8152
|
+
}
|
|
8153
|
+
return { ...action, declaration: declarationOfAction };
|
|
8154
|
+
})
|
|
8155
|
+
};
|
|
8156
|
+
}
|
|
8157
|
+
var VERSIONED_EVENT_FIELDS = [
|
|
8158
|
+
"id",
|
|
8159
|
+
"label",
|
|
8160
|
+
"advancedSearch",
|
|
8161
|
+
"versions"
|
|
8162
|
+
];
|
|
8163
|
+
function validateNoVersionFieldsAtTopLevel(config, ctx) {
|
|
8164
|
+
Object.keys(config).filter((key) => !VERSIONED_EVENT_FIELDS.includes(key)).forEach((key) => {
|
|
8165
|
+
ctx.addIssue({
|
|
8166
|
+
code: "custom",
|
|
8167
|
+
message: `Event '${config.id}' defines \`versions\`, so \`${key}\` must be defined on each version, not at the top level.`,
|
|
8168
|
+
path: [key]
|
|
8169
|
+
});
|
|
8170
|
+
});
|
|
8171
|
+
}
|
|
8172
|
+
function toVersionedInput(config) {
|
|
8173
|
+
if ("versions" in config) {
|
|
8174
|
+
return config;
|
|
8175
|
+
}
|
|
8176
|
+
const { id, label, advancedSearch, ...version } = moveDeclarationToDeclareAction(config);
|
|
8177
|
+
return {
|
|
8178
|
+
id,
|
|
8179
|
+
label,
|
|
8180
|
+
advancedSearch,
|
|
8181
|
+
versions: [{ ...version, id: INITIAL_EVENT_CONFIG_VERSION_ID, label }]
|
|
8182
|
+
};
|
|
8183
|
+
}
|
|
8184
|
+
var WESTERNMOST_TIME_ZONE = "Etc/GMT+12";
|
|
8185
|
+
function validateVersionInEffectToday(config, ctx) {
|
|
8186
|
+
const today = toPlainDateInTimeZone(/* @__PURE__ */ new Date(), WESTERNMOST_TIME_ZONE);
|
|
8187
|
+
const isAnyVersionInEffect = config.versions.some(
|
|
8188
|
+
({ effectiveFrom }) => effectiveFrom <= today
|
|
8189
|
+
);
|
|
8190
|
+
if (!isAnyVersionInEffect) {
|
|
8191
|
+
ctx.addIssue({
|
|
8192
|
+
code: "custom",
|
|
8193
|
+
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.`,
|
|
8194
|
+
path: ["versions"]
|
|
8195
|
+
});
|
|
8196
|
+
}
|
|
8197
|
+
}
|
|
8198
|
+
var EventConfigDefinition = z43.custom().superRefine((config, ctx) => {
|
|
8199
|
+
if ("versions" in config) {
|
|
8200
|
+
validateNoVersionFieldsAtTopLevel(config, ctx);
|
|
8201
|
+
return;
|
|
8202
|
+
}
|
|
8203
|
+
const eventCtx = { ...ctx, value: config };
|
|
8204
|
+
if (validateExactlyOneDeclareAction(config, eventCtx)) {
|
|
8205
|
+
validateDeclarationGivenExactlyOnce(config, eventCtx);
|
|
8206
|
+
}
|
|
8207
|
+
}).transform(toVersionedInput).pipe(VersionedEventConfig2).superRefine(validateVersionInEffectToday);
|
|
8208
|
+
var defineConfig = (config) => EventConfigDefinition.parse(config);
|
|
8209
|
+
|
|
8210
|
+
// ../commons/src/events/toNotificationForm.ts
|
|
8211
|
+
function toOptionalField(field3) {
|
|
8212
|
+
const { validation: _validation, ...rest } = field3;
|
|
8213
|
+
if (rest.type === FieldType.FIELD_GROUP && "fields" in rest) {
|
|
8214
|
+
return {
|
|
8215
|
+
...rest,
|
|
8216
|
+
required: false,
|
|
8217
|
+
fields: rest.fields.map(toOptionalField)
|
|
8218
|
+
};
|
|
8219
|
+
}
|
|
8220
|
+
return { ...rest, required: false };
|
|
8221
|
+
}
|
|
8222
|
+
function toNotificationForm(declaration) {
|
|
8223
|
+
return {
|
|
8224
|
+
...declaration,
|
|
8225
|
+
pages: declaration.pages.map((page) => ({
|
|
8226
|
+
...page,
|
|
8227
|
+
fields: page.fields.map(
|
|
8228
|
+
toOptionalField
|
|
8229
|
+
)
|
|
8230
|
+
}))
|
|
8231
|
+
};
|
|
8232
|
+
}
|
|
8233
|
+
function toNotificationReview(review) {
|
|
8234
|
+
return {
|
|
8235
|
+
...review,
|
|
8236
|
+
fields: review.fields.map(
|
|
8237
|
+
toOptionalField
|
|
8238
|
+
)
|
|
8239
|
+
};
|
|
8240
|
+
}
|
|
7533
8241
|
|
|
7534
8242
|
// ../commons/src/events/transactions.ts
|
|
7535
8243
|
function generateTransactionId() {
|
|
@@ -8787,7 +9495,7 @@ var TENNIS_CLUB_DECLARATION_FORM = defineDeclarationForm({
|
|
|
8787
9495
|
});
|
|
8788
9496
|
|
|
8789
9497
|
// ../commons/src/fixtures/tennis-club-membership-event.ts
|
|
8790
|
-
var
|
|
9498
|
+
var versionedTennisClubMembershipEvent = defineConfig({
|
|
8791
9499
|
id: TENNIS_CLUB_MEMBERSHIP,
|
|
8792
9500
|
declaration: TENNIS_CLUB_DECLARATION_FORM,
|
|
8793
9501
|
label: {
|
|
@@ -8846,6 +9554,8 @@ var tennisClubMembershipEvent = defineConfig({
|
|
|
8846
9554
|
description: "This is shown as the action name anywhere the user can trigger the action from",
|
|
8847
9555
|
id: "event.tennis-club-membership.action.notify.label"
|
|
8848
9556
|
},
|
|
9557
|
+
notificationForm: toNotificationForm(TENNIS_CLUB_DECLARATION_FORM),
|
|
9558
|
+
review: toNotificationReview(TENNIS_CLUB_DECLARATION_REVIEW),
|
|
8849
9559
|
flags: [
|
|
8850
9560
|
{
|
|
8851
9561
|
id: "health-worker-notified",
|
|
@@ -9142,9 +9852,12 @@ var tennisClubMembershipEvent = defineConfig({
|
|
|
9142
9852
|
}
|
|
9143
9853
|
]
|
|
9144
9854
|
});
|
|
9855
|
+
var tennisClubMembershipEvent = resolveEventConfig(
|
|
9856
|
+
versionedTennisClubMembershipEvent
|
|
9857
|
+
);
|
|
9145
9858
|
|
|
9146
9859
|
// ../commons/src/fixtures/football-club-membership-event.ts
|
|
9147
|
-
var
|
|
9860
|
+
var versionedFootballClubMembershipEvent = defineConfig({
|
|
9148
9861
|
id: "FOOTBALL_CLUB_MEMBERSHIP",
|
|
9149
9862
|
label: {
|
|
9150
9863
|
defaultMessage: "Football club membership application",
|
|
@@ -9467,6 +10180,9 @@ var footballClubMembershipEvent = defineConfig({
|
|
|
9467
10180
|
],
|
|
9468
10181
|
declaration: TENNIS_CLUB_DECLARATION_FORM
|
|
9469
10182
|
});
|
|
10183
|
+
var footballClubMembershipEvent = resolveEventConfig(
|
|
10184
|
+
versionedFootballClubMembershipEvent
|
|
10185
|
+
);
|
|
9470
10186
|
|
|
9471
10187
|
// ../commons/src/fixtures/library-membership-event.ts
|
|
9472
10188
|
var libraryMembershipForm = defineDeclarationForm({
|
|
@@ -9510,7 +10226,7 @@ var libraryMembershipForm = defineDeclarationForm({
|
|
|
9510
10226
|
}
|
|
9511
10227
|
]
|
|
9512
10228
|
});
|
|
9513
|
-
var
|
|
10229
|
+
var versionedLibraryMembershipEvent = defineConfig({
|
|
9514
10230
|
id: "library-membership",
|
|
9515
10231
|
label: {
|
|
9516
10232
|
defaultMessage: "Library membership application",
|
|
@@ -9523,9 +10239,29 @@ var libraryMembershipEvent = defineConfig({
|
|
|
9523
10239
|
id: "event.library-membership.title"
|
|
9524
10240
|
},
|
|
9525
10241
|
summary: { fields: [] },
|
|
9526
|
-
actions: [
|
|
10242
|
+
actions: [
|
|
10243
|
+
{
|
|
10244
|
+
type: ActionType.DECLARE,
|
|
10245
|
+
label: {
|
|
10246
|
+
defaultMessage: "Declare",
|
|
10247
|
+
description: "This is shown as the action name anywhere the user can trigger the action from",
|
|
10248
|
+
id: "event.library-membership.action.declare.label"
|
|
10249
|
+
},
|
|
10250
|
+
review: {
|
|
10251
|
+
title: {
|
|
10252
|
+
defaultMessage: "Library membership application",
|
|
10253
|
+
description: "Title of the review page",
|
|
10254
|
+
id: "event.library-membership.action.declare.form.review.title"
|
|
10255
|
+
},
|
|
10256
|
+
fields: []
|
|
10257
|
+
}
|
|
10258
|
+
}
|
|
10259
|
+
],
|
|
9527
10260
|
declaration: libraryMembershipForm
|
|
9528
10261
|
});
|
|
10262
|
+
var libraryMembershipEvent = resolveEventConfig(
|
|
10263
|
+
versionedLibraryMembershipEvent
|
|
10264
|
+
);
|
|
9529
10265
|
|
|
9530
10266
|
// ../commons/src/fixtures/child-onboarding-event.ts
|
|
9531
10267
|
function generateTranslationConfig(message) {
|
|
@@ -9739,7 +10475,7 @@ var CHILD_ONBOARDING_DECLARATION_FORM = defineDeclarationForm({
|
|
|
9739
10475
|
label: generateTranslationConfig("Birth decalration form"),
|
|
9740
10476
|
pages: [child, mother]
|
|
9741
10477
|
});
|
|
9742
|
-
var
|
|
10478
|
+
var versionedChildOnboardingEvent = defineConfig({
|
|
9743
10479
|
id: CHILD_ONBOARDING_EVENT,
|
|
9744
10480
|
title: generateTranslationConfig(
|
|
9745
10481
|
"{child.name.firstname} {child.name.surname}"
|
|
@@ -9767,6 +10503,9 @@ var ChildOnboardingEvent = defineConfig({
|
|
|
9767
10503
|
],
|
|
9768
10504
|
advancedSearch: []
|
|
9769
10505
|
});
|
|
10506
|
+
var ChildOnboardingEvent = resolveEventConfig(
|
|
10507
|
+
versionedChildOnboardingEvent
|
|
10508
|
+
);
|
|
9770
10509
|
|
|
9771
10510
|
// ../commons/src/fixtures/digital-identity-issuance-event.ts
|
|
9772
10511
|
var PRINT_DIGITAL_ID_CERTIFICATE_FORM = defineActionForm({
|
|
@@ -9955,7 +10694,7 @@ var digitalIdentityForm = defineDeclarationForm({
|
|
|
9955
10694
|
}
|
|
9956
10695
|
]
|
|
9957
10696
|
});
|
|
9958
|
-
var
|
|
10697
|
+
var versionedDigitalIdentityEvent = defineConfig({
|
|
9959
10698
|
id: "digital-identity",
|
|
9960
10699
|
label: {
|
|
9961
10700
|
defaultMessage: "Digital identity issuance",
|
|
@@ -9969,6 +10708,22 @@ var digitalIdentityEvent = defineConfig({
|
|
|
9969
10708
|
},
|
|
9970
10709
|
summary: { fields: [] },
|
|
9971
10710
|
actions: [
|
|
10711
|
+
{
|
|
10712
|
+
type: ActionType.DECLARE,
|
|
10713
|
+
label: {
|
|
10714
|
+
defaultMessage: "Declare",
|
|
10715
|
+
description: "This is shown as the action name anywhere the user can trigger the action from",
|
|
10716
|
+
id: "event.digital-identity.action.declare.label"
|
|
10717
|
+
},
|
|
10718
|
+
review: {
|
|
10719
|
+
title: {
|
|
10720
|
+
defaultMessage: "Digital identity issuance",
|
|
10721
|
+
description: "Title of the review page",
|
|
10722
|
+
id: "event.digital-identity.action.declare.form.review.title"
|
|
10723
|
+
},
|
|
10724
|
+
fields: []
|
|
10725
|
+
}
|
|
10726
|
+
},
|
|
9972
10727
|
{
|
|
9973
10728
|
type: ActionType.PRINT_CERTIFICATE,
|
|
9974
10729
|
label: {
|
|
@@ -9981,47 +10736,50 @@ var digitalIdentityEvent = defineConfig({
|
|
|
9981
10736
|
],
|
|
9982
10737
|
declaration: digitalIdentityForm
|
|
9983
10738
|
});
|
|
10739
|
+
var digitalIdentityEvent = resolveEventConfig(
|
|
10740
|
+
versionedDigitalIdentityEvent
|
|
10741
|
+
);
|
|
9984
10742
|
|
|
9985
10743
|
// ../commons/src/events/test.utils.ts
|
|
9986
|
-
var
|
|
10744
|
+
var z45 = __toESM(require("zod/v4"));
|
|
9987
10745
|
|
|
9988
10746
|
// ../commons/src/events/locations.ts
|
|
9989
|
-
var
|
|
9990
|
-
var LocationTypeV1 =
|
|
10747
|
+
var z44 = __toESM(require("zod/v4"));
|
|
10748
|
+
var LocationTypeV1 = z44.enum([
|
|
9991
10749
|
"ADMIN_STRUCTURE",
|
|
9992
10750
|
"CRVS_OFFICE",
|
|
9993
10751
|
"HEALTH_FACILITY"
|
|
9994
10752
|
]);
|
|
9995
|
-
var LocationStatus =
|
|
10753
|
+
var LocationStatus = z44.enum(["active", "inactive"]);
|
|
9996
10754
|
var InactiveOfficeError = class extends Error {
|
|
9997
10755
|
constructor(message = "Assigned office is inactive") {
|
|
9998
10756
|
super(message);
|
|
9999
10757
|
this.name = "InactiveOfficeError";
|
|
10000
10758
|
}
|
|
10001
10759
|
};
|
|
10002
|
-
var LocationVersion =
|
|
10760
|
+
var LocationVersion = z44.object({
|
|
10003
10761
|
versionId: UUID,
|
|
10004
|
-
effectiveFrom:
|
|
10005
|
-
name:
|
|
10006
|
-
externalId:
|
|
10762
|
+
effectiveFrom: z44.iso.date(),
|
|
10763
|
+
name: z44.string(),
|
|
10764
|
+
externalId: z44.string().nullish(),
|
|
10007
10765
|
status: LocationStatus
|
|
10008
10766
|
});
|
|
10009
|
-
var AdministrativeArea =
|
|
10767
|
+
var AdministrativeArea = z44.object({
|
|
10010
10768
|
id: UUID,
|
|
10011
|
-
name:
|
|
10012
|
-
externalId:
|
|
10769
|
+
name: z44.string(),
|
|
10770
|
+
externalId: z44.string().nullish(),
|
|
10013
10771
|
parentId: UUID.nullable(),
|
|
10014
10772
|
status: LocationStatus,
|
|
10015
|
-
versions:
|
|
10773
|
+
versions: z44.array(LocationVersion)
|
|
10016
10774
|
});
|
|
10017
|
-
var Location =
|
|
10775
|
+
var Location = z44.object({
|
|
10018
10776
|
id: UUID,
|
|
10019
|
-
name:
|
|
10020
|
-
externalId:
|
|
10777
|
+
name: z44.string(),
|
|
10778
|
+
externalId: z44.string().nullish(),
|
|
10021
10779
|
administrativeAreaId: UUID.nullable(),
|
|
10022
|
-
locationType:
|
|
10780
|
+
locationType: z44.string().nullable(),
|
|
10023
10781
|
status: LocationStatus,
|
|
10024
|
-
versions:
|
|
10782
|
+
versions: z44.array(LocationVersion)
|
|
10025
10783
|
});
|
|
10026
10784
|
var ClientAdministrativeArea = AdministrativeArea.omit({
|
|
10027
10785
|
name: true,
|
|
@@ -10062,22 +10820,22 @@ function validateUniqueIds(versions, ctx) {
|
|
|
10062
10820
|
ctx.addIssue("versions must not repeat a versionId");
|
|
10063
10821
|
}
|
|
10064
10822
|
}
|
|
10065
|
-
var SeededLocationVersions =
|
|
10823
|
+
var SeededLocationVersions = z44.array(LocationVersion).min(1).superRefine((versions, ctx) => {
|
|
10066
10824
|
validateAscendingDates(versions, ctx);
|
|
10067
10825
|
validateUniqueIds(versions, ctx);
|
|
10068
10826
|
});
|
|
10069
|
-
var SetLocationPayload =
|
|
10827
|
+
var SetLocationPayload = z44.object({
|
|
10070
10828
|
id: UUID,
|
|
10071
|
-
name:
|
|
10072
|
-
externalId:
|
|
10829
|
+
name: z44.string(),
|
|
10830
|
+
externalId: z44.string().nullish(),
|
|
10073
10831
|
administrativeAreaId: UUID.nullable(),
|
|
10074
|
-
locationType:
|
|
10832
|
+
locationType: z44.string().nullable(),
|
|
10075
10833
|
versions: SeededLocationVersions.optional()
|
|
10076
10834
|
});
|
|
10077
|
-
var SetAdministrativeAreaPayload =
|
|
10835
|
+
var SetAdministrativeAreaPayload = z44.object({
|
|
10078
10836
|
id: UUID,
|
|
10079
|
-
name:
|
|
10080
|
-
externalId:
|
|
10837
|
+
name: z44.string(),
|
|
10838
|
+
externalId: z44.string().nullish(),
|
|
10081
10839
|
parentId: UUID.nullable(),
|
|
10082
10840
|
versions: SeededLocationVersions.optional()
|
|
10083
10841
|
});
|
|
@@ -10280,8 +11038,8 @@ function userCanAccessEventWithScopes(event2, scopes, user2, customActionType) {
|
|
|
10280
11038
|
}
|
|
10281
11039
|
function getAdministrativeAreaHierarchy(administrativeAreaId, administrativeAreas) {
|
|
10282
11040
|
const collectedLocations = [];
|
|
10283
|
-
const
|
|
10284
|
-
let current =
|
|
11041
|
+
const maybeAdministrativeAreaId = maybeUuid(administrativeAreaId);
|
|
11042
|
+
let current = maybeAdministrativeAreaId ? administrativeAreas.get(maybeAdministrativeAreaId) : null;
|
|
10285
11043
|
while (current) {
|
|
10286
11044
|
collectedLocations.push(current);
|
|
10287
11045
|
if (!current.parentId) {
|
|
@@ -10666,7 +11424,7 @@ var V2_DEFAULT_MOCK_CLIENT_ADMINISTRATIVE_AREAS_MAP = new Map(
|
|
|
10666
11424
|
|
|
10667
11425
|
// ../commons/src/events/test.utils.ts
|
|
10668
11426
|
var TEST_SYSTEM_IANA_TIMEZONE = "Asia/Dhaka";
|
|
10669
|
-
var TestUserRole =
|
|
11427
|
+
var TestUserRole = z45.enum([
|
|
10670
11428
|
"FIELD_AGENT",
|
|
10671
11429
|
"LOCAL_REGISTRAR",
|
|
10672
11430
|
"LOCAL_SYSTEM_ADMIN",
|
|
@@ -10881,11 +11639,10 @@ function fieldConfigsToActionPayload(fields, rng, administrativeHierarchy) {
|
|
|
10881
11639
|
);
|
|
10882
11640
|
}
|
|
10883
11641
|
function generateActionDeclarationInput(configuration, action, rng, overrides, administrativeHierarchy) {
|
|
10884
|
-
const parsed = DeclarationUpdateActions.safeParse(action);
|
|
10885
11642
|
if ((0, import_lodash5.isEmpty)(overrides) && typeof overrides === "object") {
|
|
10886
11643
|
return {};
|
|
10887
11644
|
}
|
|
10888
|
-
if (
|
|
11645
|
+
if (DeclarationUpdateActions.validate(action)) {
|
|
10889
11646
|
const fields = getDeclarationFields(configuration);
|
|
10890
11647
|
const declarationConfig = getDeclaration(configuration);
|
|
10891
11648
|
const declaration = fieldConfigsToActionPayload(
|
|
@@ -11010,7 +11767,8 @@ function eventPayloadGenerator(rng, configuration = tennisClubMembershipEvent) {
|
|
|
11010
11767
|
...input
|
|
11011
11768
|
}),
|
|
11012
11769
|
/**
|
|
11013
|
-
*
|
|
11770
|
+
* NOTIFY submits the values of the notification form, and the record can stay incomplete.
|
|
11771
|
+
* When `declaration` is not given, string values are left out of the generated declaration to make it incomplete.
|
|
11014
11772
|
*/
|
|
11015
11773
|
notify: (eventId, input = {}) => {
|
|
11016
11774
|
let declaration = input.declaration;
|
|
@@ -11076,6 +11834,22 @@ function eventPayloadGenerator(rng, configuration = tennisClubMembershipEvent) {
|
|
|
11076
11834
|
eventId,
|
|
11077
11835
|
...input
|
|
11078
11836
|
}),
|
|
11837
|
+
revokeRegistration: (eventId, input = {}) => ({
|
|
11838
|
+
type: ActionType.REVOKE_REGISTRATION,
|
|
11839
|
+
transactionId: input.transactionId ?? getUUID(),
|
|
11840
|
+
declaration: {},
|
|
11841
|
+
annotation: {},
|
|
11842
|
+
eventId,
|
|
11843
|
+
...input
|
|
11844
|
+
}),
|
|
11845
|
+
reinstateRegistration: (eventId, input = {}) => ({
|
|
11846
|
+
type: ActionType.REINSTATE_REGISTRATION,
|
|
11847
|
+
transactionId: input.transactionId ?? getUUID(),
|
|
11848
|
+
declaration: {},
|
|
11849
|
+
annotation: {},
|
|
11850
|
+
eventId,
|
|
11851
|
+
...input
|
|
11852
|
+
}),
|
|
11079
11853
|
reject: (eventId, input = {}) => ({
|
|
11080
11854
|
type: ActionType.REJECT,
|
|
11081
11855
|
transactionId: input.transactionId ?? getUUID(),
|
|
@@ -11244,12 +12018,14 @@ function generateActionDocument({
|
|
|
11244
12018
|
case ActionType.REGISTER:
|
|
11245
12019
|
case ActionType.REQUEST_CORRECTION:
|
|
11246
12020
|
case ActionType.UNARCHIVE:
|
|
12021
|
+
case ActionType.REVOKE_REGISTRATION:
|
|
12022
|
+
case ActionType.REINSTATE_REGISTRATION:
|
|
11247
12023
|
return { ...actionBase, type: action };
|
|
11248
12024
|
case ActionType.EDIT:
|
|
11249
12025
|
return {
|
|
12026
|
+
content: { comment: "Test comment" },
|
|
11250
12027
|
...actionBase,
|
|
11251
|
-
type: action
|
|
11252
|
-
content: { comment: "Test comment" }
|
|
12028
|
+
type: action
|
|
11253
12029
|
};
|
|
11254
12030
|
case ActionType.CUSTOM:
|
|
11255
12031
|
return {
|
|
@@ -11268,9 +12044,9 @@ function generateActionDocument({
|
|
|
11268
12044
|
};
|
|
11269
12045
|
}
|
|
11270
12046
|
case ActionType.ARCHIVE:
|
|
11271
|
-
return {
|
|
12047
|
+
return { content: { reason: "Archive" }, ...actionBase, type: action };
|
|
11272
12048
|
case ActionType.REJECT:
|
|
11273
|
-
return {
|
|
12049
|
+
return { content: { reason: "Reject" }, ...actionBase, type: action };
|
|
11274
12050
|
case ActionType.PRINT_CERTIFICATE: {
|
|
11275
12051
|
const printActionDefaults = defaults;
|
|
11276
12052
|
return {
|
|
@@ -11280,13 +12056,13 @@ function generateActionDocument({
|
|
|
11280
12056
|
};
|
|
11281
12057
|
}
|
|
11282
12058
|
case ActionType.APPROVE_CORRECTION:
|
|
11283
|
-
return {
|
|
12059
|
+
return { requestId: getUUID(), ...actionBase, type: action };
|
|
11284
12060
|
case ActionType.REJECT_CORRECTION:
|
|
11285
12061
|
return {
|
|
11286
|
-
...actionBase,
|
|
11287
12062
|
requestId: getUUID(),
|
|
11288
|
-
|
|
11289
|
-
|
|
12063
|
+
content: { reason: "Correction rejection" },
|
|
12064
|
+
...actionBase,
|
|
12065
|
+
type: action
|
|
11290
12066
|
};
|
|
11291
12067
|
case ActionType.DUPLICATE_DETECTED: {
|
|
11292
12068
|
const duplicateActionDefaults = defaults;
|
|
@@ -11303,6 +12079,65 @@ function generateActionDocument({
|
|
|
11303
12079
|
throw new Error(`Unsupported action type: ${action}`);
|
|
11304
12080
|
}
|
|
11305
12081
|
}
|
|
12082
|
+
function isConfirmableAction(type) {
|
|
12083
|
+
return ConfirmableActions.some((confirmable) => confirmable === type);
|
|
12084
|
+
}
|
|
12085
|
+
function generateActionDocuments({
|
|
12086
|
+
confirmation,
|
|
12087
|
+
...args
|
|
12088
|
+
}) {
|
|
12089
|
+
const actionDocument = generateActionDocument(args);
|
|
12090
|
+
if (!isConfirmableAction(actionDocument.type)) {
|
|
12091
|
+
return [actionDocument];
|
|
12092
|
+
}
|
|
12093
|
+
if (args.defaults?.status !== void 0) {
|
|
12094
|
+
throw new Error(
|
|
12095
|
+
`generateActionDocuments: set the status of ${actionDocument.type} with confirmation.status, not defaults.status`
|
|
12096
|
+
);
|
|
12097
|
+
}
|
|
12098
|
+
const status2 = confirmation?.status ?? ActionStatus.Accepted;
|
|
12099
|
+
if (status2 === ActionStatus.Requested) {
|
|
12100
|
+
if (confirmation?.defaults) {
|
|
12101
|
+
throw new Error(
|
|
12102
|
+
"generateActionDocuments: confirmation.defaults have no confirming action to apply to while the request is pending"
|
|
12103
|
+
);
|
|
12104
|
+
}
|
|
12105
|
+
return [{ ...actionDocument, status: ActionStatus.Requested }];
|
|
12106
|
+
}
|
|
12107
|
+
const requestedAction = {
|
|
12108
|
+
...actionDocument,
|
|
12109
|
+
id: getUUID(),
|
|
12110
|
+
status: ActionStatus.Requested
|
|
12111
|
+
};
|
|
12112
|
+
const confirmingAction = {
|
|
12113
|
+
...actionDocument,
|
|
12114
|
+
originalActionId: requestedAction.id,
|
|
12115
|
+
createdAt: new Date(
|
|
12116
|
+
new Date(actionDocument.createdAt).getTime() + 1
|
|
12117
|
+
).toISOString(),
|
|
12118
|
+
...confirmation?.defaults
|
|
12119
|
+
};
|
|
12120
|
+
if (status2 === ActionStatus.Rejected) {
|
|
12121
|
+
const { declaration, annotation, ...rejectedAction } = confirmingAction;
|
|
12122
|
+
return [
|
|
12123
|
+
requestedAction,
|
|
12124
|
+
{
|
|
12125
|
+
...rejectedAction,
|
|
12126
|
+
type: actionDocument.type,
|
|
12127
|
+
status: ActionStatus.Rejected
|
|
12128
|
+
}
|
|
12129
|
+
];
|
|
12130
|
+
}
|
|
12131
|
+
return [
|
|
12132
|
+
requestedAction,
|
|
12133
|
+
{
|
|
12134
|
+
...confirmingAction,
|
|
12135
|
+
status: ActionStatus.Accepted,
|
|
12136
|
+
declaration: {},
|
|
12137
|
+
annotation: {}
|
|
12138
|
+
}
|
|
12139
|
+
];
|
|
12140
|
+
}
|
|
11306
12141
|
function generateRandomDatetime(rng, start, end) {
|
|
11307
12142
|
const range = end.getTime() - start.getTime();
|
|
11308
12143
|
const offset = Math.floor(rng() * range);
|
|
@@ -11321,9 +12156,20 @@ function generateEventDocument({
|
|
|
11321
12156
|
}) {
|
|
11322
12157
|
return {
|
|
11323
12158
|
trackingId: generateTrackingId(rng),
|
|
12159
|
+
configVersionId: INITIAL_EVENT_CONFIG_VERSION_ID,
|
|
11324
12160
|
type: configuration.id,
|
|
11325
|
-
actions: actions.
|
|
11326
|
-
(
|
|
12161
|
+
actions: actions.flatMap((action, i) => {
|
|
12162
|
+
const createdAt = (0, import_date_fns4.addDays)(
|
|
12163
|
+
new Date(
|
|
12164
|
+
generateRandomDatetime(
|
|
12165
|
+
rng,
|
|
12166
|
+
new Date(2025, 0, 1),
|
|
12167
|
+
new Date(2025, 11, 31)
|
|
12168
|
+
)
|
|
12169
|
+
),
|
|
12170
|
+
i
|
|
12171
|
+
);
|
|
12172
|
+
return generateActionDocuments({
|
|
11327
12173
|
configuration,
|
|
11328
12174
|
action: action.type,
|
|
11329
12175
|
defaults: {
|
|
@@ -11331,20 +12177,11 @@ function generateEventDocument({
|
|
|
11331
12177
|
createdAtLocation: action.user?.primaryOfficeId,
|
|
11332
12178
|
assignedTo: action.user?.assignedTo,
|
|
11333
12179
|
createdByRole: action.user?.role,
|
|
11334
|
-
createdAt: (
|
|
11335
|
-
new Date(
|
|
11336
|
-
generateRandomDatetime(
|
|
11337
|
-
rng,
|
|
11338
|
-
new Date(2025, 0, 1),
|
|
11339
|
-
new Date(2025, 11, 31)
|
|
11340
|
-
)
|
|
11341
|
-
),
|
|
11342
|
-
i
|
|
11343
|
-
).toISOString()
|
|
12180
|
+
createdAt: createdAt.toISOString()
|
|
11344
12181
|
},
|
|
11345
12182
|
declarationOverrides: action.declarationOverrides
|
|
11346
|
-
})
|
|
11347
|
-
),
|
|
12183
|
+
});
|
|
12184
|
+
}),
|
|
11348
12185
|
// Offset is needed so the createdAt timestamps for events, actions and drafts make logical sense in storybook tests.
|
|
11349
12186
|
// @TODO: This should be fixed in the future.
|
|
11350
12187
|
createdAt: new Date(Date.now() - 1e3).toISOString(),
|
|
@@ -11371,6 +12208,7 @@ function generateEventDraftDocument({
|
|
|
11371
12208
|
transactionId: getUUID(),
|
|
11372
12209
|
action: {
|
|
11373
12210
|
...action,
|
|
12211
|
+
type: actionType,
|
|
11374
12212
|
declaration: {
|
|
11375
12213
|
...action.declaration,
|
|
11376
12214
|
...declaration
|
|
@@ -11413,6 +12251,7 @@ var eventQueryDataGenerator = (overrides = {}, seed = 1) => {
|
|
|
11413
12251
|
return {
|
|
11414
12252
|
id: overrides.id ?? generateUuid(rng),
|
|
11415
12253
|
type: overrides.type ?? TENNIS_CLUB_MEMBERSHIP,
|
|
12254
|
+
configVersionId: overrides.configVersionId ?? INITIAL_EVENT_CONFIG_VERSION_ID,
|
|
11416
12255
|
status: overrides.status ?? pickRandom(rng, EventStatus.options),
|
|
11417
12256
|
createdAt: overrides.createdAt ?? createdAt,
|
|
11418
12257
|
createdByUserType: overrides.createdByUserType ?? "user",
|
|
@@ -11458,46 +12297,62 @@ var generateEventConfig = ({
|
|
|
11458
12297
|
dateOfEventId,
|
|
11459
12298
|
actions = []
|
|
11460
12299
|
}) => {
|
|
11461
|
-
return
|
|
11462
|
-
|
|
11463
|
-
|
|
11464
|
-
|
|
11465
|
-
|
|
11466
|
-
|
|
11467
|
-
|
|
11468
|
-
placeOfEvent: placeOfEventId ? { $$field: placeOfEventId } : void 0,
|
|
11469
|
-
dateOfEvent: dateOfEventId ? { $$field: dateOfEventId } : void 0,
|
|
11470
|
-
declaration: {
|
|
11471
|
-
label: generateTranslationConfig2(`${id} Declaration`),
|
|
11472
|
-
pages: [
|
|
11473
|
-
{
|
|
11474
|
-
id: "page1",
|
|
11475
|
-
title: generateTranslationConfig2("Page 1"),
|
|
11476
|
-
fields
|
|
11477
|
-
}
|
|
11478
|
-
]
|
|
11479
|
-
},
|
|
11480
|
-
actions: [
|
|
11481
|
-
{
|
|
11482
|
-
type: ActionType.READ,
|
|
11483
|
-
label: generateTranslationConfig2("Read"),
|
|
11484
|
-
review: {
|
|
11485
|
-
title: generateTranslationConfig2("Review Read Action"),
|
|
11486
|
-
fields: []
|
|
11487
|
-
}
|
|
12300
|
+
return resolveEventConfig(
|
|
12301
|
+
defineConfig({
|
|
12302
|
+
id,
|
|
12303
|
+
label: generateTranslationConfig2(id),
|
|
12304
|
+
title: generateTranslationConfig2(`${id} Event`),
|
|
12305
|
+
summary: {
|
|
12306
|
+
fields: []
|
|
11488
12307
|
},
|
|
11489
|
-
{
|
|
11490
|
-
|
|
11491
|
-
|
|
11492
|
-
|
|
11493
|
-
|
|
11494
|
-
|
|
11495
|
-
|
|
12308
|
+
placeOfEvent: placeOfEventId ? { $$field: placeOfEventId } : void 0,
|
|
12309
|
+
dateOfEvent: dateOfEventId ? { $$field: dateOfEventId } : void 0,
|
|
12310
|
+
declaration: {
|
|
12311
|
+
label: generateTranslationConfig2(`${id} Declaration`),
|
|
12312
|
+
pages: [
|
|
12313
|
+
{
|
|
12314
|
+
id: "page1",
|
|
12315
|
+
title: generateTranslationConfig2("Page 1"),
|
|
12316
|
+
fields
|
|
12317
|
+
}
|
|
12318
|
+
]
|
|
11496
12319
|
},
|
|
11497
|
-
|
|
11498
|
-
|
|
11499
|
-
|
|
12320
|
+
actions: [
|
|
12321
|
+
{
|
|
12322
|
+
type: ActionType.READ,
|
|
12323
|
+
label: generateTranslationConfig2("Read"),
|
|
12324
|
+
review: {
|
|
12325
|
+
title: generateTranslationConfig2("Review Read Action"),
|
|
12326
|
+
fields: []
|
|
12327
|
+
}
|
|
12328
|
+
},
|
|
12329
|
+
{
|
|
12330
|
+
type: ActionType.DECLARE,
|
|
12331
|
+
label: generateTranslationConfig2("Declare"),
|
|
12332
|
+
review: {
|
|
12333
|
+
title: generateTranslationConfig2("Review Declare Action"),
|
|
12334
|
+
fields: []
|
|
12335
|
+
}
|
|
12336
|
+
},
|
|
12337
|
+
...actions
|
|
12338
|
+
]
|
|
12339
|
+
})
|
|
12340
|
+
);
|
|
11500
12341
|
};
|
|
12342
|
+
function withDeclaration(configuration, declaration) {
|
|
12343
|
+
return {
|
|
12344
|
+
...configuration,
|
|
12345
|
+
actions: configuration.actions.map((action) => {
|
|
12346
|
+
if (action.type === ActionType.DECLARE) {
|
|
12347
|
+
return { ...action, declaration };
|
|
12348
|
+
}
|
|
12349
|
+
if (action.type === ActionType.NOTIFY) {
|
|
12350
|
+
return { ...action, notificationForm: toNotificationForm(declaration) };
|
|
12351
|
+
}
|
|
12352
|
+
return action;
|
|
12353
|
+
})
|
|
12354
|
+
};
|
|
12355
|
+
}
|
|
11501
12356
|
function getLeafAdministrativeAreaIds(administrativeAreas) {
|
|
11502
12357
|
const nonLeafAdministrativeAreaIds = /* @__PURE__ */ new Set();
|
|
11503
12358
|
for (const [, location] of administrativeAreas) {
|
|
@@ -11546,6 +12401,26 @@ function generateTestValidatorContext(userRole2, eventWithConfig) {
|
|
|
11546
12401
|
event: getEventValidatorContext(event2, eventConfig)
|
|
11547
12402
|
};
|
|
11548
12403
|
}
|
|
12404
|
+
function toVersionedEventConfig({
|
|
12405
|
+
id,
|
|
12406
|
+
label,
|
|
12407
|
+
advancedSearch,
|
|
12408
|
+
...version
|
|
12409
|
+
}) {
|
|
12410
|
+
return {
|
|
12411
|
+
id,
|
|
12412
|
+
label,
|
|
12413
|
+
advancedSearch,
|
|
12414
|
+
versions: [
|
|
12415
|
+
{
|
|
12416
|
+
...version,
|
|
12417
|
+
id: INITIAL_EVENT_CONFIG_VERSION_ID,
|
|
12418
|
+
label,
|
|
12419
|
+
effectiveFrom: DEFAULT_EFFECTIVE_FROM
|
|
12420
|
+
}
|
|
12421
|
+
]
|
|
12422
|
+
};
|
|
12423
|
+
}
|
|
11549
12424
|
|
|
11550
12425
|
// ../commons/src/events/TemplateConfig.ts
|
|
11551
12426
|
var window2 = () => ({
|
|
@@ -11559,7 +12434,7 @@ function isTemplateVariable(value) {
|
|
|
11559
12434
|
return typeof value === "string" && value.startsWith("$");
|
|
11560
12435
|
}
|
|
11561
12436
|
function isFieldValue(value) {
|
|
11562
|
-
return FieldValue.
|
|
12437
|
+
return FieldValue.validate(value);
|
|
11563
12438
|
}
|
|
11564
12439
|
function isFieldValueWithoutTemplates(value) {
|
|
11565
12440
|
if (isTemplateVariable(value)) {
|
|
@@ -11602,8 +12477,12 @@ var ACTION_SCOPE_MAP = {
|
|
|
11602
12477
|
"record.correct"
|
|
11603
12478
|
],
|
|
11604
12479
|
[ClientSpecificAction.REVIEW_CORRECTION_REQUEST]: ["record.correct"],
|
|
12480
|
+
// Not granted by a scope: the client checks the draft's own action instead
|
|
12481
|
+
[ClientSpecificAction.CONTINUE_DRAFT]: [],
|
|
11605
12482
|
[ActionType.REJECT_CORRECTION]: ["record.correct"],
|
|
11606
12483
|
[ActionType.APPROVE_CORRECTION]: ["record.correct"],
|
|
12484
|
+
[ActionType.REVOKE_REGISTRATION]: ["record.revoke-registration"],
|
|
12485
|
+
[ActionType.REINSTATE_REGISTRATION]: ["record.reinstate-registration"],
|
|
11607
12486
|
[ActionType.MARK_AS_DUPLICATE]: ["record.review-duplicates"],
|
|
11608
12487
|
[ActionType.MARK_AS_NOT_DUPLICATE]: ["record.review-duplicates"],
|
|
11609
12488
|
[ActionType.ARCHIVE]: ["record.archive"],
|
|
@@ -11626,6 +12505,8 @@ var DOCUMENT_DELETE_SCOPES = [
|
|
|
11626
12505
|
"record.print-certified-copies",
|
|
11627
12506
|
"record.request-correction",
|
|
11628
12507
|
"record.correct",
|
|
12508
|
+
"record.revoke-registration",
|
|
12509
|
+
"record.reinstate-registration",
|
|
11629
12510
|
"record.review-duplicates",
|
|
11630
12511
|
"record.archive",
|
|
11631
12512
|
"record.unarchive",
|
|
@@ -11765,6 +12646,10 @@ function deserializeQueryExpression(expression, user2) {
|
|
|
11765
12646
|
expression["legalStatuses.REGISTERED.createdAtLocation"].location,
|
|
11766
12647
|
user2
|
|
11767
12648
|
) : void 0;
|
|
12649
|
+
const revokedLocation = expression["legalStatuses.REVOKED.createdAtLocation"] ? userDeserializer(
|
|
12650
|
+
expression["legalStatuses.REVOKED.createdAtLocation"].location,
|
|
12651
|
+
user2
|
|
12652
|
+
) : void 0;
|
|
11768
12653
|
return {
|
|
11769
12654
|
...expression,
|
|
11770
12655
|
assignedTo: expression.assignedTo && isDefined(assignedTo) ? { ...expression.assignedTo, term: assignedTo } : void 0,
|
|
@@ -11783,6 +12668,10 @@ function deserializeQueryExpression(expression, user2) {
|
|
|
11783
12668
|
["legalStatuses.REGISTERED.createdAtLocation"]: expression["legalStatuses.REGISTERED.createdAtLocation"] && isDefined(registeredLocation) ? {
|
|
11784
12669
|
...expression["legalStatuses.REGISTERED.createdAtLocation"],
|
|
11785
12670
|
location: registeredLocation
|
|
12671
|
+
} : void 0,
|
|
12672
|
+
["legalStatuses.REVOKED.createdAtLocation"]: expression["legalStatuses.REVOKED.createdAtLocation"] && isDefined(revokedLocation) ? {
|
|
12673
|
+
...expression["legalStatuses.REVOKED.createdAtLocation"],
|
|
12674
|
+
location: revokedLocation
|
|
11786
12675
|
} : void 0
|
|
11787
12676
|
};
|
|
11788
12677
|
}
|
|
@@ -11829,7 +12718,12 @@ var AVAILABLE_ACTIONS_BY_EVENT_STATUS = {
|
|
|
11829
12718
|
ActionType.APPROVE_CORRECTION,
|
|
11830
12719
|
ActionType.REJECT_CORRECTION,
|
|
11831
12720
|
ActionType.CUSTOM,
|
|
11832
|
-
ClientSpecificAction.REVIEW_CORRECTION_REQUEST
|
|
12721
|
+
ClientSpecificAction.REVIEW_CORRECTION_REQUEST,
|
|
12722
|
+
ActionType.REVOKE_REGISTRATION
|
|
12723
|
+
],
|
|
12724
|
+
[EventStatus.enum.REVOKED]: [
|
|
12725
|
+
ActionType.READ,
|
|
12726
|
+
ActionType.REINSTATE_REGISTRATION
|
|
11833
12727
|
],
|
|
11834
12728
|
[EventStatus.enum.ARCHIVED]: [
|
|
11835
12729
|
ActionType.READ,
|
|
@@ -11843,6 +12737,8 @@ var ACTION_FILTERS = {
|
|
|
11843
12737
|
[ClientSpecificAction.REVIEW_CORRECTION_REQUEST]: (flags) => flags.includes(InherentFlags.CORRECTION_REQUESTED) && !flags.some((flag2) => flag2.endsWith(":requested")),
|
|
11844
12738
|
[ActionType.APPROVE_CORRECTION]: (flags) => flags.includes(InherentFlags.CORRECTION_REQUESTED) && !flags.some((flag2) => flag2.endsWith(":requested")),
|
|
11845
12739
|
[ActionType.REJECT_CORRECTION]: (flags) => flags.includes(InherentFlags.CORRECTION_REQUESTED) && !flags.some((flag2) => flag2.endsWith(":requested")),
|
|
12740
|
+
[ActionType.REVOKE_REGISTRATION]: (flags) => !flags.includes(InherentFlags.CORRECTION_REQUESTED) && !flags.some((flag2) => flag2.endsWith(":requested")),
|
|
12741
|
+
[ActionType.REINSTATE_REGISTRATION]: (flags) => !flags.some((flag2) => flag2.endsWith(":requested")),
|
|
11846
12742
|
[ActionType.MARK_AS_DUPLICATE]: (flags) => flags.includes(InherentFlags.POTENTIAL_DUPLICATE) && !flags.some((flag2) => flag2.endsWith(":requested")),
|
|
11847
12743
|
[ActionType.EDIT]: (flags) => !flags.includes(InherentFlags.POTENTIAL_DUPLICATE) && !flags.some((flag2) => flag2.endsWith(":requested")),
|
|
11848
12744
|
[ActionType.REGISTER]: (flags) => !flags.includes(InherentFlags.POTENTIAL_DUPLICATE) && !flags.some((flag2) => flag2.endsWith(":requested")),
|
|
@@ -11892,13 +12788,11 @@ function getFilePathsFromEvent(event2) {
|
|
|
11892
12788
|
...declarationValues,
|
|
11893
12789
|
...annotationValues
|
|
11894
12790
|
].flatMap((value) => {
|
|
11895
|
-
|
|
11896
|
-
|
|
11897
|
-
return [fileParsed.data.path];
|
|
12791
|
+
if (isFileFieldValue(value)) {
|
|
12792
|
+
return [value.path];
|
|
11898
12793
|
}
|
|
11899
|
-
|
|
11900
|
-
|
|
11901
|
-
return fileOptionParsed.data.map((val) => val.path);
|
|
12794
|
+
if (isFileFieldWithOptionValue(value)) {
|
|
12795
|
+
return value.map((val) => val.path);
|
|
11902
12796
|
}
|
|
11903
12797
|
return [];
|
|
11904
12798
|
});
|
|
@@ -11908,49 +12802,49 @@ function getFilePathsFromEvent(event2) {
|
|
|
11908
12802
|
}
|
|
11909
12803
|
|
|
11910
12804
|
// ../commons/src/events/locationPayloads.ts
|
|
11911
|
-
var
|
|
11912
|
-
var CreateLocationPayload =
|
|
12805
|
+
var z46 = __toESM(require("zod/v4"));
|
|
12806
|
+
var CreateLocationPayload = z46.object({
|
|
11913
12807
|
id: UUID.optional(),
|
|
11914
12808
|
versionId: UUID.optional(),
|
|
11915
|
-
name:
|
|
11916
|
-
externalId:
|
|
12809
|
+
name: z46.string(),
|
|
12810
|
+
externalId: z46.string().nullish(),
|
|
11917
12811
|
administrativeAreaId: UUID.nullable(),
|
|
11918
|
-
locationType:
|
|
11919
|
-
effectiveFrom:
|
|
12812
|
+
locationType: z46.string().nullable(),
|
|
12813
|
+
effectiveFrom: z46.iso.date().optional(),
|
|
11920
12814
|
status: LocationStatus.default("active")
|
|
11921
12815
|
});
|
|
11922
|
-
var UpdateLocationPayload =
|
|
12816
|
+
var UpdateLocationPayload = z46.strictObject({
|
|
11923
12817
|
id: UUID,
|
|
11924
12818
|
versionId: UUID.optional(),
|
|
11925
|
-
name:
|
|
11926
|
-
externalId:
|
|
12819
|
+
name: z46.string(),
|
|
12820
|
+
externalId: z46.string().nullish(),
|
|
11927
12821
|
status: LocationStatus,
|
|
11928
|
-
effectiveFrom:
|
|
12822
|
+
effectiveFrom: z46.iso.date().optional(),
|
|
11929
12823
|
lastVersionId: UUID
|
|
11930
12824
|
});
|
|
11931
|
-
var WithdrawLocationVersionPayload =
|
|
12825
|
+
var WithdrawLocationVersionPayload = z46.object({
|
|
11932
12826
|
id: UUID,
|
|
11933
12827
|
versionId: UUID
|
|
11934
12828
|
});
|
|
11935
|
-
var CreateAdministrativeAreaPayload =
|
|
12829
|
+
var CreateAdministrativeAreaPayload = z46.object({
|
|
11936
12830
|
id: UUID.optional(),
|
|
11937
12831
|
versionId: UUID.optional(),
|
|
11938
|
-
name:
|
|
11939
|
-
externalId:
|
|
12832
|
+
name: z46.string(),
|
|
12833
|
+
externalId: z46.string().nullish(),
|
|
11940
12834
|
parentId: UUID.nullable(),
|
|
11941
|
-
effectiveFrom:
|
|
12835
|
+
effectiveFrom: z46.iso.date().optional(),
|
|
11942
12836
|
status: LocationStatus.default("active")
|
|
11943
12837
|
});
|
|
11944
|
-
var UpdateAdministrativeAreaPayload =
|
|
12838
|
+
var UpdateAdministrativeAreaPayload = z46.strictObject({
|
|
11945
12839
|
id: UUID,
|
|
11946
12840
|
versionId: UUID.optional(),
|
|
11947
|
-
name:
|
|
11948
|
-
externalId:
|
|
12841
|
+
name: z46.string(),
|
|
12842
|
+
externalId: z46.string().nullish(),
|
|
11949
12843
|
status: LocationStatus,
|
|
11950
|
-
effectiveFrom:
|
|
12844
|
+
effectiveFrom: z46.iso.date().optional(),
|
|
11951
12845
|
lastVersionId: UUID
|
|
11952
12846
|
});
|
|
11953
|
-
var WithdrawAdministrativeAreaVersionPayload =
|
|
12847
|
+
var WithdrawAdministrativeAreaVersionPayload = z46.object({
|
|
11954
12848
|
id: UUID,
|
|
11955
12849
|
versionId: UUID
|
|
11956
12850
|
});
|