@opencrvs/toolkit 2.1.0-rc.462d2a9 → 2.1.0-rc.468b2be
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/dist/application-config/index.js +190 -200
- package/dist/commons/api/router.d.ts +111 -7
- package/dist/commons/conditionals/conditionals.d.ts +6 -6
- package/dist/commons/conditionals/validate.d.ts +4 -5
- package/dist/commons/events/ActionConfig.d.ts +0 -21
- package/dist/commons/events/ActionDocument.d.ts +7 -1
- package/dist/commons/events/AdvancedSearchConfig.d.ts +6 -6
- package/dist/commons/events/AuditLog.d.ts +37 -0
- package/dist/commons/events/CountryConfigQueryInput.d.ts +0 -18
- package/dist/commons/events/EventIndex.d.ts +24 -5
- package/dist/commons/events/EventMetadata.d.ts +0 -1
- package/dist/commons/events/FieldConfig.d.ts +5 -5
- package/dist/commons/events/FieldTypeMapping.d.ts +19 -19
- package/dist/commons/events/FieldValue.d.ts +2 -2
- package/dist/commons/events/Flag.d.ts +0 -48
- package/dist/commons/events/PlainDate.d.ts +8 -0
- package/dist/commons/events/WorkqueueConfig.d.ts +12 -27
- package/dist/commons/events/index.d.ts +1 -0
- package/dist/commons/events/locationPayloads.d.ts +95 -0
- package/dist/commons/events/locations.d.ts +191 -11
- package/dist/commons/events/mocks.test.utils.d.ts +46 -2
- package/dist/commons/events/test.utils.d.ts +5 -5
- package/dist/conditionals/index.js +56 -303
- package/dist/events/index.js +3617 -3507
- package/dist/notification/index.js +1067 -1529
- package/dist/scopes/index.d.ts +3 -251
- package/dist/scopes/index.js +56 -304
- package/opencrvs-toolkit-2.1.0-rc.468b2be.tgz +0 -0
- package/package.json +3 -2
- package/tsconfig.tsbuildinfo +1 -1
- package/dist/commons/events/ActionStatus.d.ts +0 -14
- package/opencrvs-toolkit-2.1.0-rc.462d2a9.tgz +0 -0
|
@@ -38,7 +38,7 @@ __export(notification_exports, {
|
|
|
38
38
|
triggerUserEventNotification: () => triggerUserEventNotification
|
|
39
39
|
});
|
|
40
40
|
module.exports = __toCommonJS(notification_exports);
|
|
41
|
-
var
|
|
41
|
+
var z46 = __toESM(require("zod/v4"));
|
|
42
42
|
|
|
43
43
|
// ../commons/src/url.ts
|
|
44
44
|
function joinUrl(base, path) {
|
|
@@ -47,14 +47,14 @@ function joinUrl(base, path) {
|
|
|
47
47
|
}
|
|
48
48
|
|
|
49
49
|
// ../commons/src/events/AuditLog.ts
|
|
50
|
-
var
|
|
50
|
+
var z5 = __toESM(require("zod/v4"));
|
|
51
51
|
|
|
52
52
|
// ../commons/src/authentication.ts
|
|
53
53
|
var import_jwt_decode = __toESM(require("jwt-decode"));
|
|
54
|
-
var
|
|
54
|
+
var z3 = __toESM(require("zod/v4"));
|
|
55
55
|
|
|
56
56
|
// ../commons/src/scopes.ts
|
|
57
|
-
var
|
|
57
|
+
var z2 = __toESM(require("zod/v4"));
|
|
58
58
|
var qs = __toESM(require("qs"));
|
|
59
59
|
|
|
60
60
|
// ../commons/src/uuid.ts
|
|
@@ -65,264 +65,12 @@ function getUUID() {
|
|
|
65
65
|
return (0, import_uuid.v4)();
|
|
66
66
|
}
|
|
67
67
|
|
|
68
|
-
// ../commons/src/events/ActionType.ts
|
|
69
|
-
var z2 = __toESM(require("zod/v4"));
|
|
70
|
-
var ActionType = {
|
|
71
|
-
// Pre-declaration actions
|
|
72
|
-
DELETE: "DELETE",
|
|
73
|
-
CREATE: "CREATE",
|
|
74
|
-
NOTIFY: "NOTIFY",
|
|
75
|
-
// Declaration actions
|
|
76
|
-
DECLARE: "DECLARE",
|
|
77
|
-
REGISTER: "REGISTER",
|
|
78
|
-
EDIT: "EDIT",
|
|
79
|
-
// Declaration system actions. Non-configurable.
|
|
80
|
-
DUPLICATE_DETECTED: "DUPLICATE_DETECTED",
|
|
81
|
-
REJECT: "REJECT",
|
|
82
|
-
// REJECT_DECLARATION
|
|
83
|
-
MARK_AS_DUPLICATE: "MARK_AS_DUPLICATE",
|
|
84
|
-
MARK_AS_NOT_DUPLICATE: "MARK_AS_NOT_DUPLICATE",
|
|
85
|
-
ARCHIVE: "ARCHIVE",
|
|
86
|
-
UNARCHIVE: "UNARCHIVE",
|
|
87
|
-
// Record actions
|
|
88
|
-
PRINT_CERTIFICATE: "PRINT_CERTIFICATE",
|
|
89
|
-
REQUEST_CORRECTION: "REQUEST_CORRECTION",
|
|
90
|
-
REJECT_CORRECTION: "REJECT_CORRECTION",
|
|
91
|
-
APPROVE_CORRECTION: "APPROVE_CORRECTION",
|
|
92
|
-
// General actions
|
|
93
|
-
READ: "READ",
|
|
94
|
-
ASSIGN: "ASSIGN",
|
|
95
|
-
UNASSIGN: "UNASSIGN",
|
|
96
|
-
// Custom action
|
|
97
|
-
CUSTOM: "CUSTOM"
|
|
98
|
-
};
|
|
99
|
-
var ConfirmableActions = [
|
|
100
|
-
ActionType.NOTIFY,
|
|
101
|
-
ActionType.DECLARE,
|
|
102
|
-
ActionType.EDIT,
|
|
103
|
-
ActionType.REGISTER,
|
|
104
|
-
ActionType.REJECT,
|
|
105
|
-
ActionType.ARCHIVE,
|
|
106
|
-
ActionType.UNARCHIVE,
|
|
107
|
-
ActionType.PRINT_CERTIFICATE,
|
|
108
|
-
ActionType.REQUEST_CORRECTION,
|
|
109
|
-
ActionType.APPROVE_CORRECTION,
|
|
110
|
-
ActionType.REJECT_CORRECTION,
|
|
111
|
-
ActionType.CUSTOM
|
|
112
|
-
];
|
|
113
|
-
var ActionTypes = z2.enum([
|
|
114
|
-
"DELETE",
|
|
115
|
-
"CREATE",
|
|
116
|
-
"NOTIFY",
|
|
117
|
-
"DECLARE",
|
|
118
|
-
"EDIT",
|
|
119
|
-
"REGISTER",
|
|
120
|
-
"DUPLICATE_DETECTED",
|
|
121
|
-
"REJECT",
|
|
122
|
-
"MARK_AS_DUPLICATE",
|
|
123
|
-
"MARK_AS_NOT_DUPLICATE",
|
|
124
|
-
"ARCHIVE",
|
|
125
|
-
"UNARCHIVE",
|
|
126
|
-
"PRINT_CERTIFICATE",
|
|
127
|
-
"REQUEST_CORRECTION",
|
|
128
|
-
"REJECT_CORRECTION",
|
|
129
|
-
"APPROVE_CORRECTION",
|
|
130
|
-
"READ",
|
|
131
|
-
"ASSIGN",
|
|
132
|
-
"UNASSIGN",
|
|
133
|
-
"CUSTOM"
|
|
134
|
-
]);
|
|
135
|
-
var ClientSpecificAction = {
|
|
136
|
-
REVIEW_CORRECTION_REQUEST: "REVIEW_CORRECTION_REQUEST"
|
|
137
|
-
};
|
|
138
|
-
var declarationActionValues = [
|
|
139
|
-
ActionTypes.enum.DECLARE,
|
|
140
|
-
ActionTypes.enum.EDIT,
|
|
141
|
-
ActionTypes.enum.REGISTER,
|
|
142
|
-
ActionTypes.enum.NOTIFY,
|
|
143
|
-
ActionTypes.enum.DUPLICATE_DETECTED
|
|
144
|
-
];
|
|
145
|
-
var DeclarationActions = ActionTypes.extract(declarationActionValues);
|
|
146
|
-
var declarationUpdateActionValues = [
|
|
147
|
-
...declarationActionValues,
|
|
148
|
-
ActionTypes.enum.REQUEST_CORRECTION
|
|
149
|
-
];
|
|
150
|
-
var DeclarationUpdateActions = ActionTypes.extract(
|
|
151
|
-
declarationUpdateActionValues
|
|
152
|
-
);
|
|
153
|
-
var annotationActions = ActionTypes.exclude(declarationActionValues);
|
|
154
|
-
var writeActions = ActionTypes.exclude([
|
|
155
|
-
ActionType.CREATE,
|
|
156
|
-
ActionType.READ,
|
|
157
|
-
ActionType.ASSIGN,
|
|
158
|
-
ActionType.UNASSIGN
|
|
159
|
-
]);
|
|
160
|
-
var WorkqueueActionType = ActionTypes.extract([
|
|
161
|
-
ActionType.READ,
|
|
162
|
-
ActionType.DELETE,
|
|
163
|
-
ActionType.DECLARE,
|
|
164
|
-
ActionType.REGISTER,
|
|
165
|
-
ActionType.EDIT,
|
|
166
|
-
ActionType.REJECT,
|
|
167
|
-
ActionType.MARK_AS_DUPLICATE,
|
|
168
|
-
ActionType.ARCHIVE,
|
|
169
|
-
ActionType.UNARCHIVE,
|
|
170
|
-
ActionType.PRINT_CERTIFICATE,
|
|
171
|
-
ActionType.REQUEST_CORRECTION
|
|
172
|
-
]);
|
|
173
|
-
var META_ACTIONS = [
|
|
174
|
-
ActionType.ASSIGN,
|
|
175
|
-
ActionType.UNASSIGN,
|
|
176
|
-
ActionType.READ
|
|
177
|
-
];
|
|
178
|
-
function isMetaAction(actionType) {
|
|
179
|
-
return META_ACTIONS.includes(actionType);
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
// ../commons/src/events/ActionStatus.ts
|
|
183
|
-
var ActionStatus = {
|
|
184
|
-
Requested: "Requested",
|
|
185
|
-
Accepted: "Accepted",
|
|
186
|
-
Rejected: "Rejected"
|
|
187
|
-
};
|
|
188
|
-
|
|
189
|
-
// ../commons/src/events/Flag.ts
|
|
190
|
-
var z5 = __toESM(require("zod/v4"));
|
|
191
|
-
|
|
192
|
-
// ../commons/src/events/TranslationConfig.ts
|
|
193
|
-
var z3 = __toESM(require("zod/v4"));
|
|
194
|
-
var TranslationConfig = z3.object({
|
|
195
|
-
id: z3.string().describe(
|
|
196
|
-
"The identifier of the translation referred in translation CSV files"
|
|
197
|
-
),
|
|
198
|
-
defaultMessage: z3.string().describe("Default translation message"),
|
|
199
|
-
description: z3.string().describe(
|
|
200
|
-
"Describe the translation for a translator to be able to identify it."
|
|
201
|
-
)
|
|
202
|
-
}).meta({
|
|
203
|
-
description: "Translation configuration",
|
|
204
|
-
id: "TranslationConfig"
|
|
205
|
-
});
|
|
206
|
-
|
|
207
|
-
// ../commons/src/events/Conditional.ts
|
|
208
|
-
var z4 = __toESM(require("zod/v4"));
|
|
209
|
-
var Conditional = z4.any().describe("JSONSchema").meta({
|
|
210
|
-
description: "JSON schema conditional configuration",
|
|
211
|
-
id: "Conditional"
|
|
212
|
-
});
|
|
213
|
-
var ConditionalType = {
|
|
214
|
-
SHOW: "SHOW",
|
|
215
|
-
ENABLE: "ENABLE",
|
|
216
|
-
DISPLAY_ON_REVIEW: "DISPLAY_ON_REVIEW"
|
|
217
|
-
};
|
|
218
|
-
var ShowConditional = z4.object({
|
|
219
|
-
type: z4.literal(ConditionalType.SHOW),
|
|
220
|
-
conditional: Conditional
|
|
221
|
-
}).describe(
|
|
222
|
-
"If 'SHOW' conditional is defined, the component is shown to the user only if the condition is met"
|
|
223
|
-
);
|
|
224
|
-
var EnableConditional = z4.object({
|
|
225
|
-
type: z4.literal(ConditionalType.ENABLE),
|
|
226
|
-
conditional: Conditional
|
|
227
|
-
}).describe(
|
|
228
|
-
"If 'ENABLE' conditional is defined, the component is enabled only if the condition is met"
|
|
229
|
-
);
|
|
230
|
-
var ActionConditional = z4.discriminatedUnion("type", [
|
|
231
|
-
// Action can be shown / hidden
|
|
232
|
-
ShowConditional,
|
|
233
|
-
// Action can be shown to the user in the list but as disabled
|
|
234
|
-
EnableConditional
|
|
235
|
-
]).meta({
|
|
236
|
-
id: "ActionConditional",
|
|
237
|
-
description: "Conditional gating whether an action is shown (SHOW) or enabled (ENABLE). When omitted from an action, the action is shown and enabled for everyone."
|
|
238
|
-
});
|
|
239
|
-
var DisplayOnReviewConditional = z4.object({
|
|
240
|
-
type: z4.literal(ConditionalType.DISPLAY_ON_REVIEW),
|
|
241
|
-
conditional: Conditional
|
|
242
|
-
}).describe(
|
|
243
|
-
"If 'DISPLAY_ON_REVIEW' conditional is defined, the component is shown on the review page only if both the 'DISPLAY_ON_REVIEW' and 'SHOW' conditions are met. This should only be used for fields within declaration forms, as they are the only ones with review pages."
|
|
244
|
-
);
|
|
245
|
-
var FieldConditional = z4.discriminatedUnion("type", [
|
|
246
|
-
// Field input can be shown / hidden
|
|
247
|
-
ShowConditional,
|
|
248
|
-
// Field input can be shown to the user but as disabled
|
|
249
|
-
EnableConditional,
|
|
250
|
-
// Field output can be shown / hidden on the review page
|
|
251
|
-
DisplayOnReviewConditional
|
|
252
|
-
]).meta({
|
|
253
|
-
id: "FieldConditional",
|
|
254
|
-
description: "Conditional gating whether a form field is shown (SHOW), enabled (ENABLE), or displayed on the review page (DISPLAY_ON_REVIEW). When omitted, the field is shown and enabled for everyone, and is displayed on review whenever it has a value."
|
|
255
|
-
});
|
|
256
|
-
|
|
257
|
-
// ../commons/src/events/Flag.ts
|
|
258
|
-
var InherentFlags = {
|
|
259
|
-
INCOMPLETE: "incomplete",
|
|
260
|
-
REJECTED: "rejected",
|
|
261
|
-
CORRECTION_REQUESTED: "correction-requested",
|
|
262
|
-
POTENTIAL_DUPLICATE: "potential-duplicate",
|
|
263
|
-
/**
|
|
264
|
-
* This flag is set by the Edit-action and removed after the declaration or registration.
|
|
265
|
-
* A record should never stay with the EDIT_IN_PROGRESS flag, since it should always be declared or registered right after.
|
|
266
|
-
*
|
|
267
|
-
* We only use this flag to determine that a NOTIFY, DECLARE or REGISTER action is allowed next.
|
|
268
|
-
*/
|
|
269
|
-
EDIT_IN_PROGRESS: "edit-in-progress",
|
|
270
|
-
SEALED: "sealed"
|
|
271
|
-
};
|
|
272
|
-
var actionFlagPattern;
|
|
273
|
-
function getActionFlagPattern() {
|
|
274
|
-
actionFlagPattern ??= new RegExp(
|
|
275
|
-
`^(${Object.values(ActionType).join("|").toLowerCase()}):(${Object.values(
|
|
276
|
-
ActionStatus
|
|
277
|
-
).join("|").toLowerCase()})$`
|
|
278
|
-
);
|
|
279
|
-
return actionFlagPattern;
|
|
280
|
-
}
|
|
281
|
-
var ActionFlag = z5.string().refine((value) => getActionFlagPattern().test(value), {
|
|
282
|
-
message: "Flag must be in the format ActionType:ActionStatus (lowerCase)"
|
|
283
|
-
});
|
|
284
|
-
var CustomFlag = z5.string().refine((val) => !Object.values(InherentFlags).includes(val), {
|
|
285
|
-
message: `Custom flag cannot be one of the inherent flags: ${Object.values(
|
|
286
|
-
InherentFlags
|
|
287
|
-
).join(", ")}`
|
|
288
|
-
}).refine((val) => !ActionFlag.safeParse(val).success, {
|
|
289
|
-
message: "Custom flag cannot match the ActionFlag pattern (ActionType:ActionStatus)."
|
|
290
|
-
}).describe("Custom flag identifier defined by the country config.");
|
|
291
|
-
var Flag = ActionFlag.or(z5.enum(InherentFlags)).or(CustomFlag);
|
|
292
|
-
var ContainsFlags = z5.object({
|
|
293
|
-
anyOf: z5.array(Flag).optional(),
|
|
294
|
-
noneOf: z5.array(Flag).optional(),
|
|
295
|
-
allOf: z5.array(Flag).optional()
|
|
296
|
-
}).meta({
|
|
297
|
-
id: "ContainsFlags"
|
|
298
|
-
});
|
|
299
|
-
var FlagConfig = z5.object({
|
|
300
|
-
id: CustomFlag,
|
|
301
|
-
requiresAction: z5.boolean().describe(
|
|
302
|
-
"Indicates if this flag expects an action to be performed to be cleared."
|
|
303
|
-
),
|
|
304
|
-
label: TranslationConfig.describe("Human readable label of the flag.")
|
|
305
|
-
}).meta({
|
|
306
|
-
id: "FlagConfig",
|
|
307
|
-
description: "Configuration for a custom flag that can be added to or removed from records by event actions."
|
|
308
|
-
});
|
|
309
|
-
var ActionFlagConfig = z5.object({
|
|
310
|
-
id: Flag,
|
|
311
|
-
operation: z5.enum(["add", "remove"]).describe("Operation to perform on the flag."),
|
|
312
|
-
conditional: Conditional.optional().describe(
|
|
313
|
-
"When conditional is met, the operation is performed on the flag. If not provided, the operation is performed unconditionally."
|
|
314
|
-
)
|
|
315
|
-
}).meta({
|
|
316
|
-
id: "ActionFlagConfig",
|
|
317
|
-
description: "Add or remove operation applied to a flag when the parent action is accepted. Optionally gated by a conditional."
|
|
318
|
-
});
|
|
319
|
-
|
|
320
68
|
// ../commons/src/scopes.ts
|
|
321
|
-
var JurisdictionFilter =
|
|
69
|
+
var JurisdictionFilter = z2.enum(["administrativeArea", "location", "all"]).describe(
|
|
322
70
|
"Filters based on user jurisdiction relative to their office location in hierarchy."
|
|
323
71
|
);
|
|
324
|
-
var UserFilter =
|
|
325
|
-
var RecordScopeTypeV2 =
|
|
72
|
+
var UserFilter = z2.enum(["user"]).describe("Filters based on the user. Limits to self.");
|
|
73
|
+
var RecordScopeTypeV2 = z2.enum([
|
|
326
74
|
"record.search",
|
|
327
75
|
"record.create",
|
|
328
76
|
"record.read",
|
|
@@ -340,7 +88,7 @@ var RecordScopeTypeV2 = z6.enum([
|
|
|
340
88
|
"record.unassign-others",
|
|
341
89
|
"record.custom-action"
|
|
342
90
|
]);
|
|
343
|
-
var PlainScopeType =
|
|
91
|
+
var PlainScopeType = z2.enum([
|
|
344
92
|
// Misc. system scopes
|
|
345
93
|
"bypassratelimit",
|
|
346
94
|
"record.reindex",
|
|
@@ -348,6 +96,7 @@ var PlainScopeType = z6.enum([
|
|
|
348
96
|
"integration.create",
|
|
349
97
|
"record.import",
|
|
350
98
|
"config.update-all",
|
|
99
|
+
"location.edit",
|
|
351
100
|
"attachment.upload",
|
|
352
101
|
"profile.electronic-signature",
|
|
353
102
|
"user.read-only-my-audit",
|
|
@@ -359,15 +108,15 @@ var PlainScopeType = z6.enum([
|
|
|
359
108
|
"record.confirm-registration",
|
|
360
109
|
"record.reject-registration"
|
|
361
110
|
]);
|
|
362
|
-
var scopeByEvent =
|
|
111
|
+
var scopeByEvent = z2.preprocess(
|
|
363
112
|
(val) => val === void 0 ? void 0 : [val].flat(),
|
|
364
|
-
|
|
113
|
+
z2.array(z2.string()).optional()
|
|
365
114
|
).describe("Event type, e.g. birth, death");
|
|
366
|
-
var userRole =
|
|
115
|
+
var userRole = z2.preprocess(
|
|
367
116
|
(val) => val === void 0 ? void 0 : [val].flat(),
|
|
368
|
-
|
|
117
|
+
z2.array(z2.string()).optional()
|
|
369
118
|
).describe("User role, e.g. admin, field agent");
|
|
370
|
-
var scopeOptionsPlaceEvent =
|
|
119
|
+
var scopeOptionsPlaceEvent = z2.object({
|
|
371
120
|
event: scopeByEvent,
|
|
372
121
|
placeOfEvent: JurisdictionFilter.optional()
|
|
373
122
|
}).describe("Options applicable to all record scopes.");
|
|
@@ -379,37 +128,36 @@ var scopeOptionsDeclaredOrNotified = scopeOptionsPlaceEvent.extend({
|
|
|
379
128
|
}).describe("Options applicable to actions that may take place after DECLARE");
|
|
380
129
|
var AllRecordScopeOptions = scopeOptionsDeclaredOrNotified.extend({
|
|
381
130
|
registeredIn: JurisdictionFilter.optional(),
|
|
382
|
-
registeredBy: UserFilter.optional()
|
|
383
|
-
flags: ContainsFlags.optional()
|
|
131
|
+
registeredBy: UserFilter.optional()
|
|
384
132
|
}).describe(
|
|
385
133
|
"Options applicable to actions that may take place after REGISTER, with full filtering capabilities."
|
|
386
134
|
);
|
|
387
135
|
var CustomActionScopeOptions = AllRecordScopeOptions.extend({
|
|
388
|
-
customActionTypes:
|
|
136
|
+
customActionTypes: z2.preprocess(
|
|
389
137
|
(val) => val === void 0 ? void 0 : [val].flat(),
|
|
390
|
-
|
|
138
|
+
z2.array(z2.string()).optional()
|
|
391
139
|
).describe("Allowed custom action types")
|
|
392
140
|
});
|
|
393
|
-
var AccessLevelOptions =
|
|
141
|
+
var AccessLevelOptions = z2.object({
|
|
394
142
|
accessLevel: JurisdictionFilter.optional()
|
|
395
143
|
});
|
|
396
144
|
var AllUserScopeOptions = AccessLevelOptions.extend({
|
|
397
145
|
role: userRole.optional()
|
|
398
146
|
});
|
|
399
|
-
var WorkqueueOrDashboardOptions =
|
|
400
|
-
ids:
|
|
147
|
+
var WorkqueueOrDashboardOptions = z2.object({
|
|
148
|
+
ids: z2.preprocess(
|
|
401
149
|
(val) => val === void 0 ? void 0 : [val].flat(),
|
|
402
|
-
|
|
150
|
+
z2.array(z2.string())
|
|
403
151
|
).describe("Must contain a list of workqueue or dashboard ids.")
|
|
404
152
|
});
|
|
405
|
-
var AllScopeOptions =
|
|
153
|
+
var AllScopeOptions = z2.object({
|
|
406
154
|
...AllRecordScopeOptions.shape,
|
|
407
155
|
...AccessLevelOptions.shape,
|
|
408
156
|
...AllUserScopeOptions.shape,
|
|
409
157
|
...WorkqueueOrDashboardOptions.shape
|
|
410
158
|
});
|
|
411
159
|
var ScopeOptionKey = AllScopeOptions.keyof();
|
|
412
|
-
var ResolvedScopeOptionsPlaceEvent =
|
|
160
|
+
var ResolvedScopeOptionsPlaceEvent = z2.object({
|
|
413
161
|
event: scopeByEvent,
|
|
414
162
|
placeOfEvent: UUID.nullish()
|
|
415
163
|
}).describe(
|
|
@@ -417,16 +165,15 @@ var ResolvedScopeOptionsPlaceEvent = z6.object({
|
|
|
417
165
|
);
|
|
418
166
|
var ResolvedScopeOptionsDeclared = ResolvedScopeOptionsPlaceEvent.extend({
|
|
419
167
|
notifiedIn: UUID.nullish(),
|
|
420
|
-
notifiedBy:
|
|
168
|
+
notifiedBy: z2.string().optional(),
|
|
421
169
|
declaredIn: UUID.nullish(),
|
|
422
|
-
declaredBy:
|
|
170
|
+
declaredBy: z2.string().optional()
|
|
423
171
|
}).describe(
|
|
424
172
|
"Resolved options applicable to actions that may take place after DECLARE, with location ID and user ID instead of filters."
|
|
425
173
|
);
|
|
426
174
|
var ResolvedScopeOptionsFull = ResolvedScopeOptionsDeclared.extend({
|
|
427
175
|
registeredIn: UUID.nullish(),
|
|
428
|
-
registeredBy:
|
|
429
|
-
flags: ContainsFlags.optional()
|
|
176
|
+
registeredBy: z2.string().optional()
|
|
430
177
|
}).describe(
|
|
431
178
|
"Resolved options applicable to actions that may take place after REGISTER, with full filtering capabilities and location/user IDs instead of filters."
|
|
432
179
|
);
|
|
@@ -451,38 +198,38 @@ var ScopesWithFullOptions = RecordScopeTypeV2.extract([
|
|
|
451
198
|
"record.unassign-others"
|
|
452
199
|
]);
|
|
453
200
|
var ScopeOptionsPrintCertifiedCopies = AllRecordScopeOptions.extend({
|
|
454
|
-
templates:
|
|
201
|
+
templates: z2.preprocess(
|
|
455
202
|
(val) => val === void 0 ? void 0 : [val].flat(),
|
|
456
|
-
|
|
203
|
+
z2.array(z2.string()).optional()
|
|
457
204
|
).describe(
|
|
458
205
|
"Template IDs for certified copies. Controls which certificate templates are returned to the client via the config service. Certificate printing is a client-side operation \u2014 this option is not validated when the printCertificate action is submitted."
|
|
459
206
|
)
|
|
460
207
|
});
|
|
461
|
-
var RecordScopeV2 =
|
|
462
|
-
|
|
208
|
+
var RecordScopeV2 = z2.discriminatedUnion("type", [
|
|
209
|
+
z2.object({
|
|
463
210
|
type: ScopesWithPlaceEventOptions,
|
|
464
211
|
options: scopeOptionsPlaceEvent.optional()
|
|
465
212
|
}),
|
|
466
|
-
|
|
213
|
+
z2.object({
|
|
467
214
|
type: ScopesWithDeclaredOptions,
|
|
468
215
|
options: scopeOptionsDeclaredOrNotified.optional()
|
|
469
216
|
}),
|
|
470
|
-
|
|
217
|
+
z2.object({
|
|
471
218
|
type: ScopesWithFullOptions,
|
|
472
219
|
options: AllRecordScopeOptions.optional()
|
|
473
220
|
}),
|
|
474
|
-
|
|
475
|
-
type:
|
|
221
|
+
z2.object({
|
|
222
|
+
type: z2.literal("record.custom-action"),
|
|
476
223
|
options: CustomActionScopeOptions.optional()
|
|
477
224
|
}),
|
|
478
|
-
|
|
479
|
-
type:
|
|
225
|
+
z2.object({
|
|
226
|
+
type: z2.literal("record.print-certified-copies"),
|
|
480
227
|
options: ScopeOptionsPrintCertifiedCopies.optional()
|
|
481
228
|
})
|
|
482
229
|
]).describe(
|
|
483
230
|
"Scopes used to check user's permission to perform actions on a record."
|
|
484
231
|
);
|
|
485
|
-
var SystemScopeType =
|
|
232
|
+
var SystemScopeType = z2.enum([
|
|
486
233
|
"organisation.read-locations",
|
|
487
234
|
"user.read",
|
|
488
235
|
"user.create",
|
|
@@ -496,61 +243,61 @@ var UserScopeType = SystemScopeType.extract([
|
|
|
496
243
|
"user.search"
|
|
497
244
|
]);
|
|
498
245
|
var ScopesWithRoleOption = UserScopeType.extract(["user.edit", "user.create"]);
|
|
499
|
-
var UserScopeV2 =
|
|
500
|
-
|
|
246
|
+
var UserScopeV2 = z2.discriminatedUnion("type", [
|
|
247
|
+
z2.object({
|
|
501
248
|
type: ScopesWithRoleOption,
|
|
502
249
|
options: AllUserScopeOptions.optional()
|
|
503
250
|
}),
|
|
504
|
-
|
|
251
|
+
z2.object({
|
|
505
252
|
type: UserScopeType.extract(["user.read", "user.search"]),
|
|
506
253
|
options: AccessLevelOptions.optional()
|
|
507
254
|
})
|
|
508
255
|
]);
|
|
509
|
-
var ResolvedRecordScopeV2 =
|
|
510
|
-
|
|
256
|
+
var ResolvedRecordScopeV2 = z2.discriminatedUnion("type", [
|
|
257
|
+
z2.object({
|
|
511
258
|
type: ScopesWithPlaceEventOptions,
|
|
512
259
|
options: ResolvedScopeOptionsPlaceEvent.optional()
|
|
513
260
|
}),
|
|
514
|
-
|
|
261
|
+
z2.object({
|
|
515
262
|
type: ScopesWithDeclaredOptions,
|
|
516
263
|
options: ResolvedScopeOptionsDeclared.optional()
|
|
517
264
|
}),
|
|
518
|
-
|
|
265
|
+
z2.object({
|
|
519
266
|
type: ScopesWithFullOptions,
|
|
520
267
|
options: ResolvedScopeOptionsFull.optional()
|
|
521
268
|
}),
|
|
522
|
-
|
|
523
|
-
type:
|
|
269
|
+
z2.object({
|
|
270
|
+
type: z2.literal("record.print-certified-copies"),
|
|
524
271
|
options: ResolvedScopeOptionsFull.extend({
|
|
525
|
-
templates:
|
|
272
|
+
templates: z2.array(z2.string()).optional()
|
|
526
273
|
}).optional()
|
|
527
274
|
})
|
|
528
275
|
]).describe("Resolved scope with location/user IDs instead of filters.");
|
|
529
|
-
var Scope =
|
|
530
|
-
|
|
276
|
+
var Scope = z2.discriminatedUnion("type", [
|
|
277
|
+
z2.object({ type: PlainScopeType }),
|
|
531
278
|
...RecordScopeV2.options,
|
|
532
279
|
...UserScopeV2.options,
|
|
533
|
-
|
|
534
|
-
type:
|
|
280
|
+
z2.object({
|
|
281
|
+
type: z2.literal("organisation.read-locations"),
|
|
535
282
|
options: AccessLevelOptions.optional()
|
|
536
283
|
}),
|
|
537
|
-
|
|
538
|
-
type:
|
|
284
|
+
z2.object({
|
|
285
|
+
type: z2.literal("workqueue"),
|
|
539
286
|
options: WorkqueueOrDashboardOptions
|
|
540
287
|
}),
|
|
541
|
-
|
|
542
|
-
type:
|
|
288
|
+
z2.object({
|
|
289
|
+
type: z2.literal("dashboard.view"),
|
|
543
290
|
options: WorkqueueOrDashboardOptions
|
|
544
291
|
})
|
|
545
292
|
]);
|
|
546
|
-
var ScopeType =
|
|
293
|
+
var ScopeType = z2.enum([
|
|
547
294
|
...SystemScopeType.options,
|
|
548
295
|
...RecordScopeTypeV2.options,
|
|
549
296
|
...PlainScopeType.options,
|
|
550
297
|
"workqueue",
|
|
551
298
|
"dashboard.view"
|
|
552
299
|
]);
|
|
553
|
-
var EncodedScope =
|
|
300
|
+
var EncodedScope = z2.string().brand("EncodedScope");
|
|
554
301
|
var DEFAULT_SCOPE_OPTIONS = {
|
|
555
302
|
placeOfEvent: JurisdictionFilter.enum.all,
|
|
556
303
|
accessLevel: JurisdictionFilter.enum.all,
|
|
@@ -560,147 +307,281 @@ var DEFAULT_SCOPE_OPTIONS = {
|
|
|
560
307
|
};
|
|
561
308
|
|
|
562
309
|
// ../commons/src/authentication.ts
|
|
563
|
-
var TokenUserType =
|
|
564
|
-
var TokenWithBearer =
|
|
310
|
+
var TokenUserType = z3.enum(["user", "system"]);
|
|
311
|
+
var TokenWithBearer = z3.string().regex(/^Bearer\s/);
|
|
565
312
|
|
|
566
|
-
// ../commons/src/events/
|
|
567
|
-
var
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
313
|
+
// ../commons/src/events/ActionType.ts
|
|
314
|
+
var z4 = __toESM(require("zod/v4"));
|
|
315
|
+
var ActionType = {
|
|
316
|
+
// Pre-declaration actions
|
|
317
|
+
DELETE: "DELETE",
|
|
318
|
+
CREATE: "CREATE",
|
|
319
|
+
NOTIFY: "NOTIFY",
|
|
320
|
+
// Declaration actions
|
|
321
|
+
DECLARE: "DECLARE",
|
|
322
|
+
REGISTER: "REGISTER",
|
|
323
|
+
EDIT: "EDIT",
|
|
324
|
+
// Declaration system actions. Non-configurable.
|
|
325
|
+
DUPLICATE_DETECTED: "DUPLICATE_DETECTED",
|
|
326
|
+
REJECT: "REJECT",
|
|
327
|
+
// REJECT_DECLARATION
|
|
328
|
+
MARK_AS_DUPLICATE: "MARK_AS_DUPLICATE",
|
|
329
|
+
MARK_AS_NOT_DUPLICATE: "MARK_AS_NOT_DUPLICATE",
|
|
330
|
+
ARCHIVE: "ARCHIVE",
|
|
331
|
+
UNARCHIVE: "UNARCHIVE",
|
|
332
|
+
// Record actions
|
|
333
|
+
PRINT_CERTIFICATE: "PRINT_CERTIFICATE",
|
|
334
|
+
REQUEST_CORRECTION: "REQUEST_CORRECTION",
|
|
335
|
+
REJECT_CORRECTION: "REJECT_CORRECTION",
|
|
336
|
+
APPROVE_CORRECTION: "APPROVE_CORRECTION",
|
|
337
|
+
// General actions
|
|
338
|
+
READ: "READ",
|
|
339
|
+
ASSIGN: "ASSIGN",
|
|
340
|
+
UNASSIGN: "UNASSIGN",
|
|
341
|
+
// Custom action
|
|
342
|
+
CUSTOM: "CUSTOM"
|
|
343
|
+
};
|
|
344
|
+
var ConfirmableActions = [
|
|
345
|
+
ActionType.NOTIFY,
|
|
346
|
+
ActionType.DECLARE,
|
|
347
|
+
ActionType.EDIT,
|
|
348
|
+
ActionType.REGISTER,
|
|
349
|
+
ActionType.REJECT,
|
|
350
|
+
ActionType.ARCHIVE,
|
|
351
|
+
ActionType.UNARCHIVE,
|
|
352
|
+
ActionType.PRINT_CERTIFICATE,
|
|
353
|
+
ActionType.REQUEST_CORRECTION,
|
|
354
|
+
ActionType.APPROVE_CORRECTION,
|
|
355
|
+
ActionType.REJECT_CORRECTION,
|
|
356
|
+
ActionType.CUSTOM
|
|
357
|
+
];
|
|
358
|
+
var ActionTypes = z4.enum([
|
|
359
|
+
"DELETE",
|
|
360
|
+
"CREATE",
|
|
361
|
+
"NOTIFY",
|
|
362
|
+
"DECLARE",
|
|
363
|
+
"EDIT",
|
|
364
|
+
"REGISTER",
|
|
365
|
+
"DUPLICATE_DETECTED",
|
|
366
|
+
"REJECT",
|
|
367
|
+
"MARK_AS_DUPLICATE",
|
|
368
|
+
"MARK_AS_NOT_DUPLICATE",
|
|
369
|
+
"ARCHIVE",
|
|
370
|
+
"UNARCHIVE",
|
|
371
|
+
"PRINT_CERTIFICATE",
|
|
372
|
+
"REQUEST_CORRECTION",
|
|
373
|
+
"REJECT_CORRECTION",
|
|
374
|
+
"APPROVE_CORRECTION",
|
|
375
|
+
"READ",
|
|
376
|
+
"ASSIGN",
|
|
377
|
+
"UNASSIGN",
|
|
378
|
+
"CUSTOM"
|
|
379
|
+
]);
|
|
380
|
+
var ClientSpecificAction = {
|
|
381
|
+
REVIEW_CORRECTION_REQUEST: "REVIEW_CORRECTION_REQUEST"
|
|
382
|
+
};
|
|
383
|
+
var declarationActionValues = [
|
|
384
|
+
ActionTypes.enum.DECLARE,
|
|
385
|
+
ActionTypes.enum.EDIT,
|
|
386
|
+
ActionTypes.enum.REGISTER,
|
|
387
|
+
ActionTypes.enum.NOTIFY,
|
|
388
|
+
ActionTypes.enum.DUPLICATE_DETECTED
|
|
389
|
+
];
|
|
390
|
+
var DeclarationActions = ActionTypes.extract(declarationActionValues);
|
|
391
|
+
var declarationUpdateActionValues = [
|
|
392
|
+
...declarationActionValues,
|
|
393
|
+
ActionTypes.enum.REQUEST_CORRECTION
|
|
394
|
+
];
|
|
395
|
+
var DeclarationUpdateActions = ActionTypes.extract(
|
|
396
|
+
declarationUpdateActionValues
|
|
397
|
+
);
|
|
398
|
+
var annotationActions = ActionTypes.exclude(declarationActionValues);
|
|
399
|
+
var writeActions = ActionTypes.exclude([
|
|
400
|
+
ActionType.CREATE,
|
|
401
|
+
ActionType.READ,
|
|
402
|
+
ActionType.ASSIGN,
|
|
403
|
+
ActionType.UNASSIGN
|
|
404
|
+
]);
|
|
405
|
+
var WorkqueueActionType = ActionTypes.extract([
|
|
406
|
+
ActionType.READ,
|
|
407
|
+
ActionType.DELETE,
|
|
408
|
+
ActionType.DECLARE,
|
|
409
|
+
ActionType.REGISTER,
|
|
410
|
+
ActionType.EDIT,
|
|
411
|
+
ActionType.REJECT,
|
|
412
|
+
ActionType.MARK_AS_DUPLICATE,
|
|
413
|
+
ActionType.ARCHIVE,
|
|
414
|
+
ActionType.UNARCHIVE,
|
|
415
|
+
ActionType.PRINT_CERTIFICATE,
|
|
416
|
+
ActionType.REQUEST_CORRECTION
|
|
417
|
+
]);
|
|
418
|
+
var META_ACTIONS = [
|
|
419
|
+
ActionType.ASSIGN,
|
|
420
|
+
ActionType.UNASSIGN,
|
|
421
|
+
ActionType.READ
|
|
422
|
+
];
|
|
423
|
+
|
|
424
|
+
// ../commons/src/events/AuditLog.ts
|
|
425
|
+
var AuditLogEntryBase = z5.object({
|
|
426
|
+
id: z5.string(),
|
|
427
|
+
clientId: z5.string(),
|
|
428
|
+
clientType: TokenUserType,
|
|
429
|
+
createdAt: z5.string()
|
|
430
|
+
});
|
|
431
|
+
var EventCreateEntrySchema = AuditLogEntryBase.extend({
|
|
432
|
+
operation: z5.literal("event.create"),
|
|
433
|
+
requestData: z5.object({
|
|
434
|
+
transactionId: z5.string(),
|
|
435
|
+
type: z5.string(),
|
|
436
|
+
createdAtLocation: z5.string().nullable()
|
|
437
|
+
}),
|
|
438
|
+
responseSummary: z5.object({
|
|
439
|
+
eventId: z5.string(),
|
|
440
|
+
trackingId: z5.string()
|
|
441
|
+
})
|
|
442
|
+
});
|
|
443
|
+
var EventGetEntrySchema = AuditLogEntryBase.extend({
|
|
444
|
+
operation: z5.literal("event.get"),
|
|
445
|
+
requestData: z5.object({ eventId: z5.string() }),
|
|
446
|
+
responseSummary: z5.object({
|
|
447
|
+
eventType: z5.string(),
|
|
448
|
+
trackingId: z5.string()
|
|
449
|
+
})
|
|
450
|
+
});
|
|
451
|
+
var EventSearchEntrySchema = AuditLogEntryBase.extend({
|
|
452
|
+
operation: z5.literal("event.search"),
|
|
453
|
+
clientType: z5.literal("system"),
|
|
454
|
+
requestData: z5.object({
|
|
455
|
+
query: z5.record(z5.string(), z5.unknown()).nullable(),
|
|
456
|
+
limit: z5.number().nullable(),
|
|
457
|
+
offset: z5.number().nullable()
|
|
458
|
+
}),
|
|
459
|
+
responseSummary: z5.object({
|
|
460
|
+
total: z5.number(),
|
|
461
|
+
eventIds: z5.array(z5.string())
|
|
462
|
+
})
|
|
463
|
+
});
|
|
464
|
+
var EventActionEntrySchema = AuditLogEntryBase.extend({
|
|
465
|
+
operation: z5.enum([
|
|
466
|
+
"event.actions.notify.request",
|
|
467
|
+
"event.actions.declare.request",
|
|
468
|
+
"event.actions.register.request",
|
|
469
|
+
"event.actions.reject.request",
|
|
470
|
+
"event.actions.validate.request",
|
|
471
|
+
"event.actions.edit.request",
|
|
472
|
+
"event.actions.assign.request",
|
|
473
|
+
"event.actions.unassign.request",
|
|
474
|
+
"event.actions.read.request",
|
|
475
|
+
"event.actions.archive.request",
|
|
476
|
+
"event.actions.unarchive.request",
|
|
477
|
+
"event.actions.reinstate.request",
|
|
478
|
+
"event.actions.print_certificate.request",
|
|
479
|
+
"event.actions.correction.request.request",
|
|
480
|
+
"event.actions.correction.approve.request",
|
|
481
|
+
"event.actions.correction.reject.request",
|
|
482
|
+
"event.actions.mark_as_duplicate.request",
|
|
625
483
|
"event.actions.mark_as_not_duplicate.request"
|
|
626
484
|
]),
|
|
627
|
-
requestData:
|
|
628
|
-
eventId:
|
|
629
|
-
actionType:
|
|
630
|
-
eventType:
|
|
631
|
-
trackingId:
|
|
632
|
-
transactionId:
|
|
485
|
+
requestData: z5.object({
|
|
486
|
+
eventId: z5.string(),
|
|
487
|
+
actionType: z5.string(),
|
|
488
|
+
eventType: z5.string(),
|
|
489
|
+
trackingId: z5.string(),
|
|
490
|
+
transactionId: z5.string()
|
|
633
491
|
})
|
|
634
492
|
});
|
|
635
493
|
var EventCustomActionEntrySchema = AuditLogEntryBase.extend({
|
|
636
|
-
operation:
|
|
637
|
-
requestData:
|
|
638
|
-
eventId:
|
|
639
|
-
actionType:
|
|
640
|
-
customAction:
|
|
641
|
-
eventType:
|
|
642
|
-
trackingId:
|
|
643
|
-
transactionId:
|
|
494
|
+
operation: z5.literal("event.actions.custom.request"),
|
|
495
|
+
requestData: z5.object({
|
|
496
|
+
eventId: z5.string(),
|
|
497
|
+
actionType: z5.literal(ActionType.CUSTOM),
|
|
498
|
+
customAction: z5.string(),
|
|
499
|
+
eventType: z5.string(),
|
|
500
|
+
trackingId: z5.string(),
|
|
501
|
+
transactionId: z5.string()
|
|
644
502
|
})
|
|
645
503
|
});
|
|
646
504
|
var IntegrationCreateEntrySchema = AuditLogEntryBase.extend({
|
|
647
|
-
operation:
|
|
648
|
-
requestData:
|
|
649
|
-
responseSummary:
|
|
505
|
+
operation: z5.literal("integrations.create"),
|
|
506
|
+
requestData: z5.object({ name: z5.string(), scopes: z5.array(z5.string()) }),
|
|
507
|
+
responseSummary: z5.object({ clientId: z5.string() })
|
|
650
508
|
});
|
|
651
509
|
var IntegrationRefreshTokenEntrySchema = AuditLogEntryBase.extend({
|
|
652
|
-
operation:
|
|
653
|
-
requestData:
|
|
654
|
-
responseSummary:
|
|
510
|
+
operation: z5.literal("integrations.refreshToken"),
|
|
511
|
+
requestData: z5.object({ clientId: z5.string() }),
|
|
512
|
+
responseSummary: z5.object({ clientId: z5.string() })
|
|
655
513
|
});
|
|
656
514
|
var IntegrationDeactivateEntrySchema = AuditLogEntryBase.extend({
|
|
657
|
-
operation:
|
|
658
|
-
requestData:
|
|
659
|
-
responseSummary:
|
|
515
|
+
operation: z5.literal("integrations.deactivate"),
|
|
516
|
+
requestData: z5.object({ id: z5.string() }),
|
|
517
|
+
responseSummary: z5.object({ id: z5.string(), status: z5.string() })
|
|
660
518
|
});
|
|
661
519
|
var IntegrationActivateEntrySchema = AuditLogEntryBase.extend({
|
|
662
|
-
operation:
|
|
663
|
-
requestData:
|
|
664
|
-
responseSummary:
|
|
520
|
+
operation: z5.literal("integrations.activate"),
|
|
521
|
+
requestData: z5.object({ id: z5.string() }),
|
|
522
|
+
responseSummary: z5.object({ id: z5.string(), status: z5.string() })
|
|
665
523
|
});
|
|
666
524
|
var IntegrationDeleteEntrySchema = AuditLogEntryBase.extend({
|
|
667
|
-
operation:
|
|
668
|
-
requestData:
|
|
669
|
-
responseSummary:
|
|
525
|
+
operation: z5.literal("integrations.delete"),
|
|
526
|
+
requestData: z5.object({ id: z5.string() }),
|
|
527
|
+
responseSummary: z5.object({ id: z5.string(), name: z5.string() })
|
|
670
528
|
});
|
|
671
529
|
var IntegrationRefreshSecretEntrySchema = AuditLogEntryBase.extend({
|
|
672
|
-
operation:
|
|
673
|
-
requestData:
|
|
674
|
-
responseSummary:
|
|
530
|
+
operation: z5.literal("integrations.refreshSecret"),
|
|
531
|
+
requestData: z5.object({ id: z5.string() }),
|
|
532
|
+
responseSummary: z5.object({ clientId: z5.string() })
|
|
533
|
+
});
|
|
534
|
+
var createdVersionFields = {
|
|
535
|
+
id: z5.string(),
|
|
536
|
+
versionId: z5.string(),
|
|
537
|
+
name: z5.string(),
|
|
538
|
+
externalId: z5.string().nullish(),
|
|
539
|
+
effectiveFrom: z5.string(),
|
|
540
|
+
status: z5.string()
|
|
541
|
+
};
|
|
542
|
+
var LocationCreateEntrySchema = AuditLogEntryBase.extend({
|
|
543
|
+
operation: z5.literal("locations.create"),
|
|
544
|
+
requestData: z5.object({
|
|
545
|
+
...createdVersionFields,
|
|
546
|
+
administrativeAreaId: z5.string().nullish(),
|
|
547
|
+
locationType: z5.string().nullish()
|
|
548
|
+
})
|
|
549
|
+
});
|
|
550
|
+
var AdministrativeAreaCreateEntrySchema = AuditLogEntryBase.extend({
|
|
551
|
+
operation: z5.literal("administrativeAreas.create"),
|
|
552
|
+
requestData: z5.object({
|
|
553
|
+
...createdVersionFields,
|
|
554
|
+
parentId: z5.string().nullish()
|
|
555
|
+
})
|
|
675
556
|
});
|
|
676
557
|
var AttachmentUploadEntrySchema = AuditLogEntryBase.extend({
|
|
677
|
-
operation:
|
|
678
|
-
requestData:
|
|
679
|
-
transactionId:
|
|
680
|
-
path:
|
|
558
|
+
operation: z5.literal("attachments.upload"),
|
|
559
|
+
requestData: z5.object({
|
|
560
|
+
transactionId: z5.string(),
|
|
561
|
+
path: z5.string().nullable()
|
|
681
562
|
}),
|
|
682
|
-
responseSummary:
|
|
563
|
+
responseSummary: z5.object({ fileUrl: z5.string() })
|
|
683
564
|
});
|
|
684
|
-
var subjectOnly =
|
|
685
|
-
var subjectWithReason =
|
|
686
|
-
subjectId:
|
|
687
|
-
reason:
|
|
688
|
-
comment:
|
|
565
|
+
var subjectOnly = z5.object({ subjectId: z5.string() });
|
|
566
|
+
var subjectWithReason = z5.object({
|
|
567
|
+
subjectId: z5.string(),
|
|
568
|
+
reason: z5.string(),
|
|
569
|
+
comment: z5.string().optional()
|
|
689
570
|
});
|
|
690
571
|
var UserCreateEntrySchema = AuditLogEntryBase.extend({
|
|
691
|
-
operation:
|
|
692
|
-
requestData:
|
|
693
|
-
subjectId:
|
|
694
|
-
role:
|
|
695
|
-
primaryOfficeId:
|
|
572
|
+
operation: z5.literal("user.create_user"),
|
|
573
|
+
requestData: z5.object({
|
|
574
|
+
subjectId: z5.string(),
|
|
575
|
+
role: z5.string(),
|
|
576
|
+
primaryOfficeId: z5.string()
|
|
696
577
|
})
|
|
697
578
|
});
|
|
698
579
|
var UserReasonEntrySchema = AuditLogEntryBase.extend({
|
|
699
|
-
operation:
|
|
580
|
+
operation: z5.enum(["user.deactivate", "user.reactivate"]),
|
|
700
581
|
requestData: subjectWithReason
|
|
701
582
|
});
|
|
702
583
|
var UserSubjectOnlyEntrySchema = AuditLogEntryBase.extend({
|
|
703
|
-
operation:
|
|
584
|
+
operation: z5.enum([
|
|
704
585
|
"user.edit_user",
|
|
705
586
|
"user.logged_in",
|
|
706
587
|
"user.logged_out",
|
|
@@ -714,14 +595,14 @@ var UserSubjectOnlyEntrySchema = AuditLogEntryBase.extend({
|
|
|
714
595
|
requestData: subjectOnly
|
|
715
596
|
});
|
|
716
597
|
var UserEmailChangedEntrySchema = AuditLogEntryBase.extend({
|
|
717
|
-
operation:
|
|
598
|
+
operation: z5.literal("user.email_address_changed"),
|
|
718
599
|
requestData: subjectOnly,
|
|
719
|
-
responseSummary:
|
|
600
|
+
responseSummary: z5.object({ email: z5.string() })
|
|
720
601
|
});
|
|
721
602
|
var UserPhoneChangedEntrySchema = AuditLogEntryBase.extend({
|
|
722
|
-
operation:
|
|
603
|
+
operation: z5.literal("user.phone_number_changed"),
|
|
723
604
|
requestData: subjectOnly,
|
|
724
|
-
responseSummary:
|
|
605
|
+
responseSummary: z5.object({ phoneNumber: z5.string() })
|
|
725
606
|
});
|
|
726
607
|
var userBaseOmit = {
|
|
727
608
|
id: true,
|
|
@@ -729,14 +610,14 @@ var userBaseOmit = {
|
|
|
729
610
|
clientType: true,
|
|
730
611
|
createdAt: true
|
|
731
612
|
};
|
|
732
|
-
var UserAuditRecordInput =
|
|
613
|
+
var UserAuditRecordInput = z5.discriminatedUnion("operation", [
|
|
733
614
|
UserCreateEntrySchema.omit(userBaseOmit),
|
|
734
615
|
UserReasonEntrySchema.omit(userBaseOmit),
|
|
735
616
|
UserSubjectOnlyEntrySchema.omit(userBaseOmit),
|
|
736
617
|
UserEmailChangedEntrySchema.omit(userBaseOmit),
|
|
737
618
|
UserPhoneChangedEntrySchema.omit(userBaseOmit)
|
|
738
619
|
]);
|
|
739
|
-
var AuditLogEntrySchema =
|
|
620
|
+
var AuditLogEntrySchema = z5.discriminatedUnion("operation", [
|
|
740
621
|
EventCreateEntrySchema,
|
|
741
622
|
EventGetEntrySchema,
|
|
742
623
|
EventSearchEntrySchema,
|
|
@@ -748,6 +629,8 @@ var AuditLogEntrySchema = z8.discriminatedUnion("operation", [
|
|
|
748
629
|
IntegrationActivateEntrySchema,
|
|
749
630
|
IntegrationDeleteEntrySchema,
|
|
750
631
|
IntegrationRefreshSecretEntrySchema,
|
|
632
|
+
LocationCreateEntrySchema,
|
|
633
|
+
AdministrativeAreaCreateEntrySchema,
|
|
751
634
|
AttachmentUploadEntrySchema,
|
|
752
635
|
UserCreateEntrySchema,
|
|
753
636
|
UserReasonEntrySchema,
|
|
@@ -763,11 +646,76 @@ var CHILD_ONBOARDING_EVENT = "child-onboarding";
|
|
|
763
646
|
// ../commons/src/events/ActionConfig.ts
|
|
764
647
|
var z24 = __toESM(require("zod/v4"));
|
|
765
648
|
|
|
649
|
+
// ../commons/src/events/TranslationConfig.ts
|
|
650
|
+
var z6 = __toESM(require("zod/v4"));
|
|
651
|
+
var TranslationConfig = z6.object({
|
|
652
|
+
id: z6.string().describe(
|
|
653
|
+
"The identifier of the translation referred in translation CSV files"
|
|
654
|
+
),
|
|
655
|
+
defaultMessage: z6.string().describe("Default translation message"),
|
|
656
|
+
description: z6.string().describe(
|
|
657
|
+
"Describe the translation for a translator to be able to identify it."
|
|
658
|
+
)
|
|
659
|
+
}).meta({
|
|
660
|
+
description: "Translation configuration",
|
|
661
|
+
id: "TranslationConfig"
|
|
662
|
+
});
|
|
663
|
+
|
|
766
664
|
// ../commons/src/events/FieldConfig.ts
|
|
767
665
|
var import_v43 = __toESM(require("zod/v4"));
|
|
768
666
|
|
|
667
|
+
// ../commons/src/events/Conditional.ts
|
|
668
|
+
var z7 = __toESM(require("zod/v4"));
|
|
669
|
+
var Conditional = z7.any().describe("JSONSchema").meta({
|
|
670
|
+
description: "JSON schema conditional configuration",
|
|
671
|
+
id: "Conditional"
|
|
672
|
+
});
|
|
673
|
+
var ConditionalType = {
|
|
674
|
+
SHOW: "SHOW",
|
|
675
|
+
ENABLE: "ENABLE",
|
|
676
|
+
DISPLAY_ON_REVIEW: "DISPLAY_ON_REVIEW"
|
|
677
|
+
};
|
|
678
|
+
var ShowConditional = z7.object({
|
|
679
|
+
type: z7.literal(ConditionalType.SHOW),
|
|
680
|
+
conditional: Conditional
|
|
681
|
+
}).describe(
|
|
682
|
+
"If 'SHOW' conditional is defined, the component is shown to the user only if the condition is met"
|
|
683
|
+
);
|
|
684
|
+
var EnableConditional = z7.object({
|
|
685
|
+
type: z7.literal(ConditionalType.ENABLE),
|
|
686
|
+
conditional: Conditional
|
|
687
|
+
}).describe(
|
|
688
|
+
"If 'ENABLE' conditional is defined, the component is enabled only if the condition is met"
|
|
689
|
+
);
|
|
690
|
+
var ActionConditional = z7.discriminatedUnion("type", [
|
|
691
|
+
// Action can be shown / hidden
|
|
692
|
+
ShowConditional,
|
|
693
|
+
// Action can be shown to the user in the list but as disabled
|
|
694
|
+
EnableConditional
|
|
695
|
+
]).meta({
|
|
696
|
+
id: "ActionConditional",
|
|
697
|
+
description: "Conditional gating whether an action is shown (SHOW) or enabled (ENABLE). When omitted from an action, the action is shown and enabled for everyone."
|
|
698
|
+
});
|
|
699
|
+
var DisplayOnReviewConditional = z7.object({
|
|
700
|
+
type: z7.literal(ConditionalType.DISPLAY_ON_REVIEW),
|
|
701
|
+
conditional: Conditional
|
|
702
|
+
}).describe(
|
|
703
|
+
"If 'DISPLAY_ON_REVIEW' conditional is defined, the component is shown on the review page only if both the 'DISPLAY_ON_REVIEW' and 'SHOW' conditions are met. This should only be used for fields within declaration forms, as they are the only ones with review pages."
|
|
704
|
+
);
|
|
705
|
+
var FieldConditional = z7.discriminatedUnion("type", [
|
|
706
|
+
// Field input can be shown / hidden
|
|
707
|
+
ShowConditional,
|
|
708
|
+
// Field input can be shown to the user but as disabled
|
|
709
|
+
EnableConditional,
|
|
710
|
+
// Field output can be shown / hidden on the review page
|
|
711
|
+
DisplayOnReviewConditional
|
|
712
|
+
]).meta({
|
|
713
|
+
id: "FieldConditional",
|
|
714
|
+
description: "Conditional gating whether a form field is shown (SHOW), enabled (ENABLE), or displayed on the review page (DISPLAY_ON_REVIEW). When omitted, the field is shown and enabled for everyone, and is displayed on review whenever it has a value."
|
|
715
|
+
});
|
|
716
|
+
|
|
769
717
|
// ../commons/src/events/FieldType.ts
|
|
770
|
-
var
|
|
718
|
+
var z8 = __toESM(require("zod/v4"));
|
|
771
719
|
var FieldType = {
|
|
772
720
|
NAME: "NAME",
|
|
773
721
|
PHONE: "PHONE",
|
|
@@ -831,7 +779,7 @@ var FieldType = {
|
|
|
831
779
|
*/
|
|
832
780
|
_EXPERIMENTAL_CUSTOM: "CUSTOM"
|
|
833
781
|
};
|
|
834
|
-
var FileFieldType =
|
|
782
|
+
var FileFieldType = z8.enum([
|
|
835
783
|
FieldType.FILE,
|
|
836
784
|
FieldType.FILE_WITH_OPTIONS,
|
|
837
785
|
FieldType.SIGNATURE
|
|
@@ -867,164 +815,160 @@ var HiddenFieldTypes = [
|
|
|
867
815
|
];
|
|
868
816
|
|
|
869
817
|
// ../commons/src/events/FieldValue.ts
|
|
870
|
-
var
|
|
818
|
+
var z12 = __toESM(require("zod/v4"));
|
|
871
819
|
|
|
872
820
|
// ../commons/src/documents.ts
|
|
873
|
-
var
|
|
874
|
-
var FullDocumentUrl =
|
|
821
|
+
var z9 = __toESM(require("zod/v4"));
|
|
822
|
+
var FullDocumentUrl = z9.string().brand("FullDocumentUrl").describe(
|
|
875
823
|
"A full url with protocol, host, bucket name, starting from the root of the S3 server, https://minio.opencrvs.com/bucket-name/document-id.jpg"
|
|
876
824
|
);
|
|
877
|
-
var FullDocumentPath =
|
|
825
|
+
var FullDocumentPath = z9.string().overwrite((val) => val.startsWith("/") ? val : `/${val}`).meta({ effectType: "input", type: "string" }).describe(
|
|
878
826
|
"A full absolute path with bucket name, starting from the root of the S3 server, /bucket-name/document-id.jpg"
|
|
879
827
|
);
|
|
880
|
-
var DocumentPath =
|
|
828
|
+
var DocumentPath = z9.string().brand("DocumentPath").describe(
|
|
881
829
|
"A relative path within the S3 bucket, never starting with /. e.g. document-id.jpg or directory/document-id.jpg. The document service constructs the full /bucket/path internally."
|
|
882
830
|
);
|
|
883
831
|
|
|
884
832
|
// ../commons/src/events/CompositeFieldValue.ts
|
|
885
|
-
var
|
|
833
|
+
var z10 = __toESM(require("zod/v4"));
|
|
886
834
|
var AddressType = {
|
|
887
835
|
DOMESTIC: "DOMESTIC",
|
|
888
836
|
INTERNATIONAL: "INTERNATIONAL"
|
|
889
837
|
};
|
|
890
|
-
var FileFieldValue =
|
|
838
|
+
var FileFieldValue = z10.object({
|
|
891
839
|
path: DocumentPath,
|
|
892
|
-
originalFilename:
|
|
893
|
-
type:
|
|
894
|
-
});
|
|
895
|
-
var NameFieldValue =
|
|
896
|
-
firstname:
|
|
897
|
-
surname:
|
|
898
|
-
middlename:
|
|
899
|
-
});
|
|
900
|
-
var NameFieldUpdateValue =
|
|
901
|
-
firstname:
|
|
902
|
-
surname:
|
|
903
|
-
middlename:
|
|
904
|
-
}).or(
|
|
905
|
-
var StreetLevelDetailsValue =
|
|
906
|
-
var StreetLevelDetailsUpdateValue =
|
|
907
|
-
var BaseAddressFieldValue =
|
|
908
|
-
country:
|
|
840
|
+
originalFilename: z10.string(),
|
|
841
|
+
type: z10.string()
|
|
842
|
+
});
|
|
843
|
+
var NameFieldValue = z10.object({
|
|
844
|
+
firstname: z10.string(),
|
|
845
|
+
surname: z10.string(),
|
|
846
|
+
middlename: z10.string().optional()
|
|
847
|
+
});
|
|
848
|
+
var NameFieldUpdateValue = z10.object({
|
|
849
|
+
firstname: z10.string().nullish(),
|
|
850
|
+
surname: z10.string().nullish(),
|
|
851
|
+
middlename: z10.string().nullish()
|
|
852
|
+
}).or(z10.null()).or(z10.undefined());
|
|
853
|
+
var StreetLevelDetailsValue = z10.record(z10.string(), z10.string()).optional();
|
|
854
|
+
var StreetLevelDetailsUpdateValue = z10.record(z10.string(), z10.string().nullable()).nullish();
|
|
855
|
+
var BaseAddressFieldValue = z10.object({
|
|
856
|
+
country: z10.string(),
|
|
909
857
|
streetLevelDetails: StreetLevelDetailsValue
|
|
910
858
|
});
|
|
911
|
-
var BaseAddressFieldUpdateValue =
|
|
912
|
-
country:
|
|
859
|
+
var BaseAddressFieldUpdateValue = z10.object({
|
|
860
|
+
country: z10.string().nullish(),
|
|
913
861
|
streetLevelDetails: StreetLevelDetailsUpdateValue
|
|
914
862
|
});
|
|
915
863
|
var DomesticAddressFieldValue = BaseAddressFieldValue.extend({
|
|
916
|
-
addressType:
|
|
917
|
-
administrativeArea:
|
|
864
|
+
addressType: z10.literal(AddressType.DOMESTIC),
|
|
865
|
+
administrativeArea: z10.string().uuid()
|
|
918
866
|
});
|
|
919
867
|
var InternationalAddressFieldValue = BaseAddressFieldValue.extend({
|
|
920
|
-
addressType:
|
|
868
|
+
addressType: z10.literal(AddressType.INTERNATIONAL)
|
|
921
869
|
});
|
|
922
|
-
var AddressFieldValue =
|
|
870
|
+
var AddressFieldValue = z10.discriminatedUnion("addressType", [
|
|
923
871
|
DomesticAddressFieldValue,
|
|
924
872
|
InternationalAddressFieldValue
|
|
925
873
|
]);
|
|
926
874
|
var DomesticAddressUpdateFieldValue = BaseAddressFieldUpdateValue.extend({
|
|
927
|
-
addressType:
|
|
928
|
-
administrativeArea:
|
|
875
|
+
addressType: z10.literal(AddressType.DOMESTIC),
|
|
876
|
+
administrativeArea: z10.string().uuid().nullish()
|
|
929
877
|
/* Leaf level admin structure */
|
|
930
878
|
});
|
|
931
879
|
var InternationalAddressUpdateFieldValue = BaseAddressFieldUpdateValue.extend(
|
|
932
880
|
{
|
|
933
|
-
addressType:
|
|
881
|
+
addressType: z10.literal(AddressType.INTERNATIONAL)
|
|
934
882
|
}
|
|
935
883
|
);
|
|
936
|
-
var AddressFieldUpdateValue =
|
|
884
|
+
var AddressFieldUpdateValue = z10.discriminatedUnion("addressType", [
|
|
937
885
|
DomesticAddressUpdateFieldValue,
|
|
938
886
|
InternationalAddressUpdateFieldValue
|
|
939
887
|
]).nullish();
|
|
940
|
-
var FileFieldValueWithOption =
|
|
888
|
+
var FileFieldValueWithOption = z10.object({
|
|
941
889
|
path: DocumentPath,
|
|
942
|
-
originalFilename:
|
|
943
|
-
type:
|
|
944
|
-
option:
|
|
945
|
-
});
|
|
946
|
-
var FileFieldWithOptionValue =
|
|
947
|
-
var HttpFieldValue =
|
|
948
|
-
loading:
|
|
949
|
-
error:
|
|
950
|
-
data:
|
|
951
|
-
});
|
|
952
|
-
var HttpFieldUpdateValue =
|
|
953
|
-
loading:
|
|
954
|
-
error:
|
|
955
|
-
data:
|
|
956
|
-
}).or(
|
|
957
|
-
var QueryParamReaderFieldValue =
|
|
958
|
-
data:
|
|
959
|
-
updatedAt:
|
|
890
|
+
originalFilename: z10.string(),
|
|
891
|
+
type: z10.string(),
|
|
892
|
+
option: z10.string()
|
|
893
|
+
});
|
|
894
|
+
var FileFieldWithOptionValue = z10.array(FileFieldValueWithOption);
|
|
895
|
+
var HttpFieldValue = z10.object({
|
|
896
|
+
loading: z10.boolean(),
|
|
897
|
+
error: z10.object({ statusCode: z10.number(), message: z10.string() }).nullish(),
|
|
898
|
+
data: z10.any()
|
|
899
|
+
});
|
|
900
|
+
var HttpFieldUpdateValue = z10.object({
|
|
901
|
+
loading: z10.boolean().nullish(),
|
|
902
|
+
error: z10.object({ statusCode: z10.number(), message: z10.string() }).nullish(),
|
|
903
|
+
data: z10.any().nullish()
|
|
904
|
+
}).or(z10.null()).or(z10.undefined());
|
|
905
|
+
var QueryParamReaderFieldValue = z10.object({
|
|
906
|
+
data: z10.record(z10.string(), z10.string()),
|
|
907
|
+
updatedAt: z10.iso.datetime()
|
|
960
908
|
}).nullish();
|
|
961
|
-
var QueryParamReaderFieldUpdateValue =
|
|
962
|
-
data:
|
|
909
|
+
var QueryParamReaderFieldUpdateValue = z10.object({
|
|
910
|
+
data: z10.record(z10.string(), z10.string())
|
|
963
911
|
});
|
|
964
|
-
var ReadDataValue =
|
|
965
|
-
data:
|
|
912
|
+
var ReadDataValue = z10.object({
|
|
913
|
+
data: z10.any()
|
|
966
914
|
});
|
|
967
915
|
var QrReaderFieldValue = ReadDataValue;
|
|
968
916
|
var IdReaderFieldValue = ReadDataValue;
|
|
969
|
-
var NumberWithUnitFieldValue =
|
|
970
|
-
numericValue:
|
|
971
|
-
unit:
|
|
917
|
+
var NumberWithUnitFieldValue = z10.object({
|
|
918
|
+
numericValue: z10.number(),
|
|
919
|
+
unit: z10.string()
|
|
972
920
|
});
|
|
973
|
-
var NumberWithUnitFieldUpdateValue =
|
|
974
|
-
numericValue:
|
|
975
|
-
unit:
|
|
921
|
+
var NumberWithUnitFieldUpdateValue = z10.object({
|
|
922
|
+
numericValue: z10.number().optional(),
|
|
923
|
+
unit: z10.string().optional()
|
|
976
924
|
});
|
|
977
|
-
var CustomFieldValue =
|
|
925
|
+
var CustomFieldValue = z10.unknown().brand("CustomFieldValue");
|
|
978
926
|
|
|
979
927
|
// ../commons/src/events/PlainDate.ts
|
|
980
928
|
var import_zod = require("zod");
|
|
981
929
|
var PlainDate = import_zod.z.string().date().brand("PlainDate").describe("Date in the format YYYY-MM-DD");
|
|
982
|
-
function plainDateToLocalDate(date) {
|
|
983
|
-
const [year, month, day] = date.split("-").map(Number);
|
|
984
|
-
return new Date(year, month - 1, day);
|
|
985
|
-
}
|
|
986
930
|
|
|
987
931
|
// ../commons/src/events/FieldValue.ts
|
|
988
|
-
var TextValue =
|
|
989
|
-
var HiddenFieldValue =
|
|
990
|
-
var NonEmptyTextValue =
|
|
991
|
-
var DateValue =
|
|
992
|
-
var AgeValue =
|
|
993
|
-
age:
|
|
994
|
-
asOfDateRef:
|
|
932
|
+
var TextValue = z12.string();
|
|
933
|
+
var HiddenFieldValue = z12.string();
|
|
934
|
+
var NonEmptyTextValue = z12.string().trim().min(1);
|
|
935
|
+
var DateValue = z12.iso.date().describe("Date in the format YYYY-MM-DD");
|
|
936
|
+
var AgeValue = z12.object({
|
|
937
|
+
age: z12.number(),
|
|
938
|
+
asOfDateRef: z12.string()
|
|
995
939
|
});
|
|
996
940
|
var AgeUpdateValue = AgeValue.optional().nullable();
|
|
997
|
-
var AutocompleteValue =
|
|
998
|
-
label:
|
|
999
|
-
value:
|
|
941
|
+
var AutocompleteValue = z12.object({
|
|
942
|
+
label: z12.string(),
|
|
943
|
+
value: z12.string()
|
|
1000
944
|
});
|
|
1001
945
|
var AutocompleteUpdateValue = AutocompleteValue.optional().nullable();
|
|
1002
|
-
var TimeValue =
|
|
1003
|
-
var DatetimeValue =
|
|
1004
|
-
var SelectDateRangeValue =
|
|
946
|
+
var TimeValue = z12.string().regex(/^([01][0-9]|2[0-3]):[0-5][0-9]$/);
|
|
947
|
+
var DatetimeValue = z12.iso.datetime();
|
|
948
|
+
var SelectDateRangeValue = z12.enum([
|
|
1005
949
|
"last7Days",
|
|
1006
950
|
"last30Days",
|
|
1007
951
|
"last90Days",
|
|
1008
952
|
"last365Days"
|
|
1009
953
|
]);
|
|
1010
|
-
var DateRangeFieldValue =
|
|
954
|
+
var DateRangeFieldValue = z12.object({
|
|
1011
955
|
start: PlainDate,
|
|
1012
956
|
end: PlainDate
|
|
1013
957
|
}).or(PlainDate).describe(
|
|
1014
958
|
"Date range with start and end dates in the format YYYY-MM-DD. Inclusive start, exclusive end."
|
|
1015
959
|
);
|
|
1016
|
-
var EmailValue =
|
|
1017
|
-
var CheckboxFieldValue =
|
|
1018
|
-
var NumberFieldValue =
|
|
960
|
+
var EmailValue = z12.email();
|
|
961
|
+
var CheckboxFieldValue = z12.boolean();
|
|
962
|
+
var NumberFieldValue = z12.number();
|
|
1019
963
|
var SignatureFieldValue = FileFieldValue;
|
|
1020
|
-
var ButtonFieldValue =
|
|
1021
|
-
var VerificationStatusValue =
|
|
964
|
+
var ButtonFieldValue = z12.number();
|
|
965
|
+
var VerificationStatusValue = z12.enum([
|
|
1022
966
|
"verified",
|
|
1023
967
|
"authenticated",
|
|
1024
968
|
"failed",
|
|
1025
969
|
"pending"
|
|
1026
970
|
]);
|
|
1027
|
-
var LeafFieldValues =
|
|
971
|
+
var LeafFieldValues = z12.union([
|
|
1028
972
|
AddressFieldValue,
|
|
1029
973
|
TextValue,
|
|
1030
974
|
PlainDate,
|
|
@@ -1050,11 +994,11 @@ var LeafFieldValues = z13.union([
|
|
|
1050
994
|
AutocompleteValue,
|
|
1051
995
|
AutocompleteUpdateValue
|
|
1052
996
|
]);
|
|
1053
|
-
var FieldGroupValue =
|
|
1054
|
-
var DataFieldValue =
|
|
1055
|
-
data:
|
|
997
|
+
var FieldGroupValue = z12.record(z12.string(), LeafFieldValues);
|
|
998
|
+
var DataFieldValue = z12.object({
|
|
999
|
+
data: z12.record(z12.string(), LeafFieldValues)
|
|
1056
1000
|
}).nullish();
|
|
1057
|
-
var FieldValue =
|
|
1001
|
+
var FieldValue = z12.union([
|
|
1058
1002
|
LeafFieldValues,
|
|
1059
1003
|
DataFieldValue,
|
|
1060
1004
|
FieldGroupValue
|
|
@@ -1088,7 +1032,7 @@ function safeUnion(schemas) {
|
|
|
1088
1032
|
const sortedSchemas = [...schemas].sort(
|
|
1089
1033
|
(a, b) => schemaPriority(a) - schemaPriority(b)
|
|
1090
1034
|
);
|
|
1091
|
-
return
|
|
1035
|
+
return z12.any().superRefine((val, ctx) => {
|
|
1092
1036
|
for (const schema of sortedSchemas) {
|
|
1093
1037
|
if (schema.safeParse(val).success) {
|
|
1094
1038
|
return;
|
|
@@ -1127,9 +1071,9 @@ var FieldUpdateValue = safeUnion([
|
|
|
1127
1071
|
]);
|
|
1128
1072
|
|
|
1129
1073
|
// ../commons/src/events/serializers/user/serializer.ts
|
|
1130
|
-
var
|
|
1131
|
-
var SerializedUserField =
|
|
1132
|
-
$userField:
|
|
1074
|
+
var z13 = __toESM(require("zod/v4"));
|
|
1075
|
+
var SerializedUserField = z13.object({
|
|
1076
|
+
$userField: z13.enum([
|
|
1133
1077
|
"id",
|
|
1134
1078
|
"name",
|
|
1135
1079
|
"role",
|
|
@@ -1143,7 +1087,7 @@ var SerializedUserField = z14.object({
|
|
|
1143
1087
|
"primaryOfficeId",
|
|
1144
1088
|
"administrativeAreaId"
|
|
1145
1089
|
]),
|
|
1146
|
-
$location:
|
|
1090
|
+
$location: z13.string().optional()
|
|
1147
1091
|
});
|
|
1148
1092
|
function userSerializer(userField) {
|
|
1149
1093
|
return {
|
|
@@ -1169,22 +1113,27 @@ var import_v4 = require("zod/v4");
|
|
|
1169
1113
|
var z16 = __toESM(require("zod/v4"));
|
|
1170
1114
|
|
|
1171
1115
|
// ../commons/src/events/ActionDocument.ts
|
|
1172
|
-
var
|
|
1173
|
-
var ActionUpdate =
|
|
1116
|
+
var z14 = __toESM(require("zod/v4"));
|
|
1117
|
+
var ActionUpdate = z14.record(z14.string(), FieldUpdateValue).describe(
|
|
1174
1118
|
"Record of field-level changes made by an action. Supports partial updates and nullable values."
|
|
1175
1119
|
);
|
|
1176
|
-
var EventState =
|
|
1120
|
+
var EventState = z14.record(z14.string(), FieldValue).describe(
|
|
1177
1121
|
"Aggregate representation of event data after all actions have been applied, with all updates consolidated and null values removed."
|
|
1178
1122
|
);
|
|
1179
|
-
var
|
|
1123
|
+
var ActionStatus = {
|
|
1124
|
+
Requested: "Requested",
|
|
1125
|
+
Accepted: "Accepted",
|
|
1126
|
+
Rejected: "Rejected"
|
|
1127
|
+
};
|
|
1128
|
+
var ActionBase = z14.object({
|
|
1180
1129
|
id: UUID.describe("Unique identifier of the action."),
|
|
1181
|
-
transactionId:
|
|
1130
|
+
transactionId: z14.string().describe("Unique identifier of the transaction."),
|
|
1182
1131
|
createdByUserType: TokenUserType.describe(
|
|
1183
1132
|
"Indicates whether the action was created by a human-user or by a system-user."
|
|
1184
1133
|
),
|
|
1185
|
-
createdAt:
|
|
1186
|
-
createdBy:
|
|
1187
|
-
createdByRole:
|
|
1134
|
+
createdAt: z14.string().datetime().describe("Timestamp indicating when the action was created."),
|
|
1135
|
+
createdBy: z14.string().describe("Identifier of the user who created the action."),
|
|
1136
|
+
createdByRole: z14.string().optional().describe("Role of the user who created the action."),
|
|
1188
1137
|
createdBySignature: DocumentPath.nullish().describe(
|
|
1189
1138
|
"Reference to the signature of the user who created the action."
|
|
1190
1139
|
),
|
|
@@ -1196,7 +1145,7 @@ var ActionBase = z15.object({
|
|
|
1196
1145
|
"Declaration data defined by the ActionConfig. Supports partial updates."
|
|
1197
1146
|
),
|
|
1198
1147
|
annotation: ActionUpdate.optional().nullable().describe("Action-specific metadata used to annotate the event."),
|
|
1199
|
-
status:
|
|
1148
|
+
status: z14.enum([
|
|
1200
1149
|
ActionStatus.Requested,
|
|
1201
1150
|
ActionStatus.Accepted,
|
|
1202
1151
|
ActionStatus.Rejected
|
|
@@ -1208,139 +1157,139 @@ var ActionBase = z15.object({
|
|
|
1208
1157
|
)
|
|
1209
1158
|
});
|
|
1210
1159
|
var AssignedAction = ActionBase.extend(
|
|
1211
|
-
|
|
1212
|
-
type:
|
|
1213
|
-
assignedTo:
|
|
1160
|
+
z14.object({
|
|
1161
|
+
type: z14.literal(ActionType.ASSIGN),
|
|
1162
|
+
assignedTo: z14.string().describe("Identifier of the user to whom the action is assigned.")
|
|
1214
1163
|
// TODO move into 'content' property
|
|
1215
1164
|
}).shape
|
|
1216
1165
|
);
|
|
1217
1166
|
var UnassignedAction = ActionBase.extend(
|
|
1218
|
-
|
|
1219
|
-
type:
|
|
1167
|
+
z14.object({
|
|
1168
|
+
type: z14.literal(ActionType.UNASSIGN)
|
|
1220
1169
|
}).shape
|
|
1221
1170
|
);
|
|
1222
1171
|
var RegisterAction = ActionBase.extend(
|
|
1223
|
-
|
|
1224
|
-
type:
|
|
1225
|
-
registrationNumber:
|
|
1172
|
+
z14.object({
|
|
1173
|
+
type: z14.literal(ActionType.REGISTER),
|
|
1174
|
+
registrationNumber: z14.string().optional().describe(
|
|
1226
1175
|
"Registration number of the event. Always present for accepted registrations."
|
|
1227
1176
|
)
|
|
1228
1177
|
// TODO move into 'content' property
|
|
1229
1178
|
}).shape
|
|
1230
1179
|
);
|
|
1231
1180
|
var DeclareAction = ActionBase.extend(
|
|
1232
|
-
|
|
1233
|
-
type:
|
|
1181
|
+
z14.object({
|
|
1182
|
+
type: z14.literal(ActionType.DECLARE)
|
|
1234
1183
|
}).shape
|
|
1235
1184
|
);
|
|
1236
|
-
var ReasonContent =
|
|
1237
|
-
reason:
|
|
1185
|
+
var ReasonContent = z14.object({
|
|
1186
|
+
reason: z14.string().min(1, { error: "Message cannot be empty" }).describe(
|
|
1238
1187
|
"Message describing the reason for rejecting or archiving the event."
|
|
1239
1188
|
)
|
|
1240
1189
|
});
|
|
1241
1190
|
var RejectAction = ActionBase.extend(
|
|
1242
|
-
|
|
1243
|
-
type:
|
|
1191
|
+
z14.object({
|
|
1192
|
+
type: z14.literal(ActionType.REJECT),
|
|
1244
1193
|
content: ReasonContent
|
|
1245
1194
|
}).shape
|
|
1246
1195
|
);
|
|
1247
|
-
var PotentialDuplicate =
|
|
1196
|
+
var PotentialDuplicate = z14.object({
|
|
1248
1197
|
id: UUID,
|
|
1249
|
-
trackingId:
|
|
1198
|
+
trackingId: z14.string()
|
|
1250
1199
|
});
|
|
1251
1200
|
var DuplicateDetectedAction = ActionBase.extend(
|
|
1252
|
-
|
|
1253
|
-
type:
|
|
1254
|
-
content:
|
|
1255
|
-
duplicates:
|
|
1201
|
+
z14.object({
|
|
1202
|
+
type: z14.literal(ActionType.DUPLICATE_DETECTED),
|
|
1203
|
+
content: z14.object({
|
|
1204
|
+
duplicates: z14.array(PotentialDuplicate)
|
|
1256
1205
|
})
|
|
1257
1206
|
}).shape
|
|
1258
1207
|
);
|
|
1259
1208
|
var MarkNotDuplicateAction = ActionBase.extend(
|
|
1260
|
-
|
|
1261
|
-
type:
|
|
1209
|
+
z14.object({
|
|
1210
|
+
type: z14.literal(ActionType.MARK_AS_NOT_DUPLICATE)
|
|
1262
1211
|
}).shape
|
|
1263
1212
|
);
|
|
1264
1213
|
var MarkAsDuplicateAction = ActionBase.extend(
|
|
1265
|
-
|
|
1266
|
-
type:
|
|
1267
|
-
content:
|
|
1214
|
+
z14.object({
|
|
1215
|
+
type: z14.literal(ActionType.MARK_AS_DUPLICATE),
|
|
1216
|
+
content: z14.object({
|
|
1268
1217
|
duplicateOf: UUID
|
|
1269
1218
|
}).optional()
|
|
1270
1219
|
}).shape
|
|
1271
1220
|
);
|
|
1272
1221
|
var ArchiveAction = ActionBase.extend(
|
|
1273
|
-
|
|
1274
|
-
type:
|
|
1222
|
+
z14.object({
|
|
1223
|
+
type: z14.literal(ActionType.ARCHIVE),
|
|
1275
1224
|
content: ReasonContent
|
|
1276
1225
|
}).shape
|
|
1277
1226
|
);
|
|
1278
1227
|
var UnarchiveAction = ActionBase.extend(
|
|
1279
|
-
|
|
1280
|
-
type:
|
|
1228
|
+
z14.object({
|
|
1229
|
+
type: z14.literal(ActionType.UNARCHIVE)
|
|
1281
1230
|
}).shape
|
|
1282
1231
|
);
|
|
1283
1232
|
var CreatedAction = ActionBase.extend(
|
|
1284
|
-
|
|
1285
|
-
type:
|
|
1233
|
+
z14.object({
|
|
1234
|
+
type: z14.literal(ActionType.CREATE)
|
|
1286
1235
|
}).shape
|
|
1287
1236
|
);
|
|
1288
1237
|
var NotifiedAction = ActionBase.extend(
|
|
1289
|
-
|
|
1290
|
-
type:
|
|
1238
|
+
z14.object({
|
|
1239
|
+
type: z14.literal(ActionType.NOTIFY)
|
|
1291
1240
|
}).shape
|
|
1292
1241
|
);
|
|
1293
1242
|
var EditAction = ActionBase.extend(
|
|
1294
|
-
|
|
1295
|
-
type:
|
|
1243
|
+
z14.object({
|
|
1244
|
+
type: z14.literal(ActionType.EDIT),
|
|
1296
1245
|
/** @deprecated New Edit-actions should no longer contain content. This is kept for old 2.0 edits. */
|
|
1297
|
-
content:
|
|
1298
|
-
comment:
|
|
1246
|
+
content: z14.object({
|
|
1247
|
+
comment: z14.string().describe("Comment for the edit action.").optional()
|
|
1299
1248
|
}).optional()
|
|
1300
1249
|
}).shape
|
|
1301
1250
|
);
|
|
1302
|
-
var PrintContent =
|
|
1303
|
-
templateId:
|
|
1251
|
+
var PrintContent = z14.object({
|
|
1252
|
+
templateId: z14.string().optional()
|
|
1304
1253
|
});
|
|
1305
1254
|
var PrintCertificateAction = ActionBase.extend(
|
|
1306
|
-
|
|
1307
|
-
type:
|
|
1255
|
+
z14.object({
|
|
1256
|
+
type: z14.literal(ActionType.PRINT_CERTIFICATE),
|
|
1308
1257
|
content: PrintContent.optional().nullable()
|
|
1309
1258
|
}).shape
|
|
1310
1259
|
);
|
|
1311
1260
|
var RequestedCorrectionAction = ActionBase.extend(
|
|
1312
|
-
|
|
1313
|
-
type:
|
|
1261
|
+
z14.object({
|
|
1262
|
+
type: z14.literal(ActionType.REQUEST_CORRECTION)
|
|
1314
1263
|
}).shape
|
|
1315
1264
|
);
|
|
1316
1265
|
var ApprovedCorrectionAction = ActionBase.extend(
|
|
1317
|
-
|
|
1318
|
-
type:
|
|
1319
|
-
requestId:
|
|
1266
|
+
z14.object({
|
|
1267
|
+
type: z14.literal(ActionType.APPROVE_CORRECTION),
|
|
1268
|
+
requestId: z14.string(),
|
|
1320
1269
|
// TODO move into 'content' property
|
|
1321
|
-
content:
|
|
1270
|
+
content: z14.object({ immediateCorrection: z14.boolean().optional() }).optional()
|
|
1322
1271
|
}).shape
|
|
1323
1272
|
);
|
|
1324
1273
|
var RejectedCorrectionAction = ActionBase.extend(
|
|
1325
|
-
|
|
1326
|
-
type:
|
|
1327
|
-
requestId:
|
|
1274
|
+
z14.object({
|
|
1275
|
+
type: z14.literal(ActionType.REJECT_CORRECTION),
|
|
1276
|
+
requestId: z14.string(),
|
|
1328
1277
|
// TODO move into 'content' property
|
|
1329
1278
|
content: ReasonContent
|
|
1330
1279
|
}).shape
|
|
1331
1280
|
);
|
|
1332
1281
|
var ReadAction = ActionBase.extend(
|
|
1333
|
-
|
|
1334
|
-
type:
|
|
1282
|
+
z14.object({
|
|
1283
|
+
type: z14.literal(ActionType.READ)
|
|
1335
1284
|
}).shape
|
|
1336
1285
|
);
|
|
1337
1286
|
var CustomAction = ActionBase.merge(
|
|
1338
|
-
|
|
1339
|
-
type:
|
|
1340
|
-
customActionType:
|
|
1287
|
+
z14.object({
|
|
1288
|
+
type: z14.literal(ActionType.CUSTOM),
|
|
1289
|
+
customActionType: z14.string()
|
|
1341
1290
|
})
|
|
1342
1291
|
);
|
|
1343
|
-
var ActionDocument =
|
|
1292
|
+
var ActionDocument = z14.discriminatedUnion("type", [
|
|
1344
1293
|
CreatedAction.meta({ id: "CreatedAction" }),
|
|
1345
1294
|
RejectAction.meta({ id: "RejectAction" }),
|
|
1346
1295
|
DuplicateDetectedAction.meta({ id: "DuplicateDetectedAction" }),
|
|
@@ -1367,12 +1316,64 @@ var AsyncRejectActionDocument = ActionBase.omit({
|
|
|
1367
1316
|
declaration: true,
|
|
1368
1317
|
annotation: true
|
|
1369
1318
|
}).extend(
|
|
1370
|
-
|
|
1371
|
-
type:
|
|
1372
|
-
status:
|
|
1319
|
+
z14.object({
|
|
1320
|
+
type: z14.enum(ConfirmableActions),
|
|
1321
|
+
status: z14.literal(ActionStatus.Rejected)
|
|
1373
1322
|
}).shape
|
|
1374
1323
|
);
|
|
1375
|
-
var Action =
|
|
1324
|
+
var Action = z14.union([ActionDocument, AsyncRejectActionDocument]);
|
|
1325
|
+
|
|
1326
|
+
// ../commons/src/events/Flag.ts
|
|
1327
|
+
var z15 = __toESM(require("zod/v4"));
|
|
1328
|
+
var InherentFlags = {
|
|
1329
|
+
INCOMPLETE: "incomplete",
|
|
1330
|
+
REJECTED: "rejected",
|
|
1331
|
+
CORRECTION_REQUESTED: "correction-requested",
|
|
1332
|
+
POTENTIAL_DUPLICATE: "potential-duplicate",
|
|
1333
|
+
/**
|
|
1334
|
+
* This flag is set by the Edit-action and removed after the declaration or registration.
|
|
1335
|
+
* A record should never stay with the EDIT_IN_PROGRESS flag, since it should always be declared or registered right after.
|
|
1336
|
+
*
|
|
1337
|
+
* We only use this flag to determine that a NOTIFY, DECLARE or REGISTER action is allowed next.
|
|
1338
|
+
*/
|
|
1339
|
+
EDIT_IN_PROGRESS: "edit-in-progress"
|
|
1340
|
+
};
|
|
1341
|
+
var ActionFlag = z15.string().regex(
|
|
1342
|
+
new RegExp(
|
|
1343
|
+
`^(${Object.values(ActionType).join("|").toLowerCase()}):(${Object.values(
|
|
1344
|
+
ActionStatus
|
|
1345
|
+
).join("|").toLowerCase()})$`
|
|
1346
|
+
),
|
|
1347
|
+
"Flag must be in the format ActionType:ActionStatus (lowerCase)"
|
|
1348
|
+
);
|
|
1349
|
+
var CustomFlag = z15.string().refine((val) => !Object.values(InherentFlags).includes(val), {
|
|
1350
|
+
message: `Custom flag cannot be one of the inherent flags: ${Object.values(
|
|
1351
|
+
InherentFlags
|
|
1352
|
+
).join(", ")}`
|
|
1353
|
+
}).refine((val) => !ActionFlag.safeParse(val).success, {
|
|
1354
|
+
message: "Custom flag cannot match the ActionFlag pattern (ActionType:ActionStatus)."
|
|
1355
|
+
}).describe("Custom flag identifier defined by the country config.");
|
|
1356
|
+
var Flag = ActionFlag.or(z15.enum(InherentFlags)).or(CustomFlag);
|
|
1357
|
+
var FlagConfig = z15.object({
|
|
1358
|
+
id: CustomFlag,
|
|
1359
|
+
requiresAction: z15.boolean().describe(
|
|
1360
|
+
"Indicates if this flag expects an action to be performed to be cleared."
|
|
1361
|
+
),
|
|
1362
|
+
label: TranslationConfig.describe("Human readable label of the flag.")
|
|
1363
|
+
}).meta({
|
|
1364
|
+
id: "FlagConfig",
|
|
1365
|
+
description: "Configuration for a custom flag that can be added to or removed from records by event actions."
|
|
1366
|
+
});
|
|
1367
|
+
var ActionFlagConfig = z15.object({
|
|
1368
|
+
id: Flag,
|
|
1369
|
+
operation: z15.enum(["add", "remove"]).describe("Operation to perform on the flag."),
|
|
1370
|
+
conditional: Conditional.optional().describe(
|
|
1371
|
+
"When conditional is met, the operation is performed on the flag. If not provided, the operation is performed unconditionally."
|
|
1372
|
+
)
|
|
1373
|
+
}).meta({
|
|
1374
|
+
id: "ActionFlagConfig",
|
|
1375
|
+
description: "Add or remove operation applied to a flag when the parent action is accepted. Optionally gated by a conditional."
|
|
1376
|
+
});
|
|
1376
1377
|
|
|
1377
1378
|
// ../commons/src/events/EventMetadata.ts
|
|
1378
1379
|
var EventStatus = z16.enum([
|
|
@@ -1530,6 +1531,13 @@ var Range = import_v4.z.object({
|
|
|
1530
1531
|
}).meta({
|
|
1531
1532
|
id: "Range"
|
|
1532
1533
|
});
|
|
1534
|
+
var ContainsFlags = import_v4.z.object({
|
|
1535
|
+
anyOf: import_v4.z.array(Flag).optional(),
|
|
1536
|
+
noneOf: import_v4.z.array(Flag).optional(),
|
|
1537
|
+
allOf: import_v4.z.array(Flag).optional()
|
|
1538
|
+
}).meta({
|
|
1539
|
+
id: "ContainsFlags"
|
|
1540
|
+
});
|
|
1533
1541
|
var Within = import_v4.z.object({ type: import_v4.z.literal("within"), location: import_v4.z.string() }).meta({
|
|
1534
1542
|
id: "Within"
|
|
1535
1543
|
});
|
|
@@ -3163,13 +3171,13 @@ var AdvancedSearchConfig = z28.object({
|
|
|
3163
3171
|
});
|
|
3164
3172
|
|
|
3165
3173
|
// ../commons/src/events/utils.ts
|
|
3166
|
-
var
|
|
3174
|
+
var import_lodash = require("lodash");
|
|
3167
3175
|
|
|
3168
3176
|
// ../commons/src/conditionals/validate.ts
|
|
3169
3177
|
var import__ = __toESM(require("ajv/dist/2019"));
|
|
3170
3178
|
var import_ajv_formats = __toESM(require("ajv-formats"));
|
|
3171
|
-
var
|
|
3172
|
-
var
|
|
3179
|
+
var z31 = __toESM(require("zod/v4"));
|
|
3180
|
+
var import_date_fns = require("date-fns");
|
|
3173
3181
|
|
|
3174
3182
|
// ../commons/src/events/FieldTypeMapping.ts
|
|
3175
3183
|
var z30 = __toESM(require("zod/v4"));
|
|
@@ -3177,300 +3185,200 @@ var z30 = __toESM(require("zod/v4"));
|
|
|
3177
3185
|
// ../commons/src/events/DynamicFieldValue.ts
|
|
3178
3186
|
var z29 = __toESM(require("zod/v4"));
|
|
3179
3187
|
|
|
3180
|
-
// ../commons/src/
|
|
3181
|
-
var
|
|
3182
|
-
|
|
3183
|
-
|
|
3184
|
-
|
|
3185
|
-
|
|
3186
|
-
|
|
3187
|
-
|
|
3188
|
-
|
|
3189
|
-
|
|
3190
|
-
return x;
|
|
3191
|
-
}
|
|
3192
|
-
function joinValues(values, separator = " ") {
|
|
3193
|
-
return values.filter((value) => !!value).join(separator).trim();
|
|
3194
|
-
}
|
|
3195
|
-
var FullNameV1 = z31.array(
|
|
3196
|
-
z31.object({
|
|
3197
|
-
use: z31.string(),
|
|
3198
|
-
family: z31.string(),
|
|
3199
|
-
given: z31.array(z31.string())
|
|
3188
|
+
// ../commons/src/conditionals/validate.ts
|
|
3189
|
+
var ajv = new import__.default({
|
|
3190
|
+
$data: true,
|
|
3191
|
+
allowUnionTypes: true,
|
|
3192
|
+
strict: false
|
|
3193
|
+
// Allow minContains and other newer features
|
|
3194
|
+
});
|
|
3195
|
+
var DataContext = z31.object({
|
|
3196
|
+
rootData: z31.object({
|
|
3197
|
+
$leafAdminStructureLocationIds: z31.array(z31.object({ id: UUID }))
|
|
3200
3198
|
})
|
|
3201
|
-
);
|
|
3202
|
-
function
|
|
3203
|
-
|
|
3204
|
-
|
|
3205
|
-
|
|
3206
|
-
|
|
3207
|
-
|
|
3199
|
+
});
|
|
3200
|
+
function resolveDataPath(rootData, dataPath, instancePath) {
|
|
3201
|
+
const pathParts = dataPath.split("/");
|
|
3202
|
+
const levels = parseInt(pathParts[0], 10);
|
|
3203
|
+
const referencePath = pathParts.slice(1);
|
|
3204
|
+
const instanceParts = instancePath.split("/").filter(Boolean);
|
|
3205
|
+
const traversedParts = instanceParts.slice(0, -levels);
|
|
3206
|
+
let current = rootData;
|
|
3207
|
+
for (const part of traversedParts) {
|
|
3208
|
+
if (current === null || current === void 0) {
|
|
3209
|
+
return void 0;
|
|
3210
|
+
}
|
|
3211
|
+
current = current[part];
|
|
3208
3212
|
}
|
|
3209
|
-
const
|
|
3210
|
-
|
|
3211
|
-
|
|
3212
|
-
newObj[key] = omitKeyDeep(obj[key], keyToRemove);
|
|
3213
|
+
for (const part of referencePath) {
|
|
3214
|
+
if (current === null || current === void 0) {
|
|
3215
|
+
return void 0;
|
|
3213
3216
|
}
|
|
3217
|
+
current = current[part];
|
|
3214
3218
|
}
|
|
3215
|
-
return
|
|
3219
|
+
return current;
|
|
3216
3220
|
}
|
|
3217
|
-
|
|
3218
|
-
|
|
3219
|
-
var import_lodash = require("lodash");
|
|
3220
|
-
function getActionRequests(actionType, actions) {
|
|
3221
|
-
const filtered = actions.filter((action) => action.type === actionType).reverse();
|
|
3222
|
-
const accept = filtered.find(
|
|
3223
|
-
(action) => action.status === ActionStatus.Accepted
|
|
3224
|
-
);
|
|
3225
|
-
const request = filtered.find(
|
|
3226
|
-
(action) => action.status === ActionStatus.Requested
|
|
3227
|
-
);
|
|
3228
|
-
const reject = filtered.find(
|
|
3229
|
-
(action) => action.status === ActionStatus.Rejected
|
|
3230
|
-
);
|
|
3231
|
-
return {
|
|
3232
|
-
reject,
|
|
3233
|
-
accept,
|
|
3234
|
-
request
|
|
3235
|
-
};
|
|
3221
|
+
function todayISO() {
|
|
3222
|
+
return (0, import_date_fns.formatISO)(/* @__PURE__ */ new Date(), { representation: "date" });
|
|
3236
3223
|
}
|
|
3237
|
-
|
|
3238
|
-
|
|
3239
|
-
|
|
3240
|
-
|
|
3241
|
-
|
|
3242
|
-
|
|
3243
|
-
return null;
|
|
3224
|
+
var compiledFunctionCache = /* @__PURE__ */ new Map();
|
|
3225
|
+
function compileClientFunction(code) {
|
|
3226
|
+
let fn = compiledFunctionCache.get(code);
|
|
3227
|
+
if (!fn) {
|
|
3228
|
+
fn = new Function(`return (${code})`)();
|
|
3229
|
+
compiledFunctionCache.set(code, fn);
|
|
3244
3230
|
}
|
|
3245
|
-
|
|
3246
|
-
return {
|
|
3247
|
-
// When 3rd party API returns 200 OK, we assume that the request was accepted, and persist single 'accepted' action.
|
|
3248
|
-
createdAt: requestAction?.createdAt ?? acceptAction.createdAt,
|
|
3249
|
-
createdBy: requestAction?.createdBy ?? acceptAction.createdBy,
|
|
3250
|
-
createdByUserType: requestAction?.createdByUserType ?? acceptAction.createdByUserType,
|
|
3251
|
-
createdAtLocation: requestAction?.createdAtLocation ?? acceptAction.createdAtLocation,
|
|
3252
|
-
acceptedAt: acceptAction.createdAt,
|
|
3253
|
-
createdByRole: requestAction?.createdByRole ?? acceptAction.createdByRole,
|
|
3254
|
-
registrationNumber
|
|
3255
|
-
};
|
|
3256
|
-
}
|
|
3257
|
-
var updateActions = ActionTypes.extract([
|
|
3258
|
-
ActionType.CREATE,
|
|
3259
|
-
ActionType.NOTIFY,
|
|
3260
|
-
ActionType.EDIT,
|
|
3261
|
-
ActionType.DECLARE,
|
|
3262
|
-
ActionType.REGISTER,
|
|
3263
|
-
ActionType.REJECT,
|
|
3264
|
-
ActionType.ARCHIVE,
|
|
3265
|
-
ActionType.UNARCHIVE,
|
|
3266
|
-
ActionType.PRINT_CERTIFICATE,
|
|
3267
|
-
ActionType.REQUEST_CORRECTION,
|
|
3268
|
-
ActionType.APPROVE_CORRECTION,
|
|
3269
|
-
ActionType.REJECT_CORRECTION,
|
|
3270
|
-
ActionType.CUSTOM
|
|
3271
|
-
]);
|
|
3272
|
-
function getActionUpdateMetadata(actions) {
|
|
3273
|
-
const createAction = getOrThrow(
|
|
3274
|
-
actions.find((action) => action.type === ActionType.CREATE),
|
|
3275
|
-
`Event has no ${ActionType.CREATE} action`
|
|
3276
|
-
);
|
|
3277
|
-
const metadataFields = [
|
|
3278
|
-
"createdAt",
|
|
3279
|
-
"createdBy",
|
|
3280
|
-
"createdByUserType",
|
|
3281
|
-
"createdAtLocation",
|
|
3282
|
-
"createdByRole"
|
|
3283
|
-
];
|
|
3284
|
-
return actions.filter(({ type }) => updateActions.safeParse(type).success).reduce(
|
|
3285
|
-
(_2, action) => {
|
|
3286
|
-
if (action.originalActionId) {
|
|
3287
|
-
const originalAction = actions.find(({ id }) => id === action.originalActionId) ?? action;
|
|
3288
|
-
return (0, import_lodash.pick)(originalAction, metadataFields);
|
|
3289
|
-
}
|
|
3290
|
-
return (0, import_lodash.pick)(action, metadataFields);
|
|
3291
|
-
},
|
|
3292
|
-
(0, import_lodash.pick)(createAction, metadataFields)
|
|
3293
|
-
);
|
|
3231
|
+
return fn;
|
|
3294
3232
|
}
|
|
3295
|
-
|
|
3233
|
+
(0, import_ajv_formats.default)(ajv);
|
|
3234
|
+
function buildClientFunctionContext(input) {
|
|
3296
3235
|
return {
|
|
3297
|
-
|
|
3298
|
-
|
|
3299
|
-
|
|
3300
|
-
),
|
|
3301
|
-
|
|
3302
|
-
|
|
3303
|
-
|
|
3304
|
-
|
|
3305
|
-
|
|
3306
|
-
|
|
3307
|
-
|
|
3308
|
-
)
|
|
3236
|
+
$form: input.form,
|
|
3237
|
+
$now: todayISO(),
|
|
3238
|
+
// eslint-disable-next-line @typescript-eslint/no-use-before-define
|
|
3239
|
+
$online: isOnline(),
|
|
3240
|
+
$user: input.validatorContext?.user,
|
|
3241
|
+
$event: input.validatorContext?.event,
|
|
3242
|
+
$leafAdminStructureLocationIds: input.validatorContext?.leafAdminStructureLocationIds ?? [],
|
|
3243
|
+
user: input.systemVariables?.user,
|
|
3244
|
+
$window: input.systemVariables?.$window,
|
|
3245
|
+
locations: input.locations,
|
|
3246
|
+
adminLevelIds: input.adminLevelIds
|
|
3309
3247
|
};
|
|
3310
3248
|
}
|
|
3311
|
-
|
|
3312
|
-
|
|
3313
|
-
var import_lodash2 = require("lodash");
|
|
3314
|
-
var import_date_fns = require("date-fns");
|
|
3315
|
-
function isFlagConditionMet(conditional, form, action) {
|
|
3316
|
-
const now2 = (0, import_date_fns.isValid)((0, import_date_fns.parseISO)(action.createdAt)) ? (0, import_date_fns.formatISO)((0, import_date_fns.parseISO)(action.createdAt), { representation: "date" }) : (0, import_date_fns.formatISO)(/* @__PURE__ */ new Date(), { representation: "date" });
|
|
3317
|
-
return validate(conditional, {
|
|
3318
|
-
$form: form,
|
|
3319
|
-
$now: now2,
|
|
3320
|
-
$online: true,
|
|
3321
|
-
$user: {
|
|
3322
|
-
sub: "",
|
|
3323
|
-
exp: "",
|
|
3324
|
-
role: action.createdByRole,
|
|
3325
|
-
algorithm: "",
|
|
3326
|
-
scope: [],
|
|
3327
|
-
userType: action.createdByUserType
|
|
3328
|
-
}
|
|
3329
|
-
});
|
|
3330
|
-
}
|
|
3331
|
-
function actionConfigRemovesFlag(action, flagId, actionsUpToAndIncluding, event2, eventConfiguration) {
|
|
3332
|
-
if (!isActionConfigType(action.type)) {
|
|
3333
|
-
return false;
|
|
3334
|
-
}
|
|
3335
|
-
const actionConfig = getActionConfig({
|
|
3336
|
-
eventConfiguration,
|
|
3337
|
-
actionType: action.type,
|
|
3338
|
-
customActionType: "customActionType" in action ? action.customActionType : void 0
|
|
3339
|
-
});
|
|
3340
|
-
const removeOperations = (actionConfig?.flags ?? []).filter(
|
|
3341
|
-
({ id, operation }) => id === flagId && operation === "remove"
|
|
3342
|
-
);
|
|
3343
|
-
if (removeOperations.length === 0) {
|
|
3344
|
-
return false;
|
|
3345
|
-
}
|
|
3346
|
-
const eventUpToThisAction = { ...event2, actions: actionsUpToAndIncluding };
|
|
3347
|
-
const declaration = aggregateActionDeclarations(eventUpToThisAction);
|
|
3348
|
-
const annotation = aggregateActionAnnotations(eventUpToThisAction);
|
|
3349
|
-
const form = { ...declaration, ...annotation };
|
|
3350
|
-
return removeOperations.some(
|
|
3351
|
-
({ conditional }) => conditional ? isFlagConditionMet(conditional, form, action) : true
|
|
3352
|
-
);
|
|
3249
|
+
function runClientFunction(code, data, context) {
|
|
3250
|
+
return compileClientFunction(code)(data, context);
|
|
3353
3251
|
}
|
|
3354
|
-
|
|
3355
|
-
|
|
3356
|
-
|
|
3357
|
-
|
|
3358
|
-
|
|
3359
|
-
|
|
3360
|
-
{
|
|
3361
|
-
|
|
3362
|
-
|
|
3363
|
-
// are deliberately excluded so the flag freezes across an archive/unarchive
|
|
3364
|
-
// round trip and comes back exactly as it was.
|
|
3365
|
-
flag: InherentFlags.INCOMPLETE,
|
|
3366
|
-
setOn: [ActionType.NOTIFY],
|
|
3367
|
-
resetOn: [ActionType.CREATE, ActionType.DECLARE, ActionType.REGISTER]
|
|
3368
|
-
},
|
|
3369
|
-
{
|
|
3370
|
-
flag: InherentFlags.REJECTED,
|
|
3371
|
-
setOn: [ActionType.REJECT],
|
|
3372
|
-
resetOn: [
|
|
3373
|
-
ActionType.NOTIFY,
|
|
3374
|
-
ActionType.DECLARE,
|
|
3375
|
-
ActionType.EDIT,
|
|
3376
|
-
ActionType.REGISTER
|
|
3377
|
-
]
|
|
3378
|
-
},
|
|
3379
|
-
{
|
|
3380
|
-
flag: InherentFlags.POTENTIAL_DUPLICATE,
|
|
3381
|
-
setOn: [ActionType.DUPLICATE_DETECTED],
|
|
3382
|
-
resetOn: [ActionType.MARK_AS_DUPLICATE, ActionType.MARK_AS_NOT_DUPLICATE]
|
|
3383
|
-
},
|
|
3384
|
-
{
|
|
3385
|
-
flag: InherentFlags.EDIT_IN_PROGRESS,
|
|
3386
|
-
setOn: [ActionType.EDIT],
|
|
3387
|
-
resetOnAnyOtherAction: true
|
|
3388
|
-
}
|
|
3389
|
-
];
|
|
3390
|
-
function resolveInherentFlag(rule, acceptedActions, event2, eventConfiguration) {
|
|
3391
|
-
return acceptedActions.reduce((present, action, idx) => {
|
|
3392
|
-
if (rule.setOn.includes(action.type)) {
|
|
3393
|
-
return true;
|
|
3252
|
+
ajv.addKeyword({
|
|
3253
|
+
keyword: "daysFromDate",
|
|
3254
|
+
type: "string",
|
|
3255
|
+
schemaType: "object",
|
|
3256
|
+
$data: true,
|
|
3257
|
+
errors: true,
|
|
3258
|
+
validate(schema, data, _2, dataContext) {
|
|
3259
|
+
if (!(dataContext && dataContext.rootData && typeof dataContext.rootData === "object" && "$now" in dataContext.rootData && typeof dataContext.rootData.$now === "string")) {
|
|
3260
|
+
throw new Error("Validation context must contain $now");
|
|
3394
3261
|
}
|
|
3395
|
-
|
|
3262
|
+
const { days, clause } = schema;
|
|
3263
|
+
if (typeof data !== "string") {
|
|
3396
3264
|
return false;
|
|
3397
3265
|
}
|
|
3398
|
-
|
|
3399
|
-
|
|
3400
|
-
rule.flag,
|
|
3401
|
-
acceptedActions.slice(0, idx + 1),
|
|
3402
|
-
event2,
|
|
3403
|
-
eventConfiguration
|
|
3404
|
-
)) {
|
|
3266
|
+
const date = new Date(data);
|
|
3267
|
+
if (isNaN(date.getTime())) {
|
|
3405
3268
|
return false;
|
|
3406
3269
|
}
|
|
3407
|
-
|
|
3408
|
-
|
|
3409
|
-
|
|
3410
|
-
|
|
3411
|
-
|
|
3412
|
-
|
|
3413
|
-
|
|
3414
|
-
if (isActionConfigType(action.type)) {
|
|
3415
|
-
actionConfig = getActionConfig({
|
|
3416
|
-
eventConfiguration,
|
|
3417
|
-
actionType: action.type,
|
|
3418
|
-
customActionType: "customActionType" in action ? action.customActionType : void 0
|
|
3419
|
-
});
|
|
3270
|
+
let referenceDate = schema.referenceDate;
|
|
3271
|
+
if (referenceDate && typeof referenceDate === "object" && "$data" in referenceDate) {
|
|
3272
|
+
referenceDate = resolveDataPath(
|
|
3273
|
+
dataContext.rootData,
|
|
3274
|
+
referenceDate.$data,
|
|
3275
|
+
dataContext.instancePath
|
|
3276
|
+
);
|
|
3420
3277
|
}
|
|
3421
|
-
if (!
|
|
3422
|
-
|
|
3278
|
+
if (!referenceDate) {
|
|
3279
|
+
referenceDate = dataContext.rootData.$now;
|
|
3423
3280
|
}
|
|
3424
|
-
const
|
|
3425
|
-
|
|
3426
|
-
|
|
3427
|
-
}
|
|
3428
|
-
const
|
|
3429
|
-
|
|
3430
|
-
|
|
3431
|
-
|
|
3432
|
-
|
|
3433
|
-
|
|
3434
|
-
|
|
3281
|
+
const baseDate = new Date(referenceDate);
|
|
3282
|
+
if (isNaN(baseDate.getTime())) {
|
|
3283
|
+
return false;
|
|
3284
|
+
}
|
|
3285
|
+
const offsetDate = new Date(baseDate.getTime() + days * 24 * 60 * 60 * 1e3);
|
|
3286
|
+
return clause === "after" ? (0, import_date_fns.isAfter)(date, offsetDate) : (0, import_date_fns.isBefore)(date, offsetDate);
|
|
3287
|
+
}
|
|
3288
|
+
});
|
|
3289
|
+
ajv.addKeyword({
|
|
3290
|
+
keyword: "isLeafLevelLocation",
|
|
3291
|
+
type: "string",
|
|
3292
|
+
schemaType: "boolean",
|
|
3293
|
+
$data: true,
|
|
3294
|
+
errors: true,
|
|
3295
|
+
// @ts-ignore -- Force type. We will move this away from AJV next. Parsing the array will take seconds and is only called by core.
|
|
3296
|
+
validate(_schema, data, _2, dataContext) {
|
|
3297
|
+
const locationIdInput = data;
|
|
3298
|
+
const locations = dataContext?.rootData.$leafAdminStructureLocationIds ?? [];
|
|
3299
|
+
return locations.some((location) => location.id === locationIdInput);
|
|
3300
|
+
}
|
|
3301
|
+
});
|
|
3302
|
+
ajv.addKeyword({
|
|
3303
|
+
keyword: "customClientValidator",
|
|
3304
|
+
schemaType: "object",
|
|
3305
|
+
errors: true,
|
|
3306
|
+
// @ts-expect-error -- AJV's public types don't expose `rootData`. All
|
|
3307
|
+
// `validate()` callers build root data via `buildClientFunctionContext`,
|
|
3308
|
+
// so the cast holds.
|
|
3309
|
+
validate(schema, data, _2, dataContext) {
|
|
3310
|
+
return Boolean(
|
|
3311
|
+
runClientFunction(
|
|
3312
|
+
schema.code,
|
|
3313
|
+
data,
|
|
3314
|
+
dataContext?.rootData ?? buildClientFunctionContext({ form: {} })
|
|
3435
3315
|
)
|
|
3436
3316
|
);
|
|
3437
|
-
|
|
3438
|
-
|
|
3439
|
-
|
|
3440
|
-
|
|
3441
|
-
|
|
3442
|
-
|
|
3443
|
-
|
|
3317
|
+
}
|
|
3318
|
+
});
|
|
3319
|
+
function isOnline() {
|
|
3320
|
+
if (typeof window !== "undefined" && typeof navigator !== "undefined") {
|
|
3321
|
+
return navigator.onLine;
|
|
3322
|
+
}
|
|
3323
|
+
return true;
|
|
3444
3324
|
}
|
|
3445
|
-
|
|
3446
|
-
|
|
3447
|
-
|
|
3448
|
-
|
|
3449
|
-
|
|
3450
|
-
|
|
3451
|
-
|
|
3452
|
-
|
|
3453
|
-
|
|
3454
|
-
|
|
3455
|
-
|
|
3456
|
-
|
|
3325
|
+
|
|
3326
|
+
// ../commons/src/utils.ts
|
|
3327
|
+
var z32 = __toESM(require("zod/v4"));
|
|
3328
|
+
var _ = __toESM(require("lodash"));
|
|
3329
|
+
var FullNameV1 = z32.array(
|
|
3330
|
+
z32.object({
|
|
3331
|
+
use: z32.string(),
|
|
3332
|
+
family: z32.string(),
|
|
3333
|
+
given: z32.array(z32.string())
|
|
3334
|
+
})
|
|
3335
|
+
);
|
|
3336
|
+
function omitKeyDeep(obj, keyToRemove) {
|
|
3337
|
+
if (Array.isArray(obj)) {
|
|
3338
|
+
return obj.map((item) => omitKeyDeep(item, keyToRemove));
|
|
3339
|
+
}
|
|
3340
|
+
if (obj === null || typeof obj !== "object") {
|
|
3341
|
+
return obj;
|
|
3342
|
+
}
|
|
3343
|
+
const newObj = {};
|
|
3344
|
+
for (const key of Object.keys(obj)) {
|
|
3345
|
+
if (key !== keyToRemove) {
|
|
3346
|
+
newObj[key] = omitKeyDeep(obj[key], keyToRemove);
|
|
3347
|
+
}
|
|
3348
|
+
}
|
|
3349
|
+
return newObj;
|
|
3457
3350
|
}
|
|
3458
|
-
|
|
3459
|
-
|
|
3460
|
-
|
|
3461
|
-
|
|
3462
|
-
return
|
|
3463
|
-
(rule) => resolveInherentFlag(rule, acceptedActions, event2, eventConfiguration)
|
|
3464
|
-
).map(({ flag }) => flag);
|
|
3351
|
+
|
|
3352
|
+
// ../commons/src/events/utils.ts
|
|
3353
|
+
var import_date_fns2 = require("date-fns");
|
|
3354
|
+
function getDeclarationFields(configuration) {
|
|
3355
|
+
return configuration.declaration.pages.flatMap(({ fields }) => fields);
|
|
3465
3356
|
}
|
|
3466
|
-
|
|
3467
|
-
|
|
3468
|
-
|
|
3469
|
-
|
|
3470
|
-
|
|
3471
|
-
|
|
3472
|
-
|
|
3357
|
+
var getActionAnnotationFields = (actionConfig) => {
|
|
3358
|
+
if (actionConfig.type === ActionType.REQUEST_CORRECTION) {
|
|
3359
|
+
return actionConfig.correctionForm.pages.flatMap(({ fields }) => fields);
|
|
3360
|
+
}
|
|
3361
|
+
if (actionConfig.type === ActionType.PRINT_CERTIFICATE) {
|
|
3362
|
+
return actionConfig.printForm.pages.flatMap(({ fields }) => fields);
|
|
3363
|
+
}
|
|
3364
|
+
const reviewFields = "review" in actionConfig && actionConfig.review != null ? actionConfig.review.fields : [];
|
|
3365
|
+
const formFields = "form" in actionConfig && actionConfig.form != null ? actionConfig.form : [];
|
|
3366
|
+
return [...reviewFields, ...formFields];
|
|
3367
|
+
};
|
|
3368
|
+
function getAllAnnotationFields(config) {
|
|
3369
|
+
return (0, import_lodash.flattenDeep)(config.actions.map(getActionAnnotationFields));
|
|
3473
3370
|
}
|
|
3371
|
+
var findAllFields = (config) => {
|
|
3372
|
+
return (0, import_lodash.flattenDeep)([
|
|
3373
|
+
...getDeclarationFields(config),
|
|
3374
|
+
...getAllAnnotationFields(config)
|
|
3375
|
+
]);
|
|
3376
|
+
};
|
|
3377
|
+
var EXCLUDED_ACTIONS = [
|
|
3378
|
+
ActionType.REQUEST_CORRECTION,
|
|
3379
|
+
ActionType.PRINT_CERTIFICATE,
|
|
3380
|
+
ActionType.REJECT_CORRECTION
|
|
3381
|
+
];
|
|
3474
3382
|
|
|
3475
3383
|
// ../commons/src/conditionals/conditionals.ts
|
|
3476
3384
|
var objectHash = __toESM(require("object-hash"));
|
|
@@ -3994,595 +3902,89 @@ function createFieldConditionals(fieldId) {
|
|
|
3994
3902
|
[fieldId]: wrapToPath(
|
|
3995
3903
|
{
|
|
3996
3904
|
type: "number",
|
|
3997
|
-
minimum: min,
|
|
3998
|
-
maximum: max
|
|
3999
|
-
},
|
|
4000
|
-
this.$$subfield
|
|
4001
|
-
)
|
|
4002
|
-
},
|
|
4003
|
-
required: [fieldId]
|
|
4004
|
-
});
|
|
4005
|
-
},
|
|
4006
|
-
getId: () => ({ fieldId }),
|
|
4007
|
-
/**
|
|
4008
|
-
* @deprecated
|
|
4009
|
-
* use field(fieldId).get(nestedProperty) instead
|
|
4010
|
-
* with 'and' combinator e.g.
|
|
4011
|
-
* and(
|
|
4012
|
-
* field('child.name').get('firstname').isEqualTo('John'),
|
|
4013
|
-
* field('child.name').get('surname').isEqualTo('Doe')
|
|
4014
|
-
* )
|
|
4015
|
-
*/
|
|
4016
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
4017
|
-
object: (options) => defineFormConditional({
|
|
4018
|
-
type: "object",
|
|
4019
|
-
properties: {
|
|
4020
|
-
[fieldId]: {
|
|
4021
|
-
type: "object",
|
|
4022
|
-
properties: Object.fromEntries(
|
|
4023
|
-
Object.entries(options).map(([key, value]) => {
|
|
4024
|
-
return [key, value.properties.$form.properties[key]];
|
|
4025
|
-
})
|
|
4026
|
-
),
|
|
4027
|
-
required: Object.keys(options)
|
|
4028
|
-
}
|
|
4029
|
-
},
|
|
4030
|
-
required: [fieldId]
|
|
4031
|
-
}),
|
|
4032
|
-
/**
|
|
4033
|
-
* Custom client-side validator. The provided function is serialised and executed
|
|
4034
|
-
* just-in-time on the client only. External references (e.g. lodash) are not
|
|
4035
|
-
* available inside the function body — all logic must be self-contained.
|
|
4036
|
-
*
|
|
4037
|
-
* @example
|
|
4038
|
-
* field('nid').customClientValidator((value) => {
|
|
4039
|
-
* // LUHN check — all logic must be inline
|
|
4040
|
-
* const digits = String(value).split('').map(Number)
|
|
4041
|
-
* // ...
|
|
4042
|
-
* return isValid
|
|
4043
|
-
* })
|
|
4044
|
-
*/
|
|
4045
|
-
customClientValidator(validationFn) {
|
|
4046
|
-
const code = validationFn.toString();
|
|
4047
|
-
return defineFormConditional({
|
|
4048
|
-
type: "object",
|
|
4049
|
-
properties: wrapToPath(
|
|
4050
|
-
{ [fieldId]: { customClientValidator: { code } } },
|
|
4051
|
-
this.$$subfield
|
|
4052
|
-
),
|
|
4053
|
-
required: [fieldId]
|
|
4054
|
-
});
|
|
4055
|
-
},
|
|
4056
|
-
/**
|
|
4057
|
-
* Custom client-side evaluation. Returns a {@link FieldReference} descriptor
|
|
4058
|
-
* that can be used as the `value` property or a DATA component entry.
|
|
4059
|
-
* The function receives the referenced field's value as the first argument and
|
|
4060
|
-
* the full form context as the second; its return value replaces the field reference.
|
|
4061
|
-
* The function is serialised and executed just-in-time on the client only.
|
|
4062
|
-
* External references (e.g. lodash) are not available inside the function body.
|
|
4063
|
-
*
|
|
4064
|
-
* For computing a default value without referencing a specific field, use
|
|
4065
|
-
* `evaluate(fn)` in the `defaultValue` property instead.
|
|
4066
|
-
*
|
|
4067
|
-
* @example
|
|
4068
|
-
* field('a').customClientEvaluation((aValue, ctx) =>
|
|
4069
|
-
* Number(aValue) + Number(ctx.$form.b)
|
|
4070
|
-
* )
|
|
4071
|
-
*/
|
|
4072
|
-
customClientEvaluation(computationFn) {
|
|
4073
|
-
return {
|
|
4074
|
-
$$code: computationFn.toString(),
|
|
4075
|
-
$$field: fieldId,
|
|
4076
|
-
$$subfield: this.$$subfield
|
|
4077
|
-
};
|
|
4078
|
-
}
|
|
4079
|
-
};
|
|
4080
|
-
}
|
|
4081
|
-
|
|
4082
|
-
// ../commons/src/events/state/index.ts
|
|
4083
|
-
function getStatusFromActions(actions) {
|
|
4084
|
-
const acceptedActions = actions.filter(
|
|
4085
|
-
({ status }) => status === ActionStatus.Accepted
|
|
4086
|
-
);
|
|
4087
|
-
const isCurrentlyArchived = acceptedActions.reduce(
|
|
4088
|
-
(archived, action) => {
|
|
4089
|
-
if (action.type === ActionType.ARCHIVE) {
|
|
4090
|
-
return true;
|
|
4091
|
-
}
|
|
4092
|
-
if (action.type === ActionType.UNARCHIVE) {
|
|
4093
|
-
return false;
|
|
4094
|
-
}
|
|
4095
|
-
return archived;
|
|
4096
|
-
},
|
|
4097
|
-
false
|
|
4098
|
-
);
|
|
4099
|
-
if (isCurrentlyArchived) {
|
|
4100
|
-
return EventStatus.enum.ARCHIVED;
|
|
4101
|
-
}
|
|
4102
|
-
return acceptedActions.filter(
|
|
4103
|
-
({ type }) => type !== ActionType.ARCHIVE && type !== ActionType.UNARCHIVE
|
|
4104
|
-
).reduce((status, action) => {
|
|
4105
|
-
switch (action.type) {
|
|
4106
|
-
case ActionType.CREATE:
|
|
4107
|
-
return EventStatus.enum.CREATED;
|
|
4108
|
-
case ActionType.DECLARE:
|
|
4109
|
-
return EventStatus.enum.DECLARED;
|
|
4110
|
-
case ActionType.REGISTER:
|
|
4111
|
-
return EventStatus.enum.REGISTERED;
|
|
4112
|
-
case ActionType.NOTIFY:
|
|
4113
|
-
return EventStatus.enum.NOTIFIED;
|
|
4114
|
-
// Already filtered out above; listed here only to satisfy exhaustiveness.
|
|
4115
|
-
case ActionType.ARCHIVE:
|
|
4116
|
-
case ActionType.UNARCHIVE:
|
|
4117
|
-
case ActionType.CUSTOM:
|
|
4118
|
-
case ActionType.PRINT_CERTIFICATE:
|
|
4119
|
-
case ActionType.ASSIGN:
|
|
4120
|
-
case ActionType.UNASSIGN:
|
|
4121
|
-
case ActionType.REJECT:
|
|
4122
|
-
case ActionType.REQUEST_CORRECTION:
|
|
4123
|
-
case ActionType.APPROVE_CORRECTION:
|
|
4124
|
-
case ActionType.DUPLICATE_DETECTED:
|
|
4125
|
-
case ActionType.MARK_AS_NOT_DUPLICATE:
|
|
4126
|
-
case ActionType.MARK_AS_DUPLICATE:
|
|
4127
|
-
case ActionType.REJECT_CORRECTION:
|
|
4128
|
-
case ActionType.READ:
|
|
4129
|
-
case ActionType.EDIT:
|
|
4130
|
-
default:
|
|
4131
|
-
return status;
|
|
4132
|
-
}
|
|
4133
|
-
}, EventStatus.enum.CREATED);
|
|
4134
|
-
}
|
|
4135
|
-
function getAssignedUserFromActions(actions) {
|
|
4136
|
-
return actions.reduce((user2, action) => {
|
|
4137
|
-
if (action.type === ActionType.ASSIGN) {
|
|
4138
|
-
return action.assignedTo;
|
|
4139
|
-
}
|
|
4140
|
-
if (action.type === ActionType.UNASSIGN) {
|
|
4141
|
-
return null;
|
|
4142
|
-
}
|
|
4143
|
-
return user2;
|
|
4144
|
-
}, null);
|
|
4145
|
-
}
|
|
4146
|
-
function deepDropNulls(obj) {
|
|
4147
|
-
if (Array.isArray(obj)) {
|
|
4148
|
-
return obj.map(deepDropNulls);
|
|
4149
|
-
}
|
|
4150
|
-
if (obj !== null && typeof obj === "object") {
|
|
4151
|
-
return Object.entries(obj).reduce((acc, [key, value]) => {
|
|
4152
|
-
const cleanedValue = deepDropNulls(value);
|
|
4153
|
-
if (cleanedValue !== null) {
|
|
4154
|
-
;
|
|
4155
|
-
acc[key] = cleanedValue;
|
|
4156
|
-
}
|
|
4157
|
-
return acc;
|
|
4158
|
-
}, {});
|
|
4159
|
-
}
|
|
4160
|
-
return obj;
|
|
4161
|
-
}
|
|
4162
|
-
var DEFAULT_DATE_OF_EVENT_PROPERTY = "createdAt";
|
|
4163
|
-
function extractDateString(dateTime) {
|
|
4164
|
-
return dateTime.split("T")[0];
|
|
4165
|
-
}
|
|
4166
|
-
function resolveDateOfEvent(eventIndex, declaration, config) {
|
|
4167
|
-
if (!config.dateOfEvent) {
|
|
4168
|
-
return extractDateString(eventIndex[DEFAULT_DATE_OF_EVENT_PROPERTY]);
|
|
4169
|
-
}
|
|
4170
|
-
const parsedDate = isFieldReference(config.dateOfEvent) ? ZodDate.safeParse(declaration[config.dateOfEvent.$$field]) : ZodDateTime.safeParse(
|
|
4171
|
-
getMixedPath(eventIndex, config.dateOfEvent.$$event)
|
|
4172
|
-
);
|
|
4173
|
-
return parsedDate.success ? extractDateString(parsedDate.data) : void 0;
|
|
4174
|
-
}
|
|
4175
|
-
var DEFAULT_PLACE_OF_EVENT_PROPERTY = "createdAtLocation";
|
|
4176
|
-
function getParsedUUID(value, oldValue) {
|
|
4177
|
-
const parsed = UUID.safeParse(value);
|
|
4178
|
-
return parsed.success ? parsed.data : oldValue;
|
|
4179
|
-
}
|
|
4180
|
-
function resolvePlaceOfEvent(eventMetadata, declaration, config) {
|
|
4181
|
-
let placeOfEvent = getParsedUUID(
|
|
4182
|
-
eventMetadata[DEFAULT_PLACE_OF_EVENT_PROPERTY]
|
|
4183
|
-
);
|
|
4184
|
-
if (config.placeOfEvent) {
|
|
4185
|
-
const addressFieldValue = AddressFieldValue.safeParse(
|
|
4186
|
-
declaration[config.placeOfEvent.$$field]
|
|
4187
|
-
);
|
|
4188
|
-
if (addressFieldValue.success && addressFieldValue.data.addressType === AddressType.DOMESTIC && addressFieldValue.data.administrativeArea) {
|
|
4189
|
-
placeOfEvent = getParsedUUID(
|
|
4190
|
-
addressFieldValue.data.administrativeArea,
|
|
4191
|
-
placeOfEvent
|
|
4192
|
-
);
|
|
4193
|
-
} else {
|
|
4194
|
-
placeOfEvent = getParsedUUID(
|
|
4195
|
-
declaration[config.placeOfEvent.$$field],
|
|
4196
|
-
placeOfEvent
|
|
4197
|
-
);
|
|
4198
|
-
}
|
|
4199
|
-
}
|
|
4200
|
-
return placeOfEvent;
|
|
4201
|
-
}
|
|
4202
|
-
function extractPotentialDuplicatesFromActions(actions) {
|
|
4203
|
-
return actions.reduce((duplicates, action) => {
|
|
4204
|
-
if (action.type === ActionType.DUPLICATE_DETECTED) {
|
|
4205
|
-
duplicates = action.content.duplicates;
|
|
4206
|
-
}
|
|
4207
|
-
if (action.type === ActionType.MARK_AS_NOT_DUPLICATE || action.type === ActionType.MARK_AS_DUPLICATE) {
|
|
4208
|
-
duplicates = [];
|
|
4209
|
-
}
|
|
4210
|
-
return duplicates;
|
|
4211
|
-
}, []);
|
|
4212
|
-
}
|
|
4213
|
-
function getCurrentEventState(event2, config) {
|
|
4214
|
-
const sortedActions = event2.actions.slice().sort((a, b) => a.createdAt.localeCompare(b.createdAt));
|
|
4215
|
-
const creationAction = sortedActions.find(
|
|
4216
|
-
(action) => action.type === ActionType.CREATE
|
|
4217
|
-
);
|
|
4218
|
-
if (!creationAction) {
|
|
4219
|
-
throw new Error(`Event ${event2.id} has no creation action`);
|
|
4220
|
-
}
|
|
4221
|
-
const acceptedActions = getAcceptedActions(event2).sort(
|
|
4222
|
-
(a, b) => a.createdAt.localeCompare(b.createdAt)
|
|
4223
|
-
);
|
|
4224
|
-
const requestActionMetadata = getActionUpdateMetadata(sortedActions);
|
|
4225
|
-
const acceptedActionMetadata = getActionUpdateMetadata(acceptedActions);
|
|
4226
|
-
const declaration = aggregateActionDeclarations(event2);
|
|
4227
|
-
const status = getStatusFromActions(sortedActions);
|
|
4228
|
-
const legalStatuses = getLegalStatuses(sortedActions);
|
|
4229
|
-
const base = deepDropNulls({
|
|
4230
|
-
id: event2.id,
|
|
4231
|
-
type: event2.type,
|
|
4232
|
-
status,
|
|
4233
|
-
legalStatuses,
|
|
4234
|
-
createdAt: creationAction.createdAt,
|
|
4235
|
-
createdBy: creationAction.createdBy,
|
|
4236
|
-
createdByUserType: creationAction.createdByUserType,
|
|
4237
|
-
createdAtLocation: creationAction.createdAtLocation,
|
|
4238
|
-
updatedAt: acceptedActionMetadata.createdAt,
|
|
4239
|
-
assignedTo: getAssignedUserFromActions(acceptedActions),
|
|
4240
|
-
updatedBy: requestActionMetadata.createdBy,
|
|
4241
|
-
updatedAtLocation: requestActionMetadata.createdAtLocation,
|
|
4242
|
-
declaration,
|
|
4243
|
-
trackingId: event2.trackingId,
|
|
4244
|
-
updatedByUserRole: requestActionMetadata.createdByRole,
|
|
4245
|
-
placeOfEvent: resolvePlaceOfEvent(
|
|
4246
|
-
{ createdAtLocation: creationAction.createdAtLocation },
|
|
4247
|
-
declaration,
|
|
4248
|
-
config
|
|
4249
|
-
),
|
|
4250
|
-
potentialDuplicates: extractPotentialDuplicatesFromActions(sortedActions),
|
|
4251
|
-
flags: getEventFlags(event2, config)
|
|
4252
|
-
});
|
|
4253
|
-
return deepDropNulls({
|
|
4254
|
-
...base,
|
|
4255
|
-
dateOfEvent: resolveDateOfEvent(base, declaration, config)
|
|
4256
|
-
});
|
|
4257
|
-
}
|
|
4258
|
-
|
|
4259
|
-
// ../commons/src/conditionals/validate.ts
|
|
4260
|
-
var ajv = new import__.default({
|
|
4261
|
-
$data: true,
|
|
4262
|
-
allowUnionTypes: true,
|
|
4263
|
-
strict: false
|
|
4264
|
-
// Allow minContains and other newer features
|
|
4265
|
-
});
|
|
4266
|
-
var DataContext = z32.object({
|
|
4267
|
-
rootData: z32.object({
|
|
4268
|
-
$leafAdminStructureLocationIds: z32.array(z32.object({ id: UUID }))
|
|
4269
|
-
})
|
|
4270
|
-
});
|
|
4271
|
-
function resolveDataPath(rootData, dataPath, instancePath) {
|
|
4272
|
-
const pathParts = dataPath.split("/");
|
|
4273
|
-
const levels = parseInt(pathParts[0], 10);
|
|
4274
|
-
const referencePath = pathParts.slice(1);
|
|
4275
|
-
const instanceParts = instancePath.split("/").filter(Boolean);
|
|
4276
|
-
const traversedParts = instanceParts.slice(0, -levels);
|
|
4277
|
-
let current = rootData;
|
|
4278
|
-
for (const part of traversedParts) {
|
|
4279
|
-
if (current === null || current === void 0) {
|
|
4280
|
-
return void 0;
|
|
4281
|
-
}
|
|
4282
|
-
current = current[part];
|
|
4283
|
-
}
|
|
4284
|
-
for (const part of referencePath) {
|
|
4285
|
-
if (current === null || current === void 0) {
|
|
4286
|
-
return void 0;
|
|
4287
|
-
}
|
|
4288
|
-
current = current[part];
|
|
4289
|
-
}
|
|
4290
|
-
return current;
|
|
4291
|
-
}
|
|
4292
|
-
function todayISO() {
|
|
4293
|
-
return (0, import_date_fns2.formatISO)(/* @__PURE__ */ new Date(), { representation: "date" });
|
|
4294
|
-
}
|
|
4295
|
-
var compiledFunctionCache = /* @__PURE__ */ new Map();
|
|
4296
|
-
function compileClientFunction(code) {
|
|
4297
|
-
let fn = compiledFunctionCache.get(code);
|
|
4298
|
-
if (!fn) {
|
|
4299
|
-
fn = new Function(`return (${code})`)();
|
|
4300
|
-
compiledFunctionCache.set(code, fn);
|
|
4301
|
-
}
|
|
4302
|
-
return fn;
|
|
4303
|
-
}
|
|
4304
|
-
(0, import_ajv_formats.default)(ajv);
|
|
4305
|
-
function buildClientFunctionContext(input) {
|
|
4306
|
-
const flags = input.validatorContext?.event && input.validatorContext?.eventConfig ? getCurrentEventState(
|
|
4307
|
-
input.validatorContext?.event,
|
|
4308
|
-
input.validatorContext?.eventConfig
|
|
4309
|
-
)?.flags : [];
|
|
4310
|
-
return {
|
|
4311
|
-
$form: input.form,
|
|
4312
|
-
$flags: flags,
|
|
4313
|
-
$now: todayISO(),
|
|
4314
|
-
// eslint-disable-next-line @typescript-eslint/no-use-before-define
|
|
4315
|
-
$online: isOnline(),
|
|
4316
|
-
$user: input.validatorContext?.user,
|
|
4317
|
-
$event: input.validatorContext?.event,
|
|
4318
|
-
$leafAdminStructureLocationIds: input.validatorContext?.leafAdminStructureLocationIds ?? [],
|
|
4319
|
-
user: input.systemVariables?.user,
|
|
4320
|
-
$window: input.systemVariables?.$window,
|
|
4321
|
-
locations: input.locations,
|
|
4322
|
-
adminLevelIds: input.adminLevelIds
|
|
4323
|
-
};
|
|
4324
|
-
}
|
|
4325
|
-
function runClientFunction(code, data, context) {
|
|
4326
|
-
return compileClientFunction(code)(data, context);
|
|
4327
|
-
}
|
|
4328
|
-
ajv.addKeyword({
|
|
4329
|
-
keyword: "daysFromDate",
|
|
4330
|
-
type: "string",
|
|
4331
|
-
schemaType: "object",
|
|
4332
|
-
$data: true,
|
|
4333
|
-
errors: true,
|
|
4334
|
-
validate(schema, data, _2, dataContext) {
|
|
4335
|
-
if (!(dataContext && dataContext.rootData && typeof dataContext.rootData === "object" && "$now" in dataContext.rootData && typeof dataContext.rootData.$now === "string")) {
|
|
4336
|
-
throw new Error("Validation context must contain $now");
|
|
4337
|
-
}
|
|
4338
|
-
const { days, clause } = schema;
|
|
4339
|
-
if (typeof data !== "string") {
|
|
4340
|
-
return false;
|
|
4341
|
-
}
|
|
4342
|
-
const date = new Date(data);
|
|
4343
|
-
if (isNaN(date.getTime())) {
|
|
4344
|
-
return false;
|
|
4345
|
-
}
|
|
4346
|
-
let referenceDate = schema.referenceDate;
|
|
4347
|
-
if (referenceDate && typeof referenceDate === "object" && "$data" in referenceDate) {
|
|
4348
|
-
referenceDate = resolveDataPath(
|
|
4349
|
-
dataContext.rootData,
|
|
4350
|
-
referenceDate.$data,
|
|
4351
|
-
dataContext.instancePath
|
|
4352
|
-
);
|
|
4353
|
-
}
|
|
4354
|
-
if (!referenceDate) {
|
|
4355
|
-
referenceDate = dataContext.rootData.$now;
|
|
4356
|
-
}
|
|
4357
|
-
const baseDate = new Date(referenceDate);
|
|
4358
|
-
if (isNaN(baseDate.getTime())) {
|
|
4359
|
-
return false;
|
|
4360
|
-
}
|
|
4361
|
-
const offsetDate = new Date(baseDate.getTime() + days * 24 * 60 * 60 * 1e3);
|
|
4362
|
-
return clause === "after" ? (0, import_date_fns2.isAfter)(date, offsetDate) : (0, import_date_fns2.isBefore)(date, offsetDate);
|
|
4363
|
-
}
|
|
4364
|
-
});
|
|
4365
|
-
ajv.addKeyword({
|
|
4366
|
-
keyword: "isLeafLevelLocation",
|
|
4367
|
-
type: "string",
|
|
4368
|
-
schemaType: "boolean",
|
|
4369
|
-
$data: true,
|
|
4370
|
-
errors: true,
|
|
4371
|
-
// @ts-ignore -- Force type. We will move this away from AJV next. Parsing the array will take seconds and is only called by core.
|
|
4372
|
-
validate(_schema, data, _2, dataContext) {
|
|
4373
|
-
const locationIdInput = data;
|
|
4374
|
-
const locations = dataContext?.rootData.$leafAdminStructureLocationIds ?? [];
|
|
4375
|
-
return locations.some((location) => location.id === locationIdInput);
|
|
4376
|
-
}
|
|
4377
|
-
});
|
|
4378
|
-
function isAgeValue(value) {
|
|
4379
|
-
return typeof value === "object" && value !== null && "age" in value && typeof value.age === "number";
|
|
4380
|
-
}
|
|
4381
|
-
ajv.addKeyword({
|
|
4382
|
-
keyword: "customClientValidator",
|
|
4383
|
-
schemaType: "object",
|
|
4384
|
-
errors: true,
|
|
4385
|
-
// @ts-expect-error -- AJV's public types don't expose `rootData`. All
|
|
4386
|
-
// `validate()` callers build root data via `buildClientFunctionContext`,
|
|
4387
|
-
// so the cast holds.
|
|
4388
|
-
validate(schema, data, _2, dataContext) {
|
|
4389
|
-
return Boolean(
|
|
4390
|
-
runClientFunction(
|
|
4391
|
-
schema.code,
|
|
4392
|
-
data,
|
|
4393
|
-
dataContext?.rootData ?? buildClientFunctionContext({ form: {} })
|
|
4394
|
-
)
|
|
4395
|
-
);
|
|
4396
|
-
}
|
|
4397
|
-
});
|
|
4398
|
-
function validate(schema, data) {
|
|
4399
|
-
const validator = ajv.getSchema(schema.$id) || ajv.compile(schema);
|
|
4400
|
-
if ("$form" in data) {
|
|
4401
|
-
const entries = Object.entries(data.$form).map(([key, value]) => {
|
|
4402
|
-
if (!isAgeValue(value)) {
|
|
4403
|
-
return [key, value];
|
|
4404
|
-
}
|
|
4405
|
-
const age = value.age;
|
|
4406
|
-
const maybeAsOfDate = PlainDate.safeParse(data.$form[value.asOfDateRef]);
|
|
4407
|
-
return [
|
|
4408
|
-
key,
|
|
4409
|
-
{
|
|
4410
|
-
age,
|
|
4411
|
-
dob: ageToDate(
|
|
4412
|
-
age,
|
|
4413
|
-
maybeAsOfDate.success ? maybeAsOfDate.data : PlainDate.parse(data.$now)
|
|
3905
|
+
minimum: min,
|
|
3906
|
+
maximum: max
|
|
3907
|
+
},
|
|
3908
|
+
this.$$subfield
|
|
4414
3909
|
)
|
|
3910
|
+
},
|
|
3911
|
+
required: [fieldId]
|
|
3912
|
+
});
|
|
3913
|
+
},
|
|
3914
|
+
getId: () => ({ fieldId }),
|
|
3915
|
+
/**
|
|
3916
|
+
* @deprecated
|
|
3917
|
+
* use field(fieldId).get(nestedProperty) instead
|
|
3918
|
+
* with 'and' combinator e.g.
|
|
3919
|
+
* and(
|
|
3920
|
+
* field('child.name').get('firstname').isEqualTo('John'),
|
|
3921
|
+
* field('child.name').get('surname').isEqualTo('Doe')
|
|
3922
|
+
* )
|
|
3923
|
+
*/
|
|
3924
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
3925
|
+
object: (options) => defineFormConditional({
|
|
3926
|
+
type: "object",
|
|
3927
|
+
properties: {
|
|
3928
|
+
[fieldId]: {
|
|
3929
|
+
type: "object",
|
|
3930
|
+
properties: Object.fromEntries(
|
|
3931
|
+
Object.entries(options).map(([key, value]) => {
|
|
3932
|
+
return [key, value.properties.$form.properties[key]];
|
|
3933
|
+
})
|
|
3934
|
+
),
|
|
3935
|
+
required: Object.keys(options)
|
|
4415
3936
|
}
|
|
4416
|
-
|
|
4417
|
-
|
|
4418
|
-
|
|
4419
|
-
|
|
4420
|
-
|
|
4421
|
-
|
|
4422
|
-
|
|
4423
|
-
|
|
4424
|
-
|
|
4425
|
-
|
|
4426
|
-
|
|
4427
|
-
|
|
4428
|
-
|
|
4429
|
-
|
|
4430
|
-
|
|
4431
|
-
|
|
4432
|
-
|
|
4433
|
-
|
|
4434
|
-
|
|
4435
|
-
|
|
4436
|
-
|
|
4437
|
-
|
|
4438
|
-
|
|
4439
|
-
|
|
4440
|
-
|
|
4441
|
-
}
|
|
4442
|
-
|
|
4443
|
-
|
|
4444
|
-
|
|
4445
|
-
|
|
4446
|
-
|
|
4447
|
-
|
|
4448
|
-
|
|
4449
|
-
|
|
4450
|
-
|
|
4451
|
-
|
|
4452
|
-
|
|
4453
|
-
|
|
4454
|
-
|
|
4455
|
-
|
|
4456
|
-
|
|
4457
|
-
|
|
4458
|
-
|
|
4459
|
-
|
|
4460
|
-
|
|
4461
|
-
|
|
4462
|
-
|
|
4463
|
-
|
|
4464
|
-
|
|
4465
|
-
const formFields = "form" in actionConfig && actionConfig.form != null ? actionConfig.form : [];
|
|
4466
|
-
return [...reviewFields, ...formFields];
|
|
4467
|
-
};
|
|
4468
|
-
function getAllAnnotationFields(config) {
|
|
4469
|
-
return (0, import_lodash4.flattenDeep)(config.actions.map(getActionAnnotationFields));
|
|
4470
|
-
}
|
|
4471
|
-
function deepMerge(currentDocument, actionDocument) {
|
|
4472
|
-
const currentDocumentClone = (0, import_lodash4.cloneDeep)(currentDocument);
|
|
4473
|
-
return (0, import_lodash4.mergeWith)(
|
|
4474
|
-
(0, import_lodash4.cloneDeep)(currentDocumentClone),
|
|
4475
|
-
actionDocument,
|
|
4476
|
-
(previousValue, incomingValue) => {
|
|
4477
|
-
if (incomingValue === void 0) {
|
|
4478
|
-
return previousValue;
|
|
4479
|
-
}
|
|
4480
|
-
if ((0, import_lodash4.isArray)(incomingValue)) {
|
|
4481
|
-
return incomingValue;
|
|
4482
|
-
}
|
|
4483
|
-
if ((0, import_lodash4.isObject)(previousValue) && (0, import_lodash4.isObject)(incomingValue)) {
|
|
4484
|
-
return void 0;
|
|
4485
|
-
}
|
|
4486
|
-
return incomingValue;
|
|
4487
|
-
}
|
|
4488
|
-
);
|
|
4489
|
-
}
|
|
4490
|
-
var findAllFields = (config) => {
|
|
4491
|
-
return (0, import_lodash4.flattenDeep)([
|
|
4492
|
-
...getDeclarationFields(config),
|
|
4493
|
-
...getAllAnnotationFields(config)
|
|
4494
|
-
]);
|
|
4495
|
-
};
|
|
4496
|
-
function getMixedPath(obj, path, defaultValue) {
|
|
4497
|
-
const parts = path.split(".");
|
|
4498
|
-
const resolve = (current, segments) => {
|
|
4499
|
-
if (current == null || segments.length === 0) {
|
|
4500
|
-
return current;
|
|
4501
|
-
}
|
|
4502
|
-
for (let i = segments.length; i > 0; i--) {
|
|
4503
|
-
const compoundKey = segments.slice(0, i).join(".");
|
|
4504
|
-
if ((0, import_lodash4.has)(current, compoundKey)) {
|
|
4505
|
-
const next = (0, import_lodash4.get)(current, compoundKey);
|
|
4506
|
-
return resolve(next, segments.slice(i));
|
|
4507
|
-
}
|
|
3937
|
+
},
|
|
3938
|
+
required: [fieldId]
|
|
3939
|
+
}),
|
|
3940
|
+
/**
|
|
3941
|
+
* Custom client-side validator. The provided function is serialised and executed
|
|
3942
|
+
* just-in-time on the client only. External references (e.g. lodash) are not
|
|
3943
|
+
* available inside the function body — all logic must be self-contained.
|
|
3944
|
+
*
|
|
3945
|
+
* @example
|
|
3946
|
+
* field('nid').customClientValidator((value) => {
|
|
3947
|
+
* // LUHN check — all logic must be inline
|
|
3948
|
+
* const digits = String(value).split('').map(Number)
|
|
3949
|
+
* // ...
|
|
3950
|
+
* return isValid
|
|
3951
|
+
* })
|
|
3952
|
+
*/
|
|
3953
|
+
customClientValidator(validationFn) {
|
|
3954
|
+
const code = validationFn.toString();
|
|
3955
|
+
return defineFormConditional({
|
|
3956
|
+
type: "object",
|
|
3957
|
+
properties: wrapToPath(
|
|
3958
|
+
{ [fieldId]: { customClientValidator: { code } } },
|
|
3959
|
+
this.$$subfield
|
|
3960
|
+
),
|
|
3961
|
+
required: [fieldId]
|
|
3962
|
+
});
|
|
3963
|
+
},
|
|
3964
|
+
/**
|
|
3965
|
+
* Custom client-side evaluation. Returns a {@link FieldReference} descriptor
|
|
3966
|
+
* that can be used as the `value` property or a DATA component entry.
|
|
3967
|
+
* The function receives the referenced field's value as the first argument and
|
|
3968
|
+
* the full form context as the second; its return value replaces the field reference.
|
|
3969
|
+
* The function is serialised and executed just-in-time on the client only.
|
|
3970
|
+
* External references (e.g. lodash) are not available inside the function body.
|
|
3971
|
+
*
|
|
3972
|
+
* For computing a default value without referencing a specific field, use
|
|
3973
|
+
* `evaluate(fn)` in the `defaultValue` property instead.
|
|
3974
|
+
*
|
|
3975
|
+
* @example
|
|
3976
|
+
* field('a').customClientEvaluation((aValue, ctx) =>
|
|
3977
|
+
* Number(aValue) + Number(ctx.$form.b)
|
|
3978
|
+
* )
|
|
3979
|
+
*/
|
|
3980
|
+
customClientEvaluation(computationFn) {
|
|
3981
|
+
return {
|
|
3982
|
+
$$code: computationFn.toString(),
|
|
3983
|
+
$$field: fieldId,
|
|
3984
|
+
$$subfield: this.$$subfield
|
|
3985
|
+
};
|
|
4508
3986
|
}
|
|
4509
|
-
return void 0;
|
|
4510
3987
|
};
|
|
4511
|
-
const result = resolve(obj, parts);
|
|
4512
|
-
return (0, import_lodash4.isNil)(result) ? defaultValue : result;
|
|
4513
|
-
}
|
|
4514
|
-
function isAcceptedAction(a) {
|
|
4515
|
-
return a.status === ActionStatus.Accepted;
|
|
4516
|
-
}
|
|
4517
|
-
function getCompleteActionAnnotation(event2, action) {
|
|
4518
|
-
if (action.originalActionId) {
|
|
4519
|
-
const originalAction = event2.actions.find(
|
|
4520
|
-
({ id }) => id === action.originalActionId
|
|
4521
|
-
);
|
|
4522
|
-
if (originalAction?.status === ActionStatus.Requested) {
|
|
4523
|
-
return deepMerge(originalAction.annotation ?? {}, action.annotation ?? {});
|
|
4524
|
-
}
|
|
4525
|
-
}
|
|
4526
|
-
return action.annotation ?? {};
|
|
4527
|
-
}
|
|
4528
|
-
function getCompleteActionDeclaration(declaration, event2, action) {
|
|
4529
|
-
if (action.originalActionId) {
|
|
4530
|
-
const originalAction = event2.actions.find(
|
|
4531
|
-
({ id }) => id === action.originalActionId
|
|
4532
|
-
);
|
|
4533
|
-
if (originalAction?.status === ActionStatus.Requested) {
|
|
4534
|
-
return deepMerge(
|
|
4535
|
-
deepMerge(declaration, originalAction.declaration),
|
|
4536
|
-
action.declaration
|
|
4537
|
-
);
|
|
4538
|
-
}
|
|
4539
|
-
}
|
|
4540
|
-
return deepMerge(declaration, action.declaration);
|
|
4541
|
-
}
|
|
4542
|
-
function getAcceptedActions(event2) {
|
|
4543
|
-
return event2.actions.filter(isAcceptedAction).map((action) => ({
|
|
4544
|
-
...action,
|
|
4545
|
-
declaration: getCompleteActionDeclaration({}, event2, action),
|
|
4546
|
-
annotation: getCompleteActionAnnotation(event2, action)
|
|
4547
|
-
}));
|
|
4548
|
-
}
|
|
4549
|
-
var EXCLUDED_ACTIONS = [
|
|
4550
|
-
ActionType.REQUEST_CORRECTION,
|
|
4551
|
-
ActionType.PRINT_CERTIFICATE,
|
|
4552
|
-
ActionType.REJECT_CORRECTION
|
|
4553
|
-
];
|
|
4554
|
-
function aggregateActionDeclarations(event2) {
|
|
4555
|
-
const allAcceptedActions = getAcceptedActions(event2);
|
|
4556
|
-
const aggregatedActions = allAcceptedActions.filter((a) => !EXCLUDED_ACTIONS.some((type) => type === a.type)).sort((a, b) => a.createdAt.localeCompare(b.createdAt));
|
|
4557
|
-
return aggregatedActions.reduce((declaration, action) => {
|
|
4558
|
-
if (action.type === ActionType.APPROVE_CORRECTION) {
|
|
4559
|
-
const requestAction = allAcceptedActions.find(
|
|
4560
|
-
({ id }) => id === action.requestId
|
|
4561
|
-
);
|
|
4562
|
-
if (!requestAction) {
|
|
4563
|
-
return declaration;
|
|
4564
|
-
}
|
|
4565
|
-
const declarationWithApprovedCorrection = getCompleteActionDeclaration(
|
|
4566
|
-
declaration,
|
|
4567
|
-
event2,
|
|
4568
|
-
requestAction
|
|
4569
|
-
);
|
|
4570
|
-
return getCompleteActionDeclaration(
|
|
4571
|
-
declarationWithApprovedCorrection,
|
|
4572
|
-
event2,
|
|
4573
|
-
action
|
|
4574
|
-
);
|
|
4575
|
-
}
|
|
4576
|
-
return getCompleteActionDeclaration(declaration, event2, action);
|
|
4577
|
-
}, {});
|
|
4578
|
-
}
|
|
4579
|
-
function aggregateActionAnnotations(event2) {
|
|
4580
|
-
return event2.actions.reduce((ann, sortedAction) => {
|
|
4581
|
-
if (!("annotation" in sortedAction) || !sortedAction.annotation) {
|
|
4582
|
-
return ann;
|
|
4583
|
-
}
|
|
4584
|
-
return deepMerge(ann, sortedAction.annotation);
|
|
4585
|
-
}, {});
|
|
4586
3988
|
}
|
|
4587
3989
|
|
|
4588
3990
|
// ../commons/src/events/eventConfigValidation.ts
|
|
@@ -5426,14 +4828,14 @@ var DraftInput = BaseActionInput.omit({ waitFor: true }).extend({
|
|
|
5426
4828
|
|
|
5427
4829
|
// ../commons/src/events/EventInput.ts
|
|
5428
4830
|
var z40 = __toESM(require("zod/v4"));
|
|
5429
|
-
var
|
|
4831
|
+
var import_uuid10 = require("uuid");
|
|
5430
4832
|
var EventInput = z40.object({
|
|
5431
4833
|
transactionId: z40.string(),
|
|
5432
4834
|
type: z40.string(),
|
|
5433
4835
|
createdAtLocation: UUID.nullish().describe(
|
|
5434
4836
|
"Location where the event occurred. Required for system users."
|
|
5435
4837
|
)
|
|
5436
|
-
}).meta({ default: { transactionId: (0,
|
|
4838
|
+
}).meta({ default: { transactionId: (0, import_uuid10.v4)(), type: "birth" } });
|
|
5437
4839
|
|
|
5438
4840
|
// ../commons/src/events/EventDocument.ts
|
|
5439
4841
|
var z41 = __toESM(require("zod/v4"));
|
|
@@ -5450,6 +4852,67 @@ var EventDocument = z41.object({
|
|
|
5450
4852
|
)
|
|
5451
4853
|
}).meta({ id: "EventDocument" });
|
|
5452
4854
|
|
|
4855
|
+
// ../commons/src/events/state/index.ts
|
|
4856
|
+
var import_lodash4 = require("lodash");
|
|
4857
|
+
|
|
4858
|
+
// ../commons/src/events/state/utils.ts
|
|
4859
|
+
var import_lodash2 = require("lodash");
|
|
4860
|
+
var updateActions = ActionTypes.extract([
|
|
4861
|
+
ActionType.CREATE,
|
|
4862
|
+
ActionType.NOTIFY,
|
|
4863
|
+
ActionType.EDIT,
|
|
4864
|
+
ActionType.DECLARE,
|
|
4865
|
+
ActionType.REGISTER,
|
|
4866
|
+
ActionType.REJECT,
|
|
4867
|
+
ActionType.ARCHIVE,
|
|
4868
|
+
ActionType.UNARCHIVE,
|
|
4869
|
+
ActionType.PRINT_CERTIFICATE,
|
|
4870
|
+
ActionType.REQUEST_CORRECTION,
|
|
4871
|
+
ActionType.APPROVE_CORRECTION,
|
|
4872
|
+
ActionType.REJECT_CORRECTION,
|
|
4873
|
+
ActionType.CUSTOM
|
|
4874
|
+
]);
|
|
4875
|
+
|
|
4876
|
+
// ../commons/src/events/state/flags.ts
|
|
4877
|
+
var import_lodash3 = require("lodash");
|
|
4878
|
+
var import_date_fns3 = require("date-fns");
|
|
4879
|
+
var INHERENT_FLAG_RULES = [
|
|
4880
|
+
{
|
|
4881
|
+
flag: InherentFlags.CORRECTION_REQUESTED,
|
|
4882
|
+
setOn: [ActionType.REQUEST_CORRECTION],
|
|
4883
|
+
resetOn: [ActionType.APPROVE_CORRECTION, ActionType.REJECT_CORRECTION]
|
|
4884
|
+
},
|
|
4885
|
+
{
|
|
4886
|
+
// INCOMPLETE mirrors the NOTIFIED status: set by NOTIFY, cleared by any
|
|
4887
|
+
// other status-changing action (see getStatusFromActions). ARCHIVE/UNARCHIVE
|
|
4888
|
+
// are deliberately excluded so the flag freezes across an archive/unarchive
|
|
4889
|
+
// round trip and comes back exactly as it was.
|
|
4890
|
+
flag: InherentFlags.INCOMPLETE,
|
|
4891
|
+
setOn: [ActionType.NOTIFY],
|
|
4892
|
+
resetOn: [ActionType.CREATE, ActionType.DECLARE, ActionType.REGISTER]
|
|
4893
|
+
},
|
|
4894
|
+
{
|
|
4895
|
+
flag: InherentFlags.REJECTED,
|
|
4896
|
+
setOn: [ActionType.REJECT],
|
|
4897
|
+
resetOn: [
|
|
4898
|
+
ActionType.NOTIFY,
|
|
4899
|
+
ActionType.DECLARE,
|
|
4900
|
+
ActionType.EDIT,
|
|
4901
|
+
ActionType.REGISTER
|
|
4902
|
+
]
|
|
4903
|
+
},
|
|
4904
|
+
{
|
|
4905
|
+
flag: InherentFlags.POTENTIAL_DUPLICATE,
|
|
4906
|
+
setOn: [ActionType.DUPLICATE_DETECTED],
|
|
4907
|
+
resetOn: [ActionType.MARK_AS_DUPLICATE, ActionType.MARK_AS_NOT_DUPLICATE]
|
|
4908
|
+
},
|
|
4909
|
+
{
|
|
4910
|
+
flag: InherentFlags.EDIT_IN_PROGRESS,
|
|
4911
|
+
setOn: [ActionType.EDIT],
|
|
4912
|
+
resetOnAnyOtherAction: true
|
|
4913
|
+
}
|
|
4914
|
+
];
|
|
4915
|
+
|
|
5453
4916
|
// ../commons/src/events/defineConfig.ts
|
|
5454
4917
|
var IGNORED_EVENT_TYPES = [
|
|
5455
4918
|
"FOOTBALL_CLUB_MEMBERSHIP",
|
|
@@ -7922,21 +7385,69 @@ var LocationTypeV1 = z43.enum([
|
|
|
7922
7385
|
"CRVS_OFFICE",
|
|
7923
7386
|
"HEALTH_FACILITY"
|
|
7924
7387
|
]);
|
|
7388
|
+
var LocationStatus = z43.enum(["active", "inactive"]);
|
|
7389
|
+
var LocationVersion = z43.object({
|
|
7390
|
+
versionId: UUID,
|
|
7391
|
+
effectiveFrom: z43.iso.date(),
|
|
7392
|
+
name: z43.string(),
|
|
7393
|
+
externalId: z43.string().nullish(),
|
|
7394
|
+
status: LocationStatus
|
|
7395
|
+
});
|
|
7925
7396
|
var AdministrativeArea = z43.object({
|
|
7926
7397
|
id: UUID,
|
|
7927
7398
|
name: z43.string(),
|
|
7928
7399
|
externalId: z43.string().nullish(),
|
|
7929
7400
|
parentId: UUID.nullable(),
|
|
7930
|
-
|
|
7401
|
+
status: LocationStatus,
|
|
7402
|
+
versions: z43.array(LocationVersion)
|
|
7931
7403
|
});
|
|
7932
7404
|
var Location = z43.object({
|
|
7933
7405
|
id: UUID,
|
|
7934
7406
|
name: z43.string(),
|
|
7935
7407
|
externalId: z43.string().nullish(),
|
|
7936
7408
|
administrativeAreaId: UUID.nullable(),
|
|
7937
|
-
|
|
7409
|
+
locationType: z43.string().nullable(),
|
|
7410
|
+
status: LocationStatus,
|
|
7411
|
+
versions: z43.array(LocationVersion)
|
|
7412
|
+
});
|
|
7413
|
+
var ClientAdministrativeArea = AdministrativeArea.omit({
|
|
7414
|
+
name: true,
|
|
7415
|
+
status: true,
|
|
7416
|
+
externalId: true
|
|
7417
|
+
});
|
|
7418
|
+
var ClientLocation = Location.omit({
|
|
7419
|
+
name: true,
|
|
7420
|
+
status: true,
|
|
7421
|
+
externalId: true
|
|
7422
|
+
});
|
|
7423
|
+
function toClientLocation(location) {
|
|
7424
|
+
return {
|
|
7425
|
+
id: location.id,
|
|
7426
|
+
administrativeAreaId: location.administrativeAreaId,
|
|
7427
|
+
locationType: location.locationType,
|
|
7428
|
+
versions: location.versions
|
|
7429
|
+
};
|
|
7430
|
+
}
|
|
7431
|
+
function toClientAdministrativeArea(area) {
|
|
7432
|
+
return {
|
|
7433
|
+
id: area.id,
|
|
7434
|
+
parentId: area.parentId,
|
|
7435
|
+
versions: area.versions
|
|
7436
|
+
};
|
|
7437
|
+
}
|
|
7438
|
+
var SetLocationPayload = z43.object({
|
|
7439
|
+
id: UUID,
|
|
7440
|
+
name: z43.string(),
|
|
7441
|
+
externalId: z43.string().nullish(),
|
|
7442
|
+
administrativeAreaId: UUID.nullable(),
|
|
7938
7443
|
locationType: z43.string().nullable()
|
|
7939
7444
|
});
|
|
7445
|
+
var SetAdministrativeAreaPayload = z43.object({
|
|
7446
|
+
id: UUID,
|
|
7447
|
+
name: z43.string(),
|
|
7448
|
+
externalId: z43.string().nullish(),
|
|
7449
|
+
parentId: UUID.nullable()
|
|
7450
|
+
});
|
|
7940
7451
|
|
|
7941
7452
|
// ../commons/src/events/scopes.ts
|
|
7942
7453
|
var ACTION_SCOPE_MAP = {
|
|
@@ -8035,75 +7546,80 @@ var REJECTED_ACTIONS = [
|
|
|
8035
7546
|
var import_lodash7 = require("lodash");
|
|
8036
7547
|
|
|
8037
7548
|
// ../commons/src/events/mocks.test.utils.ts
|
|
8038
|
-
|
|
7549
|
+
function withVersionFields(entity) {
|
|
7550
|
+
return {
|
|
7551
|
+
...entity,
|
|
7552
|
+
status: "active",
|
|
7553
|
+
versions: [
|
|
7554
|
+
{
|
|
7555
|
+
versionId: entity.id,
|
|
7556
|
+
effectiveFrom: "0001-01-01",
|
|
7557
|
+
name: entity.name,
|
|
7558
|
+
externalId: entity.externalId ?? null,
|
|
7559
|
+
status: "active"
|
|
7560
|
+
}
|
|
7561
|
+
]
|
|
7562
|
+
};
|
|
7563
|
+
}
|
|
7564
|
+
var MOCK_ADMINISTRATIVE_AREAS_BASE = [
|
|
8039
7565
|
{
|
|
8040
7566
|
id: "a45b982a-5c7b-4bd9-8fd8-a42d0994054c",
|
|
8041
7567
|
name: "Central",
|
|
8042
7568
|
parentId: null,
|
|
8043
|
-
validUntil: null,
|
|
8044
7569
|
externalId: "ydyJb1RAy4U1"
|
|
8045
7570
|
},
|
|
8046
7571
|
{
|
|
8047
7572
|
id: "c599b691-fd2d-45e1-abf4-d185de727fb5",
|
|
8048
7573
|
name: "Sulaka",
|
|
8049
7574
|
parentId: null,
|
|
8050
|
-
validUntil: null,
|
|
8051
7575
|
externalId: "pQ8nGxWmZ2Q3"
|
|
8052
7576
|
},
|
|
8053
7577
|
{
|
|
8054
7578
|
id: "7ef2b9c7-5e6d-49f6-ae05-656207d0fc64",
|
|
8055
7579
|
name: "Pualula",
|
|
8056
7580
|
parentId: null,
|
|
8057
|
-
validUntil: null,
|
|
8058
7581
|
externalId: "Aq91DweLmT8k"
|
|
8059
7582
|
},
|
|
8060
7583
|
{
|
|
8061
7584
|
id: "6d1a59df-988c-4021-a846-ccbc021931a7",
|
|
8062
7585
|
name: "Chuminga",
|
|
8063
7586
|
parentId: null,
|
|
8064
|
-
validUntil: null,
|
|
8065
7587
|
externalId: "Rw0fYNh2Xk9a"
|
|
8066
7588
|
},
|
|
8067
7589
|
{
|
|
8068
7590
|
id: "62a0ccb4-880d-4f30-8882-f256007dfff9",
|
|
8069
7591
|
name: "Ibombo",
|
|
8070
7592
|
parentId: "a45b982a-5c7b-4bd9-8fd8-a42d0994054c",
|
|
8071
|
-
validUntil: null,
|
|
8072
7593
|
externalId: "k7DsP4vbN1Qe"
|
|
8073
7594
|
},
|
|
8074
7595
|
{
|
|
8075
7596
|
id: "27160bbd-32d1-4625-812f-860226bfb92a",
|
|
8076
7597
|
name: "Isango",
|
|
8077
7598
|
parentId: "a45b982a-5c7b-4bd9-8fd8-a42d0994054c",
|
|
8078
|
-
validUntil: null,
|
|
8079
7599
|
externalId: "Gm3Z9eQpHw4L"
|
|
8080
7600
|
},
|
|
8081
7601
|
{
|
|
8082
7602
|
id: "967032fd-3f81-478a-826c-30cb8fe121bd",
|
|
8083
7603
|
name: "Isamba",
|
|
8084
7604
|
parentId: "a45b982a-5c7b-4bd9-8fd8-a42d0994054c",
|
|
8085
|
-
validUntil: null,
|
|
8086
7605
|
externalId: "sT0xVu1KqJ7r"
|
|
8087
7606
|
},
|
|
8088
7607
|
{
|
|
8089
7608
|
id: "89a33893-b17d-481d-a26d-6461e7ac1651",
|
|
8090
7609
|
name: "Itambo",
|
|
8091
7610
|
parentId: "a45b982a-5c7b-4bd9-8fd8-a42d0994054c",
|
|
8092
|
-
validUntil: null,
|
|
8093
7611
|
externalId: "Nq6Bv2HpL9Te"
|
|
8094
7612
|
},
|
|
8095
7613
|
{
|
|
8096
7614
|
id: "d42ab2fe-e7ed-470e-8b31-4fb27f9b8250",
|
|
8097
7615
|
name: "Ezhi",
|
|
8098
7616
|
parentId: "a45b982a-5c7b-4bd9-8fd8-a42d0994054c",
|
|
8099
|
-
validUntil: null,
|
|
8100
7617
|
externalId: "xK8cQ0ZRy5Wd"
|
|
8101
7618
|
},
|
|
8102
7619
|
{
|
|
8103
7620
|
id: "8fbd09d2-212b-47f4-beb3-5e1694931d9f",
|
|
8104
7621
|
name: "Ilanga",
|
|
8105
7622
|
parentId: "c599b691-fd2d-45e1-abf4-d185de727fb5",
|
|
8106
|
-
validUntil: null,
|
|
8107
7623
|
externalId: "Cq4Jm1XvN8Ls"
|
|
8108
7624
|
},
|
|
8109
7625
|
// Villages under Ibombo (62a0ccb4-880d-4f30-8882-f256007dfff9)
|
|
@@ -8111,49 +7627,42 @@ var V2_DEFAULT_MOCK_ADMINISTRATIVE_AREAS = [
|
|
|
8111
7627
|
id: "1d4e5f6a-7b8c-4912-8efa-345678901234",
|
|
8112
7628
|
name: "Klow",
|
|
8113
7629
|
parentId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
|
|
8114
|
-
validUntil: null,
|
|
8115
7630
|
externalId: "IkYcYBUcyY2"
|
|
8116
7631
|
},
|
|
8117
7632
|
{
|
|
8118
7633
|
id: "2e5f6a7b-8c9d-4a23-8fab-456789012345",
|
|
8119
7634
|
name: "Mbondo",
|
|
8120
7635
|
parentId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
|
|
8121
|
-
validUntil: null,
|
|
8122
7636
|
externalId: "Qhvv5hvo3mY"
|
|
8123
7637
|
},
|
|
8124
7638
|
{
|
|
8125
7639
|
id: "3f6a7b8c-9d0e-4b34-8abc-567890123456",
|
|
8126
7640
|
name: "Ndara",
|
|
8127
7641
|
parentId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
|
|
8128
|
-
validUntil: null,
|
|
8129
7642
|
externalId: "crXh068O9TR"
|
|
8130
7643
|
},
|
|
8131
7644
|
{
|
|
8132
7645
|
id: "4a7b8c9d-0e1f-4c45-abcd-678901234567",
|
|
8133
7646
|
name: "Olani",
|
|
8134
7647
|
parentId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
|
|
8135
|
-
validUntil: null,
|
|
8136
7648
|
externalId: "r00It8Tvvp7"
|
|
8137
7649
|
},
|
|
8138
7650
|
{
|
|
8139
7651
|
id: "5b8c9d0e-1f2a-4d56-bcde-789012345678",
|
|
8140
7652
|
name: "Pemba",
|
|
8141
7653
|
parentId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
|
|
8142
|
-
validUntil: null,
|
|
8143
7654
|
externalId: "ZnUWsbONIaH"
|
|
8144
7655
|
},
|
|
8145
7656
|
{
|
|
8146
7657
|
id: "6c9d0e1f-2a3b-4e67-8def-890123456789",
|
|
8147
7658
|
name: "Quanza",
|
|
8148
7659
|
parentId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
|
|
8149
|
-
validUntil: null,
|
|
8150
7660
|
externalId: "fDZycvQTa7l"
|
|
8151
7661
|
},
|
|
8152
7662
|
{
|
|
8153
7663
|
id: "7d0e1f2a-3b4c-4f78-8efa-901234567890",
|
|
8154
7664
|
name: "Rivka",
|
|
8155
7665
|
parentId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
|
|
8156
|
-
validUntil: null,
|
|
8157
7666
|
externalId: "KqswxCGTELa"
|
|
8158
7667
|
},
|
|
8159
7668
|
// Villages under Isamba (967032fd-3f81-478a-826c-30cb8fe121bd)
|
|
@@ -8161,35 +7670,30 @@ var V2_DEFAULT_MOCK_ADMINISTRATIVE_AREAS = [
|
|
|
8161
7670
|
id: "8e1f2a3b-4c5d-4089-8fab-012345678901",
|
|
8162
7671
|
name: "Mbula",
|
|
8163
7672
|
parentId: "967032fd-3f81-478a-826c-30cb8fe121bd",
|
|
8164
|
-
validUntil: null,
|
|
8165
7673
|
externalId: "osEbKjRc9Kg"
|
|
8166
7674
|
},
|
|
8167
7675
|
{
|
|
8168
7676
|
id: "9f2a3b4c-5d6e-4190-8abf-123456789012",
|
|
8169
7677
|
name: "Ndoki",
|
|
8170
7678
|
parentId: "967032fd-3f81-478a-826c-30cb8fe121bd",
|
|
8171
|
-
validUntil: null,
|
|
8172
7679
|
externalId: "aq4daBUAGr3"
|
|
8173
7680
|
},
|
|
8174
7681
|
{
|
|
8175
7682
|
id: "0a3b4c5d-6e7f-4201-abcd-234567890123",
|
|
8176
7683
|
name: "Tsanga",
|
|
8177
7684
|
parentId: "967032fd-3f81-478a-826c-30cb8fe121bd",
|
|
8178
|
-
validUntil: null,
|
|
8179
7685
|
externalId: "cqis6Y8trbJ"
|
|
8180
7686
|
},
|
|
8181
7687
|
{
|
|
8182
7688
|
id: "1b4c5d6e-7f8a-4312-bcde-345678901234",
|
|
8183
7689
|
name: "Waziri",
|
|
8184
7690
|
parentId: "967032fd-3f81-478a-826c-30cb8fe121bd",
|
|
8185
|
-
validUntil: null,
|
|
8186
7691
|
externalId: "LMijHPyyx6d"
|
|
8187
7692
|
},
|
|
8188
7693
|
{
|
|
8189
7694
|
id: "2c5d6e7f-8a9b-4423-8def-456789012345",
|
|
8190
7695
|
name: "Zimbi",
|
|
8191
7696
|
parentId: "967032fd-3f81-478a-826c-30cb8fe121bd",
|
|
8192
|
-
validUntil: null,
|
|
8193
7697
|
externalId: "pcQYbPuKGZ7"
|
|
8194
7698
|
},
|
|
8195
7699
|
// Villages under Itambo (89a33893-b17d-481d-a26d-6461e7ac1651)
|
|
@@ -8197,67 +7701,59 @@ var V2_DEFAULT_MOCK_ADMINISTRATIVE_AREAS = [
|
|
|
8197
7701
|
id: "3d6e7f8a-9b0c-4534-8efa-567890123456",
|
|
8198
7702
|
name: "Felani",
|
|
8199
7703
|
parentId: "89a33893-b17d-481d-a26d-6461e7ac1651",
|
|
8200
|
-
validUntil: null,
|
|
8201
7704
|
externalId: "gSqpoCGdMXp"
|
|
8202
7705
|
},
|
|
8203
7706
|
{
|
|
8204
7707
|
id: "4e7f8a9b-0c1d-4645-8fab-678901234567",
|
|
8205
7708
|
name: "Goroma",
|
|
8206
7709
|
parentId: "89a33893-b17d-481d-a26d-6461e7ac1651",
|
|
8207
|
-
validUntil: null,
|
|
8208
7710
|
externalId: "KvAAIaNqVrp"
|
|
8209
7711
|
},
|
|
8210
7712
|
{
|
|
8211
7713
|
id: "5f8a9b0c-1d2e-4756-8abc-789012345678",
|
|
8212
7714
|
name: "Halifu",
|
|
8213
7715
|
parentId: "89a33893-b17d-481d-a26d-6461e7ac1651",
|
|
8214
|
-
validUntil: null,
|
|
8215
7716
|
externalId: "qe4UnEVt1hv"
|
|
8216
7717
|
},
|
|
8217
7718
|
{
|
|
8218
7719
|
id: "6a9b0c1d-2e3f-4867-abcd-890123456789",
|
|
8219
7720
|
name: "Jabari",
|
|
8220
7721
|
parentId: "89a33893-b17d-481d-a26d-6461e7ac1651",
|
|
8221
|
-
validUntil: null,
|
|
8222
7722
|
externalId: "yHH9Nz4rLOt"
|
|
8223
7723
|
},
|
|
8224
7724
|
{
|
|
8225
7725
|
id: "7b0c1d2e-3f4a-4978-bcde-901234567890",
|
|
8226
7726
|
name: "Kifani",
|
|
8227
7727
|
parentId: "89a33893-b17d-481d-a26d-6461e7ac1651",
|
|
8228
|
-
validUntil: null,
|
|
8229
7728
|
externalId: "eSWmXIGeu1I"
|
|
8230
7729
|
},
|
|
8231
7730
|
{
|
|
8232
7731
|
id: "8c1d2e3f-4a5b-4089-8def-012345678901",
|
|
8233
7732
|
name: "Lumela",
|
|
8234
7733
|
parentId: "89a33893-b17d-481d-a26d-6461e7ac1651",
|
|
8235
|
-
validUntil: null,
|
|
8236
7734
|
externalId: "bh0b3aI1uP3"
|
|
8237
7735
|
}
|
|
8238
7736
|
];
|
|
8239
|
-
var
|
|
7737
|
+
var V2_DEFAULT_MOCK_ADMINISTRATIVE_AREAS = MOCK_ADMINISTRATIVE_AREAS_BASE.map(withVersionFields);
|
|
7738
|
+
var MOCK_LOCATIONS_BASE = [
|
|
8240
7739
|
{
|
|
8241
7740
|
id: "6f6186ce-cd5f-4a5f-810a-2d99e7c4ba12",
|
|
8242
7741
|
name: "Central Provincial Office",
|
|
8243
7742
|
locationType: "CRVS_OFFICE",
|
|
8244
7743
|
administrativeAreaId: "a45b982a-5c7b-4bd9-8fd8-a42d0994054c",
|
|
8245
|
-
validUntil: null,
|
|
8246
7744
|
externalId: "Xr3Df8WpK6Ys"
|
|
8247
7745
|
},
|
|
8248
7746
|
{
|
|
8249
7747
|
id: "b1c2d3e4-f5a6-7890-bcde-f12345678901",
|
|
8250
7748
|
name: "Central Health Post",
|
|
8251
7749
|
locationType: "HEALTH_FACILITY",
|
|
8252
|
-
administrativeAreaId: "a45b982a-5c7b-4bd9-8fd8-a42d0994054c"
|
|
8253
|
-
validUntil: null
|
|
7750
|
+
administrativeAreaId: "a45b982a-5c7b-4bd9-8fd8-a42d0994054c"
|
|
8254
7751
|
},
|
|
8255
7752
|
{
|
|
8256
7753
|
id: "028d2c85-ca31-426d-b5d1-2cef545a4902",
|
|
8257
7754
|
name: "Ibombo District Office",
|
|
8258
7755
|
locationType: "CRVS_OFFICE",
|
|
8259
7756
|
administrativeAreaId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
|
|
8260
|
-
validUntil: null,
|
|
8261
7757
|
externalId: "Sm4Nw7GrD2Vy"
|
|
8262
7758
|
},
|
|
8263
7759
|
{
|
|
@@ -8265,7 +7761,6 @@ var V2_DEFAULT_MOCK_LOCATIONS = [
|
|
|
8265
7761
|
name: "Isamba District Office",
|
|
8266
7762
|
locationType: "CRVS_OFFICE",
|
|
8267
7763
|
administrativeAreaId: "967032fd-3f81-478a-826c-30cb8fe121bd",
|
|
8268
|
-
validUntil: null,
|
|
8269
7764
|
externalId: "Vg1Bq5XeH9Lt"
|
|
8270
7765
|
},
|
|
8271
7766
|
{
|
|
@@ -8273,7 +7768,6 @@ var V2_DEFAULT_MOCK_LOCATIONS = [
|
|
|
8273
7768
|
name: "Isango District Office",
|
|
8274
7769
|
locationType: "CRVS_OFFICE",
|
|
8275
7770
|
administrativeAreaId: "27160bbd-32d1-4625-812f-860226bfb92a",
|
|
8276
|
-
validUntil: null,
|
|
8277
7771
|
externalId: "Je7Lm2XqN9Vz"
|
|
8278
7772
|
},
|
|
8279
7773
|
{
|
|
@@ -8281,7 +7775,6 @@ var V2_DEFAULT_MOCK_LOCATIONS = [
|
|
|
8281
7775
|
name: "Sulaka Provincial Office",
|
|
8282
7776
|
locationType: "CRVS_OFFICE",
|
|
8283
7777
|
administrativeAreaId: "c599b691-fd2d-45e1-abf4-d185de727fb5",
|
|
8284
|
-
validUntil: null,
|
|
8285
7778
|
externalId: "Ht2Wp9KcX5Qv"
|
|
8286
7779
|
},
|
|
8287
7780
|
{
|
|
@@ -8289,7 +7782,6 @@ var V2_DEFAULT_MOCK_LOCATIONS = [
|
|
|
8289
7782
|
name: "Ilanga District Office",
|
|
8290
7783
|
locationType: "CRVS_OFFICE",
|
|
8291
7784
|
administrativeAreaId: "8fbd09d2-212b-47f4-beb3-5e1694931d9f",
|
|
8292
|
-
validUntil: null,
|
|
8293
7785
|
externalId: "Yp6Ds1WqN3Xz"
|
|
8294
7786
|
},
|
|
8295
7787
|
{
|
|
@@ -8297,7 +7789,6 @@ var V2_DEFAULT_MOCK_LOCATIONS = [
|
|
|
8297
7789
|
name: "Chamakubi Health Post",
|
|
8298
7790
|
locationType: "HEALTH_FACILITY",
|
|
8299
7791
|
administrativeAreaId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
|
|
8300
|
-
validUntil: null,
|
|
8301
7792
|
externalId: "M1nFr8LbC2Qy"
|
|
8302
7793
|
},
|
|
8303
7794
|
{
|
|
@@ -8305,7 +7796,6 @@ var V2_DEFAULT_MOCK_LOCATIONS = [
|
|
|
8305
7796
|
name: "Ibombo Rural Health Centre",
|
|
8306
7797
|
locationType: "HEALTH_FACILITY",
|
|
8307
7798
|
administrativeAreaId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
|
|
8308
|
-
validUntil: null,
|
|
8309
7799
|
externalId: "bT7pV6YrW0Xc"
|
|
8310
7800
|
},
|
|
8311
7801
|
{
|
|
@@ -8313,7 +7803,6 @@ var V2_DEFAULT_MOCK_LOCATIONS = [
|
|
|
8313
7803
|
name: "Chikobo Rural Health Centre",
|
|
8314
7804
|
locationType: "HEALTH_FACILITY",
|
|
8315
7805
|
administrativeAreaId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
|
|
8316
|
-
validUntil: null,
|
|
8317
7806
|
externalId: "zE4qPn2SgJ5d"
|
|
8318
7807
|
},
|
|
8319
7808
|
{
|
|
@@ -8321,7 +7810,6 @@ var V2_DEFAULT_MOCK_LOCATIONS = [
|
|
|
8321
7810
|
name: "Chilochabalenje Health Post",
|
|
8322
7811
|
locationType: "HEALTH_FACILITY",
|
|
8323
7812
|
administrativeAreaId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
|
|
8324
|
-
validUntil: null,
|
|
8325
7813
|
externalId: "H8vDs1MqR4Uf"
|
|
8326
7814
|
},
|
|
8327
7815
|
{
|
|
@@ -8329,7 +7817,6 @@ var V2_DEFAULT_MOCK_LOCATIONS = [
|
|
|
8329
7817
|
name: "Chipeso Rural Health Centre",
|
|
8330
7818
|
locationType: "HEALTH_FACILITY",
|
|
8331
7819
|
administrativeAreaId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
|
|
8332
|
-
validUntil: null,
|
|
8333
7820
|
externalId: "Qw3uZ9KfX6Lm"
|
|
8334
7821
|
},
|
|
8335
7822
|
{
|
|
@@ -8337,7 +7824,6 @@ var V2_DEFAULT_MOCK_LOCATIONS = [
|
|
|
8337
7824
|
name: "Chisamba Rural Health Centre",
|
|
8338
7825
|
locationType: "HEALTH_FACILITY",
|
|
8339
7826
|
administrativeAreaId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
|
|
8340
|
-
validUntil: null,
|
|
8341
7827
|
externalId: "Yr0pCg8LdM2s"
|
|
8342
7828
|
},
|
|
8343
7829
|
{
|
|
@@ -8345,7 +7831,6 @@ var V2_DEFAULT_MOCK_LOCATIONS = [
|
|
|
8345
7831
|
name: "Chitanda Rural Health Centre",
|
|
8346
7832
|
locationType: "HEALTH_FACILITY",
|
|
8347
7833
|
administrativeAreaId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
|
|
8348
|
-
validUntil: null,
|
|
8349
7834
|
externalId: "tS9gJ4PwB1Qx"
|
|
8350
7835
|
},
|
|
8351
7836
|
{
|
|
@@ -8353,7 +7838,6 @@ var V2_DEFAULT_MOCK_LOCATIONS = [
|
|
|
8353
7838
|
name: "Golden Valley Rural Health Centre",
|
|
8354
7839
|
locationType: "HEALTH_FACILITY",
|
|
8355
7840
|
administrativeAreaId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
|
|
8356
|
-
validUntil: null,
|
|
8357
7841
|
externalId: "Ld7Qm3XsA8Vr"
|
|
8358
7842
|
},
|
|
8359
7843
|
{
|
|
@@ -8361,7 +7845,6 @@ var V2_DEFAULT_MOCK_LOCATIONS = [
|
|
|
8361
7845
|
name: "Ipongo Rural Health Centre",
|
|
8362
7846
|
locationType: "HEALTH_FACILITY",
|
|
8363
7847
|
administrativeAreaId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
|
|
8364
|
-
validUntil: null,
|
|
8365
7848
|
externalId: "kF2sW9DmH0Bt"
|
|
8366
7849
|
},
|
|
8367
7850
|
{
|
|
@@ -8369,7 +7852,6 @@ var V2_DEFAULT_MOCK_LOCATIONS = [
|
|
|
8369
7852
|
name: "Itumbwe Health Post",
|
|
8370
7853
|
locationType: "HEALTH_FACILITY",
|
|
8371
7854
|
administrativeAreaId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
|
|
8372
|
-
validUntil: null,
|
|
8373
7855
|
externalId: "Ue5Xb3VaC7Pq"
|
|
8374
7856
|
},
|
|
8375
7857
|
{
|
|
@@ -8377,7 +7859,6 @@ var V2_DEFAULT_MOCK_LOCATIONS = [
|
|
|
8377
7859
|
name: "Kabangalala Rural Health Centre",
|
|
8378
7860
|
locationType: "HEALTH_FACILITY",
|
|
8379
7861
|
administrativeAreaId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
|
|
8380
|
-
validUntil: null,
|
|
8381
7862
|
externalId: "Pz8Kc1TqH6Jn"
|
|
8382
7863
|
},
|
|
8383
7864
|
// Village offices
|
|
@@ -8386,19 +7867,76 @@ var V2_DEFAULT_MOCK_LOCATIONS = [
|
|
|
8386
7867
|
name: "Klow Village Office",
|
|
8387
7868
|
locationType: "CRVS_OFFICE",
|
|
8388
7869
|
administrativeAreaId: "1d4e5f6a-7b8c-4912-8efa-345678901234",
|
|
8389
|
-
validUntil: null,
|
|
8390
7870
|
externalId: "PmAyxAJkxiJ"
|
|
8391
7871
|
}
|
|
8392
7872
|
];
|
|
7873
|
+
var V2_DEFAULT_MOCK_LOCATIONS = MOCK_LOCATIONS_BASE.map(withVersionFields);
|
|
8393
7874
|
var V2_DEFAULT_MOCK_LOCATIONS_MAP = new Map(
|
|
8394
7875
|
V2_DEFAULT_MOCK_LOCATIONS.map((l) => [l.id, l])
|
|
8395
7876
|
);
|
|
8396
7877
|
var V2_DEFAULT_MOCK_ADMINISTRATIVE_AREAS_MAP = new Map(
|
|
8397
7878
|
V2_DEFAULT_MOCK_ADMINISTRATIVE_AREAS.map((a) => [a.id, a])
|
|
8398
7879
|
);
|
|
7880
|
+
var V2_DEFAULT_MOCK_CLIENT_LOCATIONS_MAP = new Map(
|
|
7881
|
+
V2_DEFAULT_MOCK_LOCATIONS.map((l) => [l.id, toClientLocation(l)])
|
|
7882
|
+
);
|
|
7883
|
+
var V2_DEFAULT_MOCK_CLIENT_ADMINISTRATIVE_AREAS_MAP = new Map(
|
|
7884
|
+
V2_DEFAULT_MOCK_ADMINISTRATIVE_AREAS.map((a) => [
|
|
7885
|
+
a.id,
|
|
7886
|
+
toClientAdministrativeArea(a)
|
|
7887
|
+
])
|
|
7888
|
+
);
|
|
8399
7889
|
|
|
8400
|
-
// ../commons/src/
|
|
7890
|
+
// ../commons/src/events/locationPayloads.ts
|
|
8401
7891
|
var z44 = __toESM(require("zod/v4"));
|
|
7892
|
+
var CreateLocationPayload = z44.object({
|
|
7893
|
+
id: UUID.optional(),
|
|
7894
|
+
versionId: UUID.optional(),
|
|
7895
|
+
name: z44.string(),
|
|
7896
|
+
externalId: z44.string().nullish(),
|
|
7897
|
+
administrativeAreaId: UUID.nullable(),
|
|
7898
|
+
locationType: z44.string().nullable(),
|
|
7899
|
+
effectiveFrom: z44.iso.date().optional(),
|
|
7900
|
+
status: LocationStatus.default("active")
|
|
7901
|
+
});
|
|
7902
|
+
var UpdateLocationPayload = z44.strictObject({
|
|
7903
|
+
id: UUID,
|
|
7904
|
+
versionId: UUID.optional(),
|
|
7905
|
+
name: z44.string(),
|
|
7906
|
+
externalId: z44.string().nullish(),
|
|
7907
|
+
status: LocationStatus,
|
|
7908
|
+
effectiveFrom: z44.iso.date().optional(),
|
|
7909
|
+
lastVersionId: UUID
|
|
7910
|
+
});
|
|
7911
|
+
var WithdrawLocationVersionPayload = z44.object({
|
|
7912
|
+
id: UUID,
|
|
7913
|
+
versionId: UUID
|
|
7914
|
+
});
|
|
7915
|
+
var CreateAdministrativeAreaPayload = z44.object({
|
|
7916
|
+
id: UUID.optional(),
|
|
7917
|
+
versionId: UUID.optional(),
|
|
7918
|
+
name: z44.string(),
|
|
7919
|
+
externalId: z44.string().nullish(),
|
|
7920
|
+
parentId: UUID.nullable(),
|
|
7921
|
+
effectiveFrom: z44.iso.date().optional(),
|
|
7922
|
+
status: LocationStatus.default("active")
|
|
7923
|
+
});
|
|
7924
|
+
var UpdateAdministrativeAreaPayload = z44.strictObject({
|
|
7925
|
+
id: UUID,
|
|
7926
|
+
versionId: UUID.optional(),
|
|
7927
|
+
name: z44.string(),
|
|
7928
|
+
externalId: z44.string().nullish(),
|
|
7929
|
+
status: LocationStatus,
|
|
7930
|
+
effectiveFrom: z44.iso.date().optional(),
|
|
7931
|
+
lastVersionId: UUID
|
|
7932
|
+
});
|
|
7933
|
+
var WithdrawAdministrativeAreaVersionPayload = z44.object({
|
|
7934
|
+
id: UUID,
|
|
7935
|
+
versionId: UUID
|
|
7936
|
+
});
|
|
7937
|
+
|
|
7938
|
+
// ../commons/src/notification/UserNotifications.ts
|
|
7939
|
+
var z45 = __toESM(require("zod/v4"));
|
|
8402
7940
|
var TriggerEvent = {
|
|
8403
7941
|
USER_CREATED: "user-created",
|
|
8404
7942
|
USER_UPDATED: "user-updated",
|
|
@@ -8411,54 +7949,54 @@ var TriggerEvent = {
|
|
|
8411
7949
|
CHANGE_PHONE_NUMBER: "change-phone-number",
|
|
8412
7950
|
CHANGE_EMAIL_ADDRESS: "change-email-address"
|
|
8413
7951
|
};
|
|
8414
|
-
var Recipient =
|
|
7952
|
+
var Recipient = z45.object({
|
|
8415
7953
|
name: NameFieldValue.optional(),
|
|
8416
|
-
mobile:
|
|
8417
|
-
email:
|
|
8418
|
-
bcc:
|
|
7954
|
+
mobile: z45.string().optional(),
|
|
7955
|
+
email: z45.string().optional(),
|
|
7956
|
+
bcc: z45.array(z45.string()).optional()
|
|
8419
7957
|
});
|
|
8420
|
-
var BasePayload =
|
|
7958
|
+
var BasePayload = z45.object({
|
|
8421
7959
|
recipient: Recipient
|
|
8422
7960
|
});
|
|
8423
7961
|
var TriggerPayload = {
|
|
8424
7962
|
[TriggerEvent.USER_CREATED]: BasePayload.extend({
|
|
8425
|
-
username:
|
|
8426
|
-
temporaryPassword:
|
|
7963
|
+
username: z45.string(),
|
|
7964
|
+
temporaryPassword: z45.string()
|
|
8427
7965
|
}),
|
|
8428
7966
|
[TriggerEvent.USER_UPDATED]: BasePayload.extend({
|
|
8429
|
-
oldUsername:
|
|
8430
|
-
newUsername:
|
|
7967
|
+
oldUsername: z45.string(),
|
|
7968
|
+
newUsername: z45.string()
|
|
8431
7969
|
}),
|
|
8432
7970
|
[TriggerEvent.USERNAME_REMINDER]: BasePayload.extend({
|
|
8433
|
-
username:
|
|
7971
|
+
username: z45.string()
|
|
8434
7972
|
}),
|
|
8435
7973
|
[TriggerEvent.RESET_PASSWORD]: BasePayload.extend({
|
|
8436
|
-
code:
|
|
7974
|
+
code: z45.string()
|
|
8437
7975
|
}),
|
|
8438
7976
|
[TriggerEvent.RESET_PASSWORD_BY_ADMIN]: BasePayload.extend({
|
|
8439
|
-
temporaryPassword:
|
|
8440
|
-
admin:
|
|
8441
|
-
id:
|
|
7977
|
+
temporaryPassword: z45.string(),
|
|
7978
|
+
admin: z45.object({
|
|
7979
|
+
id: z45.string(),
|
|
8442
7980
|
name: NameFieldValue,
|
|
8443
|
-
role:
|
|
7981
|
+
role: z45.string()
|
|
8444
7982
|
})
|
|
8445
7983
|
}),
|
|
8446
7984
|
[TriggerEvent.RESEND_INVITE]: BasePayload.extend({
|
|
8447
|
-
username:
|
|
8448
|
-
temporaryPassword:
|
|
7985
|
+
username: z45.string(),
|
|
7986
|
+
temporaryPassword: z45.string()
|
|
8449
7987
|
}),
|
|
8450
7988
|
[TriggerEvent.TWO_FA]: BasePayload.extend({
|
|
8451
|
-
code:
|
|
7989
|
+
code: z45.string()
|
|
8452
7990
|
}),
|
|
8453
7991
|
[TriggerEvent.ALL_USER_NOTIFICATION]: BasePayload.extend({
|
|
8454
|
-
subject:
|
|
8455
|
-
body:
|
|
7992
|
+
subject: z45.string(),
|
|
7993
|
+
body: z45.string()
|
|
8456
7994
|
}),
|
|
8457
7995
|
[TriggerEvent.CHANGE_PHONE_NUMBER]: BasePayload.extend({
|
|
8458
|
-
code:
|
|
7996
|
+
code: z45.string()
|
|
8459
7997
|
}),
|
|
8460
7998
|
[TriggerEvent.CHANGE_EMAIL_ADDRESS]: BasePayload.extend({
|
|
8461
|
-
code:
|
|
7999
|
+
code: z45.string()
|
|
8462
8000
|
})
|
|
8463
8001
|
};
|
|
8464
8002
|
async function triggerUserEventNotification({
|
|
@@ -8482,4 +8020,4 @@ function parseUserEventTrigger(event2, body) {
|
|
|
8482
8020
|
}
|
|
8483
8021
|
|
|
8484
8022
|
// src/notification/index.ts
|
|
8485
|
-
|
|
8023
|
+
z46.globalRegistry.clear();
|