@opencrvs/toolkit 1.9.13-rc.797da9b → 1.9.13-rc.7acbd3f

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.
@@ -5,7 +5,7 @@ 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 { CodeToEvaluate, FieldReference } from '../events/FieldConfig';
8
+ import { FieldReference } from '../events/FieldConfig';
9
9
  /** @knipignore */
10
10
  export type JSONSchema = {
11
11
  $id: string;
@@ -82,11 +82,6 @@ export declare const user: typeof userSerializer & {
82
82
  };
83
83
  export declare function isFieldReference(value: unknown): value is FieldReference;
84
84
  export declare function isEventFieldReference(value: unknown): value is FieldReference;
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;
90
85
  /**
91
86
  * Generate conditional rules for a form field.
92
87
  *
@@ -177,32 +172,6 @@ export declare function createFieldConditionals(fieldId: string): {
177
172
  * )
178
173
  */
179
174
  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;
206
175
  };
207
176
  asDob(): any;
208
177
  asAge(): any;
@@ -262,32 +231,6 @@ export declare function createFieldConditionals(fieldId: string): {
262
231
  * )
263
232
  */
264
233
  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;
291
234
  };
292
235
  getByPath(fieldPath: string[]): {
293
236
  $$subfield: string[];
@@ -361,32 +304,6 @@ export declare function createFieldConditionals(fieldId: string): {
361
304
  * )
362
305
  */
363
306
  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;
390
307
  };
391
308
  getByPath(fieldPath: string[]): any;
392
309
  asDob(): {
@@ -455,32 +372,6 @@ export declare function createFieldConditionals(fieldId: string): {
455
372
  * )
456
373
  */
457
374
  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;
484
375
  };
485
376
  asAge(): {
486
377
  $$subfield: string[];
@@ -548,32 +439,6 @@ export declare function createFieldConditionals(fieldId: string): {
548
439
  * )
549
440
  */
550
441
  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;
577
442
  };
578
443
  isAfter(): {
579
444
  days: (days: number) => {
@@ -631,32 +496,6 @@ export declare function createFieldConditionals(fieldId: string): {
631
496
  * )
632
497
  */
633
498
  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;
660
499
  };
661
500
  asDob(): {
662
501
  $$subfield: string[];
@@ -731,32 +570,6 @@ export declare function createFieldConditionals(fieldId: string): {
731
570
  * )
732
571
  */
733
572
  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;
760
573
  };
761
574
  asDob(): any;
762
575
  asAge(): any;
@@ -816,32 +629,6 @@ export declare function createFieldConditionals(fieldId: string): {
816
629
  * )
817
630
  */
818
631
  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;
845
632
  };
846
633
  asAge(): {
847
634
  $$subfield: string[];
@@ -916,32 +703,6 @@ export declare function createFieldConditionals(fieldId: string): {
916
703
  * )
917
704
  */
918
705
  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;
945
706
  };
946
707
  asDob(): any;
947
708
  asAge(): any;
@@ -1001,32 +762,6 @@ export declare function createFieldConditionals(fieldId: string): {
1001
762
  * )
1002
763
  */
1003
764
  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;
1030
765
  };
1031
766
  isAfter(): {
1032
767
  days: (days: number) => {
@@ -1084,32 +819,6 @@ export declare function createFieldConditionals(fieldId: string): {
1084
819
  * )
1085
820
  */
1086
821
  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;
1113
822
  };
1114
823
  export {};
1115
824
  //# sourceMappingURL=conditionals.d.ts.map
@@ -9,14 +9,6 @@ import { UUID } from '../uuid';
9
9
  import { FormState } from '../events/utils';
10
10
  import { ActionType } from '../events/ActionType';
11
11
  import { EventDocument } from '../events/EventDocument';
12
- /** Returns today's date as an ISO date string (YYYY-MM-DD). */
13
- export declare function todayISO(): string;
14
- /**
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
- */
19
- export declare function compileClientFunction(code: string): (...args: unknown[]) => unknown;
20
12
  export declare function validate(schema: JSONSchema, data: ConditionalParameters): boolean;
21
13
  export declare function validateValue(schema: JSONSchema, data: unknown): boolean;
22
14
  export declare function isOnline(): boolean;