@opencrvs/toolkit 1.9.13-rc.72233cd → 1.9.13-rc.797da9b

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 (122) hide show
  1. package/build.sh +0 -13
  2. package/dist/api/index.d.ts.map +1 -1
  3. package/dist/commons/api/router.d.ts +4561 -3370
  4. package/dist/commons/conditionals/conditionals.d.ts +295 -28
  5. package/dist/commons/conditionals/validate.d.ts +9 -11
  6. package/dist/commons/events/ActionConfig.d.ts +1555 -415
  7. package/dist/commons/events/ActionDocument.d.ts +1941 -888
  8. package/dist/commons/events/ActionInput.d.ts +1277 -277
  9. package/dist/commons/events/ActionType.d.ts +11 -91
  10. package/dist/commons/events/AdvancedSearchConfig.d.ts +1496 -294
  11. package/dist/commons/events/CompositeFieldValue.d.ts +190 -30
  12. package/dist/commons/events/Conditional.d.ts +38 -26
  13. package/dist/commons/events/Constants.d.ts +1 -1
  14. package/dist/commons/events/CountryConfigQueryInput.d.ts +4471 -1592
  15. package/dist/commons/events/CreatedAtLocation.d.ts +2 -0
  16. package/dist/commons/events/DeduplicationConfig.d.ts +171 -15
  17. package/dist/commons/events/Draft.d.ts +113 -72
  18. package/dist/commons/events/DynamicFieldValue.d.ts +78 -12
  19. package/dist/commons/events/EventConfig.d.ts +2420 -35
  20. package/dist/commons/events/EventConfigInput.d.ts +3 -0
  21. package/dist/commons/events/EventDocument.d.ts +1366 -354
  22. package/dist/commons/events/EventIndex.d.ts +1010 -212
  23. package/dist/commons/events/EventInput.d.ts +8 -3
  24. package/dist/commons/events/EventMetadata.d.ts +357 -130
  25. package/dist/commons/events/FieldConfig.d.ts +16025 -2936
  26. package/dist/commons/events/FieldType.d.ts +4 -26
  27. package/dist/commons/events/FieldTypeMapping.d.ts +906 -314
  28. package/dist/commons/events/FieldValue.d.ts +527 -149
  29. package/dist/commons/events/FileUtils.d.ts +2 -2
  30. package/dist/commons/events/FormConfig.d.ts +721 -54
  31. package/dist/commons/events/PageConfig.d.ts +320 -58
  32. package/dist/commons/events/PlainDate.d.ts +1 -1
  33. package/dist/commons/events/SummaryConfig.d.ts +161 -14
  34. package/dist/commons/events/TemplateConfig.d.ts +3 -2
  35. package/dist/commons/events/TranslationConfig.d.ts +2 -2
  36. package/dist/commons/events/WorkqueueColumnConfig.d.ts +37 -74
  37. package/dist/commons/events/WorkqueueConfig.d.ts +7480 -2135
  38. package/dist/commons/events/deduplication.d.ts +3 -3
  39. package/dist/commons/events/defineConfig.d.ts +247 -2
  40. package/dist/commons/events/field.d.ts +22 -0
  41. package/dist/commons/events/index.d.ts +0 -3
  42. package/dist/commons/events/locations.d.ts +20 -57
  43. package/dist/commons/events/scopes.d.ts +34 -35
  44. package/dist/commons/events/state/availableActions.d.ts +2 -7
  45. package/dist/commons/events/state/flags.d.ts +3 -21
  46. package/dist/commons/events/state/index.d.ts +27 -30
  47. package/dist/commons/events/state/utils.d.ts +172 -190
  48. package/dist/commons/events/test.utils.d.ts +11 -52
  49. package/dist/commons/events/transactions.d.ts +1 -1
  50. package/dist/commons/events/utils.d.ts +273 -373
  51. package/dist/commons/notification/UserNotifications.d.ts +637 -61
  52. package/dist/conditionals/index.d.ts.map +1 -1
  53. package/dist/conditionals/index.js +2006 -270
  54. package/dist/events/deduplication.d.ts +3 -3
  55. package/dist/events/index.js +2203 -2847
  56. package/dist/notification/index.d.ts.map +1 -1
  57. package/dist/notification/index.js +1844 -2076
  58. package/dist/scopes/index.d.ts +353 -640
  59. package/dist/scopes/index.d.ts.map +1 -1
  60. package/dist/scopes/index.js +300 -340
  61. package/package.json +3 -13
  62. package/tsconfig.json +2 -12
  63. package/tsconfig.tsbuildinfo +1 -1
  64. package/dist/application-config/index.d.ts +0 -2
  65. package/dist/application-config/index.d.ts.map +0 -1
  66. package/dist/application-config/index.js +0 -2128
  67. package/dist/cli.d.ts +0 -2
  68. package/dist/cli.d.ts.map +0 -1
  69. package/dist/cli.js +0 -3237
  70. package/dist/commons/application-config/index.d.ts +0 -84
  71. package/dist/commons/events/AuditLog.d.ts +0 -405
  72. package/dist/commons/events/Flag.d.ts +0 -67
  73. package/dist/commons/events/eventConfigValidation.d.ts +0 -8
  74. package/dist/migrations/v2.0/add-birth-certificate-issuance-flag.d.ts +0 -3
  75. package/dist/migrations/v2.0/add-birth-certificate-issuance-flag.d.ts.map +0 -1
  76. package/dist/migrations/v2.0/add-birth-certificate-issuance-flag.js +0 -405
  77. package/dist/migrations/v2.0/convert-config-files-to-ts.d.ts +0 -2
  78. package/dist/migrations/v2.0/convert-config-files-to-ts.d.ts.map +0 -1
  79. package/dist/migrations/v2.0/convert-config-files-to-ts.js +0 -829
  80. package/dist/migrations/v2.0/convert-paragraph-to-heading.d.ts +0 -3
  81. package/dist/migrations/v2.0/convert-paragraph-to-heading.d.ts.map +0 -1
  82. package/dist/migrations/v2.0/convert-paragraph-to-heading.js +0 -159
  83. package/dist/migrations/v2.0/index.d.ts +0 -7
  84. package/dist/migrations/v2.0/index.d.ts.map +0 -1
  85. package/dist/migrations/v2.0/index.js +0 -3176
  86. package/dist/migrations/v2.0/make-built-in-validate-actions-custom.d.ts +0 -3
  87. package/dist/migrations/v2.0/make-built-in-validate-actions-custom.d.ts.map +0 -1
  88. package/dist/migrations/v2.0/make-built-in-validate-actions-custom.js +0 -344
  89. package/dist/migrations/v2.0/migrate-scopes.d.ts +0 -3
  90. package/dist/migrations/v2.0/migrate-scopes.d.ts.map +0 -1
  91. package/dist/migrations/v2.0/migrate-scopes.js +0 -282
  92. package/dist/migrations/v2.0/migrate-validated-workqueue-status-to-flag.d.ts +0 -3
  93. package/dist/migrations/v2.0/migrate-validated-workqueue-status-to-flag.d.ts.map +0 -1
  94. package/dist/migrations/v2.0/migrate-validated-workqueue-status-to-flag.js +0 -268
  95. package/dist/migrations/v2.0/migrate-workqueue-configs.d.ts +0 -3
  96. package/dist/migrations/v2.0/migrate-workqueue-configs.d.ts.map +0 -1
  97. package/dist/migrations/v2.0/migrate-workqueue-configs.js +0 -237
  98. package/dist/migrations/v2.0/remove-delete-actions.d.ts +0 -3
  99. package/dist/migrations/v2.0/remove-delete-actions.d.ts.map +0 -1
  100. package/dist/migrations/v2.0/remove-delete-actions.js +0 -157
  101. package/dist/migrations/v2.0/remove-demo-scope.d.ts +0 -3
  102. package/dist/migrations/v2.0/remove-demo-scope.d.ts.map +0 -1
  103. package/dist/migrations/v2.0/remove-demo-scope.js +0 -75
  104. package/dist/migrations/v2.0/remove-deprecated-imports.d.ts +0 -3
  105. package/dist/migrations/v2.0/remove-deprecated-imports.d.ts.map +0 -1
  106. package/dist/migrations/v2.0/remove-deprecated-imports.js +0 -97
  107. package/dist/migrations/v2.0/remove-hearth-migrations.d.ts +0 -3
  108. package/dist/migrations/v2.0/remove-hearth-migrations.d.ts.map +0 -1
  109. package/dist/migrations/v2.0/remove-hearth-migrations.js +0 -78
  110. package/dist/migrations/v2.0/remove-pending-certification-flag.d.ts +0 -3
  111. package/dist/migrations/v2.0/remove-pending-certification-flag.d.ts.map +0 -1
  112. package/dist/migrations/v2.0/remove-pending-certification-flag.js +0 -110
  113. package/dist/migrations/v2.0/remove-review-from-register-action.d.ts +0 -3
  114. package/dist/migrations/v2.0/remove-review-from-register-action.d.ts.map +0 -1
  115. package/dist/migrations/v2.0/remove-review-from-register-action.js +0 -164
  116. package/dist/migrations/v2.0/rename-api-paths.d.ts +0 -3
  117. package/dist/migrations/v2.0/rename-api-paths.d.ts.map +0 -1
  118. package/dist/migrations/v2.0/rename-api-paths.js +0 -188
  119. package/dist/migrations/v2.0/rename-location-parent-id.d.ts +0 -3
  120. package/dist/migrations/v2.0/rename-location-parent-id.d.ts.map +0 -1
  121. package/dist/migrations/v2.0/rename-location-parent-id.js +0 -181
  122. package/opencrvs-toolkit-1.9.13-rc.72233cd.tgz +0 -0
