@opencrvs/toolkit 2.1.0-rc.12673aa → 2.1.0-rc.14fb6a5

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 (188) hide show
  1. package/build.sh +14 -4
  2. package/create-countryconfig/index.js +59 -30
  3. package/dist/application-config/index.js +26 -13
  4. package/dist/authentication/index.d.ts +8 -9
  5. package/dist/authentication/index.js +23 -8
  6. package/dist/cli.js +2268 -1385
  7. package/dist/commons/api/router.d.ts +252 -290
  8. package/dist/commons/application-config/index.d.ts +0 -2
  9. package/dist/commons/conditionals/conditionals.d.ts +6 -6
  10. package/dist/commons/conditionals/validate.d.ts +18 -3
  11. package/dist/commons/events/ActionConfig.d.ts +5 -14
  12. package/dist/commons/events/ActionDocument.d.ts +30 -4
  13. package/dist/commons/events/AdvancedSearchConfig.d.ts +24 -12
  14. package/dist/commons/events/AuditLog.d.ts +1 -0
  15. package/dist/commons/events/Draft.d.ts +1 -21
  16. package/dist/commons/events/EventDocument.d.ts +4 -4
  17. package/dist/commons/events/FieldConfig.d.ts +20 -10
  18. package/dist/commons/events/FieldTypeMapping.d.ts +10 -10
  19. package/dist/commons/events/FieldValue.d.ts +1 -0
  20. package/dist/commons/events/FormConfig.d.ts +6 -0
  21. package/dist/commons/events/PageConfig.d.ts +4 -0
  22. package/dist/commons/events/scopes.d.ts +21 -1
  23. package/dist/commons/events/test.utils.d.ts +53 -21
  24. package/dist/commons/events/utils.d.ts +26 -2
  25. package/dist/conditionals/index.js +21 -7
  26. package/dist/environment/index.d.ts.map +1 -1
  27. package/dist/environment/index.js +2 -1
  28. package/dist/environment/setup-environment.d.ts +1 -1
  29. package/dist/environment/setup-environment.d.ts.map +1 -1
  30. package/dist/environment/setup-environment.js +586 -569
  31. package/dist/environment/swarm-to-k8s.js +3 -4
  32. package/dist/events/index.js +282 -138
  33. package/dist/migrations/v2.1/add-recovery-link-notifications.js +4 -4
  34. package/dist/migrations/v2.1/add-translations.d.ts.map +1 -1
  35. package/dist/migrations/v2.1/add-translations.js +4 -68
  36. package/dist/migrations/v2.1/enable-telemetry.d.ts.map +1 -1
  37. package/dist/migrations/v2.1/enable-telemetry.js +30 -13
  38. package/dist/migrations/v2.1/index.d.ts.map +1 -1
  39. package/dist/migrations/v2.1/index.js +927 -33
  40. package/dist/migrations/v2.1/migrate-infrastructure-to-assets.d.ts +14 -0
  41. package/dist/migrations/v2.1/migrate-infrastructure-to-assets.d.ts.map +1 -0
  42. package/dist/migrations/v2.1/migrate-infrastructure-to-assets.js +348 -0
  43. package/dist/migrations/v2.1/remove-metabase-package-installs.d.ts +2 -0
  44. package/dist/migrations/v2.1/remove-metabase-package-installs.d.ts.map +1 -0
  45. package/dist/migrations/v2.1/remove-metabase-package-installs.js +161 -0
  46. package/dist/migrations/{v2.0/migrate-scopes.d.ts → v2.1/remove-sentry.d.ts} +1 -1
  47. package/dist/migrations/v2.1/remove-sentry.d.ts.map +1 -0
  48. package/dist/migrations/v2.1/remove-sentry.js +354 -0
  49. package/dist/migrations/{v2.0/rename-api-paths.d.ts → v2.1/rename-trigger-paths.d.ts} +1 -1
  50. package/dist/migrations/v2.1/rename-trigger-paths.d.ts.map +1 -0
  51. package/dist/migrations/{v2.0/rename-api-paths.js → v2.1/rename-trigger-paths.js} +69 -40
  52. package/dist/migrations/v2.1/template-files.d.ts +8 -0
  53. package/dist/migrations/v2.1/template-files.d.ts.map +1 -0
  54. package/dist/migrations/v2.1/template-files.js +49 -0
  55. package/dist/migrations/v2.1/upgrade-tilt.d.ts +8 -0
  56. package/dist/migrations/v2.1/upgrade-tilt.d.ts.map +1 -0
  57. package/dist/migrations/v2.1/upgrade-tilt.js +139 -0
  58. package/dist/notification/index.js +105 -61
  59. package/dist/scopes/index.d.ts +288 -5
  60. package/dist/scopes/index.js +22 -7
  61. package/dist/telemetry/index.js +4 -0
  62. package/dist/templates/charts-values/dependencies/values.yaml +6 -0
  63. package/dist/templates/charts-values/opencrvs-services/values.yaml +6 -0
  64. package/dist/templates/charts-values/opentelemetry/values.yaml +7 -0
  65. package/dist/templates/countryconfig-template/.tiltignore +1 -0
  66. package/dist/templates/countryconfig-template/Dockerfile.assets +7 -0
  67. package/dist/templates/countryconfig-template/Tiltfile +112 -0
  68. package/dist/templates/countryconfig-template/assets/README.md +1 -0
  69. package/dist/templates/countryconfig-template/assets/clear-all-data-dev.sh +61 -0
  70. package/dist/templates/countryconfig-template/assets/deployment/deploy.sh +455 -0
  71. package/dist/templates/countryconfig-template/assets/deployment/reindex.sh +168 -0
  72. package/dist/templates/countryconfig-template/assets/deployment/validate-required-variables-in-compose-files.ts +67 -0
  73. package/dist/templates/countryconfig-template/assets/elasticsearch/reindex.sh +168 -0
  74. package/dist/templates/countryconfig-template/assets/metabase/README.md +34 -0
  75. package/dist/templates/countryconfig-template/assets/metabase/environment-configuration.sql +36 -0
  76. package/dist/templates/countryconfig-template/assets/metabase/initialize-database.sh +46 -0
  77. package/dist/templates/countryconfig-template/assets/metabase/metabase.init.db.sql +27737 -0
  78. package/dist/templates/countryconfig-template/assets/metabase/open-shell.sh +21 -0
  79. package/dist/templates/countryconfig-template/assets/metabase/package.json +13 -0
  80. package/dist/templates/countryconfig-template/assets/metabase/run-dev.sh +108 -0
  81. package/dist/templates/countryconfig-template/assets/metabase/run.sh +120 -0
  82. package/dist/templates/countryconfig-template/assets/metabase/update-database.sh +40 -0
  83. package/dist/templates/countryconfig-template/assets/postgres/setup-analytics.sh +135 -0
  84. package/dist/templates/countryconfig-template/assets/postgres/setup-reference-data.sh +108 -0
  85. package/dist/templates/countryconfig-template/tilt/clear-all-data.ps1 +50 -0
  86. package/dist/templates/countryconfig-template/tilt/clear-all-data.sh +35 -0
  87. package/dist/templates/countryconfig-template/tilt/common.tilt +145 -0
  88. package/dist/templates/countryconfig-template/tilt/examples/dependencies/values.yaml +15 -0
  89. package/dist/templates/countryconfig-template/tilt/examples/opencrvs-services/values.yaml +56 -0
  90. package/dist/templates/countryconfig-template/tilt/examples/traefik/values-minikube.yaml +21 -0
  91. package/dist/templates/countryconfig-template/tilt/examples/traefik/values.yaml +38 -0
  92. package/dist/templates/countryconfig-template/tilt/helm/dependencies/values.yaml +17 -0
  93. package/dist/templates/countryconfig-template/tilt/helm/opencrvs-services/values.yaml +16 -0
  94. package/dist/templates/countryconfig-template/tilt/lib.tilt +95 -0
  95. package/dist/templates/countryconfig-template/tilt/opencrvs.tilt +136 -0
  96. package/dist/translations/template.d.ts +11 -0
  97. package/dist/translations/template.d.ts.map +1 -0
  98. package/dist/translations/template.js +100 -0
  99. package/dist/verify/endpoints.d.ts.map +1 -1
  100. package/dist/verify/endpoints.js +179 -14
  101. package/opencrvs-toolkit-2.1.0-rc.14fb6a5.tgz +0 -0
  102. package/package.json +2 -1
  103. package/tsconfig.build.tsbuildinfo +1 -1
  104. package/dist/migrations/v2.0/add-birth-certificate-issuance-flag.d.ts +0 -3
  105. package/dist/migrations/v2.0/add-birth-certificate-issuance-flag.d.ts.map +0 -1
  106. package/dist/migrations/v2.0/add-birth-certificate-issuance-flag.js +0 -429
  107. package/dist/migrations/v2.0/add-resend-invite-notification.d.ts +0 -3
  108. package/dist/migrations/v2.0/add-resend-invite-notification.d.ts.map +0 -1
  109. package/dist/migrations/v2.0/add-resend-invite-notification.js +0 -373
  110. package/dist/migrations/v2.0/checkout-upstream-files.d.ts +0 -22
  111. package/dist/migrations/v2.0/checkout-upstream-files.d.ts.map +0 -1
  112. package/dist/migrations/v2.0/checkout-upstream-files.js +0 -146
  113. package/dist/migrations/v2.0/convert-config-files-to-ts.d.ts +0 -2
  114. package/dist/migrations/v2.0/convert-config-files-to-ts.d.ts.map +0 -1
  115. package/dist/migrations/v2.0/convert-config-files-to-ts.js +0 -838
  116. package/dist/migrations/v2.0/convert-paragraph-to-heading.d.ts +0 -3
  117. package/dist/migrations/v2.0/convert-paragraph-to-heading.d.ts.map +0 -1
  118. package/dist/migrations/v2.0/convert-paragraph-to-heading.js +0 -158
  119. package/dist/migrations/v2.0/create-events-index.d.ts +0 -3
  120. package/dist/migrations/v2.0/create-events-index.d.ts.map +0 -1
  121. package/dist/migrations/v2.0/create-events-index.js +0 -325
  122. package/dist/migrations/v2.0/delete-infrastructure-directory.d.ts +0 -11
  123. package/dist/migrations/v2.0/delete-infrastructure-directory.d.ts.map +0 -1
  124. package/dist/migrations/v2.0/delete-infrastructure-directory.js +0 -123
  125. package/dist/migrations/v2.0/fix-accept-requested-registration-function-type.d.ts +0 -3
  126. package/dist/migrations/v2.0/fix-accept-requested-registration-function-type.d.ts.map +0 -1
  127. package/dist/migrations/v2.0/fix-accept-requested-registration-function-type.js +0 -110
  128. package/dist/migrations/v2.0/index.d.ts +0 -13
  129. package/dist/migrations/v2.0/index.d.ts.map +0 -1
  130. package/dist/migrations/v2.0/index.js +0 -103
  131. package/dist/migrations/v2.0/make-built-in-validate-actions-custom.d.ts +0 -3
  132. package/dist/migrations/v2.0/make-built-in-validate-actions-custom.d.ts.map +0 -1
  133. package/dist/migrations/v2.0/make-built-in-validate-actions-custom.js +0 -432
  134. package/dist/migrations/v2.0/merge-infrastructure-directory.d.ts +0 -13
  135. package/dist/migrations/v2.0/merge-infrastructure-directory.d.ts.map +0 -1
  136. package/dist/migrations/v2.0/merge-infrastructure-directory.js +0 -222
  137. package/dist/migrations/v2.0/migrate-application-config-url.d.ts +0 -3
  138. package/dist/migrations/v2.0/migrate-application-config-url.d.ts.map +0 -1
  139. package/dist/migrations/v2.0/migrate-application-config-url.js +0 -343
  140. package/dist/migrations/v2.0/migrate-scopes.d.ts.map +0 -1
  141. package/dist/migrations/v2.0/migrate-scopes.js +0 -305
  142. package/dist/migrations/v2.0/migrate-validated-workqueue-status-to-flag.d.ts +0 -3
  143. package/dist/migrations/v2.0/migrate-validated-workqueue-status-to-flag.d.ts.map +0 -1
  144. package/dist/migrations/v2.0/migrate-validated-workqueue-status-to-flag.js +0 -267
  145. package/dist/migrations/v2.0/migrate-workqueue-configs.d.ts +0 -3
  146. package/dist/migrations/v2.0/migrate-workqueue-configs.d.ts.map +0 -1
  147. package/dist/migrations/v2.0/migrate-workqueue-configs.js +0 -317
  148. package/dist/migrations/v2.0/remove-delete-actions.d.ts +0 -3
  149. package/dist/migrations/v2.0/remove-delete-actions.d.ts.map +0 -1
  150. package/dist/migrations/v2.0/remove-delete-actions.js +0 -156
  151. package/dist/migrations/v2.0/remove-demo-scope.d.ts +0 -3
  152. package/dist/migrations/v2.0/remove-demo-scope.d.ts.map +0 -1
  153. package/dist/migrations/v2.0/remove-demo-scope.js +0 -74
  154. package/dist/migrations/v2.0/remove-deprecated-imports.d.ts +0 -3
  155. package/dist/migrations/v2.0/remove-deprecated-imports.d.ts.map +0 -1
  156. package/dist/migrations/v2.0/remove-deprecated-imports.js +0 -96
  157. package/dist/migrations/v2.0/remove-fhir-url-helpers.d.ts +0 -3
  158. package/dist/migrations/v2.0/remove-fhir-url-helpers.d.ts.map +0 -1
  159. package/dist/migrations/v2.0/remove-fhir-url-helpers.js +0 -163
  160. package/dist/migrations/v2.0/remove-hearth-migrations.d.ts +0 -3
  161. package/dist/migrations/v2.0/remove-hearth-migrations.d.ts.map +0 -1
  162. package/dist/migrations/v2.0/remove-hearth-migrations.js +0 -87
  163. package/dist/migrations/v2.0/remove-old-statistics-service.d.ts +0 -3
  164. package/dist/migrations/v2.0/remove-old-statistics-service.d.ts.map +0 -1
  165. package/dist/migrations/v2.0/remove-old-statistics-service.js +0 -356
  166. package/dist/migrations/v2.0/remove-pending-certification-flag.d.ts +0 -3
  167. package/dist/migrations/v2.0/remove-pending-certification-flag.d.ts.map +0 -1
  168. package/dist/migrations/v2.0/remove-pending-certification-flag.js +0 -109
  169. package/dist/migrations/v2.0/remove-review-from-register-action.d.ts +0 -3
  170. package/dist/migrations/v2.0/remove-review-from-register-action.d.ts.map +0 -1
  171. package/dist/migrations/v2.0/remove-review-from-register-action.js +0 -163
  172. package/dist/migrations/v2.0/remove-unused-environment-variables.d.ts +0 -3
  173. package/dist/migrations/v2.0/remove-unused-environment-variables.d.ts.map +0 -1
  174. package/dist/migrations/v2.0/remove-unused-environment-variables.js +0 -186
  175. package/dist/migrations/v2.0/rename-api-paths.d.ts.map +0 -1
  176. package/dist/migrations/v2.0/rename-location-parent-id.d.ts +0 -3
  177. package/dist/migrations/v2.0/rename-location-parent-id.d.ts.map +0 -1
  178. package/dist/migrations/v2.0/rename-location-parent-id.js +0 -180
  179. package/dist/migrations/v2.0/simplify-analytics-precalculations.d.ts +0 -3
  180. package/dist/migrations/v2.0/simplify-analytics-precalculations.d.ts.map +0 -1
  181. package/dist/migrations/v2.0/simplify-analytics-precalculations.js +0 -195
  182. package/dist/migrations/v2.0/update-package-json.d.ts +0 -3
  183. package/dist/migrations/v2.0/update-package-json.d.ts.map +0 -1
  184. package/dist/migrations/v2.0/update-package-json.js +0 -105
  185. package/dist/translations/check.d.ts +0 -21
  186. package/dist/translations/check.d.ts.map +0 -1
  187. package/dist/translations/check.js +0 -132
  188. package/opencrvs-toolkit-2.1.0-rc.12673aa.tgz +0 -0
