@opencrvs/toolkit 1.8.0-rc.feaeeb7 → 1.8.0-rc.fef85f2

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.
Files changed (36) hide show
  1. package/README.md +1 -1
  2. package/dist/commons/api/router.d.ts +6711 -9366
  3. package/dist/commons/conditionals/conditionals.d.ts +26 -3
  4. package/dist/commons/conditionals/validate-address.test.d.ts +2 -0
  5. package/dist/commons/conditionals/validate.d.ts +39 -17
  6. package/dist/commons/conditionals/validate.test.d.ts +2 -0
  7. package/dist/commons/events/ActionConfig.d.ts +1116 -2067
  8. package/dist/commons/events/ActionDocument.d.ts +9488 -312
  9. package/dist/commons/events/ActionInput.d.ts +5331 -558
  10. package/dist/commons/events/ActionType.d.ts +27 -12
  11. package/dist/commons/events/CompositeFieldValue.d.ts +155 -2
  12. package/dist/commons/events/Conditional.d.ts +21 -5
  13. package/dist/commons/events/Draft.d.ts +351 -51
  14. package/dist/commons/events/EventConfig.d.ts +704 -1245
  15. package/dist/commons/events/EventConfigInput.d.ts +6 -3
  16. package/dist/commons/events/EventDocument.d.ts +3348 -429
  17. package/dist/commons/events/EventIndex.d.ts +9 -3
  18. package/dist/commons/events/EventMetadata.d.ts +6 -0
  19. package/dist/commons/events/FieldConfig.d.ts +568 -74
  20. package/dist/commons/events/FieldType.d.ts +6 -1
  21. package/dist/commons/events/FieldTypeMapping.d.ts +154 -3
  22. package/dist/commons/events/FieldValue.d.ts +76 -2
  23. package/dist/commons/events/FormConfig.d.ts +633 -48
  24. package/dist/commons/events/PageConfig.d.ts +335 -0
  25. package/dist/commons/events/SummaryConfig.d.ts +93 -7
  26. package/dist/commons/events/TemplateConfig.d.ts +30 -10
  27. package/dist/commons/events/User.d.ts +5 -0
  28. package/dist/commons/events/defineConfig.d.ts +104 -224
  29. package/dist/commons/events/index.d.ts +3 -1
  30. package/dist/commons/events/scopes.d.ts +25 -0
  31. package/dist/commons/events/test.utils.d.ts +141 -214
  32. package/dist/commons/events/utils.d.ts +196 -69
  33. package/dist/commons/events/utils.test.d.ts +2 -0
  34. package/dist/conditionals/index.js +166 -81
  35. package/dist/events/index.js +1717 -843
  36. package/package.json +1 -1