@@ -1,12 +1,11 @@
1
1
  import { EventDocument } from '../events/EventDocument';
2
2
  import { EventState } from '../events/ActionDocument';
3
- import { ITokenPayload as TokenPayload } from '../authentication';
3
+ import { ITokenPayload as TokenPayload, Scope } from '../authentication';
4
4
  import { PartialSchema as AjvJSONSchemaType } from 'ajv/dist/types/json-schema';
5
5
  import { userSerializer } from '../events/serializers/user/serializer';
6
6
  import { UUID } from '../uuid';
7
7
  import { todayDateTimeValueSerializer } from '../events/serializers/date/serializer';
8
- import { EventStatus } from '../events/EventMetadata';
9
- import { FieldReference } from '../events/FieldConfig';
8
+ import { CodeToEvaluate, FieldReference } from '../events/FieldConfig';
10
9
  /** @knipignore */
11
10
  export type JSONSchema = {
12
11
  $id: string;
@@ -30,11 +29,7 @@ export type FormConditionalParameters = CommonConditionalParameters & {
30
29
  id: UUID;
31
30
  }>;
32
31
  };
33
- export type EventStateConditionalParameters = CommonConditionalParameters & {
34
- $flags: string[];
35
- $status: EventStatus;
36
- };
37
- export type ConditionalParameters = UserConditionalParameters | EventConditionalParameters | FormConditionalParameters | EventStateConditionalParameters;
32
+ export type ConditionalParameters = UserConditionalParameters | EventConditionalParameters | FormConditionalParameters;
38
33
  type UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends (k: infer I) => void ? I : never;
