@opencrvs/toolkit 2.0.0-rc.0f51ec5 → 2.0.0-rc.0fb1707

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.
@@ -58,12 +58,6 @@ export declare const CheckboxFieldValue: z.ZodBoolean;
58
58
  export type CheckboxFieldValue = z.infer<typeof CheckboxFieldValue>;
59
59
  export declare const NumberFieldValue: z.ZodNumber;
60
60
  export type NumberFieldValue = z.infer<typeof NumberFieldValue>;
61
- export declare const SignatureFieldValue: z.ZodObject<{
62
- path: z.core.$ZodBranded<z.ZodString, "DocumentPath", "out">;
63
- originalFilename: z.ZodString;
64
- type: z.ZodString;
65
- }, z.core.$strip>;
66
- export type SignatureFieldValue = z.infer<typeof SignatureFieldValue>;
67
61
  export declare const ButtonFieldValue: z.ZodNumber;
68
62
  export type ButtonFieldValue = z.infer<typeof ButtonFieldValue>;
69
63
  export declare const VerificationStatusValue: z.ZodEnum<{
@@ -1,30 +1,6 @@
1
- import { FormConditionalParameters } from '../conditionals/conditionals';
2
1
  import { FieldConditional } from './Conditional';
3
2
  import { TranslationConfig } from './TranslationConfig';
4
- import { ComputedDefaultValue, SelectOption, ValidationConfig } from './FieldConfig';
5
- /**
6
- * Creates a {@link ComputedDefaultValue} descriptor for use in a field's `defaultValue`.
7
- *
8
- * Unlike `field(id).customClientEvaluation(fn)`, this builder is **not tied to any
9
- * specific field**. Use it when the initial value should be derived purely from
10
- * context variables (`$now`, `$online`, system variables such as `$user`) rather
11
- * than from another field's current value.
12
- *
13
- * The serialised function receives `(undefined, context)` at runtime, where
14
- * `context` is a {@link FormConditionalParameters} object.
15
- *
16
- * External references (e.g. lodash) are **not** available inside the function body —
17
- * all logic must be self-contained so the code survives serialisation.
18
- *
19
- * @example
20
- * // Default a date field to today
21
- * defaultValue: evaluate((_, ctx) => ctx.$now)
22
- *
23
- * @example
24
- * // Default to the current user's role
25
- * defaultValue: evaluate((_, ctx) => ctx.user.role)
26
- */
27
- export declare function evaluate(computationFn: (fieldValue: undefined, context: FormConditionalParameters) => unknown): ComputedDefaultValue;
3
+ import { SelectOption, ValidationConfig } from './FieldConfig';
28
4
  /**
29
5
  * Entry point for defining conditional logic or configuration for a form field.
30
6
  * @param fieldId - The ID of the field to define rules or config for.
@@ -131,8 +107,6 @@ export declare function field(fieldId: string, options?: {
131
107
  fieldId: string;
132
108
  };
133
109
  object: (options: Record<string, any>) => import("../conditionals/conditionals").JSONSchema;
134
- customClientValidator(validationFn: (fieldValue: unknown, context: import(".").ClientFunctionContext) => boolean): import("../conditionals/conditionals").JSONSchema;
135
- customClientEvaluation(computationFn: (fieldValue: unknown, context: import(".").ClientFunctionContext) => unknown): import("./FieldConfig").CodeToEvaluate;
136
110
  };
137
111
  asDob(): any;
138
112
  asAge(): any;
@@ -170,8 +144,6 @@ export declare function field(fieldId: string, options?: {
170
144
  fieldId: string;
171
145
  };
172
146
  object: (options: Record<string, any>) => import("../conditionals/conditionals").JSONSchema;
173
- customClientValidator(validationFn: (fieldValue: unknown, context: import(".").ClientFunctionContext) => boolean): import("../conditionals/conditionals").JSONSchema;
174
- customClientEvaluation(computationFn: (fieldValue: unknown, context: import(".").ClientFunctionContext) => unknown): import("./FieldConfig").CodeToEvaluate;
175
147
  };
176
148
  getByPath(fieldPath: string[]): {
177
149
  $$subfield: string[];
@@ -217,8 +189,6 @@ export declare function field(fieldId: string, options?: {
217
189
  fieldId: string;
218
190
  };
219
191
  object: (options: Record<string, any>) => import("../conditionals/conditionals").JSONSchema;
220
- customClientValidator(validationFn: (fieldValue: unknown, context: import(".").ClientFunctionContext) => boolean): import("../conditionals/conditionals").JSONSchema;
221
- customClientEvaluation(computationFn: (fieldValue: unknown, context: import(".").ClientFunctionContext) => unknown): import("./FieldConfig").CodeToEvaluate;
222
192
  };
223
193
  getByPath(fieldPath: string[]): any;
224
194
  asDob(): {
@@ -262,8 +232,6 @@ export declare function field(fieldId: string, options?: {
262
232
  fieldId: string;
263
233
  };
264
234
  object: (options: Record<string, any>) => import("../conditionals/conditionals").JSONSchema;
265
- customClientValidator(validationFn: (fieldValue: unknown, context: import(".").ClientFunctionContext) => boolean): import("../conditionals/conditionals").JSONSchema;
266
- customClientEvaluation(computationFn: (fieldValue: unknown, context: import(".").ClientFunctionContext) => unknown): import("./FieldConfig").CodeToEvaluate;
267
235
  };
268
236
  asAge(): {
269
237
  $$subfield: string[];
@@ -306,8 +274,6 @@ export declare function field(fieldId: string, options?: {
306
274
  fieldId: string;
307
275
  };
308
276
  object: (options: Record<string, any>) => import("../conditionals/conditionals").JSONSchema;
309
- customClientValidator(validationFn: (fieldValue: unknown, context: import(".").ClientFunctionContext) => boolean): import("../conditionals/conditionals").JSONSchema;
310
- customClientEvaluation(computationFn: (fieldValue: unknown, context: import(".").ClientFunctionContext) => unknown): import("./FieldConfig").CodeToEvaluate;
311
277
  };
312
278
  isAfter(): {
313
279
  days: (days: number) => {
@@ -343,8 +309,6 @@ export declare function field(fieldId: string, options?: {
343
309
  fieldId: string;
344
310
  };
345
311
  object: (options: Record<string, any>) => import("../conditionals/conditionals").JSONSchema;
346
- customClientValidator(validationFn: (fieldValue: unknown, context: import(".").ClientFunctionContext) => boolean): import("../conditionals/conditionals").JSONSchema;
347
- customClientEvaluation(computationFn: (fieldValue: unknown, context: import(".").ClientFunctionContext) => unknown): import("./FieldConfig").CodeToEvaluate;
348
312
  };
349
313
  asDob(): {
350
314
  $$subfield: string[];
@@ -391,8 +355,6 @@ export declare function field(fieldId: string, options?: {
391
355
  fieldId: string;
392
356
  };
393
357
  object: (options: Record<string, any>) => import("../conditionals/conditionals").JSONSchema;
394
- customClientValidator(validationFn: (fieldValue: unknown, context: import(".").ClientFunctionContext) => boolean): import("../conditionals/conditionals").JSONSchema;
395
- customClientEvaluation(computationFn: (fieldValue: unknown, context: import(".").ClientFunctionContext) => unknown): import("./FieldConfig").CodeToEvaluate;
396
358
  };
397
359
  asDob(): any;
398
360
  asAge(): any;
@@ -430,8 +392,6 @@ export declare function field(fieldId: string, options?: {
430
392
  fieldId: string;
431
393
  };
432
394
  object: (options: Record<string, any>) => import("../conditionals/conditionals").JSONSchema;
433
- customClientValidator(validationFn: (fieldValue: unknown, context: import(".").ClientFunctionContext) => boolean): import("../conditionals/conditionals").JSONSchema;
434
- customClientEvaluation(computationFn: (fieldValue: unknown, context: import(".").ClientFunctionContext) => unknown): import("./FieldConfig").CodeToEvaluate;
435
395
  };
436
396
  asAge(): {
437
397
  $$subfield: string[];
@@ -478,8 +438,6 @@ export declare function field(fieldId: string, options?: {
478
438
  fieldId: string;
479
439
  };
480
440
  object: (options: Record<string, any>) => import("../conditionals/conditionals").JSONSchema;
481
- customClientValidator(validationFn: (fieldValue: unknown, context: import(".").ClientFunctionContext) => boolean): import("../conditionals/conditionals").JSONSchema;
482
- customClientEvaluation(computationFn: (fieldValue: unknown, context: import(".").ClientFunctionContext) => unknown): import("./FieldConfig").CodeToEvaluate;
483
441
  };
484
442
  asDob(): any;
485
443
  asAge(): any;
@@ -517,8 +475,6 @@ export declare function field(fieldId: string, options?: {
517
475
  fieldId: string;
518
476
  };
519
477
  object: (options: Record<string, any>) => import("../conditionals/conditionals").JSONSchema;
520
- customClientValidator(validationFn: (fieldValue: unknown, context: import(".").ClientFunctionContext) => boolean): import("../conditionals/conditionals").JSONSchema;
521
- customClientEvaluation(computationFn: (fieldValue: unknown, context: import(".").ClientFunctionContext) => unknown): import("./FieldConfig").CodeToEvaluate;
522
478
  };
523
479
  isAfter(): {
524
480
  days: (days: number) => {
@@ -554,7 +510,5 @@ export declare function field(fieldId: string, options?: {
554
510
  fieldId: string;
555
511
  };
556
512
  object: (options: Record<string, any>) => import("../conditionals/conditionals").JSONSchema;
557
- customClientValidator(validationFn: (fieldValue: unknown, context: import(".").ClientFunctionContext) => boolean): import("../conditionals/conditionals").JSONSchema;
558
- customClientEvaluation(computationFn: (fieldValue: unknown, context: import(".").ClientFunctionContext) => unknown): import("./FieldConfig").CodeToEvaluate;
559
513
  };
560
514
  //# sourceMappingURL=field.d.ts.map
@@ -559,7 +559,7 @@ export declare function timePeriodToDateRange(value: SelectDateRangeValue): {
559
559
  };
560
560
  export declare function mergeDrafts(currentDraft: Draft, incomingDraft: Draft): Draft;
561
561
  export declare function getPendingAction(actions: Action[]): ActionDocument;
562
- export declare function getCompleteActionAnnotation(event: EventDocument, action: ActionDocument): ActionUpdate;
562
+ export declare function getCompleteActionAnnotation(annotation: ActionUpdate, event: EventDocument, action: ActionDocument): ActionUpdate;
563
563
  export declare function getCompleteActionDeclaration<T extends EventState | ActionUpdate>(declaration: T, event: EventDocument, action: ActionDocument): T;
564
564
  export declare function getAcceptedActions(event: EventDocument): ActionDocument[];
565
565
  export declare function aggregateActionDeclarations(event: EventDocument): EventState;
@@ -1005,54 +1005,7 @@ function createFieldConditionals(fieldId) {
1005
1005
  }
1006
1006
  },
1007
1007
  required: [fieldId]
1008
- }),
1009
- /**
1010
- * Custom client-side validator. The provided function is serialised and executed
1011
- * just-in-time on the client only. External references (e.g. lodash) are not
1012
- * available inside the function body — all logic must be self-contained.
1013
- *
1014
- * @example
1015
- * field('nid').customClientValidator((value) => {
1016
- * // LUHN check — all logic must be inline
1017
- * const digits = String(value).split('').map(Number)
1018
- * // ...
1019
- * return isValid
1020
- * })
1021
- */
1022
- customClientValidator(validationFn) {
1023
- const code = validationFn.toString();
1024
- return defineFormConditional({
1025
- type: "object",
1026
- properties: wrapToPath(
1027
- { [fieldId]: { customClientValidator: { code } } },
1028
- this.$$subfield
1029
- ),
1030
- required: [fieldId]
1031
- });
1032
- },
1033
- /**
1034
- * Custom client-side evaluation. Returns a {@link FieldReference} descriptor
1035
- * that can be used as the `value` property or a DATA component entry.
1036
- * The function receives the referenced field's value as the first argument and
1037
- * the full form context as the second; its return value replaces the field reference.
1038
- * The function is serialised and executed just-in-time on the client only.
1039
- * External references (e.g. lodash) are not available inside the function body.
1040
- *
1041
- * For computing a default value without referencing a specific field, use
1042
- * `evaluate(fn)` in the `defaultValue` property instead.
1043
- *
1044
- * @example
1045
- * field('a').customClientEvaluation((aValue, ctx) =>
1046
- * Number(aValue) + Number(ctx.$form.b)
1047
- * )
1048
- */
1049
- customClientEvaluation(computationFn) {
1050
- return {
1051
- $$code: computationFn.toString(),
1052
- $$field: fieldId,
1053
- $$subfield: this.$$subfield
1054
- };
1055
- }
1008
+ })
1056
1009
  };
1057
1010
  }
1058
1011