@opencrvs/toolkit 1.8.0-rc.fc43738 → 1.8.0-rc.fca3e39
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 +7518 -2532
- package/dist/commons/conditionals/conditionals.d.ts +3 -2
- package/dist/commons/conditionals/validate-address.test.d.ts +2 -0
- package/dist/commons/conditionals/validate.d.ts +33 -6
- package/dist/commons/conditionals/validate.test.d.ts +2 -0
- package/dist/commons/events/ActionConfig.d.ts +6 -24
- package/dist/commons/events/ActionDocument.d.ts +3196 -1113
- package/dist/commons/events/ActionInput.d.ts +4796 -1760
- package/dist/commons/events/ActionType.d.ts +6 -1
- package/dist/commons/events/CompositeFieldValue.d.ts +414 -0
- package/dist/commons/events/Draft.d.ts +440 -155
- package/dist/commons/events/EventConfig.d.ts +4 -28
- package/dist/commons/events/EventDocument.d.ts +3845 -1325
- package/dist/commons/events/EventIndex.d.ts +3 -3
- package/dist/commons/events/EventMetadata.d.ts +3 -3
- package/dist/commons/events/FieldConfig.d.ts +64 -1
- package/dist/commons/events/FieldType.d.ts +4 -0
- package/dist/commons/events/FieldTypeMapping.d.ts +252 -38
- package/dist/commons/events/FieldValue.d.ts +133 -64
- package/dist/commons/events/TemplateConfig.d.ts +38 -0
- package/dist/commons/events/defineConfig.d.ts +1 -7
- package/dist/commons/events/index.d.ts +2 -0
- package/dist/commons/events/test.utils.d.ts +219 -69
- package/dist/commons/events/utils.d.ts +123 -3
- package/dist/conditionals/index.js +17 -0
- package/dist/events/index.js +780 -487
- package/package.json +1 -1
@@ -1,9 +1,26 @@
|
|
1
1
|
import { z } from 'zod';
|
2
|
+
import { AddressFieldValue, AddressFieldUpdateValue, FileFieldValue, FileFieldWithOptionValue } from './CompositeFieldValue';
|
3
|
+
/**
|
4
|
+
* FieldValues defined in this file are primitive field values.
|
5
|
+
* FieldValues defined in CompositeFieldValue.ts are composed of multiple primitive field values (Address, File etc).
|
6
|
+
*
|
7
|
+
* FieldValue is a union of primitive and composite field values.
|
8
|
+
* FieldValue can never be null.
|
9
|
+
*
|
10
|
+
* FieldUpdateValue accepts null values for primitive field values when they are optional.
|
11
|
+
* API is build assuming partial (PATCH) updates. In order to edit and remove optional value, we need to accept null values.
|
12
|
+
* Omitting a field value in partial updates leaves it untouched.
|
13
|
+
*
|
14
|
+
*/
|
2
15
|
export declare const TextValue: z.ZodString;
|
3
16
|
export declare const RequiredTextValue: z.ZodString;
|
4
17
|
export declare const DateValue: z.ZodString;
|
5
18
|
export declare const EmailValue: z.ZodString;
|
6
|
-
export declare const
|
19
|
+
export declare const CheckboxFieldValue: z.ZodBoolean;
|
20
|
+
export type CheckboxFieldValue = z.infer<typeof CheckboxFieldValue>;
|
21
|
+
export declare const NumberFieldValue: z.ZodNumber;
|
22
|
+
export type NumberFieldValue = z.infer<typeof NumberFieldValue>;
|
23
|
+
export declare const FieldValue: z.ZodUnion<[z.ZodString, z.ZodString, z.ZodBoolean, z.ZodNumber, z.ZodObject<{
|
7
24
|
filename: z.ZodString;
|
8
25
|
originalFilename: z.ZodString;
|
9
26
|
type: z.ZodString;
|
@@ -15,10 +32,24 @@ export declare const FileFieldValue: z.ZodObject<{
|
|
15
32
|
type: string;
|
16
33
|
filename: string;
|
17
34
|
originalFilename: string;
|
18
|
-
}
|
19
|
-
|
20
|
-
|
35
|
+
}>, z.ZodArray<z.ZodObject<{
|
36
|
+
filename: z.ZodString;
|
37
|
+
originalFilename: z.ZodString;
|
38
|
+
type: z.ZodString;
|
39
|
+
option: z.ZodString;
|
40
|
+
}, "strip", z.ZodTypeAny, {
|
41
|
+
type: string;
|
42
|
+
option: string;
|
43
|
+
filename: string;
|
44
|
+
originalFilename: string;
|
45
|
+
}, {
|
46
|
+
type: string;
|
47
|
+
option: string;
|
48
|
+
filename: string;
|
49
|
+
originalFilename: string;
|
50
|
+
}>, "many">, z.ZodObject<z.objectUtil.extendShape<{
|
21
51
|
country: z.ZodString;
|
52
|
+
addressType: z.ZodLiteral<"DOMESTIC">;
|
22
53
|
province: z.ZodString;
|
23
54
|
district: z.ZodString;
|
24
55
|
}, {
|
@@ -31,6 +62,7 @@ export declare const AddressFieldValue: z.ZodDiscriminatedUnion<"urbanOrRural",
|
|
31
62
|
}>, "strip", z.ZodTypeAny, {
|
32
63
|
country: string;
|
33
64
|
district: string;
|
65
|
+
addressType: "DOMESTIC";
|
34
66
|
province: string;
|
35
67
|
urbanOrRural: "URBAN";
|
36
68
|
number?: string | undefined;
|
@@ -41,6 +73,7 @@ export declare const AddressFieldValue: z.ZodDiscriminatedUnion<"urbanOrRural",
|
|
41
73
|
}, {
|
42
74
|
country: string;
|
43
75
|
district: string;
|
76
|
+
addressType: "DOMESTIC";
|
44
77
|
province: string;
|
45
78
|
urbanOrRural: "URBAN";
|
46
79
|
number?: string | undefined;
|
@@ -50,6 +83,7 @@ export declare const AddressFieldValue: z.ZodDiscriminatedUnion<"urbanOrRural",
|
|
50
83
|
zipCode?: string | undefined;
|
51
84
|
}>, z.ZodObject<z.objectUtil.extendShape<{
|
52
85
|
country: z.ZodString;
|
86
|
+
addressType: z.ZodLiteral<"DOMESTIC">;
|
53
87
|
province: z.ZodString;
|
54
88
|
district: z.ZodString;
|
55
89
|
}, {
|
@@ -58,56 +92,50 @@ export declare const AddressFieldValue: z.ZodDiscriminatedUnion<"urbanOrRural",
|
|
58
92
|
}>, "strip", z.ZodTypeAny, {
|
59
93
|
country: string;
|
60
94
|
district: string;
|
95
|
+
addressType: "DOMESTIC";
|
61
96
|
province: string;
|
62
97
|
urbanOrRural: "RURAL";
|
63
98
|
village?: string | undefined;
|
64
99
|
}, {
|
65
100
|
country: string;
|
66
101
|
district: string;
|
102
|
+
addressType: "DOMESTIC";
|
67
103
|
province: string;
|
68
104
|
urbanOrRural: "RURAL";
|
69
105
|
village?: string | undefined;
|
70
|
-
}
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
filename: string;
|
81
|
-
originalFilename: string;
|
82
|
-
}, {
|
83
|
-
type: string;
|
84
|
-
option: string;
|
85
|
-
filename: string;
|
86
|
-
originalFilename: string;
|
87
|
-
}>;
|
88
|
-
export type FileFieldValueWithOption = z.infer<typeof FileFieldValueWithOption>;
|
89
|
-
export declare const FileFieldWithOptionValue: z.ZodArray<z.ZodObject<{
|
90
|
-
filename: z.ZodString;
|
91
|
-
originalFilename: z.ZodString;
|
92
|
-
type: z.ZodString;
|
93
|
-
option: z.ZodString;
|
106
|
+
}>, z.ZodObject<{
|
107
|
+
country: z.ZodString;
|
108
|
+
addressType: z.ZodLiteral<"INTERNATIONAL">;
|
109
|
+
state: z.ZodString;
|
110
|
+
district2: z.ZodString;
|
111
|
+
cityOrTown: z.ZodOptional<z.ZodString>;
|
112
|
+
addressLine1: z.ZodOptional<z.ZodString>;
|
113
|
+
addressLine2: z.ZodOptional<z.ZodString>;
|
114
|
+
addressLine3: z.ZodOptional<z.ZodString>;
|
115
|
+
postcodeOrZip: z.ZodOptional<z.ZodString>;
|
94
116
|
}, "strip", z.ZodTypeAny, {
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
117
|
+
country: string;
|
118
|
+
state: string;
|
119
|
+
addressType: "INTERNATIONAL";
|
120
|
+
district2: string;
|
121
|
+
cityOrTown?: string | undefined;
|
122
|
+
addressLine1?: string | undefined;
|
123
|
+
addressLine2?: string | undefined;
|
124
|
+
addressLine3?: string | undefined;
|
125
|
+
postcodeOrZip?: string | undefined;
|
99
126
|
}, {
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
export
|
127
|
+
country: string;
|
128
|
+
state: string;
|
129
|
+
addressType: "INTERNATIONAL";
|
130
|
+
district2: string;
|
131
|
+
cityOrTown?: string | undefined;
|
132
|
+
addressLine1?: string | undefined;
|
133
|
+
addressLine2?: string | undefined;
|
134
|
+
addressLine3?: string | undefined;
|
135
|
+
postcodeOrZip?: string | undefined;
|
136
|
+
}>]>;
|
137
|
+
export type FieldValue = z.infer<typeof FieldValue>;
|
138
|
+
export declare const FieldUpdateValue: z.ZodUnion<[z.ZodString, z.ZodString, z.ZodBoolean, z.ZodNumber, z.ZodObject<{
|
111
139
|
filename: z.ZodString;
|
112
140
|
originalFilename: z.ZodString;
|
113
141
|
type: z.ZodString;
|
@@ -134,61 +162,102 @@ export declare const FieldValue: z.ZodUnion<[z.ZodString, z.ZodString, z.ZodObje
|
|
134
162
|
option: string;
|
135
163
|
filename: string;
|
136
164
|
originalFilename: string;
|
137
|
-
}>, "many">, z.
|
165
|
+
}>, "many">, z.ZodObject<z.objectUtil.extendShape<{
|
138
166
|
country: z.ZodString;
|
167
|
+
addressType: z.ZodLiteral<"DOMESTIC">;
|
139
168
|
province: z.ZodString;
|
140
169
|
district: z.ZodString;
|
141
170
|
}, {
|
142
171
|
urbanOrRural: z.ZodLiteral<"URBAN">;
|
143
|
-
town: z.ZodOptional<z.ZodString
|
144
|
-
residentialArea: z.ZodOptional<z.ZodString
|
145
|
-
street: z.ZodOptional<z.ZodString
|
146
|
-
number: z.ZodOptional<z.ZodString
|
147
|
-
zipCode: z.ZodOptional<z.ZodString
|
172
|
+
town: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
173
|
+
residentialArea: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
174
|
+
street: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
175
|
+
number: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
176
|
+
zipCode: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
148
177
|
}>, "strip", z.ZodTypeAny, {
|
149
178
|
country: string;
|
150
179
|
district: string;
|
180
|
+
addressType: "DOMESTIC";
|
151
181
|
province: string;
|
152
182
|
urbanOrRural: "URBAN";
|
153
|
-
number?: string | undefined;
|
154
|
-
town?: string | undefined;
|
155
|
-
residentialArea?: string | undefined;
|
156
|
-
street?: string | undefined;
|
157
|
-
zipCode?: string | undefined;
|
183
|
+
number?: string | null | undefined;
|
184
|
+
town?: string | null | undefined;
|
185
|
+
residentialArea?: string | null | undefined;
|
186
|
+
street?: string | null | undefined;
|
187
|
+
zipCode?: string | null | undefined;
|
158
188
|
}, {
|
159
189
|
country: string;
|
160
190
|
district: string;
|
191
|
+
addressType: "DOMESTIC";
|
161
192
|
province: string;
|
162
193
|
urbanOrRural: "URBAN";
|
163
|
-
number?: string | undefined;
|
164
|
-
town?: string | undefined;
|
165
|
-
residentialArea?: string | undefined;
|
166
|
-
street?: string | undefined;
|
167
|
-
zipCode?: string | undefined;
|
194
|
+
number?: string | null | undefined;
|
195
|
+
town?: string | null | undefined;
|
196
|
+
residentialArea?: string | null | undefined;
|
197
|
+
street?: string | null | undefined;
|
198
|
+
zipCode?: string | null | undefined;
|
168
199
|
}>, z.ZodObject<z.objectUtil.extendShape<{
|
169
200
|
country: z.ZodString;
|
201
|
+
addressType: z.ZodLiteral<"DOMESTIC">;
|
170
202
|
province: z.ZodString;
|
171
203
|
district: z.ZodString;
|
172
204
|
}, {
|
173
205
|
urbanOrRural: z.ZodLiteral<"RURAL">;
|
174
|
-
village: z.ZodOptional<z.ZodString
|
206
|
+
village: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
175
207
|
}>, "strip", z.ZodTypeAny, {
|
176
208
|
country: string;
|
177
209
|
district: string;
|
210
|
+
addressType: "DOMESTIC";
|
178
211
|
province: string;
|
179
212
|
urbanOrRural: "RURAL";
|
180
|
-
village?: string | undefined;
|
213
|
+
village?: string | null | undefined;
|
181
214
|
}, {
|
182
215
|
country: string;
|
183
216
|
district: string;
|
217
|
+
addressType: "DOMESTIC";
|
184
218
|
province: string;
|
185
219
|
urbanOrRural: "RURAL";
|
186
|
-
village?: string | undefined;
|
220
|
+
village?: string | null | undefined;
|
221
|
+
}>, z.ZodObject<{
|
222
|
+
country: z.ZodString;
|
223
|
+
addressType: z.ZodLiteral<"INTERNATIONAL">;
|
224
|
+
state: z.ZodString;
|
225
|
+
district2: z.ZodString;
|
226
|
+
cityOrTown: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
227
|
+
addressLine1: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
228
|
+
addressLine2: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
229
|
+
addressLine3: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
230
|
+
postcodeOrZip: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
231
|
+
}, "strip", z.ZodTypeAny, {
|
232
|
+
country: string;
|
233
|
+
state: string;
|
234
|
+
addressType: "INTERNATIONAL";
|
235
|
+
district2: string;
|
236
|
+
cityOrTown?: string | null | undefined;
|
237
|
+
addressLine1?: string | null | undefined;
|
238
|
+
addressLine2?: string | null | undefined;
|
239
|
+
addressLine3?: string | null | undefined;
|
240
|
+
postcodeOrZip?: string | null | undefined;
|
241
|
+
}, {
|
242
|
+
country: string;
|
243
|
+
state: string;
|
244
|
+
addressType: "INTERNATIONAL";
|
245
|
+
district2: string;
|
246
|
+
cityOrTown?: string | null | undefined;
|
247
|
+
addressLine1?: string | null | undefined;
|
248
|
+
addressLine2?: string | null | undefined;
|
249
|
+
addressLine3?: string | null | undefined;
|
250
|
+
postcodeOrZip?: string | null | undefined;
|
187
251
|
}>]>;
|
188
|
-
export type
|
252
|
+
export type FieldUpdateValue = z.infer<typeof FieldUpdateValue>;
|
189
253
|
/**
|
190
254
|
* NOTE: This is an exception. We need schema as a type in order to generate schema dynamically.
|
191
255
|
* */
|
192
256
|
export type FieldValueSchema = typeof FileFieldValue | typeof FileFieldWithOptionValue | typeof CheckboxFieldValue | typeof AddressFieldValue | typeof NumberFieldValue | z.ZodString | z.ZodBoolean;
|
193
|
-
|
257
|
+
/**
|
258
|
+
* NOTE: This is an exception. We need schema as a type in order to generate schema dynamically.
|
259
|
+
*
|
260
|
+
* FieldValueInputSchema uses Input types which have set optional values as nullish
|
261
|
+
* */
|
262
|
+
export type FieldUpdateValueSchema = typeof FileFieldValue | typeof FileFieldWithOptionValue | typeof CheckboxFieldValue | typeof AddressFieldUpdateValue | typeof NumberFieldValue | z.ZodString | z.ZodBoolean;
|
194
263
|
//# sourceMappingURL=FieldValue.d.ts.map
|
@@ -0,0 +1,38 @@
|
|
1
|
+
/**
|
2
|
+
* TemplateConfig defines configuration rules for system-based variables (e.g. $user.province).
|
3
|
+
* They are currently used for providing default values in FieldConfig.
|
4
|
+
*/
|
5
|
+
import { FieldValue } from './FieldValue';
|
6
|
+
/**
|
7
|
+
* Available system variables for configuration.
|
8
|
+
*/
|
9
|
+
export interface MetaFields {
|
10
|
+
$user: {
|
11
|
+
province: string;
|
12
|
+
district: string;
|
13
|
+
};
|
14
|
+
}
|
15
|
+
/**
|
16
|
+
* Recursively flatten the keys of an object. Used to limit types when configuring default values in country config.
|
17
|
+
* @example
|
18
|
+
* type Test = FlattenedKeyStrings<{ a: { b: string, c: { d: string } } }>
|
19
|
+
* // 'a.b' | 'a.c.d' but not 'a' or 'a.c'
|
20
|
+
*/
|
21
|
+
type FlattenedKeyStrings<T, Prefix extends string = ''> = {
|
22
|
+
[K in keyof T]: T[K] extends Record<string, any> ? FlattenedKeyStrings<T[K], `${Prefix}${K & string}.`> : `${Prefix}${K & string}`;
|
23
|
+
}[keyof T];
|
24
|
+
export type FlattenedMetaFields = FlattenedKeyStrings<MetaFields>;
|
25
|
+
/**
|
26
|
+
* Default value for a field when configuring a form.
|
27
|
+
*/
|
28
|
+
export type FieldConfigDefaultValue = FieldValue | FlattenedMetaFields | Record<string, FlattenedMetaFields | FieldValue>;
|
29
|
+
export declare function isTemplateVariable(value: FieldConfigDefaultValue): value is FlattenedMetaFields;
|
30
|
+
export declare function isFieldValue(value: FieldConfigDefaultValue): value is FieldValue;
|
31
|
+
/**
|
32
|
+
* Checks if given value is valid for a field, and known template variables are already resolved.
|
33
|
+
* @todo: Extend functionality to arbitrary depth objects. Currently only checks first level since our compoosite fields are only 1 level deep.
|
34
|
+
*/
|
35
|
+
export declare function isFieldValueWithoutTemplates(value: FieldConfigDefaultValue): value is FieldValue;
|
36
|
+
export declare function isFieldConfigDefaultValue(value: any): value is FieldConfigDefaultValue;
|
37
|
+
export {};
|
38
|
+
//# sourceMappingURL=TemplateConfig.d.ts.map
|
@@ -63,7 +63,6 @@ export declare const defineConfig: (config: EventConfigInput) => {
|
|
63
63
|
draft?: boolean | undefined;
|
64
64
|
} | {
|
65
65
|
type: "REJECT";
|
66
|
-
comment: string;
|
67
66
|
conditionals: ({
|
68
67
|
type: "SHOW";
|
69
68
|
conditional: import(".").JSONSchema;
|
@@ -89,11 +88,9 @@ export declare const defineConfig: (config: EventConfigInput) => {
|
|
89
88
|
fields: import("./FieldConfig").Inferred[];
|
90
89
|
};
|
91
90
|
}[];
|
92
|
-
isDuplicate: boolean;
|
93
91
|
draft?: boolean | undefined;
|
94
92
|
} | {
|
95
93
|
type: "MARKED_AS_DUPLICATE";
|
96
|
-
comment: string;
|
97
94
|
conditionals: ({
|
98
95
|
type: "SHOW";
|
99
96
|
conditional: import(".").JSONSchema;
|
@@ -119,11 +116,9 @@ export declare const defineConfig: (config: EventConfigInput) => {
|
|
119
116
|
fields: import("./FieldConfig").Inferred[];
|
120
117
|
};
|
121
118
|
}[];
|
122
|
-
duplicates: string[];
|
123
119
|
draft?: boolean | undefined;
|
124
120
|
} | {
|
125
|
-
type: "
|
126
|
-
comment: string;
|
121
|
+
type: "ARCHIVE";
|
127
122
|
conditionals: ({
|
128
123
|
type: "SHOW";
|
129
124
|
conditional: import(".").JSONSchema;
|
@@ -149,7 +144,6 @@ export declare const defineConfig: (config: EventConfigInput) => {
|
|
149
144
|
fields: import("./FieldConfig").Inferred[];
|
150
145
|
};
|
151
146
|
}[];
|
152
|
-
isDuplicate: boolean;
|
153
147
|
draft?: boolean | undefined;
|
154
148
|
} | {
|
155
149
|
type: "REGISTER";
|
@@ -15,6 +15,7 @@ export * from './ActionDocument';
|
|
15
15
|
export * from './EventIndex';
|
16
16
|
export * from './TranslationConfig';
|
17
17
|
export * from './FieldValue';
|
18
|
+
export * from './CompositeFieldValue';
|
18
19
|
export * from './state';
|
19
20
|
export * from './utils';
|
20
21
|
export * from './defineConfig';
|
@@ -27,6 +28,7 @@ export * from './FieldTypeMapping';
|
|
27
28
|
export * from './Conditional';
|
28
29
|
export * from './AdvancedSearchConfig';
|
29
30
|
export * from './test.utils';
|
31
|
+
export * from './TemplateConfig';
|
30
32
|
export * from '../conditionals/conditionals';
|
31
33
|
export * from '../conditionals/validate';
|
32
34
|
//# sourceMappingURL=index.d.ts.map
|