39
34
  type AjvJSONSchema = AjvJSONSchemaType<UnionToIntersection<ConditionalParameters>>;
40
35
  /**
@@ -76,7 +71,7 @@ export declare const now: typeof todayDateTimeValueSerializer;
76
71
  * Generate conditional rules for user.
77
72
  */
78
73
  export declare const user: typeof userSerializer & {
79
- hasScope: (scope: string) => JSONSchema;
74
+ hasScope: (scope: Scope) => JSONSchema;
80
75
  hasRole: (role: string) => JSONSchema;
81
76
  isOnline: () => JSONSchema;
82
77
  locationLevel: (adminLevelId: string) => {
@@ -84,28 +79,14 @@ export declare const user: typeof userSerializer & {
84
79
  $location: string;
85
80
  };
86
81
  };
87
- scope: (scope: import("../scopes").ScopeType) => {
88
- attribute: (option: import("../scopes").ScopeOptionKey) => {
89
- $scope: "record.search" | "record.create" | "record.read" | "record.declare" | "record.notify" | "record.edit" | "record.reject" | "record.archive" | "record.review-duplicates" | "record.register" | "record.print-certified-copies" | "record.request-correction" | "record.correct" | "record.unassign-others" | "record.custom-action" | "bypassratelimit" | "record.reindex" | "user.data-seeding" | "integration.create" | "record.import" | "config.update-all" | "attachment.upload" | "profile.electronic-signature" | "user.read-only-my-audit" | "performance.read" | "performance.read-dashboards" | "performance.vital-statistics-export" | "record.confirm-registration" | "record.reject-registration" | "organisation.read-locations" | "user.read" | "user.create" | "user.edit" | "workqueue" | "dashboard.view";
90
- $option: "event" | "placeOfEvent" | "declaredIn" | "declaredBy" | "registeredIn" | "registeredBy" | "accessLevel" | "ids";
91
- };
92
- };
93
- jurisdiction: (jurisdiction: import("../scopes").JurisdictionFilter | {
94
- $scope: "record.search" | "record.create" | "record.read" | "record.declare" | "record.notify" | "record.edit" | "record.reject" | "record.archive" | "record.review-duplicates" | "record.register" | "record.print-certified-copies" | "record.request-correction" | "record.correct" | "record.unassign-others" | "record.custom-action" | "bypassratelimit" | "record.reindex" | "user.data-seeding" | "integration.create" | "record.import" | "config.update-all" | "attachment.upload" | "profile.electronic-signature" | "user.read-only-my-audit" | "performance.read" | "performance.read-dashboards" | "performance.vital-statistics-export" | "record.confirm-registration" | "record.reject-registration" | "organisation.read-locations" | "user.read" | "user.create" | "user.edit" | "workqueue" | "dashboard.view";
95
- $option: "event" | "placeOfEvent" | "declaredIn" | "declaredBy" | "registeredIn" | "registeredBy" | "accessLevel" | "ids";
96
- }) => {
97
- $jurisdiction: "administrativeArea" | "location" | "all" | {
98
- $scope: "record.search" | "record.create" | "record.read" | "record.declare" | "record.notify" | "record.edit" | "record.reject" | "record.archive" | "record.review-duplicates" | "record.register" | "record.print-certified-copies" | "record.request-correction" | "record.correct" | "record.unassign-others" | "record.custom-action" | "bypassratelimit" | "record.reindex" | "user.data-seeding" | "integration.create" | "record.import" | "config.update-all" | "attachment.upload" | "profile.electronic-signature" | "user.read-only-my-audit" | "performance.read" | "performance.read-dashboards" | "performance.vital-statistics-export" | "record.confirm-registration" | "record.reject-registration" | "organisation.read-locations" | "user.read" | "user.create" | "user.edit" | "workqueue" | "dashboard.view";
99
- $option: "event" | "placeOfEvent" | "declaredIn" | "declaredBy" | "registeredIn" | "registeredBy" | "accessLevel" | "ids";
100
- };
101
- };
102
82
  };
