@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
@@ -47,7 +47,7 @@ __export(conditionals_exports, {
47
47
  user: () => user
48
48
  });
49
49
  module.exports = __toCommonJS(conditionals_exports);
50
- var z12 = __toESM(require("zod/v4"));
50
+ var z13 = __toESM(require("zod/v4"));
51
51
 
52
52
  // ../commons/src/conditionals/conditionals.ts
53
53
  var objectHash = __toESM(require("object-hash"));
@@ -124,7 +124,7 @@ function todayDateTimeValueSerializer() {
124
124
  }
125
125
 
126
126
  // ../commons/src/scopes.ts
127
- var z10 = __toESM(require("zod/v4"));
127
+ var z11 = __toESM(require("zod/v4"));
128
128
  var qs = __toESM(require("qs"));
129
129
 
130
130
  // ../commons/src/uuid.ts
@@ -383,12 +383,22 @@ var ActionFlagConfig = z9.object({
383
383
  description: "Add or remove operation applied to a flag when the parent action is accepted. Optionally gated by a conditional."
384
384
  });
385
385
 
386
+ // ../commons/src/events/EventStatus.ts
387
+ var z10 = __toESM(require("zod/v4"));
388
+ var EventStatus = z10.enum([
389
+ "CREATED",
390
+ "NOTIFIED",
391
+ "DECLARED",
392
+ "REGISTERED",
393
+ "ARCHIVED"
394
+ ]);
395
+
386
396
  // ../commons/src/scopes.ts
