@opencrvs/toolkit 1.8.0-rc.ffe8c17 → 1.8.1-rc.008155b
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 +8949 -10987
- package/dist/commons/conditionals/conditionals.d.ts +31 -12
- package/dist/commons/conditionals/validate-address.test.d.ts +2 -0
- package/dist/commons/conditionals/validate.d.ts +23 -17
- package/dist/commons/events/ActionConfig.d.ts +118678 -3282
- package/dist/commons/events/ActionDocument.d.ts +14099 -797
- package/dist/commons/events/ActionInput.d.ts +8194 -1095
- package/dist/commons/events/ActionType.d.ts +35 -11
- package/dist/commons/events/AdvancedSearchConfig.d.ts +1300 -22
- package/dist/commons/events/CompositeFieldValue.d.ts +192 -11
- 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 +4132 -0
- package/dist/commons/events/CreatedAtLocation.d.ts +2 -0
- package/dist/commons/events/Draft.d.ts +608 -114
- package/dist/commons/events/EventConfig.d.ts +53975 -3192
- package/dist/commons/events/EventConfigInput.d.ts +6 -3
- package/dist/commons/events/EventDocument.d.ts +5847 -999
- package/dist/commons/events/EventIndex.d.ts +2350 -26
- package/dist/commons/events/EventMetadata.d.ts +347 -44
- package/dist/commons/events/FieldConfig.d.ts +6978 -1210
- package/dist/commons/events/FieldType.d.ts +8 -3
- package/dist/commons/events/FieldTypeMapping.d.ts +253 -268
- package/dist/commons/events/FieldValue.d.ts +159 -93
- package/dist/commons/events/FormConfig.d.ts +55832 -336
- package/dist/commons/events/PageConfig.d.ts +13951 -0
- 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 +34 -2
- package/dist/commons/events/WorkqueueColumnConfig.d.ts +53 -0
- package/dist/commons/events/WorkqueueConfig.d.ts +8240 -20
- package/dist/commons/events/defineConfig.d.ts +8535 -460
- package/dist/commons/events/event.d.ts +54 -0
- package/dist/commons/events/field.d.ts +108 -0
- package/dist/commons/events/index.d.ts +10 -1
- package/dist/commons/events/scopes.d.ts +45 -0
- package/dist/commons/events/serializer.d.ts +2 -0
- package/dist/commons/events/test.utils.d.ts +284 -237
- package/dist/commons/events/transactions.d.ts +1 -1
- package/dist/commons/events/utils.d.ts +15486 -168
- package/dist/commons/events/utils.test.d.ts +2 -0
- package/dist/commons/events/workqueueDefaultColumns.d.ts +3 -0
- package/dist/conditionals/index.js +210 -115
- package/dist/events/index.js +5261 -1870
- package/dist/scopes/index.d.ts +247 -1
- package/dist/scopes/index.js +231 -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
|
+
createFieldConditionals: () => createFieldConditionals,
|
25
26
|
defineConditional: () => defineConditional,
|
26
|
-
|
27
|
-
|
27
|
+
defineFormConditional: () => defineFormConditional,
|
28
|
+
never: () => never,
|
28
29
|
not: () => not,
|
29
30
|
or: () => or,
|
30
31
|
user: () => user
|
31
32
|
});
|
32
33
|
module.exports = __toCommonJS(conditionals_exports);
|
33
34
|
|
35
|
+
// ../commons/src/events/serializers/user/serializer.ts
|
36
|
+
var import_zod = require("zod");
|
37
|
+
var SerializedUserField = import_zod.z.object({
|
38
|
+
$userField: import_zod.z.enum([
|
39
|
+
"id",
|
40
|
+
"name",
|
41
|
+
"role",
|
42
|
+
"signature",
|
43
|
+
"avatar",
|
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,96 +111,124 @@ var user = {
|
|
79
111
|
},
|
80
112
|
required: ["$user"]
|
81
113
|
})
|
82
|
-
};
|
83
|
-
|
84
|
-
|
114
|
+
});
|
115
|
+
function getDateRangeToFieldReference(fieldId, comparedFieldId, clause) {
|
116
|
+
return {
|
85
117
|
type: "object",
|
86
118
|
properties: {
|
87
|
-
|
88
|
-
type: "
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
119
|
+
[fieldId]: {
|
120
|
+
type: "string",
|
121
|
+
format: "date",
|
122
|
+
[clause]: { $data: `1/${comparedFieldId}` }
|
123
|
+
},
|
124
|
+
[comparedFieldId]: { type: "string", format: "date" }
|
125
|
+
},
|
126
|
+
required: [fieldId]
|
127
|
+
};
|
128
|
+
}
|
129
|
+
function isFieldReference(value) {
|
130
|
+
return typeof value === "object" && value !== null && "$$field" in value;
|
131
|
+
}
|
132
|
+
function createFieldConditionals(fieldId) {
|
133
|
+
const getDayRange = (days, clause) => ({
|
134
|
+
type: "object",
|
135
|
+
properties: {
|
136
|
+
[fieldId]: {
|
137
|
+
type: "string",
|
138
|
+
format: "date",
|
139
|
+
daysFromNow: {
|
140
|
+
days,
|
141
|
+
clause
|
142
|
+
}
|
104
143
|
}
|
105
144
|
},
|
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];
|
145
|
+
required: [fieldId]
|
146
|
+
});
|
111
147
|
const getDateRange = (date, clause) => ({
|
112
148
|
type: "object",
|
113
149
|
properties: {
|
114
|
-
|
115
|
-
type: "
|
116
|
-
|
117
|
-
|
118
|
-
type: "string",
|
119
|
-
format: "date",
|
120
|
-
[clause]: date
|
121
|
-
}
|
122
|
-
},
|
123
|
-
required: [fieldId]
|
150
|
+
[fieldId]: {
|
151
|
+
type: "string",
|
152
|
+
format: "date",
|
153
|
+
[clause]: date
|
124
154
|
}
|
125
155
|
},
|
126
|
-
required: [
|
156
|
+
required: [fieldId]
|
127
157
|
});
|
128
158
|
return {
|
159
|
+
/**
|
160
|
+
* @private Internal property used for field reference tracking.
|
161
|
+
*/
|
162
|
+
$$field: fieldId,
|
129
163
|
isAfter: () => ({
|
130
164
|
days: (days) => ({
|
131
|
-
inPast: () =>
|
132
|
-
|
133
|
-
),
|
134
|
-
inFuture: () => defineConditional(
|
135
|
-
getDateRange(getDateFromNow(-days), "formatMinimum")
|
136
|
-
)
|
165
|
+
inPast: () => defineFormConditional(getDayRange(-days, "after")),
|
166
|
+
inFuture: () => defineFormConditional(getDayRange(days, "after"))
|
137
167
|
}),
|
138
|
-
date: (date) =>
|
139
|
-
|
168
|
+
date: (date) => {
|
169
|
+
if (isFieldReference(date)) {
|
170
|
+
const comparedFieldId = date.$$field;
|
171
|
+
return defineFormConditional(
|
172
|
+
getDateRangeToFieldReference(
|
173
|
+
fieldId,
|
174
|
+
comparedFieldId,
|
175
|
+
"formatMinimum"
|
176
|
+
)
|
177
|
+
);
|
178
|
+
}
|
179
|
+
return defineFormConditional(getDateRange(date, "formatMinimum"));
|
180
|
+
},
|
181
|
+
now: () => defineFormConditional(getDateRange({ $data: "/$now" }, "formatMinimum"))
|
140
182
|
}),
|
141
183
|
isBefore: () => ({
|
142
184
|
days: (days) => ({
|
143
|
-
inPast: () =>
|
144
|
-
|
145
|
-
),
|
146
|
-
inFuture: () => defineConditional(
|
147
|
-
getDateRange(getDateFromNow(-days), "formatMaximum")
|
148
|
-
)
|
185
|
+
inPast: () => defineFormConditional(getDayRange(days, "before")),
|
186
|
+
inFuture: () => defineFormConditional(getDayRange(-days, "before"))
|
149
187
|
}),
|
150
|
-
date: (date) =>
|
151
|
-
|
188
|
+
date: (date) => {
|
189
|
+
if (isFieldReference(date)) {
|
190
|
+
const comparedFieldId = date.$$field;
|
191
|
+
return defineFormConditional(
|
192
|
+
getDateRangeToFieldReference(
|
193
|
+
fieldId,
|
194
|
+
comparedFieldId,
|
195
|
+
"formatMaximum"
|
196
|
+
)
|
197
|
+
);
|
198
|
+
}
|
199
|
+
return defineFormConditional(getDateRange(date, "formatMaximum"));
|
200
|
+
},
|
201
|
+
now: () => defineFormConditional(getDateRange({ $data: "/$now" }, "formatMaximum"))
|
152
202
|
}),
|
153
|
-
isEqualTo: (value) =>
|
154
|
-
|
155
|
-
|
156
|
-
|
203
|
+
isEqualTo: (value) => {
|
204
|
+
if (isFieldReference(value)) {
|
205
|
+
const comparedFieldId = value.$$field;
|
206
|
+
return defineFormConditional({
|
157
207
|
type: "object",
|
158
208
|
properties: {
|
159
209
|
[fieldId]: {
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
const: value
|
165
|
-
}
|
210
|
+
type: ["string", "boolean"],
|
211
|
+
const: { $data: `/$form/${comparedFieldId}` }
|
212
|
+
},
|
213
|
+
[comparedFieldId]: { type: ["string", "boolean"] }
|
166
214
|
},
|
167
|
-
required: [fieldId]
|
168
|
-
}
|
169
|
-
}
|
170
|
-
|
171
|
-
|
215
|
+
required: [fieldId, comparedFieldId]
|
216
|
+
});
|
217
|
+
}
|
218
|
+
return defineFormConditional({
|
219
|
+
type: "object",
|
220
|
+
properties: {
|
221
|
+
[fieldId]: {
|
222
|
+
oneOf: [
|
223
|
+
{ type: "string", const: value },
|
224
|
+
{ type: "boolean", const: value }
|
225
|
+
],
|
226
|
+
const: value
|
227
|
+
}
|
228
|
+
},
|
229
|
+
required: [fieldId]
|
230
|
+
});
|
231
|
+
},
|
172
232
|
/**
|
173
233
|
* Use case: Some fields are rendered when selection is not made, or boolean false is explicitly selected.
|
174
234
|
* @example field('recommender.none').isFalsy() vs not(field('recommender.none').isEqualTo(true))
|
@@ -177,68 +237,103 @@ function field(fieldId) {
|
|
177
237
|
* NOTE: For now, this only works with string, boolean, and null types. 0 is still allowed.
|
178
238
|
*
|
179
239
|
*/
|
180
|
-
isFalsy: () =>
|
240
|
+
isFalsy: () => defineFormConditional({
|
181
241
|
type: "object",
|
182
242
|
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
|
-
},
|
243
|
+
[fieldId]: {
|
195
244
|
anyOf: [
|
196
|
-
{
|
197
|
-
|
198
|
-
},
|
199
|
-
{
|
200
|
-
not: {
|
201
|
-
required: [fieldId]
|
202
|
-
}
|
203
|
-
}
|
245
|
+
{ const: "undefined" },
|
246
|
+
{ const: false },
|
247
|
+
{ const: null },
|
248
|
+
{ const: "" }
|
204
249
|
]
|
205
250
|
}
|
206
251
|
},
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
$form: {
|
213
|
-
type: "object",
|
214
|
-
properties: {
|
215
|
-
[fieldId]: {
|
216
|
-
type: "string",
|
217
|
-
enum: ["undefined"]
|
218
|
-
}
|
219
|
-
},
|
252
|
+
anyOf: [
|
253
|
+
{
|
254
|
+
required: [fieldId]
|
255
|
+
},
|
256
|
+
{
|
220
257
|
not: {
|
221
258
|
required: [fieldId]
|
222
259
|
}
|
223
260
|
}
|
261
|
+
]
|
262
|
+
}),
|
263
|
+
isUndefined: () => defineFormConditional({
|
264
|
+
type: "object",
|
265
|
+
properties: {
|
266
|
+
[fieldId]: {
|
267
|
+
type: "string",
|
268
|
+
enum: ["undefined"]
|
269
|
+
}
|
224
270
|
},
|
225
|
-
|
271
|
+
not: {
|
272
|
+
required: [fieldId]
|
273
|
+
}
|
226
274
|
}),
|
227
|
-
inArray: (values) =>
|
275
|
+
inArray: (values) => defineFormConditional({
|
228
276
|
type: "object",
|
229
277
|
properties: {
|
230
|
-
|
278
|
+
[fieldId]: {
|
279
|
+
type: "string",
|
280
|
+
enum: values
|
281
|
+
}
|
282
|
+
},
|
283
|
+
required: [fieldId]
|
284
|
+
}),
|
285
|
+
isValidEnglishName: () => defineFormConditional({
|
286
|
+
type: "object",
|
287
|
+
properties: {
|
288
|
+
[fieldId]: {
|
289
|
+
type: "string",
|
290
|
+
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'.-]*)*$",
|
291
|
+
description: "Name must contain only letters, numbers, and allowed special characters ('.-). No double spaces."
|
292
|
+
}
|
293
|
+
}
|
294
|
+
}),
|
295
|
+
/**
|
296
|
+
* Checks if the field value matches a given regular expression pattern.
|
297
|
+
* @param pattern - The regular expression pattern to match the field value against.
|
298
|
+
* @returns A JSONSchema conditional that validates the field value against the pattern.
|
299
|
+
*/
|
300
|
+
matches: (pattern) => defineFormConditional({
|
301
|
+
type: "object",
|
302
|
+
properties: {
|
303
|
+
[fieldId]: {
|
304
|
+
type: "string",
|
305
|
+
pattern
|
306
|
+
}
|
307
|
+
},
|
308
|
+
required: [fieldId]
|
309
|
+
}),
|
310
|
+
isBetween: (min, max) => defineFormConditional({
|
311
|
+
type: "object",
|
312
|
+
properties: {
|
313
|
+
[fieldId]: {
|
314
|
+
type: "number",
|
315
|
+
minimum: min,
|
316
|
+
maximum: max
|
317
|
+
}
|
318
|
+
},
|
319
|
+
required: [fieldId]
|
320
|
+
}),
|
321
|
+
getId: () => ({ fieldId }),
|
322
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
323
|
+
object: (options) => defineFormConditional({
|
324
|
+
type: "object",
|
325
|
+
properties: {
|
326
|
+
[fieldId]: {
|
231
327
|
type: "object",
|
232
|
-
properties:
|
233
|
-
[
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
required: [fieldId]
|
328
|
+
properties: Object.fromEntries(
|
329
|
+
Object.entries(options).map(([key, value]) => {
|
330
|
+
return [key, value.properties.$form.properties[key]];
|
331
|
+
})
|
332
|
+
),
|
333
|
+
required: Object.keys(options)
|
239
334
|
}
|
240
335
|
},
|
241
|
-
required: [
|
336
|
+
required: [fieldId]
|
242
337
|
})
|
243
338
|
};
|
244
339
|
}
|