@opencrvs/toolkit 1.8.0-rc.ffe8c17 → 1.8.1-rc.a372970

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 (33) hide show
  1. package/README.md +1 -1
  2. package/dist/commons/api/router.d.ts +6644 -9555
  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 +14 -17
  6. package/dist/commons/events/ActionConfig.d.ts +1008 -3209
  7. package/dist/commons/events/ActionDocument.d.ts +9488 -312
  8. package/dist/commons/events/ActionInput.d.ts +5329 -472
  9. package/dist/commons/events/ActionType.d.ts +26 -11
  10. package/dist/commons/events/CompositeFieldValue.d.ts +152 -2
  11. package/dist/commons/events/Conditional.d.ts +21 -5
  12. package/dist/commons/events/Draft.d.ts +351 -48
  13. package/dist/commons/events/EventConfig.d.ts +639 -2862
  14. package/dist/commons/events/EventConfigInput.d.ts +6 -3
  15. package/dist/commons/events/EventDocument.d.ts +3340 -424
  16. package/dist/commons/events/EventIndex.d.ts +6 -3
  17. package/dist/commons/events/EventMetadata.d.ts +3 -0
  18. package/dist/commons/events/FieldConfig.d.ts +383 -104
  19. package/dist/commons/events/FieldTypeMapping.d.ts +104 -207
  20. package/dist/commons/events/FieldValue.d.ts +71 -76
  21. package/dist/commons/events/FormConfig.d.ts +527 -279
  22. package/dist/commons/events/PageConfig.d.ts +335 -0
  23. package/dist/commons/events/TemplateConfig.d.ts +5 -5
  24. package/dist/commons/events/defineConfig.d.ts +40 -417
  25. package/dist/commons/events/index.d.ts +2 -1
  26. package/dist/commons/events/test.utils.d.ts +140 -213
  27. package/dist/commons/events/utils.d.ts +126 -156
  28. package/dist/commons/events/utils.test.d.ts +2 -0
  29. package/dist/conditionals/index.js +166 -81
  30. package/dist/events/index.js +1287 -795
  31. package/dist/scopes/index.d.ts +70 -1
  32. package/dist/scopes/index.js +130 -0
  33. package/package.json +1 -1
@@ -1,171 +1,94 @@
1
- import { TranslationConfig } from './TranslationConfig';
2
- import { ActionType } from './ActionType';
1
+ import { ActionType, DeclarationActionType } from './ActionType';
3
2
  import { EventConfig } from './EventConfig';
4
- import { EventConfigInput } from './EventConfigInput';
5
- import { EventMetadataKeys } from './EventMetadata';
6
3
  import { FieldConfig } from './FieldConfig';
7
4
  import { WorkqueueConfig } from './WorkqueueConfig';
8
- import { EventState } from './ActionDocument';
9
- import { FormConfig } from './FormConfig';
5
+ import { Action, ActionUpdate, EventState } from './ActionDocument';
6
+ import { PageConfig, VerificationPageConfig } from './PageConfig';
10
7
  import { Draft } from './Draft';
11
8
  import { EventDocument } from './EventDocument';
