@opencrvs/toolkit 1.8.0-rc.f876361 → 1.8.0-rc.f89fbcb
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/commons/api/router.d.ts +8398 -831
- package/dist/commons/conditionals/conditionals.d.ts +26 -11
- package/dist/commons/conditionals/validate.d.ts +18 -17
- package/dist/commons/events/ActionConfig.d.ts +120018 -1729
- package/dist/commons/events/ActionDocument.d.ts +2581 -554
- package/dist/commons/events/ActionInput.d.ts +2674 -499
- package/dist/commons/events/ActionType.d.ts +9 -3
- package/dist/commons/events/AdvancedSearchConfig.d.ts +1255 -22
- package/dist/commons/events/CompositeFieldValue.d.ts +31 -0
- 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 +172 -46
- package/dist/commons/events/EventConfig.d.ts +57845 -1354
- package/dist/commons/events/EventDocument.d.ts +1635 -391
- package/dist/commons/events/EventIndex.d.ts +2007 -27
- package/dist/commons/events/EventMetadata.d.ts +343 -45
- package/dist/commons/events/FieldConfig.d.ts +5780 -1066
- package/dist/commons/events/FieldType.d.ts +6 -3
- package/dist/commons/events/FieldTypeMapping.d.ts +103 -54
- package/dist/commons/events/FieldValue.d.ts +49 -8
- package/dist/commons/events/FormConfig.d.ts +50248 -514
- package/dist/commons/events/PageConfig.d.ts +12472 -234
- package/dist/commons/events/SummaryConfig.d.ts +93 -42
- package/dist/commons/events/TemplateConfig.d.ts +5 -5
- package/dist/commons/events/User.d.ts +31 -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 +9289 -58
- package/dist/commons/events/event.d.ts +54 -0
- package/dist/commons/events/field.d.ts +94 -0
- package/dist/commons/events/index.d.ts +8 -0
- 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 +157 -157
- package/dist/commons/events/transactions.d.ts +1 -1
- package/dist/commons/events/utils.d.ts +13799 -78
- package/dist/commons/events/utils.test.d.ts +2 -0
- package/dist/commons/events/workqueueDefaultColumns.d.ts +3 -0
- package/dist/conditionals/index.js +208 -185
- package/dist/events/index.js +4843 -2050
- package/dist/scopes/index.d.ts +161 -1
- package/dist/scopes/index.js +202 -1
- package/package.json +4 -3
@@ -22,19 +22,48 @@ 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
|
+
"signatureFilename",
|
44
|
+
"primaryOfficeId"
|
45
|
+
])
|
46
|
+
});
|
47
|
+
function userSerializer(userField) {
|
48
|
+
return {
|
49
|
+
$userField: userField
|
50
|
+
};
|
51
|
+
}
|
52
|
+
|
34
53
|
// ../commons/src/conditionals/conditionals.ts
|
35
54
|
function defineConditional(schema) {
|
36
55
|
return schema;
|
37
56
|
}
|
57
|
+
function defineFormConditional(schema) {
|
58
|
+
const schemaWithForm = {
|
59
|
+
type: "object",
|
60
|
+
properties: {
|
61
|
+
$form: schema
|
62
|
+
},
|
63
|
+
required: ["$form"]
|
64
|
+
};
|
65
|
+
return defineConditional(schemaWithForm);
|
66
|
+
}
|
38
67
|
function alwaysTrue() {
|
39
68
|
return {};
|
40
69
|
}
|
@@ -59,7 +88,10 @@ function not(condition) {
|
|
59
88
|
required: []
|
60
89
|
});
|
61
90
|
}
|
62
|
-
|
91
|
+
function never() {
|
92
|
+
return not(alwaysTrue());
|
93
|
+
}
|
94
|
+
var user = Object.assign(userSerializer, {
|
63
95
|
hasScope: (scope) => defineConditional({
|
64
96
|
type: "object",
|
65
97
|
properties: {
|
@@ -79,127 +111,154 @@ var user = {
|
|
79
111
|
},
|
80
112
|
required: ["$user"]
|
81
113
|
})
|
82
|
-
};
|
83
|
-
|
84
|
-
|
114
|
+
});
|
115
|
+
function createEventConditionals() {
|
116
|
+
return {
|
117
|
+
/**
|
118
|
+
* Checks if the event contains a specific action type.
|
119
|
+
* @param action - The action type to check for.
|
120
|
+
*/
|
121
|
+
hasAction: (action) => defineConditional({
|
122
|
+
type: "object",
|
123
|
+
properties: {
|
124
|
+
$event: {
|
125
|
+
type: "object",
|
126
|
+
properties: {
|
127
|
+
actions: {
|
128
|
+
type: "array",
|
129
|
+
contains: {
|
130
|
+
type: "object",
|
131
|
+
properties: {
|
132
|
+
type: {
|
133
|
+
const: action
|
134
|
+
}
|
135
|
+
},
|
136
|
+
required: ["type"]
|
137
|
+
}
|
138
|
+
}
|
139
|
+
},
|
140
|
+
required: ["actions"]
|
141
|
+
}
|
142
|
+
},
|
143
|
+
required: ["$event"]
|
144
|
+
})
|
145
|
+
};
|
146
|
+
}
|
147
|
+
function getDateRangeToFieldReference(fieldId, comparedFieldId, clause) {
|
148
|
+
return {
|
85
149
|
type: "object",
|
86
150
|
properties: {
|
87
|
-
|
88
|
-
type: "
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
151
|
+
[fieldId]: {
|
152
|
+
type: "string",
|
153
|
+
format: "date",
|
154
|
+
[clause]: { $data: `1/${comparedFieldId}` }
|
155
|
+
},
|
156
|
+
[comparedFieldId]: { type: "string", format: "date" }
|
157
|
+
},
|
158
|
+
required: [fieldId]
|
159
|
+
};
|
160
|
+
}
|
161
|
+
function isFieldReference(value) {
|
162
|
+
return typeof value === "object" && value !== null && "$$field" in value;
|
163
|
+
}
|
164
|
+
function createFieldConditionals(fieldId) {
|
165
|
+
const getDayRange = (days, clause) => ({
|
166
|
+
type: "object",
|
167
|
+
properties: {
|
168
|
+
[fieldId]: {
|
169
|
+
type: "string",
|
170
|
+
format: "date",
|
171
|
+
daysFromNow: {
|
172
|
+
days,
|
173
|
+
clause
|
174
|
+
}
|
104
175
|
}
|
105
176
|
},
|
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];
|
177
|
+
required: [fieldId]
|
178
|
+
});
|
111
179
|
const getDateRange = (date, clause) => ({
|
112
180
|
type: "object",
|
113
181
|
properties: {
|
114
|
-
|
115
|
-
type: "
|
116
|
-
|
117
|
-
|
118
|
-
type: "string",
|
119
|
-
format: "date",
|
120
|
-
[clause]: date
|
121
|
-
}
|
122
|
-
},
|
123
|
-
required: [fieldId]
|
182
|
+
[fieldId]: {
|
183
|
+
type: "string",
|
184
|
+
format: "date",
|
185
|
+
[clause]: date
|
124
186
|
}
|
125
187
|
},
|
126
|
-
required: [
|
188
|
+
required: [fieldId]
|
127
189
|
});
|
128
190
|
return {
|
129
191
|
/**
|
130
192
|
* @private Internal property used for field reference tracking.
|
131
193
|
*/
|
132
|
-
|
194
|
+
$$field: fieldId,
|
133
195
|
isAfter: () => ({
|
134
196
|
days: (days) => ({
|
135
|
-
inPast: () =>
|
136
|
-
|
137
|
-
),
|
138
|
-
inFuture: () => defineConditional(
|
139
|
-
getDateRange(getDateFromNow(-days), "formatMinimum")
|
140
|
-
)
|
197
|
+
inPast: () => defineFormConditional(getDayRange(-days, "after")),
|
198
|
+
inFuture: () => defineFormConditional(getDayRange(days, "after"))
|
141
199
|
}),
|
142
|
-
date: (date) =>
|
143
|
-
|
200
|
+
date: (date) => {
|
201
|
+
if (isFieldReference(date)) {
|
202
|
+
const comparedFieldId = date.$$field;
|
203
|
+
return defineFormConditional(
|
204
|
+
getDateRangeToFieldReference(
|
205
|
+
fieldId,
|
206
|
+
comparedFieldId,
|
207
|
+
"formatMinimum"
|
208
|
+
)
|
209
|
+
);
|
210
|
+
}
|
211
|
+
return defineFormConditional(getDateRange(date, "formatMinimum"));
|
212
|
+
},
|
213
|
+
now: () => defineFormConditional(getDateRange({ $data: "/$now" }, "formatMinimum"))
|
144
214
|
}),
|
145
215
|
isBefore: () => ({
|
146
216
|
days: (days) => ({
|
147
|
-
inPast: () =>
|
148
|
-
|
149
|
-
),
|
150
|
-
inFuture: () => defineConditional(
|
151
|
-
getDateRange(getDateFromNow(-days), "formatMaximum")
|
152
|
-
)
|
217
|
+
inPast: () => defineFormConditional(getDayRange(days, "before")),
|
218
|
+
inFuture: () => defineFormConditional(getDayRange(-days, "before"))
|
153
219
|
}),
|
154
|
-
date: (date) =>
|
155
|
-
|
220
|
+
date: (date) => {
|
221
|
+
if (isFieldReference(date)) {
|
222
|
+
const comparedFieldId = date.$$field;
|
223
|
+
return defineFormConditional(
|
224
|
+
getDateRangeToFieldReference(
|
225
|
+
fieldId,
|
226
|
+
comparedFieldId,
|
227
|
+
"formatMaximum"
|
228
|
+
)
|
229
|
+
);
|
230
|
+
}
|
231
|
+
return defineFormConditional(getDateRange(date, "formatMaximum"));
|
232
|
+
},
|
233
|
+
now: () => defineFormConditional(getDateRange({ $data: "/$now" }, "formatMaximum"))
|
156
234
|
}),
|
157
|
-
// TODO CIHAN: typing
|
158
235
|
isEqualTo: (value) => {
|
159
|
-
if (
|
160
|
-
const comparedFieldId = value
|
161
|
-
return
|
236
|
+
if (isFieldReference(value)) {
|
237
|
+
const comparedFieldId = value.$$field;
|
238
|
+
return defineFormConditional({
|
162
239
|
type: "object",
|
163
240
|
properties: {
|
164
|
-
|
165
|
-
type: "
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
},
|
170
|
-
required: [fieldId, comparedFieldId],
|
171
|
-
allOf: [
|
172
|
-
{
|
173
|
-
properties: {
|
174
|
-
[fieldId]: {
|
175
|
-
const: { $data: `1/${comparedFieldId}` }
|
176
|
-
}
|
177
|
-
}
|
178
|
-
}
|
179
|
-
]
|
180
|
-
}
|
241
|
+
[fieldId]: {
|
242
|
+
type: ["string", "boolean"],
|
243
|
+
const: { $data: `/$form/${comparedFieldId}` }
|
244
|
+
},
|
245
|
+
[comparedFieldId]: { type: ["string", "boolean"] }
|
181
246
|
},
|
182
|
-
required: [
|
247
|
+
required: [fieldId, comparedFieldId]
|
183
248
|
});
|
184
249
|
}
|
185
|
-
return
|
250
|
+
return defineFormConditional({
|
186
251
|
type: "object",
|
187
252
|
properties: {
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
{ type: "boolean", const: value }
|
195
|
-
],
|
196
|
-
const: value
|
197
|
-
}
|
198
|
-
},
|
199
|
-
required: [fieldId]
|
253
|
+
[fieldId]: {
|
254
|
+
oneOf: [
|
255
|
+
{ type: "string", const: value },
|
256
|
+
{ type: "boolean", const: value }
|
257
|
+
],
|
258
|
+
const: value
|
200
259
|
}
|
201
260
|
},
|
202
|
-
required: [
|
261
|
+
required: [fieldId]
|
203
262
|
});
|
204
263
|
},
|
205
264
|
/**
|
@@ -210,140 +269,104 @@ function field(fieldId) {
|
|
210
269
|
* NOTE: For now, this only works with string, boolean, and null types. 0 is still allowed.
|
211
270
|
*
|
212
271
|
*/
|
213
|
-
isFalsy: () =>
|
272
|
+
isFalsy: () => defineFormConditional({
|
214
273
|
type: "object",
|
215
274
|
properties: {
|
216
|
-
|
217
|
-
type: "object",
|
218
|
-
properties: {
|
219
|
-
[fieldId]: {
|
220
|
-
anyOf: [
|
221
|
-
{ const: "undefined" },
|
222
|
-
{ const: false },
|
223
|
-
{ const: null },
|
224
|
-
{ const: "" }
|
225
|
-
]
|
226
|
-
}
|
227
|
-
},
|
275
|
+
[fieldId]: {
|
228
276
|
anyOf: [
|
229
|
-
{
|
230
|
-
|
231
|
-
},
|
232
|
-
{
|
233
|
-
not: {
|
234
|
-
required: [fieldId]
|
235
|
-
}
|
236
|
-
}
|
277
|
+
{ const: "undefined" },
|
278
|
+
{ const: false },
|
279
|
+
{ const: null },
|
280
|
+
{ const: "" }
|
237
281
|
]
|
238
282
|
}
|
239
283
|
},
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
$form: {
|
246
|
-
type: "object",
|
247
|
-
properties: {
|
248
|
-
[fieldId]: {
|
249
|
-
type: "string",
|
250
|
-
enum: ["undefined"]
|
251
|
-
}
|
252
|
-
},
|
284
|
+
anyOf: [
|
285
|
+
{
|
286
|
+
required: [fieldId]
|
287
|
+
},
|
288
|
+
{
|
253
289
|
not: {
|
254
290
|
required: [fieldId]
|
255
291
|
}
|
256
292
|
}
|
257
|
-
|
258
|
-
required: ["$form"]
|
293
|
+
]
|
259
294
|
}),
|
260
|
-
|
295
|
+
isUndefined: () => defineFormConditional({
|
261
296
|
type: "object",
|
262
297
|
properties: {
|
263
|
-
|
264
|
-
type: "
|
265
|
-
|
266
|
-
[fieldId]: {
|
267
|
-
type: "string",
|
268
|
-
enum: values
|
269
|
-
}
|
270
|
-
},
|
271
|
-
required: [fieldId]
|
298
|
+
[fieldId]: {
|
299
|
+
type: "string",
|
300
|
+
enum: ["undefined"]
|
272
301
|
}
|
273
302
|
},
|
274
|
-
|
303
|
+
not: {
|
304
|
+
required: [fieldId]
|
305
|
+
}
|
275
306
|
}),
|
276
|
-
|
307
|
+
inArray: (values) => defineFormConditional({
|
277
308
|
type: "object",
|
278
309
|
properties: {
|
279
|
-
|
280
|
-
type: "
|
281
|
-
|
282
|
-
[fieldId]: {
|
283
|
-
type: "string",
|
284
|
-
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'._-]*)*$",
|
285
|
-
description: "Name must contain only letters, numbers, and allowed special characters ('._-). No double spaces."
|
286
|
-
}
|
287
|
-
},
|
288
|
-
required: [fieldId]
|
310
|
+
[fieldId]: {
|
311
|
+
type: "string",
|
312
|
+
enum: values
|
289
313
|
}
|
290
314
|
},
|
291
|
-
required: [
|
315
|
+
required: [fieldId]
|
292
316
|
}),
|
293
|
-
|
317
|
+
isValidEnglishName: () => defineFormConditional({
|
294
318
|
type: "object",
|
295
319
|
properties: {
|
296
|
-
|
297
|
-
type: "
|
298
|
-
|
299
|
-
|
300
|
-
type: "string",
|
301
|
-
pattern: "^[0-9]{9}$",
|
302
|
-
description: "The National ID can only be numeric and must be 9 digits long."
|
303
|
-
}
|
304
|
-
},
|
305
|
-
required: [fieldId]
|
320
|
+
[fieldId]: {
|
321
|
+
type: "string",
|
322
|
+
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'._-]*)*$",
|
323
|
+
description: "Name must contain only letters, numbers, and allowed special characters ('._-). No double spaces."
|
306
324
|
}
|
307
325
|
},
|
308
|
-
required: [
|
326
|
+
required: [fieldId]
|
309
327
|
}),
|
310
328
|
/**
|
311
329
|
* Checks if the field value matches a given regular expression pattern.
|
312
330
|
* @param pattern - The regular expression pattern to match the field value against.
|
313
331
|
* @returns A JSONSchema conditional that validates the field value against the pattern.
|
314
332
|
*/
|
315
|
-
matches: (pattern) =>
|
333
|
+
matches: (pattern) => defineFormConditional({
|
316
334
|
type: "object",
|
317
335
|
properties: {
|
318
|
-
|
319
|
-
type: "
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
336
|
+
[fieldId]: {
|
337
|
+
type: "string",
|
338
|
+
pattern
|
339
|
+
}
|
340
|
+
},
|
341
|
+
required: [fieldId]
|
342
|
+
}),
|
343
|
+
isBetween: (min, max) => defineFormConditional({
|
344
|
+
type: "object",
|
345
|
+
properties: {
|
346
|
+
[fieldId]: {
|
347
|
+
type: "number",
|
348
|
+
minimum: min,
|
349
|
+
maximum: max
|
327
350
|
}
|
328
351
|
},
|
329
|
-
required: [
|
352
|
+
required: [fieldId]
|
330
353
|
}),
|
331
|
-
|
354
|
+
getId: () => ({ fieldId }),
|
355
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
356
|
+
object: (options) => defineFormConditional({
|
332
357
|
type: "object",
|
333
358
|
properties: {
|
334
|
-
|
359
|
+
[fieldId]: {
|
335
360
|
type: "object",
|
336
|
-
properties:
|
337
|
-
[
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
},
|
343
|
-
required: [fieldId]
|
361
|
+
properties: Object.fromEntries(
|
362
|
+
Object.entries(options).map(([key, value]) => {
|
363
|
+
return [key, value.properties.$form.properties[key]];
|
364
|
+
})
|
365
|
+
),
|
366
|
+
required: Object.keys(options)
|
344
367
|
}
|
345
368
|
},
|
346
|
-
required: [
|
369
|
+
required: [fieldId]
|
347
370
|
})
|
348
371
|
};
|
349
372
|
}
|