@opencrvs/toolkit 2.1.0-rc.d876831 → 2.1.0-rc.d987aec

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 (81) hide show
  1. package/README.md +2 -12
  2. package/build.sh +9 -1
  3. package/create-countryconfig/index.js +412 -59
  4. package/create-countryconfig/node_modules/.bin/degit +21 -0
  5. package/create-countryconfig/package.json +4 -1
  6. package/dist/application-config/index.js +248 -215
  7. package/dist/authentication/index.d.ts +67 -0
  8. package/dist/authentication/index.d.ts.map +1 -0
  9. package/dist/authentication/index.js +750 -0
  10. package/dist/cli.js +1650 -100
  11. package/dist/commons/api/router.d.ts +407 -50
  12. package/dist/commons/conditionals/conditionals.d.ts +6 -6
  13. package/dist/commons/conditionals/validate.d.ts +7 -3
  14. package/dist/commons/events/ActionDocument.d.ts +4 -4
  15. package/dist/commons/events/ActionInput.d.ts +4 -4
  16. package/dist/commons/events/AdvancedSearchConfig.d.ts +12 -0
  17. package/dist/commons/events/EventDocument.d.ts +470 -2
  18. package/dist/commons/events/EventMetadata.d.ts +1 -11
  19. package/dist/commons/events/EventStatus.d.ts +19 -0
  20. package/dist/commons/events/FieldConfig.d.ts +24 -5
  21. package/dist/commons/events/FieldTypeMapping.d.ts +15 -15
  22. package/dist/commons/events/locations.d.ts +63 -10
  23. package/dist/commons/events/test.utils.d.ts +25 -4
  24. package/dist/commons/events/utils.d.ts +13 -2
  25. package/dist/commons/notification/UserNotifications.d.ts +28 -13
  26. package/dist/commons/notification/dispatch.d.ts +10 -0
  27. package/dist/commons/notification/index.d.ts +1 -0
  28. package/dist/conditionals/index.js +79 -57
  29. package/dist/csv.d.ts +25 -0
  30. package/dist/csv.d.ts.map +1 -0
  31. package/dist/csv.js +120 -0
  32. package/dist/environment/logger.d.ts +3 -0
  33. package/dist/environment/logger.d.ts.map +1 -1
  34. package/dist/environment/manage-users.js +1 -1
  35. package/dist/environment/questions.d.ts.map +1 -1
  36. package/dist/environment/questions.js +20 -14
  37. package/dist/environment/setup-environment.js +26 -6
  38. package/dist/environment/templates.d.ts +0 -1
  39. package/dist/environment/templates.d.ts.map +1 -1
  40. package/dist/environment/templates.js +3 -8
  41. package/dist/events/index.js +2632 -2481
  42. package/dist/migrations/v2.0/checkout-upstream-files.d.ts +2 -2
  43. package/dist/migrations/v2.0/checkout-upstream-files.d.ts.map +1 -1
  44. package/dist/migrations/v2.0/checkout-upstream-files.js +2 -2
  45. package/dist/migrations/v2.1/add-recovery-link-notifications.d.ts +3 -0
  46. package/dist/migrations/v2.1/add-recovery-link-notifications.d.ts.map +1 -0
  47. package/dist/migrations/v2.1/add-recovery-link-notifications.js +511 -0
  48. package/dist/migrations/v2.1/add-translations.d.ts +9 -0
  49. package/dist/migrations/v2.1/add-translations.d.ts.map +1 -0
  50. package/dist/migrations/v2.1/add-translations.js +213 -0
  51. package/dist/migrations/v2.1/enable-telemetry.d.ts +3 -0
  52. package/dist/migrations/v2.1/enable-telemetry.d.ts.map +1 -0
  53. package/dist/migrations/v2.1/enable-telemetry.js +438 -0
  54. package/dist/migrations/v2.1/index.d.ts.map +1 -1
  55. package/dist/migrations/v2.1/index.js +1058 -0
  56. package/dist/notification/index.js +1027 -1452
  57. package/dist/scopes/index.d.ts +77 -7
  58. package/dist/scopes/index.js +79 -57
  59. package/dist/telemetry/index.d.ts +45 -0
  60. package/dist/telemetry/index.d.ts.map +1 -0
  61. package/dist/telemetry/index.js +39 -0
  62. package/dist/templates/charts-values/dependencies/values.yaml +2 -0
  63. package/dist/templates/charts-values/opencrvs-services/values.yaml +1 -1
  64. package/dist/templates/charts-values/opentelemetry/values.yaml +22 -0
  65. package/dist/templates/charts-values/traefik/values.yaml +23 -9
  66. package/dist/templates/inventory/inventory.template.yml +1 -3
  67. package/dist/translations/check.d.ts +21 -0
  68. package/dist/translations/check.d.ts.map +1 -0
  69. package/dist/translations/check.js +132 -0
  70. package/dist/verify/endpoints.d.ts +2 -0
  71. package/dist/verify/endpoints.d.ts.map +1 -0
  72. package/dist/verify/endpoints.js +345 -0
  73. package/opencrvs-toolkit-2.1.0-rc.d987aec.tgz +0 -0
  74. package/package.json +9 -4
  75. package/tsconfig.build.json +11 -0
  76. package/tsconfig.build.tsbuildinfo +1 -0
  77. package/tsconfig.json +3 -0
  78. package/dist/templates/inventory/production.example.yml +0 -77
  79. package/dist/templates/inventory/qa.example.yml +0 -48
  80. package/opencrvs-toolkit-2.1.0-rc.d876831.tgz +0 -0
  81. package/tsconfig.tsbuildinfo +0 -1
