@opencrvs/toolkit 1.8.0-rc.fb5b9fe → 1.8.0-rc.fb8e005

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 (36) hide show
  1. package/dist/commons/api/router.d.ts +5924 -8783
  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 +21534 -6326
  5. package/dist/commons/events/ActionDocument.d.ts +1783 -280
  6. package/dist/commons/events/ActionInput.d.ts +1382 -182
  7. package/dist/commons/events/ActionType.d.ts +4 -0
  8. package/dist/commons/events/AdvancedSearchConfig.d.ts +279 -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 +1161 -413
  12. package/dist/commons/events/Draft.d.ts +118 -17
  13. package/dist/commons/events/EventConfig.d.ts +11557 -4116
  14. package/dist/commons/events/EventDocument.d.ts +1144 -205
  15. package/dist/commons/events/EventIndex.d.ts +839 -185
  16. package/dist/commons/events/EventMetadata.d.ts +52 -40
  17. package/dist/commons/events/FieldConfig.d.ts +1896 -872
  18. package/dist/commons/events/FieldType.d.ts +4 -1
  19. package/dist/commons/events/FieldTypeMapping.d.ts +89 -50
  20. package/dist/commons/events/FieldValue.d.ts +41 -5
  21. package/dist/commons/events/FormConfig.d.ts +8840 -2444
  22. package/dist/commons/events/PageConfig.d.ts +3104 -1540
  23. package/dist/commons/events/SummaryConfig.d.ts +0 -5
  24. package/dist/commons/events/WorkqueueColumnConfig.d.ts +11 -11
  25. package/dist/commons/events/WorkqueueConfig.d.ts +4460 -1685
  26. package/dist/commons/events/defineConfig.d.ts +1279 -17
  27. package/dist/commons/events/field.d.ts +9 -0
  28. package/dist/commons/events/index.d.ts +1 -0
  29. package/dist/commons/events/scopes.d.ts +1 -2
  30. package/dist/commons/events/test.utils.d.ts +146 -38
  31. package/dist/commons/events/utils.d.ts +10117 -10
  32. package/dist/conditionals/index.js +38 -18
  33. package/dist/events/index.js +1718 -1057
  34. package/dist/scopes/index.d.ts +4 -1
  35. package/dist/scopes/index.js +67 -17
  36. package/package.json +3 -3
@@ -1,5 +1,6 @@
1
1
  import { FieldConditional } from './Conditional';
2
2
  import { TranslationConfig } from './TranslationConfig';
3
+ import { ValidationConfig } from './FieldConfig';
3
4
  /**
4
5
  * Entry point for defining conditional logic or configuration for a form field.
5
6
  * @param fieldId - The ID of the field to define rules or config for.
@@ -7,10 +8,12 @@ import { TranslationConfig } from './TranslationConfig';
7
8
  */