12
- /**
13
- * @returns All the fields in the event configuration input.
14
- */
15
- export declare const findInputPageFields: (config: EventConfigInput) => {
9
+ import { ActionConfig } from './ActionConfig';
10
+ import { FormConfig } from './FormConfig';
11
+ export declare function getDeclarationFields(configuration: EventConfig): FieldConfig[];
12
+ export declare function getDeclarationPages(configuration: EventConfig): {
13
+ type: "FORM";
16
14
  id: string;
17
- label: TranslationConfig;
15
+ title: import("./TranslationConfig").TranslationConfig;
16
+ fields: import("./FieldConfig").Inferred[];
17
+ conditional?: import(".").JSONSchema | undefined;
18
18
  }[];
19
+ export declare function getDeclaration(configuration: EventConfig): {
20
+ label: import("./TranslationConfig").TranslationConfig;
21
+ pages: {
22
+ type: "FORM";
23
+ id: string;
24
+ title: import("./TranslationConfig").TranslationConfig;
25
+ fields: import("./FieldConfig").Inferred[];
26
+ conditional?: import(".").JSONSchema | undefined;
27
+ }[];
28
+ };
29
+ export declare const getActionAnnotationFields: (actionConfig: ActionConfig) => import("./FieldConfig").Inferred[];
30
+ export declare const getAllAnnotationFields: (config: EventConfig) => FieldConfig[];
19
31
  /**
20
32
  * @returns All the fields in the event configuration.
21
33
  */
22
- export declare const findPageFields: (config: EventConfig) => FieldConfig[];
34
+ export declare const findAllFields: (config: EventConfig) => FieldConfig[];
23
35
  /**
24
- *
25
- * @param pageFields - All the fields in the event configuration
26
- * @param refFields - The fields referencing values within the event configuration (e.g. summary fields) or within system provided metadata fields (e.g. createdAt, updatedBy)
27
- * @returns referenced fields with populated labels
36
+ * @TODO: Request correction should have same format as print certificate
28
37
  */
29
- export declare const resolveLabelsFromKnownFields: ({ pageFields, refFields }: {
30
- pageFields: {
31
- id: string;
32
- label: TranslationConfig;
33
- }[];
34
- refFields: {
35
- id: EventMetadataKeys | string;
36
- label?: TranslationConfig;
37
- }[];
38
- }) => {
39
- id: EventMetadataKeys | string;
40
- label?: TranslationConfig;
41
- }[];
42
- export declare function getAllFields(configuration: EventConfig): import("./FieldConfig").Inferred[];
43
- export declare function getAllPages(configuration: EventConfig): ({
44
- type: import("./FormConfig").PageType.FORM;
45
- id: string;
46
- title: TranslationConfig;
47
- fields: import("./FieldConfig").Inferred[];
48
- } | {
49
- type: import("./FormConfig").PageType.VERIFICATION;
50
- id: string;
51
- title: TranslationConfig;
52
- actions: {
53
- verify: {
54
- label: TranslationConfig;
55
- };
56
- cancel: {
57
- label: TranslationConfig;
58
- confirmation: {
59
- title: TranslationConfig;
60
- body: TranslationConfig;
61
- };
62
- };
63
- };
38
+ export declare const findRecordActionPages: (config: EventConfig, actionType: ActionType) => PageConfig[];
39
+ export declare function getActionReview(configuration: EventConfig, actionType: ActionType): {
40
+ title: import("./TranslationConfig").TranslationConfig;
64
41
  fields: import("./FieldConfig").Inferred[];
65
- })[];
42
+ };
43
+ export declare function getActionReviewFields(configuration: EventConfig, actionType: DeclarationActionType): import("./FieldConfig").Inferred[];
66
44
  export declare function validateWorkqueueConfig(workqueueConfigs: WorkqueueConfig[]): void;
67
- export declare const findActiveActionForm: (configuration: EventConfig, action: ActionType) => {
68
- active: boolean;
69
- version: {
70
- id: string;
71
- label: TranslationConfig;
72
- };
73
- label: TranslationConfig;
74
- pages: ({
75
- type: import("./FormConfig").PageType.FORM;
76
- id: string;
77
- title: TranslationConfig;
78
- fields: import("./FieldConfig").Inferred[];
79
- } | {
80
- type: import("./FormConfig").PageType.VERIFICATION;
81
- id: string;
82
- title: TranslationConfig;
83
- actions: {
84
- verify: {
85
- label: TranslationConfig;
86
- };
87
- cancel: {
88
- label: TranslationConfig;
89
- confirmation: {
90
- title: TranslationConfig;
91
- body: TranslationConfig;
92
- };
93
- };
94
- };
95
- fields: import("./FieldConfig").Inferred[];
96
- })[];
97
- review: {
98
- title: TranslationConfig;
99
- fields: import("./FieldConfig").Inferred[];
100
- };
101
- } | undefined;
102
- export declare const findActiveActionFormPages: (configuration: EventConfig, action: ActionType) => ({
103
- type: import("./FormConfig").PageType.FORM;
104
- id: string;
105
- title: TranslationConfig;
106
- fields: import("./FieldConfig").Inferred[];
45
+ export declare function isPageVisible(page: PageConfig, formValues: ActionUpdate): boolean;
46
+ export declare function omitHiddenFields(fields: FieldConfig[], values: EventState): import("lodash").Dictionary<string | number | boolean | {
47
+ type: string;
48
+ filename: string;
49
+ originalFilename: string;
107
50
  } | {
108
- type: import("./FormConfig").PageType.VERIFICATION;
109
- id: string;
110
- title: TranslationConfig;
111
- actions: {
112
- verify: {
113
- label: TranslationConfig;
114
- };
115
- cancel: {
116
- label: TranslationConfig;
117
- confirmation: {
118
- title: TranslationConfig;
119
- body: TranslationConfig;
120
- };
121
- };
122
- };
123
- fields: import("./FieldConfig").Inferred[];
124
- })[] | undefined;
125
- export declare const getFormFields: (formConfig: FormConfig) => import("./FieldConfig").Inferred[];
126
- /**
127
- * Returns only form fields for the action type, if any, excluding review fields.
128
- */
129
- export declare const findActiveActionFormFields: (configuration: EventConfig, action: ActionType) => FieldConfig[] | undefined;
130
- /**
131
- * Returns all fields for the action type, including review fields, if any.
132
- */
133
- export declare const findActiveActionFields: (configuration: EventConfig, action: ActionType) => FieldConfig[] | undefined;
134
- export declare const getActiveActionFormPages: (configuration: EventConfig, action: ActionType) => ({
135
- type: import("./FormConfig").PageType.FORM;
136
- id: string;
137
- title: TranslationConfig;
138
- fields: import("./FieldConfig").Inferred[];
51
+ country: string;
52
+ district: string;
53
+ addressType: "DOMESTIC";
54
+ province: string;
55
+ urbanOrRural: "URBAN";
56
+ number?: string | undefined;
57
+ town?: string | undefined;
58
+ residentialArea?: string | undefined;
59
+ street?: string | undefined;
60
+ zipCode?: string | undefined;
139
61
  } | {
140
- type: import("./FormConfig").PageType.VERIFICATION;
141
- id: string;
142
- title: TranslationConfig;
143
- actions: {
144
- verify: {
145
- label: TranslationConfig;
146
- };
147
- cancel: {
148
- label: TranslationConfig;
149
- confirmation: {
150
- title: TranslationConfig;
151
- body: TranslationConfig;
152
- };
153
- };
154
- };
155
- fields: import("./FieldConfig").Inferred[];
156
- })[];
157
- /**
158
- * Returns all fields for the action type, including review fields, or throws
159
- */
160
- export declare function getActiveActionFields(configuration: EventConfig, action: ActionType): FieldConfig[];
161
- export declare function getEventConfiguration(eventConfigurations: EventConfig[], type: string): EventConfig;
162
- export declare function stripHiddenFields(fields: FieldConfig[], data: EventState): import("lodash").Dictionary<string | number | boolean | {
62
+ country: string;
63
+ district: string;
64
+ addressType: "DOMESTIC";
65
+ province: string;
66
+ urbanOrRural: "RURAL";
67
+ village?: string | undefined;
68
+ } | {
69
+ country: string;
70
+ state: string;
71
+ addressType: "INTERNATIONAL";
72
+ district2: string;
73
+ cityOrTown?: string | undefined;
74
+ addressLine1?: string | undefined;
75
+ addressLine2?: string | undefined;
76
+ addressLine3?: string | undefined;
77
+ postcodeOrZip?: string | undefined;
78
+ } | {
79
+ type: string;
80
+ option: string;
81
+ filename: string;
82
+ originalFilename: string;
83
+ }[] | undefined>;
84
+ export declare function omitHiddenPaginatedFields(formConfig: FormConfig, declaration: EventState): import("lodash").Dictionary<string | number | boolean | {
163
85
  type: string;
164
86
  filename: string;
165
87
  originalFilename: string;
166
88
  } | {
167
89
  country: string;
168
90
  district: string;
91
+ addressType: "DOMESTIC";
169
92
  province: string;
170
93
  urbanOrRural: "URBAN";
171
94
  number?: string | undefined;
@@ -176,29 +99,44 @@ export declare function stripHiddenFields(fields: FieldConfig[], data: EventStat
176
99
  } | {
177
100
  country: string;
178
101
  district: string;
102
+ addressType: "DOMESTIC";
179
103
  province: string;
180
104
  urbanOrRural: "RURAL";
181
105
  village?: string | undefined;
106
+ } | {
107
+ country: string;
108
+ state: string;
109
+ addressType: "INTERNATIONAL";
110
+ district2: string;
111
+ cityOrTown?: string | undefined;
112
+ addressLine1?: string | undefined;
113
+ addressLine2?: string | undefined;
114
+ addressLine3?: string | undefined;
115
+ postcodeOrZip?: string | undefined;
182
116
  } | {
183
117
  type: string;
184
118
  option: string;
185
119
  filename: string;
186
120
  originalFilename: string;
187
- }[]>;
121
+ }[] | undefined>;
188
122
  export declare function findActiveDrafts(event: EventDocument, drafts: Draft[]): {
189
123
  id: string;
190
124
  createdAt: string;
191
125
  eventId: string;
192
126
  transactionId: string;
193
127
  action: {
194
- type: ActionType;
195
- data: Record<string, string | number | boolean | {
128
+ type: "DECLARE" | "REGISTER" | "VALIDATE" | "DELETE" | "CREATE" | "NOTIFY" | "DETECT_DUPLICATE" | "REJECT" | "MARKED_AS_DUPLICATE" | "ARCHIVE" | "PRINT_CERTIFICATE" | "REQUEST_CORRECTION" | "REJECT_CORRECTION" | "APPROVE_CORRECTION" | "READ" | "ASSIGN" | "UNASSIGN";
129
+ status: "Rejected" | "Requested" | "Accepted";
130
+ createdAt: string;
131
+ createdBy: string;
132
+ declaration: Record<string, string | number | boolean | {
196
133
  type: string;
197
134
  filename: string;
198
135
  originalFilename: string;
199
136
  } | {
200
137
  country: string;
201
138
  district: string;
139
+ addressType: "DOMESTIC";
202
140
  province: string;
203
141
  urbanOrRural: "URBAN";
204
142
  number?: string | null | undefined;
@@ -209,25 +147,35 @@ export declare function findActiveDrafts(event: EventDocument, drafts: Draft[]):
209
147
  } | {
210
148
  country: string;
211
149
  district: string;
150
+ addressType: "DOMESTIC";
212
151
  province: string;
213
152
  urbanOrRural: "RURAL";
214
153
  village?: string | null | undefined;
154
+ } | {
155
+ country: string;
156
+ state: string;
157
+ addressType: "INTERNATIONAL";
158
+ district2: string;
159
+ cityOrTown?: string | null | undefined;
160
+ addressLine1?: string | null | undefined;
161
+ addressLine2?: string | null | undefined;
162
+ addressLine3?: string | null | undefined;
163
+ postcodeOrZip?: string | null | undefined;
215
164
  } | {
216
165
  type: string;
217
166
  option: string;
218
167
  filename: string;
219
168
  originalFilename: string;
220
- }[]>;
221
- createdAt: string;
222
- createdBy: string;
169
+ }[] | undefined>;
223
170
  createdAtLocation: string;
224
- metadata?: Record<string, string | number | boolean | {
171
+ annotation?: Record<string, string | number | boolean | {
225
172
  type: string;
226
173
  filename: string;
227
174
  originalFilename: string;
228
175
  } | {
229
176
  country: string;
230
177
  district: string;
178
+ addressType: "DOMESTIC";
231
179
  province: string;
232
180
  urbanOrRural: "URBAN";
233
181
  number?: string | null | undefined;
@@ -238,15 +186,27 @@ export declare function findActiveDrafts(event: EventDocument, drafts: Draft[]):
238
186
  } | {
239
187
  country: string;
240
188
  district: string;
189
+ addressType: "DOMESTIC";
241
190
  province: string;
242
191
  urbanOrRural: "RURAL";
243
192
  village?: string | null | undefined;
193
+ } | {
194
+ country: string;
195
+ state: string;
196
+ addressType: "INTERNATIONAL";
197
+ district2: string;
198
+ cityOrTown?: string | null | undefined;
199
+ addressLine1?: string | null | undefined;
200
+ addressLine2?: string | null | undefined;
201
+ addressLine3?: string | null | undefined;
202
+ postcodeOrZip?: string | null | undefined;
244
203
  } | {
245
204
  type: string;
246
205
  option: string;
247
206
  filename: string;
248
207
  originalFilename: string;
249
- }[]> | undefined;
208
+ }[] | undefined> | undefined;
209
+ originalActionId?: string | undefined;
250
210
  };
251
211
  }[];
252
212
  export declare function createEmptyDraft(eventId: string, draftId: string, actionType: ActionType): {
@@ -256,11 +216,21 @@ export declare function createEmptyDraft(eventId: string, draftId: string, actio
256
216
  transactionId: import("../uuid").UUID;
257
217
  action: {
258
218
  type: ActionType;
259
- data: {};
260
- metadata: {};
219
+ declaration: {};
220
+ annotation: {};
261
221
  createdAt: string;
262
222
  createdBy: string;
263
223
  createdAtLocation: string;
264
224
  };
265
225
  };
226
+ export declare function isVerificationPage(page: PageConfig): page is VerificationPageConfig;
227
+ export declare function deepMerge<T extends Record<string, unknown>>(currentDocument: T, actionDocument: T): T;
228
+ export declare function findLastAssignmentAction(actions: Action[]): Action | undefined;
229
+ /** Tell compiler that accessing record with arbitrary key might result to undefined
230
+ * Use when you **cannot guarantee** that key exists in the record
231
+ */
232
+ export type IndexMap<T> = {
233
+ [id: string]: T | undefined;
234
+ };
235
+ export declare function isWriteAction(actionType: ActionType): boolean;
266
236
  //# sourceMappingURL=utils.d.ts.map
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=utils.test.d.ts.map