@opencrvs/toolkit 1.8.0-rc.fe87a15 → 1.8.0-rc.fe8c092

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 (38) hide show
  1. package/dist/commons/api/router.d.ts +6884 -614
  2. package/dist/commons/conditionals/conditionals.d.ts +4 -0
  3. package/dist/commons/conditionals/validate.d.ts +6 -0
  4. package/dist/commons/events/ActionConfig.d.ts +18678 -6326
  5. package/dist/commons/events/ActionDocument.d.ts +1923 -414
  6. package/dist/commons/events/ActionInput.d.ts +1504 -304
  7. package/dist/commons/events/ActionType.d.ts +6 -0
  8. package/dist/commons/events/AdvancedSearchConfig.d.ts +75 -3
  9. package/dist/commons/events/CompositeFieldValue.d.ts +28 -0
  10. package/dist/commons/events/Constants.d.ts +1 -0
  11. package/dist/commons/events/CountryConfigQueryInput.d.ts +254 -168
  12. package/dist/commons/events/CreatedAtLocation.d.ts +2 -1
  13. package/dist/commons/events/Draft.d.ts +134 -33
  14. package/dist/commons/events/EventConfig.d.ts +8242 -2365
  15. package/dist/commons/events/EventDocument.d.ts +1242 -298
  16. package/dist/commons/events/EventIndex.d.ts +798 -123
  17. package/dist/commons/events/EventMetadata.d.ts +62 -59
  18. package/dist/commons/events/FieldConfig.d.ts +1572 -746
  19. package/dist/commons/events/FieldType.d.ts +4 -1
  20. package/dist/commons/events/FieldTypeMapping.d.ts +89 -50
  21. package/dist/commons/events/FieldValue.d.ts +41 -5
  22. package/dist/commons/events/FormConfig.d.ts +7640 -2444
  23. package/dist/commons/events/PageConfig.d.ts +2816 -1540
  24. package/dist/commons/events/SummaryConfig.d.ts +0 -5
  25. package/dist/commons/events/WorkqueueColumnConfig.d.ts +11 -11
  26. package/dist/commons/events/WorkqueueConfig.d.ts +3277 -1512
  27. package/dist/commons/events/defineConfig.d.ts +959 -13
  28. package/dist/commons/events/field.d.ts +4 -0
  29. package/dist/commons/events/index.d.ts +1 -0
  30. package/dist/commons/events/scopes.d.ts +1 -2
  31. package/dist/commons/events/test.utils.d.ts +138 -40
  32. package/dist/commons/events/transactions.d.ts +1 -1
  33. package/dist/commons/events/utils.d.ts +9666 -16
  34. package/dist/conditionals/index.js +18 -1
  35. package/dist/events/index.js +1592 -1011
  36. package/dist/scopes/index.d.ts +4 -1
  37. package/dist/scopes/index.js +67 -17
  38. package/package.json +1 -1