103
83
  export declare function isFieldReference(value: unknown): value is FieldReference;
104
84
  export declare function isEventFieldReference(value: unknown): value is FieldReference;
105
- /** Check if an event flag is present */
106
- export declare function flag(flagvalue: string): JSONSchema;
107
- /** Check if an event flag is present */
108
- export declare function status(statusValue: EventStatus): JSONSchema;
85
+ /**
86
+ * Centralised guard so a future third reference type only needs to be added here
87
+ * and in {@link parseFieldReferenceToValue}, not at every call site.
88
+ */
89
+ export declare function isResolvableValueReference(value: unknown): value is FieldReference | CodeToEvaluate;
109
90
  /**
110
91
  * Generate conditional rules for a form field.
111
92
  *
@@ -196,6 +177,32 @@ export declare function createFieldConditionals(fieldId: string): {
196
177
  * )
197
178
  */
198
179
  object: (options: Record<string, any>) => JSONSchema;
180
+ /**
181
+ * Custom client-side validator. The provided function is serialised and executed
182
+ * just-in-time on the client only. External references (e.g. lodash) are not
183
+ * available inside the function body — all logic must be self-contained.
184
+ *
185
+ * @example
186
+ * field('nid').customClientValidator((value) => {
187
+ * // LUHN check — all logic must be inline
188
+ * const digits = String(value).split('').map(Number)
189
+ * // ...
190
+ * return isValid
191
+ * })
192
+ */
193
+ customClientValidator(validationFn: (fieldValue: unknown, context: FormConditionalParameters) => boolean): JSONSchema;
194
+ /**
195
+ * Custom client-side evaluation. Returns a {@link CodeToEvaluate} descriptor
196
+ * that can be used as `value`, `evaluatedDefaultValue`, or a DATA component entry.
197
+ * The function is serialised and executed just-in-time on the client only.
198
+ * External references (e.g. lodash) are not available inside the function body.
199
+ *
200
+ * @example
201
+ * field('a').customClientEvaluation((aValue, ctx) =>
202
+ * Number(aValue) + Number(ctx.$form.b)
203
+ * )
204
+ */
205
+ customClientEvaluation(computationFn: (fieldValue: unknown, context: FormConditionalParameters) => unknown): CodeToEvaluate;
199
206
  };
200
207
  asDob(): any;
201
208
  asAge(): any;
@@ -255,6 +262,32 @@ export declare function createFieldConditionals(fieldId: string): {
255
262
  * )
256
263
  */
257
264
  object: (options: Record<string, any>) => JSONSchema;
