@nira-opencrvs/toolkit 1.9.11-rc.1f36427

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.
Files changed (77) hide show
  1. package/README.md +70 -0
  2. package/build.sh +56 -0
  3. package/dist/api/index.d.ts +11 -0
  4. package/dist/api/index.d.ts.map +1 -0
  5. package/dist/api/index.js +52 -0
  6. package/dist/commons/api/router.d.ts +4125 -0
  7. package/dist/commons/conditionals/conditionals.d.ts +824 -0
  8. package/dist/commons/conditionals/index.d.ts +2 -0
  9. package/dist/commons/conditionals/validate.d.ts +101 -0
  10. package/dist/commons/events/ActionConfig.d.ts +1609 -0
  11. package/dist/commons/events/ActionDocument.d.ts +2180 -0
  12. package/dist/commons/events/ActionInput.d.ts +1229 -0
  13. package/dist/commons/events/ActionType.d.ts +52 -0
  14. package/dist/commons/events/AdvancedSearchConfig.d.ts +1538 -0
  15. package/dist/commons/events/CompositeFieldValue.d.ts +280 -0
  16. package/dist/commons/events/Conditional.d.ts +55 -0
  17. package/dist/commons/events/Constants.d.ts +3 -0
  18. package/dist/commons/events/CountryConfigQueryInput.d.ts +4784 -0
  19. package/dist/commons/events/CreatedAtLocation.d.ts +2 -0
  20. package/dist/commons/events/DeduplicationConfig.d.ts +233 -0
  21. package/dist/commons/events/Draft.d.ts +118 -0
  22. package/dist/commons/events/DynamicFieldValue.d.ts +139 -0
  23. package/dist/commons/events/EventConfig.d.ts +2255 -0
  24. package/dist/commons/events/EventConfigInput.d.ts +10 -0
  25. package/dist/commons/events/EventDocument.d.ts +1457 -0
  26. package/dist/commons/events/EventIndex.d.ts +1134 -0
  27. package/dist/commons/events/EventInput.d.ts +13 -0
  28. package/dist/commons/events/EventMetadata.d.ts +413 -0
  29. package/dist/commons/events/FieldConfig.d.ts +12935 -0
  30. package/dist/commons/events/FieldType.d.ts +55 -0
  31. package/dist/commons/events/FieldTypeMapping.d.ts +1289 -0
  32. package/dist/commons/events/FieldValue.d.ts +512 -0
  33. package/dist/commons/events/FileUtils.d.ts +4 -0
  34. package/dist/commons/events/FormConfig.d.ts +755 -0
  35. package/dist/commons/events/PageConfig.d.ts +342 -0
  36. package/dist/commons/events/PlainDate.d.ts +19 -0
  37. package/dist/commons/events/SummaryConfig.d.ts +170 -0
  38. package/dist/commons/events/TemplateConfig.d.ts +66 -0
  39. package/dist/commons/events/TranslationConfig.d.ts +15 -0
  40. package/dist/commons/events/WorkqueueColumnConfig.d.ts +53 -0
  41. package/dist/commons/events/WorkqueueConfig.d.ts +7957 -0
  42. package/dist/commons/events/deduplication.d.ts +69 -0
  43. package/dist/commons/events/defineConfig.d.ts +234 -0
  44. package/dist/commons/events/event.d.ts +80 -0
  45. package/dist/commons/events/field.d.ts +514 -0
  46. package/dist/commons/events/index.d.ts +45 -0
  47. package/dist/commons/events/locations.d.ts +24 -0
  48. package/dist/commons/events/scopes.d.ts +55 -0
  49. package/dist/commons/events/serializer.d.ts +2 -0
  50. package/dist/commons/events/state/availableActions.d.ts +6 -0
  51. package/dist/commons/events/state/flags.d.ts +4 -0
  52. package/dist/commons/events/state/index.d.ts +119 -0
  53. package/dist/commons/events/state/utils.d.ts +311 -0
  54. package/dist/commons/events/test.utils.d.ts +248 -0
  55. package/dist/commons/events/transactions.d.ts +2 -0
  56. package/dist/commons/events/utils.d.ts +486 -0
  57. package/dist/commons/events/workqueueDefaultColumns.d.ts +3 -0
  58. package/dist/commons/notification/UserNotifications.d.ts +762 -0
  59. package/dist/commons/notification/index.d.ts +2 -0
  60. package/dist/conditionals/index.d.ts +2 -0
  61. package/dist/conditionals/index.d.ts.map +1 -0
  62. package/dist/conditionals/index.js +689 -0
  63. package/dist/events/deduplication.d.ts +69 -0
  64. package/dist/events/deduplication.d.ts.map +1 -0
  65. package/dist/events/deduplication.js +101 -0
  66. package/dist/events/index.d.ts +2 -0
  67. package/dist/events/index.d.ts.map +1 -0
  68. package/dist/events/index.js +9327 -0
  69. package/dist/notification/index.d.ts +2 -0
  70. package/dist/notification/index.d.ts.map +1 -0
  71. package/dist/notification/index.js +6674 -0
  72. package/dist/scopes/index.d.ts +385 -0
  73. package/dist/scopes/index.d.ts.map +1 -0
  74. package/dist/scopes/index.js +349 -0
  75. package/package.json +40 -0
  76. package/tsconfig.json +27 -0
  77. package/tsconfig.tsbuildinfo +1 -0
