@opencrvs/toolkit 1.8.0-rc.f876361 → 1.8.0-rc.f8e4107

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.
@@ -2,30 +2,6 @@ import { z } from 'zod';
2
2
  import { TranslationConfig } from './TranslationConfig';
3
3
  export declare const PageTypes: z.ZodEnum<["FORM", "VERIFICATION"]>;
4
4
  export type PageType = z.infer<typeof PageTypes>;
5
- export declare const PageConfigBase: z.ZodObject<{
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
- }, "strip", z.ZodTypeAny, {
15
- id: string;
16
- title: TranslationConfig;
17
- fields: import("./FieldConfig").Inferred[];
18
- conditional?: import(".").JSONSchema | undefined;
19
- }, {
20
- id: string;
21
- title: {
22
- id: string;
23
- description: string;
24
- defaultMessage: string;
25
- };
26
- fields: import("./FieldConfig").InferredInput[];
27
- conditional?: import(".").JSONSchema | undefined;
28
- }>;
29
5
  export declare const FormPageConfig: z.ZodObject<z.objectUtil.extendShape<{
30
6
  id: z.ZodString;
31
7
  title: z.ZodObject<import("./TranslationConfig").MessageDescriptorZod, "strip", z.ZodTypeAny, TranslationConfig, {
@@ -6,12 +6,12 @@ import { FieldValue } from './FieldValue';
6
6
  /**
7
7
  * Available system variables for configuration.
8
8
  */
9
- export interface MetaFields {
9
+ export type SystemVariables = {
10
10
  $user: {
11
11
  province: string;
12
12
  district: string;
13
13
  };
14
- }
14
+ };
15
15
  /**
16
16
  * Recursively flatten the keys of an object. Used to limit types when configuring default values in country config.
17
17
  * @example
@@ -21,12 +21,12 @@ export interface MetaFields {
21
21
  type FlattenedKeyStrings<T, Prefix extends string = ''> = {
22
22
  [K in keyof T]: T[K] extends Record<string, any> ? FlattenedKeyStrings<T[K], `${Prefix}${K & string}.`> : `${Prefix}${K & string}`;
23
23
  }[keyof T];
24
- export type FlattenedMetaFields = FlattenedKeyStrings<MetaFields>;
24
+ export type FlattenenedSystemVariables = FlattenedKeyStrings<SystemVariables>;
25
25
  /**
26
26
  * Default value for a field when configuring a form.
27
27
  */
28
- export type FieldConfigDefaultValue = FieldValue | FlattenedMetaFields | Record<string, FlattenedMetaFields | FieldValue>;
29
- export declare function isTemplateVariable(value: FieldConfigDefaultValue): value is FlattenedMetaFields;
28
+ export type FieldConfigDefaultValue = FieldValue | FlattenenedSystemVariables | Record<string, FlattenenedSystemVariables | FieldValue>;
29
+ export declare function isTemplateVariable(value: FieldConfigDefaultValue): value is FlattenenedSystemVariables;
30
30
  export declare function isFieldValue(value: FieldConfigDefaultValue): value is FieldValue;
31
31
  /**
32
32
  * Checks if given value is valid for a field, and known template variables are already resolved.
@@ -46,7 +46,7 @@ export declare const defineConfig: (config: EventConfigInput) => {
46
46
  };
47
47
  draft?: boolean | undefined;
48
48
  } | {
49
- type: "REGISTER";
49
+ type: "REJECT";
50
50
  conditionals: ({
51
51
  type: "SHOW";
52
52
  conditional: import(".").JSONSchema;
@@ -55,13 +55,9 @@ export declare const defineConfig: (config: EventConfigInput) => {
55
55
  conditional: import(".").JSONSchema;
56
56
  })[];
57
57
  label: import("./TranslationConfig").TranslationConfig;
58
- review: {
59
- title: import("./TranslationConfig").TranslationConfig;
60
- fields: import("./FieldConfig").Inferred[];
61
- };
62
58
  draft?: boolean | undefined;
63
59
  } | {
64
- type: "REJECT";
60
+ type: "MARKED_AS_DUPLICATE";
65
61
  conditionals: ({
66
62
  type: "SHOW";
67
63
  conditional: import(".").JSONSchema;
@@ -72,7 +68,7 @@ export declare const defineConfig: (config: EventConfigInput) => {
72
68
  label: import("./TranslationConfig").TranslationConfig;
73
69
  draft?: boolean | undefined;
74
70
  } | {
75
- type: "MARKED_AS_DUPLICATE";
71
+ type: "ARCHIVE";
76
72
  conditionals: ({
77
73
  type: "SHOW";
78
74
  conditional: import(".").JSONSchema;
@@ -83,7 +79,7 @@ export declare const defineConfig: (config: EventConfigInput) => {
83
79
  label: import("./TranslationConfig").TranslationConfig;
84
80
  draft?: boolean | undefined;
85
81
  } | {
86
- type: "ARCHIVE";
82
+ type: "REGISTER";
87
83
  conditionals: ({
88
84
  type: "SHOW";
89
85
  conditional: import(".").JSONSchema;
@@ -92,6 +88,10 @@ export declare const defineConfig: (config: EventConfigInput) => {
92
88
  conditional: import(".").JSONSchema;
93
89
  })[];
94
90
  label: import("./TranslationConfig").TranslationConfig;
91
+ review: {
92
+ title: import("./TranslationConfig").TranslationConfig;
93
+ fields: import("./FieldConfig").Inferred[];
94
+ };
95
95
  draft?: boolean | undefined;
96
96
  } | {
97
97
  type: "DELETE";
@@ -255,10 +255,14 @@ export declare const defineConfig: (config: EventConfigInput) => {
255
255
  advancedSearch: {
256
256
  title: import("./TranslationConfig").TranslationConfig;
257
257
  fields: {
258
- fieldId: string;
259
- config?: {
258
+ config: {
260
259
  type: "FUZZY" | "EXACT" | "RANGE";
261
- } | undefined;
260
+ };
261
+ fieldId: string;
262
+ options?: {
263
+ value: string;
264
+ label: import("./TranslationConfig").TranslationConfig;
265
+ }[] | undefined;
262
266
  }[];
263
267
  }[];
264
268
  };
@@ -1,5 +1,5 @@
1
1
  import { ActionDocument, ActionUpdate } from './ActionDocument';
2
- import { ArchiveActionInput, DeclareActionInput, RegisterActionInput, RejectDeclarationActionInput, RequestCorrectionActionInput, ValidateActionInput } from './ActionInput';
2
+ import { ArchiveActionInput, AssignActionInput, DeclareActionInput, RegisterActionInput, RejectDeclarationActionInput, RequestCorrectionActionInput, UnassignActionInput, ValidateActionInput } from './ActionInput';
3
3
  import { ActionType } from './ActionType';
4
4
  import { Draft } from './Draft';
5
5
  import { EventConfig } from './EventConfig';
@@ -8,7 +8,7 @@ import { EventIndex } from './EventIndex';
8
8
  import { EventInput } from './EventInput';
9
9
  import { FieldValue } from './FieldValue';
10
10
  import { TranslationConfig } from './TranslationConfig';
11
- export declare function generateActionInput(configuration: EventConfig, action: ActionType): import("lodash").Dictionary<string | number | boolean | {
11
+ export declare function generateActionDeclarationInput(configuration: EventConfig, action: ActionType): import("lodash").Dictionary<string | number | boolean | {
12
12
  type: string;
13
13
  filename: string;
14
14
  originalFilename: string;
@@ -46,7 +46,7 @@ export declare function generateActionInput(configuration: EventConfig, action:
46
46
  filename: string;
47
47
  originalFilename: string;
48
48
  }[] | undefined>;
49
- export declare function generateActionMetadataInput(configuration: EventConfig, action: ActionType): {};
49
+ export declare function generateActionAnnotationInput(configuration: EventConfig, action: ActionType): {};
50
50
  export declare const eventPayloadGenerator: {
51
51
  create: (input?: Partial<EventInput>) => {
52
52
  transactionId: string;
@@ -57,116 +57,10 @@ export declare const eventPayloadGenerator: {
57
57
  type: string;
58
58
  id: string;
59
59
  };
60
- draft: (eventId: string, input?: Partial<Draft>) => {
61
- id: import("../uuid").UUID;
60
+ draft: ({ eventId, actionType }: {
62
61
  eventId: string;
63
- createdAt: string;
64
- transactionId: import("../uuid").UUID;
65
- action: {
66
- type: "REQUEST_CORRECTION";
67
- declaration: {
68
- 'applicant.firstname': string;
69
- 'applicant.surname': string;
70
- 'applicant.dob': string;
71
- 'recommender.none': boolean;
72
- };
73
- annotation: {
74
- 'correction.requester.relationship': string;
75
- 'correction.request.reason': string;
76
- };
77
- createdAt: string;
78
- createdBy: string;
79
- createdAtLocation: string;
80
- };
81
- } & Partial<{
82
- id: string;
83
- createdAt: string;
84
- eventId: string;
85
- transactionId: string;
86
- action: {
87
- 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";
88
- createdAt: string;
89
- createdBy: string;
90
- declaration: Record<string, string | number | boolean | {
91
- type: string;
92
- filename: string;
93
- originalFilename: string;
94
- } | {
95
- country: string;
96
- district: string;
97
- addressType: "DOMESTIC";
98
- province: string;
99
- urbanOrRural: "URBAN";
100
- number?: string | null | undefined;
101
- town?: string | null | undefined;
102
- residentialArea?: string | null | undefined;
103
- street?: string | null | undefined;
104
- zipCode?: string | null | undefined;
105
- } | {
106
- country: string;
107
- district: string;
108
- addressType: "DOMESTIC";
109
- province: string;
110
- urbanOrRural: "RURAL";
111
- village?: string | null | undefined;
112
- } | {
113
- country: string;
114
- state: string;
115
- addressType: "INTERNATIONAL";
116
- district2: string;
117
- cityOrTown?: string | null | undefined;
118
- addressLine1?: string | null | undefined;
119
- addressLine2?: string | null | undefined;
120
- addressLine3?: string | null | undefined;
121
- postcodeOrZip?: string | null | undefined;
122
- } | {
123
- type: string;
124
- option: string;
125
- filename: string;
126
- originalFilename: string;
127
- }[] | undefined>;
128
- createdAtLocation: string;
129
- annotation?: Record<string, string | number | boolean | {
130
- type: string;
131
- filename: string;
132
- originalFilename: string;
133
- } | {
134
- country: string;
135
- district: string;
136
- addressType: "DOMESTIC";
137
- province: string;
138
- urbanOrRural: "URBAN";
139
- number?: string | null | undefined;
140
- town?: string | null | undefined;
141
- residentialArea?: string | null | undefined;
142
- street?: string | null | undefined;
143
- zipCode?: string | null | undefined;
144
- } | {
145
- country: string;
146
- district: string;
147
- addressType: "DOMESTIC";
148
- province: string;
149
- urbanOrRural: "RURAL";
150
- village?: string | null | undefined;
151
- } | {
152
- country: string;
153
- state: string;
154
- addressType: "INTERNATIONAL";
155
- district2: string;
156
- cityOrTown?: string | null | undefined;
157
- addressLine1?: string | null | undefined;
158
- addressLine2?: string | null | undefined;
159
- addressLine3?: string | null | undefined;
160
- postcodeOrZip?: string | null | undefined;
161
- } | {
162
- type: string;
163
- option: string;
164
- filename: string;
165
- originalFilename: string;
166
- }[] | undefined> | undefined;
167
- originalActionId?: string | undefined;
168
- };
169
- }>;
62
+ actionType: ActionType;
63
+ }, input?: Partial<Draft>) => Draft;
170
64
  actions: {
171
65
  declare: (eventId: string, input?: Partial<Pick<DeclareActionInput, "transactionId" | "declaration" | "annotation">>) => {
172
66
  type: "DECLARE";
@@ -306,6 +200,20 @@ export declare const eventPayloadGenerator: {
306
200
  duplicates: never[];
307
201
  eventId: string;
308
202
  };
203
+ assign: (eventId: string, input?: Partial<Pick<AssignActionInput, "transactionId" | "assignedTo">>) => {
204
+ type: "ASSIGN";
205
+ transactionId: string;
206
+ declaration: {};
207
+ assignedTo: string;
208
+ eventId: string;
209
+ };
210
+ unassign: (eventId: string, input?: Partial<Pick<UnassignActionInput, "transactionId">>) => {
211
+ type: "UNASSIGN";
212
+ transactionId: string;
213
+ declaration: {};
214
+ assignedTo: null;
215
+ eventId: string;
216
+ };
309
217
  archive: (eventId: string, input?: Partial<Pick<ArchiveActionInput, "transactionId" | "declaration">>, isDuplicate?: boolean) => {
310
218
  type: "ARCHIVE";
311
219
  transactionId: string;
@@ -1,23 +1,13 @@
1
- import { ActionType, DeclarationAction } from './ActionType';
1
+ import { ActionType, DeclarationActionType } from './ActionType';
2
2
  import { EventConfig } from './EventConfig';
3
3
  import { FieldConfig } from './FieldConfig';
4
4
  import { WorkqueueConfig } from './WorkqueueConfig';
5
- import { ActionUpdate, EventState } from './ActionDocument';
5
+ import { Action, ActionUpdate, EventState } from './ActionDocument';
6
6
  import { PageConfig, VerificationPageConfig } from './PageConfig';
7
7
  import { Draft } from './Draft';
8
8
  import { EventDocument } from './EventDocument';
9
9
  import { ActionConfig } from './ActionConfig';
10
10
  import { FormConfig } from './FormConfig';
11
- /**
12
- * @returns All the fields in the event configuration.
13
- */
14
- export declare const findAllFields: (config: EventConfig) => FieldConfig[];
15
- export declare const getAllAnnotationFields: (config: EventConfig) => FieldConfig[];
16
- export declare const getActionAnnotationFields: (actionConfig: ActionConfig) => import("./FieldConfig").Inferred[];
17
- /**
18
- * @TODO: Request correction should have same format as print certificate
19
- */
20
- export declare const findRecordActionPages: (config: EventConfig, actionType: ActionType) => PageConfig[];
21
11
  export declare function getDeclarationFields(configuration: EventConfig): FieldConfig[];
22
12
  export declare function getDeclarationPages(configuration: EventConfig): {
23
13
  type: "FORM";
@@ -36,15 +26,58 @@ export declare function getDeclaration(configuration: EventConfig): {
36
26
  conditional?: import(".").JSONSchema | undefined;
37
27
  }[];
38
28
  };
39
- export declare function getActionReviewFields(configuration: EventConfig, actionType: DeclarationAction): import("./FieldConfig").Inferred[];
29
+ export declare const getActionAnnotationFields: (actionConfig: ActionConfig) => import("./FieldConfig").Inferred[];
30
+ export declare const getAllAnnotationFields: (config: EventConfig) => FieldConfig[];
31
+ /**
32
+ * @TODO: Request correction should have same format as print certificate
33
+ */
34
+ export declare const findRecordActionPages: (config: EventConfig, actionType: ActionType) => PageConfig[];
40
35
  export declare function getActionReview(configuration: EventConfig, actionType: ActionType): {
41
36
  title: import("./TranslationConfig").TranslationConfig;
42
37
  fields: import("./FieldConfig").Inferred[];
43
38
  };
39
+ export declare function getActionReviewFields(configuration: EventConfig, actionType: DeclarationActionType): import("./FieldConfig").Inferred[];
44
40
  export declare function validateWorkqueueConfig(workqueueConfigs: WorkqueueConfig[]): void;
45
41
  export declare function isPageVisible(page: PageConfig, formValues: ActionUpdate): boolean;
46
- export declare const getVisiblePagesFormFields: (formConfig: FormConfig, formData: ActionUpdate) => import("./FieldConfig").Inferred[];
47
- export declare function stripHiddenFields(fields: FieldConfig[], declaration: EventState): import("lodash").Dictionary<string | number | boolean | {
42
+ export declare function omitHiddenFields(fields: FieldConfig[], values: EventState): import("lodash").Dictionary<string | number | boolean | {
43
+ type: string;
44
+ filename: string;
45
+ originalFilename: string;
46
+ } | {
47
+ country: string;
48
+ district: string;
49
+ addressType: "DOMESTIC";
50
+ province: string;
51
+ urbanOrRural: "URBAN";
52
+ number?: string | undefined;
53
+ town?: string | undefined;
54
+ residentialArea?: string | undefined;
55
+ street?: string | undefined;
56
+ zipCode?: string | undefined;
57
+ } | {
58
+ country: string;
59
+ district: string;
60
+ addressType: "DOMESTIC";
61
+ province: string;
62
+ urbanOrRural: "RURAL";
63
+ village?: string | undefined;
64
+ } | {
65
+ country: string;
66
+ state: string;
67
+ addressType: "INTERNATIONAL";
68
+ district2: string;
69
+ cityOrTown?: string | undefined;
70
+ addressLine1?: string | undefined;
71
+ addressLine2?: string | undefined;
72
+ addressLine3?: string | undefined;
73
+ postcodeOrZip?: string | undefined;
74
+ } | {
75
+ type: string;
76
+ option: string;
77
+ filename: string;
78
+ originalFilename: string;
79
+ }[] | undefined>;
80
+ export declare function omitHiddenPaginatedFields(formConfig: FormConfig, declaration: EventState): import("lodash").Dictionary<string | number | boolean | {
48
81
  type: string;
49
82
  filename: string;
50
83
  originalFilename: string;
@@ -89,6 +122,7 @@ export declare function findActiveDrafts(event: EventDocument, drafts: Draft[]):
89
122
  transactionId: string;
90
123
  action: {
91
124
  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";
125
+ status: "Rejected" | "Requested" | "Accepted";
92
126
  createdAt: string;
93
127
  createdBy: string;
94
128
  declaration: Record<string, string | number | boolean | {
@@ -129,7 +163,6 @@ export declare function findActiveDrafts(event: EventDocument, drafts: Draft[]):
129
163
  filename: string;
130
164
  originalFilename: string;
131
165
  }[] | undefined>;
132
- createdAtLocation: string;
133
166
  annotation?: Record<string, string | number | boolean | {
134
167
  type: string;
135
168
  filename: string;
@@ -168,6 +201,8 @@ export declare function findActiveDrafts(event: EventDocument, drafts: Draft[]):
168
201
  filename: string;
169
202
  originalFilename: string;
170
203
  }[] | undefined> | undefined;
204
+ createdAtLocation?: string | undefined;
205
+ updatedAtLocation?: string | undefined;
171
206
  originalActionId?: string | undefined;
172
207
  };
173
208
  }[];
@@ -186,42 +221,13 @@ export declare function createEmptyDraft(eventId: string, draftId: string, actio
186
221
  };
187
222
  };
188
223
  export declare function isVerificationPage(page: PageConfig): page is VerificationPageConfig;
189
- export declare function deepMerge(currentDocument: ActionUpdate, actionDocument: ActionUpdate): Record<string, string | number | boolean | {
190
- type: string;
191
- filename: string;
192
- originalFilename: string;
193
- } | {
194
- country: string;
195
- district: string;
196
- addressType: "DOMESTIC";
197
- province: string;
198
- urbanOrRural: "URBAN";
199
- number?: string | null | undefined;
200
- town?: string | null | undefined;
201
- residentialArea?: string | null | undefined;
202
- street?: string | null | undefined;
203
- zipCode?: string | null | undefined;
204
- } | {
205
- country: string;
206
- district: string;
207
- addressType: "DOMESTIC";
208
- province: string;
209
- urbanOrRural: "RURAL";
210
- village?: string | null | undefined;
211
- } | {
212
- country: string;
213
- state: string;
214
- addressType: "INTERNATIONAL";
215
- district2: string;
216
- cityOrTown?: string | null | undefined;
217
- addressLine1?: string | null | undefined;
218
- addressLine2?: string | null | undefined;
219
- addressLine3?: string | null | undefined;
220
- postcodeOrZip?: string | null | undefined;
221
- } | {
222
- type: string;
223
- option: string;
224
- filename: string;
225
- originalFilename: string;
226
- }[] | undefined>;
224
+ export declare function deepMerge<T extends Record<string, unknown>>(currentDocument: T, actionDocument: T): T;
225
+ export declare function findLastAssignmentAction(actions: Action[]): Action | undefined;
226
+ /** Tell compiler that accessing record with arbitrary key might result to undefined
227
+ * Use when you **cannot guarantee** that key exists in the record
228
+ */
229
+ export type IndexMap<T> = {
230
+ [id: string]: T | undefined;
231
+ };
232
+ export declare function isWriteAction(actionType: ActionType): boolean;
227
233
  //# sourceMappingURL=utils.d.ts.map
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=utils.test.d.ts.map