@opencrvs/toolkit 1.8.0-rc.f876361 → 1.8.0-rc.f881988
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 +7334 -1430
- package/dist/commons/conditionals/conditionals.d.ts +23 -13
- package/dist/commons/conditionals/validate.d.ts +12 -17
- package/dist/commons/events/ActionConfig.d.ts +86380 -1682
- package/dist/commons/events/ActionDocument.d.ts +420 -103
- package/dist/commons/events/ActionInput.d.ts +1135 -232
- package/dist/commons/events/ActionType.d.ts +5 -3
- package/dist/commons/events/AdvancedSearchConfig.d.ts +371 -25
- package/dist/commons/events/CompositeFieldValue.d.ts +3 -0
- package/dist/commons/events/Conditional.d.ts +21 -5
- package/dist/commons/events/Draft.d.ts +37 -15
- package/dist/commons/events/EventConfig.d.ts +41061 -1337
- package/dist/commons/events/EventDocument.d.ts +334 -77
- package/dist/commons/events/EventIndex.d.ts +915 -4
- package/dist/commons/events/EventInput.d.ts +13 -0
- package/dist/commons/events/EventMetadata.d.ts +13 -3
- package/dist/commons/events/FieldConfig.d.ts +3628 -745
- package/dist/commons/events/FieldType.d.ts +1 -2
- package/dist/commons/events/FieldValue.d.ts +1 -1
- package/dist/commons/events/FormConfig.d.ts +38845 -517
- package/dist/commons/events/PageConfig.d.ts +9655 -211
- package/dist/commons/events/SummaryConfig.d.ts +81 -42
- package/dist/commons/events/TemplateConfig.d.ts +5 -5
- package/dist/commons/events/User.d.ts +5 -0
- package/dist/commons/events/WorkqueueConfig.d.ts +44 -20
- package/dist/commons/events/defineConfig.d.ts +6681 -31
- package/dist/commons/events/event.d.ts +25 -0
- package/dist/commons/events/field.d.ts +68 -0
- package/dist/commons/events/index.d.ts +3 -0
- package/dist/commons/events/scopes.d.ts +26 -0
- package/dist/commons/events/test.utils.d.ts +20 -149
- package/dist/commons/events/utils.d.ts +3417 -97
- package/dist/commons/events/utils.test.d.ts +2 -0
- package/dist/conditionals/index.js +164 -181
- package/dist/events/index.js +1336 -889
- package/package.json +3 -2
@@ -22,9 +22,11 @@ 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
|
@@ -35,6 +37,16 @@ module.exports = __toCommonJS(conditionals_exports);
|
|
35
37
|
function defineConditional(schema) {
|
36
38
|
return schema;
|
37
39
|
}
|
40
|
+
function defineFormConditional(schema) {
|
41
|
+
const schemaWithForm = {
|
42
|
+
type: "object",
|
43
|
+
properties: {
|
44
|
+
$form: schema
|
45
|
+
},
|
46
|
+
required: ["$form"]
|
47
|
+
};
|
48
|
+
return defineConditional(schemaWithForm);
|
49
|
+
}
|
38
50
|
function alwaysTrue() {
|
39
51
|
return {};
|
40
52
|
}
|
@@ -59,6 +71,9 @@ function not(condition) {
|
|
59
71
|
required: []
|
60
72
|
});
|
61
73
|
}
|
74
|
+
function never() {
|
75
|
+
return not(alwaysTrue());
|
76
|
+
}
|
62
77
|
var user = {
|
63
78
|
hasScope: (scope) => defineConditional({
|
64
79
|
type: "object",
|
@@ -80,126 +95,146 @@ var user = {
|
|
80
95
|
required: ["$user"]
|
81
96
|
})
|
82
97
|
};
|
83
|
-
|
84
|
-
|
98
|
+
function createEventConditionals() {
|
99
|
+
return {
|
100
|
+
/**
|
101
|
+
* Checks if the event contains a specific action type.
|
102
|
+
* @param action - The action type to check for.
|
103
|
+
*/
|
104
|
+
hasAction: (action) => defineConditional({
|
105
|
+
type: "object",
|
106
|
+
properties: {
|
107
|
+
$event: {
|
108
|
+
type: "object",
|
109
|
+
properties: {
|
110
|
+
actions: {
|
111
|
+
type: "array",
|
112
|
+
contains: {
|
113
|
+
type: "object",
|
114
|
+
properties: {
|
115
|
+
type: {
|
116
|
+
const: action
|
117
|
+
}
|
118
|
+
},
|
119
|
+
required: ["type"]
|
120
|
+
}
|
121
|
+
}
|
122
|
+
},
|
123
|
+
required: ["actions"]
|
124
|
+
}
|
125
|
+
},
|
126
|
+
required: ["$event"]
|
127
|
+
})
|
128
|
+
};
|
129
|
+
}
|
130
|
+
function getDateFromNow(days) {
|
131
|
+
return new Date(Date.now() - days * 24 * 60 * 60 * 1e3).toISOString().split("T")[0];
|
132
|
+
}
|
133
|
+
function getDateRangeToFieldReference(fieldId, comparedFieldId, clause) {
|
134
|
+
return {
|
85
135
|
type: "object",
|
86
136
|
properties: {
|
87
|
-
|
88
|
-
type: "
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
type: "object",
|
94
|
-
properties: {
|
95
|
-
type: {
|
96
|
-
const: action
|
97
|
-
}
|
98
|
-
},
|
99
|
-
required: ["type"]
|
100
|
-
}
|
101
|
-
}
|
102
|
-
},
|
103
|
-
required: ["actions"]
|
104
|
-
}
|
137
|
+
[fieldId]: {
|
138
|
+
type: "string",
|
139
|
+
format: "date",
|
140
|
+
[clause]: { $data: `1/${comparedFieldId}` }
|
141
|
+
},
|
142
|
+
[comparedFieldId]: { type: "string", format: "date" }
|
105
143
|
},
|
106
|
-
required: [
|
107
|
-
}
|
108
|
-
}
|
109
|
-
function
|
110
|
-
|
144
|
+
required: [fieldId]
|
145
|
+
};
|
146
|
+
}
|
147
|
+
function isFieldReference(value) {
|
148
|
+
return typeof value === "object" && value !== null && "_fieldId" in value;
|
149
|
+
}
|
150
|
+
function createFieldConditionals(fieldId) {
|
111
151
|
const getDateRange = (date, clause) => ({
|
112
152
|
type: "object",
|
113
153
|
properties: {
|
114
|
-
|
115
|
-
type: "
|
116
|
-
|
117
|
-
|
118
|
-
type: "string",
|
119
|
-
format: "date",
|
120
|
-
[clause]: date
|
121
|
-
}
|
122
|
-
},
|
123
|
-
required: [fieldId]
|
154
|
+
[fieldId]: {
|
155
|
+
type: "string",
|
156
|
+
format: "date",
|
157
|
+
[clause]: date
|
124
158
|
}
|
125
159
|
},
|
126
|
-
required: [
|
160
|
+
required: [fieldId]
|
127
161
|
});
|
128
162
|
return {
|
129
|
-
/**
|
130
|
-
* @private Internal property used for field reference tracking.
|
131
|
-
*/
|
132
|
-
_returning: fieldId,
|
133
163
|
isAfter: () => ({
|
134
164
|
days: (days) => ({
|
135
|
-
inPast: () =>
|
165
|
+
inPast: () => defineFormConditional(
|
136
166
|
getDateRange(getDateFromNow(days), "formatMinimum")
|
137
167
|
),
|
138
|
-
inFuture: () =>
|
168
|
+
inFuture: () => defineFormConditional(
|
139
169
|
getDateRange(getDateFromNow(-days), "formatMinimum")
|
140
170
|
)
|
141
171
|
}),
|
142
|
-
date: (date) =>
|
143
|
-
|
172
|
+
date: (date) => {
|
173
|
+
if (isFieldReference(date)) {
|
174
|
+
const comparedFieldId = date._fieldId;
|
175
|
+
return defineFormConditional(
|
176
|
+
getDateRangeToFieldReference(
|
177
|
+
fieldId,
|
178
|
+
comparedFieldId,
|
179
|
+
"formatMinimum"
|
180
|
+
)
|
181
|
+
);
|
182
|
+
}
|
183
|
+
return defineFormConditional(getDateRange(date, "formatMinimum"));
|
184
|
+
},
|
185
|
+
now: () => defineFormConditional(getDateRange(getDateFromNow(0), "formatMinimum"))
|
144
186
|
}),
|
145
187
|
isBefore: () => ({
|
146
188
|
days: (days) => ({
|
147
|
-
inPast: () =>
|
189
|
+
inPast: () => defineFormConditional(
|
148
190
|
getDateRange(getDateFromNow(days), "formatMaximum")
|
149
191
|
),
|
150
|
-
inFuture: () =>
|
192
|
+
inFuture: () => defineFormConditional(
|
151
193
|
getDateRange(getDateFromNow(-days), "formatMaximum")
|
152
194
|
)
|
153
195
|
}),
|
154
|
-
date: (date) =>
|
155
|
-
|
196
|
+
date: (date) => {
|
197
|
+
if (isFieldReference(date)) {
|
198
|
+
const comparedFieldId = date._fieldId;
|
199
|
+
return defineFormConditional(
|
200
|
+
getDateRangeToFieldReference(
|
201
|
+
fieldId,
|
202
|
+
comparedFieldId,
|
203
|
+
"formatMaximum"
|
204
|
+
)
|
205
|
+
);
|
206
|
+
}
|
207
|
+
return defineFormConditional(getDateRange(date, "formatMaximum"));
|
208
|
+
},
|
209
|
+
now: () => defineFormConditional(getDateRange(getDateFromNow(0), "formatMaximum"))
|
156
210
|
}),
|
157
|
-
// TODO CIHAN: typing
|
158
211
|
isEqualTo: (value) => {
|
159
|
-
if (
|
160
|
-
const comparedFieldId = value.
|
161
|
-
return
|
212
|
+
if (isFieldReference(value)) {
|
213
|
+
const comparedFieldId = value._fieldId;
|
214
|
+
return defineFormConditional({
|
162
215
|
type: "object",
|
163
216
|
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
|
-
}
|
217
|
+
[fieldId]: {
|
218
|
+
type: ["string", "boolean"],
|
219
|
+
const: { $data: `1/${comparedFieldId}` }
|
220
|
+
},
|
221
|
+
[comparedFieldId]: { type: ["string", "boolean"] }
|
181
222
|
},
|
182
|
-
required: [
|
223
|
+
required: [fieldId, comparedFieldId]
|
183
224
|
});
|
184
225
|
}
|
185
|
-
return
|
226
|
+
return defineFormConditional({
|
186
227
|
type: "object",
|
187
228
|
properties: {
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
{ type: "boolean", const: value }
|
195
|
-
],
|
196
|
-
const: value
|
197
|
-
}
|
198
|
-
},
|
199
|
-
required: [fieldId]
|
229
|
+
[fieldId]: {
|
230
|
+
oneOf: [
|
231
|
+
{ type: "string", const: value },
|
232
|
+
{ type: "boolean", const: value }
|
233
|
+
],
|
234
|
+
const: value
|
200
235
|
}
|
201
236
|
},
|
202
|
-
required: [
|
237
|
+
required: [fieldId]
|
203
238
|
});
|
204
239
|
},
|
205
240
|
/**
|
@@ -210,140 +245,88 @@ function field(fieldId) {
|
|
210
245
|
* NOTE: For now, this only works with string, boolean, and null types. 0 is still allowed.
|
211
246
|
*
|
212
247
|
*/
|
213
|
-
isFalsy: () =>
|
248
|
+
isFalsy: () => defineFormConditional({
|
214
249
|
type: "object",
|
215
250
|
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
|
-
},
|
251
|
+
[fieldId]: {
|
228
252
|
anyOf: [
|
229
|
-
{
|
230
|
-
|
231
|
-
},
|
232
|
-
{
|
233
|
-
not: {
|
234
|
-
required: [fieldId]
|
235
|
-
}
|
236
|
-
}
|
253
|
+
{ const: "undefined" },
|
254
|
+
{ const: false },
|
255
|
+
{ const: null },
|
256
|
+
{ const: "" }
|
237
257
|
]
|
238
258
|
}
|
239
259
|
},
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
$form: {
|
246
|
-
type: "object",
|
247
|
-
properties: {
|
248
|
-
[fieldId]: {
|
249
|
-
type: "string",
|
250
|
-
enum: ["undefined"]
|
251
|
-
}
|
252
|
-
},
|
260
|
+
anyOf: [
|
261
|
+
{
|
262
|
+
required: [fieldId]
|
263
|
+
},
|
264
|
+
{
|
253
265
|
not: {
|
254
266
|
required: [fieldId]
|
255
267
|
}
|
256
268
|
}
|
257
|
-
|
258
|
-
required: ["$form"]
|
269
|
+
]
|
259
270
|
}),
|
260
|
-
|
271
|
+
isUndefined: () => defineFormConditional({
|
261
272
|
type: "object",
|
262
273
|
properties: {
|
263
|
-
|
264
|
-
type: "
|
265
|
-
|
266
|
-
[fieldId]: {
|
267
|
-
type: "string",
|
268
|
-
enum: values
|
269
|
-
}
|
270
|
-
},
|
271
|
-
required: [fieldId]
|
274
|
+
[fieldId]: {
|
275
|
+
type: "string",
|
276
|
+
enum: ["undefined"]
|
272
277
|
}
|
273
278
|
},
|
274
|
-
|
279
|
+
not: {
|
280
|
+
required: [fieldId]
|
281
|
+
}
|
275
282
|
}),
|
276
|
-
|
283
|
+
inArray: (values) => defineFormConditional({
|
277
284
|
type: "object",
|
278
285
|
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]
|
286
|
+
[fieldId]: {
|
287
|
+
type: "string",
|
288
|
+
enum: values
|
289
289
|
}
|
290
290
|
},
|
291
|
-
required: [
|
291
|
+
required: [fieldId]
|
292
292
|
}),
|
293
|
-
|
293
|
+
isValidEnglishName: () => defineFormConditional({
|
294
294
|
type: "object",
|
295
295
|
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]
|
296
|
+
[fieldId]: {
|
297
|
+
type: "string",
|
298
|
+
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'._-]*)*$",
|
299
|
+
description: "Name must contain only letters, numbers, and allowed special characters ('._-). No double spaces."
|
306
300
|
}
|
307
301
|
},
|
308
|
-
required: [
|
302
|
+
required: [fieldId]
|
309
303
|
}),
|
310
304
|
/**
|
311
305
|
* Checks if the field value matches a given regular expression pattern.
|
312
306
|
* @param pattern - The regular expression pattern to match the field value against.
|
313
307
|
* @returns A JSONSchema conditional that validates the field value against the pattern.
|
314
308
|
*/
|
315
|
-
matches: (pattern) =>
|
309
|
+
matches: (pattern) => defineFormConditional({
|
316
310
|
type: "object",
|
317
311
|
properties: {
|
318
|
-
|
319
|
-
type: "
|
320
|
-
|
321
|
-
[fieldId]: {
|
322
|
-
type: "string",
|
323
|
-
pattern
|
324
|
-
}
|
325
|
-
},
|
326
|
-
required: [fieldId]
|
312
|
+
[fieldId]: {
|
313
|
+
type: "string",
|
314
|
+
pattern
|
327
315
|
}
|
328
316
|
},
|
329
|
-
required: [
|
317
|
+
required: [fieldId]
|
330
318
|
}),
|
331
|
-
isBetween: (min, max) =>
|
319
|
+
isBetween: (min, max) => defineFormConditional({
|
332
320
|
type: "object",
|
333
321
|
properties: {
|
334
|
-
|
335
|
-
type: "
|
336
|
-
|
337
|
-
|
338
|
-
type: "number",
|
339
|
-
minimum: min,
|
340
|
-
maximum: max
|
341
|
-
}
|
342
|
-
},
|
343
|
-
required: [fieldId]
|
322
|
+
[fieldId]: {
|
323
|
+
type: "number",
|
324
|
+
minimum: min,
|
325
|
+
maximum: max
|
344
326
|
}
|
345
327
|
},
|
346
|
-
required: [
|
347
|
-
})
|
328
|
+
required: [fieldId]
|
329
|
+
}),
|
330
|
+
getId: () => ({ fieldId })
|
348
331
|
};
|
349
332
|
}
|