@opencrvs/toolkit 1.8.0-rc.f876361 → 1.8.0-rc.f8e4107
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 +3159 -158
- package/dist/commons/conditionals/conditionals.d.ts +80 -8
- package/dist/commons/conditionals/validate.d.ts +14 -17
- package/dist/commons/events/ActionDocument.d.ts +212 -101
- package/dist/commons/events/ActionInput.d.ts +1109 -214
- package/dist/commons/events/ActionType.d.ts +5 -3
- package/dist/commons/events/AdvancedSearchConfig.d.ts +107 -14
- package/dist/commons/events/Conditional.d.ts +21 -5
- package/dist/commons/events/Draft.d.ts +24 -12
- package/dist/commons/events/EventConfig.d.ts +132 -66
- package/dist/commons/events/EventDocument.d.ts +161 -76
- package/dist/commons/events/EventIndex.d.ts +746 -4
- package/dist/commons/events/EventMetadata.d.ts +6 -3
- package/dist/commons/events/FieldConfig.d.ts +208 -70
- package/dist/commons/events/PageConfig.d.ts +0 -24
- package/dist/commons/events/TemplateConfig.d.ts +5 -5
- package/dist/commons/events/defineConfig.d.ts +15 -11
- package/dist/commons/events/test.utils.d.ts +20 -112
- package/dist/commons/events/utils.d.ts +60 -54
- package/dist/commons/events/utils.test.d.ts +2 -0
- package/dist/conditionals/index.js +180 -151
- package/dist/events/index.js +1325 -1103
- package/package.json +1 -1
@@ -3,11 +3,14 @@ import { EventState } from '../events/ActionDocument';
|
|
3
3
|
import { ITokenPayload as TokenPayload, Scope } from '../authentication';
|
4
4
|
import { ActionType } from '../events/ActionType';
|
5
5
|
import { PartialSchema as AjvJSONSchemaType } from 'ajv/dist/types/json-schema';
|
6
|
+
import { SelectOption } from '../events/FieldConfig';
|
7
|
+
import { MetadataField } from '../utils';
|
6
8
|
/** @knipignore */
|
7
9
|
export type JSONSchema = {
|
8
10
|
readonly __nominal__type: 'JSONSchema';
|
9
11
|
};
|
10
12
|
export declare function defineConditional(schema: any): JSONSchema;
|
13
|
+
export declare function defineFormConditional(schema: Record<string, unknown>): JSONSchema;
|
11
14
|
export type UserConditionalParameters = {
|
12
15
|
$now: string;
|
13
16
|
$user: TokenPayload;
|
@@ -47,6 +50,12 @@ export declare function or(...conditions: AjvJSONSchema[]): JSONSchema;
|
|
47
50
|
* @example not(field('foo').isEqualTo('bar'))
|
48
51
|
*/
|
49
52
|
export declare function not(condition: AjvJSONSchema): JSONSchema;
|
53
|
+
/**
|
54
|
+
* Returns an JSON Schema object, which is treated as always invalid.
|
55
|
+
*
|
56
|
+
* @returns {JSONSchema} An schema object that always evaluates to false.
|
57
|
+
*/
|
58
|
+
export declare function never(): JSONSchema;
|
50
59
|
/**
|
51
60
|
*
|
52
61
|
* Generate conditional rules for user.
|
@@ -61,6 +70,10 @@ export declare const user: {
|
|
61
70
|
export declare const event: {
|
62
71
|
hasAction: (action: ActionType) => JSONSchema;
|
63
72
|
};
|
73
|
+
type FieldReference = {
|
74
|
+
_fieldId: string;
|
75
|
+
[key: string]: unknown;
|
76
|
+
};
|
64
77
|
/**
|
65
78
|
* Generate conditional rules for a form field.
|
66
79
|
*
|
@@ -73,13 +86,13 @@ export declare function field(fieldId: string): {
|
|
73
86
|
/**
|
74
87
|
* @private Internal property used for field reference tracking.
|
75
88
|
*/
|
76
|
-
|
89
|
+
_fieldId: string;
|
77
90
|
isAfter: () => {
|
78
91
|
days: (days: number) => {
|
79
92
|
inPast: () => JSONSchema;
|
80
93
|
inFuture: () => JSONSchema;
|
81
94
|
};
|
82
|
-
date: (date: string) => JSONSchema;
|
95
|
+
date: (date: string | FieldReference) => JSONSchema;
|
83
96
|
now: () => JSONSchema;
|
84
97
|
};
|
85
98
|
isBefore: () => {
|
@@ -87,13 +100,10 @@ export declare function field(fieldId: string): {
|
|
87
100
|
inPast: () => JSONSchema;
|
88
101
|
inFuture: () => JSONSchema;
|
89
102
|
};
|
90
|
-
date: (date: string) => JSONSchema;
|
103
|
+
date: (date: string | FieldReference) => JSONSchema;
|
91
104
|
now: () => JSONSchema;
|
92
105
|
};
|
93
|
-
isEqualTo: (value: string | boolean |
|
94
|
-
_returning: string;
|
95
|
-
[key: string]: unknown;
|
96
|
-
}) => JSONSchema;
|
106
|
+
isEqualTo: (value: string | boolean | FieldReference) => JSONSchema;
|
97
107
|
/**
|
98
108
|
* Use case: Some fields are rendered when selection is not made, or boolean false is explicitly selected.
|
99
109
|
* @example field('recommender.none').isFalsy() vs not(field('recommender.none').isEqualTo(true))
|
@@ -106,7 +116,6 @@ export declare function field(fieldId: string): {
|
|
106
116
|
isUndefined: () => JSONSchema;
|
107
117
|
inArray: (values: string[]) => JSONSchema;
|
108
118
|
isValidEnglishName: () => JSONSchema;
|
109
|
-
isValidNationalId: () => JSONSchema;
|
110
119
|
/**
|
111
120
|
* Checks if the field value matches a given regular expression pattern.
|
112
121
|
* @param pattern - The regular expression pattern to match the field value against.
|
@@ -114,6 +123,69 @@ export declare function field(fieldId: string): {
|
|
114
123
|
*/
|
115
124
|
matches: (pattern: string) => JSONSchema;
|
116
125
|
isBetween: (min: number, max: number) => JSONSchema;
|
126
|
+
/**
|
127
|
+
* Creates a range configuration for the specified field.
|
128
|
+
*
|
129
|
+
* @returns An object containing the field ID and a configuration object with a type of 'RANGE'.
|
130
|
+
*
|
131
|
+
* @example field('age').range()
|
132
|
+
* // {
|
133
|
+
* // fieldId: 'age',
|
134
|
+
* // config: { type: 'RANGE' }
|
135
|
+
* // }
|
136
|
+
*/
|
137
|
+
range: () => {
|
138
|
+
fieldId: string;
|
139
|
+
config: {
|
140
|
+
type: "RANGE";
|
141
|
+
};
|
142
|
+
};
|
143
|
+
/**
|
144
|
+
* Creates a configuration for exact matching of the specified field.
|
145
|
+
* @returns An object containing the field ID and a configuration object with a type of 'EXACT'.
|
146
|
+
* @example field('dob').exact()
|
147
|
+
* // {
|
148
|
+
* // fieldId: 'dob',
|
149
|
+
* // config: { type: 'EXACT' }
|
150
|
+
* // }
|
151
|
+
*/
|
152
|
+
exact: () => {
|
153
|
+
fieldId: string;
|
154
|
+
config: {
|
155
|
+
type: "EXACT";
|
156
|
+
};
|
157
|
+
};
|
158
|
+
/**
|
159
|
+
* Creates a configuration for fuzzy matching of the specified field.
|
160
|
+
* @returns An object containing the field ID and a configuration object with a type of 'EXACT'.
|
161
|
+
* @example field('name').fuzzy()
|
162
|
+
* // {
|
163
|
+
* // fieldId: 'name',
|
164
|
+
* // config: { type: 'FUZZY' }
|
165
|
+
* // }
|
166
|
+
*/
|
167
|
+
fuzzy: () => {
|
168
|
+
fieldId: string;
|
169
|
+
config: {
|
170
|
+
type: "FUZZY";
|
171
|
+
};
|
172
|
+
};
|
173
|
+
};
|
174
|
+
/**
|
175
|
+
* @param fieldId - The field ID condition is applied to.
|
176
|
+
* @param options - The options for the select field.
|
177
|
+
* @returns An object containing the configuration for the searching the metadata fields of an event.
|
178
|
+
* @example eventField('status', [{ label: 'Option 1', value: '1' }])
|
179
|
+
*/
|
180
|
+
export declare function eventField(fieldId: MetadataField, options?: SelectOption[]): {
|
181
|
+
fieldId: "status" | "trackingId";
|
182
|
+
options: {
|
183
|
+
value: string;
|
184
|
+
label: import("..").TranslationConfig;
|
185
|
+
}[] | undefined;
|
186
|
+
config: {
|
187
|
+
type: "EXACT";
|
188
|
+
};
|
117
189
|
};
|
118
190
|
export {};
|
119
191
|
//# 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
|