387
- var JurisdictionFilter = z10.enum(["administrativeArea", "location", "all"]).describe(
397
+ var JurisdictionFilter = z11.enum(["administrativeArea", "location", "all"]).describe(
388
398
  "Filters based on user jurisdiction relative to their office location in hierarchy."
389
399
  );
390
- var UserFilter = z10.enum(["user"]).describe("Filters based on the user. Limits to self.");
391
- var RecordScopeTypeV2 = z10.enum([
400
+ var UserFilter = z11.enum(["user"]).describe("Filters based on the user. Limits to self.");
401
+ var RecordScopeTypeV2 = z11.enum([
392
402
  "record.search",
393
403
  "record.create",
394
404
  "record.read",
@@ -406,12 +416,17 @@ var RecordScopeTypeV2 = z10.enum([
406
416
  "record.unassign-others",
407
417
  "record.custom-action"
408
418
  ]);
409
- var PlainScopeType = z10.enum([
419
+ var PlainScopeType = z11.enum([
410
420
  // Misc. system scopes
411
421
  "bypassratelimit",
412
422
  "record.reindex",
413
423
  "user.data-seeding",
414
424
  "integration.create",
425
+ // Reading an integration's audit log. Deliberately separate from
426
+ // 'integration.create' so read-only oversight can be granted on its own, and
427
+ // deliberately option-less: system clients have no office and no
428
+ // administrative area, so jurisdiction options would have nothing to bind to.
429
+ "integration.audit.read",
415
430
  "record.import",
416
431
  "config.update-all",
417
432
  "location.edit",
@@ -426,15 +441,21 @@ var PlainScopeType = z10.enum([
426
441
  "record.confirm-registration",
427
442
  "record.reject-registration"
428
443
  ]);
429
- var scopeByEvent = z10.preprocess(
444
+ var scopeByEvent = z11.preprocess(
430
445
  (val) => val === void 0 ? void 0 : [val].flat(),
431
- z10.array(z10.string()).optional()
446
+ z11.array(z11.string()).optional()
432
447
  ).describe("Event type, e.g. birth, death");
433
- var userRole = z10.preprocess(
448
+ var scopeByStatus = z11.preprocess(
434
449
  (val) => val === void 0 ? void 0 : [val].flat(),
435
- z10.array(z10.string()).optional()
450
+ z11.array(EventStatus).optional()
451
+ ).describe(
452
+ "Restricts the scope to records currently in one of these statuses."
453
+ );
454
+ var userRole = z11.preprocess(
455
+ (val) => val === void 0 ? void 0 : [val].flat(),
456
+ z11.array(z11.string()).optional()
436
457
  ).describe("User role, e.g. admin, field agent");
437
- var scopeOptionsPlaceEvent = z10.object({
458
+ var scopeOptionsPlaceEvent = z11.object({
438
459
  event: scopeByEvent,
439
460
  placeOfEvent: JurisdictionFilter.optional()
440
461
  }).describe("Options applicable to all record scopes.");
@@ -442,7 +463,8 @@ var scopeOptionsDeclaredOrNotified = scopeOptionsPlaceEvent.extend({
442
463
  notifiedIn: JurisdictionFilter.optional(),
443
464
  notifiedBy: UserFilter.optional(),
444
465
  declaredIn: JurisdictionFilter.optional(),
445
- declaredBy: UserFilter.optional()
466
+ declaredBy: UserFilter.optional(),
467
+ status: scopeByStatus
446
468
  }).describe("Options applicable to actions that may take place after DECLARE");
447
469
  var AllRecordScopeOptions = scopeOptionsDeclaredOrNotified.extend({
448
470
  registeredIn: JurisdictionFilter.optional(),
@@ -452,31 +474,31 @@ var AllRecordScopeOptions = scopeOptionsDeclaredOrNotified.extend({
452
474
  "Options applicable to actions that may take place after REGISTER, with full filtering capabilities."
453
475
  );
454
476
  var CustomActionScopeOptions = AllRecordScopeOptions.extend({
455
- customActionTypes: z10.preprocess(
477
+ customActionTypes: z11.preprocess(
456
478
  (val) => val === void 0 ? void 0 : [val].flat(),
457
- z10.array(z10.string()).optional()
479
+ z11.array(z11.string()).optional()
458
480
  ).describe("Allowed custom action types")
459
481
  });
460
- var AccessLevelOptions = z10.object({
482
+ var AccessLevelOptions = z11.object({
461
483
  accessLevel: JurisdictionFilter.optional()
462
484
  });
463
485
  var AllUserScopeOptions = AccessLevelOptions.extend({
464
486
  role: userRole.optional()
465
487
  });
466
- var WorkqueueOrDashboardOptions = z10.object({
467
- ids: z10.preprocess(
488
+ var WorkqueueOrDashboardOptions = z11.object({
489
+ ids: z11.preprocess(
468
490
  (val) => val === void 0 ? void 0 : [val].flat(),
469
- z10.array(z10.string())
491
+ z11.array(z11.string())
470
492
  ).describe("Must contain a list of workqueue or dashboard ids.")
471
493
  });
472
- var AllScopeOptions = z10.object({
494
+ var AllScopeOptions = z11.object({
473
495
  ...AllRecordScopeOptions.shape,
474
496
  ...AccessLevelOptions.shape,
475
497
  ...AllUserScopeOptions.shape,
476
498
  ...WorkqueueOrDashboardOptions.shape
477
499
  });
478
500
  var ScopeOptionKey = AllScopeOptions.keyof();
479
- var ResolvedScopeOptionsPlaceEvent = z10.object({
501
+ var ResolvedScopeOptionsPlaceEvent = z11.object({
480
502
  event: scopeByEvent,
481
503
  placeOfEvent: UUID.nullish()
482
504
  }).describe(
@@ -484,15 +506,15 @@ var ResolvedScopeOptionsPlaceEvent = z10.object({
484
506
  );
485
507
  var ResolvedScopeOptionsDeclared = ResolvedScopeOptionsPlaceEvent.extend({
486
508
  notifiedIn: UUID.nullish(),
487
- notifiedBy: z10.string().optional(),
509
+ notifiedBy: z11.string().optional(),
488
510
  declaredIn: UUID.nullish(),
489
- declaredBy: z10.string().optional()
511
+ declaredBy: z11.string().optional()
490
512
  }).describe(
491
513
  "Resolved options applicable to actions that may take place after DECLARE, with location ID and user ID instead of filters."
492
514
  );
493
515
  var ResolvedScopeOptionsFull = ResolvedScopeOptionsDeclared.extend({
494
516
  registeredIn: UUID.nullish(),
495
- registeredBy: z10.string().optional(),
517
+ registeredBy: z11.string().optional(),
496
518
  flags: ContainsFlags.optional()
497
519
  }).describe(
498
520
  "Resolved options applicable to actions that may take place after REGISTER, with full filtering capabilities and location/user IDs instead of filters."
@@ -507,7 +529,6 @@ var ScopesWithDeclaredOptions = RecordScopeTypeV2.extract([
507
529
  "record.reject",
508
530
  "record.archive",
509
531
  "record.unarchive",
510
- "record.review-duplicates",
511
532
  "record.register"
512
533
  ]);
513
534
  var ScopesWithFullOptions = RecordScopeTypeV2.extract([
@@ -515,41 +536,42 @@ var ScopesWithFullOptions = RecordScopeTypeV2.extract([
515
536
  "record.read",
516
537
  "record.request-correction",
517
538
  "record.correct",
518
- "record.unassign-others"
539
+ "record.unassign-others",
540
+ "record.review-duplicates"
519
541
  ]);
520
542
  var ScopeOptionsPrintCertifiedCopies = AllRecordScopeOptions.extend({
521
- templates: z10.preprocess(
543
+ templates: z11.preprocess(
522
544
  (val) => val === void 0 ? void 0 : [val].flat(),
523
- z10.array(z10.string()).optional()
545
+ z11.array(z11.string()).optional()
524
546
  ).describe(
525
547
  "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."
526
548
  )
527
549
  });
528
- var RecordScopeV2 = z10.discriminatedUnion("type", [
529
- z10.object({
550
+ var RecordScopeV2 = z11.discriminatedUnion("type", [
551
+ z11.object({
530
552
  type: ScopesWithPlaceEventOptions,
531
553
  options: scopeOptionsPlaceEvent.optional()
532
554
  }),
533
- z10.object({
555
+ z11.object({
534
556
  type: ScopesWithDeclaredOptions,
535
557
  options: scopeOptionsDeclaredOrNotified.optional()
536
558
  }),
537
- z10.object({
559
+ z11.object({
538
560
  type: ScopesWithFullOptions,
539
561
  options: AllRecordScopeOptions.optional()
540
562
  }),
541
- z10.object({
542
- type: z10.literal("record.custom-action"),
563
+ z11.object({
564
+ type: z11.literal("record.custom-action"),
543
565
  options: CustomActionScopeOptions.optional()
544
566
  }),
545
- z10.object({
546
- type: z10.literal("record.print-certified-copies"),
567
+ z11.object({
568
+ type: z11.literal("record.print-certified-copies"),
547
569
  options: ScopeOptionsPrintCertifiedCopies.optional()
548
570
  })
549
571
  ]).describe(
550
572
  "Scopes used to check user's permission to perform actions on a record."
551
573
  );
552
- var SystemScopeType = z10.enum([
574
+ var SystemScopeType = z11.enum([
553
575
  "organisation.read-locations",
554
576
  "user.read",
555
577
  "user.create",
@@ -563,61 +585,61 @@ var UserScopeType = SystemScopeType.extract([
563
585
  "user.search"
564
586
  ]);
565
587
  var ScopesWithRoleOption = UserScopeType.extract(["user.edit", "user.create"]);
566
- var UserScopeV2 = z10.discriminatedUnion("type", [
567
- z10.object({
588
+ var UserScopeV2 = z11.discriminatedUnion("type", [
589
+ z11.object({
568
590
  type: ScopesWithRoleOption,
569
591
  options: AllUserScopeOptions.optional()
570
592
  }),
571
- z10.object({
593
+ z11.object({
572
594
  type: UserScopeType.extract(["user.read", "user.search"]),
573
595
  options: AccessLevelOptions.optional()
574
596
  })
575
597
  ]);
576
- var ResolvedRecordScopeV2 = z10.discriminatedUnion("type", [
577
- z10.object({
598
+ var ResolvedRecordScopeV2 = z11.discriminatedUnion("type", [
599
+ z11.object({
578
600
  type: ScopesWithPlaceEventOptions,
579
601
  options: ResolvedScopeOptionsPlaceEvent.optional()
580
602
  }),
581
- z10.object({
603
+ z11.object({
582
604
  type: ScopesWithDeclaredOptions,
583
605
  options: ResolvedScopeOptionsDeclared.optional()
584
606
  }),
585
- z10.object({
607
+ z11.object({
586
608
  type: ScopesWithFullOptions,
587
609
  options: ResolvedScopeOptionsFull.optional()
588
610
  }),
589
- z10.object({
590
- type: z10.literal("record.print-certified-copies"),
611
+ z11.object({
612
+ type: z11.literal("record.print-certified-copies"),
591
613
  options: ResolvedScopeOptionsFull.extend({
592
- templates: z10.array(z10.string()).optional()
614
+ templates: z11.array(z11.string()).optional()
593
615
  }).optional()
594
616
  })
595
617
  ]).describe("Resolved scope with location/user IDs instead of filters.");
596
- var Scope2 = z10.discriminatedUnion("type", [
597
- z10.object({ type: PlainScopeType }),
618
+ var Scope2 = z11.discriminatedUnion("type", [
619
+ z11.object({ type: PlainScopeType }),
598
620
  ...RecordScopeV2.options,
599
621
  ...UserScopeV2.options,
600
- z10.object({
601
- type: z10.literal("organisation.read-locations"),
622
+ z11.object({
623
+ type: z11.literal("organisation.read-locations"),
602
624
  options: AccessLevelOptions.optional()
603
625
  }),
604
- z10.object({
605
- type: z10.literal("workqueue"),
626
+ z11.object({
627
+ type: z11.literal("workqueue"),
606
628
  options: WorkqueueOrDashboardOptions
607
629
  }),
608
- z10.object({
609
- type: z10.literal("dashboard.view"),
630
+ z11.object({
631
+ type: z11.literal("dashboard.view"),
610
632
  options: WorkqueueOrDashboardOptions
611
633
  })
612
634
  ]);
613
- var ScopeType2 = z10.enum([
635
+ var ScopeType2 = z11.enum([
614
636
  ...SystemScopeType.options,
615
637
  ...RecordScopeTypeV2.options,
616
638
  ...PlainScopeType.options,
617
639
  "workqueue",
618
640
  "dashboard.view"
619
641
  ]);
620
- var EncodedScope2 = z10.string().brand("EncodedScope");
642
+ var EncodedScope2 = z11.string().brand("EncodedScope");
621
643
  var DEFAULT_SCOPE_OPTIONS = {
622
644
  placeOfEvent: JurisdictionFilter.enum.all,
623
645
  accessLevel: JurisdictionFilter.enum.all,
@@ -1312,4 +1334,4 @@ function createFieldConditionals(fieldId) {
1312
1334
  }
1313
1335
 
1314
1336
  // src/conditionals/index.ts
1315
- z12.globalRegistry.clear();
1337
+ z13.globalRegistry.clear();
package/dist/csv.d.ts ADDED
@@ -0,0 +1,25 @@
1
+ export type CsvFile = {
2
+ header: string;
3
+ body: string[];
4
+ /** Preserved so a file written on Windows stays written on Windows. */
5
+ newline: string;
6
+ trailingNewline: boolean;
7
+ };
8
+ export declare function parseCsvLine(line: string): string[];
9
+ export declare function toCsvLine(values: string[]): string;
10
+ /**
11
+ * The id of a row, which is its first column. Translation ids never contain a
12
+ * comma or a quote, so this does not need the parser.
13
+ */
14
+ export declare function idOf(line: string): string;
15
+ export declare function readCsvFile(path: string): CsvFile | undefined;
16
+ export declare function writeCsvFile(path: string, file: CsvFile): void;
17
+ /**
18
+ * Adds the rows the file does not already have an id for, in place. Rows go in
19
+ * sorted position when the file is sorted by id, and at the end when it is not,
20
+ * so a country config that keeps its own order keeps it.
21
+ *
22
+ * Returns the ids that were added.
23
+ */
24
+ export declare function addRows(file: CsvFile, rows: string[]): string[];
25
+ //# sourceMappingURL=csv.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"csv.d.ts","sourceRoot":"","sources":["../src/csv.ts"],"names":[],"mappings":"AAuBA,MAAM,MAAM,OAAO,GAAG;IACpB,MAAM,EAAE,MAAM,CAAA;IACd,IAAI,EAAE,MAAM,EAAE,CAAA;IACd,uEAAuE;IACvE,OAAO,EAAE,MAAM,CAAA;IACf,eAAe,EAAE,OAAO,CAAA;CACzB,CAAA;AAED,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,CAiCnD;AAED,wBAAgB,SAAS,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,CAMlD;AAED;;;GAGG;AACH,wBAAgB,IAAI,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAKzC;AAED,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,GAAG,SAAS,CAe7D;AAED,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,GAAG,IAAI,CAM9D;AAED;;;;;;GAMG;AACH,wBAAgB,OAAO,CAAC,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,MAAM,EAAE,CA4B/D"}
package/dist/csv.js ADDED
@@ -0,0 +1,120 @@
1
+ "use strict";
2
+ /*
3
+ * This Source Code Form is subject to the terms of the Mozilla Public
4
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
5
+ * file, You can obtain one at https://mozilla.org/MPL/2.0/.
6
+ *
7
+ * OpenCRVS is also distributed under the terms of the Civil Registration
8
+ * & Healthcare Disclaimer located at http://opencrvs.org/license.
9
+ *
10
+ * Copyright (C) The OpenCRVS Authors located at https://github.com/opencrvs/opencrvs-core/blob/master/AUTHORS.
11
+ */
12
+ Object.defineProperty(exports, "__esModule", { value: true });
13
+ exports.parseCsvLine = parseCsvLine;
14
+ exports.toCsvLine = toCsvLine;
15
+ exports.idOf = idOf;
16
+ exports.readCsvFile = readCsvFile;
17
+ exports.writeCsvFile = writeCsvFile;
18
+ exports.addRows = addRows;
19
+ /**
20
+ * Just enough CSV for the translation files codemods edit. They are read and
21
+ * written a line at a time rather than through a parser, so that adding two
22
+ * rows to a file of sixteen hundred produces a diff of two lines instead of a
23
+ * re-quoted rewrite of the whole thing.
24
+ *
25
+ * Rows spanning multiple lines are not supported, and none of the translation
26
+ * files contain any.
27
+ */
28
+ const fs_1 = require("fs");
29
+ function parseCsvLine(line) {
30
+ const values = [];
31
+ let value = '';
32
+ let quoted = false;
33
+ for (let index = 0; index < line.length; index++) {
34
+ const character = line[index];
35
+ if (quoted) {
36
+ if (character !== '"') {
37
+ value += character;
38
+ }
39
+ else if (line[index + 1] === '"') {
40
+ value += '"';
41
+ index++;
42
+ }
43
+ else {
44
+ quoted = false;
45
+ }
46
+ continue;
47
+ }
48
+ if (character === '"') {
49
+ quoted = true;
50
+ }
51
+ else if (character === ',') {
52
+ values.push(value);
53
+ value = '';
54
+ }
55
+ else {
56
+ value += character;
57
+ }
58
+ }
59
+ values.push(value);
60
+ return values;
61
+ }
62
+ function toCsvLine(values) {
63
+ return values
64
+ .map((value) => /["\n,]/.test(value) ? `"${value.replace(/"/g, '""')}"` : value)
65
+ .join(',');
66
+ }
67
+ /**
68
+ * The id of a row, which is its first column. Translation ids never contain a
69
+ * comma or a quote, so this does not need the parser.
70
+ */
71
+ function idOf(line) {
72
+ const comma = line.indexOf(',');
73
+ // No comma: `slice(0, -1)` would eat the last character.
74
+ return comma === -1 ? line : line.slice(0, comma);
75
+ }
76
+ function readCsvFile(path) {
77
+ if (!(0, fs_1.existsSync)(path)) {
78
+ return undefined;
79
+ }
80
+ const contents = (0, fs_1.readFileSync)(path, 'utf8');
81
+ const newline = contents.includes('\r\n') ? '\r\n' : '\n';
82
+ const trailingNewline = /\r?\n$/.test(contents);
83
+ const lines = contents.replace(/\r?\n$/, '').split(/\r?\n/);
84
+ // Trailing blank line leaves an empty entry. It sorts before every id, so
85
+ // the file reads as unsorted.
86
+ const body = lines.slice(1).filter((line) => line !== '');
87
+ return { header: lines[0], body, newline, trailingNewline };
88
+ }
89
+ function writeCsvFile(path, file) {
90
+ (0, fs_1.writeFileSync)(path, [file.header, ...file.body].join(file.newline) +
91
+ (file.trailingNewline ? file.newline : ''));
92
+ }
93
+ /**
94
+ * Adds the rows the file does not already have an id for, in place. Rows go in
95
+ * sorted position when the file is sorted by id, and at the end when it is not,
96
+ * so a country config that keeps its own order keeps it.
97
+ *
98
+ * Returns the ids that were added.
99
+ */
100
+ function addRows(file, rows) {
101
+ const isSorted = file.body.every((line, index) => index === 0 || idOf(file.body[index - 1]) <= idOf(line));
102
+ const added = [];
103
+ for (const row of rows) {
104
+ const id = idOf(row);
105
+ if (file.body.some((line) => idOf(line) === id)) {
106
+ continue;
107
+ }
108
+ const insertAt = isSorted
109
+ ? file.body.findIndex((line) => idOf(line) > id)
110
+ : -1;
111
+ if (insertAt === -1) {
112
+ file.body.push(row);
113
+ }
114
+ else {
115
+ file.body.splice(insertAt, 0, row);
116
+ }
117
+ added.push(id);
118
+ }
119
+ return added;
120
+ }
@@ -1,15 +1,18 @@
1
1
  export declare const log: {
2
2
  (message?: any, ...optionalParams: any[]): void;
3
3
  (message?: any, ...optionalParams: any[]): void;
4
+ (message?: any, ...optionalParams: any[]): void;
4
5
  };
5
6
  export declare const warn: {
6
7
  (message?: any, ...optionalParams: any[]): void;
7
8
  (message?: any, ...optionalParams: any[]): void;
9
+ (message?: any, ...optionalParams: any[]): void;
8
10
  };
9
11
  export declare const success: (...args: any[]) => void;
10
12
  export declare const info: {
11
13
  (message?: any, ...optionalParams: any[]): void;
12
14
  (message?: any, ...optionalParams: any[]): void;
15
+ (message?: any, ...optionalParams: any[]): void;
13
16
  };
14
17
  export declare const error: (...args: any[]) => void;
15
18
  //# sourceMappingURL=logger.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../src/environment/logger.ts"],"names":[],"mappings":"AAcA,eAAO,MAAM,GAAG;;;CAAc,CAAA;AAC9B,eAAO,MAAM,IAAI;;;CAAe,CAAA;AAChC,eAAO,MAAM,OAAO,YAAa,GAAG,EAAE,SACI,CAAA;AAC1C,eAAO,MAAM,IAAI;;;CAAe,CAAA;AAChC,eAAO,MAAM,KAAK,YAAa,GAAG,EAAE,SAA2C,CAAA"}
1
+ {"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../src/environment/logger.ts"],"names":[],"mappings":"AAcA,eAAO,MAAM,GAAG;;;;CAAc,CAAA;AAC9B,eAAO,MAAM,IAAI;;;;CAAe,CAAA;AAChC,eAAO,MAAM,OAAO,YAAa,GAAG,EAAE,SACI,CAAA;AAC1C,eAAO,MAAM,IAAI;;;;CAAe,CAAA;AAChC,eAAO,MAAM,KAAK,YAAa,GAAG,EAAE,SAA2C,CAAA"}
@@ -95,7 +95,7 @@ function updateInventoryFile(filePath, users) {
95
95
  function parseInventoryFile(filePath) {
96
96
  try {
97
97
  const data = (0, utils_1.readYamlFile)(filePath);
98
- return (0, templates_1.getUsers)(data);
98
+ return (0, templates_1.extractAndModifyUsers)(data);
99
99
  }
100
100
  catch (_a) {
101
101
  return [];
@@ -1 +1 @@
1
- {"version":3,"file":"questions.d.ts","sourceRoot":"","sources":["../../src/environment/questions.ts"],"names":[],"mappings":"AAeA,QAAA,MAAM,QAAQ,UAAW,MAAM,GAAG,MAAM,kCAC4B,CAAA;AAepE,iBAAS,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,MAAM,CAgBnD;AAED,eAAO,MAAM,kBAAkB;;UAGrB,MAAM;;eAED,QAAQ;;;;WAIZ,YAAY;GAiCtB,CAAA;AAED,eAAO,MAAM,eAAe;;UAGlB,MAAM;;;;WAIL,YAAY;GAUtB,CAAA;AACD,eAAO,MAAM,oBAAoB;;UAGvB,MAAM;;;eAGD,UAAU;;WAEd,YAAY;;;;;UAIb,QAAQ;;;;;;eAaH,UAAU;;;;WAId,aAAa;IAEvB,CAAA;AACD,eAAO,MAAM,mBAAmB;;UAGtB,MAAM;;;;eAID,QAAQ;WACZ,YAAY;;GAGtB,CAAA;AAED,eAAO,MAAM,gBAAgB;;UAGnB,MAAM;;eAGD,UAAU;;;WAGd,YAAY;GAEtB,CAAA;AAED,eAAO,MAAM,uBAAuB;;UAG1B,MAAM;;eAED,UAAU;;;;WAId,aAAa;;;;UAId,MAAM;;eAED,UAAU;;;WAId,aAAa;;;UAId,MAAM;;eAED,UAAU;;;;WAId,aAAa;IAYvB,CAAA;AAED,eAAO,MAAM,sBAAsB;;UAGzB,MAAM;;eAED,QAAQ;;;;WAIZ,aAAa;GAYvB,CAAA;AAED,eAAO,MAAM,eAAe;;;;UAGlB,MAAM;;eAED,UAAU;;;WAId,aAAa;;;;UAId,MAAM;;eAED,QAAQ;;;;WAIZ,aAAa;;;UAId,QAAQ;;;;;;eAYH,UAAU;;;;WAId,aAAa;IAEvB,CAAA;AAED,eAAO,MAAM,aAAa;;UAGhB,MAAM;;eAID,UAAU;;;;WAId,aAAa;GAEvB,CAAA;AAED,eAAO,MAAM,8BAA8B;;UAGjC,MAAM;;eAED,QAAQ;;;;WAIZ,aAAa;GAYvB,CAAA;AAED,eAAO,MAAM,cAAc;;;UAGjB,MAAM;;eAED,QAAQ;;;;WAIZ,aAAa;;;UAkCd,QAAQ;;;;;;eAYH,QAAQ;;;;WAIZ,aAAa;IAuBvB,CAAA;AAED,eAAO,MAAM,eAAe;;UAGlB,MAAM;;eAED,QAAQ;;;;WAIZ,aAAa;GAEvB,CAAA;AAED,eAAO,MAAM,sBAAsB;eAEpB,QAAQ;;UAEb,MAAM;;;WAIL,aAAa;;GAYvB,CAAA"}
1
+ {"version":3,"file":"questions.d.ts","sourceRoot":"","sources":["../../src/environment/questions.ts"],"names":[],"mappings":"AAeA,QAAA,MAAM,QAAQ,UAAW,MAAM,GAAG,MAAM,kCAC4B,CAAA;AAepE,iBAAS,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,MAAM,CAgBnD;AAED,eAAO,MAAM,kBAAkB;;UAGrB,MAAM;;eAED,QAAQ;;;;WAIZ,YAAY;GAiCtB,CAAA;AAED,eAAO,MAAM,eAAe;;UAGlB,MAAM;;;;WAIL,YAAY;GAUtB,CAAA;AACD,eAAO,MAAM,oBAAoB;;UAGvB,MAAM;;;eAGD,UAAU;;WAEd,YAAY;;;;;UAIb,QAAQ;;;;;;eAaH,UAAU;;;;WAId,aAAa;IAEvB,CAAA;AACD,eAAO,MAAM,mBAAmB;;UAGtB,MAAM;;;;eAID,QAAQ;WACZ,YAAY;;GAGtB,CAAA;AAED,eAAO,MAAM,gBAAgB;;UAGnB,MAAM;;eAGD,UAAU;;;WAGd,YAAY;GAEtB,CAAA;AAED,eAAO,MAAM,uBAAuB;;UAG1B,MAAM;;eAED,UAAU;;;;WAId,aAAa;;;;UAId,MAAM;;eAED,UAAU;;;WAGd,aAAa;;;UAsBd,MAAM;;eAED,UAAU;;;;WAId,aAAa;IAEvB,CAAA;AAED,eAAO,MAAM,sBAAsB;;UAGzB,MAAM;;eAED,QAAQ;;;;WAIZ,aAAa;GAYvB,CAAA;AAED,eAAO,MAAM,eAAe;;;;UAGlB,MAAM;;eAED,UAAU;;;WAGd,aAAa;;;;UAId,MAAM;;eAED,QAAQ;;;;WAIZ,aAAa;;;UAId,QAAQ;;;;;;eAYH,UAAU;;;;WAId,aAAa;IAEvB,CAAA;AAED,eAAO,MAAM,aAAa;;UAGhB,MAAM;;eAID,UAAU;;;;WAId,aAAa;GAEvB,CAAA;AAED,eAAO,MAAM,8BAA8B;;UAGjC,MAAM;;eAED,QAAQ;;;;WAIZ,aAAa;GAYvB,CAAA;AAED,eAAO,MAAM,cAAc;;;UAGjB,MAAM;;eAED,QAAQ;;;;WAIZ,aAAa;;;UAkCd,QAAQ;;;;;;eAYH,QAAQ;;;;WAIZ,aAAa;IAuBvB,CAAA;AAED,eAAO,MAAM,eAAe;;UAGlB,MAAM;;eAED,QAAQ;;;;WAIZ,aAAa;GAEvB,CAAA;AAED,eAAO,MAAM,sBAAsB;eAEpB,QAAQ;;UAEb,MAAM;;;WAIL,aAAa;;GAYvB,CAAA"}
@@ -166,11 +166,28 @@ exports.infrastructureQuestions = [
166
166
  scope: 'ENVIRONMENT'
167
167
  },
168
168
  {
169
- name: 'kubeAPIHost',
169
+ name: 'kubeMasterNode',
170
170
  type: 'text',
171
- message: `Kubernetes API endpoint (default: auto-detect)`,
171
+ message: `Kubernetes master node hostnames or IP (default: auto-detect)`,
172
+ valueType: 'VARIABLE',
173
+ valueLabel: 'KUBE_MASTER_NODE',
174
+ initial: process.env.KUBE_MASTER_NODE,
175
+ scope: 'ENVIRONMENT'
176
+ },
177
+ {
178
+ name: 'kubeWorkerNodes',
179
+ type: 'text',
180
+ message: `Kubernetes worker node hostnames or IPs (comma-separated, default: no worker nodes)`,
181
+ valueType: 'VARIABLE',
182
+ valueLabel: 'KUBE_WORKER_NODES',
183
+ initial: process.env.KUBE_WORKER_NODES || '',
184
+ scope: 'ENVIRONMENT'
185
+ },
186
+ {
187
+ name: 'kubeApiHost',
188
+ type: 'text',
189
+ message: `Kubernetes API endpoint IP (default: KUBE_MASTER_NODE)`,
172
190
  valueType: 'VARIABLE',
173
- // validate: notEmpty,
174
191
  valueLabel: 'KUBE_API_HOST',
175
192
  initial: process.env.KUBE_API_HOST,
176
193
  scope: 'ENVIRONMENT'
@@ -185,16 +202,6 @@ exports.infrastructureQuestions = [
185
202
  initial: process.env.KUBE_API_ALLOWED_CIDRS || '',
186
203
  scope: 'ENVIRONMENT'
187
204
  },
188
- {
189
- name: 'kubeWorkerNodes',
190
- type: 'text',
191
- message: `Kubernetes worker node hostnames or IPs (comma-separated, default: no worker nodes)`,
192
- valueType: 'VARIABLE',
193
- // validate: notEmpty,
194
- valueLabel: 'KUBE_WORKER_NODES',
195
- initial: process.env.KUBE_WORKER_NODES || '',
196
- scope: 'ENVIRONMENT'
197
- }
198
205
  ];
199
206
  exports.staticSSLCertQuestions = [
200
207
  {
@@ -224,7 +231,6 @@ exports.backupQuestions = [
224
231
  type: 'text',
225
232
  message: `Please enter backup server host/IP address, (default: no backup):`,
226
233
  valueType: 'VARIABLE',
227
- // validate: notEmpty,
228
234
  valueLabel: 'BACKUP_HOST',
229
235
  initial: process.env.BACKUP_HOST || '',
230
236
  scope: 'ENVIRONMENT'
@@ -49,6 +49,12 @@ function select(options) {
49
49
  return inquirer.select(options);
50
50
  });
51
51
  }
52
+ function input(options) {
53
+ return __awaiter(this, void 0, void 0, function* () {
54
+ const inquirer = yield import('@inquirer/prompts');
55
+ return inquirer.input(options);
56
+ });
57
+ }
52
58
  const github_1 = require("./github");
53
59
  const derived_variables_1 = require("./derived-variables");
54
60
  const utils_1 = require("./utils");
@@ -171,7 +177,7 @@ function promptAndStoreAnswer(environment, questions, existingValues) {
171
177
  }
172
178
  ALL_QUESTIONS.push(...questions_1.githubTokenQuestion, ...questions_1.githubOtherQuestions, ...questions_1.dockerhubQuestions, ...questions_1.diskQuestions, ...questions_1.infrastructureQuestions, ...questions_1.backupQuestions, ...questions_1.countryQuestions, ...questions_1.databaseAndMonitoringQuestions, ...questions_1.emailQuestions, ...questions_1.sentryQuestions, ...derived_variables_1.derivedVariables, ...questions_1.metabaseAdminQuestions);
173
179
  (() => __awaiter(void 0, void 0, void 0, function* () {
174
- var _a, _b, _c;
180
+ var _a, _b, _c, _d;
175
181
  (0, logger_1.log)('\n', kleur_1.default.bold().underline('Github'), '\n');
176
182
  const { githubOrganisation, githubRepository } = yield (0, prompts_1.default)(questions_1.githubQuestions.map(questionToPrompt), {
177
183
  onCancel: () => {
@@ -331,7 +337,8 @@ ALL_QUESTIONS.push(...questions_1.githubTokenQuestion, ...questions_1.githubOthe
331
337
  let backupHost = ((_a = (0, utils_1.findExistingValue)('BACKUP_HOST', 'VARIABLE', 'ENVIRONMENT', existingValues)) === null || _a === void 0 ? void 0 : _a.value) || '';
332
338
  let backupType = '';
333
339
  let restoreEnvironmentName = (_b = (0, utils_1.findExistingValue)('RESTORE_ENVIRONMENT_NAME', 'VARIABLE', 'ENVIRONMENT', existingValues)) === null || _b === void 0 ? void 0 : _b.value;
334
- let restoreType = ((_c = (0, utils_1.findExistingValue)('RESTORE_ENVIRONMENT_MODE', 'VARIABLE', 'ENVIRONMENT', existingValues)) === null || _c === void 0 ? void 0 : _c.value) ||
340
+ let restoreHost = ((_c = (0, utils_1.findExistingValue)('RESTORE_HOST', 'VARIABLE', 'ENVIRONMENT', existingValues)) === null || _c === void 0 ? void 0 : _c.value) || '';
341
+ let restoreType = ((_d = (0, utils_1.findExistingValue)('RESTORE_ENVIRONMENT_MODE', 'VARIABLE', 'ENVIRONMENT', existingValues)) === null || _d === void 0 ? void 0 : _d.value) ||
335
342
  process.env.RESTORE_ENVIRONMENT_MODE ||
336
343
  'dump';
337
344
  (0, logger_1.log)('\n', kleur_1.default.bold().underline('Backup'));
@@ -393,6 +400,10 @@ ALL_QUESTIONS.push(...questions_1.githubTokenQuestion, ...questions_1.githubOthe
393
400
  }
394
401
  ]
395
402
  });
403
+ restoreHost = yield input({
404
+ message: 'What is the host/IP address of the restore backup server?',
405
+ default: restoreHost
406
+ });
396
407
  }
397
408
  else {
398
409
  (0, logger_1.log)(kleur_1.default.bold().green('✔'), kleur_1.default.bold().yellow('Restore is disabled'));
@@ -557,6 +568,13 @@ ALL_QUESTIONS.push(...questions_1.githubTokenQuestion, ...questions_1.githubOthe
557
568
  value: answerOrExisting(restoreEnvironmentName, (0, utils_1.findExistingValue)('RESTORE_ENVIRONMENT_NAME', 'VARIABLE', 'ENVIRONMENT', existingValues), (val) => val || ''),
558
569
  didExist: (0, utils_1.findExistingValue)('RESTORE_ENVIRONMENT_NAME', 'VARIABLE', 'ENVIRONMENT', existingValues),
559
570
  scope: 'ENVIRONMENT'
571
+ },
572
+ {
573
+ type: 'VARIABLE',
574
+ name: 'RESTORE_HOST',
575
+ value: answerOrExisting(restoreHost, (0, utils_1.findExistingValue)('RESTORE_HOST', 'VARIABLE', 'ENVIRONMENT', existingValues), (val) => val || ''),
576
+ didExist: (0, utils_1.findExistingValue)('RESTORE_HOST', 'VARIABLE', 'ENVIRONMENT', existingValues),
577
+ scope: 'ENVIRONMENT'
560
578
  }
561
579
  ];
562
580
  if (enableEncryption) {
@@ -717,7 +735,7 @@ ALL_QUESTIONS.push(...questions_1.githubTokenQuestion, ...questions_1.githubOthe
717
735
  (0, logger_1.log)('\n', kleur_1.default.bold().underline('Running configuration files updates'));
718
736
  (0, templates_1.generateInventory)(environment, {
719
737
  kube_worker_nodes: kubeWorkerNodes,
720
- kube_api_host: infrastructure.kubeAPIHost || '',
738
+ kube_api_host: infrastructure.kubeApiHost || '',
721
739
  backup_host: backupHost || '',
722
740
  users: users
723
741
  });
@@ -728,12 +746,14 @@ ALL_QUESTIONS.push(...questions_1.githubTokenQuestion, ...questions_1.githubOthe
728
746
  // Hardcode like this blocks us from being generic:
729
747
  // https://github.com/opencrvs/opencrvs-core/issues/11171
730
748
  two_fa_enabled: environment !== 'production' ? false : true,
731
- backup_enabled: configureBackup ? true : false,
749
+ traefik_mode: traefikConfOption,
732
750
  restore_enabled: restoreEnvironmentName ? true : false,
733
751
  restore_environment_name: restoreEnvironmentName || '',
734
752
  restore_type: restoreType,
735
- traefik_mode: traefikConfOption,
736
- backup_type: backupType
753
+ restore_host: restoreHost || '',
754
+ backup_enabled: configureBackup ? true : false,
755
+ backup_type: backupType,
756
+ backup_host: backupHost || ''
737
757
  });
738
758
  let addon_message = kubeWorkerNodes.length > 0 || configureBackup
739
759
  ? '--------------------------------------------------------------------------------------------\n' +
@@ -1,4 +1,3 @@
1
- export declare function getUsers(data: any): any;
2
1
  export declare function extractAndModifyUsers(data: any): any;
3
2
  export declare function dockerManagerFirst(data: any): string;
4
3
  export declare function extractBackupNode(data: any): string;
@@ -1 +1 @@
1
- {"version":3,"file":"templates.d.ts","sourceRoot":"","sources":["../../src/environment/templates.ts"],"names":[],"mappings":"AAuBA,wBAAgB,QAAQ,CAAC,IAAI,EAAE,GAAG,GAAG,GAAG,CAKvC;AAID,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,GAAG,GAAG,GAAG,CAYpD;AAED,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,GAAG,GAAG,MAAM,CAWpD;AAED,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,GAAG,GAAG,MAAM,CASnD;AAED,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,GAAG,GAAG,MAAM,EAAE,CAStD;AAGD;;;;GAIG;AACH;;GAEG;AACH,wBAAgB,gBAAgB,CAC9B,GAAG,EAAE,MAAM,EACX,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,QA0CzC;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,QAsBzE"}
1
+ {"version":3,"file":"templates.d.ts","sourceRoot":"","sources":["../../src/environment/templates.ts"],"names":[],"mappings":"AA0BA,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,GAAG,GAAG,GAAG,CAepD;AAED,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,GAAG,GAAG,MAAM,CAWpD;AAED,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,GAAG,GAAG,MAAM,CASnD;AAED,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,GAAG,GAAG,MAAM,EAAE,CAStD;AAGD;;;;GAIG;AACH;;GAEG;AACH,wBAAgB,gBAAgB,CAC9B,GAAG,EAAE,MAAM,EACX,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,QA0CzC;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,QAsBzE"}