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