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

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.
@@ -285,7 +285,6 @@ export declare const EventConfig: z.ZodEffects<z.ZodObject<{
285
285
  draft?: boolean | undefined;
286
286
  } | {
287
287
  type: "REJECT";
288
- comment: string;
289
288
  conditionals: ({
290
289
  type: "SHOW";
291
290
  conditional: import(".").JSONSchema;
@@ -311,11 +310,9 @@ export declare const EventConfig: z.ZodEffects<z.ZodObject<{
311
310
  fields: import("./FieldConfig").Inferred[];
312
311
  };
313
312
  }[];
314
- isDuplicate: boolean;
315
313
  draft?: boolean | undefined;
316
314
  } | {
317
315
  type: "MARKED_AS_DUPLICATE";
318
- comment: string;
319
316
  conditionals: ({
320
317
  type: "SHOW";
321
318
  conditional: import(".").JSONSchema;
@@ -341,11 +338,9 @@ export declare const EventConfig: z.ZodEffects<z.ZodObject<{
341
338
  fields: import("./FieldConfig").Inferred[];
342
339
  };
343
340
  }[];
344
- duplicates: string[];
345
341
  draft?: boolean | undefined;
346
342
  } | {
347
- type: "ARCHIVED";
348
- comment: string;
343
+ type: "ARCHIVE";
349
344
  conditionals: ({
350
345
  type: "SHOW";
351
346
  conditional: import(".").JSONSchema;
@@ -371,7 +366,6 @@ export declare const EventConfig: z.ZodEffects<z.ZodObject<{
371
366
  fields: import("./FieldConfig").Inferred[];
372
367
  };
373
368
  }[];
374
- isDuplicate: boolean;
375
369
  draft?: boolean | undefined;
376
370
  } | {
377
371
  type: "REGISTER";
@@ -714,7 +708,6 @@ export declare const EventConfig: z.ZodEffects<z.ZodObject<{
714
708
  })[] | undefined;
715
709
  } | {
716
710
  type: "REJECT";
717
- comment: string;
718
711
  label: {
719
712
  id: string;
720
713
  description: string;
@@ -753,7 +746,6 @@ export declare const EventConfig: z.ZodEffects<z.ZodObject<{
753
746
  };
754
747
  active?: boolean | undefined;
755
748
  }[];
756
- isDuplicate: boolean;
757
749
  draft?: boolean | undefined;
758
750
  conditionals?: ({
759
751
  type: "SHOW";
@@ -764,7 +756,6 @@ export declare const EventConfig: z.ZodEffects<z.ZodObject<{
764
756
  })[] | undefined;
765
757
  } | {
766
758
  type: "MARKED_AS_DUPLICATE";
767
- comment: string;
768
759
  label: {
769
760
  id: string;
770
761
  description: string;
@@ -803,7 +794,6 @@ export declare const EventConfig: z.ZodEffects<z.ZodObject<{
803
794
  };
804
795
  active?: boolean | undefined;
805
796
  }[];
806
- duplicates: string[];
807
797
  draft?: boolean | undefined;
808
798
  conditionals?: ({
809
799
  type: "SHOW";
@@ -813,8 +803,7 @@ export declare const EventConfig: z.ZodEffects<z.ZodObject<{
813
803
  conditional: import(".").JSONSchema;
814
804
  })[] | undefined;
815
805
  } | {
816
- type: "ARCHIVED";
817
- comment: string;
806
+ type: "ARCHIVE";
818
807
  label: {
819
808
  id: string;
820
809
  description: string;
@@ -853,7 +842,6 @@ export declare const EventConfig: z.ZodEffects<z.ZodObject<{
853
842
  };
854
843
  active?: boolean | undefined;
855
844
  }[];
856
- isDuplicate: boolean;
857
845
  draft?: boolean | undefined;
858
846
  conditionals?: ({
859
847
  type: "SHOW";
@@ -1343,7 +1331,6 @@ export declare const EventConfig: z.ZodEffects<z.ZodObject<{
1343
1331
  draft?: boolean | undefined;
1344
1332
  } | {
1345
1333
  type: "REJECT";
1346
- comment: string;
1347
1334
  conditionals: ({
1348
1335
  type: "SHOW";
1349
1336
  conditional: import(".").JSONSchema;
@@ -1369,11 +1356,9 @@ export declare const EventConfig: z.ZodEffects<z.ZodObject<{
1369
1356
  fields: import("./FieldConfig").Inferred[];
1370
1357
  };
1371
1358
  }[];
1372
- isDuplicate: boolean;
1373
1359
  draft?: boolean | undefined;
1374
1360
  } | {
1375
1361
  type: "MARKED_AS_DUPLICATE";
1376
- comment: string;
1377
1362
  conditionals: ({
1378
1363
  type: "SHOW";
1379
1364
  conditional: import(".").JSONSchema;
@@ -1399,11 +1384,9 @@ export declare const EventConfig: z.ZodEffects<z.ZodObject<{
1399
1384
  fields: import("./FieldConfig").Inferred[];
1400
1385
  };
1401
1386
  }[];
1402
- duplicates: string[];
1403
1387
  draft?: boolean | undefined;
1404
1388
  } | {
1405
- type: "ARCHIVED";
1406
- comment: string;
1389
+ type: "ARCHIVE";
1407
1390
  conditionals: ({
1408
1391
  type: "SHOW";
1409
1392
  conditional: import(".").JSONSchema;
@@ -1429,7 +1412,6 @@ export declare const EventConfig: z.ZodEffects<z.ZodObject<{
1429
1412
  fields: import("./FieldConfig").Inferred[];
1430
1413
  };
1431
1414
  }[];
1432
- isDuplicate: boolean;
1433
1415
  draft?: boolean | undefined;
1434
1416
  } | {
1435
1417
  type: "REGISTER";
@@ -1772,7 +1754,6 @@ export declare const EventConfig: z.ZodEffects<z.ZodObject<{
1772
1754
  })[] | undefined;
1773
1755
  } | {
1774
1756
  type: "REJECT";
1775
- comment: string;
1776
1757
  label: {
1777
1758
  id: string;
1778
1759
  description: string;
@@ -1811,7 +1792,6 @@ export declare const EventConfig: z.ZodEffects<z.ZodObject<{
1811
1792
  };
1812
1793
  active?: boolean | undefined;
1813
1794
  }[];
1814
- isDuplicate: boolean;
1815
1795
  draft?: boolean | undefined;
1816
1796
  conditionals?: ({
1817
1797
  type: "SHOW";
@@ -1822,7 +1802,6 @@ export declare const EventConfig: z.ZodEffects<z.ZodObject<{
1822
1802
  })[] | undefined;
1823
1803
  } | {
1824
1804
  type: "MARKED_AS_DUPLICATE";
1825
- comment: string;
1826
1805
  label: {
1827
1806
  id: string;
1828
1807
  description: string;
@@ -1861,7 +1840,6 @@ export declare const EventConfig: z.ZodEffects<z.ZodObject<{
1861
1840
  };
1862
1841
  active?: boolean | undefined;
1863
1842
  }[];
1864
- duplicates: string[];
1865
1843
  draft?: boolean | undefined;
1866
1844
  conditionals?: ({
1867
1845
  type: "SHOW";
@@ -1871,8 +1849,7 @@ export declare const EventConfig: z.ZodEffects<z.ZodObject<{
1871
1849
  conditional: import(".").JSONSchema;
1872
1850
  })[] | undefined;
1873
1851
  } | {
1874
- type: "ARCHIVED";
1875
- comment: string;
1852
+ type: "ARCHIVE";
1876
1853
  label: {
1877
1854
  id: string;
1878
1855
  description: string;
@@ -1911,7 +1888,6 @@ export declare const EventConfig: z.ZodEffects<z.ZodObject<{
1911
1888
  };
1912
1889
  active?: boolean | undefined;
1913
1890
  }[];
1914
- isDuplicate: boolean;
1915
1891
  draft?: boolean | undefined;
1916
1892
  conditionals?: ({
1917
1893
  type: "SHOW";
@@ -1282,9 +1282,9 @@ export declare const EventDocument: z.ZodObject<{
1282
1282
  }>]>>>;
1283
1283
  createdAtLocation: z.ZodString;
1284
1284
  }, {
1285
- type: z.ZodLiteral<"ARCHIVED">;
1285
+ type: z.ZodLiteral<"ARCHIVE">;
1286
1286
  }>, "strip", z.ZodTypeAny, {
1287
- type: "ARCHIVED";
1287
+ type: "ARCHIVE";
1288
1288
  id: string;
1289
1289
  data: Record<string, string | number | boolean | {
1290
1290
  type: string;
@@ -1342,7 +1342,7 @@ export declare const EventDocument: z.ZodObject<{
1342
1342
  originalFilename: string;
1343
1343
  }[]> | undefined;
1344
1344
  }, {
1345
- type: "ARCHIVED";
1345
+ type: "ARCHIVE";
1346
1346
  id: string;
1347
1347
  data: Record<string, string | number | boolean | {
1348
1348
  type: string;
@@ -4636,7 +4636,7 @@ export declare const EventDocument: z.ZodObject<{
4636
4636
  originalFilename: string;
4637
4637
  }[]> | undefined;
4638
4638
  } | {
4639
- type: "ARCHIVED";
4639
+ type: "ARCHIVE";
4640
4640
  id: string;
4641
4641
  data: Record<string, string | number | boolean | {
4642
4642
  type: string;
@@ -5520,7 +5520,7 @@ export declare const EventDocument: z.ZodObject<{
5520
5520
  originalFilename: string;
5521
5521
  }[]> | undefined;
5522
5522
  } | {
5523
- type: "ARCHIVED";
5523
+ type: "ARCHIVE";
5524
5524
  id: string;
5525
5525
  data: Record<string, string | number | boolean | {
5526
5526
  type: string;
@@ -2319,6 +2319,7 @@ declare const Country: z.ZodObject<z.objectUtil.extendShape<{
2319
2319
  hideLabel?: boolean | undefined;
2320
2320
  }>;
2321
2321
  export type Country = z.infer<typeof Country>;
2322
+ export declare const AdministrativeAreas: z.ZodEnum<["ADMIN_STRUCTURE", "HEALTH_FACILITY", "CRVS_OFFICE"]>;
2322
2323
  declare const AdministrativeAreaConfiguration: z.ZodObject<{
2323
2324
  partOf: z.ZodOptional<z.ZodObject<{
2324
2325
  $data: z.ZodString;
@@ -24,4 +24,8 @@ export declare const FieldType: {
24
24
  };
25
25
  export declare const fieldTypes: ("ADDRESS" | "TEXT" | "NUMBER" | "TEXTAREA" | "EMAIL" | "DATE" | "PARAGRAPH" | "PAGE_HEADER" | "RADIO_GROUP" | "FILE" | "FILE_WITH_OPTIONS" | "HIDDEN" | "BULLET_LIST" | "CHECKBOX" | "SELECT" | "COUNTRY" | "LOCATION" | "DIVIDER" | "ADMINISTRATIVE_AREA" | "FACILITY" | "OFFICE" | "SIGNATURE")[];
26
26
  export type FieldType = (typeof fieldTypes)[number];
27
+ /**
28
+ * Composite field types are field types that consist of multiple field values.
29
+ */
30
+ export declare const compositeFieldTypes: ("ADDRESS" | "FILE" | "FILE_WITH_OPTIONS")[];
27
31
  //# sourceMappingURL=FieldType.d.ts.map
@@ -258,6 +258,36 @@ export declare function mapFieldTypeToMockValue(field: FieldConfig, i: number):
258
258
  number?: undefined;
259
259
  zipCode?: undefined;
260
260
  } | null;
261
+ /**
262
+ * Maps complex or nested field types, such as Address fields, to their corresponding empty values.
263
+ */
264
+ export declare function mapFieldTypeToEmptyValue(field: FieldConfig): never[] | {
265
+ country: null;
266
+ province: null;
267
+ district: null;
268
+ urbanOrRural: string;
269
+ town: null;
270
+ residentialArea: null;
271
+ street: null;
272
+ number: null;
273
+ zipCode: null;
274
+ filename?: undefined;
275
+ originalFilename?: undefined;
276
+ type?: undefined;
277
+ } | {
278
+ filename: string;
279
+ originalFilename: string;
280
+ type: string;
281
+ country?: undefined;
282
+ province?: undefined;
283
+ district?: undefined;
284
+ urbanOrRural?: undefined;
285
+ town?: undefined;
286
+ residentialArea?: undefined;
287
+ street?: undefined;
288
+ number?: undefined;
289
+ zipCode?: undefined;
290
+ } | null;
261
291
  export declare const isParagraphFieldType: (field: {
262
292
  config: FieldConfig;
263
293
  value: FieldValue;
@@ -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: "ARCHIVED";
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";
@@ -28,6 +28,7 @@ export * from './FieldTypeMapping';
28
28
  export * from './Conditional';
29
29
  export * from './AdvancedSearchConfig';
30
30
  export * from './test.utils';
31
+ export * from './TemplateConfig';
31
32
  export * from '../conditionals/conditionals';
32
33
  export * from '../conditionals/validate';
33
34
  //# sourceMappingURL=index.d.ts.map
@@ -1,5 +1,5 @@
1
1
  import { ActionDocument } from './ActionDocument';
2
- import { ArchivedActionInput, DeclareActionInput, RegisterActionInput, RejectDeclarationActionInput, RequestCorrectionActionInput, ValidateActionInput } from './ActionInput';
2
+ import { ArchiveActionInput, DeclareActionInput, RegisterActionInput, RejectDeclarationActionInput, RequestCorrectionActionInput, ValidateActionInput } from './ActionInput';
3
3
  import { ActionType } from './ActionType';
4
4
  import { Draft } from './Draft';
5
5
  import { EventConfig } from './EventConfig';
@@ -192,8 +192,8 @@ export declare const eventPayloadGenerator: {
192
192
  duplicates: never[];
193
193
  eventId: string;
194
194
  };
195
- archive: (eventId: string, input?: Partial<Pick<ArchivedActionInput, "transactionId" | "data">>, isDuplicate?: boolean) => {
196
- type: "ARCHIVED";
195
+ archive: (eventId: string, input?: Partial<Pick<ArchiveActionInput, "transactionId" | "data">>, isDuplicate?: boolean) => {
196
+ type: "ARCHIVE";
197
197
  transactionId: string;
198
198
  data: Record<string, string | number | boolean | {
199
199
  type: string;
@@ -7,6 +7,8 @@ import { FieldConfig } from './FieldConfig';
7
7
  import { WorkqueueConfig } from './WorkqueueConfig';
8
8
  import { EventState } from './ActionDocument';
9
9
  import { FormConfig } from './FormConfig';
10
+ import { Draft } from './Draft';
11
+ import { EventDocument } from './EventDocument';
10
12
  /**
11
13
  * @returns All the fields in the event configuration input.
12
14
  */
@@ -75,6 +77,11 @@ export declare const findActiveActionFormFields: (configuration: EventConfig, ac
75
77
  * Returns all fields for the action type, including review fields, if any.
76
78
  */
77
79
  export declare const findActiveActionFields: (configuration: EventConfig, action: ActionType) => FieldConfig[] | undefined;
80
+ export declare const getActiveActionFormPages: (configuration: EventConfig, action: ActionType) => {
81
+ id: string;
82
+ title: TranslationConfig;
83
+ fields: import("./FieldConfig").Inferred[];
84
+ }[];
78
85
  /**
79
86
  * Returns all fields for the action type, including review fields, or throws
80
87
  */
@@ -106,4 +113,82 @@ export declare function stripHiddenFields(fields: FieldConfig[], data: EventStat
106
113
  filename: string;
107
114
  originalFilename: string;
108
115
  }[]>;
116
+ export declare function findActiveDrafts(event: EventDocument, drafts: Draft[]): {
117
+ id: string;
118
+ createdAt: string;
119
+ eventId: string;
120
+ transactionId: string;
121
+ action: {
122
+ type: ActionType;
123
+ data: Record<string, string | number | boolean | {
124
+ type: string;
125
+ filename: string;
126
+ originalFilename: string;
127
+ } | {
128
+ country: string;
129
+ district: string;
130
+ province: string;
131
+ urbanOrRural: "URBAN";
132
+ number?: string | null | undefined;
133
+ town?: string | null | undefined;
134
+ residentialArea?: string | null | undefined;
135
+ street?: string | null | undefined;
136
+ zipCode?: string | null | undefined;
137
+ } | {
138
+ country: string;
139
+ district: string;
140
+ province: string;
141
+ urbanOrRural: "RURAL";
142
+ village?: string | null | undefined;
143
+ } | {
144
+ type: string;
145
+ option: string;
146
+ filename: string;
147
+ originalFilename: string;
148
+ }[]>;
149
+ createdAt: string;
150
+ createdBy: string;
151
+ createdAtLocation: string;
152
+ metadata?: Record<string, string | number | boolean | {
153
+ type: string;
154
+ filename: string;
155
+ originalFilename: string;
156
+ } | {
157
+ country: string;
158
+ district: string;
159
+ province: string;
160
+ urbanOrRural: "URBAN";
161
+ number?: string | null | undefined;
162
+ town?: string | null | undefined;
163
+ residentialArea?: string | null | undefined;
164
+ street?: string | null | undefined;
165
+ zipCode?: string | null | undefined;
166
+ } | {
167
+ country: string;
168
+ district: string;
169
+ province: string;
170
+ urbanOrRural: "RURAL";
171
+ village?: string | null | undefined;
172
+ } | {
173
+ type: string;
174
+ option: string;
175
+ filename: string;
176
+ originalFilename: string;
177
+ }[]> | undefined;
178
+ };
179
+ }[];
180
+ export declare function createEmptyDraft(eventId: string, draftId: string, actionType: ActionType): {
181
+ id: string;
182
+ eventId: string;
183
+ createdAt: string;
184
+ transactionId: import("../uuid").UUID;
185
+ action: {
186
+ type: ActionType;
187
+ data: {};
188
+ metadata: {};
189
+ createdAt: string;
190
+ createdBy: string;
191
+ createdAtLocation: string;
192
+ };
193
+ };
109
194
  //# sourceMappingURL=utils.d.ts.map