@opencrvs/toolkit 2.0.0-rc.fe94e41 → 2.0.0-rc.fea498b

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.
@@ -1,12 +1,13 @@
1
1
  import { EventDocument } from '../events/EventDocument';
2
- import { EventState } from '../events/ActionDocument';
2
+ import { ActionUpdate, EventState } from '../events/ActionDocument';
3
3
  import { ITokenPayload as TokenPayload } 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
8
  import { EventStatus } from '../events/EventMetadata';
9
- import { FieldReference } from '../events/FieldConfig';
9
+ import { CodeToEvaluate, FieldReference } from '../events/FieldConfig';
10
+ import type { ClientFunctionContext } from './validate';
10
11
  /** @knipignore */
11
12
  export type JSONSchema = {
12
13
  $id: string;
@@ -25,7 +26,7 @@ export type EventConditionalParameters = CommonConditionalParameters & {
25
26
  $event: EventDocument;
26
27
  };
27
28
  export type FormConditionalParameters = CommonConditionalParameters & {
28
- $form: EventState | Record<string, unknown>;
29
+ $form: EventState | ActionUpdate;
29
30
  $leafAdminStructureLocationIds?: Array<{
30
31
  id: UUID;
31
32
  }>;
@@ -107,7 +108,9 @@ export declare const user: typeof userSerializer & {
107
108
  };
108
109
  };
109
110
  export declare function isFieldReference(value: unknown): value is FieldReference;
110
- export declare function isEventFieldReference(value: unknown): value is FieldReference;
111
+ export declare function isEventFieldReference(value: unknown): value is {
112
+ $$event: string;
113
+ };
111
114
  /** Check if an event flag is present */
112
115
  export declare function flag(flagvalue: string): JSONSchema;
113
116
  /** Check if an event flag is present */
@@ -202,6 +205,37 @@ export declare function createFieldConditionals(fieldId: string): {
202
205
  * )
203
206
  */
204
207
  object: (options: Record<string, any>) => JSONSchema;
208
+ /**
209
+ * Custom client-side validator. The provided function is serialised and executed
210
+ * just-in-time on the client only. External references (e.g. lodash) are not
211
+ * available inside the function body — all logic must be self-contained.
212
+ *
213
+ * @example
214
+ * field('nid').customClientValidator((value) => {
215
+ * // LUHN check — all logic must be inline
216
+ * const digits = String(value).split('').map(Number)
217
+ * // ...
218
+ * return isValid
219
+ * })
220
+ */
221
+ customClientValidator(validationFn: (fieldValue: unknown, context: ClientFunctionContext) => boolean): JSONSchema;
222
+ /**
223
+ * Custom client-side evaluation. Returns a {@link FieldReference} descriptor
224
+ * that can be used as the `value` property or a DATA component entry.
225
+ * The function receives the referenced field's value as the first argument and
226
+ * the full form context as the second; its return value replaces the field reference.
227
+ * The function is serialised and executed just-in-time on the client only.
228
+ * External references (e.g. lodash) are not available inside the function body.
229
+ *
230
+ * For computing a default value without referencing a specific field, use
231
+ * `evaluate(fn)` in the `defaultValue` property instead.
232
+ *
233
+ * @example
234
+ * field('a').customClientEvaluation((aValue, ctx) =>
235
+ * Number(aValue) + Number(ctx.$form.b)
236
+ * )
237
+ */
238
+ customClientEvaluation(computationFn: (fieldValue: unknown, context: ClientFunctionContext) => unknown): CodeToEvaluate;
205
239
  };
206
240
  asDob(): any;
207
241
  asAge(): any;
@@ -261,6 +295,37 @@ export declare function createFieldConditionals(fieldId: string): {
261
295
  * )
262
296
  */
263
297
  object: (options: Record<string, any>) => JSONSchema;
