@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
|
@@ -38,7 +38,10 @@ __export(notification_exports, {
|
|
|
38
38
|
triggerUserEventNotification: () => triggerUserEventNotification
|
|
39
39
|
});
|
|
40
40
|
module.exports = __toCommonJS(notification_exports);
|
|
41
|
-
var
|
|
41
|
+
var z48 = __toESM(require("zod/v4"));
|
|
42
|
+
|
|
43
|
+
// ../commons/src/events/index.ts
|
|
44
|
+
var import_compile = require("zod/compile");
|
|
42
45
|
|
|
43
46
|
// ../commons/src/events/AuditLog.ts
|
|
44
47
|
var z9 = __toESM(require("zod/v4"));
|
|
@@ -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,6 +326,7 @@ var EventStatus = z6.enum([
|
|
|
314
326
|
"NOTIFIED",
|
|
315
327
|
"DECLARED",
|
|
316
328
|
"REGISTERED",
|
|
329
|
+
"REVOKED",
|
|
317
330
|
"ARCHIVED"
|
|
318
331
|
]);
|
|
319
332
|
|
|
@@ -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
|
]);
|
|
@@ -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"
|
|
@@ -1197,7 +1216,7 @@ function safeUnion(schemas) {
|
|
|
1197
1216
|
);
|
|
1198
1217
|
return z14.any().superRefine((val, ctx) => {
|
|
1199
1218
|
for (const schema of sortedSchemas) {
|
|
1200
|
-
if (schema.
|
|
1219
|
+
if (schema.validate(val)) {
|
|
1201
1220
|
return;
|
|
1202
1221
|
}
|
|
1203
1222
|
}
|
|
@@ -1391,6 +1410,16 @@ var UnarchiveAction = ActionBase.extend(
|
|
|
1391
1410
|
type: z16.literal(ActionType.UNARCHIVE)
|
|
1392
1411
|
}).shape
|
|
1393
1412
|
);
|
|
1413
|
+
var RevokeRegistrationAction = ActionBase.extend(
|
|
1414
|
+
z16.object({
|
|
1415
|
+
type: z16.literal(ActionType.REVOKE_REGISTRATION)
|
|
1416
|
+
}).shape
|
|
1417
|
+
);
|
|
1418
|
+
var ReinstateRegistrationAction = ActionBase.extend(
|
|
1419
|
+
z16.object({
|
|
1420
|
+
type: z16.literal(ActionType.REINSTATE_REGISTRATION)
|
|
1421
|
+
}).shape
|
|
1422
|
+
);
|
|
1394
1423
|
var CreatedAction = ActionBase.extend(
|
|
1395
1424
|
z16.object({
|
|
1396
1425
|
type: z16.literal(ActionType.CREATE)
|
|
@@ -1459,6 +1488,8 @@ var ActionDocument = z16.discriminatedUnion("type", [
|
|
|
1459
1488
|
MarkAsDuplicateAction.meta({ id: "MarkAsDuplicateAction" }),
|
|
1460
1489
|
ArchiveAction.meta({ id: "ArchiveAction" }),
|
|
1461
1490
|
UnarchiveAction.meta({ id: "UnarchiveAction" }),
|
|
1491
|
+
RevokeRegistrationAction.meta({ id: "RevokeRegistrationAction" }),
|
|
1492
|
+
ReinstateRegistrationAction.meta({ id: "ReinstateRegistrationAction" }),
|
|
1462
1493
|
NotifiedAction.meta({ id: "NotifiedAction" }),
|
|
1463
1494
|
RegisterAction.meta({ id: "RegisterAction" }),
|
|
1464
1495
|
DeclareAction.meta({ id: "DeclareAction" }),
|
|
@@ -1507,7 +1538,8 @@ var RegistrationCreationMetadata = ActionCreationMetadata.extend({
|
|
|
1507
1538
|
var LegalStatuses = z17.object({
|
|
1508
1539
|
[EventStatus.enum.NOTIFIED]: ActionCreationMetadata.nullish(),
|
|
1509
1540
|
[EventStatus.enum.DECLARED]: ActionCreationMetadata.nullish(),
|
|
1510
|
-
[EventStatus.enum.REGISTERED]: RegistrationCreationMetadata.nullish()
|
|
1541
|
+
[EventStatus.enum.REGISTERED]: RegistrationCreationMetadata.nullish(),
|
|
1542
|
+
[EventStatus.enum.REVOKED]: ActionCreationMetadata.nullish()
|
|
1511
1543
|
});
|
|
1512
1544
|
var EventMetadata = z17.object({
|
|
1513
1545
|
id: UUID,
|
|
@@ -1627,6 +1659,12 @@ var AnyOfStatus = import_v4.z.object({
|
|
|
1627
1659
|
}).meta({
|
|
1628
1660
|
id: "AnyOfStatus"
|
|
1629
1661
|
});
|
|
1662
|
+
var NoneOfStatus = import_v4.z.object({
|
|
1663
|
+
type: import_v4.z.literal("noneOf"),
|
|
1664
|
+
terms: import_v4.z.array(EventStatus)
|
|
1665
|
+
}).meta({
|
|
1666
|
+
id: "NoneOfStatus"
|
|
1667
|
+
});
|
|
1630
1668
|
var Range = import_v4.z.object({
|
|
1631
1669
|
type: import_v4.z.literal("range"),
|
|
1632
1670
|
gte: import_v4.z.string(),
|
|
@@ -1667,7 +1705,7 @@ var QueryInput = import_v4.z.lazy(
|
|
|
1667
1705
|
var QueryExpression = import_v4.z.object({
|
|
1668
1706
|
id: import_v4.z.optional(import_v4.z.string()),
|
|
1669
1707
|
eventType: import_v4.z.string(),
|
|
1670
|
-
status: import_v4.z.optional(import_v4.z.union([AnyOfStatus, ExactStatus])),
|
|
1708
|
+
status: import_v4.z.optional(import_v4.z.union([AnyOfStatus, NoneOfStatus, ExactStatus])),
|
|
1671
1709
|
createdAt: import_v4.z.optional(DateCondition),
|
|
1672
1710
|
updatedAt: import_v4.z.optional(DateCondition),
|
|
1673
1711
|
"legalStatuses.DECLARED.createdAtLocation": import_v4.z.optional(Within).nullable(),
|
|
@@ -1676,6 +1714,7 @@ var QueryExpression = import_v4.z.object({
|
|
|
1676
1714
|
"legalStatuses.REGISTERED.createdAtLocation": import_v4.z.optional(Within).nullable(),
|
|
1677
1715
|
"legalStatuses.REGISTERED.createdByRole": import_v4.z.optional(AnyOf),
|
|
1678
1716
|
"legalStatuses.REGISTERED.registrationNumber": import_v4.z.optional(Exact),
|
|
1717
|
+
"legalStatuses.REVOKED.createdAtLocation": import_v4.z.optional(Within).nullable(),
|
|
1679
1718
|
createdAtLocation: import_v4.z.optional(import_v4.z.union([Within, Exact])),
|
|
1680
1719
|
updatedAtLocation: import_v4.z.optional(import_v4.z.union([Within, Exact])),
|
|
1681
1720
|
assignedTo: import_v4.z.optional(Exact),
|
|
@@ -2873,6 +2912,12 @@ var ReadActionConfig = ActionConfigBase.extend(
|
|
|
2873
2912
|
var NotifyConfig = ActionConfigBase.extend(
|
|
2874
2913
|
z25.object({
|
|
2875
2914
|
type: z25.literal(ActionType.NOTIFY),
|
|
2915
|
+
notificationForm: DeclarationFormConfig.describe(
|
|
2916
|
+
"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."
|
|
2917
|
+
),
|
|
2918
|
+
review: DeclarationReviewConfig.describe(
|
|
2919
|
+
"Review page configuration for the notify action. Values of its fields are stored as the NOTIFY action annotation."
|
|
2920
|
+
),
|
|
2876
2921
|
form: actionConfirmationForm
|
|
2877
2922
|
}).shape
|
|
2878
2923
|
);
|
|
@@ -2925,6 +2970,9 @@ var DeleteConfig = ActionConfigBase.extend(
|
|
|
2925
2970
|
var DeclareConfig = DeclarationActionBase.extend(
|
|
2926
2971
|
z25.object({
|
|
2927
2972
|
type: z25.literal(ActionType.DECLARE),
|
|
2973
|
+
declaration: DeclarationFormConfig.describe(
|
|
2974
|
+
"Configuration of the form used to gather event data."
|
|
2975
|
+
),
|
|
2928
2976
|
review: DeclarationReviewConfig.describe(
|
|
2929
2977
|
"Configuration of the review page fields."
|
|
2930
2978
|
),
|
|
@@ -2953,6 +3001,18 @@ var UnarchiveConfig = ActionConfigBase.extend(
|
|
|
2953
3001
|
type: z25.literal(ActionType.UNARCHIVE)
|
|
2954
3002
|
}).shape
|
|
2955
3003
|
);
|
|
3004
|
+
var RevokeRegistrationConfig = ActionConfigBase.extend(
|
|
3005
|
+
z25.object({
|
|
3006
|
+
type: z25.literal(ActionType.REVOKE_REGISTRATION),
|
|
3007
|
+
form: actionConfirmationForm
|
|
3008
|
+
}).shape
|
|
3009
|
+
);
|
|
3010
|
+
var ReinstateRegistrationConfig = ActionConfigBase.extend(
|
|
3011
|
+
z25.object({
|
|
3012
|
+
type: z25.literal(ActionType.REINSTATE_REGISTRATION),
|
|
3013
|
+
form: actionConfirmationForm
|
|
3014
|
+
}).shape
|
|
3015
|
+
);
|
|
2956
3016
|
var EditActionConfig = ActionConfigBase.extend(
|
|
2957
3017
|
z25.object({
|
|
2958
3018
|
type: z25.literal(ActionType.EDIT),
|
|
@@ -3039,11 +3099,11 @@ var ActionConfig = z25.discriminatedUnion("type", [
|
|
|
3039
3099
|
}),
|
|
3040
3100
|
NotifyConfig.meta({
|
|
3041
3101
|
id: "NotifyActionConfig",
|
|
3042
|
-
description: "Configuration for the notify action
|
|
3102
|
+
description: "Configuration for the notify action, including the notification form and its review page. When undefined, it is generated using the DeclareActionConfig."
|
|
3043
3103
|
}),
|
|
3044
3104
|
DeclareConfig.meta({
|
|
3045
3105
|
id: "DeclareActionConfig",
|
|
3046
|
-
description: "Configuration for the declare action. Includes review-page fields.
|
|
3106
|
+
description: "Configuration for the declare action. Includes the declaration form and review-page fields."
|
|
3047
3107
|
}),
|
|
3048
3108
|
DuplicateDetectedConfig.meta({
|
|
3049
3109
|
id: "DuplicateDetectedActionConfig",
|
|
@@ -3093,6 +3153,14 @@ var ActionConfig = z25.discriminatedUnion("type", [
|
|
|
3093
3153
|
id: "UnarchiveActionConfig",
|
|
3094
3154
|
description: "Configuration for unarchiving a record."
|
|
3095
3155
|
}),
|
|
3156
|
+
RevokeRegistrationConfig.meta({
|
|
3157
|
+
id: "RevokeRegistrationActionConfig",
|
|
3158
|
+
description: "Configuration for revoking a registered record."
|
|
3159
|
+
}),
|
|
3160
|
+
ReinstateRegistrationConfig.meta({
|
|
3161
|
+
id: "ReinstateRegistrationActionConfig",
|
|
3162
|
+
description: "Configuration for reinstating a revoked record back to registered."
|
|
3163
|
+
}),
|
|
3096
3164
|
CustomActionConfig.meta({
|
|
3097
3165
|
id: "CustomActionConfig",
|
|
3098
3166
|
description: "Configuration for a country-defined custom action. An event may include any number of these."
|
|
@@ -3394,7 +3462,10 @@ var SearchQueryParams = z30.object({
|
|
|
3394
3462
|
}).catchall(FieldValue);
|
|
3395
3463
|
var FieldConfigSchema = BaseField3.extend({
|
|
3396
3464
|
fieldId: z30.string(),
|
|
3397
|
-
fieldType: z30.literal("field")
|
|
3465
|
+
fieldType: z30.literal("field"),
|
|
3466
|
+
defaultValue: z30.union([z30.boolean(), z30.string(), z30.number()]).optional().describe(
|
|
3467
|
+
`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.`
|
|
3468
|
+
)
|
|
3398
3469
|
});
|
|
3399
3470
|
var EventFieldIdInput = z30.enum([
|
|
3400
3471
|
"trackingId",
|
|
@@ -3457,6 +3528,144 @@ var z32 = __toESM(require("zod/v4"));
|
|
|
3457
3528
|
|
|
3458
3529
|
// ../commons/src/events/DynamicFieldValue.ts
|
|
3459
3530
|
var z31 = __toESM(require("zod/v4"));
|
|
3531
|
+
function getDynamicNameValue(field3) {
|
|
3532
|
+
const nameConfiguration = field3.configuration?.name;
|
|
3533
|
+
const firstnameRequired = nameConfiguration?.firstname?.required ?? field3.required;
|
|
3534
|
+
const surnameRequired = nameConfiguration?.surname?.required ?? field3.required;
|
|
3535
|
+
return z31.object({
|
|
3536
|
+
firstname: firstnameRequired ? NonEmptyTextValue : TextValue,
|
|
3537
|
+
surname: surnameRequired ? NonEmptyTextValue : TextValue,
|
|
3538
|
+
middlename: nameConfiguration?.middlename?.required ? NonEmptyTextValue : TextValue.optional()
|
|
3539
|
+
});
|
|
3540
|
+
}
|
|
3541
|
+
function getDynamicAddressFieldValue(field3) {
|
|
3542
|
+
const schema = field3.required ? AddressFieldValue : AddressFieldUpdateValue;
|
|
3543
|
+
const configIds = field3.configuration?.streetAddressForm?.map((a) => a.id) ?? [];
|
|
3544
|
+
return schema.refine((arg) => {
|
|
3545
|
+
if (!arg) {
|
|
3546
|
+
return true;
|
|
3547
|
+
}
|
|
3548
|
+
const submittedKeys = Object.keys(arg.streetLevelDetails ?? {});
|
|
3549
|
+
const invalidKeys = submittedKeys.filter((k) => !configIds.includes(k));
|
|
3550
|
+
if (invalidKeys.length) {
|
|
3551
|
+
console.log(
|
|
3552
|
+
"Invalid streetLevelDetails: unknown keys",
|
|
3553
|
+
JSON.stringify(invalidKeys, null, 2)
|
|
3554
|
+
);
|
|
3555
|
+
return false;
|
|
3556
|
+
}
|
|
3557
|
+
return true;
|
|
3558
|
+
});
|
|
3559
|
+
}
|
|
3560
|
+
|
|
3561
|
+
// ../commons/src/events/FieldTypeMapping.ts
|
|
3562
|
+
function mapFieldTypeToZod(field3, actionType) {
|
|
3563
|
+
let schema;
|
|
3564
|
+
switch (field3.type) {
|
|
3565
|
+
case FieldType.FIELD_GROUP: {
|
|
3566
|
+
schema = z32.object(
|
|
3567
|
+
field3.fields.reduce((acc, subfield) => {
|
|
3568
|
+
acc[subfield.id] = mapFieldTypeToZod(subfield, actionType);
|
|
3569
|
+
return acc;
|
|
3570
|
+
}, {})
|
|
3571
|
+
);
|
|
3572
|
+
break;
|
|
3573
|
+
}
|
|
3574
|
+
case FieldType.DATE:
|
|
3575
|
+
schema = PlainDate;
|
|
3576
|
+
break;
|
|
3577
|
+
case FieldType.AGE:
|
|
3578
|
+
schema = AgeValue;
|
|
3579
|
+
break;
|
|
3580
|
+
case FieldType.TIME:
|
|
3581
|
+
schema = TimeValue;
|
|
3582
|
+
break;
|
|
3583
|
+
case FieldType.EMAIL:
|
|
3584
|
+
schema = EmailValue;
|
|
3585
|
+
break;
|
|
3586
|
+
case FieldType.DATE_RANGE:
|
|
3587
|
+
schema = DateRangeFieldValue;
|
|
3588
|
+
break;
|
|
3589
|
+
case FieldType.SELECT_DATE_RANGE:
|
|
3590
|
+
schema = SelectDateRangeValue;
|
|
3591
|
+
break;
|
|
3592
|
+
case FieldType.TEXT:
|
|
3593
|
+
case FieldType.TEXTAREA:
|
|
3594
|
+
case FieldType.DIVIDER:
|
|
3595
|
+
case FieldType.BULLET_LIST:
|
|
3596
|
+
case FieldType.PAGE_HEADER:
|
|
3597
|
+
case FieldType.LOCATION:
|
|
3598
|
+
case FieldType.SELECT:
|
|
3599
|
+
case FieldType.COUNTRY:
|
|
3600
|
+
case FieldType.RADIO_GROUP:
|
|
3601
|
+
case FieldType.PARAGRAPH:
|
|
3602
|
+
case FieldType.HEADING:
|
|
3603
|
+
case FieldType.IMAGE_VIEW:
|
|
3604
|
+
case FieldType.ADMINISTRATIVE_AREA:
|
|
3605
|
+
case FieldType.FACILITY:
|
|
3606
|
+
case FieldType.OFFICE:
|
|
3607
|
+
case FieldType.PHONE:
|
|
3608
|
+
case FieldType.LINK_BUTTON:
|
|
3609
|
+
case FieldType.VERIFICATION_STATUS:
|
|
3610
|
+
case FieldType.ID:
|
|
3611
|
+
case FieldType.LOADER:
|
|
3612
|
+
case FieldType.ALPHA_HIDDEN:
|
|
3613
|
+
case FieldType.USER_ROLE:
|
|
3614
|
+
schema = field3.required ? NonEmptyTextValue : TextValue;
|
|
3615
|
+
break;
|
|
3616
|
+
case FieldType.NUMBER:
|
|
3617
|
+
schema = NumberFieldValue;
|
|
3618
|
+
break;
|
|
3619
|
+
case FieldType.NUMBER_WITH_UNIT:
|
|
3620
|
+
schema = field3.required ? NumberWithUnitFieldValue : NumberWithUnitFieldUpdateValue;
|
|
3621
|
+
break;
|
|
3622
|
+
case FieldType.CHECKBOX:
|
|
3623
|
+
schema = CheckboxFieldValue;
|
|
3624
|
+
break;
|
|
3625
|
+
case FieldType.SIGNATURE:
|
|
3626
|
+
case FieldType.FILE:
|
|
3627
|
+
schema = FileFieldValue;
|
|
3628
|
+
break;
|
|
3629
|
+
case FieldType.FILE_WITH_OPTIONS:
|
|
3630
|
+
schema = field3.required ? FileFieldWithOptionValue.min(1) : FileFieldWithOptionValue;
|
|
3631
|
+
break;
|
|
3632
|
+
case FieldType.ADDRESS:
|
|
3633
|
+
schema = getDynamicAddressFieldValue(field3);
|
|
3634
|
+
break;
|
|
3635
|
+
case FieldType.DATA:
|
|
3636
|
+
schema = DataFieldValue;
|
|
3637
|
+
break;
|
|
3638
|
+
case FieldType.NAME:
|
|
3639
|
+
schema = actionType === ActionType.NOTIFY ? NameFieldUpdateValue : getDynamicNameValue(field3);
|
|
3640
|
+
break;
|
|
3641
|
+
case FieldType.BUTTON:
|
|
3642
|
+
schema = ButtonFieldValue;
|
|
3643
|
+
break;
|
|
3644
|
+
case FieldType.ALPHA_PRINT_BUTTON:
|
|
3645
|
+
schema = TextValue;
|
|
3646
|
+
break;
|
|
3647
|
+
case FieldType.AUTOCOMPLETE:
|
|
3648
|
+
schema = AutocompleteValue;
|
|
3649
|
+
break;
|
|
3650
|
+
case FieldType.HTTP:
|
|
3651
|
+
case FieldType.SEARCH:
|
|
3652
|
+
schema = HttpFieldUpdateValue;
|
|
3653
|
+
break;
|
|
3654
|
+
case FieldType.QUERY_PARAM_READER:
|
|
3655
|
+
schema = QueryParamReaderFieldUpdateValue;
|
|
3656
|
+
break;
|
|
3657
|
+
case FieldType.QR_READER:
|
|
3658
|
+
schema = QrReaderFieldValue;
|
|
3659
|
+
break;
|
|
3660
|
+
case FieldType.ID_READER:
|
|
3661
|
+
schema = IdReaderFieldValue;
|
|
3662
|
+
break;
|
|
3663
|
+
case FieldType._EXPERIMENTAL_CUSTOM:
|
|
3664
|
+
schema = CustomFieldValue;
|
|
3665
|
+
break;
|
|
3666
|
+
}
|
|
3667
|
+
return field3.required ? schema : schema.nullish();
|
|
3668
|
+
}
|
|
3460
3669
|
|
|
3461
3670
|
// ../commons/src/events/state/index.ts
|
|
3462
3671
|
var import_lodash3 = require("lodash");
|
|
@@ -3503,6 +3712,8 @@ var updateActions = new Set(
|
|
|
3503
3712
|
ActionType.REQUEST_CORRECTION,
|
|
3504
3713
|
ActionType.APPROVE_CORRECTION,
|
|
3505
3714
|
ActionType.REJECT_CORRECTION,
|
|
3715
|
+
ActionType.REVOKE_REGISTRATION,
|
|
3716
|
+
ActionType.REINSTATE_REGISTRATION,
|
|
3506
3717
|
ActionType.CUSTOM
|
|
3507
3718
|
]).options
|
|
3508
3719
|
);
|
|
@@ -3516,15 +3727,6 @@ var INHERENT_FLAG_RULES = [
|
|
|
3516
3727
|
setOn: [ActionType.REQUEST_CORRECTION],
|
|
3517
3728
|
resetOn: [ActionType.APPROVE_CORRECTION, ActionType.REJECT_CORRECTION]
|
|
3518
3729
|
},
|
|
3519
|
-
{
|
|
3520
|
-
// INCOMPLETE mirrors the NOTIFIED status: set by NOTIFY, cleared by any
|
|
3521
|
-
// other status-changing action (see getStatusFromActions). ARCHIVE/UNARCHIVE
|
|
3522
|
-
// are deliberately excluded so the flag freezes across an archive/unarchive
|
|
3523
|
-
// round trip and comes back exactly as it was.
|
|
3524
|
-
flag: InherentFlags.INCOMPLETE,
|
|
3525
|
-
setOn: [ActionType.NOTIFY],
|
|
3526
|
-
resetOn: [ActionType.CREATE, ActionType.DECLARE, ActionType.REGISTER]
|
|
3527
|
-
},
|
|
3528
3730
|
{
|
|
3529
3731
|
flag: InherentFlags.REJECTED,
|
|
3530
3732
|
setOn: [ActionType.REJECT],
|
|
@@ -4235,7 +4437,9 @@ function buildClientFunctionContext(input) {
|
|
|
4235
4437
|
// eslint-disable-next-line @typescript-eslint/no-use-before-define
|
|
4236
4438
|
$online: isOnline(),
|
|
4237
4439
|
$user: input.validatorContext?.user,
|
|
4238
|
-
$event: input.validatorContext?.event?.document
|
|
4440
|
+
$event: input.validatorContext?.event?.document ? getEventWithCompleteAcceptedActions(
|
|
4441
|
+
input.validatorContext.event.document
|
|
4442
|
+
) : void 0,
|
|
4239
4443
|
$leafAdminStructureLocationIds: input.validatorContext?.leafAdminStructureLocationIds ?? [],
|
|
4240
4444
|
user: input.systemVariables?.user,
|
|
4241
4445
|
$window: input.systemVariables?.$window,
|
|
@@ -4322,8 +4526,28 @@ function isOnline() {
|
|
|
4322
4526
|
|
|
4323
4527
|
// ../commons/src/events/utils.ts
|
|
4324
4528
|
var import_date_fns3 = require("date-fns");
|
|
4529
|
+
function getDeclaration(configuration) {
|
|
4530
|
+
const declareAction = configuration.actions.find(
|
|
4531
|
+
(action) => action.type === ActionType.DECLARE
|
|
4532
|
+
);
|
|
4533
|
+
if (!declareAction) {
|
|
4534
|
+
throw new Error(
|
|
4535
|
+
`Event '${configuration.id}' has no ${ActionType.DECLARE} action to read the declaration from`
|
|
4536
|
+
);
|
|
4537
|
+
}
|
|
4538
|
+
return declareAction.declaration;
|
|
4539
|
+
}
|
|
4540
|
+
function getDeclarationPages(configuration) {
|
|
4541
|
+
return getDeclaration(configuration).pages;
|
|
4542
|
+
}
|
|
4325
4543
|
function getDeclarationFields(configuration) {
|
|
4326
|
-
return configuration.
|
|
4544
|
+
return getDeclarationPages(configuration).flatMap(({ fields }) => fields);
|
|
4545
|
+
}
|
|
4546
|
+
function findNotificationForm(configuration) {
|
|
4547
|
+
const notifyAction = configuration.actions.find(
|
|
4548
|
+
(action) => action.type === ActionType.NOTIFY
|
|
4549
|
+
);
|
|
4550
|
+
return notifyAction?.type === ActionType.NOTIFY ? notifyAction.notificationForm : void 0;
|
|
4327
4551
|
}
|
|
4328
4552
|
var getActionAnnotationFields = (actionConfig) => {
|
|
4329
4553
|
if (actionConfig.type === ActionType.REQUEST_CORRECTION) {
|
|
@@ -4339,12 +4563,108 @@ var getActionAnnotationFields = (actionConfig) => {
|
|
|
4339
4563
|
function getAllAnnotationFields(config) {
|
|
4340
4564
|
return (0, import_lodash4.flattenDeep)(config.actions.map(getActionAnnotationFields));
|
|
4341
4565
|
}
|
|
4566
|
+
function deepMerge(currentDocument, actionDocument) {
|
|
4567
|
+
return (0, import_lodash4.mergeWith)(
|
|
4568
|
+
(0, import_lodash4.cloneDeep)(currentDocument),
|
|
4569
|
+
actionDocument,
|
|
4570
|
+
(previousValue, incomingValue) => {
|
|
4571
|
+
if (incomingValue === void 0) {
|
|
4572
|
+
return previousValue;
|
|
4573
|
+
}
|
|
4574
|
+
if ((0, import_lodash4.isArray)(incomingValue)) {
|
|
4575
|
+
return incomingValue;
|
|
4576
|
+
}
|
|
4577
|
+
if ((0, import_lodash4.isObject)(previousValue) && (0, import_lodash4.isObject)(incomingValue)) {
|
|
4578
|
+
return void 0;
|
|
4579
|
+
}
|
|
4580
|
+
return incomingValue;
|
|
4581
|
+
}
|
|
4582
|
+
);
|
|
4583
|
+
}
|
|
4342
4584
|
var findAllFields = (config) => {
|
|
4343
4585
|
return (0, import_lodash4.flattenDeep)([
|
|
4344
4586
|
...getDeclarationFields(config),
|
|
4587
|
+
...findNotificationForm(config)?.pages.flatMap(({ fields }) => fields) ?? [],
|
|
4345
4588
|
...getAllAnnotationFields(config)
|
|
4346
4589
|
]);
|
|
4347
4590
|
};
|
|
4591
|
+
function isAcceptedAction(a) {
|
|
4592
|
+
return a.status === ActionStatus.Accepted;
|
|
4593
|
+
}
|
|
4594
|
+
function getCompleteActionAnnotation(event2, action) {
|
|
4595
|
+
if (action.originalActionId) {
|
|
4596
|
+
const originalAction = event2.actions.find(
|
|
4597
|
+
({ id }) => id === action.originalActionId
|
|
4598
|
+
);
|
|
4599
|
+
if (originalAction?.status === ActionStatus.Requested) {
|
|
4600
|
+
return deepMerge(originalAction.annotation ?? {}, action.annotation ?? {});
|
|
4601
|
+
}
|
|
4602
|
+
}
|
|
4603
|
+
return action.annotation ?? {};
|
|
4604
|
+
}
|
|
4605
|
+
function getCompleteActionContent(event2, action) {
|
|
4606
|
+
const currentContent = "content" in action ? action.content : void 0;
|
|
4607
|
+
if (!action.originalActionId) {
|
|
4608
|
+
return currentContent;
|
|
4609
|
+
}
|
|
4610
|
+
const originalAction = event2.actions.find(
|
|
4611
|
+
({ id }) => id === action.originalActionId
|
|
4612
|
+
);
|
|
4613
|
+
if (originalAction && "content" in originalAction && originalAction.content) {
|
|
4614
|
+
return {
|
|
4615
|
+
...originalAction.content,
|
|
4616
|
+
...currentContent ?? {}
|
|
4617
|
+
};
|
|
4618
|
+
}
|
|
4619
|
+
return currentContent;
|
|
4620
|
+
}
|
|
4621
|
+
function getCompleteActionDeclaration(declaration, event2, action) {
|
|
4622
|
+
if (action.originalActionId) {
|
|
4623
|
+
const originalAction = event2.actions.find(
|
|
4624
|
+
({ id }) => id === action.originalActionId
|
|
4625
|
+
);
|
|
4626
|
+
if (originalAction?.status === ActionStatus.Requested) {
|
|
4627
|
+
return deepMerge(
|
|
4628
|
+
deepMerge(declaration, originalAction.declaration),
|
|
4629
|
+
action.declaration
|
|
4630
|
+
);
|
|
4631
|
+
}
|
|
4632
|
+
}
|
|
4633
|
+
return deepMerge(declaration, action.declaration);
|
|
4634
|
+
}
|
|
4635
|
+
function completeAcceptedAction(event2, action) {
|
|
4636
|
+
return {
|
|
4637
|
+
...action,
|
|
4638
|
+
declaration: getCompleteActionDeclaration({}, event2, action),
|
|
4639
|
+
annotation: getCompleteActionAnnotation(event2, action)
|
|
4640
|
+
};
|
|
4641
|
+
}
|
|
4642
|
+
function getEventWithCompleteAcceptedActions(event2) {
|
|
4643
|
+
return {
|
|
4644
|
+
...event2,
|
|
4645
|
+
actions: event2.actions.map((action) => {
|
|
4646
|
+
if (!isAcceptedAction(action) || !action.originalActionId) {
|
|
4647
|
+
return action;
|
|
4648
|
+
}
|
|
4649
|
+
const requestedAction = event2.actions.find(
|
|
4650
|
+
({ id }) => id === action.originalActionId
|
|
4651
|
+
);
|
|
4652
|
+
if (requestedAction?.status !== ActionStatus.Requested) {
|
|
4653
|
+
return action;
|
|
4654
|
+
}
|
|
4655
|
+
const content = getCompleteActionContent(event2, action);
|
|
4656
|
+
return {
|
|
4657
|
+
...completeAcceptedAction(event2, action),
|
|
4658
|
+
// Who requested the action, as getActionUpdateMetadata resolves it.
|
|
4659
|
+
createdBy: requestedAction.createdBy,
|
|
4660
|
+
createdByRole: requestedAction.createdByRole,
|
|
4661
|
+
createdByUserType: requestedAction.createdByUserType,
|
|
4662
|
+
createdAtLocation: requestedAction.createdAtLocation,
|
|
4663
|
+
...content ? { content } : {}
|
|
4664
|
+
};
|
|
4665
|
+
})
|
|
4666
|
+
};
|
|
4667
|
+
}
|
|
4348
4668
|
var EXCLUDED_ACTIONS = [
|
|
4349
4669
|
ActionType.REQUEST_CORRECTION,
|
|
4350
4670
|
ActionType.PRINT_CERTIFICATE,
|
|
@@ -4352,6 +4672,20 @@ var EXCLUDED_ACTIONS = [
|
|
|
4352
4672
|
];
|
|
4353
4673
|
|
|
4354
4674
|
// ../commons/src/events/eventConfigValidation.ts
|
|
4675
|
+
var SEARCH_DEFAULT_VALUE_FIELD_TYPES = [
|
|
4676
|
+
FieldType.TEXT,
|
|
4677
|
+
FieldType.TEXTAREA,
|
|
4678
|
+
FieldType.EMAIL,
|
|
4679
|
+
FieldType.PHONE,
|
|
4680
|
+
FieldType.ID,
|
|
4681
|
+
FieldType.SELECT,
|
|
4682
|
+
FieldType.RADIO_GROUP,
|
|
4683
|
+
FieldType.COUNTRY,
|
|
4684
|
+
FieldType.LOCATION,
|
|
4685
|
+
FieldType.ADMINISTRATIVE_AREA,
|
|
4686
|
+
FieldType.NUMBER,
|
|
4687
|
+
FieldType.DATE
|
|
4688
|
+
];
|
|
4355
4689
|
function validateAdvancedSearchConfig(event2, ctx) {
|
|
4356
4690
|
const allFields = findAllFields(event2);
|
|
4357
4691
|
const fieldIds = allFields.map((field3) => field3.id);
|
|
@@ -4383,6 +4717,56 @@ function validateAdvancedSearchConfig(event2, ctx) {
|
|
|
4383
4717
|
path: ["advancedSearch"]
|
|
4384
4718
|
});
|
|
4385
4719
|
}
|
|
4720
|
+
event2.advancedSearch.forEach((section, sectionIndex) => {
|
|
4721
|
+
section.fields.forEach((searchField, fieldIndex) => {
|
|
4722
|
+
if (searchField.fieldType !== "field" || searchField.defaultValue === void 0) {
|
|
4723
|
+
return;
|
|
4724
|
+
}
|
|
4725
|
+
const path = [
|
|
4726
|
+
"advancedSearch",
|
|
4727
|
+
sectionIndex,
|
|
4728
|
+
"fields",
|
|
4729
|
+
fieldIndex,
|
|
4730
|
+
"defaultValue"
|
|
4731
|
+
];
|
|
4732
|
+
if (searchField.config.searchFields && searchField.config.searchFields.length > 0) {
|
|
4733
|
+
ctx.addIssue({
|
|
4734
|
+
code: "custom",
|
|
4735
|
+
message: `Advanced search field ${searchField.fieldId} searches across several form fields, so it does not support a defaultValue.`,
|
|
4736
|
+
path
|
|
4737
|
+
});
|
|
4738
|
+
return;
|
|
4739
|
+
}
|
|
4740
|
+
if (typeof searchField.defaultValue === "boolean") {
|
|
4741
|
+
return;
|
|
4742
|
+
}
|
|
4743
|
+
const formField = allFields.find(({ id }) => id === searchField.fieldId);
|
|
4744
|
+
if (!formField) {
|
|
4745
|
+
return;
|
|
4746
|
+
}
|
|
4747
|
+
if (!SEARCH_DEFAULT_VALUE_FIELD_TYPES.some(
|
|
4748
|
+
(type) => type === formField.type
|
|
4749
|
+
)) {
|
|
4750
|
+
ctx.addIssue({
|
|
4751
|
+
code: "custom",
|
|
4752
|
+
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(", ")}.`,
|
|
4753
|
+
path
|
|
4754
|
+
});
|
|
4755
|
+
} else if (formField.type === FieldType.DATE && searchField.config.type === "range") {
|
|
4756
|
+
ctx.addIssue({
|
|
4757
|
+
code: "custom",
|
|
4758
|
+
message: `Advanced search field ${searchField.fieldId} is searched as a date range, so its defaultValue can only be true or false.`,
|
|
4759
|
+
path
|
|
4760
|
+
});
|
|
4761
|
+
} else if (!mapFieldTypeToZod(formField).safeParse(searchField.defaultValue).success) {
|
|
4762
|
+
ctx.addIssue({
|
|
4763
|
+
code: "custom",
|
|
4764
|
+
message: `Advanced search field ${searchField.fieldId} has defaultValue "${searchField.defaultValue}", which is not a valid ${formField.type} value.`,
|
|
4765
|
+
path
|
|
4766
|
+
});
|
|
4767
|
+
}
|
|
4768
|
+
});
|
|
4769
|
+
});
|
|
4386
4770
|
}
|
|
4387
4771
|
function validateDateOfEvent(event2, ctx) {
|
|
4388
4772
|
if (event2.dateOfEvent && isFieldReference(event2.dateOfEvent)) {
|
|
@@ -4469,15 +4853,102 @@ function validateActionOrder(event2, ctx) {
|
|
|
4469
4853
|
}
|
|
4470
4854
|
}
|
|
4471
4855
|
}
|
|
4856
|
+
function validateExactlyOneDeclareAction(event2, ctx) {
|
|
4857
|
+
const declareActionCount = event2.actions.filter(
|
|
4858
|
+
(action) => action.type === ActionType.DECLARE
|
|
4859
|
+
).length;
|
|
4860
|
+
if (declareActionCount !== 1) {
|
|
4861
|
+
ctx.addIssue({
|
|
4862
|
+
code: "custom",
|
|
4863
|
+
message: `Event must have exactly one ${ActionType.DECLARE} action. Found ${declareActionCount} for event ${event2.id}`,
|
|
4864
|
+
path: ["actions"]
|
|
4865
|
+
});
|
|
4866
|
+
return false;
|
|
4867
|
+
}
|
|
4868
|
+
return true;
|
|
4869
|
+
}
|
|
4870
|
+
function validateDeclarationGivenExactlyOnce(config, ctx) {
|
|
4871
|
+
const declareActionIndex = config.actions.findIndex(
|
|
4872
|
+
(action) => action.type === ActionType.DECLARE
|
|
4873
|
+
);
|
|
4874
|
+
const declareAction = config.actions[declareActionIndex];
|
|
4875
|
+
const onDeclareAction = declareAction.type === ActionType.DECLARE && !!declareAction.declaration;
|
|
4876
|
+
const onTopLevel = !!config.declaration;
|
|
4877
|
+
const declareActionPath = `actions[${declareActionIndex}].declaration`;
|
|
4878
|
+
if (onTopLevel && onDeclareAction) {
|
|
4879
|
+
ctx.addIssue({
|
|
4880
|
+
code: "custom",
|
|
4881
|
+
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.`,
|
|
4882
|
+
path: ["declaration"]
|
|
4883
|
+
});
|
|
4884
|
+
}
|
|
4885
|
+
if (!onTopLevel && !onDeclareAction) {
|
|
4886
|
+
ctx.addIssue({
|
|
4887
|
+
code: "custom",
|
|
4888
|
+
message: `Event '${config.id}' does not define \`declaration\`. Define it either at the top level or on the ${ActionType.DECLARE} action (\`${declareActionPath}\`).`,
|
|
4889
|
+
path: ["declaration"]
|
|
4890
|
+
});
|
|
4891
|
+
}
|
|
4892
|
+
}
|
|
4893
|
+
function validateNotificationForm(event2, ctx) {
|
|
4894
|
+
const declarationFields = getDeclarationPages(event2).flatMap(
|
|
4895
|
+
(page) => page.fields.map((field3) => ({ field: field3, pageId: page.id }))
|
|
4896
|
+
);
|
|
4897
|
+
event2.actions.forEach((action, actionIndex) => {
|
|
4898
|
+
if (action.type !== ActionType.NOTIFY) {
|
|
4899
|
+
return;
|
|
4900
|
+
}
|
|
4901
|
+
action.notificationForm.pages.forEach((page, pageIndex) => {
|
|
4902
|
+
page.fields.forEach((field3, fieldIndex) => {
|
|
4903
|
+
const path = [
|
|
4904
|
+
"actions",
|
|
4905
|
+
actionIndex,
|
|
4906
|
+
"notificationForm",
|
|
4907
|
+
"pages",
|
|
4908
|
+
pageIndex,
|
|
4909
|
+
"fields",
|
|
4910
|
+
fieldIndex
|
|
4911
|
+
];
|
|
4912
|
+
const matchingFields = declarationFields.filter(
|
|
4913
|
+
(declarationField) => declarationField.field.id === field3.id
|
|
4914
|
+
);
|
|
4915
|
+
if (matchingFields.length === 0) {
|
|
4916
|
+
ctx.addIssue({
|
|
4917
|
+
code: "custom",
|
|
4918
|
+
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.`,
|
|
4919
|
+
path
|
|
4920
|
+
});
|
|
4921
|
+
return;
|
|
4922
|
+
}
|
|
4923
|
+
if (!matchingFields.some(
|
|
4924
|
+
(declarationField) => declarationField.field.type === field3.type
|
|
4925
|
+
)) {
|
|
4926
|
+
const [declarationField] = matchingFields;
|
|
4927
|
+
ctx.addIssue({
|
|
4928
|
+
code: "custom",
|
|
4929
|
+
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}.`,
|
|
4930
|
+
path
|
|
4931
|
+
});
|
|
4932
|
+
}
|
|
4933
|
+
});
|
|
4934
|
+
});
|
|
4935
|
+
});
|
|
4936
|
+
}
|
|
4472
4937
|
|
|
4473
4938
|
// ../commons/src/events/EventConfig.ts
|
|
4474
4939
|
var EventFieldReference = z35.object({ $$event: EventMetadataDateFieldIdInput }).describe(
|
|
4475
4940
|
"Reference to a field defined in the event metadata, using the field id."
|
|
4476
4941
|
);
|
|
4477
|
-
var
|
|
4942
|
+
var eventLevelFields = {
|
|
4478
4943
|
id: z35.string().describe(
|
|
4479
4944
|
'Machine-readable identifier of the event (e.g. "birth", "death").'
|
|
4480
4945
|
),
|
|
4946
|
+
label: TranslationConfig.describe("Human-readable label for the event type."),
|
|
4947
|
+
advancedSearch: z35.array(AdvancedSearchConfig).optional().default([]).describe(
|
|
4948
|
+
"Configuration of fields available in the advanced search feature."
|
|
4949
|
+
)
|
|
4950
|
+
};
|
|
4951
|
+
var versionFields = {
|
|
4481
4952
|
dateOfEvent: FieldReference.or(EventFieldReference).optional().describe(
|
|
4482
4953
|
"Reference to the field capturing the date of the event (e.g. date of birth). Defaults to the event creation date if unspecified."
|
|
4483
4954
|
),
|
|
@@ -4493,19 +4964,12 @@ var _EventConfigBase = z35.object({
|
|
|
4493
4964
|
summary: SummaryConfig.describe(
|
|
4494
4965
|
"Summary information displayed in the event overview."
|
|
4495
4966
|
),
|
|
4496
|
-
label: TranslationConfig.describe("Human-readable label for the event type."),
|
|
4497
4967
|
actions: z35.array(ActionConfig).describe(
|
|
4498
4968
|
"Configuration of core and custom actions associated with the event."
|
|
4499
4969
|
),
|
|
4500
4970
|
actionOrder: z35.array(z35.string()).optional().describe(
|
|
4501
4971
|
"Order of actions in the action menu. Use either the action type for core actions or the customActionType for custom actions."
|
|
4502
4972
|
),
|
|
4503
|
-
declaration: DeclarationFormConfig.describe(
|
|
4504
|
-
"Configuration of the form used to gather event data."
|
|
4505
|
-
),
|
|
4506
|
-
advancedSearch: z35.array(AdvancedSearchConfig).optional().default([]).describe(
|
|
4507
|
-
"Configuration of fields available in the advanced search feature."
|
|
4508
|
-
),
|
|
4509
4973
|
flags: z35.array(FlagConfig).optional().default([]).describe(
|
|
4510
4974
|
"Configuration of custom flags associated with the actions of this event type."
|
|
4511
4975
|
),
|
|
@@ -4515,17 +4979,128 @@ var _EventConfigBase = z35.object({
|
|
|
4515
4979
|
icon: z35.partialRecord(AvailableIcons, Conditional).optional().describe(
|
|
4516
4980
|
'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.'
|
|
4517
4981
|
)
|
|
4518
|
-
}
|
|
4519
|
-
var
|
|
4982
|
+
};
|
|
4983
|
+
var _EventConfigBase = z35.object({ ...eventLevelFields, ...versionFields });
|
|
4984
|
+
function validateEventConfig(event2, ctx) {
|
|
4985
|
+
if (!validateExactlyOneDeclareAction(event2, ctx)) {
|
|
4986
|
+
return;
|
|
4987
|
+
}
|
|
4988
|
+
validateNotificationForm(event2, ctx);
|
|
4520
4989
|
validateAdvancedSearchConfig(event2, ctx);
|
|
4521
4990
|
validateDateOfEvent(event2, ctx);
|
|
4522
4991
|
validatePlaceOfEvent(event2, ctx);
|
|
4523
4992
|
validateActionFlags(event2, ctx);
|
|
4524
4993
|
validateActionOrder(event2, ctx);
|
|
4525
|
-
}
|
|
4994
|
+
}
|
|
4995
|
+
var EventConfig = _EventConfigBase.superRefine(validateEventConfig).meta({
|
|
4526
4996
|
id: "EventConfig",
|
|
4527
4997
|
description: "Configuration defining an event type registered in OpenCRVS (for example birth or death)."
|
|
4528
4998
|
});
|
|
4999
|
+
var DEFAULT_EVENT_CONFIG_VERSION_ID = "default";
|
|
5000
|
+
var DEFAULT_EFFECTIVE_FROM = "0001-01-01";
|
|
5001
|
+
var _EventConfigVersion = z35.object({
|
|
5002
|
+
id: z35.string().describe(
|
|
5003
|
+
'Identifier of the version, unique within the event (e.g. "birth-v2").'
|
|
5004
|
+
),
|
|
5005
|
+
effectiveFrom: z35.iso.date().default(DEFAULT_EFFECTIVE_FROM).describe(
|
|
5006
|
+
`Date (YYYY-MM-DD) from which this version is effective. A version without one is effective from the beginning of time ('${DEFAULT_EFFECTIVE_FROM}').`
|
|
5007
|
+
),
|
|
5008
|
+
...versionFields
|
|
5009
|
+
});
|
|
5010
|
+
var resolvedConfigs = /* @__PURE__ */ new WeakMap();
|
|
5011
|
+
function getEventConfigOfVersion(config, version) {
|
|
5012
|
+
let resolvedVersions = resolvedConfigs.get(config);
|
|
5013
|
+
if (!resolvedVersions) {
|
|
5014
|
+
resolvedVersions = /* @__PURE__ */ new WeakMap();
|
|
5015
|
+
resolvedConfigs.set(config, resolvedVersions);
|
|
5016
|
+
}
|
|
5017
|
+
const cached = resolvedVersions.get(version);
|
|
5018
|
+
if (cached) {
|
|
5019
|
+
return cached;
|
|
5020
|
+
}
|
|
5021
|
+
const { id: _id, effectiveFrom: _effectiveFrom, ...fields } = version;
|
|
5022
|
+
const resolved = {
|
|
5023
|
+
...fields,
|
|
5024
|
+
id: config.id,
|
|
5025
|
+
label: config.label,
|
|
5026
|
+
advancedSearch: config.advancedSearch
|
|
5027
|
+
};
|
|
5028
|
+
resolvedVersions.set(version, resolved);
|
|
5029
|
+
return resolved;
|
|
5030
|
+
}
|
|
5031
|
+
function resolveEventConfig(config) {
|
|
5032
|
+
return getEventConfigOfVersion(config, config.versions[0]);
|
|
5033
|
+
}
|
|
5034
|
+
function validateVersionList(config, ctx) {
|
|
5035
|
+
const ids = /* @__PURE__ */ new Set();
|
|
5036
|
+
const versionIdByEffectiveFrom = /* @__PURE__ */ new Map();
|
|
5037
|
+
config.versions.forEach((version, index) => {
|
|
5038
|
+
if (ids.has(version.id)) {
|
|
5039
|
+
ctx.addIssue({
|
|
5040
|
+
code: "custom",
|
|
5041
|
+
message: `Event '${config.id}' has more than one version with id '${version.id}'. Each version must have a different id.`,
|
|
5042
|
+
path: ["versions", index, "id"]
|
|
5043
|
+
});
|
|
5044
|
+
}
|
|
5045
|
+
ids.add(version.id);
|
|
5046
|
+
const sameEffectiveFromId = versionIdByEffectiveFrom.get(
|
|
5047
|
+
version.effectiveFrom
|
|
5048
|
+
);
|
|
5049
|
+
if (sameEffectiveFromId !== void 0) {
|
|
5050
|
+
const versionIds = `'${sameEffectiveFromId}', '${version.id}'`;
|
|
5051
|
+
ctx.addIssue({
|
|
5052
|
+
code: "custom",
|
|
5053
|
+
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.`,
|
|
5054
|
+
path: ["versions", index, "effectiveFrom"]
|
|
5055
|
+
});
|
|
5056
|
+
} else {
|
|
5057
|
+
versionIdByEffectiveFrom.set(version.effectiveFrom, version.id);
|
|
5058
|
+
}
|
|
5059
|
+
});
|
|
5060
|
+
}
|
|
5061
|
+
function validateEachVersion(ctx, events, validate2) {
|
|
5062
|
+
const reported = /* @__PURE__ */ new Set();
|
|
5063
|
+
events.forEach((event2, index) => {
|
|
5064
|
+
const addIssue = (issue) => {
|
|
5065
|
+
if (typeof issue === "string") {
|
|
5066
|
+
ctx.addIssue({
|
|
5067
|
+
code: "custom",
|
|
5068
|
+
message: issue,
|
|
5069
|
+
path: ["versions", index]
|
|
5070
|
+
});
|
|
5071
|
+
return;
|
|
5072
|
+
}
|
|
5073
|
+
const [field3] = issue.path ?? [];
|
|
5074
|
+
const isEventLevel = typeof field3 === "string" && field3 in eventLevelFields;
|
|
5075
|
+
const path = isEventLevel ? issue.path ?? [] : ["versions", index, ...issue.path ?? []];
|
|
5076
|
+
const key = JSON.stringify([path, issue.message]);
|
|
5077
|
+
if (reported.has(key)) {
|
|
5078
|
+
return;
|
|
5079
|
+
}
|
|
5080
|
+
reported.add(key);
|
|
5081
|
+
ctx.addIssue({ ...issue, path });
|
|
5082
|
+
};
|
|
5083
|
+
validate2(event2, { value: event2, addIssue });
|
|
5084
|
+
});
|
|
5085
|
+
}
|
|
5086
|
+
var VersionedEventConfig = z35.object({
|
|
5087
|
+
...eventLevelFields,
|
|
5088
|
+
versions: z35.array(_EventConfigVersion).min(1).describe(
|
|
5089
|
+
`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}'.`
|
|
5090
|
+
)
|
|
5091
|
+
}).superRefine((config, ctx) => {
|
|
5092
|
+
validateVersionList(config, ctx);
|
|
5093
|
+
validateEachVersion(
|
|
5094
|
+
ctx,
|
|
5095
|
+
config.versions.map(
|
|
5096
|
+
(version) => getEventConfigOfVersion(config, version)
|
|
5097
|
+
),
|
|
5098
|
+
validateEventConfig
|
|
5099
|
+
);
|
|
5100
|
+
}).meta({
|
|
5101
|
+
id: "VersionedEventConfig",
|
|
5102
|
+
description: "Configuration of an event type registered in OpenCRVS (for example birth or death), with every version of it."
|
|
5103
|
+
});
|
|
4529
5104
|
|
|
4530
5105
|
// ../commons/src/events/EventConfigInput.ts
|
|
4531
5106
|
var defineDeclarationForm = (form) => DeclarationFormConfig.parse(form);
|
|
@@ -4597,7 +5172,7 @@ function createSearchConfig(baseField) {
|
|
|
4597
5172
|
|
|
4598
5173
|
// ../commons/src/event-config/event-configuration.ts
|
|
4599
5174
|
function isNonSearchableEventMetadataTimeFieldId(fieldId) {
|
|
4600
|
-
return !EventFieldIdInput.
|
|
5175
|
+
return !EventFieldIdInput.validate(fieldId);
|
|
4601
5176
|
}
|
|
4602
5177
|
function createEventFieldConfig(fieldId) {
|
|
4603
5178
|
const baseField = {
|
|
@@ -4624,7 +5199,10 @@ function eventFn(fieldId) {
|
|
|
4624
5199
|
}
|
|
4625
5200
|
var event = Object.assign(eventFn, {
|
|
4626
5201
|
/**
|
|
4627
|
-
* Checks if the event contains a specific action type.
|
|
5202
|
+
* Checks if the event contains a specific accepted action type.
|
|
5203
|
+
* Only Accepted actions are matched: a confirmable action is stored as a
|
|
5204
|
+
* Requested and an Accepted action, and a pending or rejected request must
|
|
5205
|
+
* not count as the action having happened.
|
|
4628
5206
|
* Can be used directly as a conditional or chained with additional methods.
|
|
4629
5207
|
* @param action - The action type to check for.
|
|
4630
5208
|
*/
|
|
@@ -4642,9 +5220,12 @@ var event = Object.assign(eventFn, {
|
|
|
4642
5220
|
properties: {
|
|
4643
5221
|
type: {
|
|
4644
5222
|
const: action
|
|
5223
|
+
},
|
|
5224
|
+
status: {
|
|
5225
|
+
const: ActionStatus.Accepted
|
|
4645
5226
|
}
|
|
4646
5227
|
},
|
|
4647
|
-
required: ["type"]
|
|
5228
|
+
required: ["type", "status"]
|
|
4648
5229
|
}
|
|
4649
5230
|
}
|
|
4650
5231
|
},
|
|
@@ -4655,9 +5236,10 @@ var event = Object.assign(eventFn, {
|
|
|
4655
5236
|
});
|
|
4656
5237
|
const buildActionConstraints = (additionalFields) => {
|
|
4657
5238
|
const actionProperties = {
|
|
4658
|
-
type: { const: action }
|
|
5239
|
+
type: { const: action },
|
|
5240
|
+
status: { const: ActionStatus.Accepted }
|
|
4659
5241
|
};
|
|
4660
|
-
const requiredFields = ["type"];
|
|
5242
|
+
const requiredFields = ["type", "status"];
|
|
4661
5243
|
if (additionalFields) {
|
|
4662
5244
|
Object.entries(additionalFields).forEach(([key, value]) => {
|
|
4663
5245
|
actionProperties[key] = { const: value };
|
|
@@ -4779,7 +5361,7 @@ var SerializableWithin = z37.object({
|
|
|
4779
5361
|
});
|
|
4780
5362
|
var SerializedQueryExpression = z37.object({
|
|
4781
5363
|
eventType: z37.string(),
|
|
4782
|
-
status: z37.optional(z37.union([AnyOfStatus, ExactStatus])),
|
|
5364
|
+
status: z37.optional(z37.union([AnyOfStatus, NoneOfStatus, ExactStatus])),
|
|
4783
5365
|
createdAt: z37.optional(DateCondition),
|
|
4784
5366
|
updatedAt: z37.optional(DateCondition),
|
|
4785
5367
|
"legalStatuses.DECLARED.createdAtLocation": z37.optional(SerializableWithin),
|
|
@@ -4788,6 +5370,7 @@ var SerializedQueryExpression = z37.object({
|
|
|
4788
5370
|
"legalStatuses.REGISTERED.createdAtLocation": z37.optional(SerializableWithin),
|
|
4789
5371
|
"legalStatuses.REGISTERED.createdByRole": z37.optional(AnyOf),
|
|
4790
5372
|
"legalStatuses.REGISTERED.registrationNumber": z37.optional(Exact),
|
|
5373
|
+
"legalStatuses.REVOKED.createdAtLocation": z37.optional(SerializableWithin),
|
|
4791
5374
|
createdAtLocation: z37.optional(
|
|
4792
5375
|
z37.union([SerializableWithin, SerializableExact])
|
|
4793
5376
|
),
|
|
@@ -4927,6 +5510,12 @@ var RegisterActionInput = BaseActionInput.extend(
|
|
|
4927
5510
|
var NotifyActionInput = BaseActionInput.extend(
|
|
4928
5511
|
z39.object({
|
|
4929
5512
|
type: z39.literal(ActionType.NOTIFY).default(ActionType.NOTIFY),
|
|
5513
|
+
declaration: BaseActionInput.shape.declaration.describe(
|
|
5514
|
+
"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."
|
|
5515
|
+
),
|
|
5516
|
+
annotation: BaseActionInput.shape.annotation.describe(
|
|
5517
|
+
"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."
|
|
5518
|
+
),
|
|
4930
5519
|
// For normal users, the createdAtLocation is resolved on the backend from the user's primaryOfficeId.
|
|
4931
5520
|
createdAtLocation: UUID.nullish().describe(
|
|
4932
5521
|
"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."
|
|
@@ -4999,6 +5588,16 @@ var UnarchiveActionInput = BaseActionInput.extend(
|
|
|
4999
5588
|
type: z39.literal(ActionType.UNARCHIVE).default(ActionType.UNARCHIVE)
|
|
5000
5589
|
}).shape
|
|
5001
5590
|
);
|
|
5591
|
+
var RevokeRegistrationActionInput = BaseActionInput.extend(
|
|
5592
|
+
z39.object({
|
|
5593
|
+
type: z39.literal(ActionType.REVOKE_REGISTRATION).default(ActionType.REVOKE_REGISTRATION)
|
|
5594
|
+
}).shape
|
|
5595
|
+
);
|
|
5596
|
+
var ReinstateRegistrationActionInput = BaseActionInput.extend(
|
|
5597
|
+
z39.object({
|
|
5598
|
+
type: z39.literal(ActionType.REINSTATE_REGISTRATION).default(ActionType.REINSTATE_REGISTRATION)
|
|
5599
|
+
}).shape
|
|
5600
|
+
);
|
|
5002
5601
|
var AssignActionInput = BaseActionInput.extend(
|
|
5003
5602
|
z39.object({
|
|
5004
5603
|
type: z39.literal(ActionType.ASSIGN),
|
|
@@ -5061,6 +5660,12 @@ var ActionInput = z39.discriminatedUnion("type", [
|
|
|
5061
5660
|
}),
|
|
5062
5661
|
ArchiveActionInput.meta({ id: "ArchiveActionInput" }),
|
|
5063
5662
|
UnarchiveActionInput.meta({ id: "UnarchiveActionInput" }),
|
|
5663
|
+
RevokeRegistrationActionInput.meta({
|
|
5664
|
+
id: "RevokeRegistrationActionInput"
|
|
5665
|
+
}),
|
|
5666
|
+
ReinstateRegistrationActionInput.meta({
|
|
5667
|
+
id: "ReinstateRegistrationActionInput"
|
|
5668
|
+
}),
|
|
5064
5669
|
AssignActionInput.meta({ id: "AssignActionInput" }),
|
|
5065
5670
|
UnassignActionInput.meta({ id: "UnassignActionInput" }),
|
|
5066
5671
|
PrintCertificateActionInput.meta({ id: "PrintCertificateActionInput" }),
|
|
@@ -5094,17 +5699,19 @@ var DraftInput = BaseActionInput.omit({ waitFor: true }).extend({
|
|
|
5094
5699
|
/*
|
|
5095
5700
|
* A draft can name a file that no action references. Such a file stays until
|
|
5096
5701
|
* the record is deleted or the record's next action sweeps its prefix.
|
|
5097
|
-
*
|
|
5098
|
-
*
|
|
5099
|
-
* which is about to be declared or registered.
|
|
5702
|
+
* Drafts are therefore saved only on a created record, which can still be deleted.
|
|
5703
|
+
* The server refuses them on any other record.
|
|
5100
5704
|
*/
|
|
5101
|
-
type: z40.
|
|
5705
|
+
type: z40.enum([ActionTypes.enum.DECLARE, ActionTypes.enum.NOTIFY]),
|
|
5102
5706
|
status: z40.enum([
|
|
5103
5707
|
ActionStatus.Requested,
|
|
5104
5708
|
ActionStatus.Accepted,
|
|
5105
5709
|
ActionStatus.Rejected
|
|
5106
5710
|
])
|
|
5107
5711
|
});
|
|
5712
|
+
var RemoteDraft = Draft.extend({
|
|
5713
|
+
action: Draft.shape.action.extend({ type: DraftInput.shape.type })
|
|
5714
|
+
});
|
|
5108
5715
|
|
|
5109
5716
|
// ../commons/src/events/EventInput.ts
|
|
5110
5717
|
var z41 = __toESM(require("zod/v4"));
|
|
@@ -5136,10 +5743,100 @@ var EventDocumentOnlyLastAction = EventDocument.extend({
|
|
|
5136
5743
|
}).brand("EventDocumentOnlyLastAction");
|
|
5137
5744
|
|
|
5138
5745
|
// ../commons/src/events/defineConfig.ts
|
|
5139
|
-
var
|
|
5140
|
-
|
|
5141
|
-
|
|
5142
|
-
|
|
5746
|
+
var z43 = __toESM(require("zod/v4"));
|
|
5747
|
+
function moveDeclarationToDeclareAction({
|
|
5748
|
+
declaration,
|
|
5749
|
+
...config
|
|
5750
|
+
}) {
|
|
5751
|
+
if (declaration) {
|
|
5752
|
+
console.warn(
|
|
5753
|
+
`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.`
|
|
5754
|
+
);
|
|
5755
|
+
}
|
|
5756
|
+
return {
|
|
5757
|
+
...config,
|
|
5758
|
+
actions: config.actions.map((action) => {
|
|
5759
|
+
if (action.type !== ActionType.DECLARE) {
|
|
5760
|
+
return action;
|
|
5761
|
+
}
|
|
5762
|
+
const declarationOfAction = action.declaration ?? declaration;
|
|
5763
|
+
if (!declarationOfAction) {
|
|
5764
|
+
throw new Error(`Event '${config.id}' does not define \`declaration\`.`);
|
|
5765
|
+
}
|
|
5766
|
+
return { ...action, declaration: declarationOfAction };
|
|
5767
|
+
})
|
|
5768
|
+
};
|
|
5769
|
+
}
|
|
5770
|
+
var VERSIONED_EVENT_FIELDS = [
|
|
5771
|
+
"id",
|
|
5772
|
+
"label",
|
|
5773
|
+
"advancedSearch",
|
|
5774
|
+
"versions"
|
|
5775
|
+
];
|
|
5776
|
+
function validateNoVersionFieldsAtTopLevel(config, ctx) {
|
|
5777
|
+
Object.keys(config).filter((key) => !VERSIONED_EVENT_FIELDS.includes(key)).forEach((key) => {
|
|
5778
|
+
ctx.addIssue({
|
|
5779
|
+
code: "custom",
|
|
5780
|
+
message: `Event '${config.id}' defines \`versions\`, so \`${key}\` must be defined on each version, not at the top level.`,
|
|
5781
|
+
path: [key]
|
|
5782
|
+
});
|
|
5783
|
+
});
|
|
5784
|
+
}
|
|
5785
|
+
function toVersionedInput(config) {
|
|
5786
|
+
if ("versions" in config) {
|
|
5787
|
+
return config;
|
|
5788
|
+
}
|
|
5789
|
+
const { id, label, advancedSearch, ...version } = moveDeclarationToDeclareAction(config);
|
|
5790
|
+
return {
|
|
5791
|
+
id,
|
|
5792
|
+
label,
|
|
5793
|
+
advancedSearch,
|
|
5794
|
+
versions: [{ ...version, id: DEFAULT_EVENT_CONFIG_VERSION_ID }]
|
|
5795
|
+
};
|
|
5796
|
+
}
|
|
5797
|
+
var EventConfigDefinition = z43.custom().superRefine((config, ctx) => {
|
|
5798
|
+
if ("versions" in config) {
|
|
5799
|
+
validateNoVersionFieldsAtTopLevel(config, ctx);
|
|
5800
|
+
return;
|
|
5801
|
+
}
|
|
5802
|
+
const eventCtx = { ...ctx, value: config };
|
|
5803
|
+
if (validateExactlyOneDeclareAction(config, eventCtx)) {
|
|
5804
|
+
validateDeclarationGivenExactlyOnce(config, eventCtx);
|
|
5805
|
+
}
|
|
5806
|
+
}).transform(toVersionedInput).pipe(VersionedEventConfig);
|
|
5807
|
+
var defineConfig = (config) => EventConfigDefinition.parse(config);
|
|
5808
|
+
|
|
5809
|
+
// ../commons/src/events/toNotificationForm.ts
|
|
5810
|
+
function toOptionalField(field3) {
|
|
5811
|
+
const { validation: _validation, ...rest } = field3;
|
|
5812
|
+
if (rest.type === FieldType.FIELD_GROUP && "fields" in rest) {
|
|
5813
|
+
return {
|
|
5814
|
+
...rest,
|
|
5815
|
+
required: false,
|
|
5816
|
+
fields: rest.fields.map(toOptionalField)
|
|
5817
|
+
};
|
|
5818
|
+
}
|
|
5819
|
+
return { ...rest, required: false };
|
|
5820
|
+
}
|
|
5821
|
+
function toNotificationForm(declaration) {
|
|
5822
|
+
return {
|
|
5823
|
+
...declaration,
|
|
5824
|
+
pages: declaration.pages.map((page) => ({
|
|
5825
|
+
...page,
|
|
5826
|
+
fields: page.fields.map(
|
|
5827
|
+
toOptionalField
|
|
5828
|
+
)
|
|
5829
|
+
}))
|
|
5830
|
+
};
|
|
5831
|
+
}
|
|
5832
|
+
function toNotificationReview(review) {
|
|
5833
|
+
return {
|
|
5834
|
+
...review,
|
|
5835
|
+
fields: review.fields.map(
|
|
5836
|
+
toOptionalField
|
|
5837
|
+
)
|
|
5838
|
+
};
|
|
5839
|
+
}
|
|
5143
5840
|
|
|
5144
5841
|
// ../commons/src/events/test.utils.ts
|
|
5145
5842
|
var import_lodash5 = require("lodash");
|
|
@@ -6389,7 +7086,7 @@ var TENNIS_CLUB_DECLARATION_FORM = defineDeclarationForm({
|
|
|
6389
7086
|
});
|
|
6390
7087
|
|
|
6391
7088
|
// ../commons/src/fixtures/tennis-club-membership-event.ts
|
|
6392
|
-
var
|
|
7089
|
+
var versionedTennisClubMembershipEvent = defineConfig({
|
|
6393
7090
|
id: TENNIS_CLUB_MEMBERSHIP,
|
|
6394
7091
|
declaration: TENNIS_CLUB_DECLARATION_FORM,
|
|
6395
7092
|
label: {
|
|
@@ -6448,6 +7145,8 @@ var tennisClubMembershipEvent = defineConfig({
|
|
|
6448
7145
|
description: "This is shown as the action name anywhere the user can trigger the action from",
|
|
6449
7146
|
id: "event.tennis-club-membership.action.notify.label"
|
|
6450
7147
|
},
|
|
7148
|
+
notificationForm: toNotificationForm(TENNIS_CLUB_DECLARATION_FORM),
|
|
7149
|
+
review: toNotificationReview(TENNIS_CLUB_DECLARATION_REVIEW),
|
|
6451
7150
|
flags: [
|
|
6452
7151
|
{
|
|
6453
7152
|
id: "health-worker-notified",
|
|
@@ -6744,9 +7443,12 @@ var tennisClubMembershipEvent = defineConfig({
|
|
|
6744
7443
|
}
|
|
6745
7444
|
]
|
|
6746
7445
|
});
|
|
7446
|
+
var tennisClubMembershipEvent = resolveEventConfig(
|
|
7447
|
+
versionedTennisClubMembershipEvent
|
|
7448
|
+
);
|
|
6747
7449
|
|
|
6748
7450
|
// ../commons/src/fixtures/football-club-membership-event.ts
|
|
6749
|
-
var
|
|
7451
|
+
var versionedFootballClubMembershipEvent = defineConfig({
|
|
6750
7452
|
id: "FOOTBALL_CLUB_MEMBERSHIP",
|
|
6751
7453
|
label: {
|
|
6752
7454
|
defaultMessage: "Football club membership application",
|
|
@@ -7069,6 +7771,9 @@ var footballClubMembershipEvent = defineConfig({
|
|
|
7069
7771
|
],
|
|
7070
7772
|
declaration: TENNIS_CLUB_DECLARATION_FORM
|
|
7071
7773
|
});
|
|
7774
|
+
var footballClubMembershipEvent = resolveEventConfig(
|
|
7775
|
+
versionedFootballClubMembershipEvent
|
|
7776
|
+
);
|
|
7072
7777
|
|
|
7073
7778
|
// ../commons/src/fixtures/library-membership-event.ts
|
|
7074
7779
|
var libraryMembershipForm = defineDeclarationForm({
|
|
@@ -7112,7 +7817,7 @@ var libraryMembershipForm = defineDeclarationForm({
|
|
|
7112
7817
|
}
|
|
7113
7818
|
]
|
|
7114
7819
|
});
|
|
7115
|
-
var
|
|
7820
|
+
var versionedLibraryMembershipEvent = defineConfig({
|
|
7116
7821
|
id: "library-membership",
|
|
7117
7822
|
label: {
|
|
7118
7823
|
defaultMessage: "Library membership application",
|
|
@@ -7125,9 +7830,29 @@ var libraryMembershipEvent = defineConfig({
|
|
|
7125
7830
|
id: "event.library-membership.title"
|
|
7126
7831
|
},
|
|
7127
7832
|
summary: { fields: [] },
|
|
7128
|
-
actions: [
|
|
7833
|
+
actions: [
|
|
7834
|
+
{
|
|
7835
|
+
type: ActionType.DECLARE,
|
|
7836
|
+
label: {
|
|
7837
|
+
defaultMessage: "Declare",
|
|
7838
|
+
description: "This is shown as the action name anywhere the user can trigger the action from",
|
|
7839
|
+
id: "event.library-membership.action.declare.label"
|
|
7840
|
+
},
|
|
7841
|
+
review: {
|
|
7842
|
+
title: {
|
|
7843
|
+
defaultMessage: "Library membership application",
|
|
7844
|
+
description: "Title of the review page",
|
|
7845
|
+
id: "event.library-membership.action.declare.form.review.title"
|
|
7846
|
+
},
|
|
7847
|
+
fields: []
|
|
7848
|
+
}
|
|
7849
|
+
}
|
|
7850
|
+
],
|
|
7129
7851
|
declaration: libraryMembershipForm
|
|
7130
7852
|
});
|
|
7853
|
+
var libraryMembershipEvent = resolveEventConfig(
|
|
7854
|
+
versionedLibraryMembershipEvent
|
|
7855
|
+
);
|
|
7131
7856
|
|
|
7132
7857
|
// ../commons/src/fixtures/child-onboarding-event.ts
|
|
7133
7858
|
function generateTranslationConfig(message) {
|
|
@@ -7341,7 +8066,7 @@ var CHILD_ONBOARDING_DECLARATION_FORM = defineDeclarationForm({
|
|
|
7341
8066
|
label: generateTranslationConfig("Birth decalration form"),
|
|
7342
8067
|
pages: [child, mother]
|
|
7343
8068
|
});
|
|
7344
|
-
var
|
|
8069
|
+
var versionedChildOnboardingEvent = defineConfig({
|
|
7345
8070
|
id: CHILD_ONBOARDING_EVENT,
|
|
7346
8071
|
title: generateTranslationConfig(
|
|
7347
8072
|
"{child.name.firstname} {child.name.surname}"
|
|
@@ -7369,6 +8094,9 @@ var ChildOnboardingEvent = defineConfig({
|
|
|
7369
8094
|
],
|
|
7370
8095
|
advancedSearch: []
|
|
7371
8096
|
});
|
|
8097
|
+
var ChildOnboardingEvent = resolveEventConfig(
|
|
8098
|
+
versionedChildOnboardingEvent
|
|
8099
|
+
);
|
|
7372
8100
|
|
|
7373
8101
|
// ../commons/src/fixtures/digital-identity-issuance-event.ts
|
|
7374
8102
|
var PRINT_DIGITAL_ID_CERTIFICATE_FORM = defineActionForm({
|
|
@@ -7557,7 +8285,7 @@ var digitalIdentityForm = defineDeclarationForm({
|
|
|
7557
8285
|
}
|
|
7558
8286
|
]
|
|
7559
8287
|
});
|
|
7560
|
-
var
|
|
8288
|
+
var versionedDigitalIdentityEvent = defineConfig({
|
|
7561
8289
|
id: "digital-identity",
|
|
7562
8290
|
label: {
|
|
7563
8291
|
defaultMessage: "Digital identity issuance",
|
|
@@ -7571,6 +8299,22 @@ var digitalIdentityEvent = defineConfig({
|
|
|
7571
8299
|
},
|
|
7572
8300
|
summary: { fields: [] },
|
|
7573
8301
|
actions: [
|
|
8302
|
+
{
|
|
8303
|
+
type: ActionType.DECLARE,
|
|
8304
|
+
label: {
|
|
8305
|
+
defaultMessage: "Declare",
|
|
8306
|
+
description: "This is shown as the action name anywhere the user can trigger the action from",
|
|
8307
|
+
id: "event.digital-identity.action.declare.label"
|
|
8308
|
+
},
|
|
8309
|
+
review: {
|
|
8310
|
+
title: {
|
|
8311
|
+
defaultMessage: "Digital identity issuance",
|
|
8312
|
+
description: "Title of the review page",
|
|
8313
|
+
id: "event.digital-identity.action.declare.form.review.title"
|
|
8314
|
+
},
|
|
8315
|
+
fields: []
|
|
8316
|
+
}
|
|
8317
|
+
},
|
|
7574
8318
|
{
|
|
7575
8319
|
type: ActionType.PRINT_CERTIFICATE,
|
|
7576
8320
|
label: {
|
|
@@ -7583,41 +8327,44 @@ var digitalIdentityEvent = defineConfig({
|
|
|
7583
8327
|
],
|
|
7584
8328
|
declaration: digitalIdentityForm
|
|
7585
8329
|
});
|
|
8330
|
+
var digitalIdentityEvent = resolveEventConfig(
|
|
8331
|
+
versionedDigitalIdentityEvent
|
|
8332
|
+
);
|
|
7586
8333
|
|
|
7587
8334
|
// ../commons/src/events/test.utils.ts
|
|
7588
|
-
var
|
|
8335
|
+
var z45 = __toESM(require("zod/v4"));
|
|
7589
8336
|
|
|
7590
8337
|
// ../commons/src/events/locations.ts
|
|
7591
|
-
var
|
|
7592
|
-
var LocationTypeV1 =
|
|
8338
|
+
var z44 = __toESM(require("zod/v4"));
|
|
8339
|
+
var LocationTypeV1 = z44.enum([
|
|
7593
8340
|
"ADMIN_STRUCTURE",
|
|
7594
8341
|
"CRVS_OFFICE",
|
|
7595
8342
|
"HEALTH_FACILITY"
|
|
7596
8343
|
]);
|
|
7597
|
-
var LocationStatus =
|
|
7598
|
-
var LocationVersion =
|
|
8344
|
+
var LocationStatus = z44.enum(["active", "inactive"]);
|
|
8345
|
+
var LocationVersion = z44.object({
|
|
7599
8346
|
versionId: UUID,
|
|
7600
|
-
effectiveFrom:
|
|
7601
|
-
name:
|
|
7602
|
-
externalId:
|
|
8347
|
+
effectiveFrom: z44.iso.date(),
|
|
8348
|
+
name: z44.string(),
|
|
8349
|
+
externalId: z44.string().nullish(),
|
|
7603
8350
|
status: LocationStatus
|
|
7604
8351
|
});
|
|
7605
|
-
var AdministrativeArea =
|
|
8352
|
+
var AdministrativeArea = z44.object({
|
|
7606
8353
|
id: UUID,
|
|
7607
|
-
name:
|
|
7608
|
-
externalId:
|
|
8354
|
+
name: z44.string(),
|
|
8355
|
+
externalId: z44.string().nullish(),
|
|
7609
8356
|
parentId: UUID.nullable(),
|
|
7610
8357
|
status: LocationStatus,
|
|
7611
|
-
versions:
|
|
8358
|
+
versions: z44.array(LocationVersion)
|
|
7612
8359
|
});
|
|
7613
|
-
var Location =
|
|
8360
|
+
var Location = z44.object({
|
|
7614
8361
|
id: UUID,
|
|
7615
|
-
name:
|
|
7616
|
-
externalId:
|
|
8362
|
+
name: z44.string(),
|
|
8363
|
+
externalId: z44.string().nullish(),
|
|
7617
8364
|
administrativeAreaId: UUID.nullable(),
|
|
7618
|
-
locationType:
|
|
8365
|
+
locationType: z44.string().nullable(),
|
|
7619
8366
|
status: LocationStatus,
|
|
7620
|
-
versions:
|
|
8367
|
+
versions: z44.array(LocationVersion)
|
|
7621
8368
|
});
|
|
7622
8369
|
var ClientAdministrativeArea = AdministrativeArea.omit({
|
|
7623
8370
|
name: true,
|
|
@@ -7658,22 +8405,22 @@ function validateUniqueIds(versions, ctx) {
|
|
|
7658
8405
|
ctx.addIssue("versions must not repeat a versionId");
|
|
7659
8406
|
}
|
|
7660
8407
|
}
|
|
7661
|
-
var SeededLocationVersions =
|
|
8408
|
+
var SeededLocationVersions = z44.array(LocationVersion).min(1).superRefine((versions, ctx) => {
|
|
7662
8409
|
validateAscendingDates(versions, ctx);
|
|
7663
8410
|
validateUniqueIds(versions, ctx);
|
|
7664
8411
|
});
|
|
7665
|
-
var SetLocationPayload =
|
|
8412
|
+
var SetLocationPayload = z44.object({
|
|
7666
8413
|
id: UUID,
|
|
7667
|
-
name:
|
|
7668
|
-
externalId:
|
|
8414
|
+
name: z44.string(),
|
|
8415
|
+
externalId: z44.string().nullish(),
|
|
7669
8416
|
administrativeAreaId: UUID.nullable(),
|
|
7670
|
-
locationType:
|
|
8417
|
+
locationType: z44.string().nullable(),
|
|
7671
8418
|
versions: SeededLocationVersions.optional()
|
|
7672
8419
|
});
|
|
7673
|
-
var SetAdministrativeAreaPayload =
|
|
8420
|
+
var SetAdministrativeAreaPayload = z44.object({
|
|
7674
8421
|
id: UUID,
|
|
7675
|
-
name:
|
|
7676
|
-
externalId:
|
|
8422
|
+
name: z44.string(),
|
|
8423
|
+
externalId: z44.string().nullish(),
|
|
7677
8424
|
parentId: UUID.nullable(),
|
|
7678
8425
|
versions: SeededLocationVersions.optional()
|
|
7679
8426
|
});
|
|
@@ -8021,7 +8768,7 @@ var V2_DEFAULT_MOCK_CLIENT_ADMINISTRATIVE_AREAS_MAP = new Map(
|
|
|
8021
8768
|
);
|
|
8022
8769
|
|
|
8023
8770
|
// ../commons/src/events/test.utils.ts
|
|
8024
|
-
var TestUserRole =
|
|
8771
|
+
var TestUserRole = z45.enum([
|
|
8025
8772
|
"FIELD_AGENT",
|
|
8026
8773
|
"LOCAL_REGISTRAR",
|
|
8027
8774
|
"LOCAL_SYSTEM_ADMIN",
|
|
@@ -8049,8 +8796,12 @@ var ACTION_SCOPE_MAP = {
|
|
|
8049
8796
|
"record.correct"
|
|
8050
8797
|
],
|
|
8051
8798
|
[ClientSpecificAction.REVIEW_CORRECTION_REQUEST]: ["record.correct"],
|
|
8799
|
+
// Not granted by a scope: the client checks the draft's own action instead
|
|
8800
|
+
[ClientSpecificAction.CONTINUE_DRAFT]: [],
|
|
8052
8801
|
[ActionType.REJECT_CORRECTION]: ["record.correct"],
|
|
8053
8802
|
[ActionType.APPROVE_CORRECTION]: ["record.correct"],
|
|
8803
|
+
[ActionType.REVOKE_REGISTRATION]: ["record.revoke-registration"],
|
|
8804
|
+
[ActionType.REINSTATE_REGISTRATION]: ["record.reinstate-registration"],
|
|
8054
8805
|
[ActionType.MARK_AS_DUPLICATE]: ["record.review-duplicates"],
|
|
8055
8806
|
[ActionType.MARK_AS_NOT_DUPLICATE]: ["record.review-duplicates"],
|
|
8056
8807
|
[ActionType.ARCHIVE]: ["record.archive"],
|
|
@@ -8097,7 +8848,12 @@ var AVAILABLE_ACTIONS_BY_EVENT_STATUS = {
|
|
|
8097
8848
|
ActionType.APPROVE_CORRECTION,
|
|
8098
8849
|
ActionType.REJECT_CORRECTION,
|
|
8099
8850
|
ActionType.CUSTOM,
|
|
8100
|
-
ClientSpecificAction.REVIEW_CORRECTION_REQUEST
|
|
8851
|
+
ClientSpecificAction.REVIEW_CORRECTION_REQUEST,
|
|
8852
|
+
ActionType.REVOKE_REGISTRATION
|
|
8853
|
+
],
|
|
8854
|
+
[EventStatus.enum.REVOKED]: [
|
|
8855
|
+
ActionType.READ,
|
|
8856
|
+
ActionType.REINSTATE_REGISTRATION
|
|
8101
8857
|
],
|
|
8102
8858
|
[EventStatus.enum.ARCHIVED]: [
|
|
8103
8859
|
ActionType.READ,
|
|
@@ -8111,6 +8867,8 @@ var ACTION_FILTERS = {
|
|
|
8111
8867
|
[ClientSpecificAction.REVIEW_CORRECTION_REQUEST]: (flags) => flags.includes(InherentFlags.CORRECTION_REQUESTED) && !flags.some((flag2) => flag2.endsWith(":requested")),
|
|
8112
8868
|
[ActionType.APPROVE_CORRECTION]: (flags) => flags.includes(InherentFlags.CORRECTION_REQUESTED) && !flags.some((flag2) => flag2.endsWith(":requested")),
|
|
8113
8869
|
[ActionType.REJECT_CORRECTION]: (flags) => flags.includes(InherentFlags.CORRECTION_REQUESTED) && !flags.some((flag2) => flag2.endsWith(":requested")),
|
|
8870
|
+
[ActionType.REVOKE_REGISTRATION]: (flags) => !flags.includes(InherentFlags.CORRECTION_REQUESTED) && !flags.some((flag2) => flag2.endsWith(":requested")),
|
|
8871
|
+
[ActionType.REINSTATE_REGISTRATION]: (flags) => !flags.some((flag2) => flag2.endsWith(":requested")),
|
|
8114
8872
|
[ActionType.MARK_AS_DUPLICATE]: (flags) => flags.includes(InherentFlags.POTENTIAL_DUPLICATE) && !flags.some((flag2) => flag2.endsWith(":requested")),
|
|
8115
8873
|
[ActionType.EDIT]: (flags) => !flags.includes(InherentFlags.POTENTIAL_DUPLICATE) && !flags.some((flag2) => flag2.endsWith(":requested")),
|
|
8116
8874
|
[ActionType.REGISTER]: (flags) => !flags.includes(InherentFlags.POTENTIAL_DUPLICATE) && !flags.some((flag2) => flag2.endsWith(":requested")),
|
|
@@ -8133,55 +8891,55 @@ var REJECTED_ACTIONS = [
|
|
|
8133
8891
|
var import_lodash7 = require("lodash");
|
|
8134
8892
|
|
|
8135
8893
|
// ../commons/src/events/locationPayloads.ts
|
|
8136
|
-
var
|
|
8137
|
-
var CreateLocationPayload =
|
|
8894
|
+
var z46 = __toESM(require("zod/v4"));
|
|
8895
|
+
var CreateLocationPayload = z46.object({
|
|
8138
8896
|
id: UUID.optional(),
|
|
8139
8897
|
versionId: UUID.optional(),
|
|
8140
|
-
name:
|
|
8141
|
-
externalId:
|
|
8898
|
+
name: z46.string(),
|
|
8899
|
+
externalId: z46.string().nullish(),
|
|
8142
8900
|
administrativeAreaId: UUID.nullable(),
|
|
8143
|
-
locationType:
|
|
8144
|
-
effectiveFrom:
|
|
8901
|
+
locationType: z46.string().nullable(),
|
|
8902
|
+
effectiveFrom: z46.iso.date().optional(),
|
|
8145
8903
|
status: LocationStatus.default("active")
|
|
8146
8904
|
});
|
|
8147
|
-
var UpdateLocationPayload =
|
|
8905
|
+
var UpdateLocationPayload = z46.strictObject({
|
|
8148
8906
|
id: UUID,
|
|
8149
8907
|
versionId: UUID.optional(),
|
|
8150
|
-
name:
|
|
8151
|
-
externalId:
|
|
8908
|
+
name: z46.string(),
|
|
8909
|
+
externalId: z46.string().nullish(),
|
|
8152
8910
|
status: LocationStatus,
|
|
8153
|
-
effectiveFrom:
|
|
8911
|
+
effectiveFrom: z46.iso.date().optional(),
|
|
8154
8912
|
lastVersionId: UUID
|
|
8155
8913
|
});
|
|
8156
|
-
var WithdrawLocationVersionPayload =
|
|
8914
|
+
var WithdrawLocationVersionPayload = z46.object({
|
|
8157
8915
|
id: UUID,
|
|
8158
8916
|
versionId: UUID
|
|
8159
8917
|
});
|
|
8160
|
-
var CreateAdministrativeAreaPayload =
|
|
8918
|
+
var CreateAdministrativeAreaPayload = z46.object({
|
|
8161
8919
|
id: UUID.optional(),
|
|
8162
8920
|
versionId: UUID.optional(),
|
|
8163
|
-
name:
|
|
8164
|
-
externalId:
|
|
8921
|
+
name: z46.string(),
|
|
8922
|
+
externalId: z46.string().nullish(),
|
|
8165
8923
|
parentId: UUID.nullable(),
|
|
8166
|
-
effectiveFrom:
|
|
8924
|
+
effectiveFrom: z46.iso.date().optional(),
|
|
8167
8925
|
status: LocationStatus.default("active")
|
|
8168
8926
|
});
|
|
8169
|
-
var UpdateAdministrativeAreaPayload =
|
|
8927
|
+
var UpdateAdministrativeAreaPayload = z46.strictObject({
|
|
8170
8928
|
id: UUID,
|
|
8171
8929
|
versionId: UUID.optional(),
|
|
8172
|
-
name:
|
|
8173
|
-
externalId:
|
|
8930
|
+
name: z46.string(),
|
|
8931
|
+
externalId: z46.string().nullish(),
|
|
8174
8932
|
status: LocationStatus,
|
|
8175
|
-
effectiveFrom:
|
|
8933
|
+
effectiveFrom: z46.iso.date().optional(),
|
|
8176
8934
|
lastVersionId: UUID
|
|
8177
8935
|
});
|
|
8178
|
-
var WithdrawAdministrativeAreaVersionPayload =
|
|
8936
|
+
var WithdrawAdministrativeAreaVersionPayload = z46.object({
|
|
8179
8937
|
id: UUID,
|
|
8180
8938
|
versionId: UUID
|
|
8181
8939
|
});
|
|
8182
8940
|
|
|
8183
8941
|
// ../commons/src/notification/UserNotifications.ts
|
|
8184
|
-
var
|
|
8942
|
+
var z47 = __toESM(require("zod/v4"));
|
|
8185
8943
|
var TriggerEvent = {
|
|
8186
8944
|
USER_CREATED: "user-created",
|
|
8187
8945
|
USER_UPDATED: "user-updated",
|
|
@@ -8196,60 +8954,60 @@ var TriggerEvent = {
|
|
|
8196
8954
|
CHANGE_PHONE_NUMBER: "change-phone-number",
|
|
8197
8955
|
CHANGE_EMAIL_ADDRESS: "change-email-address"
|
|
8198
8956
|
};
|
|
8199
|
-
var Recipient =
|
|
8957
|
+
var Recipient = z47.object({
|
|
8200
8958
|
name: NameFieldValue.optional(),
|
|
8201
|
-
mobile:
|
|
8202
|
-
email:
|
|
8203
|
-
bcc:
|
|
8959
|
+
mobile: z47.string().optional(),
|
|
8960
|
+
email: z47.string().optional(),
|
|
8961
|
+
bcc: z47.array(z47.string()).optional()
|
|
8204
8962
|
});
|
|
8205
|
-
var BasePayload =
|
|
8963
|
+
var BasePayload = z47.object({
|
|
8206
8964
|
recipient: Recipient
|
|
8207
8965
|
});
|
|
8208
8966
|
var TriggerPayload = {
|
|
8209
8967
|
[TriggerEvent.USER_CREATED]: BasePayload.extend({
|
|
8210
|
-
username:
|
|
8211
|
-
temporaryPassword:
|
|
8968
|
+
username: z47.string(),
|
|
8969
|
+
temporaryPassword: z47.string()
|
|
8212
8970
|
}),
|
|
8213
8971
|
[TriggerEvent.USER_UPDATED]: BasePayload.extend({
|
|
8214
|
-
oldUsername:
|
|
8215
|
-
newUsername:
|
|
8972
|
+
oldUsername: z47.string(),
|
|
8973
|
+
newUsername: z47.string()
|
|
8216
8974
|
}),
|
|
8217
8975
|
[TriggerEvent.USERNAME_REMINDER]: BasePayload.extend({
|
|
8218
|
-
username:
|
|
8976
|
+
username: z47.string()
|
|
8219
8977
|
}),
|
|
8220
8978
|
[TriggerEvent.RESET_PASSWORD]: BasePayload.extend({
|
|
8221
|
-
code:
|
|
8979
|
+
code: z47.string()
|
|
8222
8980
|
}),
|
|
8223
8981
|
[TriggerEvent.RESET_PASSWORD_BY_ADMIN]: BasePayload.extend({
|
|
8224
|
-
temporaryPassword:
|
|
8225
|
-
admin:
|
|
8226
|
-
id:
|
|
8982
|
+
temporaryPassword: z47.string(),
|
|
8983
|
+
admin: z47.object({
|
|
8984
|
+
id: z47.string(),
|
|
8227
8985
|
name: NameFieldValue,
|
|
8228
|
-
role:
|
|
8986
|
+
role: z47.string()
|
|
8229
8987
|
})
|
|
8230
8988
|
}),
|
|
8231
8989
|
[TriggerEvent.PASSWORD_RESET_LINK]: BasePayload.extend({
|
|
8232
|
-
token:
|
|
8990
|
+
token: z47.string()
|
|
8233
8991
|
}),
|
|
8234
8992
|
[TriggerEvent.USERNAME_REMINDER_LINK]: BasePayload.extend({
|
|
8235
|
-
token:
|
|
8993
|
+
token: z47.string()
|
|
8236
8994
|
}),
|
|
8237
8995
|
[TriggerEvent.RESEND_INVITE]: BasePayload.extend({
|
|
8238
|
-
username:
|
|
8239
|
-
temporaryPassword:
|
|
8996
|
+
username: z47.string(),
|
|
8997
|
+
temporaryPassword: z47.string()
|
|
8240
8998
|
}),
|
|
8241
8999
|
[TriggerEvent.TWO_FA]: BasePayload.extend({
|
|
8242
|
-
code:
|
|
9000
|
+
code: z47.string()
|
|
8243
9001
|
}),
|
|
8244
9002
|
[TriggerEvent.ALL_USER_NOTIFICATION]: BasePayload.extend({
|
|
8245
|
-
subject:
|
|
8246
|
-
body:
|
|
9003
|
+
subject: z47.string(),
|
|
9004
|
+
body: z47.string()
|
|
8247
9005
|
}),
|
|
8248
9006
|
[TriggerEvent.CHANGE_PHONE_NUMBER]: BasePayload.extend({
|
|
8249
|
-
code:
|
|
9007
|
+
code: z47.string()
|
|
8250
9008
|
}),
|
|
8251
9009
|
[TriggerEvent.CHANGE_EMAIL_ADDRESS]: BasePayload.extend({
|
|
8252
|
-
code:
|
|
9010
|
+
code: z47.string()
|
|
8253
9011
|
})
|
|
8254
9012
|
};
|
|
8255
9013
|
function parseUserEventTrigger(event2, body) {
|
|
@@ -8352,7 +9110,7 @@ async function triggerUserEventNotification({
|
|
|
8352
9110
|
}
|
|
8353
9111
|
|
|
8354
9112
|
// src/notification/index.ts
|
|
8355
|
-
|
|
9113
|
+
z48.globalRegistry.clear();
|
|
8356
9114
|
// Annotate the CommonJS export names for ESM import in node:
|
|
8357
9115
|
0 && (module.exports = {
|
|
8358
9116
|
BasePayload,
|