8
9
  export declare function field(fieldId: string, options?: {
9
10
  conditionals?: FieldConditional[];
11
+ validations?: ValidationConfig[];
10
12
  searchCriteriaLabelPrefix?: TranslationConfig;
11
13
  }): {
12
14
  range: () => {
13
15
  conditionals?: FieldConditional[];
16
+ validations?: ValidationConfig[];
14
17
  searchCriteriaLabelPrefix?: TranslationConfig;
15
18
  fieldId: string;
16
19
  fieldType: "field";
@@ -21,6 +24,7 @@ export declare function field(fieldId: string, options?: {
21
24
  };
22
25
  exact: () => {
23
26
  conditionals?: FieldConditional[];
27
+ validations?: ValidationConfig[];
24
28
  searchCriteriaLabelPrefix?: TranslationConfig;
25
29
  fieldId: string;
26
30
  fieldType: "field";
@@ -31,6 +35,7 @@ export declare function field(fieldId: string, options?: {
31
35
  };
32
36
  fuzzy: () => {
33
37
  conditionals?: FieldConditional[];
38
+ validations?: ValidationConfig[];
34
39
  searchCriteriaLabelPrefix?: TranslationConfig;
35
40
  fieldId: string;
36
41
  fieldType: "field";
@@ -69,5 +74,9 @@ export declare function field(fieldId: string, options?: {
69
74
  isValidEnglishName: () => import("../conditionals/conditionals").JSONSchema;
70
75
  matches: (pattern: string) => import("../conditionals/conditionals").JSONSchema;
71
76
  isBetween: (min: number, max: number) => import("../conditionals/conditionals").JSONSchema;
77
+ getId: () => {
78
+ fieldId: string;
79
+ };
80
+ object: (options: Record<string, any>) => import("../conditionals/conditionals").JSONSchema;
72
81
  };
73
82
  //# 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,6 @@
1
1
  import { UUID } from '../uuid';
2
- import { ActionDocument, ActionUpdate, EventState } from './ActionDocument';
3
- import { ArchiveActionInput, AssignActionInput, DeclareActionInput, RegisterActionInput, RejectDeclarationActionInput, RequestCorrectionActionInput, UnassignActionInput, ValidateActionInput } from './ActionInput';
2
+ import { ActionDocument, EventState } from './ActionDocument';
3
+ import { ArchiveActionInput, AssignActionInput, DeclareActionInput, NotifyActionInput, RegisterActionInput, RejectDeclarationActionInput, RequestCorrectionActionInput, UnassignActionInput, ValidateActionInput } from './ActionInput';
4
4
  import { ActionType } from './ActionType';
5
5
  import { Draft } from './Draft';
6
6
  import { EventConfig } from './EventConfig';
@@ -8,10 +8,27 @@ import { EventDocument } from './EventDocument';
8
8
  import { EventIndex } from './EventIndex';
9
9
  import { EventInput } from './EventInput';
10
10
  import { TranslationConfig } from './TranslationConfig';
11
+ import { FieldConfig } from './FieldConfig';
11
12
  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: {
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): {
15
32
  create: (input?: Partial<EventInput>) => {
16
33
  transactionId: string;
17
34
  type: string;
@@ -26,8 +43,7 @@ export declare const eventPayloadGenerator: {
26
43
  actionType: ActionType;
27
44
  }, input?: Partial<Draft>) => Draft;
28
45
  actions: {
29
- declare: (eventId: string, input?: Partial<Pick<DeclareActionInput, "transactionId" | "declaration" | "annotation">>) => {
30
- type: "DECLARE";
46
+ declare: (eventId: string, input?: Partial<Pick<DeclareActionInput, "transactionId" | "declaration" | "annotation" | "keepAssignment">>) => {
31
47
  transactionId: string;
32
48
  declaration: Record<string, string | number | boolean | {
33
49
  type: string;
@@ -44,6 +60,10 @@ export declare const eventPayloadGenerator: {
44
60
  residentialArea?: string | null | undefined;
45
61
  street?: string | null | undefined;
46
62
  zipCode?: string | null | undefined;
63
+ } | {
64
+ firstname?: string | null | undefined;
65
+ surname?: string | null | undefined;
66
+ middlename?: string | null | undefined;
47
67
  } | {
48
68
  country: string;
49
69
  district: string;
@@ -66,20 +86,19 @@ export declare const eventPayloadGenerator: {
66
86
  option: string;
67
87
  filename: string;
68
88
  originalFilename: string;
69
- }[] | [string, string] | undefined>;
89
+ }[] | [string, string] | null | undefined>;
70
90
  annotation: {};
91
+ keepAssignment?: boolean | undefined;
92
+ type: "DECLARE";
71
93
  eventId: string;
72
94
  };
73
95
  /**
74
96
  * Notify allows sending incomplete data. Think it as 'partial declare' for now.
75
97
  */
76
- notify: (eventId: string, input?: {
77
- transactionId?: string;
78
- declaration?: Partial<ActionUpdate>;
79
- }) => {
98
+ notify: (eventId: string, input?: Partial<Pick<NotifyActionInput, "transactionId" | "declaration" | "keepAssignment">>) => {
80
99
  type: "NOTIFY";
81
100
  transactionId: string;
82
- declaration: Partial<Record<string, string | number | boolean | {
101
+ declaration: Record<string, string | number | boolean | {
83
102
  type: string;
84
103
  filename: string;
85
104
  originalFilename: string;
@@ -94,6 +113,10 @@ export declare const eventPayloadGenerator: {
94
113
  residentialArea?: string | null | undefined;
95
114
  street?: string | null | undefined;
96
115
  zipCode?: string | null | undefined;
116
+ } | {
117
+ firstname?: string | null | undefined;
118
+ surname?: string | null | undefined;
119
+ middlename?: string | null | undefined;
97
120
  } | {
98
121
  country: string;
99
122
  district: string;
@@ -116,11 +139,11 @@ export declare const eventPayloadGenerator: {
116
139
  option: string;
117
140
  filename: string;
118
141
  originalFilename: string;
119
- }[] | [string, string] | undefined>>;
142
+ }[] | [string, string] | null | undefined>;
120
143
  eventId: string;
144
+ keepAssignment: boolean | undefined;
121
145
  };
122
- validate: (eventId: string, input?: Partial<Pick<ValidateActionInput, "transactionId" | "declaration" | "annotation">>) => {
123
- type: "VALIDATE";
146
+ validate: (eventId: string, input?: Partial<Pick<ValidateActionInput, "transactionId" | "declaration" | "annotation" | "keepAssignment">>) => {
124
147
  transactionId: string;
125
148
  declaration: Record<string, string | number | boolean | {
126
149
  type: string;
@@ -137,6 +160,10 @@ export declare const eventPayloadGenerator: {
137
160
  residentialArea?: string | null | undefined;
138
161
  street?: string | null | undefined;
139
162
  zipCode?: string | null | undefined;
163
+ } | {
164
+ firstname?: string | null | undefined;
165
+ surname?: string | null | undefined;
166
+ middlename?: string | null | undefined;
140
167
  } | {
141
168
  country: string;
142
169
  district: string;
@@ -159,8 +186,10 @@ export declare const eventPayloadGenerator: {
159
186
  option: string;
160
187
  filename: string;
161
188
  originalFilename: string;
162
- }[] | [string, string] | undefined>;
189
+ }[] | [string, string] | null | undefined>;
163
190
  annotation: {};
191
+ keepAssignment?: boolean | undefined;
192
+ type: "VALIDATE";
164
193
  duplicates: never[];
165
194
  eventId: string;
166
195
  };
@@ -178,10 +207,52 @@ export declare const eventPayloadGenerator: {
178
207
  assignedTo: null;
179
208
  eventId: string;
180
209
  };
181
- archive: (eventId: string, input?: Partial<Pick<ArchiveActionInput, "transactionId" | "declaration">>, isDuplicate?: boolean) => {
182
- type: "ARCHIVE";
210
+ archive: (eventId: string, input?: Partial<Pick<ArchiveActionInput, "transactionId" | "declaration" | "keepAssignment">>, isDuplicate?: boolean) => {
183
211
  transactionId: string;
184
- declaration: {};
212
+ declaration: Record<string, string | number | boolean | {
213
+ type: string;
214
+ filename: string;
215
+ originalFilename: string;
216
+ } | {
217
+ country: string;
218
+ district: string;
219
+ addressType: "DOMESTIC";
220
+ province: string;
221
+ urbanOrRural: "URBAN";
222
+ number?: string | null | undefined;
223
+ town?: string | null | undefined;
224
+ residentialArea?: string | null | undefined;
225
+ street?: string | null | undefined;
226
+ zipCode?: string | null | undefined;
227
+ } | {
228
+ firstname?: string | null | undefined;
229
+ surname?: string | null | undefined;
230
+ middlename?: string | null | undefined;
231
+ } | {
232
+ country: string;
233
+ district: string;
234
+ addressType: "DOMESTIC";
235
+ province: string;
236
+ urbanOrRural: "RURAL";
237
+ village?: string | null | undefined;
238
+ } | {
239
+ country: string;
240
+ state: string;
241
+ addressType: "INTERNATIONAL";
242
+ district2: string;
243
+ cityOrTown?: string | null | undefined;
244
+ addressLine1?: string | null | undefined;
245
+ addressLine2?: string | null | undefined;
246
+ addressLine3?: string | null | undefined;
247
+ postcodeOrZip?: string | null | undefined;
248
+ } | {
249
+ type: string;
250
+ option: string;
251
+ filename: string;
252
+ originalFilename: string;
253
+ }[] | [string, string] | null | undefined>;
254
+ keepAssignment?: boolean | undefined;
255
+ type: "ARCHIVE";
185
256
  annotation: {};
186
257
  duplicates: never[];
187
258
  eventId: string;
@@ -190,19 +261,19 @@ export declare const eventPayloadGenerator: {
190
261
  isDuplicate: boolean;
191
262
  };
192
263
  };
193
- reject: (eventId: string, input?: Partial<Pick<RejectDeclarationActionInput, "transactionId" | "annotation">>) => {
194
- type: "REJECT";
264
+ reject: (eventId: string, input?: Partial<Pick<RejectDeclarationActionInput, "transactionId" | "annotation" | "keepAssignment">>) => {
195
265
  transactionId: string;
196
- declaration: {};
197
266
  annotation: {};
267
+ keepAssignment?: boolean | undefined;
268
+ type: "REJECT";
269
+ declaration: {};
198
270
  duplicates: never[];
199
271
  eventId: string;
200
272
  reason: {
201
273
  message: string;
202
274
  };
203
275
  };
204
- register: (eventId: string, input?: Partial<Pick<RegisterActionInput, "transactionId" | "declaration" | "annotation">>) => {
205
- type: "REGISTER";
276
+ register: (eventId: string, input?: Partial<Pick<RegisterActionInput, "transactionId" | "declaration" | "annotation" | "keepAssignment" | "registrationNumber">>) => {
206
277
  transactionId: string;
207
278
  declaration: Record<string, string | number | boolean | {
208
279
  type: string;
@@ -219,6 +290,10 @@ export declare const eventPayloadGenerator: {
219
290
  residentialArea?: string | null | undefined;
220
291
  street?: string | null | undefined;
221
292
  zipCode?: string | null | undefined;
293
+ } | {
294
+ firstname?: string | null | undefined;
295
+ surname?: string | null | undefined;
296
+ middlename?: string | null | undefined;
222
297
  } | {
223
298
  country: string;
224
299
  district: string;
@@ -241,19 +316,23 @@ export declare const eventPayloadGenerator: {
241
316
  option: string;
242
317
  filename: string;
243
318
  originalFilename: string;
244
- }[] | [string, string] | undefined>;
319
+ }[] | [string, string] | null | undefined>;
245
320
  annotation: {};
321
+ registrationNumber?: string | undefined;
322
+ keepAssignment?: boolean | undefined;
323
+ type: "REGISTER";
246
324
  eventId: string;
247
325
  };
248
- printCertificate: (eventId: string, input?: Partial<Pick<RegisterActionInput, "transactionId" | "annotation">>) => {
249
- type: "PRINT_CERTIFICATE";
326
+ printCertificate: (eventId: string, input?: Partial<Pick<RegisterActionInput, "transactionId" | "annotation" | "keepAssignment">>) => {
250
327
  transactionId: string;
251
- declaration: {};
252
328
  annotation: {};
329
+ keepAssignment?: boolean | undefined;
330
+ type: "PRINT_CERTIFICATE";
331
+ declaration: {};
253
332
  eventId: string;
254
333
  };
255
334
  correction: {
256
- request: (eventId: string, input?: Partial<Pick<RequestCorrectionActionInput, "transactionId" | "declaration" | "annotation">>) => {
335
+ request: (eventId: string, input?: Partial<Pick<RequestCorrectionActionInput, "transactionId" | "declaration" | "annotation" | "keepAssignment">>) => {
257
336
  type: "REQUEST_CORRECTION";
258
337
  transactionId: string;
259
338
  declaration: Record<string, string | number | boolean | {
@@ -271,6 +350,10 @@ export declare const eventPayloadGenerator: {
271
350
  residentialArea?: string | null | undefined;
272
351
  street?: string | null | undefined;
273
352
  zipCode?: string | null | undefined;
353
+ } | {
354
+ firstname?: string | null | undefined;
355
+ surname?: string | null | undefined;
356
+ middlename?: string | null | undefined;
274
357
  } | {
275
358
  country: string;
276
359
  district: string;
@@ -293,47 +376,72 @@ export declare const eventPayloadGenerator: {
293
376
  option: string;
294
377
  filename: string;
295
378
  originalFilename: string;
296
- }[] | [string, string] | undefined>;
379
+ }[] | [string, string] | null | undefined>;
297
380
  annotation: {};
298
381
  eventId: string;
382
+ keepAssignment: boolean | undefined;
299
383
  };
300
- approve: (eventId: string, requestId: string, input?: Partial<Pick<RequestCorrectionActionInput, "transactionId" | "annotation">>) => {
384
+ approve: (eventId: string, requestId: string, input?: Partial<Pick<RequestCorrectionActionInput, "transactionId" | "annotation" | "keepAssignment">>) => {
301
385
  type: "APPROVE_CORRECTION";
302
386
  transactionId: string;
303
387
  declaration: {};
304
388
  annotation: {};
305
389
  eventId: string;
306
390
  requestId: string;
391
+ keepAssignment: boolean | undefined;
307
392
  };
308
- reject: (eventId: string, requestId: string, input?: Partial<Pick<RequestCorrectionActionInput, "transactionId" | "annotation">>) => {
393
+ reject: (eventId: string, requestId: string, input?: Partial<Pick<RequestCorrectionActionInput, "transactionId" | "annotation" | "keepAssignment">>) => {
309
394
  type: "REJECT_CORRECTION";
310
395
  transactionId: string;
311
396
  declaration: {};
312
397
  annotation: {};
313
398
  eventId: string;
314
399
  requestId: string;
400
+ keepAssignment: boolean | undefined;
315
401
  };
316
402
  };
317
403
  };
318
404
  };
319
- export declare function generateActionDocument({ configuration, action, defaults }: {
405
+ export declare function generateActionDocument({ configuration, action, rng, defaults, user }: {
320
406
  configuration: EventConfig;
321
407
  action: ActionType;
408
+ rng?: () => number;
322
409
  defaults?: Partial<ActionDocument>;
410
+ user?: Partial<{
411
+ signature: string;
412
+ primaryOfficeId: UUID;
413
+ role: TestUserRole;
414
+ id: string;
415
+ }>;
323
416
  }): ActionDocument;
324
- export declare function generateEventDocument({ configuration, actions }: {
417
+ export declare function generateEventDocument({ configuration, actions, rng, user }: {
325
418
  configuration: EventConfig;
326
419
  actions: ActionType[];
420
+ rng?: () => number;
421
+ user?: Partial<{
422
+ signature: string;
423
+ primaryOfficeId: UUID;
424
+ role: TestUserRole;
425
+ id: string;
426
+ }>;
327
427
  }): EventDocument;
328
- export declare function generateEventDraftDocument(eventId: UUID, actionType?: ActionType, declaration?: EventState): Draft;
428
+ export declare function generateEventDraftDocument({ eventId, actionType, rng, declaration }: {
429
+ eventId: UUID;
430
+ actionType: ActionType;
431
+ rng?: () => number;
432
+ declaration?: EventState;
433
+ }): Draft;
329
434
  export declare function getRandomDatetime(rng: () => number, start: Date, end: Date): string;
435
+ export declare function getRandomDate(rng: () => number, start: string, end: string): string;
330
436
  /**
331
437
  * Useful for testing when we need deterministic outcome.
332
438
  * @param seed - Seed value for the pseudo-random number generator
333
439
  *
334
- * @returns A function that generates pseudo-random numbers between 0 and 1
440
+ * @returns A function that generates pseudo-random numbers between 0 and 1 [0, 1)
335
441
  */
336
- export declare function createPseudoRandomNumberGenerator(seed: number): () => number;
442
+ export declare function createPrng(seed: number): () => number;
443
+ export declare function generateUuid(rng?: () => number): UUID;
444
+ export declare function generateRegistrationNumber(rng: () => number): string;
337
445
  export declare function generateRandomSignature(rng: () => number): string;
338
446
  export declare const eventQueryDataGenerator: (overrides?: Partial<EventIndex>, seed?: number) => EventIndex;
339
447
  export declare const generateTranslationConfig: (message: string) => TranslationConfig;