@@ -69,5 +69,9 @@ export declare function field(fieldId: string, options?: {
69
69
  isValidEnglishName: () => import("../conditionals/conditionals").JSONSchema;
70
70
  matches: (pattern: string) => import("../conditionals/conditionals").JSONSchema;
71
71
  isBetween: (min: number, max: number) => import("../conditionals/conditionals").JSONSchema;
72
+ getId: () => {
73
+ fieldId: string;
74
+ };
75
+ object: (options: Record<string, any>) => import("../conditionals/conditionals").JSONSchema;
72
76
  };
73
77
  //# sourceMappingURL=field.d.ts.map
@@ -35,6 +35,7 @@ export * from './test.utils';
35
35
  export * from './TemplateConfig';
36
36
  export * from './scopes';
37
37
  export * from './serializer';
38
+ export * from './state/availableActions';
38
39
  export * from '../conditionals/conditionals';
39
40
  export * from '../conditionals/validate';
40
41
  export * from './field';
@@ -1,5 +1,4 @@
1
1
  import { Scope } from '../scopes';
2
- import { ActionType } from './ActionType';
3
2
  export declare const CONFIG_GET_ALLOWED_SCOPES: ["record.declare-birth", "record.read", "record.declaration-submit-incomplete", "record.declaration-submit-for-review", "record.register", "record.export-records", "config", "config.update:all"];
4
3
  export declare const CONFIG_SEARCH_ALLOWED_SCOPES: ("search.birth:my-jurisdiction" | "search.birth" | "search.death:my-jurisdiction" | "search.death" | "search.marriage:my-jurisdiction" | "search.marriage")[];
5
4
  export declare const ACTION_ALLOWED_SCOPES: {
@@ -40,6 +39,6 @@ export declare const ACTION_ALLOWED_CONFIGURABLE_SCOPES: {
40
39
  UNASSIGN: never[];
41
40
  DETECT_DUPLICATE: never[];
42
41
  };
42
+ export declare const WRITE_ACTION_SCOPES: ("record.declare-birth" | "record.declaration-submit-for-approval" | "record.register" | "record.registration-print&issue-certified-copies")[];
43
43
  export declare function hasAnyOfScopes(a: Scope[], b: Scope[]): boolean;
44
- export declare function filterUnallowedActions(actions: ActionType[], userScopes: Scope[]): ActionType[];
45
44
  //# sourceMappingURL=scopes.d.ts.map
@@ -1,6 +1,5 @@
1
- import { UUID } from '../uuid';
2
- import { ActionDocument, ActionUpdate, EventState } from './ActionDocument';
3
- import { ArchiveActionInput, AssignActionInput, DeclareActionInput, RegisterActionInput, RejectDeclarationActionInput, RequestCorrectionActionInput, UnassignActionInput, ValidateActionInput } from './ActionInput';
1
+ import { ActionDocument, EventState } from './ActionDocument';
2
+ import { ArchiveActionInput, AssignActionInput, DeclareActionInput, NotifyActionInput, RegisterActionInput, RejectDeclarationActionInput, RequestCorrectionActionInput, UnassignActionInput, ValidateActionInput } from './ActionInput';
4
3
  import { ActionType } from './ActionType';
5
4
  import { Draft } from './Draft';
6
5
  import { EventConfig } from './EventConfig';
@@ -8,10 +7,27 @@ import { EventDocument } from './EventDocument';
8
7
  import { EventIndex } from './EventIndex';
9
8
  import { EventInput } from './EventInput';
10
9
  import { TranslationConfig } from './TranslationConfig';
10
+ import { FieldConfig } from './FieldConfig';
11
11
  import { WorkqueueConfig } from './WorkqueueConfig';
12
- export declare function generateActionDeclarationInput(configuration: EventConfig, action: ActionType): EventState;
13
- export declare function generateActionAnnotationInput(configuration: EventConfig, action: ActionType): {};
14
- export declare const eventPayloadGenerator: {
12
+ import { FieldValue } from './FieldValue';
13
+ import { z } from 'zod';
14
+ /**
15
+ * In real application, the roles are defined in the countryconfig.
16
+ * These are just for testing purposes to generate realistic mock data.
17
+ */
18
+ export declare const TestUserRole: z.ZodEnum<["FIELD_AGENT", "LOCAL_REGISTRAR", "LOCAL_SYSTEM_ADMIN", "NATIONAL_REGISTRAR", "REGISTRATION_AGENT"]>;
19
+ export type TestUserRole = z.infer<typeof TestUserRole>;
20
+ export declare function generateRandomName(rng: () => number): {
21
+ firstname: string;
22
+ surname: string;
23
+ };
24
+ /**
25
+ * Quick-and-dirty mock data generator for event actions.
26
+ */
27
+ export declare function mapFieldTypeToMockValue(field: FieldConfig, i: number, rng: () => number): FieldValue;
28
+ export declare function generateActionDeclarationInput(configuration: EventConfig, action: ActionType, rng: () => number): EventState;
29
+ export declare function generateActionAnnotationInput(configuration: EventConfig, action: ActionType, rng: () => number): {};
30
+ export declare function eventPayloadGenerator(rng: () => number): {
15
31
  create: (input?: Partial<EventInput>) => {
16
32
  transactionId: string;
17
33
  type: string;
@@ -22,12 +38,11 @@ export declare const eventPayloadGenerator: {
22
38
  id: string;
23
39
  };
24
40
  draft: ({ eventId, actionType }: {
25
- eventId: UUID;
41
+ eventId: string;
26
42
  actionType: ActionType;
27
43
  }, input?: Partial<Draft>) => Draft;
28
44
  actions: {
29
- declare: (eventId: string, input?: Partial<Pick<DeclareActionInput, "transactionId" | "declaration" | "annotation">>) => {
30
- type: "DECLARE";
45
+ declare: (eventId: string, input?: Partial<Pick<DeclareActionInput, "transactionId" | "declaration" | "annotation" | "keepAssignment">>) => {
31
46
  transactionId: string;
32
47
  declaration: Record<string, string | number | boolean | {
33
48
  type: string;
@@ -44,6 +59,10 @@ export declare const eventPayloadGenerator: {
44
59
  residentialArea?: string | null | undefined;
45
60
  street?: string | null | undefined;
46
61
  zipCode?: string | null | undefined;
62
+ } | {
63
+ firstname: string;
64
+ surname: string;
65
+ middlename?: string | null | undefined;
47
66
  } | {
48
67
  country: string;
49
68
  district: string;
@@ -66,20 +85,19 @@ export declare const eventPayloadGenerator: {
66
85
  option: string;
67
86
  filename: string;
68
87
  originalFilename: string;
69
- }[] | [string, string] | undefined>;
88
+ }[] | [string, string] | null | undefined>;
70
89
  annotation: {};
90
+ keepAssignment?: boolean | undefined;
91
+ type: "DECLARE";
71
92
  eventId: string;
72
93
  };
73
94
  /**
74
95
  * Notify allows sending incomplete data. Think it as 'partial declare' for now.
75
96
  */
76
- notify: (eventId: string, input?: {
77
- transactionId?: string;
78
- declaration?: Partial<ActionUpdate>;
79
- }) => {
97
+ notify: (eventId: string, input?: Partial<Pick<NotifyActionInput, "transactionId" | "declaration" | "keepAssignment">>) => {
80
98
  type: "NOTIFY";
81
99
  transactionId: string;
82
- declaration: Partial<Record<string, string | number | boolean | {
100
+ declaration: Record<string, string | number | boolean | {
83
101
  type: string;
84
102
  filename: string;
85
103
  originalFilename: string;
@@ -94,6 +112,10 @@ export declare const eventPayloadGenerator: {
94
112
  residentialArea?: string | null | undefined;
95
113
  street?: string | null | undefined;
96
114
  zipCode?: string | null | undefined;
115
+ } | {
116
+ firstname: string;
117
+ surname: string;
118
+ middlename?: string | null | undefined;
97
119
  } | {
98
120
  country: string;
99
121
  district: string;
@@ -116,11 +138,11 @@ export declare const eventPayloadGenerator: {
116
138
  option: string;
117
139
  filename: string;
118
140
  originalFilename: string;
119
- }[] | [string, string] | undefined>>;
141
+ }[] | [string, string] | null | undefined>;
120
142
  eventId: string;
143
+ keepAssignment: boolean | undefined;
121
144
  };
122
- validate: (eventId: string, input?: Partial<Pick<ValidateActionInput, "transactionId" | "declaration" | "annotation">>) => {
123
- type: "VALIDATE";
145
+ validate: (eventId: string, input?: Partial<Pick<ValidateActionInput, "transactionId" | "declaration" | "annotation" | "keepAssignment">>) => {
124
146
  transactionId: string;
125
147
  declaration: Record<string, string | number | boolean | {
126
148
  type: string;
@@ -137,6 +159,10 @@ export declare const eventPayloadGenerator: {
137
159
  residentialArea?: string | null | undefined;
138
160
  street?: string | null | undefined;
139
161
  zipCode?: string | null | undefined;
162
+ } | {
163
+ firstname: string;
164
+ surname: string;
165
+ middlename?: string | null | undefined;
140
166
  } | {
141
167
  country: string;
142
168
  district: string;
@@ -159,8 +185,10 @@ export declare const eventPayloadGenerator: {
159
185
  option: string;
160
186
  filename: string;
161
187
  originalFilename: string;
162
- }[] | [string, string] | undefined>;
188
+ }[] | [string, string] | null | undefined>;
163
189
  annotation: {};
190
+ keepAssignment?: boolean | undefined;
191
+ type: "VALIDATE";
164
192
  duplicates: never[];
165
193
  eventId: string;
166
194
  };
@@ -178,10 +206,52 @@ export declare const eventPayloadGenerator: {
178
206
  assignedTo: null;
179
207
  eventId: string;
180
208
  };
181
- archive: (eventId: string, input?: Partial<Pick<ArchiveActionInput, "transactionId" | "declaration">>, isDuplicate?: boolean) => {
182
- type: "ARCHIVE";
209
+ archive: (eventId: string, input?: Partial<Pick<ArchiveActionInput, "transactionId" | "declaration" | "keepAssignment">>, isDuplicate?: boolean) => {
183
210
  transactionId: string;
184
- declaration: {};
211
+ declaration: Record<string, string | number | boolean | {
212
+ type: string;
213
+ filename: string;
214
+ originalFilename: string;
215
+ } | {
216
+ country: string;
217
+ district: string;
218
+ addressType: "DOMESTIC";
219
+ province: string;
220
+ urbanOrRural: "URBAN";
221
+ number?: string | null | undefined;
222
+ town?: string | null | undefined;
223
+ residentialArea?: string | null | undefined;
224
+ street?: string | null | undefined;
225
+ zipCode?: string | null | undefined;
226
+ } | {
227
+ firstname: string;
228
+ surname: string;
229
+ middlename?: string | null | undefined;
230
+ } | {
231
+ country: string;
232
+ district: string;
233
+ addressType: "DOMESTIC";
234
+ province: string;
235
+ urbanOrRural: "RURAL";
236
+ village?: string | null | undefined;
237
+ } | {
238
+ country: string;
239
+ state: string;
240
+ addressType: "INTERNATIONAL";
241
+ district2: string;
242
+ cityOrTown?: string | null | undefined;
243
+ addressLine1?: string | null | undefined;
244
+ addressLine2?: string | null | undefined;
245
+ addressLine3?: string | null | undefined;
246
+ postcodeOrZip?: string | null | undefined;
247
+ } | {
248
+ type: string;
249
+ option: string;
250
+ filename: string;
251
+ originalFilename: string;
252
+ }[] | [string, string] | null | undefined>;
253
+ keepAssignment?: boolean | undefined;
254
+ type: "ARCHIVE";
185
255
  annotation: {};
186
256
  duplicates: never[];
187
257
  eventId: string;
@@ -190,19 +260,19 @@ export declare const eventPayloadGenerator: {
190
260
  isDuplicate: boolean;
191
261
  };
192
262
  };
193
- reject: (eventId: string, input?: Partial<Pick<RejectDeclarationActionInput, "transactionId" | "annotation">>) => {
194
- type: "REJECT";
263
+ reject: (eventId: string, input?: Partial<Pick<RejectDeclarationActionInput, "transactionId" | "annotation" | "keepAssignment">>) => {
195
264
  transactionId: string;
196
- declaration: {};
197
265
  annotation: {};
266
+ keepAssignment?: boolean | undefined;
267
+ type: "REJECT";
268
+ declaration: {};
198
269
  duplicates: never[];
199
270
  eventId: string;
200
271
  reason: {
201
272
  message: string;
202
273
  };
203
274
  };
204
- register: (eventId: string, input?: Partial<Pick<RegisterActionInput, "transactionId" | "declaration" | "annotation">>) => {
205
- type: "REGISTER";
275
+ register: (eventId: string, input?: Partial<Pick<RegisterActionInput, "transactionId" | "declaration" | "annotation" | "keepAssignment">>) => {
206
276
  transactionId: string;
207
277
  declaration: Record<string, string | number | boolean | {
208
278
  type: string;
@@ -219,6 +289,10 @@ export declare const eventPayloadGenerator: {
219
289
  residentialArea?: string | null | undefined;
220
290
  street?: string | null | undefined;
221
291
  zipCode?: string | null | undefined;
292
+ } | {
293
+ firstname: string;
294
+ surname: string;
295
+ middlename?: string | null | undefined;
222
296
  } | {
223
297
  country: string;
224
298
  district: string;
@@ -241,19 +315,22 @@ export declare const eventPayloadGenerator: {
241
315
  option: string;
242
316
  filename: string;
243
317
  originalFilename: string;
244
- }[] | [string, string] | undefined>;
318
+ }[] | [string, string] | null | undefined>;
245
319
  annotation: {};
320
+ keepAssignment?: boolean | undefined;
321
+ type: "REGISTER";
246
322
  eventId: string;
247
323
  };
248
- printCertificate: (eventId: string, input?: Partial<Pick<RegisterActionInput, "transactionId" | "annotation">>) => {
249
- type: "PRINT_CERTIFICATE";
324
+ printCertificate: (eventId: string, input?: Partial<Pick<RegisterActionInput, "transactionId" | "annotation" | "keepAssignment">>) => {
250
325
  transactionId: string;
251
- declaration: {};
252
326
  annotation: {};
327
+ keepAssignment?: boolean | undefined;
328
+ type: "PRINT_CERTIFICATE";
329
+ declaration: {};
253
330
  eventId: string;
254
331
  };
255
332
  correction: {
256
- request: (eventId: string, input?: Partial<Pick<RequestCorrectionActionInput, "transactionId" | "declaration" | "annotation">>) => {
333
+ request: (eventId: string, input?: Partial<Pick<RequestCorrectionActionInput, "transactionId" | "declaration" | "annotation" | "keepAssignment">>) => {
257
334
  type: "REQUEST_CORRECTION";
258
335
  transactionId: string;
259
336
  declaration: Record<string, string | number | boolean | {
@@ -271,6 +348,10 @@ export declare const eventPayloadGenerator: {
271
348
  residentialArea?: string | null | undefined;
272
349
  street?: string | null | undefined;
273
350
  zipCode?: string | null | undefined;
351
+ } | {
352
+ firstname: string;
353
+ surname: string;
354
+ middlename?: string | null | undefined;
274
355
  } | {
275
356
  country: string;
276
357
  district: string;
@@ -293,47 +374,64 @@ export declare const eventPayloadGenerator: {
293
374
  option: string;
294
375
  filename: string;
295
376
  originalFilename: string;
296
- }[] | [string, string] | undefined>;
377
+ }[] | [string, string] | null | undefined>;
297
378
  annotation: {};
298
379
  eventId: string;
380
+ keepAssignment: boolean | undefined;
299
381
  };
300
- approve: (eventId: string, requestId: string, input?: Partial<Pick<RequestCorrectionActionInput, "transactionId" | "annotation">>) => {
382
+ approve: (eventId: string, requestId: string, input?: Partial<Pick<RequestCorrectionActionInput, "transactionId" | "annotation" | "keepAssignment">>) => {
301
383
  type: "APPROVE_CORRECTION";
302
384
  transactionId: string;
303
385
  declaration: {};
304
386
  annotation: {};
305
387
  eventId: string;
306
388
  requestId: string;
389
+ keepAssignment: boolean | undefined;
307
390
  };
308
- reject: (eventId: string, requestId: string, input?: Partial<Pick<RequestCorrectionActionInput, "transactionId" | "annotation">>) => {
391
+ reject: (eventId: string, requestId: string, input?: Partial<Pick<RequestCorrectionActionInput, "transactionId" | "annotation" | "keepAssignment">>) => {
309
392
  type: "REJECT_CORRECTION";
310
393
  transactionId: string;
311
394
  declaration: {};
312
395
  annotation: {};
313
396
  eventId: string;
314
397
  requestId: string;
398
+ keepAssignment: boolean | undefined;
315
399
  };
316
400
  };
317
401
  };
318
402
  };
319
- export declare function generateActionDocument({ configuration, action, defaults }: {
403
+ export declare function generateActionDocument({ configuration, action, rng, defaults }: {
320
404
  configuration: EventConfig;
321
405
  action: ActionType;
406
+ rng?: () => number;
322
407
  defaults?: Partial<ActionDocument>;
408
+ user?: Partial<{
409
+ signature: string;
410
+ primaryOfficeId: string;
411
+ role: TestUserRole;
412
+ id: string;
413
+ }>;
323
414
  }): ActionDocument;
324
- export declare function generateEventDocument({ configuration, actions }: {
415
+ export declare function generateEventDocument({ configuration, actions, rng }: {
325
416
  configuration: EventConfig;
326
417
  actions: ActionType[];
418
+ rng?: () => number;
327
419
  }): EventDocument;
328
- export declare function generateEventDraftDocument(eventId: UUID, actionType?: ActionType, declaration?: EventState): Draft;
420
+ export declare function generateEventDraftDocument({ eventId, actionType, rng, declaration }: {
421
+ eventId: string;
422
+ actionType: ActionType;
423
+ rng?: () => number;
424
+ declaration?: EventState;
425
+ }): Draft;
329
426
  export declare function getRandomDatetime(rng: () => number, start: Date, end: Date): string;
427
+ export declare function getRandomDate(rng: () => number, start: string, end: string): string;
330
428
  /**
331
429
  * Useful for testing when we need deterministic outcome.
332
430
  * @param seed - Seed value for the pseudo-random number generator
333
431
  *
334
- * @returns A function that generates pseudo-random numbers between 0 and 1
432
+ * @returns A function that generates pseudo-random numbers between 0 and 1 [0, 1)
335
433
  */
336
- export declare function createPseudoRandomNumberGenerator(seed: number): () => number;
434
+ export declare function createPrng(seed: number): () => number;
337
435
  export declare function generateRandomSignature(rng: () => number): string;
338
436
  export declare const eventQueryDataGenerator: (overrides?: Partial<EventIndex>, seed?: number) => EventIndex;
339
437
  export declare const generateTranslationConfig: (message: string) => TranslationConfig;
@@ -1,2 +1,2 @@
1
- export declare function generateTransactionId(): string & import("zod").BRAND<"UUID">;
1
+ export declare function generateTransactionId(): import("../uuid").UUID;
2
2
  //# sourceMappingURL=transactions.d.ts.map