@opencrvs/toolkit 1.8.0-rc.ffe8c17 → 1.8.1-rc.25f3d5c
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 +9379 -11054
- package/dist/commons/conditionals/conditionals.d.ts +31 -12
- package/dist/commons/conditionals/validate-address.test.d.ts +2 -0
- package/dist/commons/conditionals/validate.d.ts +23 -17
- package/dist/commons/events/ActionConfig.d.ts +118678 -3282
- package/dist/commons/events/ActionDocument.d.ts +14206 -817
- package/dist/commons/events/ActionInput.d.ts +8680 -1103
- package/dist/commons/events/ActionType.d.ts +35 -11
- package/dist/commons/events/AdvancedSearchConfig.d.ts +1282 -22
- package/dist/commons/events/CompositeFieldValue.d.ts +192 -11
- package/dist/commons/events/Conditional.d.ts +21 -5
- package/dist/commons/events/Constants.d.ts +3 -0
- package/dist/commons/events/CountryConfigQueryInput.d.ts +4132 -0
- package/dist/commons/events/CreatedAtLocation.d.ts +2 -0
- package/dist/commons/events/Draft.d.ts +652 -114
- package/dist/commons/events/EventConfig.d.ts +53975 -3192
- package/dist/commons/events/EventConfigInput.d.ts +6 -3
- package/dist/commons/events/EventDocument.d.ts +6216 -997
- package/dist/commons/events/EventIndex.d.ts +2228 -26
- package/dist/commons/events/EventMetadata.d.ts +347 -44
- package/dist/commons/events/FieldConfig.d.ts +6984 -1209
- package/dist/commons/events/FieldType.d.ts +8 -3
- package/dist/commons/events/FieldTypeMapping.d.ts +253 -268
- package/dist/commons/events/FieldValue.d.ts +159 -93
- package/dist/commons/events/FormConfig.d.ts +55832 -336
- package/dist/commons/events/PageConfig.d.ts +13951 -0
- package/dist/commons/events/SummaryConfig.d.ts +93 -42
- package/dist/commons/events/TemplateConfig.d.ts +5 -5
- package/dist/commons/events/User.d.ts +34 -2
- package/dist/commons/events/WorkqueueColumnConfig.d.ts +53 -0
- package/dist/commons/events/WorkqueueConfig.d.ts +8116 -20
- package/dist/commons/events/defineConfig.d.ts +8535 -460
- package/dist/commons/events/event.d.ts +46 -0
- package/dist/commons/events/field.d.ts +94 -0
- package/dist/commons/events/index.d.ts +10 -1
- package/dist/commons/events/scopes.d.ts +45 -0
- package/dist/commons/events/serializer.d.ts +2 -0
- package/dist/commons/events/test.utils.d.ts +280 -237
- package/dist/commons/events/transactions.d.ts +1 -1
- package/dist/commons/events/utils.d.ts +15490 -168
- package/dist/commons/events/utils.test.d.ts +2 -0
- package/dist/commons/events/workqueueDefaultColumns.d.ts +3 -0
- package/dist/conditionals/index.js +210 -115
- package/dist/events/index.js +5244 -1873
- package/dist/scopes/index.d.ts +247 -1
- package/dist/scopes/index.js +231 -1
- package/package.json +4 -3
@@ -1,13 +1,14 @@
|
|
1
1
|
import { EventDocument } from '../events/EventDocument';
|
2
2
|
import { EventState } from '../events/ActionDocument';
|
3
3
|
import { ITokenPayload as TokenPayload, Scope } from '../authentication';
|
4
|
-
import { ActionType } from '../events/ActionType';
|
5
4
|
import { PartialSchema as AjvJSONSchemaType } from 'ajv/dist/types/json-schema';
|
5
|
+
import { userSerializer } from '../events/serializers/user/serializer';
|
6
6
|
/** @knipignore */
|
7
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;
|
@@ -48,18 +49,20 @@ export declare function or(...conditions: AjvJSONSchema[]): JSONSchema;
|
|
48
49
|
*/
|
49
50
|
export declare function not(condition: AjvJSONSchema): JSONSchema;
|
50
51
|
/**
|
52
|
+
* Returns an JSON Schema object, which is treated as always invalid.
|
51
53
|
*
|
52
|
-
*
|
54
|
+
* @returns {JSONSchema} An schema object that always evaluates to false.
|
53
55
|
*/
|
54
|
-
export declare
|
55
|
-
hasScope: (scope: Scope) => JSONSchema;
|
56
|
-
};
|
56
|
+
export declare function never(): JSONSchema;
|
57
57
|
/**
|
58
58
|
*
|
59
|
-
* Generate conditional rules for
|
59
|
+
* Generate conditional rules for user.
|
60
60
|
*/
|
61
|
-
export declare const
|
62
|
-
|
61
|
+
export declare const user: typeof userSerializer & {
|
62
|
+
hasScope: (scope: Scope) => JSONSchema;
|
63
|
+
};
|
64
|
+
type FieldReference = {
|
65
|
+
$$field: string;
|
63
66
|
};
|
64
67
|
/**
|
65
68
|
* Generate conditional rules for a form field.
|
@@ -69,13 +72,17 @@ export declare const event: {
|
|
69
72
|
* and(field('foo').isEqualTo('bar'), field('baz').isUndefined())
|
70
73
|
*
|
71
74
|
*/
|
72
|
-
export declare function
|
75
|
+
export declare function createFieldConditionals(fieldId: string): {
|
76
|
+
/**
|
77
|
+
* @private Internal property used for field reference tracking.
|
78
|
+
*/
|
79
|
+
$$field: string;
|
73
80
|
isAfter: () => {
|
74
81
|
days: (days: number) => {
|
75
82
|
inPast: () => JSONSchema;
|
76
83
|
inFuture: () => JSONSchema;
|
77
84
|
};
|
78
|
-
date: (date: string) => JSONSchema;
|
85
|
+
date: (date: string | FieldReference) => JSONSchema;
|
79
86
|
now: () => JSONSchema;
|
80
87
|
};
|
81
88
|
isBefore: () => {
|
@@ -83,10 +90,10 @@ export declare function field(fieldId: string): {
|
|
83
90
|
inPast: () => JSONSchema;
|
84
91
|
inFuture: () => JSONSchema;
|
85
92
|
};
|
86
|
-
date: (date: string) => JSONSchema;
|
93
|
+
date: (date: string | FieldReference) => JSONSchema;
|
87
94
|
now: () => JSONSchema;
|
88
95
|
};
|
89
|
-
isEqualTo: (value: string | boolean) => JSONSchema;
|
96
|
+
isEqualTo: (value: string | boolean | FieldReference) => JSONSchema;
|
90
97
|
/**
|
91
98
|
* Use case: Some fields are rendered when selection is not made, or boolean false is explicitly selected.
|
92
99
|
* @example field('recommender.none').isFalsy() vs not(field('recommender.none').isEqualTo(true))
|
@@ -98,6 +105,18 @@ export declare function field(fieldId: string): {
|
|
98
105
|
isFalsy: () => JSONSchema;
|
99
106
|
isUndefined: () => JSONSchema;
|
100
107
|
inArray: (values: string[]) => JSONSchema;
|
108
|
+
isValidEnglishName: () => JSONSchema;
|
109
|
+
/**
|
110
|
+
* Checks if the field value matches a given regular expression pattern.
|
111
|
+
* @param pattern - The regular expression pattern to match the field value against.
|
112
|
+
* @returns A JSONSchema conditional that validates the field value against the pattern.
|
113
|
+
*/
|
114
|
+
matches: (pattern: string) => JSONSchema;
|
115
|
+
isBetween: (min: number, max: number) => JSONSchema;
|
116
|
+
getId: () => {
|
117
|
+
fieldId: string;
|
118
|
+
};
|
119
|
+
object: (options: Record<string, any>) => JSONSchema;
|
101
120
|
};
|
102
121
|
export {};
|
103
122
|
//# sourceMappingURL=conditionals.d.ts.map
|
@@ -3,9 +3,13 @@ import { EventState, ActionUpdate } from '../events/ActionDocument';
|
|
3
3
|
import { FieldConfig } from '../events/FieldConfig';
|
4
4
|
import { FieldUpdateValue } from '../events/FieldValue';
|
5
5
|
import { TranslationConfig } from '../events/TranslationConfig';
|
6
|
+
import { FieldConditional } from '../events/Conditional';
|
6
7
|
export declare function validate(schema: JSONSchema, data: ConditionalParameters): boolean;
|
8
|
+
export declare function isConditionMet(conditional: JSONSchema, values: Record<string, unknown>): boolean;
|
9
|
+
export declare function areConditionsMet(conditions: FieldConditional[], values: Record<string, unknown>): boolean;
|
7
10
|
export declare function isFieldVisible(field: FieldConfig, form: ActionUpdate | EventState): boolean;
|
8
11
|
export declare function isFieldEnabled(field: FieldConfig, form: ActionUpdate | EventState): boolean;
|
12
|
+
export declare function isFieldDisplayedOnReview(field: FieldConfig, form: ActionUpdate | EventState): boolean;
|
9
13
|
export declare const errorMessages: {
|
10
14
|
hiddenField: {
|
11
15
|
id: string;
|
@@ -32,6 +36,16 @@ export declare const errorMessages: {
|
|
32
36
|
description: string;
|
33
37
|
id: string;
|
34
38
|
};
|
39
|
+
unexpectedField: {
|
40
|
+
defaultMessage: string;
|
41
|
+
description: string;
|
42
|
+
id: string;
|
43
|
+
};
|
44
|
+
correctionNotAllowed: {
|
45
|
+
defaultMessage: string;
|
46
|
+
description: string;
|
47
|
+
id: string;
|
48
|
+
};
|
35
49
|
};
|
36
50
|
/**
|
37
51
|
* Custom error map for Zod to override the default error messages in intl-formik format.
|
@@ -43,23 +57,6 @@ export type CustomZodToIntlErrorMap = {
|
|
43
57
|
message: TranslationConfig;
|
44
58
|
};
|
45
59
|
};
|
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
60
|
/**
|
64
61
|
* Validates primitive fields defined by the FieldConfig type.
|
65
62
|
* e.g. email is proper format, date is a valid date, etc.
|
@@ -71,4 +68,13 @@ export declare function validateFieldInput({ field, value }: {
|
|
71
68
|
}): {
|
72
69
|
message: TranslationConfig;
|
73
70
|
}[];
|
71
|
+
export declare function runFieldValidations({ field, values }: {
|
72
|
+
field: FieldConfig;
|
73
|
+
values: ActionUpdate;
|
74
|
+
}): {
|
75
|
+
errors: {
|
76
|
+
message: TranslationConfig;
|
77
|
+
}[];
|
78
|
+
};
|
79
|
+
export declare function getValidatorsForField(fieldId: FieldConfig['id'], validations: NonNullable<FieldConfig['validation']>): NonNullable<FieldConfig['validation']>;
|
74
80
|
//# sourceMappingURL=validate.d.ts.map
|