@opencrvs/toolkit 1.9.13-rc.de92f80 → 1.9.13-rc.e396178
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 +2489 -166
- package/dist/commons/conditionals/conditionals.d.ts +345 -2
- package/dist/commons/conditionals/validate.d.ts +8 -0
- package/dist/commons/events/ActionInput.d.ts +204 -0
- package/dist/commons/events/Draft.d.ts +6 -0
- package/dist/commons/events/EventConfig.d.ts +7 -0
- package/dist/commons/events/FieldConfig.d.ts +1489 -88
- package/dist/commons/events/defineConfig.d.ts +1 -0
- package/dist/commons/events/field.d.ts +47 -1
- package/dist/commons/events/utils.d.ts +1 -0
- package/dist/conditionals/index.js +48 -1
- package/dist/events/index.js +131 -38
- package/dist/notification/index.js +114 -35
- package/package.json +7 -7
|
@@ -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 { FieldReference } from '../events/FieldConfig';
|
|
8
|
+
import { CodeToEvaluate, FieldReference } from '../events/FieldConfig';
|
|
9
9
|
/** @knipignore */
|
|
10
10
|
export type JSONSchema = {
|
|
11
11
|
$id: string;
|
|
@@ -81,7 +81,9 @@ export declare const user: typeof userSerializer & {
|
|
|
81
81
|
};
|
|
82
82
|
};
|
|
83
83
|
export declare function isFieldReference(value: unknown): value is FieldReference;
|
|
84
|
-
export declare function isEventFieldReference(value: unknown): value is
|
|
84
|
+
export declare function isEventFieldReference(value: unknown): value is {
|
|
85
|
+
$$event: string;
|
|
86
|
+
};
|
|
85
87
|
/**
|
|
86
88
|
* Generate conditional rules for a form field.
|
|
87
89
|
*
|
|
@@ -172,6 +174,37 @@ export declare function createFieldConditionals(fieldId: string): {
|
|
|
172
174
|
* )
|
|
173
175
|
*/
|
|
174
176
|
object: (options: Record<string, any>) => JSONSchema;
|
|
177
|
+
/**
|
|
178
|
+
* Custom client-side validator. The provided function is serialised and executed
|
|
179
|
+
* just-in-time on the client only. External references (e.g. lodash) are not
|
|
180
|
+
* available inside the function body — all logic must be self-contained.
|
|
181
|
+
*
|
|
182
|
+
* @example
|
|
183
|
+
* field('nid').customClientValidator((value) => {
|
|
184
|
+
* // LUHN check — all logic must be inline
|
|
185
|
+
* const digits = String(value).split('').map(Number)
|
|
186
|
+
* // ...
|
|
187
|
+
* return isValid
|
|
188
|
+
* })
|
|
189
|
+
*/
|
|
190
|
+
customClientValidator(validationFn: (fieldValue: unknown, context: FormConditionalParameters) => boolean): JSONSchema;
|
|
191
|
+
/**
|
|
192
|
+
* Custom client-side evaluation. Returns a {@link FieldReference} descriptor
|
|
193
|
+
* that can be used as the `value` property or a DATA component entry.
|
|
194
|
+
* The function receives the referenced field's value as the first argument and
|
|
195
|
+
* the full form context as the second; its return value replaces the field reference.
|
|
196
|
+
* The function is serialised and executed just-in-time on the client only.
|
|
197
|
+
* External references (e.g. lodash) are not available inside the function body.
|
|
198
|
+
*
|
|
199
|
+
* For computing a default value without referencing a specific field, use
|
|
200
|
+
* `evaluate(fn)` in the `defaultValue` property instead.
|
|
201
|
+
*
|
|
202
|
+
* @example
|
|
203
|
+
* field('a').customClientEvaluation((aValue, ctx) =>
|
|
204
|
+
* Number(aValue) + Number(ctx.$form.b)
|
|
205
|
+
* )
|
|
206
|
+
*/
|
|
207
|
+
customClientEvaluation(computationFn: (fieldValue: unknown, context: FormConditionalParameters) => unknown): CodeToEvaluate;
|
|
175
208
|
};
|
|
176
209
|
asDob(): any;
|
|
177
210
|
asAge(): any;
|
|
@@ -231,6 +264,37 @@ export declare function createFieldConditionals(fieldId: string): {
|
|
|
231
264
|
* )
|
|
232
265
|
*/
|
|
233
266
|
object: (options: Record<string, any>) => JSONSchema;
|
|
267
|
+
/**
|
|
268
|
+
* Custom client-side validator. The provided function is serialised and executed
|
|
269
|
+
* just-in-time on the client only. External references (e.g. lodash) are not
|
|
270
|
+
* available inside the function body — all logic must be self-contained.
|
|
271
|
+
*
|
|
272
|
+
* @example
|
|
273
|
+
* field('nid').customClientValidator((value) => {
|
|
274
|
+
* // LUHN check — all logic must be inline
|
|
275
|
+
* const digits = String(value).split('').map(Number)
|
|
276
|
+
* // ...
|
|
277
|
+
* return isValid
|
|
278
|
+
* })
|
|
279
|
+
*/
|
|
280
|
+
customClientValidator(validationFn: (fieldValue: unknown, context: FormConditionalParameters) => boolean): JSONSchema;
|
|
281
|
+
/**
|
|
282
|
+
* Custom client-side evaluation. Returns a {@link FieldReference} descriptor
|
|
283
|
+
* that can be used as the `value` property or a DATA component entry.
|
|
284
|
+
* The function receives the referenced field's value as the first argument and
|
|
285
|
+
* the full form context as the second; its return value replaces the field reference.
|
|
286
|
+
* The function is serialised and executed just-in-time on the client only.
|
|
287
|
+
* External references (e.g. lodash) are not available inside the function body.
|
|
288
|
+
*
|
|
289
|
+
* For computing a default value without referencing a specific field, use
|
|
290
|
+
* `evaluate(fn)` in the `defaultValue` property instead.
|
|
291
|
+
*
|
|
292
|
+
* @example
|
|
293
|
+
* field('a').customClientEvaluation((aValue, ctx) =>
|
|
294
|
+
* Number(aValue) + Number(ctx.$form.b)
|
|
295
|
+
* )
|
|
296
|
+
*/
|
|
297
|
+
customClientEvaluation(computationFn: (fieldValue: unknown, context: FormConditionalParameters) => unknown): CodeToEvaluate;
|
|
234
298
|
};
|
|
235
299
|
getByPath(fieldPath: string[]): {
|
|
236
300
|
$$subfield: string[];
|
|
@@ -304,6 +368,37 @@ export declare function createFieldConditionals(fieldId: string): {
|
|
|
304
368
|
* )
|
|
305
369
|
*/
|
|
306
370
|
object: (options: Record<string, any>) => JSONSchema;
|
|
371
|
+
/**
|
|
372
|
+
* Custom client-side validator. The provided function is serialised and executed
|
|
373
|
+
* just-in-time on the client only. External references (e.g. lodash) are not
|
|
374
|
+
* available inside the function body — all logic must be self-contained.
|
|
375
|
+
*
|
|
376
|
+
* @example
|
|
377
|
+
* field('nid').customClientValidator((value) => {
|
|
378
|
+
* // LUHN check — all logic must be inline
|
|
379
|
+
* const digits = String(value).split('').map(Number)
|
|
380
|
+
* // ...
|
|
381
|
+
* return isValid
|
|
382
|
+
* })
|
|
383
|
+
*/
|
|
384
|
+
customClientValidator(validationFn: (fieldValue: unknown, context: FormConditionalParameters) => boolean): JSONSchema;
|
|
385
|
+
/**
|
|
386
|
+
* Custom client-side evaluation. Returns a {@link FieldReference} descriptor
|
|
387
|
+
* that can be used as the `value` property or a DATA component entry.
|
|
388
|
+
* The function receives the referenced field's value as the first argument and
|
|
389
|
+
* the full form context as the second; its return value replaces the field reference.
|
|
390
|
+
* The function is serialised and executed just-in-time on the client only.
|
|
391
|
+
* External references (e.g. lodash) are not available inside the function body.
|
|
392
|
+
*
|
|
393
|
+
* For computing a default value without referencing a specific field, use
|
|
394
|
+
* `evaluate(fn)` in the `defaultValue` property instead.
|
|
395
|
+
*
|
|
396
|
+
* @example
|
|
397
|
+
* field('a').customClientEvaluation((aValue, ctx) =>
|
|
398
|
+
* Number(aValue) + Number(ctx.$form.b)
|
|
399
|
+
* )
|
|
400
|
+
*/
|
|
401
|
+
customClientEvaluation(computationFn: (fieldValue: unknown, context: FormConditionalParameters) => unknown): CodeToEvaluate;
|
|
307
402
|
};
|
|
308
403
|
getByPath(fieldPath: string[]): any;
|
|
309
404
|
asDob(): {
|
|
@@ -372,6 +467,37 @@ export declare function createFieldConditionals(fieldId: string): {
|
|
|
372
467
|
* )
|
|
373
468
|
*/
|
|
374
469
|
object: (options: Record<string, any>) => JSONSchema;
|
|
470
|
+
/**
|
|
471
|
+
* Custom client-side validator. The provided function is serialised and executed
|
|
472
|
+
* just-in-time on the client only. External references (e.g. lodash) are not
|
|
473
|
+
* available inside the function body — all logic must be self-contained.
|
|
474
|
+
*
|
|
475
|
+
* @example
|
|
476
|
+
* field('nid').customClientValidator((value) => {
|
|
477
|
+
* // LUHN check — all logic must be inline
|
|
478
|
+
* const digits = String(value).split('').map(Number)
|
|
479
|
+
* // ...
|
|
480
|
+
* return isValid
|
|
481
|
+
* })
|
|
482
|
+
*/
|
|
483
|
+
customClientValidator(validationFn: (fieldValue: unknown, context: FormConditionalParameters) => boolean): JSONSchema;
|
|
484
|
+
/**
|
|
485
|
+
* Custom client-side evaluation. Returns a {@link FieldReference} descriptor
|
|
486
|
+
* that can be used as the `value` property or a DATA component entry.
|
|
487
|
+
* The function receives the referenced field's value as the first argument and
|
|
488
|
+
* the full form context as the second; its return value replaces the field reference.
|
|
489
|
+
* The function is serialised and executed just-in-time on the client only.
|
|
490
|
+
* External references (e.g. lodash) are not available inside the function body.
|
|
491
|
+
*
|
|
492
|
+
* For computing a default value without referencing a specific field, use
|
|
493
|
+
* `evaluate(fn)` in the `defaultValue` property instead.
|
|
494
|
+
*
|
|
495
|
+
* @example
|
|
496
|
+
* field('a').customClientEvaluation((aValue, ctx) =>
|
|
497
|
+
* Number(aValue) + Number(ctx.$form.b)
|
|
498
|
+
* )
|
|
499
|
+
*/
|
|
500
|
+
customClientEvaluation(computationFn: (fieldValue: unknown, context: FormConditionalParameters) => unknown): CodeToEvaluate;
|
|
375
501
|
};
|
|
376
502
|
asAge(): {
|
|
377
503
|
$$subfield: string[];
|
|
@@ -439,6 +565,37 @@ export declare function createFieldConditionals(fieldId: string): {
|
|
|
439
565
|
* )
|
|
440
566
|
*/
|
|
441
567
|
object: (options: Record<string, any>) => JSONSchema;
|
|
568
|
+
/**
|
|
569
|
+
* Custom client-side validator. The provided function is serialised and executed
|
|
570
|
+
* just-in-time on the client only. External references (e.g. lodash) are not
|
|
571
|
+
* available inside the function body — all logic must be self-contained.
|
|
572
|
+
*
|
|
573
|
+
* @example
|
|
574
|
+
* field('nid').customClientValidator((value) => {
|
|
575
|
+
* // LUHN check — all logic must be inline
|
|
576
|
+
* const digits = String(value).split('').map(Number)
|
|
577
|
+
* // ...
|
|
578
|
+
* return isValid
|
|
579
|
+
* })
|
|
580
|
+
*/
|
|
581
|
+
customClientValidator(validationFn: (fieldValue: unknown, context: FormConditionalParameters) => boolean): JSONSchema;
|
|
582
|
+
/**
|
|
583
|
+
* Custom client-side evaluation. Returns a {@link FieldReference} descriptor
|
|
584
|
+
* that can be used as the `value` property or a DATA component entry.
|
|
585
|
+
* The function receives the referenced field's value as the first argument and
|
|
586
|
+
* the full form context as the second; its return value replaces the field reference.
|
|
587
|
+
* The function is serialised and executed just-in-time on the client only.
|
|
588
|
+
* External references (e.g. lodash) are not available inside the function body.
|
|
589
|
+
*
|
|
590
|
+
* For computing a default value without referencing a specific field, use
|
|
591
|
+
* `evaluate(fn)` in the `defaultValue` property instead.
|
|
592
|
+
*
|
|
593
|
+
* @example
|
|
594
|
+
* field('a').customClientEvaluation((aValue, ctx) =>
|
|
595
|
+
* Number(aValue) + Number(ctx.$form.b)
|
|
596
|
+
* )
|
|
597
|
+
*/
|
|
598
|
+
customClientEvaluation(computationFn: (fieldValue: unknown, context: FormConditionalParameters) => unknown): CodeToEvaluate;
|
|
442
599
|
};
|
|
443
600
|
isAfter(): {
|
|
444
601
|
days: (days: number) => {
|
|
@@ -496,6 +653,37 @@ export declare function createFieldConditionals(fieldId: string): {
|
|
|
496
653
|
* )
|
|
497
654
|
*/
|
|
498
655
|
object: (options: Record<string, any>) => JSONSchema;
|
|
656
|
+
/**
|
|
657
|
+
* Custom client-side validator. The provided function is serialised and executed
|
|
658
|
+
* just-in-time on the client only. External references (e.g. lodash) are not
|
|
659
|
+
* available inside the function body — all logic must be self-contained.
|
|
660
|
+
*
|
|
661
|
+
* @example
|
|
662
|
+
* field('nid').customClientValidator((value) => {
|
|
663
|
+
* // LUHN check — all logic must be inline
|
|
664
|
+
* const digits = String(value).split('').map(Number)
|
|
665
|
+
* // ...
|
|
666
|
+
* return isValid
|
|
667
|
+
* })
|
|
668
|
+
*/
|
|
669
|
+
customClientValidator(validationFn: (fieldValue: unknown, context: FormConditionalParameters) => boolean): JSONSchema;
|
|
670
|
+
/**
|
|
671
|
+
* Custom client-side evaluation. Returns a {@link FieldReference} descriptor
|
|
672
|
+
* that can be used as the `value` property or a DATA component entry.
|
|
673
|
+
* The function receives the referenced field's value as the first argument and
|
|
674
|
+
* the full form context as the second; its return value replaces the field reference.
|
|
675
|
+
* The function is serialised and executed just-in-time on the client only.
|
|
676
|
+
* External references (e.g. lodash) are not available inside the function body.
|
|
677
|
+
*
|
|
678
|
+
* For computing a default value without referencing a specific field, use
|
|
679
|
+
* `evaluate(fn)` in the `defaultValue` property instead.
|
|
680
|
+
*
|
|
681
|
+
* @example
|
|
682
|
+
* field('a').customClientEvaluation((aValue, ctx) =>
|
|
683
|
+
* Number(aValue) + Number(ctx.$form.b)
|
|
684
|
+
* )
|
|
685
|
+
*/
|
|
686
|
+
customClientEvaluation(computationFn: (fieldValue: unknown, context: FormConditionalParameters) => unknown): CodeToEvaluate;
|
|
499
687
|
};
|
|
500
688
|
asDob(): {
|
|
501
689
|
$$subfield: string[];
|
|
@@ -570,6 +758,37 @@ export declare function createFieldConditionals(fieldId: string): {
|
|
|
570
758
|
* )
|
|
571
759
|
*/
|
|
572
760
|
object: (options: Record<string, any>) => JSONSchema;
|
|
761
|
+
/**
|
|
762
|
+
* Custom client-side validator. The provided function is serialised and executed
|
|
763
|
+
* just-in-time on the client only. External references (e.g. lodash) are not
|
|
764
|
+
* available inside the function body — all logic must be self-contained.
|
|
765
|
+
*
|
|
766
|
+
* @example
|
|
767
|
+
* field('nid').customClientValidator((value) => {
|
|
768
|
+
* // LUHN check — all logic must be inline
|
|
769
|
+
* const digits = String(value).split('').map(Number)
|
|
770
|
+
* // ...
|
|
771
|
+
* return isValid
|
|
772
|
+
* })
|
|
773
|
+
*/
|
|
774
|
+
customClientValidator(validationFn: (fieldValue: unknown, context: FormConditionalParameters) => boolean): JSONSchema;
|
|
775
|
+
/**
|
|
776
|
+
* Custom client-side evaluation. Returns a {@link FieldReference} descriptor
|
|
777
|
+
* that can be used as the `value` property or a DATA component entry.
|
|
778
|
+
* The function receives the referenced field's value as the first argument and
|
|
779
|
+
* the full form context as the second; its return value replaces the field reference.
|
|
780
|
+
* The function is serialised and executed just-in-time on the client only.
|
|
781
|
+
* External references (e.g. lodash) are not available inside the function body.
|
|
782
|
+
*
|
|
783
|
+
* For computing a default value without referencing a specific field, use
|
|
784
|
+
* `evaluate(fn)` in the `defaultValue` property instead.
|
|
785
|
+
*
|
|
786
|
+
* @example
|
|
787
|
+
* field('a').customClientEvaluation((aValue, ctx) =>
|
|
788
|
+
* Number(aValue) + Number(ctx.$form.b)
|
|
789
|
+
* )
|
|
790
|
+
*/
|
|
791
|
+
customClientEvaluation(computationFn: (fieldValue: unknown, context: FormConditionalParameters) => unknown): CodeToEvaluate;
|
|
573
792
|
};
|
|
574
793
|
asDob(): any;
|
|
575
794
|
asAge(): any;
|
|
@@ -629,6 +848,37 @@ export declare function createFieldConditionals(fieldId: string): {
|
|
|
629
848
|
* )
|
|
630
849
|
*/
|
|
631
850
|
object: (options: Record<string, any>) => JSONSchema;
|
|
851
|
+
/**
|
|
852
|
+
* Custom client-side validator. The provided function is serialised and executed
|
|
853
|
+
* just-in-time on the client only. External references (e.g. lodash) are not
|
|
854
|
+
* available inside the function body — all logic must be self-contained.
|
|
855
|
+
*
|
|
856
|
+
* @example
|
|
857
|
+
* field('nid').customClientValidator((value) => {
|
|
858
|
+
* // LUHN check — all logic must be inline
|
|
859
|
+
* const digits = String(value).split('').map(Number)
|
|
860
|
+
* // ...
|
|
861
|
+
* return isValid
|
|
862
|
+
* })
|
|
863
|
+
*/
|
|
864
|
+
customClientValidator(validationFn: (fieldValue: unknown, context: FormConditionalParameters) => boolean): JSONSchema;
|
|
865
|
+
/**
|
|
866
|
+
* Custom client-side evaluation. Returns a {@link FieldReference} descriptor
|
|
867
|
+
* that can be used as the `value` property or a DATA component entry.
|
|
868
|
+
* The function receives the referenced field's value as the first argument and
|
|
869
|
+
* the full form context as the second; its return value replaces the field reference.
|
|
870
|
+
* The function is serialised and executed just-in-time on the client only.
|
|
871
|
+
* External references (e.g. lodash) are not available inside the function body.
|
|
872
|
+
*
|
|
873
|
+
* For computing a default value without referencing a specific field, use
|
|
874
|
+
* `evaluate(fn)` in the `defaultValue` property instead.
|
|
875
|
+
*
|
|
876
|
+
* @example
|
|
877
|
+
* field('a').customClientEvaluation((aValue, ctx) =>
|
|
878
|
+
* Number(aValue) + Number(ctx.$form.b)
|
|
879
|
+
* )
|
|
880
|
+
*/
|
|
881
|
+
customClientEvaluation(computationFn: (fieldValue: unknown, context: FormConditionalParameters) => unknown): CodeToEvaluate;
|
|
632
882
|
};
|
|
633
883
|
asAge(): {
|
|
634
884
|
$$subfield: string[];
|
|
@@ -703,6 +953,37 @@ export declare function createFieldConditionals(fieldId: string): {
|
|
|
703
953
|
* )
|
|
704
954
|
*/
|
|
705
955
|
object: (options: Record<string, any>) => JSONSchema;
|
|
956
|
+
/**
|
|
957
|
+
* Custom client-side validator. The provided function is serialised and executed
|
|
958
|
+
* just-in-time on the client only. External references (e.g. lodash) are not
|
|
959
|
+
* available inside the function body — all logic must be self-contained.
|
|
960
|
+
*
|
|
961
|
+
* @example
|
|
962
|
+
* field('nid').customClientValidator((value) => {
|
|
963
|
+
* // LUHN check — all logic must be inline
|
|
964
|
+
* const digits = String(value).split('').map(Number)
|
|
965
|
+
* // ...
|
|
966
|
+
* return isValid
|
|
967
|
+
* })
|
|
968
|
+
*/
|
|
969
|
+
customClientValidator(validationFn: (fieldValue: unknown, context: FormConditionalParameters) => boolean): JSONSchema;
|
|
970
|
+
/**
|
|
971
|
+
* Custom client-side evaluation. Returns a {@link FieldReference} descriptor
|
|
972
|
+
* that can be used as the `value` property or a DATA component entry.
|
|
973
|
+
* The function receives the referenced field's value as the first argument and
|
|
974
|
+
* the full form context as the second; its return value replaces the field reference.
|
|
975
|
+
* The function is serialised and executed just-in-time on the client only.
|
|
976
|
+
* External references (e.g. lodash) are not available inside the function body.
|
|
977
|
+
*
|
|
978
|
+
* For computing a default value without referencing a specific field, use
|
|
979
|
+
* `evaluate(fn)` in the `defaultValue` property instead.
|
|
980
|
+
*
|
|
981
|
+
* @example
|
|
982
|
+
* field('a').customClientEvaluation((aValue, ctx) =>
|
|
983
|
+
* Number(aValue) + Number(ctx.$form.b)
|
|
984
|
+
* )
|
|
985
|
+
*/
|
|
986
|
+
customClientEvaluation(computationFn: (fieldValue: unknown, context: FormConditionalParameters) => unknown): CodeToEvaluate;
|
|
706
987
|
};
|
|
707
988
|
asDob(): any;
|
|
708
989
|
asAge(): any;
|
|
@@ -762,6 +1043,37 @@ export declare function createFieldConditionals(fieldId: string): {
|
|
|
762
1043
|
* )
|
|
763
1044
|
*/
|
|
764
1045
|
object: (options: Record<string, any>) => JSONSchema;
|
|
1046
|
+
/**
|
|
1047
|
+
* Custom client-side validator. The provided function is serialised and executed
|
|
1048
|
+
* just-in-time on the client only. External references (e.g. lodash) are not
|
|
1049
|
+
* available inside the function body — all logic must be self-contained.
|
|
1050
|
+
*
|
|
1051
|
+
* @example
|
|
1052
|
+
* field('nid').customClientValidator((value) => {
|
|
1053
|
+
* // LUHN check — all logic must be inline
|
|
1054
|
+
* const digits = String(value).split('').map(Number)
|
|
1055
|
+
* // ...
|
|
1056
|
+
* return isValid
|
|
1057
|
+
* })
|
|
1058
|
+
*/
|
|
1059
|
+
customClientValidator(validationFn: (fieldValue: unknown, context: FormConditionalParameters) => boolean): JSONSchema;
|
|
1060
|
+
/**
|
|
1061
|
+
* Custom client-side evaluation. Returns a {@link FieldReference} descriptor
|
|
1062
|
+
* that can be used as the `value` property or a DATA component entry.
|
|
1063
|
+
* The function receives the referenced field's value as the first argument and
|
|
1064
|
+
* the full form context as the second; its return value replaces the field reference.
|
|
1065
|
+
* The function is serialised and executed just-in-time on the client only.
|
|
1066
|
+
* External references (e.g. lodash) are not available inside the function body.
|
|
1067
|
+
*
|
|
1068
|
+
* For computing a default value without referencing a specific field, use
|
|
1069
|
+
* `evaluate(fn)` in the `defaultValue` property instead.
|
|
1070
|
+
*
|
|
1071
|
+
* @example
|
|
1072
|
+
* field('a').customClientEvaluation((aValue, ctx) =>
|
|
1073
|
+
* Number(aValue) + Number(ctx.$form.b)
|
|
1074
|
+
* )
|
|
1075
|
+
*/
|
|
1076
|
+
customClientEvaluation(computationFn: (fieldValue: unknown, context: FormConditionalParameters) => unknown): CodeToEvaluate;
|
|
765
1077
|
};
|
|
766
1078
|
isAfter(): {
|
|
767
1079
|
days: (days: number) => {
|
|
@@ -819,6 +1131,37 @@ export declare function createFieldConditionals(fieldId: string): {
|
|
|
819
1131
|
* )
|
|
820
1132
|
*/
|
|
821
1133
|
object: (options: Record<string, any>) => JSONSchema;
|
|
1134
|
+
/**
|
|
1135
|
+
* Custom client-side validator. The provided function is serialised and executed
|
|
1136
|
+
* just-in-time on the client only. External references (e.g. lodash) are not
|
|
1137
|
+
* available inside the function body — all logic must be self-contained.
|
|
1138
|
+
*
|
|
1139
|
+
* @example
|
|
1140
|
+
* field('nid').customClientValidator((value) => {
|
|
1141
|
+
* // LUHN check — all logic must be inline
|
|
1142
|
+
* const digits = String(value).split('').map(Number)
|
|
1143
|
+
* // ...
|
|
1144
|
+
* return isValid
|
|
1145
|
+
* })
|
|
1146
|
+
*/
|
|
1147
|
+
customClientValidator(validationFn: (fieldValue: unknown, context: FormConditionalParameters) => boolean): JSONSchema;
|
|
1148
|
+
/**
|
|
1149
|
+
* Custom client-side evaluation. Returns a {@link FieldReference} descriptor
|
|
1150
|
+
* that can be used as the `value` property or a DATA component entry.
|
|
1151
|
+
* The function receives the referenced field's value as the first argument and
|
|
1152
|
+
* the full form context as the second; its return value replaces the field reference.
|
|
1153
|
+
* The function is serialised and executed just-in-time on the client only.
|
|
1154
|
+
* External references (e.g. lodash) are not available inside the function body.
|
|
1155
|
+
*
|
|
1156
|
+
* For computing a default value without referencing a specific field, use
|
|
1157
|
+
* `evaluate(fn)` in the `defaultValue` property instead.
|
|
1158
|
+
*
|
|
1159
|
+
* @example
|
|
1160
|
+
* field('a').customClientEvaluation((aValue, ctx) =>
|
|
1161
|
+
* Number(aValue) + Number(ctx.$form.b)
|
|
1162
|
+
* )
|
|
1163
|
+
*/
|
|
1164
|
+
customClientEvaluation(computationFn: (fieldValue: unknown, context: FormConditionalParameters) => unknown): CodeToEvaluate;
|
|
822
1165
|
};
|
|
823
1166
|
export {};
|
|
824
1167
|
//# sourceMappingURL=conditionals.d.ts.map
|
|
@@ -9,6 +9,14 @@ 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;
|
|
12
20
|
export declare function validate(schema: JSONSchema, data: ConditionalParameters): boolean;
|
|
13
21
|
export declare function validateValue(schema: JSONSchema, data: unknown): boolean;
|
|
14
22
|
export declare function isOnline(): boolean;
|