298
+ /**
299
+ * Custom client-side validator. The provided function is serialised and executed
300
+ * just-in-time on the client only. External references (e.g. lodash) are not
301
+ * available inside the function body — all logic must be self-contained.
302
+ *
303
+ * @example
304
+ * field('nid').customClientValidator((value) => {
305
+ * // LUHN check — all logic must be inline
306
+ * const digits = String(value).split('').map(Number)
307
+ * // ...
308
+ * return isValid
309
+ * })
310
+ */
311
+ customClientValidator(validationFn: (fieldValue: unknown, context: ClientFunctionContext) => boolean): JSONSchema;
312
+ /**
313
+ * Custom client-side evaluation. Returns a {@link FieldReference} descriptor
314
+ * that can be used as the `value` property or a DATA component entry.
315
+ * The function receives the referenced field's value as the first argument and
316
+ * the full form context as the second; its return value replaces the field reference.
317
+ * The function is serialised and executed just-in-time on the client only.
318
+ * External references (e.g. lodash) are not available inside the function body.
319
+ *
320
+ * For computing a default value without referencing a specific field, use
321
+ * `evaluate(fn)` in the `defaultValue` property instead.
322
+ *
323
+ * @example
324
+ * field('a').customClientEvaluation((aValue, ctx) =>
325
+ * Number(aValue) + Number(ctx.$form.b)
326
+ * )
327
+ */
328
+ customClientEvaluation(computationFn: (fieldValue: unknown, context: ClientFunctionContext) => unknown): CodeToEvaluate;
264
329
  };
265
330
  getByPath(fieldPath: string[]): {
266
331
  $$subfield: string[];
@@ -334,6 +399,37 @@ export declare function createFieldConditionals(fieldId: string): {
334
399
  * )
335
400
  */
336
401
  object: (options: Record<string, any>) => JSONSchema;
402
+ /**
403
+ * Custom client-side validator. The provided function is serialised and executed
404
+ * just-in-time on the client only. External references (e.g. lodash) are not
405
+ * available inside the function body — all logic must be self-contained.
406
+ *
407
+ * @example
408
+ * field('nid').customClientValidator((value) => {
409
+ * // LUHN check — all logic must be inline
410
+ * const digits = String(value).split('').map(Number)
411
+ * // ...
412
+ * return isValid
413
+ * })
414
+ */
415
+ customClientValidator(validationFn: (fieldValue: unknown, context: ClientFunctionContext) => boolean): JSONSchema;
416
+ /**
417
+ * Custom client-side evaluation. Returns a {@link FieldReference} descriptor
418
+ * that can be used as the `value` property or a DATA component entry.
419
+ * The function receives the referenced field's value as the first argument and
420
+ * the full form context as the second; its return value replaces the field reference.
421
+ * The function is serialised and executed just-in-time on the client only.
422
+ * External references (e.g. lodash) are not available inside the function body.
423
+ *
424
+ * For computing a default value without referencing a specific field, use
425
+ * `evaluate(fn)` in the `defaultValue` property instead.
426
+ *
427
+ * @example
428
+ * field('a').customClientEvaluation((aValue, ctx) =>
429
+ * Number(aValue) + Number(ctx.$form.b)
430
+ * )
431
+ */
432
+ customClientEvaluation(computationFn: (fieldValue: unknown, context: ClientFunctionContext) => unknown): CodeToEvaluate;
337
433
  };
338
434
  getByPath(fieldPath: string[]): any;
339
435
  asDob(): {
@@ -402,6 +498,37 @@ export declare function createFieldConditionals(fieldId: string): {
402
498
  * )
403
499
  */
404
500
  object: (options: Record<string, any>) => JSONSchema;
501
+ /**
502
+ * Custom client-side validator. The provided function is serialised and executed
503
+ * just-in-time on the client only. External references (e.g. lodash) are not
504
+ * available inside the function body — all logic must be self-contained.
505
+ *
506
+ * @example
507
+ * field('nid').customClientValidator((value) => {
508
+ * // LUHN check — all logic must be inline
509
+ * const digits = String(value).split('').map(Number)
510
+ * // ...
511
+ * return isValid
512
+ * })
513
+ */
514
+ customClientValidator(validationFn: (fieldValue: unknown, context: ClientFunctionContext) => boolean): JSONSchema;
515
+ /**
516
+ * Custom client-side evaluation. Returns a {@link FieldReference} descriptor
517
+ * that can be used as the `value` property or a DATA component entry.
518
+ * The function receives the referenced field's value as the first argument and
519
+ * the full form context as the second; its return value replaces the field reference.
520
+ * The function is serialised and executed just-in-time on the client only.
521
+ * External references (e.g. lodash) are not available inside the function body.
522
+ *
523
+ * For computing a default value without referencing a specific field, use
524
+ * `evaluate(fn)` in the `defaultValue` property instead.
525
+ *
526
+ * @example
527
+ * field('a').customClientEvaluation((aValue, ctx) =>
528
+ * Number(aValue) + Number(ctx.$form.b)
529
+ * )
530
+ */
531
+ customClientEvaluation(computationFn: (fieldValue: unknown, context: ClientFunctionContext) => unknown): CodeToEvaluate;
405
532
  };
