@opencrvs/toolkit 1.8.0-rc.ffe8c17 → 1.8.1-rc.a372970
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/README.md +1 -1
- package/dist/commons/api/router.d.ts +6644 -9555
- package/dist/commons/conditionals/conditionals.d.ts +26 -3
- package/dist/commons/conditionals/validate-address.test.d.ts +2 -0
- package/dist/commons/conditionals/validate.d.ts +14 -17
- package/dist/commons/events/ActionConfig.d.ts +1008 -3209
- package/dist/commons/events/ActionDocument.d.ts +9488 -312
- package/dist/commons/events/ActionInput.d.ts +5329 -472
- package/dist/commons/events/ActionType.d.ts +26 -11
- package/dist/commons/events/CompositeFieldValue.d.ts +152 -2
- package/dist/commons/events/Conditional.d.ts +21 -5
- package/dist/commons/events/Draft.d.ts +351 -48
- package/dist/commons/events/EventConfig.d.ts +639 -2862
- package/dist/commons/events/EventConfigInput.d.ts +6 -3
- package/dist/commons/events/EventDocument.d.ts +3340 -424
- package/dist/commons/events/EventIndex.d.ts +6 -3
- package/dist/commons/events/EventMetadata.d.ts +3 -0
- package/dist/commons/events/FieldConfig.d.ts +383 -104
- package/dist/commons/events/FieldTypeMapping.d.ts +104 -207
- package/dist/commons/events/FieldValue.d.ts +71 -76
- package/dist/commons/events/FormConfig.d.ts +527 -279
- package/dist/commons/events/PageConfig.d.ts +335 -0
- package/dist/commons/events/TemplateConfig.d.ts +5 -5
- package/dist/commons/events/defineConfig.d.ts +40 -417
- package/dist/commons/events/index.d.ts +2 -1
- package/dist/commons/events/test.utils.d.ts +140 -213
- package/dist/commons/events/utils.d.ts +126 -156
- package/dist/commons/events/utils.test.d.ts +2 -0
- package/dist/conditionals/index.js +166 -81
- package/dist/events/index.js +1287 -795
- package/dist/scopes/index.d.ts +70 -1
- package/dist/scopes/index.js +130 -0
- package/package.json +1 -1
@@ -8,6 +8,7 @@ export type JSONSchema = {
|
|
8
8
|
readonly __nominal__type: 'JSONSchema';
|
9
9
|
};
|
10
10
|
export declare function defineConditional(schema: any): JSONSchema;
|
11
|
+
export declare function defineFormConditional(schema: Record<string, unknown>): JSONSchema;
|
11
12
|
export type UserConditionalParameters = {
|
12
13
|
$now: string;
|
13
14
|
$user: TokenPayload;
|
@@ -47,6 +48,12 @@ export declare function or(...conditions: AjvJSONSchema[]): JSONSchema;
|
|
47
48
|
* @example not(field('foo').isEqualTo('bar'))
|
48
49
|
*/
|
49
50
|
export declare function not(condition: AjvJSONSchema): JSONSchema;
|
51
|
+
/**
|
52
|
+
* Returns an JSON Schema object, which is treated as always invalid.
|
53
|
+
*
|
54
|
+
* @returns {JSONSchema} An schema object that always evaluates to false.
|
55
|
+
*/
|
56
|
+
export declare function never(): JSONSchema;
|
50
57
|
/**
|
51
58
|
*
|
52
59
|
* Generate conditional rules for user.
|
@@ -61,6 +68,10 @@ export declare const user: {
|
|
61
68
|
export declare const event: {
|
62
69
|
hasAction: (action: ActionType) => JSONSchema;
|
63
70
|
};
|
71
|
+
type FieldReference = {
|
72
|
+
_fieldId: string;
|
73
|
+
[key: string]: unknown;
|
74
|
+
};
|
64
75
|
/**
|
65
76
|
* Generate conditional rules for a form field.
|
66
77
|
*
|
@@ -70,12 +81,16 @@ export declare const event: {
|
|
70
81
|
*
|
71
82
|
*/
|
72
83
|
export declare function field(fieldId: string): {
|
84
|
+
/**
|
85
|
+
* @private Internal property used for field reference tracking.
|
86
|
+
*/
|
87
|
+
_fieldId: string;
|
73
88
|
isAfter: () => {
|
74
89
|
days: (days: number) => {
|
75
90
|
inPast: () => JSONSchema;
|
76
91
|
inFuture: () => JSONSchema;
|
77
92
|
};
|
78
|
-
date: (date: string) => JSONSchema;
|
93
|
+
date: (date: string | FieldReference) => JSONSchema;
|
79
94
|
now: () => JSONSchema;
|
80
95
|
};
|
81
96
|
isBefore: () => {
|
@@ -83,10 +98,10 @@ export declare function field(fieldId: string): {
|
|
83
98
|
inPast: () => JSONSchema;
|
84
99
|
inFuture: () => JSONSchema;
|
85
100
|
};
|
86
|
-
date: (date: string) => JSONSchema;
|
101
|
+
date: (date: string | FieldReference) => JSONSchema;
|
87
102
|
now: () => JSONSchema;
|
88
103
|
};
|
89
|
-
isEqualTo: (value: string | boolean) => JSONSchema;
|
104
|
+
isEqualTo: (value: string | boolean | FieldReference) => JSONSchema;
|
90
105
|
/**
|
91
106
|
* Use case: Some fields are rendered when selection is not made, or boolean false is explicitly selected.
|
92
107
|
* @example field('recommender.none').isFalsy() vs not(field('recommender.none').isEqualTo(true))
|
@@ -98,6 +113,14 @@ export declare function field(fieldId: string): {
|
|
98
113
|
isFalsy: () => JSONSchema;
|
99
114
|
isUndefined: () => JSONSchema;
|
100
115
|
inArray: (values: string[]) => JSONSchema;
|
116
|
+
isValidEnglishName: () => JSONSchema;
|
117
|
+
/**
|
118
|
+
* Checks if the field value matches a given regular expression pattern.
|
119
|
+
* @param pattern - The regular expression pattern to match the field value against.
|
120
|
+
* @returns A JSONSchema conditional that validates the field value against the pattern.
|
121
|
+
*/
|
122
|
+
matches: (pattern: string) => JSONSchema;
|
123
|
+
isBetween: (min: number, max: number) => JSONSchema;
|
101
124
|
};
|
102
125
|
export {};
|
103
126
|
//# sourceMappingURL=conditionals.d.ts.map
|
@@ -6,6 +6,7 @@ import { TranslationConfig } from '../events/TranslationConfig';
|
|
6
6
|
export declare function validate(schema: JSONSchema, data: ConditionalParameters): boolean;
|
7
7
|
export declare function isFieldVisible(field: FieldConfig, form: ActionUpdate | EventState): boolean;
|
8
8
|
export declare function isFieldEnabled(field: FieldConfig, form: ActionUpdate | EventState): boolean;
|
9
|
+
export declare function isFieldDisplayedOnReview(field: FieldConfig, form: ActionUpdate | EventState): boolean;
|
9
10
|
export declare const errorMessages: {
|
10
11
|
hiddenField: {
|
11
12
|
id: string;
|
@@ -43,23 +44,6 @@ export type CustomZodToIntlErrorMap = {
|
|
43
44
|
message: TranslationConfig;
|
44
45
|
};
|
45
46
|
};
|
46
|
-
/**
|
47
|
-
* Checks if a field has validation errors based on its type and custom conditionals.
|
48
|
-
*
|
49
|
-
* @returns an array of error messages for the field
|
50
|
-
*/
|
51
|
-
export declare function getFieldValidationErrors({ field, values }: {
|
52
|
-
field: FieldConfig;
|
53
|
-
values: ActionUpdate;
|
54
|
-
}): {
|
55
|
-
errors: {
|
56
|
-
message: {
|
57
|
-
id: string;
|
58
|
-
defaultMessage: string;
|
59
|
-
description: string;
|
60
|
-
};
|
61
|
-
}[];
|
62
|
-
};
|
63
47
|
/**
|
64
48
|
* Validates primitive fields defined by the FieldConfig type.
|
65
49
|
* e.g. email is proper format, date is a valid date, etc.
|
@@ -71,4 +55,17 @@ export declare function validateFieldInput({ field, value }: {
|
|
71
55
|
}): {
|
72
56
|
message: TranslationConfig;
|
73
57
|
}[];
|
58
|
+
/**
|
59
|
+
* Gets applicable validation errors based on its type and custom validators.
|
60
|
+
*
|
61
|
+
* @returns an array of error messages for the field
|
62
|
+
*/
|
63
|
+
export declare function getFieldValidationErrors({ field, values }: {
|
64
|
+
field: FieldConfig;
|
65
|
+
values: ActionUpdate;
|
66
|
+
}): {
|
67
|
+
errors: {
|
68
|
+
message: TranslationConfig;
|
69
|
+
}[];
|
70
|
+
};
|
74
71
|
//# sourceMappingURL=validate.d.ts.map
|