@@ -0,0 +1,2 @@
1
+ export * from './UserNotifications';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,2 @@
1
+ export * from '../commons/conditionals';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/conditionals/index.ts"],"names":[],"mappings":"AAUA,cAAc,gCAAgC,CAAA"}
@@ -0,0 +1,689 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+
30
+ // src/conditionals/index.ts
31
+ var conditionals_exports = {};
32
+ __export(conditionals_exports, {
33
+ alwaysTrue: () => alwaysTrue,
34
+ and: () => and,
35
+ createFieldConditionals: () => createFieldConditionals,
36
+ defineConditional: () => defineConditional,
37
+ defineFormConditional: () => defineFormConditional,
38
+ isEventFieldReference: () => isEventFieldReference,
39
+ isFieldReference: () => isFieldReference,
40
+ never: () => never,
41
+ not: () => not,
42
+ now: () => now,
43
+ or: () => or,
44
+ user: () => user
45
+ });
46
+ module.exports = __toCommonJS(conditionals_exports);
47
+
48
+ // ../commons/src/conditionals/conditionals.ts
49
+ var objectHash = __toESM(require("object-hash"));
50
+
51
+ // ../commons/src/events/serializers/user/serializer.ts
52
+ var import_zod = require("zod");
53
+ var SerializedUserField = import_zod.z.object({
54
+ $userField: import_zod.z.enum([
55
+ "id",
56
+ "name",
57
+ "role",
58
+ "fullHonorificName",
59
+ "device",
60
+ "firstname",
61
+ "middlename",
62
+ "surname",
63
+ "district",
64
+ "province",
65
+ "primaryOfficeId"
66
+ ]),
67
+ $location: import_zod.z.string().optional()
68
+ });
69
+ function userSerializer(userField) {
70
+ return {
71
+ $userField: userField,
72
+ locationLevel(adminLevelId) {
73
+ return {
74
+ $userField: this.$userField,
75
+ $location: adminLevelId
76
+ };
77
+ },
78
+ toJSON() {
79
+ return {
80
+ $userField: userField
81
+ };
82
+ }
83
+ };
84
+ }
85
+
86
+ // ../commons/src/utils.ts
87
+ var z2 = __toESM(require("zod"));
88
+ var _ = __toESM(require("lodash"));
89
+ var FullNameV1 = z2.array(
90
+ z2.object({
91
+ use: z2.string(),
92
+ family: z2.string(),
93
+ given: z2.array(z2.string())
94
+ })
95
+ );
96
+ function omitKeyDeep(obj, keyToRemove) {
97
+ if (Array.isArray(obj)) {
98
+ return obj.map((item) => omitKeyDeep(item, keyToRemove));
99
+ }
100
+ if (obj === null || typeof obj !== "object") {
101
+ return obj;
102
+ }
103
+ const newObj = {};
104
+ for (const key of Object.keys(obj)) {
105
+ if (key !== keyToRemove) {
106
+ newObj[key] = omitKeyDeep(obj[key], keyToRemove);
107
+ }
108
+ }
109
+ return newObj;
110
+ }
111
+
112
+ // ../commons/src/events/serializers/date/serializer.ts
113
+ var import_zod2 = require("zod");
114
+ var SerializedNowDateTime = import_zod2.z.object({
115
+ $$now: import_zod2.z.literal(true)
116
+ });
117
+ function todayDateTimeValueSerializer() {
118
+ return { $$now: true };
119
+ }
120
+
121
+ // ../commons/src/conditionals/conditionals.ts
122
+ function defineConditional(schema) {
123
+ const schemaWithooutIDRef = omitKeyDeep(schema, "$id");
124
+ return {
125
+ $id: `https://opencrvs.org/conditionals/${objectHash.sha1(schemaWithooutIDRef)}`,
126
+ ...schemaWithooutIDRef
127
+ };
128
+ }
129
+ function defineFormConditional(schema) {
130
+ const schemaWithForm = {
131
+ type: "object",
132
+ properties: {
133
+ $form: schema
134
+ },
135
+ required: ["$form"]
136
+ };
137
+ return defineConditional(schemaWithForm);
138
+ }
139
+ function alwaysTrue() {
140
+ return {};
141
+ }
142
+ function and(...conditions) {
143
+ return defineConditional({
144
+ type: "object",
145
+ allOf: conditions,
146
+ required: []
147
+ });
148
+ }
149
+ function or(...conditions) {
150
+ return defineConditional({
151
+ type: "object",
152
+ anyOf: conditions,
153
+ required: []
154
+ });
155
+ }
156
+ function not(condition) {
157
+ return defineConditional({
158
+ type: "object",
159
+ not: condition,
160
+ required: []
161
+ });
162
+ }
163
+ function never() {
164
+ return not(alwaysTrue());
165
+ }
166
+ function jsonFieldPath(field) {
167
+ return [field.$$field, ...field.$$subfield].join("/");
168
+ }
169
+ function wrapToPath(condition, path) {
170
+ if (path.length === 0) {
171
+ return condition;
172
+ }
173
+ return path.reduceRight((conditionNow, part) => {
174
+ return {
175
+ type: "object",
176
+ properties: {
177
+ [part]: conditionNow
178
+ },
179
+ required: [part]
180
+ };
181
+ }, condition);
182
+ }
183
+ function wrapToPathOptional(condition, path) {
184
+ if (path.length === 0) {
185
+ return condition;
186
+ }
187
+ return path.reduceRight((conditionNow, part) => {
188
+ return {
189
+ type: "object",
190
+ properties: { [part]: conditionNow }
191
+ };
192
+ }, condition);
193
+ }
194
+ var now = Object.assign(todayDateTimeValueSerializer, {});
195
+ var user = Object.assign(userSerializer, {
196
+ hasScope: (scope) => defineConditional({
197
+ type: "object",
198
+ properties: {
199
+ $user: {
200
+ type: "object",
201
+ required: ["scope"],
202
+ properties: {
203
+ scope: {
204
+ type: "array",
205
+ contains: {
206
+ type: "string",
207
+ const: scope
208
+ }
209
+ }
210
+ }
211
+ }
212
+ },
213
+ required: ["$user"]
214
+ }),
215
+ hasRole: (role) => defineConditional({
216
+ type: "object",
217
+ properties: {
218
+ $user: {
219
+ type: "object",
220
+ required: ["role"],
221
+ properties: {
222
+ role: {
223
+ type: "string",
224
+ const: role
225
+ }
226
+ }
227
+ }
228
+ },
229
+ required: ["$user"]
230
+ }),
231
+ isOnline: () => defineConditional({
232
+ type: "object",
233
+ properties: {
234
+ $online: {
235
+ type: "boolean",
236
+ const: true
237
+ }
238
+ },
239
+ required: ["$online"]
240
+ }),
241
+ locationLevel: (adminLevelId) => ({
242
+ $user: {
243
+ $location: adminLevelId
244
+ }
245
+ })
246
+ });
247
+ function isFieldReference(value) {
248
+ return typeof value === "object" && value !== null && "$$field" in value;
249
+ }
250
+ function isEventFieldReference(value) {
251
+ return typeof value === "object" && value !== null && "$$event" in value;
252
+ }
253
+ function getDateRangeToFieldReference(field, comparedField, clause) {
254
+ return {
255
+ type: "object",
256
+ properties: {
257
+ [field.$$field]: wrapToPath(
258
+ {
259
+ type: "string",
260
+ format: "date",
261
+ [clause]: {
262
+ $data: `${field.$$subfield.length + 1}/${jsonFieldPath(comparedField)}`
263
+ }
264
+ },
265
+ field.$$subfield
266
+ ),
267
+ [comparedField.$$field]: wrapToPath(
268
+ { type: "string", format: "date" },
269
+ comparedField.$$subfield
270
+ )
271
+ },
272
+ required: [field.$$field]
273
+ };
274
+ }
275
+ function getDayRangeToFieldReference(field, comparedField, days, clause) {
276
+ return {
277
+ type: "object",
278
+ properties: {
279
+ [field.$$field]: wrapToPath(
280
+ {
281
+ type: "string",
282
+ format: "date",
283
+ daysFromDate: {
284
+ referenceDate: {
285
+ $data: `${field.$$subfield.length + 1}/${jsonFieldPath(
286
+ comparedField
287
+ )}`
288
+ },
289
+ clause,
290
+ days
291
+ }
292
+ },
293
+ field.$$subfield
294
+ ),
295
+ [comparedField.$$field]: wrapToPath(
296
+ { type: "string", format: "date" },
297
+ comparedField.$$subfield
298
+ )
299
+ },
300
+ required: [field.$$field]
301
+ };
302
+ }
303
+ function defineComparison(field, value, keyword) {
304
+ if (isFieldReference(value)) {
305
+ const comparedField = value;
306
+ return defineFormConditional({
307
+ type: "object",
308
+ properties: {
309
+ [field.$$field]: wrapToPath(
310
+ {
311
+ type: ["number"],
312
+ [keyword]: {
313
+ $data: `${field.$$subfield.length + 1}/${jsonFieldPath(comparedField)}`
314
+ }
315
+ },
316
+ field.$$subfield
317
+ ),
318
+ [comparedField.$$field]: wrapToPath(
319
+ { type: "number" },
320
+ comparedField.$$subfield
321
+ )
322
+ },
323
+ required: [field.$$field]
324
+ });
325
+ }
326
+ return defineFormConditional({
327
+ type: "object",
328
+ properties: {
329
+ [field.$$field]: wrapToPath(
330
+ { type: "number", [keyword]: value },
331
+ field.$$subfield
332
+ )
333
+ },
334
+ required: [field.$$field]
335
+ });
336
+ }
337
+ function createFieldConditionals(fieldId) {
338
+ const getDayRange = (field, days, clause, referenceDate) => ({
339
+ type: "object",
340
+ properties: {
341
+ [field.$$field]: wrapToPath(
342
+ {
343
+ type: "string",
344
+ format: "date",
345
+ daysFromDate: {
346
+ days,
347
+ clause,
348
+ referenceDate
349
+ }
350
+ },
351
+ field.$$subfield
352
+ )
353
+ },
354
+ required: [field.$$field]
355
+ });
356
+ const getDateRange = (field, date, clause) => ({
357
+ type: "object",
358
+ properties: {
359
+ [field.$$field]: wrapToPath(
360
+ {
361
+ type: "string",
362
+ format: "date",
363
+ [clause]: date
364
+ },
365
+ field.$$subfield
366
+ )
367
+ },
368
+ required: [field.$$field]
369
+ });
370
+ return {
371
+ /**
372
+ * @private Internal property used for field reference tracking.
373
+ */
374
+ $$field: fieldId,
375
+ /**
376
+ * @private Internal property used for solving a object path within field's value
377
+ */
378
+ $$subfield: [],
379
+ get(fieldPath) {
380
+ return {
381
+ ...this,
382
+ $$subfield: fieldPath.split(".")
383
+ };
384
+ },
385
+ getByPath(fieldPath) {
386
+ return {
387
+ ...this,
388
+ $$subfield: fieldPath
389
+ };
390
+ },
391
+ asDob() {
392
+ return this.get("dob");
393
+ },
394
+ asAge() {
395
+ return this.get("age");
396
+ },
397
+ isAfter() {
398
+ return {
399
+ days: (days) => ({
400
+ inPast: () => defineFormConditional(getDayRange(this, -days, "after")),
401
+ inFuture: () => defineFormConditional(getDayRange(this, days, "after")),
402
+ fromDate: (date) => {
403
+ if (isFieldReference(date)) {
404
+ const comparedField = date;
405
+ return defineFormConditional(
406
+ getDayRangeToFieldReference(this, comparedField, days, "after")
407
+ );
408
+ }
409
+ return defineFormConditional(getDayRange(this, days, "after", date));
410
+ },
411
+ fromNow: () => {
412
+ return defineFormConditional(getDayRange(this, days, "after"));
413
+ }
414
+ }),
415
+ date: (date) => {
416
+ if (isFieldReference(date)) {
417
+ const comparedField = date;
418
+ return defineFormConditional(
419
+ getDateRangeToFieldReference(this, comparedField, "formatMinimum")
420
+ );
421
+ }
422
+ return defineFormConditional(
423
+ getDateRange(this, date, "formatMinimum")
424
+ );
425
+ },
426
+ now: () => defineFormConditional(
427
+ getDateRange(this, { $data: "/$now" }, "formatMinimum")
428
+ )
429
+ };
430
+ },
431
+ isBefore() {
432
+ return {
433
+ days: (days) => ({
434
+ inPast: () => defineFormConditional(getDayRange(this, -days, "before")),
435
+ inFuture: () => defineFormConditional(getDayRange(this, days, "before")),
436
+ fromDate: (date) => {
437
+ if (isFieldReference(date)) {
438
+ const comparedField = date;
439
+ return defineFormConditional(
440
+ getDayRangeToFieldReference(
441
+ this,
442
+ comparedField,
443
+ -days,
444
+ "before"
445
+ )
446
+ );
447
+ }
448
+ return defineFormConditional(
449
+ getDayRange(this, -days, "before", date)
450
+ );
451
+ },
452
+ fromNow: () => {
453
+ return defineFormConditional(getDayRange(this, -days, "before"));
454
+ }
455
+ }),
456
+ date: (date) => {
457
+ if (isFieldReference(date)) {
458
+ const comparedField = date;
459
+ return defineFormConditional(
460
+ getDateRangeToFieldReference(this, comparedField, "formatMaximum")
461
+ );
462
+ }
463
+ return defineFormConditional(
464
+ getDateRange(this, date, "formatMaximum")
465
+ );
466
+ },
467
+ now: () => defineFormConditional(
468
+ getDateRange(this, { $data: "/$now" }, "formatMaximum")
469
+ )
470
+ };
471
+ },
472
+ isGreaterThan(value) {
473
+ return defineComparison(this, value, "exclusiveMinimum");
474
+ },
475
+ isLessThan(value) {
476
+ return defineComparison(this, value, "exclusiveMaximum");
477
+ },
478
+ isEqualTo(value) {
479
+ if (isFieldReference(value)) {
480
+ const comparedField = value;
481
+ return defineFormConditional({
482
+ type: "object",
483
+ properties: {
484
+ [this.$$field]: wrapToPath(
485
+ {
486
+ type: ["string", "boolean", "number"],
487
+ const: {
488
+ $data: `/$form/${jsonFieldPath(comparedField)}`
489
+ }
490
+ },
491
+ this.$$subfield
492
+ ),
493
+ [comparedField.$$field]: wrapToPath(
494
+ { type: ["string", "boolean", "number"] },
495
+ comparedField.$$subfield
496
+ )
497
+ },
498
+ required: [this.$$field, comparedField.$$field]
499
+ });
500
+ }
501
+ return defineFormConditional({
502
+ type: "object",
503
+ properties: {
504
+ [this.$$field]: wrapToPath(
505
+ {
506
+ type: ["string", "boolean", "number"],
507
+ const: value
508
+ },
509
+ this.$$subfield
510
+ )
511
+ },
512
+ required: [this.$$field]
513
+ });
514
+ },
515
+ /**
516
+ * Use case: Some fields are rendered when selection is not made, or boolean false is explicitly selected.
517
+ * @example field('recommender.none').isFalsy() vs not(field('recommender.none').isEqualTo(true))
518
+ * @returns whether the field is falsy (undefined, false, null, empty string)
519
+ *
520
+ * NOTE: For now, this only works with string, boolean, and null types. 0 is still allowed.
521
+ *
522
+ */
523
+ isFalsy() {
524
+ const hasSubpath = this.$$subfield.length > 0;
525
+ const falsyLeaf = {
526
+ anyOf: [
527
+ { const: "undefined" },
528
+ { const: false },
529
+ { const: null },
530
+ { const: "" }
531
+ ]
532
+ };
533
+ return defineFormConditional({
534
+ type: "object",
535
+ properties: {
536
+ [fieldId]: hasSubpath ? {
537
+ // either the whole parent is null (treat as undefined),
538
+ // or the nested leaf is falsy
539
+ anyOf: [
540
+ { const: null },
541
+ wrapToPathOptional(falsyLeaf, this.$$subfield)
542
+ ]
543
+ } : falsyLeaf
544
+ },
545
+ anyOf: [{ required: [fieldId] }, { not: { required: [fieldId] } }]
546
+ });
547
+ },
548
+ isUndefined() {
549
+ return defineFormConditional({
550
+ type: "object",
551
+ properties: {
552
+ [fieldId]: wrapToPath(
553
+ {
554
+ type: "string",
555
+ enum: ["undefined"]
556
+ },
557
+ this.$$subfield
558
+ )
559
+ },
560
+ not: {
561
+ required: [fieldId]
562
+ }
563
+ });
564
+ },
565
+ inArray(values) {
566
+ return defineFormConditional({
567
+ type: "object",
568
+ properties: {
569
+ [fieldId]: wrapToPath(
570
+ {
571
+ type: "string",
572
+ enum: values
573
+ },
574
+ this.$$subfield
575
+ )
576
+ },
577
+ required: [fieldId]
578
+ });
579
+ },
580
+ isValidEnglishName() {
581
+ return defineFormConditional({
582
+ type: "object",
583
+ properties: {
584
+ [fieldId]: wrapToPathOptional(
585
+ {
586
+ type: "string",
587
+ 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'.-]*)*$",
588
+ description: "Name must contain only letters, numbers, and allowed special characters ('.-). No double spaces."
589
+ },
590
+ this.$$subfield
591
+ )
592
+ }
593
+ });
594
+ },
595
+ isValidAdministrativeLeafLevel() {
596
+ const baseCondition = {
597
+ type: "object",
598
+ properties: {
599
+ administrativeArea: {
600
+ type: "string",
601
+ isLeafLevelLocation: true
602
+ }
603
+ },
604
+ description: "The provided administrative value should have a value corresponding to the required lowest administrative level when addressType is DOMESTIC"
605
+ };
606
+ const conditional = {
607
+ if: {
608
+ type: "object",
609
+ properties: {
610
+ addressType: { const: "DOMESTIC" }
611
+ }
612
+ },
613
+ then: {
614
+ ...baseCondition,
615
+ required: ["administrativeArea"]
616
+ },
617
+ else: baseCondition
618
+ };
619
+ return defineFormConditional({
620
+ type: "object",
621
+ properties: {
622
+ [fieldId]: wrapToPath(conditional, this.$$subfield)
623
+ }
624
+ });
625
+ },
626
+ /**
627
+ * Checks if the field value matches a given regular expression pattern.
628
+ * @param pattern - The regular expression pattern to match the field value against.
629
+ * @returns A JSONSchema conditional that validates the field value against the pattern.
630
+ */
631
+ matches(pattern) {
632
+ return defineFormConditional({
633
+ type: "object",
634
+ properties: wrapToPath(
635
+ {
636
+ [fieldId]: {
637
+ type: "string",
638
+ pattern
639
+ }
640
+ },
641
+ this.$$subfield
642
+ ),
643
+ required: [fieldId]
644
+ });
645
+ },
646
+ isBetween(min, max) {
647
+ return defineFormConditional({
648
+ type: "object",
649
+ properties: {
650
+ [fieldId]: wrapToPath(
651
+ {
652
+ type: "number",
653
+ minimum: min,
654
+ maximum: max
655
+ },
656
+ this.$$subfield
657
+ )
658
+ },
659
+ required: [fieldId]
660
+ });
661
+ },
662
+ getId: () => ({ fieldId }),
663
+ /**
664
+ * @deprecated
665
+ * use field(fieldId).get(nestedProperty) instead
666
+ * with 'and' combinator e.g.
667
+ * and(
668
+ * field('child.name').get('firstname').isEqualTo('John'),
669
+ * field('child.name').get('surname').isEqualTo('Doe')
670
+ * )
671
+ */
672
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
673
+ object: (options) => defineFormConditional({
674
+ type: "object",
675
+ properties: {
676
+ [fieldId]: {
677
+ type: "object",
678
+ properties: Object.fromEntries(
679
+ Object.entries(options).map(([key, value]) => {
680
+ return [key, value.properties.$form.properties[key]];
681
+ })
682
+ ),
683
+ required: Object.keys(options)
684
+ }
685
+ },
686
+ required: [fieldId]
687
+ })
688
+ };
689
+ }