406
533
  asAge(): {
407
534
  $$subfield: string[];
@@ -469,6 +596,37 @@ export declare function createFieldConditionals(fieldId: string): {
469
596
  * )
470
597
  */
471
598
  object: (options: Record<string, any>) => JSONSchema;
599
+ /**
600
+ * Custom client-side validator. The provided function is serialised and executed
601
+ * just-in-time on the client only. External references (e.g. lodash) are not
602
+ * available inside the function body — all logic must be self-contained.
603
+ *
604
+ * @example
605
+ * field('nid').customClientValidator((value) => {
606
+ * // LUHN check — all logic must be inline
607
+ * const digits = String(value).split('').map(Number)
608
+ * // ...
609
+ * return isValid
610
+ * })
611
+ */
612
+ customClientValidator(validationFn: (fieldValue: unknown, context: ClientFunctionContext) => boolean): JSONSchema;
613
+ /**
614
+ * Custom client-side evaluation. Returns a {@link FieldReference} descriptor
615
+ * that can be used as the `value` property or a DATA component entry.
616
+ * The function receives the referenced field's value as the first argument and
617
+ * the full form context as the second; its return value replaces the field reference.
618
+ * The function is serialised and executed just-in-time on the client only.
619
+ * External references (e.g. lodash) are not available inside the function body.
620
+ *
621
+ * For computing a default value without referencing a specific field, use
622
+ * `evaluate(fn)` in the `defaultValue` property instead.
623
+ *
624
+ * @example
625
+ * field('a').customClientEvaluation((aValue, ctx) =>
626
+ * Number(aValue) + Number(ctx.$form.b)
627
+ * )
628
+ */
629
+ customClientEvaluation(computationFn: (fieldValue: unknown, context: ClientFunctionContext) => unknown): CodeToEvaluate;
472
630
  };
