@opencrvs/toolkit 2.1.0-rc.75e32d8 → 2.1.0-rc.7737766

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 (134) hide show
  1. package/README.md +1 -0
  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 +349 -277
  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 +754 -0
  10. package/dist/cli.js +1782 -113
  11. package/dist/commons/api/router.d.ts +3976 -3374
  12. package/dist/commons/application-config/index.d.ts +6 -6
  13. package/dist/commons/conditionals/conditionals.d.ts +32 -323
  14. package/dist/commons/conditionals/validate.d.ts +16 -5
  15. package/dist/commons/events/ActionConfig.d.ts +109 -105
  16. package/dist/commons/events/ActionDocument.d.ts +121 -127
  17. package/dist/commons/events/ActionInput.d.ts +4 -10
  18. package/dist/commons/events/ActionStatus.d.ts +14 -0
  19. package/dist/commons/events/ActionType.d.ts +62 -62
  20. package/dist/commons/events/AdvancedSearchConfig.d.ts +543 -507
  21. package/dist/commons/events/AuditLog.d.ts +189 -42
  22. package/dist/commons/events/CompositeFieldValue.d.ts +4 -4
  23. package/dist/commons/events/Conditional.d.ts +3 -3
  24. package/dist/commons/events/CountryConfigQueryInput.d.ts +590 -590
  25. package/dist/commons/events/Draft.d.ts +37 -37
  26. package/dist/commons/events/DynamicFieldValue.d.ts +9 -9
  27. package/dist/commons/events/EventConfig.d.ts +8 -5
  28. package/dist/commons/events/EventDocument.d.ts +518 -50
  29. package/dist/commons/events/EventIndex.d.ts +49 -72
  30. package/dist/commons/events/EventMetadata.d.ts +39 -49
  31. package/dist/commons/events/EventStatus.d.ts +19 -0
  32. package/dist/commons/events/FieldConfig.d.ts +434 -389
  33. package/dist/commons/events/FieldType.d.ts +51 -51
  34. package/dist/commons/events/FieldTypeMapping.d.ts +86 -86
  35. package/dist/commons/events/FieldValue.d.ts +14 -14
  36. package/dist/commons/events/Flag.d.ts +57 -15
  37. package/dist/commons/events/FormConfig.d.ts +6 -0
  38. package/dist/commons/events/PageConfig.d.ts +4 -0
  39. package/dist/commons/events/PlainDate.d.ts +8 -0
  40. package/dist/commons/events/SummaryConfig.d.ts +249 -0
  41. package/dist/commons/events/TemplateConfig.d.ts +1 -1
  42. package/dist/commons/events/WorkqueueColumnConfig.d.ts +40 -40
  43. package/dist/commons/events/WorkqueueConfig.d.ts +817 -814
  44. package/dist/commons/events/deduplication.d.ts +1 -1
  45. package/dist/commons/events/event.d.ts +14 -2
  46. package/dist/commons/events/field.d.ts +69 -198
  47. package/dist/commons/events/index.d.ts +1 -0
  48. package/dist/commons/events/locationPayloads.d.ts +95 -0
  49. package/dist/commons/events/locations.d.ts +247 -14
  50. package/dist/commons/events/mocks.test.utils.d.ts +48 -4
  51. package/dist/commons/events/scopes.d.ts +4 -4
  52. package/dist/commons/events/state/index.d.ts +17 -17
  53. package/dist/commons/events/state/utils.d.ts +7 -7
  54. package/dist/commons/events/test.utils.d.ts +64 -46
  55. package/dist/commons/events/utils.d.ts +129 -114
  56. package/dist/commons/notification/UserNotifications.d.ts +38 -23
  57. package/dist/commons/notification/dispatch.d.ts +10 -0
  58. package/dist/commons/notification/index.d.ts +1 -0
  59. package/dist/conditionals/index.js +334 -60
  60. package/dist/csv.d.ts +25 -0
  61. package/dist/csv.d.ts.map +1 -0
  62. package/dist/csv.js +120 -0
  63. package/dist/environment/derived-variables.d.ts +119 -119
  64. package/dist/environment/derived-variables.d.ts.map +1 -1
  65. package/dist/environment/index.d.ts +1 -0
  66. package/dist/environment/index.d.ts.map +1 -1
  67. package/dist/environment/index.js +10 -0
  68. package/dist/environment/logger.d.ts +6 -3
  69. package/dist/environment/logger.d.ts.map +1 -1
  70. package/dist/environment/manage-users.js +17 -7
  71. package/dist/environment/paths.d.ts +7 -0
  72. package/dist/environment/paths.d.ts.map +1 -0
  73. package/dist/environment/paths.js +72 -0
  74. package/dist/environment/questions.d.ts +75 -74
  75. package/dist/environment/questions.d.ts.map +1 -1
  76. package/dist/environment/questions.js +20 -14
  77. package/dist/environment/setup-environment.js +36 -21
  78. package/dist/environment/swarm-to-k8s.js +17 -7
  79. package/dist/environment/templates.d.ts.map +1 -1
  80. package/dist/environment/templates.js +2 -1
  81. package/dist/environment/update-workflows.d.ts.map +1 -1
  82. package/dist/environment/update-workflows.js +34 -12
  83. package/dist/environment/upgrade.d.ts +2 -0
  84. package/dist/environment/upgrade.d.ts.map +1 -0
  85. package/dist/environment/upgrade.js +82 -0
  86. package/dist/environment/users.js +28 -20
  87. package/dist/environment/utils.d.ts +1 -1
  88. package/dist/environment/utils.js +17 -7
  89. package/dist/events/deduplication.d.ts +1 -1
  90. package/dist/events/index.js +7641 -7128
  91. package/dist/migrations/v2.0/checkout-upstream-files.d.ts +2 -2
  92. package/dist/migrations/v2.0/checkout-upstream-files.d.ts.map +1 -1
  93. package/dist/migrations/v2.0/checkout-upstream-files.js +2 -2
  94. package/dist/migrations/v2.0/convert-config-files-to-ts.js +17 -7
  95. package/dist/migrations/v2.0/merge-infrastructure-directory.js +3 -3
  96. package/dist/migrations/v2.0/migrate-application-config-url.js +4 -3
  97. package/dist/migrations/v2.0/remove-hearth-migrations.js +17 -7
  98. package/dist/migrations/v2.1/add-recovery-link-notifications.d.ts +3 -0
  99. package/dist/migrations/v2.1/add-recovery-link-notifications.d.ts.map +1 -0
  100. package/dist/migrations/v2.1/add-recovery-link-notifications.js +511 -0
  101. package/dist/migrations/v2.1/add-translations.d.ts +9 -0
  102. package/dist/migrations/v2.1/add-translations.d.ts.map +1 -0
  103. package/dist/migrations/v2.1/add-translations.js +213 -0
  104. package/dist/migrations/v2.1/enable-telemetry.d.ts +3 -0
  105. package/dist/migrations/v2.1/enable-telemetry.d.ts.map +1 -0
  106. package/dist/migrations/v2.1/enable-telemetry.js +438 -0
  107. package/dist/migrations/v2.1/index.d.ts.map +1 -1
  108. package/dist/migrations/v2.1/index.js +1058 -0
  109. package/dist/notification/index.js +1870 -1464
  110. package/dist/scopes/index.d.ts +560 -157
  111. package/dist/scopes/index.js +335 -60
  112. package/dist/telemetry/index.d.ts +45 -0
  113. package/dist/telemetry/index.d.ts.map +1 -0
  114. package/dist/telemetry/index.js +39 -0
  115. package/dist/templates/charts-values/dependencies/values.yaml +2 -0
  116. package/dist/templates/charts-values/opencrvs-services/values.yaml +4 -3
  117. package/dist/templates/charts-values/opentelemetry/values.yaml +95 -0
  118. package/dist/templates/charts-values/traefik/values.yaml +23 -9
  119. package/dist/templates/inventory/inventory.template.yml +1 -3
  120. package/dist/translations/check.d.ts +21 -0
  121. package/dist/translations/check.d.ts.map +1 -0
  122. package/dist/translations/check.js +132 -0
  123. package/dist/verify/endpoints.d.ts +2 -0
  124. package/dist/verify/endpoints.d.ts.map +1 -0
  125. package/dist/verify/endpoints.js +345 -0
  126. package/opencrvs-toolkit-2.1.0-rc.7737766.tgz +0 -0
  127. package/package.json +12 -7
  128. package/tsconfig.build.json +11 -0
  129. package/tsconfig.build.tsbuildinfo +1 -0
  130. package/tsconfig.json +3 -0
  131. package/dist/templates/inventory/production.example.yml +0 -77
  132. package/dist/templates/inventory/qa.example.yml +0 -48
  133. package/opencrvs-toolkit-2.1.0-rc.75e32d8.tgz +0 -0
  134. package/tsconfig.tsbuildinfo +0 -1