265
+ /**
266
+ * Custom client-side validator. The provided function is serialised and executed
267
+ * just-in-time on the client only. External references (e.g. lodash) are not
268
+ * available inside the function body — all logic must be self-contained.
269
+ *
270
+ * @example
271
+ * field('nid').customClientValidator((value) => {
272
+ * // LUHN check — all logic must be inline
273
+ * const digits = String(value).split('').map(Number)
274
+ * // ...
275
+ * return isValid
276
+ * })
277
+ */
278
+ customClientValidator(validationFn: (fieldValue: unknown, context: FormConditionalParameters) => boolean): JSONSchema;
279
+ /**
280
+ * Custom client-side evaluation. Returns a {@link CodeToEvaluate} descriptor
281
+ * that can be used as `value`, `evaluatedDefaultValue`, or a DATA component entry.
282
+ * The function is serialised and executed just-in-time on the client only.
283
+ * External references (e.g. lodash) are not available inside the function body.
284
+ *
285
+ * @example
286
+ * field('a').customClientEvaluation((aValue, ctx) =>
287
+ * Number(aValue) + Number(ctx.$form.b)
288
+ * )
289
+ */
290
+ customClientEvaluation(computationFn: (fieldValue: unknown, context: FormConditionalParameters) => unknown): CodeToEvaluate;
258
291
  };
259
292
  getByPath(fieldPath: string[]): {
260
293
  $$subfield: string[];
@@ -328,6 +361,32 @@ export declare function createFieldConditionals(fieldId: string): {
328
361
  * )
329
362
  */
330
363
  object: (options: Record<string, any>) => JSONSchema;
364
+ /**
365
+ * Custom client-side validator. The provided function is serialised and executed
366
+ * just-in-time on the client only. External references (e.g. lodash) are not
367
+ * available inside the function body — all logic must be self-contained.
368
+ *
369
+ * @example
370
+ * field('nid').customClientValidator((value) => {
371
+ * // LUHN check — all logic must be inline
372
+ * const digits = String(value).split('').map(Number)
373
+ * // ...
374
+ * return isValid
375
+ * })
376
+ */
377
+ customClientValidator(validationFn: (fieldValue: unknown, context: FormConditionalParameters) => boolean): JSONSchema;
378
+ /**
379
+ * Custom client-side evaluation. Returns a {@link CodeToEvaluate} descriptor
380
+ * that can be used as `value`, `evaluatedDefaultValue`, or a DATA component entry.
381
+ * The function is serialised and executed just-in-time on the client only.
382
+ * External references (e.g. lodash) are not available inside the function body.
383
+ *
384
+ * @example
385
+ * field('a').customClientEvaluation((aValue, ctx) =>
386
+ * Number(aValue) + Number(ctx.$form.b)
387
+ * )
388
+ */
389
+ customClientEvaluation(computationFn: (fieldValue: unknown, context: FormConditionalParameters) => unknown): CodeToEvaluate;
331
390
  };
332
391
  getByPath(fieldPath: string[]): any;
333
392
  asDob(): {
@@ -396,6 +455,32 @@ export declare function createFieldConditionals(fieldId: string): {
396
455
  * )
397
456
  */
398
457
  object: (options: Record<string, any>) => JSONSchema;
458
+ /**
459
+ * Custom client-side validator. The provided function is serialised and executed
460
+ * just-in-time on the client only. External references (e.g. lodash) are not
461
+ * available inside the function body — all logic must be self-contained.
462
+ *
463
+ * @example
464
+ * field('nid').customClientValidator((value) => {
465
+ * // LUHN check — all logic must be inline
466
+ * const digits = String(value).split('').map(Number)
467
+ * // ...
468
+ * return isValid
469
+ * })
470
+ */
471
+ customClientValidator(validationFn: (fieldValue: unknown, context: FormConditionalParameters) => boolean): JSONSchema;
472
+ /**
473
+ * Custom client-side evaluation. Returns a {@link CodeToEvaluate} descriptor
474
+ * that can be used as `value`, `evaluatedDefaultValue`, or a DATA component entry.
475
+ * The function is serialised and executed just-in-time on the client only.
476
+ * External references (e.g. lodash) are not available inside the function body.
477
+ *
478
+ * @example
479
+ * field('a').customClientEvaluation((aValue, ctx) =>
480
+ * Number(aValue) + Number(ctx.$form.b)
481
+ * )
482
+ */
483
+ customClientEvaluation(computationFn: (fieldValue: unknown, context: FormConditionalParameters) => unknown): CodeToEvaluate;
399
484
  };
