@opencrvs/toolkit 2.0.0-rc.fc7f7fc → 2.0.0-rc.fef9d21

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 (70) hide show
  1. package/dist/cli.js +1383 -142
  2. package/dist/commons/api/router.d.ts +42 -63
  3. package/dist/migrations/v2.0/add-birth-certificate-issuance-flag.d.ts.map +1 -1
  4. package/dist/migrations/v2.0/add-birth-certificate-issuance-flag.js +3 -4
  5. package/dist/migrations/v2.0/add-resend-invite-notification.d.ts +3 -0
  6. package/dist/migrations/v2.0/add-resend-invite-notification.d.ts.map +1 -0
  7. package/dist/migrations/v2.0/add-resend-invite-notification.js +373 -0
  8. package/dist/migrations/v2.0/checkout-upstream-files.d.ts +19 -0
  9. package/dist/migrations/v2.0/checkout-upstream-files.d.ts.map +1 -1
  10. package/dist/migrations/v2.0/checkout-upstream-files.js +17 -13
  11. package/dist/migrations/v2.0/convert-config-files-to-ts.d.ts.map +1 -1
  12. package/dist/migrations/v2.0/convert-config-files-to-ts.js +4 -5
  13. package/dist/migrations/v2.0/convert-paragraph-to-heading.d.ts.map +1 -1
  14. package/dist/migrations/v2.0/convert-paragraph-to-heading.js +4 -5
  15. package/dist/migrations/v2.0/create-events-index.d.ts.map +1 -1
  16. package/dist/migrations/v2.0/create-events-index.js +1 -2
  17. package/dist/migrations/v2.0/delete-infrastructure-directory.d.ts +3 -0
  18. package/dist/migrations/v2.0/delete-infrastructure-directory.d.ts.map +1 -0
  19. package/dist/migrations/v2.0/delete-infrastructure-directory.js +77 -0
  20. package/dist/migrations/v2.0/index.d.ts +8 -4
  21. package/dist/migrations/v2.0/index.d.ts.map +1 -1
  22. package/dist/migrations/v2.0/index.js +1351 -139
  23. package/dist/migrations/v2.0/make-built-in-validate-actions-custom.d.ts.map +1 -1
  24. package/dist/migrations/v2.0/make-built-in-validate-actions-custom.js +5 -6
  25. package/dist/migrations/v2.0/merge-infrastructure-directory.d.ts +3 -0
  26. package/dist/migrations/v2.0/merge-infrastructure-directory.d.ts.map +1 -0
  27. package/dist/migrations/v2.0/merge-infrastructure-directory.js +221 -0
  28. package/dist/migrations/v2.0/migrate-application-config-url.d.ts +3 -0
  29. package/dist/migrations/v2.0/migrate-application-config-url.d.ts.map +1 -0
  30. package/dist/migrations/v2.0/migrate-application-config-url.js +342 -0
  31. package/dist/migrations/v2.0/migrate-scopes.d.ts.map +1 -1
  32. package/dist/migrations/v2.0/migrate-scopes.js +6 -7
  33. package/dist/migrations/v2.0/migrate-validated-workqueue-status-to-flag.d.ts.map +1 -1
  34. package/dist/migrations/v2.0/migrate-validated-workqueue-status-to-flag.js +3 -4
  35. package/dist/migrations/v2.0/migrate-workqueue-configs.d.ts.map +1 -1
  36. package/dist/migrations/v2.0/migrate-workqueue-configs.js +3 -4
  37. package/dist/migrations/v2.0/remove-delete-actions.d.ts.map +1 -1
  38. package/dist/migrations/v2.0/remove-delete-actions.js +3 -4
  39. package/dist/migrations/v2.0/remove-demo-scope.d.ts.map +1 -1
  40. package/dist/migrations/v2.0/remove-demo-scope.js +2 -3
  41. package/dist/migrations/v2.0/remove-deprecated-imports.d.ts.map +1 -1
  42. package/dist/migrations/v2.0/remove-deprecated-imports.js +3 -4
  43. package/dist/migrations/v2.0/remove-fhir-url-helpers.d.ts +3 -0
  44. package/dist/migrations/v2.0/remove-fhir-url-helpers.d.ts.map +1 -0
  45. package/dist/migrations/v2.0/remove-fhir-url-helpers.js +163 -0
  46. package/dist/migrations/v2.0/remove-hearth-migrations.d.ts.map +1 -1
  47. package/dist/migrations/v2.0/remove-hearth-migrations.js +1 -2
  48. package/dist/migrations/v2.0/remove-old-statistics-service.d.ts +3 -0
  49. package/dist/migrations/v2.0/remove-old-statistics-service.d.ts.map +1 -0
  50. package/dist/migrations/v2.0/remove-old-statistics-service.js +356 -0
  51. package/dist/migrations/v2.0/remove-pending-certification-flag.d.ts.map +1 -1
  52. package/dist/migrations/v2.0/remove-pending-certification-flag.js +3 -4
  53. package/dist/migrations/v2.0/remove-review-from-register-action.d.ts.map +1 -1
  54. package/dist/migrations/v2.0/remove-review-from-register-action.js +3 -4
  55. package/dist/migrations/v2.0/remove-unused-environment-variables.d.ts +3 -0
  56. package/dist/migrations/v2.0/remove-unused-environment-variables.d.ts.map +1 -0
  57. package/dist/migrations/v2.0/remove-unused-environment-variables.js +186 -0
  58. package/dist/migrations/v2.0/rename-api-paths.d.ts.map +1 -1
  59. package/dist/migrations/v2.0/rename-api-paths.js +3 -4
  60. package/dist/migrations/v2.0/rename-location-parent-id.d.ts.map +1 -1
  61. package/dist/migrations/v2.0/rename-location-parent-id.js +3 -4
  62. package/dist/migrations/v2.0/simplify-analytics-precalculations.d.ts.map +1 -1
  63. package/dist/migrations/v2.0/simplify-analytics-precalculations.js +1 -2
  64. package/dist/migrations/v2.0/update-package-json.d.ts +3 -0
  65. package/dist/migrations/v2.0/update-package-json.d.ts.map +1 -0
  66. package/dist/migrations/v2.0/update-package-json.js +105 -0
  67. package/opencrvs-toolkit-2.0.0-rc.fef9d21.tgz +0 -0
  68. package/package.json +1 -1
  69. package/tsconfig.tsbuildinfo +1 -1
  70. package/opencrvs-toolkit-2.0.0-rc.fc7f7fc.tgz +0 -0
