@opencrvs/toolkit 2.1.0-rc.982e0ae → 2.1.0-rc.9a83eed

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 (64) hide show
  1. package/README.md +2 -12
  2. package/create-countryconfig/index.js +133 -2
  3. package/dist/application-config/index.js +17 -18
  4. package/dist/authentication/index.js +7 -6
  5. package/dist/cli.js +458 -204
  6. package/dist/commons/api/router.d.ts +6 -42
  7. package/dist/commons/conditionals/conditionals.d.ts +6 -6
  8. package/dist/commons/conditionals/validate.d.ts +1 -1
  9. package/dist/commons/events/ActionConfig.d.ts +4 -0
  10. package/dist/commons/events/AdvancedSearchConfig.d.ts +12 -12
  11. package/dist/commons/events/FieldConfig.d.ts +16 -15
  12. package/dist/commons/events/FormConfig.d.ts +6 -0
  13. package/dist/commons/events/PageConfig.d.ts +4 -0
  14. package/dist/commons/events/locations.d.ts +4 -0
  15. package/dist/commons/events/test.utils.d.ts +18 -1
  16. package/dist/commons/events/utils.d.ts +15 -0
  17. package/dist/conditionals/index.js +7 -6
  18. package/dist/environment/manage-users.js +1 -1
  19. package/dist/environment/setup-environment.js +44 -26
  20. package/dist/environment/templates.d.ts +0 -1
  21. package/dist/environment/templates.d.ts.map +1 -1
  22. package/dist/environment/templates.js +3 -8
  23. package/dist/environment/update-workflows.d.ts.map +1 -1
  24. package/dist/environment/update-workflows.js +4 -0
  25. package/dist/environment/utils.d.ts +0 -12
  26. package/dist/environment/utils.d.ts.map +1 -1
  27. package/dist/environment/utils.js +1 -28
  28. package/dist/events/index.js +1901 -1792
  29. package/dist/migrations/v2.0/merge-infrastructure-directory.js +3 -3
  30. package/dist/migrations/v2.1/add-explicit-correction-flags.d.ts +1 -1
  31. package/dist/migrations/v2.1/add-explicit-correction-flags.d.ts.map +1 -1
  32. package/dist/migrations/v2.1/add-explicit-correction-flags.js +34 -6
  33. package/dist/migrations/v2.1/add-recovery-link-notifications.d.ts +1 -1
  34. package/dist/migrations/v2.1/add-recovery-link-notifications.d.ts.map +1 -1
  35. package/dist/migrations/v2.1/add-recovery-link-notifications.js +2 -7
  36. package/dist/migrations/v2.1/add-translations.d.ts +1 -1
  37. package/dist/migrations/v2.1/add-translations.d.ts.map +1 -1
  38. package/dist/migrations/v2.1/add-translations.js +1 -6
  39. package/dist/migrations/v2.1/enable-telemetry.d.ts +1 -1
  40. package/dist/migrations/v2.1/enable-telemetry.d.ts.map +1 -1
  41. package/dist/migrations/v2.1/enable-telemetry.js +1 -6
  42. package/dist/migrations/v2.1/index.d.ts +14 -1
  43. package/dist/migrations/v2.1/index.d.ts.map +1 -1
  44. package/dist/migrations/v2.1/index.js +96 -84
  45. package/dist/notification/index.js +155 -152
  46. package/dist/scopes/index.d.ts +109 -5
  47. package/dist/scopes/index.js +7 -6
  48. package/dist/templates/charts-values/dependencies/values.yaml +2 -0
  49. package/dist/translations/check.d.ts +2 -0
  50. package/dist/translations/check.d.ts.map +1 -1
  51. package/dist/translations/check.js +9 -4
  52. package/dist/verify/endpoints.d.ts +18 -1
  53. package/dist/verify/endpoints.d.ts.map +1 -1
  54. package/dist/verify/endpoints.js +12 -4
  55. package/dist/verify/scopes.d.ts +13 -0
  56. package/dist/verify/scopes.d.ts.map +1 -0
  57. package/dist/verify/scopes.js +131 -0
  58. package/dist/verify/upgrade.d.ts +14 -0
  59. package/dist/verify/upgrade.d.ts.map +1 -0
  60. package/dist/verify/upgrade.js +111 -0
  61. package/opencrvs-toolkit-2.1.0-rc.9a83eed.tgz +0 -0
  62. package/package.json +2 -2
  63. package/tsconfig.build.tsbuildinfo +1 -1
  64. package/opencrvs-toolkit-2.1.0-rc.982e0ae.tgz +0 -0
@@ -42,6 +42,14 @@ declare const AllScopeOptions: z.ZodObject<{
42
42
  all: "all";
43
43
  location: "location";
44
44
  }>>;