400
485
  asAge(): {
401
486
  $$subfield: string[];
@@ -463,6 +548,32 @@ export declare function createFieldConditionals(fieldId: string): {
463
548
  * )
464
549
  */
465
550
  object: (options: Record<string, any>) => JSONSchema;
551
+ /**
552
+ * Custom client-side validator. The provided function is serialised and executed
553
+ * just-in-time on the client only. External references (e.g. lodash) are not
554
+ * available inside the function body — all logic must be self-contained.
555
+ *
556
+ * @example
557
+ * field('nid').customClientValidator((value) => {
558
+ * // LUHN check — all logic must be inline
559
+ * const digits = String(value).split('').map(Number)
560
+ * // ...
561
+ * return isValid
562
+ * })
563
+ */
564
+ customClientValidator(validationFn: (fieldValue: unknown, context: FormConditionalParameters) => boolean): JSONSchema;
565
+ /**
566
+ * Custom client-side evaluation. Returns a {@link CodeToEvaluate} descriptor
567
+ * that can be used as `value`, `evaluatedDefaultValue`, or a DATA component entry.
568
+ * The function is serialised and executed just-in-time on the client only.
569
+ * External references (e.g. lodash) are not available inside the function body.
570
+ *
571
+ * @example
572
+ * field('a').customClientEvaluation((aValue, ctx) =>
573
+ * Number(aValue) + Number(ctx.$form.b)
574
+ * )
575
+ */
576
+ customClientEvaluation(computationFn: (fieldValue: unknown, context: FormConditionalParameters) => unknown): CodeToEvaluate;
466
577
  };
467
578
  isAfter(): {
468
579
  days: (days: number) => {
@@ -520,6 +631,32 @@ export declare function createFieldConditionals(fieldId: string): {
520
631
  * )
521
632
  */
522
633
  object: (options: Record<string, any>) => JSONSchema;
634
+ /**
635
+ * Custom client-side validator. The provided function is serialised and executed
636
+ * just-in-time on the client only. External references (e.g. lodash) are not
637
+ * available inside the function body — all logic must be self-contained.
638
+ *
639
+ * @example
640
+ * field('nid').customClientValidator((value) => {
641
+ * // LUHN check — all logic must be inline
642
+ * const digits = String(value).split('').map(Number)
643
+ * // ...
644
+ * return isValid
645
+ * })
646
+ */
647
+ customClientValidator(validationFn: (fieldValue: unknown, context: FormConditionalParameters) => boolean): JSONSchema;
648
+ /**
649
+ * Custom client-side evaluation. Returns a {@link CodeToEvaluate} descriptor
650
+ * that can be used as `value`, `evaluatedDefaultValue`, or a DATA component entry.
651
+ * The function is serialised and executed just-in-time on the client only.
652
+ * External references (e.g. lodash) are not available inside the function body.
653
+ *
654
+ * @example
655
+ * field('a').customClientEvaluation((aValue, ctx) =>
656
+ * Number(aValue) + Number(ctx.$form.b)
657
+ * )
658
+ */
659
+ customClientEvaluation(computationFn: (fieldValue: unknown, context: FormConditionalParameters) => unknown): CodeToEvaluate;
523
660
  };
524
661
  asDob(): {
525
662
  $$subfield: string[];
@@ -594,6 +731,32 @@ export declare function createFieldConditionals(fieldId: string): {
594
731
  * )
595
732
  */
596
733
  object: (options: Record<string, any>) => JSONSchema;
734
+ /**
735
+ * Custom client-side validator. The provided function is serialised and executed
736
+ * just-in-time on the client only. External references (e.g. lodash) are not
737
+ * available inside the function body — all logic must be self-contained.
738
+ *
739
+ * @example
740
+ * field('nid').customClientValidator((value) => {
741
+ * // LUHN check — all logic must be inline
742
+ * const digits = String(value).split('').map(Number)
743
+ * // ...
744
+ * return isValid
745
+ * })
746
+ */
747
+ customClientValidator(validationFn: (fieldValue: unknown, context: FormConditionalParameters) => boolean): JSONSchema;
748
+ /**
749
+ * Custom client-side evaluation. Returns a {@link CodeToEvaluate} descriptor
750
+ * that can be used as `value`, `evaluatedDefaultValue`, or a DATA component entry.
751
+ * The function is serialised and executed just-in-time on the client only.
752
+ * External references (e.g. lodash) are not available inside the function body.
753
+ *
754
+ * @example
755
+ * field('a').customClientEvaluation((aValue, ctx) =>
756
+ * Number(aValue) + Number(ctx.$form.b)
757
+ * )
758
+ */
759
+ customClientEvaluation(computationFn: (fieldValue: unknown, context: FormConditionalParameters) => unknown): CodeToEvaluate;
597
760
  };
598
761
  asDob(): any;
599
762
  asAge(): any;
@@ -653,6 +816,32 @@ export declare function createFieldConditionals(fieldId: string): {
653
816
  * )
654
817
  */
655
818
  object: (options: Record<string, any>) => JSONSchema;
819
+ /**
820
+ * Custom client-side validator. The provided function is serialised and executed
821
+ * just-in-time on the client only. External references (e.g. lodash) are not
822
+ * available inside the function body — all logic must be self-contained.
823
+ *
824
+ * @example
825
+ * field('nid').customClientValidator((value) => {
826
+ * // LUHN check — all logic must be inline
827
+ * const digits = String(value).split('').map(Number)
828
+ * // ...
829
+ * return isValid
830
+ * })
831
+ */
832
+ customClientValidator(validationFn: (fieldValue: unknown, context: FormConditionalParameters) => boolean): JSONSchema;
833
+ /**
834
+ * Custom client-side evaluation. Returns a {@link CodeToEvaluate} descriptor
835
+ * that can be used as `value`, `evaluatedDefaultValue`, or a DATA component entry.
836
+ * The function is serialised and executed just-in-time on the client only.
837
+ * External references (e.g. lodash) are not available inside the function body.
838
+ *
839
+ * @example
840
+ * field('a').customClientEvaluation((aValue, ctx) =>
841
+ * Number(aValue) + Number(ctx.$form.b)
842
+ * )
843
+ */
844
+ customClientEvaluation(computationFn: (fieldValue: unknown, context: FormConditionalParameters) => unknown): CodeToEvaluate;
656
845
  };
