@opencrvs/toolkit 1.8.0-rc.f8f3eb3 → 1.8.0-rc.f9911ed

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.
@@ -1,5 +1,9 @@
1
1
  import { z } from 'zod';
2
2
  import { TranslationConfig } from './TranslationConfig';
3
+ export declare const FormPageType: {
4
+ readonly FORM: "FORM";
5
+ readonly VERIFICATION: "VERIFICATION";
6
+ };
3
7
  export declare const FormPage: z.ZodObject<{
4
8
  id: z.ZodString;
5
9
  title: z.ZodObject<import("./TranslationConfig").MessageDescriptorZod, "strip", z.ZodTypeAny, TranslationConfig, {
@@ -7,8 +11,10 @@ export declare const FormPage: z.ZodObject<{
7
11
  description: string;
8
12
  defaultMessage: string;
9
13
  }>;
10
- fields: z.ZodArray<z.ZodType<import("./FieldConfig").Inferred, any, import("./FieldConfig").Inferred>, "many">;
14
+ fields: z.ZodArray<z.ZodType<import("./FieldConfig").Inferred, any, import("./FieldConfig").InferredInput>, "many">;
15
+ type: z.ZodDefault<z.ZodLiteral<"FORM">>;
11
16
  }, "strip", z.ZodTypeAny, {
17
+ type: "FORM";
12
18
  id: string;
13
19
  title: TranslationConfig;
14
20
  fields: import("./FieldConfig").Inferred[];
@@ -19,61 +25,337 @@ export declare const FormPage: z.ZodObject<{
19
25
  description: string;
20
26
  defaultMessage: string;
21
27
  };
22
- fields: import("./FieldConfig").Inferred[];
28
+ fields: import("./FieldConfig").InferredInput[];
29
+ type?: "FORM" | undefined;
23
30
  }>;
24
- export declare const FormConfig: z.ZodObject<{
25
- label: z.ZodObject<import("./TranslationConfig").MessageDescriptorZod, "strip", z.ZodTypeAny, TranslationConfig, {
26
- id: string;
27
- description: string;
28
- defaultMessage: string;
31
+ export declare const VerificationPageConfig: z.ZodObject<{
32
+ verify: z.ZodObject<{
33
+ label: z.ZodObject<import("./TranslationConfig").MessageDescriptorZod, "strip", z.ZodTypeAny, TranslationConfig, {
34
+ id: string;
35
+ description: string;
36
+ defaultMessage: string;
37
+ }>;
38
+ }, "strip", z.ZodTypeAny, {
39
+ label: TranslationConfig;
40
+ }, {
41
+ label: {
42
+ id: string;
43
+ description: string;
44
+ defaultMessage: string;
45
+ };
29
46
  }>;
30
- version: z.ZodObject<{
31
- id: z.ZodString;
47
+ cancel: z.ZodObject<{
32
48
  label: z.ZodObject<import("./TranslationConfig").MessageDescriptorZod, "strip", z.ZodTypeAny, TranslationConfig, {
33
49
  id: string;
34
50
  description: string;
35
51
  defaultMessage: string;
36
52
  }>;
53
+ confirmation: z.ZodObject<{
54
+ title: z.ZodObject<import("./TranslationConfig").MessageDescriptorZod, "strip", z.ZodTypeAny, TranslationConfig, {
55
+ id: string;
56
+ description: string;
57
+ defaultMessage: string;
58
+ }>;
59
+ body: z.ZodObject<import("./TranslationConfig").MessageDescriptorZod, "strip", z.ZodTypeAny, TranslationConfig, {
60
+ id: string;
61
+ description: string;
62
+ defaultMessage: string;
63
+ }>;
64
+ }, "strip", z.ZodTypeAny, {
65
+ title: TranslationConfig;
66
+ body: TranslationConfig;
67
+ }, {
68
+ title: {
69
+ id: string;
70
+ description: string;
71
+ defaultMessage: string;
72
+ };
73
+ body: {
74
+ id: string;
75
+ description: string;
76
+ defaultMessage: string;
77
+ };
78
+ }>;
37
79
  }, "strip", z.ZodTypeAny, {
38
- id: string;
39
80
  label: TranslationConfig;
81
+ confirmation: {
82
+ title: TranslationConfig;
83
+ body: TranslationConfig;
84
+ };
40
85
  }, {
41
- id: string;
42
86
  label: {
43
87
  id: string;
44
88
  description: string;
45
89
  defaultMessage: string;
46
90
  };
91
+ confirmation: {
92
+ title: {
93
+ id: string;
94
+ description: string;
95
+ defaultMessage: string;
96
+ };
97
+ body: {
98
+ id: string;
99
+ description: string;
100
+ defaultMessage: string;
101
+ };
102
+ };
47
103
  }>;
48
- active: z.ZodDefault<z.ZodBoolean>;
49
- pages: z.ZodArray<z.ZodObject<{
104
+ }, "strip", z.ZodTypeAny, {
105
+ verify: {
106
+ label: TranslationConfig;
107
+ };
108
+ cancel: {
109
+ label: TranslationConfig;
110
+ confirmation: {
111
+ title: TranslationConfig;
112
+ body: TranslationConfig;
113
+ };
114
+ };
115
+ }, {
116
+ verify: {
117
+ label: {
118
+ id: string;
119
+ description: string;
120
+ defaultMessage: string;
121
+ };
122
+ };
123
+ cancel: {
124
+ label: {
125
+ id: string;
126
+ description: string;
127
+ defaultMessage: string;
128
+ };
129
+ confirmation: {
130
+ title: {
131
+ id: string;
132
+ description: string;
133
+ defaultMessage: string;
134
+ };
135
+ body: {
136
+ id: string;
137
+ description: string;
138
+ defaultMessage: string;
139
+ };
140
+ };
141
+ };
142
+ }>;
143
+ export declare const VerificationPage: z.ZodObject<z.objectUtil.extendShape<{
144
+ id: z.ZodString;
145
+ title: z.ZodObject<import("./TranslationConfig").MessageDescriptorZod, "strip", z.ZodTypeAny, TranslationConfig, {
146
+ id: string;
147
+ description: string;
148
+ defaultMessage: string;
149
+ }>;
150
+ fields: z.ZodArray<z.ZodType<import("./FieldConfig").Inferred, any, import("./FieldConfig").InferredInput>, "many">;
151
+ type: z.ZodDefault<z.ZodLiteral<"FORM">>;
152
+ }, {
153
+ type: z.ZodLiteral<"VERIFICATION">;
154
+ actions: z.ZodObject<{
155
+ verify: z.ZodObject<{
156
+ label: z.ZodObject<import("./TranslationConfig").MessageDescriptorZod, "strip", z.ZodTypeAny, TranslationConfig, {
157
+ id: string;
158
+ description: string;
159
+ defaultMessage: string;
160
+ }>;
161
+ }, "strip", z.ZodTypeAny, {
162
+ label: TranslationConfig;
163
+ }, {
164
+ label: {
165
+ id: string;
166
+ description: string;
167
+ defaultMessage: string;
168
+ };
169
+ }>;
170
+ cancel: z.ZodObject<{
171
+ label: z.ZodObject<import("./TranslationConfig").MessageDescriptorZod, "strip", z.ZodTypeAny, TranslationConfig, {
172
+ id: string;
173
+ description: string;
174
+ defaultMessage: string;
175
+ }>;
176
+ confirmation: z.ZodObject<{
177
+ title: z.ZodObject<import("./TranslationConfig").MessageDescriptorZod, "strip", z.ZodTypeAny, TranslationConfig, {
178
+ id: string;
179
+ description: string;
180
+ defaultMessage: string;
181
+ }>;
182
+ body: z.ZodObject<import("./TranslationConfig").MessageDescriptorZod, "strip", z.ZodTypeAny, TranslationConfig, {
183
+ id: string;
184
+ description: string;
185
+ defaultMessage: string;
186
+ }>;
187
+ }, "strip", z.ZodTypeAny, {
188
+ title: TranslationConfig;
189
+ body: TranslationConfig;
190
+ }, {
191
+ title: {
192
+ id: string;
193
+ description: string;
194
+ defaultMessage: string;
195
+ };
196
+ body: {
197
+ id: string;
198
+ description: string;
199
+ defaultMessage: string;
200
+ };
201
+ }>;
202
+ }, "strip", z.ZodTypeAny, {
203
+ label: TranslationConfig;
204
+ confirmation: {
205
+ title: TranslationConfig;
206
+ body: TranslationConfig;
207
+ };
208
+ }, {
209
+ label: {
210
+ id: string;
211
+ description: string;
212
+ defaultMessage: string;
213
+ };
214
+ confirmation: {
215
+ title: {
216
+ id: string;
217
+ description: string;
218
+ defaultMessage: string;
219
+ };
220
+ body: {
221
+ id: string;
222
+ description: string;
223
+ defaultMessage: string;
224
+ };
225
+ };
226
+ }>;
227
+ }, "strip", z.ZodTypeAny, {
228
+ verify: {
229
+ label: TranslationConfig;
230
+ };
231
+ cancel: {
232
+ label: TranslationConfig;
233
+ confirmation: {
234
+ title: TranslationConfig;
235
+ body: TranslationConfig;
236
+ };
237
+ };
238
+ }, {
239
+ verify: {
240
+ label: {
241
+ id: string;
242
+ description: string;
243
+ defaultMessage: string;
244
+ };
245
+ };
246
+ cancel: {
247
+ label: {
248
+ id: string;
249
+ description: string;
250
+ defaultMessage: string;
251
+ };
252
+ confirmation: {
253
+ title: {
254
+ id: string;
255
+ description: string;
256
+ defaultMessage: string;
257
+ };
258
+ body: {
259
+ id: string;
260
+ description: string;
261
+ defaultMessage: string;
262
+ };
263
+ };
264
+ };
265
+ }>;
266
+ }>, "strip", z.ZodTypeAny, {
267
+ type: "VERIFICATION";
268
+ id: string;
269
+ title: TranslationConfig;
270
+ actions: {
271
+ verify: {
272
+ label: TranslationConfig;
273
+ };
274
+ cancel: {
275
+ label: TranslationConfig;
276
+ confirmation: {
277
+ title: TranslationConfig;
278
+ body: TranslationConfig;
279
+ };
280
+ };
281
+ };
282
+ fields: import("./FieldConfig").Inferred[];
283
+ }, {
284
+ type: "VERIFICATION";
285
+ id: string;
286
+ title: {
287
+ id: string;
288
+ description: string;
289
+ defaultMessage: string;
290
+ };
291
+ actions: {
292
+ verify: {
293
+ label: {
294
+ id: string;
295
+ description: string;
296
+ defaultMessage: string;
297
+ };
298
+ };
299
+ cancel: {
300
+ label: {
301
+ id: string;
302
+ description: string;
303
+ defaultMessage: string;
304
+ };
305
+ confirmation: {
306
+ title: {
307
+ id: string;
308
+ description: string;
309
+ defaultMessage: string;
310
+ };
311
+ body: {
312
+ id: string;
313
+ description: string;
314
+ defaultMessage: string;
315
+ };
316
+ };
317
+ };
318
+ };
319
+ fields: import("./FieldConfig").InferredInput[];
320
+ }>;
321
+ export type VerificationPageConfig = z.infer<typeof VerificationPageConfig>;
322
+ type AllPageConfigs = typeof FormPage | typeof VerificationPage;
323
+ export declare const FormPageConfig: z.ZodDiscriminatedUnion<"type", AllPageConfigs[]>;
324
+ export type FormPageConfigInput = z.input<typeof FormPageConfig>;
325
+ export type FormPageConfig = z.infer<typeof FormPageConfig>;
326
+ export declare const FormConfig: z.ZodObject<{
327
+ label: z.ZodObject<import("./TranslationConfig").MessageDescriptorZod, "strip", z.ZodTypeAny, TranslationConfig, {
328
+ id: string;
329
+ description: string;
330
+ defaultMessage: string;
331
+ }>;
332
+ version: z.ZodObject<{
50
333
  id: z.ZodString;
51
- title: z.ZodObject<import("./TranslationConfig").MessageDescriptorZod, "strip", z.ZodTypeAny, TranslationConfig, {
334
+ label: z.ZodObject<import("./TranslationConfig").MessageDescriptorZod, "strip", z.ZodTypeAny, TranslationConfig, {
52
335
  id: string;
53
336
  description: string;
54
337
  defaultMessage: string;
55
338
  }>;
56
- fields: z.ZodArray<z.ZodType<import("./FieldConfig").Inferred, any, import("./FieldConfig").Inferred>, "many">;
57
339
  }, "strip", z.ZodTypeAny, {
58
340
  id: string;
59
- title: TranslationConfig;
60
- fields: import("./FieldConfig").Inferred[];
341
+ label: TranslationConfig;
61
342
  }, {
62
343
  id: string;
63
- title: {
344
+ label: {
64
345
  id: string;
65
346
  description: string;
66
347
  defaultMessage: string;
67
348
  };
68
- fields: import("./FieldConfig").Inferred[];
69
- }>, "many">;
349
+ }>;
350
+ active: z.ZodDefault<z.ZodBoolean>;
351
+ pages: z.ZodArray<z.ZodDiscriminatedUnion<"type", AllPageConfigs[]>, "many">;
70
352
  review: z.ZodObject<{
71
353
  title: z.ZodObject<import("./TranslationConfig").MessageDescriptorZod, "strip", z.ZodTypeAny, TranslationConfig, {
72
354
  id: string;
73
355
  description: string;
74
356
  defaultMessage: string;
75
357
  }>;
76
- fields: z.ZodArray<z.ZodType<import("./FieldConfig").Inferred, any, import("./FieldConfig").Inferred>, "many">;
358
+ fields: z.ZodArray<z.ZodType<import("./FieldConfig").Inferred, any, import("./FieldConfig").InferredInput>, "many">;
77
359
  }, "strip", z.ZodTypeAny, {
78
360
  title: TranslationConfig;
79
361
  fields: import("./FieldConfig").Inferred[];
@@ -83,7 +365,7 @@ export declare const FormConfig: z.ZodObject<{
83
365
  description: string;
84
366
  defaultMessage: string;
85
367
  };
86
- fields: import("./FieldConfig").Inferred[];
368
+ fields: import("./FieldConfig").InferredInput[];
87
369
  }>;
88
370
  }, "strip", z.ZodTypeAny, {
89
371
  active: boolean;
@@ -92,11 +374,29 @@ export declare const FormConfig: z.ZodObject<{
92
374
  label: TranslationConfig;
93
375
  };
94
376
  label: TranslationConfig;
95
- pages: {
377
+ pages: ({
378
+ type: "FORM";
96
379
  id: string;
97
380
  title: TranslationConfig;
98
381
  fields: import("./FieldConfig").Inferred[];
99
- }[];
382
+ } | {
383
+ type: "VERIFICATION";
384
+ id: string;
385
+ title: TranslationConfig;
386
+ actions: {
387
+ verify: {
388
+ label: TranslationConfig;
389
+ };
390
+ cancel: {
391
+ label: TranslationConfig;
392
+ confirmation: {
393
+ title: TranslationConfig;
394
+ body: TranslationConfig;
395
+ };
396
+ };
397
+ };
398
+ fields: import("./FieldConfig").Inferred[];
399
+ })[];
100
400
  review: {
101
401
  title: TranslationConfig;
102
402
  fields: import("./FieldConfig").Inferred[];
@@ -115,26 +415,64 @@ export declare const FormConfig: z.ZodObject<{
115
415
  description: string;
116
416
  defaultMessage: string;
117
417
  };
118
- pages: {
418
+ pages: ({
119
419
  id: string;
120
420
  title: {
121
421
  id: string;
122
422
  description: string;
123
423
  defaultMessage: string;
124
424
  };
125
- fields: import("./FieldConfig").Inferred[];
126
- }[];
425
+ fields: import("./FieldConfig").InferredInput[];
426
+ type?: "FORM" | undefined;
427
+ } | {
428
+ type: "VERIFICATION";
429
+ id: string;
430
+ title: {
431
+ id: string;
432
+ description: string;
433
+ defaultMessage: string;
434
+ };
435
+ actions: {
436
+ verify: {
437
+ label: {
438
+ id: string;
439
+ description: string;
440
+ defaultMessage: string;
441
+ };
442
+ };
443
+ cancel: {
444
+ label: {
445
+ id: string;
446
+ description: string;
447
+ defaultMessage: string;
448
+ };
449
+ confirmation: {
450
+ title: {
451
+ id: string;
452
+ description: string;
453
+ defaultMessage: string;
454
+ };
455
+ body: {
456
+ id: string;
457
+ description: string;
458
+ defaultMessage: string;
459
+ };
460
+ };
461
+ };
462
+ };
463
+ fields: import("./FieldConfig").InferredInput[];
464
+ })[];
127
465
  review: {
128
466
  title: {
129
467
  id: string;
130
468
  description: string;
131
469
  defaultMessage: string;
132
470
  };
133
- fields: import("./FieldConfig").Inferred[];
471
+ fields: import("./FieldConfig").InferredInput[];
134
472
  };
135
473
  active?: boolean | undefined;
136
474
  }>;
137
- export type FormPage = z.infer<typeof FormPage>;
138
475
  export type FormConfig = z.infer<typeof FormConfig>;
139
476
  export type FormConfigInput = z.input<typeof FormConfig>;
477
+ export {};
140
478
  //# sourceMappingURL=FormConfig.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