@opencrvs/toolkit 1.9.13-rc.0f86459 → 1.9.13-rc.1045e45

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.
@@ -240,7 +240,6 @@ export declare const defineConfig: (config: EventConfigInput) => {
240
240
  dateOfEvent?: {
241
241
  $$field: string;
242
242
  $$subfield: string[];
243
- $$code?: string | undefined;
244
243
  } | {
245
244
  $$event: "createdAt" | "updatedAt" | "legalStatuses.DECLARED.createdAt" | "legalStatuses.DECLARED.acceptedAt" | "legalStatuses.REGISTERED.createdAt" | "legalStatuses.REGISTERED.acceptedAt";
246
245
  } | undefined;
@@ -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: FormConditionalParameters) => boolean): import("../conditionals/conditionals").JSONSchema;
135
- customClientEvaluation(computationFn: (fieldValue: unknown, context: FormConditionalParameters) => 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: FormConditionalParameters) => boolean): import("../conditionals/conditionals").JSONSchema;
174
- customClientEvaluation(computationFn: (fieldValue: unknown, context: FormConditionalParameters) => 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: FormConditionalParameters) => boolean): import("../conditionals/conditionals").JSONSchema;
221
- customClientEvaluation(computationFn: (fieldValue: unknown, context: FormConditionalParameters) => 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: FormConditionalParameters) => boolean): import("../conditionals/conditionals").JSONSchema;
266
- customClientEvaluation(computationFn: (fieldValue: unknown, context: FormConditionalParameters) => 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: FormConditionalParameters) => boolean): import("../conditionals/conditionals").JSONSchema;
310
- customClientEvaluation(computationFn: (fieldValue: unknown, context: FormConditionalParameters) => 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: FormConditionalParameters) => boolean): import("../conditionals/conditionals").JSONSchema;
347
- customClientEvaluation(computationFn: (fieldValue: unknown, context: FormConditionalParameters) => 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: FormConditionalParameters) => boolean): import("../conditionals/conditionals").JSONSchema;
395
- customClientEvaluation(computationFn: (fieldValue: unknown, context: FormConditionalParameters) => 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: FormConditionalParameters) => boolean): import("../conditionals/conditionals").JSONSchema;
434
- customClientEvaluation(computationFn: (fieldValue: unknown, context: FormConditionalParameters) => 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: FormConditionalParameters) => boolean): import("../conditionals/conditionals").JSONSchema;
482
- customClientEvaluation(computationFn: (fieldValue: unknown, context: FormConditionalParameters) => 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: FormConditionalParameters) => boolean): import("../conditionals/conditionals").JSONSchema;
521
- customClientEvaluation(computationFn: (fieldValue: unknown, context: FormConditionalParameters) => 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: FormConditionalParameters) => boolean): import("../conditionals/conditionals").JSONSchema;
558
- customClientEvaluation(computationFn: (fieldValue: unknown, context: FormConditionalParameters) => unknown): import("./FieldConfig").CodeToEvaluate;
559
513
  };
560
514
  //# sourceMappingURL=field.d.ts.map
@@ -449,7 +449,6 @@ export declare function getEventConfigById(eventConfigs: EventConfig[], id: stri
449
449
  dateOfEvent?: {
450
450
  $$field: string;
451
451
  $$subfield: string[];
452
- $$code?: string | undefined;
453
452
  } | {
454
453
  $$event: "createdAt" | "updatedAt" | "legalStatuses.DECLARED.createdAt" | "legalStatuses.DECLARED.acceptedAt" | "legalStatuses.REGISTERED.createdAt" | "legalStatuses.REGISTERED.acceptedAt";
455
454
  } | undefined;
@@ -461,7 +460,7 @@ export declare function timePeriodToDateRange(value: SelectDateRangeValue): {
461
460
  };
462
461
  export declare function mergeDrafts(currentDraft: Draft, incomingDraft: Draft): Draft;
463
462
  export declare function getPendingAction(actions: Action[]): ActionDocument;
464
- export declare function getCompleteActionAnnotation(annotation: ActionUpdate, event: EventDocument, action: ActionDocument): ActionUpdate;
463
+ export declare function getCompleteActionAnnotation(event: EventDocument, action: ActionDocument): ActionUpdate;
465
464
  export declare function getCompleteActionDeclaration<T extends EventState | ActionUpdate>(declaration: T, event: EventDocument, action: ActionDocument): T;
466
465
  export declare function getAcceptedActions(event: EventDocument): ActionDocument[];
467
466
  export declare function aggregateActionDeclarations(event: EventDocument): EventState;
@@ -684,53 +684,6 @@ function createFieldConditionals(fieldId) {
684
684
  }
685
685
  },
686
686
  required: [fieldId]
687
- }),
688
- /**
689
- * Custom client-side validator. The provided function is serialised and executed
690
- * just-in-time on the client only. External references (e.g. lodash) are not
691
- * available inside the function body — all logic must be self-contained.
692
- *
693
- * @example
694
- * field('nid').customClientValidator((value) => {
695
- * // LUHN check — all logic must be inline
696
- * const digits = String(value).split('').map(Number)
697
- * // ...
698
- * return isValid
699
- * })
700
- */
701
- customClientValidator(validationFn) {
702
- const code = validationFn.toString();
703
- return defineFormConditional({
704
- type: "object",
705
- properties: wrapToPath(
706
- { [fieldId]: { customClientValidator: { code } } },
707
- this.$$subfield
708
- ),
709
- required: [fieldId]
710
- });
711
- },
712
- /**
713
- * Custom client-side evaluation. Returns a {@link FieldReference} descriptor
714
- * that can be used as the `value` property or a DATA component entry.
715
- * The function receives the referenced field's value as the first argument and
716
- * the full form context as the second; its return value replaces the field reference.
717
- * The function is serialised and executed just-in-time on the client only.
718
- * External references (e.g. lodash) are not available inside the function body.
719
- *
720
- * For computing a default value without referencing a specific field, use
721
- * `evaluate(fn)` in the `defaultValue` property instead.
722
- *
723
- * @example
724
- * field('a').customClientEvaluation((aValue, ctx) =>
725
- * Number(aValue) + Number(ctx.$form.b)
726
- * )
727
- */
728
- customClientEvaluation(computationFn) {
729
- return {
730
- $$code: computationFn.toString(),
731
- $$field: fieldId,
732
- $$subfield: this.$$subfield
733
- };
734
- }
687
+ })
735
688
  };
736
689
  }