657
846
  asAge(): {
658
847
  $$subfield: string[];
@@ -727,6 +916,32 @@ export declare function createFieldConditionals(fieldId: string): {
727
916
  * )
728
917
  */
729
918
  object: (options: Record<string, any>) => JSONSchema;
919
+ /**
920
+ * Custom client-side validator. The provided function is serialised and executed
921
+ * just-in-time on the client only. External references (e.g. lodash) are not
922
+ * available inside the function body — all logic must be self-contained.
923
+ *
924
+ * @example
925
+ * field('nid').customClientValidator((value) => {
926
+ * // LUHN check — all logic must be inline
927
+ * const digits = String(value).split('').map(Number)
928
+ * // ...
929
+ * return isValid
930
+ * })
931
+ */
932
+ customClientValidator(validationFn: (fieldValue: unknown, context: FormConditionalParameters) => boolean): JSONSchema;
933
+ /**
934
+ * Custom client-side evaluation. Returns a {@link CodeToEvaluate} descriptor
935
+ * that can be used as `value`, `evaluatedDefaultValue`, or a DATA component entry.
936
+ * The function is serialised and executed just-in-time on the client only.
937
+ * External references (e.g. lodash) are not available inside the function body.
938
+ *
939
+ * @example
940
+ * field('a').customClientEvaluation((aValue, ctx) =>
941
+ * Number(aValue) + Number(ctx.$form.b)
942
+ * )
943
+ */
944
+ customClientEvaluation(computationFn: (fieldValue: unknown, context: FormConditionalParameters) => unknown): CodeToEvaluate;
730
945
  };
731
946
  asDob(): any;
732
947
  asAge(): any;
@@ -786,6 +1001,32 @@ export declare function createFieldConditionals(fieldId: string): {
786
1001
  * )
787
1002
  */
788
1003
  object: (options: Record<string, any>) => JSONSchema;
1004
+ /**
1005
+ * Custom client-side validator. The provided function is serialised and executed
1006
+ * just-in-time on the client only. External references (e.g. lodash) are not
1007
+ * available inside the function body — all logic must be self-contained.
1008
+ *
1009
+ * @example
1010
+ * field('nid').customClientValidator((value) => {
1011
+ * // LUHN check — all logic must be inline
1012
+ * const digits = String(value).split('').map(Number)
1013
+ * // ...
1014
+ * return isValid
1015
+ * })
1016
+ */
1017
+ customClientValidator(validationFn: (fieldValue: unknown, context: FormConditionalParameters) => boolean): JSONSchema;
1018
+ /**
1019
+ * Custom client-side evaluation. Returns a {@link CodeToEvaluate} descriptor
1020
+ * that can be used as `value`, `evaluatedDefaultValue`, or a DATA component entry.
1021
+ * The function is serialised and executed just-in-time on the client only.
1022
+ * External references (e.g. lodash) are not available inside the function body.
1023
+ *
1024
+ * @example
1025
+ * field('a').customClientEvaluation((aValue, ctx) =>
1026
+ * Number(aValue) + Number(ctx.$form.b)
1027
+ * )
1028
+ */
1029
+ customClientEvaluation(computationFn: (fieldValue: unknown, context: FormConditionalParameters) => unknown): CodeToEvaluate;
789
1030
  };