473
631
  isAfter(): {
474
632
  days: (days: number) => {
@@ -526,6 +684,37 @@ export declare function createFieldConditionals(fieldId: string): {
526
684
  * )
527
685
  */
528
686
  object: (options: Record<string, any>) => JSONSchema;
687
+ /**
688
+ * Custom client-side validator. The provided function is serialised and executed
689
+ * just-in-time on the client only. External references (e.g. lodash) are not
690
+ * available inside the function body — all logic must be self-contained.
691
+ *
692
+ * @example
693
+ * field('nid').customClientValidator((value) => {
694
+ * // LUHN check — all logic must be inline
695
+ * const digits = String(value).split('').map(Number)
696
+ * // ...
697
+ * return isValid
698
+ * })
699
+ */
700
+ customClientValidator(validationFn: (fieldValue: unknown, context: ClientFunctionContext) => boolean): JSONSchema;
701
+ /**
702
+ * Custom client-side evaluation. Returns a {@link FieldReference} descriptor
703
+ * that can be used as the `value` property or a DATA component entry.
704
+ * The function receives the referenced field's value as the first argument and
705
+ * the full form context as the second; its return value replaces the field reference.
706
+ * The function is serialised and executed just-in-time on the client only.
707
+ * External references (e.g. lodash) are not available inside the function body.
708
+ *
709
+ * For computing a default value without referencing a specific field, use
710
+ * `evaluate(fn)` in the `defaultValue` property instead.
711
+ *
712
+ * @example
713
+ * field('a').customClientEvaluation((aValue, ctx) =>
714
+ * Number(aValue) + Number(ctx.$form.b)
715
+ * )
716
+ */
717
+ customClientEvaluation(computationFn: (fieldValue: unknown, context: ClientFunctionContext) => unknown): CodeToEvaluate;
529
718
  };
530
719
  asDob(): {
531
720
  $$subfield: string[];
@@ -600,6 +789,37 @@ export declare function createFieldConditionals(fieldId: string): {
600
789
  * )
601
790
  */
602
791
  object: (options: Record<string, any>) => JSONSchema;
792
+ /**
793
+ * Custom client-side validator. The provided function is serialised and executed
794
+ * just-in-time on the client only. External references (e.g. lodash) are not
795
+ * available inside the function body — all logic must be self-contained.
796
+ *
797
+ * @example
798
+ * field('nid').customClientValidator((value) => {
799
+ * // LUHN check — all logic must be inline
800
+ * const digits = String(value).split('').map(Number)
801
+ * // ...
802
+ * return isValid
803
+ * })
804
+ */
805
+ customClientValidator(validationFn: (fieldValue: unknown, context: ClientFunctionContext) => boolean): JSONSchema;
806
+ /**
807
+ * Custom client-side evaluation. Returns a {@link FieldReference} descriptor
808
+ * that can be used as the `value` property or a DATA component entry.
809
+ * The function receives the referenced field's value as the first argument and
810
+ * the full form context as the second; its return value replaces the field reference.
811
+ * The function is serialised and executed just-in-time on the client only.
812
+ * External references (e.g. lodash) are not available inside the function body.
813
+ *
814
+ * For computing a default value without referencing a specific field, use
815
+ * `evaluate(fn)` in the `defaultValue` property instead.
816
+ *
817
+ * @example
818
+ * field('a').customClientEvaluation((aValue, ctx) =>
819
+ * Number(aValue) + Number(ctx.$form.b)
820
+ * )
821
+ */
822
+ customClientEvaluation(computationFn: (fieldValue: unknown, context: ClientFunctionContext) => unknown): CodeToEvaluate;
603
823
  };
604
824
  asDob(): any;
605
825
  asAge(): any;
@@ -659,6 +879,37 @@ export declare function createFieldConditionals(fieldId: string): {
659
879
  * )
660
880
  */
661
881
  object: (options: Record<string, any>) => JSONSchema;
882
+ /**
883
+ * Custom client-side validator. The provided function is serialised and executed
884
+ * just-in-time on the client only. External references (e.g. lodash) are not
885
+ * available inside the function body — all logic must be self-contained.
886
+ *
887
+ * @example
888
+ * field('nid').customClientValidator((value) => {
889
+ * // LUHN check — all logic must be inline
890
+ * const digits = String(value).split('').map(Number)
891
+ * // ...
892
+ * return isValid
893
+ * })
894
+ */
895
+ customClientValidator(validationFn: (fieldValue: unknown, context: ClientFunctionContext) => boolean): JSONSchema;
896
+ /**
897
+ * Custom client-side evaluation. Returns a {@link FieldReference} descriptor
898
+ * that can be used as the `value` property or a DATA component entry.
899
+ * The function receives the referenced field's value as the first argument and
900
+ * the full form context as the second; its return value replaces the field reference.
901
+ * The function is serialised and executed just-in-time on the client only.
902
+ * External references (e.g. lodash) are not available inside the function body.
903
+ *
904
+ * For computing a default value without referencing a specific field, use
905
+ * `evaluate(fn)` in the `defaultValue` property instead.
906
+ *
907
+ * @example
908
+ * field('a').customClientEvaluation((aValue, ctx) =>
909
+ * Number(aValue) + Number(ctx.$form.b)
910
+ * )
911
+ */
912
+ customClientEvaluation(computationFn: (fieldValue: unknown, context: ClientFunctionContext) => unknown): CodeToEvaluate;
662
913
  };
663
914
  asAge(): {
664
915
  $$subfield: string[];
@@ -733,6 +984,37 @@ export declare function createFieldConditionals(fieldId: string): {
733
984
  * )
734
985
  */
735
986
  object: (options: Record<string, any>) => JSONSchema;
987
+ /**
988
+ * Custom client-side validator. The provided function is serialised and executed
989
+ * just-in-time on the client only. External references (e.g. lodash) are not
990
+ * available inside the function body — all logic must be self-contained.
991
+ *
992
+ * @example
993
+ * field('nid').customClientValidator((value) => {
994
+ * // LUHN check — all logic must be inline
995
+ * const digits = String(value).split('').map(Number)
996
+ * // ...
997
+ * return isValid
998
+ * })
999
+ */
1000
+ customClientValidator(validationFn: (fieldValue: unknown, context: ClientFunctionContext) => boolean): JSONSchema;
1001
+ /**
1002
+ * Custom client-side evaluation. Returns a {@link FieldReference} descriptor
1003
+ * that can be used as the `value` property or a DATA component entry.
1004
+ * The function receives the referenced field's value as the first argument and
1005
+ * the full form context as the second; its return value replaces the field reference.
1006
+ * The function is serialised and executed just-in-time on the client only.
1007
+ * External references (e.g. lodash) are not available inside the function body.
1008
+ *
1009
+ * For computing a default value without referencing a specific field, use
1010
+ * `evaluate(fn)` in the `defaultValue` property instead.
1011
+ *
1012
+ * @example
1013
+ * field('a').customClientEvaluation((aValue, ctx) =>
1014
+ * Number(aValue) + Number(ctx.$form.b)
1015
+ * )
1016
+ */
1017
+ customClientEvaluation(computationFn: (fieldValue: unknown, context: ClientFunctionContext) => unknown): CodeToEvaluate;
736
1018
  };
