@opencrvs/toolkit 1.8.1-rc.a372970 → 1.8.1-rc.a9d9f0d

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 (47) hide show
  1. package/dist/commons/api/router.d.ts +5951 -5078
  2. package/dist/commons/conditionals/conditionals.d.ts +9 -13
  3. package/dist/commons/conditionals/validate.d.ts +25 -7
  4. package/dist/commons/events/ActionConfig.d.ts +120964 -1729
  5. package/dist/commons/events/ActionDocument.d.ts +5425 -1299
  6. package/dist/commons/events/ActionInput.d.ts +3267 -1025
  7. package/dist/commons/events/ActionType.d.ts +10 -1
  8. package/dist/commons/events/AdvancedSearchConfig.d.ts +1300 -22
  9. package/dist/commons/events/CompositeFieldValue.d.ts +40 -9
  10. package/dist/commons/events/Constants.d.ts +3 -0
  11. package/dist/commons/events/CountryConfigQueryInput.d.ts +4132 -0
  12. package/dist/commons/events/CreatedAtLocation.d.ts +2 -0
  13. package/dist/commons/events/Draft.d.ts +288 -97
  14. package/dist/commons/events/EventConfig.d.ts +54890 -1357
  15. package/dist/commons/events/EventDocument.d.ts +2765 -833
  16. package/dist/commons/events/EventIndex.d.ts +2350 -29
  17. package/dist/commons/events/EventMetadata.d.ts +347 -47
  18. package/dist/commons/events/FieldConfig.d.ts +6985 -1278
  19. package/dist/commons/events/FieldType.d.ts +8 -3
  20. package/dist/commons/events/FieldTypeMapping.d.ts +161 -73
  21. package/dist/commons/events/FieldValue.d.ts +91 -20
  22. package/dist/commons/events/FormConfig.d.ts +56556 -522
  23. package/dist/commons/events/PageConfig.d.ts +14043 -209
  24. package/dist/commons/events/SummaryConfig.d.ts +93 -42
  25. package/dist/commons/events/User.d.ts +34 -2
  26. package/dist/commons/events/WorkqueueColumnConfig.d.ts +53 -0
  27. package/dist/commons/events/WorkqueueConfig.d.ts +8240 -20
  28. package/dist/commons/events/defineConfig.d.ts +8628 -77
  29. package/dist/commons/events/event.d.ts +108 -0
  30. package/dist/commons/events/field.d.ts +108 -0
  31. package/dist/commons/events/index.d.ts +8 -0
  32. package/dist/commons/events/scopes.d.ts +45 -0
  33. package/dist/commons/events/serializer.d.ts +2 -0
  34. package/dist/commons/events/test.utils.d.ts +210 -90
  35. package/dist/commons/events/transactions.d.ts +1 -1
  36. package/dist/commons/events/utils.d.ts +15612 -88
  37. package/dist/commons/events/workqueueDefaultColumns.d.ts +3 -0
  38. package/dist/conditionals/index.js +69 -58
  39. package/dist/events/index.js +4840 -1798
  40. package/dist/scopes/index.d.ts +184 -7
  41. package/dist/scopes/index.js +140 -40
  42. package/package.json +4 -3
  43. package/tsconfig.json +1 -1
  44. package/dist/commons/conditionals/conditionals.test.d.ts +0 -2
  45. package/dist/commons/conditionals/validate-address.test.d.ts +0 -2
  46. package/dist/commons/conditionals/validate.test.d.ts +0 -2
  47. package/dist/commons/events/utils.test.d.ts +0 -2
@@ -1,53 +1,39 @@
1
- import { ActionDocument, ActionUpdate } from './ActionDocument';
2
- import { ArchiveActionInput, AssignActionInput, DeclareActionInput, RegisterActionInput, RejectDeclarationActionInput, RequestCorrectionActionInput, UnassignActionInput, ValidateActionInput } from './ActionInput';
1
+ import { UUID } from '../uuid';
2
+ import { ActionDocument, EventState } from './ActionDocument';
3
+ import { ApproveCorrectionActionInput, ArchiveActionInput, AssignActionInput, DeclareActionInput, NotifyActionInput, RegisterActionInput, RejectCorrectionActionInput, RejectDeclarationActionInput, RequestCorrectionActionInput, UnassignActionInput, ValidateActionInput } from './ActionInput';
3
4
  import { ActionType } from './ActionType';