790
1031
  isAfter(): {
791
1032
  days: (days: number) => {
@@ -843,6 +1084,32 @@ export declare function createFieldConditionals(fieldId: string): {
843
1084
  * )
844
1085
  */
845
1086
  object: (options: Record<string, any>) => JSONSchema;
1087
+ /**
1088
+ * Custom client-side validator. The provided function is serialised and executed
1089
+ * just-in-time on the client only. External references (e.g. lodash) are not
1090
+ * available inside the function body — all logic must be self-contained.
1091
+ *
1092
+ * @example
1093
+ * field('nid').customClientValidator((value) => {
1094
+ * // LUHN check — all logic must be inline
1095
+ * const digits = String(value).split('').map(Number)
1096
+ * // ...
1097
+ * return isValid
1098
+ * })
1099
+ */
1100
+ customClientValidator(validationFn: (fieldValue: unknown, context: FormConditionalParameters) => boolean): JSONSchema;
1101
+ /**
1102
+ * Custom client-side evaluation. Returns a {@link CodeToEvaluate} descriptor
1103
+ * that can be used as `value`, `evaluatedDefaultValue`, or a DATA component entry.
1104
+ * The function is serialised and executed just-in-time on the client only.
1105
+ * External references (e.g. lodash) are not available inside the function body.
1106
+ *
1107
+ * @example
1108
+ * field('a').customClientEvaluation((aValue, ctx) =>
1109
+ * Number(aValue) + Number(ctx.$form.b)
1110
+ * )
1111
+ */
1112
+ customClientEvaluation(computationFn: (fieldValue: unknown, context: FormConditionalParameters) => unknown): CodeToEvaluate;
846
1113
  };
847
1114
  export {};
848
1115
  //# sourceMappingURL=conditionals.d.ts.map
@@ -7,34 +7,32 @@ import { TranslationConfig } from '../events/TranslationConfig';
7
7
  import { ITokenPayload } from '../authentication';
8
8
  import { UUID } from '../uuid';
9
9
  import { FormState } from '../events/utils';
10
- import { ActionConfig } from '../events/ActionConfig';
11
10
  import { ActionType } from '../events/ActionType';
12
- import { EventConfig } from '../events/EventConfig';
13
11
  import { EventDocument } from '../events/EventDocument';
14
- import { EventIndex } from '../events/EventIndex';
12
+ /** Returns today's date as an ISO date string (YYYY-MM-DD). */
13
+ export declare function todayISO(): string;
15
14
  /**
16
- * Precompiles action conditional schemas from the event configurations to improve performance of condition validation later on.
17
- * Best called once on application startup before any condition validation is done.
15
+ * Deserialises a serialised function string (produced by `.toString()`) into a callable.
16
+ * Results are cached by code string so each unique function body is compiled at most once.
17
+ * Runs in a clean scope — no access to outer closures or external imports.
18
18
  */
19
- export declare function precompileActionSchemas(eventConfigurations: EventConfig[]): void;
19
+ export declare function compileClientFunction(code: string): (...args: unknown[]) => unknown;
20
20
  export declare function validate(schema: JSONSchema, data: ConditionalParameters): boolean;
21
21
  export declare function validateValue(schema: JSONSchema, data: unknown): boolean;
22
22
  export declare function isOnline(): boolean;
23
- export declare function isConditionMet(conditional: JSONSchema, values: EventState | ActionUpdate, context: ValidatorContext, eventIndex?: EventIndex): boolean;
24
- export declare function areConditionsMet(conditions: FieldConditional[], values: Record<string, FieldValue>, context: ValidatorContext, event: EventIndex): boolean;
23
+ export declare function isConditionMet(conditional: JSONSchema, values: EventState | ActionUpdate, context: ValidatorContext): boolean;
24
+ export declare function areConditionsMet(conditions: FieldConditional[], values: Record<string, FieldValue>, context: ValidatorContext): boolean;
25
25
  export type ValidatorContext = {
26
26
  user?: ITokenPayload;
27
27
  leafAdminStructureLocationIds?: Array<{
28
28
  id: UUID;
29
29
  }>;
30
30
  event?: EventDocument;
31
+ baseFormState?: EventState;
31
32
  };
32
33
  export declare function isFieldVisible(field: FieldConfig, form: Partial<ActionUpdate | EventState>, context: ValidatorContext): boolean;
33
34
  export declare function isFieldEnabled(field: FieldConfig, form: ActionUpdate | EventState, context: ValidatorContext): boolean;
34
35
  export declare function isFieldDisplayedOnReview(field: FieldConfig, form: ActionUpdate | EventState, context: ValidatorContext): boolean;
35
- export declare function isActionEnabled(actionConfig: ActionConfig, event: EventIndex, context: ValidatorContext): boolean;
36
- export declare function isActionVisible(actionConfig: ActionConfig, event: EventIndex, context: ValidatorContext): boolean;
37
- export declare function isActionAvailable(actionConfig: ActionConfig, event: EventIndex, context: ValidatorContext): boolean;
38
36
  export declare const errorMessages: {
39
37
  hiddenField: {
40
38
  id: string;