45
+ createdBy: z.ZodOptional<z.ZodEnum<{
46
+ user: "user";
47
+ }>>;
48
+ createdIn: z.ZodOptional<z.ZodEnum<{
49
+ administrativeArea: "administrativeArea";
50
+ all: "all";
51
+ location: "location";
52
+ }>>;
45
53
  notifiedIn: z.ZodOptional<z.ZodEnum<{
46
54
  administrativeArea: "administrativeArea";
47
55
  all: "all";
@@ -107,6 +115,8 @@ declare const AllScopeOptions: z.ZodObject<{
107
115
  type AllScopeOptions = z.infer<typeof AllScopeOptions>;
108
116
  export declare const ScopeOptionKey: z.ZodEnum<{
109
117
  accessLevel: "accessLevel";
118
+ createdBy: "createdBy";
119
+ createdIn: "createdIn";
110
120
  declaredBy: "declaredBy";
111
121
  declaredIn: "declaredIn";
112
122
  event: "event";
@@ -154,6 +164,14 @@ export declare const RecordScopeV2: z.ZodDiscriminatedUnion<[z.ZodObject<{
154
164
  all: "all";
155
165
  location: "location";
156
166
  }>>;
167
+ createdBy: z.ZodOptional<z.ZodEnum<{
168
+ user: "user";
169
+ }>>;
170
+ createdIn: z.ZodOptional<z.ZodEnum<{
171
+ administrativeArea: "administrativeArea";
172
+ all: "all";
173
+ location: "location";
174
+ }>>;
157
175
  }, z.core.$strip>>;
158
176
  }, z.core.$strip>, z.ZodObject<{
159
177
  type: z.ZodEnum<{
@@ -170,6 +188,14 @@ export declare const RecordScopeV2: z.ZodDiscriminatedUnion<[z.ZodObject<{
170
188
  all: "all";
171
189
  location: "location";
172
190
  }>>;
191
+ createdBy: z.ZodOptional<z.ZodEnum<{
192
+ user: "user";
193
+ }>>;
194
+ createdIn: z.ZodOptional<z.ZodEnum<{
195
+ administrativeArea: "administrativeArea";
196
+ all: "all";
197
+ location: "location";
198
+ }>>;
173
199
  notifiedIn: z.ZodOptional<z.ZodEnum<{
174
200
  administrativeArea: "administrativeArea";
175
201
  all: "all";
@@ -210,6 +236,14 @@ export declare const RecordScopeV2: z.ZodDiscriminatedUnion<[z.ZodObject<{
210
236
  all: "all";
211
237
  location: "location";
212
238
  }>>;
239
+ createdBy: z.ZodOptional<z.ZodEnum<{
240
+ user: "user";
241
+ }>>;
242
+ createdIn: z.ZodOptional<z.ZodEnum<{
243
+ administrativeArea: "administrativeArea";
244
+ all: "all";
245
+ location: "location";
246
+ }>>;
213
247
  notifiedIn: z.ZodOptional<z.ZodEnum<{
214
248
  administrativeArea: "administrativeArea";
215
249
  all: "all";
@@ -274,6 +308,14 @@ export declare const RecordScopeV2: z.ZodDiscriminatedUnion<[z.ZodObject<{
274
308
  all: "all";
275
309
  location: "location";
276
310
  }>>;
311
+ createdBy: z.ZodOptional<z.ZodEnum<{
312
+ user: "user";
313
+ }>>;
314
+ createdIn: z.ZodOptional<z.ZodEnum<{
315
+ administrativeArea: "administrativeArea";
316
+ all: "all";
317
+ location: "location";
318
+ }>>;
277
319
  notifiedIn: z.ZodOptional<z.ZodEnum<{
278
320
  administrativeArea: "administrativeArea";
279
321
  all: "all";
@@ -339,6 +381,14 @@ export declare const RecordScopeV2: z.ZodDiscriminatedUnion<[z.ZodObject<{
339
381
  all: "all";
340
382
  location: "location";
341
383
  }>>;
384
+ createdBy: z.ZodOptional<z.ZodEnum<{
385
+ user: "user";
386
+ }>>;
387
+ createdIn: z.ZodOptional<z.ZodEnum<{
388
+ administrativeArea: "administrativeArea";
389
+ all: "all";
390
+ location: "location";
391
+ }>>;
342
392
  notifiedIn: z.ZodOptional<z.ZodEnum<{
343
393
  administrativeArea: "administrativeArea";
344
394
  all: "all";
@@ -467,6 +517,8 @@ export declare const ResolvedRecordScopeV2: z.ZodDiscriminatedUnion<[z.ZodObject
467
517
  options: z.ZodOptional<z.ZodObject<{
468
518
  event: z.ZodPreprocess<z.ZodOptional<z.ZodArray<z.ZodString>>>;
469
519
  placeOfEvent: z.ZodOptional<z.ZodNullable<z.core.$ZodBranded<z.ZodUUID, "UUID", "out">>>;
520
+ createdBy: z.ZodOptional<z.ZodString>;
521
+ createdIn: z.ZodOptional<z.ZodNullable<z.core.$ZodBranded<z.ZodUUID, "UUID", "out">>>;
470
522
  }, z.core.$strip>>;
471
523
  }, z.core.$strip>, z.ZodObject<{
472
524
  type: z.ZodEnum<{
@@ -479,6 +531,8 @@ export declare const ResolvedRecordScopeV2: z.ZodDiscriminatedUnion<[z.ZodObject
479
531
  options: z.ZodOptional<z.ZodObject<{
480
532
  event: z.ZodPreprocess<z.ZodOptional<z.ZodArray<z.ZodString>>>;
481
533
  placeOfEvent: z.ZodOptional<z.ZodNullable<z.core.$ZodBranded<z.ZodUUID, "UUID", "out">>>;
534
+ createdBy: z.ZodOptional<z.ZodString>;
535
+ createdIn: z.ZodOptional<z.ZodNullable<z.core.$ZodBranded<z.ZodUUID, "UUID", "out">>>;
482
536
  notifiedIn: z.ZodOptional<z.ZodNullable<z.core.$ZodBranded<z.ZodUUID, "UUID", "out">>>;
483
537
  notifiedBy: z.ZodOptional<z.ZodString>;
484
538
  declaredIn: z.ZodOptional<z.ZodNullable<z.core.$ZodBranded<z.ZodUUID, "UUID", "out">>>;
@@ -496,6 +550,8 @@ export declare const ResolvedRecordScopeV2: z.ZodDiscriminatedUnion<[z.ZodObject
496
550
  options: z.ZodOptional<z.ZodObject<{
497
551
  event: z.ZodPreprocess<z.ZodOptional<z.ZodArray<z.ZodString>>>;
498
552
  placeOfEvent: z.ZodOptional<z.ZodNullable<z.core.$ZodBranded<z.ZodUUID, "UUID", "out">>>;
553
+ createdBy: z.ZodOptional<z.ZodString>;
554
+ createdIn: z.ZodOptional<z.ZodNullable<z.core.$ZodBranded<z.ZodUUID, "UUID", "out">>>;
499
555
  notifiedIn: z.ZodOptional<z.ZodNullable<z.core.$ZodBranded<z.ZodUUID, "UUID", "out">>>;
500
556
  notifiedBy: z.ZodOptional<z.ZodString>;
501
557
  declaredIn: z.ZodOptional<z.ZodNullable<z.core.$ZodBranded<z.ZodUUID, "UUID", "out">>>;
@@ -531,6 +587,8 @@ export declare const ResolvedRecordScopeV2: z.ZodDiscriminatedUnion<[z.ZodObject
531
587
  options: z.ZodOptional<z.ZodObject<{
532
588
  event: z.ZodPreprocess<z.ZodOptional<z.ZodArray<z.ZodString>>>;
533
589
  placeOfEvent: z.ZodOptional<z.ZodNullable<z.core.$ZodBranded<z.ZodUUID, "UUID", "out">>>;
590
+ createdBy: z.ZodOptional<z.ZodString>;
591
+ createdIn: z.ZodOptional<z.ZodNullable<z.core.$ZodBranded<z.ZodUUID, "UUID", "out">>>;
534
592
  notifiedIn: z.ZodOptional<z.ZodNullable<z.core.$ZodBranded<z.ZodUUID, "UUID", "out">>>;
535
593
  notifiedBy: z.ZodOptional<z.ZodString>;
536
594
  declaredIn: z.ZodOptional<z.ZodNullable<z.core.$ZodBranded<z.ZodUUID, "UUID", "out">>>;
@@ -578,10 +636,8 @@ export declare const Scope: z.ZodDiscriminatedUnion<[z.ZodObject<{
578
636
  "performance.read-dashboards": "performance.read-dashboards";
579
637
  "performance.vital-statistics-export": "performance.vital-statistics-export";
580
638
  "profile.electronic-signature": "profile.electronic-signature";
581
- "record.confirm-registration": "record.confirm-registration";
582
639
  "record.import": "record.import";
583
640
  "record.reindex": "record.reindex";
584
- "record.reject-registration": "record.reject-registration";
585
641
  "user.data-seeding": "user.data-seeding";
586
642
  "user.read-only-my-audit": "user.read-only-my-audit";
587
643
  }>;
@@ -598,6 +654,14 @@ export declare const Scope: z.ZodDiscriminatedUnion<[z.ZodObject<{
598
654
  all: "all";
599
655
  location: "location";
600
656
  }>>;
657
+ createdBy: z.ZodOptional<z.ZodEnum<{
658
+ user: "user";
659
+ }>>;
660
+ createdIn: z.ZodOptional<z.ZodEnum<{
661
+ administrativeArea: "administrativeArea";
662
+ all: "all";
663
+ location: "location";
664
+ }>>;
601
665
  }, z.core.$strip>>;
602
666
  }, z.core.$strip>, z.ZodObject<{
603
667
  type: z.ZodEnum<{
@@ -614,6 +678,14 @@ export declare const Scope: z.ZodDiscriminatedUnion<[z.ZodObject<{
614
678
  all: "all";
615
679
  location: "location";
616
680
  }>>;
681
+ createdBy: z.ZodOptional<z.ZodEnum<{
682
+ user: "user";
683
+ }>>;
684
+ createdIn: z.ZodOptional<z.ZodEnum<{
685
+ administrativeArea: "administrativeArea";
686
+ all: "all";
687
+ location: "location";
688
+ }>>;
617
689
  notifiedIn: z.ZodOptional<z.ZodEnum<{
618
690
  administrativeArea: "administrativeArea";
619
691
  all: "all";
@@ -654,6 +726,14 @@ export declare const Scope: z.ZodDiscriminatedUnion<[z.ZodObject<{
654
726
  all: "all";
655
727
  location: "location";
656
728
  }>>;
729
+ createdBy: z.ZodOptional<z.ZodEnum<{
730
+ user: "user";
731
+ }>>;
732
+ createdIn: z.ZodOptional<z.ZodEnum<{
733
+ administrativeArea: "administrativeArea";
734
+ all: "all";
735
+ location: "location";
736
+ }>>;
657
737
  notifiedIn: z.ZodOptional<z.ZodEnum<{
658
738
  administrativeArea: "administrativeArea";
659
739
  all: "all";
@@ -718,6 +798,14 @@ export declare const Scope: z.ZodDiscriminatedUnion<[z.ZodObject<{
718
798
  all: "all";
719
799
  location: "location";
720
800
  }>>;
801
+ createdBy: z.ZodOptional<z.ZodEnum<{
802
+ user: "user";
803
+ }>>;
804
+ createdIn: z.ZodOptional<z.ZodEnum<{
805
+ administrativeArea: "administrativeArea";
806
+ all: "all";
807
+ location: "location";
808
+ }>>;
721
809
  notifiedIn: z.ZodOptional<z.ZodEnum<{
722
810
  administrativeArea: "administrativeArea";
723
811
  all: "all";
@@ -783,6 +871,14 @@ export declare const Scope: z.ZodDiscriminatedUnion<[z.ZodObject<{
783
871
  all: "all";
784
872
  location: "location";
785
873
  }>>;
874
+ createdBy: z.ZodOptional<z.ZodEnum<{
875
+ user: "user";
876
+ }>>;
877
+ createdIn: z.ZodOptional<z.ZodEnum<{
878
+ administrativeArea: "administrativeArea";
879
+ all: "all";
880
+ location: "location";
881
+ }>>;
786
882
  notifiedIn: z.ZodOptional<z.ZodEnum<{
787
883
  administrativeArea: "administrativeArea";
788
884
  all: "all";
@@ -899,7 +995,6 @@ export declare const ScopeType: z.ZodEnum<{
899
995
  "performance.vital-statistics-export": "performance.vital-statistics-export";
900
996
  "profile.electronic-signature": "profile.electronic-signature";
901
997
  "record.archive": "record.archive";
902
- "record.confirm-registration": "record.confirm-registration";
903
998
  "record.correct": "record.correct";
904
999
  "record.create": "record.create";
905
1000
  "record.custom-action": "record.custom-action";
@@ -912,7 +1007,6 @@ export declare const ScopeType: z.ZodEnum<{
912
1007
  "record.register": "record.register";
913
1008
  "record.reindex": "record.reindex";
914
1009
  "record.reject": "record.reject";
915
- "record.reject-registration": "record.reject-registration";
916
1010
  "record.request-correction": "record.request-correction";
917
1011
  "record.review-duplicates": "record.review-duplicates";
918
1012
  "record.search": "record.search";
@@ -952,12 +1046,16 @@ export declare const decodeScope: (encodedScope: EncodedScope) => {
952
1046
  options?: {
953
1047
  event?: string[] | undefined;
954
1048
  placeOfEvent?: "administrativeArea" | "all" | "location" | undefined;
1049
+ createdBy?: "user" | undefined;
1050
+ createdIn?: "administrativeArea" | "all" | "location" | undefined;
955
1051
  } | undefined;
956
1052
  } | {
957
1053
  type: "record.archive" | "record.edit" | "record.register" | "record.reject" | "record.unarchive";
958
1054
  options?: {
959
1055
  event?: string[] | undefined;
960
1056
  placeOfEvent?: "administrativeArea" | "all" | "location" | undefined;
1057
+ createdBy?: "user" | undefined;
1058
+ createdIn?: "administrativeArea" | "all" | "location" | undefined;
961
1059
  notifiedIn?: "administrativeArea" | "all" | "location" | undefined;
962
1060
  notifiedBy?: "user" | undefined;
963
1061
  declaredIn?: "administrativeArea" | "all" | "location" | undefined;
@@ -969,6 +1067,8 @@ export declare const decodeScope: (encodedScope: EncodedScope) => {
969
1067
  options?: {
970
1068
  event?: string[] | undefined;
971
1069
  placeOfEvent?: "administrativeArea" | "all" | "location" | undefined;
1070
+ createdBy?: "user" | undefined;
1071
+ createdIn?: "administrativeArea" | "all" | "location" | undefined;
972
1072
  notifiedIn?: "administrativeArea" | "all" | "location" | undefined;
973
1073
  notifiedBy?: "user" | undefined;
974
1074
  declaredIn?: "administrativeArea" | "all" | "location" | undefined;
@@ -987,6 +1087,8 @@ export declare const decodeScope: (encodedScope: EncodedScope) => {
987
1087
  options?: {
988
1088
  event?: string[] | undefined;
989
1089
  placeOfEvent?: "administrativeArea" | "all" | "location" | undefined;
1090
+ createdBy?: "user" | undefined;
1091
+ createdIn?: "administrativeArea" | "all" | "location" | undefined;
990
1092
  notifiedIn?: "administrativeArea" | "all" | "location" | undefined;
991
1093
  notifiedBy?: "user" | undefined;
992
1094
  declaredIn?: "administrativeArea" | "all" | "location" | undefined;
@@ -1006,6 +1108,8 @@ export declare const decodeScope: (encodedScope: EncodedScope) => {
1006
1108
  options?: {
1007
1109
  event?: string[] | undefined;
1008
1110
  placeOfEvent?: "administrativeArea" | "all" | "location" | undefined;
1111
+ createdBy?: "user" | undefined;
1112
+ createdIn?: "administrativeArea" | "all" | "location" | undefined;
1009
1113
  notifiedIn?: "administrativeArea" | "all" | "location" | undefined;
1010
1114
  notifiedBy?: "user" | undefined;
1011
1115
  declaredIn?: "administrativeArea" | "all" | "location" | undefined;
@@ -1032,7 +1136,7 @@ export declare const decodeScope: (encodedScope: EncodedScope) => {
1032
1136
  accessLevel?: "administrativeArea" | "all" | "location" | undefined;
1033
1137
  } | undefined;
1034
1138
  } | {
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";
1139
+ 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.import" | "record.reindex" | "user.data-seeding" | "user.read-only-my-audit";
1036
1140
  } | {
1037
1141
  type: "organisation.read-locations";
1038
1142
  options?: {
@@ -394,10 +394,7 @@ var PlainScopeType = z8.enum([
394
394
  // Performance dashboard
395
395
  "performance.read",
396
396
  "performance.read-dashboards",
397
- "performance.vital-statistics-export",
398
- // Scopes used exclusively by countryconfig integration token
399
- "record.confirm-registration",
400
- "record.reject-registration"
397
+ "performance.vital-statistics-export"
401
398
  ]);
402
399
  var scopeByEvent = z8.preprocess(
403
400
  (val) => val === void 0 ? void 0 : [val].flat(),
@@ -415,7 +412,9 @@ var userRole = z8.preprocess(
415
412
  ).describe("User role, e.g. admin, field agent");
416
413
  var scopeOptionsPlaceEvent = z8.object({
417
414
  event: scopeByEvent,
418
- placeOfEvent: JurisdictionFilter.optional()
415
+ placeOfEvent: JurisdictionFilter.optional(),
416
+ createdBy: UserFilter.optional(),
417
+ createdIn: JurisdictionFilter.optional()
419
418
  }).describe("Options applicable to all record scopes.");
420
419
  var scopeOptionsDeclaredOrNotified = scopeOptionsPlaceEvent.extend({
421
420
  notifiedIn: JurisdictionFilter.optional(),
@@ -458,7 +457,9 @@ var AllScopeOptions = z8.object({
458
457
  var ScopeOptionKey = AllScopeOptions.keyof();
459
458
  var ResolvedScopeOptionsPlaceEvent = z8.object({
460
459
  event: scopeByEvent,
461
- placeOfEvent: UUID.nullish()
460
+ placeOfEvent: UUID.nullish(),
461
+ createdBy: z8.string().optional(),
462
+ createdIn: UUID.nullish()
462
463
  }).describe(
463
464
  "Resolved options applicable to all record scopes, with location ID instead of jurisdiction filter."
464
465
  );
@@ -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}}
@@ -14,6 +14,8 @@ export declare function check(cwd: string): CheckResult;
14
14
  /**
15
15
  * Adds a row per missing message, filling in only English — the rest is copy
16
16
  * somebody has to write. Returns the ids added.
17
+ *
18
+ * Creates countryconfig.csv if it doesn't exist yet.
17
19
  */
18
20
  export declare function writeMissing(cwd: string, missing: Message[]): string[];
19
21
  //# sourceMappingURL=check.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"check.d.ts","sourceRoot":"","sources":["../../src/translations/check.ts"],"names":[],"mappings":"AAwCA,MAAM,MAAM,OAAO,GAAG;IACpB,EAAE,EAAE,MAAM,CAAA;IACV,cAAc,EAAE,MAAM,CAAA;IACtB,WAAW,EAAE,MAAM,CAAA;CACpB,CAAA;AAED,MAAM,MAAM,WAAW,GAAG;IACxB,OAAO,EAAE,OAAO,EAAE,CAAA;IAClB,qEAAqE;IACrE,QAAQ,EAAE,MAAM,EAAE,CAAA;IAClB,kEAAkE;IAClE,UAAU,EAAE,MAAM,EAAE,CAAA;CACrB,CAAA;AAgED,wBAAgB,KAAK,CAAC,GAAG,EAAE,MAAM,GAAG,WAAW,CAyB9C;AAED;;;GAGG;AACH,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,YAuB3D"}
1
+ {"version":3,"file":"check.d.ts","sourceRoot":"","sources":["../../src/translations/check.ts"],"names":[],"mappings":"AAwCA,MAAM,MAAM,OAAO,GAAG;IACpB,EAAE,EAAE,MAAM,CAAA;IACV,cAAc,EAAE,MAAM,CAAA;IACtB,WAAW,EAAE,MAAM,CAAA;CACpB,CAAA;AAED,MAAM,MAAM,WAAW,GAAG;IACxB,OAAO,EAAE,OAAO,EAAE,CAAA;IAClB,qEAAqE;IACrE,QAAQ,EAAE,MAAM,EAAE,CAAA;IAClB,kEAAkE;IAClE,UAAU,EAAE,MAAM,EAAE,CAAA;CACrB,CAAA;AAgED,wBAAgB,KAAK,CAAC,GAAG,EAAE,MAAM,GAAG,WAAW,CAyB9C;AAED;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,YAwB3D"}
@@ -107,12 +107,17 @@ function check(cwd) {
107
107
  /**
108
108
  * Adds a row per missing message, filling in only English — the rest is copy
109
109
  * somebody has to write. Returns the ids added.
110
+ *
111
+ * Creates countryconfig.csv if it doesn't exist yet.
110
112
  */
111
113
  function writeMissing(cwd, missing) {
112
- const file = (0, csv_1.readCsvFile)(path_1.default.join(cwd, OWN_FILE));
113
- if (!file) {
114
- throw new Error(`${OWN_FILE} not found in ${cwd}`);
115
- }
114
+ var _a;
115
+ const file = (_a = (0, csv_1.readCsvFile)(path_1.default.join(cwd, OWN_FILE))) !== null && _a !== void 0 ? _a : {
116
+ header: 'id,description,en',
117
+ body: [],
118
+ newline: '\n',
119
+ trailingNewline: true
120
+ };
116
121
  const columns = file.header.split(',');
117
122
  const rows = missing.map((message) => (0, csv_1.toCsvLine)(columns.map((column) => {
118
123
  if (column === 'id')
@@ -1,2 +1,19 @@
1
- export declare function runVerifyEndpoints(target?: string): Promise<void>;
1
+ /**
2
+ * The country config service listens on port 3040 locally. This command is
3
+ * meant to be run against that instance right after `opencrvs upgrade`, to
4
+ * confirm the upgraded config still exposes the expected endpoints and keeps
5
+ * the secured ones locked down.
6
+ */
7
+ export declare const DEFAULT_TARGET_URL = "http://localhost:3040";
8
+ /**
9
+ * Normalises the CLI argument into a base URL. Accepts either a bare domain
10
+ * (`example.org`, assumed https) or a full URL, and strips any trailing slash.
11
+ */
12
+ export declare function resolveBaseUrl(input: string): string;
13
+ export declare function line(ok: boolean, label: string, detail: string): string;
14
+ /**
15
+ * @returns the number of failed checks, so a caller that runs several
16
+ * verifications can report them together. Exiting is the CLI's decision.
17
+ */
18
+ export declare function runVerifyEndpoints(target?: string): Promise<number>;
2
19
  //# sourceMappingURL=endpoints.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"endpoints.d.ts","sourceRoot":"","sources":["../../src/verify/endpoints.ts"],"names":[],"mappings":"AA2QA,wBAAsB,kBAAkB,CACtC,MAAM,GAAE,MAA2B,GAClC,OAAO,CAAC,IAAI,CAAC,CAkIf"}
1
+ {"version":3,"file":"endpoints.d.ts","sourceRoot":"","sources":["../../src/verify/endpoints.ts"],"names":[],"mappings":"AAkBA;;;;;GAKG;AACH,eAAO,MAAM,kBAAkB,0BAA0B,CAAA;AA8MzD;;;GAGG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAGpD;AAYD,wBAAgB,IAAI,CAAC,EAAE,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAGvE;AAeD;;;GAGG;AACH,wBAAsB,kBAAkB,CACtC,MAAM,GAAE,MAA2B,GAClC,OAAO,CAAC,MAAM,CAAC,CAmIjB"}
@@ -9,6 +9,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
9
9
  });
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.DEFAULT_TARGET_URL = void 0;
13
+ exports.resolveBaseUrl = resolveBaseUrl;
14
+ exports.line = line;
12
15
  exports.runVerifyEndpoints = runVerifyEndpoints;
13
16
  /*
14
17
  * This Source Code Form is subject to the terms of the Mozilla Public
@@ -29,7 +32,7 @@ const REQUEST_TIMEOUT_MS = 15000;
29
32
  * confirm the upgraded config still exposes the expected endpoints and keeps
30
33
  * the secured ones locked down.
31
34
  */
32
- const DEFAULT_TARGET_URL = 'http://localhost:3040';
35
+ exports.DEFAULT_TARGET_URL = 'http://localhost:3040';
33
36
  /**
34
37
  * Publicly-served endpoints every country config must expose. The client and
35
38
  * login apps, and core services, fetch these before or without user
@@ -231,10 +234,14 @@ function securedDetail(status) {
231
234
  if (status === 'error') {
232
235
  return `${describeStatus(status)} — request failed`;
233
236
  }
234
- return `${describeStatus(status)} — INSECURE: processed without a token`;
237
+ return `${describeStatus(status)} — INSECURE: ensure this endpoint requires authentication!`;
235
238
  }
239
+ /**
240
+ * @returns the number of failed checks, so a caller that runs several
241
+ * verifications can report them together. Exiting is the CLI's decision.
242
+ */
236
243
  function runVerifyEndpoints() {
237
- return __awaiter(this, arguments, void 0, function* (target = DEFAULT_TARGET_URL) {
244
+ return __awaiter(this, arguments, void 0, function* (target = exports.DEFAULT_TARGET_URL) {
238
245
  const baseUrl = resolveBaseUrl(target);
239
246
  console.log((0, colors_1.bold)(`Verifying country config endpoints at ${baseUrl}\n`));
240
247
  let failures = 0;
@@ -338,8 +345,9 @@ function runVerifyEndpoints() {
338
345
  if (failures > 0) {
339
346
  console.log((0, colors_1.red)((0, colors_1.bold)(`✗ ${failures} check(s) failed.`)) +
340
347
  (0, colors_1.yellow)(' See the lines marked ✗ above.'));
341
- process.exit(1);
348
+ return failures;
342
349
  }
343
350
  console.log((0, colors_1.green)((0, colors_1.bold)('✓ All endpoint checks passed.')));
351
+ return 0;
344
352
  });
345
353
  }
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Checks the country config assigns the scopes this release added to at least
3
+ * one role.
4
+ *
5
+ * Deliberately "at least one role" and not more: which roles should hold a
6
+ * scope is the country's own policy, and this cannot know it. Assigning a scope
7
+ * to nobody, on the other hand, is almost always an upgrade that was missed
8
+ * rather than a decision.
9
+ *
10
+ * @returns the number of failed checks.
11
+ */
12
+ export declare function runVerifyScopes(target?: string): Promise<number>;
13
+ //# sourceMappingURL=scopes.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"scopes.d.ts","sourceRoot":"","sources":["../../src/verify/scopes.ts"],"names":[],"mappings":"AAgGA;;;;;;;;;;GAUG;AACH,wBAAsB,eAAe,CACnC,MAAM,GAAE,MAA2B,GAClC,OAAO,CAAC,MAAM,CAAC,CA+CjB"}
@@ -0,0 +1,131 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.runVerifyScopes = runVerifyScopes;
13
+ /*
14
+ * This Source Code Form is subject to the terms of the Mozilla Public
15
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
16
+ * file, You can obtain one at https://mozilla.org/MPL/2.0/.
17
+ *
18
+ * OpenCRVS is also distributed under the terms of the Civil Registration
19
+ * & Healthcare Disclaimer located at http://opencrvs.org/license.
20
+ *
21
+ * Copyright (C) The OpenCRVS Authors located at https://github.com/opencrvs/opencrvs-core/blob/master/AUTHORS.
22
+ */
23
+ /* eslint-disable no-console */
24
+ const colors_1 = require("kleur/colors");
25
+ const endpoints_1 = require("./endpoints");
26
+ const REQUEST_TIMEOUT_MS = 15000;
27
+ /**
28
+ * Scopes this release added, which guard features that ship whether or not a
29
+ * country config assigns them.
30
+ *
31
+ * A missing scope is the quietest kind of upgrade miss: the country config
32
+ * compiles, the deployment comes up healthy, and the feature is simply absent
33
+ * from every role — there is no error anywhere to notice. Adding a scope here
34
+ * whenever a release introduces one is what makes it noticeable.
35
+ */
36
+ const SCOPES_ADDED_THIS_RELEASE = [
37
+ {
38
+ scope: 'record.unarchive',
39
+ guards: 'the new UNARCHIVE action. Without it no role can restore an archived record, including roles that hold record.archive.'
40
+ },
41
+ {
42
+ scope: 'location.edit',
43
+ guards: 'the location and administrative area write API (create, update, withdrawVersion).'
44
+ },
45
+ {
46
+ scope: 'integration.audit.read',
47
+ guards: "reading a system client's audit log via the integrations.audit endpoint."
48
+ }
49
+ ];
50
+ /**
51
+ * The scope type out of one encoded scope.
52
+ *
53
+ * Scopes arrive from `/config/roles` in the query-string form `encodeScope`
54
+ * produces — `type=record.unarchive`, or `type=record.read&event[]=birth` once
55
+ * options are involved — so the type has to be read out of the `type` pair
56
+ * rather than matched against the whole string.
57
+ */
58
+ function scopeType(encoded) {
59
+ for (const pair of encoded.split('&')) {
60
+ const [key, value] = pair.split('=');
61
+ if (key === 'type') {
62
+ return value;
63
+ }
64
+ }
65
+ return undefined;
66
+ }
67
+ function fetchRoles(baseUrl) {
68
+ return __awaiter(this, void 0, void 0, function* () {
69
+ try {
70
+ const response = yield fetch(`${baseUrl}/config/roles`, {
71
+ signal: AbortSignal.timeout(REQUEST_TIMEOUT_MS)
72
+ });
73
+ if (!response.ok) {
74
+ return undefined;
75
+ }
76
+ const body = yield response.json();
77
+ if (!Array.isArray(body)) {
78
+ return undefined;
79
+ }
80
+ return body.filter((role) => typeof role === 'object' &&
81
+ role !== null &&
82
+ Array.isArray(role.scopes));
83
+ }
84
+ catch (_a) {
85
+ return undefined;
86
+ }
87
+ });
88
+ }
89
+ /**
90
+ * Checks the country config assigns the scopes this release added to at least
91
+ * one role.
92
+ *
93
+ * Deliberately "at least one role" and not more: which roles should hold a
94
+ * scope is the country's own policy, and this cannot know it. Assigning a scope
95
+ * to nobody, on the other hand, is almost always an upgrade that was missed
96
+ * rather than a decision.
97
+ *
98
+ * @returns the number of failed checks.
99
+ */
100
+ function runVerifyScopes() {
101
+ return __awaiter(this, arguments, void 0, function* (target = endpoints_1.DEFAULT_TARGET_URL) {
102
+ const baseUrl = (0, endpoints_1.resolveBaseUrl)(target);
103
+ console.log((0, colors_1.bold)(`Scopes added in this release, at ${baseUrl}\n`));
104
+ const roles = yield fetchRoles(baseUrl);
105
+ if (!roles) {
106
+ console.log(' ' +
107
+ (0, colors_1.yellow)('Could not read /config/roles, so the new scopes could not be checked.'));
108
+ return 1;
109
+ }
110
+ let failures = 0;
111
+ for (const { scope, guards } of SCOPES_ADDED_THIS_RELEASE) {
112
+ const holders = roles.filter((role) => role.scopes.some((encoded) => scopeType(encoded) === scope));
113
+ if (holders.length === 0) {
114
+ failures++;
115
+ console.log((0, endpoints_1.line)(false, scope, `held by no role — guards ${guards}`));
116
+ continue;
117
+ }
118
+ const named = holders
119
+ .map((role) => role.id)
120
+ .slice(0, 3)
121
+ .join(', ');
122
+ const more = holders.length > 3 ? `, +${holders.length - 3} more` : '';
123
+ console.log((0, endpoints_1.line)(true, scope, `${holders.length} role(s)${(0, colors_1.dim)(`: ${named}${more}`)}`));
124
+ }
125
+ console.log();
126
+ if (failures === 0) {
127
+ console.log((0, colors_1.green)((0, colors_1.bold)('✓ Every scope added this release is assigned.')));
128
+ }
129
+ return failures;
130
+ });
131
+ }
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Runs every post-upgrade check there is and reports them together.
3
+ *
4
+ * The point of gathering them behind one command is that an upgrade is only
5
+ * finished when all of them pass, and an operator should not have to know which
6
+ * individual commands exist — or remember to run them — to find that out.
7
+ *
8
+ * Expects to run in the country config directory, with the upgraded country
9
+ * config running (locally by default, see `target`).
10
+ *
11
+ * @returns the total number of failed checks.
12
+ */
13
+ export declare function runVerifyUpgrade(target?: string, cwd?: string): Promise<number>;
14
+ //# sourceMappingURL=upgrade.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"upgrade.d.ts","sourceRoot":"","sources":["../../src/verify/upgrade.ts"],"names":[],"mappings":"AAuEA;;;;;;;;;;;GAWG;AACH,wBAAsB,gBAAgB,CACpC,MAAM,GAAE,MAA2B,EACnC,GAAG,GAAE,MAAsB,GAC1B,OAAO,CAAC,MAAM,CAAC,CAiDjB"}