@opencrvs/toolkit 2.2.0-rc.ab91cce → 2.2.0-rc.e6591c5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build.sh +17 -14
- package/dist/application-config/index.js +57 -14
- package/dist/authentication/index.d.ts +2 -1
- package/dist/authentication/index.js +34 -14
- package/dist/cli.js +2631 -377
- package/dist/commons/api/router.d.ts +1564 -248
- package/dist/commons/application-config/index.d.ts +3 -3
- package/dist/commons/conditionals/conditionals.d.ts +7 -7
- package/dist/commons/conditionals/index.d.ts +1 -0
- package/dist/commons/conditionals/validate.d.ts +6 -1
- package/dist/commons/events/ActionConfig.d.ts +68 -21
- package/dist/commons/events/ActionDocument.d.ts +89 -0
- package/dist/commons/events/ActionInput.d.ts +56 -4
- package/dist/commons/events/ActionStatus.d.ts +2 -2
- package/dist/commons/events/ActionType.d.ts +13 -1
- package/dist/commons/events/AdvancedSearchConfig.d.ts +15 -0
- package/dist/commons/events/AuditLog.d.ts +4 -0
- package/dist/commons/events/CompositeFieldValue.d.ts +5 -1
- package/dist/commons/events/CountryConfigQueryInput.d.ts +192 -18
- package/dist/commons/events/Draft.d.ts +36 -1
- package/dist/commons/events/EventConfig.d.ts +448 -1
- package/dist/commons/events/EventDocument.d.ts +90 -0
- package/dist/commons/events/EventIndex.d.ts +44 -6
- package/dist/commons/events/EventInput.d.ts +1 -0
- package/dist/commons/events/EventMetadata.d.ts +24 -1
- package/dist/commons/events/EventStatus.d.ts +1 -0
- package/dist/commons/events/FieldConfig.d.ts +11 -1
- package/dist/commons/events/FieldTypeMapping.d.ts +17 -17
- package/dist/commons/events/Flag.d.ts +1 -7
- package/dist/commons/events/PlainDate.d.ts +6 -0
- package/dist/commons/events/WorkqueueConfig.d.ts +224 -33
- package/dist/commons/events/defineConfig.d.ts +7 -2
- package/dist/commons/events/event.d.ts +4 -1
- package/dist/commons/events/eventConfigValidation.d.ts +9 -0
- package/dist/commons/events/field.d.ts +5 -0
- package/dist/commons/events/index.d.ts +3 -0
- package/dist/commons/events/locations.d.ts +1 -1
- package/dist/commons/events/scopes.d.ts +4 -1
- package/dist/commons/events/state/flags.d.ts +1 -1
- package/dist/commons/events/state/index.d.ts +11 -2
- package/dist/commons/events/state/utils.d.ts +11 -1
- package/dist/commons/events/test.utils.d.ts +85 -8
- package/dist/commons/events/toNotificationForm.d.ts +17 -0
- package/dist/commons/events/utils.d.ts +88 -8
- package/dist/commons/users/Role.d.ts +23 -0
- package/dist/commons/users/User.d.ts +263 -0
- package/dist/commons/users/authentication.d.ts +67 -0
- package/dist/commons/users/index.d.ts +5 -0
- package/dist/commons/users/roleValidations.d.ts +15 -0
- package/dist/commons/users/scopes.d.ts +1402 -0
- package/dist/commons/users/userReferences.d.ts +176 -0
- package/dist/conditionals/index.js +19 -7
- package/dist/configurator/index.d.ts +24 -0
- package/dist/configurator/index.d.ts.map +1 -0
- package/dist/configurator/index.js +161 -0
- package/dist/configurator/layout.d.ts +29 -0
- package/dist/configurator/layout.d.ts.map +1 -0
- package/dist/configurator/layout.js +78 -0
- package/dist/configurator/paths.d.ts +13 -0
- package/dist/configurator/paths.d.ts.map +1 -0
- package/dist/configurator/paths.js +48 -0
- package/dist/configurator/server/environments.d.ts +20 -0
- package/dist/configurator/server/environments.d.ts.map +1 -0
- package/dist/configurator/server/environments.js +143 -0
- package/dist/configurator/server/files.d.ts +11 -0
- package/dist/configurator/server/files.d.ts.map +1 -0
- package/dist/configurator/server/files.js +67 -0
- package/dist/configurator/server/github.d.ts +56 -0
- package/dist/configurator/server/github.d.ts.map +1 -0
- package/dist/configurator/server/github.js +239 -0
- package/dist/configurator/server/plugin.d.ts +39 -0
- package/dist/configurator/server/plugin.d.ts.map +1 -0
- package/dist/configurator/server/plugin.js +298 -0
- package/dist/configurator/server/seal.d.ts +2 -0
- package/dist/configurator/server/seal.d.ts.map +1 -0
- package/dist/configurator/server/seal.js +36 -0
- package/dist/configurator/server/sshKeys.d.ts +5 -0
- package/dist/configurator/server/sshKeys.d.ts.map +1 -0
- package/dist/configurator/server/sshKeys.js +28 -0
- package/dist/configurator/server/start.d.ts +12 -0
- package/dist/configurator/server/start.d.ts.map +1 -0
- package/dist/configurator/server/start.js +91 -0
- package/dist/configurator/testing.d.ts +11 -0
- package/dist/configurator/testing.d.ts.map +1 -0
- package/dist/configurator/testing.js +74 -0
- package/dist/configurator/ui/bindings/bindings.d.ts +35 -0
- package/dist/configurator/ui/bindings/bindings.d.ts.map +1 -0
- package/dist/configurator/ui/bindings/bindings.js +5 -0
- package/dist/configurator/ui/bindings/parsers.d.ts +7 -0
- package/dist/configurator/ui/bindings/parsers.d.ts.map +1 -0
- package/dist/configurator/ui/bindings/parsers.js +85 -0
- package/dist/configurator/ui/form/users.d.ts +11 -0
- package/dist/configurator/ui/form/users.d.ts.map +1 -0
- package/dist/configurator/ui/form/users.js +33 -0
- package/dist/configurator/ui/plan/dependencyHosts.d.ts +2 -0
- package/dist/configurator/ui/plan/dependencyHosts.d.ts.map +1 -0
- package/dist/configurator/ui/plan/dependencyHosts.js +36 -0
- package/dist/configurator/ui/plan/templateValues.d.ts +11 -0
- package/dist/configurator/ui/plan/templateValues.d.ts.map +1 -0
- package/dist/configurator/ui/plan/templateValues.js +70 -0
- package/dist/configurator/workflows.d.ts +54 -0
- package/dist/configurator/workflows.d.ts.map +1 -0
- package/dist/configurator/workflows.js +161 -0
- package/dist/configurator-assets/forms/bindings.yml +265 -0
- package/dist/configurator-assets/templates/README.md +18 -0
- package/dist/configurator-assets/templates/charts-values/dependencies/values.override.yaml +4 -0
- package/dist/configurator-assets/templates/charts-values/dependencies/values.yaml +96 -0
- package/dist/configurator-assets/templates/charts-values/opencrvs-services/values.override.yaml +4 -0
- package/dist/configurator-assets/templates/charts-values/opencrvs-services/values.yaml +83 -0
- package/dist/configurator-assets/templates/charts-values/opentelemetry/values.yaml +102 -0
- package/dist/configurator-assets/templates/charts-values/traefik/values.override.yaml +4 -0
- package/dist/configurator-assets/templates/charts-values/traefik/values.yaml +130 -0
- package/dist/configurator-assets/templates/inventory/inventory.template.yml +98 -0
- package/dist/configurator-assets/ui/apple-touch-icon.png +0 -0
- package/dist/configurator-assets/ui/assets/index-CaqYFJUk.css +6 -0
- package/dist/configurator-assets/ui/assets/index-DU1Y6E0b.js +169 -0
- package/dist/configurator-assets/ui/assets/opencrvs-logo-sIjz08HT.svg +1 -0
- package/dist/configurator-assets/ui/assets/poppins-400-BwTUGeWf.woff2 +0 -0
- package/dist/configurator-assets/ui/assets/poppins-500-CWICHMj6.woff2 +0 -0
- package/dist/configurator-assets/ui/assets/poppins-600-DJVo7c07.woff2 +0 -0
- package/dist/configurator-assets/ui/assets/poppins-700-g9MkRaG0.woff2 +0 -0
- package/dist/configurator-assets/ui/favicon-32x32.png +0 -0
- package/dist/configurator-assets/ui/index.html +25 -0
- package/dist/environment/custom-types.d.ts +1 -0
- package/dist/environment/custom-types.d.ts.map +1 -1
- package/dist/environment/derived-variables.d.ts +18 -4
- package/dist/environment/derived-variables.d.ts.map +1 -1
- package/dist/environment/derived-variables.js +20 -4
- package/dist/environment/questions.d.ts +42 -9
- package/dist/environment/questions.d.ts.map +1 -1
- package/dist/environment/questions.js +71 -48
- package/dist/environment/registry.d.ts +15 -0
- package/dist/environment/registry.d.ts.map +1 -0
- package/dist/environment/registry.js +112 -0
- package/dist/environment/setup-environment.d.ts.map +1 -1
- package/dist/environment/setup-environment.js +145 -25
- package/dist/environment/templates.d.ts.map +1 -1
- package/dist/events/index.js +957 -215
- package/dist/migrations/add-notify-config.d.ts +40 -0
- package/dist/migrations/add-notify-config.d.ts.map +1 -0
- package/dist/migrations/add-notify-config.js +249 -0
- package/dist/migrations/index.d.ts +9 -0
- package/dist/migrations/index.d.ts.map +1 -0
- package/dist/migrations/index.js +1306 -0
- package/dist/migrations/move-declaration-to-declare-action.d.ts +38 -0
- package/dist/migrations/move-declaration-to-declare-action.d.ts.map +1 -0
- package/dist/migrations/move-declaration-to-declare-action.js +260 -0
- package/dist/migrations/{add-translations.d.ts → persistent/add-translations.d.ts} +1 -1
- package/dist/migrations/persistent/add-translations.d.ts.map +1 -0
- package/dist/migrations/{add-translations.js → persistent/add-translations.js} +2 -2
- package/dist/migrations/persistent/check-upgrade-path.d.ts +36 -0
- package/dist/migrations/persistent/check-upgrade-path.d.ts.map +1 -0
- package/dist/migrations/persistent/check-upgrade-path.js +105 -0
- package/dist/migrations/persistent/update-toolkit-dependency.d.ts +7 -0
- package/dist/migrations/persistent/update-toolkit-dependency.d.ts.map +1 -0
- package/dist/migrations/persistent/update-toolkit-dependency.js +77 -0
- package/dist/migrations/{v2.2/read-declaration-through-helper.d.ts → read-declaration-through-helper.d.ts} +1 -1
- package/dist/migrations/read-declaration-through-helper.d.ts.map +1 -0
- package/dist/migrations/{v2.2/read-declaration-through-helper.js → read-declaration-through-helper.js} +4 -62
- package/dist/migrations/replace-incomplete-flag.d.ts +26 -0
- package/dist/migrations/replace-incomplete-flag.d.ts.map +1 -0
- package/dist/migrations/replace-incomplete-flag.js +126 -0
- package/dist/migrations/resolve-versioned-event-config.d.ts +56 -0
- package/dist/migrations/resolve-versioned-event-config.d.ts.map +1 -0
- package/dist/migrations/resolve-versioned-event-config.js +353 -0
- package/dist/migrations/utils.d.ts +61 -0
- package/dist/migrations/utils.d.ts.map +1 -0
- package/dist/migrations/utils.js +218 -0
- package/dist/notification/index.js +810 -84
- package/dist/roles/index.d.ts +2 -0
- package/dist/roles/index.d.ts.map +1 -0
- package/dist/roles/index.js +730 -0
- package/dist/scopes/index.d.ts +83 -100
- package/dist/scopes/index.js +29 -13
- package/dist/templates/charts-values/dependencies/values.yaml +5 -2
- package/dist/templates/charts-values/opencrvs-services/values.yaml +5 -7
- package/dist/templates/charts-values/traefik/values.yaml +2 -0
- package/dist/verify/endpoints.d.ts +11 -0
- package/dist/verify/endpoints.d.ts.map +1 -1
- package/dist/verify/endpoints.js +21 -27
- package/opencrvs-toolkit-2.2.0-rc.e6591c5.tgz +0 -0
- package/package.json +17 -4
- package/tsconfig.build.json +11 -1
- package/tsconfig.build.tsbuildinfo +1 -1
- package/tsconfig.json +15 -6
- package/dist/migrations/add-translations.d.ts.map +0 -1
- package/dist/migrations/v2.1/add-explicit-correction-flags.d.ts +0 -3
- package/dist/migrations/v2.1/add-explicit-correction-flags.d.ts.map +0 -1
- package/dist/migrations/v2.1/add-explicit-correction-flags.js +0 -234
- package/dist/migrations/v2.1/add-recovery-link-notifications.d.ts +0 -3
- package/dist/migrations/v2.1/add-recovery-link-notifications.d.ts.map +0 -1
- package/dist/migrations/v2.1/add-recovery-link-notifications.js +0 -511
- package/dist/migrations/v2.1/enable-telemetry.d.ts +0 -3
- package/dist/migrations/v2.1/enable-telemetry.d.ts.map +0 -1
- package/dist/migrations/v2.1/enable-telemetry.js +0 -455
- package/dist/migrations/v2.1/index.d.ts +0 -6
- package/dist/migrations/v2.1/index.d.ts.map +0 -1
- package/dist/migrations/v2.1/index.js +0 -50
- package/dist/migrations/v2.1/migrate-infrastructure-to-assets.d.ts +0 -17
- package/dist/migrations/v2.1/migrate-infrastructure-to-assets.d.ts.map +0 -1
- package/dist/migrations/v2.1/migrate-infrastructure-to-assets.js +0 -348
- package/dist/migrations/v2.1/remove-metabase-package-installs.d.ts +0 -2
- package/dist/migrations/v2.1/remove-metabase-package-installs.d.ts.map +0 -1
- package/dist/migrations/v2.1/remove-metabase-package-installs.js +0 -161
- package/dist/migrations/v2.1/remove-sentry.d.ts +0 -3
- package/dist/migrations/v2.1/remove-sentry.d.ts.map +0 -1
- package/dist/migrations/v2.1/remove-sentry.js +0 -354
- package/dist/migrations/v2.1/rename-trigger-paths.d.ts +0 -3
- package/dist/migrations/v2.1/rename-trigger-paths.d.ts.map +0 -1
- package/dist/migrations/v2.1/rename-trigger-paths.js +0 -216
- package/dist/migrations/v2.1/template-files.d.ts +0 -8
- package/dist/migrations/v2.1/template-files.d.ts.map +0 -1
- package/dist/migrations/v2.1/template-files.js +0 -49
- package/dist/migrations/v2.1/upgrade-tilt.d.ts +0 -11
- package/dist/migrations/v2.1/upgrade-tilt.d.ts.map +0 -1
- package/dist/migrations/v2.1/upgrade-tilt.js +0 -139
- package/dist/migrations/v2.2/index.d.ts +0 -6
- package/dist/migrations/v2.2/index.d.ts.map +0 -1
- package/dist/migrations/v2.2/index.js +0 -456
- package/dist/migrations/v2.2/read-declaration-through-helper.d.ts.map +0 -1
- package/dist/templates/countryconfig-template/.tiltignore +0 -1
- package/dist/templates/countryconfig-template/Dockerfile.assets +0 -7
- package/dist/templates/countryconfig-template/Tiltfile +0 -112
- package/dist/templates/countryconfig-template/assets/README.md +0 -1
- package/dist/templates/countryconfig-template/assets/clear-all-data-dev.sh +0 -61
- package/dist/templates/countryconfig-template/assets/deployment/deploy.sh +0 -455
- package/dist/templates/countryconfig-template/assets/deployment/reindex.sh +0 -168
- package/dist/templates/countryconfig-template/assets/deployment/validate-required-variables-in-compose-files.ts +0 -67
- package/dist/templates/countryconfig-template/assets/elasticsearch/reindex.sh +0 -168
- package/dist/templates/countryconfig-template/assets/metabase/README.md +0 -34
- package/dist/templates/countryconfig-template/assets/metabase/environment-configuration.sql +0 -36
- package/dist/templates/countryconfig-template/assets/metabase/initialize-database.sh +0 -46
- package/dist/templates/countryconfig-template/assets/metabase/metabase.init.db.sql +0 -27737
- package/dist/templates/countryconfig-template/assets/metabase/open-shell.sh +0 -21
- package/dist/templates/countryconfig-template/assets/metabase/package.json +0 -13
- package/dist/templates/countryconfig-template/assets/metabase/run-dev.sh +0 -108
- package/dist/templates/countryconfig-template/assets/metabase/run.sh +0 -120
- package/dist/templates/countryconfig-template/assets/metabase/update-database.sh +0 -40
- package/dist/templates/countryconfig-template/assets/postgres/setup-analytics.sh +0 -135
- package/dist/templates/countryconfig-template/assets/postgres/setup-reference-data.sh +0 -108
- package/dist/templates/countryconfig-template/tilt/clear-all-data.ps1 +0 -50
- package/dist/templates/countryconfig-template/tilt/clear-all-data.sh +0 -35
- package/dist/templates/countryconfig-template/tilt/common.tilt +0 -145
- package/dist/templates/countryconfig-template/tilt/examples/dependencies/values.yaml +0 -15
- package/dist/templates/countryconfig-template/tilt/examples/opencrvs-services/values.yaml +0 -56
- package/dist/templates/countryconfig-template/tilt/examples/traefik/values-minikube.yaml +0 -21
- package/dist/templates/countryconfig-template/tilt/examples/traefik/values.yaml +0 -38
- package/dist/templates/countryconfig-template/tilt/helm/dependencies/values.yaml +0 -17
- package/dist/templates/countryconfig-template/tilt/helm/opencrvs-services/values.yaml +0 -16
- package/dist/templates/countryconfig-template/tilt/lib.tilt +0 -95
- package/dist/templates/countryconfig-template/tilt/opencrvs.tilt +0 -136
- package/opencrvs-toolkit-2.2.0-rc.ab91cce.tgz +0 -0
|
@@ -40,14 +40,17 @@ __export(notification_exports, {
|
|
|
40
40
|
module.exports = __toCommonJS(notification_exports);
|
|
41
41
|
var z48 = __toESM(require("zod/v4"));
|
|
42
42
|
|
|
43
|
+
// ../commons/src/events/index.ts
|
|
44
|
+
var import_compile = require("zod/compile");
|
|
45
|
+
|
|
43
46
|
// ../commons/src/events/AuditLog.ts
|
|
44
47
|
var z9 = __toESM(require("zod/v4"));
|
|
45
48
|
|
|
46
|
-
// ../commons/src/authentication.ts
|
|
49
|
+
// ../commons/src/users/authentication.ts
|
|
47
50
|
var import_jwt_decode = __toESM(require("jwt-decode"));
|
|
48
51
|
var z8 = __toESM(require("zod/v4"));
|
|
49
52
|
|
|
50
|
-
// ../commons/src/scopes.ts
|
|
53
|
+
// ../commons/src/users/scopes.ts
|
|
51
54
|
var z7 = __toESM(require("zod/v4"));
|
|
52
55
|
var qs = __toESM(require("qs"));
|
|
53
56
|
|
|
@@ -83,6 +86,8 @@ var ActionType = {
|
|
|
83
86
|
REQUEST_CORRECTION: "REQUEST_CORRECTION",
|
|
84
87
|
REJECT_CORRECTION: "REJECT_CORRECTION",
|
|
85
88
|
APPROVE_CORRECTION: "APPROVE_CORRECTION",
|
|
89
|
+
REVOKE_REGISTRATION: "REVOKE_REGISTRATION",
|
|
90
|
+
REINSTATE_REGISTRATION: "REINSTATE_REGISTRATION",
|
|
86
91
|
// General actions
|
|
87
92
|
READ: "READ",
|
|
88
93
|
ASSIGN: "ASSIGN",
|
|
@@ -102,6 +107,8 @@ var ConfirmableActions = [
|
|
|
102
107
|
ActionType.REQUEST_CORRECTION,
|
|
103
108
|
ActionType.APPROVE_CORRECTION,
|
|
104
109
|
ActionType.REJECT_CORRECTION,
|
|
110
|
+
ActionType.REVOKE_REGISTRATION,
|
|
111
|
+
ActionType.REINSTATE_REGISTRATION,
|
|
105
112
|
ActionType.CUSTOM
|
|
106
113
|
];
|
|
107
114
|
var ActionTypes = z2.enum([
|
|
@@ -121,13 +128,17 @@ var ActionTypes = z2.enum([
|
|
|
121
128
|
"REQUEST_CORRECTION",
|
|
122
129
|
"REJECT_CORRECTION",
|
|
123
130
|
"APPROVE_CORRECTION",
|
|
131
|
+
"REVOKE_REGISTRATION",
|
|
132
|
+
"REINSTATE_REGISTRATION",
|
|
124
133
|
"READ",
|
|
125
134
|
"ASSIGN",
|
|
126
135
|
"UNASSIGN",
|
|
127
136
|
"CUSTOM"
|
|
128
137
|
]);
|
|
129
138
|
var ClientSpecificAction = {
|
|
130
|
-
REVIEW_CORRECTION_REQUEST: "REVIEW_CORRECTION_REQUEST"
|
|
139
|
+
REVIEW_CORRECTION_REQUEST: "REVIEW_CORRECTION_REQUEST",
|
|
140
|
+
/** Opens the user's declare or notify draft of the event in its own flow */
|
|
141
|
+
CONTINUE_DRAFT: "CONTINUE_DRAFT"
|
|
131
142
|
};
|
|
132
143
|
var declarationActionValues = [
|
|
133
144
|
ActionTypes.enum.DECLARE,
|
|
@@ -162,7 +173,9 @@ var WorkqueueActionType = ActionTypes.extract([
|
|
|
162
173
|
ActionType.ARCHIVE,
|
|
163
174
|
ActionType.UNARCHIVE,
|
|
164
175
|
ActionType.PRINT_CERTIFICATE,
|
|
165
|
-
ActionType.REQUEST_CORRECTION
|
|
176
|
+
ActionType.REQUEST_CORRECTION,
|
|
177
|
+
ActionType.REVOKE_REGISTRATION,
|
|
178
|
+
ActionType.REINSTATE_REGISTRATION
|
|
166
179
|
]);
|
|
167
180
|
var META_ACTIONS = [
|
|
168
181
|
ActionType.ASSIGN,
|
|
@@ -178,7 +191,7 @@ var ActionStatus = {
|
|
|
178
191
|
};
|
|
179
192
|
|
|
180
193
|
// ../commons/src/events/Flag.ts
|
|
181
|
-
var z5 = __toESM(require("zod
|
|
194
|
+
var z5 = __toESM(require("zod"));
|
|
182
195
|
|
|
183
196
|
// ../commons/src/events/TranslationConfig.ts
|
|
184
197
|
var z3 = __toESM(require("zod/v4"));
|
|
@@ -247,7 +260,6 @@ var FieldConditional = z4.discriminatedUnion("type", [
|
|
|
247
260
|
|
|
248
261
|
// ../commons/src/events/Flag.ts
|
|
249
262
|
var InherentFlags = {
|
|
250
|
-
INCOMPLETE: "incomplete",
|
|
251
263
|
REJECTED: "rejected",
|
|
252
264
|
CORRECTION_REQUESTED: "correction-requested",
|
|
253
265
|
POTENTIAL_DUPLICATE: "potential-duplicate",
|
|
@@ -275,7 +287,7 @@ var CustomFlag = z5.string().refine((val) => !Object.values(InherentFlags).inclu
|
|
|
275
287
|
message: `Custom flag cannot be one of the inherent flags: ${Object.values(
|
|
276
288
|
InherentFlags
|
|
277
289
|
).join(", ")}`
|
|
278
|
-
}).refine((val) => !ActionFlag.
|
|
290
|
+
}).refine((val) => !ActionFlag.validate(val), {
|
|
279
291
|
message: "Custom flag cannot match the ActionFlag pattern (ActionType:ActionStatus)."
|
|
280
292
|
}).describe("Custom flag identifier defined by the country config.");
|
|
281
293
|
var Flag = ActionFlag.or(z5.enum(InherentFlags)).or(CustomFlag);
|
|
@@ -314,10 +326,11 @@ var EventStatus = z6.enum([
|
|
|
314
326
|
"NOTIFIED",
|
|
315
327
|
"DECLARED",
|
|
316
328
|
"REGISTERED",
|
|
329
|
+
"REVOKED",
|
|
317
330
|
"ARCHIVED"
|
|
318
331
|
]);
|
|
319
332
|
|
|
320
|
-
// ../commons/src/scopes.ts
|
|
333
|
+
// ../commons/src/users/scopes.ts
|
|
321
334
|
var JurisdictionFilter = z7.enum(["administrativeArea", "location", "all"]).describe(
|
|
322
335
|
"Filters based on user jurisdiction relative to their office location in hierarchy."
|
|
323
336
|
);
|
|
@@ -337,6 +350,8 @@ var RecordScopeTypeV2 = z7.enum([
|
|
|
337
350
|
"record.print-certified-copies",
|
|
338
351
|
"record.request-correction",
|
|
339
352
|
"record.correct",
|
|
353
|
+
"record.revoke-registration",
|
|
354
|
+
"record.reinstate-registration",
|
|
340
355
|
"record.unassign-others",
|
|
341
356
|
"record.custom-action",
|
|
342
357
|
"record.action.accept",
|
|
@@ -463,6 +478,8 @@ var ScopesWithFullOptions = RecordScopeTypeV2.extract([
|
|
|
463
478
|
"record.read",
|
|
464
479
|
"record.request-correction",
|
|
465
480
|
"record.correct",
|
|
481
|
+
"record.revoke-registration",
|
|
482
|
+
"record.reinstate-registration",
|
|
466
483
|
"record.unassign-others",
|
|
467
484
|
"record.review-duplicates"
|
|
468
485
|
]);
|
|
@@ -586,7 +603,7 @@ var DEFAULT_SCOPE_OPTIONS = {
|
|
|
586
603
|
registeredIn: JurisdictionFilter.enum.all
|
|
587
604
|
};
|
|
588
605
|
|
|
589
|
-
// ../commons/src/authentication.ts
|
|
606
|
+
// ../commons/src/users/authentication.ts
|
|
590
607
|
var TokenUserType = z8.enum(["user", "system"]);
|
|
591
608
|
var TokenWithBearer = z8.string().regex(/^Bearer\s/);
|
|
592
609
|
|
|
@@ -648,6 +665,8 @@ var EventActionEntrySchema = AuditLogEntryBase.extend({
|
|
|
648
665
|
"event.actions.correction.request.request",
|
|
649
666
|
"event.actions.correction.approve.request",
|
|
650
667
|
"event.actions.correction.reject.request",
|
|
668
|
+
"event.actions.revoke_registration.request",
|
|
669
|
+
"event.actions.reinstate_registration.request",
|
|
651
670
|
"event.actions.mark_as_duplicate.request",
|
|
652
671
|
"event.actions.mark_as_not_duplicate.request"
|
|
653
672
|
]),
|
|
@@ -982,7 +1001,7 @@ var z14 = __toESM(require("zod/v4"));
|
|
|
982
1001
|
// ../commons/src/documents.ts
|
|
983
1002
|
var z11 = __toESM(require("zod/v4"));
|
|
984
1003
|
var FullDocumentUrl = z11.string().brand("FullDocumentUrl").describe(
|
|
985
|
-
"A full url with protocol, host, bucket name, starting from the root of the S3 server, https://
|
|
1004
|
+
"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"
|
|
986
1005
|
);
|
|
987
1006
|
var FullDocumentPath = z11.string().overwrite((val) => val.startsWith("/") ? val : `/${val}`).meta({ effectType: "input", type: "string" }).describe(
|
|
988
1007
|
"A full absolute path with bucket name, starting from the root of the S3 server, /bucket-name/document-id.jpg"
|
|
@@ -992,7 +1011,7 @@ var DocumentPath = z11.string().brand("DocumentPath").describe(
|
|
|
992
1011
|
);
|
|
993
1012
|
|
|
994
1013
|
// ../commons/src/events/CompositeFieldValue.ts
|
|
995
|
-
var z12 = __toESM(require("zod
|
|
1014
|
+
var z12 = __toESM(require("zod"));
|
|
996
1015
|
var AddressType = {
|
|
997
1016
|
DOMESTIC: "DOMESTIC",
|
|
998
1017
|
INTERNATIONAL: "INTERNATIONAL"
|
|
@@ -1089,6 +1108,26 @@ var CustomFieldValue = z12.unknown().brand("CustomFieldValue");
|
|
|
1089
1108
|
// ../commons/src/events/PlainDate.ts
|
|
1090
1109
|
var import_zod = require("zod");
|
|
1091
1110
|
var PlainDate = import_zod.z.string().date().brand("PlainDate").describe("Date in the format YYYY-MM-DD");
|
|
1111
|
+
var dateFormats = /* @__PURE__ */ new Map();
|
|
1112
|
+
function getDateFormat(timeZone) {
|
|
1113
|
+
let format2 = dateFormats.get(timeZone);
|
|
1114
|
+
if (!format2) {
|
|
1115
|
+
format2 = new Intl.DateTimeFormat("en-US", {
|
|
1116
|
+
timeZone,
|
|
1117
|
+
year: "numeric",
|
|
1118
|
+
month: "2-digit",
|
|
1119
|
+
day: "2-digit"
|
|
1120
|
+
});
|
|
1121
|
+
dateFormats.set(timeZone, format2);
|
|
1122
|
+
}
|
|
1123
|
+
return format2;
|
|
1124
|
+
}
|
|
1125
|
+
function toPlainDateInTimeZone(date, timeZone) {
|
|
1126
|
+
const parts = Object.fromEntries(
|
|
1127
|
+
getDateFormat(timeZone).formatToParts(date).map(({ type, value }) => [type, value])
|
|
1128
|
+
);
|
|
1129
|
+
return `${parts.year}-${parts.month}-${parts.day}`;
|
|
1130
|
+
}
|
|
1092
1131
|
|
|
1093
1132
|
// ../commons/src/events/FieldValue.ts
|
|
1094
1133
|
var TextValue = z14.string();
|
|
@@ -1197,7 +1236,7 @@ function safeUnion(schemas) {
|
|
|
1197
1236
|
);
|
|
1198
1237
|
return z14.any().superRefine((val, ctx) => {
|
|
1199
1238
|
for (const schema of sortedSchemas) {
|
|
1200
|
-
if (schema.
|
|
1239
|
+
if (schema.validate(val)) {
|
|
1201
1240
|
return;
|
|
1202
1241
|
}
|
|
1203
1242
|
}
|
|
@@ -1391,6 +1430,16 @@ var UnarchiveAction = ActionBase.extend(
|
|
|
1391
1430
|
type: z16.literal(ActionType.UNARCHIVE)
|
|
1392
1431
|
}).shape
|
|
1393
1432
|
);
|
|
1433
|
+
var RevokeRegistrationAction = ActionBase.extend(
|
|
1434
|
+
z16.object({
|
|
1435
|
+
type: z16.literal(ActionType.REVOKE_REGISTRATION)
|
|
1436
|
+
}).shape
|
|
1437
|
+
);
|
|
1438
|
+
var ReinstateRegistrationAction = ActionBase.extend(
|
|
1439
|
+
z16.object({
|
|
1440
|
+
type: z16.literal(ActionType.REINSTATE_REGISTRATION)
|
|
1441
|
+
}).shape
|
|
1442
|
+
);
|
|
1394
1443
|
var CreatedAction = ActionBase.extend(
|
|
1395
1444
|
z16.object({
|
|
1396
1445
|
type: z16.literal(ActionType.CREATE)
|
|
@@ -1459,6 +1508,8 @@ var ActionDocument = z16.discriminatedUnion("type", [
|
|
|
1459
1508
|
MarkAsDuplicateAction.meta({ id: "MarkAsDuplicateAction" }),
|
|
1460
1509
|
ArchiveAction.meta({ id: "ArchiveAction" }),
|
|
1461
1510
|
UnarchiveAction.meta({ id: "UnarchiveAction" }),
|
|
1511
|
+
RevokeRegistrationAction.meta({ id: "RevokeRegistrationAction" }),
|
|
1512
|
+
ReinstateRegistrationAction.meta({ id: "ReinstateRegistrationAction" }),
|
|
1462
1513
|
NotifiedAction.meta({ id: "NotifiedAction" }),
|
|
1463
1514
|
RegisterAction.meta({ id: "RegisterAction" }),
|
|
1464
1515
|
DeclareAction.meta({ id: "DeclareAction" }),
|
|
@@ -1507,11 +1558,15 @@ var RegistrationCreationMetadata = ActionCreationMetadata.extend({
|
|
|
1507
1558
|
var LegalStatuses = z17.object({
|
|
1508
1559
|
[EventStatus.enum.NOTIFIED]: ActionCreationMetadata.nullish(),
|
|
1509
1560
|
[EventStatus.enum.DECLARED]: ActionCreationMetadata.nullish(),
|
|
1510
|
-
[EventStatus.enum.REGISTERED]: RegistrationCreationMetadata.nullish()
|
|
1561
|
+
[EventStatus.enum.REGISTERED]: RegistrationCreationMetadata.nullish(),
|
|
1562
|
+
[EventStatus.enum.REVOKED]: ActionCreationMetadata.nullish()
|
|
1511
1563
|
});
|
|
1512
1564
|
var EventMetadata = z17.object({
|
|
1513
1565
|
id: UUID,
|
|
1514
1566
|
type: z17.string().describe("The type of event, such as birth, death, or marriage."),
|
|
1567
|
+
configVersionId: z17.string().describe(
|
|
1568
|
+
"Id of the event configuration version the record was created under. Records created before versioning have 'initial'."
|
|
1569
|
+
),
|
|
1515
1570
|
status: EventStatus,
|
|
1516
1571
|
legalStatuses: LegalStatuses.describe(
|
|
1517
1572
|
"Metadata related to the legal registration of the event, such as who registered it and when."
|
|
@@ -1627,6 +1682,12 @@ var AnyOfStatus = import_v4.z.object({
|
|
|
1627
1682
|
}).meta({
|
|
1628
1683
|
id: "AnyOfStatus"
|
|
1629
1684
|
});
|
|
1685
|
+
var NoneOfStatus = import_v4.z.object({
|
|
1686
|
+
type: import_v4.z.literal("noneOf"),
|
|
1687
|
+
terms: import_v4.z.array(EventStatus)
|
|
1688
|
+
}).meta({
|
|
1689
|
+
id: "NoneOfStatus"
|
|
1690
|
+
});
|
|
1630
1691
|
var Range = import_v4.z.object({
|
|
1631
1692
|
type: import_v4.z.literal("range"),
|
|
1632
1693
|
gte: import_v4.z.string(),
|
|
@@ -1667,7 +1728,7 @@ var QueryInput = import_v4.z.lazy(
|
|
|
1667
1728
|
var QueryExpression = import_v4.z.object({
|
|
1668
1729
|
id: import_v4.z.optional(import_v4.z.string()),
|
|
1669
1730
|
eventType: import_v4.z.string(),
|
|
1670
|
-
status: import_v4.z.optional(import_v4.z.union([AnyOfStatus, ExactStatus])),
|
|
1731
|
+
status: import_v4.z.optional(import_v4.z.union([AnyOfStatus, NoneOfStatus, ExactStatus])),
|
|
1671
1732
|
createdAt: import_v4.z.optional(DateCondition),
|
|
1672
1733
|
updatedAt: import_v4.z.optional(DateCondition),
|
|
1673
1734
|
"legalStatuses.DECLARED.createdAtLocation": import_v4.z.optional(Within).nullable(),
|
|
@@ -1676,6 +1737,7 @@ var QueryExpression = import_v4.z.object({
|
|
|
1676
1737
|
"legalStatuses.REGISTERED.createdAtLocation": import_v4.z.optional(Within).nullable(),
|
|
1677
1738
|
"legalStatuses.REGISTERED.createdByRole": import_v4.z.optional(AnyOf),
|
|
1678
1739
|
"legalStatuses.REGISTERED.registrationNumber": import_v4.z.optional(Exact),
|
|
1740
|
+
"legalStatuses.REVOKED.createdAtLocation": import_v4.z.optional(Within).nullable(),
|
|
1679
1741
|
createdAtLocation: import_v4.z.optional(import_v4.z.union([Within, Exact])),
|
|
1680
1742
|
updatedAtLocation: import_v4.z.optional(import_v4.z.union([Within, Exact])),
|
|
1681
1743
|
assignedTo: import_v4.z.optional(Exact),
|
|
@@ -2873,6 +2935,12 @@ var ReadActionConfig = ActionConfigBase.extend(
|
|
|
2873
2935
|
var NotifyConfig = ActionConfigBase.extend(
|
|
2874
2936
|
z25.object({
|
|
2875
2937
|
type: z25.literal(ActionType.NOTIFY),
|
|
2938
|
+
notificationForm: DeclarationFormConfig.describe(
|
|
2939
|
+
"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."
|
|
2940
|
+
),
|
|
2941
|
+
review: DeclarationReviewConfig.describe(
|
|
2942
|
+
"Review page configuration for the notify action. Values of its fields are stored as the NOTIFY action annotation."
|
|
2943
|
+
),
|
|
2876
2944
|
form: actionConfirmationForm
|
|
2877
2945
|
}).shape
|
|
2878
2946
|
);
|
|
@@ -2956,6 +3024,18 @@ var UnarchiveConfig = ActionConfigBase.extend(
|
|
|
2956
3024
|
type: z25.literal(ActionType.UNARCHIVE)
|
|
2957
3025
|
}).shape
|
|
2958
3026
|
);
|
|
3027
|
+
var RevokeRegistrationConfig = ActionConfigBase.extend(
|
|
3028
|
+
z25.object({
|
|
3029
|
+
type: z25.literal(ActionType.REVOKE_REGISTRATION),
|
|
3030
|
+
form: actionConfirmationForm
|
|
3031
|
+
}).shape
|
|
3032
|
+
);
|
|
3033
|
+
var ReinstateRegistrationConfig = ActionConfigBase.extend(
|
|
3034
|
+
z25.object({
|
|
3035
|
+
type: z25.literal(ActionType.REINSTATE_REGISTRATION),
|
|
3036
|
+
form: actionConfirmationForm
|
|
3037
|
+
}).shape
|
|
3038
|
+
);
|
|
2959
3039
|
var EditActionConfig = ActionConfigBase.extend(
|
|
2960
3040
|
z25.object({
|
|
2961
3041
|
type: z25.literal(ActionType.EDIT),
|
|
@@ -3042,11 +3122,11 @@ var ActionConfig = z25.discriminatedUnion("type", [
|
|
|
3042
3122
|
}),
|
|
3043
3123
|
NotifyConfig.meta({
|
|
3044
3124
|
id: "NotifyActionConfig",
|
|
3045
|
-
description: "Configuration for the notify action
|
|
3125
|
+
description: "Configuration for the notify action: the notification form and its review page. An event without a NOTIFY action cannot be notified."
|
|
3046
3126
|
}),
|
|
3047
3127
|
DeclareConfig.meta({
|
|
3048
3128
|
id: "DeclareActionConfig",
|
|
3049
|
-
description: "Configuration for the declare action. Includes review-page fields.
|
|
3129
|
+
description: "Configuration for the declare action. Includes the declaration form and review-page fields."
|
|
3050
3130
|
}),
|
|
3051
3131
|
DuplicateDetectedConfig.meta({
|
|
3052
3132
|
id: "DuplicateDetectedActionConfig",
|
|
@@ -3096,6 +3176,14 @@ var ActionConfig = z25.discriminatedUnion("type", [
|
|
|
3096
3176
|
id: "UnarchiveActionConfig",
|
|
3097
3177
|
description: "Configuration for unarchiving a record."
|
|
3098
3178
|
}),
|
|
3179
|
+
RevokeRegistrationConfig.meta({
|
|
3180
|
+
id: "RevokeRegistrationActionConfig",
|
|
3181
|
+
description: "Configuration for revoking a registered record."
|
|
3182
|
+
}),
|
|
3183
|
+
ReinstateRegistrationConfig.meta({
|
|
3184
|
+
id: "ReinstateRegistrationActionConfig",
|
|
3185
|
+
description: "Configuration for reinstating a revoked record back to registered."
|
|
3186
|
+
}),
|
|
3099
3187
|
CustomActionConfig.meta({
|
|
3100
3188
|
id: "CustomActionConfig",
|
|
3101
3189
|
description: "Configuration for a country-defined custom action. An event may include any number of these."
|
|
@@ -3302,7 +3390,7 @@ var ReferenceField = BaseField2.extend({
|
|
|
3302
3390
|
var Field = BaseField2.extend({
|
|
3303
3391
|
id: z29.string().describe("Identifier of the summary field."),
|
|
3304
3392
|
value: TranslationConfig.describe(
|
|
3305
|
-
'Field value template supports variables from configuration (e.g. "{informant.phoneNo} {informant.email}") and EventMetadata (e.g. "{event.legalStatuses.REGISTERED.acceptedAt, date, ::dd MMMM yyyy}").'
|
|
3393
|
+
'Field value template supports variables from configuration (e.g. "{informant.phoneNo} {informant.email}") and EventMetadata (e.g. "{event.legalStatuses.REGISTERED.acceptedAt, date, ::dd MMMM yyyy}"). "{event.configVersionLabel}" gives the label of the configuration version that the record was created under.'
|
|
3306
3394
|
),
|
|
3307
3395
|
label: TranslationConfig
|
|
3308
3396
|
}).describe("Custom field defined for the summary view.");
|
|
@@ -3397,7 +3485,10 @@ var SearchQueryParams = z30.object({
|
|
|
3397
3485
|
}).catchall(FieldValue);
|
|
3398
3486
|
var FieldConfigSchema = BaseField3.extend({
|
|
3399
3487
|
fieldId: z30.string(),
|
|
3400
|
-
fieldType: z30.literal("field")
|
|
3488
|
+
fieldType: z30.literal("field"),
|
|
3489
|
+
defaultValue: z30.union([z30.boolean(), z30.string(), z30.number()]).optional().describe(
|
|
3490
|
+
`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.`
|
|
3491
|
+
)
|
|
3401
3492
|
});
|
|
3402
3493
|
var EventFieldIdInput = z30.enum([
|
|
3403
3494
|
"trackingId",
|
|
@@ -3446,32 +3537,20 @@ var AdvancedSearchConfig = z30.object({
|
|
|
3446
3537
|
description: "Configuration of one advanced search tab. Each tab has a title and a list of searchable fields \u2014 either declaration fields (via `field()`) or event metadata (via `event()`)."
|
|
3447
3538
|
});
|
|
3448
3539
|
|
|
3449
|
-
// ../commons/src/events/utils.ts
|
|
3450
|
-
var import_lodash4 = require("lodash");
|
|
3451
|
-
|
|
3452
|
-
// ../commons/src/conditionals/validate.ts
|
|
3453
|
-
var import__ = __toESM(require("ajv/dist/2019"));
|
|
3454
|
-
var import_ajv_formats = __toESM(require("ajv-formats"));
|
|
3455
|
-
var z34 = __toESM(require("zod/v4"));
|
|
3456
|
-
var import_date_fns2 = require("date-fns");
|
|
3457
|
-
|
|
3458
|
-
// ../commons/src/events/FieldTypeMapping.ts
|
|
3459
|
-
var z32 = __toESM(require("zod/v4"));
|
|
3460
|
-
|
|
3461
|
-
// ../commons/src/events/DynamicFieldValue.ts
|
|
3462
|
-
var z31 = __toESM(require("zod/v4"));
|
|
3463
|
-
|
|
3464
|
-
// ../commons/src/events/state/index.ts
|
|
3465
|
-
var import_lodash3 = require("lodash");
|
|
3466
|
-
|
|
3467
3540
|
// ../commons/src/utils.ts
|
|
3468
|
-
var
|
|
3541
|
+
var z31 = __toESM(require("zod/v4"));
|
|
3469
3542
|
var _ = __toESM(require("lodash"));
|
|
3470
|
-
|
|
3471
|
-
|
|
3472
|
-
|
|
3473
|
-
|
|
3474
|
-
|
|
3543
|
+
function getOrThrow(x, message) {
|
|
3544
|
+
if (x === void 0 || x === null) {
|
|
3545
|
+
throw new Error(message);
|
|
3546
|
+
}
|
|
3547
|
+
return x;
|
|
3548
|
+
}
|
|
3549
|
+
var FullNameV1 = z31.array(
|
|
3550
|
+
z31.object({
|
|
3551
|
+
use: z31.string(),
|
|
3552
|
+
family: z31.string(),
|
|
3553
|
+
given: z31.array(z31.string())
|
|
3475
3554
|
})
|
|
3476
3555
|
);
|
|
3477
3556
|
function omitKeyDeep(obj, keyToRemove) {
|
|
@@ -3490,6 +3569,162 @@ function omitKeyDeep(obj, keyToRemove) {
|
|
|
3490
3569
|
return newObj;
|
|
3491
3570
|
}
|
|
3492
3571
|
|
|
3572
|
+
// ../commons/src/events/utils.ts
|
|
3573
|
+
var import_lodash4 = require("lodash");
|
|
3574
|
+
|
|
3575
|
+
// ../commons/src/conditionals/validate.ts
|
|
3576
|
+
var import__ = __toESM(require("ajv/dist/2019"));
|
|
3577
|
+
var import_ajv_formats = __toESM(require("ajv-formats"));
|
|
3578
|
+
var z34 = __toESM(require("zod/v4"));
|
|
3579
|
+
var import_date_fns2 = require("date-fns");
|
|
3580
|
+
|
|
3581
|
+
// ../commons/src/events/FieldTypeMapping.ts
|
|
3582
|
+
var z33 = __toESM(require("zod/v4"));
|
|
3583
|
+
|
|
3584
|
+
// ../commons/src/events/DynamicFieldValue.ts
|
|
3585
|
+
var z32 = __toESM(require("zod/v4"));
|
|
3586
|
+
function getDynamicNameValue(field3) {
|
|
3587
|
+
const nameConfiguration = field3.configuration?.name;
|
|
3588
|
+
const firstnameRequired = nameConfiguration?.firstname?.required ?? field3.required;
|
|
3589
|
+
const surnameRequired = nameConfiguration?.surname?.required ?? field3.required;
|
|
3590
|
+
return z32.object({
|
|
3591
|
+
firstname: firstnameRequired ? NonEmptyTextValue : TextValue,
|
|
3592
|
+
surname: surnameRequired ? NonEmptyTextValue : TextValue,
|
|
3593
|
+
middlename: nameConfiguration?.middlename?.required ? NonEmptyTextValue : TextValue.optional()
|
|
3594
|
+
});
|
|
3595
|
+
}
|
|
3596
|
+
function getDynamicAddressFieldValue(field3) {
|
|
3597
|
+
const schema = field3.required ? AddressFieldValue : AddressFieldUpdateValue;
|
|
3598
|
+
const configIds = field3.configuration?.streetAddressForm?.map((a) => a.id) ?? [];
|
|
3599
|
+
return schema.refine((arg) => {
|
|
3600
|
+
if (!arg) {
|
|
3601
|
+
return true;
|
|
3602
|
+
}
|
|
3603
|
+
const submittedKeys = Object.keys(arg.streetLevelDetails ?? {});
|
|
3604
|
+
const invalidKeys = submittedKeys.filter((k) => !configIds.includes(k));
|
|
3605
|
+
if (invalidKeys.length) {
|
|
3606
|
+
console.log(
|
|
3607
|
+
"Invalid streetLevelDetails: unknown keys",
|
|
3608
|
+
JSON.stringify(invalidKeys, null, 2)
|
|
3609
|
+
);
|
|
3610
|
+
return false;
|
|
3611
|
+
}
|
|
3612
|
+
return true;
|
|
3613
|
+
});
|
|
3614
|
+
}
|
|
3615
|
+
|
|
3616
|
+
// ../commons/src/events/FieldTypeMapping.ts
|
|
3617
|
+
function mapFieldTypeToZod(field3, actionType) {
|
|
3618
|
+
let schema;
|
|
3619
|
+
switch (field3.type) {
|
|
3620
|
+
case FieldType.FIELD_GROUP: {
|
|
3621
|
+
schema = z33.object(
|
|
3622
|
+
field3.fields.reduce((acc, subfield) => {
|
|
3623
|
+
acc[subfield.id] = mapFieldTypeToZod(subfield, actionType);
|
|
3624
|
+
return acc;
|
|
3625
|
+
}, {})
|
|
3626
|
+
);
|
|
3627
|
+
break;
|
|
3628
|
+
}
|
|
3629
|
+
case FieldType.DATE:
|
|
3630
|
+
schema = PlainDate;
|
|
3631
|
+
break;
|
|
3632
|
+
case FieldType.AGE:
|
|
3633
|
+
schema = AgeValue;
|
|
3634
|
+
break;
|
|
3635
|
+
case FieldType.TIME:
|
|
3636
|
+
schema = TimeValue;
|
|
3637
|
+
break;
|
|
3638
|
+
case FieldType.EMAIL:
|
|
3639
|
+
schema = EmailValue;
|
|
3640
|
+
break;
|
|
3641
|
+
case FieldType.DATE_RANGE:
|
|
3642
|
+
schema = DateRangeFieldValue;
|
|
3643
|
+
break;
|
|
3644
|
+
case FieldType.SELECT_DATE_RANGE:
|
|
3645
|
+
schema = SelectDateRangeValue;
|
|
3646
|
+
break;
|
|
3647
|
+
case FieldType.TEXT:
|
|
3648
|
+
case FieldType.TEXTAREA:
|
|
3649
|
+
case FieldType.DIVIDER:
|
|
3650
|
+
case FieldType.BULLET_LIST:
|
|
3651
|
+
case FieldType.PAGE_HEADER:
|
|
3652
|
+
case FieldType.LOCATION:
|
|
3653
|
+
case FieldType.SELECT:
|
|
3654
|
+
case FieldType.COUNTRY:
|
|
3655
|
+
case FieldType.RADIO_GROUP:
|
|
3656
|
+
case FieldType.PARAGRAPH:
|
|
3657
|
+
case FieldType.HEADING:
|
|
3658
|
+
case FieldType.IMAGE_VIEW:
|
|
3659
|
+
case FieldType.ADMINISTRATIVE_AREA:
|
|
3660
|
+
case FieldType.FACILITY:
|
|
3661
|
+
case FieldType.OFFICE:
|
|
3662
|
+
case FieldType.PHONE:
|
|
3663
|
+
case FieldType.LINK_BUTTON:
|
|
3664
|
+
case FieldType.VERIFICATION_STATUS:
|
|
3665
|
+
case FieldType.ID:
|
|
3666
|
+
case FieldType.LOADER:
|
|
3667
|
+
case FieldType.ALPHA_HIDDEN:
|
|
3668
|
+
case FieldType.USER_ROLE:
|
|
3669
|
+
schema = field3.required ? NonEmptyTextValue : TextValue;
|
|
3670
|
+
break;
|
|
3671
|
+
case FieldType.NUMBER:
|
|
3672
|
+
schema = NumberFieldValue;
|
|
3673
|
+
break;
|
|
3674
|
+
case FieldType.NUMBER_WITH_UNIT:
|
|
3675
|
+
schema = field3.required ? NumberWithUnitFieldValue : NumberWithUnitFieldUpdateValue;
|
|
3676
|
+
break;
|
|
3677
|
+
case FieldType.CHECKBOX:
|
|
3678
|
+
schema = CheckboxFieldValue;
|
|
3679
|
+
break;
|
|
3680
|
+
case FieldType.SIGNATURE:
|
|
3681
|
+
case FieldType.FILE:
|
|
3682
|
+
schema = FileFieldValue;
|
|
3683
|
+
break;
|
|
3684
|
+
case FieldType.FILE_WITH_OPTIONS:
|
|
3685
|
+
schema = field3.required ? FileFieldWithOptionValue.min(1) : FileFieldWithOptionValue;
|
|
3686
|
+
break;
|
|
3687
|
+
case FieldType.ADDRESS:
|
|
3688
|
+
schema = getDynamicAddressFieldValue(field3);
|
|
3689
|
+
break;
|
|
3690
|
+
case FieldType.DATA:
|
|
3691
|
+
schema = DataFieldValue;
|
|
3692
|
+
break;
|
|
3693
|
+
case FieldType.NAME:
|
|
3694
|
+
schema = actionType === ActionType.NOTIFY ? NameFieldUpdateValue : getDynamicNameValue(field3);
|
|
3695
|
+
break;
|
|
3696
|
+
case FieldType.BUTTON:
|
|
3697
|
+
schema = ButtonFieldValue;
|
|
3698
|
+
break;
|
|
3699
|
+
case FieldType.ALPHA_PRINT_BUTTON:
|
|
3700
|
+
schema = TextValue;
|
|
3701
|
+
break;
|
|
3702
|
+
case FieldType.AUTOCOMPLETE:
|
|
3703
|
+
schema = AutocompleteValue;
|
|
3704
|
+
break;
|
|
3705
|
+
case FieldType.HTTP:
|
|
3706
|
+
case FieldType.SEARCH:
|
|
3707
|
+
schema = HttpFieldUpdateValue;
|
|
3708
|
+
break;
|
|
3709
|
+
case FieldType.QUERY_PARAM_READER:
|
|
3710
|
+
schema = QueryParamReaderFieldUpdateValue;
|
|
3711
|
+
break;
|
|
3712
|
+
case FieldType.QR_READER:
|
|
3713
|
+
schema = QrReaderFieldValue;
|
|
3714
|
+
break;
|
|
3715
|
+
case FieldType.ID_READER:
|
|
3716
|
+
schema = IdReaderFieldValue;
|
|
3717
|
+
break;
|
|
3718
|
+
case FieldType._EXPERIMENTAL_CUSTOM:
|
|
3719
|
+
schema = CustomFieldValue;
|
|
3720
|
+
break;
|
|
3721
|
+
}
|
|
3722
|
+
return field3.required ? schema : schema.nullish();
|
|
3723
|
+
}
|
|
3724
|
+
|
|
3725
|
+
// ../commons/src/events/state/index.ts
|
|
3726
|
+
var import_lodash3 = require("lodash");
|
|
3727
|
+
|
|
3493
3728
|
// ../commons/src/events/state/utils.ts
|
|
3494
3729
|
var import_lodash = require("lodash");
|
|
3495
3730
|
var updateActions = new Set(
|
|
@@ -3506,6 +3741,8 @@ var updateActions = new Set(
|
|
|
3506
3741
|
ActionType.REQUEST_CORRECTION,
|
|
3507
3742
|
ActionType.APPROVE_CORRECTION,
|
|
3508
3743
|
ActionType.REJECT_CORRECTION,
|
|
3744
|
+
ActionType.REVOKE_REGISTRATION,
|
|
3745
|
+
ActionType.REINSTATE_REGISTRATION,
|
|
3509
3746
|
ActionType.CUSTOM
|
|
3510
3747
|
]).options
|
|
3511
3748
|
);
|
|
@@ -3519,15 +3756,6 @@ var INHERENT_FLAG_RULES = [
|
|
|
3519
3756
|
setOn: [ActionType.REQUEST_CORRECTION],
|
|
3520
3757
|
resetOn: [ActionType.APPROVE_CORRECTION, ActionType.REJECT_CORRECTION]
|
|
3521
3758
|
},
|
|
3522
|
-
{
|
|
3523
|
-
// INCOMPLETE mirrors the NOTIFIED status: set by NOTIFY, cleared by any
|
|
3524
|
-
// other status-changing action (see getStatusFromActions). ARCHIVE/UNARCHIVE
|
|
3525
|
-
// are deliberately excluded so the flag freezes across an archive/unarchive
|
|
3526
|
-
// round trip and comes back exactly as it was.
|
|
3527
|
-
flag: InherentFlags.INCOMPLETE,
|
|
3528
|
-
setOn: [ActionType.NOTIFY],
|
|
3529
|
-
resetOn: [ActionType.CREATE, ActionType.DECLARE, ActionType.REGISTER]
|
|
3530
|
-
},
|
|
3531
3759
|
{
|
|
3532
3760
|
flag: InherentFlags.REJECTED,
|
|
3533
3761
|
setOn: [ActionType.REJECT],
|
|
@@ -4238,7 +4466,9 @@ function buildClientFunctionContext(input) {
|
|
|
4238
4466
|
// eslint-disable-next-line @typescript-eslint/no-use-before-define
|
|
4239
4467
|
$online: isOnline(),
|
|
4240
4468
|
$user: input.validatorContext?.user,
|
|
4241
|
-
$event: input.validatorContext?.event?.document
|
|
4469
|
+
$event: input.validatorContext?.event?.document ? getEventWithCompleteAcceptedActions(
|
|
4470
|
+
input.validatorContext.event.document
|
|
4471
|
+
) : void 0,
|
|
4242
4472
|
$leafAdminStructureLocationIds: input.validatorContext?.leafAdminStructureLocationIds ?? [],
|
|
4243
4473
|
user: input.systemVariables?.user,
|
|
4244
4474
|
$window: input.systemVariables?.$window,
|
|
@@ -4342,6 +4572,12 @@ function getDeclarationPages(configuration) {
|
|
|
4342
4572
|
function getDeclarationFields(configuration) {
|
|
4343
4573
|
return getDeclarationPages(configuration).flatMap(({ fields }) => fields);
|
|
4344
4574
|
}
|
|
4575
|
+
function findNotificationForm(configuration) {
|
|
4576
|
+
const notifyAction = configuration.actions.find(
|
|
4577
|
+
(action) => action.type === ActionType.NOTIFY
|
|
4578
|
+
);
|
|
4579
|
+
return notifyAction?.type === ActionType.NOTIFY ? notifyAction.notificationForm : void 0;
|
|
4580
|
+
}
|
|
4345
4581
|
var getActionAnnotationFields = (actionConfig) => {
|
|
4346
4582
|
if (actionConfig.type === ActionType.REQUEST_CORRECTION) {
|
|
4347
4583
|
return actionConfig.correctionForm.pages.flatMap(({ fields }) => fields);
|
|
@@ -4356,12 +4592,108 @@ var getActionAnnotationFields = (actionConfig) => {
|
|
|
4356
4592
|
function getAllAnnotationFields(config) {
|
|
4357
4593
|
return (0, import_lodash4.flattenDeep)(config.actions.map(getActionAnnotationFields));
|
|
4358
4594
|
}
|
|
4595
|
+
function deepMerge(currentDocument, actionDocument) {
|
|
4596
|
+
return (0, import_lodash4.mergeWith)(
|
|
4597
|
+
(0, import_lodash4.cloneDeep)(currentDocument),
|
|
4598
|
+
actionDocument,
|
|
4599
|
+
(previousValue, incomingValue) => {
|
|
4600
|
+
if (incomingValue === void 0) {
|
|
4601
|
+
return previousValue;
|
|
4602
|
+
}
|
|
4603
|
+
if ((0, import_lodash4.isArray)(incomingValue)) {
|
|
4604
|
+
return incomingValue;
|
|
4605
|
+
}
|
|
4606
|
+
if ((0, import_lodash4.isObject)(previousValue) && (0, import_lodash4.isObject)(incomingValue)) {
|
|
4607
|
+
return void 0;
|
|
4608
|
+
}
|
|
4609
|
+
return incomingValue;
|
|
4610
|
+
}
|
|
4611
|
+
);
|
|
4612
|
+
}
|
|
4359
4613
|
var findAllFields = (config) => {
|
|
4360
4614
|
return (0, import_lodash4.flattenDeep)([
|
|
4361
4615
|
...getDeclarationFields(config),
|
|
4616
|
+
...findNotificationForm(config)?.pages.flatMap(({ fields }) => fields) ?? [],
|
|
4362
4617
|
...getAllAnnotationFields(config)
|
|
4363
4618
|
]);
|
|
4364
4619
|
};
|
|
4620
|
+
function isAcceptedAction(a) {
|
|
4621
|
+
return a.status === ActionStatus.Accepted;
|
|
4622
|
+
}
|
|
4623
|
+
function getCompleteActionAnnotation(event2, action) {
|
|
4624
|
+
if (action.originalActionId) {
|
|
4625
|
+
const originalAction = event2.actions.find(
|
|
4626
|
+
({ id }) => id === action.originalActionId
|
|
4627
|
+
);
|
|
4628
|
+
if (originalAction?.status === ActionStatus.Requested) {
|
|
4629
|
+
return deepMerge(originalAction.annotation ?? {}, action.annotation ?? {});
|
|
4630
|
+
}
|
|
4631
|
+
}
|
|
4632
|
+
return action.annotation ?? {};
|
|
4633
|
+
}
|
|
4634
|
+
function getCompleteActionContent(event2, action) {
|
|
4635
|
+
const currentContent = "content" in action ? action.content : void 0;
|
|
4636
|
+
if (!action.originalActionId) {
|
|
4637
|
+
return currentContent;
|
|
4638
|
+
}
|
|
4639
|
+
const originalAction = event2.actions.find(
|
|
4640
|
+
({ id }) => id === action.originalActionId
|
|
4641
|
+
);
|
|
4642
|
+
if (originalAction && "content" in originalAction && originalAction.content) {
|
|
4643
|
+
return {
|
|
4644
|
+
...originalAction.content,
|
|
4645
|
+
...currentContent ?? {}
|
|
4646
|
+
};
|
|
4647
|
+
}
|
|
4648
|
+
return currentContent;
|
|
4649
|
+
}
|
|
4650
|
+
function getCompleteActionDeclaration(declaration, event2, action) {
|
|
4651
|
+
if (action.originalActionId) {
|
|
4652
|
+
const originalAction = event2.actions.find(
|
|
4653
|
+
({ id }) => id === action.originalActionId
|
|
4654
|
+
);
|
|
4655
|
+
if (originalAction?.status === ActionStatus.Requested) {
|
|
4656
|
+
return deepMerge(
|
|
4657
|
+
deepMerge(declaration, originalAction.declaration),
|
|
4658
|
+
action.declaration
|
|
4659
|
+
);
|
|
4660
|
+
}
|
|
4661
|
+
}
|
|
4662
|
+
return deepMerge(declaration, action.declaration);
|
|
4663
|
+
}
|
|
4664
|
+
function completeAcceptedAction(event2, action) {
|
|
4665
|
+
return {
|
|
4666
|
+
...action,
|
|
4667
|
+
declaration: getCompleteActionDeclaration({}, event2, action),
|
|
4668
|
+
annotation: getCompleteActionAnnotation(event2, action)
|
|
4669
|
+
};
|
|
4670
|
+
}
|
|
4671
|
+
function getEventWithCompleteAcceptedActions(event2) {
|
|
4672
|
+
return {
|
|
4673
|
+
...event2,
|
|
4674
|
+
actions: event2.actions.map((action) => {
|
|
4675
|
+
if (!isAcceptedAction(action) || !action.originalActionId) {
|
|
4676
|
+
return action;
|
|
4677
|
+
}
|
|
4678
|
+
const requestedAction = event2.actions.find(
|
|
4679
|
+
({ id }) => id === action.originalActionId
|
|
4680
|
+
);
|
|
4681
|
+
if (requestedAction?.status !== ActionStatus.Requested) {
|
|
4682
|
+
return action;
|
|
4683
|
+
}
|
|
4684
|
+
const content = getCompleteActionContent(event2, action);
|
|
4685
|
+
return {
|
|
4686
|
+
...completeAcceptedAction(event2, action),
|
|
4687
|
+
// Who requested the action, as getActionUpdateMetadata resolves it.
|
|
4688
|
+
createdBy: requestedAction.createdBy,
|
|
4689
|
+
createdByRole: requestedAction.createdByRole,
|
|
4690
|
+
createdByUserType: requestedAction.createdByUserType,
|
|
4691
|
+
createdAtLocation: requestedAction.createdAtLocation,
|
|
4692
|
+
...content ? { content } : {}
|
|
4693
|
+
};
|
|
4694
|
+
})
|
|
4695
|
+
};
|
|
4696
|
+
}
|
|
4365
4697
|
var EXCLUDED_ACTIONS = [
|
|
4366
4698
|
ActionType.REQUEST_CORRECTION,
|
|
4367
4699
|
ActionType.PRINT_CERTIFICATE,
|
|
@@ -4369,6 +4701,20 @@ var EXCLUDED_ACTIONS = [
|
|
|
4369
4701
|
];
|
|
4370
4702
|
|
|
4371
4703
|
// ../commons/src/events/eventConfigValidation.ts
|
|
4704
|
+
var SEARCH_DEFAULT_VALUE_FIELD_TYPES = [
|
|
4705
|
+
FieldType.TEXT,
|
|
4706
|
+
FieldType.TEXTAREA,
|
|
4707
|
+
FieldType.EMAIL,
|
|
4708
|
+
FieldType.PHONE,
|
|
4709
|
+
FieldType.ID,
|
|
4710
|
+
FieldType.SELECT,
|
|
4711
|
+
FieldType.RADIO_GROUP,
|
|
4712
|
+
FieldType.COUNTRY,
|
|
4713
|
+
FieldType.LOCATION,
|
|
4714
|
+
FieldType.ADMINISTRATIVE_AREA,
|
|
4715
|
+
FieldType.NUMBER,
|
|
4716
|
+
FieldType.DATE
|
|
4717
|
+
];
|
|
4372
4718
|
function validateAdvancedSearchConfig(event2, ctx) {
|
|
4373
4719
|
const allFields = findAllFields(event2);
|
|
4374
4720
|
const fieldIds = allFields.map((field3) => field3.id);
|
|
@@ -4400,6 +4746,56 @@ function validateAdvancedSearchConfig(event2, ctx) {
|
|
|
4400
4746
|
path: ["advancedSearch"]
|
|
4401
4747
|
});
|
|
4402
4748
|
}
|
|
4749
|
+
event2.advancedSearch.forEach((section, sectionIndex) => {
|
|
4750
|
+
section.fields.forEach((searchField, fieldIndex) => {
|
|
4751
|
+
if (searchField.fieldType !== "field" || searchField.defaultValue === void 0) {
|
|
4752
|
+
return;
|
|
4753
|
+
}
|
|
4754
|
+
const path = [
|
|
4755
|
+
"advancedSearch",
|
|
4756
|
+
sectionIndex,
|
|
4757
|
+
"fields",
|
|
4758
|
+
fieldIndex,
|
|
4759
|
+
"defaultValue"
|
|
4760
|
+
];
|
|
4761
|
+
if (searchField.config.searchFields && searchField.config.searchFields.length > 0) {
|
|
4762
|
+
ctx.addIssue({
|
|
4763
|
+
code: "custom",
|
|
4764
|
+
message: `Advanced search field ${searchField.fieldId} searches across several form fields, so it does not support a defaultValue.`,
|
|
4765
|
+
path
|
|
4766
|
+
});
|
|
4767
|
+
return;
|
|
4768
|
+
}
|
|
4769
|
+
if (typeof searchField.defaultValue === "boolean") {
|
|
4770
|
+
return;
|
|
4771
|
+
}
|
|
4772
|
+
const formField = allFields.find(({ id }) => id === searchField.fieldId);
|
|
4773
|
+
if (!formField) {
|
|
4774
|
+
return;
|
|
4775
|
+
}
|
|
4776
|
+
if (!SEARCH_DEFAULT_VALUE_FIELD_TYPES.some(
|
|
4777
|
+
(type) => type === formField.type
|
|
4778
|
+
)) {
|
|
4779
|
+
ctx.addIssue({
|
|
4780
|
+
code: "custom",
|
|
4781
|
+
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(", ")}.`,
|
|
4782
|
+
path
|
|
4783
|
+
});
|
|
4784
|
+
} else if (formField.type === FieldType.DATE && searchField.config.type === "range") {
|
|
4785
|
+
ctx.addIssue({
|
|
4786
|
+
code: "custom",
|
|
4787
|
+
message: `Advanced search field ${searchField.fieldId} is searched as a date range, so its defaultValue can only be true or false.`,
|
|
4788
|
+
path
|
|
4789
|
+
});
|
|
4790
|
+
} else if (!mapFieldTypeToZod(formField).safeParse(searchField.defaultValue).success) {
|
|
4791
|
+
ctx.addIssue({
|
|
4792
|
+
code: "custom",
|
|
4793
|
+
message: `Advanced search field ${searchField.fieldId} has defaultValue "${searchField.defaultValue}", which is not a valid ${formField.type} value.`,
|
|
4794
|
+
path
|
|
4795
|
+
});
|
|
4796
|
+
}
|
|
4797
|
+
});
|
|
4798
|
+
});
|
|
4403
4799
|
}
|
|
4404
4800
|
function validateDateOfEvent(event2, ctx) {
|
|
4405
4801
|
if (event2.dateOfEvent && isFieldReference(event2.dateOfEvent)) {
|
|
@@ -4523,15 +4919,65 @@ function validateDeclarationGivenExactlyOnce(config, ctx) {
|
|
|
4523
4919
|
});
|
|
4524
4920
|
}
|
|
4525
4921
|
}
|
|
4922
|
+
function validateNotificationForm(event2, ctx) {
|
|
4923
|
+
const declarationFields = getDeclarationPages(event2).flatMap(
|
|
4924
|
+
(page) => page.fields.map((field3) => ({ field: field3, pageId: page.id }))
|
|
4925
|
+
);
|
|
4926
|
+
event2.actions.forEach((action, actionIndex) => {
|
|
4927
|
+
if (action.type !== ActionType.NOTIFY) {
|
|
4928
|
+
return;
|
|
4929
|
+
}
|
|
4930
|
+
action.notificationForm.pages.forEach((page, pageIndex) => {
|
|
4931
|
+
page.fields.forEach((field3, fieldIndex) => {
|
|
4932
|
+
const path = [
|
|
4933
|
+
"actions",
|
|
4934
|
+
actionIndex,
|
|
4935
|
+
"notificationForm",
|
|
4936
|
+
"pages",
|
|
4937
|
+
pageIndex,
|
|
4938
|
+
"fields",
|
|
4939
|
+
fieldIndex
|
|
4940
|
+
];
|
|
4941
|
+
const matchingFields = declarationFields.filter(
|
|
4942
|
+
(declarationField) => declarationField.field.id === field3.id
|
|
4943
|
+
);
|
|
4944
|
+
if (matchingFields.length === 0) {
|
|
4945
|
+
ctx.addIssue({
|
|
4946
|
+
code: "custom",
|
|
4947
|
+
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.`,
|
|
4948
|
+
path
|
|
4949
|
+
});
|
|
4950
|
+
return;
|
|
4951
|
+
}
|
|
4952
|
+
if (!matchingFields.some(
|
|
4953
|
+
(declarationField) => declarationField.field.type === field3.type
|
|
4954
|
+
)) {
|
|
4955
|
+
const [declarationField] = matchingFields;
|
|
4956
|
+
ctx.addIssue({
|
|
4957
|
+
code: "custom",
|
|
4958
|
+
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}.`,
|
|
4959
|
+
path
|
|
4960
|
+
});
|
|
4961
|
+
}
|
|
4962
|
+
});
|
|
4963
|
+
});
|
|
4964
|
+
});
|
|
4965
|
+
}
|
|
4526
4966
|
|
|
4527
4967
|
// ../commons/src/events/EventConfig.ts
|
|
4528
4968
|
var EventFieldReference = z35.object({ $$event: EventMetadataDateFieldIdInput }).describe(
|
|
4529
4969
|
"Reference to a field defined in the event metadata, using the field id."
|
|
4530
4970
|
);
|
|
4531
|
-
var
|
|
4971
|
+
var eventLevelFields = {
|
|
4532
4972
|
id: z35.string().describe(
|
|
4533
4973
|
'Machine-readable identifier of the event (e.g. "birth", "death").'
|
|
4534
4974
|
),
|
|
4975
|
+
label: TranslationConfig.describe("Human-readable label for the event type."),
|
|
4976
|
+
advancedSearch: z35.array(AdvancedSearchConfig).optional().default([]).describe(
|
|
4977
|
+
"Configuration of fields available in the advanced search feature."
|
|
4978
|
+
)
|
|
4979
|
+
};
|
|
4980
|
+
var versionFields = {
|
|
4535
4981
|
dateOfEvent: FieldReference.or(EventFieldReference).optional().describe(
|
|
4536
4982
|
"Reference to the field capturing the date of the event (e.g. date of birth). Defaults to the event creation date if unspecified."
|
|
4537
4983
|
),
|
|
@@ -4547,18 +4993,12 @@ var _EventConfigBase = z35.object({
|
|
|
4547
4993
|
summary: SummaryConfig.describe(
|
|
4548
4994
|
"Summary information displayed in the event overview."
|
|
4549
4995
|
),
|
|
4550
|
-
label: TranslationConfig.describe(
|
|
4551
|
-
"Human-readable label for the event type."
|
|
4552
|
-
),
|
|
4553
4996
|
actions: z35.array(ActionConfig).describe(
|
|
4554
4997
|
"Configuration of core and custom actions associated with the event."
|
|
4555
4998
|
),
|
|
4556
4999
|
actionOrder: z35.array(z35.string()).optional().describe(
|
|
4557
5000
|
"Order of actions in the action menu. Use either the action type for core actions or the customActionType for custom actions."
|
|
4558
5001
|
),
|
|
4559
|
-
advancedSearch: z35.array(AdvancedSearchConfig).optional().default([]).describe(
|
|
4560
|
-
"Configuration of fields available in the advanced search feature."
|
|
4561
|
-
),
|
|
4562
5002
|
flags: z35.array(FlagConfig).optional().default([]).describe(
|
|
4563
5003
|
"Configuration of custom flags associated with the actions of this event type."
|
|
4564
5004
|
),
|
|
@@ -4568,20 +5008,155 @@ var _EventConfigBase = z35.object({
|
|
|
4568
5008
|
icon: z35.partialRecord(AvailableIcons, Conditional).optional().describe(
|
|
4569
5009
|
'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.'
|
|
4570
5010
|
)
|
|
4571
|
-
}
|
|
4572
|
-
var
|
|
5011
|
+
};
|
|
5012
|
+
var _EventConfigBase = z35.object({ ...eventLevelFields, ...versionFields });
|
|
5013
|
+
function validateEventConfig(event2, ctx) {
|
|
4573
5014
|
if (!validateExactlyOneDeclareAction(event2, ctx)) {
|
|
4574
5015
|
return;
|
|
4575
5016
|
}
|
|
5017
|
+
validateNotificationForm(event2, ctx);
|
|
4576
5018
|
validateAdvancedSearchConfig(event2, ctx);
|
|
4577
5019
|
validateDateOfEvent(event2, ctx);
|
|
4578
5020
|
validatePlaceOfEvent(event2, ctx);
|
|
4579
5021
|
validateActionFlags(event2, ctx);
|
|
4580
5022
|
validateActionOrder(event2, ctx);
|
|
4581
|
-
}
|
|
5023
|
+
}
|
|
5024
|
+
var EventConfig2 = _EventConfigBase.superRefine(validateEventConfig).meta({
|
|
4582
5025
|
id: "EventConfig",
|
|
4583
5026
|
description: "Configuration defining an event type registered in OpenCRVS (for example birth or death)."
|
|
4584
5027
|
});
|
|
5028
|
+
var INITIAL_EVENT_CONFIG_VERSION_ID = "initial";
|
|
5029
|
+
var DEFAULT_EFFECTIVE_FROM = "0001-01-01";
|
|
5030
|
+
var _EventConfigVersion = z35.object({
|
|
5031
|
+
id: z35.string().describe(
|
|
5032
|
+
'Identifier of the version, unique within the event (e.g. "birth-v2").'
|
|
5033
|
+
),
|
|
5034
|
+
label: TranslationConfig.describe(
|
|
5035
|
+
'Name of the version, which the UI shows wherever it names the version. For example, "{event.configVersionLabel}" in the event summary.'
|
|
5036
|
+
),
|
|
5037
|
+
effectiveFrom: z35.iso.date().default(DEFAULT_EFFECTIVE_FROM).describe(
|
|
5038
|
+
`Date (YYYY-MM-DD) from which this version is effective. A version without one is effective from the beginning of time ('${DEFAULT_EFFECTIVE_FROM}').`
|
|
5039
|
+
),
|
|
5040
|
+
...versionFields
|
|
5041
|
+
});
|
|
5042
|
+
var resolvedConfigs = /* @__PURE__ */ new WeakMap();
|
|
5043
|
+
function toEventConfig(config, version) {
|
|
5044
|
+
let resolvedVersions = resolvedConfigs.get(config);
|
|
5045
|
+
if (!resolvedVersions) {
|
|
5046
|
+
resolvedVersions = /* @__PURE__ */ new WeakMap();
|
|
5047
|
+
resolvedConfigs.set(config, resolvedVersions);
|
|
5048
|
+
}
|
|
5049
|
+
const cached = resolvedVersions.get(version);
|
|
5050
|
+
if (cached) {
|
|
5051
|
+
return cached;
|
|
5052
|
+
}
|
|
5053
|
+
const {
|
|
5054
|
+
id: _id,
|
|
5055
|
+
label: _label,
|
|
5056
|
+
effectiveFrom: _effectiveFrom,
|
|
5057
|
+
...fields
|
|
5058
|
+
} = version;
|
|
5059
|
+
const resolved = {
|
|
5060
|
+
...fields,
|
|
5061
|
+
id: config.id,
|
|
5062
|
+
label: config.label,
|
|
5063
|
+
advancedSearch: config.advancedSearch
|
|
5064
|
+
};
|
|
5065
|
+
resolvedVersions.set(version, resolved);
|
|
5066
|
+
return resolved;
|
|
5067
|
+
}
|
|
5068
|
+
function byEffectiveFrom(a, b) {
|
|
5069
|
+
return a.effectiveFrom.localeCompare(b.effectiveFrom);
|
|
5070
|
+
}
|
|
5071
|
+
function getVersionsInEffectOn(config, date) {
|
|
5072
|
+
return config.versions.filter(({ effectiveFrom }) => effectiveFrom <= date).sort(byEffectiveFrom);
|
|
5073
|
+
}
|
|
5074
|
+
function findVersionInEffectOn(config, date) {
|
|
5075
|
+
return getVersionsInEffectOn(config, date).at(-1);
|
|
5076
|
+
}
|
|
5077
|
+
function resolveEventConfigOnDate(config, date) {
|
|
5078
|
+
return toEventConfig(
|
|
5079
|
+
config,
|
|
5080
|
+
getOrThrow(
|
|
5081
|
+
findVersionInEffectOn(config, date),
|
|
5082
|
+
`Event '${config.id}' has no version in effect on ${date}`
|
|
5083
|
+
)
|
|
5084
|
+
);
|
|
5085
|
+
}
|
|
5086
|
+
function resolveEventConfigInTimeZone(config, timeZone, now2 = /* @__PURE__ */ new Date()) {
|
|
5087
|
+
return resolveEventConfigOnDate(config, toPlainDateInTimeZone(now2, timeZone));
|
|
5088
|
+
}
|
|
5089
|
+
function resolveEventConfig(config) {
|
|
5090
|
+
return resolveEventConfigInTimeZone(config, "UTC");
|
|
5091
|
+
}
|
|
5092
|
+
function validateVersionList(config, ctx) {
|
|
5093
|
+
const ids = /* @__PURE__ */ new Set();
|
|
5094
|
+
const versionIdByEffectiveFrom = /* @__PURE__ */ new Map();
|
|
5095
|
+
config.versions.forEach((version, index) => {
|
|
5096
|
+
if (ids.has(version.id)) {
|
|
5097
|
+
ctx.addIssue({
|
|
5098
|
+
code: "custom",
|
|
5099
|
+
message: `Event '${config.id}' has more than one version with id '${version.id}'. Each version must have a different id.`,
|
|
5100
|
+
path: ["versions", index, "id"]
|
|
5101
|
+
});
|
|
5102
|
+
}
|
|
5103
|
+
ids.add(version.id);
|
|
5104
|
+
const sameEffectiveFromId = versionIdByEffectiveFrom.get(
|
|
5105
|
+
version.effectiveFrom
|
|
5106
|
+
);
|
|
5107
|
+
if (sameEffectiveFromId !== void 0) {
|
|
5108
|
+
const versionIds = `'${sameEffectiveFromId}', '${version.id}'`;
|
|
5109
|
+
ctx.addIssue({
|
|
5110
|
+
code: "custom",
|
|
5111
|
+
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.`,
|
|
5112
|
+
path: ["versions", index, "effectiveFrom"]
|
|
5113
|
+
});
|
|
5114
|
+
} else {
|
|
5115
|
+
versionIdByEffectiveFrom.set(version.effectiveFrom, version.id);
|
|
5116
|
+
}
|
|
5117
|
+
});
|
|
5118
|
+
}
|
|
5119
|
+
function validateEachVersion(ctx, events, validate2) {
|
|
5120
|
+
const reported = /* @__PURE__ */ new Set();
|
|
5121
|
+
events.forEach((event2, index) => {
|
|
5122
|
+
const addIssue = (issue) => {
|
|
5123
|
+
if (typeof issue === "string") {
|
|
5124
|
+
ctx.addIssue({
|
|
5125
|
+
code: "custom",
|
|
5126
|
+
message: issue,
|
|
5127
|
+
path: ["versions", index]
|
|
5128
|
+
});
|
|
5129
|
+
return;
|
|
5130
|
+
}
|
|
5131
|
+
const [field3] = issue.path ?? [];
|
|
5132
|
+
const isEventLevel = typeof field3 === "string" && field3 in eventLevelFields;
|
|
5133
|
+
const path = isEventLevel ? issue.path ?? [] : ["versions", index, ...issue.path ?? []];
|
|
5134
|
+
const key = JSON.stringify([path, issue.message]);
|
|
5135
|
+
if (reported.has(key)) {
|
|
5136
|
+
return;
|
|
5137
|
+
}
|
|
5138
|
+
reported.add(key);
|
|
5139
|
+
ctx.addIssue({ ...issue, path });
|
|
5140
|
+
};
|
|
5141
|
+
validate2(event2, { value: event2, addIssue });
|
|
5142
|
+
});
|
|
5143
|
+
}
|
|
5144
|
+
var VersionedEventConfig2 = z35.object({
|
|
5145
|
+
...eventLevelFields,
|
|
5146
|
+
versions: z35.array(_EventConfigVersion).min(1).describe(
|
|
5147
|
+
`Versions of the event configuration, each effective from its \`effectiveFrom\`. An event configured without versions has a single version, with id '${INITIAL_EVENT_CONFIG_VERSION_ID}' and \`effectiveFrom\` '${DEFAULT_EFFECTIVE_FROM}'.`
|
|
5148
|
+
)
|
|
5149
|
+
}).superRefine((config, ctx) => {
|
|
5150
|
+
validateVersionList(config, ctx);
|
|
5151
|
+
validateEachVersion(
|
|
5152
|
+
ctx,
|
|
5153
|
+
config.versions.map((version) => toEventConfig(config, version)),
|
|
5154
|
+
validateEventConfig
|
|
5155
|
+
);
|
|
5156
|
+
}).meta({
|
|
5157
|
+
id: "VersionedEventConfig",
|
|
5158
|
+
description: "Configuration of an event type registered in OpenCRVS (for example birth or death), with every version of it."
|
|
5159
|
+
});
|
|
4585
5160
|
|
|
4586
5161
|
// ../commons/src/events/EventConfigInput.ts
|
|
4587
5162
|
var defineDeclarationForm = (form) => DeclarationFormConfig.parse(form);
|
|
@@ -4653,7 +5228,7 @@ function createSearchConfig(baseField) {
|
|
|
4653
5228
|
|
|
4654
5229
|
// ../commons/src/event-config/event-configuration.ts
|
|
4655
5230
|
function isNonSearchableEventMetadataTimeFieldId(fieldId) {
|
|
4656
|
-
return !EventFieldIdInput.
|
|
5231
|
+
return !EventFieldIdInput.validate(fieldId);
|
|
4657
5232
|
}
|
|
4658
5233
|
function createEventFieldConfig(fieldId) {
|
|
4659
5234
|
const baseField = {
|
|
@@ -4680,7 +5255,10 @@ function eventFn(fieldId) {
|
|
|
4680
5255
|
}
|
|
4681
5256
|
var event = Object.assign(eventFn, {
|
|
4682
5257
|
/**
|
|
4683
|
-
* Checks if the event contains a specific action type.
|
|
5258
|
+
* Checks if the event contains a specific accepted action type.
|
|
5259
|
+
* Only Accepted actions are matched: a confirmable action is stored as a
|
|
5260
|
+
* Requested and an Accepted action, and a pending or rejected request must
|
|
5261
|
+
* not count as the action having happened.
|
|
4684
5262
|
* Can be used directly as a conditional or chained with additional methods.
|
|
4685
5263
|
* @param action - The action type to check for.
|
|
4686
5264
|
*/
|
|
@@ -4698,9 +5276,12 @@ var event = Object.assign(eventFn, {
|
|
|
4698
5276
|
properties: {
|
|
4699
5277
|
type: {
|
|
4700
5278
|
const: action
|
|
5279
|
+
},
|
|
5280
|
+
status: {
|
|
5281
|
+
const: ActionStatus.Accepted
|
|
4701
5282
|
}
|
|
4702
5283
|
},
|
|
4703
|
-
required: ["type"]
|
|
5284
|
+
required: ["type", "status"]
|
|
4704
5285
|
}
|
|
4705
5286
|
}
|
|
4706
5287
|
},
|
|
@@ -4711,9 +5292,10 @@ var event = Object.assign(eventFn, {
|
|
|
4711
5292
|
});
|
|
4712
5293
|
const buildActionConstraints = (additionalFields) => {
|
|
4713
5294
|
const actionProperties = {
|
|
4714
|
-
type: { const: action }
|
|
5295
|
+
type: { const: action },
|
|
5296
|
+
status: { const: ActionStatus.Accepted }
|
|
4715
5297
|
};
|
|
4716
|
-
const requiredFields = ["type"];
|
|
5298
|
+
const requiredFields = ["type", "status"];
|
|
4717
5299
|
if (additionalFields) {
|
|
4718
5300
|
Object.entries(additionalFields).forEach(([key, value]) => {
|
|
4719
5301
|
actionProperties[key] = { const: value };
|
|
@@ -4835,7 +5417,7 @@ var SerializableWithin = z37.object({
|
|
|
4835
5417
|
});
|
|
4836
5418
|
var SerializedQueryExpression = z37.object({
|
|
4837
5419
|
eventType: z37.string(),
|
|
4838
|
-
status: z37.optional(z37.union([AnyOfStatus, ExactStatus])),
|
|
5420
|
+
status: z37.optional(z37.union([AnyOfStatus, NoneOfStatus, ExactStatus])),
|
|
4839
5421
|
createdAt: z37.optional(DateCondition),
|
|
4840
5422
|
updatedAt: z37.optional(DateCondition),
|
|
4841
5423
|
"legalStatuses.DECLARED.createdAtLocation": z37.optional(SerializableWithin),
|
|
@@ -4844,6 +5426,7 @@ var SerializedQueryExpression = z37.object({
|
|
|
4844
5426
|
"legalStatuses.REGISTERED.createdAtLocation": z37.optional(SerializableWithin),
|
|
4845
5427
|
"legalStatuses.REGISTERED.createdByRole": z37.optional(AnyOf),
|
|
4846
5428
|
"legalStatuses.REGISTERED.registrationNumber": z37.optional(Exact),
|
|
5429
|
+
"legalStatuses.REVOKED.createdAtLocation": z37.optional(SerializableWithin),
|
|
4847
5430
|
createdAtLocation: z37.optional(
|
|
4848
5431
|
z37.union([SerializableWithin, SerializableExact])
|
|
4849
5432
|
),
|
|
@@ -4983,6 +5566,12 @@ var RegisterActionInput = BaseActionInput.extend(
|
|
|
4983
5566
|
var NotifyActionInput = BaseActionInput.extend(
|
|
4984
5567
|
z39.object({
|
|
4985
5568
|
type: z39.literal(ActionType.NOTIFY).default(ActionType.NOTIFY),
|
|
5569
|
+
declaration: BaseActionInput.shape.declaration.describe(
|
|
5570
|
+
"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."
|
|
5571
|
+
),
|
|
5572
|
+
annotation: BaseActionInput.shape.annotation.describe(
|
|
5573
|
+
"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."
|
|
5574
|
+
),
|
|
4986
5575
|
// For normal users, the createdAtLocation is resolved on the backend from the user's primaryOfficeId.
|
|
4987
5576
|
createdAtLocation: UUID.nullish().describe(
|
|
4988
5577
|
"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."
|
|
@@ -5055,6 +5644,16 @@ var UnarchiveActionInput = BaseActionInput.extend(
|
|
|
5055
5644
|
type: z39.literal(ActionType.UNARCHIVE).default(ActionType.UNARCHIVE)
|
|
5056
5645
|
}).shape
|
|
5057
5646
|
);
|
|
5647
|
+
var RevokeRegistrationActionInput = BaseActionInput.extend(
|
|
5648
|
+
z39.object({
|
|
5649
|
+
type: z39.literal(ActionType.REVOKE_REGISTRATION).default(ActionType.REVOKE_REGISTRATION)
|
|
5650
|
+
}).shape
|
|
5651
|
+
);
|
|
5652
|
+
var ReinstateRegistrationActionInput = BaseActionInput.extend(
|
|
5653
|
+
z39.object({
|
|
5654
|
+
type: z39.literal(ActionType.REINSTATE_REGISTRATION).default(ActionType.REINSTATE_REGISTRATION)
|
|
5655
|
+
}).shape
|
|
5656
|
+
);
|
|
5058
5657
|
var AssignActionInput = BaseActionInput.extend(
|
|
5059
5658
|
z39.object({
|
|
5060
5659
|
type: z39.literal(ActionType.ASSIGN),
|
|
@@ -5117,6 +5716,12 @@ var ActionInput = z39.discriminatedUnion("type", [
|
|
|
5117
5716
|
}),
|
|
5118
5717
|
ArchiveActionInput.meta({ id: "ArchiveActionInput" }),
|
|
5119
5718
|
UnarchiveActionInput.meta({ id: "UnarchiveActionInput" }),
|
|
5719
|
+
RevokeRegistrationActionInput.meta({
|
|
5720
|
+
id: "RevokeRegistrationActionInput"
|
|
5721
|
+
}),
|
|
5722
|
+
ReinstateRegistrationActionInput.meta({
|
|
5723
|
+
id: "ReinstateRegistrationActionInput"
|
|
5724
|
+
}),
|
|
5120
5725
|
AssignActionInput.meta({ id: "AssignActionInput" }),
|
|
5121
5726
|
UnassignActionInput.meta({ id: "UnassignActionInput" }),
|
|
5122
5727
|
PrintCertificateActionInput.meta({ id: "PrintCertificateActionInput" }),
|
|
@@ -5150,17 +5755,19 @@ var DraftInput = BaseActionInput.omit({ waitFor: true }).extend({
|
|
|
5150
5755
|
/*
|
|
5151
5756
|
* A draft can name a file that no action references. Such a file stays until
|
|
5152
5757
|
* the record is deleted or the record's next action sweeps its prefix.
|
|
5153
|
-
*
|
|
5154
|
-
*
|
|
5155
|
-
* which is about to be declared or registered.
|
|
5758
|
+
* Drafts are therefore saved only on a created record, which can still be deleted.
|
|
5759
|
+
* The server refuses them on any other record.
|
|
5156
5760
|
*/
|
|
5157
|
-
type: z40.
|
|
5761
|
+
type: z40.enum([ActionTypes.enum.DECLARE, ActionTypes.enum.NOTIFY]),
|
|
5158
5762
|
status: z40.enum([
|
|
5159
5763
|
ActionStatus.Requested,
|
|
5160
5764
|
ActionStatus.Accepted,
|
|
5161
5765
|
ActionStatus.Rejected
|
|
5162
5766
|
])
|
|
5163
5767
|
});
|
|
5768
|
+
var RemoteDraft = Draft.extend({
|
|
5769
|
+
action: Draft.shape.action.extend({ type: DraftInput.shape.type })
|
|
5770
|
+
});
|
|
5164
5771
|
|
|
5165
5772
|
// ../commons/src/events/EventInput.ts
|
|
5166
5773
|
var z41 = __toESM(require("zod/v4"));
|
|
@@ -5170,6 +5777,9 @@ var EventInput = z41.object({
|
|
|
5170
5777
|
type: z41.string(),
|
|
5171
5778
|
createdAtLocation: UUID.nullish().describe(
|
|
5172
5779
|
"Location where the event occurred. Required for system users."
|
|
5780
|
+
),
|
|
5781
|
+
configVersionId: z41.string().optional().describe(
|
|
5782
|
+
"Id of the event configuration version the client created the record under, e.g. while offline. Must be configured and not take effect in the future. Defaults to the version in effect when the server receives the record."
|
|
5173
5783
|
)
|
|
5174
5784
|
}).meta({ default: { transactionId: (0, import_uuid11.v4)(), type: "birth" } });
|
|
5175
5785
|
|
|
@@ -5185,6 +5795,9 @@ var EventDocument = z42.object({
|
|
|
5185
5795
|
actions: z42.array(Action).describe("Ordered list of actions associated with the event."),
|
|
5186
5796
|
trackingId: z42.string().describe(
|
|
5187
5797
|
"System-generated tracking identifier used to look up the event."
|
|
5798
|
+
),
|
|
5799
|
+
configVersionId: z42.string().describe(
|
|
5800
|
+
"Id of the event configuration version the record was created under. Every action on the record uses that version. Records created before versioning have 'initial'."
|
|
5188
5801
|
)
|
|
5189
5802
|
}).meta({ id: "EventDocument" });
|
|
5190
5803
|
var EventDocumentOnlyLastAction = EventDocument.extend({
|
|
@@ -5204,18 +5817,103 @@ function moveDeclarationToDeclareAction({
|
|
|
5204
5817
|
}
|
|
5205
5818
|
return {
|
|
5206
5819
|
...config,
|
|
5207
|
-
actions: config.actions.map(
|
|
5208
|
-
(action
|
|
5209
|
-
|
|
5820
|
+
actions: config.actions.map((action) => {
|
|
5821
|
+
if (action.type !== ActionType.DECLARE) {
|
|
5822
|
+
return action;
|
|
5823
|
+
}
|
|
5824
|
+
const declarationOfAction = action.declaration ?? declaration;
|
|
5825
|
+
if (!declarationOfAction) {
|
|
5826
|
+
throw new Error(`Event '${config.id}' does not define \`declaration\`.`);
|
|
5827
|
+
}
|
|
5828
|
+
return { ...action, declaration: declarationOfAction };
|
|
5829
|
+
})
|
|
5210
5830
|
};
|
|
5211
5831
|
}
|
|
5832
|
+
var VERSIONED_EVENT_FIELDS = [
|
|
5833
|
+
"id",
|
|
5834
|
+
"label",
|
|
5835
|
+
"advancedSearch",
|
|
5836
|
+
"versions"
|
|
5837
|
+
];
|
|
5838
|
+
function validateNoVersionFieldsAtTopLevel(config, ctx) {
|
|
5839
|
+
Object.keys(config).filter((key) => !VERSIONED_EVENT_FIELDS.includes(key)).forEach((key) => {
|
|
5840
|
+
ctx.addIssue({
|
|
5841
|
+
code: "custom",
|
|
5842
|
+
message: `Event '${config.id}' defines \`versions\`, so \`${key}\` must be defined on each version, not at the top level.`,
|
|
5843
|
+
path: [key]
|
|
5844
|
+
});
|
|
5845
|
+
});
|
|
5846
|
+
}
|
|
5847
|
+
function toVersionedInput(config) {
|
|
5848
|
+
if ("versions" in config) {
|
|
5849
|
+
return config;
|
|
5850
|
+
}
|
|
5851
|
+
const { id, label, advancedSearch, ...version } = moveDeclarationToDeclareAction(config);
|
|
5852
|
+
return {
|
|
5853
|
+
id,
|
|
5854
|
+
label,
|
|
5855
|
+
advancedSearch,
|
|
5856
|
+
versions: [{ ...version, id: INITIAL_EVENT_CONFIG_VERSION_ID, label }]
|
|
5857
|
+
};
|
|
5858
|
+
}
|
|
5859
|
+
var WESTERNMOST_TIME_ZONE = "Etc/GMT+12";
|
|
5860
|
+
function validateVersionInEffectToday(config, ctx) {
|
|
5861
|
+
const today = toPlainDateInTimeZone(/* @__PURE__ */ new Date(), WESTERNMOST_TIME_ZONE);
|
|
5862
|
+
const isAnyVersionInEffect = config.versions.some(
|
|
5863
|
+
({ effectiveFrom }) => effectiveFrom <= today
|
|
5864
|
+
);
|
|
5865
|
+
if (!isAnyVersionInEffect) {
|
|
5866
|
+
ctx.addIssue({
|
|
5867
|
+
code: "custom",
|
|
5868
|
+
message: `Event '${config.id}' has no version in effect today (${today}, UTC\u221212, the last time zone to begin the day). At least one version must omit \`effectiveFrom\` or take effect on or before that date.`,
|
|
5869
|
+
path: ["versions"]
|
|
5870
|
+
});
|
|
5871
|
+
}
|
|
5872
|
+
}
|
|
5212
5873
|
var EventConfigDefinition = z43.custom().superRefine((config, ctx) => {
|
|
5213
|
-
if (
|
|
5214
|
-
|
|
5874
|
+
if ("versions" in config) {
|
|
5875
|
+
validateNoVersionFieldsAtTopLevel(config, ctx);
|
|
5876
|
+
return;
|
|
5877
|
+
}
|
|
5878
|
+
const eventCtx = { ...ctx, value: config };
|
|
5879
|
+
if (validateExactlyOneDeclareAction(config, eventCtx)) {
|
|
5880
|
+
validateDeclarationGivenExactlyOnce(config, eventCtx);
|
|
5215
5881
|
}
|
|
5216
|
-
}).transform(
|
|
5882
|
+
}).transform(toVersionedInput).pipe(VersionedEventConfig2).superRefine(validateVersionInEffectToday);
|
|
5217
5883
|
var defineConfig = (config) => EventConfigDefinition.parse(config);
|
|
5218
5884
|
|
|
5885
|
+
// ../commons/src/events/toNotificationForm.ts
|
|
5886
|
+
function toOptionalField(field3) {
|
|
5887
|
+
const { validation: _validation, ...rest } = field3;
|
|
5888
|
+
if (rest.type === FieldType.FIELD_GROUP && "fields" in rest) {
|
|
5889
|
+
return {
|
|
5890
|
+
...rest,
|
|
5891
|
+
required: false,
|
|
5892
|
+
fields: rest.fields.map(toOptionalField)
|
|
5893
|
+
};
|
|
5894
|
+
}
|
|
5895
|
+
return { ...rest, required: false };
|
|
5896
|
+
}
|
|
5897
|
+
function toNotificationForm(declaration) {
|
|
5898
|
+
return {
|
|
5899
|
+
...declaration,
|
|
5900
|
+
pages: declaration.pages.map((page) => ({
|
|
5901
|
+
...page,
|
|
5902
|
+
fields: page.fields.map(
|
|
5903
|
+
toOptionalField
|
|
5904
|
+
)
|
|
5905
|
+
}))
|
|
5906
|
+
};
|
|
5907
|
+
}
|
|
5908
|
+
function toNotificationReview(review) {
|
|
5909
|
+
return {
|
|
5910
|
+
...review,
|
|
5911
|
+
fields: review.fields.map(
|
|
5912
|
+
toOptionalField
|
|
5913
|
+
)
|
|
5914
|
+
};
|
|
5915
|
+
}
|
|
5916
|
+
|
|
5219
5917
|
// ../commons/src/events/test.utils.ts
|
|
5220
5918
|
var import_lodash5 = require("lodash");
|
|
5221
5919
|
var import_date_fns4 = require("date-fns");
|
|
@@ -6464,7 +7162,7 @@ var TENNIS_CLUB_DECLARATION_FORM = defineDeclarationForm({
|
|
|
6464
7162
|
});
|
|
6465
7163
|
|
|
6466
7164
|
// ../commons/src/fixtures/tennis-club-membership-event.ts
|
|
6467
|
-
var
|
|
7165
|
+
var versionedTennisClubMembershipEvent = defineConfig({
|
|
6468
7166
|
id: TENNIS_CLUB_MEMBERSHIP,
|
|
6469
7167
|
declaration: TENNIS_CLUB_DECLARATION_FORM,
|
|
6470
7168
|
label: {
|
|
@@ -6523,6 +7221,8 @@ var tennisClubMembershipEvent = defineConfig({
|
|
|
6523
7221
|
description: "This is shown as the action name anywhere the user can trigger the action from",
|
|
6524
7222
|
id: "event.tennis-club-membership.action.notify.label"
|
|
6525
7223
|
},
|
|
7224
|
+
notificationForm: toNotificationForm(TENNIS_CLUB_DECLARATION_FORM),
|
|
7225
|
+
review: toNotificationReview(TENNIS_CLUB_DECLARATION_REVIEW),
|
|
6526
7226
|
flags: [
|
|
6527
7227
|
{
|
|
6528
7228
|
id: "health-worker-notified",
|
|
@@ -6819,9 +7519,12 @@ var tennisClubMembershipEvent = defineConfig({
|
|
|
6819
7519
|
}
|
|
6820
7520
|
]
|
|
6821
7521
|
});
|
|
7522
|
+
var tennisClubMembershipEvent = resolveEventConfig(
|
|
7523
|
+
versionedTennisClubMembershipEvent
|
|
7524
|
+
);
|
|
6822
7525
|
|
|
6823
7526
|
// ../commons/src/fixtures/football-club-membership-event.ts
|
|
6824
|
-
var
|
|
7527
|
+
var versionedFootballClubMembershipEvent = defineConfig({
|
|
6825
7528
|
id: "FOOTBALL_CLUB_MEMBERSHIP",
|
|
6826
7529
|
label: {
|
|
6827
7530
|
defaultMessage: "Football club membership application",
|
|
@@ -7144,6 +7847,9 @@ var footballClubMembershipEvent = defineConfig({
|
|
|
7144
7847
|
],
|
|
7145
7848
|
declaration: TENNIS_CLUB_DECLARATION_FORM
|
|
7146
7849
|
});
|
|
7850
|
+
var footballClubMembershipEvent = resolveEventConfig(
|
|
7851
|
+
versionedFootballClubMembershipEvent
|
|
7852
|
+
);
|
|
7147
7853
|
|
|
7148
7854
|
// ../commons/src/fixtures/library-membership-event.ts
|
|
7149
7855
|
var libraryMembershipForm = defineDeclarationForm({
|
|
@@ -7187,7 +7893,7 @@ var libraryMembershipForm = defineDeclarationForm({
|
|
|
7187
7893
|
}
|
|
7188
7894
|
]
|
|
7189
7895
|
});
|
|
7190
|
-
var
|
|
7896
|
+
var versionedLibraryMembershipEvent = defineConfig({
|
|
7191
7897
|
id: "library-membership",
|
|
7192
7898
|
label: {
|
|
7193
7899
|
defaultMessage: "Library membership application",
|
|
@@ -7220,6 +7926,9 @@ var libraryMembershipEvent = defineConfig({
|
|
|
7220
7926
|
],
|
|
7221
7927
|
declaration: libraryMembershipForm
|
|
7222
7928
|
});
|
|
7929
|
+
var libraryMembershipEvent = resolveEventConfig(
|
|
7930
|
+
versionedLibraryMembershipEvent
|
|
7931
|
+
);
|
|
7223
7932
|
|
|
7224
7933
|
// ../commons/src/fixtures/child-onboarding-event.ts
|
|
7225
7934
|
function generateTranslationConfig(message) {
|
|
@@ -7433,7 +8142,7 @@ var CHILD_ONBOARDING_DECLARATION_FORM = defineDeclarationForm({
|
|
|
7433
8142
|
label: generateTranslationConfig("Birth decalration form"),
|
|
7434
8143
|
pages: [child, mother]
|
|
7435
8144
|
});
|
|
7436
|
-
var
|
|
8145
|
+
var versionedChildOnboardingEvent = defineConfig({
|
|
7437
8146
|
id: CHILD_ONBOARDING_EVENT,
|
|
7438
8147
|
title: generateTranslationConfig(
|
|
7439
8148
|
"{child.name.firstname} {child.name.surname}"
|
|
@@ -7461,6 +8170,9 @@ var ChildOnboardingEvent = defineConfig({
|
|
|
7461
8170
|
],
|
|
7462
8171
|
advancedSearch: []
|
|
7463
8172
|
});
|
|
8173
|
+
var ChildOnboardingEvent = resolveEventConfig(
|
|
8174
|
+
versionedChildOnboardingEvent
|
|
8175
|
+
);
|
|
7464
8176
|
|
|
7465
8177
|
// ../commons/src/fixtures/digital-identity-issuance-event.ts
|
|
7466
8178
|
var PRINT_DIGITAL_ID_CERTIFICATE_FORM = defineActionForm({
|
|
@@ -7649,7 +8361,7 @@ var digitalIdentityForm = defineDeclarationForm({
|
|
|
7649
8361
|
}
|
|
7650
8362
|
]
|
|
7651
8363
|
});
|
|
7652
|
-
var
|
|
8364
|
+
var versionedDigitalIdentityEvent = defineConfig({
|
|
7653
8365
|
id: "digital-identity",
|
|
7654
8366
|
label: {
|
|
7655
8367
|
defaultMessage: "Digital identity issuance",
|
|
@@ -7691,6 +8403,9 @@ var digitalIdentityEvent = defineConfig({
|
|
|
7691
8403
|
],
|
|
7692
8404
|
declaration: digitalIdentityForm
|
|
7693
8405
|
});
|
|
8406
|
+
var digitalIdentityEvent = resolveEventConfig(
|
|
8407
|
+
versionedDigitalIdentityEvent
|
|
8408
|
+
);
|
|
7694
8409
|
|
|
7695
8410
|
// ../commons/src/events/test.utils.ts
|
|
7696
8411
|
var z45 = __toESM(require("zod/v4"));
|
|
@@ -8157,8 +8872,12 @@ var ACTION_SCOPE_MAP = {
|
|
|
8157
8872
|
"record.correct"
|
|
8158
8873
|
],
|
|
8159
8874
|
[ClientSpecificAction.REVIEW_CORRECTION_REQUEST]: ["record.correct"],
|
|
8875
|
+
// Not granted by a scope: the client checks the draft's own action instead
|
|
8876
|
+
[ClientSpecificAction.CONTINUE_DRAFT]: [],
|
|
8160
8877
|
[ActionType.REJECT_CORRECTION]: ["record.correct"],
|
|
8161
8878
|
[ActionType.APPROVE_CORRECTION]: ["record.correct"],
|
|
8879
|
+
[ActionType.REVOKE_REGISTRATION]: ["record.revoke-registration"],
|
|
8880
|
+
[ActionType.REINSTATE_REGISTRATION]: ["record.reinstate-registration"],
|
|
8162
8881
|
[ActionType.MARK_AS_DUPLICATE]: ["record.review-duplicates"],
|
|
8163
8882
|
[ActionType.MARK_AS_NOT_DUPLICATE]: ["record.review-duplicates"],
|
|
8164
8883
|
[ActionType.ARCHIVE]: ["record.archive"],
|
|
@@ -8205,7 +8924,12 @@ var AVAILABLE_ACTIONS_BY_EVENT_STATUS = {
|
|
|
8205
8924
|
ActionType.APPROVE_CORRECTION,
|
|
8206
8925
|
ActionType.REJECT_CORRECTION,
|
|
8207
8926
|
ActionType.CUSTOM,
|
|
8208
|
-
ClientSpecificAction.REVIEW_CORRECTION_REQUEST
|
|
8927
|
+
ClientSpecificAction.REVIEW_CORRECTION_REQUEST,
|
|
8928
|
+
ActionType.REVOKE_REGISTRATION
|
|
8929
|
+
],
|
|
8930
|
+
[EventStatus.enum.REVOKED]: [
|
|
8931
|
+
ActionType.READ,
|
|
8932
|
+
ActionType.REINSTATE_REGISTRATION
|
|
8209
8933
|
],
|
|
8210
8934
|
[EventStatus.enum.ARCHIVED]: [
|
|
8211
8935
|
ActionType.READ,
|
|
@@ -8219,6 +8943,8 @@ var ACTION_FILTERS = {
|
|
|
8219
8943
|
[ClientSpecificAction.REVIEW_CORRECTION_REQUEST]: (flags) => flags.includes(InherentFlags.CORRECTION_REQUESTED) && !flags.some((flag2) => flag2.endsWith(":requested")),
|
|
8220
8944
|
[ActionType.APPROVE_CORRECTION]: (flags) => flags.includes(InherentFlags.CORRECTION_REQUESTED) && !flags.some((flag2) => flag2.endsWith(":requested")),
|
|
8221
8945
|
[ActionType.REJECT_CORRECTION]: (flags) => flags.includes(InherentFlags.CORRECTION_REQUESTED) && !flags.some((flag2) => flag2.endsWith(":requested")),
|
|
8946
|
+
[ActionType.REVOKE_REGISTRATION]: (flags) => !flags.includes(InherentFlags.CORRECTION_REQUESTED) && !flags.some((flag2) => flag2.endsWith(":requested")),
|
|
8947
|
+
[ActionType.REINSTATE_REGISTRATION]: (flags) => !flags.some((flag2) => flag2.endsWith(":requested")),
|
|
8222
8948
|
[ActionType.MARK_AS_DUPLICATE]: (flags) => flags.includes(InherentFlags.POTENTIAL_DUPLICATE) && !flags.some((flag2) => flag2.endsWith(":requested")),
|
|
8223
8949
|
[ActionType.EDIT]: (flags) => !flags.includes(InherentFlags.POTENTIAL_DUPLICATE) && !flags.some((flag2) => flag2.endsWith(":requested")),
|
|
8224
8950
|
[ActionType.REGISTER]: (flags) => !flags.includes(InherentFlags.POTENTIAL_DUPLICATE) && !flags.some((flag2) => flag2.endsWith(":requested")),
|