@opencrvs/toolkit 2.0.1 → 2.1.0-beta

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 (170) hide show
  1. package/README.md +16 -0
  2. package/build.sh +14 -5
  3. package/create-countryconfig/index.js +293 -103
  4. package/create-countryconfig/node_modules/.bin/degit +21 -0
  5. package/create-countryconfig/package.json +5 -2
  6. package/dist/application-config/index.js +369 -282
  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 +4343 -4788
  11. package/dist/commons/api/router.d.ts +4120 -2946
  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 +302 -71
  16. package/dist/commons/events/ActionDocument.d.ts +159 -121
  17. package/dist/commons/events/ActionInput.d.ts +30 -10
  18. package/dist/commons/events/ActionStatus.d.ts +14 -0
  19. package/dist/commons/events/ActionType.d.ts +63 -58
  20. package/dist/commons/events/AdvancedSearchConfig.d.ts +531 -501
  21. package/dist/commons/events/AuditLog.d.ts +189 -40
  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 +603 -561
  25. package/dist/commons/events/Draft.d.ts +38 -36
  26. package/dist/commons/events/DynamicFieldValue.d.ts +9 -9
  27. package/dist/commons/events/EventConfig.d.ts +8 -3
  28. package/dist/commons/events/EventDocument.d.ts +537 -47
  29. package/dist/commons/events/EventIndex.d.ts +61 -59
  30. package/dist/commons/events/EventMetadata.d.ts +59 -43
  31. package/dist/commons/events/EventStatus.d.ts +19 -0
  32. package/dist/commons/events/FieldConfig.d.ts +424 -384
  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 +0 -6
  38. package/dist/commons/events/PageConfig.d.ts +0 -4
  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 +835 -790
  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 +248 -14
  50. package/dist/commons/events/mocks.test.utils.d.ts +48 -4
  51. package/dist/commons/events/scopes.d.ts +5 -4
  52. package/dist/commons/events/state/index.d.ts +23 -15
  53. package/dist/commons/events/state/utils.d.ts +15 -6
  54. package/dist/commons/events/test.utils.d.ts +68 -42
  55. package/dist/commons/events/utils.d.ts +139 -110
  56. package/dist/commons/notification/UserNotifications.d.ts +38 -18
  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 +341 -68
  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/custom-types.d.ts +33 -0
  64. package/dist/environment/custom-types.d.ts.map +1 -0
  65. package/dist/environment/custom-types.js +12 -0
  66. package/dist/environment/derived-variables.d.ts +122 -0
  67. package/dist/environment/derived-variables.d.ts.map +1 -0
  68. package/dist/environment/derived-variables.js +155 -0
  69. package/dist/environment/editor-questions.d.ts +4 -0
  70. package/dist/environment/editor-questions.d.ts.map +1 -0
  71. package/dist/environment/editor-questions.js +67 -0
  72. package/dist/environment/git.d.ts +5 -0
  73. package/dist/environment/git.d.ts.map +1 -0
  74. package/dist/environment/git.js +38 -0
  75. package/dist/environment/github.d.ts +26 -0
  76. package/dist/environment/github.d.ts.map +1 -0
  77. package/dist/environment/github.js +247 -0
  78. package/dist/environment/index.d.ts +6 -0
  79. package/dist/environment/index.d.ts.map +1 -0
  80. package/dist/environment/index.js +81 -0
  81. package/dist/environment/logger.d.ts +18 -0
  82. package/dist/environment/logger.d.ts.map +1 -0
  83. package/dist/environment/logger.js +25 -0
  84. package/dist/environment/manage-users.d.ts +11 -0
  85. package/dist/environment/manage-users.d.ts.map +1 -0
  86. package/dist/environment/manage-users.js +507 -0
  87. package/dist/environment/paths.d.ts +7 -0
  88. package/dist/environment/paths.d.ts.map +1 -0
  89. package/dist/environment/paths.js +72 -0
  90. package/dist/environment/questions-helper.d.ts +15 -0
  91. package/dist/environment/questions-helper.d.ts.map +1 -0
  92. package/dist/environment/questions-helper.js +70 -0
  93. package/dist/environment/questions.d.ts +200 -0
  94. package/dist/environment/questions.d.ts.map +1 -0
  95. package/dist/environment/questions.js +418 -0
  96. package/dist/environment/setup-environment.d.ts +2 -0
  97. package/dist/environment/setup-environment.d.ts.map +1 -0
  98. package/dist/environment/setup-environment.js +795 -0
  99. package/dist/environment/ssh-keygen.d.ts +5 -0
  100. package/dist/environment/ssh-keygen.d.ts.map +1 -0
  101. package/dist/environment/ssh-keygen.js +21 -0
  102. package/dist/environment/swarm-to-k8s.d.ts +2 -0
  103. package/dist/environment/swarm-to-k8s.d.ts.map +1 -0
  104. package/dist/environment/swarm-to-k8s.js +183 -0
  105. package/dist/environment/templates.d.ts +27 -0
  106. package/dist/environment/templates.d.ts.map +1 -0
  107. package/dist/environment/templates.js +164 -0
  108. package/dist/environment/update-workflows.d.ts +2 -0
  109. package/dist/environment/update-workflows.d.ts.map +1 -0
  110. package/dist/environment/update-workflows.js +191 -0
  111. package/dist/environment/upgrade.d.ts +2 -0
  112. package/dist/environment/upgrade.d.ts.map +1 -0
  113. package/dist/environment/upgrade.js +82 -0
  114. package/dist/environment/users.d.ts +2 -0
  115. package/dist/environment/users.d.ts.map +1 -0
  116. package/dist/environment/users.js +120 -0
  117. package/dist/environment/utils.d.ts +18 -0
  118. package/dist/environment/utils.d.ts.map +1 -0
  119. package/dist/environment/utils.js +110 -0
  120. package/dist/events/deduplication.d.ts +1 -1
  121. package/dist/events/index.js +8104 -7408
  122. package/dist/migrations/v2.0/checkout-upstream-files.d.ts +2 -2
  123. package/dist/migrations/v2.0/checkout-upstream-files.d.ts.map +1 -1
  124. package/dist/migrations/v2.0/checkout-upstream-files.js +2 -2
  125. package/dist/migrations/v2.0/convert-config-files-to-ts.js +17 -7
  126. package/dist/migrations/v2.0/index.js +88 -5143
  127. package/dist/migrations/v2.0/merge-infrastructure-directory.js +3 -3
  128. package/dist/migrations/v2.0/migrate-application-config-url.js +4 -3
  129. package/dist/migrations/v2.0/remove-hearth-migrations.js +17 -7
  130. package/dist/migrations/v2.1/add-explicit-correction-flags.d.ts +3 -0
  131. package/dist/migrations/v2.1/add-explicit-correction-flags.d.ts.map +1 -0
  132. package/dist/migrations/v2.1/add-explicit-correction-flags.js +234 -0
  133. package/dist/migrations/v2.1/add-recovery-link-notifications.d.ts +3 -0
  134. package/dist/migrations/v2.1/add-recovery-link-notifications.d.ts.map +1 -0
  135. package/dist/migrations/v2.1/add-recovery-link-notifications.js +511 -0
  136. package/dist/migrations/v2.1/add-translations.d.ts +9 -0
  137. package/dist/migrations/v2.1/add-translations.d.ts.map +1 -0
  138. package/dist/migrations/v2.1/add-translations.js +213 -0
  139. package/dist/migrations/v2.1/enable-telemetry.d.ts +3 -0
  140. package/dist/migrations/v2.1/enable-telemetry.d.ts.map +1 -0
  141. package/dist/migrations/v2.1/enable-telemetry.js +438 -0
  142. package/dist/migrations/v2.1/index.d.ts +6 -0
  143. package/dist/migrations/v2.1/index.d.ts.map +1 -0
  144. package/dist/migrations/v2.1/index.js +1276 -0
  145. package/dist/notification/index.js +2010 -1451
  146. package/dist/scopes/index.d.ts +512 -231
  147. package/dist/scopes/index.js +342 -68
  148. package/dist/telemetry/index.d.ts +45 -0
  149. package/dist/telemetry/index.d.ts.map +1 -0
  150. package/dist/telemetry/index.js +39 -0
  151. package/dist/templates/charts-values/dependencies/values.override.yaml +4 -0
  152. package/dist/templates/charts-values/dependencies/values.yaml +82 -0
  153. package/dist/templates/charts-values/opencrvs-services/values.override.yaml +4 -0
  154. package/dist/templates/charts-values/opencrvs-services/values.yaml +78 -0
  155. package/dist/templates/charts-values/opentelemetry/values.yaml +95 -0
  156. package/dist/templates/charts-values/traefik/values.override.yaml +4 -0
  157. package/dist/templates/charts-values/traefik/values.yaml +129 -0
  158. package/dist/templates/inventory/inventory.template.yml +98 -0
  159. package/dist/translations/check.d.ts +19 -0
  160. package/dist/translations/check.d.ts.map +1 -0
  161. package/dist/translations/check.js +127 -0
  162. package/dist/verify/endpoints.d.ts.map +1 -1
  163. package/dist/verify/endpoints.js +25 -25
  164. package/opencrvs-toolkit-2.1.0-beta.tgz +0 -0
  165. package/package.json +25 -6
  166. package/tsconfig.build.json +11 -0
  167. package/tsconfig.build.tsbuildinfo +1 -0
  168. package/tsconfig.json +3 -0
  169. package/opencrvs-toolkit-2.0.1.tgz +0 -0
  170. 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
