@opencrvs/toolkit 1.9.13-rc.1d7f578 → 1.9.13-rc.2299d16
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 +1 -0
- package/dist/commons/conditionals/conditionals.d.ts +80 -28
- package/dist/commons/events/EventConfig.d.ts +7 -0
- package/dist/commons/events/FieldConfig.d.ts +1676 -3364
- package/dist/commons/events/defineConfig.d.ts +1 -0
- package/dist/commons/events/field.d.ts +47 -23
- package/dist/commons/events/utils.d.ts +2 -1
- package/dist/conditionals/index.js +7 -1984
- package/dist/events/index.js +67 -66
- package/dist/notification/index.js +53 -48
- package/package.json +1 -1
|
@@ -240,6 +240,7 @@ export declare const defineConfig: (config: EventConfigInput) => {
|
|
|
240
240
|
dateOfEvent?: {
|
|
241
241
|
$$field: string;
|
|
242
242
|
$$subfield: string[];
|
|
243
|
+
$$code?: string | undefined;
|
|
243
244
|
} | {
|
|
244
245
|
$$event: "createdAt" | "updatedAt" | "legalStatuses.DECLARED.createdAt" | "legalStatuses.DECLARED.acceptedAt" | "legalStatuses.REGISTERED.createdAt" | "legalStatuses.REGISTERED.acceptedAt";
|
|
245
246
|
} | undefined;
|
|
@@ -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,8 +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;
|
|
110
|
-
customClientValidator(validationFn: (fieldValue: unknown, context:
|
|
111
|
-
customClientEvaluation(computationFn: (fieldValue: unknown, context:
|
|
134
|
+
customClientValidator(validationFn: (fieldValue: unknown, context: FormConditionalParameters) => boolean): import("../conditionals/conditionals").JSONSchema;
|
|
135
|
+
customClientEvaluation(computationFn: (fieldValue: unknown, context: FormConditionalParameters) => unknown): import("./FieldConfig").CodeToEvaluate;
|
|
112
136
|
};
|
|
113
137
|
asDob(): any;
|
|
114
138
|
asAge(): any;
|
|
@@ -146,8 +170,8 @@ export declare function field(fieldId: string, options?: {
|
|
|
146
170
|
fieldId: string;
|
|
147
171
|
};
|
|
148
172
|
object: (options: Record<string, any>) => import("../conditionals/conditionals").JSONSchema;
|
|
149
|
-
customClientValidator(validationFn: (fieldValue: unknown, context:
|
|
150
|
-
customClientEvaluation(computationFn: (fieldValue: unknown, context:
|
|
173
|
+
customClientValidator(validationFn: (fieldValue: unknown, context: FormConditionalParameters) => boolean): import("../conditionals/conditionals").JSONSchema;
|
|
174
|
+
customClientEvaluation(computationFn: (fieldValue: unknown, context: FormConditionalParameters) => unknown): import("./FieldConfig").CodeToEvaluate;
|
|
151
175
|
};
|
|
152
176
|
getByPath(fieldPath: string[]): {
|
|
153
177
|
$$subfield: string[];
|
|
@@ -193,8 +217,8 @@ export declare function field(fieldId: string, options?: {
|
|
|
193
217
|
fieldId: string;
|
|
194
218
|
};
|
|
195
219
|
object: (options: Record<string, any>) => import("../conditionals/conditionals").JSONSchema;
|
|
196
|
-
customClientValidator(validationFn: (fieldValue: unknown, context:
|
|
197
|
-
customClientEvaluation(computationFn: (fieldValue: unknown, context:
|
|
220
|
+
customClientValidator(validationFn: (fieldValue: unknown, context: FormConditionalParameters) => boolean): import("../conditionals/conditionals").JSONSchema;
|
|
221
|
+
customClientEvaluation(computationFn: (fieldValue: unknown, context: FormConditionalParameters) => unknown): import("./FieldConfig").CodeToEvaluate;
|
|
198
222
|
};
|
|
199
223
|
getByPath(fieldPath: string[]): any;
|
|
200
224
|
asDob(): {
|
|
@@ -238,8 +262,8 @@ export declare function field(fieldId: string, options?: {
|
|
|
238
262
|
fieldId: string;
|
|
239
263
|
};
|
|
240
264
|
object: (options: Record<string, any>) => import("../conditionals/conditionals").JSONSchema;
|
|
241
|
-
customClientValidator(validationFn: (fieldValue: unknown, context:
|
|
242
|
-
customClientEvaluation(computationFn: (fieldValue: unknown, context:
|
|
265
|
+
customClientValidator(validationFn: (fieldValue: unknown, context: FormConditionalParameters) => boolean): import("../conditionals/conditionals").JSONSchema;
|
|
266
|
+
customClientEvaluation(computationFn: (fieldValue: unknown, context: FormConditionalParameters) => unknown): import("./FieldConfig").CodeToEvaluate;
|
|
243
267
|
};
|
|
244
268
|
asAge(): {
|
|
245
269
|
$$subfield: string[];
|
|
@@ -282,8 +306,8 @@ export declare function field(fieldId: string, options?: {
|
|
|
282
306
|
fieldId: string;
|
|
283
307
|
};
|
|
284
308
|
object: (options: Record<string, any>) => import("../conditionals/conditionals").JSONSchema;
|
|
285
|
-
customClientValidator(validationFn: (fieldValue: unknown, context:
|
|
286
|
-
customClientEvaluation(computationFn: (fieldValue: unknown, context:
|
|
309
|
+
customClientValidator(validationFn: (fieldValue: unknown, context: FormConditionalParameters) => boolean): import("../conditionals/conditionals").JSONSchema;
|
|
310
|
+
customClientEvaluation(computationFn: (fieldValue: unknown, context: FormConditionalParameters) => unknown): import("./FieldConfig").CodeToEvaluate;
|
|
287
311
|
};
|
|
288
312
|
isAfter(): {
|
|
289
313
|
days: (days: number) => {
|
|
@@ -319,8 +343,8 @@ export declare function field(fieldId: string, options?: {
|
|
|
319
343
|
fieldId: string;
|
|
320
344
|
};
|
|
321
345
|
object: (options: Record<string, any>) => import("../conditionals/conditionals").JSONSchema;
|
|
322
|
-
customClientValidator(validationFn: (fieldValue: unknown, context:
|
|
323
|
-
customClientEvaluation(computationFn: (fieldValue: unknown, context:
|
|
346
|
+
customClientValidator(validationFn: (fieldValue: unknown, context: FormConditionalParameters) => boolean): import("../conditionals/conditionals").JSONSchema;
|
|
347
|
+
customClientEvaluation(computationFn: (fieldValue: unknown, context: FormConditionalParameters) => unknown): import("./FieldConfig").CodeToEvaluate;
|
|
324
348
|
};
|
|
325
349
|
asDob(): {
|
|
326
350
|
$$subfield: string[];
|
|
@@ -367,8 +391,8 @@ export declare function field(fieldId: string, options?: {
|
|
|
367
391
|
fieldId: string;
|
|
368
392
|
};
|
|
369
393
|
object: (options: Record<string, any>) => import("../conditionals/conditionals").JSONSchema;
|
|
370
|
-
customClientValidator(validationFn: (fieldValue: unknown, context:
|
|
371
|
-
customClientEvaluation(computationFn: (fieldValue: unknown, context:
|
|
394
|
+
customClientValidator(validationFn: (fieldValue: unknown, context: FormConditionalParameters) => boolean): import("../conditionals/conditionals").JSONSchema;
|
|
395
|
+
customClientEvaluation(computationFn: (fieldValue: unknown, context: FormConditionalParameters) => unknown): import("./FieldConfig").CodeToEvaluate;
|
|
372
396
|
};
|
|
373
397
|
asDob(): any;
|
|
374
398
|
asAge(): any;
|
|
@@ -406,8 +430,8 @@ export declare function field(fieldId: string, options?: {
|
|
|
406
430
|
fieldId: string;
|
|
407
431
|
};
|
|
408
432
|
object: (options: Record<string, any>) => import("../conditionals/conditionals").JSONSchema;
|
|
409
|
-
customClientValidator(validationFn: (fieldValue: unknown, context:
|
|
410
|
-
customClientEvaluation(computationFn: (fieldValue: unknown, context:
|
|
433
|
+
customClientValidator(validationFn: (fieldValue: unknown, context: FormConditionalParameters) => boolean): import("../conditionals/conditionals").JSONSchema;
|
|
434
|
+
customClientEvaluation(computationFn: (fieldValue: unknown, context: FormConditionalParameters) => unknown): import("./FieldConfig").CodeToEvaluate;
|
|
411
435
|
};
|
|
412
436
|
asAge(): {
|
|
413
437
|
$$subfield: string[];
|
|
@@ -454,8 +478,8 @@ export declare function field(fieldId: string, options?: {
|
|
|
454
478
|
fieldId: string;
|
|
455
479
|
};
|
|
456
480
|
object: (options: Record<string, any>) => import("../conditionals/conditionals").JSONSchema;
|
|
457
|
-
customClientValidator(validationFn: (fieldValue: unknown, context:
|
|
458
|
-
customClientEvaluation(computationFn: (fieldValue: unknown, context:
|
|
481
|
+
customClientValidator(validationFn: (fieldValue: unknown, context: FormConditionalParameters) => boolean): import("../conditionals/conditionals").JSONSchema;
|
|
482
|
+
customClientEvaluation(computationFn: (fieldValue: unknown, context: FormConditionalParameters) => unknown): import("./FieldConfig").CodeToEvaluate;
|
|
459
483
|
};
|
|
460
484
|
asDob(): any;
|
|
461
485
|
asAge(): any;
|
|
@@ -493,8 +517,8 @@ export declare function field(fieldId: string, options?: {
|
|
|
493
517
|
fieldId: string;
|
|
494
518
|
};
|
|
495
519
|
object: (options: Record<string, any>) => import("../conditionals/conditionals").JSONSchema;
|
|
496
|
-
customClientValidator(validationFn: (fieldValue: unknown, context:
|
|
497
|
-
customClientEvaluation(computationFn: (fieldValue: unknown, context:
|
|
520
|
+
customClientValidator(validationFn: (fieldValue: unknown, context: FormConditionalParameters) => boolean): import("../conditionals/conditionals").JSONSchema;
|
|
521
|
+
customClientEvaluation(computationFn: (fieldValue: unknown, context: FormConditionalParameters) => unknown): import("./FieldConfig").CodeToEvaluate;
|
|
498
522
|
};
|
|
499
523
|
isAfter(): {
|
|
500
524
|
days: (days: number) => {
|
|
@@ -530,7 +554,7 @@ export declare function field(fieldId: string, options?: {
|
|
|
530
554
|
fieldId: string;
|
|
531
555
|
};
|
|
532
556
|
object: (options: Record<string, any>) => import("../conditionals/conditionals").JSONSchema;
|
|
533
|
-
customClientValidator(validationFn: (fieldValue: unknown, context:
|
|
534
|
-
customClientEvaluation(computationFn: (fieldValue: unknown, context:
|
|
557
|
+
customClientValidator(validationFn: (fieldValue: unknown, context: FormConditionalParameters) => boolean): import("../conditionals/conditionals").JSONSchema;
|
|
558
|
+
customClientEvaluation(computationFn: (fieldValue: unknown, context: FormConditionalParameters) => unknown): import("./FieldConfig").CodeToEvaluate;
|
|
535
559
|
};
|
|
536
560
|
//# sourceMappingURL=field.d.ts.map
|
|
@@ -449,6 +449,7 @@ export declare function getEventConfigById(eventConfigs: EventConfig[], id: stri
|
|
|
449
449
|
dateOfEvent?: {
|
|
450
450
|
$$field: string;
|
|
451
451
|
$$subfield: string[];
|
|
452
|
+
$$code?: string | undefined;
|
|
452
453
|
} | {
|
|
453
454
|
$$event: "createdAt" | "updatedAt" | "legalStatuses.DECLARED.createdAt" | "legalStatuses.DECLARED.acceptedAt" | "legalStatuses.REGISTERED.createdAt" | "legalStatuses.REGISTERED.acceptedAt";
|
|
454
455
|
} | undefined;
|
|
@@ -460,7 +461,7 @@ export declare function timePeriodToDateRange(value: SelectDateRangeValue): {
|
|
|
460
461
|
};
|
|
461
462
|
export declare function mergeDrafts(currentDraft: Draft, incomingDraft: Draft): Draft;
|
|
462
463
|
export declare function getPendingAction(actions: Action[]): ActionDocument;
|
|
463
|
-
export declare function getCompleteActionAnnotation(
|
|
464
|
+
export declare function getCompleteActionAnnotation(event: EventDocument, action: ActionDocument): ActionUpdate;
|
|
464
465
|
export declare function getCompleteActionDeclaration<T extends EventState | ActionUpdate>(declaration: T, event: EventDocument, action: ActionDocument): T;
|
|
465
466
|
export declare function getAcceptedActions(event: EventDocument): ActionDocument[];
|
|
466
467
|
export declare function aggregateActionDeclarations(event: EventDocument): EventState;
|