@opencrvs/toolkit 1.9.12 → 1.9.13-rc.00bb36c

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.
@@ -33,8 +33,8 @@ export declare const defineConfig: (config: EventConfigInput) => {
33
33
  };
34
34
  deduplication?: {
35
35
  id: string;
36
- query: import("./DeduplicationConfig").ClauseOutput;
37
36
  label: import("./TranslationConfig").TranslationConfig;
37
+ query: import("./DeduplicationConfig").ClauseOutput;
38
38
  } | undefined;
39
39
  } | {
40
40
  type: "VALIDATE";
@@ -45,8 +45,8 @@ export declare const defineConfig: (config: EventConfigInput) => {
45
45
  };
46
46
  deduplication?: {
47
47
  id: string;
48
- query: import("./DeduplicationConfig").ClauseOutput;
49
48
  label: import("./TranslationConfig").TranslationConfig;
49
+ query: import("./DeduplicationConfig").ClauseOutput;
50
50
  } | undefined;
51
51
  } | {
52
52
  type: "REJECT";
@@ -63,8 +63,8 @@ export declare const defineConfig: (config: EventConfigInput) => {
63
63
  };
64
64
  deduplication?: {
65
65
  id: string;
66
- query: import("./DeduplicationConfig").ClauseOutput;
67
66
  label: import("./TranslationConfig").TranslationConfig;
67
+ query: import("./DeduplicationConfig").ClauseOutput;
68
68
  } | undefined;
69
69
  } | {
70
70
  type: "DELETE";
@@ -167,7 +167,7 @@ export declare const defineConfig: (config: EventConfigInput) => {
167
167
  title: import("./TranslationConfig").TranslationConfig;
168
168
  fields: ({
169
169
  config: {
170
- type: "exact" | "fuzzy" | "range" | "within";
170
+ type: "exact" | "range" | "fuzzy" | "within";
171
171
  searchFields?: string[] | undefined;
172
172
  };
173
173
  fieldId: string;
@@ -202,10 +202,10 @@ export declare const defineConfig: (config: EventConfigInput) => {
202
202
  }[] | undefined;
203
203
  } | {
204
204
  config: {
205
- type: "exact" | "fuzzy" | "range" | "within";
205
+ type: "exact" | "range" | "fuzzy" | "within";
206
206
  searchFields?: string[] | undefined;
207
207
  };
208
- fieldId: "event.status" | "event.trackingId" | "event.updatedAt" | "event.legalStatuses.REGISTERED.acceptedAt" | "event.legalStatuses.REGISTERED.createdAtLocation" | "event.legalStatuses.REGISTERED.registrationNumber";
208
+ fieldId: "event.trackingId" | "event.status" | "event.legalStatuses.REGISTERED.acceptedAt" | "event.legalStatuses.REGISTERED.createdAtLocation" | "event.legalStatuses.REGISTERED.registrationNumber" | "event.updatedAt";
209
209
  fieldType: "event";
210
210
  type?: "NAME" | "PHONE" | "ID" | "ADDRESS" | "TEXT" | "NUMBER" | "NUMBER_WITH_UNIT" | "TEXTAREA" | "EMAIL" | "DATE" | "AGE" | "DATE_RANGE" | "SELECT_DATE_RANGE" | "TIME" | "PARAGRAPH" | "PAGE_HEADER" | "RADIO_GROUP" | "FIELD_GROUP" | "FILE" | "FILE_WITH_OPTIONS" | "BULLET_LIST" | "CHECKBOX" | "SELECT" | "COUNTRY" | "LOCATION" | "DIVIDER" | "ADMINISTRATIVE_AREA" | "FACILITY" | "OFFICE" | "SIGNATURE" | "DATA" | "BUTTON" | "SEARCH" | "ALPHA_PRINT_BUTTON" | "HTTP" | "LINK_BUTTON" | "VERIFICATION_STATUS" | "QUERY_PARAM_READER" | "QR_READER" | "ID_READER" | "LOADER" | undefined;
211
211
  options?: {
@@ -240,8 +240,9 @@ export declare const defineConfig: (config: EventConfigInput) => {
240
240
  dateOfEvent?: {
241
241
  $$field: string;
242
242
  $$subfield: string[];
243
+ $$code?: string | undefined;
243
244
  } | {
244
- $$event: "createdAt" | "updatedAt" | "legalStatuses.DECLARED.createdAt" | "legalStatuses.DECLARED.acceptedAt" | "legalStatuses.REGISTERED.createdAt" | "legalStatuses.REGISTERED.acceptedAt";
245
+ $$event: "createdAt" | "updatedAt" | "legalStatuses.REGISTERED.acceptedAt" | "legalStatuses.DECLARED.createdAt" | "legalStatuses.DECLARED.acceptedAt" | "legalStatuses.REGISTERED.createdAt";
245
246
  } | undefined;
246
247
  fallbackTitle?: import("./TranslationConfig").TranslationConfig | undefined;
247
248
  };
@@ -1,6 +1,30 @@
1
+ import { FormConditionalParameters } from '../conditionals/conditionals';
1
2
  import { FieldConditional } from './Conditional';
2
3
  import { TranslationConfig } from './TranslationConfig';
3
- import { SelectOption, ValidationConfig } from './FieldConfig';
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;
4
28
  /**
5
29
  * Entry point for defining conditional logic or configuration for a form field.
6
30
  * @param fieldId - The ID of the field to define rules or config for.
@@ -107,6 +131,8 @@ export declare function field(fieldId: string, options?: {
107
131
  fieldId: string;
108
132
  };
109
133
  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;
110
136
  };
111
137
  asDob(): any;
112
138
  asAge(): any;
@@ -144,6 +170,8 @@ export declare function field(fieldId: string, options?: {
144
170
  fieldId: string;
145
171
  };
146
172
  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;
147
175
  };
148
176
  getByPath(fieldPath: string[]): {
149
177
  $$subfield: string[];
@@ -189,6 +217,8 @@ export declare function field(fieldId: string, options?: {
189
217
  fieldId: string;
190
218
  };
191
219
  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;
192
222
  };
193
223
  getByPath(fieldPath: string[]): any;
194
224
  asDob(): {
@@ -232,6 +262,8 @@ export declare function field(fieldId: string, options?: {
232
262
  fieldId: string;
233
263
  };
234
264
  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;
235
267
  };
236
268
  asAge(): {
237
269
  $$subfield: string[];
@@ -274,6 +306,8 @@ export declare function field(fieldId: string, options?: {
274
306
  fieldId: string;
275
307
  };
276
308
  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;
277
311
  };
278
312
  isAfter(): {
279
313
  days: (days: number) => {
@@ -309,6 +343,8 @@ export declare function field(fieldId: string, options?: {
309
343
  fieldId: string;
310
344
  };
311
345
  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;
312
348
  };
313
349
  asDob(): {
314
350
  $$subfield: string[];
@@ -355,6 +391,8 @@ export declare function field(fieldId: string, options?: {
355
391
  fieldId: string;
356
392
  };
357
393
  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;
358
396
  };
359
397
  asDob(): any;
360
398
  asAge(): any;
@@ -392,6 +430,8 @@ export declare function field(fieldId: string, options?: {
392
430
  fieldId: string;
393
431
  };
394
432
  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;
395
435
  };
396
436
  asAge(): {
397
437
  $$subfield: string[];
@@ -438,6 +478,8 @@ export declare function field(fieldId: string, options?: {
438
478
  fieldId: string;
439
479
  };
440
480
  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;
441
483
  };
442
484
  asDob(): any;
443
485
  asAge(): any;
@@ -475,6 +517,8 @@ export declare function field(fieldId: string, options?: {
475
517
  fieldId: string;
476
518
  };
477
519
  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;
478
522
  };
479
523
  isAfter(): {
480
524
  days: (days: number) => {
@@ -510,5 +554,7 @@ export declare function field(fieldId: string, options?: {
510
554
  fieldId: string;
511
555
  };
512
556
  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;
513
559
  };
514
560
  //# sourceMappingURL=field.d.ts.map
@@ -94,176 +94,7 @@ export declare function findActiveDraftForEvent(event: EventDocument, draft: Dra
94
94
  export declare function createEmptyDraft(eventId: UUID, draftId: UUID, actionType: Exclude<ActionType, 'DELETE'>): Draft;
95
95
  export declare function isVerificationPage(page: PageConfig): page is VerificationPageConfig;
96
96
  export declare function getVisibleVerificationPageIds(pages: PageConfig[], annotation: ActionUpdate, context: ValidatorContext): string[];
97
- export declare function omitHiddenAnnotationFields(actionConfig: ActionConfig, declaration: EventState, annotation: ActionUpdate, context: ValidatorContext): Partial<{
98
- [x: string]: string | number | boolean | {
99
- type: string;
100
- path: string;
101
- originalFilename: string;
102
- } | {
103
- firstname: string;
104
- surname: string;
105
- middlename?: string | undefined;
106
- } | {
107
- firstname?: string | null | undefined;
108
- surname?: string | null | undefined;
109
- middlename?: string | null | undefined;
110
- } | {
111
- country: string;
112
- addressType: "DOMESTIC";
113
- administrativeArea: string;
114
- streetLevelDetails?: Record<string, string> | undefined;
115
- } | {
116
- country: string;
117
- addressType: "INTERNATIONAL";
118
- streetLevelDetails?: Record<string, string> | undefined;
119
- } | {
120
- addressType: "DOMESTIC";
121
- country?: string | null | undefined;
122
- streetLevelDetails?: Record<string, string | null> | null | undefined;
123
- administrativeArea?: string | null | undefined;
124
- } | {
125
- addressType: "INTERNATIONAL";
126
- country?: string | null | undefined;
127
- streetLevelDetails?: Record<string, string | null> | null | undefined;
128
- } | {
129
- type: string;
130
- option: string;
131
- path: string;
132
- originalFilename: string;
133
- }[] | {
134
- loading: boolean;
135
- data?: any;
136
- error?: {
137
- message: string;
138
- statusCode: number;
139
- } | null | undefined;
140
- } | {
141
- data?: any;
142
- error?: {
143
- message: string;
144
- statusCode: number;
145
- } | null | undefined;
146
- loading?: boolean | null | undefined;
147
- } | {
148
- data: Record<string, string>;
149
- } | {
150
- data: Record<string, string>;
151
- } | {
152
- data?: any;
153
- } | {
154
- numericValue: number;
155
- unit: string;
156
- } | {
157
- numericValue?: number | undefined;
158
- unit?: string | undefined;
159
- } | (string & import("zod").BRAND<"PlainDate">) | {
160
- age: number;
161
- asOfDateRef: string;
162
- } | {
163
- start: string & import("zod").BRAND<"PlainDate">;
164
- end: string & import("zod").BRAND<"PlainDate">;
165
- } | Record<string, string | number | boolean | {
166
- type: string;
167
- path: string;
168
- originalFilename: string;
169
- } | {
170
- firstname: string;
171
- surname: string;
172
- middlename?: string | undefined;
173
- } | {
174
- firstname?: string | null | undefined;
175
- surname?: string | null | undefined;
176
- middlename?: string | null | undefined;
177
- } | {
178
- country: string;
179
- addressType: "DOMESTIC";
180
- administrativeArea: string;
181
- streetLevelDetails?: Record<string, string> | undefined;
182
- } | {
183
- country: string;
184
- addressType: "INTERNATIONAL";
185
- streetLevelDetails?: Record<string, string> | undefined;
186
- } | {
187
- type: string;
188
- option: string;
189
- path: string;
190
- originalFilename: string;
191
- }[] | {
192
- loading: boolean;
193
- data?: any;
194
- error?: {
195
- message: string;
196
- statusCode: number;
197
- } | null | undefined;
198
- } | {
199
- data: Record<string, string>;
200
- } | {
201
- data?: any;
202
- } | {
203
- numericValue: number;
204
- unit: string;
205
- } | {
206
- numericValue?: number | undefined;
207
- unit?: string | undefined;
208
- } | (string & import("zod").BRAND<"PlainDate">) | {
209
- age: number;
210
- asOfDateRef: string;
211
- } | {
212
- start: string & import("zod").BRAND<"PlainDate">;
213
- end: string & import("zod").BRAND<"PlainDate">;
214
- } | null | undefined> | {
215
- data: Record<string, string | number | boolean | {
216
- type: string;
217
- path: string;
218
- originalFilename: string;
219
- } | {
220
- firstname: string;
221
- surname: string;
222
- middlename?: string | undefined;
223
- } | {
224
- firstname?: string | null | undefined;
225
- surname?: string | null | undefined;
226
- middlename?: string | null | undefined;
227
- } | {
228
- country: string;
229
- addressType: "DOMESTIC";
230
- administrativeArea: string;
231
- streetLevelDetails?: Record<string, string> | undefined;
232
- } | {
233
- country: string;
234
- addressType: "INTERNATIONAL";
235
- streetLevelDetails?: Record<string, string> | undefined;
236
- } | {
237
- type: string;
238
- option: string;
239
- path: string;
240
- originalFilename: string;
241
- }[] | {
242
- loading: boolean;
243
- data?: any;
244
- error?: {
245
- message: string;
246
- statusCode: number;
247
- } | null | undefined;
248
- } | {
249
- data: Record<string, string>;
250
- } | {
251
- data?: any;
252
- } | {
253
- numericValue: number;
254
- unit: string;
255
- } | {
256
- numericValue?: number | undefined;
257
- unit?: string | undefined;
258
- } | (string & import("zod").BRAND<"PlainDate">) | {
259
- age: number;
260
- asOfDateRef: string;
261
- } | {
262
- start: string & import("zod").BRAND<"PlainDate">;
263
- end: string & import("zod").BRAND<"PlainDate">;
264
- } | null | undefined>;
265
- } | null | undefined;
266
- }>;
97
+ export declare function omitHiddenAnnotationFields(actionConfig: ActionConfig, declaration: EventState, annotation: ActionUpdate, context: ValidatorContext): Partial<Record<string, import("./FieldValue").FieldUpdateValue>>;
267
98
  /**
268
99
  * Merges two documents together.
269
100
  *
@@ -411,8 +242,8 @@ export declare function getEventConfigById(eventConfigs: EventConfig[], id: stri
411
242
  };
412
243
  deduplication?: {
413
244
  id: string;
414
- query: import("./DeduplicationConfig").ClauseOutput;
415
245
  label: import("./TranslationConfig").TranslationConfig;
246
+ query: import("./DeduplicationConfig").ClauseOutput;
416
247
  } | undefined;
417
248
  } | {
418
249
  type: "VALIDATE";
@@ -423,8 +254,8 @@ export declare function getEventConfigById(eventConfigs: EventConfig[], id: stri
423
254
  };
424
255
  deduplication?: {
425
256
  id: string;
426
- query: import("./DeduplicationConfig").ClauseOutput;
427
257
  label: import("./TranslationConfig").TranslationConfig;
258
+ query: import("./DeduplicationConfig").ClauseOutput;
428
259
  } | undefined;
429
260
  } | {
430
261
  type: "REJECT";
@@ -441,8 +272,8 @@ export declare function getEventConfigById(eventConfigs: EventConfig[], id: stri
441
272
  };
442
273
  deduplication?: {
443
274
  id: string;
444
- query: import("./DeduplicationConfig").ClauseOutput;
445
275
  label: import("./TranslationConfig").TranslationConfig;
276
+ query: import("./DeduplicationConfig").ClauseOutput;
446
277
  } | undefined;
447
278
  } | {
448
279
  type: "DELETE";
@@ -545,7 +376,7 @@ export declare function getEventConfigById(eventConfigs: EventConfig[], id: stri
545
376
  title: import("./TranslationConfig").TranslationConfig;
546
377
  fields: ({
547
378
  config: {
548
- type: "exact" | "fuzzy" | "range" | "within";
379
+ type: "exact" | "range" | "fuzzy" | "within";
549
380
  searchFields?: string[] | undefined;
550
381
  };
551
382
  fieldId: string;
@@ -580,10 +411,10 @@ export declare function getEventConfigById(eventConfigs: EventConfig[], id: stri
580
411
  }[] | undefined;
581
412
  } | {
582
413
  config: {
583
- type: "exact" | "fuzzy" | "range" | "within";
414
+ type: "exact" | "range" | "fuzzy" | "within";
584
415
  searchFields?: string[] | undefined;
585
416
  };
586
- fieldId: "event.status" | "event.trackingId" | "event.updatedAt" | "event.legalStatuses.REGISTERED.acceptedAt" | "event.legalStatuses.REGISTERED.createdAtLocation" | "event.legalStatuses.REGISTERED.registrationNumber";
417
+ fieldId: "event.trackingId" | "event.status" | "event.legalStatuses.REGISTERED.acceptedAt" | "event.legalStatuses.REGISTERED.createdAtLocation" | "event.legalStatuses.REGISTERED.registrationNumber" | "event.updatedAt";
587
418
  fieldType: "event";
588
419
  type?: "NAME" | "PHONE" | "ID" | "ADDRESS" | "TEXT" | "NUMBER" | "NUMBER_WITH_UNIT" | "TEXTAREA" | "EMAIL" | "DATE" | "AGE" | "DATE_RANGE" | "SELECT_DATE_RANGE" | "TIME" | "PARAGRAPH" | "PAGE_HEADER" | "RADIO_GROUP" | "FIELD_GROUP" | "FILE" | "FILE_WITH_OPTIONS" | "BULLET_LIST" | "CHECKBOX" | "SELECT" | "COUNTRY" | "LOCATION" | "DIVIDER" | "ADMINISTRATIVE_AREA" | "FACILITY" | "OFFICE" | "SIGNATURE" | "DATA" | "BUTTON" | "SEARCH" | "ALPHA_PRINT_BUTTON" | "HTTP" | "LINK_BUTTON" | "VERIFICATION_STATUS" | "QUERY_PARAM_READER" | "QR_READER" | "ID_READER" | "LOADER" | undefined;
589
420
  options?: {
@@ -618,8 +449,9 @@ export declare function getEventConfigById(eventConfigs: EventConfig[], id: stri
618
449
  dateOfEvent?: {
619
450
  $$field: string;
620
451
  $$subfield: string[];
452
+ $$code?: string | undefined;
621
453
  } | {
622
- $$event: "createdAt" | "updatedAt" | "legalStatuses.DECLARED.createdAt" | "legalStatuses.DECLARED.acceptedAt" | "legalStatuses.REGISTERED.createdAt" | "legalStatuses.REGISTERED.acceptedAt";
454
+ $$event: "createdAt" | "updatedAt" | "legalStatuses.REGISTERED.acceptedAt" | "legalStatuses.DECLARED.createdAt" | "legalStatuses.DECLARED.acceptedAt" | "legalStatuses.REGISTERED.createdAt";
623
455
  } | undefined;
624
456
  fallbackTitle?: import("./TranslationConfig").TranslationConfig | undefined;
625
457
  };
@@ -629,7 +461,7 @@ export declare function timePeriodToDateRange(value: SelectDateRangeValue): {
629
461
  };
630
462
  export declare function mergeDrafts(currentDraft: Draft, incomingDraft: Draft): Draft;
631
463
  export declare function getPendingAction(actions: Action[]): ActionDocument;
632
- export declare function getCompleteActionAnnotation(annotation: ActionUpdate, event: EventDocument, action: ActionDocument): ActionUpdate;
464
+ export declare function getCompleteActionAnnotation(event: EventDocument, action: ActionDocument): ActionUpdate;
633
465
  export declare function getCompleteActionDeclaration<T extends EventState | ActionUpdate>(declaration: T, event: EventDocument, action: ActionDocument): T;
634
466
  export declare function getAcceptedActions(event: EventDocument): ActionDocument[];
635
467
  export declare function aggregateActionDeclarations(event: EventDocument): EventState;
@@ -684,6 +684,53 @@ function createFieldConditionals(fieldId) {
684
684
  }
685
685
  },
686
686
  required: [fieldId]
687
- })
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
+ }
688
735
  };
689
736
  }