4
5
  import { Draft } from './Draft';
5
6
  import { EventConfig } from './EventConfig';
6
7
  import { EventDocument } from './EventDocument';
7
8
  import { EventIndex } from './EventIndex';
8
9
  import { EventInput } from './EventInput';
9
- import { FieldValue } from './FieldValue';
10
10
  import { TranslationConfig } from './TranslationConfig';
11
- export declare function generateActionDeclarationInput(configuration: EventConfig, action: ActionType): import("lodash").Dictionary<string | number | boolean | {
12
- type: string;
13
- filename: string;
14
- originalFilename: string;
15
- } | {
16
- country: string;
17
- district: string;
18
- addressType: "DOMESTIC";
19
- province: string;
20
- urbanOrRural: "URBAN";
21
- number?: string | undefined;
22
- town?: string | undefined;
23
- residentialArea?: string | undefined;
24
- street?: string | undefined;
25
- zipCode?: string | undefined;
26
- } | {
27
- country: string;
28
- district: string;
29
- addressType: "DOMESTIC";
30
- province: string;
31
- urbanOrRural: "RURAL";
32
- village?: string | undefined;
33
- } | {
34
- country: string;
35
- state: string;
36
- addressType: "INTERNATIONAL";
37
- district2: string;
38
- cityOrTown?: string | undefined;
39
- addressLine1?: string | undefined;
40
- addressLine2?: string | undefined;
41
- addressLine3?: string | undefined;
42
- postcodeOrZip?: string | undefined;
43
- } | {
44
- type: string;
45
- option: string;
46
- filename: string;
47
- originalFilename: string;
48
- }[] | undefined>;
49
- export declare function generateActionAnnotationInput(configuration: EventConfig, action: ActionType): {};
50
- export declare const eventPayloadGenerator: {
11
+ import { FieldConfig } from './FieldConfig';
12
+ import { WorkqueueConfig } from './WorkqueueConfig';
13
+ import { FieldValue } from './FieldValue';
14
+ import { z } from 'zod';
15
+ /**
16
+ * IANA timezone used in testing. Used for queries that expect similar results independent of the users location (e.g. when event was registered.)
17
+ * Since we query by range, providing UTC offset will result to different results when DST changes during the range.
18
+ */
19
+ export declare const TEST_SYSTEM_IANA_TIMEZONE = "Asia/Dhaka";
20
+ /**
21
+ * In real application, the roles are defined in the countryconfig.
22
+ * These are just for testing purposes to generate realistic mock data.
23
+ */
24
+ export declare const TestUserRole: z.ZodEnum<["FIELD_AGENT", "LOCAL_REGISTRAR", "LOCAL_SYSTEM_ADMIN", "NATIONAL_REGISTRAR", "REGISTRATION_AGENT"]>;
25
+ export type TestUserRole = z.infer<typeof TestUserRole>;
26
+ export declare function generateRandomName(rng: () => number): {
27
+ firstname: string;
28
+ surname: string;
29
+ };
30
+ /**
31
+ * Quick-and-dirty mock data generator for event actions.
32
+ */
33
+ export declare function mapFieldTypeToMockValue(field: FieldConfig, i: number, rng: () => number): FieldValue;
34
+ export declare function generateActionDeclarationInput(configuration: EventConfig, action: ActionType, rng: () => number): EventState;
35
+ export declare function generateActionAnnotationInput(configuration: EventConfig, action: ActionType, rng: () => number): {};
36
+ export declare function eventPayloadGenerator(rng: () => number): {
51
37
  create: (input?: Partial<EventInput>) => {
52
38
  transactionId: string;
53
39
  type: string;
@@ -57,17 +43,17 @@ export declare const eventPayloadGenerator: {
57
43
  type: string;
58
44
  id: string;
59
45
  };
60
- draft: ({ eventId, actionType }: {
61
- eventId: string;
46
+ draft: ({ eventId, actionType, annotation }: {
47
+ eventId: UUID;
62
48
  actionType: ActionType;
49
+ annotation?: Record<string, any>;
63
50
  }, input?: Partial<Draft>) => Draft;
64
51
  actions: {
65
- declare: (eventId: string, input?: Partial<Pick<DeclareActionInput, "transactionId" | "declaration" | "annotation">>) => {
66
- type: "DECLARE";
52
+ declare: (eventId: string, input?: Partial<Pick<DeclareActionInput, "transactionId" | "declaration" | "annotation" | "keepAssignment">>) => {
67
53
  transactionId: string;
68
54
  declaration: Record<string, string | number | boolean | {
69
55
  type: string;
70
- filename: string;
56
+ path: string;
71
57
  originalFilename: string;
72
58
  } | {
73
59
  country: string;
@@ -80,6 +66,10 @@ export declare const eventPayloadGenerator: {
80
66
  residentialArea?: string | null | undefined;
81
67
  street?: string | null | undefined;
82
68
  zipCode?: string | null | undefined;
69
+ } | {
70
+ firstname: string;
71
+ surname: string;
72
+ middlename?: string | null | undefined;
83
73
  } | {
84
74
  country: string;
85
75
  district: string;
@@ -100,24 +90,26 @@ export declare const eventPayloadGenerator: {
100
90
  } | {
101
91
  type: string;
102
92
  option: string;
103
- filename: string;
93
+ path: string;
104
94
  originalFilename: string;
105
- }[] | undefined>;
95
+ }[] | {
96
+ start: string;
97
+ end: string;
98
+ } | null | undefined>;
106
99
  annotation: {};
100
+ keepAssignment?: boolean | undefined;
101
+ type: "DECLARE";
107
102
  eventId: string;
108
103
  };
109
104
  /**
110
105
  * Notify allows sending incomplete data. Think it as 'partial declare' for now.
111
106
  */
112
- notify: (eventId: string, input?: {
113
- transactionId?: string;
114
- declaration?: Partial<ActionUpdate>;
115
- }) => {
107
+ notify: (eventId: string, input?: Partial<Pick<NotifyActionInput, "transactionId" | "declaration" | "keepAssignment">>) => {
116
108
  type: "NOTIFY";
117
109
  transactionId: string;
118
- declaration: Partial<Record<string, string | number | boolean | {
110
+ declaration: Record<string, string | number | boolean | {
119
111
  type: string;
120
- filename: string;
112
+ path: string;
121
113
  originalFilename: string;
122
114
  } | {
123
115
  country: string;
@@ -130,6 +122,10 @@ export declare const eventPayloadGenerator: {
130
122
  residentialArea?: string | null | undefined;
131
123
  street?: string | null | undefined;
132
124
  zipCode?: string | null | undefined;
125
+ } | {
126
+ firstname: string;
127
+ surname: string;
128
+ middlename?: string | null | undefined;
133
129
  } | {
134
130
  country: string;
135
131
  district: string;
@@ -150,17 +146,20 @@ export declare const eventPayloadGenerator: {
150
146
  } | {
151
147
  type: string;
152
148
  option: string;
153
- filename: string;
149
+ path: string;
154
150
  originalFilename: string;
155
- }[] | undefined>>;
151
+ }[] | {
152
+ start: string;
153
+ end: string;
154
+ } | null | undefined>;
156
155
  eventId: string;
156
+ keepAssignment: boolean | undefined;
157
157
  };
158
- validate: (eventId: string, input?: Partial<Pick<ValidateActionInput, "transactionId" | "declaration" | "annotation">>) => {
159
- type: "VALIDATE";
158
+ validate: (eventId: string, input?: Partial<Pick<ValidateActionInput, "transactionId" | "declaration" | "annotation" | "keepAssignment">>) => {
160
159
  transactionId: string;
161
160
  declaration: Record<string, string | number | boolean | {
162
161
  type: string;
163
- filename: string;
162
+ path: string;
164
163
  originalFilename: string;
165
164
  } | {
166
165
  country: string;
@@ -173,6 +172,10 @@ export declare const eventPayloadGenerator: {
173
172
  residentialArea?: string | null | undefined;
174
173
  street?: string | null | undefined;
175
174
  zipCode?: string | null | undefined;
175
+ } | {
176
+ firstname: string;
177
+ surname: string;
178
+ middlename?: string | null | undefined;
176
179
  } | {
177
180
  country: string;
178
181
  district: string;
@@ -193,10 +196,15 @@ export declare const eventPayloadGenerator: {
193
196
  } | {
194
197
  type: string;
195
198
  option: string;
196
- filename: string;
199
+ path: string;
197
200
  originalFilename: string;
198
- }[] | undefined>;
201
+ }[] | {
202
+ start: string;
203
+ end: string;
204
+ } | null | undefined>;
199
205
  annotation: {};
206
+ keepAssignment?: boolean | undefined;
207
+ type: "VALIDATE";
200
208
  duplicates: never[];
201
209
  eventId: string;
202
210
  };
@@ -214,30 +222,80 @@ export declare const eventPayloadGenerator: {
214
222
  assignedTo: null;
215
223
  eventId: string;
216
224
  };
217
- archive: (eventId: string, input?: Partial<Pick<ArchiveActionInput, "transactionId" | "declaration">>, isDuplicate?: boolean) => {
218
- type: "ARCHIVE";
225
+ archive: (eventId: string, input?: Partial<Pick<ArchiveActionInput, "transactionId" | "declaration" | "keepAssignment">>, isDuplicate?: boolean) => {
219
226
  transactionId: string;
220
- declaration: {};
221
- annotation: {
222
- isDuplicate: boolean;
223
- };
227
+ declaration: Record<string, string | number | boolean | {
228
+ type: string;
229
+ path: string;
230
+ originalFilename: string;
231
+ } | {
232
+ country: string;
233
+ district: string;
234
+ addressType: "DOMESTIC";
235
+ province: string;
236
+ urbanOrRural: "URBAN";
237
+ number?: string | null | undefined;
238
+ town?: string | null | undefined;
239
+ residentialArea?: string | null | undefined;
240
+ street?: string | null | undefined;
241
+ zipCode?: string | null | undefined;
242
+ } | {
243
+ firstname: string;
244
+ surname: string;
245
+ middlename?: string | null | undefined;
246
+ } | {
247
+ country: string;
248
+ district: string;
249
+ addressType: "DOMESTIC";
250
+ province: string;
251
+ urbanOrRural: "RURAL";
252
+ village?: string | null | undefined;
253
+ } | {
254
+ country: string;
255
+ state: string;
256
+ addressType: "INTERNATIONAL";
257
+ district2: string;
258
+ cityOrTown?: string | null | undefined;
259
+ addressLine1?: string | null | undefined;
260
+ addressLine2?: string | null | undefined;
261
+ addressLine3?: string | null | undefined;
262
+ postcodeOrZip?: string | null | undefined;
263
+ } | {
264
+ type: string;
265
+ option: string;
266
+ path: string;
267
+ originalFilename: string;
268
+ }[] | {
269
+ start: string;
270
+ end: string;
271
+ } | null | undefined>;
272
+ keepAssignment?: boolean | undefined;
273
+ type: "ARCHIVE";
274
+ annotation: {};
224
275
  duplicates: never[];
225
276
  eventId: string;
277
+ reason: {
278
+ message: string;
279
+ isDuplicate: boolean;
280
+ };
226
281
  };
227
- reject: (eventId: string, input?: Partial<Pick<RejectDeclarationActionInput, "transactionId" | "annotation">>) => {
228
- type: "REJECT";
282
+ reject: (eventId: string, input?: Partial<Pick<RejectDeclarationActionInput, "transactionId" | "annotation" | "keepAssignment">>) => {
229
283
  transactionId: string;
230
- declaration: {};
231
284
  annotation: {};
285
+ keepAssignment?: boolean | undefined;
286
+ type: "REJECT";
287
+ declaration: {};
232
288
  duplicates: never[];
233
289
  eventId: string;
290
+ reason: {
291
+ message: string;
292
+ };
234
293
  };
235
- register: (eventId: string, input?: Partial<Pick<RegisterActionInput, "transactionId" | "declaration" | "annotation">>) => {
236
- type: "REGISTER";
294
+ register: (eventId: string, input?: Partial<Pick<RegisterActionInput, "transactionId" | "declaration" | "annotation" | "keepAssignment" | "registrationNumber">>) => {
237
295
  transactionId: string;
238
296
  declaration: Record<string, string | number | boolean | {
239
297
  type: string;
240
- filename: string;
298
+ path: string;
241
299
  originalFilename: string;
242
300
  } | {
243
301
  country: string;
@@ -250,6 +308,10 @@ export declare const eventPayloadGenerator: {
250
308
  residentialArea?: string | null | undefined;
251
309
  street?: string | null | undefined;
252
310
  zipCode?: string | null | undefined;
311
+ } | {
312
+ firstname: string;
313
+ surname: string;
314
+ middlename?: string | null | undefined;
253
315
  } | {
254
316
  country: string;
255
317
  district: string;
@@ -270,26 +332,33 @@ export declare const eventPayloadGenerator: {
270
332
  } | {
271
333
  type: string;
272
334
  option: string;
273
- filename: string;
335
+ path: string;
274
336
  originalFilename: string;
275
- }[] | undefined>;
337
+ }[] | {
338
+ start: string;
339
+ end: string;
340
+ } | null | undefined>;
276
341
  annotation: {};
342
+ registrationNumber?: string | undefined;
343
+ keepAssignment?: boolean | undefined;
344
+ type: "REGISTER";
277
345
  eventId: string;
278
346
  };
279
- printCertificate: (eventId: string, input?: Partial<Pick<RegisterActionInput, "transactionId" | "annotation">>) => {
280
- type: "PRINT_CERTIFICATE";
347
+ printCertificate: (eventId: string, input?: Partial<Pick<RegisterActionInput, "transactionId" | "annotation" | "keepAssignment">>) => {
281
348
  transactionId: string;
282
- declaration: {};
283
349
  annotation: {};
350
+ keepAssignment?: boolean | undefined;
351
+ type: "PRINT_CERTIFICATE";
352
+ declaration: {};
284
353
  eventId: string;
285
354
  };
286
355
  correction: {
287
- request: (eventId: string, input?: Partial<Pick<RequestCorrectionActionInput, "transactionId" | "declaration" | "annotation">>) => {
356
+ request: (eventId: string, input?: Partial<Pick<RequestCorrectionActionInput, "transactionId" | "declaration" | "annotation" | "keepAssignment">>) => {
288
357
  type: "REQUEST_CORRECTION";
289
358
  transactionId: string;
290
359
  declaration: Record<string, string | number | boolean | {
291
360
  type: string;
292
- filename: string;
361
+ path: string;
293
362
  originalFilename: string;
294
363
  } | {
295
364
  country: string;
@@ -302,6 +371,10 @@ export declare const eventPayloadGenerator: {
302
371
  residentialArea?: string | null | undefined;
303
372
  street?: string | null | undefined;
304
373
  zipCode?: string | null | undefined;
374
+ } | {
375
+ firstname: string;
376
+ surname: string;
377
+ middlename?: string | null | undefined;
305
378
  } | {
306
379
  country: string;
307
380
  district: string;
@@ -322,41 +395,88 @@ export declare const eventPayloadGenerator: {
322
395
  } | {
323
396
  type: string;
324
397
  option: string;
325
- filename: string;
398
+ path: string;
326
399
  originalFilename: string;
327
- }[] | undefined>;
400
+ }[] | {
401
+ start: string;
402
+ end: string;
403
+ } | null | undefined>;
328
404
  annotation: {};
329
405
  eventId: string;
406
+ keepAssignment: boolean | undefined;
330
407
  };
331
- approve: (eventId: string, requestId: string, input?: Partial<Pick<RequestCorrectionActionInput, "transactionId" | "annotation">>) => {
408
+ approve: (eventId: string, requestId: string, input?: Partial<Pick<ApproveCorrectionActionInput, "transactionId" | "annotation" | "keepAssignment">>) => {
332
409
  type: "APPROVE_CORRECTION";
333
410
  transactionId: string;
334
411
  declaration: {};
335
412
  annotation: {};
336
413
  eventId: string;
337
414
  requestId: string;
415
+ keepAssignment: boolean | undefined;
338
416
  };
339
- reject: (eventId: string, requestId: string, input?: Partial<Pick<RequestCorrectionActionInput, "transactionId" | "annotation">>) => {
417
+ reject: (eventId: string, requestId: string, input: Partial<Pick<RejectCorrectionActionInput, "transactionId" | "annotation" | "keepAssignment" | "reason">>) => {
340
418
  type: "REJECT_CORRECTION";
341
419
  transactionId: string;
342
420
  declaration: {};
343
421
  annotation: {};
344
422
  eventId: string;
345
423
  requestId: string;
424
+ keepAssignment: boolean | undefined;
425
+ reason: {
426
+ message: string;
427
+ isDuplicate?: boolean | undefined;
428
+ };
346
429
  };
347
430
  };
348
431
  };
349
432
  };
350
- export declare function generateActionDocument({ configuration, action, defaults }: {
433
+ export declare function generateActionDocument({ configuration, action, rng, defaults, user }: {
351
434
  configuration: EventConfig;
352
435
  action: ActionType;
436
+ rng?: () => number;
353
437
  defaults?: Partial<ActionDocument>;
438
+ user?: Partial<{
439
+ signature: string;
440
+ primaryOfficeId: UUID;
441
+ role: TestUserRole;
442
+ id: string;
443
+ }>;
354
444
  }): ActionDocument;
355
- export declare function generateEventDocument({ configuration, actions }: {
445
+ export declare function generateEventDocument({ configuration, actions, rng, user }: {
356
446
  configuration: EventConfig;
357
447
  actions: ActionType[];
448
+ rng?: () => number;
449
+ user?: Partial<{
450
+ signature: string;
451
+ primaryOfficeId: UUID;
452
+ role: TestUserRole;
453
+ id: string;
454
+ }>;
358
455
  }): EventDocument;
359
- export declare function generateEventDraftDocument(eventId: string, actionType?: ActionType, declaration?: Record<string, FieldValue>): Draft;
360
- export declare const eventQueryDataGenerator: (overrides?: Partial<EventIndex>) => EventIndex;
456
+ export declare function generateEventDraftDocument({ eventId, actionType, rng, declaration }: {
457
+ eventId: UUID;
458
+ actionType: ActionType;
459
+ rng?: () => number;
460
+ declaration?: EventState;
461
+ }): Draft;
462
+ export declare function getRandomDatetime(rng: () => number, start: Date, end: Date): string;
463
+ export declare function getRandomDate(rng: () => number, start: string, end: string): string;
464
+ /**
465
+ * Useful for testing when we need deterministic outcome.
466
+ * @param seed - Seed value for the pseudo-random number generator
467
+ *
468
+ * @returns A function that generates pseudo-random numbers between 0 and 1 [0, 1)
469
+ */
470
+ export declare function createPrng(seed: number): () => number;
471
+ export declare function generateUuid(rng?: () => number): UUID;
472
+ export declare function generateRegistrationNumber(rng: () => number): string;
473
+ export declare function generateRandomSignature(rng: () => number): string;
474
+ export declare const eventQueryDataGenerator: (overrides?: Partial<EventIndex>, seed?: number) => EventIndex;
361
475
  export declare const generateTranslationConfig: (message: string) => TranslationConfig;
476
+ export declare const BearerTokenByUserType: {
477
+ fieldAgent: string;
478
+ registrationAgent: string;
479
+ localRegistrar: string;
480
+ };
481
+ export declare const generateWorkqueues: (slug?: string) => WorkqueueConfig[];
362
482
  //# sourceMappingURL=test.utils.d.ts.map
@@ -1,2 +1,2 @@
1
- export declare function generateTransactionId(): import("../uuid").UUID;
1
+ export declare function generateTransactionId(): string & import("zod").BRAND<"UUID">;
2
2
  //# sourceMappingURL=transactions.d.ts.map