@@ -0,0 +1,82 @@
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
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
13
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
14
+ return new (P || (P = Promise))(function (resolve, reject) {
15
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
16
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
17
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
18
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
19
+ });
20
+ };
21
+ var __importDefault = (this && this.__importDefault) || function (mod) {
22
+ return (mod && mod.__esModule) ? mod : { "default": mod };
23
+ };
24
+ Object.defineProperty(exports, "__esModule", { value: true });
25
+ exports.upgradeEnvironmentLayout = upgradeEnvironmentLayout;
26
+ const fs_1 = require("fs");
27
+ const path_1 = require("path");
28
+ const kleur_1 = __importDefault(require("kleur"));
29
+ const logger_1 = require("./logger");
30
+ const paths_1 = require("./paths");
31
+ const update_workflows_1 = require("./update-workflows");
32
+ function moveFileIfDestinationMissing(sourcePath, destinationPath) {
33
+ if (!(0, fs_1.existsSync)(sourcePath)) {
34
+ return false;
35
+ }
36
+ if ((0, fs_1.existsSync)(destinationPath)) {
37
+ (0, logger_1.warn)(`⚠️ Skipped ${sourcePath}; destination already exists at ${destinationPath}`);
38
+ return false;
39
+ }
40
+ (0, fs_1.mkdirSync)((0, path_1.dirname)(destinationPath), { recursive: true });
41
+ (0, fs_1.renameSync)(sourcePath, destinationPath);
42
+ (0, logger_1.log)(` ✓ Moved ${sourcePath} -> ${destinationPath}`);
43
+ return true;
44
+ }
45
+ function migrateInventoryFiles() {
46
+ const oldInventoryFiles = (0, paths_1.findOldInventoryFiles)();
47
+ if (oldInventoryFiles.length === 0) {
48
+ (0, logger_1.log)(`ℹ️ No old inventory files found at ${paths_1.OLD_INVENTORY_DIR}`);
49
+ return false;
50
+ }
51
+ (0, logger_1.log)(kleur_1.default.bold('\nMigrating Ansible inventory files'));
52
+ let didMoveInventory = false;
53
+ for (const oldInventoryFile of oldInventoryFiles) {
54
+ const environment = (0, paths_1.getEnvironmentNameFromOldInventoryPath)(oldInventoryFile);
55
+ didMoveInventory =
56
+ moveFileIfDestinationMissing(oldInventoryFile, (0, paths_1.getEnvironmentInventoryPath)(environment)) || didMoveInventory;
57
+ }
58
+ try {
59
+ if ((0, fs_1.existsSync)(paths_1.OLD_INVENTORY_DIR) &&
60
+ (0, fs_1.readdirSync)(paths_1.OLD_INVENTORY_DIR).length === 0) {
61
+ (0, fs_1.rmdirSync)(paths_1.OLD_INVENTORY_DIR);
62
+ (0, logger_1.log)(` ✓ Removed empty ${paths_1.OLD_INVENTORY_DIR}`);
63
+ }
64
+ }
65
+ catch (_a) {
66
+ (0, logger_1.warn)(`⚠️ Could not remove ${paths_1.OLD_INVENTORY_DIR}; please review it manually`);
67
+ }
68
+ return didMoveInventory;
69
+ }
70
+ function upgradeEnvironmentLayout() {
71
+ return __awaiter(this, void 0, void 0, function* () {
72
+ const didMoveInventory = migrateInventoryFiles();
73
+ yield (0, update_workflows_1.updateWorkflowEnvironments)();
74
+ if (didMoveInventory) {
75
+ (0, logger_1.success)('\n✅ Environment layout upgrade completed successfully.');
76
+ }
77
+ else {
78
+ (0, logger_1.success)('\n✅ Environment layout already uses the current structure.');
79
+ }
80
+ (0, logger_1.log)('\nCommit changes into git after upgrade');
81
+ });
82
+ }
@@ -25,13 +25,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
25
25
  }) : function(o, v) {
26
26
  o["default"] = v;
27
27
  });
