@opencrvs/toolkit 2.1.2 → 2.2.0-rc.1a111f2
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 +2 -12
- package/create-countryconfig/package.json +1 -1
- package/dist/application-config/index.js +41 -9
- package/dist/authentication/index.d.ts +1 -0
- package/dist/authentication/index.js +30 -6
- package/dist/cli.js +1489 -2020
- package/dist/commons/api/router.d.ts +1551 -248
- package/dist/commons/application-config/index.d.ts +2 -2
- package/dist/commons/conditionals/conditionals.d.ts +3 -3
- package/dist/commons/conditionals/index.d.ts +1 -0
- package/dist/commons/conditionals/validate.d.ts +5 -0
- 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/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 +412 -6
- package/dist/commons/events/EventDocument.d.ts +88 -0
- package/dist/commons/events/EventIndex.d.ts +43 -6
- package/dist/commons/events/EventMetadata.d.ts +23 -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 +6 -6
- package/dist/commons/events/Flag.d.ts +1 -7
- package/dist/commons/events/PlainDate.d.ts +1 -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 +4 -1
- package/dist/commons/events/eventConfigValidation.d.ts +26 -1
- package/dist/commons/events/field.d.ts +5 -0
- package/dist/commons/events/index.d.ts +3 -0
- package/dist/commons/events/scopes.d.ts +3 -0
- package/dist/commons/events/state/flags.d.ts +1 -1
- package/dist/commons/events/state/index.d.ts +10 -2
- package/dist/commons/events/state/utils.d.ts +11 -1
- package/dist/commons/events/test.utils.d.ts +87 -6
- package/dist/commons/events/toNotificationForm.d.ts +17 -0
- package/dist/commons/events/utils.d.ts +75 -8
- package/dist/conditionals/index.js +16 -4
- 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 +159 -35
- package/dist/environment/templates.d.ts.map +1 -1
- package/dist/events/index.js +944 -214
- 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 +887 -129
- package/dist/scopes/index.d.ts +83 -90
- package/dist/scopes/index.js +26 -6
- package/dist/templates/charts-values/dependencies/values.yaml +3 -2
- package/dist/templates/charts-values/opencrvs-services/values.yaml +5 -7
- 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.1a111f2.tgz +0 -0
- package/package.json +3 -2
- package/tsconfig.build.tsbuildinfo +1 -1
- package/dist/migrations/v2.1/add-explicit-correction-flags.d.ts +0 -3
- package/dist/migrations/v2.1/add-explicit-correction-flags.d.ts.map +0 -1
- package/dist/migrations/v2.1/add-explicit-correction-flags.js +0 -234
- package/dist/migrations/v2.1/add-recovery-link-notifications.d.ts +0 -3
- package/dist/migrations/v2.1/add-recovery-link-notifications.d.ts.map +0 -1
- package/dist/migrations/v2.1/add-recovery-link-notifications.js +0 -511
- package/dist/migrations/v2.1/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,8 @@ __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,
|
|
92
|
+
DEFAULT_EVENT_CONFIG_VERSION_ID: () => DEFAULT_EVENT_CONFIG_VERSION_ID,
|
|
91
93
|
DEFAULT_PLACE_OF_EVENT_PROPERTY: () => DEFAULT_PLACE_OF_EVENT_PROPERTY,
|
|
92
94
|
DOCUMENT_DELETE_SCOPES: () => DOCUMENT_DELETE_SCOPES,
|
|
93
95
|
DataEntry: () => DataEntry,
|
|
@@ -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: () => VersionedEventConfig,
|
|
247
254
|
WithdrawAdministrativeAreaVersionPayload: () => WithdrawAdministrativeAreaVersionPayload,
|
|
248
255
|
WithdrawLocationVersionPayload: () => WithdrawLocationVersionPayload,
|
|
249
256
|
Within: () => Within,
|
|
@@ -318,6 +325,7 @@ __export(events_exports, {
|
|
|
318
325
|
flattenFormState: () => flattenFormState,
|
|
319
326
|
generateActionDeclarationInput: () => generateActionDeclarationInput,
|
|
320
327
|
generateActionDocument: () => generateActionDocument,
|
|
328
|
+
generateActionDocuments: () => generateActionDocuments,
|
|
321
329
|
generateActionDuplicateDeclarationInput: () => generateActionDuplicateDeclarationInput,
|
|
322
330
|
generateEventConfig: () => generateEventConfig,
|
|
323
331
|
generateEventDocument: () => generateEventDocument,
|
|
@@ -336,6 +344,7 @@ __export(events_exports, {
|
|
|
336
344
|
getActionAnnotation: () => getActionAnnotation,
|
|
337
345
|
getActionAnnotationFields: () => getActionAnnotationFields,
|
|
338
346
|
getActionConfig: () => getActionConfig,
|
|
347
|
+
getActionForm: () => getActionForm,
|
|
339
348
|
getActionFormFields: () => getActionFormFields,
|
|
340
349
|
getActionReview: () => getActionReview,
|
|
341
350
|
getActionReviewFields: () => getActionReviewFields,
|
|
@@ -358,12 +367,16 @@ __export(events_exports, {
|
|
|
358
367
|
getDeclarationPages: () => getDeclarationPages,
|
|
359
368
|
getDeclarationWithPendingAction: () => getDeclarationWithPendingAction,
|
|
360
369
|
getEventConfigById: () => getEventConfigById,
|
|
370
|
+
getEventConfigOfVersion: () => getEventConfigOfVersion,
|
|
361
371
|
getEventFlags: () => getEventFlags,
|
|
362
372
|
getEventValidatorContext: () => getEventValidatorContext,
|
|
373
|
+
getEventWithCompleteAcceptedActions: () => getEventWithCompleteAcceptedActions,
|
|
363
374
|
getFilePathsFromEvent: () => getFilePathsFromEvent,
|
|
364
375
|
getLeafAdministrativeAreaIds: () => getLeafAdministrativeAreaIds,
|
|
365
376
|
getLocationHierarchy: () => getLocationHierarchy,
|
|
366
377
|
getMixedPath: () => getMixedPath,
|
|
378
|
+
getNotificationFields: () => getNotificationFields,
|
|
379
|
+
getNotificationForm: () => getNotificationForm,
|
|
367
380
|
getPendingAction: () => getPendingAction,
|
|
368
381
|
getPrintCertificatePages: () => getPrintCertificatePages,
|
|
369
382
|
getRandomDate: () => getRandomDate,
|
|
@@ -374,10 +387,12 @@ __export(events_exports, {
|
|
|
374
387
|
hasAnyOfScopes: () => hasAnyOfScopes,
|
|
375
388
|
isActionAvailable: () => isActionAvailable,
|
|
376
389
|
isActionConfigType: () => isActionConfigType,
|
|
390
|
+
isActionDocument: () => isActionDocument,
|
|
377
391
|
isActionEnabled: () => isActionEnabled,
|
|
378
392
|
isActionInScope: () => isActionInScope,
|
|
379
393
|
isActionVisible: () => isActionVisible,
|
|
380
394
|
isAddressFieldType: () => isAddressFieldType,
|
|
395
|
+
isAddressFieldValue: () => isAddressFieldValue,
|
|
381
396
|
isAdministrativeAreaFieldType: () => isAdministrativeAreaFieldType,
|
|
382
397
|
isAgeFieldType: () => isAgeFieldType,
|
|
383
398
|
isAutocompleteFieldType: () => isAutocompleteFieldType,
|
|
@@ -392,6 +407,7 @@ __export(events_exports, {
|
|
|
392
407
|
isDateFieldType: () => isDateFieldType,
|
|
393
408
|
isDateRangeFieldType: () => isDateRangeFieldType,
|
|
394
409
|
isDividerFieldType: () => isDividerFieldType,
|
|
410
|
+
isDomesticAddressFieldValue: () => isDomesticAddressFieldValue,
|
|
395
411
|
isEmailFieldType: () => isEmailFieldType,
|
|
396
412
|
isEventFieldReference: () => isEventFieldReference,
|
|
397
413
|
isFacilityFieldType: () => isFacilityFieldType,
|
|
@@ -405,7 +421,9 @@ __export(events_exports, {
|
|
|
405
421
|
isFieldValueWithoutTemplates: () => isFieldValueWithoutTemplates,
|
|
406
422
|
isFieldVisible: () => isFieldVisible,
|
|
407
423
|
isFileFieldType: () => isFileFieldType,
|
|
424
|
+
isFileFieldValue: () => isFileFieldValue,
|
|
408
425
|
isFileFieldWithOptionType: () => isFileFieldWithOptionType,
|
|
426
|
+
isFileFieldWithOptionValue: () => isFileFieldWithOptionValue,
|
|
409
427
|
isHeadingFieldType: () => isHeadingFieldType,
|
|
410
428
|
isHiddenFieldType: () => isHiddenFieldType,
|
|
411
429
|
isHttpFieldType: () => isHttpFieldType,
|
|
@@ -426,6 +444,7 @@ __export(events_exports, {
|
|
|
426
444
|
isPageVisible: () => isPageVisible,
|
|
427
445
|
isParagraphFieldType: () => isParagraphFieldType,
|
|
428
446
|
isPhoneFieldType: () => isPhoneFieldType,
|
|
447
|
+
isPlainDate: () => isPlainDate,
|
|
429
448
|
isPotentialDuplicate: () => isPotentialDuplicate,
|
|
430
449
|
isPrintButtonFieldType: () => isPrintButtonFieldType,
|
|
431
450
|
isQrReaderFieldType: () => isQrReaderFieldType,
|
|
@@ -462,6 +481,7 @@ __export(events_exports, {
|
|
|
462
481
|
plainDateToLocalDate: () => plainDateToLocalDate,
|
|
463
482
|
precompileActionSchemas: () => precompileActionSchemas,
|
|
464
483
|
resolveDateOfEvent: () => resolveDateOfEvent,
|
|
484
|
+
resolveEventConfig: () => resolveEventConfig,
|
|
465
485
|
resolveEventCustomFlags: () => resolveEventCustomFlags,
|
|
466
486
|
resolvePath: () => resolvePath,
|
|
467
487
|
resolvePlaceOfEvent: () => resolvePlaceOfEvent,
|
|
@@ -474,18 +494,27 @@ __export(events_exports, {
|
|
|
474
494
|
timePeriodToDateRange: () => timePeriodToDateRange,
|
|
475
495
|
toClientAdministrativeArea: () => toClientAdministrativeArea,
|
|
476
496
|
toClientLocation: () => toClientLocation,
|
|
497
|
+
toNotificationForm: () => toNotificationForm,
|
|
498
|
+
toNotificationReview: () => toNotificationReview,
|
|
477
499
|
toPlainDate: () => toPlainDate,
|
|
500
|
+
toVersionedEventConfig: () => toVersionedEventConfig,
|
|
478
501
|
todayISO: () => todayISO,
|
|
479
502
|
user: () => user,
|
|
480
503
|
userCanAccessEventWithScopes: () => userCanAccessEventWithScopes,
|
|
481
504
|
validate: () => validate,
|
|
505
|
+
validateEachVersion: () => validateEachVersion,
|
|
506
|
+
validateEventConfig: () => validateEventConfig,
|
|
482
507
|
validateFieldInput: () => validateFieldInput,
|
|
483
508
|
validateValue: () => validateValue,
|
|
484
509
|
window: () => window2,
|
|
510
|
+
withDeclaration: () => withDeclaration,
|
|
485
511
|
writeActions: () => writeActions
|
|
486
512
|
});
|
|
487
513
|
module.exports = __toCommonJS(events_exports);
|
|
488
514
|
|
|
515
|
+
// ../commons/src/events/index.ts
|
|
516
|
+
var import_compile = require("zod/compile");
|
|
517
|
+
|
|
489
518
|
// ../commons/src/events/AuditLog.ts
|
|
490
519
|
var z9 = __toESM(require("zod/v4"));
|
|
491
520
|
|
|
@@ -504,6 +533,12 @@ var UUID = z.uuid().brand("UUID");
|
|
|
504
533
|
function getUUID() {
|
|
505
534
|
return (0, import_uuid.v4)();
|
|
506
535
|
}
|
|
536
|
+
function isUUID(id) {
|
|
537
|
+
return UUID.validate(id);
|
|
538
|
+
}
|
|
539
|
+
function maybeUuid(value) {
|
|
540
|
+
return isUUID(value) ? value : void 0;
|
|
541
|
+
}
|
|
507
542
|
|
|
508
543
|
// ../commons/src/events/ActionType.ts
|
|
509
544
|
var z2 = __toESM(require("zod/v4"));
|
|
@@ -529,6 +564,8 @@ var ActionType = {
|
|
|
529
564
|
REQUEST_CORRECTION: "REQUEST_CORRECTION",
|
|
530
565
|
REJECT_CORRECTION: "REJECT_CORRECTION",
|
|
531
566
|
APPROVE_CORRECTION: "APPROVE_CORRECTION",
|
|
567
|
+
REVOKE_REGISTRATION: "REVOKE_REGISTRATION",
|
|
568
|
+
REINSTATE_REGISTRATION: "REINSTATE_REGISTRATION",
|
|
532
569
|
// General actions
|
|
533
570
|
READ: "READ",
|
|
534
571
|
ASSIGN: "ASSIGN",
|
|
@@ -548,6 +585,8 @@ var ConfirmableActions = [
|
|
|
548
585
|
ActionType.REQUEST_CORRECTION,
|
|
549
586
|
ActionType.APPROVE_CORRECTION,
|
|
550
587
|
ActionType.REJECT_CORRECTION,
|
|
588
|
+
ActionType.REVOKE_REGISTRATION,
|
|
589
|
+
ActionType.REINSTATE_REGISTRATION,
|
|
551
590
|
ActionType.CUSTOM
|
|
552
591
|
];
|
|
553
592
|
var ActionTypes = z2.enum([
|
|
@@ -567,13 +606,17 @@ var ActionTypes = z2.enum([
|
|
|
567
606
|
"REQUEST_CORRECTION",
|
|
568
607
|
"REJECT_CORRECTION",
|
|
569
608
|
"APPROVE_CORRECTION",
|
|
609
|
+
"REVOKE_REGISTRATION",
|
|
610
|
+
"REINSTATE_REGISTRATION",
|
|
570
611
|
"READ",
|
|
571
612
|
"ASSIGN",
|
|
572
613
|
"UNASSIGN",
|
|
573
614
|
"CUSTOM"
|
|
574
615
|
]);
|
|
575
616
|
var ClientSpecificAction = {
|
|
576
|
-
REVIEW_CORRECTION_REQUEST: "REVIEW_CORRECTION_REQUEST"
|
|
617
|
+
REVIEW_CORRECTION_REQUEST: "REVIEW_CORRECTION_REQUEST",
|
|
618
|
+
/** Opens the user's declare or notify draft of the event in its own flow */
|
|
619
|
+
CONTINUE_DRAFT: "CONTINUE_DRAFT"
|
|
577
620
|
};
|
|
578
621
|
var declarationActionValues = [
|
|
579
622
|
ActionTypes.enum.DECLARE,
|
|
@@ -608,7 +651,9 @@ var WorkqueueActionType = ActionTypes.extract([
|
|
|
608
651
|
ActionType.ARCHIVE,
|
|
609
652
|
ActionType.UNARCHIVE,
|
|
610
653
|
ActionType.PRINT_CERTIFICATE,
|
|
611
|
-
ActionType.REQUEST_CORRECTION
|
|
654
|
+
ActionType.REQUEST_CORRECTION,
|
|
655
|
+
ActionType.REVOKE_REGISTRATION,
|
|
656
|
+
ActionType.REINSTATE_REGISTRATION
|
|
612
657
|
]);
|
|
613
658
|
var META_ACTIONS = [
|
|
614
659
|
ActionType.ASSIGN,
|
|
@@ -627,7 +672,7 @@ var ActionStatus = {
|
|
|
627
672
|
};
|
|
628
673
|
|
|
629
674
|
// ../commons/src/events/Flag.ts
|
|
630
|
-
var z5 = __toESM(require("zod
|
|
675
|
+
var z5 = __toESM(require("zod"));
|
|
631
676
|
|
|
632
677
|
// ../commons/src/events/TranslationConfig.ts
|
|
633
678
|
var z3 = __toESM(require("zod/v4"));
|
|
@@ -696,7 +741,6 @@ var FieldConditional = z4.discriminatedUnion("type", [
|
|
|
696
741
|
|
|
697
742
|
// ../commons/src/events/Flag.ts
|
|
698
743
|
var InherentFlags = {
|
|
699
|
-
INCOMPLETE: "incomplete",
|
|
700
744
|
REJECTED: "rejected",
|
|
701
745
|
CORRECTION_REQUESTED: "correction-requested",
|
|
702
746
|
POTENTIAL_DUPLICATE: "potential-duplicate",
|
|
@@ -724,7 +768,7 @@ var CustomFlag = z5.string().refine((val) => !Object.values(InherentFlags).inclu
|
|
|
724
768
|
message: `Custom flag cannot be one of the inherent flags: ${Object.values(
|
|
725
769
|
InherentFlags
|
|
726
770
|
).join(", ")}`
|
|
727
|
-
}).refine((val) => !ActionFlag.
|
|
771
|
+
}).refine((val) => !ActionFlag.validate(val), {
|
|
728
772
|
message: "Custom flag cannot match the ActionFlag pattern (ActionType:ActionStatus)."
|
|
729
773
|
}).describe("Custom flag identifier defined by the country config.");
|
|
730
774
|
var Flag = ActionFlag.or(z5.enum(InherentFlags)).or(CustomFlag);
|
|
@@ -763,6 +807,7 @@ var EventStatus = z6.enum([
|
|
|
763
807
|
"NOTIFIED",
|
|
764
808
|
"DECLARED",
|
|
765
809
|
"REGISTERED",
|
|
810
|
+
"REVOKED",
|
|
766
811
|
"ARCHIVED"
|
|
767
812
|
]);
|
|
768
813
|
|
|
@@ -786,6 +831,8 @@ var RecordScopeTypeV2 = z7.enum([
|
|
|
786
831
|
"record.print-certified-copies",
|
|
787
832
|
"record.request-correction",
|
|
788
833
|
"record.correct",
|
|
834
|
+
"record.revoke-registration",
|
|
835
|
+
"record.reinstate-registration",
|
|
789
836
|
"record.unassign-others",
|
|
790
837
|
"record.custom-action",
|
|
791
838
|
"record.action.accept",
|
|
@@ -912,6 +959,8 @@ var ScopesWithFullOptions = RecordScopeTypeV2.extract([
|
|
|
912
959
|
"record.read",
|
|
913
960
|
"record.request-correction",
|
|
914
961
|
"record.correct",
|
|
962
|
+
"record.revoke-registration",
|
|
963
|
+
"record.reinstate-registration",
|
|
915
964
|
"record.unassign-others",
|
|
916
965
|
"record.review-duplicates"
|
|
917
966
|
]);
|
|
@@ -1156,6 +1205,8 @@ var EventActionEntrySchema = AuditLogEntryBase.extend({
|
|
|
1156
1205
|
"event.actions.correction.request.request",
|
|
1157
1206
|
"event.actions.correction.approve.request",
|
|
1158
1207
|
"event.actions.correction.reject.request",
|
|
1208
|
+
"event.actions.revoke_registration.request",
|
|
1209
|
+
"event.actions.reinstate_registration.request",
|
|
1159
1210
|
"event.actions.mark_as_duplicate.request",
|
|
1160
1211
|
"event.actions.mark_as_not_duplicate.request"
|
|
1161
1212
|
]),
|
|
@@ -1490,7 +1541,7 @@ var z14 = __toESM(require("zod/v4"));
|
|
|
1490
1541
|
// ../commons/src/documents.ts
|
|
1491
1542
|
var z11 = __toESM(require("zod/v4"));
|
|
1492
1543
|
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://
|
|
1544
|
+
"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
1545
|
);
|
|
1495
1546
|
var FullDocumentPath = z11.string().overwrite((val) => val.startsWith("/") ? val : `/${val}`).meta({ effectType: "input", type: "string" }).describe(
|
|
1496
1547
|
"A full absolute path with bucket name, starting from the root of the S3 server, /bucket-name/document-id.jpg"
|
|
@@ -1500,7 +1551,7 @@ var DocumentPath = z11.string().brand("DocumentPath").describe(
|
|
|
1500
1551
|
);
|
|
1501
1552
|
|
|
1502
1553
|
// ../commons/src/events/CompositeFieldValue.ts
|
|
1503
|
-
var z12 = __toESM(require("zod
|
|
1554
|
+
var z12 = __toESM(require("zod"));
|
|
1504
1555
|
var GeographicalArea = {
|
|
1505
1556
|
URBAN: "URBAN",
|
|
1506
1557
|
RURAL: "RURAL"
|
|
@@ -1514,6 +1565,9 @@ var FileFieldValue = z12.object({
|
|
|
1514
1565
|
originalFilename: z12.string(),
|
|
1515
1566
|
type: z12.string()
|
|
1516
1567
|
});
|
|
1568
|
+
function isFileFieldValue(value) {
|
|
1569
|
+
return FileFieldValue.validate(value);
|
|
1570
|
+
}
|
|
1517
1571
|
var NameFieldValue = z12.object({
|
|
1518
1572
|
firstname: z12.string(),
|
|
1519
1573
|
surname: z12.string(),
|
|
@@ -1538,6 +1592,9 @@ var DomesticAddressFieldValue = BaseAddressFieldValue.extend({
|
|
|
1538
1592
|
addressType: z12.literal(AddressType.DOMESTIC),
|
|
1539
1593
|
administrativeArea: z12.string().uuid()
|
|
1540
1594
|
});
|
|
1595
|
+
function isDomesticAddressFieldValue(value) {
|
|
1596
|
+
return DomesticAddressFieldValue.validate(value);
|
|
1597
|
+
}
|
|
1541
1598
|
var InternationalAddressFieldValue = BaseAddressFieldValue.extend({
|
|
1542
1599
|
addressType: z12.literal(AddressType.INTERNATIONAL)
|
|
1543
1600
|
});
|
|
@@ -1545,6 +1602,9 @@ var AddressFieldValue = z12.discriminatedUnion("addressType", [
|
|
|
1545
1602
|
DomesticAddressFieldValue,
|
|
1546
1603
|
InternationalAddressFieldValue
|
|
1547
1604
|
]);
|
|
1605
|
+
function isAddressFieldValue(value) {
|
|
1606
|
+
return AddressFieldValue.validate(value);
|
|
1607
|
+
}
|
|
1548
1608
|
var DomesticAddressUpdateFieldValue = BaseAddressFieldUpdateValue.extend({
|
|
1549
1609
|
addressType: z12.literal(AddressType.DOMESTIC),
|
|
1550
1610
|
administrativeArea: z12.string().uuid().nullish()
|
|
@@ -1566,6 +1626,9 @@ var FileFieldValueWithOption = z12.object({
|
|
|
1566
1626
|
option: z12.string()
|
|
1567
1627
|
});
|
|
1568
1628
|
var FileFieldWithOptionValue = z12.array(FileFieldValueWithOption);
|
|
1629
|
+
function isFileFieldWithOptionValue(value) {
|
|
1630
|
+
return FileFieldWithOptionValue.validate(value);
|
|
1631
|
+
}
|
|
1569
1632
|
var HttpFieldValue = z12.object({
|
|
1570
1633
|
loading: z12.boolean(),
|
|
1571
1634
|
error: z12.object({ statusCode: z12.number(), message: z12.string() }).nullish(),
|
|
@@ -1601,6 +1664,7 @@ var CustomFieldValue = z12.unknown().brand("CustomFieldValue");
|
|
|
1601
1664
|
// ../commons/src/events/PlainDate.ts
|
|
1602
1665
|
var import_zod = require("zod");
|
|
1603
1666
|
var PlainDate = import_zod.z.string().date().brand("PlainDate").describe("Date in the format YYYY-MM-DD");
|
|
1667
|
+
var isPlainDate = (date) => PlainDate.validate(date);
|
|
1604
1668
|
function toPlainDate(dateTime) {
|
|
1605
1669
|
return dateTime.split("T")[0];
|
|
1606
1670
|
}
|
|
@@ -1716,7 +1780,7 @@ function safeUnion(schemas) {
|
|
|
1716
1780
|
);
|
|
1717
1781
|
return z14.any().superRefine((val, ctx) => {
|
|
1718
1782
|
for (const schema of sortedSchemas) {
|
|
1719
|
-
if (schema.
|
|
1783
|
+
if (schema.validate(val)) {
|
|
1720
1784
|
return;
|
|
1721
1785
|
}
|
|
1722
1786
|
}
|
|
@@ -1910,6 +1974,16 @@ var UnarchiveAction = ActionBase.extend(
|
|
|
1910
1974
|
type: z16.literal(ActionType.UNARCHIVE)
|
|
1911
1975
|
}).shape
|
|
1912
1976
|
);
|
|
1977
|
+
var RevokeRegistrationAction = ActionBase.extend(
|
|
1978
|
+
z16.object({
|
|
1979
|
+
type: z16.literal(ActionType.REVOKE_REGISTRATION)
|
|
1980
|
+
}).shape
|
|
1981
|
+
);
|
|
1982
|
+
var ReinstateRegistrationAction = ActionBase.extend(
|
|
1983
|
+
z16.object({
|
|
1984
|
+
type: z16.literal(ActionType.REINSTATE_REGISTRATION)
|
|
1985
|
+
}).shape
|
|
1986
|
+
);
|
|
1913
1987
|
var CreatedAction = ActionBase.extend(
|
|
1914
1988
|
z16.object({
|
|
1915
1989
|
type: z16.literal(ActionType.CREATE)
|
|
@@ -1978,6 +2052,8 @@ var ActionDocument = z16.discriminatedUnion("type", [
|
|
|
1978
2052
|
MarkAsDuplicateAction.meta({ id: "MarkAsDuplicateAction" }),
|
|
1979
2053
|
ArchiveAction.meta({ id: "ArchiveAction" }),
|
|
1980
2054
|
UnarchiveAction.meta({ id: "UnarchiveAction" }),
|
|
2055
|
+
RevokeRegistrationAction.meta({ id: "RevokeRegistrationAction" }),
|
|
2056
|
+
ReinstateRegistrationAction.meta({ id: "ReinstateRegistrationAction" }),
|
|
1981
2057
|
NotifiedAction.meta({ id: "NotifiedAction" }),
|
|
1982
2058
|
RegisterAction.meta({ id: "RegisterAction" }),
|
|
1983
2059
|
DeclareAction.meta({ id: "DeclareAction" }),
|
|
@@ -1993,6 +2069,7 @@ var ActionDocument = z16.discriminatedUnion("type", [
|
|
|
1993
2069
|
]).meta({
|
|
1994
2070
|
id: "ActionDocument"
|
|
1995
2071
|
});
|
|
2072
|
+
var isActionDocument = (a) => ActionDocument.validate(a);
|
|
1996
2073
|
var AsyncRejectActionDocument = ActionBase.omit({
|
|
1997
2074
|
declaration: true,
|
|
1998
2075
|
annotation: true
|
|
@@ -2026,7 +2103,8 @@ var RegistrationCreationMetadata = ActionCreationMetadata.extend({
|
|
|
2026
2103
|
var LegalStatuses = z17.object({
|
|
2027
2104
|
[EventStatus.enum.NOTIFIED]: ActionCreationMetadata.nullish(),
|
|
2028
2105
|
[EventStatus.enum.DECLARED]: ActionCreationMetadata.nullish(),
|
|
2029
|
-
[EventStatus.enum.REGISTERED]: RegistrationCreationMetadata.nullish()
|
|
2106
|
+
[EventStatus.enum.REGISTERED]: RegistrationCreationMetadata.nullish(),
|
|
2107
|
+
[EventStatus.enum.REVOKED]: ActionCreationMetadata.nullish()
|
|
2030
2108
|
});
|
|
2031
2109
|
var EventMetadata = z17.object({
|
|
2032
2110
|
id: UUID,
|
|
@@ -2228,6 +2306,12 @@ var AnyOfStatus = import_v4.z.object({
|
|
|
2228
2306
|
}).meta({
|
|
2229
2307
|
id: "AnyOfStatus"
|
|
2230
2308
|
});
|
|
2309
|
+
var NoneOfStatus = import_v4.z.object({
|
|
2310
|
+
type: import_v4.z.literal("noneOf"),
|
|
2311
|
+
terms: import_v4.z.array(EventStatus)
|
|
2312
|
+
}).meta({
|
|
2313
|
+
id: "NoneOfStatus"
|
|
2314
|
+
});
|
|
2231
2315
|
var Range = import_v4.z.object({
|
|
2232
2316
|
type: import_v4.z.literal("range"),
|
|
2233
2317
|
gte: import_v4.z.string(),
|
|
@@ -2268,7 +2352,7 @@ var QueryInput = import_v4.z.lazy(
|
|
|
2268
2352
|
var QueryExpression = import_v4.z.object({
|
|
2269
2353
|
id: import_v4.z.optional(import_v4.z.string()),
|
|
2270
2354
|
eventType: import_v4.z.string(),
|
|
2271
|
-
status: import_v4.z.optional(import_v4.z.union([AnyOfStatus, ExactStatus])),
|
|
2355
|
+
status: import_v4.z.optional(import_v4.z.union([AnyOfStatus, NoneOfStatus, ExactStatus])),
|
|
2272
2356
|
createdAt: import_v4.z.optional(DateCondition),
|
|
2273
2357
|
updatedAt: import_v4.z.optional(DateCondition),
|
|
2274
2358
|
"legalStatuses.DECLARED.createdAtLocation": import_v4.z.optional(Within).nullable(),
|
|
@@ -2277,6 +2361,7 @@ var QueryExpression = import_v4.z.object({
|
|
|
2277
2361
|
"legalStatuses.REGISTERED.createdAtLocation": import_v4.z.optional(Within).nullable(),
|
|
2278
2362
|
"legalStatuses.REGISTERED.createdByRole": import_v4.z.optional(AnyOf),
|
|
2279
2363
|
"legalStatuses.REGISTERED.registrationNumber": import_v4.z.optional(Exact),
|
|
2364
|
+
"legalStatuses.REVOKED.createdAtLocation": import_v4.z.optional(Within).nullable(),
|
|
2280
2365
|
createdAtLocation: import_v4.z.optional(import_v4.z.union([Within, Exact])),
|
|
2281
2366
|
updatedAtLocation: import_v4.z.optional(import_v4.z.union([Within, Exact])),
|
|
2282
2367
|
assignedTo: import_v4.z.optional(Exact),
|
|
@@ -3477,6 +3562,12 @@ var ReadActionConfig = ActionConfigBase.extend(
|
|
|
3477
3562
|
var NotifyConfig = ActionConfigBase.extend(
|
|
3478
3563
|
z25.object({
|
|
3479
3564
|
type: z25.literal(ActionType.NOTIFY),
|
|
3565
|
+
notificationForm: DeclarationFormConfig.describe(
|
|
3566
|
+
"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."
|
|
3567
|
+
),
|
|
3568
|
+
review: DeclarationReviewConfig.describe(
|
|
3569
|
+
"Review page configuration for the notify action. Values of its fields are stored as the NOTIFY action annotation."
|
|
3570
|
+
),
|
|
3480
3571
|
form: actionConfirmationForm
|
|
3481
3572
|
}).shape
|
|
3482
3573
|
);
|
|
@@ -3529,6 +3620,9 @@ var DeleteConfig = ActionConfigBase.extend(
|
|
|
3529
3620
|
var DeclareConfig = DeclarationActionBase.extend(
|
|
3530
3621
|
z25.object({
|
|
3531
3622
|
type: z25.literal(ActionType.DECLARE),
|
|
3623
|
+
declaration: DeclarationFormConfig.describe(
|
|
3624
|
+
"Configuration of the form used to gather event data."
|
|
3625
|
+
),
|
|
3532
3626
|
review: DeclarationReviewConfig.describe(
|
|
3533
3627
|
"Configuration of the review page fields."
|
|
3534
3628
|
),
|
|
@@ -3557,6 +3651,18 @@ var UnarchiveConfig = ActionConfigBase.extend(
|
|
|
3557
3651
|
type: z25.literal(ActionType.UNARCHIVE)
|
|
3558
3652
|
}).shape
|
|
3559
3653
|
);
|
|
3654
|
+
var RevokeRegistrationConfig = ActionConfigBase.extend(
|
|
3655
|
+
z25.object({
|
|
3656
|
+
type: z25.literal(ActionType.REVOKE_REGISTRATION),
|
|
3657
|
+
form: actionConfirmationForm
|
|
3658
|
+
}).shape
|
|
3659
|
+
);
|
|
3660
|
+
var ReinstateRegistrationConfig = ActionConfigBase.extend(
|
|
3661
|
+
z25.object({
|
|
3662
|
+
type: z25.literal(ActionType.REINSTATE_REGISTRATION),
|
|
3663
|
+
form: actionConfirmationForm
|
|
3664
|
+
}).shape
|
|
3665
|
+
);
|
|
3560
3666
|
var EditActionConfig = ActionConfigBase.extend(
|
|
3561
3667
|
z25.object({
|
|
3562
3668
|
type: z25.literal(ActionType.EDIT),
|
|
@@ -3643,11 +3749,11 @@ var ActionConfig = z25.discriminatedUnion("type", [
|
|
|
3643
3749
|
}),
|
|
3644
3750
|
NotifyConfig.meta({
|
|
3645
3751
|
id: "NotifyActionConfig",
|
|
3646
|
-
description: "Configuration for the notify action
|
|
3752
|
+
description: "Configuration for the notify action, including the notification form and its review page. When undefined, it is generated using the DeclareActionConfig."
|
|
3647
3753
|
}),
|
|
3648
3754
|
DeclareConfig.meta({
|
|
3649
3755
|
id: "DeclareActionConfig",
|
|
3650
|
-
description: "Configuration for the declare action. Includes review-page fields.
|
|
3756
|
+
description: "Configuration for the declare action. Includes the declaration form and review-page fields."
|
|
3651
3757
|
}),
|
|
3652
3758
|
DuplicateDetectedConfig.meta({
|
|
3653
3759
|
id: "DuplicateDetectedActionConfig",
|
|
@@ -3697,6 +3803,14 @@ var ActionConfig = z25.discriminatedUnion("type", [
|
|
|
3697
3803
|
id: "UnarchiveActionConfig",
|
|
3698
3804
|
description: "Configuration for unarchiving a record."
|
|
3699
3805
|
}),
|
|
3806
|
+
RevokeRegistrationConfig.meta({
|
|
3807
|
+
id: "RevokeRegistrationActionConfig",
|
|
3808
|
+
description: "Configuration for revoking a registered record."
|
|
3809
|
+
}),
|
|
3810
|
+
ReinstateRegistrationConfig.meta({
|
|
3811
|
+
id: "ReinstateRegistrationActionConfig",
|
|
3812
|
+
description: "Configuration for reinstating a revoked record back to registered."
|
|
3813
|
+
}),
|
|
3700
3814
|
CustomActionConfig.meta({
|
|
3701
3815
|
id: "CustomActionConfig",
|
|
3702
3816
|
description: "Configuration for a country-defined custom action. An event may include any number of these."
|
|
@@ -3998,7 +4112,10 @@ var SearchQueryParams = z30.object({
|
|
|
3998
4112
|
}).catchall(FieldValue);
|
|
3999
4113
|
var FieldConfigSchema = BaseField3.extend({
|
|
4000
4114
|
fieldId: z30.string(),
|
|
4001
|
-
fieldType: z30.literal("field")
|
|
4115
|
+
fieldType: z30.literal("field"),
|
|
4116
|
+
defaultValue: z30.union([z30.boolean(), z30.string(), z30.number()]).optional().describe(
|
|
4117
|
+
`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.`
|
|
4118
|
+
)
|
|
4002
4119
|
});
|
|
4003
4120
|
var EventFieldIdInput = z30.enum([
|
|
4004
4121
|
"trackingId",
|
|
@@ -4508,6 +4625,8 @@ var updateActions = new Set(
|
|
|
4508
4625
|
ActionType.REQUEST_CORRECTION,
|
|
4509
4626
|
ActionType.APPROVE_CORRECTION,
|
|
4510
4627
|
ActionType.REJECT_CORRECTION,
|
|
4628
|
+
ActionType.REVOKE_REGISTRATION,
|
|
4629
|
+
ActionType.REINSTATE_REGISTRATION,
|
|
4511
4630
|
ActionType.CUSTOM
|
|
4512
4631
|
]).options
|
|
4513
4632
|
);
|
|
@@ -4534,7 +4653,7 @@ function getActionUpdateMetadata(actions) {
|
|
|
4534
4653
|
(0, import_lodash.pick)(createAction, metadataFields)
|
|
4535
4654
|
);
|
|
4536
4655
|
}
|
|
4537
|
-
function getLegalStatuses(actions) {
|
|
4656
|
+
function getLegalStatuses(actions, status2) {
|
|
4538
4657
|
return {
|
|
4539
4658
|
[EventStatus.enum.NOTIFIED]: getDeclarationActionCreationMetadata(
|
|
4540
4659
|
ActionType.NOTIFY,
|
|
@@ -4547,7 +4666,12 @@ function getLegalStatuses(actions) {
|
|
|
4547
4666
|
[EventStatus.enum.REGISTERED]: getDeclarationActionCreationMetadata(
|
|
4548
4667
|
ActionType.REGISTER,
|
|
4549
4668
|
actions
|
|
4550
|
-
)
|
|
4669
|
+
),
|
|
4670
|
+
// A later reinstate does not remove the revoke action, so only report it while the record is still revoked.
|
|
4671
|
+
[EventStatus.enum.REVOKED]: status2 === EventStatus.enum.REVOKED ? getDeclarationActionCreationMetadata(
|
|
4672
|
+
ActionType.REVOKE_REGISTRATION,
|
|
4673
|
+
actions
|
|
4674
|
+
) : null
|
|
4551
4675
|
};
|
|
4552
4676
|
}
|
|
4553
4677
|
|
|
@@ -4624,15 +4748,6 @@ var INHERENT_FLAG_RULES = [
|
|
|
4624
4748
|
setOn: [ActionType.REQUEST_CORRECTION],
|
|
4625
4749
|
resetOn: [ActionType.APPROVE_CORRECTION, ActionType.REJECT_CORRECTION]
|
|
4626
4750
|
},
|
|
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
4751
|
{
|
|
4637
4752
|
flag: InherentFlags.REJECTED,
|
|
4638
4753
|
setOn: [ActionType.REJECT],
|
|
@@ -5417,6 +5532,10 @@ function getStatusFromActions(actions) {
|
|
|
5417
5532
|
return EventStatus.enum.REGISTERED;
|
|
5418
5533
|
case ActionType.NOTIFY:
|
|
5419
5534
|
return EventStatus.enum.NOTIFIED;
|
|
5535
|
+
case ActionType.REVOKE_REGISTRATION:
|
|
5536
|
+
return EventStatus.enum.REVOKED;
|
|
5537
|
+
case ActionType.REINSTATE_REGISTRATION:
|
|
5538
|
+
return EventStatus.enum.REGISTERED;
|
|
5420
5539
|
// Already filtered out above; listed here only to satisfy exhaustiveness.
|
|
5421
5540
|
case ActionType.ARCHIVE:
|
|
5422
5541
|
case ActionType.UNARCHIVE:
|
|
@@ -5476,35 +5595,24 @@ function resolveDateOfEvent(eventIndex, declaration, config) {
|
|
|
5476
5595
|
if (!config.dateOfEvent) {
|
|
5477
5596
|
return extractDateString(eventIndex[DEFAULT_DATE_OF_EVENT_PROPERTY]);
|
|
5478
5597
|
}
|
|
5479
|
-
|
|
5480
|
-
|
|
5598
|
+
if (isFieldReference(config.dateOfEvent)) {
|
|
5599
|
+
const fieldDate = declaration[config.dateOfEvent.$$field];
|
|
5600
|
+
return ZodDate.validate(fieldDate) ? extractDateString(fieldDate) : void 0;
|
|
5601
|
+
}
|
|
5602
|
+
const eventDate = getMixedPath(
|
|
5603
|
+
eventIndex,
|
|
5604
|
+
config.dateOfEvent.$$event
|
|
5481
5605
|
);
|
|
5482
|
-
return
|
|
5606
|
+
return ZodDateTime.validate(eventDate) ? extractDateString(eventDate) : void 0;
|
|
5483
5607
|
}
|
|
5484
5608
|
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
5609
|
function resolvePlaceOfEvent(eventMetadata, declaration, config) {
|
|
5490
|
-
let placeOfEvent =
|
|
5610
|
+
let placeOfEvent = maybeUuid(
|
|
5491
5611
|
eventMetadata[DEFAULT_PLACE_OF_EVENT_PROPERTY]
|
|
5492
5612
|
);
|
|
5493
5613
|
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
|
-
}
|
|
5614
|
+
const addressFieldValue = declaration[config.placeOfEvent.$$field];
|
|
5615
|
+
placeOfEvent = isDomesticAddressFieldValue(addressFieldValue) ? maybeUuid(addressFieldValue.administrativeArea) ?? placeOfEvent : maybeUuid(declaration[config.placeOfEvent.$$field]) ?? placeOfEvent;
|
|
5508
5616
|
}
|
|
5509
5617
|
return placeOfEvent;
|
|
5510
5618
|
}
|
|
@@ -5534,7 +5642,7 @@ function getCurrentEventState(event2, config) {
|
|
|
5534
5642
|
const acceptedActionMetadata = getActionUpdateMetadata(acceptedActions);
|
|
5535
5643
|
const declaration = aggregateActionDeclarations(event2);
|
|
5536
5644
|
const status2 = getStatusFromActions(sortedActions);
|
|
5537
|
-
const legalStatuses = getLegalStatuses(sortedActions);
|
|
5645
|
+
const legalStatuses = getLegalStatuses(sortedActions, status2);
|
|
5538
5646
|
const base = deepDropNulls({
|
|
5539
5647
|
id: event2.id,
|
|
5540
5648
|
type: event2.type,
|
|
@@ -5708,7 +5816,9 @@ function buildClientFunctionContext(input) {
|
|
|
5708
5816
|
// eslint-disable-next-line @typescript-eslint/no-use-before-define
|
|
5709
5817
|
$online: isOnline(),
|
|
5710
5818
|
$user: input.validatorContext?.user,
|
|
5711
|
-
$event: input.validatorContext?.event?.document
|
|
5819
|
+
$event: input.validatorContext?.event?.document ? getEventWithCompleteAcceptedActions(
|
|
5820
|
+
input.validatorContext.event.document
|
|
5821
|
+
) : void 0,
|
|
5712
5822
|
$leafAdminStructureLocationIds: input.validatorContext?.leafAdminStructureLocationIds ?? [],
|
|
5713
5823
|
user: input.systemVariables?.user,
|
|
5714
5824
|
$window: input.systemVariables?.$window,
|
|
@@ -5789,7 +5899,7 @@ function precompileActionSchemas(eventConfigurations) {
|
|
|
5789
5899
|
}
|
|
5790
5900
|
}
|
|
5791
5901
|
function isAgeValue(value) {
|
|
5792
|
-
return
|
|
5902
|
+
return AgeValue.validate(value);
|
|
5793
5903
|
}
|
|
5794
5904
|
function mergeWithBaseFormState(values, context) {
|
|
5795
5905
|
return { ...context.baseFormState, ...values };
|
|
@@ -5819,15 +5929,13 @@ function validate(schema, data) {
|
|
|
5819
5929
|
return [key, value];
|
|
5820
5930
|
}
|
|
5821
5931
|
const age = value.age;
|
|
5822
|
-
const
|
|
5932
|
+
const asOf = data.$form[value.asOfDateRef];
|
|
5933
|
+
const asOfDate = isPlainDate(asOf) ? asOf : PlainDate.parse(data.$now);
|
|
5823
5934
|
return [
|
|
5824
5935
|
key,
|
|
5825
5936
|
{
|
|
5826
5937
|
age,
|
|
5827
|
-
dob: ageToDate(
|
|
5828
|
-
age,
|
|
5829
|
-
maybeAsOfDate.success ? maybeAsOfDate.data : PlainDate.parse(data.$now)
|
|
5830
|
-
)
|
|
5938
|
+
dob: ageToDate(age, asOfDate)
|
|
5831
5939
|
}
|
|
5832
5940
|
];
|
|
5833
5941
|
});
|
|
@@ -5990,6 +6098,11 @@ var errorMessages = {
|
|
|
5990
6098
|
description: "Error message when field is not expected",
|
|
5991
6099
|
id: "error.unexpectedField"
|
|
5992
6100
|
},
|
|
6101
|
+
notInNotifyForm: {
|
|
6102
|
+
defaultMessage: "Field is not part of the notify form. Notify-only data belongs in annotation",
|
|
6103
|
+
description: "Error message when a notify declaration contains a field outside the notify form",
|
|
6104
|
+
id: "error.notInNotifyForm"
|
|
6105
|
+
},
|
|
5993
6106
|
correctionNotAllowed: {
|
|
5994
6107
|
defaultMessage: "Correction not allowed for field",
|
|
5995
6108
|
description: "Error message when correction is not allowed for field",
|
|
@@ -6209,14 +6322,45 @@ function ageToDate(age, asOfDate) {
|
|
|
6209
6322
|
const date = plainDateToLocalDate(asOfDate);
|
|
6210
6323
|
return PlainDate.parse((0, import_date_fns3.format)((0, import_date_fns3.subYears)(date, age), "yyyy-MM-dd"));
|
|
6211
6324
|
}
|
|
6212
|
-
function
|
|
6213
|
-
|
|
6325
|
+
function getDeclaration(configuration) {
|
|
6326
|
+
const declareAction = configuration.actions.find(
|
|
6327
|
+
(action) => action.type === ActionType.DECLARE
|
|
6328
|
+
);
|
|
6329
|
+
if (!declareAction) {
|
|
6330
|
+
throw new Error(
|
|
6331
|
+
`Event '${configuration.id}' has no ${ActionType.DECLARE} action to read the declaration from`
|
|
6332
|
+
);
|
|
6333
|
+
}
|
|
6334
|
+
return declareAction.declaration;
|
|
6214
6335
|
}
|
|
6215
6336
|
function getDeclarationPages(configuration) {
|
|
6216
|
-
return configuration.
|
|
6337
|
+
return getDeclaration(configuration).pages;
|
|
6217
6338
|
}
|
|
6218
|
-
function
|
|
6219
|
-
return configuration.
|
|
6339
|
+
function getDeclarationFields(configuration) {
|
|
6340
|
+
return getDeclarationPages(configuration).flatMap(({ fields }) => fields);
|
|
6341
|
+
}
|
|
6342
|
+
function findNotificationForm(configuration) {
|
|
6343
|
+
const notifyAction = configuration.actions.find(
|
|
6344
|
+
(action) => action.type === ActionType.NOTIFY
|
|
6345
|
+
);
|
|
6346
|
+
return notifyAction?.type === ActionType.NOTIFY ? notifyAction.notificationForm : void 0;
|
|
6347
|
+
}
|
|
6348
|
+
function getNotificationForm(configuration) {
|
|
6349
|
+
const notificationForm = findNotificationForm(configuration);
|
|
6350
|
+
if (!notificationForm) {
|
|
6351
|
+
throw new Error(
|
|
6352
|
+
`Event '${configuration.id}' has no ${ActionType.NOTIFY} action.`
|
|
6353
|
+
);
|
|
6354
|
+
}
|
|
6355
|
+
return notificationForm;
|
|
6356
|
+
}
|
|
6357
|
+
function getNotificationFields(configuration) {
|
|
6358
|
+
return getNotificationForm(configuration).pages.flatMap(
|
|
6359
|
+
({ fields }) => fields
|
|
6360
|
+
);
|
|
6361
|
+
}
|
|
6362
|
+
function getActionForm(configuration, actionType) {
|
|
6363
|
+
return actionType === ActionType.NOTIFY ? getNotificationForm(configuration) : getDeclaration(configuration);
|
|
6220
6364
|
}
|
|
6221
6365
|
function isActionConfigType(type) {
|
|
6222
6366
|
return actionConfigTypes.has(type);
|
|
@@ -6226,9 +6370,6 @@ function getActionConfig({
|
|
|
6226
6370
|
actionType,
|
|
6227
6371
|
customActionType
|
|
6228
6372
|
}) {
|
|
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
6373
|
return eventConfiguration.actions.find((a) => {
|
|
6233
6374
|
if (a.type === ActionType.CUSTOM && customActionType) {
|
|
6234
6375
|
return a.customActionType === customActionType;
|
|
@@ -6476,11 +6617,12 @@ function flattenFieldReference(ref) {
|
|
|
6476
6617
|
return [ref.$$field, ...ref.$$subfield];
|
|
6477
6618
|
}
|
|
6478
6619
|
function isWriteAction(actionType) {
|
|
6479
|
-
return writeActions.
|
|
6620
|
+
return writeActions.validate(actionType);
|
|
6480
6621
|
}
|
|
6481
6622
|
var findAllFields = (config) => {
|
|
6482
6623
|
return (0, import_lodash4.flattenDeep)([
|
|
6483
6624
|
...getDeclarationFields(config),
|
|
6625
|
+
...findNotificationForm(config)?.pages.flatMap(({ fields }) => fields) ?? [],
|
|
6484
6626
|
...getAllAnnotationFields(config)
|
|
6485
6627
|
]);
|
|
6486
6628
|
};
|
|
@@ -6616,12 +6758,41 @@ function getCompleteActionDeclaration(declaration, event2, action) {
|
|
|
6616
6758
|
}
|
|
6617
6759
|
return deepMerge(declaration, action.declaration);
|
|
6618
6760
|
}
|
|
6619
|
-
function
|
|
6620
|
-
return
|
|
6761
|
+
function completeAcceptedAction(event2, action) {
|
|
6762
|
+
return {
|
|
6621
6763
|
...action,
|
|
6622
6764
|
declaration: getCompleteActionDeclaration({}, event2, action),
|
|
6623
6765
|
annotation: getCompleteActionAnnotation(event2, action)
|
|
6624
|
-
}
|
|
6766
|
+
};
|
|
6767
|
+
}
|
|
6768
|
+
function getAcceptedActions(event2) {
|
|
6769
|
+
return event2.actions.filter(isAcceptedAction).map((action) => completeAcceptedAction(event2, action));
|
|
6770
|
+
}
|
|
6771
|
+
function getEventWithCompleteAcceptedActions(event2) {
|
|
6772
|
+
return {
|
|
6773
|
+
...event2,
|
|
6774
|
+
actions: event2.actions.map((action) => {
|
|
6775
|
+
if (!isAcceptedAction(action) || !action.originalActionId) {
|
|
6776
|
+
return action;
|
|
6777
|
+
}
|
|
6778
|
+
const requestedAction = event2.actions.find(
|
|
6779
|
+
({ id }) => id === action.originalActionId
|
|
6780
|
+
);
|
|
6781
|
+
if (requestedAction?.status !== ActionStatus.Requested) {
|
|
6782
|
+
return action;
|
|
6783
|
+
}
|
|
6784
|
+
const content = getCompleteActionContent(event2, action);
|
|
6785
|
+
return {
|
|
6786
|
+
...completeAcceptedAction(event2, action),
|
|
6787
|
+
// Who requested the action, as getActionUpdateMetadata resolves it.
|
|
6788
|
+
createdBy: requestedAction.createdBy,
|
|
6789
|
+
createdByRole: requestedAction.createdByRole,
|
|
6790
|
+
createdByUserType: requestedAction.createdByUserType,
|
|
6791
|
+
createdAtLocation: requestedAction.createdAtLocation,
|
|
6792
|
+
...content ? { content } : {}
|
|
6793
|
+
};
|
|
6794
|
+
})
|
|
6795
|
+
};
|
|
6625
6796
|
}
|
|
6626
6797
|
var EXCLUDED_ACTIONS = [
|
|
6627
6798
|
ActionType.REQUEST_CORRECTION,
|
|
@@ -6720,6 +6891,20 @@ function dropSecuredDeclarationFields(eventConfig, eventIndex, validatorContext)
|
|
|
6720
6891
|
}
|
|
6721
6892
|
|
|
6722
6893
|
// ../commons/src/events/eventConfigValidation.ts
|
|
6894
|
+
var SEARCH_DEFAULT_VALUE_FIELD_TYPES = [
|
|
6895
|
+
FieldType.TEXT,
|
|
6896
|
+
FieldType.TEXTAREA,
|
|
6897
|
+
FieldType.EMAIL,
|
|
6898
|
+
FieldType.PHONE,
|
|
6899
|
+
FieldType.ID,
|
|
6900
|
+
FieldType.SELECT,
|
|
6901
|
+
FieldType.RADIO_GROUP,
|
|
6902
|
+
FieldType.COUNTRY,
|
|
6903
|
+
FieldType.LOCATION,
|
|
6904
|
+
FieldType.ADMINISTRATIVE_AREA,
|
|
6905
|
+
FieldType.NUMBER,
|
|
6906
|
+
FieldType.DATE
|
|
6907
|
+
];
|
|
6723
6908
|
function validateAdvancedSearchConfig(event2, ctx) {
|
|
6724
6909
|
const allFields = findAllFields(event2);
|
|
6725
6910
|
const fieldIds = allFields.map((field3) => field3.id);
|
|
@@ -6751,6 +6936,56 @@ function validateAdvancedSearchConfig(event2, ctx) {
|
|
|
6751
6936
|
path: ["advancedSearch"]
|
|
6752
6937
|
});
|
|
6753
6938
|
}
|
|
6939
|
+
event2.advancedSearch.forEach((section, sectionIndex) => {
|
|
6940
|
+
section.fields.forEach((searchField, fieldIndex) => {
|
|
6941
|
+
if (searchField.fieldType !== "field" || searchField.defaultValue === void 0) {
|
|
6942
|
+
return;
|
|
6943
|
+
}
|
|
6944
|
+
const path = [
|
|
6945
|
+
"advancedSearch",
|
|
6946
|
+
sectionIndex,
|
|
6947
|
+
"fields",
|
|
6948
|
+
fieldIndex,
|
|
6949
|
+
"defaultValue"
|
|
6950
|
+
];
|
|
6951
|
+
if (searchField.config.searchFields && searchField.config.searchFields.length > 0) {
|
|
6952
|
+
ctx.addIssue({
|
|
6953
|
+
code: "custom",
|
|
6954
|
+
message: `Advanced search field ${searchField.fieldId} searches across several form fields, so it does not support a defaultValue.`,
|
|
6955
|
+
path
|
|
6956
|
+
});
|
|
6957
|
+
return;
|
|
6958
|
+
}
|
|
6959
|
+
if (typeof searchField.defaultValue === "boolean") {
|
|
6960
|
+
return;
|
|
6961
|
+
}
|
|
6962
|
+
const formField = allFields.find(({ id }) => id === searchField.fieldId);
|
|
6963
|
+
if (!formField) {
|
|
6964
|
+
return;
|
|
6965
|
+
}
|
|
6966
|
+
if (!SEARCH_DEFAULT_VALUE_FIELD_TYPES.some(
|
|
6967
|
+
(type) => type === formField.type
|
|
6968
|
+
)) {
|
|
6969
|
+
ctx.addIssue({
|
|
6970
|
+
code: "custom",
|
|
6971
|
+
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(", ")}.`,
|
|
6972
|
+
path
|
|
6973
|
+
});
|
|
6974
|
+
} else if (formField.type === FieldType.DATE && searchField.config.type === "range") {
|
|
6975
|
+
ctx.addIssue({
|
|
6976
|
+
code: "custom",
|
|
6977
|
+
message: `Advanced search field ${searchField.fieldId} is searched as a date range, so its defaultValue can only be true or false.`,
|
|
6978
|
+
path
|
|
6979
|
+
});
|
|
6980
|
+
} else if (!mapFieldTypeToZod(formField).safeParse(searchField.defaultValue).success) {
|
|
6981
|
+
ctx.addIssue({
|
|
6982
|
+
code: "custom",
|
|
6983
|
+
message: `Advanced search field ${searchField.fieldId} has defaultValue "${searchField.defaultValue}", which is not a valid ${formField.type} value.`,
|
|
6984
|
+
path
|
|
6985
|
+
});
|
|
6986
|
+
}
|
|
6987
|
+
});
|
|
6988
|
+
});
|
|
6754
6989
|
}
|
|
6755
6990
|
function validateDateOfEvent(event2, ctx) {
|
|
6756
6991
|
if (event2.dateOfEvent && isFieldReference(event2.dateOfEvent)) {
|
|
@@ -6837,15 +7072,102 @@ function validateActionOrder(event2, ctx) {
|
|
|
6837
7072
|
}
|
|
6838
7073
|
}
|
|
6839
7074
|
}
|
|
7075
|
+
function validateExactlyOneDeclareAction(event2, ctx) {
|
|
7076
|
+
const declareActionCount = event2.actions.filter(
|
|
7077
|
+
(action) => action.type === ActionType.DECLARE
|
|
7078
|
+
).length;
|
|
7079
|
+
if (declareActionCount !== 1) {
|
|
7080
|
+
ctx.addIssue({
|
|
7081
|
+
code: "custom",
|
|
7082
|
+
message: `Event must have exactly one ${ActionType.DECLARE} action. Found ${declareActionCount} for event ${event2.id}`,
|
|
7083
|
+
path: ["actions"]
|
|
7084
|
+
});
|
|
7085
|
+
return false;
|
|
7086
|
+
}
|
|
7087
|
+
return true;
|
|
7088
|
+
}
|
|
7089
|
+
function validateDeclarationGivenExactlyOnce(config, ctx) {
|
|
7090
|
+
const declareActionIndex = config.actions.findIndex(
|
|
7091
|
+
(action) => action.type === ActionType.DECLARE
|
|
7092
|
+
);
|
|
7093
|
+
const declareAction = config.actions[declareActionIndex];
|
|
7094
|
+
const onDeclareAction = declareAction.type === ActionType.DECLARE && !!declareAction.declaration;
|
|
7095
|
+
const onTopLevel = !!config.declaration;
|
|
7096
|
+
const declareActionPath = `actions[${declareActionIndex}].declaration`;
|
|
7097
|
+
if (onTopLevel && onDeclareAction) {
|
|
7098
|
+
ctx.addIssue({
|
|
7099
|
+
code: "custom",
|
|
7100
|
+
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.`,
|
|
7101
|
+
path: ["declaration"]
|
|
7102
|
+
});
|
|
7103
|
+
}
|
|
7104
|
+
if (!onTopLevel && !onDeclareAction) {
|
|
7105
|
+
ctx.addIssue({
|
|
7106
|
+
code: "custom",
|
|
7107
|
+
message: `Event '${config.id}' does not define \`declaration\`. Define it either at the top level or on the ${ActionType.DECLARE} action (\`${declareActionPath}\`).`,
|
|
7108
|
+
path: ["declaration"]
|
|
7109
|
+
});
|
|
7110
|
+
}
|
|
7111
|
+
}
|
|
7112
|
+
function validateNotificationForm(event2, ctx) {
|
|
7113
|
+
const declarationFields = getDeclarationPages(event2).flatMap(
|
|
7114
|
+
(page) => page.fields.map((field3) => ({ field: field3, pageId: page.id }))
|
|
7115
|
+
);
|
|
7116
|
+
event2.actions.forEach((action, actionIndex) => {
|
|
7117
|
+
if (action.type !== ActionType.NOTIFY) {
|
|
7118
|
+
return;
|
|
7119
|
+
}
|
|
7120
|
+
action.notificationForm.pages.forEach((page, pageIndex) => {
|
|
7121
|
+
page.fields.forEach((field3, fieldIndex) => {
|
|
7122
|
+
const path = [
|
|
7123
|
+
"actions",
|
|
7124
|
+
actionIndex,
|
|
7125
|
+
"notificationForm",
|
|
7126
|
+
"pages",
|
|
7127
|
+
pageIndex,
|
|
7128
|
+
"fields",
|
|
7129
|
+
fieldIndex
|
|
7130
|
+
];
|
|
7131
|
+
const matchingFields = declarationFields.filter(
|
|
7132
|
+
(declarationField) => declarationField.field.id === field3.id
|
|
7133
|
+
);
|
|
7134
|
+
if (matchingFields.length === 0) {
|
|
7135
|
+
ctx.addIssue({
|
|
7136
|
+
code: "custom",
|
|
7137
|
+
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.`,
|
|
7138
|
+
path
|
|
7139
|
+
});
|
|
7140
|
+
return;
|
|
7141
|
+
}
|
|
7142
|
+
if (!matchingFields.some(
|
|
7143
|
+
(declarationField) => declarationField.field.type === field3.type
|
|
7144
|
+
)) {
|
|
7145
|
+
const [declarationField] = matchingFields;
|
|
7146
|
+
ctx.addIssue({
|
|
7147
|
+
code: "custom",
|
|
7148
|
+
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}.`,
|
|
7149
|
+
path
|
|
7150
|
+
});
|
|
7151
|
+
}
|
|
7152
|
+
});
|
|
7153
|
+
});
|
|
7154
|
+
});
|
|
7155
|
+
}
|
|
6840
7156
|
|
|
6841
7157
|
// ../commons/src/events/EventConfig.ts
|
|
6842
7158
|
var EventFieldReference = z35.object({ $$event: EventMetadataDateFieldIdInput }).describe(
|
|
6843
7159
|
"Reference to a field defined in the event metadata, using the field id."
|
|
6844
7160
|
);
|
|
6845
|
-
var
|
|
7161
|
+
var eventLevelFields = {
|
|
6846
7162
|
id: z35.string().describe(
|
|
6847
7163
|
'Machine-readable identifier of the event (e.g. "birth", "death").'
|
|
6848
7164
|
),
|
|
7165
|
+
label: TranslationConfig.describe("Human-readable label for the event type."),
|
|
7166
|
+
advancedSearch: z35.array(AdvancedSearchConfig).optional().default([]).describe(
|
|
7167
|
+
"Configuration of fields available in the advanced search feature."
|
|
7168
|
+
)
|
|
7169
|
+
};
|
|
7170
|
+
var versionFields = {
|
|
6849
7171
|
dateOfEvent: FieldReference.or(EventFieldReference).optional().describe(
|
|
6850
7172
|
"Reference to the field capturing the date of the event (e.g. date of birth). Defaults to the event creation date if unspecified."
|
|
6851
7173
|
),
|
|
@@ -6861,19 +7183,12 @@ var _EventConfigBase = z35.object({
|
|
|
6861
7183
|
summary: SummaryConfig.describe(
|
|
6862
7184
|
"Summary information displayed in the event overview."
|
|
6863
7185
|
),
|
|
6864
|
-
label: TranslationConfig.describe("Human-readable label for the event type."),
|
|
6865
7186
|
actions: z35.array(ActionConfig).describe(
|
|
6866
7187
|
"Configuration of core and custom actions associated with the event."
|
|
6867
7188
|
),
|
|
6868
7189
|
actionOrder: z35.array(z35.string()).optional().describe(
|
|
6869
7190
|
"Order of actions in the action menu. Use either the action type for core actions or the customActionType for custom actions."
|
|
6870
7191
|
),
|
|
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
7192
|
flags: z35.array(FlagConfig).optional().default([]).describe(
|
|
6878
7193
|
"Configuration of custom flags associated with the actions of this event type."
|
|
6879
7194
|
),
|
|
@@ -6883,17 +7198,128 @@ var _EventConfigBase = z35.object({
|
|
|
6883
7198
|
icon: z35.partialRecord(AvailableIcons, Conditional).optional().describe(
|
|
6884
7199
|
'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
7200
|
)
|
|
6886
|
-
}
|
|
6887
|
-
var
|
|
7201
|
+
};
|
|
7202
|
+
var _EventConfigBase = z35.object({ ...eventLevelFields, ...versionFields });
|
|
7203
|
+
function validateEventConfig(event2, ctx) {
|
|
7204
|
+
if (!validateExactlyOneDeclareAction(event2, ctx)) {
|
|
7205
|
+
return;
|
|
7206
|
+
}
|
|
7207
|
+
validateNotificationForm(event2, ctx);
|
|
6888
7208
|
validateAdvancedSearchConfig(event2, ctx);
|
|
6889
7209
|
validateDateOfEvent(event2, ctx);
|
|
6890
7210
|
validatePlaceOfEvent(event2, ctx);
|
|
6891
7211
|
validateActionFlags(event2, ctx);
|
|
6892
7212
|
validateActionOrder(event2, ctx);
|
|
6893
|
-
}
|
|
7213
|
+
}
|
|
7214
|
+
var EventConfig = _EventConfigBase.superRefine(validateEventConfig).meta({
|
|
6894
7215
|
id: "EventConfig",
|
|
6895
7216
|
description: "Configuration defining an event type registered in OpenCRVS (for example birth or death)."
|
|
6896
7217
|
});
|
|
7218
|
+
var DEFAULT_EVENT_CONFIG_VERSION_ID = "default";
|
|
7219
|
+
var DEFAULT_EFFECTIVE_FROM = "0001-01-01";
|
|
7220
|
+
var _EventConfigVersion = z35.object({
|
|
7221
|
+
id: z35.string().describe(
|
|
7222
|
+
'Identifier of the version, unique within the event (e.g. "birth-v2").'
|
|
7223
|
+
),
|
|
7224
|
+
effectiveFrom: z35.iso.date().default(DEFAULT_EFFECTIVE_FROM).describe(
|
|
7225
|
+
`Date (YYYY-MM-DD) from which this version is effective. A version without one is effective from the beginning of time ('${DEFAULT_EFFECTIVE_FROM}').`
|
|
7226
|
+
),
|
|
7227
|
+
...versionFields
|
|
7228
|
+
});
|
|
7229
|
+
var resolvedConfigs = /* @__PURE__ */ new WeakMap();
|
|
7230
|
+
function getEventConfigOfVersion(config, version) {
|
|
7231
|
+
let resolvedVersions = resolvedConfigs.get(config);
|
|
7232
|
+
if (!resolvedVersions) {
|
|
7233
|
+
resolvedVersions = /* @__PURE__ */ new WeakMap();
|
|
7234
|
+
resolvedConfigs.set(config, resolvedVersions);
|
|
7235
|
+
}
|
|
7236
|
+
const cached = resolvedVersions.get(version);
|
|
7237
|
+
if (cached) {
|
|
7238
|
+
return cached;
|
|
7239
|
+
}
|
|
7240
|
+
const { id: _id, effectiveFrom: _effectiveFrom, ...fields } = version;
|
|
7241
|
+
const resolved = {
|
|
7242
|
+
...fields,
|
|
7243
|
+
id: config.id,
|
|
7244
|
+
label: config.label,
|
|
7245
|
+
advancedSearch: config.advancedSearch
|
|
7246
|
+
};
|
|
7247
|
+
resolvedVersions.set(version, resolved);
|
|
7248
|
+
return resolved;
|
|
7249
|
+
}
|
|
7250
|
+
function resolveEventConfig(config) {
|
|
7251
|
+
return getEventConfigOfVersion(config, config.versions[0]);
|
|
7252
|
+
}
|
|
7253
|
+
function validateVersionList(config, ctx) {
|
|
7254
|
+
const ids = /* @__PURE__ */ new Set();
|
|
7255
|
+
const versionIdByEffectiveFrom = /* @__PURE__ */ new Map();
|
|
7256
|
+
config.versions.forEach((version, index) => {
|
|
7257
|
+
if (ids.has(version.id)) {
|
|
7258
|
+
ctx.addIssue({
|
|
7259
|
+
code: "custom",
|
|
7260
|
+
message: `Event '${config.id}' has more than one version with id '${version.id}'. Each version must have a different id.`,
|
|
7261
|
+
path: ["versions", index, "id"]
|
|
7262
|
+
});
|
|
7263
|
+
}
|
|
7264
|
+
ids.add(version.id);
|
|
7265
|
+
const sameEffectiveFromId = versionIdByEffectiveFrom.get(
|
|
7266
|
+
version.effectiveFrom
|
|
7267
|
+
);
|
|
7268
|
+
if (sameEffectiveFromId !== void 0) {
|
|
7269
|
+
const versionIds = `'${sameEffectiveFromId}', '${version.id}'`;
|
|
7270
|
+
ctx.addIssue({
|
|
7271
|
+
code: "custom",
|
|
7272
|
+
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.`,
|
|
7273
|
+
path: ["versions", index, "effectiveFrom"]
|
|
7274
|
+
});
|
|
7275
|
+
} else {
|
|
7276
|
+
versionIdByEffectiveFrom.set(version.effectiveFrom, version.id);
|
|
7277
|
+
}
|
|
7278
|
+
});
|
|
7279
|
+
}
|
|
7280
|
+
function validateEachVersion(ctx, events, validate2) {
|
|
7281
|
+
const reported = /* @__PURE__ */ new Set();
|
|
7282
|
+
events.forEach((event2, index) => {
|
|
7283
|
+
const addIssue = (issue) => {
|
|
7284
|
+
if (typeof issue === "string") {
|
|
7285
|
+
ctx.addIssue({
|
|
7286
|
+
code: "custom",
|
|
7287
|
+
message: issue,
|
|
7288
|
+
path: ["versions", index]
|
|
7289
|
+
});
|
|
7290
|
+
return;
|
|
7291
|
+
}
|
|
7292
|
+
const [field3] = issue.path ?? [];
|
|
7293
|
+
const isEventLevel = typeof field3 === "string" && field3 in eventLevelFields;
|
|
7294
|
+
const path = isEventLevel ? issue.path ?? [] : ["versions", index, ...issue.path ?? []];
|
|
7295
|
+
const key = JSON.stringify([path, issue.message]);
|
|
7296
|
+
if (reported.has(key)) {
|
|
7297
|
+
return;
|
|
7298
|
+
}
|
|
7299
|
+
reported.add(key);
|
|
7300
|
+
ctx.addIssue({ ...issue, path });
|
|
7301
|
+
};
|
|
7302
|
+
validate2(event2, { value: event2, addIssue });
|
|
7303
|
+
});
|
|
7304
|
+
}
|
|
7305
|
+
var VersionedEventConfig = z35.object({
|
|
7306
|
+
...eventLevelFields,
|
|
7307
|
+
versions: z35.array(_EventConfigVersion).min(1).describe(
|
|
7308
|
+
`Versions of the event configuration, each effective from its \`effectiveFrom\`. An event configured without versions has a single version, with id '${DEFAULT_EVENT_CONFIG_VERSION_ID}' and \`effectiveFrom\` '${DEFAULT_EFFECTIVE_FROM}'.`
|
|
7309
|
+
)
|
|
7310
|
+
}).superRefine((config, ctx) => {
|
|
7311
|
+
validateVersionList(config, ctx);
|
|
7312
|
+
validateEachVersion(
|
|
7313
|
+
ctx,
|
|
7314
|
+
config.versions.map(
|
|
7315
|
+
(version) => getEventConfigOfVersion(config, version)
|
|
7316
|
+
),
|
|
7317
|
+
validateEventConfig
|
|
7318
|
+
);
|
|
7319
|
+
}).meta({
|
|
7320
|
+
id: "VersionedEventConfig",
|
|
7321
|
+
description: "Configuration of an event type registered in OpenCRVS (for example birth or death), with every version of it."
|
|
7322
|
+
});
|
|
6897
7323
|
|
|
6898
7324
|
// ../commons/src/events/EventConfigInput.ts
|
|
6899
7325
|
var defineDeclarationForm = (form) => DeclarationFormConfig.parse(form);
|
|
@@ -6966,7 +7392,7 @@ function createSearchConfig(baseField) {
|
|
|
6966
7392
|
|
|
6967
7393
|
// ../commons/src/event-config/event-configuration.ts
|
|
6968
7394
|
function isNonSearchableEventMetadataTimeFieldId(fieldId) {
|
|
6969
|
-
return !EventFieldIdInput.
|
|
7395
|
+
return !EventFieldIdInput.validate(fieldId);
|
|
6970
7396
|
}
|
|
6971
7397
|
function createEventFieldConfig(fieldId) {
|
|
6972
7398
|
const baseField = {
|
|
@@ -6993,7 +7419,10 @@ function eventFn(fieldId) {
|
|
|
6993
7419
|
}
|
|
6994
7420
|
var event = Object.assign(eventFn, {
|
|
6995
7421
|
/**
|
|
6996
|
-
* Checks if the event contains a specific action type.
|
|
7422
|
+
* Checks if the event contains a specific accepted action type.
|
|
7423
|
+
* Only Accepted actions are matched: a confirmable action is stored as a
|
|
7424
|
+
* Requested and an Accepted action, and a pending or rejected request must
|
|
7425
|
+
* not count as the action having happened.
|
|
6997
7426
|
* Can be used directly as a conditional or chained with additional methods.
|
|
6998
7427
|
* @param action - The action type to check for.
|
|
6999
7428
|
*/
|
|
@@ -7011,9 +7440,12 @@ var event = Object.assign(eventFn, {
|
|
|
7011
7440
|
properties: {
|
|
7012
7441
|
type: {
|
|
7013
7442
|
const: action
|
|
7443
|
+
},
|
|
7444
|
+
status: {
|
|
7445
|
+
const: ActionStatus.Accepted
|
|
7014
7446
|
}
|
|
7015
7447
|
},
|
|
7016
|
-
required: ["type"]
|
|
7448
|
+
required: ["type", "status"]
|
|
7017
7449
|
}
|
|
7018
7450
|
}
|
|
7019
7451
|
},
|
|
@@ -7024,9 +7456,10 @@ var event = Object.assign(eventFn, {
|
|
|
7024
7456
|
});
|
|
7025
7457
|
const buildActionConstraints = (additionalFields) => {
|
|
7026
7458
|
const actionProperties = {
|
|
7027
|
-
type: { const: action }
|
|
7459
|
+
type: { const: action },
|
|
7460
|
+
status: { const: ActionStatus.Accepted }
|
|
7028
7461
|
};
|
|
7029
|
-
const requiredFields = ["type"];
|
|
7462
|
+
const requiredFields = ["type", "status"];
|
|
7030
7463
|
if (additionalFields) {
|
|
7031
7464
|
Object.entries(additionalFields).forEach(([key, value]) => {
|
|
7032
7465
|
actionProperties[key] = { const: value };
|
|
@@ -7148,7 +7581,7 @@ var SerializableWithin = z37.object({
|
|
|
7148
7581
|
});
|
|
7149
7582
|
var SerializedQueryExpression = z37.object({
|
|
7150
7583
|
eventType: z37.string(),
|
|
7151
|
-
status: z37.optional(z37.union([AnyOfStatus, ExactStatus])),
|
|
7584
|
+
status: z37.optional(z37.union([AnyOfStatus, NoneOfStatus, ExactStatus])),
|
|
7152
7585
|
createdAt: z37.optional(DateCondition),
|
|
7153
7586
|
updatedAt: z37.optional(DateCondition),
|
|
7154
7587
|
"legalStatuses.DECLARED.createdAtLocation": z37.optional(SerializableWithin),
|
|
@@ -7157,6 +7590,7 @@ var SerializedQueryExpression = z37.object({
|
|
|
7157
7590
|
"legalStatuses.REGISTERED.createdAtLocation": z37.optional(SerializableWithin),
|
|
7158
7591
|
"legalStatuses.REGISTERED.createdByRole": z37.optional(AnyOf),
|
|
7159
7592
|
"legalStatuses.REGISTERED.registrationNumber": z37.optional(Exact),
|
|
7593
|
+
"legalStatuses.REVOKED.createdAtLocation": z37.optional(SerializableWithin),
|
|
7160
7594
|
createdAtLocation: z37.optional(
|
|
7161
7595
|
z37.union([SerializableWithin, SerializableExact])
|
|
7162
7596
|
),
|
|
@@ -7317,6 +7751,12 @@ var RegisterActionInput = BaseActionInput.extend(
|
|
|
7317
7751
|
var NotifyActionInput = BaseActionInput.extend(
|
|
7318
7752
|
z39.object({
|
|
7319
7753
|
type: z39.literal(ActionType.NOTIFY).default(ActionType.NOTIFY),
|
|
7754
|
+
declaration: BaseActionInput.shape.declaration.describe(
|
|
7755
|
+
"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."
|
|
7756
|
+
),
|
|
7757
|
+
annotation: BaseActionInput.shape.annotation.describe(
|
|
7758
|
+
"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."
|
|
7759
|
+
),
|
|
7320
7760
|
// For normal users, the createdAtLocation is resolved on the backend from the user's primaryOfficeId.
|
|
7321
7761
|
createdAtLocation: UUID.nullish().describe(
|
|
7322
7762
|
"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 +7829,16 @@ var UnarchiveActionInput = BaseActionInput.extend(
|
|
|
7389
7829
|
type: z39.literal(ActionType.UNARCHIVE).default(ActionType.UNARCHIVE)
|
|
7390
7830
|
}).shape
|
|
7391
7831
|
);
|
|
7832
|
+
var RevokeRegistrationActionInput = BaseActionInput.extend(
|
|
7833
|
+
z39.object({
|
|
7834
|
+
type: z39.literal(ActionType.REVOKE_REGISTRATION).default(ActionType.REVOKE_REGISTRATION)
|
|
7835
|
+
}).shape
|
|
7836
|
+
);
|
|
7837
|
+
var ReinstateRegistrationActionInput = BaseActionInput.extend(
|
|
7838
|
+
z39.object({
|
|
7839
|
+
type: z39.literal(ActionType.REINSTATE_REGISTRATION).default(ActionType.REINSTATE_REGISTRATION)
|
|
7840
|
+
}).shape
|
|
7841
|
+
);
|
|
7392
7842
|
var AssignActionInput = BaseActionInput.extend(
|
|
7393
7843
|
z39.object({
|
|
7394
7844
|
type: z39.literal(ActionType.ASSIGN),
|
|
@@ -7451,6 +7901,12 @@ var ActionInput = z39.discriminatedUnion("type", [
|
|
|
7451
7901
|
}),
|
|
7452
7902
|
ArchiveActionInput.meta({ id: "ArchiveActionInput" }),
|
|
7453
7903
|
UnarchiveActionInput.meta({ id: "UnarchiveActionInput" }),
|
|
7904
|
+
RevokeRegistrationActionInput.meta({
|
|
7905
|
+
id: "RevokeRegistrationActionInput"
|
|
7906
|
+
}),
|
|
7907
|
+
ReinstateRegistrationActionInput.meta({
|
|
7908
|
+
id: "ReinstateRegistrationActionInput"
|
|
7909
|
+
}),
|
|
7454
7910
|
AssignActionInput.meta({ id: "AssignActionInput" }),
|
|
7455
7911
|
UnassignActionInput.meta({ id: "UnassignActionInput" }),
|
|
7456
7912
|
PrintCertificateActionInput.meta({ id: "PrintCertificateActionInput" }),
|
|
@@ -7484,17 +7940,19 @@ var DraftInput = BaseActionInput.omit({ waitFor: true }).extend({
|
|
|
7484
7940
|
/*
|
|
7485
7941
|
* A draft can name a file that no action references. Such a file stays until
|
|
7486
7942
|
* the record is deleted or the record's next action sweeps its prefix.
|
|
7487
|
-
*
|
|
7488
|
-
*
|
|
7489
|
-
* which is about to be declared or registered.
|
|
7943
|
+
* Drafts are therefore saved only on a created record, which can still be deleted.
|
|
7944
|
+
* The server refuses them on any other record.
|
|
7490
7945
|
*/
|
|
7491
|
-
type: z40.
|
|
7946
|
+
type: z40.enum([ActionTypes.enum.DECLARE, ActionTypes.enum.NOTIFY]),
|
|
7492
7947
|
status: z40.enum([
|
|
7493
7948
|
ActionStatus.Requested,
|
|
7494
7949
|
ActionStatus.Accepted,
|
|
7495
7950
|
ActionStatus.Rejected
|
|
7496
7951
|
])
|
|
7497
7952
|
});
|
|
7953
|
+
var RemoteDraft = Draft.extend({
|
|
7954
|
+
action: Draft.shape.action.extend({ type: DraftInput.shape.type })
|
|
7955
|
+
});
|
|
7498
7956
|
|
|
7499
7957
|
// ../commons/src/events/EventInput.ts
|
|
7500
7958
|
var z41 = __toESM(require("zod/v4"));
|
|
@@ -7526,10 +7984,100 @@ var EventDocumentOnlyLastAction = EventDocument.extend({
|
|
|
7526
7984
|
}).brand("EventDocumentOnlyLastAction");
|
|
7527
7985
|
|
|
7528
7986
|
// ../commons/src/events/defineConfig.ts
|
|
7529
|
-
var
|
|
7530
|
-
|
|
7531
|
-
|
|
7532
|
-
|
|
7987
|
+
var z43 = __toESM(require("zod/v4"));
|
|
7988
|
+
function moveDeclarationToDeclareAction({
|
|
7989
|
+
declaration,
|
|
7990
|
+
...config
|
|
7991
|
+
}) {
|
|
7992
|
+
if (declaration) {
|
|
7993
|
+
console.warn(
|
|
7994
|
+
`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.`
|
|
7995
|
+
);
|
|
7996
|
+
}
|
|
7997
|
+
return {
|
|
7998
|
+
...config,
|
|
7999
|
+
actions: config.actions.map((action) => {
|
|
8000
|
+
if (action.type !== ActionType.DECLARE) {
|
|
8001
|
+
return action;
|
|
8002
|
+
}
|
|
8003
|
+
const declarationOfAction = action.declaration ?? declaration;
|
|
8004
|
+
if (!declarationOfAction) {
|
|
8005
|
+
throw new Error(`Event '${config.id}' does not define \`declaration\`.`);
|
|
8006
|
+
}
|
|
8007
|
+
return { ...action, declaration: declarationOfAction };
|
|
8008
|
+
})
|
|
8009
|
+
};
|
|
8010
|
+
}
|
|
8011
|
+
var VERSIONED_EVENT_FIELDS = [
|
|
8012
|
+
"id",
|
|
8013
|
+
"label",
|
|
8014
|
+
"advancedSearch",
|
|
8015
|
+
"versions"
|
|
8016
|
+
];
|
|
8017
|
+
function validateNoVersionFieldsAtTopLevel(config, ctx) {
|
|
8018
|
+
Object.keys(config).filter((key) => !VERSIONED_EVENT_FIELDS.includes(key)).forEach((key) => {
|
|
8019
|
+
ctx.addIssue({
|
|
8020
|
+
code: "custom",
|
|
8021
|
+
message: `Event '${config.id}' defines \`versions\`, so \`${key}\` must be defined on each version, not at the top level.`,
|
|
8022
|
+
path: [key]
|
|
8023
|
+
});
|
|
8024
|
+
});
|
|
8025
|
+
}
|
|
8026
|
+
function toVersionedInput(config) {
|
|
8027
|
+
if ("versions" in config) {
|
|
8028
|
+
return config;
|
|
8029
|
+
}
|
|
8030
|
+
const { id, label, advancedSearch, ...version } = moveDeclarationToDeclareAction(config);
|
|
8031
|
+
return {
|
|
8032
|
+
id,
|
|
8033
|
+
label,
|
|
8034
|
+
advancedSearch,
|
|
8035
|
+
versions: [{ ...version, id: DEFAULT_EVENT_CONFIG_VERSION_ID }]
|
|
8036
|
+
};
|
|
8037
|
+
}
|
|
8038
|
+
var EventConfigDefinition = z43.custom().superRefine((config, ctx) => {
|
|
8039
|
+
if ("versions" in config) {
|
|
8040
|
+
validateNoVersionFieldsAtTopLevel(config, ctx);
|
|
8041
|
+
return;
|
|
8042
|
+
}
|
|
8043
|
+
const eventCtx = { ...ctx, value: config };
|
|
8044
|
+
if (validateExactlyOneDeclareAction(config, eventCtx)) {
|
|
8045
|
+
validateDeclarationGivenExactlyOnce(config, eventCtx);
|
|
8046
|
+
}
|
|
8047
|
+
}).transform(toVersionedInput).pipe(VersionedEventConfig);
|
|
8048
|
+
var defineConfig = (config) => EventConfigDefinition.parse(config);
|
|
8049
|
+
|
|
8050
|
+
// ../commons/src/events/toNotificationForm.ts
|
|
8051
|
+
function toOptionalField(field3) {
|
|
8052
|
+
const { validation: _validation, ...rest } = field3;
|
|
8053
|
+
if (rest.type === FieldType.FIELD_GROUP && "fields" in rest) {
|
|
8054
|
+
return {
|
|
8055
|
+
...rest,
|
|
8056
|
+
required: false,
|
|
8057
|
+
fields: rest.fields.map(toOptionalField)
|
|
8058
|
+
};
|
|
8059
|
+
}
|
|
8060
|
+
return { ...rest, required: false };
|
|
8061
|
+
}
|
|
8062
|
+
function toNotificationForm(declaration) {
|
|
8063
|
+
return {
|
|
8064
|
+
...declaration,
|
|
8065
|
+
pages: declaration.pages.map((page) => ({
|
|
8066
|
+
...page,
|
|
8067
|
+
fields: page.fields.map(
|
|
8068
|
+
toOptionalField
|
|
8069
|
+
)
|
|
8070
|
+
}))
|
|
8071
|
+
};
|
|
8072
|
+
}
|
|
8073
|
+
function toNotificationReview(review) {
|
|
8074
|
+
return {
|
|
8075
|
+
...review,
|
|
8076
|
+
fields: review.fields.map(
|
|
8077
|
+
toOptionalField
|
|
8078
|
+
)
|
|
8079
|
+
};
|
|
8080
|
+
}
|
|
7533
8081
|
|
|
7534
8082
|
// ../commons/src/events/transactions.ts
|
|
7535
8083
|
function generateTransactionId() {
|
|
@@ -8787,7 +9335,7 @@ var TENNIS_CLUB_DECLARATION_FORM = defineDeclarationForm({
|
|
|
8787
9335
|
});
|
|
8788
9336
|
|
|
8789
9337
|
// ../commons/src/fixtures/tennis-club-membership-event.ts
|
|
8790
|
-
var
|
|
9338
|
+
var versionedTennisClubMembershipEvent = defineConfig({
|
|
8791
9339
|
id: TENNIS_CLUB_MEMBERSHIP,
|
|
8792
9340
|
declaration: TENNIS_CLUB_DECLARATION_FORM,
|
|
8793
9341
|
label: {
|
|
@@ -8846,6 +9394,8 @@ var tennisClubMembershipEvent = defineConfig({
|
|
|
8846
9394
|
description: "This is shown as the action name anywhere the user can trigger the action from",
|
|
8847
9395
|
id: "event.tennis-club-membership.action.notify.label"
|
|
8848
9396
|
},
|
|
9397
|
+
notificationForm: toNotificationForm(TENNIS_CLUB_DECLARATION_FORM),
|
|
9398
|
+
review: toNotificationReview(TENNIS_CLUB_DECLARATION_REVIEW),
|
|
8849
9399
|
flags: [
|
|
8850
9400
|
{
|
|
8851
9401
|
id: "health-worker-notified",
|
|
@@ -9142,9 +9692,12 @@ var tennisClubMembershipEvent = defineConfig({
|
|
|
9142
9692
|
}
|
|
9143
9693
|
]
|
|
9144
9694
|
});
|
|
9695
|
+
var tennisClubMembershipEvent = resolveEventConfig(
|
|
9696
|
+
versionedTennisClubMembershipEvent
|
|
9697
|
+
);
|
|
9145
9698
|
|
|
9146
9699
|
// ../commons/src/fixtures/football-club-membership-event.ts
|
|
9147
|
-
var
|
|
9700
|
+
var versionedFootballClubMembershipEvent = defineConfig({
|
|
9148
9701
|
id: "FOOTBALL_CLUB_MEMBERSHIP",
|
|
9149
9702
|
label: {
|
|
9150
9703
|
defaultMessage: "Football club membership application",
|
|
@@ -9467,6 +10020,9 @@ var footballClubMembershipEvent = defineConfig({
|
|
|
9467
10020
|
],
|
|
9468
10021
|
declaration: TENNIS_CLUB_DECLARATION_FORM
|
|
9469
10022
|
});
|
|
10023
|
+
var footballClubMembershipEvent = resolveEventConfig(
|
|
10024
|
+
versionedFootballClubMembershipEvent
|
|
10025
|
+
);
|
|
9470
10026
|
|
|
9471
10027
|
// ../commons/src/fixtures/library-membership-event.ts
|
|
9472
10028
|
var libraryMembershipForm = defineDeclarationForm({
|
|
@@ -9510,7 +10066,7 @@ var libraryMembershipForm = defineDeclarationForm({
|
|
|
9510
10066
|
}
|
|
9511
10067
|
]
|
|
9512
10068
|
});
|
|
9513
|
-
var
|
|
10069
|
+
var versionedLibraryMembershipEvent = defineConfig({
|
|
9514
10070
|
id: "library-membership",
|
|
9515
10071
|
label: {
|
|
9516
10072
|
defaultMessage: "Library membership application",
|
|
@@ -9523,9 +10079,29 @@ var libraryMembershipEvent = defineConfig({
|
|
|
9523
10079
|
id: "event.library-membership.title"
|
|
9524
10080
|
},
|
|
9525
10081
|
summary: { fields: [] },
|
|
9526
|
-
actions: [
|
|
10082
|
+
actions: [
|
|
10083
|
+
{
|
|
10084
|
+
type: ActionType.DECLARE,
|
|
10085
|
+
label: {
|
|
10086
|
+
defaultMessage: "Declare",
|
|
10087
|
+
description: "This is shown as the action name anywhere the user can trigger the action from",
|
|
10088
|
+
id: "event.library-membership.action.declare.label"
|
|
10089
|
+
},
|
|
10090
|
+
review: {
|
|
10091
|
+
title: {
|
|
10092
|
+
defaultMessage: "Library membership application",
|
|
10093
|
+
description: "Title of the review page",
|
|
10094
|
+
id: "event.library-membership.action.declare.form.review.title"
|
|
10095
|
+
},
|
|
10096
|
+
fields: []
|
|
10097
|
+
}
|
|
10098
|
+
}
|
|
10099
|
+
],
|
|
9527
10100
|
declaration: libraryMembershipForm
|
|
9528
10101
|
});
|
|
10102
|
+
var libraryMembershipEvent = resolveEventConfig(
|
|
10103
|
+
versionedLibraryMembershipEvent
|
|
10104
|
+
);
|
|
9529
10105
|
|
|
9530
10106
|
// ../commons/src/fixtures/child-onboarding-event.ts
|
|
9531
10107
|
function generateTranslationConfig(message) {
|
|
@@ -9739,7 +10315,7 @@ var CHILD_ONBOARDING_DECLARATION_FORM = defineDeclarationForm({
|
|
|
9739
10315
|
label: generateTranslationConfig("Birth decalration form"),
|
|
9740
10316
|
pages: [child, mother]
|
|
9741
10317
|
});
|
|
9742
|
-
var
|
|
10318
|
+
var versionedChildOnboardingEvent = defineConfig({
|
|
9743
10319
|
id: CHILD_ONBOARDING_EVENT,
|
|
9744
10320
|
title: generateTranslationConfig(
|
|
9745
10321
|
"{child.name.firstname} {child.name.surname}"
|
|
@@ -9767,6 +10343,9 @@ var ChildOnboardingEvent = defineConfig({
|
|
|
9767
10343
|
],
|
|
9768
10344
|
advancedSearch: []
|
|
9769
10345
|
});
|
|
10346
|
+
var ChildOnboardingEvent = resolveEventConfig(
|
|
10347
|
+
versionedChildOnboardingEvent
|
|
10348
|
+
);
|
|
9770
10349
|
|
|
9771
10350
|
// ../commons/src/fixtures/digital-identity-issuance-event.ts
|
|
9772
10351
|
var PRINT_DIGITAL_ID_CERTIFICATE_FORM = defineActionForm({
|
|
@@ -9955,7 +10534,7 @@ var digitalIdentityForm = defineDeclarationForm({
|
|
|
9955
10534
|
}
|
|
9956
10535
|
]
|
|
9957
10536
|
});
|
|
9958
|
-
var
|
|
10537
|
+
var versionedDigitalIdentityEvent = defineConfig({
|
|
9959
10538
|
id: "digital-identity",
|
|
9960
10539
|
label: {
|
|
9961
10540
|
defaultMessage: "Digital identity issuance",
|
|
@@ -9969,6 +10548,22 @@ var digitalIdentityEvent = defineConfig({
|
|
|
9969
10548
|
},
|
|
9970
10549
|
summary: { fields: [] },
|
|
9971
10550
|
actions: [
|
|
10551
|
+
{
|
|
10552
|
+
type: ActionType.DECLARE,
|
|
10553
|
+
label: {
|
|
10554
|
+
defaultMessage: "Declare",
|
|
10555
|
+
description: "This is shown as the action name anywhere the user can trigger the action from",
|
|
10556
|
+
id: "event.digital-identity.action.declare.label"
|
|
10557
|
+
},
|
|
10558
|
+
review: {
|
|
10559
|
+
title: {
|
|
10560
|
+
defaultMessage: "Digital identity issuance",
|
|
10561
|
+
description: "Title of the review page",
|
|
10562
|
+
id: "event.digital-identity.action.declare.form.review.title"
|
|
10563
|
+
},
|
|
10564
|
+
fields: []
|
|
10565
|
+
}
|
|
10566
|
+
},
|
|
9972
10567
|
{
|
|
9973
10568
|
type: ActionType.PRINT_CERTIFICATE,
|
|
9974
10569
|
label: {
|
|
@@ -9981,47 +10576,50 @@ var digitalIdentityEvent = defineConfig({
|
|
|
9981
10576
|
],
|
|
9982
10577
|
declaration: digitalIdentityForm
|
|
9983
10578
|
});
|
|
10579
|
+
var digitalIdentityEvent = resolveEventConfig(
|
|
10580
|
+
versionedDigitalIdentityEvent
|
|
10581
|
+
);
|
|
9984
10582
|
|
|
9985
10583
|
// ../commons/src/events/test.utils.ts
|
|
9986
|
-
var
|
|
10584
|
+
var z45 = __toESM(require("zod/v4"));
|
|
9987
10585
|
|
|
9988
10586
|
// ../commons/src/events/locations.ts
|
|
9989
|
-
var
|
|
9990
|
-
var LocationTypeV1 =
|
|
10587
|
+
var z44 = __toESM(require("zod/v4"));
|
|
10588
|
+
var LocationTypeV1 = z44.enum([
|
|
9991
10589
|
"ADMIN_STRUCTURE",
|
|
9992
10590
|
"CRVS_OFFICE",
|
|
9993
10591
|
"HEALTH_FACILITY"
|
|
9994
10592
|
]);
|
|
9995
|
-
var LocationStatus =
|
|
10593
|
+
var LocationStatus = z44.enum(["active", "inactive"]);
|
|
9996
10594
|
var InactiveOfficeError = class extends Error {
|
|
9997
10595
|
constructor(message = "Assigned office is inactive") {
|
|
9998
10596
|
super(message);
|
|
9999
10597
|
this.name = "InactiveOfficeError";
|
|
10000
10598
|
}
|
|
10001
10599
|
};
|
|
10002
|
-
var LocationVersion =
|
|
10600
|
+
var LocationVersion = z44.object({
|
|
10003
10601
|
versionId: UUID,
|
|
10004
|
-
effectiveFrom:
|
|
10005
|
-
name:
|
|
10006
|
-
externalId:
|
|
10602
|
+
effectiveFrom: z44.iso.date(),
|
|
10603
|
+
name: z44.string(),
|
|
10604
|
+
externalId: z44.string().nullish(),
|
|
10007
10605
|
status: LocationStatus
|
|
10008
10606
|
});
|
|
10009
|
-
var AdministrativeArea =
|
|
10607
|
+
var AdministrativeArea = z44.object({
|
|
10010
10608
|
id: UUID,
|
|
10011
|
-
name:
|
|
10012
|
-
externalId:
|
|
10609
|
+
name: z44.string(),
|
|
10610
|
+
externalId: z44.string().nullish(),
|
|
10013
10611
|
parentId: UUID.nullable(),
|
|
10014
10612
|
status: LocationStatus,
|
|
10015
|
-
versions:
|
|
10613
|
+
versions: z44.array(LocationVersion)
|
|
10016
10614
|
});
|
|
10017
|
-
var Location =
|
|
10615
|
+
var Location = z44.object({
|
|
10018
10616
|
id: UUID,
|
|
10019
|
-
name:
|
|
10020
|
-
externalId:
|
|
10617
|
+
name: z44.string(),
|
|
10618
|
+
externalId: z44.string().nullish(),
|
|
10021
10619
|
administrativeAreaId: UUID.nullable(),
|
|
10022
|
-
locationType:
|
|
10620
|
+
locationType: z44.string().nullable(),
|
|
10023
10621
|
status: LocationStatus,
|
|
10024
|
-
versions:
|
|
10622
|
+
versions: z44.array(LocationVersion)
|
|
10025
10623
|
});
|
|
10026
10624
|
var ClientAdministrativeArea = AdministrativeArea.omit({
|
|
10027
10625
|
name: true,
|
|
@@ -10062,22 +10660,22 @@ function validateUniqueIds(versions, ctx) {
|
|
|
10062
10660
|
ctx.addIssue("versions must not repeat a versionId");
|
|
10063
10661
|
}
|
|
10064
10662
|
}
|
|
10065
|
-
var SeededLocationVersions =
|
|
10663
|
+
var SeededLocationVersions = z44.array(LocationVersion).min(1).superRefine((versions, ctx) => {
|
|
10066
10664
|
validateAscendingDates(versions, ctx);
|
|
10067
10665
|
validateUniqueIds(versions, ctx);
|
|
10068
10666
|
});
|
|
10069
|
-
var SetLocationPayload =
|
|
10667
|
+
var SetLocationPayload = z44.object({
|
|
10070
10668
|
id: UUID,
|
|
10071
|
-
name:
|
|
10072
|
-
externalId:
|
|
10669
|
+
name: z44.string(),
|
|
10670
|
+
externalId: z44.string().nullish(),
|
|
10073
10671
|
administrativeAreaId: UUID.nullable(),
|
|
10074
|
-
locationType:
|
|
10672
|
+
locationType: z44.string().nullable(),
|
|
10075
10673
|
versions: SeededLocationVersions.optional()
|
|
10076
10674
|
});
|
|
10077
|
-
var SetAdministrativeAreaPayload =
|
|
10675
|
+
var SetAdministrativeAreaPayload = z44.object({
|
|
10078
10676
|
id: UUID,
|
|
10079
|
-
name:
|
|
10080
|
-
externalId:
|
|
10677
|
+
name: z44.string(),
|
|
10678
|
+
externalId: z44.string().nullish(),
|
|
10081
10679
|
parentId: UUID.nullable(),
|
|
10082
10680
|
versions: SeededLocationVersions.optional()
|
|
10083
10681
|
});
|
|
@@ -10280,8 +10878,8 @@ function userCanAccessEventWithScopes(event2, scopes, user2, customActionType) {
|
|
|
10280
10878
|
}
|
|
10281
10879
|
function getAdministrativeAreaHierarchy(administrativeAreaId, administrativeAreas) {
|
|
10282
10880
|
const collectedLocations = [];
|
|
10283
|
-
const
|
|
10284
|
-
let current =
|
|
10881
|
+
const maybeAdministrativeAreaId = maybeUuid(administrativeAreaId);
|
|
10882
|
+
let current = maybeAdministrativeAreaId ? administrativeAreas.get(maybeAdministrativeAreaId) : null;
|
|
10285
10883
|
while (current) {
|
|
10286
10884
|
collectedLocations.push(current);
|
|
10287
10885
|
if (!current.parentId) {
|
|
@@ -10666,7 +11264,7 @@ var V2_DEFAULT_MOCK_CLIENT_ADMINISTRATIVE_AREAS_MAP = new Map(
|
|
|
10666
11264
|
|
|
10667
11265
|
// ../commons/src/events/test.utils.ts
|
|
10668
11266
|
var TEST_SYSTEM_IANA_TIMEZONE = "Asia/Dhaka";
|
|
10669
|
-
var TestUserRole =
|
|
11267
|
+
var TestUserRole = z45.enum([
|
|
10670
11268
|
"FIELD_AGENT",
|
|
10671
11269
|
"LOCAL_REGISTRAR",
|
|
10672
11270
|
"LOCAL_SYSTEM_ADMIN",
|
|
@@ -10881,11 +11479,10 @@ function fieldConfigsToActionPayload(fields, rng, administrativeHierarchy) {
|
|
|
10881
11479
|
);
|
|
10882
11480
|
}
|
|
10883
11481
|
function generateActionDeclarationInput(configuration, action, rng, overrides, administrativeHierarchy) {
|
|
10884
|
-
const parsed = DeclarationUpdateActions.safeParse(action);
|
|
10885
11482
|
if ((0, import_lodash5.isEmpty)(overrides) && typeof overrides === "object") {
|
|
10886
11483
|
return {};
|
|
10887
11484
|
}
|
|
10888
|
-
if (
|
|
11485
|
+
if (DeclarationUpdateActions.validate(action)) {
|
|
10889
11486
|
const fields = getDeclarationFields(configuration);
|
|
10890
11487
|
const declarationConfig = getDeclaration(configuration);
|
|
10891
11488
|
const declaration = fieldConfigsToActionPayload(
|
|
@@ -11076,6 +11673,22 @@ function eventPayloadGenerator(rng, configuration = tennisClubMembershipEvent) {
|
|
|
11076
11673
|
eventId,
|
|
11077
11674
|
...input
|
|
11078
11675
|
}),
|
|
11676
|
+
revokeRegistration: (eventId, input = {}) => ({
|
|
11677
|
+
type: ActionType.REVOKE_REGISTRATION,
|
|
11678
|
+
transactionId: input.transactionId ?? getUUID(),
|
|
11679
|
+
declaration: {},
|
|
11680
|
+
annotation: {},
|
|
11681
|
+
eventId,
|
|
11682
|
+
...input
|
|
11683
|
+
}),
|
|
11684
|
+
reinstateRegistration: (eventId, input = {}) => ({
|
|
11685
|
+
type: ActionType.REINSTATE_REGISTRATION,
|
|
11686
|
+
transactionId: input.transactionId ?? getUUID(),
|
|
11687
|
+
declaration: {},
|
|
11688
|
+
annotation: {},
|
|
11689
|
+
eventId,
|
|
11690
|
+
...input
|
|
11691
|
+
}),
|
|
11079
11692
|
reject: (eventId, input = {}) => ({
|
|
11080
11693
|
type: ActionType.REJECT,
|
|
11081
11694
|
transactionId: input.transactionId ?? getUUID(),
|
|
@@ -11244,12 +11857,14 @@ function generateActionDocument({
|
|
|
11244
11857
|
case ActionType.REGISTER:
|
|
11245
11858
|
case ActionType.REQUEST_CORRECTION:
|
|
11246
11859
|
case ActionType.UNARCHIVE:
|
|
11860
|
+
case ActionType.REVOKE_REGISTRATION:
|
|
11861
|
+
case ActionType.REINSTATE_REGISTRATION:
|
|
11247
11862
|
return { ...actionBase, type: action };
|
|
11248
11863
|
case ActionType.EDIT:
|
|
11249
11864
|
return {
|
|
11865
|
+
content: { comment: "Test comment" },
|
|
11250
11866
|
...actionBase,
|
|
11251
|
-
type: action
|
|
11252
|
-
content: { comment: "Test comment" }
|
|
11867
|
+
type: action
|
|
11253
11868
|
};
|
|
11254
11869
|
case ActionType.CUSTOM:
|
|
11255
11870
|
return {
|
|
@@ -11268,9 +11883,9 @@ function generateActionDocument({
|
|
|
11268
11883
|
};
|
|
11269
11884
|
}
|
|
11270
11885
|
case ActionType.ARCHIVE:
|
|
11271
|
-
return {
|
|
11886
|
+
return { content: { reason: "Archive" }, ...actionBase, type: action };
|
|
11272
11887
|
case ActionType.REJECT:
|
|
11273
|
-
return {
|
|
11888
|
+
return { content: { reason: "Reject" }, ...actionBase, type: action };
|
|
11274
11889
|
case ActionType.PRINT_CERTIFICATE: {
|
|
11275
11890
|
const printActionDefaults = defaults;
|
|
11276
11891
|
return {
|
|
@@ -11280,13 +11895,13 @@ function generateActionDocument({
|
|
|
11280
11895
|
};
|
|
11281
11896
|
}
|
|
11282
11897
|
case ActionType.APPROVE_CORRECTION:
|
|
11283
|
-
return {
|
|
11898
|
+
return { requestId: getUUID(), ...actionBase, type: action };
|
|
11284
11899
|
case ActionType.REJECT_CORRECTION:
|
|
11285
11900
|
return {
|
|
11286
|
-
...actionBase,
|
|
11287
11901
|
requestId: getUUID(),
|
|
11288
|
-
|
|
11289
|
-
|
|
11902
|
+
content: { reason: "Correction rejection" },
|
|
11903
|
+
...actionBase,
|
|
11904
|
+
type: action
|
|
11290
11905
|
};
|
|
11291
11906
|
case ActionType.DUPLICATE_DETECTED: {
|
|
11292
11907
|
const duplicateActionDefaults = defaults;
|
|
@@ -11303,6 +11918,65 @@ function generateActionDocument({
|
|
|
11303
11918
|
throw new Error(`Unsupported action type: ${action}`);
|
|
11304
11919
|
}
|
|
11305
11920
|
}
|
|
11921
|
+
function isConfirmableAction(type) {
|
|
11922
|
+
return ConfirmableActions.some((confirmable) => confirmable === type);
|
|
11923
|
+
}
|
|
11924
|
+
function generateActionDocuments({
|
|
11925
|
+
confirmation,
|
|
11926
|
+
...args
|
|
11927
|
+
}) {
|
|
11928
|
+
const actionDocument = generateActionDocument(args);
|
|
11929
|
+
if (!isConfirmableAction(actionDocument.type)) {
|
|
11930
|
+
return [actionDocument];
|
|
11931
|
+
}
|
|
11932
|
+
if (args.defaults?.status !== void 0) {
|
|
11933
|
+
throw new Error(
|
|
11934
|
+
`generateActionDocuments: set the status of ${actionDocument.type} with confirmation.status, not defaults.status`
|
|
11935
|
+
);
|
|
11936
|
+
}
|
|
11937
|
+
const status2 = confirmation?.status ?? ActionStatus.Accepted;
|
|
11938
|
+
if (status2 === ActionStatus.Requested) {
|
|
11939
|
+
if (confirmation?.defaults) {
|
|
11940
|
+
throw new Error(
|
|
11941
|
+
"generateActionDocuments: confirmation.defaults have no confirming action to apply to while the request is pending"
|
|
11942
|
+
);
|
|
11943
|
+
}
|
|
11944
|
+
return [{ ...actionDocument, status: ActionStatus.Requested }];
|
|
11945
|
+
}
|
|
11946
|
+
const requestedAction = {
|
|
11947
|
+
...actionDocument,
|
|
11948
|
+
id: getUUID(),
|
|
11949
|
+
status: ActionStatus.Requested
|
|
11950
|
+
};
|
|
11951
|
+
const confirmingAction = {
|
|
11952
|
+
...actionDocument,
|
|
11953
|
+
originalActionId: requestedAction.id,
|
|
11954
|
+
createdAt: new Date(
|
|
11955
|
+
new Date(actionDocument.createdAt).getTime() + 1
|
|
11956
|
+
).toISOString(),
|
|
11957
|
+
...confirmation?.defaults
|
|
11958
|
+
};
|
|
11959
|
+
if (status2 === ActionStatus.Rejected) {
|
|
11960
|
+
const { declaration, annotation, ...rejectedAction } = confirmingAction;
|
|
11961
|
+
return [
|
|
11962
|
+
requestedAction,
|
|
11963
|
+
{
|
|
11964
|
+
...rejectedAction,
|
|
11965
|
+
type: actionDocument.type,
|
|
11966
|
+
status: ActionStatus.Rejected
|
|
11967
|
+
}
|
|
11968
|
+
];
|
|
11969
|
+
}
|
|
11970
|
+
return [
|
|
11971
|
+
requestedAction,
|
|
11972
|
+
{
|
|
11973
|
+
...confirmingAction,
|
|
11974
|
+
status: ActionStatus.Accepted,
|
|
11975
|
+
declaration: {},
|
|
11976
|
+
annotation: {}
|
|
11977
|
+
}
|
|
11978
|
+
];
|
|
11979
|
+
}
|
|
11306
11980
|
function generateRandomDatetime(rng, start, end) {
|
|
11307
11981
|
const range = end.getTime() - start.getTime();
|
|
11308
11982
|
const offset = Math.floor(rng() * range);
|
|
@@ -11322,8 +11996,18 @@ function generateEventDocument({
|
|
|
11322
11996
|
return {
|
|
11323
11997
|
trackingId: generateTrackingId(rng),
|
|
11324
11998
|
type: configuration.id,
|
|
11325
|
-
actions: actions.
|
|
11326
|
-
(
|
|
11999
|
+
actions: actions.flatMap((action, i) => {
|
|
12000
|
+
const createdAt = (0, import_date_fns4.addDays)(
|
|
12001
|
+
new Date(
|
|
12002
|
+
generateRandomDatetime(
|
|
12003
|
+
rng,
|
|
12004
|
+
new Date(2025, 0, 1),
|
|
12005
|
+
new Date(2025, 11, 31)
|
|
12006
|
+
)
|
|
12007
|
+
),
|
|
12008
|
+
i
|
|
12009
|
+
);
|
|
12010
|
+
return generateActionDocuments({
|
|
11327
12011
|
configuration,
|
|
11328
12012
|
action: action.type,
|
|
11329
12013
|
defaults: {
|
|
@@ -11331,20 +12015,11 @@ function generateEventDocument({
|
|
|
11331
12015
|
createdAtLocation: action.user?.primaryOfficeId,
|
|
11332
12016
|
assignedTo: action.user?.assignedTo,
|
|
11333
12017
|
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()
|
|
12018
|
+
createdAt: createdAt.toISOString()
|
|
11344
12019
|
},
|
|
11345
12020
|
declarationOverrides: action.declarationOverrides
|
|
11346
|
-
})
|
|
11347
|
-
),
|
|
12021
|
+
});
|
|
12022
|
+
}),
|
|
11348
12023
|
// Offset is needed so the createdAt timestamps for events, actions and drafts make logical sense in storybook tests.
|
|
11349
12024
|
// @TODO: This should be fixed in the future.
|
|
11350
12025
|
createdAt: new Date(Date.now() - 1e3).toISOString(),
|
|
@@ -11371,6 +12046,7 @@ function generateEventDraftDocument({
|
|
|
11371
12046
|
transactionId: getUUID(),
|
|
11372
12047
|
action: {
|
|
11373
12048
|
...action,
|
|
12049
|
+
type: actionType,
|
|
11374
12050
|
declaration: {
|
|
11375
12051
|
...action.declaration,
|
|
11376
12052
|
...declaration
|
|
@@ -11458,46 +12134,62 @@ var generateEventConfig = ({
|
|
|
11458
12134
|
dateOfEventId,
|
|
11459
12135
|
actions = []
|
|
11460
12136
|
}) => {
|
|
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
|
-
}
|
|
12137
|
+
return resolveEventConfig(
|
|
12138
|
+
defineConfig({
|
|
12139
|
+
id,
|
|
12140
|
+
label: generateTranslationConfig2(id),
|
|
12141
|
+
title: generateTranslationConfig2(`${id} Event`),
|
|
12142
|
+
summary: {
|
|
12143
|
+
fields: []
|
|
11488
12144
|
},
|
|
11489
|
-
{
|
|
11490
|
-
|
|
11491
|
-
|
|
11492
|
-
|
|
11493
|
-
|
|
11494
|
-
|
|
11495
|
-
|
|
12145
|
+
placeOfEvent: placeOfEventId ? { $$field: placeOfEventId } : void 0,
|
|
12146
|
+
dateOfEvent: dateOfEventId ? { $$field: dateOfEventId } : void 0,
|
|
12147
|
+
declaration: {
|
|
12148
|
+
label: generateTranslationConfig2(`${id} Declaration`),
|
|
12149
|
+
pages: [
|
|
12150
|
+
{
|
|
12151
|
+
id: "page1",
|
|
12152
|
+
title: generateTranslationConfig2("Page 1"),
|
|
12153
|
+
fields
|
|
12154
|
+
}
|
|
12155
|
+
]
|
|
11496
12156
|
},
|
|
11497
|
-
|
|
11498
|
-
|
|
11499
|
-
|
|
12157
|
+
actions: [
|
|
12158
|
+
{
|
|
12159
|
+
type: ActionType.READ,
|
|
12160
|
+
label: generateTranslationConfig2("Read"),
|
|
12161
|
+
review: {
|
|
12162
|
+
title: generateTranslationConfig2("Review Read Action"),
|
|
12163
|
+
fields: []
|
|
12164
|
+
}
|
|
12165
|
+
},
|
|
12166
|
+
{
|
|
12167
|
+
type: ActionType.DECLARE,
|
|
12168
|
+
label: generateTranslationConfig2("Declare"),
|
|
12169
|
+
review: {
|
|
12170
|
+
title: generateTranslationConfig2("Review Declare Action"),
|
|
12171
|
+
fields: []
|
|
12172
|
+
}
|
|
12173
|
+
},
|
|
12174
|
+
...actions
|
|
12175
|
+
]
|
|
12176
|
+
})
|
|
12177
|
+
);
|
|
11500
12178
|
};
|
|
12179
|
+
function withDeclaration(configuration, declaration) {
|
|
12180
|
+
return {
|
|
12181
|
+
...configuration,
|
|
12182
|
+
actions: configuration.actions.map((action) => {
|
|
12183
|
+
if (action.type === ActionType.DECLARE) {
|
|
12184
|
+
return { ...action, declaration };
|
|
12185
|
+
}
|
|
12186
|
+
if (action.type === ActionType.NOTIFY) {
|
|
12187
|
+
return { ...action, notificationForm: toNotificationForm(declaration) };
|
|
12188
|
+
}
|
|
12189
|
+
return action;
|
|
12190
|
+
})
|
|
12191
|
+
};
|
|
12192
|
+
}
|
|
11501
12193
|
function getLeafAdministrativeAreaIds(administrativeAreas) {
|
|
11502
12194
|
const nonLeafAdministrativeAreaIds = /* @__PURE__ */ new Set();
|
|
11503
12195
|
for (const [, location] of administrativeAreas) {
|
|
@@ -11546,6 +12238,25 @@ function generateTestValidatorContext(userRole2, eventWithConfig) {
|
|
|
11546
12238
|
event: getEventValidatorContext(event2, eventConfig)
|
|
11547
12239
|
};
|
|
11548
12240
|
}
|
|
12241
|
+
function toVersionedEventConfig({
|
|
12242
|
+
id,
|
|
12243
|
+
label,
|
|
12244
|
+
advancedSearch,
|
|
12245
|
+
...version
|
|
12246
|
+
}) {
|
|
12247
|
+
return {
|
|
12248
|
+
id,
|
|
12249
|
+
label,
|
|
12250
|
+
advancedSearch,
|
|
12251
|
+
versions: [
|
|
12252
|
+
{
|
|
12253
|
+
...version,
|
|
12254
|
+
id: DEFAULT_EVENT_CONFIG_VERSION_ID,
|
|
12255
|
+
effectiveFrom: DEFAULT_EFFECTIVE_FROM
|
|
12256
|
+
}
|
|
12257
|
+
]
|
|
12258
|
+
};
|
|
12259
|
+
}
|
|
11549
12260
|
|
|
11550
12261
|
// ../commons/src/events/TemplateConfig.ts
|
|
11551
12262
|
var window2 = () => ({
|
|
@@ -11559,7 +12270,7 @@ function isTemplateVariable(value) {
|
|
|
11559
12270
|
return typeof value === "string" && value.startsWith("$");
|
|
11560
12271
|
}
|
|
11561
12272
|
function isFieldValue(value) {
|
|
11562
|
-
return FieldValue.
|
|
12273
|
+
return FieldValue.validate(value);
|
|
11563
12274
|
}
|
|
11564
12275
|
function isFieldValueWithoutTemplates(value) {
|
|
11565
12276
|
if (isTemplateVariable(value)) {
|
|
@@ -11602,8 +12313,12 @@ var ACTION_SCOPE_MAP = {
|
|
|
11602
12313
|
"record.correct"
|
|
11603
12314
|
],
|
|
11604
12315
|
[ClientSpecificAction.REVIEW_CORRECTION_REQUEST]: ["record.correct"],
|
|
12316
|
+
// Not granted by a scope: the client checks the draft's own action instead
|
|
12317
|
+
[ClientSpecificAction.CONTINUE_DRAFT]: [],
|
|
11605
12318
|
[ActionType.REJECT_CORRECTION]: ["record.correct"],
|
|
11606
12319
|
[ActionType.APPROVE_CORRECTION]: ["record.correct"],
|
|
12320
|
+
[ActionType.REVOKE_REGISTRATION]: ["record.revoke-registration"],
|
|
12321
|
+
[ActionType.REINSTATE_REGISTRATION]: ["record.reinstate-registration"],
|
|
11607
12322
|
[ActionType.MARK_AS_DUPLICATE]: ["record.review-duplicates"],
|
|
11608
12323
|
[ActionType.MARK_AS_NOT_DUPLICATE]: ["record.review-duplicates"],
|
|
11609
12324
|
[ActionType.ARCHIVE]: ["record.archive"],
|
|
@@ -11626,6 +12341,8 @@ var DOCUMENT_DELETE_SCOPES = [
|
|
|
11626
12341
|
"record.print-certified-copies",
|
|
11627
12342
|
"record.request-correction",
|
|
11628
12343
|
"record.correct",
|
|
12344
|
+
"record.revoke-registration",
|
|
12345
|
+
"record.reinstate-registration",
|
|
11629
12346
|
"record.review-duplicates",
|
|
11630
12347
|
"record.archive",
|
|
11631
12348
|
"record.unarchive",
|
|
@@ -11765,6 +12482,10 @@ function deserializeQueryExpression(expression, user2) {
|
|
|
11765
12482
|
expression["legalStatuses.REGISTERED.createdAtLocation"].location,
|
|
11766
12483
|
user2
|
|
11767
12484
|
) : void 0;
|
|
12485
|
+
const revokedLocation = expression["legalStatuses.REVOKED.createdAtLocation"] ? userDeserializer(
|
|
12486
|
+
expression["legalStatuses.REVOKED.createdAtLocation"].location,
|
|
12487
|
+
user2
|
|
12488
|
+
) : void 0;
|
|
11768
12489
|
return {
|
|
11769
12490
|
...expression,
|
|
11770
12491
|
assignedTo: expression.assignedTo && isDefined(assignedTo) ? { ...expression.assignedTo, term: assignedTo } : void 0,
|
|
@@ -11783,6 +12504,10 @@ function deserializeQueryExpression(expression, user2) {
|
|
|
11783
12504
|
["legalStatuses.REGISTERED.createdAtLocation"]: expression["legalStatuses.REGISTERED.createdAtLocation"] && isDefined(registeredLocation) ? {
|
|
11784
12505
|
...expression["legalStatuses.REGISTERED.createdAtLocation"],
|
|
11785
12506
|
location: registeredLocation
|
|
12507
|
+
} : void 0,
|
|
12508
|
+
["legalStatuses.REVOKED.createdAtLocation"]: expression["legalStatuses.REVOKED.createdAtLocation"] && isDefined(revokedLocation) ? {
|
|
12509
|
+
...expression["legalStatuses.REVOKED.createdAtLocation"],
|
|
12510
|
+
location: revokedLocation
|
|
11786
12511
|
} : void 0
|
|
11787
12512
|
};
|
|
11788
12513
|
}
|
|
@@ -11829,7 +12554,12 @@ var AVAILABLE_ACTIONS_BY_EVENT_STATUS = {
|
|
|
11829
12554
|
ActionType.APPROVE_CORRECTION,
|
|
11830
12555
|
ActionType.REJECT_CORRECTION,
|
|
11831
12556
|
ActionType.CUSTOM,
|
|
11832
|
-
ClientSpecificAction.REVIEW_CORRECTION_REQUEST
|
|
12557
|
+
ClientSpecificAction.REVIEW_CORRECTION_REQUEST,
|
|
12558
|
+
ActionType.REVOKE_REGISTRATION
|
|
12559
|
+
],
|
|
12560
|
+
[EventStatus.enum.REVOKED]: [
|
|
12561
|
+
ActionType.READ,
|
|
12562
|
+
ActionType.REINSTATE_REGISTRATION
|
|
11833
12563
|
],
|
|
11834
12564
|
[EventStatus.enum.ARCHIVED]: [
|
|
11835
12565
|
ActionType.READ,
|
|
@@ -11843,6 +12573,8 @@ var ACTION_FILTERS = {
|
|
|
11843
12573
|
[ClientSpecificAction.REVIEW_CORRECTION_REQUEST]: (flags) => flags.includes(InherentFlags.CORRECTION_REQUESTED) && !flags.some((flag2) => flag2.endsWith(":requested")),
|
|
11844
12574
|
[ActionType.APPROVE_CORRECTION]: (flags) => flags.includes(InherentFlags.CORRECTION_REQUESTED) && !flags.some((flag2) => flag2.endsWith(":requested")),
|
|
11845
12575
|
[ActionType.REJECT_CORRECTION]: (flags) => flags.includes(InherentFlags.CORRECTION_REQUESTED) && !flags.some((flag2) => flag2.endsWith(":requested")),
|
|
12576
|
+
[ActionType.REVOKE_REGISTRATION]: (flags) => !flags.includes(InherentFlags.CORRECTION_REQUESTED) && !flags.some((flag2) => flag2.endsWith(":requested")),
|
|
12577
|
+
[ActionType.REINSTATE_REGISTRATION]: (flags) => !flags.some((flag2) => flag2.endsWith(":requested")),
|
|
11846
12578
|
[ActionType.MARK_AS_DUPLICATE]: (flags) => flags.includes(InherentFlags.POTENTIAL_DUPLICATE) && !flags.some((flag2) => flag2.endsWith(":requested")),
|
|
11847
12579
|
[ActionType.EDIT]: (flags) => !flags.includes(InherentFlags.POTENTIAL_DUPLICATE) && !flags.some((flag2) => flag2.endsWith(":requested")),
|
|
11848
12580
|
[ActionType.REGISTER]: (flags) => !flags.includes(InherentFlags.POTENTIAL_DUPLICATE) && !flags.some((flag2) => flag2.endsWith(":requested")),
|
|
@@ -11892,13 +12624,11 @@ function getFilePathsFromEvent(event2) {
|
|
|
11892
12624
|
...declarationValues,
|
|
11893
12625
|
...annotationValues
|
|
11894
12626
|
].flatMap((value) => {
|
|
11895
|
-
|
|
11896
|
-
|
|
11897
|
-
return [fileParsed.data.path];
|
|
12627
|
+
if (isFileFieldValue(value)) {
|
|
12628
|
+
return [value.path];
|
|
11898
12629
|
}
|
|
11899
|
-
|
|
11900
|
-
|
|
11901
|
-
return fileOptionParsed.data.map((val) => val.path);
|
|
12630
|
+
if (isFileFieldWithOptionValue(value)) {
|
|
12631
|
+
return value.map((val) => val.path);
|
|
11902
12632
|
}
|
|
11903
12633
|
return [];
|
|
11904
12634
|
});
|
|
@@ -11908,49 +12638,49 @@ function getFilePathsFromEvent(event2) {
|
|
|
11908
12638
|
}
|
|
11909
12639
|
|
|
11910
12640
|
// ../commons/src/events/locationPayloads.ts
|
|
11911
|
-
var
|
|
11912
|
-
var CreateLocationPayload =
|
|
12641
|
+
var z46 = __toESM(require("zod/v4"));
|
|
12642
|
+
var CreateLocationPayload = z46.object({
|
|
11913
12643
|
id: UUID.optional(),
|
|
11914
12644
|
versionId: UUID.optional(),
|
|
11915
|
-
name:
|
|
11916
|
-
externalId:
|
|
12645
|
+
name: z46.string(),
|
|
12646
|
+
externalId: z46.string().nullish(),
|
|
11917
12647
|
administrativeAreaId: UUID.nullable(),
|
|
11918
|
-
locationType:
|
|
11919
|
-
effectiveFrom:
|
|
12648
|
+
locationType: z46.string().nullable(),
|
|
12649
|
+
effectiveFrom: z46.iso.date().optional(),
|
|
11920
12650
|
status: LocationStatus.default("active")
|
|
11921
12651
|
});
|
|
11922
|
-
var UpdateLocationPayload =
|
|
12652
|
+
var UpdateLocationPayload = z46.strictObject({
|
|
11923
12653
|
id: UUID,
|
|
11924
12654
|
versionId: UUID.optional(),
|
|
11925
|
-
name:
|
|
11926
|
-
externalId:
|
|
12655
|
+
name: z46.string(),
|
|
12656
|
+
externalId: z46.string().nullish(),
|
|
11927
12657
|
status: LocationStatus,
|
|
11928
|
-
effectiveFrom:
|
|
12658
|
+
effectiveFrom: z46.iso.date().optional(),
|
|
11929
12659
|
lastVersionId: UUID
|
|
11930
12660
|
});
|
|
11931
|
-
var WithdrawLocationVersionPayload =
|
|
12661
|
+
var WithdrawLocationVersionPayload = z46.object({
|
|
11932
12662
|
id: UUID,
|
|
11933
12663
|
versionId: UUID
|
|
11934
12664
|
});
|
|
11935
|
-
var CreateAdministrativeAreaPayload =
|
|
12665
|
+
var CreateAdministrativeAreaPayload = z46.object({
|
|
11936
12666
|
id: UUID.optional(),
|
|
11937
12667
|
versionId: UUID.optional(),
|
|
11938
|
-
name:
|
|
11939
|
-
externalId:
|
|
12668
|
+
name: z46.string(),
|
|
12669
|
+
externalId: z46.string().nullish(),
|
|
11940
12670
|
parentId: UUID.nullable(),
|
|
11941
|
-
effectiveFrom:
|
|
12671
|
+
effectiveFrom: z46.iso.date().optional(),
|
|
11942
12672
|
status: LocationStatus.default("active")
|
|
11943
12673
|
});
|
|
11944
|
-
var UpdateAdministrativeAreaPayload =
|
|
12674
|
+
var UpdateAdministrativeAreaPayload = z46.strictObject({
|
|
11945
12675
|
id: UUID,
|
|
11946
12676
|
versionId: UUID.optional(),
|
|
11947
|
-
name:
|
|
11948
|
-
externalId:
|
|
12677
|
+
name: z46.string(),
|
|
12678
|
+
externalId: z46.string().nullish(),
|
|
11949
12679
|
status: LocationStatus,
|
|
11950
|
-
effectiveFrom:
|
|
12680
|
+
effectiveFrom: z46.iso.date().optional(),
|
|
11951
12681
|
lastVersionId: UUID
|
|
11952
12682
|
});
|
|
11953
|
-
var WithdrawAdministrativeAreaVersionPayload =
|
|
12683
|
+
var WithdrawAdministrativeAreaVersionPayload = z46.object({
|
|
11954
12684
|
id: UUID,
|
|
11955
12685
|
versionId: UUID
|
|
11956
12686
|
});
|