@opencrvs/toolkit 2.1.0-rc.fc582d7 → 2.1.0-rc.fd36a56
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 +189 -200
- package/dist/commons/api/router.d.ts +1 -1
- package/dist/commons/conditionals/conditionals.d.ts +3 -3
- package/dist/commons/conditionals/validate.d.ts +1 -10
- package/dist/commons/events/ActionConfig.d.ts +0 -21
- package/dist/commons/events/ActionDocument.d.ts +7 -1
- package/dist/commons/events/AdvancedSearchConfig.d.ts +0 -6
- package/dist/commons/events/CountryConfigQueryInput.d.ts +0 -18
- package/dist/commons/events/EventConfig.d.ts +0 -3
- package/dist/commons/events/EventIndex.d.ts +24 -5
- package/dist/commons/events/EventMetadata.d.ts +0 -1
- package/dist/commons/events/FieldConfig.d.ts +0 -5
- package/dist/commons/events/FieldTypeMapping.d.ts +27 -27
- package/dist/commons/events/Flag.d.ts +0 -48
- package/dist/commons/events/WorkqueueConfig.d.ts +14 -32
- package/dist/commons/events/event.d.ts +0 -12
- package/dist/conditionals/index.js +55 -303
- package/dist/events/index.js +2798 -2870
- package/dist/notification/index.js +1035 -1639
- package/dist/scopes/index.d.ts +0 -250
- package/dist/scopes/index.js +55 -304
- package/opencrvs-toolkit-2.1.0-rc.fd36a56.tgz +0 -0
- package/package.json +1 -1
- package/dist/commons/events/ActionStatus.d.ts +0 -14
- package/opencrvs-toolkit-2.1.0-rc.fc582d7.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,139 @@ 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:
|
|
1217
|
+
z14.object({
|
|
1218
|
+
type: z14.literal(ActionType.EDIT),
|
|
1296
1219
|
/** @deprecated New Edit-actions should no longer contain content. This is kept for old 2.0 edits. */
|
|
1297
|
-
content:
|
|
1298
|
-
comment:
|
|
1220
|
+
content: z14.object({
|
|
1221
|
+
comment: z14.string().describe("Comment for the edit action.").optional()
|
|
1299
1222
|
}).optional()
|
|
1300
1223
|
}).shape
|
|
1301
1224
|
);
|
|
1302
|
-
var PrintContent =
|
|
1303
|
-
templateId:
|
|
1225
|
+
var PrintContent = z14.object({
|
|
1226
|
+
templateId: z14.string().optional()
|
|
1304
1227
|
});
|
|
1305
1228
|
var PrintCertificateAction = ActionBase.extend(
|
|
1306
|
-
|
|
1307
|
-
type:
|
|
1229
|
+
z14.object({
|
|
1230
|
+
type: z14.literal(ActionType.PRINT_CERTIFICATE),
|
|
1308
1231
|
content: PrintContent.optional().nullable()
|
|
1309
1232
|
}).shape
|
|
1310
1233
|
);
|
|
1311
1234
|
var RequestedCorrectionAction = ActionBase.extend(
|
|
1312
|
-
|
|
1313
|
-
type:
|
|
1235
|
+
z14.object({
|
|
1236
|
+
type: z14.literal(ActionType.REQUEST_CORRECTION)
|
|
1314
1237
|
}).shape
|
|
1315
1238
|
);
|
|
1316
1239
|
var ApprovedCorrectionAction = ActionBase.extend(
|
|
1317
|
-
|
|
1318
|
-
type:
|
|
1319
|
-
requestId:
|
|
1240
|
+
z14.object({
|
|
1241
|
+
type: z14.literal(ActionType.APPROVE_CORRECTION),
|
|
1242
|
+
requestId: z14.string(),
|
|
1320
1243
|
// TODO move into 'content' property
|
|
1321
|
-
content:
|
|
1244
|
+
content: z14.object({ immediateCorrection: z14.boolean().optional() }).optional()
|
|
1322
1245
|
}).shape
|
|
1323
1246
|
);
|
|
1324
1247
|
var RejectedCorrectionAction = ActionBase.extend(
|
|
1325
|
-
|
|
1326
|
-
type:
|
|
1327
|
-
requestId:
|
|
1248
|
+
z14.object({
|
|
1249
|
+
type: z14.literal(ActionType.REJECT_CORRECTION),
|
|
1250
|
+
requestId: z14.string(),
|
|
1328
1251
|
// TODO move into 'content' property
|
|
1329
1252
|
content: ReasonContent
|
|
1330
1253
|
}).shape
|
|
1331
1254
|
);
|
|
1332
1255
|
var ReadAction = ActionBase.extend(
|
|
1333
|
-
|
|
1334
|
-
type:
|
|
1256
|
+
z14.object({
|
|
1257
|
+
type: z14.literal(ActionType.READ)
|
|
1335
1258
|
}).shape
|
|
1336
1259
|
);
|
|
1337
1260
|
var CustomAction = ActionBase.merge(
|
|
1338
|
-
|
|
1339
|
-
type:
|
|
1340
|
-
customActionType:
|
|
1261
|
+
z14.object({
|
|
1262
|
+
type: z14.literal(ActionType.CUSTOM),
|
|
1263
|
+
customActionType: z14.string()
|
|
1341
1264
|
})
|
|
1342
1265
|
);
|
|
1343
|
-
var ActionDocument =
|
|
1266
|
+
var ActionDocument = z14.discriminatedUnion("type", [
|
|
1344
1267
|
CreatedAction.meta({ id: "CreatedAction" }),
|
|
1345
1268
|
RejectAction.meta({ id: "RejectAction" }),
|
|
1346
1269
|
DuplicateDetectedAction.meta({ id: "DuplicateDetectedAction" }),
|
|
@@ -1367,12 +1290,64 @@ var AsyncRejectActionDocument = ActionBase.omit({
|
|
|
1367
1290
|
declaration: true,
|
|
1368
1291
|
annotation: true
|
|
1369
1292
|
}).extend(
|
|
1370
|
-
|
|
1371
|
-
type:
|
|
1372
|
-
status:
|
|
1293
|
+
z14.object({
|
|
1294
|
+
type: z14.enum(ConfirmableActions),
|
|
1295
|
+
status: z14.literal(ActionStatus.Rejected)
|
|
1373
1296
|
}).shape
|
|
1374
1297
|
);
|
|
1375
|
-
var Action =
|
|
1298
|
+
var Action = z14.union([ActionDocument, AsyncRejectActionDocument]);
|
|
1299
|
+
|
|
1300
|
+
// ../commons/src/events/Flag.ts
|
|
1301
|
+
var z15 = __toESM(require("zod/v4"));
|
|
1302
|
+
var InherentFlags = {
|
|
1303
|
+
INCOMPLETE: "incomplete",
|
|
1304
|
+
REJECTED: "rejected",
|
|
1305
|
+
CORRECTION_REQUESTED: "correction-requested",
|
|
1306
|
+
POTENTIAL_DUPLICATE: "potential-duplicate",
|
|
1307
|
+
/**
|
|
1308
|
+
* This flag is set by the Edit-action and removed after the declaration or registration.
|
|
1309
|
+
* A record should never stay with the EDIT_IN_PROGRESS flag, since it should always be declared or registered right after.
|
|
1310
|
+
*
|
|
1311
|
+
* We only use this flag to determine that a NOTIFY, DECLARE or REGISTER action is allowed next.
|
|
1312
|
+
*/
|
|
1313
|
+
EDIT_IN_PROGRESS: "edit-in-progress"
|
|
1314
|
+
};
|
|
1315
|
+
var ActionFlag = z15.string().regex(
|
|
1316
|
+
new RegExp(
|
|
1317
|
+
`^(${Object.values(ActionType).join("|").toLowerCase()}):(${Object.values(
|
|
1318
|
+
ActionStatus
|
|
1319
|
+
).join("|").toLowerCase()})$`
|
|
1320
|
+
),
|
|
1321
|
+
"Flag must be in the format ActionType:ActionStatus (lowerCase)"
|
|
1322
|
+
);
|
|
1323
|
+
var CustomFlag = z15.string().refine((val) => !Object.values(InherentFlags).includes(val), {
|
|
1324
|
+
message: `Custom flag cannot be one of the inherent flags: ${Object.values(
|
|
1325
|
+
InherentFlags
|
|
1326
|
+
).join(", ")}`
|
|
1327
|
+
}).refine((val) => !ActionFlag.safeParse(val).success, {
|
|
1328
|
+
message: "Custom flag cannot match the ActionFlag pattern (ActionType:ActionStatus)."
|
|
1329
|
+
}).describe("Custom flag identifier defined by the country config.");
|
|
1330
|
+
var Flag = ActionFlag.or(z15.enum(InherentFlags)).or(CustomFlag);
|
|
1331
|
+
var FlagConfig = z15.object({
|
|
1332
|
+
id: CustomFlag,
|
|
1333
|
+
requiresAction: z15.boolean().describe(
|
|
1334
|
+
"Indicates if this flag expects an action to be performed to be cleared."
|
|
1335
|
+
),
|
|
1336
|
+
label: TranslationConfig.describe("Human readable label of the flag.")
|
|
1337
|
+
}).meta({
|
|
1338
|
+
id: "FlagConfig",
|
|
1339
|
+
description: "Configuration for a custom flag that can be added to or removed from records by event actions."
|
|
1340
|
+
});
|
|
1341
|
+
var ActionFlagConfig = z15.object({
|
|
1342
|
+
id: Flag,
|
|
1343
|
+
operation: z15.enum(["add", "remove"]).describe("Operation to perform on the flag."),
|
|
1344
|
+
conditional: Conditional.optional().describe(
|
|
1345
|
+
"When conditional is met, the operation is performed on the flag. If not provided, the operation is performed unconditionally."
|
|
1346
|
+
)
|
|
1347
|
+
}).meta({
|
|
1348
|
+
id: "ActionFlagConfig",
|
|
1349
|
+
description: "Add or remove operation applied to a flag when the parent action is accepted. Optionally gated by a conditional."
|
|
1350
|
+
});
|
|
1376
1351
|
|
|
1377
1352
|
// ../commons/src/events/EventMetadata.ts
|
|
1378
1353
|
var EventStatus = z16.enum([
|
|
@@ -1530,6 +1505,13 @@ var Range = import_v4.z.object({
|
|
|
1530
1505
|
}).meta({
|
|
1531
1506
|
id: "Range"
|
|
1532
1507
|
});
|
|
1508
|
+
var ContainsFlags = import_v4.z.object({
|
|
1509
|
+
anyOf: import_v4.z.array(Flag).optional(),
|
|
1510
|
+
noneOf: import_v4.z.array(Flag).optional(),
|
|
1511
|
+
allOf: import_v4.z.array(Flag).optional()
|
|
1512
|
+
}).meta({
|
|
1513
|
+
id: "ContainsFlags"
|
|
1514
|
+
});
|
|
1533
1515
|
var Within = import_v4.z.object({ type: import_v4.z.literal("within"), location: import_v4.z.string() }).meta({
|
|
1534
1516
|
id: "Within"
|
|
1535
1517
|
});
|
|
@@ -3002,7 +2984,7 @@ var LanguageConfig = z26.object({
|
|
|
3002
2984
|
});
|
|
3003
2985
|
|
|
3004
2986
|
// ../commons/src/events/EventConfig.ts
|
|
3005
|
-
var
|
|
2987
|
+
var z33 = __toESM(require("zod/v4"));
|
|
3006
2988
|
|
|
3007
2989
|
// ../commons/src/events/SummaryConfig.ts
|
|
3008
2990
|
var z27 = __toESM(require("zod/v4"));
|
|
@@ -3162,145 +3144,162 @@ var AdvancedSearchConfig = z28.object({
|
|
|
3162
3144
|
description: "Configuration of one advanced search tab. Each tab has a title and a list of searchable fields \u2014 either declaration fields (via `field()`) or event metadata (via `event()`)."
|
|
3163
3145
|
});
|
|
3164
3146
|
|
|
3165
|
-
// ../commons/src/icons.ts
|
|
3166
|
-
var z29 = __toESM(require("zod/v4"));
|
|
3167
|
-
var AvailableIcons = z29.enum([
|
|
3168
|
-
"Archived",
|
|
3169
|
-
"Assigned",
|
|
3170
|
-
"Briefcase",
|
|
3171
|
-
"Certified",
|
|
3172
|
-
"Close",
|
|
3173
|
-
"Collapse",
|
|
3174
|
-
"Draft",
|
|
3175
|
-
"DuplicateYellow",
|
|
3176
|
-
"Expand",
|
|
3177
|
-
"ExternalValidate",
|
|
3178
|
-
"FilledCheck",
|
|
3179
|
-
"InReview",
|
|
3180
|
-
"Offline",
|
|
3181
|
-
"Registered",
|
|
3182
|
-
"RequiresUpdates",
|
|
3183
|
-
"Sent",
|
|
3184
|
-
"Validated",
|
|
3185
|
-
"WaitingApproval",
|
|
3186
|
-
"ChartActivity",
|
|
3187
|
-
"Activity",
|
|
3188
|
-
"Archive",
|
|
3189
|
-
"ArchiveTray",
|
|
3190
|
-
"ArrowLeft",
|
|
3191
|
-
"ArrowRight",
|
|
3192
|
-
"Buildings",
|
|
3193
|
-
"Circle",
|
|
3194
|
-
"CaretDown",
|
|
3195
|
-
"CaretLeft",
|
|
3196
|
-
"CaretRight",
|
|
3197
|
-
"ChartBar",
|
|
3198
|
-
"ChartLine",
|
|
3199
|
-
"ChatCircle",
|
|
3200
|
-
"CheckSquare",
|
|
3201
|
-
"Compass",
|
|
3202
|
-
"Check",
|
|
3203
|
-
"Copy",
|
|
3204
|
-
"Database",
|
|
3205
|
-
"DotsThreeVertical",
|
|
3206
|
-
"ArrowCounterClockwise",
|
|
3207
|
-
"MagnifyingGlassMinus",
|
|
3208
|
-
"MagnifyingGlassPlus",
|
|
3209
|
-
"Export",
|
|
3210
|
-
"Eye",
|
|
3211
|
-
"EyeSlash",
|
|
3212
|
-
"Envelope",
|
|
3213
|
-
"File",
|
|
3214
|
-
"FileLock",
|
|
3215
|
-
"FileSearch",
|
|
3216
|
-
"FileMinus",
|
|
3217
|
-
"FilePlus",
|
|
3218
|
-
"FileText",
|
|
3219
|
-
"FileX",
|
|
3220
|
-
"Handshake",
|
|
3221
|
-
"Gear",
|
|
3222
|
-
"GitBranch",
|
|
3223
|
-
"IdentificationCard",
|
|
3224
|
-
"List",
|
|
3225
|
-
"ListBullets",
|
|
3226
|
-
"Lock",
|
|
3227
|
-
"MagnifyingGlass",
|
|
3228
|
-
"MapPin",
|
|
3229
|
-
"Medal",
|
|
3230
|
-
"NotePencil",
|
|
3231
|
-
"Paperclip",
|
|
3232
|
-
"PaperPlaneTilt",
|
|
3233
|
-
"Pen",
|
|
3234
|
-
"PenNib",
|
|
3235
|
-
"Pencil",
|
|
3236
|
-
"PencilSimpleLine",
|
|
3237
|
-
"Phone",
|
|
3238
|
-
"Plus",
|
|
3239
|
-
"Printer",
|
|
3240
|
-
"SignOut",
|
|
3241
|
-
"Stamp",
|
|
3242
|
-
"Star",
|
|
3243
|
-
"Target",
|
|
3244
|
-
"TextT",
|
|
3245
|
-
"Trash",
|
|
3246
|
-
"UploadSimple",
|
|
3247
|
-
"User",
|
|
3248
|
-
"UserPlus",
|
|
3249
|
-
"Users",
|
|
3250
|
-
"WarningCircle",
|
|
3251
|
-
"X",
|
|
3252
|
-
"ChatText",
|
|
3253
|
-
"CircleWavyCheck",
|
|
3254
|
-
"CircleWavyQuestion",
|
|
3255
|
-
"ArchiveBox",
|
|
3256
|
-
"ArrowCircleDown",
|
|
3257
|
-
"FileArrowUp",
|
|
3258
|
-
"FileDotted",
|
|
3259
|
-
"Files",
|
|
3260
|
-
"PencilLine",
|
|
3261
|
-
"PencilCircle",
|
|
3262
|
-
"UserCircle",
|
|
3263
|
-
"Clock",
|
|
3264
|
-
"QrCode",
|
|
3265
|
-
"Webcam",
|
|
3266
|
-
"Sun",
|
|
3267
|
-
"DeviceTabletCamera",
|
|
3268
|
-
"Globe",
|
|
3269
|
-
"Fingerprint",
|
|
3270
|
-
"PushPin",
|
|
3271
|
-
"Timer"
|
|
3272
|
-
]);
|
|
3273
|
-
|
|
3274
3147
|
// ../commons/src/events/utils.ts
|
|
3275
|
-
var
|
|
3148
|
+
var import_lodash = require("lodash");
|
|
3276
3149
|
|
|
3277
3150
|
// ../commons/src/conditionals/validate.ts
|
|
3278
3151
|
var import__ = __toESM(require("ajv/dist/2019"));
|
|
3279
3152
|
var import_ajv_formats = __toESM(require("ajv-formats"));
|
|
3280
|
-
var
|
|
3281
|
-
var
|
|
3153
|
+
var z31 = __toESM(require("zod/v4"));
|
|
3154
|
+
var import_date_fns = require("date-fns");
|
|
3282
3155
|
|
|
3283
3156
|
// ../commons/src/events/FieldTypeMapping.ts
|
|
3284
|
-
var
|
|
3157
|
+
var z30 = __toESM(require("zod/v4"));
|
|
3285
3158
|
|
|
3286
3159
|
// ../commons/src/events/DynamicFieldValue.ts
|
|
3287
|
-
var
|
|
3160
|
+
var z29 = __toESM(require("zod/v4"));
|
|
3288
3161
|
|
|
3289
|
-
// ../commons/src/
|
|
3290
|
-
var
|
|
3162
|
+
// ../commons/src/conditionals/validate.ts
|
|
3163
|
+
var ajv = new import__.default({
|
|
3164
|
+
$data: true,
|
|
3165
|
+
allowUnionTypes: true,
|
|
3166
|
+
strict: false
|
|
3167
|
+
// Allow minContains and other newer features
|
|
3168
|
+
});
|
|
3169
|
+
var DataContext = z31.object({
|
|
3170
|
+
rootData: z31.object({
|
|
3171
|
+
$leafAdminStructureLocationIds: z31.array(z31.object({ id: UUID }))
|
|
3172
|
+
})
|
|
3173
|
+
});
|
|
3174
|
+
function resolveDataPath(rootData, dataPath, instancePath) {
|
|
3175
|
+
const pathParts = dataPath.split("/");
|
|
3176
|
+
const levels = parseInt(pathParts[0], 10);
|
|
3177
|
+
const referencePath = pathParts.slice(1);
|
|
3178
|
+
const instanceParts = instancePath.split("/").filter(Boolean);
|
|
3179
|
+
const traversedParts = instanceParts.slice(0, -levels);
|
|
3180
|
+
let current = rootData;
|
|
3181
|
+
for (const part of traversedParts) {
|
|
3182
|
+
if (current === null || current === void 0) {
|
|
3183
|
+
return void 0;
|
|
3184
|
+
}
|
|
3185
|
+
current = current[part];
|
|
3186
|
+
}
|
|
3187
|
+
for (const part of referencePath) {
|
|
3188
|
+
if (current === null || current === void 0) {
|
|
3189
|
+
return void 0;
|
|
3190
|
+
}
|
|
3191
|
+
current = current[part];
|
|
3192
|
+
}
|
|
3193
|
+
return current;
|
|
3194
|
+
}
|
|
3195
|
+
function todayISO() {
|
|
3196
|
+
return (0, import_date_fns.formatISO)(/* @__PURE__ */ new Date(), { representation: "date" });
|
|
3197
|
+
}
|
|
3198
|
+
var compiledFunctionCache = /* @__PURE__ */ new Map();
|
|
3199
|
+
function compileClientFunction(code) {
|
|
3200
|
+
let fn = compiledFunctionCache.get(code);
|
|
3201
|
+
if (!fn) {
|
|
3202
|
+
fn = new Function(`return (${code})`)();
|
|
3203
|
+
compiledFunctionCache.set(code, fn);
|
|
3204
|
+
}
|
|
3205
|
+
return fn;
|
|
3206
|
+
}
|
|
3207
|
+
(0, import_ajv_formats.default)(ajv);
|
|
3208
|
+
function buildClientFunctionContext(input) {
|
|
3209
|
+
return {
|
|
3210
|
+
$form: input.form,
|
|
3211
|
+
$now: todayISO(),
|
|
3212
|
+
// eslint-disable-next-line @typescript-eslint/no-use-before-define
|
|
3213
|
+
$online: isOnline(),
|
|
3214
|
+
$user: input.validatorContext?.user,
|
|
3215
|
+
$event: input.validatorContext?.event,
|
|
3216
|
+
$leafAdminStructureLocationIds: input.validatorContext?.leafAdminStructureLocationIds ?? [],
|
|
3217
|
+
user: input.systemVariables?.user,
|
|
3218
|
+
$window: input.systemVariables?.$window,
|
|
3219
|
+
locations: input.locations,
|
|
3220
|
+
adminLevelIds: input.adminLevelIds
|
|
3221
|
+
};
|
|
3222
|
+
}
|
|
3223
|
+
function runClientFunction(code, data, context) {
|
|
3224
|
+
return compileClientFunction(code)(data, context);
|
|
3225
|
+
}
|
|
3226
|
+
ajv.addKeyword({
|
|
3227
|
+
keyword: "daysFromDate",
|
|
3228
|
+
type: "string",
|
|
3229
|
+
schemaType: "object",
|
|
3230
|
+
$data: true,
|
|
3231
|
+
errors: true,
|
|
3232
|
+
validate(schema, data, _2, dataContext) {
|
|
3233
|
+
if (!(dataContext && dataContext.rootData && typeof dataContext.rootData === "object" && "$now" in dataContext.rootData && typeof dataContext.rootData.$now === "string")) {
|
|
3234
|
+
throw new Error("Validation context must contain $now");
|
|
3235
|
+
}
|
|
3236
|
+
const { days, clause } = schema;
|
|
3237
|
+
if (typeof data !== "string") {
|
|
3238
|
+
return false;
|
|
3239
|
+
}
|
|
3240
|
+
const date = new Date(data);
|
|
3241
|
+
if (isNaN(date.getTime())) {
|
|
3242
|
+
return false;
|
|
3243
|
+
}
|
|
3244
|
+
let referenceDate = schema.referenceDate;
|
|
3245
|
+
if (referenceDate && typeof referenceDate === "object" && "$data" in referenceDate) {
|
|
3246
|
+
referenceDate = resolveDataPath(
|
|
3247
|
+
dataContext.rootData,
|
|
3248
|
+
referenceDate.$data,
|
|
3249
|
+
dataContext.instancePath
|
|
3250
|
+
);
|
|
3251
|
+
}
|
|
3252
|
+
if (!referenceDate) {
|
|
3253
|
+
referenceDate = dataContext.rootData.$now;
|
|
3254
|
+
}
|
|
3255
|
+
const baseDate = new Date(referenceDate);
|
|
3256
|
+
if (isNaN(baseDate.getTime())) {
|
|
3257
|
+
return false;
|
|
3258
|
+
}
|
|
3259
|
+
const offsetDate = new Date(baseDate.getTime() + days * 24 * 60 * 60 * 1e3);
|
|
3260
|
+
return clause === "after" ? (0, import_date_fns.isAfter)(date, offsetDate) : (0, import_date_fns.isBefore)(date, offsetDate);
|
|
3261
|
+
}
|
|
3262
|
+
});
|
|
3263
|
+
ajv.addKeyword({
|
|
3264
|
+
keyword: "isLeafLevelLocation",
|
|
3265
|
+
type: "string",
|
|
3266
|
+
schemaType: "boolean",
|
|
3267
|
+
$data: true,
|
|
3268
|
+
errors: true,
|
|
3269
|
+
// @ts-ignore -- Force type. We will move this away from AJV next. Parsing the array will take seconds and is only called by core.
|
|
3270
|
+
validate(_schema, data, _2, dataContext) {
|
|
3271
|
+
const locationIdInput = data;
|
|
3272
|
+
const locations = dataContext?.rootData.$leafAdminStructureLocationIds ?? [];
|
|
3273
|
+
return locations.some((location) => location.id === locationIdInput);
|
|
3274
|
+
}
|
|
3275
|
+
});
|
|
3276
|
+
ajv.addKeyword({
|
|
3277
|
+
keyword: "customClientValidator",
|
|
3278
|
+
schemaType: "object",
|
|
3279
|
+
errors: true,
|
|
3280
|
+
// @ts-expect-error -- AJV's public types don't expose `rootData`. All
|
|
3281
|
+
// `validate()` callers build root data via `buildClientFunctionContext`,
|
|
3282
|
+
// so the cast holds.
|
|
3283
|
+
validate(schema, data, _2, dataContext) {
|
|
3284
|
+
return Boolean(
|
|
3285
|
+
runClientFunction(
|
|
3286
|
+
schema.code,
|
|
3287
|
+
data,
|
|
3288
|
+
dataContext?.rootData ?? buildClientFunctionContext({ form: {} })
|
|
3289
|
+
)
|
|
3290
|
+
);
|
|
3291
|
+
}
|
|
3292
|
+
});
|
|
3293
|
+
function isOnline() {
|
|
3294
|
+
if (typeof window !== "undefined" && typeof navigator !== "undefined") {
|
|
3295
|
+
return navigator.onLine;
|
|
3296
|
+
}
|
|
3297
|
+
return true;
|
|
3298
|
+
}
|
|
3291
3299
|
|
|
3292
3300
|
// ../commons/src/utils.ts
|
|
3293
3301
|
var z32 = __toESM(require("zod/v4"));
|
|
3294
3302
|
var _ = __toESM(require("lodash"));
|
|
3295
|
-
function getOrThrow(x, message) {
|
|
3296
|
-
if (x === void 0 || x === null) {
|
|
3297
|
-
throw new Error(message);
|
|
3298
|
-
}
|
|
3299
|
-
return x;
|
|
3300
|
-
}
|
|
3301
|
-
function joinValues(values, separator = " ") {
|
|
3302
|
-
return values.filter((value) => !!value).join(separator).trim();
|
|
3303
|
-
}
|
|
3304
3303
|
var FullNameV1 = z32.array(
|
|
3305
3304
|
z32.object({
|
|
3306
3305
|
use: z32.string(),
|
|
@@ -3324,262 +3323,36 @@ function omitKeyDeep(obj, keyToRemove) {
|
|
|
3324
3323
|
return newObj;
|
|
3325
3324
|
}
|
|
3326
3325
|
|
|
3327
|
-
// ../commons/src/events/
|
|
3328
|
-
var
|
|
3329
|
-
function
|
|
3330
|
-
|
|
3331
|
-
const accept = filtered.find(
|
|
3332
|
-
(action) => action.status === ActionStatus.Accepted
|
|
3333
|
-
);
|
|
3334
|
-
const request = filtered.find(
|
|
3335
|
-
(action) => action.status === ActionStatus.Requested
|
|
3336
|
-
);
|
|
3337
|
-
const reject = filtered.find(
|
|
3338
|
-
(action) => action.status === ActionStatus.Rejected
|
|
3339
|
-
);
|
|
3340
|
-
return {
|
|
3341
|
-
reject,
|
|
3342
|
-
accept,
|
|
3343
|
-
request
|
|
3344
|
-
};
|
|
3345
|
-
}
|
|
3346
|
-
function getDeclarationActionCreationMetadata(actionType, actions) {
|
|
3347
|
-
const { accept: acceptAction, request: requestAction } = getActionRequests(
|
|
3348
|
-
actionType,
|
|
3349
|
-
actions
|
|
3350
|
-
);
|
|
3351
|
-
if (!acceptAction) {
|
|
3352
|
-
return null;
|
|
3353
|
-
}
|
|
3354
|
-
const registrationNumber = acceptAction.type === ActionType.REGISTER ? acceptAction.registrationNumber : null;
|
|
3355
|
-
return {
|
|
3356
|
-
// When 3rd party API returns 200 OK, we assume that the request was accepted, and persist single 'accepted' action.
|
|
3357
|
-
createdAt: requestAction?.createdAt ?? acceptAction.createdAt,
|
|
3358
|
-
createdBy: requestAction?.createdBy ?? acceptAction.createdBy,
|
|
3359
|
-
createdByUserType: requestAction?.createdByUserType ?? acceptAction.createdByUserType,
|
|
3360
|
-
createdAtLocation: requestAction?.createdAtLocation ?? acceptAction.createdAtLocation,
|
|
3361
|
-
acceptedAt: acceptAction.createdAt,
|
|
3362
|
-
createdByRole: requestAction?.createdByRole ?? acceptAction.createdByRole,
|
|
3363
|
-
registrationNumber
|
|
3364
|
-
};
|
|
3365
|
-
}
|
|
3366
|
-
var updateActions = ActionTypes.extract([
|
|
3367
|
-
ActionType.CREATE,
|
|
3368
|
-
ActionType.NOTIFY,
|
|
3369
|
-
ActionType.EDIT,
|
|
3370
|
-
ActionType.DECLARE,
|
|
3371
|
-
ActionType.REGISTER,
|
|
3372
|
-
ActionType.REJECT,
|
|
3373
|
-
ActionType.ARCHIVE,
|
|
3374
|
-
ActionType.UNARCHIVE,
|
|
3375
|
-
ActionType.PRINT_CERTIFICATE,
|
|
3376
|
-
ActionType.REQUEST_CORRECTION,
|
|
3377
|
-
ActionType.APPROVE_CORRECTION,
|
|
3378
|
-
ActionType.REJECT_CORRECTION,
|
|
3379
|
-
ActionType.CUSTOM
|
|
3380
|
-
]);
|
|
3381
|
-
function getActionUpdateMetadata(actions) {
|
|
3382
|
-
const createAction = getOrThrow(
|
|
3383
|
-
actions.find((action) => action.type === ActionType.CREATE),
|
|
3384
|
-
`Event has no ${ActionType.CREATE} action`
|
|
3385
|
-
);
|
|
3386
|
-
const metadataFields = [
|
|
3387
|
-
"createdAt",
|
|
3388
|
-
"createdBy",
|
|
3389
|
-
"createdByUserType",
|
|
3390
|
-
"createdAtLocation",
|
|
3391
|
-
"createdByRole"
|
|
3392
|
-
];
|
|
3393
|
-
return actions.filter(({ type }) => updateActions.safeParse(type).success).reduce(
|
|
3394
|
-
(_2, action) => {
|
|
3395
|
-
if (action.originalActionId) {
|
|
3396
|
-
const originalAction = actions.find(({ id }) => id === action.originalActionId) ?? action;
|
|
3397
|
-
return (0, import_lodash.pick)(originalAction, metadataFields);
|
|
3398
|
-
}
|
|
3399
|
-
return (0, import_lodash.pick)(action, metadataFields);
|
|
3400
|
-
},
|
|
3401
|
-
(0, import_lodash.pick)(createAction, metadataFields)
|
|
3402
|
-
);
|
|
3403
|
-
}
|
|
3404
|
-
function getLegalStatuses(actions) {
|
|
3405
|
-
return {
|
|
3406
|
-
[EventStatus.enum.NOTIFIED]: getDeclarationActionCreationMetadata(
|
|
3407
|
-
ActionType.NOTIFY,
|
|
3408
|
-
actions
|
|
3409
|
-
),
|
|
3410
|
-
[EventStatus.enum.DECLARED]: getDeclarationActionCreationMetadata(
|
|
3411
|
-
ActionType.DECLARE,
|
|
3412
|
-
actions
|
|
3413
|
-
),
|
|
3414
|
-
[EventStatus.enum.REGISTERED]: getDeclarationActionCreationMetadata(
|
|
3415
|
-
ActionType.REGISTER,
|
|
3416
|
-
actions
|
|
3417
|
-
)
|
|
3418
|
-
};
|
|
3419
|
-
}
|
|
3420
|
-
|
|
3421
|
-
// ../commons/src/events/state/flags.ts
|
|
3422
|
-
var import_lodash2 = require("lodash");
|
|
3423
|
-
var import_date_fns = require("date-fns");
|
|
3424
|
-
function isFlagConditionMet(conditional, form, action) {
|
|
3425
|
-
const now2 = (0, import_date_fns.isValid)((0, import_date_fns.parseISO)(action.createdAt)) ? (0, import_date_fns.formatISO)((0, import_date_fns.parseISO)(action.createdAt), { representation: "date" }) : (0, import_date_fns.formatISO)(/* @__PURE__ */ new Date(), { representation: "date" });
|
|
3426
|
-
return validate(conditional, {
|
|
3427
|
-
$form: form,
|
|
3428
|
-
$now: now2,
|
|
3429
|
-
$online: true,
|
|
3430
|
-
$user: {
|
|
3431
|
-
sub: "",
|
|
3432
|
-
exp: "",
|
|
3433
|
-
role: action.createdByRole,
|
|
3434
|
-
algorithm: "",
|
|
3435
|
-
scope: [],
|
|
3436
|
-
userType: action.createdByUserType
|
|
3437
|
-
}
|
|
3438
|
-
});
|
|
3326
|
+
// ../commons/src/events/utils.ts
|
|
3327
|
+
var import_date_fns2 = require("date-fns");
|
|
3328
|
+
function getDeclarationFields(configuration) {
|
|
3329
|
+
return configuration.declaration.pages.flatMap(({ fields }) => fields);
|
|
3439
3330
|
}
|
|
3440
|
-
|
|
3441
|
-
if (
|
|
3442
|
-
return
|
|
3331
|
+
var getActionAnnotationFields = (actionConfig) => {
|
|
3332
|
+
if (actionConfig.type === ActionType.REQUEST_CORRECTION) {
|
|
3333
|
+
return actionConfig.correctionForm.pages.flatMap(({ fields }) => fields);
|
|
3443
3334
|
}
|
|
3444
|
-
|
|
3445
|
-
|
|
3446
|
-
actionType: action.type,
|
|
3447
|
-
customActionType: "customActionType" in action ? action.customActionType : void 0
|
|
3448
|
-
});
|
|
3449
|
-
const removeOperations = (actionConfig?.flags ?? []).filter(
|
|
3450
|
-
({ id, operation }) => id === flagId && operation === "remove"
|
|
3451
|
-
);
|
|
3452
|
-
if (removeOperations.length === 0) {
|
|
3453
|
-
return false;
|
|
3335
|
+
if (actionConfig.type === ActionType.PRINT_CERTIFICATE) {
|
|
3336
|
+
return actionConfig.printForm.pages.flatMap(({ fields }) => fields);
|
|
3454
3337
|
}
|
|
3455
|
-
const
|
|
3456
|
-
const
|
|
3457
|
-
|
|
3458
|
-
|
|
3459
|
-
|
|
3460
|
-
|
|
3461
|
-
);
|
|
3338
|
+
const reviewFields = "review" in actionConfig && actionConfig.review != null ? actionConfig.review.fields : [];
|
|
3339
|
+
const formFields = "form" in actionConfig && actionConfig.form != null ? actionConfig.form : [];
|
|
3340
|
+
return [...reviewFields, ...formFields];
|
|
3341
|
+
};
|
|
3342
|
+
function getAllAnnotationFields(config) {
|
|
3343
|
+
return (0, import_lodash.flattenDeep)(config.actions.map(getActionAnnotationFields));
|
|
3462
3344
|
}
|
|
3463
|
-
var
|
|
3464
|
-
|
|
3465
|
-
|
|
3466
|
-
|
|
3467
|
-
|
|
3468
|
-
|
|
3469
|
-
|
|
3470
|
-
|
|
3471
|
-
|
|
3472
|
-
|
|
3473
|
-
// round trip and comes back exactly as it was.
|
|
3474
|
-
flag: InherentFlags.INCOMPLETE,
|
|
3475
|
-
setOn: [ActionType.NOTIFY],
|
|
3476
|
-
resetOn: [ActionType.CREATE, ActionType.DECLARE, ActionType.REGISTER]
|
|
3477
|
-
},
|
|
3478
|
-
{
|
|
3479
|
-
flag: InherentFlags.REJECTED,
|
|
3480
|
-
setOn: [ActionType.REJECT],
|
|
3481
|
-
resetOn: [
|
|
3482
|
-
ActionType.NOTIFY,
|
|
3483
|
-
ActionType.DECLARE,
|
|
3484
|
-
ActionType.EDIT,
|
|
3485
|
-
ActionType.REGISTER
|
|
3486
|
-
]
|
|
3487
|
-
},
|
|
3488
|
-
{
|
|
3489
|
-
flag: InherentFlags.POTENTIAL_DUPLICATE,
|
|
3490
|
-
setOn: [ActionType.DUPLICATE_DETECTED],
|
|
3491
|
-
resetOn: [ActionType.MARK_AS_DUPLICATE, ActionType.MARK_AS_NOT_DUPLICATE]
|
|
3492
|
-
},
|
|
3493
|
-
{
|
|
3494
|
-
flag: InherentFlags.EDIT_IN_PROGRESS,
|
|
3495
|
-
setOn: [ActionType.EDIT],
|
|
3496
|
-
resetOnAnyOtherAction: true
|
|
3497
|
-
}
|
|
3345
|
+
var findAllFields = (config) => {
|
|
3346
|
+
return (0, import_lodash.flattenDeep)([
|
|
3347
|
+
...getDeclarationFields(config),
|
|
3348
|
+
...getAllAnnotationFields(config)
|
|
3349
|
+
]);
|
|
3350
|
+
};
|
|
3351
|
+
var EXCLUDED_ACTIONS = [
|
|
3352
|
+
ActionType.REQUEST_CORRECTION,
|
|
3353
|
+
ActionType.PRINT_CERTIFICATE,
|
|
3354
|
+
ActionType.REJECT_CORRECTION
|
|
3498
3355
|
];
|
|
3499
|
-
function resolveInherentFlag(rule, acceptedActions, event2, eventConfiguration) {
|
|
3500
|
-
return acceptedActions.reduce((present, action, idx) => {
|
|
3501
|
-
if (rule.setOn.includes(action.type)) {
|
|
3502
|
-
return true;
|
|
3503
|
-
}
|
|
3504
|
-
if (rule.resetOnAnyOtherAction || (rule.resetOn ?? []).includes(action.type)) {
|
|
3505
|
-
return false;
|
|
3506
|
-
}
|
|
3507
|
-
if (actionConfigRemovesFlag(
|
|
3508
|
-
action,
|
|
3509
|
-
rule.flag,
|
|
3510
|
-
acceptedActions.slice(0, idx + 1),
|
|
3511
|
-
event2,
|
|
3512
|
-
eventConfiguration
|
|
3513
|
-
)) {
|
|
3514
|
-
return false;
|
|
3515
|
-
}
|
|
3516
|
-
return present;
|
|
3517
|
-
}, false);
|
|
3518
|
-
}
|
|
3519
|
-
function resolveEventCustomFlags(event2, eventConfiguration) {
|
|
3520
|
-
const actions = getAcceptedActions(event2).filter(({ type }) => !isMetaAction(type)).sort((a, b) => a.createdAt.localeCompare(b.createdAt));
|
|
3521
|
-
return actions.reduce((acc, action, idx) => {
|
|
3522
|
-
let actionConfig;
|
|
3523
|
-
if (isActionConfigType(action.type)) {
|
|
3524
|
-
actionConfig = getActionConfig({
|
|
3525
|
-
eventConfiguration,
|
|
3526
|
-
actionType: action.type,
|
|
3527
|
-
customActionType: "customActionType" in action ? action.customActionType : void 0
|
|
3528
|
-
});
|
|
3529
|
-
}
|
|
3530
|
-
if (!actionConfig) {
|
|
3531
|
-
return acc;
|
|
3532
|
-
}
|
|
3533
|
-
const eventUpToThisAction = {
|
|
3534
|
-
...event2,
|
|
3535
|
-
actions: actions.slice(0, idx + 1)
|
|
3536
|
-
};
|
|
3537
|
-
const declaration = aggregateActionDeclarations(eventUpToThisAction);
|
|
3538
|
-
const annotation = aggregateActionAnnotations(eventUpToThisAction);
|
|
3539
|
-
const form = { ...declaration, ...annotation };
|
|
3540
|
-
const flagsWithMetConditions = (actionConfig.flags ?? []).filter(
|
|
3541
|
-
({ conditional }) => (
|
|
3542
|
-
// If conditional is not provided, the flag is resolved
|
|
3543
|
-
conditional ? isFlagConditionMet(conditional, form, action) : true
|
|
3544
|
-
)
|
|
3545
|
-
);
|
|
3546
|
-
const addedFlags = flagsWithMetConditions.filter(({ operation }) => operation === "add").map(({ id }) => id);
|
|
3547
|
-
const removedFlags = flagsWithMetConditions.filter(({ operation }) => operation === "remove").map(({ id }) => id);
|
|
3548
|
-
const flags = [...acc, ...addedFlags].filter(
|
|
3549
|
-
(flagId) => !removedFlags.includes(flagId)
|
|
3550
|
-
);
|
|
3551
|
-
return (0, import_lodash2.uniq)(flags);
|
|
3552
|
-
}, []);
|
|
3553
|
-
}
|
|
3554
|
-
function getActionStatusFlags(sortedActions) {
|
|
3555
|
-
const actionStatus = sortedActions.reduce(
|
|
3556
|
-
(actionStatuses, { type, status: status2 }) => ({
|
|
3557
|
-
...actionStatuses,
|
|
3558
|
-
[type]: status2
|
|
3559
|
-
}),
|
|
3560
|
-
{}
|
|
3561
|
-
);
|
|
3562
|
-
return Object.entries(actionStatus).filter(([, status2]) => status2 !== ActionStatus.Accepted).map(([type, status2]) => {
|
|
3563
|
-
const flag2 = joinValues([type, status2], ":").toLowerCase();
|
|
3564
|
-
return flag2;
|
|
3565
|
-
});
|
|
3566
|
-
}
|
|
3567
|
-
function getInherentFlags(sortedActions, event2, eventConfiguration) {
|
|
3568
|
-
const acceptedActions = sortedActions.filter(
|
|
3569
|
-
({ status: status2 }) => status2 === ActionStatus.Accepted
|
|
3570
|
-
);
|
|
3571
|
-
return INHERENT_FLAG_RULES.filter(
|
|
3572
|
-
(rule) => resolveInherentFlag(rule, acceptedActions, event2, eventConfiguration)
|
|
3573
|
-
).map(({ flag: flag2 }) => flag2);
|
|
3574
|
-
}
|
|
3575
|
-
function getEventFlags(event2, config) {
|
|
3576
|
-
const sortedActions = event2.actions.filter(({ type }) => !isMetaAction(type)).sort((a, b) => a.createdAt.localeCompare(b.createdAt));
|
|
3577
|
-
return [
|
|
3578
|
-
...getActionStatusFlags(sortedActions),
|
|
3579
|
-
...getInherentFlags(sortedActions, event2, config),
|
|
3580
|
-
...resolveEventCustomFlags(event2, config)
|
|
3581
|
-
];
|
|
3582
|
-
}
|
|
3583
3356
|
|
|
3584
3357
|
// ../commons/src/conditionals/conditionals.ts
|
|
3585
3358
|
var objectHash = __toESM(require("object-hash"));
|
|
@@ -3787,33 +3560,6 @@ function defineComparison(field3, value, keyword) {
|
|
|
3787
3560
|
required: [field3.$$field]
|
|
3788
3561
|
});
|
|
3789
3562
|
}
|
|
3790
|
-
function flag(flagvalue) {
|
|
3791
|
-
return defineConditional({
|
|
3792
|
-
type: "object",
|
|
3793
|
-
properties: {
|
|
3794
|
-
$flags: {
|
|
3795
|
-
type: "array",
|
|
3796
|
-
contains: {
|
|
3797
|
-
type: "string",
|
|
3798
|
-
const: flagvalue
|
|
3799
|
-
}
|
|
3800
|
-
}
|
|
3801
|
-
},
|
|
3802
|
-
required: ["$flags"]
|
|
3803
|
-
});
|
|
3804
|
-
}
|
|
3805
|
-
function status(statusValue) {
|
|
3806
|
-
return defineConditional({
|
|
3807
|
-
type: "object",
|
|
3808
|
-
properties: {
|
|
3809
|
-
$status: {
|
|
3810
|
-
type: "string",
|
|
3811
|
-
const: statusValue
|
|
3812
|
-
}
|
|
3813
|
-
},
|
|
3814
|
-
required: ["$status"]
|
|
3815
|
-
});
|
|
3816
|
-
}
|
|
3817
3563
|
function createFieldConditionals(fieldId) {
|
|
3818
3564
|
const getDayRange = (field3, days, clause, referenceDate) => ({
|
|
3819
3565
|
type: "object",
|
|
@@ -4158,567 +3904,61 @@ function createFieldConditionals(fieldId) {
|
|
|
4158
3904
|
properties: Object.fromEntries(
|
|
4159
3905
|
Object.entries(options).map(([key, value]) => {
|
|
4160
3906
|
return [key, value.properties.$form.properties[key]];
|
|
4161
|
-
})
|
|
4162
|
-
),
|
|
4163
|
-
required: Object.keys(options)
|
|
4164
|
-
}
|
|
4165
|
-
},
|
|
4166
|
-
required: [fieldId]
|
|
4167
|
-
}),
|
|
4168
|
-
/**
|
|
4169
|
-
* Custom client-side validator. The provided function is serialised and executed
|
|
4170
|
-
* just-in-time on the client only. External references (e.g. lodash) are not
|
|
4171
|
-
* available inside the function body — all logic must be self-contained.
|
|
4172
|
-
*
|
|
4173
|
-
* @example
|
|
4174
|
-
* field('nid').customClientValidator((value) => {
|
|
4175
|
-
* // LUHN check — all logic must be inline
|
|
4176
|
-
* const digits = String(value).split('').map(Number)
|
|
4177
|
-
* // ...
|
|
4178
|
-
* return isValid
|
|
4179
|
-
* })
|
|
4180
|
-
*/
|
|
4181
|
-
customClientValidator(validationFn) {
|
|
4182
|
-
const code = validationFn.toString();
|
|
4183
|
-
return defineFormConditional({
|
|
4184
|
-
type: "object",
|
|
4185
|
-
properties: wrapToPath(
|
|
4186
|
-
{ [fieldId]: { customClientValidator: { code } } },
|
|
4187
|
-
this.$$subfield
|
|
4188
|
-
),
|
|
4189
|
-
required: [fieldId]
|
|
4190
|
-
});
|
|
4191
|
-
},
|
|
4192
|
-
/**
|
|
4193
|
-
* Custom client-side evaluation. Returns a {@link FieldReference} descriptor
|
|
4194
|
-
* that can be used as the `value` property or a DATA component entry.
|
|
4195
|
-
* The function receives the referenced field's value as the first argument and
|
|
4196
|
-
* the full form context as the second; its return value replaces the field reference.
|
|
4197
|
-
* The function is serialised and executed just-in-time on the client only.
|
|
4198
|
-
* External references (e.g. lodash) are not available inside the function body.
|
|
4199
|
-
*
|
|
4200
|
-
* For computing a default value without referencing a specific field, use
|
|
4201
|
-
* `evaluate(fn)` in the `defaultValue` property instead.
|
|
4202
|
-
*
|
|
4203
|
-
* @example
|
|
4204
|
-
* field('a').customClientEvaluation((aValue, ctx) =>
|
|
4205
|
-
* Number(aValue) + Number(ctx.$form.b)
|
|
4206
|
-
* )
|
|
4207
|
-
*/
|
|
4208
|
-
customClientEvaluation(computationFn) {
|
|
4209
|
-
return {
|
|
4210
|
-
$$code: computationFn.toString(),
|
|
4211
|
-
$$field: fieldId,
|
|
4212
|
-
$$subfield: this.$$subfield
|
|
4213
|
-
};
|
|
4214
|
-
}
|
|
4215
|
-
};
|
|
4216
|
-
}
|
|
4217
|
-
|
|
4218
|
-
// ../commons/src/events/state/index.ts
|
|
4219
|
-
function getStatusFromActions(actions) {
|
|
4220
|
-
const acceptedActions = actions.filter(
|
|
4221
|
-
({ status: status2 }) => status2 === ActionStatus.Accepted
|
|
4222
|
-
);
|
|
4223
|
-
const isCurrentlyArchived = acceptedActions.reduce(
|
|
4224
|
-
(archived, action) => {
|
|
4225
|
-
if (action.type === ActionType.ARCHIVE) {
|
|
4226
|
-
return true;
|
|
4227
|
-
}
|
|
4228
|
-
if (action.type === ActionType.UNARCHIVE) {
|
|
4229
|
-
return false;
|
|
4230
|
-
}
|
|
4231
|
-
return archived;
|
|
4232
|
-
},
|
|
4233
|
-
false
|
|
4234
|
-
);
|
|
4235
|
-
if (isCurrentlyArchived) {
|
|
4236
|
-
return EventStatus.enum.ARCHIVED;
|
|
4237
|
-
}
|
|
4238
|
-
return acceptedActions.filter(
|
|
4239
|
-
({ type }) => type !== ActionType.ARCHIVE && type !== ActionType.UNARCHIVE
|
|
4240
|
-
).reduce((status2, action) => {
|
|
4241
|
-
switch (action.type) {
|
|
4242
|
-
case ActionType.CREATE:
|
|
4243
|
-
return EventStatus.enum.CREATED;
|
|
4244
|
-
case ActionType.DECLARE:
|
|
4245
|
-
return EventStatus.enum.DECLARED;
|
|
4246
|
-
case ActionType.REGISTER:
|
|
4247
|
-
return EventStatus.enum.REGISTERED;
|
|
4248
|
-
case ActionType.NOTIFY:
|
|
4249
|
-
return EventStatus.enum.NOTIFIED;
|
|
4250
|
-
// Already filtered out above; listed here only to satisfy exhaustiveness.
|
|
4251
|
-
case ActionType.ARCHIVE:
|
|
4252
|
-
case ActionType.UNARCHIVE:
|
|
4253
|
-
case ActionType.CUSTOM:
|
|
4254
|
-
case ActionType.PRINT_CERTIFICATE:
|
|
4255
|
-
case ActionType.ASSIGN:
|
|
4256
|
-
case ActionType.UNASSIGN:
|
|
4257
|
-
case ActionType.REJECT:
|
|
4258
|
-
case ActionType.REQUEST_CORRECTION:
|
|
4259
|
-
case ActionType.APPROVE_CORRECTION:
|
|
4260
|
-
case ActionType.DUPLICATE_DETECTED:
|
|
4261
|
-
case ActionType.MARK_AS_NOT_DUPLICATE:
|
|
4262
|
-
case ActionType.MARK_AS_DUPLICATE:
|
|
4263
|
-
case ActionType.REJECT_CORRECTION:
|
|
4264
|
-
case ActionType.READ:
|
|
4265
|
-
case ActionType.EDIT:
|
|
4266
|
-
default:
|
|
4267
|
-
return status2;
|
|
4268
|
-
}
|
|
4269
|
-
}, EventStatus.enum.CREATED);
|
|
4270
|
-
}
|
|
4271
|
-
function getAssignedUserFromActions(actions) {
|
|
4272
|
-
return actions.reduce((user2, action) => {
|
|
4273
|
-
if (action.type === ActionType.ASSIGN) {
|
|
4274
|
-
return action.assignedTo;
|
|
4275
|
-
}
|
|
4276
|
-
if (action.type === ActionType.UNASSIGN) {
|
|
4277
|
-
return null;
|
|
4278
|
-
}
|
|
4279
|
-
return user2;
|
|
4280
|
-
}, null);
|
|
4281
|
-
}
|
|
4282
|
-
function deepDropNulls(obj) {
|
|
4283
|
-
if (Array.isArray(obj)) {
|
|
4284
|
-
return obj.map(deepDropNulls);
|
|
4285
|
-
}
|
|
4286
|
-
if (obj !== null && typeof obj === "object") {
|
|
4287
|
-
return Object.entries(obj).reduce((acc, [key, value]) => {
|
|
4288
|
-
const cleanedValue = deepDropNulls(value);
|
|
4289
|
-
if (cleanedValue !== null) {
|
|
4290
|
-
;
|
|
4291
|
-
acc[key] = cleanedValue;
|
|
4292
|
-
}
|
|
4293
|
-
return acc;
|
|
4294
|
-
}, {});
|
|
4295
|
-
}
|
|
4296
|
-
return obj;
|
|
4297
|
-
}
|
|
4298
|
-
var DEFAULT_DATE_OF_EVENT_PROPERTY = "createdAt";
|
|
4299
|
-
function extractDateString(dateTime) {
|
|
4300
|
-
return dateTime.split("T")[0];
|
|
4301
|
-
}
|
|
4302
|
-
function resolveDateOfEvent(eventIndex, declaration, config) {
|
|
4303
|
-
if (!config.dateOfEvent) {
|
|
4304
|
-
return extractDateString(eventIndex[DEFAULT_DATE_OF_EVENT_PROPERTY]);
|
|
4305
|
-
}
|
|
4306
|
-
const parsedDate = isFieldReference(config.dateOfEvent) ? ZodDate.safeParse(declaration[config.dateOfEvent.$$field]) : ZodDateTime.safeParse(
|
|
4307
|
-
getMixedPath(eventIndex, config.dateOfEvent.$$event)
|
|
4308
|
-
);
|
|
4309
|
-
return parsedDate.success ? extractDateString(parsedDate.data) : void 0;
|
|
4310
|
-
}
|
|
4311
|
-
var DEFAULT_PLACE_OF_EVENT_PROPERTY = "createdAtLocation";
|
|
4312
|
-
function getParsedUUID(value, oldValue) {
|
|
4313
|
-
const parsed = UUID.safeParse(value);
|
|
4314
|
-
return parsed.success ? parsed.data : oldValue;
|
|
4315
|
-
}
|
|
4316
|
-
function resolvePlaceOfEvent(eventMetadata, declaration, config) {
|
|
4317
|
-
let placeOfEvent = getParsedUUID(
|
|
4318
|
-
eventMetadata[DEFAULT_PLACE_OF_EVENT_PROPERTY]
|
|
4319
|
-
);
|
|
4320
|
-
if (config.placeOfEvent) {
|
|
4321
|
-
const addressFieldValue = AddressFieldValue.safeParse(
|
|
4322
|
-
declaration[config.placeOfEvent.$$field]
|
|
4323
|
-
);
|
|
4324
|
-
if (addressFieldValue.success && addressFieldValue.data.addressType === AddressType.DOMESTIC && addressFieldValue.data.administrativeArea) {
|
|
4325
|
-
placeOfEvent = getParsedUUID(
|
|
4326
|
-
addressFieldValue.data.administrativeArea,
|
|
4327
|
-
placeOfEvent
|
|
4328
|
-
);
|
|
4329
|
-
} else {
|
|
4330
|
-
placeOfEvent = getParsedUUID(
|
|
4331
|
-
declaration[config.placeOfEvent.$$field],
|
|
4332
|
-
placeOfEvent
|
|
4333
|
-
);
|
|
4334
|
-
}
|
|
4335
|
-
}
|
|
4336
|
-
return placeOfEvent;
|
|
4337
|
-
}
|
|
4338
|
-
function extractPotentialDuplicatesFromActions(actions) {
|
|
4339
|
-
return actions.reduce((duplicates, action) => {
|
|
4340
|
-
if (action.type === ActionType.DUPLICATE_DETECTED) {
|
|
4341
|
-
duplicates = action.content.duplicates;
|
|
4342
|
-
}
|
|
4343
|
-
if (action.type === ActionType.MARK_AS_NOT_DUPLICATE || action.type === ActionType.MARK_AS_DUPLICATE) {
|
|
4344
|
-
duplicates = [];
|
|
4345
|
-
}
|
|
4346
|
-
return duplicates;
|
|
4347
|
-
}, []);
|
|
4348
|
-
}
|
|
4349
|
-
function getCurrentEventState(event2, config) {
|
|
4350
|
-
const sortedActions = event2.actions.slice().sort((a, b) => a.createdAt.localeCompare(b.createdAt));
|
|
4351
|
-
const creationAction = sortedActions.find(
|
|
4352
|
-
(action) => action.type === ActionType.CREATE
|
|
4353
|
-
);
|
|
4354
|
-
if (!creationAction) {
|
|
4355
|
-
throw new Error(`Event ${event2.id} has no creation action`);
|
|
4356
|
-
}
|
|
4357
|
-
const acceptedActions = getAcceptedActions(event2).sort(
|
|
4358
|
-
(a, b) => a.createdAt.localeCompare(b.createdAt)
|
|
4359
|
-
);
|
|
4360
|
-
const requestActionMetadata = getActionUpdateMetadata(sortedActions);
|
|
4361
|
-
const acceptedActionMetadata = getActionUpdateMetadata(acceptedActions);
|
|
4362
|
-
const declaration = aggregateActionDeclarations(event2);
|
|
4363
|
-
const status2 = getStatusFromActions(sortedActions);
|
|
4364
|
-
const legalStatuses = getLegalStatuses(sortedActions);
|
|
4365
|
-
const base = deepDropNulls({
|
|
4366
|
-
id: event2.id,
|
|
4367
|
-
type: event2.type,
|
|
4368
|
-
status: status2,
|
|
4369
|
-
legalStatuses,
|
|
4370
|
-
createdAt: creationAction.createdAt,
|
|
4371
|
-
createdBy: creationAction.createdBy,
|
|
4372
|
-
createdByUserType: creationAction.createdByUserType,
|
|
4373
|
-
createdAtLocation: creationAction.createdAtLocation,
|
|
4374
|
-
updatedAt: acceptedActionMetadata.createdAt,
|
|
4375
|
-
assignedTo: getAssignedUserFromActions(acceptedActions),
|
|
4376
|
-
updatedBy: requestActionMetadata.createdBy,
|
|
4377
|
-
updatedAtLocation: requestActionMetadata.createdAtLocation,
|
|
4378
|
-
declaration,
|
|
4379
|
-
trackingId: event2.trackingId,
|
|
4380
|
-
updatedByUserRole: requestActionMetadata.createdByRole,
|
|
4381
|
-
placeOfEvent: resolvePlaceOfEvent(
|
|
4382
|
-
{ createdAtLocation: creationAction.createdAtLocation },
|
|
4383
|
-
declaration,
|
|
4384
|
-
config
|
|
4385
|
-
),
|
|
4386
|
-
potentialDuplicates: extractPotentialDuplicatesFromActions(sortedActions),
|
|
4387
|
-
flags: getEventFlags(event2, config)
|
|
4388
|
-
});
|
|
4389
|
-
return deepDropNulls({
|
|
4390
|
-
...base,
|
|
4391
|
-
dateOfEvent: resolveDateOfEvent(base, declaration, config)
|
|
4392
|
-
});
|
|
4393
|
-
}
|
|
4394
|
-
|
|
4395
|
-
// ../commons/src/conditionals/validate.ts
|
|
4396
|
-
var ajv = new import__.default({
|
|
4397
|
-
$data: true,
|
|
4398
|
-
allowUnionTypes: true,
|
|
4399
|
-
strict: false
|
|
4400
|
-
// Allow minContains and other newer features
|
|
4401
|
-
});
|
|
4402
|
-
var DataContext = z33.object({
|
|
4403
|
-
rootData: z33.object({
|
|
4404
|
-
$leafAdminStructureLocationIds: z33.array(z33.object({ id: UUID }))
|
|
4405
|
-
})
|
|
4406
|
-
});
|
|
4407
|
-
function resolveDataPath(rootData, dataPath, instancePath) {
|
|
4408
|
-
const pathParts = dataPath.split("/");
|
|
4409
|
-
const levels = parseInt(pathParts[0], 10);
|
|
4410
|
-
const referencePath = pathParts.slice(1);
|
|
4411
|
-
const instanceParts = instancePath.split("/").filter(Boolean);
|
|
4412
|
-
const traversedParts = instanceParts.slice(0, -levels);
|
|
4413
|
-
let current = rootData;
|
|
4414
|
-
for (const part of traversedParts) {
|
|
4415
|
-
if (current === null || current === void 0) {
|
|
4416
|
-
return void 0;
|
|
4417
|
-
}
|
|
4418
|
-
current = current[part];
|
|
4419
|
-
}
|
|
4420
|
-
for (const part of referencePath) {
|
|
4421
|
-
if (current === null || current === void 0) {
|
|
4422
|
-
return void 0;
|
|
4423
|
-
}
|
|
4424
|
-
current = current[part];
|
|
4425
|
-
}
|
|
4426
|
-
return current;
|
|
4427
|
-
}
|
|
4428
|
-
function todayISO() {
|
|
4429
|
-
return (0, import_date_fns2.formatISO)(/* @__PURE__ */ new Date(), { representation: "date" });
|
|
4430
|
-
}
|
|
4431
|
-
var compiledFunctionCache = /* @__PURE__ */ new Map();
|
|
4432
|
-
function compileClientFunction(code) {
|
|
4433
|
-
let fn = compiledFunctionCache.get(code);
|
|
4434
|
-
if (!fn) {
|
|
4435
|
-
fn = new Function(`return (${code})`)();
|
|
4436
|
-
compiledFunctionCache.set(code, fn);
|
|
4437
|
-
}
|
|
4438
|
-
return fn;
|
|
4439
|
-
}
|
|
4440
|
-
(0, import_ajv_formats.default)(ajv);
|
|
4441
|
-
function buildClientFunctionContext(input) {
|
|
4442
|
-
const flags = input.validatorContext?.event && input.validatorContext?.eventConfig ? getCurrentEventState(
|
|
4443
|
-
input.validatorContext?.event,
|
|
4444
|
-
input.validatorContext?.eventConfig
|
|
4445
|
-
)?.flags : [];
|
|
4446
|
-
return {
|
|
4447
|
-
$form: input.form,
|
|
4448
|
-
$flags: flags,
|
|
4449
|
-
$now: todayISO(),
|
|
4450
|
-
// eslint-disable-next-line @typescript-eslint/no-use-before-define
|
|
4451
|
-
$online: isOnline(),
|
|
4452
|
-
$user: input.validatorContext?.user,
|
|
4453
|
-
$event: input.validatorContext?.event,
|
|
4454
|
-
$leafAdminStructureLocationIds: input.validatorContext?.leafAdminStructureLocationIds ?? [],
|
|
4455
|
-
user: input.systemVariables?.user,
|
|
4456
|
-
$window: input.systemVariables?.$window,
|
|
4457
|
-
locations: input.locations,
|
|
4458
|
-
adminLevelIds: input.adminLevelIds
|
|
4459
|
-
};
|
|
4460
|
-
}
|
|
4461
|
-
function runClientFunction(code, data, context) {
|
|
4462
|
-
return compileClientFunction(code)(data, context);
|
|
4463
|
-
}
|
|
4464
|
-
ajv.addKeyword({
|
|
4465
|
-
keyword: "daysFromDate",
|
|
4466
|
-
type: "string",
|
|
4467
|
-
schemaType: "object",
|
|
4468
|
-
$data: true,
|
|
4469
|
-
errors: true,
|
|
4470
|
-
validate(schema, data, _2, dataContext) {
|
|
4471
|
-
if (!(dataContext && dataContext.rootData && typeof dataContext.rootData === "object" && "$now" in dataContext.rootData && typeof dataContext.rootData.$now === "string")) {
|
|
4472
|
-
throw new Error("Validation context must contain $now");
|
|
4473
|
-
}
|
|
4474
|
-
const { days, clause } = schema;
|
|
4475
|
-
if (typeof data !== "string") {
|
|
4476
|
-
return false;
|
|
4477
|
-
}
|
|
4478
|
-
const date = new Date(data);
|
|
4479
|
-
if (isNaN(date.getTime())) {
|
|
4480
|
-
return false;
|
|
4481
|
-
}
|
|
4482
|
-
let referenceDate = schema.referenceDate;
|
|
4483
|
-
if (referenceDate && typeof referenceDate === "object" && "$data" in referenceDate) {
|
|
4484
|
-
referenceDate = resolveDataPath(
|
|
4485
|
-
dataContext.rootData,
|
|
4486
|
-
referenceDate.$data,
|
|
4487
|
-
dataContext.instancePath
|
|
4488
|
-
);
|
|
4489
|
-
}
|
|
4490
|
-
if (!referenceDate) {
|
|
4491
|
-
referenceDate = dataContext.rootData.$now;
|
|
4492
|
-
}
|
|
4493
|
-
const baseDate = new Date(referenceDate);
|
|
4494
|
-
if (isNaN(baseDate.getTime())) {
|
|
4495
|
-
return false;
|
|
4496
|
-
}
|
|
4497
|
-
const offsetDate = new Date(baseDate.getTime() + days * 24 * 60 * 60 * 1e3);
|
|
4498
|
-
return clause === "after" ? (0, import_date_fns2.isAfter)(date, offsetDate) : (0, import_date_fns2.isBefore)(date, offsetDate);
|
|
4499
|
-
}
|
|
4500
|
-
});
|
|
4501
|
-
ajv.addKeyword({
|
|
4502
|
-
keyword: "isLeafLevelLocation",
|
|
4503
|
-
type: "string",
|
|
4504
|
-
schemaType: "boolean",
|
|
4505
|
-
$data: true,
|
|
4506
|
-
errors: true,
|
|
4507
|
-
// @ts-ignore -- Force type. We will move this away from AJV next. Parsing the array will take seconds and is only called by core.
|
|
4508
|
-
validate(_schema, data, _2, dataContext) {
|
|
4509
|
-
const locationIdInput = data;
|
|
4510
|
-
const locations = dataContext?.rootData.$leafAdminStructureLocationIds ?? [];
|
|
4511
|
-
return locations.some((location) => location.id === locationIdInput);
|
|
4512
|
-
}
|
|
4513
|
-
});
|
|
4514
|
-
function isAgeValue(value) {
|
|
4515
|
-
return typeof value === "object" && value !== null && "age" in value && typeof value.age === "number";
|
|
4516
|
-
}
|
|
4517
|
-
ajv.addKeyword({
|
|
4518
|
-
keyword: "customClientValidator",
|
|
4519
|
-
schemaType: "object",
|
|
4520
|
-
errors: true,
|
|
4521
|
-
// @ts-expect-error -- AJV's public types don't expose `rootData`. All
|
|
4522
|
-
// `validate()` callers build root data via `buildClientFunctionContext`,
|
|
4523
|
-
// so the cast holds.
|
|
4524
|
-
validate(schema, data, _2, dataContext) {
|
|
4525
|
-
return Boolean(
|
|
4526
|
-
runClientFunction(
|
|
4527
|
-
schema.code,
|
|
4528
|
-
data,
|
|
4529
|
-
dataContext?.rootData ?? buildClientFunctionContext({ form: {} })
|
|
4530
|
-
)
|
|
4531
|
-
);
|
|
4532
|
-
}
|
|
4533
|
-
});
|
|
4534
|
-
function validate(schema, data) {
|
|
4535
|
-
const validator = ajv.getSchema(schema.$id) || ajv.compile(schema);
|
|
4536
|
-
if ("$form" in data) {
|
|
4537
|
-
const entries = Object.entries(data.$form).map(([key, value]) => {
|
|
4538
|
-
if (!isAgeValue(value)) {
|
|
4539
|
-
return [key, value];
|
|
4540
|
-
}
|
|
4541
|
-
const age = value.age;
|
|
4542
|
-
const maybeAsOfDate = PlainDate.safeParse(data.$form[value.asOfDateRef]);
|
|
4543
|
-
return [
|
|
4544
|
-
key,
|
|
4545
|
-
{
|
|
4546
|
-
age,
|
|
4547
|
-
dob: ageToDate(
|
|
4548
|
-
age,
|
|
4549
|
-
maybeAsOfDate.success ? maybeAsOfDate.data : PlainDate.parse(data.$now)
|
|
4550
|
-
)
|
|
4551
|
-
}
|
|
4552
|
-
];
|
|
4553
|
-
});
|
|
4554
|
-
data.$form = Object.fromEntries(entries);
|
|
4555
|
-
}
|
|
4556
|
-
const result = validator(data);
|
|
4557
|
-
return result;
|
|
4558
|
-
}
|
|
4559
|
-
function isOnline() {
|
|
4560
|
-
if (typeof window !== "undefined" && typeof navigator !== "undefined") {
|
|
4561
|
-
return navigator.onLine;
|
|
4562
|
-
}
|
|
4563
|
-
return true;
|
|
4564
|
-
}
|
|
4565
|
-
|
|
4566
|
-
// ../commons/src/events/utils.ts
|
|
4567
|
-
var import_date_fns3 = require("date-fns");
|
|
4568
|
-
function ageToDate(age, asOfDate) {
|
|
4569
|
-
const date = plainDateToLocalDate(asOfDate);
|
|
4570
|
-
return PlainDate.parse((0, import_date_fns3.format)((0, import_date_fns3.subYears)(date, age), "yyyy-MM-dd"));
|
|
4571
|
-
}
|
|
4572
|
-
function getDeclarationFields(configuration) {
|
|
4573
|
-
return configuration.declaration.pages.flatMap(({ fields }) => fields);
|
|
4574
|
-
}
|
|
4575
|
-
function isActionConfigType(type) {
|
|
4576
|
-
return actionConfigTypes.has(type);
|
|
4577
|
-
}
|
|
4578
|
-
function getActionConfig({
|
|
4579
|
-
eventConfiguration,
|
|
4580
|
-
actionType,
|
|
4581
|
-
customActionType
|
|
4582
|
-
}) {
|
|
4583
|
-
if (actionType === ActionType.NOTIFY) {
|
|
4584
|
-
return eventConfiguration.actions.find((a) => a.type === ActionType.NOTIFY) ?? eventConfiguration.actions.find((a) => a.type === ActionType.DECLARE);
|
|
4585
|
-
}
|
|
4586
|
-
return eventConfiguration.actions.find((a) => {
|
|
4587
|
-
if (a.type === ActionType.CUSTOM && customActionType) {
|
|
4588
|
-
return a.customActionType === customActionType;
|
|
4589
|
-
}
|
|
4590
|
-
return a.type === actionType;
|
|
4591
|
-
});
|
|
4592
|
-
}
|
|
4593
|
-
var getActionAnnotationFields = (actionConfig) => {
|
|
4594
|
-
if (actionConfig.type === ActionType.REQUEST_CORRECTION) {
|
|
4595
|
-
return actionConfig.correctionForm.pages.flatMap(({ fields }) => fields);
|
|
4596
|
-
}
|
|
4597
|
-
if (actionConfig.type === ActionType.PRINT_CERTIFICATE) {
|
|
4598
|
-
return actionConfig.printForm.pages.flatMap(({ fields }) => fields);
|
|
4599
|
-
}
|
|
4600
|
-
const reviewFields = "review" in actionConfig && actionConfig.review != null ? actionConfig.review.fields : [];
|
|
4601
|
-
const formFields = "form" in actionConfig && actionConfig.form != null ? actionConfig.form : [];
|
|
4602
|
-
return [...reviewFields, ...formFields];
|
|
4603
|
-
};
|
|
4604
|
-
function getAllAnnotationFields(config) {
|
|
4605
|
-
return (0, import_lodash4.flattenDeep)(config.actions.map(getActionAnnotationFields));
|
|
4606
|
-
}
|
|
4607
|
-
function deepMerge(currentDocument, actionDocument) {
|
|
4608
|
-
const currentDocumentClone = (0, import_lodash4.cloneDeep)(currentDocument);
|
|
4609
|
-
return (0, import_lodash4.mergeWith)(
|
|
4610
|
-
(0, import_lodash4.cloneDeep)(currentDocumentClone),
|
|
4611
|
-
actionDocument,
|
|
4612
|
-
(previousValue, incomingValue) => {
|
|
4613
|
-
if (incomingValue === void 0) {
|
|
4614
|
-
return previousValue;
|
|
4615
|
-
}
|
|
4616
|
-
if ((0, import_lodash4.isArray)(incomingValue)) {
|
|
4617
|
-
return incomingValue;
|
|
4618
|
-
}
|
|
4619
|
-
if ((0, import_lodash4.isObject)(previousValue) && (0, import_lodash4.isObject)(incomingValue)) {
|
|
4620
|
-
return void 0;
|
|
4621
|
-
}
|
|
4622
|
-
return incomingValue;
|
|
4623
|
-
}
|
|
4624
|
-
);
|
|
4625
|
-
}
|
|
4626
|
-
var findAllFields = (config) => {
|
|
4627
|
-
return (0, import_lodash4.flattenDeep)([
|
|
4628
|
-
...getDeclarationFields(config),
|
|
4629
|
-
...getAllAnnotationFields(config)
|
|
4630
|
-
]);
|
|
4631
|
-
};
|
|
4632
|
-
function getMixedPath(obj, path, defaultValue) {
|
|
4633
|
-
const parts = path.split(".");
|
|
4634
|
-
const resolve = (current, segments) => {
|
|
4635
|
-
if (current == null || segments.length === 0) {
|
|
4636
|
-
return current;
|
|
4637
|
-
}
|
|
4638
|
-
for (let i = segments.length; i > 0; i--) {
|
|
4639
|
-
const compoundKey = segments.slice(0, i).join(".");
|
|
4640
|
-
if ((0, import_lodash4.has)(current, compoundKey)) {
|
|
4641
|
-
const next = (0, import_lodash4.get)(current, compoundKey);
|
|
4642
|
-
return resolve(next, segments.slice(i));
|
|
4643
|
-
}
|
|
3907
|
+
})
|
|
3908
|
+
),
|
|
3909
|
+
required: Object.keys(options)
|
|
3910
|
+
}
|
|
3911
|
+
},
|
|
3912
|
+
required: [fieldId]
|
|
3913
|
+
}),
|
|
3914
|
+
/**
|
|
3915
|
+
* Custom client-side validator. The provided function is serialised and executed
|
|
3916
|
+
* just-in-time on the client only. External references (e.g. lodash) are not
|
|
3917
|
+
* available inside the function body — all logic must be self-contained.
|
|
3918
|
+
*
|
|
3919
|
+
* @example
|
|
3920
|
+
* field('nid').customClientValidator((value) => {
|
|
3921
|
+
* // LUHN check — all logic must be inline
|
|
3922
|
+
* const digits = String(value).split('').map(Number)
|
|
3923
|
+
* // ...
|
|
3924
|
+
* return isValid
|
|
3925
|
+
* })
|
|
3926
|
+
*/
|
|
3927
|
+
customClientValidator(validationFn) {
|
|
3928
|
+
const code = validationFn.toString();
|
|
3929
|
+
return defineFormConditional({
|
|
3930
|
+
type: "object",
|
|
3931
|
+
properties: wrapToPath(
|
|
3932
|
+
{ [fieldId]: { customClientValidator: { code } } },
|
|
3933
|
+
this.$$subfield
|
|
3934
|
+
),
|
|
3935
|
+
required: [fieldId]
|
|
3936
|
+
});
|
|
3937
|
+
},
|
|
3938
|
+
/**
|
|
3939
|
+
* Custom client-side evaluation. Returns a {@link FieldReference} descriptor
|
|
3940
|
+
* that can be used as the `value` property or a DATA component entry.
|
|
3941
|
+
* The function receives the referenced field's value as the first argument and
|
|
3942
|
+
* the full form context as the second; its return value replaces the field reference.
|
|
3943
|
+
* The function is serialised and executed just-in-time on the client only.
|
|
3944
|
+
* External references (e.g. lodash) are not available inside the function body.
|
|
3945
|
+
*
|
|
3946
|
+
* For computing a default value without referencing a specific field, use
|
|
3947
|
+
* `evaluate(fn)` in the `defaultValue` property instead.
|
|
3948
|
+
*
|
|
3949
|
+
* @example
|
|
3950
|
+
* field('a').customClientEvaluation((aValue, ctx) =>
|
|
3951
|
+
* Number(aValue) + Number(ctx.$form.b)
|
|
3952
|
+
* )
|
|
3953
|
+
*/
|
|
3954
|
+
customClientEvaluation(computationFn) {
|
|
3955
|
+
return {
|
|
3956
|
+
$$code: computationFn.toString(),
|
|
3957
|
+
$$field: fieldId,
|
|
3958
|
+
$$subfield: this.$$subfield
|
|
3959
|
+
};
|
|
4644
3960
|
}
|
|
4645
|
-
return void 0;
|
|
4646
3961
|
};
|
|
4647
|
-
const result = resolve(obj, parts);
|
|
4648
|
-
return (0, import_lodash4.isNil)(result) ? defaultValue : result;
|
|
4649
|
-
}
|
|
4650
|
-
function isAcceptedAction(a) {
|
|
4651
|
-
return a.status === ActionStatus.Accepted;
|
|
4652
|
-
}
|
|
4653
|
-
function getCompleteActionAnnotation(event2, action) {
|
|
4654
|
-
if (action.originalActionId) {
|
|
4655
|
-
const originalAction = event2.actions.find(
|
|
4656
|
-
({ id }) => id === action.originalActionId
|
|
4657
|
-
);
|
|
4658
|
-
if (originalAction?.status === ActionStatus.Requested) {
|
|
4659
|
-
return deepMerge(originalAction.annotation ?? {}, action.annotation ?? {});
|
|
4660
|
-
}
|
|
4661
|
-
}
|
|
4662
|
-
return action.annotation ?? {};
|
|
4663
|
-
}
|
|
4664
|
-
function getCompleteActionDeclaration(declaration, event2, action) {
|
|
4665
|
-
if (action.originalActionId) {
|
|
4666
|
-
const originalAction = event2.actions.find(
|
|
4667
|
-
({ id }) => id === action.originalActionId
|
|
4668
|
-
);
|
|
4669
|
-
if (originalAction?.status === ActionStatus.Requested) {
|
|
4670
|
-
return deepMerge(
|
|
4671
|
-
deepMerge(declaration, originalAction.declaration),
|
|
4672
|
-
action.declaration
|
|
4673
|
-
);
|
|
4674
|
-
}
|
|
4675
|
-
}
|
|
4676
|
-
return deepMerge(declaration, action.declaration);
|
|
4677
|
-
}
|
|
4678
|
-
function getAcceptedActions(event2) {
|
|
4679
|
-
return event2.actions.filter(isAcceptedAction).map((action) => ({
|
|
4680
|
-
...action,
|
|
4681
|
-
declaration: getCompleteActionDeclaration({}, event2, action),
|
|
4682
|
-
annotation: getCompleteActionAnnotation(event2, action)
|
|
4683
|
-
}));
|
|
4684
|
-
}
|
|
4685
|
-
var EXCLUDED_ACTIONS = [
|
|
4686
|
-
ActionType.REQUEST_CORRECTION,
|
|
4687
|
-
ActionType.PRINT_CERTIFICATE,
|
|
4688
|
-
ActionType.REJECT_CORRECTION
|
|
4689
|
-
];
|
|
4690
|
-
function aggregateActionDeclarations(event2) {
|
|
4691
|
-
const allAcceptedActions = getAcceptedActions(event2);
|
|
4692
|
-
const aggregatedActions = allAcceptedActions.filter((a) => !EXCLUDED_ACTIONS.some((type) => type === a.type)).sort((a, b) => a.createdAt.localeCompare(b.createdAt));
|
|
4693
|
-
return aggregatedActions.reduce((declaration, action) => {
|
|
4694
|
-
if (action.type === ActionType.APPROVE_CORRECTION) {
|
|
4695
|
-
const requestAction = allAcceptedActions.find(
|
|
4696
|
-
({ id }) => id === action.requestId
|
|
4697
|
-
);
|
|
4698
|
-
if (!requestAction) {
|
|
4699
|
-
return declaration;
|
|
4700
|
-
}
|
|
4701
|
-
const declarationWithApprovedCorrection = getCompleteActionDeclaration(
|
|
4702
|
-
declaration,
|
|
4703
|
-
event2,
|
|
4704
|
-
requestAction
|
|
4705
|
-
);
|
|
4706
|
-
return getCompleteActionDeclaration(
|
|
4707
|
-
declarationWithApprovedCorrection,
|
|
4708
|
-
event2,
|
|
4709
|
-
action
|
|
4710
|
-
);
|
|
4711
|
-
}
|
|
4712
|
-
return getCompleteActionDeclaration(declaration, event2, action);
|
|
4713
|
-
}, {});
|
|
4714
|
-
}
|
|
4715
|
-
function aggregateActionAnnotations(event2) {
|
|
4716
|
-
return event2.actions.reduce((ann, sortedAction) => {
|
|
4717
|
-
if (!("annotation" in sortedAction) || !sortedAction.annotation) {
|
|
4718
|
-
return ann;
|
|
4719
|
-
}
|
|
4720
|
-
return deepMerge(ann, sortedAction.annotation);
|
|
4721
|
-
}, {});
|
|
4722
3962
|
}
|
|
4723
3963
|
|
|
4724
3964
|
// ../commons/src/events/eventConfigValidation.ts
|
|
@@ -4803,9 +4043,9 @@ function validatePlaceOfEvent(event2, ctx) {
|
|
|
4803
4043
|
}
|
|
4804
4044
|
function validateActionFlags(event2, ctx) {
|
|
4805
4045
|
const isInherentFlag = (value) => Object.values(InherentFlags).includes(value);
|
|
4806
|
-
const configuredFlagIds = event2.flags.map((
|
|
4046
|
+
const configuredFlagIds = event2.flags.map((flag) => flag.id);
|
|
4807
4047
|
const actionFlagIds = event2.actions.flatMap(
|
|
4808
|
-
(action) => (action.flags ?? []).map((
|
|
4048
|
+
(action) => (action.flags ?? []).map((flag) => flag.id)
|
|
4809
4049
|
);
|
|
4810
4050
|
for (const actionFlagId of actionFlagIds) {
|
|
4811
4051
|
const isConfigured = configuredFlagIds.includes(actionFlagId);
|
|
@@ -4841,11 +4081,11 @@ function validateActionOrder(event2, ctx) {
|
|
|
4841
4081
|
}
|
|
4842
4082
|
|
|
4843
4083
|
// ../commons/src/events/EventConfig.ts
|
|
4844
|
-
var EventFieldReference =
|
|
4084
|
+
var EventFieldReference = z33.object({ $$event: EventMetadataDateFieldIdInput }).describe(
|
|
4845
4085
|
"Reference to a field defined in the event metadata, using the field id."
|
|
4846
4086
|
);
|
|
4847
|
-
var _EventConfigBase =
|
|
4848
|
-
id:
|
|
4087
|
+
var _EventConfigBase = z33.object({
|
|
4088
|
+
id: z33.string().describe(
|
|
4849
4089
|
'Machine-readable identifier of the event (e.g. "birth", "death").'
|
|
4850
4090
|
),
|
|
4851
4091
|
dateOfEvent: FieldReference.or(EventFieldReference).optional().describe(
|
|
@@ -4864,26 +4104,23 @@ var _EventConfigBase = z34.object({
|
|
|
4864
4104
|
"Summary information displayed in the event overview."
|
|
4865
4105
|
),
|
|
4866
4106
|
label: TranslationConfig.describe("Human-readable label for the event type."),
|
|
4867
|
-
actions:
|
|
4107
|
+
actions: z33.array(ActionConfig).describe(
|
|
4868
4108
|
"Configuration of core and custom actions associated with the event."
|
|
4869
4109
|
),
|
|
4870
|
-
actionOrder:
|
|
4110
|
+
actionOrder: z33.array(z33.string()).optional().describe(
|
|
4871
4111
|
"Order of actions in the action menu. Use either the action type for core actions or the customActionType for custom actions."
|
|
4872
4112
|
),
|
|
4873
4113
|
declaration: DeclarationFormConfig.describe(
|
|
4874
4114
|
"Configuration of the form used to gather event data."
|
|
4875
4115
|
),
|
|
4876
|
-
advancedSearch:
|
|
4116
|
+
advancedSearch: z33.array(AdvancedSearchConfig).optional().default([]).describe(
|
|
4877
4117
|
"Configuration of fields available in the advanced search feature."
|
|
4878
4118
|
),
|
|
4879
|
-
flags:
|
|
4119
|
+
flags: z33.array(FlagConfig).optional().default([]).describe(
|
|
4880
4120
|
"Configuration of custom flags associated with the actions of this event type."
|
|
4881
4121
|
),
|
|
4882
|
-
analytics:
|
|
4122
|
+
analytics: z33.boolean().optional().default(true).describe(
|
|
4883
4123
|
"Indicates whether the records of this event type are included in analytics"
|
|
4884
|
-
),
|
|
4885
|
-
icon: z34.partialRecord(AvailableIcons, Conditional).optional().describe(
|
|
4886
|
-
'Maps an icon name to a conditional. The icon of the first entry (in definition order) whose conditional matches the event is used when rendering it (e.g. in the "iconWithName"/"iconWithNameEvent" workqueue columns). Falls back to the default status-based icon when unset or when no conditional matches.'
|
|
4887
4124
|
)
|
|
4888
4125
|
});
|
|
4889
4126
|
var EventConfig = _EventConfigBase.superRefine((event2, ctx) => {
|
|
@@ -5100,31 +4337,21 @@ var event = Object.assign(eventFn, {
|
|
|
5100
4337
|
return {
|
|
5101
4338
|
$event: field3
|
|
5102
4339
|
};
|
|
5103
|
-
}
|
|
5104
|
-
/**
|
|
5105
|
-
* Checks if the event currently has the given status.
|
|
5106
|
-
* @param eventStatus - The status to check for.
|
|
5107
|
-
*/
|
|
5108
|
-
hasStatus: (eventStatus) => status(eventStatus),
|
|
5109
|
-
/**
|
|
5110
|
-
* Checks if the event currently carries the given flag.
|
|
5111
|
-
* @param flagValue - The flag to check for.
|
|
5112
|
-
*/
|
|
5113
|
-
hasFlag: (flagValue) => flag(flagValue)
|
|
4340
|
+
}
|
|
5114
4341
|
});
|
|
5115
4342
|
|
|
5116
4343
|
// ../commons/src/events/WorkqueueColumnConfig.ts
|
|
5117
|
-
var
|
|
4344
|
+
var z34 = __toESM(require("zod/v4"));
|
|
5118
4345
|
var WorkqueueColumnKeysArray = [
|
|
5119
4346
|
...EventMetadataKeysArray,
|
|
5120
4347
|
"title",
|
|
5121
4348
|
"outbox"
|
|
5122
4349
|
];
|
|
5123
|
-
var WorkqueueColumnKeys =
|
|
5124
|
-
var WorkqueueColumnValue =
|
|
4350
|
+
var WorkqueueColumnKeys = z34.enum(WorkqueueColumnKeysArray);
|
|
4351
|
+
var WorkqueueColumnValue = z34.object({
|
|
5125
4352
|
$event: WorkqueueColumnKeys
|
|
5126
4353
|
});
|
|
5127
|
-
var WorkqueueColumn =
|
|
4354
|
+
var WorkqueueColumn = z34.object({
|
|
5128
4355
|
label: TranslationConfig,
|
|
5129
4356
|
value: WorkqueueColumnValue
|
|
5130
4357
|
}).meta({
|
|
@@ -5138,56 +4365,164 @@ function defineWorkqueuesColumns(workqueueColumns) {
|
|
|
5138
4365
|
}
|
|
5139
4366
|
|
|
5140
4367
|
// ../commons/src/events/CountryConfigQueryInput.ts
|
|
5141
|
-
var
|
|
5142
|
-
var SerializableExact =
|
|
5143
|
-
type:
|
|
5144
|
-
term:
|
|
5145
|
-
});
|
|
5146
|
-
var SerializableWithin =
|
|
5147
|
-
type:
|
|
5148
|
-
location:
|
|
5149
|
-
});
|
|
5150
|
-
var SerializedQueryExpression =
|
|
5151
|
-
eventType:
|
|
5152
|
-
status:
|
|
5153
|
-
createdAt:
|
|
5154
|
-
updatedAt:
|
|
5155
|
-
"legalStatuses.DECLARED.createdAtLocation":
|
|
5156
|
-
"legalStatuses.DECLARED.createdByRole":
|
|
5157
|
-
"legalStatuses.REGISTERED.createdAt":
|
|
5158
|
-
"legalStatuses.REGISTERED.createdAtLocation":
|
|
5159
|
-
"legalStatuses.REGISTERED.createdByRole":
|
|
5160
|
-
"legalStatuses.REGISTERED.registrationNumber":
|
|
5161
|
-
createdAtLocation:
|
|
5162
|
-
|
|
4368
|
+
var z35 = __toESM(require("zod/v4"));
|
|
4369
|
+
var SerializableExact = z35.object({
|
|
4370
|
+
type: z35.literal("exact"),
|
|
4371
|
+
term: z35.union([z35.string(), SerializedUserField])
|
|
4372
|
+
});
|
|
4373
|
+
var SerializableWithin = z35.object({
|
|
4374
|
+
type: z35.literal("within"),
|
|
4375
|
+
location: z35.union([z35.string(), SerializedUserField])
|
|
4376
|
+
});
|
|
4377
|
+
var SerializedQueryExpression = z35.object({
|
|
4378
|
+
eventType: z35.string(),
|
|
4379
|
+
status: z35.optional(z35.union([AnyOfStatus, ExactStatus])),
|
|
4380
|
+
createdAt: z35.optional(DateCondition),
|
|
4381
|
+
updatedAt: z35.optional(DateCondition),
|
|
4382
|
+
"legalStatuses.DECLARED.createdAtLocation": z35.optional(SerializableWithin),
|
|
4383
|
+
"legalStatuses.DECLARED.createdByRole": z35.optional(AnyOf),
|
|
4384
|
+
"legalStatuses.REGISTERED.createdAt": z35.optional(DateCondition),
|
|
4385
|
+
"legalStatuses.REGISTERED.createdAtLocation": z35.optional(SerializableWithin),
|
|
4386
|
+
"legalStatuses.REGISTERED.createdByRole": z35.optional(AnyOf),
|
|
4387
|
+
"legalStatuses.REGISTERED.registrationNumber": z35.optional(Exact),
|
|
4388
|
+
createdAtLocation: z35.optional(
|
|
4389
|
+
z35.union([SerializableWithin, SerializableExact])
|
|
5163
4390
|
),
|
|
5164
|
-
updatedAtLocation:
|
|
5165
|
-
|
|
4391
|
+
updatedAtLocation: z35.optional(
|
|
4392
|
+
z35.union([SerializableWithin, SerializableExact])
|
|
5166
4393
|
),
|
|
5167
|
-
updatedByUserRole:
|
|
5168
|
-
assignedTo:
|
|
5169
|
-
createdBy:
|
|
4394
|
+
updatedByUserRole: z35.optional(SerializableExact),
|
|
4395
|
+
assignedTo: z35.optional(SerializableExact),
|
|
4396
|
+
createdBy: z35.optional(SerializableExact),
|
|
5170
4397
|
createdByUserType: ExactUserType,
|
|
5171
|
-
updatedBy:
|
|
5172
|
-
trackingId:
|
|
5173
|
-
flags:
|
|
4398
|
+
updatedBy: z35.optional(SerializableExact),
|
|
4399
|
+
trackingId: z35.optional(Exact),
|
|
4400
|
+
flags: z35.optional(ContainsFlags),
|
|
5174
4401
|
data: QueryInput
|
|
5175
4402
|
}).partial();
|
|
5176
|
-
var Or2 =
|
|
5177
|
-
type:
|
|
5178
|
-
clauses:
|
|
4403
|
+
var Or2 = z35.object({
|
|
4404
|
+
type: z35.literal("or"),
|
|
4405
|
+
clauses: z35.array(SerializedQueryExpression)
|
|
5179
4406
|
});
|
|
5180
|
-
var And2 =
|
|
5181
|
-
type:
|
|
5182
|
-
clauses:
|
|
4407
|
+
var And2 = z35.object({
|
|
4408
|
+
type: z35.literal("and"),
|
|
4409
|
+
clauses: z35.array(SerializedQueryExpression)
|
|
5183
4410
|
});
|
|
5184
|
-
var CountryConfigQueryType =
|
|
5185
|
-
var CountryConfigQueryInputType =
|
|
4411
|
+
var CountryConfigQueryType = z35.discriminatedUnion("type", [And2, Or2]);
|
|
4412
|
+
var CountryConfigQueryInputType = z35.union([
|
|
5186
4413
|
SerializedQueryExpression,
|
|
5187
4414
|
And2,
|
|
5188
4415
|
Or2
|
|
5189
4416
|
]);
|
|
5190
4417
|
|
|
4418
|
+
// ../commons/src/icons.ts
|
|
4419
|
+
var z36 = __toESM(require("zod/v4"));
|
|
4420
|
+
var AvailableIcons = z36.enum([
|
|
4421
|
+
"Archived",
|
|
4422
|
+
"Assigned",
|
|
4423
|
+
"Briefcase",
|
|
4424
|
+
"Certified",
|
|
4425
|
+
"Close",
|
|
4426
|
+
"Collapse",
|
|
4427
|
+
"Draft",
|
|
4428
|
+
"DuplicateYellow",
|
|
4429
|
+
"Expand",
|
|
4430
|
+
"ExternalValidate",
|
|
4431
|
+
"FilledCheck",
|
|
4432
|
+
"InReview",
|
|
4433
|
+
"Offline",
|
|
4434
|
+
"Registered",
|
|
4435
|
+
"RequiresUpdates",
|
|
4436
|
+
"Sent",
|
|
4437
|
+
"Validated",
|
|
4438
|
+
"WaitingApproval",
|
|
4439
|
+
"ChartActivity",
|
|
4440
|
+
"Activity",
|
|
4441
|
+
"Archive",
|
|
4442
|
+
"ArchiveTray",
|
|
4443
|
+
"ArrowLeft",
|
|
4444
|
+
"ArrowRight",
|
|
4445
|
+
"Buildings",
|
|
4446
|
+
"Circle",
|
|
4447
|
+
"CaretDown",
|
|
4448
|
+
"CaretLeft",
|
|
4449
|
+
"CaretRight",
|
|
4450
|
+
"ChartBar",
|
|
4451
|
+
"ChartLine",
|
|
4452
|
+
"ChatCircle",
|
|
4453
|
+
"CheckSquare",
|
|
4454
|
+
"Compass",
|
|
4455
|
+
"Check",
|
|
4456
|
+
"Copy",
|
|
4457
|
+
"Database",
|
|
4458
|
+
"DotsThreeVertical",
|
|
4459
|
+
"ArrowCounterClockwise",
|
|
4460
|
+
"MagnifyingGlassMinus",
|
|
4461
|
+
"MagnifyingGlassPlus",
|
|
4462
|
+
"Export",
|
|
4463
|
+
"Eye",
|
|
4464
|
+
"EyeSlash",
|
|
4465
|
+
"Envelope",
|
|
4466
|
+
"File",
|
|
4467
|
+
"FileSearch",
|
|
4468
|
+
"FileMinus",
|
|
4469
|
+
"FilePlus",
|
|
4470
|
+
"FileText",
|
|
4471
|
+
"FileX",
|
|
4472
|
+
"Handshake",
|
|
4473
|
+
"Gear",
|
|
4474
|
+
"GitBranch",
|
|
4475
|
+
"IdentificationCard",
|
|
4476
|
+
"List",
|
|
4477
|
+
"ListBullets",
|
|
4478
|
+
"Lock",
|
|
4479
|
+
"MagnifyingGlass",
|
|
4480
|
+
"MapPin",
|
|
4481
|
+
"Medal",
|
|
4482
|
+
"NotePencil",
|
|
4483
|
+
"Paperclip",
|
|
4484
|
+
"PaperPlaneTilt",
|
|
4485
|
+
"Pen",
|
|
4486
|
+
"PenNib",
|
|
4487
|
+
"Pencil",
|
|
4488
|
+
"PencilSimpleLine",
|
|
4489
|
+
"Phone",
|
|
4490
|
+
"Plus",
|
|
4491
|
+
"Printer",
|
|
4492
|
+
"SignOut",
|
|
4493
|
+
"Stamp",
|
|
4494
|
+
"Star",
|
|
4495
|
+
"Target",
|
|
4496
|
+
"TextT",
|
|
4497
|
+
"Trash",
|
|
4498
|
+
"UploadSimple",
|
|
4499
|
+
"User",
|
|
4500
|
+
"UserPlus",
|
|
4501
|
+
"Users",
|
|
4502
|
+
"WarningCircle",
|
|
4503
|
+
"X",
|
|
4504
|
+
"ChatText",
|
|
4505
|
+
"CircleWavyCheck",
|
|
4506
|
+
"CircleWavyQuestion",
|
|
4507
|
+
"ArchiveBox",
|
|
4508
|
+
"ArrowCircleDown",
|
|
4509
|
+
"FileArrowUp",
|
|
4510
|
+
"FileDotted",
|
|
4511
|
+
"Files",
|
|
4512
|
+
"PencilLine",
|
|
4513
|
+
"PencilCircle",
|
|
4514
|
+
"UserCircle",
|
|
4515
|
+
"Clock",
|
|
4516
|
+
"QrCode",
|
|
4517
|
+
"Webcam",
|
|
4518
|
+
"Sun",
|
|
4519
|
+
"DeviceTabletCamera",
|
|
4520
|
+
"Globe",
|
|
4521
|
+
"Fingerprint",
|
|
4522
|
+
"PushPin",
|
|
4523
|
+
"Timer"
|
|
4524
|
+
]);
|
|
4525
|
+
|
|
5191
4526
|
// ../commons/src/events/WorkqueueConfig.ts
|
|
5192
4527
|
var mandatoryColumns = defineWorkqueuesColumns([
|
|
5193
4528
|
{
|
|
@@ -5467,14 +4802,14 @@ var DraftInput = BaseActionInput.omit({ waitFor: true }).extend({
|
|
|
5467
4802
|
|
|
5468
4803
|
// ../commons/src/events/EventInput.ts
|
|
5469
4804
|
var z40 = __toESM(require("zod/v4"));
|
|
5470
|
-
var
|
|
4805
|
+
var import_uuid10 = require("uuid");
|
|
5471
4806
|
var EventInput = z40.object({
|
|
5472
4807
|
transactionId: z40.string(),
|
|
5473
4808
|
type: z40.string(),
|
|
5474
4809
|
createdAtLocation: UUID.nullish().describe(
|
|
5475
4810
|
"Location where the event occurred. Required for system users."
|
|
5476
4811
|
)
|
|
5477
|
-
}).meta({ default: { transactionId: (0,
|
|
4812
|
+
}).meta({ default: { transactionId: (0, import_uuid10.v4)(), type: "birth" } });
|
|
5478
4813
|
|
|
5479
4814
|
// ../commons/src/events/EventDocument.ts
|
|
5480
4815
|
var z41 = __toESM(require("zod/v4"));
|
|
@@ -5491,6 +4826,67 @@ var EventDocument = z41.object({
|
|
|
5491
4826
|
)
|
|
5492
4827
|
}).meta({ id: "EventDocument" });
|
|
5493
4828
|
|
|
4829
|
+
// ../commons/src/events/state/index.ts
|
|
4830
|
+
var import_lodash4 = require("lodash");
|
|
4831
|
+
|
|
4832
|
+
// ../commons/src/events/state/utils.ts
|
|
4833
|
+
var import_lodash2 = require("lodash");
|
|
4834
|
+
var updateActions = ActionTypes.extract([
|
|
4835
|
+
ActionType.CREATE,
|
|
4836
|
+
ActionType.NOTIFY,
|
|
4837
|
+
ActionType.EDIT,
|
|
4838
|
+
ActionType.DECLARE,
|
|
4839
|
+
ActionType.REGISTER,
|
|
4840
|
+
ActionType.REJECT,
|
|
4841
|
+
ActionType.ARCHIVE,
|
|
4842
|
+
ActionType.UNARCHIVE,
|
|
4843
|
+
ActionType.PRINT_CERTIFICATE,
|
|
4844
|
+
ActionType.REQUEST_CORRECTION,
|
|
4845
|
+
ActionType.APPROVE_CORRECTION,
|
|
4846
|
+
ActionType.REJECT_CORRECTION,
|
|
4847
|
+
ActionType.CUSTOM
|
|
4848
|
+
]);
|
|
4849
|
+
|
|
4850
|
+
// ../commons/src/events/state/flags.ts
|
|
4851
|
+
var import_lodash3 = require("lodash");
|
|
4852
|
+
var import_date_fns3 = require("date-fns");
|
|
4853
|
+
var INHERENT_FLAG_RULES = [
|
|
4854
|
+
{
|
|
4855
|
+
flag: InherentFlags.CORRECTION_REQUESTED,
|
|
4856
|
+
setOn: [ActionType.REQUEST_CORRECTION],
|
|
4857
|
+
resetOn: [ActionType.APPROVE_CORRECTION, ActionType.REJECT_CORRECTION]
|
|
4858
|
+
},
|
|
4859
|
+
{
|
|
4860
|
+
// INCOMPLETE mirrors the NOTIFIED status: set by NOTIFY, cleared by any
|
|
4861
|
+
// other status-changing action (see getStatusFromActions). ARCHIVE/UNARCHIVE
|
|
4862
|
+
// are deliberately excluded so the flag freezes across an archive/unarchive
|
|
4863
|
+
// round trip and comes back exactly as it was.
|
|
4864
|
+
flag: InherentFlags.INCOMPLETE,
|
|
4865
|
+
setOn: [ActionType.NOTIFY],
|
|
4866
|
+
resetOn: [ActionType.CREATE, ActionType.DECLARE, ActionType.REGISTER]
|
|
4867
|
+
},
|
|
4868
|
+
{
|
|
4869
|
+
flag: InherentFlags.REJECTED,
|
|
4870
|
+
setOn: [ActionType.REJECT],
|
|
4871
|
+
resetOn: [
|
|
4872
|
+
ActionType.NOTIFY,
|
|
4873
|
+
ActionType.DECLARE,
|
|
4874
|
+
ActionType.EDIT,
|
|
4875
|
+
ActionType.REGISTER
|
|
4876
|
+
]
|
|
4877
|
+
},
|
|
4878
|
+
{
|
|
4879
|
+
flag: InherentFlags.POTENTIAL_DUPLICATE,
|
|
4880
|
+
setOn: [ActionType.DUPLICATE_DETECTED],
|
|
4881
|
+
resetOn: [ActionType.MARK_AS_DUPLICATE, ActionType.MARK_AS_NOT_DUPLICATE]
|
|
4882
|
+
},
|
|
4883
|
+
{
|
|
4884
|
+
flag: InherentFlags.EDIT_IN_PROGRESS,
|
|
4885
|
+
setOn: [ActionType.EDIT],
|
|
4886
|
+
resetOnAnyOtherAction: true
|
|
4887
|
+
}
|
|
4888
|
+
];
|
|
4889
|
+
|
|
5494
4890
|
// ../commons/src/events/defineConfig.ts
|
|
5495
4891
|
var IGNORED_EVENT_TYPES = [
|
|
5496
4892
|
"FOOTBALL_CLUB_MEMBERSHIP",
|
|
@@ -8072,20 +7468,20 @@ var AVAILABLE_ACTIONS_BY_EVENT_STATUS = {
|
|
|
8072
7468
|
]
|
|
8073
7469
|
};
|
|
8074
7470
|
var ACTION_FILTERS = {
|
|
8075
|
-
[ActionType.PRINT_CERTIFICATE]: (flags) => !flags.includes(InherentFlags.CORRECTION_REQUESTED) && !flags.some((
|
|
8076
|
-
[ActionType.REQUEST_CORRECTION]: (flags) => !flags.includes(InherentFlags.CORRECTION_REQUESTED) && !flags.some((
|
|
8077
|
-
[ClientSpecificAction.REVIEW_CORRECTION_REQUEST]: (flags) => flags.includes(InherentFlags.CORRECTION_REQUESTED) && !flags.some((
|
|
8078
|
-
[ActionType.APPROVE_CORRECTION]: (flags) => flags.includes(InherentFlags.CORRECTION_REQUESTED) && !flags.some((
|
|
8079
|
-
[ActionType.REJECT_CORRECTION]: (flags) => flags.includes(InherentFlags.CORRECTION_REQUESTED) && !flags.some((
|
|
8080
|
-
[ActionType.MARK_AS_DUPLICATE]: (flags) => flags.includes(InherentFlags.POTENTIAL_DUPLICATE) && !flags.some((
|
|
8081
|
-
[ActionType.EDIT]: (flags) => !flags.includes(InherentFlags.POTENTIAL_DUPLICATE) && !flags.some((
|
|
8082
|
-
[ActionType.REGISTER]: (flags) => !flags.includes(InherentFlags.POTENTIAL_DUPLICATE) && !flags.some((
|
|
8083
|
-
[ActionType.REJECT]: (flags) => !flags.includes(InherentFlags.REJECTED) && !flags.some((
|
|
8084
|
-
[ActionType.ARCHIVE]: (flags) => !flags.some((
|
|
8085
|
-
[ActionType.UNARCHIVE]: (flags) => !flags.some((
|
|
8086
|
-
[ActionType.ASSIGN]: (flags) => !flags.some((
|
|
8087
|
-
[ActionType.UNASSIGN]: (flags) => !flags.some((
|
|
8088
|
-
[ActionType.CUSTOM]: (flags) => !flags.some((
|
|
7471
|
+
[ActionType.PRINT_CERTIFICATE]: (flags) => !flags.includes(InherentFlags.CORRECTION_REQUESTED) && !flags.some((flag) => flag.endsWith(":requested")),
|
|
7472
|
+
[ActionType.REQUEST_CORRECTION]: (flags) => !flags.includes(InherentFlags.CORRECTION_REQUESTED) && !flags.some((flag) => flag.endsWith(":requested")),
|
|
7473
|
+
[ClientSpecificAction.REVIEW_CORRECTION_REQUEST]: (flags) => flags.includes(InherentFlags.CORRECTION_REQUESTED) && !flags.some((flag) => flag.endsWith(":requested")),
|
|
7474
|
+
[ActionType.APPROVE_CORRECTION]: (flags) => flags.includes(InherentFlags.CORRECTION_REQUESTED) && !flags.some((flag) => flag.endsWith(":requested")),
|
|
7475
|
+
[ActionType.REJECT_CORRECTION]: (flags) => flags.includes(InherentFlags.CORRECTION_REQUESTED) && !flags.some((flag) => flag.endsWith(":requested")),
|
|
7476
|
+
[ActionType.MARK_AS_DUPLICATE]: (flags) => flags.includes(InherentFlags.POTENTIAL_DUPLICATE) && !flags.some((flag) => flag.endsWith(":requested")),
|
|
7477
|
+
[ActionType.EDIT]: (flags) => !flags.includes(InherentFlags.POTENTIAL_DUPLICATE) && !flags.some((flag) => flag.endsWith(":requested")),
|
|
7478
|
+
[ActionType.REGISTER]: (flags) => !flags.includes(InherentFlags.POTENTIAL_DUPLICATE) && !flags.some((flag) => flag.endsWith(":requested")),
|
|
7479
|
+
[ActionType.REJECT]: (flags) => !flags.includes(InherentFlags.REJECTED) && !flags.some((flag) => flag.endsWith(":requested")),
|
|
7480
|
+
[ActionType.ARCHIVE]: (flags) => !flags.some((flag) => flag.endsWith(":requested")),
|
|
7481
|
+
[ActionType.UNARCHIVE]: (flags) => !flags.some((flag) => flag.endsWith(":requested")),
|
|
7482
|
+
[ActionType.ASSIGN]: (flags) => !flags.some((flag) => flag.endsWith(":requested")),
|
|
7483
|
+
[ActionType.UNASSIGN]: (flags) => !flags.some((flag) => flag.endsWith(":requested")),
|
|
7484
|
+
[ActionType.CUSTOM]: (flags) => !flags.some((flag) => flag.endsWith(":requested"))
|
|
8089
7485
|
};
|
|
8090
7486
|
var REJECTED_ACTIONS = [
|
|
8091
7487
|
ActionType.READ,
|