+ }
@@ -0,0 +1,2 @@
1
+ export declare function manageEnvironmentUsers(): Promise<void>;
2
+ //# sourceMappingURL=users.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"users.d.ts","sourceRoot":"","sources":["../../src/environment/users.ts"],"names":[],"mappings":"AA4EA,wBAAsB,sBAAsB,kBAO3C"}
@@ -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
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
13
+ if (k2 === undefined) k2 = k;
14
+ var desc = Object.getOwnPropertyDescriptor(m, k);
15
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
16
+ desc = { enumerable: true, get: function() { return m[k]; } };
17
+ }
18
+ Object.defineProperty(o, k2, desc);
19
+ }) : (function(o, m, k, k2) {
20
+ if (k2 === undefined) k2 = k;
21
+ o[k2] = m[k];
22
+ }));
23
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
24
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
25
+ }) : function(o, v) {
26
+ o["default"] = v;
27
+ });
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
+ })();
45
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
46
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
47
+ return new (P || (P = Promise))(function (resolve, reject) {
48
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
49
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
50
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
51
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
52
+ });
53
+ };
54
+ var __importDefault = (this && this.__importDefault) || function (mod) {
55
+ return (mod && mod.__esModule) ? mod : { "default": mod };
56
+ };
57
+ Object.defineProperty(exports, "__esModule", { value: true });
58
+ exports.manageEnvironmentUsers = manageEnvironmentUsers;
59
+ const fs = __importStar(require("fs"));
60
+ /* eslint-disable no-console */
61
+ const path = __importStar(require("path"));
62
+ const kleur_1 = __importDefault(require("kleur"));
63
+ const manage_users_1 = require("./manage-users");
64
+ const logger_1 = require("./logger");
65
+ const paths_1 = require("./paths");
66
+ function select(options) {
67
+ return __awaiter(this, void 0, void 0, function* () {
68
+ const inquirer = yield import('@inquirer/prompts');
69
+ return inquirer.select(options);
70
+ });
71
+ }
72
+ /**
73
+ * Allow user to select inventory file (environment from a list)
74
+ *
75
+ * @param {string} dirPath - Path to the inventory file
76
+ *
77
+ * * @returns {string} Inventory file
78
+ */
79
+ function selectInventoryFile() {
80
+ return __awaiter(this, arguments, void 0, function* (dirPath = './environments') {
81
+ // Check if directory exists
82
+ if (!fs.existsSync(dirPath)) {
83
+ (0, logger_1.warn)(`⚠️ No environment configuration directory found at ${dirPath}`);
84
+ (0, logger_1.warn)('Hint: If this is a new infrastructure repository, run `opencrvs environment init` first.');
85
+ return null;
86
+ }
87
+ const environments = fs
88
+ .readdirSync(dirPath)
89
+ .filter((entry) => {
90
+ const filePath = path.join(dirPath, entry);
91
+ return (fs.statSync(filePath).isDirectory() &&
92
+ fs.existsSync((0, paths_1.getEnvironmentInventoryPath)(entry)));
93
+ })
94
+ .sort();
95
+ if (environments.length === 0) {
96
+ (0, logger_1.warn)(`⚠️ No environment configuration files found at ${dirPath}`);
97
+ (0, logger_1.warn)('Hint: If this is a new infrastructure repository, run `opencrvs environment init` first.');
98
+ return null;
99
+ }
100
+ const choices = environments.map((environment) => ({
101
+ name: environment,
102
+ value: (0, paths_1.getEnvironmentInventoryPath)(environment)
103
+ }));
104
+ const selectedFile = yield select({
105
+ message: 'Select environment (inventory file) to load users:',
106
+ choices: choices
107
+ });
108
+ return selectedFile;
109
+ });
110
+ }
111
+ function manageEnvironmentUsers() {
112
+ return __awaiter(this, void 0, void 0, function* () {
113
+ console.log('\n', kleur_1.default.bold().underline('Manage users'), '\n');
114
+ const inventory_file = yield selectInventoryFile();
115
+ if (!inventory_file) {
116
+ return;
117
+ }
118
+ yield (0, manage_users_1.manageUsers)(inventory_file);
119
+ });
120
+ }
@@ -0,0 +1,18 @@
1
+ import { Secret, Variable } from './github';
2
+ import { Answers } from './custom-types';
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;
5
+ /**
6
+ * Merges and stores secrets in `.env.{environment}` file.
7
+ * Updates existing variables, preserves unchanged ones, adds new ones.
8
+ *
9
+ * @param environment - Environment name (e.g., 'production')
10
+ * @param answers - Variables to update: `[{ name: 'KEY', value: 'val' }]`
11
+ *
12
+ * @example
13
+ * storeSecrets('prod', [{ name: 'API_KEY', value: 'abc123' }]);
14
+ */
15
+ export declare function storeSecrets(environment: string, answers: Answers): void;
16
+ export declare function readYamlFile(filePath: any): any;
17
+ export declare function writeYamlFile(filePath: string, data: any): void;
18
+ //# sourceMappingURL=utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/environment/utils.ts"],"names":[],"mappings":"AAeA,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAA;AAC3C,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAA;AAExC,wBAAgB,oBAAoB,WAMnC;AAED,wBAAgB,iBAAiB,CAAC,CAAC,SAAS,MAAM,EAChD,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,CAAC,EACP,KAAK,EAAE,aAAa,GAAG,YAAY,EACnC,cAAc,EAAE,KAAK,CAAC,MAAM,GAAG,QAAQ,CAAC,GAMpC,CAAC,CAAC,SAAS,QAAQ,GAAG,MAAM,GAAG,CAAC,SAAS,UAAU,GAAG,QAAQ,GAAG,KAAK,CAAC,GACvE,SAAS,CACd;AAED;;;;;;;;;GASG;AACH,wBAAgB,YAAY,CAAC,WAAW,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,QAoBjE;AAED,wBAAgB,YAAY,CAAC,QAAQ,EAAE,GAAG,GAAG,GAAG,CAG/C;AAED,wBAAgB,aAAa,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,QAcxD"}
@@ -0,0 +1,110 @@
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 __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
13
+ if (k2 === undefined) k2 = k;
14
+ var desc = Object.getOwnPropertyDescriptor(m, k);
15
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
16
+ desc = { enumerable: true, get: function() { return m[k]; } };
17
+ }
18
+ Object.defineProperty(o, k2, desc);
19
+ }) : (function(o, m, k, k2) {
20
+ if (k2 === undefined) k2 = k;
21
+ o[k2] = m[k];
22
+ }));
23
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
24
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
25
+ }) : function(o, v) {
26
+ o["default"] = v;
27
+ });
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
+ })();
45
+ var __importDefault = (this && this.__importDefault) || function (mod) {
46
+ return (mod && mod.__esModule) ? mod : { "default": mod };
47
+ };
48
+ Object.defineProperty(exports, "__esModule", { value: true });
49
+ exports.generateLongPassword = generateLongPassword;
50
+ exports.findExistingValue = findExistingValue;
51
+ exports.storeSecrets = storeSecrets;
52
+ exports.readYamlFile = readYamlFile;
53
+ exports.writeYamlFile = writeYamlFile;
54
+ const fs_1 = __importStar(require("fs"));
55
+ const yaml = __importStar(require("js-yaml"));
56
+ const dotenv_1 = __importDefault(require("dotenv"));
57
+ function generateLongPassword() {
58
+ const chars = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
59
+ let result = '';
60
+ for (let i = 16; i > 0; --i)
61
+ result += chars[Math.floor(Math.random() * chars.length)];
62
+ return result;
63
+ }
64
+ function findExistingValue(name, type, scope, existingValues) {
65
+ return existingValues.find((value) => value.name === name && value.type === type && value.scope === scope);
66
+ }
67
+ /**
68
+ * Merges and stores secrets in `.env.{environment}` file.
69
+ * Updates existing variables, preserves unchanged ones, adds new ones.
70
+ *
71
+ * @param environment - Environment name (e.g., 'production')
72
+ * @param answers - Variables to update: `[{ name: 'KEY', value: 'val' }]`
73
+ *
74
+ * @example
75
+ * storeSecrets('prod', [{ name: 'API_KEY', value: 'abc123' }]);
76
+ */
77
+ function storeSecrets(environment, answers) {
78
+ let envConfig = {};
79
+ try {
80
+ envConfig = dotenv_1.default.parse((0, fs_1.readFileSync)(`${process.cwd()}/.env.${environment}`));
81
+ }
82
+ catch (error) {
83
+ envConfig = {};
84
+ }
85
+ const linesFromAnswers = answers.map((update) => `${update.name}="${update.value}"`);
86
+ const linesFromEnvConfig = Object.entries(envConfig)
87
+ .filter(([name]) => !answers.find((update) => update.name === name))
88
+ .map(([name, value]) => `${name}="${value}"`);
89
+ const allLines = [...linesFromEnvConfig, ...linesFromAnswers].sort();
90
+ (0, fs_1.writeFileSync)(`.env.${environment}`, allLines.join('\n'));
91
+ }
92
+ function readYamlFile(filePath) {
93
+ const fileContent = fs_1.default.readFileSync(filePath, 'utf8');
94
+ return yaml.load(fileContent);
95
+ }
96
+ function writeYamlFile(filePath, data) {
97
+ try {
98
+ const yamlContent = yaml.dump(data, {
99
+ indent: 2,
100
+ lineWidth: -1,
101
+ flowLevel: -1, // Prevent flow style for arrays/objects
102
+ noRefs: true,
103
+ sortKeys: false
104
+ });
105
+ fs_1.default.writeFileSync(filePath, yamlContent, 'utf8');
106
+ }
107
+ catch (error) {
108
+ throw new Error(`Failed to write inventory file: ${error}`);
109
+ }
110
+ }
@@ -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
  };