@@ -1,3 +0,0 @@
1
- declare function main(): Promise<void>;
2
- export { main };
3
- //# sourceMappingURL=remove-fhir-url-helpers.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"remove-fhir-url-helpers.d.ts","sourceRoot":"","sources":["../../../src/migrations/v2.0/remove-fhir-url-helpers.ts"],"names":[],"mappings":"AAiHA,iBAAe,IAAI,kBAyElB;AAED,OAAO,EAAE,IAAI,EAAE,CAAA"}
@@ -1,163 +0,0 @@
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.main = main;
26
- /**
27
- * Codemod: remove legacy FHIR URL helpers after `FHIR_URL` env cleanup.
28
- *
29
- * Targets:
30
- * - `FHIR_URL` named imports
31
- * - functions: `getFromFhir`, `updateResourceFromHearth`, `updateResourceInHearth`
32
- *
33
- * What it does:
34
- * 1. Removes top-level declarations with one of the helper names.
35
- * Supported declaration forms:
36
- * - `function getFromFhir(...) {}`
37
- * - `const getFromFhir = (...) => {}`
38
- * - `export const getFromFhir = (...) => {}`
39
- * 2. Removes `FHIR_URL` named imports from any import declaration.
40
- * Empty import declarations are dropped.
41
- * 3. Reports any remaining `FHIR_URL` identifier references so developers
42
- * can manually clean up unusual patterns.
43
- */
44
- const path_1 = __importDefault(require("path"));
45
- const ts_morph_1 = require("ts-morph");
46
- const FHIR_IMPORT = 'FHIR_URL';
47
- const HELPER_NAMES = new Set([
48
- 'getFromFhir',
49
- 'updateResourceFromHearth',
50
- 'updateResourceInHearth'
51
- ]);
52
- function removeHelpers(sourceFilePath, project) {
53
- const sourceFile = project.getSourceFile(sourceFilePath);
54
- if (!sourceFile) {
55
- return {
56
- removedHelpers: [],
57
- removedImportCount: 0,
58
- remainingFhirReferences: 0
59
- };
60
- }
61
- const removedHelpers = [];
62
- let removedImportCount = 0;
63
- // Function declarations: `function getFromFhir(...) { ... }`
64
- for (const fn of sourceFile.getFunctions()) {
65
- const name = fn.getName();
66
- if (!name || !HELPER_NAMES.has(name))
67
- continue;
68
- removedHelpers.push(name);
69
- fn.remove();
70
- }
71
- // Variable declarations: `const getFromFhir = ...`
72
- for (const stmt of [...sourceFile.getVariableStatements()]) {
73
- const declarations = [...stmt.getDeclarations()];
74
- const toRemove = declarations.filter((decl) => HELPER_NAMES.has(decl.getName()));
75
- if (toRemove.length === 0)
76
- continue;
77
- removedHelpers.push(...toRemove.map((decl) => decl.getName()));
78
- if (toRemove.length === declarations.length) {
79
- stmt.remove();
80
- }
81
- else {
82
- for (const decl of toRemove)
83
- decl.remove();
84
- }
85
- }
86
- // Remove FHIR_URL named imports.
87
- for (const decl of sourceFile.getImportDeclarations()) {
88
- const matches = decl
89
- .getNamedImports()
90
- .filter((ni) => ni.getName() === FHIR_IMPORT);
91
- if (matches.length === 0)
92
- continue;
93
- for (const named of matches) {
94
- named.remove();
95
- removedImportCount++;
96
- }
97
- const hasAnyNamedImportsLeft = decl.getNamedImports().length > 0;
98
- const hasDefaultImport = !!decl.getDefaultImport();
99
- const hasNamespaceImport = !!decl.getNamespaceImport();
100
- if (!hasAnyNamedImportsLeft && !hasDefaultImport && !hasNamespaceImport) {
101
- decl.remove();
102
- }
103
- }
104
- const remainingFhirReferences = sourceFile
105
- .getDescendantsOfKind(ts_morph_1.SyntaxKind.Identifier)
106
- .filter((id) => id.getText() === FHIR_IMPORT)
107
- .filter((id) => !id.getFirstAncestorByKind(ts_morph_1.SyntaxKind.ImportDeclaration))
108
- .length;
109
- return { removedHelpers, removedImportCount, remainingFhirReferences };
110
- }
111
- function main() {
112
- return __awaiter(this, void 0, void 0, function* () {
113
- const project = new ts_morph_1.Project({
114
- tsConfigFilePath: path_1.default.resolve(process.cwd(), 'tsconfig.json'),
115
- skipAddingFilesFromTsConfig: false
116
- });
117
- const sourceFiles = project.getSourceFiles().filter((sf) => {
118
- const fp = sf.getFilePath();
119
- return fp.includes('/src/') && !fp.includes('/node_modules/');
120
- });
121
- console.log(`Removing legacy FHIR_URL helpers in ${sourceFiles.length} source file(s)...\n`);
122
- let totalRemovedImports = 0;
123
- let totalRemovedHelpers = 0;
124
- const modifiedFiles = [];
125
- const warnings = [];
126
- for (const sourceFile of sourceFiles) {
127
- const filePath = sourceFile.getFilePath();
128
- const rel = path_1.default.relative(process.cwd(), filePath);
129
- const result = removeHelpers(filePath, project);
130
- const changed = result.removedImportCount > 0 || result.removedHelpers.length > 0;
131
- if (changed) {
132
- modifiedFiles.push(filePath);
133
- totalRemovedImports += result.removedImportCount;
134
- totalRemovedHelpers += result.removedHelpers.length;
135
- if (result.removedHelpers.length > 0) {
136
- console.log(` [${rel}] Removed helper(s): ${result.removedHelpers.join(', ')}`);
137
- }
138
- if (result.removedImportCount > 0) {
139
- console.log(` [${rel}] Removed ${result.removedImportCount} '${FHIR_IMPORT}' import(s)`);
140
- }
141
- }
142
- if (result.remainingFhirReferences > 0) {
143
- warnings.push(`${rel}: ${result.remainingFhirReferences} remaining '${FHIR_IMPORT}' reference(s)`);
144
- }
145
- }
146
- if (modifiedFiles.length === 0 && warnings.length === 0) {
147
- console.log('No FHIR_URL imports/helpers found. Nothing to do.');
148
- return;
149
- }
150
- if (modifiedFiles.length > 0) {
151
- console.log(`\nSaving ${modifiedFiles.length} modified file(s)...`);
152
- for (const filePath of modifiedFiles) {
153
- yield project.getSourceFileOrThrow(filePath).save();
154
- console.log(` Saved: ${path_1.default.relative(process.cwd(), filePath)}`);
155
- }
156
- }
157
- if (warnings.length > 0) {
158
- console.warn(`\n WARNING: Some '${FHIR_IMPORT}' usages remain and need manual cleanup:\n` +
159
- warnings.map((line) => ` - ${line}`).join('\n'));
160
- }
161
- console.log(`\nDone. Removed ${totalRemovedHelpers} helper declaration(s) and ${totalRemovedImports} '${FHIR_IMPORT}' import(s).`);
162
- });
163
- }
@@ -1,3 +0,0 @@
1
- declare function main(): Promise<void>;
2
- export { main };
3
- //# sourceMappingURL=remove-hearth-migrations.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"remove-hearth-migrations.d.ts","sourceRoot":"","sources":["../../../src/migrations/v2.0/remove-hearth-migrations.ts"],"names":[],"mappings":"AAyBA,iBAAe,IAAI,kBAalB;AAED,OAAO,EAAE,IAAI,EAAE,CAAA"}
@@ -1,87 +0,0 @@
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.main = main;
59
- const fs = __importStar(require("fs"));
60
- const path_1 = __importDefault(require("path"));
61
- const PATHS_TO_REMOVE = [
62
- {
63
- relativePath: 'src/migrations/hearth',
64
- label: 'Hearth migrations directory'
65
- },
66
- {
67
- relativePath: 'src/migrations/user-mgnt',
68
- label: 'user-mgnt migrations directory'
69
- },
70
- { relativePath: 'src/utils/hearth-helpers.ts', label: 'Hearth helpers file' }
71
- ];
72
- function main() {
73
- return __awaiter(this, void 0, void 0, function* () {
74
- for (const { relativePath, label } of PATHS_TO_REMOVE) {
75
- const absolutePath = path_1.default.join(process.cwd(), relativePath);
76
- if (fs.existsSync(absolutePath)) {
77
- fs.rmSync(absolutePath, { recursive: true, force: true });
78
- // eslint-disable-next-line no-console
79
- console.log(`Removed ${label} '${relativePath}'.`);
80
- }
81
- else {
82
- // eslint-disable-next-line no-console
83
- console.log(`No ${label} found at '${relativePath}'.`);
84
- }
85
- }
86
- });
87
- }
@@ -1,3 +0,0 @@
1
- declare function main(): Promise<void>;
2
- export { main };
3
- //# sourceMappingURL=remove-old-statistics-service.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"remove-old-statistics-service.d.ts","sourceRoot":"","sources":["../../../src/migrations/v2.0/remove-old-statistics-service.ts"],"names":[],"mappings":"AAuUA,iBAAe,IAAI,kBA4FlB;AAED,OAAO,EAAE,IAAI,EAAE,CAAA"}
@@ -1,356 +0,0 @@
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.main = main;
26
- /**
27
- * Codemod: Remove the legacy `GET /statistics` Hapi route and its handler.
28
- *
29
- * Background:
30
- * In v1.x country configs exposed a `GET /statistics` route used by the
31
- * demo data-generator script to seed location statistics. In v2.0 this is
32
- * no longer part of the country config surface — the data-generator (where
33
- * it remains) talks to the Core FHIR APIs directly.
34
- *
35
- * What it does (per source file under `src/`):
36
- * 1. Removes any `<receiver>.route({ method: 'GET', path: '/statistics', ... })`
37
- * call. Both single-route (`server.route({...})`) and array-route
38
- * (`server.route([{...}, {...}])`) forms are handled — for the array
39
- * form only the matching object is removed, the other routes stay.
40
- * 2. Removes any `statisticsHandler` named import. If that empties an
41
- * import declaration, the whole declaration is dropped.
42
- * 3. Finds the file that defines `export async function statisticsHandler`
43
- * (typically `src/api/data-generator/handler.ts`):
44
- * - If `statisticsHandler` is the file's *only* export → the whole
45
- * file is deleted.
46
- * - Otherwise → just the function declaration is removed and a
47
- * warning is logged so the developer can decide what to do with
48
- * the rest of the file.
49
- * 4. After deleting the handler file, performs a transitive orphan sweep
50
- * bounded to the handler's directory subtree (e.g.
51
- * `src/api/data-generator/`):
52
- * - Each project-local import the handler had is checked. If no
53
- * remaining file in the project imports that module, the module
54
- * file is deleted too.
55
- * - Recursive: a deleted file's own local imports are then checked
56
- * the same way. The directory boundary prevents this from ever
57
- * touching shared utilities outside the handler's subtree.
58
- * This is what reaches `service.ts` (and friends) once nothing else
59
- * uses it.
60
- *
61
- * Caveats:
62
- * - Only project-local imports inside the handler's directory are
63
- * considered for orphan deletion. Helpers in shared locations (e.g.
64
- * `src/utils/`, `src/constants.ts`) are never auto-deleted.
65
- * - Files that are still referenced by *anything* in the project (other
66
- * handlers, scripts, demo/data-generators) are kept untouched.
67
- * - The codemod is a no-op when the route doesn't exist (already
68
- * migrated country configs).
69
- */
70
- const path_1 = __importDefault(require("path"));
71
- const ts_morph_1 = require("ts-morph");
72
- const ROUTE_PATH = '/statistics';
73
- const HANDLER_NAME = 'statisticsHandler';
74
- /**
75
- * Returns true if the given object literal has a property `path` whose
76
- * value (string literal or no-substitution template literal) equals
77
- * `ROUTE_PATH`.
78
- */
79
- function isStatisticsRouteObject(obj) {
80
- const pathProp = obj.getProperty('path');
81
- if (!pathProp || !ts_morph_1.Node.isPropertyAssignment(pathProp))
82
- return false;
83
- const init = pathProp.getInitializer();
84
- if (!init)
85
- return false;
86
- if (ts_morph_1.Node.isStringLiteral(init) || ts_morph_1.Node.isNoSubstitutionTemplateLiteral(init)) {
87
- return init.getLiteralValue() === ROUTE_PATH;
88
- }
89
- return false;
90
- }
91
- /**
92
- * Removes `<receiver>.route({...})` and `<receiver>.route([{...}, ...])`
93
- * calls whose route object has `path: '/statistics'`. For the array form
94
- * only the matching element is removed; siblings are preserved.
95
- *
96
- * Returns the number of routes removed in this file.
97
- */
98
- function removeStatisticsRoutes(sourceFile) {
99
- let removed = 0;
100
- // Snapshot first — we'll be mutating the AST during iteration.
101
- const callExpressions = [
102
- ...sourceFile.getDescendantsOfKind(ts_morph_1.SyntaxKind.CallExpression)
103
- ];
104
- for (const call of callExpressions) {
105
- if (call.wasForgotten())
106
- continue;
107
- const expr = call.getExpression();
108
- if (!ts_morph_1.Node.isPropertyAccessExpression(expr))
109
- continue;
110
- if (expr.getName() !== 'route')
111
- continue;
112
- const args = call.getArguments();
113
- if (args.length === 0)
114
- continue;
115
- const firstArg = args[0];
116
- // Single-route form: `server.route({ method, path, handler, ... })`
117
- if (ts_morph_1.Node.isObjectLiteralExpression(firstArg)) {
118
- if (!isStatisticsRouteObject(firstArg))
119
- continue;
120
- // Drop the whole `server.route({...})` statement, not just the call,
121
- // so we don't leave a dangling `;` behind.
122
- const stmt = call.getFirstAncestorByKind(ts_morph_1.SyntaxKind.ExpressionStatement);
123
- if (stmt) {
124
- stmt.remove();
125
- removed++;
126
- }
127
- else {
128
- // Fallback (shouldn't happen at top level): replace the call.
129
- call.replaceWithText('');
130
- removed++;
131
- }
132
- continue;
133
- }
134
- // Array-route form: `server.route([{...}, {...}])`
135
- if (ts_morph_1.Node.isArrayLiteralExpression(firstArg)) {
136
- const matchingIndexes = firstArg
137
- .getElements()
138
- .map((el, idx) => ({ el, idx }))
139
- .filter(({ el }) => ts_morph_1.Node.isObjectLiteralExpression(el) && isStatisticsRouteObject(el))
140
- .map(({ idx }) => idx);
141
- // Highest index first so each removal doesn't shift the index of
142
- // matches we haven't dropped yet.
143
- matchingIndexes
144
- .sort((a, b) => b - a)
145
- .forEach((idx) => {
146
- firstArg.removeElement(idx);
147
- removed++;
148
- });
149
- }
150
- }
151
- return removed;
152
- }
153
- /**
154
- * Removes any `statisticsHandler` named import. Returns true if the file
155
- * was modified.
156
- */
157
- function removeStatisticsHandlerImports(sourceFile) {
158
- let changed = false;
159
- for (const decl of sourceFile.getImportDeclarations()) {
160
- const targetNamed = decl
161
- .getNamedImports()
162
- .find((ni) => ni.getName() === HANDLER_NAME);
163
- if (!targetNamed)
164
- continue;
165
- targetNamed.remove();
166
- changed = true;
167
- const isNowEmpty = decl.getNamedImports().length === 0 &&
168
- !decl.getDefaultImport() &&
169
- !decl.getNamespaceImport();
170
- if (isNowEmpty)
171
- decl.remove();
172
- }
173
- return changed;
174
- }
175
- function processFile(sourceFile) {
176
- const routesRemoved = removeStatisticsRoutes(sourceFile);
177
- const importsCleaned = removeStatisticsHandlerImports(sourceFile);
178
- return { routesRemoved, importsCleaned };
179
- }
180
- /**
181
- * Returns local-project import paths from the given source file that
182
- * resolve to a file inside `subtreeRoot`. External (npm) imports and
183
- * imports outside the subtree are excluded.
184
- */
185
- function collectLocalImportsInSubtree(sourceFile, subtreeRoot) {
186
- const result = [];
187
- for (const decl of sourceFile.getImportDeclarations()) {
188
- const moduleSf = decl.getModuleSpecifierSourceFile();
189
- if (!moduleSf)
190
- continue;
191
- const fp = moduleSf.getFilePath();
192
- if (!fp.startsWith(subtreeRoot))
193
- continue;
194
- result.push(fp);
195
- }
196
- return result;
197
- }
198
- /**
199
- * Walks files reachable from a deleted starting file via local imports
200
- * within `subtreeRoot`, deleting any that nobody else imports. Recursive
201
- * via worklist — when a file is deleted, its own local imports become
202
- * candidates for the next round.
203
- */
204
- function deleteOrphanedDescendants(project, startingFile, subtreeRoot) {
205
- const initialCandidates = collectLocalImportsInSubtree(startingFile, subtreeRoot);
206
- const startingPath = startingFile.getFilePath();
207
- const deleted = new Set([startingPath]);
208
- const seen = new Set();
209
- const worklist = [...initialCandidates];
210
- const orphans = [];
211
- while (worklist.length > 0) {
212
- const candidate = worklist.shift();
213
- if (seen.has(candidate))
214
- continue;
215
- seen.add(candidate);
216
- if (deleted.has(candidate))
217
- continue;
218
- if (!candidate.startsWith(subtreeRoot))
219
- continue;
220
- const candidateSf = project.getSourceFile(candidate);
221
- if (!candidateSf)
222
- continue;
223
- // Anyone left in the project still importing this file (including
224
- // files outside the subtree)? If so, it's not actually orphaned.
225
- const stillImported = project.getSourceFiles().some((sf) => {
226
- const sfPath = sf.getFilePath();
227
- if (deleted.has(sfPath))
228
- return false;
229
- if (sfPath === candidate)
230
- return false;
231
- return sf
232
- .getImportDeclarations()
233
- .some((decl) => { var _a; return ((_a = decl.getModuleSpecifierSourceFile()) === null || _a === void 0 ? void 0 : _a.getFilePath()) === candidate; });
234
- });
235
- if (stillImported)
236
- continue;
237
- // Capture local imports BEFORE deletion — `delete()` invalidates the
238
- // node, so we wouldn't be able to read them afterwards.
239
- const next = collectLocalImportsInSubtree(candidateSf, subtreeRoot);
240
- worklist.push(...next);
241
- candidateSf.delete();
242
- deleted.add(candidate);
243
- orphans.push(candidate);
244
- }
245
- return orphans;
246
- }
247
- /**
248
- * Finds the file that exports `statisticsHandler` and either deletes the
249
- * whole file (when it's the sole export) or just removes the function
250
- * declaration. When the file is deleted, also performs a transitive
251
- * orphan sweep bounded to the file's directory.
252
- */
253
- function processHandlerFile(project) {
254
- const sourceFiles = project.getSourceFiles().filter((sf) => {
255
- const fp = sf.getFilePath();
256
- return fp.includes('/src/') && !fp.includes('/node_modules/');
257
- });
258
- for (const sf of sourceFiles) {
259
- const fn = sf.getFunction(HANDLER_NAME);
260
- if (!fn)
261
- continue;
262
- const filePath = sf.getFilePath();
263
- const exportsByName = [...sf.getExportedDeclarations().keys()];
264
- const otherExports = exportsByName.filter((name) => name !== HANDLER_NAME);
265
- if (otherExports.length === 0) {
266
- // Sole export — delete the file, then sweep orphans inside its
267
- // directory subtree.
268
- const subtreeRoot = path_1.default.dirname(filePath) + path_1.default.sep;
269
- const orphansDeleted = deleteOrphanedDescendants(project, sf, subtreeRoot);
270
- sf.delete();
271
- return { filePath, action: 'deleted', orphansDeleted };
272
- }
273
- // Other exports exist; surgically remove just this function.
274
- // We don't run the orphan sweep here — the file isn't gone, so
275
- // anything it imports is presumably still in use.
276
- fn.remove();
277
- return {
278
- filePath,
279
- action: 'function-removed',
280
- remainingExports: otherExports,
281
- orphansDeleted: []
282
- };
283
- }
284
- return { filePath: '', action: 'not-found', orphansDeleted: [] };
285
- }
286
- function main() {
287
- return __awaiter(this, void 0, void 0, function* () {
288
- var _a;
289
- const project = new ts_morph_1.Project({
290
- tsConfigFilePath: path_1.default.resolve(process.cwd(), 'tsconfig.json'),
291
- skipAddingFilesFromTsConfig: false
292
- });
293
- const sourceFiles = project.getSourceFiles().filter((sf) => {
294
- const fp = sf.getFilePath();
295
- return fp.includes('/src/') && !fp.includes('/node_modules/');
296
- });
297
- console.log(`Removing legacy 'GET ${ROUTE_PATH}' route and '${HANDLER_NAME}' across ${sourceFiles.length} source file(s)...\n`);
298
- let totalRoutesRemoved = 0;
299
- let totalFilesWithImportsCleaned = 0;
300
- let totalFilesWithRoutesRemoved = 0;
301
- for (const sourceFile of sourceFiles) {
302
- const filePath = sourceFile.getFilePath();
303
- const rel = path_1.default.relative(process.cwd(), filePath);
304
- const result = processFile(sourceFile);
305
- if (result.routesRemoved > 0) {
306
- console.log(` [${rel}] Removed ${result.routesRemoved} '${ROUTE_PATH}' route(s)`);
307
- totalRoutesRemoved += result.routesRemoved;
308
- totalFilesWithRoutesRemoved++;
309
- }
310
- if (result.importsCleaned) {
311
- console.log(` [${rel}] Cleaned up '${HANDLER_NAME}' import`);
312
- totalFilesWithImportsCleaned++;
313
- }
314
- if (result.routesRemoved > 0 || result.importsCleaned) {
315
- yield sourceFile.save();
316
- }
317
- }
318
- const handlerResult = processHandlerFile(project);
319
- switch (handlerResult.action) {
320
- case 'deleted': {
321
- const rel = path_1.default.relative(process.cwd(), handlerResult.filePath);
322
- console.log(` [${rel}] Deleted handler file ('${HANDLER_NAME}' was the sole export).`);
323
- for (const orphanPath of handlerResult.orphansDeleted) {
324
- const orphanRel = path_1.default.relative(process.cwd(), orphanPath);
325
- console.log(` [${orphanRel}] Deleted (no remaining importers in the project after handler removal).`);
326
- }
327
- // `delete()` schedules deletion; `save()` writes it to disk.
328
- yield project.save();
329
- break;
330
- }
331
- case 'function-removed': {
332
- const rel = path_1.default.relative(process.cwd(), handlerResult.filePath);
333
- console.warn(` [${rel}] Removed '${HANDLER_NAME}' function but kept the file (other exports remain: ${(_a = handlerResult.remainingExports) === null || _a === void 0 ? void 0 : _a.join(', ')}). Review whether the file is still needed.`);
334
- // Save the source file with the function removed.
335
- const sf = project.getSourceFile(handlerResult.filePath);
336
- if (sf)
337
- yield sf.save();
338
- break;
339
- }
340
- case 'not-found':
341
- // Either already migrated or the handler lives somewhere unexpected.
342
- // Not an error — continue silently.
343
- break;
344
- }
345
- if (totalRoutesRemoved === 0 &&
346
- totalFilesWithImportsCleaned === 0 &&
347
- handlerResult.action === 'not-found') {
348
- console.log(`\nNo legacy '${ROUTE_PATH}' route or handler found. Nothing to do.`);
349
- return;
350
- }
351
- const orphansSummary = handlerResult.orphansDeleted.length > 0
352
- ? ` and ${handlerResult.orphansDeleted.length} orphaned helper file(s)`
353
- : '';
354
- console.log(`\nDone. Removed ${totalRoutesRemoved} route(s) across ${totalFilesWithRoutesRemoved} file(s); cleaned ${HANDLER_NAME} import in ${totalFilesWithImportsCleaned} file(s)${orphansSummary}.`);
355
- });
356
- }
@@ -1,3 +0,0 @@
1
- declare function main(): Promise<void>;
2
- export { main };
3
- //# sourceMappingURL=remove-pending-certification-flag.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"remove-pending-certification-flag.d.ts","sourceRoot":"","sources":["../../../src/migrations/v2.0/remove-pending-certification-flag.ts"],"names":[],"mappings":"AAyEA,iBAAe,IAAI,kBAiDlB;AAED,OAAO,EAAE,IAAI,EAAE,CAAA"}