737
1019
  asDob(): any;
738
1020
  asAge(): any;
@@ -792,6 +1074,37 @@ export declare function createFieldConditionals(fieldId: string): {
792
1074
  * )
793
1075
  */
794
1076
  object: (options: Record<string, any>) => JSONSchema;
1077
+ /**
1078
+ * Custom client-side validator. The provided function is serialised and executed
1079
+ * just-in-time on the client only. External references (e.g. lodash) are not
1080
+ * available inside the function body — all logic must be self-contained.
1081
+ *
1082
+ * @example
1083
+ * field('nid').customClientValidator((value) => {
1084
+ * // LUHN check — all logic must be inline
1085
+ * const digits = String(value).split('').map(Number)
1086
+ * // ...
1087
+ * return isValid
1088
+ * })
1089
+ */
1090
+ customClientValidator(validationFn: (fieldValue: unknown, context: ClientFunctionContext) => boolean): JSONSchema;
1091
+ /**
1092
+ * Custom client-side evaluation. Returns a {@link FieldReference} descriptor
1093
+ * that can be used as the `value` property or a DATA component entry.
1094
+ * The function receives the referenced field's value as the first argument and
1095
+ * the full form context as the second; its return value replaces the field reference.
1096
+ * The function is serialised and executed just-in-time on the client only.
1097
+ * External references (e.g. lodash) are not available inside the function body.
1098
+ *
1099
+ * For computing a default value without referencing a specific field, use
1100
+ * `evaluate(fn)` in the `defaultValue` property instead.
1101
+ *
1102
+ * @example
1103
+ * field('a').customClientEvaluation((aValue, ctx) =>
1104
+ * Number(aValue) + Number(ctx.$form.b)
1105
+ * )
1106
+ */
1107
+ customClientEvaluation(computationFn: (fieldValue: unknown, context: ClientFunctionContext) => unknown): CodeToEvaluate;
795
1108
  };
