@opencrvs/toolkit 1.8.0-rc.fe799b0 → 1.8.0-rc.fe7c504
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/README.md +1 -1
- package/dist/commons/api/router.d.ts +12626 -10500
- package/dist/commons/conditionals/conditionals.d.ts +37 -6
- package/dist/commons/conditionals/validate-address.test.d.ts +2 -0
- package/dist/commons/conditionals/validate.d.ts +45 -17
- package/dist/commons/conditionals/validate.test.d.ts +2 -0
- package/dist/commons/events/ActionConfig.d.ts +119422 -2084
- package/dist/commons/events/ActionDocument.d.ts +11632 -435
- package/dist/commons/events/ActionInput.d.ts +6716 -663
- package/dist/commons/events/ActionType.d.ts +31 -12
- package/dist/commons/events/AdvancedSearchConfig.d.ts +1233 -22
- package/dist/commons/events/CompositeFieldValue.d.ts +183 -2
- package/dist/commons/events/Conditional.d.ts +21 -5
- package/dist/commons/events/Constants.d.ts +3 -0
- package/dist/commons/events/CountryConfigQueryInput.d.ts +3730 -0
- package/dist/commons/events/CreatedAtLocation.d.ts +2 -0
- package/dist/commons/events/Draft.d.ts +488 -69
- package/dist/commons/events/EventConfig.d.ts +57615 -1821
- package/dist/commons/events/EventConfigInput.d.ts +6 -3
- package/dist/commons/events/EventDocument.d.ts +4762 -607
- package/dist/commons/events/EventIndex.d.ts +2012 -24
- package/dist/commons/events/EventMetadata.d.ts +343 -42
- package/dist/commons/events/FieldConfig.d.ts +6001 -972
- package/dist/commons/events/FieldType.d.ts +10 -2
- package/dist/commons/events/FieldTypeMapping.d.ts +218 -18
- package/dist/commons/events/FieldValue.d.ts +123 -8
- package/dist/commons/events/FormConfig.d.ts +50409 -90
- package/dist/commons/events/PageConfig.d.ts +12597 -0
- package/dist/commons/events/SummaryConfig.d.ts +93 -42
- package/dist/commons/events/TemplateConfig.d.ts +38 -0
- package/dist/commons/events/User.d.ts +34 -2
- package/dist/commons/events/WorkqueueColumnConfig.d.ts +53 -0
- package/dist/commons/events/WorkqueueConfig.d.ts +7300 -20
- package/dist/commons/events/defineConfig.d.ts +9405 -307
- package/dist/commons/events/event.d.ts +54 -0
- package/dist/commons/events/field.d.ts +82 -0
- package/dist/commons/events/index.d.ts +11 -1
- package/dist/commons/events/scopes.d.ts +44 -0
- package/dist/commons/events/serializer.d.ts +2 -0
- package/dist/commons/events/test.utils.d.ts +245 -225
- package/dist/commons/events/transactions.d.ts +1 -1
- package/dist/commons/events/utils.d.ts +13906 -69
- package/dist/commons/events/utils.test.d.ts +2 -0
- package/dist/commons/events/workqueueDefaultColumns.d.ts +3 -0
- package/dist/conditionals/index.js +244 -115
- package/dist/events/index.js +5263 -1871
- package/dist/scopes/index.d.ts +247 -1
- package/dist/scopes/index.js +231 -1
- package/package.json +4 -3
@@ -22,19 +22,49 @@ var conditionals_exports = {};
|
|
22
22
|
__export(conditionals_exports, {
|
23
23
|
alwaysTrue: () => alwaysTrue,
|
24
24
|
and: () => and,
|
25
|
+
createEventConditionals: () => createEventConditionals,
|
26
|
+
createFieldConditionals: () => createFieldConditionals,
|
25
27
|
defineConditional: () => defineConditional,
|
26
|
-
|
27
|
-
|
28
|
+
defineFormConditional: () => defineFormConditional,
|
29
|
+
never: () => never,
|
28
30
|
not: () => not,
|
29
31
|
or: () => or,
|
30
32
|
user: () => user
|
31
33
|
});
|
32
34
|
module.exports = __toCommonJS(conditionals_exports);
|
33
35
|
|
36
|
+
// ../commons/src/events/serializers/user/serializer.ts
|
37
|
+
var import_zod = require("zod");
|
38
|
+
var SerializedUserField = import_zod.z.object({
|
39
|
+
$userField: import_zod.z.enum([
|
40
|
+
"id",
|
41
|
+
"name",
|
42
|
+
"role",
|
43
|
+
"signature",
|
44
|
+
"avatar",
|
45
|
+
"primaryOfficeId"
|
46
|
+
])
|
47
|
+
});
|
48
|
+
function userSerializer(userField) {
|
49
|
+
return {
|
50
|
+
$userField: userField
|
51
|
+
};
|
52
|
+
}
|
53
|
+
|
34
54
|
// ../commons/src/conditionals/conditionals.ts
|
35
55
|
function defineConditional(schema) {
|
36
56
|
return schema;
|
37
57
|
}
|
58
|
+
function defineFormConditional(schema) {
|
59
|
+
const schemaWithForm = {
|
60
|
+
type: "object",
|
61
|
+
properties: {
|
62
|
+
$form: schema
|
63
|
+
},
|
64
|
+
required: ["$form"]
|
65
|
+
};
|
66
|
+
return defineConditional(schemaWithForm);
|
67
|
+
}
|
38
68
|
function alwaysTrue() {
|
39
69
|
return {};
|
40
70
|
}
|
@@ -59,7 +89,10 @@ function not(condition) {
|
|
59
89
|
required: []
|
60
90
|
});
|
61
91
|
}
|
62
|
-
|
92
|
+
function never() {
|
93
|
+
return not(alwaysTrue());
|
94
|
+
}
|
95
|
+
var user = Object.assign(userSerializer, {
|
63
96
|
hasScope: (scope) => defineConditional({
|
64
97
|
type: "object",
|
65
98
|
properties: {
|
@@ -79,96 +112,156 @@ var user = {
|
|
79
112
|
},
|
80
113
|
required: ["$user"]
|
81
114
|
})
|
82
|
-
};
|
83
|
-
|
84
|
-
|
115
|
+
});
|
116
|
+
function createEventConditionals() {
|
117
|
+
return {
|
118
|
+
/**
|
119
|
+
* Checks if the event contains a specific action type.
|
120
|
+
* @param action - The action type to check for.
|
121
|
+
*/
|
122
|
+
hasAction: (action) => defineConditional({
|
123
|
+
type: "object",
|
124
|
+
properties: {
|
125
|
+
$event: {
|
126
|
+
type: "object",
|
127
|
+
properties: {
|
128
|
+
actions: {
|
129
|
+
type: "array",
|
130
|
+
contains: {
|
131
|
+
type: "object",
|
132
|
+
properties: {
|
133
|
+
type: {
|
134
|
+
const: action
|
135
|
+
}
|
136
|
+
},
|
137
|
+
required: ["type"]
|
138
|
+
}
|
139
|
+
}
|
140
|
+
},
|
141
|
+
required: ["actions"]
|
142
|
+
}
|
143
|
+
},
|
144
|
+
required: ["$event"]
|
145
|
+
})
|
146
|
+
};
|
147
|
+
}
|
148
|
+
function getDateRangeToFieldReference(fieldId, comparedFieldId, clause) {
|
149
|
+
return {
|
85
150
|
type: "object",
|
86
151
|
properties: {
|
87
|
-
|
88
|
-
type: "
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
152
|
+
[fieldId]: {
|
153
|
+
type: "string",
|
154
|
+
format: "date",
|
155
|
+
[clause]: { $data: `1/${comparedFieldId}` }
|
156
|
+
},
|
157
|
+
[comparedFieldId]: { type: "string", format: "date" }
|
158
|
+
},
|
159
|
+
required: [fieldId]
|
160
|
+
};
|
161
|
+
}
|
162
|
+
function isFieldReference(value) {
|
163
|
+
return typeof value === "object" && value !== null && "$$field" in value;
|
164
|
+
}
|
165
|
+
function createFieldConditionals(fieldId) {
|
166
|
+
const getDayRange = (days, clause) => ({
|
167
|
+
type: "object",
|
168
|
+
properties: {
|
169
|
+
[fieldId]: {
|
170
|
+
type: "string",
|
171
|
+
format: "date",
|
172
|
+
daysFromNow: {
|
173
|
+
days,
|
174
|
+
clause
|
175
|
+
}
|
104
176
|
}
|
105
177
|
},
|
106
|
-
required: [
|
107
|
-
})
|
108
|
-
};
|
109
|
-
function field(fieldId) {
|
110
|
-
const getDateFromNow = (days) => new Date(Date.now() - days * 24 * 60 * 60 * 1e3).toISOString().split("T")[0];
|
178
|
+
required: [fieldId]
|
179
|
+
});
|
111
180
|
const getDateRange = (date, clause) => ({
|
112
181
|
type: "object",
|
113
182
|
properties: {
|
114
|
-
|
115
|
-
type: "
|
116
|
-
|
117
|
-
|
118
|
-
type: "string",
|
119
|
-
format: "date",
|
120
|
-
[clause]: date
|
121
|
-
}
|
122
|
-
},
|
123
|
-
required: [fieldId]
|
183
|
+
[fieldId]: {
|
184
|
+
type: "string",
|
185
|
+
format: "date",
|
186
|
+
[clause]: date
|
124
187
|
}
|
125
188
|
},
|
126
|
-
required: [
|
189
|
+
required: [fieldId]
|
127
190
|
});
|
128
191
|
return {
|
192
|
+
/**
|
193
|
+
* @private Internal property used for field reference tracking.
|
194
|
+
*/
|
195
|
+
$$field: fieldId,
|
129
196
|
isAfter: () => ({
|
130
197
|
days: (days) => ({
|
131
|
-
inPast: () =>
|
132
|
-
|
133
|
-
),
|
134
|
-
inFuture: () => defineConditional(
|
135
|
-
getDateRange(getDateFromNow(-days), "formatMinimum")
|
136
|
-
)
|
198
|
+
inPast: () => defineFormConditional(getDayRange(-days, "after")),
|
199
|
+
inFuture: () => defineFormConditional(getDayRange(days, "after"))
|
137
200
|
}),
|
138
|
-
date: (date) =>
|
139
|
-
|
201
|
+
date: (date) => {
|
202
|
+
if (isFieldReference(date)) {
|
203
|
+
const comparedFieldId = date.$$field;
|
204
|
+
return defineFormConditional(
|
205
|
+
getDateRangeToFieldReference(
|
206
|
+
fieldId,
|
207
|
+
comparedFieldId,
|
208
|
+
"formatMinimum"
|
209
|
+
)
|
210
|
+
);
|
211
|
+
}
|
212
|
+
return defineFormConditional(getDateRange(date, "formatMinimum"));
|
213
|
+
},
|
214
|
+
now: () => defineFormConditional(getDateRange({ $data: "/$now" }, "formatMinimum"))
|
140
215
|
}),
|
141
216
|
isBefore: () => ({
|
142
217
|
days: (days) => ({
|
143
|
-
inPast: () =>
|
144
|
-
|
145
|
-
),
|
146
|
-
inFuture: () => defineConditional(
|
147
|
-
getDateRange(getDateFromNow(-days), "formatMaximum")
|
148
|
-
)
|
218
|
+
inPast: () => defineFormConditional(getDayRange(days, "before")),
|
219
|
+
inFuture: () => defineFormConditional(getDayRange(-days, "before"))
|
149
220
|
}),
|
150
|
-
date: (date) =>
|
151
|
-
|
221
|
+
date: (date) => {
|
222
|
+
if (isFieldReference(date)) {
|
223
|
+
const comparedFieldId = date.$$field;
|
224
|
+
return defineFormConditional(
|
225
|
+
getDateRangeToFieldReference(
|
226
|
+
fieldId,
|
227
|
+
comparedFieldId,
|
228
|
+
"formatMaximum"
|
229
|
+
)
|
230
|
+
);
|
231
|
+
}
|
232
|
+
return defineFormConditional(getDateRange(date, "formatMaximum"));
|
233
|
+
},
|
234
|
+
now: () => defineFormConditional(getDateRange({ $data: "/$now" }, "formatMaximum"))
|
152
235
|
}),
|
153
|
-
isEqualTo: (value) =>
|
154
|
-
|
155
|
-
|
156
|
-
|
236
|
+
isEqualTo: (value) => {
|
237
|
+
if (isFieldReference(value)) {
|
238
|
+
const comparedFieldId = value.$$field;
|
239
|
+
return defineFormConditional({
|
157
240
|
type: "object",
|
158
241
|
properties: {
|
159
242
|
[fieldId]: {
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
const: value
|
165
|
-
}
|
243
|
+
type: ["string", "boolean"],
|
244
|
+
const: { $data: `/$form/${comparedFieldId}` }
|
245
|
+
},
|
246
|
+
[comparedFieldId]: { type: ["string", "boolean"] }
|
166
247
|
},
|
167
|
-
required: [fieldId]
|
168
|
-
}
|
169
|
-
}
|
170
|
-
|
171
|
-
|
248
|
+
required: [fieldId, comparedFieldId]
|
249
|
+
});
|
250
|
+
}
|
251
|
+
return defineFormConditional({
|
252
|
+
type: "object",
|
253
|
+
properties: {
|
254
|
+
[fieldId]: {
|
255
|
+
oneOf: [
|
256
|
+
{ type: "string", const: value },
|
257
|
+
{ type: "boolean", const: value }
|
258
|
+
],
|
259
|
+
const: value
|
260
|
+
}
|
261
|
+
},
|
262
|
+
required: [fieldId]
|
263
|
+
});
|
264
|
+
},
|
172
265
|
/**
|
173
266
|
* Use case: Some fields are rendered when selection is not made, or boolean false is explicitly selected.
|
174
267
|
* @example field('recommender.none').isFalsy() vs not(field('recommender.none').isEqualTo(true))
|
@@ -177,68 +270,104 @@ function field(fieldId) {
|
|
177
270
|
* NOTE: For now, this only works with string, boolean, and null types. 0 is still allowed.
|
178
271
|
*
|
179
272
|
*/
|
180
|
-
isFalsy: () =>
|
273
|
+
isFalsy: () => defineFormConditional({
|
181
274
|
type: "object",
|
182
275
|
properties: {
|
183
|
-
|
184
|
-
type: "object",
|
185
|
-
properties: {
|
186
|
-
[fieldId]: {
|
187
|
-
anyOf: [
|
188
|
-
{ const: "undefined" },
|
189
|
-
{ const: false },
|
190
|
-
{ const: null },
|
191
|
-
{ const: "" }
|
192
|
-
]
|
193
|
-
}
|
194
|
-
},
|
276
|
+
[fieldId]: {
|
195
277
|
anyOf: [
|
196
|
-
{
|
197
|
-
|
198
|
-
},
|
199
|
-
{
|
200
|
-
not: {
|
201
|
-
required: [fieldId]
|
202
|
-
}
|
203
|
-
}
|
278
|
+
{ const: "undefined" },
|
279
|
+
{ const: false },
|
280
|
+
{ const: null },
|
281
|
+
{ const: "" }
|
204
282
|
]
|
205
283
|
}
|
206
284
|
},
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
$form: {
|
213
|
-
type: "object",
|
214
|
-
properties: {
|
215
|
-
[fieldId]: {
|
216
|
-
type: "string",
|
217
|
-
enum: ["undefined"]
|
218
|
-
}
|
219
|
-
},
|
285
|
+
anyOf: [
|
286
|
+
{
|
287
|
+
required: [fieldId]
|
288
|
+
},
|
289
|
+
{
|
220
290
|
not: {
|
221
291
|
required: [fieldId]
|
222
292
|
}
|
223
293
|
}
|
294
|
+
]
|
295
|
+
}),
|
296
|
+
isUndefined: () => defineFormConditional({
|
297
|
+
type: "object",
|
298
|
+
properties: {
|
299
|
+
[fieldId]: {
|
300
|
+
type: "string",
|
301
|
+
enum: ["undefined"]
|
302
|
+
}
|
303
|
+
},
|
304
|
+
not: {
|
305
|
+
required: [fieldId]
|
306
|
+
}
|
307
|
+
}),
|
308
|
+
inArray: (values) => defineFormConditional({
|
309
|
+
type: "object",
|
310
|
+
properties: {
|
311
|
+
[fieldId]: {
|
312
|
+
type: "string",
|
313
|
+
enum: values
|
314
|
+
}
|
315
|
+
},
|
316
|
+
required: [fieldId]
|
317
|
+
}),
|
318
|
+
isValidEnglishName: () => defineFormConditional({
|
319
|
+
type: "object",
|
320
|
+
properties: {
|
321
|
+
[fieldId]: {
|
322
|
+
type: "string",
|
323
|
+
pattern: "^[\\p{Script=Latin}0-9'._-]*(\\([\\p{Script=Latin}0-9'._-]+\\))?[\\p{Script=Latin}0-9'._-]*( [\\p{Script=Latin}0-9'._-]*(\\([\\p{Script=Latin}0-9'._-]+\\))?[\\p{Script=Latin}0-9'._-]*)*$",
|
324
|
+
description: "Name must contain only letters, numbers, and allowed special characters ('._-). No double spaces."
|
325
|
+
}
|
326
|
+
},
|
327
|
+
required: [fieldId]
|
328
|
+
}),
|
329
|
+
/**
|
330
|
+
* Checks if the field value matches a given regular expression pattern.
|
331
|
+
* @param pattern - The regular expression pattern to match the field value against.
|
332
|
+
* @returns A JSONSchema conditional that validates the field value against the pattern.
|
333
|
+
*/
|
334
|
+
matches: (pattern) => defineFormConditional({
|
335
|
+
type: "object",
|
336
|
+
properties: {
|
337
|
+
[fieldId]: {
|
338
|
+
type: "string",
|
339
|
+
pattern
|
340
|
+
}
|
341
|
+
},
|
342
|
+
required: [fieldId]
|
343
|
+
}),
|
344
|
+
isBetween: (min, max) => defineFormConditional({
|
345
|
+
type: "object",
|
346
|
+
properties: {
|
347
|
+
[fieldId]: {
|
348
|
+
type: "number",
|
349
|
+
minimum: min,
|
350
|
+
maximum: max
|
351
|
+
}
|
224
352
|
},
|
225
|
-
required: [
|
353
|
+
required: [fieldId]
|
226
354
|
}),
|
227
|
-
|
355
|
+
getId: () => ({ fieldId }),
|
356
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
357
|
+
object: (options) => defineFormConditional({
|
228
358
|
type: "object",
|
229
359
|
properties: {
|
230
|
-
|
360
|
+
[fieldId]: {
|
231
361
|
type: "object",
|
232
|
-
properties:
|
233
|
-
[
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
required: [fieldId]
|
362
|
+
properties: Object.fromEntries(
|
363
|
+
Object.entries(options).map(([key, value]) => {
|
364
|
+
return [key, value.properties.$form.properties[key]];
|
365
|
+
})
|
366
|
+
),
|
367
|
+
required: Object.keys(options)
|
239
368
|
}
|
240
369
|
},
|
241
|
-
required: [
|
370
|
+
required: [fieldId]
|
242
371
|
})
|
243
372
|
};
|
244
373
|
}
|