@opencrvs/toolkit 1.8.1-rc.0377f8e → 1.8.1-rc.0c6d168

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.
package/build.sh CHANGED
@@ -34,6 +34,11 @@ npx esbuild src/api/index.ts --bundle --format=cjs --outdir=./dist/api --allow-o
34
34
  mkdir -p ./dist/commons/api
35
35
  cp -r ../events/build/types/router/router.d.ts ./dist/commons/api
36
36
 
37
+ # Build common notifications
38
+ npx esbuild src/notification/index.ts --bundle --format=cjs --outdir=./dist/notification --allow-overwrite --packages=external
39
+ mkdir -p ./dist/commons/notification
40
+ cp -r ../commons/build/dist/common/notification/*.d.ts ./dist/commons/notification
41
+
37
42
  if [[ "$OSTYPE" == "darwin"* ]]; then
38
43
  sed -i '' 's|@opencrvs/events/build/types|../commons/api|g' dist/api/index.d.ts
39
44
  find dist -type f -exec sed -i '' 's|@opencrvs/commons|../commons|g' {} +
@@ -0,0 +1,547 @@
1
+ import { z } from 'zod';
2
+ export declare const TriggerEvent: {
3
+ readonly USER_CREATED: "user-created";
4
+ readonly USER_UPDATED: "user-updated";
5
+ readonly USERNAME_REMINDER: "username-reminder";
6
+ readonly RESET_PASSWORD: "reset-password";
7
+ readonly RESET_PASSWORD_BY_ADMIN: "reset-password-by-admin";
8
+ readonly TWO_FA: "2fa";
9
+ };
10
+ export type TriggerEvent = (typeof TriggerEvent)[keyof typeof TriggerEvent];
11
+ export declare const FullName: z.ZodObject<{
12
+ use: z.ZodString;
13
+ family: z.ZodString;
14
+ given: z.ZodArray<z.ZodString, "many">;
15
+ }, "strip", z.ZodTypeAny, {
16
+ use: string;
17
+ given: string[];
18
+ family: string;
19
+ }, {
20
+ use: string;
21
+ given: string[];
22
+ family: string;
23
+ }>;
24
+ export type FullName = z.infer<typeof FullName>;
25
+ export declare const Recipient: z.ZodObject<{
26
+ name: z.ZodArray<z.ZodObject<{
27
+ use: z.ZodString;
28
+ family: z.ZodString;
29
+ given: z.ZodArray<z.ZodString, "many">;
30
+ }, "strip", z.ZodTypeAny, {
31
+ use: string;
32
+ given: string[];
33
+ family: string;
34
+ }, {
35
+ use: string;
36
+ given: string[];
37
+ family: string;
38
+ }>, "many">;
39
+ mobile: z.ZodOptional<z.ZodString>;
40
+ email: z.ZodOptional<z.ZodString>;
41
+ }, "strip", z.ZodTypeAny, {
42
+ name: {
43
+ use: string;
44
+ given: string[];
45
+ family: string;
46
+ }[];
47
+ email?: string | undefined;
48
+ mobile?: string | undefined;
49
+ }, {
50
+ name: {
51
+ use: string;
52
+ given: string[];
53
+ family: string;
54
+ }[];
55
+ email?: string | undefined;
56
+ mobile?: string | undefined;
57
+ }>;
58
+ export type Recipient = z.infer<typeof Recipient>;
59
+ export declare const BasePayload: z.ZodObject<{
60
+ recipient: z.ZodObject<{
61
+ name: z.ZodArray<z.ZodObject<{
62
+ use: z.ZodString;
63
+ family: z.ZodString;
64
+ given: z.ZodArray<z.ZodString, "many">;
65
+ }, "strip", z.ZodTypeAny, {
66
+ use: string;
67
+ given: string[];
68
+ family: string;
69
+ }, {
70
+ use: string;
71
+ given: string[];
72
+ family: string;
73
+ }>, "many">;
74
+ mobile: z.ZodOptional<z.ZodString>;
75
+ email: z.ZodOptional<z.ZodString>;
76
+ }, "strip", z.ZodTypeAny, {
77
+ name: {
78
+ use: string;
79
+ given: string[];
80
+ family: string;
81
+ }[];
82
+ email?: string | undefined;
83
+ mobile?: string | undefined;
84
+ }, {
85
+ name: {
86
+ use: string;
87
+ given: string[];
88
+ family: string;
89
+ }[];
90
+ email?: string | undefined;
91
+ mobile?: string | undefined;
92
+ }>;
93
+ }, "strip", z.ZodTypeAny, {
94
+ recipient: {
95
+ name: {
96
+ use: string;
97
+ given: string[];
98
+ family: string;
99
+ }[];
100
+ email?: string | undefined;
101
+ mobile?: string | undefined;
102
+ };
103
+ }, {
104
+ recipient: {
105
+ name: {
106
+ use: string;
107
+ given: string[];
108
+ family: string;
109
+ }[];
110
+ email?: string | undefined;
111
+ mobile?: string | undefined;
112
+ };
113
+ }>;
114
+ export type BasePayload = z.infer<typeof BasePayload>;
115
+ export declare const TriggerPayload: {
116
+ readonly "user-created": z.ZodObject<z.objectUtil.extendShape<{
117
+ recipient: z.ZodObject<{
118
+ name: z.ZodArray<z.ZodObject<{
119
+ use: z.ZodString;
120
+ family: z.ZodString;
121
+ given: z.ZodArray<z.ZodString, "many">;
122
+ }, "strip", z.ZodTypeAny, {
123
+ use: string;
124
+ given: string[];
125
+ family: string;
126
+ }, {
127
+ use: string;
128
+ given: string[];
129
+ family: string;
130
+ }>, "many">;
131
+ mobile: z.ZodOptional<z.ZodString>;
132
+ email: z.ZodOptional<z.ZodString>;
133
+ }, "strip", z.ZodTypeAny, {
134
+ name: {
135
+ use: string;
136
+ given: string[];
137
+ family: string;
138
+ }[];
139
+ email?: string | undefined;
140
+ mobile?: string | undefined;
141
+ }, {
142
+ name: {
143
+ use: string;
144
+ given: string[];
145
+ family: string;
146
+ }[];
147
+ email?: string | undefined;
148
+ mobile?: string | undefined;
149
+ }>;
150
+ }, {
151
+ username: z.ZodString;
152
+ temporaryPassword: z.ZodString;
153
+ }>, "strip", z.ZodTypeAny, {
154
+ recipient: {
155
+ name: {
156
+ use: string;
157
+ given: string[];
158
+ family: string;
159
+ }[];
160
+ email?: string | undefined;
161
+ mobile?: string | undefined;
162
+ };
163
+ username: string;
164
+ temporaryPassword: string;
165
+ }, {
166
+ recipient: {
167
+ name: {
168
+ use: string;
169
+ given: string[];
170
+ family: string;
171
+ }[];
172
+ email?: string | undefined;
173
+ mobile?: string | undefined;
174
+ };
175
+ username: string;
176
+ temporaryPassword: string;
177
+ }>;
178
+ readonly "user-updated": z.ZodObject<z.objectUtil.extendShape<{
179
+ recipient: z.ZodObject<{
180
+ name: z.ZodArray<z.ZodObject<{
181
+ use: z.ZodString;
182
+ family: z.ZodString;
183
+ given: z.ZodArray<z.ZodString, "many">;
184
+ }, "strip", z.ZodTypeAny, {
185
+ use: string;
186
+ given: string[];
187
+ family: string;
188
+ }, {
189
+ use: string;
190
+ given: string[];
191
+ family: string;
192
+ }>, "many">;
193
+ mobile: z.ZodOptional<z.ZodString>;
194
+ email: z.ZodOptional<z.ZodString>;
195
+ }, "strip", z.ZodTypeAny, {
196
+ name: {
197
+ use: string;
198
+ given: string[];
199
+ family: string;
200
+ }[];
201
+ email?: string | undefined;
202
+ mobile?: string | undefined;
203
+ }, {
204
+ name: {
205
+ use: string;
206
+ given: string[];
207
+ family: string;
208
+ }[];
209
+ email?: string | undefined;
210
+ mobile?: string | undefined;
211
+ }>;
212
+ }, {
213
+ username: z.ZodString;
214
+ }>, "strip", z.ZodTypeAny, {
215
+ recipient: {
216
+ name: {
217
+ use: string;
218
+ given: string[];
219
+ family: string;
220
+ }[];
221
+ email?: string | undefined;
222
+ mobile?: string | undefined;
223
+ };
224
+ username: string;
225
+ }, {
226
+ recipient: {
227
+ name: {
228
+ use: string;
229
+ given: string[];
230
+ family: string;
231
+ }[];
232
+ email?: string | undefined;
233
+ mobile?: string | undefined;
234
+ };
235
+ username: string;
236
+ }>;
237
+ readonly "username-reminder": z.ZodObject<z.objectUtil.extendShape<{
238
+ recipient: z.ZodObject<{
239
+ name: z.ZodArray<z.ZodObject<{
240
+ use: z.ZodString;
241
+ family: z.ZodString;
242
+ given: z.ZodArray<z.ZodString, "many">;
243
+ }, "strip", z.ZodTypeAny, {
244
+ use: string;
245
+ given: string[];
246
+ family: string;
247
+ }, {
248
+ use: string;
249
+ given: string[];
250
+ family: string;
251
+ }>, "many">;
252
+ mobile: z.ZodOptional<z.ZodString>;
253
+ email: z.ZodOptional<z.ZodString>;
254
+ }, "strip", z.ZodTypeAny, {
255
+ name: {
256
+ use: string;
257
+ given: string[];
258
+ family: string;
259
+ }[];
260
+ email?: string | undefined;
261
+ mobile?: string | undefined;
262
+ }, {
263
+ name: {
264
+ use: string;
265
+ given: string[];
266
+ family: string;
267
+ }[];
268
+ email?: string | undefined;
269
+ mobile?: string | undefined;
270
+ }>;
271
+ }, {
272
+ username: z.ZodString;
273
+ }>, "strip", z.ZodTypeAny, {
274
+ recipient: {
275
+ name: {
276
+ use: string;
277
+ given: string[];
278
+ family: string;
279
+ }[];
280
+ email?: string | undefined;
281
+ mobile?: string | undefined;
282
+ };
283
+ username: string;
284
+ }, {
285
+ recipient: {
286
+ name: {
287
+ use: string;
288
+ given: string[];
289
+ family: string;
290
+ }[];
291
+ email?: string | undefined;
292
+ mobile?: string | undefined;
293
+ };
294
+ username: string;
295
+ }>;
296
+ readonly "reset-password": z.ZodObject<z.objectUtil.extendShape<{
297
+ recipient: z.ZodObject<{
298
+ name: z.ZodArray<z.ZodObject<{
299
+ use: z.ZodString;
300
+ family: z.ZodString;
301
+ given: z.ZodArray<z.ZodString, "many">;
302
+ }, "strip", z.ZodTypeAny, {
303
+ use: string;
304
+ given: string[];
305
+ family: string;
306
+ }, {
307
+ use: string;
308
+ given: string[];
309
+ family: string;
310
+ }>, "many">;
311
+ mobile: z.ZodOptional<z.ZodString>;
312
+ email: z.ZodOptional<z.ZodString>;
313
+ }, "strip", z.ZodTypeAny, {
314
+ name: {
315
+ use: string;
316
+ given: string[];
317
+ family: string;
318
+ }[];
319
+ email?: string | undefined;
320
+ mobile?: string | undefined;
321
+ }, {
322
+ name: {
323
+ use: string;
324
+ given: string[];
325
+ family: string;
326
+ }[];
327
+ email?: string | undefined;
328
+ mobile?: string | undefined;
329
+ }>;
330
+ }, {
331
+ code: z.ZodString;
332
+ }>, "strip", z.ZodTypeAny, {
333
+ code: string;
334
+ recipient: {
335
+ name: {
336
+ use: string;
337
+ given: string[];
338
+ family: string;
339
+ }[];
340
+ email?: string | undefined;
341
+ mobile?: string | undefined;
342
+ };
343
+ }, {
344
+ code: string;
345
+ recipient: {
346
+ name: {
347
+ use: string;
348
+ given: string[];
349
+ family: string;
350
+ }[];
351
+ email?: string | undefined;
352
+ mobile?: string | undefined;
353
+ };
354
+ }>;
355
+ readonly "reset-password-by-admin": z.ZodObject<z.objectUtil.extendShape<{
356
+ recipient: z.ZodObject<{
357
+ name: z.ZodArray<z.ZodObject<{
358
+ use: z.ZodString;
359
+ family: z.ZodString;
360
+ given: z.ZodArray<z.ZodString, "many">;
361
+ }, "strip", z.ZodTypeAny, {
362
+ use: string;
363
+ given: string[];
364
+ family: string;
365
+ }, {
366
+ use: string;
367
+ given: string[];
368
+ family: string;
369
+ }>, "many">;
370
+ mobile: z.ZodOptional<z.ZodString>;
371
+ email: z.ZodOptional<z.ZodString>;
372
+ }, "strip", z.ZodTypeAny, {
373
+ name: {
374
+ use: string;
375
+ given: string[];
376
+ family: string;
377
+ }[];
378
+ email?: string | undefined;
379
+ mobile?: string | undefined;
380
+ }, {
381
+ name: {
382
+ use: string;
383
+ given: string[];
384
+ family: string;
385
+ }[];
386
+ email?: string | undefined;
387
+ mobile?: string | undefined;
388
+ }>;
389
+ }, {
390
+ temporaryPassword: z.ZodString;
391
+ admin: z.ZodObject<{
392
+ id: z.ZodString;
393
+ name: z.ZodArray<z.ZodObject<{
394
+ use: z.ZodString;
395
+ given: z.ZodArray<z.ZodString, "many">;
396
+ family: z.ZodString;
397
+ }, "strip", z.ZodTypeAny, {
398
+ use: string;
399
+ given: string[];
400
+ family: string;
401
+ }, {
402
+ use: string;
403
+ given: string[];
404
+ family: string;
405
+ }>, "many">;
406
+ role: z.ZodString;
407
+ avatar: z.ZodOptional<z.ZodEffects<z.ZodString, string, string>>;
408
+ signature: z.ZodOptional<z.ZodEffects<z.ZodString, string, string>>;
409
+ }, "strip", z.ZodTypeAny, {
410
+ id: string;
411
+ name: {
412
+ use: string;
413
+ given: string[];
414
+ family: string;
415
+ }[];
416
+ role: string;
417
+ signature?: string | undefined;
418
+ avatar?: string | undefined;
419
+ }, {
420
+ id: string;
421
+ name: {
422
+ use: string;
423
+ given: string[];
424
+ family: string;
425
+ }[];
426
+ role: string;
427
+ signature?: string | undefined;
428
+ avatar?: string | undefined;
429
+ }>;
430
+ }>, "strip", z.ZodTypeAny, {
431
+ recipient: {
432
+ name: {
433
+ use: string;
434
+ given: string[];
435
+ family: string;
436
+ }[];
437
+ email?: string | undefined;
438
+ mobile?: string | undefined;
439
+ };
440
+ temporaryPassword: string;
441
+ admin: {
442
+ id: string;
443
+ name: {
444
+ use: string;
445
+ given: string[];
446
+ family: string;
447
+ }[];
448
+ role: string;
449
+ signature?: string | undefined;
450
+ avatar?: string | undefined;
451
+ };
452
+ }, {
453
+ recipient: {
454
+ name: {
455
+ use: string;
456
+ given: string[];
457
+ family: string;
458
+ }[];
459
+ email?: string | undefined;
460
+ mobile?: string | undefined;
461
+ };
462
+ temporaryPassword: string;
463
+ admin: {
464
+ id: string;
465
+ name: {
466
+ use: string;
467
+ given: string[];
468
+ family: string;
469
+ }[];
470
+ role: string;
471
+ signature?: string | undefined;
472
+ avatar?: string | undefined;
473
+ };
474
+ }>;
475
+ readonly "2fa": z.ZodObject<z.objectUtil.extendShape<{
476
+ recipient: z.ZodObject<{
477
+ name: z.ZodArray<z.ZodObject<{
478
+ use: z.ZodString;
479
+ family: z.ZodString;
480
+ given: z.ZodArray<z.ZodString, "many">;
481
+ }, "strip", z.ZodTypeAny, {
482
+ use: string;
483
+ given: string[];
484
+ family: string;
485
+ }, {
486
+ use: string;
487
+ given: string[];
488
+ family: string;
489
+ }>, "many">;
490
+ mobile: z.ZodOptional<z.ZodString>;
491
+ email: z.ZodOptional<z.ZodString>;
492
+ }, "strip", z.ZodTypeAny, {
493
+ name: {
494
+ use: string;
495
+ given: string[];
496
+ family: string;
497
+ }[];
498
+ email?: string | undefined;
499
+ mobile?: string | undefined;
500
+ }, {
501
+ name: {
502
+ use: string;
503
+ given: string[];
504
+ family: string;
505
+ }[];
506
+ email?: string | undefined;
507
+ mobile?: string | undefined;
508
+ }>;
509
+ }, {
510
+ code: z.ZodString;
511
+ }>, "strip", z.ZodTypeAny, {
512
+ code: string;
513
+ recipient: {
514
+ name: {
515
+ use: string;
516
+ given: string[];
517
+ family: string;
518
+ }[];
519
+ email?: string | undefined;
520
+ mobile?: string | undefined;
521
+ };
522
+ }, {
523
+ code: string;
524
+ recipient: {
525
+ name: {
526
+ use: string;
527
+ given: string[];
528
+ family: string;
529
+ }[];
530
+ email?: string | undefined;
531
+ mobile?: string | undefined;
532
+ };
533
+ }>;
534
+ };
535
+ export type TriggerPayload = {
536
+ [K in TriggerEvent]: z.infer<(typeof TriggerPayload)[K]>;
537
+ };
538
+ export declare function triggerUserEventNotification<T extends TriggerEvent>({ event, payload, countryConfigUrl, authHeader }: {
539
+ event: T;
540
+ payload: TriggerPayload[T];
541
+ countryConfigUrl: string;
542
+ authHeader: {
543
+ Authorization: string;
544
+ };
545
+ }): Promise<Response>;
546
+ export declare function parseUserEventTrigger<T extends TriggerEvent>(event: T, body: unknown): TriggerPayload[T];
547
+ //# sourceMappingURL=UserNotifications.d.ts.map
@@ -0,0 +1,2 @@
1
+ export * from './UserNotifications';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -2288,14 +2288,17 @@ var isNonInteractiveFieldType = (field2) => {
2288
2288
  };
2289
2289
 
2290
2290
  // ../commons/src/conditionals/validate.ts
2291
- var ajv = new import__.default({
2291
+ var AJV_OPTIONS = {
2292
2292
  $data: true,
2293
2293
  allowUnionTypes: true,
2294
+ // This must be here to prevent memory leaks
2295
+ // https://www.poberezkin.com/posts/2021-02-11-ajv-version-7-big-changes-and-improvements.html#caching-compiled-schemas
2296
+ // https://github.com/ajv-validator/ajv/issues/1413
2297
+ addUsedSchema: false,
2294
2298
  strict: false
2295
2299
  // Allow minContains and other newer features
2296
- });
2297
- (0, import_ajv_formats.default)(ajv);
2298
- ajv.addKeyword({
2300
+ };
2301
+ var daysFromNow = {
2299
2302
  keyword: "daysFromNow",
2300
2303
  type: "string",
2301
2304
  schemaType: "object",
@@ -2317,8 +2320,11 @@ ajv.addKeyword({
2317
2320
  const offsetDate = new Date(now.getTime() + days * 24 * 60 * 60 * 1e3);
2318
2321
  return clause === "after" ? (0, import_date_fns.isAfter)(date, offsetDate) : (0, import_date_fns.isBefore)(date, offsetDate);
2319
2322
  }
2320
- });
2323
+ };
2321
2324
  function validate(schema, data) {
2325
+ const ajv = new import__.default(AJV_OPTIONS);
2326
+ (0, import_ajv_formats.default)(ajv);
2327
+ ajv.addKeyword(daysFromNow);
2322
2328
  return ajv.validate(schema, data);
2323
2329
  }
2324
2330
  function isConditionMet(conditional, values) {
@@ -2548,6 +2554,9 @@ function getValidatorsForField(fieldId, validations) {
2548
2554
  }).filter((x) => x !== null);
2549
2555
  }
2550
2556
  function areCertificateConditionsMet(conditions, values) {
2557
+ const ajv = new import__.default(AJV_OPTIONS);
2558
+ (0, import_ajv_formats.default)(ajv);
2559
+ ajv.addKeyword(daysFromNow);
2551
2560
  return conditions.every((condition) => {
2552
2561
  return ajv.validate(condition.conditional, values);
2553
2562
  });
@@ -5741,44 +5750,41 @@ var tennisClubMembershipEvent = defineConfig({
5741
5750
  },
5742
5751
  {
5743
5752
  id: "identity-check",
5744
- type: PageTypes.enum.FORM,
5753
+ type: PageTypes.enum.VERIFICATION,
5745
5754
  title: {
5746
- id: "event.tennis-club-membership.action.requestCorrection.form.section.verify",
5747
- defaultMessage: "Verify their identity",
5755
+ id: "v2.event.birth.action.correction.form.section.requester.identity.verify.title",
5756
+ defaultMessage: "Verify ID",
5748
5757
  description: "This is the title of the section"
5749
5758
  },
5750
- fields: [
5751
- {
5752
- id: "correction.identity-check.instructions",
5753
- type: "PAGE_HEADER",
5759
+ fields: [],
5760
+ actions: {
5761
+ verify: {
5754
5762
  label: {
5755
- id: "correction.corrector.identity.instruction",
5756
- defaultMessage: "Please verify the identity of the person making this request",
5757
- description: "The title for the corrector form"
5763
+ defaultMessage: "Verified",
5764
+ description: "This is the label for the verification button",
5765
+ id: "v2.event.birth.action.correction.form.verify"
5758
5766
  }
5759
5767
  },
5760
- {
5761
- id: "correction.identity-check.verified",
5762
- type: "RADIO_GROUP",
5768
+ cancel: {
5763
5769
  label: {
5764
- id: "correction.corrector.identity.verified.label",
5765
- defaultMessage: "Identity verified",
5766
- description: "The title for the corrector form"
5770
+ defaultMessage: "Identity does not match",
5771
+ description: "This is the label for the verification cancellation button",
5772
+ id: "v2.event.birth.action.correction.form.cancel"
5767
5773
  },
5768
- defaultValue: "",
5769
- required: true,
5770
- options: [
5771
- {
5772
- value: "VERIFIED",
5773
- label: {
5774
- id: "correction.corrector.identity.verified",
5775
- defaultMessage: "I have verified their identity",
5776
- description: "Label for verified option in corrector identity check page"
5777
- }
5774
+ confirmation: {
5775
+ title: {
5776
+ defaultMessage: "Correct without proof of ID?",
5777
+ description: "This is the title for the verification cancellation modal",
5778
+ id: "v2.event.birth.action.correction.form.cancel.confirmation.title"
5779
+ },
5780
+ body: {
5781
+ defaultMessage: "Please be aware that if you proceed, you will be responsible for making a change to this record without the necessary proof of identification",
5782
+ description: "This is the body for the verification cancellation modal",
5783
+ id: "v2.event.birth.action.correction.form.cancel.confirmation.body"
5778
5784
  }
5779
- ]
5785
+ }
5780
5786
  }
5781
- ]
5787
+ }
5782
5788
  },
5783
5789
  {
5784
5790
  id: "correction-request.supporting-documents",
@@ -6752,6 +6758,7 @@ function eventPayloadGenerator(rng) {
6752
6758
  annotation: {
6753
6759
  "correction.requester.relationship": "ANOTHER_AGENT",
6754
6760
  "correction.request.reason": "Child's name was incorrect",
6761
+ "identity-check": true,
6755
6762
  ...annotation
6756
6763
  },
6757
6764
  createdAt: (/* @__PURE__ */ new Date()).toISOString(),
@@ -0,0 +1,2 @@
1
+ export * from '../commons/notification';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/notification/index.ts"],"names":[],"mappings":"AAUA,cAAc,gCAAgC,CAAA"}