@@ -0,0 +1,335 @@
1
+ import { z } from 'zod';
2
+ import { TranslationConfig } from './TranslationConfig';
3
+ export declare const PageTypes: z.ZodEnum<["FORM", "VERIFICATION"]>;
4
+ export type PageType = z.infer<typeof PageTypes>;
5
+ export declare const FormPageConfig: z.ZodObject<z.objectUtil.extendShape<{
6
+ id: z.ZodString;
7
+ title: z.ZodObject<import("./TranslationConfig").MessageDescriptorZod, "strip", z.ZodTypeAny, TranslationConfig, {
8
+ id: string;
9
+ description: string;
10
+ defaultMessage: string;
11
+ }>;
12
+ fields: z.ZodArray<z.ZodType<import("./FieldConfig").Inferred, any, import("./FieldConfig").InferredInput>, "many">;
13
+ conditional: z.ZodOptional<z.ZodType<import(".").JSONSchema, z.ZodTypeDef, import(".").JSONSchema>>;
14
+ }, {
15
+ type: z.ZodDefault<z.ZodLiteral<"FORM">>;
16
+ }>, "strip", z.ZodTypeAny, {
17
+ type: "FORM";
18
+ id: string;
19
+ title: TranslationConfig;
20
+ fields: import("./FieldConfig").Inferred[];
21
+ conditional?: import(".").JSONSchema | undefined;
22
+ }, {
23
+ id: string;
24
+ title: {
25
+ id: string;
26
+ description: string;
27
+ defaultMessage: string;
28
+ };
29
+ fields: import("./FieldConfig").InferredInput[];
30
+ type?: "FORM" | undefined;
31
+ conditional?: import(".").JSONSchema | undefined;
32
+ }>;
33
+ export type FormPageConfig = z.infer<typeof FormPageConfig>;
34
+ export type FormPageConfigInput = z.input<typeof FormPageConfig>;
35
+ export declare const VerificationActionConfig: z.ZodObject<{
36
+ verify: z.ZodObject<{
37
+ label: z.ZodObject<import("./TranslationConfig").MessageDescriptorZod, "strip", z.ZodTypeAny, TranslationConfig, {
38
+ id: string;
39
+ description: string;
40
+ defaultMessage: string;
41
+ }>;
42
+ }, "strip", z.ZodTypeAny, {
43
+ label: TranslationConfig;
44
+ }, {
45
+ label: {
46
+ id: string;
47
+ description: string;
48
+ defaultMessage: string;
49
+ };
50
+ }>;
51
+ cancel: z.ZodObject<{
52
+ label: z.ZodObject<import("./TranslationConfig").MessageDescriptorZod, "strip", z.ZodTypeAny, TranslationConfig, {
53
+ id: string;
54
+ description: string;
55
+ defaultMessage: string;
56
+ }>;
57
+ confirmation: z.ZodObject<{
58
+ title: z.ZodObject<import("./TranslationConfig").MessageDescriptorZod, "strip", z.ZodTypeAny, TranslationConfig, {
59
+ id: string;
60
+ description: string;
61
+ defaultMessage: string;
62
+ }>;
63
+ body: z.ZodObject<import("./TranslationConfig").MessageDescriptorZod, "strip", z.ZodTypeAny, TranslationConfig, {
64
+ id: string;
65
+ description: string;
66
+ defaultMessage: string;
67
+ }>;
68
+ }, "strip", z.ZodTypeAny, {
69
+ title: TranslationConfig;
70
+ body: TranslationConfig;
71
+ }, {
72
+ title: {
73
+ id: string;
74
+ description: string;
75
+ defaultMessage: string;
76
+ };
77
+ body: {
78
+ id: string;
79
+ description: string;
80
+ defaultMessage: string;
81
+ };
82
+ }>;
83
+ }, "strip", z.ZodTypeAny, {
84
+ label: TranslationConfig;
85
+ confirmation: {
86
+ title: TranslationConfig;
87
+ body: TranslationConfig;
88
+ };
89
+ }, {
90
+ label: {
91
+ id: string;
92
+ description: string;
93
+ defaultMessage: string;
94
+ };
95
+ confirmation: {
96
+ title: {
97
+ id: string;
98
+ description: string;
99
+ defaultMessage: string;
100
+ };
101
+ body: {
102
+ id: string;
103
+ description: string;
104
+ defaultMessage: string;
105
+ };
106
+ };
107
+ }>;
108
+ }, "strip", z.ZodTypeAny, {
109
+ verify: {
110
+ label: TranslationConfig;
111
+ };
112
+ cancel: {
113
+ label: TranslationConfig;
114
+ confirmation: {
115
+ title: TranslationConfig;
116
+ body: TranslationConfig;
117
+ };
118
+ };
119
+ }, {
120
+ verify: {
121
+ label: {
122
+ id: string;
123
+ description: string;
124
+ defaultMessage: string;
125
+ };
126
+ };
127
+ cancel: {
128
+ label: {
129
+ id: string;
130
+ description: string;
131
+ defaultMessage: string;
132
+ };
133
+ confirmation: {
134
+ title: {
135
+ id: string;
136
+ description: string;
137
+ defaultMessage: string;
138
+ };
139
+ body: {
140
+ id: string;
141
+ description: string;
142
+ defaultMessage: string;
143
+ };
144
+ };
145
+ };
146
+ }>;
147
+ export declare const VerificationPageConfig: z.ZodObject<z.objectUtil.extendShape<z.objectUtil.extendShape<{
148
+ id: z.ZodString;
149
+ title: z.ZodObject<import("./TranslationConfig").MessageDescriptorZod, "strip", z.ZodTypeAny, TranslationConfig, {
150
+ id: string;
151
+ description: string;
152
+ defaultMessage: string;
153
+ }>;
154
+ fields: z.ZodArray<z.ZodType<import("./FieldConfig").Inferred, any, import("./FieldConfig").InferredInput>, "many">;
155
+ conditional: z.ZodOptional<z.ZodType<import(".").JSONSchema, z.ZodTypeDef, import(".").JSONSchema>>;
156
+ }, {
157
+ type: z.ZodDefault<z.ZodLiteral<"FORM">>;
158
+ }>, {
159
+ type: z.ZodLiteral<"VERIFICATION">;
160
+ actions: z.ZodObject<{
161
+ verify: z.ZodObject<{
162
+ label: z.ZodObject<import("./TranslationConfig").MessageDescriptorZod, "strip", z.ZodTypeAny, TranslationConfig, {
163
+ id: string;
164
+ description: string;
165
+ defaultMessage: string;
166
+ }>;
167
+ }, "strip", z.ZodTypeAny, {
168
+ label: TranslationConfig;
169
+ }, {
170
+ label: {
171
+ id: string;
172
+ description: string;
173
+ defaultMessage: string;
174
+ };
175
+ }>;
176
+ cancel: z.ZodObject<{
177
+ label: z.ZodObject<import("./TranslationConfig").MessageDescriptorZod, "strip", z.ZodTypeAny, TranslationConfig, {
178
+ id: string;
179
+ description: string;
180
+ defaultMessage: string;
181
+ }>;
182
+ confirmation: z.ZodObject<{
183
+ title: z.ZodObject<import("./TranslationConfig").MessageDescriptorZod, "strip", z.ZodTypeAny, TranslationConfig, {
184
+ id: string;
185
+ description: string;
186
+ defaultMessage: string;
187
+ }>;
188
+ body: z.ZodObject<import("./TranslationConfig").MessageDescriptorZod, "strip", z.ZodTypeAny, TranslationConfig, {
189
+ id: string;
190
+ description: string;
191
+ defaultMessage: string;
192
+ }>;
193
+ }, "strip", z.ZodTypeAny, {
194
+ title: TranslationConfig;
195
+ body: TranslationConfig;
196
+ }, {
197
+ title: {
198
+ id: string;
199
+ description: string;
200
+ defaultMessage: string;
201
+ };
202
+ body: {
203
+ id: string;
204
+ description: string;
205
+ defaultMessage: string;
206
+ };
207
+ }>;
208
+ }, "strip", z.ZodTypeAny, {
209
+ label: TranslationConfig;
210
+ confirmation: {
211
+ title: TranslationConfig;
212
+ body: TranslationConfig;
213
+ };
214
+ }, {
215
+ label: {
216
+ id: string;
217
+ description: string;
218
+ defaultMessage: string;
219
+ };
220
+ confirmation: {
221
+ title: {
222
+ id: string;
223
+ description: string;
224
+ defaultMessage: string;
225
+ };
226
+ body: {
227
+ id: string;
228
+ description: string;
229
+ defaultMessage: string;
230
+ };
231
+ };
232
+ }>;
233
+ }, "strip", z.ZodTypeAny, {
234
+ verify: {
235
+ label: TranslationConfig;
236
+ };
237
+ cancel: {
238
+ label: TranslationConfig;
239
+ confirmation: {
240
+ title: TranslationConfig;
241
+ body: TranslationConfig;
242
+ };
243
+ };
244
+ }, {
245
+ verify: {
246
+ label: {
247
+ id: string;
248
+ description: string;
249
+ defaultMessage: string;
250
+ };
251
+ };
252
+ cancel: {
253
+ label: {
254
+ id: string;
255
+ description: string;
256
+ defaultMessage: string;
257
+ };
258
+ confirmation: {
259
+ title: {
260
+ id: string;
261
+ description: string;
262
+ defaultMessage: string;
263
+ };
264
+ body: {
265
+ id: string;
266
+ description: string;
267
+ defaultMessage: string;
268
+ };
269
+ };
270
+ };
271
+ }>;
272
+ }>, "strip", z.ZodTypeAny, {
273
+ type: "VERIFICATION";
274
+ id: string;
275
+ title: TranslationConfig;
276
+ actions: {
277
+ verify: {
278
+ label: TranslationConfig;
279
+ };
280
+ cancel: {
281
+ label: TranslationConfig;
282
+ confirmation: {
283
+ title: TranslationConfig;
284
+ body: TranslationConfig;
285
+ };
286
+ };
287
+ };
288
+ fields: import("./FieldConfig").Inferred[];
289
+ conditional?: import(".").JSONSchema | undefined;
290
+ }, {
291
+ type: "VERIFICATION";
292
+ id: string;
293
+ title: {
294
+ id: string;
295
+ description: string;
296
+ defaultMessage: string;
297
+ };
298
+ actions: {
299
+ verify: {
300
+ label: {
301
+ id: string;
302
+ description: string;
303
+ defaultMessage: string;
304
+ };
305
+ };
306
+ cancel: {
307
+ label: {
308
+ id: string;
309
+ description: string;
310
+ defaultMessage: string;
311
+ };
312
+ confirmation: {
313
+ title: {
314
+ id: string;
315
+ description: string;
316
+ defaultMessage: string;
317
+ };
318
+ body: {
319
+ id: string;
320
+ description: string;
321
+ defaultMessage: string;
322
+ };
323
+ };
324
+ };
325
+ };
326
+ fields: import("./FieldConfig").InferredInput[];
327
+ conditional?: import(".").JSONSchema | undefined;
328
+ }>;
329
+ export type VerificationPageConfig = z.infer<typeof VerificationPageConfig>;
330
+ type AllPageConfig = typeof VerificationPageConfig | typeof FormPageConfig;
331
+ export declare const PageConfig: z.ZodDiscriminatedUnion<"type", AllPageConfig[]>;
332
+ export type PageConfig = z.infer<typeof PageConfig>;
333
+ export type PageConfigInput = z.input<typeof PageConfig>;
334
+ export {};
335
+ //# sourceMappingURL=PageConfig.d.ts.map
@@ -30,7 +30,23 @@ export declare const SummaryConfig: z.ZodObject<{
30
30
  defaultMessage: string;
31
31
  } | undefined;