796
1109
  isAfter(): {
797
1110
  days: (days: number) => {
@@ -849,6 +1162,37 @@ export declare function createFieldConditionals(fieldId: string): {
849
1162
  * )
850
1163
  */
851
1164
  object: (options: Record<string, any>) => JSONSchema;
1165
+ /**
1166
+ * Custom client-side validator. The provided function is serialised and executed
1167
+ * just-in-time on the client only. External references (e.g. lodash) are not
1168
+ * available inside the function body — all logic must be self-contained.
1169
+ *
1170
+ * @example
1171
+ * field('nid').customClientValidator((value) => {
1172
+ * // LUHN check — all logic must be inline
1173
+ * const digits = String(value).split('').map(Number)
1174
+ * // ...
1175
+ * return isValid
1176
+ * })
1177
+ */
1178
+ customClientValidator(validationFn: (fieldValue: unknown, context: ClientFunctionContext) => boolean): JSONSchema;
1179
+ /**
1180
+ * Custom client-side evaluation. Returns a {@link FieldReference} descriptor
1181
+ * that can be used as the `value` property or a DATA component entry.
1182
+ * The function receives the referenced field's value as the first argument and
1183
+ * the full form context as the second; its return value replaces the field reference.
1184
+ * The function is serialised and executed just-in-time on the client only.
1185
+ * External references (e.g. lodash) are not available inside the function body.
1186
+ *
1187
+ * For computing a default value without referencing a specific field, use
1188
+ * `evaluate(fn)` in the `defaultValue` property instead.
1189
+ *
1190
+ * @example
1191
+ * field('a').customClientEvaluation((aValue, ctx) =>
1192
+ * Number(aValue) + Number(ctx.$form.b)
1193
+ * )
1194
+ */
1195
+ customClientEvaluation(computationFn: (fieldValue: unknown, context: ClientFunctionContext) => unknown): CodeToEvaluate;
852
1196
  };
853
1197
  export {};
854
1198
  //# sourceMappingURL=conditionals.d.ts.map
@@ -12,6 +12,54 @@ import { ActionType } from '../events/ActionType';
12
12
  import { EventConfig } from '../events/EventConfig';
13
13
  import { EventDocument } from '../events/EventDocument';
14
14
  import { EventIndex } from '../events/EventIndex';
15
+ import { Location } from '../events/locations';
16
+ import { SystemVariables } from '../events/TemplateConfig';
17
+ /** Returns today's date as an ISO date string (YYYY-MM-DD). */
18
+ export declare function todayISO(): string;
19
+ /**
20
+ * Context passed to every serialised client-side function ({@link runClientFunction}).
21
+ *
22
+ * `$user` (full {@link ITokenPayload}, validator paths) and `user` (a
23
+ * {@link SystemVariables} subset for template substitution, default-value
24
+ * path) are distinct sources, not duplicates.
25
+ */
26
+ export type ClientFunctionContext = {
27
+ $form: EventState | ActionUpdate;
28
+ $now: string;
29
+ $online: boolean;
30
+ $user?: ITokenPayload;
31
+ $event?: EventDocument;
32
+ $leafAdminStructureLocationIds: Array<{
33
+ id: UUID;
34
+ }>;
35
+ user?: SystemVariables['user'];
36
+ $window?: SystemVariables['$window'];
37
+ locations?: Location[];
38
+ adminLevelIds?: string[];
39
+ $flags?: string[];
40
+ $status?: string;
41
+ };
42
+ type CompiledClientFunction = (data: FieldValue | undefined, context: ClientFunctionContext) => unknown;
43
+ /**
44
+ * Deserialises a serialised function string (produced by `.toString()`) into a callable.
45
+ * Results are cached by code string so each unique function body is compiled at most once.
46
+ * Runs in a clean scope — no access to outer closures or external imports.
47
+ */
48
+ export declare function compileClientFunction(code: string): CompiledClientFunction;
49
+ export declare function buildClientFunctionContext(input: {
50
+ form: EventState | ActionUpdate;
51
+ validatorContext?: ValidatorContext;
52
+ systemVariables?: SystemVariables;
53
+ /**
54
+ * In real use cases, there can be hundreds of thousands of locations.
55
+ * Make sure that the context contains only the locations that are needed for validation.
56
+ * E.g. if the user is a leaf admin, only the leaf locations under their admin structure are needed.
57
+ * Loading few megabytes of locations to memory just for validation is not efficient and will choke the application.
58
+ */
59
+ locations?: Location[];
60
+ adminLevelIds?: string[];
61
+ }): ClientFunctionContext;
62
+ export declare function runClientFunction(code: string, data: FieldValue | undefined, context: ClientFunctionContext): unknown;
15
63
  /**
16
64
  * Precompiles action conditional schemas from the event configurations to improve performance of condition validation later on.
17
65
  * Best called once on application startup before any condition validation is done.
@@ -20,8 +68,8 @@ export declare function precompileActionSchemas(eventConfigurations: EventConfig
20
68
  export declare function validate(schema: JSONSchema, data: ConditionalParameters): boolean;
21
69
  export declare function validateValue(schema: JSONSchema, data: unknown): boolean;
22
70
  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;
71
+ export declare function isConditionMet(conditional: JSONSchema, values: EventState | ActionUpdate, context: ValidatorContext): boolean;
72
+ export declare function areConditionsMet(conditions: FieldConditional[], values: Record<string, FieldValue>, context: ValidatorContext, _event: EventIndex): boolean;
25
73
  export type ValidatorContext = {
26
74
  user?: ITokenPayload;
27
75
  leafAdminStructureLocationIds?: Array<{
@@ -113,4 +161,5 @@ export declare function runFieldValidations({ field: config, form, value, contex
113
161
  }>>;
114
162
  export declare function getValidatorsForField(fieldId: FieldConfig['id'], validations: NonNullable<FieldConfig['validation']>): NonNullable<FieldConfig['validation']>;
115
163
  export declare function areCertificateConditionsMet(conditions: FieldConditional[], values: ConditionalParameters): boolean;
164
+ export {};
116
165
  //# sourceMappingURL=validate.d.ts.map
@@ -85,6 +85,41 @@ export declare const ActionConfig: z.ZodDiscriminatedUnion<[z.ZodObject<{
85
85
  fields: z.ZodArray<z.ZodType<FieldConfig, import("./FieldConfig").FieldConfigInput, z.core.$ZodTypeInternals<FieldConfig, import("./FieldConfig").FieldConfigInput>>>;
86
86
  }, z.core.$strip>;
87
87
  conditionals: z.ZodOptional<z.ZodNever>;
88
+ }, z.core.$strip>, z.ZodObject<{
89
+ label: z.ZodObject<import("./TranslationConfig").MessageDescriptorZod, z.core.$strip>;
90
+ flags: z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodObject<{
91
+ id: z.ZodUnion<[z.ZodUnion<[z.ZodString, z.ZodEnum<{
92
+ readonly INCOMPLETE: "incomplete";
93
+ readonly REJECTED: "rejected";
94
+ readonly CORRECTION_REQUESTED: "correction-requested";
95
+ readonly POTENTIAL_DUPLICATE: "potential-duplicate";
96
+ readonly EDIT_IN_PROGRESS: "edit-in-progress";
97
+ }>]>, z.ZodString]>;
98
+ operation: z.ZodEnum<{
99
+ add: "add";
100
+ remove: "remove";
101
+ }>;
102
+ conditional: z.ZodOptional<z.ZodAny>;
103
+ }, z.core.$strip>>>>;
104
+ supportingCopy: z.ZodOptional<z.ZodObject<import("./TranslationConfig").MessageDescriptorZod, z.core.$strip>>;
105
+ icon: z.ZodOptional<z.ZodString>;
106
+ conditionals: z.ZodOptional<z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
107
+ type: z.ZodLiteral<"SHOW">;
108
+ conditional: z.ZodAny;
109
+ }, z.core.$strip>, z.ZodObject<{
110
+ type: z.ZodLiteral<"ENABLE">;
111
+ conditional: z.ZodAny;
112
+ }, z.core.$strip>], "type">>>;
113
+ deduplication: z.ZodOptional<z.ZodObject<{
114
+ id: z.ZodString;
115
+ label: z.ZodObject<import("./TranslationConfig").MessageDescriptorZod, z.core.$strip>;
116
+ query: z.ZodType<import("./DeduplicationConfig").ClauseOutput, import("./DeduplicationConfig").ClauseInput, z.core.$ZodTypeInternals<import("./DeduplicationConfig").ClauseOutput, import("./DeduplicationConfig").ClauseInput>>;
117
+ }, z.core.$strip>>;
118
+ type: z.ZodLiteral<"NOTIFY">;
119
+ review: z.ZodOptional<z.ZodObject<{
120
+ title: z.ZodObject<import("./TranslationConfig").MessageDescriptorZod, z.core.$strip>;
121
+ fields: z.ZodArray<z.ZodType<FieldConfig, import("./FieldConfig").FieldConfigInput, z.core.$ZodTypeInternals<FieldConfig, import("./FieldConfig").FieldConfigInput>>>;
122
+ }, z.core.$strip>>;
88
123
  }, z.core.$strip>, z.ZodObject<{
89
124
  label: z.ZodObject<import("./TranslationConfig").MessageDescriptorZod, z.core.$strip>;
90
125
  flags: z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodObject<{
@@ -388,8 +423,8 @@ export declare const actionConfigTypes: Set<ActionConfigTypes>;
388
423
  *
389
424
  * These are not the same as the broader workflow `action.type` values.
390
425
  * `ActionConfigTypes` includes only the action kinds that can be defined
391
- * in the country configuration (e.g. DECLARE, VALIDATE, CUSTOM), and
392
- * excludes workflow-only types such as CREATE or NOTIFY.
426
+ * in the country configuration (e.g. NOTIFY, DECLARE, VALIDATE, CUSTOM), and
427
+ * excludes workflow-only types such as CREATE.
393
428
  */
394
429
  export type ActionConfigTypes = ActionConfig['type'];
395
430
  export declare const DeclarationActionConfig: z.ZodDiscriminatedUnion<[z.ZodObject<{