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

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 (45) hide show
  1. package/dist/commons/api/router.d.ts +8398 -831
  2. package/dist/commons/conditionals/conditionals.d.ts +26 -11
  3. package/dist/commons/conditionals/validate.d.ts +18 -17
  4. package/dist/commons/events/ActionConfig.d.ts +120018 -1729
  5. package/dist/commons/events/ActionDocument.d.ts +2581 -554
  6. package/dist/commons/events/ActionInput.d.ts +2674 -499
  7. package/dist/commons/events/ActionType.d.ts +9 -3
  8. package/dist/commons/events/AdvancedSearchConfig.d.ts +1255 -22
  9. package/dist/commons/events/CompositeFieldValue.d.ts +31 -0
  10. package/dist/commons/events/Conditional.d.ts +21 -5
  11. package/dist/commons/events/Constants.d.ts +3 -0
  12. package/dist/commons/events/CountryConfigQueryInput.d.ts +3730 -0
  13. package/dist/commons/events/CreatedAtLocation.d.ts +2 -0
  14. package/dist/commons/events/Draft.d.ts +172 -46
  15. package/dist/commons/events/EventConfig.d.ts +57845 -1354
  16. package/dist/commons/events/EventDocument.d.ts +1635 -391
  17. package/dist/commons/events/EventIndex.d.ts +2007 -27
  18. package/dist/commons/events/EventMetadata.d.ts +343 -45
  19. package/dist/commons/events/FieldConfig.d.ts +5780 -1066
  20. package/dist/commons/events/FieldType.d.ts +6 -3
  21. package/dist/commons/events/FieldTypeMapping.d.ts +103 -54
  22. package/dist/commons/events/FieldValue.d.ts +49 -8
  23. package/dist/commons/events/FormConfig.d.ts +50248 -514
  24. package/dist/commons/events/PageConfig.d.ts +12472 -234
  25. package/dist/commons/events/SummaryConfig.d.ts +93 -42
  26. package/dist/commons/events/TemplateConfig.d.ts +5 -5
  27. package/dist/commons/events/User.d.ts +31 -2
  28. package/dist/commons/events/WorkqueueColumnConfig.d.ts +53 -0
  29. package/dist/commons/events/WorkqueueConfig.d.ts +7300 -20
  30. package/dist/commons/events/defineConfig.d.ts +9289 -58
  31. package/dist/commons/events/event.d.ts +54 -0
  32. package/dist/commons/events/field.d.ts +94 -0
  33. package/dist/commons/events/index.d.ts +8 -0
  34. package/dist/commons/events/scopes.d.ts +44 -0
  35. package/dist/commons/events/serializer.d.ts +2 -0
  36. package/dist/commons/events/test.utils.d.ts +157 -157
  37. package/dist/commons/events/transactions.d.ts +1 -1
  38. package/dist/commons/events/utils.d.ts +13799 -78
  39. package/dist/commons/events/utils.test.d.ts +2 -0
  40. package/dist/commons/events/workqueueDefaultColumns.d.ts +3 -0
  41. package/dist/conditionals/index.js +208 -185
  42. package/dist/events/index.js +4843 -2050
  43. package/dist/scopes/index.d.ts +161 -1
  44. package/dist/scopes/index.js +202 -1
  45. package/package.json +4 -3
