@opencrvs/toolkit 2.1.0-rc.806dc30 → 2.1.0-rc.811fc78
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 +200 -190
- package/dist/commons/api/router.d.ts +1514 -1618
- package/dist/commons/application-config/index.d.ts +6 -6
- package/dist/commons/conditionals/conditionals.d.ts +2102 -259
- package/dist/commons/conditionals/validate.d.ts +2 -1
- package/dist/commons/events/ActionConfig.d.ts +126 -105
- package/dist/commons/events/ActionDocument.d.ts +111 -117
- package/dist/commons/events/ActionStatus.d.ts +14 -0
- package/dist/commons/events/ActionType.d.ts +62 -62
- package/dist/commons/events/AdvancedSearchConfig.d.ts +513 -513
- package/dist/commons/events/AuditLog.d.ts +42 -79
- package/dist/commons/events/CompositeFieldValue.d.ts +4 -4
- package/dist/commons/events/Conditional.d.ts +3 -3
- package/dist/commons/events/CountryConfigQueryInput.d.ts +608 -590
- package/dist/commons/events/Draft.d.ts +37 -37
- package/dist/commons/events/DynamicFieldValue.d.ts +9 -9
- package/dist/commons/events/EventConfig.d.ts +5 -5
- package/dist/commons/events/EventDocument.d.ts +46 -46
- package/dist/commons/events/EventIndex.d.ts +52 -71
- package/dist/commons/events/EventMetadata.d.ts +41 -40
- package/dist/commons/events/FieldConfig.d.ts +342 -342
- package/dist/commons/events/FieldType.d.ts +51 -51
- package/dist/commons/events/FieldTypeMapping.d.ts +100 -100
- package/dist/commons/events/FieldValue.d.ts +12 -12
- package/dist/commons/events/Flag.d.ts +63 -15
- package/dist/commons/events/TemplateConfig.d.ts +1 -1
- package/dist/commons/events/WorkqueueColumnConfig.d.ts +40 -40
- package/dist/commons/events/WorkqueueConfig.d.ts +835 -820
- package/dist/commons/events/deduplication.d.ts +1 -1
- package/dist/commons/events/event.d.ts +2 -2
- package/dist/commons/events/field.d.ts +895 -78
- package/dist/commons/events/index.d.ts +0 -1
- package/dist/commons/events/locations.d.ts +6 -103
- package/dist/commons/events/mocks.test.utils.d.ts +4 -18
- package/dist/commons/events/scopes.d.ts +4 -4
- package/dist/commons/events/state/index.d.ts +17 -17
- package/dist/commons/events/state/utils.d.ts +7 -7
- package/dist/commons/events/test.utils.d.ts +40 -40
- package/dist/commons/events/utils.d.ts +114 -114
- package/dist/commons/notification/UserNotifications.d.ts +10 -10
- package/dist/conditionals/index.js +303 -56
- package/dist/environment/derived-variables.d.ts +119 -119
- package/dist/environment/derived-variables.d.ts.map +1 -1
- package/dist/environment/logger.d.ts.map +1 -1
- package/dist/environment/questions.d.ts +74 -75
- package/dist/environment/questions.d.ts.map +1 -1
- package/dist/environment/setup-environment.js +14 -8
- package/dist/environment/utils.d.ts +1 -1
- package/dist/events/deduplication.d.ts +1 -1
- package/dist/events/index.js +3278 -3333
- package/dist/migrations/v2.0/migrate-application-config-url.js +3 -4
- package/dist/notification/index.js +1492 -996
- package/dist/scopes/index.d.ts +396 -148
- package/dist/scopes/index.js +304 -56
- package/opencrvs-toolkit-2.1.0-rc.811fc78.tgz +0 -0
- package/package.json +5 -5
- package/tsconfig.tsbuildinfo +1 -1
- package/dist/commons/events/locationPayloads.d.ts +0 -95
- package/opencrvs-toolkit-2.1.0-rc.806dc30.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 z45 = __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 z8 = __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 z7 = __toESM(require("zod/v4"));
|
|
55
55
|
|
|
56
56
|
// ../commons/src/scopes.ts
|
|
57
|
-
var
|
|
57
|
+
var z6 = __toESM(require("zod/v4"));
|
|
58
58
|
var qs = __toESM(require("qs"));
|
|
59
59
|
|
|
60
60
|
// ../commons/src/uuid.ts
|
|
@@ -65,12 +65,264 @@ 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
|
+
|
|
68
320
|
// ../commons/src/scopes.ts
|
|
69
|
-
var JurisdictionFilter =
|
|
321
|
+
var JurisdictionFilter = z6.enum(["administrativeArea", "location", "all"]).describe(
|
|
70
322
|
"Filters based on user jurisdiction relative to their office location in hierarchy."
|
|
71
323
|
);
|
|
72
|
-
var UserFilter =
|
|
73
|
-
var RecordScopeTypeV2 =
|
|
324
|
+
var UserFilter = z6.enum(["user"]).describe("Filters based on the user. Limits to self.");
|
|
325
|
+
var RecordScopeTypeV2 = z6.enum([
|
|
74
326
|
"record.search",
|
|
75
327
|
"record.create",
|
|
76
328
|
"record.read",
|
|
@@ -88,7 +340,7 @@ var RecordScopeTypeV2 = z2.enum([
|
|
|
88
340
|
"record.unassign-others",
|
|
89
341
|
"record.custom-action"
|
|
90
342
|
]);
|
|
91
|
-
var PlainScopeType =
|
|
343
|
+
var PlainScopeType = z6.enum([
|
|
92
344
|
// Misc. system scopes
|
|
93
345
|
"bypassratelimit",
|
|
94
346
|
"record.reindex",
|
|
@@ -96,7 +348,6 @@ var PlainScopeType = z2.enum([
|
|
|
96
348
|
"integration.create",
|
|
97
349
|
"record.import",
|
|
98
350
|
"config.update-all",
|
|
99
|
-
"location.edit",
|
|
100
351
|
"attachment.upload",
|
|
101
352
|
"profile.electronic-signature",
|
|
102
353
|
"user.read-only-my-audit",
|
|
@@ -108,15 +359,15 @@ var PlainScopeType = z2.enum([
|
|
|
108
359
|
"record.confirm-registration",
|
|
109
360
|
"record.reject-registration"
|
|
110
361
|
]);
|
|
111
|
-
var scopeByEvent =
|
|
362
|
+
var scopeByEvent = z6.preprocess(
|
|
112
363
|
(val) => val === void 0 ? void 0 : [val].flat(),
|
|
113
|
-
|
|
364
|
+
z6.array(z6.string()).optional()
|
|
114
365
|
).describe("Event type, e.g. birth, death");
|
|
115
|
-
var userRole =
|
|
366
|
+
var userRole = z6.preprocess(
|
|
116
367
|
(val) => val === void 0 ? void 0 : [val].flat(),
|
|
117
|
-
|
|
368
|
+
z6.array(z6.string()).optional()
|
|
118
369
|
).describe("User role, e.g. admin, field agent");
|
|
119
|
-
var scopeOptionsPlaceEvent =
|
|
370
|
+
var scopeOptionsPlaceEvent = z6.object({
|
|
120
371
|
event: scopeByEvent,
|
|
121
372
|
placeOfEvent: JurisdictionFilter.optional()
|
|
122
373
|
}).describe("Options applicable to all record scopes.");
|
|
@@ -128,36 +379,37 @@ var scopeOptionsDeclaredOrNotified = scopeOptionsPlaceEvent.extend({
|
|
|
128
379
|
}).describe("Options applicable to actions that may take place after DECLARE");
|
|
129
380
|
var AllRecordScopeOptions = scopeOptionsDeclaredOrNotified.extend({
|
|
130
381
|
registeredIn: JurisdictionFilter.optional(),
|
|
131
|
-
registeredBy: UserFilter.optional()
|
|
382
|
+
registeredBy: UserFilter.optional(),
|
|
383
|
+
flags: ContainsFlags.optional()
|
|
132
384
|
}).describe(
|
|
133
385
|
"Options applicable to actions that may take place after REGISTER, with full filtering capabilities."
|
|
134
386
|
);
|
|
135
387
|
var CustomActionScopeOptions = AllRecordScopeOptions.extend({
|
|
136
|
-
customActionTypes:
|
|
388
|
+
customActionTypes: z6.preprocess(
|
|
137
389
|
(val) => val === void 0 ? void 0 : [val].flat(),
|
|
138
|
-
|
|
390
|
+
z6.array(z6.string()).optional()
|
|
139
391
|
).describe("Allowed custom action types")
|
|
140
392
|
});
|
|
141
|
-
var AccessLevelOptions =
|
|
393
|
+
var AccessLevelOptions = z6.object({
|
|
142
394
|
accessLevel: JurisdictionFilter.optional()
|
|
143
395
|
});
|
|
144
396
|
var AllUserScopeOptions = AccessLevelOptions.extend({
|
|
145
397
|
role: userRole.optional()
|
|
146
398
|
});
|
|
147
|
-
var WorkqueueOrDashboardOptions =
|
|
148
|
-
ids:
|
|
399
|
+
var WorkqueueOrDashboardOptions = z6.object({
|
|
400
|
+
ids: z6.preprocess(
|
|
149
401
|
(val) => val === void 0 ? void 0 : [val].flat(),
|
|
150
|
-
|
|
402
|
+
z6.array(z6.string())
|
|
151
403
|
).describe("Must contain a list of workqueue or dashboard ids.")
|
|
152
404
|
});
|
|
153
|
-
var AllScopeOptions =
|
|
405
|
+
var AllScopeOptions = z6.object({
|
|
154
406
|
...AllRecordScopeOptions.shape,
|
|
155
407
|
...AccessLevelOptions.shape,
|
|
156
408
|
...AllUserScopeOptions.shape,
|
|
157
409
|
...WorkqueueOrDashboardOptions.shape
|
|
158
410
|
});
|
|
159
411
|
var ScopeOptionKey = AllScopeOptions.keyof();
|
|
160
|
-
var ResolvedScopeOptionsPlaceEvent =
|
|
412
|
+
var ResolvedScopeOptionsPlaceEvent = z6.object({
|
|
161
413
|
event: scopeByEvent,
|
|
162
414
|
placeOfEvent: UUID.nullish()
|
|
163
415
|
}).describe(
|
|
@@ -165,15 +417,16 @@ var ResolvedScopeOptionsPlaceEvent = z2.object({
|
|
|
165
417
|
);
|
|
166
418
|
var ResolvedScopeOptionsDeclared = ResolvedScopeOptionsPlaceEvent.extend({
|
|
167
419
|
notifiedIn: UUID.nullish(),
|
|
168
|
-
notifiedBy:
|
|
420
|
+
notifiedBy: z6.string().optional(),
|
|
169
421
|
declaredIn: UUID.nullish(),
|
|
170
|
-
declaredBy:
|
|
422
|
+
declaredBy: z6.string().optional()
|
|
171
423
|
}).describe(
|
|
172
424
|
"Resolved options applicable to actions that may take place after DECLARE, with location ID and user ID instead of filters."
|
|
173
425
|
);
|
|
174
426
|
var ResolvedScopeOptionsFull = ResolvedScopeOptionsDeclared.extend({
|
|
175
427
|
registeredIn: UUID.nullish(),
|
|
176
|
-
registeredBy:
|
|
428
|
+
registeredBy: z6.string().optional(),
|
|
429
|
+
flags: ContainsFlags.optional()
|
|
177
430
|
}).describe(
|
|
178
431
|
"Resolved options applicable to actions that may take place after REGISTER, with full filtering capabilities and location/user IDs instead of filters."
|
|
179
432
|
);
|
|
@@ -198,38 +451,38 @@ var ScopesWithFullOptions = RecordScopeTypeV2.extract([
|
|
|
198
451
|
"record.unassign-others"
|
|
199
452
|
]);
|
|
200
453
|
var ScopeOptionsPrintCertifiedCopies = AllRecordScopeOptions.extend({
|
|
201
|
-
templates:
|
|
454
|
+
templates: z6.preprocess(
|
|
202
455
|
(val) => val === void 0 ? void 0 : [val].flat(),
|
|
203
|
-
|
|
456
|
+
z6.array(z6.string()).optional()
|
|
204
457
|
).describe(
|
|
205
458
|
"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."
|
|
206
459
|
)
|
|
207
460
|
});
|
|
208
|
-
var RecordScopeV2 =
|
|
209
|
-
|
|
461
|
+
var RecordScopeV2 = z6.discriminatedUnion("type", [
|
|
462
|
+
z6.object({
|
|
210
463
|
type: ScopesWithPlaceEventOptions,
|
|
211
464
|
options: scopeOptionsPlaceEvent.optional()
|
|
212
465
|
}),
|
|
213
|
-
|
|
466
|
+
z6.object({
|
|
214
467
|
type: ScopesWithDeclaredOptions,
|
|
215
468
|
options: scopeOptionsDeclaredOrNotified.optional()
|
|
216
469
|
}),
|
|
217
|
-
|
|
470
|
+
z6.object({
|
|
218
471
|
type: ScopesWithFullOptions,
|
|
219
472
|
options: AllRecordScopeOptions.optional()
|
|
220
473
|
}),
|
|
221
|
-
|
|
222
|
-
type:
|
|
474
|
+
z6.object({
|
|
475
|
+
type: z6.literal("record.custom-action"),
|
|
223
476
|
options: CustomActionScopeOptions.optional()
|
|
224
477
|
}),
|
|
225
|
-
|
|
226
|
-
type:
|
|
478
|
+
z6.object({
|
|
479
|
+
type: z6.literal("record.print-certified-copies"),
|
|
227
480
|
options: ScopeOptionsPrintCertifiedCopies.optional()
|
|
228
481
|
})
|
|
229
482
|
]).describe(
|
|
230
483
|
"Scopes used to check user's permission to perform actions on a record."
|
|
231
484
|
);
|
|
232
|
-
var SystemScopeType =
|
|
485
|
+
var SystemScopeType = z6.enum([
|
|
233
486
|
"organisation.read-locations",
|
|
234
487
|
"user.read",
|
|
235
488
|
"user.create",
|
|
@@ -243,61 +496,61 @@ var UserScopeType = SystemScopeType.extract([
|
|
|
243
496
|
"user.search"
|
|
244
497
|
]);
|
|
245
498
|
var ScopesWithRoleOption = UserScopeType.extract(["user.edit", "user.create"]);
|
|
246
|
-
var UserScopeV2 =
|
|
247
|
-
|
|
499
|
+
var UserScopeV2 = z6.discriminatedUnion("type", [
|
|
500
|
+
z6.object({
|
|
248
501
|
type: ScopesWithRoleOption,
|
|
249
502
|
options: AllUserScopeOptions.optional()
|
|
250
503
|
}),
|
|
251
|
-
|
|
504
|
+
z6.object({
|
|
252
505
|
type: UserScopeType.extract(["user.read", "user.search"]),
|
|
253
506
|
options: AccessLevelOptions.optional()
|
|
254
507
|
})
|
|
255
508
|
]);
|
|
256
|
-
var ResolvedRecordScopeV2 =
|
|
257
|
-
|
|
509
|
+
var ResolvedRecordScopeV2 = z6.discriminatedUnion("type", [
|
|
510
|
+
z6.object({
|
|
258
511
|
type: ScopesWithPlaceEventOptions,
|
|
259
512
|
options: ResolvedScopeOptionsPlaceEvent.optional()
|
|
260
513
|
}),
|
|
261
|
-
|
|
514
|
+
z6.object({
|
|
262
515
|
type: ScopesWithDeclaredOptions,
|
|
263
516
|
options: ResolvedScopeOptionsDeclared.optional()
|
|
264
517
|
}),
|
|
265
|
-
|
|
518
|
+
z6.object({
|
|
266
519
|
type: ScopesWithFullOptions,
|
|
267
520
|
options: ResolvedScopeOptionsFull.optional()
|
|
268
521
|
}),
|
|
269
|
-
|
|
270
|
-
type:
|
|
522
|
+
z6.object({
|
|
523
|
+
type: z6.literal("record.print-certified-copies"),
|
|
271
524
|
options: ResolvedScopeOptionsFull.extend({
|
|
272
|
-
templates:
|
|
525
|
+
templates: z6.array(z6.string()).optional()
|
|
273
526
|
}).optional()
|
|
274
527
|
})
|
|
275
528
|
]).describe("Resolved scope with location/user IDs instead of filters.");
|
|
276
|
-
var Scope =
|
|
277
|
-
|
|
529
|
+
var Scope = z6.discriminatedUnion("type", [
|
|
530
|
+
z6.object({ type: PlainScopeType }),
|
|
278
531
|
...RecordScopeV2.options,
|
|
279
532
|
...UserScopeV2.options,
|
|
280
|
-
|
|
281
|
-
type:
|
|
533
|
+
z6.object({
|
|
534
|
+
type: z6.literal("organisation.read-locations"),
|
|
282
535
|
options: AccessLevelOptions.optional()
|
|
283
536
|
}),
|
|
284
|
-
|
|
285
|
-
type:
|
|
537
|
+
z6.object({
|
|
538
|
+
type: z6.literal("workqueue"),
|
|
286
539
|
options: WorkqueueOrDashboardOptions
|
|
287
540
|
}),
|
|
288
|
-
|
|
289
|
-
type:
|
|
541
|
+
z6.object({
|
|
542
|
+
type: z6.literal("dashboard.view"),
|
|
290
543
|
options: WorkqueueOrDashboardOptions
|
|
291
544
|
})
|
|
292
545
|
]);
|
|
293
|
-
var ScopeType =
|
|
546
|
+
var ScopeType = z6.enum([
|
|
294
547
|
...SystemScopeType.options,
|
|
295
548
|
...RecordScopeTypeV2.options,
|
|
296
549
|
...PlainScopeType.options,
|
|
297
550
|
"workqueue",
|
|
298
551
|
"dashboard.view"
|
|
299
552
|
]);
|
|
300
|
-
var EncodedScope =
|
|
553
|
+
var EncodedScope = z6.string().brand("EncodedScope");
|
|
301
554
|
var DEFAULT_SCOPE_OPTIONS = {
|
|
302
555
|
placeOfEvent: JurisdictionFilter.enum.all,
|
|
303
556
|
accessLevel: JurisdictionFilter.enum.all,
|
|
@@ -307,162 +560,51 @@ var DEFAULT_SCOPE_OPTIONS = {
|
|
|
307
560
|
};
|
|
308
561
|
|
|
309
562
|
// ../commons/src/authentication.ts
|
|
310
|
-
var TokenUserType =
|
|
311
|
-
var TokenWithBearer =
|
|
312
|
-
|
|
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
|
-
];
|
|
563
|
+
var TokenUserType = z7.enum(["user", "system"]);
|
|
564
|
+
var TokenWithBearer = z7.string().regex(/^Bearer\s/);
|
|
423
565
|
|
|
424
566
|
// ../commons/src/events/AuditLog.ts
|
|
425
|
-
var AuditLogEntryBase =
|
|
426
|
-
id:
|
|
427
|
-
clientId:
|
|
567
|
+
var AuditLogEntryBase = z8.object({
|
|
568
|
+
id: z8.string(),
|
|
569
|
+
clientId: z8.string(),
|
|
428
570
|
clientType: TokenUserType,
|
|
429
|
-
createdAt:
|
|
571
|
+
createdAt: z8.string()
|
|
430
572
|
});
|
|
431
573
|
var EventCreateEntrySchema = AuditLogEntryBase.extend({
|
|
432
|
-
operation:
|
|
433
|
-
requestData:
|
|
434
|
-
transactionId:
|
|
435
|
-
type:
|
|
436
|
-
createdAtLocation:
|
|
574
|
+
operation: z8.literal("event.create"),
|
|
575
|
+
requestData: z8.object({
|
|
576
|
+
transactionId: z8.string(),
|
|
577
|
+
type: z8.string(),
|
|
578
|
+
createdAtLocation: z8.string().nullable()
|
|
437
579
|
}),
|
|
438
|
-
responseSummary:
|
|
439
|
-
eventId:
|
|
440
|
-
trackingId:
|
|
580
|
+
responseSummary: z8.object({
|
|
581
|
+
eventId: z8.string(),
|
|
582
|
+
trackingId: z8.string()
|
|
441
583
|
})
|
|
442
584
|
});
|
|
443
585
|
var EventGetEntrySchema = AuditLogEntryBase.extend({
|
|
444
|
-
operation:
|
|
445
|
-
requestData:
|
|
446
|
-
responseSummary:
|
|
447
|
-
eventType:
|
|
448
|
-
trackingId:
|
|
586
|
+
operation: z8.literal("event.get"),
|
|
587
|
+
requestData: z8.object({ eventId: z8.string() }),
|
|
588
|
+
responseSummary: z8.object({
|
|
589
|
+
eventType: z8.string(),
|
|
590
|
+
trackingId: z8.string()
|
|
449
591
|
})
|
|
450
592
|
});
|
|
451
593
|
var EventSearchEntrySchema = AuditLogEntryBase.extend({
|
|
452
|
-
operation:
|
|
453
|
-
clientType:
|
|
454
|
-
requestData:
|
|
455
|
-
query:
|
|
456
|
-
limit:
|
|
457
|
-
offset:
|
|
594
|
+
operation: z8.literal("event.search"),
|
|
595
|
+
clientType: z8.literal("system"),
|
|
596
|
+
requestData: z8.object({
|
|
597
|
+
query: z8.record(z8.string(), z8.unknown()).nullable(),
|
|
598
|
+
limit: z8.number().nullable(),
|
|
599
|
+
offset: z8.number().nullable()
|
|
458
600
|
}),
|
|
459
|
-
responseSummary:
|
|
460
|
-
total:
|
|
461
|
-
eventIds:
|
|
601
|
+
responseSummary: z8.object({
|
|
602
|
+
total: z8.number(),
|
|
603
|
+
eventIds: z8.array(z8.string())
|
|
462
604
|
})
|
|
463
605
|
});
|
|
464
606
|
var EventActionEntrySchema = AuditLogEntryBase.extend({
|
|
465
|
-
operation:
|
|
607
|
+
operation: z8.enum([
|
|
466
608
|
"event.actions.notify.request",
|
|
467
609
|
"event.actions.declare.request",
|
|
468
610
|
"event.actions.register.request",
|
|
@@ -482,106 +624,83 @@ var EventActionEntrySchema = AuditLogEntryBase.extend({
|
|
|
482
624
|
"event.actions.mark_as_duplicate.request",
|
|
483
625
|
"event.actions.mark_as_not_duplicate.request"
|
|
484
626
|
]),
|
|
485
|
-
requestData:
|
|
486
|
-
eventId:
|
|
487
|
-
actionType:
|
|
488
|
-
eventType:
|
|
489
|
-
trackingId:
|
|
490
|
-
transactionId:
|
|
627
|
+
requestData: z8.object({
|
|
628
|
+
eventId: z8.string(),
|
|
629
|
+
actionType: z8.string(),
|
|
630
|
+
eventType: z8.string(),
|
|
631
|
+
trackingId: z8.string(),
|
|
632
|
+
transactionId: z8.string()
|
|
491
633
|
})
|
|
492
634
|
});
|
|
493
635
|
var EventCustomActionEntrySchema = AuditLogEntryBase.extend({
|
|
494
|
-
operation:
|
|
495
|
-
requestData:
|
|
496
|
-
eventId:
|
|
497
|
-
actionType:
|
|
498
|
-
customAction:
|
|
499
|
-
eventType:
|
|
500
|
-
trackingId:
|
|
501
|
-
transactionId:
|
|
636
|
+
operation: z8.literal("event.actions.custom.request"),
|
|
637
|
+
requestData: z8.object({
|
|
638
|
+
eventId: z8.string(),
|
|
639
|
+
actionType: z8.literal(ActionType.CUSTOM),
|
|
640
|
+
customAction: z8.string(),
|
|
641
|
+
eventType: z8.string(),
|
|
642
|
+
trackingId: z8.string(),
|
|
643
|
+
transactionId: z8.string()
|
|
502
644
|
})
|
|
503
645
|
});
|
|
504
646
|
var IntegrationCreateEntrySchema = AuditLogEntryBase.extend({
|
|
505
|
-
operation:
|
|
506
|
-
requestData:
|
|
507
|
-
responseSummary:
|
|
647
|
+
operation: z8.literal("integrations.create"),
|
|
648
|
+
requestData: z8.object({ name: z8.string(), scopes: z8.array(z8.string()) }),
|
|
649
|
+
responseSummary: z8.object({ clientId: z8.string() })
|
|
508
650
|
});
|
|
509
651
|
var IntegrationRefreshTokenEntrySchema = AuditLogEntryBase.extend({
|
|
510
|
-
operation:
|
|
511
|
-
requestData:
|
|
512
|
-
responseSummary:
|
|
652
|
+
operation: z8.literal("integrations.refreshToken"),
|
|
653
|
+
requestData: z8.object({ clientId: z8.string() }),
|
|
654
|
+
responseSummary: z8.object({ clientId: z8.string() })
|
|
513
655
|
});
|
|
514
656
|
var IntegrationDeactivateEntrySchema = AuditLogEntryBase.extend({
|
|
515
|
-
operation:
|
|
516
|
-
requestData:
|
|
517
|
-
responseSummary:
|
|
657
|
+
operation: z8.literal("integrations.deactivate"),
|
|
658
|
+
requestData: z8.object({ id: z8.string() }),
|
|
659
|
+
responseSummary: z8.object({ id: z8.string(), status: z8.string() })
|
|
518
660
|
});
|
|
519
661
|
var IntegrationActivateEntrySchema = AuditLogEntryBase.extend({
|
|
520
|
-
operation:
|
|
521
|
-
requestData:
|
|
522
|
-
responseSummary:
|
|
662
|
+
operation: z8.literal("integrations.activate"),
|
|
663
|
+
requestData: z8.object({ id: z8.string() }),
|
|
664
|
+
responseSummary: z8.object({ id: z8.string(), status: z8.string() })
|
|
523
665
|
});
|
|
524
666
|
var IntegrationDeleteEntrySchema = AuditLogEntryBase.extend({
|
|
525
|
-
operation:
|
|
526
|
-
requestData:
|
|
527
|
-
responseSummary:
|
|
667
|
+
operation: z8.literal("integrations.delete"),
|
|
668
|
+
requestData: z8.object({ id: z8.string() }),
|
|
669
|
+
responseSummary: z8.object({ id: z8.string(), name: z8.string() })
|
|
528
670
|
});
|
|
529
671
|
var IntegrationRefreshSecretEntrySchema = AuditLogEntryBase.extend({
|
|
530
|
-
operation:
|
|
531
|
-
requestData:
|
|
532
|
-
responseSummary:
|
|
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
|
-
})
|
|
672
|
+
operation: z8.literal("integrations.refreshSecret"),
|
|
673
|
+
requestData: z8.object({ id: z8.string() }),
|
|
674
|
+
responseSummary: z8.object({ clientId: z8.string() })
|
|
556
675
|
});
|
|
557
676
|
var AttachmentUploadEntrySchema = AuditLogEntryBase.extend({
|
|
558
|
-
operation:
|
|
559
|
-
requestData:
|
|
560
|
-
transactionId:
|
|
561
|
-
path:
|
|
677
|
+
operation: z8.literal("attachments.upload"),
|
|
678
|
+
requestData: z8.object({
|
|
679
|
+
transactionId: z8.string(),
|
|
680
|
+
path: z8.string().nullable()
|
|
562
681
|
}),
|
|
563
|
-
responseSummary:
|
|
682
|
+
responseSummary: z8.object({ fileUrl: z8.string() })
|
|
564
683
|
});
|
|
565
|
-
var subjectOnly =
|
|
566
|
-
var subjectWithReason =
|
|
567
|
-
subjectId:
|
|
568
|
-
reason:
|
|
569
|
-
comment:
|
|
684
|
+
var subjectOnly = z8.object({ subjectId: z8.string() });
|
|
685
|
+
var subjectWithReason = z8.object({
|
|
686
|
+
subjectId: z8.string(),
|
|
687
|
+
reason: z8.string(),
|
|
688
|
+
comment: z8.string().optional()
|
|
570
689
|
});
|
|
571
690
|
var UserCreateEntrySchema = AuditLogEntryBase.extend({
|
|
572
|
-
operation:
|
|
573
|
-
requestData:
|
|
574
|
-
subjectId:
|
|
575
|
-
role:
|
|
576
|
-
primaryOfficeId:
|
|
691
|
+
operation: z8.literal("user.create_user"),
|
|
692
|
+
requestData: z8.object({
|
|
693
|
+
subjectId: z8.string(),
|
|
694
|
+
role: z8.string(),
|
|
695
|
+
primaryOfficeId: z8.string()
|
|
577
696
|
})
|
|
578
697
|
});
|
|
579
698
|
var UserReasonEntrySchema = AuditLogEntryBase.extend({
|
|
580
|
-
operation:
|
|
699
|
+
operation: z8.enum(["user.deactivate", "user.reactivate"]),
|
|
581
700
|
requestData: subjectWithReason
|
|
582
701
|
});
|
|
583
702
|
var UserSubjectOnlyEntrySchema = AuditLogEntryBase.extend({
|
|
584
|
-
operation:
|
|
703
|
+
operation: z8.enum([
|
|
585
704
|
"user.edit_user",
|
|
586
705
|
"user.logged_in",
|
|
587
706
|
"user.logged_out",
|
|
@@ -595,14 +714,14 @@ var UserSubjectOnlyEntrySchema = AuditLogEntryBase.extend({
|
|
|
595
714
|
requestData: subjectOnly
|
|
596
715
|
});
|
|
597
716
|
var UserEmailChangedEntrySchema = AuditLogEntryBase.extend({
|
|
598
|
-
operation:
|
|
717
|
+
operation: z8.literal("user.email_address_changed"),
|
|
599
718
|
requestData: subjectOnly,
|
|
600
|
-
responseSummary:
|
|
719
|
+
responseSummary: z8.object({ email: z8.string() })
|
|
601
720
|
});
|
|
602
721
|
var UserPhoneChangedEntrySchema = AuditLogEntryBase.extend({
|
|
603
|
-
operation:
|
|
722
|
+
operation: z8.literal("user.phone_number_changed"),
|
|
604
723
|
requestData: subjectOnly,
|
|
605
|
-
responseSummary:
|
|
724
|
+
responseSummary: z8.object({ phoneNumber: z8.string() })
|
|
606
725
|
});
|
|
607
726
|
var userBaseOmit = {
|
|
608
727
|
id: true,
|
|
@@ -610,14 +729,14 @@ var userBaseOmit = {
|
|
|
610
729
|
clientType: true,
|
|
611
730
|
createdAt: true
|
|
612
731
|
};
|
|
613
|
-
var UserAuditRecordInput =
|
|
732
|
+
var UserAuditRecordInput = z8.discriminatedUnion("operation", [
|
|
614
733
|
UserCreateEntrySchema.omit(userBaseOmit),
|
|
615
734
|
UserReasonEntrySchema.omit(userBaseOmit),
|
|
616
735
|
UserSubjectOnlyEntrySchema.omit(userBaseOmit),
|
|
617
736
|
UserEmailChangedEntrySchema.omit(userBaseOmit),
|
|
618
737
|
UserPhoneChangedEntrySchema.omit(userBaseOmit)
|
|
619
738
|
]);
|
|
620
|
-
var AuditLogEntrySchema =
|
|
739
|
+
var AuditLogEntrySchema = z8.discriminatedUnion("operation", [
|
|
621
740
|
EventCreateEntrySchema,
|
|
622
741
|
EventGetEntrySchema,
|
|
623
742
|
EventSearchEntrySchema,
|
|
@@ -629,8 +748,6 @@ var AuditLogEntrySchema = z5.discriminatedUnion("operation", [
|
|
|
629
748
|
IntegrationActivateEntrySchema,
|
|
630
749
|
IntegrationDeleteEntrySchema,
|
|
631
750
|
IntegrationRefreshSecretEntrySchema,
|
|
632
|
-
LocationCreateEntrySchema,
|
|
633
|
-
AdministrativeAreaCreateEntrySchema,
|
|
634
751
|
AttachmentUploadEntrySchema,
|
|
635
752
|
UserCreateEntrySchema,
|
|
636
753
|
UserReasonEntrySchema,
|
|
@@ -646,76 +763,11 @@ var CHILD_ONBOARDING_EVENT = "child-onboarding";
|
|
|
646
763
|
// ../commons/src/events/ActionConfig.ts
|
|
647
764
|
var z24 = __toESM(require("zod/v4"));
|
|
648
765
|
|
|
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
|
-
|
|
664
766
|
// ../commons/src/events/FieldConfig.ts
|
|
665
767
|
var import_v43 = __toESM(require("zod/v4"));
|
|
666
768
|
|
|
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
|
-
|
|
717
769
|
// ../commons/src/events/FieldType.ts
|
|
718
|
-
var
|
|
770
|
+
var z9 = __toESM(require("zod/v4"));
|
|
719
771
|
var FieldType = {
|
|
720
772
|
NAME: "NAME",
|
|
721
773
|
PHONE: "PHONE",
|
|
@@ -779,7 +831,7 @@ var FieldType = {
|
|
|
779
831
|
*/
|
|
780
832
|
_EXPERIMENTAL_CUSTOM: "CUSTOM"
|
|
781
833
|
};
|
|
782
|
-
var FileFieldType =
|
|
834
|
+
var FileFieldType = z9.enum([
|
|
783
835
|
FieldType.FILE,
|
|
784
836
|
FieldType.FILE_WITH_OPTIONS,
|
|
785
837
|
FieldType.SIGNATURE
|
|
@@ -815,160 +867,164 @@ var HiddenFieldTypes = [
|
|
|
815
867
|
];
|
|
816
868
|
|
|
817
869
|
// ../commons/src/events/FieldValue.ts
|
|
818
|
-
var
|
|
870
|
+
var z13 = __toESM(require("zod/v4"));
|
|
819
871
|
|
|
820
872
|
// ../commons/src/documents.ts
|
|
821
|
-
var
|
|
822
|
-
var FullDocumentUrl =
|
|
873
|
+
var z10 = __toESM(require("zod/v4"));
|
|
874
|
+
var FullDocumentUrl = z10.string().brand("FullDocumentUrl").describe(
|
|
823
875
|
"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"
|
|
824
876
|
);
|
|
825
|
-
var FullDocumentPath =
|
|
877
|
+
var FullDocumentPath = z10.string().overwrite((val) => val.startsWith("/") ? val : `/${val}`).meta({ effectType: "input", type: "string" }).describe(
|
|
826
878
|
"A full absolute path with bucket name, starting from the root of the S3 server, /bucket-name/document-id.jpg"
|
|
827
879
|
);
|
|
828
|
-
var DocumentPath =
|
|
880
|
+
var DocumentPath = z10.string().brand("DocumentPath").describe(
|
|
829
881
|
"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."
|
|
830
882
|
);
|
|
831
883
|
|
|
832
884
|
// ../commons/src/events/CompositeFieldValue.ts
|
|
833
|
-
var
|
|
885
|
+
var z11 = __toESM(require("zod/v4"));
|
|
834
886
|
var AddressType = {
|
|
835
887
|
DOMESTIC: "DOMESTIC",
|
|
836
888
|
INTERNATIONAL: "INTERNATIONAL"
|
|
837
889
|
};
|
|
838
|
-
var FileFieldValue =
|
|
890
|
+
var FileFieldValue = z11.object({
|
|
839
891
|
path: DocumentPath,
|
|
840
|
-
originalFilename:
|
|
841
|
-
type:
|
|
842
|
-
});
|
|
843
|
-
var NameFieldValue =
|
|
844
|
-
firstname:
|
|
845
|
-
surname:
|
|
846
|
-
middlename:
|
|
847
|
-
});
|
|
848
|
-
var NameFieldUpdateValue =
|
|
849
|
-
firstname:
|
|
850
|
-
surname:
|
|
851
|
-
middlename:
|
|
852
|
-
}).or(
|
|
853
|
-
var StreetLevelDetailsValue =
|
|
854
|
-
var StreetLevelDetailsUpdateValue =
|
|
855
|
-
var BaseAddressFieldValue =
|
|
856
|
-
country:
|
|
892
|
+
originalFilename: z11.string(),
|
|
893
|
+
type: z11.string()
|
|
894
|
+
});
|
|
895
|
+
var NameFieldValue = z11.object({
|
|
896
|
+
firstname: z11.string(),
|
|
897
|
+
surname: z11.string(),
|
|
898
|
+
middlename: z11.string().optional()
|
|
899
|
+
});
|
|
900
|
+
var NameFieldUpdateValue = z11.object({
|
|
901
|
+
firstname: z11.string().nullish(),
|
|
902
|
+
surname: z11.string().nullish(),
|
|
903
|
+
middlename: z11.string().nullish()
|
|
904
|
+
}).or(z11.null()).or(z11.undefined());
|
|
905
|
+
var StreetLevelDetailsValue = z11.record(z11.string(), z11.string()).optional();
|
|
906
|
+
var StreetLevelDetailsUpdateValue = z11.record(z11.string(), z11.string().nullable()).nullish();
|
|
907
|
+
var BaseAddressFieldValue = z11.object({
|
|
908
|
+
country: z11.string(),
|
|
857
909
|
streetLevelDetails: StreetLevelDetailsValue
|
|
858
910
|
});
|
|
859
|
-
var BaseAddressFieldUpdateValue =
|
|
860
|
-
country:
|
|
911
|
+
var BaseAddressFieldUpdateValue = z11.object({
|
|
912
|
+
country: z11.string().nullish(),
|
|
861
913
|
streetLevelDetails: StreetLevelDetailsUpdateValue
|
|
862
914
|
});
|
|
863
915
|
var DomesticAddressFieldValue = BaseAddressFieldValue.extend({
|
|
864
|
-
addressType:
|
|
865
|
-
administrativeArea:
|
|
916
|
+
addressType: z11.literal(AddressType.DOMESTIC),
|
|
917
|
+
administrativeArea: z11.string().uuid()
|
|
866
918
|
});
|
|
867
919
|
var InternationalAddressFieldValue = BaseAddressFieldValue.extend({
|
|
868
|
-
addressType:
|
|
920
|
+
addressType: z11.literal(AddressType.INTERNATIONAL)
|
|
869
921
|
});
|
|
870
|
-
var AddressFieldValue =
|
|
922
|
+
var AddressFieldValue = z11.discriminatedUnion("addressType", [
|
|
871
923
|
DomesticAddressFieldValue,
|
|
872
924
|
InternationalAddressFieldValue
|
|
873
925
|
]);
|
|
874
926
|
var DomesticAddressUpdateFieldValue = BaseAddressFieldUpdateValue.extend({
|
|
875
|
-
addressType:
|
|
876
|
-
administrativeArea:
|
|
927
|
+
addressType: z11.literal(AddressType.DOMESTIC),
|
|
928
|
+
administrativeArea: z11.string().uuid().nullish()
|
|
877
929
|
/* Leaf level admin structure */
|
|
878
930
|
});
|
|
879
931
|
var InternationalAddressUpdateFieldValue = BaseAddressFieldUpdateValue.extend(
|
|
880
932
|
{
|
|
881
|
-
addressType:
|
|
933
|
+
addressType: z11.literal(AddressType.INTERNATIONAL)
|
|
882
934
|
}
|
|
883
935
|
);
|
|
884
|
-
var AddressFieldUpdateValue =
|
|
936
|
+
var AddressFieldUpdateValue = z11.discriminatedUnion("addressType", [
|
|
885
937
|
DomesticAddressUpdateFieldValue,
|
|
886
938
|
InternationalAddressUpdateFieldValue
|
|
887
939
|
]).nullish();
|
|
888
|
-
var FileFieldValueWithOption =
|
|
940
|
+
var FileFieldValueWithOption = z11.object({
|
|
889
941
|
path: DocumentPath,
|
|
890
|
-
originalFilename:
|
|
891
|
-
type:
|
|
892
|
-
option:
|
|
893
|
-
});
|
|
894
|
-
var FileFieldWithOptionValue =
|
|
895
|
-
var HttpFieldValue =
|
|
896
|
-
loading:
|
|
897
|
-
error:
|
|
898
|
-
data:
|
|
899
|
-
});
|
|
900
|
-
var HttpFieldUpdateValue =
|
|
901
|
-
loading:
|
|
902
|
-
error:
|
|
903
|
-
data:
|
|
904
|
-
}).or(
|
|
905
|
-
var QueryParamReaderFieldValue =
|
|
906
|
-
data:
|
|
907
|
-
updatedAt:
|
|
942
|
+
originalFilename: z11.string(),
|
|
943
|
+
type: z11.string(),
|
|
944
|
+
option: z11.string()
|
|
945
|
+
});
|
|
946
|
+
var FileFieldWithOptionValue = z11.array(FileFieldValueWithOption);
|
|
947
|
+
var HttpFieldValue = z11.object({
|
|
948
|
+
loading: z11.boolean(),
|
|
949
|
+
error: z11.object({ statusCode: z11.number(), message: z11.string() }).nullish(),
|
|
950
|
+
data: z11.any()
|
|
951
|
+
});
|
|
952
|
+
var HttpFieldUpdateValue = z11.object({
|
|
953
|
+
loading: z11.boolean().nullish(),
|
|
954
|
+
error: z11.object({ statusCode: z11.number(), message: z11.string() }).nullish(),
|
|
955
|
+
data: z11.any().nullish()
|
|
956
|
+
}).or(z11.null()).or(z11.undefined());
|
|
957
|
+
var QueryParamReaderFieldValue = z11.object({
|
|
958
|
+
data: z11.record(z11.string(), z11.string()),
|
|
959
|
+
updatedAt: z11.iso.datetime()
|
|
908
960
|
}).nullish();
|
|
909
|
-
var QueryParamReaderFieldUpdateValue =
|
|
910
|
-
data:
|
|
961
|
+
var QueryParamReaderFieldUpdateValue = z11.object({
|
|
962
|
+
data: z11.record(z11.string(), z11.string())
|
|
911
963
|
});
|
|
912
|
-
var ReadDataValue =
|
|
913
|
-
data:
|
|
964
|
+
var ReadDataValue = z11.object({
|
|
965
|
+
data: z11.any()
|
|
914
966
|
});
|
|
915
967
|
var QrReaderFieldValue = ReadDataValue;
|
|
916
968
|
var IdReaderFieldValue = ReadDataValue;
|
|
917
|
-
var NumberWithUnitFieldValue =
|
|
918
|
-
numericValue:
|
|
919
|
-
unit:
|
|
969
|
+
var NumberWithUnitFieldValue = z11.object({
|
|
970
|
+
numericValue: z11.number(),
|
|
971
|
+
unit: z11.string()
|
|
920
972
|
});
|
|
921
|
-
var NumberWithUnitFieldUpdateValue =
|
|
922
|
-
numericValue:
|
|
923
|
-
unit:
|
|
973
|
+
var NumberWithUnitFieldUpdateValue = z11.object({
|
|
974
|
+
numericValue: z11.number().optional(),
|
|
975
|
+
unit: z11.string().optional()
|
|
924
976
|
});
|
|
925
|
-
var CustomFieldValue =
|
|
977
|
+
var CustomFieldValue = z11.unknown().brand("CustomFieldValue");
|
|
926
978
|
|
|
927
979
|
// ../commons/src/events/PlainDate.ts
|
|
928
980
|
var import_zod = require("zod");
|
|
929
981
|
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
|
+
}
|
|
930
986
|
|
|
931
987
|
// ../commons/src/events/FieldValue.ts
|
|
932
|
-
var TextValue =
|
|
933
|
-
var HiddenFieldValue =
|
|
934
|
-
var NonEmptyTextValue =
|
|
935
|
-
var DateValue =
|
|
936
|
-
var AgeValue =
|
|
937
|
-
age:
|
|
938
|
-
asOfDateRef:
|
|
988
|
+
var TextValue = z13.string();
|
|
989
|
+
var HiddenFieldValue = z13.string();
|
|
990
|
+
var NonEmptyTextValue = z13.string().trim().min(1);
|
|
991
|
+
var DateValue = z13.iso.date().describe("Date in the format YYYY-MM-DD");
|
|
992
|
+
var AgeValue = z13.object({
|
|
993
|
+
age: z13.number(),
|
|
994
|
+
asOfDateRef: z13.string()
|
|
939
995
|
});
|
|
940
996
|
var AgeUpdateValue = AgeValue.optional().nullable();
|
|
941
|
-
var AutocompleteValue =
|
|
942
|
-
label:
|
|
943
|
-
value:
|
|
997
|
+
var AutocompleteValue = z13.object({
|
|
998
|
+
label: z13.string(),
|
|
999
|
+
value: z13.string()
|
|
944
1000
|
});
|
|
945
1001
|
var AutocompleteUpdateValue = AutocompleteValue.optional().nullable();
|
|
946
|
-
var TimeValue =
|
|
947
|
-
var DatetimeValue =
|
|
948
|
-
var SelectDateRangeValue =
|
|
1002
|
+
var TimeValue = z13.string().regex(/^([01][0-9]|2[0-3]):[0-5][0-9]$/);
|
|
1003
|
+
var DatetimeValue = z13.iso.datetime();
|
|
1004
|
+
var SelectDateRangeValue = z13.enum([
|
|
949
1005
|
"last7Days",
|
|
950
1006
|
"last30Days",
|
|
951
1007
|
"last90Days",
|
|
952
1008
|
"last365Days"
|
|
953
1009
|
]);
|
|
954
|
-
var DateRangeFieldValue =
|
|
1010
|
+
var DateRangeFieldValue = z13.object({
|
|
955
1011
|
start: PlainDate,
|
|
956
1012
|
end: PlainDate
|
|
957
1013
|
}).or(PlainDate).describe(
|
|
958
1014
|
"Date range with start and end dates in the format YYYY-MM-DD. Inclusive start, exclusive end."
|
|
959
1015
|
);
|
|
960
|
-
var EmailValue =
|
|
961
|
-
var CheckboxFieldValue =
|
|
962
|
-
var NumberFieldValue =
|
|
1016
|
+
var EmailValue = z13.email();
|
|
1017
|
+
var CheckboxFieldValue = z13.boolean();
|
|
1018
|
+
var NumberFieldValue = z13.number();
|
|
963
1019
|
var SignatureFieldValue = FileFieldValue;
|
|
964
|
-
var ButtonFieldValue =
|
|
965
|
-
var VerificationStatusValue =
|
|
1020
|
+
var ButtonFieldValue = z13.number();
|
|
1021
|
+
var VerificationStatusValue = z13.enum([
|
|
966
1022
|
"verified",
|
|
967
1023
|
"authenticated",
|
|
968
1024
|
"failed",
|
|
969
1025
|
"pending"
|
|
970
1026
|
]);
|
|
971
|
-
var LeafFieldValues =
|
|
1027
|
+
var LeafFieldValues = z13.union([
|
|
972
1028
|
AddressFieldValue,
|
|
973
1029
|
TextValue,
|
|
974
1030
|
PlainDate,
|
|
@@ -994,11 +1050,11 @@ var LeafFieldValues = z12.union([
|
|
|
994
1050
|
AutocompleteValue,
|
|
995
1051
|
AutocompleteUpdateValue
|
|
996
1052
|
]);
|
|
997
|
-
var FieldGroupValue =
|
|
998
|
-
var DataFieldValue =
|
|
999
|
-
data:
|
|
1053
|
+
var FieldGroupValue = z13.record(z13.string(), LeafFieldValues);
|
|
1054
|
+
var DataFieldValue = z13.object({
|
|
1055
|
+
data: z13.record(z13.string(), LeafFieldValues)
|
|
1000
1056
|
}).nullish();
|
|
1001
|
-
var FieldValue =
|
|
1057
|
+
var FieldValue = z13.union([
|
|
1002
1058
|
LeafFieldValues,
|
|
1003
1059
|
DataFieldValue,
|
|
1004
1060
|
FieldGroupValue
|
|
@@ -1032,7 +1088,7 @@ function safeUnion(schemas) {
|
|
|
1032
1088
|
const sortedSchemas = [...schemas].sort(
|
|
1033
1089
|
(a, b) => schemaPriority(a) - schemaPriority(b)
|
|
1034
1090
|
);
|
|
1035
|
-
return
|
|
1091
|
+
return z13.any().superRefine((val, ctx) => {
|
|
1036
1092
|
for (const schema of sortedSchemas) {
|
|
1037
1093
|
if (schema.safeParse(val).success) {
|
|
1038
1094
|
return;
|
|
@@ -1071,9 +1127,9 @@ var FieldUpdateValue = safeUnion([
|
|
|
1071
1127
|
]);
|
|
1072
1128
|
|
|
1073
1129
|
// ../commons/src/events/serializers/user/serializer.ts
|
|
1074
|
-
var
|
|
1075
|
-
var SerializedUserField =
|
|
1076
|
-
$userField:
|
|
1130
|
+
var z14 = __toESM(require("zod/v4"));
|
|
1131
|
+
var SerializedUserField = z14.object({
|
|
1132
|
+
$userField: z14.enum([
|
|
1077
1133
|
"id",
|
|
1078
1134
|
"name",
|
|
1079
1135
|
"role",
|
|
@@ -1087,7 +1143,7 @@ var SerializedUserField = z13.object({
|
|
|
1087
1143
|
"primaryOfficeId",
|
|
1088
1144
|
"administrativeAreaId"
|
|
1089
1145
|
]),
|
|
1090
|
-
$location:
|
|
1146
|
+
$location: z14.string().optional()
|
|
1091
1147
|
});
|
|
1092
1148
|
function userSerializer(userField) {
|
|
1093
1149
|
return {
|
|
@@ -1113,27 +1169,22 @@ var import_v4 = require("zod/v4");
|
|
|
1113
1169
|
var z16 = __toESM(require("zod/v4"));
|
|
1114
1170
|
|
|
1115
1171
|
// ../commons/src/events/ActionDocument.ts
|
|
1116
|
-
var
|
|
1117
|
-
var ActionUpdate =
|
|
1172
|
+
var z15 = __toESM(require("zod/v4"));
|
|
1173
|
+
var ActionUpdate = z15.record(z15.string(), FieldUpdateValue).describe(
|
|
1118
1174
|
"Record of field-level changes made by an action. Supports partial updates and nullable values."
|
|
1119
1175
|
);
|
|
1120
|
-
var EventState =
|
|
1176
|
+
var EventState = z15.record(z15.string(), FieldValue).describe(
|
|
1121
1177
|
"Aggregate representation of event data after all actions have been applied, with all updates consolidated and null values removed."
|
|
1122
1178
|
);
|
|
1123
|
-
var
|
|
1124
|
-
Requested: "Requested",
|
|
1125
|
-
Accepted: "Accepted",
|
|
1126
|
-
Rejected: "Rejected"
|
|
1127
|
-
};
|
|
1128
|
-
var ActionBase = z14.object({
|
|
1179
|
+
var ActionBase = z15.object({
|
|
1129
1180
|
id: UUID.describe("Unique identifier of the action."),
|
|
1130
|
-
transactionId:
|
|
1181
|
+
transactionId: z15.string().describe("Unique identifier of the transaction."),
|
|
1131
1182
|
createdByUserType: TokenUserType.describe(
|
|
1132
1183
|
"Indicates whether the action was created by a human-user or by a system-user."
|
|
1133
1184
|
),
|
|
1134
|
-
createdAt:
|
|
1135
|
-
createdBy:
|
|
1136
|
-
createdByRole:
|
|
1185
|
+
createdAt: z15.string().datetime().describe("Timestamp indicating when the action was created."),
|
|
1186
|
+
createdBy: z15.string().describe("Identifier of the user who created the action."),
|
|
1187
|
+
createdByRole: z15.string().optional().describe("Role of the user who created the action."),
|
|
1137
1188
|
createdBySignature: DocumentPath.nullish().describe(
|
|
1138
1189
|
"Reference to the signature of the user who created the action."
|
|
1139
1190
|
),
|
|
@@ -1145,7 +1196,7 @@ var ActionBase = z14.object({
|
|
|
1145
1196
|
"Declaration data defined by the ActionConfig. Supports partial updates."
|
|
1146
1197
|
),
|
|
1147
1198
|
annotation: ActionUpdate.optional().nullable().describe("Action-specific metadata used to annotate the event."),
|
|
1148
|
-
status:
|
|
1199
|
+
status: z15.enum([
|
|
1149
1200
|
ActionStatus.Requested,
|
|
1150
1201
|
ActionStatus.Accepted,
|
|
1151
1202
|
ActionStatus.Rejected
|
|
@@ -1157,139 +1208,139 @@ var ActionBase = z14.object({
|
|
|
1157
1208
|
)
|
|
1158
1209
|
});
|
|
1159
1210
|
var AssignedAction = ActionBase.extend(
|
|
1160
|
-
|
|
1161
|
-
type:
|
|
1162
|
-
assignedTo:
|
|
1211
|
+
z15.object({
|
|
1212
|
+
type: z15.literal(ActionType.ASSIGN),
|
|
1213
|
+
assignedTo: z15.string().describe("Identifier of the user to whom the action is assigned.")
|
|
1163
1214
|
// TODO move into 'content' property
|
|
1164
1215
|
}).shape
|
|
1165
1216
|
);
|
|
1166
1217
|
var UnassignedAction = ActionBase.extend(
|
|
1167
|
-
|
|
1168
|
-
type:
|
|
1218
|
+
z15.object({
|
|
1219
|
+
type: z15.literal(ActionType.UNASSIGN)
|
|
1169
1220
|
}).shape
|
|
1170
1221
|
);
|
|
1171
1222
|
var RegisterAction = ActionBase.extend(
|
|
1172
|
-
|
|
1173
|
-
type:
|
|
1174
|
-
registrationNumber:
|
|
1223
|
+
z15.object({
|
|
1224
|
+
type: z15.literal(ActionType.REGISTER),
|
|
1225
|
+
registrationNumber: z15.string().optional().describe(
|
|
1175
1226
|
"Registration number of the event. Always present for accepted registrations."
|
|
1176
1227
|
)
|
|
1177
1228
|
// TODO move into 'content' property
|
|
1178
1229
|
}).shape
|
|
1179
1230
|
);
|
|
1180
1231
|
var DeclareAction = ActionBase.extend(
|
|
1181
|
-
|
|
1182
|
-
type:
|
|
1232
|
+
z15.object({
|
|
1233
|
+
type: z15.literal(ActionType.DECLARE)
|
|
1183
1234
|
}).shape
|
|
1184
1235
|
);
|
|
1185
|
-
var ReasonContent =
|
|
1186
|
-
reason:
|
|
1236
|
+
var ReasonContent = z15.object({
|
|
1237
|
+
reason: z15.string().min(1, { error: "Message cannot be empty" }).describe(
|
|
1187
1238
|
"Message describing the reason for rejecting or archiving the event."
|
|
1188
1239
|
)
|
|
1189
1240
|
});
|
|
1190
1241
|
var RejectAction = ActionBase.extend(
|
|
1191
|
-
|
|
1192
|
-
type:
|
|
1242
|
+
z15.object({
|
|
1243
|
+
type: z15.literal(ActionType.REJECT),
|
|
1193
1244
|
content: ReasonContent
|
|
1194
1245
|
}).shape
|
|
1195
1246
|
);
|
|
1196
|
-
var PotentialDuplicate =
|
|
1247
|
+
var PotentialDuplicate = z15.object({
|
|
1197
1248
|
id: UUID,
|
|
1198
|
-
trackingId:
|
|
1249
|
+
trackingId: z15.string()
|
|
1199
1250
|
});
|
|
1200
1251
|
var DuplicateDetectedAction = ActionBase.extend(
|
|
1201
|
-
|
|
1202
|
-
type:
|
|
1203
|
-
content:
|
|
1204
|
-
duplicates:
|
|
1252
|
+
z15.object({
|
|
1253
|
+
type: z15.literal(ActionType.DUPLICATE_DETECTED),
|
|
1254
|
+
content: z15.object({
|
|
1255
|
+
duplicates: z15.array(PotentialDuplicate)
|
|
1205
1256
|
})
|
|
1206
1257
|
}).shape
|
|
1207
1258
|
);
|
|
1208
1259
|
var MarkNotDuplicateAction = ActionBase.extend(
|
|
1209
|
-
|
|
1210
|
-
type:
|
|
1260
|
+
z15.object({
|
|
1261
|
+
type: z15.literal(ActionType.MARK_AS_NOT_DUPLICATE)
|
|
1211
1262
|
}).shape
|
|
1212
1263
|
);
|
|
1213
1264
|
var MarkAsDuplicateAction = ActionBase.extend(
|
|
1214
|
-
|
|
1215
|
-
type:
|
|
1216
|
-
content:
|
|
1265
|
+
z15.object({
|
|
1266
|
+
type: z15.literal(ActionType.MARK_AS_DUPLICATE),
|
|
1267
|
+
content: z15.object({
|
|
1217
1268
|
duplicateOf: UUID
|
|
1218
1269
|
}).optional()
|
|
1219
1270
|
}).shape
|
|
1220
1271
|
);
|
|
1221
1272
|
var ArchiveAction = ActionBase.extend(
|
|
1222
|
-
|
|
1223
|
-
type:
|
|
1273
|
+
z15.object({
|
|
1274
|
+
type: z15.literal(ActionType.ARCHIVE),
|
|
1224
1275
|
content: ReasonContent
|
|
1225
1276
|
}).shape
|
|
1226
1277
|
);
|
|
1227
1278
|
var UnarchiveAction = ActionBase.extend(
|
|
1228
|
-
|
|
1229
|
-
type:
|
|
1279
|
+
z15.object({
|
|
1280
|
+
type: z15.literal(ActionType.UNARCHIVE)
|
|
1230
1281
|
}).shape
|
|
1231
1282
|
);
|
|
1232
1283
|
var CreatedAction = ActionBase.extend(
|
|
1233
|
-
|
|
1234
|
-
type:
|
|
1284
|
+
z15.object({
|
|
1285
|
+
type: z15.literal(ActionType.CREATE)
|
|
1235
1286
|
}).shape
|
|
1236
1287
|
);
|
|
1237
1288
|
var NotifiedAction = ActionBase.extend(
|
|
1238
|
-
|
|
1239
|
-
type:
|
|
1289
|
+
z15.object({
|
|
1290
|
+
type: z15.literal(ActionType.NOTIFY)
|
|
1240
1291
|
}).shape
|
|
1241
1292
|
);
|
|
1242
1293
|
var EditAction = ActionBase.extend(
|
|
1243
|
-
|
|
1244
|
-
type:
|
|
1294
|
+
z15.object({
|
|
1295
|
+
type: z15.literal(ActionType.EDIT),
|
|
1245
1296
|
/** @deprecated New Edit-actions should no longer contain content. This is kept for old 2.0 edits. */
|
|
1246
|
-
content:
|
|
1247
|
-
comment:
|
|
1297
|
+
content: z15.object({
|
|
1298
|
+
comment: z15.string().describe("Comment for the edit action.").optional()
|
|
1248
1299
|
}).optional()
|
|
1249
1300
|
}).shape
|
|
1250
1301
|
);
|
|
1251
|
-
var PrintContent =
|
|
1252
|
-
templateId:
|
|
1302
|
+
var PrintContent = z15.object({
|
|
1303
|
+
templateId: z15.string().optional()
|
|
1253
1304
|
});
|
|
1254
1305
|
var PrintCertificateAction = ActionBase.extend(
|
|
1255
|
-
|
|
1256
|
-
type:
|
|
1306
|
+
z15.object({
|
|
1307
|
+
type: z15.literal(ActionType.PRINT_CERTIFICATE),
|
|
1257
1308
|
content: PrintContent.optional().nullable()
|
|
1258
1309
|
}).shape
|
|
1259
1310
|
);
|
|
1260
1311
|
var RequestedCorrectionAction = ActionBase.extend(
|
|
1261
|
-
|
|
1262
|
-
type:
|
|
1312
|
+
z15.object({
|
|
1313
|
+
type: z15.literal(ActionType.REQUEST_CORRECTION)
|
|
1263
1314
|
}).shape
|
|
1264
1315
|
);
|
|
1265
1316
|
var ApprovedCorrectionAction = ActionBase.extend(
|
|
1266
|
-
|
|
1267
|
-
type:
|
|
1268
|
-
requestId:
|
|
1317
|
+
z15.object({
|
|
1318
|
+
type: z15.literal(ActionType.APPROVE_CORRECTION),
|
|
1319
|
+
requestId: z15.string(),
|
|
1269
1320
|
// TODO move into 'content' property
|
|
1270
|
-
content:
|
|
1321
|
+
content: z15.object({ immediateCorrection: z15.boolean().optional() }).optional()
|
|
1271
1322
|
}).shape
|
|
1272
1323
|
);
|
|
1273
1324
|
var RejectedCorrectionAction = ActionBase.extend(
|
|
1274
|
-
|
|
1275
|
-
type:
|
|
1276
|
-
requestId:
|
|
1325
|
+
z15.object({
|
|
1326
|
+
type: z15.literal(ActionType.REJECT_CORRECTION),
|
|
1327
|
+
requestId: z15.string(),
|
|
1277
1328
|
// TODO move into 'content' property
|
|
1278
1329
|
content: ReasonContent
|
|
1279
1330
|
}).shape
|
|
1280
1331
|
);
|
|
1281
1332
|
var ReadAction = ActionBase.extend(
|
|
1282
|
-
|
|
1283
|
-
type:
|
|
1333
|
+
z15.object({
|
|
1334
|
+
type: z15.literal(ActionType.READ)
|
|
1284
1335
|
}).shape
|
|
1285
1336
|
);
|
|
1286
1337
|
var CustomAction = ActionBase.merge(
|
|
1287
|
-
|
|
1288
|
-
type:
|
|
1289
|
-
customActionType:
|
|
1338
|
+
z15.object({
|
|
1339
|
+
type: z15.literal(ActionType.CUSTOM),
|
|
1340
|
+
customActionType: z15.string()
|
|
1290
1341
|
})
|
|
1291
1342
|
);
|
|
1292
|
-
var ActionDocument =
|
|
1343
|
+
var ActionDocument = z15.discriminatedUnion("type", [
|
|
1293
1344
|
CreatedAction.meta({ id: "CreatedAction" }),
|
|
1294
1345
|
RejectAction.meta({ id: "RejectAction" }),
|
|
1295
1346
|
DuplicateDetectedAction.meta({ id: "DuplicateDetectedAction" }),
|
|
@@ -1316,64 +1367,12 @@ var AsyncRejectActionDocument = ActionBase.omit({
|
|
|
1316
1367
|
declaration: true,
|
|
1317
1368
|
annotation: true
|
|
1318
1369
|
}).extend(
|
|
1319
|
-
|
|
1320
|
-
type:
|
|
1321
|
-
status:
|
|
1370
|
+
z15.object({
|
|
1371
|
+
type: z15.enum(ConfirmableActions),
|
|
1372
|
+
status: z15.literal(ActionStatus.Rejected)
|
|
1322
1373
|
}).shape
|
|
1323
1374
|
);
|
|
1324
|
-
var Action =
|
|
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
|
-
});
|
|
1375
|
+
var Action = z15.union([ActionDocument, AsyncRejectActionDocument]);
|
|
1377
1376
|
|
|
1378
1377
|
// ../commons/src/events/EventMetadata.ts
|
|
1379
1378
|
var EventStatus = z16.enum([
|
|
@@ -1531,13 +1530,6 @@ var Range = import_v4.z.object({
|
|
|
1531
1530
|
}).meta({
|
|
1532
1531
|
id: "Range"
|
|
1533
1532
|
});
|
|
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
|
-
});
|
|
1541
1533
|
var Within = import_v4.z.object({ type: import_v4.z.literal("within"), location: import_v4.z.string() }).meta({
|
|
1542
1534
|
id: "Within"
|
|
1543
1535
|
});
|
|
@@ -3171,13 +3163,13 @@ var AdvancedSearchConfig = z28.object({
|
|
|
3171
3163
|
});
|
|
3172
3164
|
|
|
3173
3165
|
// ../commons/src/events/utils.ts
|
|
3174
|
-
var
|
|
3166
|
+
var import_lodash4 = require("lodash");
|
|
3175
3167
|
|
|
3176
3168
|
// ../commons/src/conditionals/validate.ts
|
|
3177
3169
|
var import__ = __toESM(require("ajv/dist/2019"));
|
|
3178
3170
|
var import_ajv_formats = __toESM(require("ajv-formats"));
|
|
3179
|
-
var
|
|
3180
|
-
var
|
|
3171
|
+
var z32 = __toESM(require("zod/v4"));
|
|
3172
|
+
var import_date_fns2 = require("date-fns");
|
|
3181
3173
|
|
|
3182
3174
|
// ../commons/src/events/FieldTypeMapping.ts
|
|
3183
3175
|
var z30 = __toESM(require("zod/v4"));
|
|
@@ -3185,152 +3177,26 @@ var z30 = __toESM(require("zod/v4"));
|
|
|
3185
3177
|
// ../commons/src/events/DynamicFieldValue.ts
|
|
3186
3178
|
var z29 = __toESM(require("zod/v4"));
|
|
3187
3179
|
|
|
3188
|
-
// ../commons/src/
|
|
3189
|
-
var
|
|
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 }))
|
|
3198
|
-
})
|
|
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];
|
|
3212
|
-
}
|
|
3213
|
-
for (const part of referencePath) {
|
|
3214
|
-
if (current === null || current === void 0) {
|
|
3215
|
-
return void 0;
|
|
3216
|
-
}
|
|
3217
|
-
current = current[part];
|
|
3218
|
-
}
|
|
3219
|
-
return current;
|
|
3220
|
-
}
|
|
3221
|
-
function todayISO() {
|
|
3222
|
-
return (0, import_date_fns.formatISO)(/* @__PURE__ */ new Date(), { representation: "date" });
|
|
3223
|
-
}
|
|
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);
|
|
3230
|
-
}
|
|
3231
|
-
return fn;
|
|
3232
|
-
}
|
|
3233
|
-
(0, import_ajv_formats.default)(ajv);
|
|
3234
|
-
function buildClientFunctionContext(input) {
|
|
3235
|
-
return {
|
|
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
|
|
3247
|
-
};
|
|
3248
|
-
}
|
|
3249
|
-
function runClientFunction(code, data, context) {
|
|
3250
|
-
return compileClientFunction(code)(data, context);
|
|
3251
|
-
}
|
|
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");
|
|
3261
|
-
}
|
|
3262
|
-
const { days, clause } = schema;
|
|
3263
|
-
if (typeof data !== "string") {
|
|
3264
|
-
return false;
|
|
3265
|
-
}
|
|
3266
|
-
const date = new Date(data);
|
|
3267
|
-
if (isNaN(date.getTime())) {
|
|
3268
|
-
return false;
|
|
3269
|
-
}
|
|
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
|
-
);
|
|
3277
|
-
}
|
|
3278
|
-
if (!referenceDate) {
|
|
3279
|
-
referenceDate = dataContext.rootData.$now;
|
|
3280
|
-
}
|
|
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: {} })
|
|
3315
|
-
)
|
|
3316
|
-
);
|
|
3317
|
-
}
|
|
3318
|
-
});
|
|
3319
|
-
function isOnline() {
|
|
3320
|
-
if (typeof window !== "undefined" && typeof navigator !== "undefined") {
|
|
3321
|
-
return navigator.onLine;
|
|
3322
|
-
}
|
|
3323
|
-
return true;
|
|
3324
|
-
}
|
|
3180
|
+
// ../commons/src/events/state/index.ts
|
|
3181
|
+
var import_lodash3 = require("lodash");
|
|
3325
3182
|
|
|
3326
3183
|
// ../commons/src/utils.ts
|
|
3327
|
-
var
|
|
3184
|
+
var z31 = __toESM(require("zod/v4"));
|
|
3328
3185
|
var _ = __toESM(require("lodash"));
|
|
3329
|
-
|
|
3330
|
-
|
|
3331
|
-
|
|
3332
|
-
|
|
3333
|
-
|
|
3186
|
+
function getOrThrow(x, message) {
|
|
3187
|
+
if (x === void 0 || x === null) {
|
|
3188
|
+
throw new Error(message);
|
|
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())
|
|
3334
3200
|
})
|
|
3335
3201
|
);
|
|
3336
3202
|
function omitKeyDeep(obj, keyToRemove) {
|
|
@@ -3349,36 +3215,262 @@ function omitKeyDeep(obj, keyToRemove) {
|
|
|
3349
3215
|
return newObj;
|
|
3350
3216
|
}
|
|
3351
3217
|
|
|
3352
|
-
// ../commons/src/events/utils.ts
|
|
3353
|
-
var
|
|
3354
|
-
function
|
|
3355
|
-
|
|
3218
|
+
// ../commons/src/events/state/utils.ts
|
|
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
|
+
};
|
|
3356
3236
|
}
|
|
3357
|
-
|
|
3358
|
-
|
|
3359
|
-
|
|
3360
|
-
|
|
3361
|
-
|
|
3362
|
-
|
|
3237
|
+
function getDeclarationActionCreationMetadata(actionType, actions) {
|
|
3238
|
+
const { accept: acceptAction, request: requestAction } = getActionRequests(
|
|
3239
|
+
actionType,
|
|
3240
|
+
actions
|
|
3241
|
+
);
|
|
3242
|
+
if (!acceptAction) {
|
|
3243
|
+
return null;
|
|
3363
3244
|
}
|
|
3364
|
-
const
|
|
3365
|
-
|
|
3366
|
-
|
|
3367
|
-
|
|
3368
|
-
|
|
3369
|
-
|
|
3245
|
+
const registrationNumber = acceptAction.type === ActionType.REGISTER ? acceptAction.registrationNumber : null;
|
|
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
|
+
};
|
|
3370
3256
|
}
|
|
3371
|
-
var
|
|
3372
|
-
|
|
3373
|
-
|
|
3374
|
-
|
|
3375
|
-
|
|
3376
|
-
|
|
3377
|
-
|
|
3378
|
-
ActionType.
|
|
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,
|
|
3379
3266
|
ActionType.PRINT_CERTIFICATE,
|
|
3380
|
-
ActionType.
|
|
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
|
+
);
|
|
3294
|
+
}
|
|
3295
|
+
function getLegalStatuses(actions) {
|
|
3296
|
+
return {
|
|
3297
|
+
[EventStatus.enum.NOTIFIED]: getDeclarationActionCreationMetadata(
|
|
3298
|
+
ActionType.NOTIFY,
|
|
3299
|
+
actions
|
|
3300
|
+
),
|
|
3301
|
+
[EventStatus.enum.DECLARED]: getDeclarationActionCreationMetadata(
|
|
3302
|
+
ActionType.DECLARE,
|
|
3303
|
+
actions
|
|
3304
|
+
),
|
|
3305
|
+
[EventStatus.enum.REGISTERED]: getDeclarationActionCreationMetadata(
|
|
3306
|
+
ActionType.REGISTER,
|
|
3307
|
+
actions
|
|
3308
|
+
)
|
|
3309
|
+
};
|
|
3310
|
+
}
|
|
3311
|
+
|
|
3312
|
+
// ../commons/src/events/state/flags.ts
|
|
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
|
+
);
|
|
3353
|
+
}
|
|
3354
|
+
var INHERENT_FLAG_RULES = [
|
|
3355
|
+
{
|
|
3356
|
+
flag: InherentFlags.CORRECTION_REQUESTED,
|
|
3357
|
+
setOn: [ActionType.REQUEST_CORRECTION],
|
|
3358
|
+
resetOn: [ActionType.APPROVE_CORRECTION, ActionType.REJECT_CORRECTION]
|
|
3359
|
+
},
|
|
3360
|
+
{
|
|
3361
|
+
// INCOMPLETE mirrors the NOTIFIED status: set by NOTIFY, cleared by any
|
|
3362
|
+
// other status-changing action (see getStatusFromActions). ARCHIVE/UNARCHIVE
|
|
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
|
+
}
|
|
3381
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;
|
|
3394
|
+
}
|
|
3395
|
+
if (rule.resetOnAnyOtherAction || (rule.resetOn ?? []).includes(action.type)) {
|
|
3396
|
+
return false;
|
|
3397
|
+
}
|
|
3398
|
+
if (actionConfigRemovesFlag(
|
|
3399
|
+
action,
|
|
3400
|
+
rule.flag,
|
|
3401
|
+
acceptedActions.slice(0, idx + 1),
|
|
3402
|
+
event2,
|
|
3403
|
+
eventConfiguration
|
|
3404
|
+
)) {
|
|
3405
|
+
return false;
|
|
3406
|
+
}
|
|
3407
|
+
return present;
|
|
3408
|
+
}, false);
|
|
3409
|
+
}
|
|
3410
|
+
function resolveEventCustomFlags(event2, eventConfiguration) {
|
|
3411
|
+
const actions = getAcceptedActions(event2).filter(({ type }) => !isMetaAction(type)).sort((a, b) => a.createdAt.localeCompare(b.createdAt));
|
|
3412
|
+
return actions.reduce((acc, action, idx) => {
|
|
3413
|
+
let actionConfig;
|
|
3414
|
+
if (isActionConfigType(action.type)) {
|
|
3415
|
+
actionConfig = getActionConfig({
|
|
3416
|
+
eventConfiguration,
|
|
3417
|
+
actionType: action.type,
|
|
3418
|
+
customActionType: "customActionType" in action ? action.customActionType : void 0
|
|
3419
|
+
});
|
|
3420
|
+
}
|
|
3421
|
+
if (!actionConfig) {
|
|
3422
|
+
return acc;
|
|
3423
|
+
}
|
|
3424
|
+
const eventUpToThisAction = {
|
|
3425
|
+
...event2,
|
|
3426
|
+
actions: actions.slice(0, idx + 1)
|
|
3427
|
+
};
|
|
3428
|
+
const declaration = aggregateActionDeclarations(eventUpToThisAction);
|
|
3429
|
+
const annotation = aggregateActionAnnotations(eventUpToThisAction);
|
|
3430
|
+
const form = { ...declaration, ...annotation };
|
|
3431
|
+
const flagsWithMetConditions = (actionConfig.flags ?? []).filter(
|
|
3432
|
+
({ conditional }) => (
|
|
3433
|
+
// If conditional is not provided, the flag is resolved
|
|
3434
|
+
conditional ? isFlagConditionMet(conditional, form, action) : true
|
|
3435
|
+
)
|
|
3436
|
+
);
|
|
3437
|
+
const addedFlags = flagsWithMetConditions.filter(({ operation }) => operation === "add").map(({ id }) => id);
|
|
3438
|
+
const removedFlags = flagsWithMetConditions.filter(({ operation }) => operation === "remove").map(({ id }) => id);
|
|
3439
|
+
const flags = [...acc, ...addedFlags].filter(
|
|
3440
|
+
(flagId) => !removedFlags.includes(flagId)
|
|
3441
|
+
);
|
|
3442
|
+
return (0, import_lodash2.uniq)(flags);
|
|
3443
|
+
}, []);
|
|
3444
|
+
}
|
|
3445
|
+
function getActionStatusFlags(sortedActions) {
|
|
3446
|
+
const actionStatus = sortedActions.reduce(
|
|
3447
|
+
(actionStatuses, { type, status }) => ({
|
|
3448
|
+
...actionStatuses,
|
|
3449
|
+
[type]: status
|
|
3450
|
+
}),
|
|
3451
|
+
{}
|
|
3452
|
+
);
|
|
3453
|
+
return Object.entries(actionStatus).filter(([, status]) => status !== ActionStatus.Accepted).map(([type, status]) => {
|
|
3454
|
+
const flag = joinValues([type, status], ":").toLowerCase();
|
|
3455
|
+
return flag;
|
|
3456
|
+
});
|
|
3457
|
+
}
|
|
3458
|
+
function getInherentFlags(sortedActions, event2, eventConfiguration) {
|
|
3459
|
+
const acceptedActions = sortedActions.filter(
|
|
3460
|
+
({ status }) => status === ActionStatus.Accepted
|
|
3461
|
+
);
|
|
3462
|
+
return INHERENT_FLAG_RULES.filter(
|
|
3463
|
+
(rule) => resolveInherentFlag(rule, acceptedActions, event2, eventConfiguration)
|
|
3464
|
+
).map(({ flag }) => flag);
|
|
3465
|
+
}
|
|
3466
|
+
function getEventFlags(event2, config) {
|
|
3467
|
+
const sortedActions = event2.actions.filter(({ type }) => !isMetaAction(type)).sort((a, b) => a.createdAt.localeCompare(b.createdAt));
|
|
3468
|
+
return [
|
|
3469
|
+
...getActionStatusFlags(sortedActions),
|
|
3470
|
+
...getInherentFlags(sortedActions, event2, config),
|
|
3471
|
+
...resolveEventCustomFlags(event2, config)
|
|
3472
|
+
];
|
|
3473
|
+
}
|
|
3382
3474
|
|
|
3383
3475
|
// ../commons/src/conditionals/conditionals.ts
|
|
3384
3476
|
var objectHash = __toESM(require("object-hash"));
|
|
@@ -3907,84 +3999,590 @@ function createFieldConditionals(fieldId) {
|
|
|
3907
3999
|
},
|
|
3908
4000
|
this.$$subfield
|
|
3909
4001
|
)
|
|
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)
|
|
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)
|
|
4414
|
+
)
|
|
3936
4415
|
}
|
|
3937
|
-
|
|
3938
|
-
|
|
3939
|
-
|
|
3940
|
-
|
|
3941
|
-
|
|
3942
|
-
|
|
3943
|
-
|
|
3944
|
-
|
|
3945
|
-
|
|
3946
|
-
|
|
3947
|
-
|
|
3948
|
-
|
|
3949
|
-
|
|
3950
|
-
|
|
3951
|
-
|
|
3952
|
-
|
|
3953
|
-
|
|
3954
|
-
|
|
3955
|
-
|
|
3956
|
-
|
|
3957
|
-
|
|
3958
|
-
|
|
3959
|
-
|
|
3960
|
-
|
|
3961
|
-
|
|
3962
|
-
|
|
3963
|
-
|
|
3964
|
-
|
|
3965
|
-
|
|
3966
|
-
|
|
3967
|
-
|
|
3968
|
-
|
|
3969
|
-
|
|
3970
|
-
|
|
3971
|
-
|
|
3972
|
-
|
|
3973
|
-
|
|
3974
|
-
|
|
3975
|
-
|
|
3976
|
-
|
|
3977
|
-
|
|
3978
|
-
|
|
3979
|
-
|
|
3980
|
-
|
|
3981
|
-
|
|
3982
|
-
|
|
3983
|
-
|
|
3984
|
-
|
|
3985
|
-
|
|
4416
|
+
];
|
|
4417
|
+
});
|
|
4418
|
+
data.$form = Object.fromEntries(entries);
|
|
4419
|
+
}
|
|
4420
|
+
const result = validator(data);
|
|
4421
|
+
return result;
|
|
4422
|
+
}
|
|
4423
|
+
function isOnline() {
|
|
4424
|
+
if (typeof window !== "undefined" && typeof navigator !== "undefined") {
|
|
4425
|
+
return navigator.onLine;
|
|
4426
|
+
}
|
|
4427
|
+
return true;
|
|
4428
|
+
}
|
|
4429
|
+
|
|
4430
|
+
// ../commons/src/events/utils.ts
|
|
4431
|
+
var import_date_fns3 = require("date-fns");
|
|
4432
|
+
function ageToDate(age, asOfDate) {
|
|
4433
|
+
const date = plainDateToLocalDate(asOfDate);
|
|
4434
|
+
return PlainDate.parse((0, import_date_fns3.format)((0, import_date_fns3.subYears)(date, age), "yyyy-MM-dd"));
|
|
4435
|
+
}
|
|
4436
|
+
function getDeclarationFields(configuration) {
|
|
4437
|
+
return configuration.declaration.pages.flatMap(({ fields }) => fields);
|
|
4438
|
+
}
|
|
4439
|
+
function isActionConfigType(type) {
|
|
4440
|
+
return actionConfigTypes.has(type);
|
|
4441
|
+
}
|
|
4442
|
+
function getActionConfig({
|
|
4443
|
+
eventConfiguration,
|
|
4444
|
+
actionType,
|
|
4445
|
+
customActionType
|
|
4446
|
+
}) {
|
|
4447
|
+
if (actionType === ActionType.NOTIFY) {
|
|
4448
|
+
return eventConfiguration.actions.find((a) => a.type === ActionType.NOTIFY) ?? eventConfiguration.actions.find((a) => a.type === ActionType.DECLARE);
|
|
4449
|
+
}
|
|
4450
|
+
return eventConfiguration.actions.find((a) => {
|
|
4451
|
+
if (a.type === ActionType.CUSTOM && customActionType) {
|
|
4452
|
+
return a.customActionType === customActionType;
|
|
4453
|
+
}
|
|
4454
|
+
return a.type === actionType;
|
|
4455
|
+
});
|
|
4456
|
+
}
|
|
4457
|
+
var getActionAnnotationFields = (actionConfig) => {
|
|
4458
|
+
if (actionConfig.type === ActionType.REQUEST_CORRECTION) {
|
|
4459
|
+
return actionConfig.correctionForm.pages.flatMap(({ fields }) => fields);
|
|
4460
|
+
}
|
|
4461
|
+
if (actionConfig.type === ActionType.PRINT_CERTIFICATE) {
|
|
4462
|
+
return actionConfig.printForm.pages.flatMap(({ fields }) => fields);
|
|
4463
|
+
}
|
|
4464
|
+
const reviewFields = "review" in actionConfig && actionConfig.review != null ? actionConfig.review.fields : [];
|
|
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;
|
|
3986
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
|
+
}
|
|
4508
|
+
}
|
|
4509
|
+
return void 0;
|
|
3987
4510
|
};
|
|
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
|
+
}, {});
|
|
3988
4586
|
}
|
|
3989
4587
|
|
|
3990
4588
|
// ../commons/src/events/eventConfigValidation.ts
|
|
@@ -4828,14 +5426,14 @@ var DraftInput = BaseActionInput.omit({ waitFor: true }).extend({
|
|
|
4828
5426
|
|
|
4829
5427
|
// ../commons/src/events/EventInput.ts
|
|
4830
5428
|
var z40 = __toESM(require("zod/v4"));
|
|
4831
|
-
var
|
|
5429
|
+
var import_uuid11 = require("uuid");
|
|
4832
5430
|
var EventInput = z40.object({
|
|
4833
5431
|
transactionId: z40.string(),
|
|
4834
5432
|
type: z40.string(),
|
|
4835
5433
|
createdAtLocation: UUID.nullish().describe(
|
|
4836
5434
|
"Location where the event occurred. Required for system users."
|
|
4837
5435
|
)
|
|
4838
|
-
}).meta({ default: { transactionId: (0,
|
|
5436
|
+
}).meta({ default: { transactionId: (0, import_uuid11.v4)(), type: "birth" } });
|
|
4839
5437
|
|
|
4840
5438
|
// ../commons/src/events/EventDocument.ts
|
|
4841
5439
|
var z41 = __toESM(require("zod/v4"));
|
|
@@ -4852,67 +5450,6 @@ var EventDocument = z41.object({
|
|
|
4852
5450
|
)
|
|
4853
5451
|
}).meta({ id: "EventDocument" });
|
|
4854
5452
|
|
|
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
|
-
|
|
4916
5453
|
// ../commons/src/events/defineConfig.ts
|
|
4917
5454
|
var IGNORED_EVENT_TYPES = [
|
|
4918
5455
|
"FOOTBALL_CLUB_MEMBERSHIP",
|
|
@@ -7385,44 +7922,21 @@ var LocationTypeV1 = z43.enum([
|
|
|
7385
7922
|
"CRVS_OFFICE",
|
|
7386
7923
|
"HEALTH_FACILITY"
|
|
7387
7924
|
]);
|
|
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
|
-
});
|
|
7396
7925
|
var AdministrativeArea = z43.object({
|
|
7397
7926
|
id: UUID,
|
|
7398
7927
|
name: z43.string(),
|
|
7399
7928
|
externalId: z43.string().nullish(),
|
|
7400
7929
|
parentId: UUID.nullable(),
|
|
7401
|
-
|
|
7402
|
-
versions: z43.array(LocationVersion)
|
|
7930
|
+
validUntil: z43.iso.datetime().nullable()
|
|
7403
7931
|
});
|
|
7404
7932
|
var Location = z43.object({
|
|
7405
7933
|
id: UUID,
|
|
7406
7934
|
name: z43.string(),
|
|
7407
7935
|
externalId: z43.string().nullish(),
|
|
7408
7936
|
administrativeAreaId: UUID.nullable(),
|
|
7409
|
-
|
|
7410
|
-
status: LocationStatus,
|
|
7411
|
-
versions: z43.array(LocationVersion)
|
|
7412
|
-
});
|
|
7413
|
-
var SetLocationPayload = z43.object({
|
|
7414
|
-
id: UUID,
|
|
7415
|
-
name: z43.string(),
|
|
7416
|
-
externalId: z43.string().nullish(),
|
|
7417
|
-
administrativeAreaId: UUID.nullable(),
|
|
7937
|
+
validUntil: z43.iso.datetime().nullable(),
|
|
7418
7938
|
locationType: z43.string().nullable()
|
|
7419
7939
|
});
|
|
7420
|
-
var SetAdministrativeAreaPayload = z43.object({
|
|
7421
|
-
id: UUID,
|
|
7422
|
-
name: z43.string(),
|
|
7423
|
-
externalId: z43.string().nullish(),
|
|
7424
|
-
parentId: UUID.nullable()
|
|
7425
|
-
});
|
|
7426
7940
|
|
|
7427
7941
|
// ../commons/src/events/scopes.ts
|
|
7428
7942
|
var ACTION_SCOPE_MAP = {
|
|
@@ -7521,80 +8035,75 @@ var REJECTED_ACTIONS = [
|
|
|
7521
8035
|
var import_lodash7 = require("lodash");
|
|
7522
8036
|
|
|
7523
8037
|
// ../commons/src/events/mocks.test.utils.ts
|
|
7524
|
-
|
|
7525
|
-
return {
|
|
7526
|
-
...entity,
|
|
7527
|
-
status: "active",
|
|
7528
|
-
versions: [
|
|
7529
|
-
{
|
|
7530
|
-
versionId: entity.id,
|
|
7531
|
-
effectiveFrom: "0001-01-01",
|
|
7532
|
-
name: entity.name,
|
|
7533
|
-
externalId: entity.externalId ?? null,
|
|
7534
|
-
status: "active"
|
|
7535
|
-
}
|
|
7536
|
-
]
|
|
7537
|
-
};
|
|
7538
|
-
}
|
|
7539
|
-
var MOCK_ADMINISTRATIVE_AREAS_BASE = [
|
|
8038
|
+
var V2_DEFAULT_MOCK_ADMINISTRATIVE_AREAS = [
|
|
7540
8039
|
{
|
|
7541
8040
|
id: "a45b982a-5c7b-4bd9-8fd8-a42d0994054c",
|
|
7542
8041
|
name: "Central",
|
|
7543
8042
|
parentId: null,
|
|
8043
|
+
validUntil: null,
|
|
7544
8044
|
externalId: "ydyJb1RAy4U1"
|
|
7545
8045
|
},
|
|
7546
8046
|
{
|
|
7547
8047
|
id: "c599b691-fd2d-45e1-abf4-d185de727fb5",
|
|
7548
8048
|
name: "Sulaka",
|
|
7549
8049
|
parentId: null,
|
|
8050
|
+
validUntil: null,
|
|
7550
8051
|
externalId: "pQ8nGxWmZ2Q3"
|
|
7551
8052
|
},
|
|
7552
8053
|
{
|
|
7553
8054
|
id: "7ef2b9c7-5e6d-49f6-ae05-656207d0fc64",
|
|
7554
8055
|
name: "Pualula",
|
|
7555
8056
|
parentId: null,
|
|
8057
|
+
validUntil: null,
|
|
7556
8058
|
externalId: "Aq91DweLmT8k"
|
|
7557
8059
|
},
|
|
7558
8060
|
{
|
|
7559
8061
|
id: "6d1a59df-988c-4021-a846-ccbc021931a7",
|
|
7560
8062
|
name: "Chuminga",
|
|
7561
8063
|
parentId: null,
|
|
8064
|
+
validUntil: null,
|
|
7562
8065
|
externalId: "Rw0fYNh2Xk9a"
|
|
7563
8066
|
},
|
|
7564
8067
|
{
|
|
7565
8068
|
id: "62a0ccb4-880d-4f30-8882-f256007dfff9",
|
|
7566
8069
|
name: "Ibombo",
|
|
7567
8070
|
parentId: "a45b982a-5c7b-4bd9-8fd8-a42d0994054c",
|
|
8071
|
+
validUntil: null,
|
|
7568
8072
|
externalId: "k7DsP4vbN1Qe"
|
|
7569
8073
|
},
|
|
7570
8074
|
{
|
|
7571
8075
|
id: "27160bbd-32d1-4625-812f-860226bfb92a",
|
|
7572
8076
|
name: "Isango",
|
|
7573
8077
|
parentId: "a45b982a-5c7b-4bd9-8fd8-a42d0994054c",
|
|
8078
|
+
validUntil: null,
|
|
7574
8079
|
externalId: "Gm3Z9eQpHw4L"
|
|
7575
8080
|
},
|
|
7576
8081
|
{
|
|
7577
8082
|
id: "967032fd-3f81-478a-826c-30cb8fe121bd",
|
|
7578
8083
|
name: "Isamba",
|
|
7579
8084
|
parentId: "a45b982a-5c7b-4bd9-8fd8-a42d0994054c",
|
|
8085
|
+
validUntil: null,
|
|
7580
8086
|
externalId: "sT0xVu1KqJ7r"
|
|
7581
8087
|
},
|
|
7582
8088
|
{
|
|
7583
8089
|
id: "89a33893-b17d-481d-a26d-6461e7ac1651",
|
|
7584
8090
|
name: "Itambo",
|
|
7585
8091
|
parentId: "a45b982a-5c7b-4bd9-8fd8-a42d0994054c",
|
|
8092
|
+
validUntil: null,
|
|
7586
8093
|
externalId: "Nq6Bv2HpL9Te"
|
|
7587
8094
|
},
|
|
7588
8095
|
{
|
|
7589
8096
|
id: "d42ab2fe-e7ed-470e-8b31-4fb27f9b8250",
|
|
7590
8097
|
name: "Ezhi",
|
|
7591
8098
|
parentId: "a45b982a-5c7b-4bd9-8fd8-a42d0994054c",
|
|
8099
|
+
validUntil: null,
|
|
7592
8100
|
externalId: "xK8cQ0ZRy5Wd"
|
|
7593
8101
|
},
|
|
7594
8102
|
{
|
|
7595
8103
|
id: "8fbd09d2-212b-47f4-beb3-5e1694931d9f",
|
|
7596
8104
|
name: "Ilanga",
|
|
7597
8105
|
parentId: "c599b691-fd2d-45e1-abf4-d185de727fb5",
|
|
8106
|
+
validUntil: null,
|
|
7598
8107
|
externalId: "Cq4Jm1XvN8Ls"
|
|
7599
8108
|
},
|
|
7600
8109
|
// Villages under Ibombo (62a0ccb4-880d-4f30-8882-f256007dfff9)
|
|
@@ -7602,42 +8111,49 @@ var MOCK_ADMINISTRATIVE_AREAS_BASE = [
|
|
|
7602
8111
|
id: "1d4e5f6a-7b8c-4912-8efa-345678901234",
|
|
7603
8112
|
name: "Klow",
|
|
7604
8113
|
parentId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
|
|
8114
|
+
validUntil: null,
|
|
7605
8115
|
externalId: "IkYcYBUcyY2"
|
|
7606
8116
|
},
|
|
7607
8117
|
{
|
|
7608
8118
|
id: "2e5f6a7b-8c9d-4a23-8fab-456789012345",
|
|
7609
8119
|
name: "Mbondo",
|
|
7610
8120
|
parentId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
|
|
8121
|
+
validUntil: null,
|
|
7611
8122
|
externalId: "Qhvv5hvo3mY"
|
|
7612
8123
|
},
|
|
7613
8124
|
{
|
|
7614
8125
|
id: "3f6a7b8c-9d0e-4b34-8abc-567890123456",
|
|
7615
8126
|
name: "Ndara",
|
|
7616
8127
|
parentId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
|
|
8128
|
+
validUntil: null,
|
|
7617
8129
|
externalId: "crXh068O9TR"
|
|
7618
8130
|
},
|
|
7619
8131
|
{
|
|
7620
8132
|
id: "4a7b8c9d-0e1f-4c45-abcd-678901234567",
|
|
7621
8133
|
name: "Olani",
|
|
7622
8134
|
parentId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
|
|
8135
|
+
validUntil: null,
|
|
7623
8136
|
externalId: "r00It8Tvvp7"
|
|
7624
8137
|
},
|
|
7625
8138
|
{
|
|
7626
8139
|
id: "5b8c9d0e-1f2a-4d56-bcde-789012345678",
|
|
7627
8140
|
name: "Pemba",
|
|
7628
8141
|
parentId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
|
|
8142
|
+
validUntil: null,
|
|
7629
8143
|
externalId: "ZnUWsbONIaH"
|
|
7630
8144
|
},
|
|
7631
8145
|
{
|
|
7632
8146
|
id: "6c9d0e1f-2a3b-4e67-8def-890123456789",
|
|
7633
8147
|
name: "Quanza",
|
|
7634
8148
|
parentId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
|
|
8149
|
+
validUntil: null,
|
|
7635
8150
|
externalId: "fDZycvQTa7l"
|
|
7636
8151
|
},
|
|
7637
8152
|
{
|
|
7638
8153
|
id: "7d0e1f2a-3b4c-4f78-8efa-901234567890",
|
|
7639
8154
|
name: "Rivka",
|
|
7640
8155
|
parentId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
|
|
8156
|
+
validUntil: null,
|
|
7641
8157
|
externalId: "KqswxCGTELa"
|
|
7642
8158
|
},
|
|
7643
8159
|
// Villages under Isamba (967032fd-3f81-478a-826c-30cb8fe121bd)
|
|
@@ -7645,30 +8161,35 @@ var MOCK_ADMINISTRATIVE_AREAS_BASE = [
|
|
|
7645
8161
|
id: "8e1f2a3b-4c5d-4089-8fab-012345678901",
|
|
7646
8162
|
name: "Mbula",
|
|
7647
8163
|
parentId: "967032fd-3f81-478a-826c-30cb8fe121bd",
|
|
8164
|
+
validUntil: null,
|
|
7648
8165
|
externalId: "osEbKjRc9Kg"
|
|
7649
8166
|
},
|
|
7650
8167
|
{
|
|
7651
8168
|
id: "9f2a3b4c-5d6e-4190-8abf-123456789012",
|
|
7652
8169
|
name: "Ndoki",
|
|
7653
8170
|
parentId: "967032fd-3f81-478a-826c-30cb8fe121bd",
|
|
8171
|
+
validUntil: null,
|
|
7654
8172
|
externalId: "aq4daBUAGr3"
|
|
7655
8173
|
},
|
|
7656
8174
|
{
|
|
7657
8175
|
id: "0a3b4c5d-6e7f-4201-abcd-234567890123",
|
|
7658
8176
|
name: "Tsanga",
|
|
7659
8177
|
parentId: "967032fd-3f81-478a-826c-30cb8fe121bd",
|
|
8178
|
+
validUntil: null,
|
|
7660
8179
|
externalId: "cqis6Y8trbJ"
|
|
7661
8180
|
},
|
|
7662
8181
|
{
|
|
7663
8182
|
id: "1b4c5d6e-7f8a-4312-bcde-345678901234",
|
|
7664
8183
|
name: "Waziri",
|
|
7665
8184
|
parentId: "967032fd-3f81-478a-826c-30cb8fe121bd",
|
|
8185
|
+
validUntil: null,
|
|
7666
8186
|
externalId: "LMijHPyyx6d"
|
|
7667
8187
|
},
|
|
7668
8188
|
{
|
|
7669
8189
|
id: "2c5d6e7f-8a9b-4423-8def-456789012345",
|
|
7670
8190
|
name: "Zimbi",
|
|
7671
8191
|
parentId: "967032fd-3f81-478a-826c-30cb8fe121bd",
|
|
8192
|
+
validUntil: null,
|
|
7672
8193
|
externalId: "pcQYbPuKGZ7"
|
|
7673
8194
|
},
|
|
7674
8195
|
// Villages under Itambo (89a33893-b17d-481d-a26d-6461e7ac1651)
|
|
@@ -7676,59 +8197,67 @@ var MOCK_ADMINISTRATIVE_AREAS_BASE = [
|
|
|
7676
8197
|
id: "3d6e7f8a-9b0c-4534-8efa-567890123456",
|
|
7677
8198
|
name: "Felani",
|
|
7678
8199
|
parentId: "89a33893-b17d-481d-a26d-6461e7ac1651",
|
|
8200
|
+
validUntil: null,
|
|
7679
8201
|
externalId: "gSqpoCGdMXp"
|
|
7680
8202
|
},
|
|
7681
8203
|
{
|
|
7682
8204
|
id: "4e7f8a9b-0c1d-4645-8fab-678901234567",
|
|
7683
8205
|
name: "Goroma",
|
|
7684
8206
|
parentId: "89a33893-b17d-481d-a26d-6461e7ac1651",
|
|
8207
|
+
validUntil: null,
|
|
7685
8208
|
externalId: "KvAAIaNqVrp"
|
|
7686
8209
|
},
|
|
7687
8210
|
{
|
|
7688
8211
|
id: "5f8a9b0c-1d2e-4756-8abc-789012345678",
|
|
7689
8212
|
name: "Halifu",
|
|
7690
8213
|
parentId: "89a33893-b17d-481d-a26d-6461e7ac1651",
|
|
8214
|
+
validUntil: null,
|
|
7691
8215
|
externalId: "qe4UnEVt1hv"
|
|
7692
8216
|
},
|
|
7693
8217
|
{
|
|
7694
8218
|
id: "6a9b0c1d-2e3f-4867-abcd-890123456789",
|
|
7695
8219
|
name: "Jabari",
|
|
7696
8220
|
parentId: "89a33893-b17d-481d-a26d-6461e7ac1651",
|
|
8221
|
+
validUntil: null,
|
|
7697
8222
|
externalId: "yHH9Nz4rLOt"
|
|
7698
8223
|
},
|
|
7699
8224
|
{
|
|
7700
8225
|
id: "7b0c1d2e-3f4a-4978-bcde-901234567890",
|
|
7701
8226
|
name: "Kifani",
|
|
7702
8227
|
parentId: "89a33893-b17d-481d-a26d-6461e7ac1651",
|
|
8228
|
+
validUntil: null,
|
|
7703
8229
|
externalId: "eSWmXIGeu1I"
|
|
7704
8230
|
},
|
|
7705
8231
|
{
|
|
7706
8232
|
id: "8c1d2e3f-4a5b-4089-8def-012345678901",
|
|
7707
8233
|
name: "Lumela",
|
|
7708
8234
|
parentId: "89a33893-b17d-481d-a26d-6461e7ac1651",
|
|
8235
|
+
validUntil: null,
|
|
7709
8236
|
externalId: "bh0b3aI1uP3"
|
|
7710
8237
|
}
|
|
7711
8238
|
];
|
|
7712
|
-
var
|
|
7713
|
-
var MOCK_LOCATIONS_BASE = [
|
|
8239
|
+
var V2_DEFAULT_MOCK_LOCATIONS = [
|
|
7714
8240
|
{
|
|
7715
8241
|
id: "6f6186ce-cd5f-4a5f-810a-2d99e7c4ba12",
|
|
7716
8242
|
name: "Central Provincial Office",
|
|
7717
8243
|
locationType: "CRVS_OFFICE",
|
|
7718
8244
|
administrativeAreaId: "a45b982a-5c7b-4bd9-8fd8-a42d0994054c",
|
|
8245
|
+
validUntil: null,
|
|
7719
8246
|
externalId: "Xr3Df8WpK6Ys"
|
|
7720
8247
|
},
|
|
7721
8248
|
{
|
|
7722
8249
|
id: "b1c2d3e4-f5a6-7890-bcde-f12345678901",
|
|
7723
8250
|
name: "Central Health Post",
|
|
7724
8251
|
locationType: "HEALTH_FACILITY",
|
|
7725
|
-
administrativeAreaId: "a45b982a-5c7b-4bd9-8fd8-a42d0994054c"
|
|
8252
|
+
administrativeAreaId: "a45b982a-5c7b-4bd9-8fd8-a42d0994054c",
|
|
8253
|
+
validUntil: null
|
|
7726
8254
|
},
|
|
7727
8255
|
{
|
|
7728
8256
|
id: "028d2c85-ca31-426d-b5d1-2cef545a4902",
|
|
7729
8257
|
name: "Ibombo District Office",
|
|
7730
8258
|
locationType: "CRVS_OFFICE",
|
|
7731
8259
|
administrativeAreaId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
|
|
8260
|
+
validUntil: null,
|
|
7732
8261
|
externalId: "Sm4Nw7GrD2Vy"
|
|
7733
8262
|
},
|
|
7734
8263
|
{
|
|
@@ -7736,6 +8265,7 @@ var MOCK_LOCATIONS_BASE = [
|
|
|
7736
8265
|
name: "Isamba District Office",
|
|
7737
8266
|
locationType: "CRVS_OFFICE",
|
|
7738
8267
|
administrativeAreaId: "967032fd-3f81-478a-826c-30cb8fe121bd",
|
|
8268
|
+
validUntil: null,
|
|
7739
8269
|
externalId: "Vg1Bq5XeH9Lt"
|
|
7740
8270
|
},
|
|
7741
8271
|
{
|
|
@@ -7743,6 +8273,7 @@ var MOCK_LOCATIONS_BASE = [
|
|
|
7743
8273
|
name: "Isango District Office",
|
|
7744
8274
|
locationType: "CRVS_OFFICE",
|
|
7745
8275
|
administrativeAreaId: "27160bbd-32d1-4625-812f-860226bfb92a",
|
|
8276
|
+
validUntil: null,
|
|
7746
8277
|
externalId: "Je7Lm2XqN9Vz"
|
|
7747
8278
|
},
|
|
7748
8279
|
{
|
|
@@ -7750,6 +8281,7 @@ var MOCK_LOCATIONS_BASE = [
|
|
|
7750
8281
|
name: "Sulaka Provincial Office",
|
|
7751
8282
|
locationType: "CRVS_OFFICE",
|
|
7752
8283
|
administrativeAreaId: "c599b691-fd2d-45e1-abf4-d185de727fb5",
|
|
8284
|
+
validUntil: null,
|
|
7753
8285
|
externalId: "Ht2Wp9KcX5Qv"
|
|
7754
8286
|
},
|
|
7755
8287
|
{
|
|
@@ -7757,6 +8289,7 @@ var MOCK_LOCATIONS_BASE = [
|
|
|
7757
8289
|
name: "Ilanga District Office",
|
|
7758
8290
|
locationType: "CRVS_OFFICE",
|
|
7759
8291
|
administrativeAreaId: "8fbd09d2-212b-47f4-beb3-5e1694931d9f",
|
|
8292
|
+
validUntil: null,
|
|
7760
8293
|
externalId: "Yp6Ds1WqN3Xz"
|
|
7761
8294
|
},
|
|
7762
8295
|
{
|
|
@@ -7764,6 +8297,7 @@ var MOCK_LOCATIONS_BASE = [
|
|
|
7764
8297
|
name: "Chamakubi Health Post",
|
|
7765
8298
|
locationType: "HEALTH_FACILITY",
|
|
7766
8299
|
administrativeAreaId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
|
|
8300
|
+
validUntil: null,
|
|
7767
8301
|
externalId: "M1nFr8LbC2Qy"
|
|
7768
8302
|
},
|
|
7769
8303
|
{
|
|
@@ -7771,6 +8305,7 @@ var MOCK_LOCATIONS_BASE = [
|
|
|
7771
8305
|
name: "Ibombo Rural Health Centre",
|
|
7772
8306
|
locationType: "HEALTH_FACILITY",
|
|
7773
8307
|
administrativeAreaId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
|
|
8308
|
+
validUntil: null,
|
|
7774
8309
|
externalId: "bT7pV6YrW0Xc"
|
|
7775
8310
|
},
|
|
7776
8311
|
{
|
|
@@ -7778,6 +8313,7 @@ var MOCK_LOCATIONS_BASE = [
|
|
|
7778
8313
|
name: "Chikobo Rural Health Centre",
|
|
7779
8314
|
locationType: "HEALTH_FACILITY",
|
|
7780
8315
|
administrativeAreaId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
|
|
8316
|
+
validUntil: null,
|
|
7781
8317
|
externalId: "zE4qPn2SgJ5d"
|
|
7782
8318
|
},
|
|
7783
8319
|
{
|
|
@@ -7785,6 +8321,7 @@ var MOCK_LOCATIONS_BASE = [
|
|
|
7785
8321
|
name: "Chilochabalenje Health Post",
|
|
7786
8322
|
locationType: "HEALTH_FACILITY",
|
|
7787
8323
|
administrativeAreaId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
|
|
8324
|
+
validUntil: null,
|
|
7788
8325
|
externalId: "H8vDs1MqR4Uf"
|
|
7789
8326
|
},
|
|
7790
8327
|
{
|
|
@@ -7792,6 +8329,7 @@ var MOCK_LOCATIONS_BASE = [
|
|
|
7792
8329
|
name: "Chipeso Rural Health Centre",
|
|
7793
8330
|
locationType: "HEALTH_FACILITY",
|
|
7794
8331
|
administrativeAreaId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
|
|
8332
|
+
validUntil: null,
|
|
7795
8333
|
externalId: "Qw3uZ9KfX6Lm"
|
|
7796
8334
|
},
|
|
7797
8335
|
{
|
|
@@ -7799,6 +8337,7 @@ var MOCK_LOCATIONS_BASE = [
|
|
|
7799
8337
|
name: "Chisamba Rural Health Centre",
|
|
7800
8338
|
locationType: "HEALTH_FACILITY",
|
|
7801
8339
|
administrativeAreaId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
|
|
8340
|
+
validUntil: null,
|
|
7802
8341
|
externalId: "Yr0pCg8LdM2s"
|
|
7803
8342
|
},
|
|
7804
8343
|
{
|
|
@@ -7806,6 +8345,7 @@ var MOCK_LOCATIONS_BASE = [
|
|
|
7806
8345
|
name: "Chitanda Rural Health Centre",
|
|
7807
8346
|
locationType: "HEALTH_FACILITY",
|
|
7808
8347
|
administrativeAreaId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
|
|
8348
|
+
validUntil: null,
|
|
7809
8349
|
externalId: "tS9gJ4PwB1Qx"
|
|
7810
8350
|
},
|
|
7811
8351
|
{
|
|
@@ -7813,6 +8353,7 @@ var MOCK_LOCATIONS_BASE = [
|
|
|
7813
8353
|
name: "Golden Valley Rural Health Centre",
|
|
7814
8354
|
locationType: "HEALTH_FACILITY",
|
|
7815
8355
|
administrativeAreaId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
|
|
8356
|
+
validUntil: null,
|
|
7816
8357
|
externalId: "Ld7Qm3XsA8Vr"
|
|
7817
8358
|
},
|
|
7818
8359
|
{
|
|
@@ -7820,6 +8361,7 @@ var MOCK_LOCATIONS_BASE = [
|
|
|
7820
8361
|
name: "Ipongo Rural Health Centre",
|
|
7821
8362
|
locationType: "HEALTH_FACILITY",
|
|
7822
8363
|
administrativeAreaId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
|
|
8364
|
+
validUntil: null,
|
|
7823
8365
|
externalId: "kF2sW9DmH0Bt"
|
|
7824
8366
|
},
|
|
7825
8367
|
{
|
|
@@ -7827,6 +8369,7 @@ var MOCK_LOCATIONS_BASE = [
|
|
|
7827
8369
|
name: "Itumbwe Health Post",
|
|
7828
8370
|
locationType: "HEALTH_FACILITY",
|
|
7829
8371
|
administrativeAreaId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
|
|
8372
|
+
validUntil: null,
|
|
7830
8373
|
externalId: "Ue5Xb3VaC7Pq"
|
|
7831
8374
|
},
|
|
7832
8375
|
{
|
|
@@ -7834,6 +8377,7 @@ var MOCK_LOCATIONS_BASE = [
|
|
|
7834
8377
|
name: "Kabangalala Rural Health Centre",
|
|
7835
8378
|
locationType: "HEALTH_FACILITY",
|
|
7836
8379
|
administrativeAreaId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
|
|
8380
|
+
validUntil: null,
|
|
7837
8381
|
externalId: "Pz8Kc1TqH6Jn"
|
|
7838
8382
|
},
|
|
7839
8383
|
// Village offices
|
|
@@ -7842,10 +8386,10 @@ var MOCK_LOCATIONS_BASE = [
|
|
|
7842
8386
|
name: "Klow Village Office",
|
|
7843
8387
|
locationType: "CRVS_OFFICE",
|
|
7844
8388
|
administrativeAreaId: "1d4e5f6a-7b8c-4912-8efa-345678901234",
|
|
8389
|
+
validUntil: null,
|
|
7845
8390
|
externalId: "PmAyxAJkxiJ"
|
|
7846
8391
|
}
|
|
7847
8392
|
];
|
|
7848
|
-
var V2_DEFAULT_MOCK_LOCATIONS = MOCK_LOCATIONS_BASE.map(withVersionFields);
|
|
7849
8393
|
var V2_DEFAULT_MOCK_LOCATIONS_MAP = new Map(
|
|
7850
8394
|
V2_DEFAULT_MOCK_LOCATIONS.map((l) => [l.id, l])
|
|
7851
8395
|
);
|
|
@@ -7853,56 +8397,8 @@ var V2_DEFAULT_MOCK_ADMINISTRATIVE_AREAS_MAP = new Map(
|
|
|
7853
8397
|
V2_DEFAULT_MOCK_ADMINISTRATIVE_AREAS.map((a) => [a.id, a])
|
|
7854
8398
|
);
|
|
7855
8399
|
|
|
7856
|
-
// ../commons/src/events/locationPayloads.ts
|
|
7857
|
-
var z44 = __toESM(require("zod/v4"));
|
|
7858
|
-
var CreateLocationPayload = z44.object({
|
|
7859
|
-
id: UUID.optional(),
|
|
7860
|
-
versionId: UUID.optional(),
|
|
7861
|
-
name: z44.string(),
|
|
7862
|
-
externalId: z44.string().nullish(),
|
|
7863
|
-
administrativeAreaId: UUID.nullable(),
|
|
7864
|
-
locationType: z44.string().nullable(),
|
|
7865
|
-
effectiveFrom: z44.iso.date().optional(),
|
|
7866
|
-
status: LocationStatus.default("active")
|
|
7867
|
-
});
|
|
7868
|
-
var UpdateLocationPayload = z44.strictObject({
|
|
7869
|
-
id: UUID,
|
|
7870
|
-
versionId: UUID.optional(),
|
|
7871
|
-
name: z44.string(),
|
|
7872
|
-
externalId: z44.string().nullish(),
|
|
7873
|
-
status: LocationStatus,
|
|
7874
|
-
effectiveFrom: z44.iso.date().optional(),
|
|
7875
|
-
lastVersionId: UUID
|
|
7876
|
-
});
|
|
7877
|
-
var WithdrawLocationVersionPayload = z44.object({
|
|
7878
|
-
id: UUID,
|
|
7879
|
-
versionId: UUID
|
|
7880
|
-
});
|
|
7881
|
-
var CreateAdministrativeAreaPayload = z44.object({
|
|
7882
|
-
id: UUID.optional(),
|
|
7883
|
-
versionId: UUID.optional(),
|
|
7884
|
-
name: z44.string(),
|
|
7885
|
-
externalId: z44.string().nullish(),
|
|
7886
|
-
parentId: UUID.nullable(),
|
|
7887
|
-
effectiveFrom: z44.iso.date().optional(),
|
|
7888
|
-
status: LocationStatus.default("active")
|
|
7889
|
-
});
|
|
7890
|
-
var UpdateAdministrativeAreaPayload = z44.strictObject({
|
|
7891
|
-
id: UUID,
|
|
7892
|
-
versionId: UUID.optional(),
|
|
7893
|
-
name: z44.string(),
|
|
7894
|
-
externalId: z44.string().nullish(),
|
|
7895
|
-
status: LocationStatus,
|
|
7896
|
-
effectiveFrom: z44.iso.date().optional(),
|
|
7897
|
-
lastVersionId: UUID
|
|
7898
|
-
});
|
|
7899
|
-
var WithdrawAdministrativeAreaVersionPayload = z44.object({
|
|
7900
|
-
id: UUID,
|
|
7901
|
-
versionId: UUID
|
|
7902
|
-
});
|
|
7903
|
-
|
|
7904
8400
|
// ../commons/src/notification/UserNotifications.ts
|
|
7905
|
-
var
|
|
8401
|
+
var z44 = __toESM(require("zod/v4"));
|
|
7906
8402
|
var TriggerEvent = {
|
|
7907
8403
|
USER_CREATED: "user-created",
|
|
7908
8404
|
USER_UPDATED: "user-updated",
|
|
@@ -7915,54 +8411,54 @@ var TriggerEvent = {
|
|
|
7915
8411
|
CHANGE_PHONE_NUMBER: "change-phone-number",
|
|
7916
8412
|
CHANGE_EMAIL_ADDRESS: "change-email-address"
|
|
7917
8413
|
};
|
|
7918
|
-
var Recipient =
|
|
8414
|
+
var Recipient = z44.object({
|
|
7919
8415
|
name: NameFieldValue.optional(),
|
|
7920
|
-
mobile:
|
|
7921
|
-
email:
|
|
7922
|
-
bcc:
|
|
8416
|
+
mobile: z44.string().optional(),
|
|
8417
|
+
email: z44.string().optional(),
|
|
8418
|
+
bcc: z44.array(z44.string()).optional()
|
|
7923
8419
|
});
|
|
7924
|
-
var BasePayload =
|
|
8420
|
+
var BasePayload = z44.object({
|
|
7925
8421
|
recipient: Recipient
|
|
7926
8422
|
});
|
|
7927
8423
|
var TriggerPayload = {
|
|
7928
8424
|
[TriggerEvent.USER_CREATED]: BasePayload.extend({
|
|
7929
|
-
username:
|
|
7930
|
-
temporaryPassword:
|
|
8425
|
+
username: z44.string(),
|
|
8426
|
+
temporaryPassword: z44.string()
|
|
7931
8427
|
}),
|
|
7932
8428
|
[TriggerEvent.USER_UPDATED]: BasePayload.extend({
|
|
7933
|
-
oldUsername:
|
|
7934
|
-
newUsername:
|
|
8429
|
+
oldUsername: z44.string(),
|
|
8430
|
+
newUsername: z44.string()
|
|
7935
8431
|
}),
|
|
7936
8432
|
[TriggerEvent.USERNAME_REMINDER]: BasePayload.extend({
|
|
7937
|
-
username:
|
|
8433
|
+
username: z44.string()
|
|
7938
8434
|
}),
|
|
7939
8435
|
[TriggerEvent.RESET_PASSWORD]: BasePayload.extend({
|
|
7940
|
-
code:
|
|
8436
|
+
code: z44.string()
|
|
7941
8437
|
}),
|
|
7942
8438
|
[TriggerEvent.RESET_PASSWORD_BY_ADMIN]: BasePayload.extend({
|
|
7943
|
-
temporaryPassword:
|
|
7944
|
-
admin:
|
|
7945
|
-
id:
|
|
8439
|
+
temporaryPassword: z44.string(),
|
|
8440
|
+
admin: z44.object({
|
|
8441
|
+
id: z44.string(),
|
|
7946
8442
|
name: NameFieldValue,
|
|
7947
|
-
role:
|
|
8443
|
+
role: z44.string()
|
|
7948
8444
|
})
|
|
7949
8445
|
}),
|
|
7950
8446
|
[TriggerEvent.RESEND_INVITE]: BasePayload.extend({
|
|
7951
|
-
username:
|
|
7952
|
-
temporaryPassword:
|
|
8447
|
+
username: z44.string(),
|
|
8448
|
+
temporaryPassword: z44.string()
|
|
7953
8449
|
}),
|
|
7954
8450
|
[TriggerEvent.TWO_FA]: BasePayload.extend({
|
|
7955
|
-
code:
|
|
8451
|
+
code: z44.string()
|
|
7956
8452
|
}),
|
|
7957
8453
|
[TriggerEvent.ALL_USER_NOTIFICATION]: BasePayload.extend({
|
|
7958
|
-
subject:
|
|
7959
|
-
body:
|
|
8454
|
+
subject: z44.string(),
|
|
8455
|
+
body: z44.string()
|
|
7960
8456
|
}),
|
|
7961
8457
|
[TriggerEvent.CHANGE_PHONE_NUMBER]: BasePayload.extend({
|
|
7962
|
-
code:
|
|
8458
|
+
code: z44.string()
|
|
7963
8459
|
}),
|
|
7964
8460
|
[TriggerEvent.CHANGE_EMAIL_ADDRESS]: BasePayload.extend({
|
|
7965
|
-
code:
|
|
8461
|
+
code: z44.string()
|
|
7966
8462
|
})
|
|
7967
8463
|
};
|
|
7968
8464
|
async function triggerUserEventNotification({
|
|
@@ -7986,4 +8482,4 @@ function parseUserEventTrigger(event2, body) {
|
|
|
7986
8482
|
}
|
|
7987
8483
|
|
|
7988
8484
|
// src/notification/index.ts
|
|
7989
|
-
|
|
8485
|
+
z45.globalRegistry.clear();
|