32
32
  }>;
33
- fields: z.ZodArray<z.ZodObject<{
33
+ fields: z.ZodArray<z.ZodUnion<[z.ZodObject<z.objectUtil.extendShape<{
34
+ emptyValueMessage: z.ZodOptional<z.ZodObject<import("./TranslationConfig").MessageDescriptorZod, "strip", z.ZodTypeAny, TranslationConfig, {
35
+ id: string;
36
+ description: string;
37
+ defaultMessage: string;
38
+ }>>;
39
+ conditionals: z.ZodOptional<z.ZodDefault<z.ZodArray<z.ZodObject<{
40
+ type: z.ZodLiteral<"SHOW">;
41
+ conditional: z.ZodType<import(".").JSONSchema, z.ZodTypeDef, import(".").JSONSchema>;
42
+ }, "strip", z.ZodTypeAny, {
43
+ type: "SHOW";
44
+ conditional: import(".").JSONSchema;
45
+ }, {
46
+ type: "SHOW";
47
+ conditional: import(".").JSONSchema;
48
+ }>, "many">>>;
49
+ }, {
34
50
  id: z.ZodString;
35
51
  value: z.ZodObject<import("./TranslationConfig").MessageDescriptorZod, "strip", z.ZodTypeAny, TranslationConfig, {
36
52
  id: string;
@@ -47,10 +63,14 @@ export declare const SummaryConfig: z.ZodObject<{
47
63
  description: string;
48
64
  defaultMessage: string;
49
65
  }>>;
50
- }, "strip", z.ZodTypeAny, {
66
+ }>, "strip", z.ZodTypeAny, {
51
67
  id: string;
52
68
  value: TranslationConfig;
53
69
  label: TranslationConfig;
70
+ conditionals?: {
71
+ type: "SHOW";
72
+ conditional: import(".").JSONSchema;
73
+ }[] | undefined;
54
74
  emptyValueMessage?: TranslationConfig | undefined;
55
75
  }, {
56
76
  id: string;
@@ -64,24 +84,75 @@ export declare const SummaryConfig: z.ZodObject<{
64
84
  description: string;
65
85
  defaultMessage: string;
66
86
  };
87
+ conditionals?: {
88
+ type: "SHOW";
89
+ conditional: import(".").JSONSchema;
90
+ }[] | undefined;
91
+ emptyValueMessage?: {
92
+ id: string;
93
+ description: string;
94
+ defaultMessage: string;
95
+ } | undefined;
96
+ }>, z.ZodObject<z.objectUtil.extendShape<{
97
+ emptyValueMessage: z.ZodOptional<z.ZodObject<import("./TranslationConfig").MessageDescriptorZod, "strip", z.ZodTypeAny, TranslationConfig, {
98
+ id: string;
99
+ description: string;
100
+ defaultMessage: string;
101
+ }>>;
102
+ conditionals: z.ZodOptional<z.ZodDefault<z.ZodArray<z.ZodObject<{
103
+ type: z.ZodLiteral<"SHOW">;
104
+ conditional: z.ZodType<import(".").JSONSchema, z.ZodTypeDef, import(".").JSONSchema>;
105
+ }, "strip", z.ZodTypeAny, {
106
+ type: "SHOW";
107
+ conditional: import(".").JSONSchema;
108
+ }, {
109
+ type: "SHOW";
110
+ conditional: import(".").JSONSchema;
111
+ }>, "many">>>;
112
+ }, {
113
+ fieldId: z.ZodString;
114
+ }>, "strip", z.ZodTypeAny, {
115
+ fieldId: string;
116
+ conditionals?: {
117
+ type: "SHOW";
118
+ conditional: import(".").JSONSchema;
119
+ }[] | undefined;
120
+ emptyValueMessage?: TranslationConfig | undefined;
121
+ }, {
122
+ fieldId: string;
123
+ conditionals?: {
124
+ type: "SHOW";
125
+ conditional: import(".").JSONSchema;
126
+ }[] | undefined;
67
127
  emptyValueMessage?: {
68
128
  id: string;
69
129
  description: string;
70
130
  defaultMessage: string;
71
131
  } | undefined;
72
- }>, "many">;
132
+ }>]>, "many">;
73
133
  }, "strip", z.ZodTypeAny, {
74
134
  title: {
75
135
  id: string;
76
136
  label: TranslationConfig;
77
137
  emptyValueMessage?: TranslationConfig | undefined;
78
138
  };
79
- fields: {
139
+ fields: ({
140
+ fieldId: string;
141
+ conditionals?: {
142
+ type: "SHOW";
143
+ conditional: import(".").JSONSchema;
144
+ }[] | undefined;
145
+ emptyValueMessage?: TranslationConfig | undefined;
146
+ } | {
80
147
  id: string;
81
148
  value: TranslationConfig;
82
149
  label: TranslationConfig;
150
+ conditionals?: {
151
+ type: "SHOW";
152
+ conditional: import(".").JSONSchema;
153
+ }[] | undefined;
83
154
  emptyValueMessage?: TranslationConfig | undefined;
84
- }[];
155
+ })[];
85
156
  }, {
86
157
  title: {
87
158
  id: string;
@@ -96,7 +167,18 @@ export declare const SummaryConfig: z.ZodObject<{
96
167
  defaultMessage: string;
97
168
  } | undefined;
98
169
  };
99
- fields: {
170
+ fields: ({
171
+ fieldId: string;
172
+ conditionals?: {
173
+ type: "SHOW";
174
+ conditional: import(".").JSONSchema;
175
+ }[] | undefined;
176
+ emptyValueMessage?: {
177
+ id: string;
178
+ description: string;
179
+ defaultMessage: string;
180
+ } | undefined;
181
+ } | {
100
182
  id: string;
101
183
  value: {
102
184
  id: string;
@@ -108,12 +190,16 @@ export declare const SummaryConfig: z.ZodObject<{
108
190
  description: string;
109
191
  defaultMessage: string;
110
192
  };
193
+ conditionals?: {
194
+ type: "SHOW";
195
+ conditional: import(".").JSONSchema;
196
+ }[] | undefined;
111
197
  emptyValueMessage?: {
112
198
  id: string;
113
199
  description: string;
114
200
  defaultMessage: string;
115
201
  } | undefined;
116
- }[];
202
+ })[];
117
203
  }>;
118
204
  export type SummaryConfig = z.infer<typeof SummaryConfig>;
119
205
  //# sourceMappingURL=SummaryConfig.d.ts.map
@@ -1,18 +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
+ */
1
5
  import { FieldValue } from './FieldValue';
2
- export type DefaultValue = FieldValue | MetaFieldsDotted | Record<string, MetaFieldsDotted | FieldValue>;
3
- export declare function isTemplateVariable(value: DefaultValue): value is MetaFieldsDotted;
4
- export declare function isFieldValue(value: DefaultValue): value is FieldValue;
5
- export declare function isFieldValueWithoutTemplates(value: DefaultValue): value is FieldValue;
6
- export declare function isDefaultValue(value: any): value is DefaultValue;
7
- export interface MetaFields {
6
+ /**
7
+ * Available system variables for configuration.
8
+ */
9
+ export type SystemVariables = {
8
10
  $user: {
9
11
  province: string;
10
12
  district: string;
11
13
  };
12
- }
13
- type DottedKeys<T, Prefix extends string = ''> = {
14
- [K in keyof T]: T[K] extends Record<string, string> ? DottedKeys<T[K], `${Prefix}${K & string}.`> : `${Prefix}${K & string}`;
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}`;
15
23
  }[keyof T];
16
- export type MetaFieldsDotted = DottedKeys<MetaFields>;
24
+ export type FlattenenedSystemVariables = FlattenedKeyStrings<SystemVariables>;
25
+ /**
26
+ * Default value for a field when configuring a form.
27
+ */
28
+ export type FieldConfigDefaultValue = FieldValue | FlattenenedSystemVariables | Record<string, FlattenenedSystemVariables | FieldValue>;
29
+ export declare function isTemplateVariable(value: FieldConfigDefaultValue): value is FlattenenedSystemVariables;
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;
17
37
  export {};
18
38
  //# sourceMappingURL=TemplateConfig.d.ts.map
@@ -6,5 +6,10 @@ export type User = {
6
6
  family: string;
7
7
  }[];
8
8
  role: string;
9
+ /**
10
+ * The filename of the user's signature stored in MinIO, ex: 'a552f64a-31c4-4e78-b44f-292c3179e2ef.png'.
11
+ * This is used to retrieve the signature file from storage.
12
+ */
13
+ signatureFilename?: string;
9
14
  };
10
15
  //# sourceMappingURL=User.d.ts.map