@@ -1,53 +1,34 @@
1
- import { ActionDocument, ActionUpdate } from './ActionDocument';
2
- import { ArchiveActionInput, DeclareActionInput, RegisterActionInput, RejectDeclarationActionInput, RequestCorrectionActionInput, ValidateActionInput } from './ActionInput';
1
+ import { UUID } from '../uuid';
2
+ import { ActionDocument, EventState } from './ActionDocument';
3
+ import { ArchiveActionInput, AssignActionInput, DeclareActionInput, NotifyActionInput, RegisterActionInput, 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 generateActionInput(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 generateActionMetadataInput(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
+ * In real application, the roles are defined in the countryconfig.
17
+ * These are just for testing purposes to generate realistic mock data.
18
+ */
19
+ export declare const TestUserRole: z.ZodEnum<["FIELD_AGENT", "LOCAL_REGISTRAR", "LOCAL_SYSTEM_ADMIN", "NATIONAL_REGISTRAR", "REGISTRATION_AGENT"]>;
20
+ export type TestUserRole = z.infer<typeof TestUserRole>;
21
+ export declare function generateRandomName(rng: () => number): {
22
+ firstname: string;
23
+ surname: string;
24
+ };
25
+ /**
26
+ * Quick-and-dirty mock data generator for event actions.
27
+ */
28
+ export declare function mapFieldTypeToMockValue(field: FieldConfig, i: number, rng: () => number): FieldValue;
29
+ export declare function generateActionDeclarationInput(configuration: EventConfig, action: ActionType, rng: () => number): EventState;
30
+ export declare function generateActionAnnotationInput(configuration: EventConfig, action: ActionType, rng: () => number): {};
31
+ export declare function eventPayloadGenerator(rng: () => number): {
51
32
  create: (input?: Partial<EventInput>) => {
52
33
  transactionId: string;
53
34
  type: string;
@@ -57,36 +38,13 @@ export declare const eventPayloadGenerator: {
57
38
  type: string;
58
39
  id: string;
59
40
  };
60
- draft: (eventId: string, input?: Partial<Draft>) => {
61
- id: import("../uuid").UUID;
62
- 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;
41
+ draft: ({ eventId, actionType }: {
42
+ eventId: UUID;
43
+ actionType: ActionType;
44
+ }, input?: Partial<Draft>) => Draft;
45
+ actions: {
46
+ declare: (eventId: string, input?: Partial<Pick<DeclareActionInput, "transactionId" | "declaration" | "annotation" | "keepAssignment">>) => {
47
+ transactionId: string;
90
48
  declaration: Record<string, string | number | boolean | {
91
49
  type: string;
92
50
  filename: string;
@@ -103,44 +61,9 @@ export declare const eventPayloadGenerator: {
103
61
  street?: string | null | undefined;
104
62
  zipCode?: string | null | undefined;
105
63
  } | {
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;
64
+ firstname: string;
65
+ surname: string;
66
+ middlename?: string | null | undefined;
144
67
  } | {
145
68
  country: string;
146
69
  district: string;
@@ -163,13 +86,17 @@ export declare const eventPayloadGenerator: {
163
86
  option: string;
164
87
  filename: string;
165
88
  originalFilename: string;
166
- }[] | undefined> | undefined;
167
- originalActionId?: string | undefined;
168
- };
169
- }>;
170
- actions: {
171
- declare: (eventId: string, input?: Partial<Pick<DeclareActionInput, "transactionId" | "declaration" | "annotation">>) => {
89
+ }[] | [string, string] | null | undefined>;
90
+ annotation: {};
91
+ keepAssignment?: boolean | undefined;
172
92
  type: "DECLARE";
93
+ eventId: string;
94
+ };
95
+ /**
96
+ * Notify allows sending incomplete data. Think it as 'partial declare' for now.
97
+ */
98
+ notify: (eventId: string, input?: Partial<Pick<NotifyActionInput, "transactionId" | "declaration" | "keepAssignment">>) => {
99
+ type: "NOTIFY";
173
100
  transactionId: string;
174
101
  declaration: Record<string, string | number | boolean | {
175
102
  type: string;
@@ -186,6 +113,10 @@ export declare const eventPayloadGenerator: {
186
113
  residentialArea?: string | null | undefined;
187
114
  street?: string | null | undefined;
188
115
  zipCode?: string | null | undefined;
116
+ } | {
117
+ firstname: string;
118
+ surname: string;
119
+ middlename?: string | null | undefined;
189
120
  } | {
190
121
  country: string;
191
122
  district: string;
@@ -208,20 +139,13 @@ export declare const eventPayloadGenerator: {
208
139
  option: string;
209
140
  filename: string;
210
141
  originalFilename: string;
211
- }[] | undefined>;
212
- annotation: {};
142
+ }[] | [string, string] | null | undefined>;
213
143
  eventId: string;
144
+ keepAssignment: boolean | undefined;
214
145
  };
215
- /**
216
- * Notify allows sending incomplete data. Think it as 'partial declare' for now.
217
- */
218
- notify: (eventId: string, input?: {
219
- transactionId?: string;
220
- declaration?: Partial<ActionUpdate>;
221
- }) => {
222
- type: "NOTIFY";
146
+ validate: (eventId: string, input?: Partial<Pick<ValidateActionInput, "transactionId" | "declaration" | "annotation" | "keepAssignment">>) => {
223
147
  transactionId: string;
224
- declaration: Partial<Record<string, string | number | boolean | {
148
+ declaration: Record<string, string | number | boolean | {
225
149
  type: string;
226
150
  filename: string;
227
151
  originalFilename: string;
@@ -236,6 +160,10 @@ export declare const eventPayloadGenerator: {
236
160
  residentialArea?: string | null | undefined;
237
161
  street?: string | null | undefined;
238
162
  zipCode?: string | null | undefined;
163
+ } | {
164
+ firstname: string;
165
+ surname: string;
166
+ middlename?: string | null | undefined;
239
167
  } | {
240
168
  country: string;
241
169
  district: string;
@@ -258,11 +186,28 @@ export declare const eventPayloadGenerator: {
258
186
  option: string;
259
187
  filename: string;
260
188
  originalFilename: string;
261
- }[] | undefined>>;
189
+ }[] | [string, string] | null | undefined>;
190
+ annotation: {};
191
+ keepAssignment?: boolean | undefined;
192
+ type: "VALIDATE";
193
+ duplicates: never[];
262
194
  eventId: string;
263
195
  };
264
- validate: (eventId: string, input?: Partial<Pick<ValidateActionInput, "transactionId" | "declaration" | "annotation">>) => {
265
- type: "VALIDATE";
196
+ assign: (eventId: string, input?: Partial<Pick<AssignActionInput, "transactionId" | "assignedTo">>) => {
197
+ type: "ASSIGN";
198
+ transactionId: string;
199
+ declaration: {};
200
+ assignedTo: string;
201
+ eventId: string;
202
+ };
203
+ unassign: (eventId: string, input?: Partial<Pick<UnassignActionInput, "transactionId">>) => {
204
+ type: "UNASSIGN";
205
+ transactionId: string;
206
+ declaration: {};
207
+ assignedTo: null;
208
+ eventId: string;
209
+ };
210
+ archive: (eventId: string, input?: Partial<Pick<ArchiveActionInput, "transactionId" | "declaration" | "keepAssignment">>, isDuplicate?: boolean) => {
266
211
  transactionId: string;
267
212
  declaration: Record<string, string | number | boolean | {
268
213
  type: string;
@@ -279,6 +224,10 @@ export declare const eventPayloadGenerator: {
279
224
  residentialArea?: string | null | undefined;
280
225
  street?: string | null | undefined;
281
226
  zipCode?: string | null | undefined;
227
+ } | {
228
+ firstname: string;
229
+ surname: string;
230
+ middlename?: string | null | undefined;
282
231
  } | {
283
232
  country: string;
284
233
  district: string;
@@ -301,31 +250,30 @@ export declare const eventPayloadGenerator: {
301
250
  option: string;
302
251
  filename: string;
303
252
  originalFilename: string;
304
- }[] | undefined>;
253
+ }[] | [string, string] | null | undefined>;
254
+ keepAssignment?: boolean | undefined;
255
+ type: "ARCHIVE";
305
256
  annotation: {};
306
257
  duplicates: never[];
307
258
  eventId: string;
308
- };
309
- archive: (eventId: string, input?: Partial<Pick<ArchiveActionInput, "transactionId" | "declaration">>, isDuplicate?: boolean) => {
310
- type: "ARCHIVE";
311
- transactionId: string;
312
- declaration: {};
313
- annotation: {
259
+ reason: {
260
+ message: string;
314
261
  isDuplicate: boolean;
315
262
  };
316
- duplicates: never[];
317
- eventId: string;
318
263
  };
319
- reject: (eventId: string, input?: Partial<Pick<RejectDeclarationActionInput, "transactionId" | "annotation">>) => {
320
- type: "REJECT";
264
+ reject: (eventId: string, input?: Partial<Pick<RejectDeclarationActionInput, "transactionId" | "annotation" | "keepAssignment">>) => {
321
265
  transactionId: string;
322
- declaration: {};
323
266
  annotation: {};
267
+ keepAssignment?: boolean | undefined;
268
+ type: "REJECT";
269
+ declaration: {};
324
270
  duplicates: never[];
325
271
  eventId: string;
272
+ reason: {
273
+ message: string;
274
+ };
326
275
  };
327
- register: (eventId: string, input?: Partial<Pick<RegisterActionInput, "transactionId" | "declaration" | "annotation">>) => {
328
- type: "REGISTER";
276
+ register: (eventId: string, input?: Partial<Pick<RegisterActionInput, "transactionId" | "declaration" | "annotation" | "keepAssignment" | "registrationNumber">>) => {
329
277
  transactionId: string;
330
278
  declaration: Record<string, string | number | boolean | {
331
279
  type: string;
@@ -342,6 +290,10 @@ export declare const eventPayloadGenerator: {
342
290
  residentialArea?: string | null | undefined;
343
291
  street?: string | null | undefined;
344
292
  zipCode?: string | null | undefined;
293
+ } | {
294
+ firstname: string;
295
+ surname: string;
296
+ middlename?: string | null | undefined;
345
297
  } | {
346
298
  country: string;
347
299
  district: string;
@@ -364,19 +316,23 @@ export declare const eventPayloadGenerator: {
364
316
  option: string;
365
317
  filename: string;
366
318
  originalFilename: string;
367
- }[] | undefined>;
319
+ }[] | [string, string] | null | undefined>;
368
320
  annotation: {};
321
+ registrationNumber?: string | undefined;
322
+ keepAssignment?: boolean | undefined;
323
+ type: "REGISTER";
369
324
  eventId: string;
370
325
  };
371
- printCertificate: (eventId: string, input?: Partial<Pick<RegisterActionInput, "transactionId" | "annotation">>) => {
372
- type: "PRINT_CERTIFICATE";
326
+ printCertificate: (eventId: string, input?: Partial<Pick<RegisterActionInput, "transactionId" | "annotation" | "keepAssignment">>) => {
373
327
  transactionId: string;
374
- declaration: {};
375
328
  annotation: {};
329
+ keepAssignment?: boolean | undefined;
330
+ type: "PRINT_CERTIFICATE";
331
+ declaration: {};
376
332
  eventId: string;
377
333
  };
378
334
  correction: {
379
- request: (eventId: string, input?: Partial<Pick<RequestCorrectionActionInput, "transactionId" | "declaration" | "annotation">>) => {
335
+ request: (eventId: string, input?: Partial<Pick<RequestCorrectionActionInput, "transactionId" | "declaration" | "annotation" | "keepAssignment">>) => {
380
336
  type: "REQUEST_CORRECTION";
381
337
  transactionId: string;
382
338
  declaration: Record<string, string | number | boolean | {
@@ -394,6 +350,10 @@ export declare const eventPayloadGenerator: {
394
350
  residentialArea?: string | null | undefined;
395
351
  street?: string | null | undefined;
396
352
  zipCode?: string | null | undefined;
353
+ } | {
354
+ firstname: string;
355
+ surname: string;
356
+ middlename?: string | null | undefined;
397
357
  } | {
398
358
  country: string;
399
359
  district: string;
@@ -416,39 +376,79 @@ export declare const eventPayloadGenerator: {
416
376
  option: string;
417
377
  filename: string;
418
378
  originalFilename: string;
419
- }[] | undefined>;
379
+ }[] | [string, string] | null | undefined>;
420
380
  annotation: {};
421
381
  eventId: string;
382
+ keepAssignment: boolean | undefined;
422
383
  };
423
- approve: (eventId: string, requestId: string, input?: Partial<Pick<RequestCorrectionActionInput, "transactionId" | "annotation">>) => {
384
+ approve: (eventId: string, requestId: string, input?: Partial<Pick<RequestCorrectionActionInput, "transactionId" | "annotation" | "keepAssignment">>) => {
424
385
  type: "APPROVE_CORRECTION";
425
386
  transactionId: string;
426
387
  declaration: {};
427
388
  annotation: {};
428
389
  eventId: string;
429
390
  requestId: string;
391
+ keepAssignment: boolean | undefined;
430
392
  };
431
- reject: (eventId: string, requestId: string, input?: Partial<Pick<RequestCorrectionActionInput, "transactionId" | "annotation">>) => {
393
+ reject: (eventId: string, requestId: string, input?: Partial<Pick<RequestCorrectionActionInput, "transactionId" | "annotation" | "keepAssignment">>) => {
432
394
  type: "REJECT_CORRECTION";
433
395
  transactionId: string;
434
396
  declaration: {};
435
397
  annotation: {};
436
398
  eventId: string;
437
399
  requestId: string;
400
+ keepAssignment: boolean | undefined;
438
401
  };
439
402
  };
440
403
  };
441
404
  };
442
- export declare function generateActionDocument({ configuration, action, defaults }: {
405
+ export declare function generateActionDocument({ configuration, action, rng, defaults, user }: {
443
406
  configuration: EventConfig;
444
407
  action: ActionType;
408
+ rng?: () => number;
445
409
  defaults?: Partial<ActionDocument>;
410
+ user?: Partial<{
411
+ signature: string;
412
+ primaryOfficeId: UUID;
413
+ role: TestUserRole;
414
+ id: string;
415
+ }>;
446
416
  }): ActionDocument;
447
- export declare function generateEventDocument({ configuration, actions }: {
417
+ export declare function generateEventDocument({ configuration, actions, rng, user }: {
448
418
  configuration: EventConfig;
449
419
  actions: ActionType[];
420
+ rng?: () => number;
421
+ user?: Partial<{
422
+ signature: string;
423
+ primaryOfficeId: UUID;
424
+ role: TestUserRole;
425
+ id: string;
426
+ }>;
450
427
  }): EventDocument;
451
- export declare function generateEventDraftDocument(eventId: string, actionType?: ActionType, declaration?: Record<string, FieldValue>): Draft;
452
- export declare const eventQueryDataGenerator: (overrides?: Partial<EventIndex>) => EventIndex;
428
+ export declare function generateEventDraftDocument({ eventId, actionType, rng, declaration }: {
429
+ eventId: UUID;
430
+ actionType: ActionType;
431
+ rng?: () => number;
432
+ declaration?: EventState;
433
+ }): Draft;
434
+ export declare function getRandomDatetime(rng: () => number, start: Date, end: Date): string;
435
+ export declare function getRandomDate(rng: () => number, start: string, end: string): string;
436
+ /**
437
+ * Useful for testing when we need deterministic outcome.
438
+ * @param seed - Seed value for the pseudo-random number generator
439
+ *
440
+ * @returns A function that generates pseudo-random numbers between 0 and 1 [0, 1)
441
+ */
442
+ export declare function createPrng(seed: number): () => number;
443
+ export declare function generateUuid(rng?: () => number): UUID;
444
+ export declare function generateRegistrationNumber(rng: () => number): string;
445
+ export declare function generateRandomSignature(rng: () => number): string;
446
+ export declare const eventQueryDataGenerator: (overrides?: Partial<EventIndex>, seed?: number) => EventIndex;
453
447
  export declare const generateTranslationConfig: (message: string) => TranslationConfig;
448
+ export declare const BearerTokenByUserType: {
449
+ fieldAgent: string;
450
+ registrationAgent: string;
451
+ localRegistrar: string;
452
+ };
453
+ export declare const generateWorkqueues: (slug?: string) => WorkqueueConfig[];
454
454
  //# 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