28
- var __importStar = (this && this.__importStar) || function (mod) {
29
- if (mod && mod.__esModule) return mod;
30
- var result = {};
31
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
32
- __setModuleDefault(result, mod);
33
- return result;
34
- };
28
+ var __importStar = (this && this.__importStar) || (function () {
29
+ var ownKeys = function(o) {
30
+ ownKeys = Object.getOwnPropertyNames || function (o) {
31
+ var ar = [];
32
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
33
+ return ar;
34
+ };
35
+ return ownKeys(o);
36
+ };
37
+ return function (mod) {
38
+ if (mod && mod.__esModule) return mod;
39
+ var result = {};
40
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
41
+ __setModuleDefault(result, mod);
42
+ return result;
43
+ };
44
+ })();
35
45
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
36
46
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
37
47
  return new (P || (P = Promise))(function (resolve, reject) {
@@ -52,6 +62,7 @@ const path = __importStar(require("path"));
52
62
  const kleur_1 = __importDefault(require("kleur"));
53
63
  const manage_users_1 = require("./manage-users");
54
64
  const logger_1 = require("./logger");
65
+ const paths_1 = require("./paths");
55
66
  function select(options) {
56
67
  return __awaiter(this, void 0, void 0, function* () {
57
68
  const inquirer = yield import('@inquirer/prompts');
@@ -66,32 +77,29 @@ function select(options) {
66
77
  * * @returns {string} Inventory file
67
78
  */
68
79
  function selectInventoryFile() {
69
- return __awaiter(this, arguments, void 0, function* (dirPath = './infrastructure/server-setup/inventory/') {
80
+ return __awaiter(this, arguments, void 0, function* (dirPath = './environments') {
70
81
  // Check if directory exists
71
82
  if (!fs.existsSync(dirPath)) {
72
83
  (0, logger_1.warn)(`⚠️ No environment configuration directory found at ${dirPath}`);
73
84
  (0, logger_1.warn)('Hint: If this is a new infrastructure repository, run `opencrvs environment init` first.');
74
85
  return null;
75
86
  }
76
- // Read and filter files
77
- const files = fs
87
+ const environments = fs
78
88
  .readdirSync(dirPath)
79
- .filter((file) => {
80
- const filePath = path.join(dirPath, file);
81
- const isFile = fs.statSync(filePath).isFile();
82
- const ext = path.extname(file).slice(1).toLowerCase();
83
- return isFile && (ext === 'yml' || ext === 'yaml');
89
+ .filter((entry) => {
90
+ const filePath = path.join(dirPath, entry);
91
+ return (fs.statSync(filePath).isDirectory() &&
92
+ fs.existsSync((0, paths_1.getEnvironmentInventoryPath)(entry)));
84
93
  })
85
94
  .sort();
86
- if (files.length === 0) {
95
+ if (environments.length === 0) {
87
96
  (0, logger_1.warn)(`⚠️ No environment configuration files found at ${dirPath}`);
88
97
  (0, logger_1.warn)('Hint: If this is a new infrastructure repository, run `opencrvs environment init` first.');
89
98
  return null;
90
99
  }
91
- // Create choices - remove extension from display
92
- const choices = files.map((file) => ({
93
- name: path.basename(file, path.extname(file)),
94
- value: path.join(dirPath, file)
100
+ const choices = environments.map((environment) => ({
101
+ name: environment,
102
+ value: (0, paths_1.getEnvironmentInventoryPath)(environment)
95
103
  }));
96
104
  const selectedFile = yield select({
97
105
  message: 'Select environment (inventory file) to load users:',
@@ -1,7 +1,7 @@
1
1
  import { Secret, Variable } from './github';
2
2
  import { Answers } from './custom-types';
3
3
  export declare function generateLongPassword(): string;
4
- export declare function findExistingValue<T extends string>(name: string, type: T, scope: 'ENVIRONMENT' | 'REPOSITORY', existingValues: Array<Secret | Variable>): (T extends "SECRET" ? Secret : T extends "VARIABLE" ? Variable : never) | undefined;
4
+ export declare function findExistingValue<T extends string>(name: string, type: T, scope: 'ENVIRONMENT' | 'REPOSITORY', existingValues: Array<Secret | Variable>): (T extends 'SECRET' ? Secret : T extends 'VARIABLE' ? Variable : never) | undefined;
5
5
  /**
6
6
  * Merges and stores secrets in `.env.{environment}` file.
7
7
  * Updates existing variables, preserves unchanged ones, adds new ones.
@@ -25,13 +25,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
25
25
  }) : function(o, v) {
26
26
  o["default"] = v;
27
27
  });
28
- var __importStar = (this && this.__importStar) || function (mod) {
29
- if (mod && mod.__esModule) return mod;
30
- var result = {};
31
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
32
- __setModuleDefault(result, mod);
33
- return result;
34
- };
28
+ var __importStar = (this && this.__importStar) || (function () {
29
+ var ownKeys = function(o) {
30
+ ownKeys = Object.getOwnPropertyNames || function (o) {
31
+ var ar = [];
32
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
33
+ return ar;
34
+ };
35
+ return ownKeys(o);
36
+ };
37
+ return function (mod) {
38
+ if (mod && mod.__esModule) return mod;
39
+ var result = {};
40
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
41
+ __setModuleDefault(result, mod);
42
+ return result;
43
+ };
44
+ })();
35
45
  var __importDefault = (this && this.__importDefault) || function (mod) {
36
46
  return (mod && mod.__esModule) ? mod : { "default": mod };
37
47
  };
@@ -59,8 +59,8 @@ export declare function field(fieldId: string): {
59
59
  fieldId: string;
60
60
  type: "dateRange";
61
61
  options: {
62
- days: number;
63
62
  pivot?: number | undefined;
63
+ days: number;
64
64
  boost?: number | undefined;
65
65
  matchAgainst?: string | undefined;
66
66
  };