@opencrvs/toolkit 1.8.0-rc.f7910f3 → 1.8.0-rc.f876361
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 +4276 -14979
- package/dist/commons/conditionals/conditionals.d.ts +16 -1
- package/dist/commons/events/ActionConfig.d.ts +1202 -6605
- package/dist/commons/events/ActionDocument.d.ts +7338 -244
- package/dist/commons/events/ActionInput.d.ts +1098 -256
- package/dist/commons/events/ActionType.d.ts +24 -16
- package/dist/commons/events/Draft.d.ts +42 -34
- package/dist/commons/events/EventConfig.d.ts +648 -2983
- package/dist/commons/events/EventConfigInput.d.ts +5 -2
- package/dist/commons/events/EventDocument.d.ts +695 -304
- package/dist/commons/events/EventIndex.d.ts +6 -3
- package/dist/commons/events/EventMetadata.d.ts +3 -0
- package/dist/commons/events/FieldConfig.d.ts +84 -22
- package/dist/commons/events/FormConfig.d.ts +559 -322
- package/dist/commons/events/PageConfig.d.ts +359 -0
- package/dist/commons/events/defineConfig.d.ts +28 -433
- package/dist/commons/events/index.d.ts +2 -1
- package/dist/commons/events/test.utils.d.ts +53 -182
- package/dist/commons/events/utils.d.ts +73 -177
- package/dist/conditionals/index.js +103 -15
- package/dist/events/index.js +833 -651
- package/package.json +1 -1
@@ -126,6 +126,10 @@ function field(fieldId) {
|
|
126
126
|
required: ["$form"]
|
127
127
|
});
|
128
128
|
return {
|
129
|
+
/**
|
130
|
+
* @private Internal property used for field reference tracking.
|
131
|
+
*/
|
132
|
+
_returning: fieldId,
|
129
133
|
isAfter: () => ({
|
130
134
|
days: (days) => ({
|
131
135
|
inPast: () => defineConditional(
|
@@ -150,25 +154,54 @@ function field(fieldId) {
|
|
150
154
|
date: (date) => defineConditional(getDateRange(date, "formatMaximum")),
|
151
155
|
now: () => defineConditional(getDateRange(getDateFromNow(0), "formatMaximum"))
|
152
156
|
}),
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
+
// TODO CIHAN: typing
|
158
|
+
isEqualTo: (value) => {
|
159
|
+
if (typeof value === "object" && value._returning) {
|
160
|
+
const comparedFieldId = value._returning;
|
161
|
+
return defineConditional({
|
157
162
|
type: "object",
|
158
163
|
properties: {
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
{ type: "
|
163
|
-
|
164
|
-
|
164
|
+
$form: {
|
165
|
+
type: "object",
|
166
|
+
properties: {
|
167
|
+
[fieldId]: { type: ["string", "boolean"] },
|
168
|
+
[comparedFieldId]: { type: ["string", "boolean"] }
|
169
|
+
},
|
170
|
+
required: [fieldId, comparedFieldId],
|
171
|
+
allOf: [
|
172
|
+
{
|
173
|
+
properties: {
|
174
|
+
[fieldId]: {
|
175
|
+
const: { $data: `1/${comparedFieldId}` }
|
176
|
+
}
|
177
|
+
}
|
178
|
+
}
|
179
|
+
]
|
165
180
|
}
|
166
181
|
},
|
167
|
-
required: [
|
168
|
-
}
|
169
|
-
}
|
170
|
-
|
171
|
-
|
182
|
+
required: ["$form"]
|
183
|
+
});
|
184
|
+
}
|
185
|
+
return defineConditional({
|
186
|
+
type: "object",
|
187
|
+
properties: {
|
188
|
+
$form: {
|
189
|
+
type: "object",
|
190
|
+
properties: {
|
191
|
+
[fieldId]: {
|
192
|
+
oneOf: [
|
193
|
+
{ type: "string", const: value },
|
194
|
+
{ type: "boolean", const: value }
|
195
|
+
],
|
196
|
+
const: value
|
197
|
+
}
|
198
|
+
},
|
199
|
+
required: [fieldId]
|
200
|
+
}
|
201
|
+
},
|
202
|
+
required: ["$form"]
|
203
|
+
});
|
204
|
+
},
|
172
205
|
/**
|
173
206
|
* Use case: Some fields are rendered when selection is not made, or boolean false is explicitly selected.
|
174
207
|
* @example field('recommender.none').isFalsy() vs not(field('recommender.none').isEqualTo(true))
|
@@ -256,6 +289,61 @@ function field(fieldId) {
|
|
256
289
|
}
|
257
290
|
},
|
258
291
|
required: ["$form"]
|
292
|
+
}),
|
293
|
+
isValidNationalId: () => defineConditional({
|
294
|
+
type: "object",
|
295
|
+
properties: {
|
296
|
+
$form: {
|
297
|
+
type: "object",
|
298
|
+
properties: {
|
299
|
+
[fieldId]: {
|
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]
|
306
|
+
}
|
307
|
+
},
|
308
|
+
required: ["$form"]
|
309
|
+
}),
|
310
|
+
/**
|
311
|
+
* Checks if the field value matches a given regular expression pattern.
|
312
|
+
* @param pattern - The regular expression pattern to match the field value against.
|
313
|
+
* @returns A JSONSchema conditional that validates the field value against the pattern.
|
314
|
+
*/
|
315
|
+
matches: (pattern) => defineConditional({
|
316
|
+
type: "object",
|
317
|
+
properties: {
|
318
|
+
$form: {
|
319
|
+
type: "object",
|
320
|
+
properties: {
|
321
|
+
[fieldId]: {
|
322
|
+
type: "string",
|
323
|
+
pattern
|
324
|
+
}
|
325
|
+
},
|
326
|
+
required: [fieldId]
|
327
|
+
}
|
328
|
+
},
|
329
|
+
required: ["$form"]
|
330
|
+
}),
|
331
|
+
isBetween: (min, max) => defineConditional({
|
332
|
+
type: "object",
|
333
|
+
properties: {
|
334
|
+
$form: {
|
335
|
+
type: "object",
|
336
|
+
properties: {
|
337
|
+
[fieldId]: {
|
338
|
+
type: "number",
|
339
|
+
minimum: min,
|
340
|
+
maximum: max
|
341
|
+
}
|
342
|
+
},
|
343
|
+
required: [fieldId]
|
344
|
+
}
|
345
|
+
},
|
346
|
+
required: ["$form"]
|
259
347
|
})
|
260
348
|
};
|
261
349
|
}
|