@@ -27,7 +27,6 @@ const ts_morph_1 = require("ts-morph");
27
27
  const path_1 = __importDefault(require("path"));
28
28
  const scopes_1 = require("../commons/scopes");
29
29
  const scopes_deprecated_do_not_use_1 = require("../commons/scopes.deprecated.do-not-use");
30
- const _1 = require(".");
31
30
  const ROLES_FILE_RELATIVE_PATH = 'src/data-seeding/roles/roles.ts';
32
31
  const SCOPES_PROPERTY_NAME = 'scopes';
33
32
  const TOOLKIT_SCOPES_MODULE = '@opencrvs/toolkit/scopes';
@@ -87,7 +86,7 @@ function migrateScopesArrays(rolesFilePath, project) {
87
86
  const scopeKey = resolveScopeKeyFromElementAccess(element);
88
87
  if (scopeKey && !(scopeKey in scopes_deprecated_do_not_use_1.SCOPES)) {
89
88
  // eslint-disable-next-line no-console
90
- console.warn(` [${path_1.default.relative((0, _1.getCwd)(), rolesFilePath)}] Removing unknown scope reference: SCOPES.${scopeKey}`);
89
+ console.warn(` [${path_1.default.relative(process.cwd(), rolesFilePath)}] Removing unknown scope reference: SCOPES.${scopeKey}`);
91
90
  initializer.removeElement(index);
92
91
  removedCount++;
93
92
  continue;
@@ -95,7 +94,7 @@ function migrateScopesArrays(rolesFilePath, project) {
95
94
  const legacyScope = resolveLegacyScopeFromElement(element);
96
95
  if (!legacyScope) {
97
96
  // eslint-disable-next-line no-console
98
- console.warn(` [${path_1.default.relative((0, _1.getCwd)(), rolesFilePath)}] Skipping non-literal scope expression: ${element.getText()}`);
97
+ console.warn(` [${path_1.default.relative(process.cwd(), rolesFilePath)}] Skipping non-literal scope expression: ${element.getText()}`);
99
98
  continue;
100
99
  }
101
100
  try {
@@ -103,7 +102,7 @@ function migrateScopesArrays(rolesFilePath, project) {
103
102
  const scope = (0, scopes_1.decodeScope)(migratedScope);
104
103
  if (!scope) {
105
104
  // eslint-disable-next-line no-console
106
- console.warn(` [${path_1.default.relative((0, _1.getCwd)(), rolesFilePath)}] Could not decode migrated scope '${migratedScope}'.`);
105
+ console.warn(` [${path_1.default.relative(process.cwd(), rolesFilePath)}] Could not decode migrated scope '${migratedScope}'.`);
107
106
  continue;
108
107
  }
109
108
  element.replaceWithText(JSON.stringify(scope));
@@ -111,13 +110,13 @@ function migrateScopesArrays(rolesFilePath, project) {
111
110
  }
112
111
  catch (error) {
113
112
  // eslint-disable-next-line no-console
114
- console.warn(` [${path_1.default.relative((0, _1.getCwd)(), rolesFilePath)}] Could not migrate scope '${legacyScope}': ${error}`);
113
+ console.warn(` [${path_1.default.relative(process.cwd(), rolesFilePath)}] Could not migrate scope '${legacyScope}': ${error}`);
115
114
  }
116
115
  }
117
116
  }
118
117
  if (removedCount > 0) {
119
118
  // eslint-disable-next-line no-console
120
- console.log(` Removed ${removedCount} unknown SCOPES reference(s) from '${path_1.default.relative((0, _1.getCwd)(), rolesFilePath)}'.`);
119
+ console.log(` Removed ${removedCount} unknown SCOPES reference(s) from '${path_1.default.relative(process.cwd(), rolesFilePath)}'.`);
121
120
  }
122
121
  return { migratedCount, removedCount };
123
122
  }
@@ -249,7 +248,7 @@ function removeRoleTypeDefinitionAndUnusedImports(rolesFilePath, project) {
249
248
  }
250
249
  function main() {
251
250
  return __awaiter(this, void 0, void 0, function* () {
252
- const cwd = (0, _1.getCwd)();
251
+ const cwd = process.cwd();
253
252
  const srcDir = path_1.default.join(cwd, 'src');
254
253
  const rolesFilePath = path_1.default.join(cwd, ROLES_FILE_RELATIVE_PATH);
255
254
  console.log(`Scanning roles scopes in: ${rolesFilePath}`);
@@ -1 +1 @@
1
- {"version":3,"file":"migrate-validated-workqueue-status-to-flag.d.ts","sourceRoot":"","sources":["../../../src/migrations/v2.0/migrate-validated-workqueue-status-to-flag.ts"],"names":[],"mappings":"AA2QA,iBAAe,IAAI,kBA+ClB;AAED,OAAO,EAAE,IAAI,EAAE,CAAA"}
1
+ {"version":3,"file":"migrate-validated-workqueue-status-to-flag.d.ts","sourceRoot":"","sources":["../../../src/migrations/v2.0/migrate-validated-workqueue-status-to-flag.ts"],"names":[],"mappings":"AAyQA,iBAAe,IAAI,kBA+ClB;AAED,OAAO,EAAE,IAAI,EAAE,CAAA"}
@@ -45,7 +45,6 @@ exports.main = main;
45
45
  */
46
46
  const ts_morph_1 = require("ts-morph");
47
47
  const path_1 = __importDefault(require("path"));
48
- const _1 = require(".");
49
48
  const DEFINE_WORKQUEUES_NAME = 'defineWorkqueues';
50
49
  const QUERY_PROPERTY_NAME = 'query';
51
50
  const TYPE_PROPERTY_NAME = 'type';
@@ -223,7 +222,7 @@ function processFile(filePath, project) {
223
222
  const changed = walkQuery(queryInit);
224
223
  if (changed > 0) {
225
224
  migratedCount += changed;
226
- console.log(` [${path_1.default.relative((0, _1.getCwd)(), filePath)}] Migrated ${changed} clause(s): VALIDATED status → flags.anyOf`);
225
+ console.log(` [${path_1.default.relative(process.cwd(), filePath)}] Migrated ${changed} clause(s): VALIDATED status → flags.anyOf`);
227
226
  }
228
227
  }
229
228
  }
@@ -232,7 +231,7 @@ function processFile(filePath, project) {
232
231
  // ─── Entry point ─────────────────────────────────────────────────────────────
233
232
  function main() {
234
233
  return __awaiter(this, void 0, void 0, function* () {
235
- const srcDir = path_1.default.join((0, _1.getCwd)(), 'src');
234
+ const srcDir = path_1.default.join(process.cwd(), 'src');
236
235
  console.log(`Scanning for defineWorkqueues calls in: ${srcDir}\n`);
237
236
  const project = new ts_morph_1.Project({
238
237
  tsConfigFilePath: path_1.default.resolve(srcDir, '../tsconfig.json'),
@@ -261,7 +260,7 @@ function main() {
261
260
  for (const filePath of modifiedFiles) {
262
261
  const sourceFile = project.getSourceFileOrThrow(filePath);
263
262
  yield sourceFile.save();
264
- console.log(` Saved: ${path_1.default.relative((0, _1.getCwd)(), filePath)}`);
263
+ console.log(` Saved: ${path_1.default.relative(process.cwd(), filePath)}`);
265
264
  }
266
265
  console.log(`\nDone. Migrated ${totalMigrated} clause(s) from VALIDATED status to flags.anyOf['validated'].`);
267
266
  });
@@ -1 +1 @@
1
- {"version":3,"file":"migrate-workqueue-configs.d.ts","sourceRoot":"","sources":["../../../src/migrations/v2.0/migrate-workqueue-configs.ts"],"names":[],"mappings":"AAiPA,iBAAe,IAAI,kBAqDlB;AAED,OAAO,EAAE,IAAI,EAAE,CAAA"}
1
+ {"version":3,"file":"migrate-workqueue-configs.d.ts","sourceRoot":"","sources":["../../../src/migrations/v2.0/migrate-workqueue-configs.ts"],"names":[],"mappings":"AA+OA,iBAAe,IAAI,kBAqDlB;AAED,OAAO,EAAE,IAAI,EAAE,CAAA"}
@@ -43,7 +43,6 @@ exports.main = main;
43
43
  */
44
44
  const ts_morph_1 = require("ts-morph");
45
45
  const path_1 = __importDefault(require("path"));
46
- const _1 = require(".");
47
46
  const DEFINE_WORKQUEUES_NAME = 'defineWorkqueues';
48
47
  const ACTIONS_PROPERTY_NAME = 'actions';
49
48
  const ACTION_PROPERTY_NAME = 'action';
@@ -171,7 +170,7 @@ function processFile(filePath, project) {
171
170
  if (!sourceFile)
172
171
  return 0;
173
172
  let migratedWorkqueues = 0;
174
- const relPath = path_1.default.relative((0, _1.getCwd)(), filePath);
173
+ const relPath = path_1.default.relative(process.cwd(), filePath);
175
174
  const callExpressions = sourceFile.getDescendantsOfKind(ts_morph_1.SyntaxKind.CallExpression);
176
175
  for (const call of callExpressions) {
177
176
  const expression = call.getExpression();
@@ -195,7 +194,7 @@ function processFile(filePath, project) {
195
194
  }
196
195
  function main() {
197
196
  return __awaiter(this, void 0, void 0, function* () {
198
- const srcDir = path_1.default.join((0, _1.getCwd)(), 'src');
197
+ const srcDir = path_1.default.join(process.cwd(), 'src');
199
198
  // eslint-disable-next-line no-console
200
199
  console.log(`Scanning for defineWorkqueues calls in: ${srcDir}\n`);
201
200
  const project = new ts_morph_1.Project({
@@ -229,7 +228,7 @@ function main() {
229
228
  const sourceFile = project.getSourceFileOrThrow(filePath);
230
229
  yield sourceFile.save();
231
230
  // eslint-disable-next-line no-console
232
- console.log(` Saved: ${path_1.default.relative((0, _1.getCwd)(), filePath)}`);
231
+ console.log(` Saved: ${path_1.default.relative(process.cwd(), filePath)}`);
233
232
  }
234
233
  // eslint-disable-next-line no-console
235
234
  console.log(`\nDone. Migrated ${totalMigrated} deprecated workqueue 'actions' definition(s) to 'action'.`);
@@ -1 +1 @@
1
- {"version":3,"file":"remove-delete-actions.d.ts","sourceRoot":"","sources":["../../../src/migrations/v2.0/remove-delete-actions.ts"],"names":[],"mappings":"AA2IA,iBAAe,IAAI,kBAiDlB;AAED,OAAO,EAAE,IAAI,EAAE,CAAA"}
1
+ {"version":3,"file":"remove-delete-actions.d.ts","sourceRoot":"","sources":["../../../src/migrations/v2.0/remove-delete-actions.ts"],"names":[],"mappings":"AAyIA,iBAAe,IAAI,kBAiDlB;AAED,OAAO,EAAE,IAAI,EAAE,CAAA"}
@@ -39,7 +39,6 @@ exports.main = main;
39
39
  */
40
40
  const ts_morph_1 = require("ts-morph");
41
41
  const path_1 = __importDefault(require("path"));
42
- const _1 = require(".");
43
42
  const DEFINE_CONFIG_NAME = 'defineConfig';
44
43
  const ACTIONS_PROPERTY_NAME = 'actions';
45
44
  const TYPE_PROPERTY_NAME = 'type';
@@ -112,14 +111,14 @@ function processFile(filePath, project) {
112
111
  for (const index of indicesToRemove.reverse()) {
113
112
  actionsInitializer.removeElement(index);
114
113
  removedCount++;
115
- console.log(` [${path_1.default.relative((0, _1.getCwd)(), filePath)}] Removed DELETE action at index ${index}`);
114
+ console.log(` [${path_1.default.relative(process.cwd(), filePath)}] Removed DELETE action at index ${index}`);
116
115
  }
117
116
  }
118
117
  return removedCount;
119
118
  }
120
119
  function main() {
121
120
  return __awaiter(this, void 0, void 0, function* () {
122
- const srcDir = path_1.default.join((0, _1.getCwd)(), 'src');
121
+ const srcDir = path_1.default.join(process.cwd(), 'src');
123
122
  console.log(`Scanning for defineConfig calls in: ${srcDir}\n`);
124
123
  const project = new ts_morph_1.Project({
125
124
  tsConfigFilePath: path_1.default.resolve(srcDir, '../tsconfig.json'),
@@ -150,7 +149,7 @@ function main() {
150
149
  for (const filePath of modifiedFiles) {
151
150
  const sourceFile = project.getSourceFileOrThrow(filePath);
152
151
  yield sourceFile.save();
153
- console.log(` Saved: ${path_1.default.relative((0, _1.getCwd)(), filePath)}`);
152
+ console.log(` Saved: ${path_1.default.relative(process.cwd(), filePath)}`);
154
153
  }
155
154
  console.log(`\nDone. Removed ${totalRemoved} DELETE action(s) from defineConfig call(s).`);
156
155
  });
@@ -1 +1 @@
1
- {"version":3,"file":"remove-demo-scope.d.ts","sourceRoot":"","sources":["../../../src/migrations/v2.0/remove-demo-scope.ts"],"names":[],"mappings":"AAiBA,iBAAe,IAAI,kBA8DlB;AAED,OAAO,EAAE,IAAI,EAAE,CAAA"}
1
+ {"version":3,"file":"remove-demo-scope.d.ts","sourceRoot":"","sources":["../../../src/migrations/v2.0/remove-demo-scope.ts"],"names":[],"mappings":"AAeA,iBAAe,IAAI,kBA8DlB;AAED,OAAO,EAAE,IAAI,EAAE,CAAA"}
@@ -25,14 +25,13 @@ Object.defineProperty(exports, "__esModule", { value: true });
25
25
  exports.main = main;
26
26
  const path_1 = __importDefault(require("path"));
27
27
  const ts_morph_1 = require("ts-morph");
28
- const _1 = require(".");
29
28
  const ROLES_HANDLER_RELATIVE_PATH = 'src/data-seeding/roles/handler.ts';
30
29
  function main() {
31
30
  return __awaiter(this, void 0, void 0, function* () {
32
31
  var _a;
33
- const rolesHandlerPath = path_1.default.join((0, _1.getCwd)(), ROLES_HANDLER_RELATIVE_PATH);
32
+ const rolesHandlerPath = path_1.default.join(process.cwd(), ROLES_HANDLER_RELATIVE_PATH);
34
33
  const project = new ts_morph_1.Project({
35
- tsConfigFilePath: path_1.default.resolve((0, _1.getCwd)(), 'tsconfig.json'),
34
+ tsConfigFilePath: path_1.default.resolve(process.cwd(), 'tsconfig.json'),
36
35
  skipAddingFilesFromTsConfig: false
37
36
  });
38
37
  const sourceFile = project.getSourceFile(rolesHandlerPath);
@@ -1 +1 @@
1
- {"version":3,"file":"remove-deprecated-imports.d.ts","sourceRoot":"","sources":["../../../src/migrations/v2.0/remove-deprecated-imports.ts"],"names":[],"mappings":"AA2DA,iBAAe,IAAI,kBAyClB;AAED,OAAO,EAAE,IAAI,EAAE,CAAA"}
1
+ {"version":3,"file":"remove-deprecated-imports.d.ts","sourceRoot":"","sources":["../../../src/migrations/v2.0/remove-deprecated-imports.ts"],"names":[],"mappings":"AAyDA,iBAAe,IAAI,kBAyClB;AAED,OAAO,EAAE,IAAI,EAAE,CAAA"}
@@ -25,7 +25,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
25
25
  exports.main = main;
26
26
  const ts_morph_1 = require("ts-morph");
27
27
  const path_1 = __importDefault(require("path"));
28
- const _1 = require(".");
29
28
  const DEPRECATED_IMPORT = 'SCOPES';
30
29
  const TARGET_MODULES = new Set([
31
30
  '@opencrvs/toolkit/scopes',
@@ -56,13 +55,13 @@ function processFile(filePath, project) {
56
55
  if (!hasAnyNamedImportsLeft && !hasDefaultImport && !hasNamespaceImport) {
57
56
  decl.remove();
58
57
  }
59
- console.log(` [${path_1.default.relative((0, _1.getCwd)(), filePath)}] Removed ${matchingNamedImports.length} deprecated '${DEPRECATED_IMPORT}' import(s) from '${decl.getModuleSpecifierValue()}'`);
58
+ console.log(` [${path_1.default.relative(process.cwd(), filePath)}] Removed ${matchingNamedImports.length} deprecated '${DEPRECATED_IMPORT}' import(s) from '${decl.getModuleSpecifierValue()}'`);
60
59
  }
61
60
  return removedCount;
62
61
  }
63
62
  function main() {
64
63
  return __awaiter(this, void 0, void 0, function* () {
65
- const srcDir = path_1.default.join((0, _1.getCwd)(), 'src');
64
+ const srcDir = path_1.default.join(process.cwd(), 'src');
66
65
  console.log(`Scanning for deprecated imports in: ${srcDir}\n`);
67
66
  const project = new ts_morph_1.Project({
68
67
  tsConfigFilePath: path_1.default.resolve(srcDir, '../tsconfig.json'),
@@ -90,7 +89,7 @@ function main() {
90
89
  console.log(`\nSaving ${modifiedFiles.length} modified file(s)...`);
91
90
  for (const filePath of modifiedFiles) {
92
91
  yield project.getSourceFileOrThrow(filePath).save();
93
- console.log(` Saved: ${path_1.default.relative((0, _1.getCwd)(), filePath)}`);
92
+ console.log(` Saved: ${path_1.default.relative(process.cwd(), filePath)}`);
94
93
  }
95
94
  console.log(`\nDone. Removed ${totalRemoved} deprecated import(s).`);
96
95
  });
@@ -0,0 +1,3 @@
1
+ declare function main(): Promise<void>;
2
+ export { main };
3
+ //# sourceMappingURL=remove-fhir-url-helpers.d.ts.map
@@ -0,0 +1 @@
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"}
@@ -0,0 +1,163 @@
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 +1 @@
1
- {"version":3,"file":"remove-hearth-migrations.d.ts","sourceRoot":"","sources":["../../../src/migrations/v2.0/remove-hearth-migrations.ts"],"names":[],"mappings":"AA2BA,iBAAe,IAAI,kBAalB;AAED,OAAO,EAAE,IAAI,EAAE,CAAA"}
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"}
@@ -48,7 +48,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
48
48
  exports.main = main;
49
49
  const fs = __importStar(require("fs"));
50
50
  const path_1 = __importDefault(require("path"));
51
- const _1 = require(".");
52
51
  const PATHS_TO_REMOVE = [
53
52
  {
54
53
  relativePath: 'src/migrations/hearth',
@@ -63,7 +62,7 @@ const PATHS_TO_REMOVE = [
63
62
  function main() {
64
63
  return __awaiter(this, void 0, void 0, function* () {
65
64
  for (const { relativePath, label } of PATHS_TO_REMOVE) {
66
- const absolutePath = path_1.default.join((0, _1.getCwd)(), relativePath);
65
+ const absolutePath = path_1.default.join(process.cwd(), relativePath);
67
66
  if (fs.existsSync(absolutePath)) {
68
67
  fs.rmSync(absolutePath, { recursive: true, force: true });
69
68
  // eslint-disable-next-line no-console
@@ -0,0 +1,3 @@
1
+ declare function main(): Promise<void>;
2
+ export { main };
3
+ //# sourceMappingURL=remove-old-statistics-service.d.ts.map
@@ -0,0 +1 @@
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"}