@@ -58,6 +58,13 @@ declare const AllScopeOptions: z.ZodObject<{
58
58
  declaredBy: z.ZodOptional<z.ZodEnum<{
59
59
  user: "user";
60
60
  }>>;
61
+ status: z.ZodPreprocess<z.ZodOptional<z.ZodArray<z.ZodEnum<{
62
+ ARCHIVED: "ARCHIVED";
63
+ CREATED: "CREATED";
64
+ DECLARED: "DECLARED";
65
+ NOTIFIED: "NOTIFIED";
66
+ REGISTERED: "REGISTERED";
67
+ }>>>>;
61
68
  registeredIn: z.ZodOptional<z.ZodEnum<{
62
69
  administrativeArea: "administrativeArea";
63
70
  all: "all";
@@ -111,6 +118,7 @@ export declare const ScopeOptionKey: z.ZodEnum<{
111
118
  registeredBy: "registeredBy";
112
119
  registeredIn: "registeredIn";
113
120
  role: "role";
121
+ status: "status";
114
122
  }>;
115
123
  export type ScopeOptionKey = z.infer<typeof ScopeOptionKey>;
116
124
  export declare const ScopesWithPlaceEventOptions: z.ZodEnum<{
@@ -123,13 +131,13 @@ export declare const ScopesWithDeclaredOptions: z.ZodEnum<{
123
131
  "record.edit": "record.edit";
124
132
  "record.register": "record.register";
125
133
  "record.reject": "record.reject";
126
- "record.review-duplicates": "record.review-duplicates";
127
134
  "record.unarchive": "record.unarchive";
128
135
  }>;
129
136
  export declare const ScopesWithFullOptions: z.ZodEnum<{
130
137
  "record.correct": "record.correct";
131
138
  "record.read": "record.read";
132
139
  "record.request-correction": "record.request-correction";
140
+ "record.review-duplicates": "record.review-duplicates";
133
141
  "record.search": "record.search";
134
142
  "record.unassign-others": "record.unassign-others";
135
143
  }>;
@@ -153,7 +161,6 @@ export declare const RecordScopeV2: z.ZodDiscriminatedUnion<[z.ZodObject<{
153
161
  "record.edit": "record.edit";
154
162
  "record.register": "record.register";
155
163
  "record.reject": "record.reject";
156
- "record.review-duplicates": "record.review-duplicates";
157
164
  "record.unarchive": "record.unarchive";
158
165
  }>;
159
166
  options: z.ZodOptional<z.ZodObject<{
@@ -179,12 +186,20 @@ export declare const RecordScopeV2: z.ZodDiscriminatedUnion<[z.ZodObject<{
179
186
  declaredBy: z.ZodOptional<z.ZodEnum<{
180
187
  user: "user";
181
188
  }>>;
189
+ status: z.ZodPreprocess<z.ZodOptional<z.ZodArray<z.ZodEnum<{
190
+ ARCHIVED: "ARCHIVED";
191
+ CREATED: "CREATED";
192
+ DECLARED: "DECLARED";
193
+ NOTIFIED: "NOTIFIED";
194
+ REGISTERED: "REGISTERED";
195
+ }>>>>;
182
196
  }, z.core.$strip>>;
183
197
  }, z.core.$strip>, z.ZodObject<{
184
198
  type: z.ZodEnum<{
185
199
  "record.correct": "record.correct";
186
200
  "record.read": "record.read";
187
201
  "record.request-correction": "record.request-correction";
202
+ "record.review-duplicates": "record.review-duplicates";
188
203
  "record.search": "record.search";
189
204
  "record.unassign-others": "record.unassign-others";
190
205
  }>;
@@ -211,6 +226,13 @@ export declare const RecordScopeV2: z.ZodDiscriminatedUnion<[z.ZodObject<{
211
226
  declaredBy: z.ZodOptional<z.ZodEnum<{
212
227
  user: "user";
213
228
  }>>;
229
+ status: z.ZodPreprocess<z.ZodOptional<z.ZodArray<z.ZodEnum<{
230
+ ARCHIVED: "ARCHIVED";
231
+ CREATED: "CREATED";
232
+ DECLARED: "DECLARED";
233
+ NOTIFIED: "NOTIFIED";
234
+ REGISTERED: "REGISTERED";
235
+ }>>>>;
214
236
  registeredIn: z.ZodOptional<z.ZodEnum<{
215
237
  administrativeArea: "administrativeArea";
216
238
  all: "all";
@@ -268,6 +290,13 @@ export declare const RecordScopeV2: z.ZodDiscriminatedUnion<[z.ZodObject<{
268
290
  declaredBy: z.ZodOptional<z.ZodEnum<{
269
291
  user: "user";
270
292
  }>>;
293
+ status: z.ZodPreprocess<z.ZodOptional<z.ZodArray<z.ZodEnum<{
294
+ ARCHIVED: "ARCHIVED";
295
+ CREATED: "CREATED";
296
+ DECLARED: "DECLARED";
297
+ NOTIFIED: "NOTIFIED";
298
+ REGISTERED: "REGISTERED";
299
+ }>>>>;
271
300
  registeredIn: z.ZodOptional<z.ZodEnum<{
272
301
  administrativeArea: "administrativeArea";
273
302
  all: "all";
@@ -326,6 +355,13 @@ export declare const RecordScopeV2: z.ZodDiscriminatedUnion<[z.ZodObject<{
326
355
  declaredBy: z.ZodOptional<z.ZodEnum<{
327
356
  user: "user";
328
357
  }>>;
358
+ status: z.ZodPreprocess<z.ZodOptional<z.ZodArray<z.ZodEnum<{
359
+ ARCHIVED: "ARCHIVED";
360
+ CREATED: "CREATED";
361
+ DECLARED: "DECLARED";
362
+ NOTIFIED: "NOTIFIED";
363
+ REGISTERED: "REGISTERED";
364
+ }>>>>;
329
365
  registeredIn: z.ZodOptional<z.ZodEnum<{
330
366
  administrativeArea: "administrativeArea";
331
367
  all: "all";
@@ -438,7 +474,6 @@ export declare const ResolvedRecordScopeV2: z.ZodDiscriminatedUnion<[z.ZodObject
438
474
  "record.edit": "record.edit";
439
475
  "record.register": "record.register";
440
476
  "record.reject": "record.reject";
441
- "record.review-duplicates": "record.review-duplicates";
442
477
  "record.unarchive": "record.unarchive";
443
478
  }>;
444
479
  options: z.ZodOptional<z.ZodObject<{
@@ -454,6 +489,7 @@ export declare const ResolvedRecordScopeV2: z.ZodDiscriminatedUnion<[z.ZodObject
454
489
  "record.correct": "record.correct";
455
490
  "record.read": "record.read";
456
491
  "record.request-correction": "record.request-correction";
492
+ "record.review-duplicates": "record.review-duplicates";
457
493
  "record.search": "record.search";
458
494
  "record.unassign-others": "record.unassign-others";
459
495
  }>;
@@ -535,6 +571,7 @@ export declare const Scope: z.ZodDiscriminatedUnion<[z.ZodObject<{
535
571
  "attachment.upload": "attachment.upload";
536
572
  bypassratelimit: "bypassratelimit";
537
573
  "config.update-all": "config.update-all";
574
+ "integration.audit.read": "integration.audit.read";
538
575
  "integration.create": "integration.create";
539
576
  "location.edit": "location.edit";
540
577
  "performance.read": "performance.read";
@@ -568,7 +605,6 @@ export declare const Scope: z.ZodDiscriminatedUnion<[z.ZodObject<{
568
605
  "record.edit": "record.edit";
569
606
  "record.register": "record.register";
570
607
  "record.reject": "record.reject";
571
- "record.review-duplicates": "record.review-duplicates";
572
608
  "record.unarchive": "record.unarchive";
573
609
  }>;
574
610
  options: z.ZodOptional<z.ZodObject<{
@@ -594,12 +630,20 @@ export declare const Scope: z.ZodDiscriminatedUnion<[z.ZodObject<{
594
630
  declaredBy: z.ZodOptional<z.ZodEnum<{
595
631
  user: "user";
596
632
  }>>;
633
+ status: z.ZodPreprocess<z.ZodOptional<z.ZodArray<z.ZodEnum<{
634
+ ARCHIVED: "ARCHIVED";
635
+ CREATED: "CREATED";
636
+ DECLARED: "DECLARED";
637
+ NOTIFIED: "NOTIFIED";
638
+ REGISTERED: "REGISTERED";
639
+ }>>>>;
597
640
  }, z.core.$strip>>;
598
641
  }, z.core.$strip>, z.ZodObject<{
599
642
  type: z.ZodEnum<{
600
643
  "record.correct": "record.correct";
601
644
  "record.read": "record.read";
602
645
  "record.request-correction": "record.request-correction";
646
+ "record.review-duplicates": "record.review-duplicates";
603
647
  "record.search": "record.search";
604
648
  "record.unassign-others": "record.unassign-others";
605
649
  }>;
@@ -626,6 +670,13 @@ export declare const Scope: z.ZodDiscriminatedUnion<[z.ZodObject<{
626
670
  declaredBy: z.ZodOptional<z.ZodEnum<{
627
671
  user: "user";
628
672
  }>>;
673
+ status: z.ZodPreprocess<z.ZodOptional<z.ZodArray<z.ZodEnum<{
674
+ ARCHIVED: "ARCHIVED";
675
+ CREATED: "CREATED";
676
+ DECLARED: "DECLARED";
677
+ NOTIFIED: "NOTIFIED";
678
+ REGISTERED: "REGISTERED";
679
+ }>>>>;
629
680
  registeredIn: z.ZodOptional<z.ZodEnum<{
630
681
  administrativeArea: "administrativeArea";
631
682
  all: "all";
@@ -683,6 +734,13 @@ export declare const Scope: z.ZodDiscriminatedUnion<[z.ZodObject<{
683
734
  declaredBy: z.ZodOptional<z.ZodEnum<{
684
735
  user: "user";
685
736
  }>>;
737
+ status: z.ZodPreprocess<z.ZodOptional<z.ZodArray<z.ZodEnum<{
738
+ ARCHIVED: "ARCHIVED";
739
+ CREATED: "CREATED";
740
+ DECLARED: "DECLARED";
741
+ NOTIFIED: "NOTIFIED";
742
+ REGISTERED: "REGISTERED";
743
+ }>>>>;
686
744
  registeredIn: z.ZodOptional<z.ZodEnum<{
687
745
  administrativeArea: "administrativeArea";
688
746
  all: "all";
@@ -741,6 +799,13 @@ export declare const Scope: z.ZodDiscriminatedUnion<[z.ZodObject<{
741
799
  declaredBy: z.ZodOptional<z.ZodEnum<{
742
800
  user: "user";
743
801
  }>>;
802
+ status: z.ZodPreprocess<z.ZodOptional<z.ZodArray<z.ZodEnum<{
803
+ ARCHIVED: "ARCHIVED";
804
+ CREATED: "CREATED";
805
+ DECLARED: "DECLARED";
806
+ NOTIFIED: "NOTIFIED";
807
+ REGISTERED: "REGISTERED";
808
+ }>>>>;
744
809
  registeredIn: z.ZodOptional<z.ZodEnum<{
745
810
  administrativeArea: "administrativeArea";
746
811
  all: "all";
@@ -825,6 +890,7 @@ export declare const ScopeType: z.ZodEnum<{
825
890
  bypassratelimit: "bypassratelimit";
826
891
  "config.update-all": "config.update-all";
827
892
  "dashboard.view": "dashboard.view";
893
+ "integration.audit.read": "integration.audit.read";
828
894
  "integration.create": "integration.create";
829
895
  "location.edit": "location.edit";
830
896
  "organisation.read-locations": "organisation.read-locations";
@@ -888,7 +954,7 @@ export declare const decodeScope: (encodedScope: EncodedScope) => {
888
954
  placeOfEvent?: "administrativeArea" | "all" | "location" | undefined;
889
955
  } | undefined;
890
956
  } | {
891
- type: "record.archive" | "record.edit" | "record.register" | "record.reject" | "record.review-duplicates" | "record.unarchive";
957
+ type: "record.archive" | "record.edit" | "record.register" | "record.reject" | "record.unarchive";
892
958
  options?: {
893
959
  event?: string[] | undefined;
894
960
  placeOfEvent?: "administrativeArea" | "all" | "location" | undefined;
@@ -896,9 +962,10 @@ export declare const decodeScope: (encodedScope: EncodedScope) => {
896
962
  notifiedBy?: "user" | undefined;
897
963
  declaredIn?: "administrativeArea" | "all" | "location" | undefined;
898
964
  declaredBy?: "user" | undefined;
965
+ status?: ("ARCHIVED" | "CREATED" | "DECLARED" | "NOTIFIED" | "REGISTERED")[] | undefined;
899
966
  } | undefined;
900
967
  } | {
901
- type: "record.correct" | "record.read" | "record.request-correction" | "record.search" | "record.unassign-others";
968
+ type: "record.correct" | "record.read" | "record.request-correction" | "record.review-duplicates" | "record.search" | "record.unassign-others";
902
969
  options?: {
903
970
  event?: string[] | undefined;
904
971
  placeOfEvent?: "administrativeArea" | "all" | "location" | undefined;
@@ -906,6 +973,7 @@ export declare const decodeScope: (encodedScope: EncodedScope) => {
906
973
  notifiedBy?: "user" | undefined;
907
974
  declaredIn?: "administrativeArea" | "all" | "location" | undefined;
908
975
  declaredBy?: "user" | undefined;
976
+ status?: ("ARCHIVED" | "CREATED" | "DECLARED" | "NOTIFIED" | "REGISTERED")[] | undefined;
909
977
  registeredIn?: "administrativeArea" | "all" | "location" | undefined;
910
978
  registeredBy?: "user" | undefined;
911
979
  flags?: {
@@ -923,6 +991,7 @@ export declare const decodeScope: (encodedScope: EncodedScope) => {
923
991
  notifiedBy?: "user" | undefined;
924
992
  declaredIn?: "administrativeArea" | "all" | "location" | undefined;
925
993
  declaredBy?: "user" | undefined;
994
+ status?: ("ARCHIVED" | "CREATED" | "DECLARED" | "NOTIFIED" | "REGISTERED")[] | undefined;
926
995
  registeredIn?: "administrativeArea" | "all" | "location" | undefined;
927
996
  registeredBy?: "user" | undefined;
928
997
  flags?: {
@@ -941,6 +1010,7 @@ export declare const decodeScope: (encodedScope: EncodedScope) => {
941
1010
  notifiedBy?: "user" | undefined;
942
1011
  declaredIn?: "administrativeArea" | "all" | "location" | undefined;
943
1012
  declaredBy?: "user" | undefined;
1013
+ status?: ("ARCHIVED" | "CREATED" | "DECLARED" | "NOTIFIED" | "REGISTERED")[] | undefined;
944
1014
  registeredIn?: "administrativeArea" | "all" | "location" | undefined;
945
1015
  registeredBy?: "user" | undefined;
946
1016
  flags?: {
@@ -962,7 +1032,7 @@ export declare const decodeScope: (encodedScope: EncodedScope) => {
962
1032
  accessLevel?: "administrativeArea" | "all" | "location" | undefined;
963
1033
  } | undefined;
964
1034
  } | {
965
- type: "attachment.upload" | "bypassratelimit" | "config.update-all" | "integration.create" | "location.edit" | "performance.read" | "performance.read-dashboards" | "performance.vital-statistics-export" | "profile.electronic-signature" | "record.confirm-registration" | "record.import" | "record.reindex" | "record.reject-registration" | "user.data-seeding" | "user.read-only-my-audit";
1035
+ type: "attachment.upload" | "bypassratelimit" | "config.update-all" | "integration.audit.read" | "integration.create" | "location.edit" | "performance.read" | "performance.read-dashboards" | "performance.vital-statistics-export" | "profile.electronic-signature" | "record.confirm-registration" | "record.import" | "record.reindex" | "record.reject-registration" | "user.data-seeding" | "user.read-only-my-audit";
966
1036
  } | {
967
1037
  type: "organisation.read-locations";
968
1038
  options?: {
@@ -59,10 +59,10 @@ __export(scopes_exports, {
59
59
  scopeUsesRoleOptions: () => scopeUsesRoleOptions
60
60
  });
61
61
  module.exports = __toCommonJS(scopes_exports);
62
- var z8 = __toESM(require("zod/v4"));
62
+ var z9 = __toESM(require("zod/v4"));
63
63
 
64
64
  // ../commons/src/scopes.ts
65
- var z7 = __toESM(require("zod/v4"));
65
+ var z8 = __toESM(require("zod/v4"));
66
66
  var qs = __toESM(require("qs"));
67
67
 
68
68
  // ../commons/src/uuid.ts
@@ -341,12 +341,22 @@ var ActionFlagConfig = z6.object({
341
341
  description: "Add or remove operation applied to a flag when the parent action is accepted. Optionally gated by a conditional."
342
342
  });
343
343
 
344
+ // ../commons/src/events/EventStatus.ts
345
+ var z7 = __toESM(require("zod/v4"));
346
+ var EventStatus = z7.enum([
347
+ "CREATED",
348
+ "NOTIFIED",
349
+ "DECLARED",
350
+ "REGISTERED",
351
+ "ARCHIVED"
352
+ ]);
353
+
344
354
  // ../commons/src/scopes.ts
345
- var JurisdictionFilter = z7.enum(["administrativeArea", "location", "all"]).describe(
355
+ var JurisdictionFilter = z8.enum(["administrativeArea", "location", "all"]).describe(
346
356
  "Filters based on user jurisdiction relative to their office location in hierarchy."
347
357
  );
348
- var UserFilter = z7.enum(["user"]).describe("Filters based on the user. Limits to self.");
349
- var RecordScopeTypeV2 = z7.enum([
358
+ var UserFilter = z8.enum(["user"]).describe("Filters based on the user. Limits to self.");
359
+ var RecordScopeTypeV2 = z8.enum([
350
360
  "record.search",
351
361
  "record.create",
352
362
  "record.read",
@@ -364,12 +374,17 @@ var RecordScopeTypeV2 = z7.enum([
364
374
  "record.unassign-others",
365
375
  "record.custom-action"
366
376
  ]);
367
- var PlainScopeType = z7.enum([
377
+ var PlainScopeType = z8.enum([
368
378
  // Misc. system scopes
369
379
  "bypassratelimit",
370
380
  "record.reindex",
371
381
  "user.data-seeding",
372
382
  "integration.create",
383
+ // Reading an integration's audit log. Deliberately separate from
384
+ // 'integration.create' so read-only oversight can be granted on its own, and
385
+ // deliberately option-less: system clients have no office and no
386
+ // administrative area, so jurisdiction options would have nothing to bind to.
387
+ "integration.audit.read",
373
388
  "record.import",
374
389
  "config.update-all",
375
390
  "location.edit",
@@ -384,15 +399,21 @@ var PlainScopeType = z7.enum([
384
399
  "record.confirm-registration",
385
400
  "record.reject-registration"
386
401
  ]);
387
- var scopeByEvent = z7.preprocess(
402
+ var scopeByEvent = z8.preprocess(
388
403
  (val) => val === void 0 ? void 0 : [val].flat(),
389
- z7.array(z7.string()).optional()
404
+ z8.array(z8.string()).optional()
390
405
  ).describe("Event type, e.g. birth, death");
391
- var userRole = z7.preprocess(
406
+ var scopeByStatus = z8.preprocess(
407
+ (val) => val === void 0 ? void 0 : [val].flat(),
408
+ z8.array(EventStatus).optional()
409
+ ).describe(
410
+ "Restricts the scope to records currently in one of these statuses."
411
+ );
412
+ var userRole = z8.preprocess(
392
413
  (val) => val === void 0 ? void 0 : [val].flat(),
393
- z7.array(z7.string()).optional()
414
+ z8.array(z8.string()).optional()
394
415
  ).describe("User role, e.g. admin, field agent");
395
- var scopeOptionsPlaceEvent = z7.object({
416
+ var scopeOptionsPlaceEvent = z8.object({
396
417
  event: scopeByEvent,
397
418
  placeOfEvent: JurisdictionFilter.optional()
398
419
  }).describe("Options applicable to all record scopes.");
@@ -400,7 +421,8 @@ var scopeOptionsDeclaredOrNotified = scopeOptionsPlaceEvent.extend({
400
421
  notifiedIn: JurisdictionFilter.optional(),
401
422
  notifiedBy: UserFilter.optional(),
402
423
  declaredIn: JurisdictionFilter.optional(),
403
- declaredBy: UserFilter.optional()
424
+ declaredBy: UserFilter.optional(),
425
+ status: scopeByStatus
404
426
  }).describe("Options applicable to actions that may take place after DECLARE");
405
427
  var AllRecordScopeOptions = scopeOptionsDeclaredOrNotified.extend({
406
428
  registeredIn: JurisdictionFilter.optional(),
@@ -410,31 +432,31 @@ var AllRecordScopeOptions = scopeOptionsDeclaredOrNotified.extend({
410
432
  "Options applicable to actions that may take place after REGISTER, with full filtering capabilities."
411
433
  );
412
434
  var CustomActionScopeOptions = AllRecordScopeOptions.extend({
413
- customActionTypes: z7.preprocess(
435
+ customActionTypes: z8.preprocess(
414
436
  (val) => val === void 0 ? void 0 : [val].flat(),
415
- z7.array(z7.string()).optional()
437
+ z8.array(z8.string()).optional()
416
438
  ).describe("Allowed custom action types")
417
439
  });
418
- var AccessLevelOptions = z7.object({
440
+ var AccessLevelOptions = z8.object({
419
441
  accessLevel: JurisdictionFilter.optional()
420
442
  });
421
443
  var AllUserScopeOptions = AccessLevelOptions.extend({
422
444
  role: userRole.optional()
423
445
  });
424
- var WorkqueueOrDashboardOptions = z7.object({
425
- ids: z7.preprocess(
446
+ var WorkqueueOrDashboardOptions = z8.object({
447
+ ids: z8.preprocess(
426
448
  (val) => val === void 0 ? void 0 : [val].flat(),
427
- z7.array(z7.string())
449
+ z8.array(z8.string())
428
450
  ).describe("Must contain a list of workqueue or dashboard ids.")
429
451
  });
430
- var AllScopeOptions = z7.object({
452
+ var AllScopeOptions = z8.object({
431
453
  ...AllRecordScopeOptions.shape,
432
454
  ...AccessLevelOptions.shape,
433
455
  ...AllUserScopeOptions.shape,
434
456
  ...WorkqueueOrDashboardOptions.shape
435
457
  });
436
458
  var ScopeOptionKey = AllScopeOptions.keyof();
437
- var ResolvedScopeOptionsPlaceEvent = z7.object({
459
+ var ResolvedScopeOptionsPlaceEvent = z8.object({
438
460
  event: scopeByEvent,
439
461
  placeOfEvent: UUID.nullish()
440
462
  }).describe(
@@ -442,15 +464,15 @@ var ResolvedScopeOptionsPlaceEvent = z7.object({
442
464
  );
443
465
  var ResolvedScopeOptionsDeclared = ResolvedScopeOptionsPlaceEvent.extend({
444
466
  notifiedIn: UUID.nullish(),
445
- notifiedBy: z7.string().optional(),
467
+ notifiedBy: z8.string().optional(),
446
468
  declaredIn: UUID.nullish(),
447
- declaredBy: z7.string().optional()
469
+ declaredBy: z8.string().optional()
448
470
  }).describe(
449
471
  "Resolved options applicable to actions that may take place after DECLARE, with location ID and user ID instead of filters."
450
472
  );
451
473
  var ResolvedScopeOptionsFull = ResolvedScopeOptionsDeclared.extend({
452
474
  registeredIn: UUID.nullish(),
453
- registeredBy: z7.string().optional(),
475
+ registeredBy: z8.string().optional(),
454
476
  flags: ContainsFlags.optional()
455
477
  }).describe(
456
478
  "Resolved options applicable to actions that may take place after REGISTER, with full filtering capabilities and location/user IDs instead of filters."
@@ -465,7 +487,6 @@ var ScopesWithDeclaredOptions = RecordScopeTypeV2.extract([
465
487
  "record.reject",
466
488
  "record.archive",
467
489
  "record.unarchive",
468
- "record.review-duplicates",
469
490
  "record.register"
470
491
  ]);
471
492
  var ScopesWithFullOptions = RecordScopeTypeV2.extract([
@@ -473,41 +494,42 @@ var ScopesWithFullOptions = RecordScopeTypeV2.extract([
473
494
  "record.read",
474
495
  "record.request-correction",
475
496
  "record.correct",
476
- "record.unassign-others"
497
+ "record.unassign-others",
498
+ "record.review-duplicates"
477
499
  ]);
478
500
  var ScopeOptionsPrintCertifiedCopies = AllRecordScopeOptions.extend({
479
- templates: z7.preprocess(
501
+ templates: z8.preprocess(
480
502
  (val) => val === void 0 ? void 0 : [val].flat(),
481
- z7.array(z7.string()).optional()
503
+ z8.array(z8.string()).optional()
482
504
  ).describe(
483
505
  "Template IDs for certified copies. Controls which certificate templates are returned to the client via the config service. Certificate printing is a client-side operation \u2014 this option is not validated when the printCertificate action is submitted."
484
506
  )
485
507
  });
486
- var RecordScopeV2 = z7.discriminatedUnion("type", [
487
- z7.object({
508
+ var RecordScopeV2 = z8.discriminatedUnion("type", [
509
+ z8.object({
488
510
  type: ScopesWithPlaceEventOptions,
489
511
  options: scopeOptionsPlaceEvent.optional()
490
512
  }),
491
- z7.object({
513
+ z8.object({
492
514
  type: ScopesWithDeclaredOptions,
493
515
  options: scopeOptionsDeclaredOrNotified.optional()
494
516
  }),
495
- z7.object({
517
+ z8.object({
496
518
  type: ScopesWithFullOptions,
497
519
  options: AllRecordScopeOptions.optional()
498
520
  }),
499
- z7.object({
500
- type: z7.literal("record.custom-action"),
521
+ z8.object({
522
+ type: z8.literal("record.custom-action"),
501
523
  options: CustomActionScopeOptions.optional()
502
524
  }),
503
- z7.object({
504
- type: z7.literal("record.print-certified-copies"),
525
+ z8.object({
526
+ type: z8.literal("record.print-certified-copies"),
505
527
  options: ScopeOptionsPrintCertifiedCopies.optional()
506
528
  })
507
529
  ]).describe(
508
530
  "Scopes used to check user's permission to perform actions on a record."
509
531
  );
510
- var SystemScopeType = z7.enum([
532
+ var SystemScopeType = z8.enum([
511
533
  "organisation.read-locations",
512
534
  "user.read",
513
535
  "user.create",
@@ -521,12 +543,12 @@ var UserScopeType = SystemScopeType.extract([
521
543
  "user.search"
522
544
  ]);
523
545
  var ScopesWithRoleOption = UserScopeType.extract(["user.edit", "user.create"]);
524
- var UserScopeV2 = z7.discriminatedUnion("type", [
525
- z7.object({
546
+ var UserScopeV2 = z8.discriminatedUnion("type", [
547
+ z8.object({
526
548
  type: ScopesWithRoleOption,
527
549
  options: AllUserScopeOptions.optional()
528
550
  }),
529
- z7.object({
551
+ z8.object({
530
552
  type: UserScopeType.extract(["user.read", "user.search"]),
531
553
  options: AccessLevelOptions.optional()
532
554
  })
@@ -546,44 +568,44 @@ function scopeUsesPrintCertifiedCopiesOptions(scope) {
546
568
  function isCustomActionScope(scope) {
547
569
  return scope.type === "record.custom-action";
548
570
  }
549
- var ResolvedRecordScopeV2 = z7.discriminatedUnion("type", [
550
- z7.object({
571
+ var ResolvedRecordScopeV2 = z8.discriminatedUnion("type", [
572
+ z8.object({
551
573
  type: ScopesWithPlaceEventOptions,
552
574
  options: ResolvedScopeOptionsPlaceEvent.optional()
553
575
  }),
554
- z7.object({
576
+ z8.object({
555
577
  type: ScopesWithDeclaredOptions,
556
578
  options: ResolvedScopeOptionsDeclared.optional()
557
579
  }),
558
- z7.object({
580
+ z8.object({
559
581
  type: ScopesWithFullOptions,
560
582
  options: ResolvedScopeOptionsFull.optional()
561
583
  }),
562
- z7.object({
563
- type: z7.literal("record.print-certified-copies"),
584
+ z8.object({
585
+ type: z8.literal("record.print-certified-copies"),
564
586
  options: ResolvedScopeOptionsFull.extend({
565
- templates: z7.array(z7.string()).optional()
587
+ templates: z8.array(z8.string()).optional()
566
588
  }).optional()
567
589
  })
568
590
  ]).describe("Resolved scope with location/user IDs instead of filters.");
569
- var Scope2 = z7.discriminatedUnion("type", [
570
- z7.object({ type: PlainScopeType }),
591
+ var Scope2 = z8.discriminatedUnion("type", [
592
+ z8.object({ type: PlainScopeType }),
571
593
  ...RecordScopeV2.options,
572
594
  ...UserScopeV2.options,
573
- z7.object({
574
- type: z7.literal("organisation.read-locations"),
595
+ z8.object({
596
+ type: z8.literal("organisation.read-locations"),
575
597
  options: AccessLevelOptions.optional()
576
598
  }),
577
- z7.object({
578
- type: z7.literal("workqueue"),
599
+ z8.object({
600
+ type: z8.literal("workqueue"),
579
601
  options: WorkqueueOrDashboardOptions
580
602
  }),
581
- z7.object({
582
- type: z7.literal("dashboard.view"),
603
+ z8.object({
604
+ type: z8.literal("dashboard.view"),
583
605
  options: WorkqueueOrDashboardOptions
584
606
  })
585
607
  ]);
586
- var ScopeType2 = z7.enum([
608
+ var ScopeType2 = z8.enum([
587
609
  ...SystemScopeType.options,
588
610
  ...RecordScopeTypeV2.options,
589
611
  ...PlainScopeType.options,
@@ -598,7 +620,7 @@ var unflattenScope = (input) => {
598
620
  const { type, ...options } = input;
599
621
  return { type, options };
600
622
  };
601
- var EncodedScope2 = z7.string().brand("EncodedScope");
623
+ var EncodedScope2 = z8.string().brand("EncodedScope");
602
624
  var encodeScope = (scope) => {
603
625
  const flattened = flattenScope(scope);
604
626
  return qs.stringify(flattened, {
@@ -685,4 +707,4 @@ function defineRoles(roles) {
685
707
  }
686
708
 
687
709
  // src/scopes/index.ts
688
- z8.globalRegistry.clear();
710
+ z9.globalRegistry.clear();
@@ -0,0 +1,45 @@
1
+ /** A single telemetry metric value. */
2
+ export type TelemetryMetricValue = number | string | boolean;
3
+ /**
4
+ * The telemetry report a country configuration hands to {@link sendTelemetry}.
5
+ * `schema_version` is stamped by `sendTelemetry`, not by the caller.
6
+ */
7
+ export interface TelemetryReport {
8
+ /** Client clock, ISO 8601. Kept stable across retries of the same report. */
9
+ reported_at: string;
10
+ /** ISO-style country code of the instance. */
11
+ country_code: string;
12
+ /** Organisation running the instance. Empty string when unset. */
13
+ organisation: string;
14
+ /** Public domain of the instance, or `null`. */
15
+ domain: string | null;
16
+ instance: {
17
+ application_name: string;
18
+ environment: string;
19
+ app_version?: string;
20
+ };
21
+ /** Flat map of dotted metric keys to primitive values. */
22
+ metrics: Record<string, TelemetryMetricValue>;
23
+ }
24
+ /** Outcome of a {@link sendTelemetry} call. */
25
+ export interface TelemetryResult {
26
+ /**
27
+ * How the send resolved:
28
+ * - `sent` — the status service accepted the report (2xx);
29
+ * - `rejected` — the status service returned a non-2xx response.
30
+ */
31
+ outcome: 'sent' | 'rejected';
32
+ /** HTTP status of the request. */
33
+ status: number;
34
+ /** Response body for a `rejected` outcome. */
35
+ detail?: string;
36
+ }
37
+ /**
38
+ * Sends a telemetry report to the OpenCRVS status service. The endpoint and the
39
+ * schema version are fixed by this version of the toolkit.
40
+ *
41
+ * This always attempts the send; deciding *whether* to report (e.g. only from
42
+ * production instances) is the caller's responsibility. Network errors reject.
43
+ */
44
+ export declare function sendTelemetry(report: TelemetryReport): Promise<TelemetryResult>;
45
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/telemetry/index.ts"],"names":[],"mappings":"AAuBA,uCAAuC;AACvC,MAAM,MAAM,oBAAoB,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,CAAA;AAE5D;;;GAGG;AACH,MAAM,WAAW,eAAe;IAC9B,6EAA6E;IAC7E,WAAW,EAAE,MAAM,CAAA;IACnB,8CAA8C;IAC9C,YAAY,EAAE,MAAM,CAAA;IACpB,kEAAkE;IAClE,YAAY,EAAE,MAAM,CAAA;IACpB,gDAAgD;IAChD,MAAM,EAAE,MAAM,GAAG,IAAI,CAAA;IACrB,QAAQ,EAAE;QACR,gBAAgB,EAAE,MAAM,CAAA;QACxB,WAAW,EAAE,MAAM,CAAA;QACnB,WAAW,CAAC,EAAE,MAAM,CAAA;KACrB,CAAA;IACD,0DAA0D;IAC1D,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,oBAAoB,CAAC,CAAA;CAC9C;AAED,+CAA+C;AAC/C,MAAM,WAAW,eAAe;IAC9B;;;;OAIG;IACH,OAAO,EAAE,MAAM,GAAG,UAAU,CAAA;IAC5B,kCAAkC;IAClC,MAAM,EAAE,MAAM,CAAA;IACd,8CAA8C;IAC9C,MAAM,CAAC,EAAE,MAAM,CAAA;CAChB;AAED;;;;;;GAMG;AACH,wBAAsB,aAAa,CACjC,MAAM,EAAE,eAAe,GACtB,OAAO,CAAC,eAAe,CAAC,CAa1B"}
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/telemetry/index.ts
21
+ var telemetry_exports = {};
22
+ __export(telemetry_exports, {
23
+ sendTelemetry: () => sendTelemetry
24
+ });
25
+ module.exports = __toCommonJS(telemetry_exports);
26
+ var TELEMETRY_URL = "https://status.opencrvs.org/v1/telemetry";
27
+ var SCHEMA_VERSION = "1.0";
28
+ async function sendTelemetry(report) {
29
+ const response = await fetch(TELEMETRY_URL, {
30
+ method: "POST",
31
+ headers: { "Content-Type": "application/json" },
32
+ body: JSON.stringify({ schema_version: SCHEMA_VERSION, ...report })
33
+ });
34
+ if (response.ok) {
35
+ return { outcome: "sent", status: response.status };
36
+ }
37
+ const detail = await response.text().catch(() => "");
38
+ return { outcome: "rejected", status: response.status, detail };
39
+ }
@@ -69,6 +69,7 @@ backup:
69
69
  schedule: "0 1 * * *"
70
70
  backup_server_secret: backup-server-ssh-credentials
71
71
  backup_server_dir: /home/backup/{{env}}
72
+ host: {{backup_host}}
72
73
 
73
74
 
74
75
  # Restore configuration
@@ -78,3 +79,4 @@ restore:
78
79
  backup_server_secret: backup-server-ssh-credentials
79
80
  backup_server_dir: /home/backup/{{restore_environment_name}}
80
81
  backup_encryption_secret: restore-encryption-secret
82
+ host: {{restore_host}}