@opencrvs/toolkit 1.9.12-rc.d350fab → 1.9.12-rc.d4e5c22

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 (151) hide show
  1. package/build.sh +13 -0
  2. package/dist/api/index.d.ts.map +1 -1
  3. package/dist/application-config/index.d.ts +2 -0
  4. package/dist/application-config/index.d.ts.map +1 -0
  5. package/dist/application-config/index.js +2128 -0
  6. package/dist/cli.d.ts +2 -0
  7. package/dist/cli.d.ts.map +1 -0
  8. package/dist/cli.js +4527 -0
  9. package/dist/commons/api/router.d.ts +3435 -2288
  10. package/dist/commons/application-config/index.d.ts +84 -0
  11. package/dist/commons/conditionals/conditionals.d.ts +27 -3
  12. package/dist/commons/conditionals/validate.d.ts +13 -2
  13. package/dist/commons/events/ActionConfig.d.ts +415 -1555
  14. package/dist/commons/events/ActionDocument.d.ts +888 -1941
  15. package/dist/commons/events/ActionInput.d.ts +277 -1073
  16. package/dist/commons/events/ActionType.d.ts +91 -11
  17. package/dist/commons/events/AdvancedSearchConfig.d.ts +294 -1238
  18. package/dist/commons/events/AuditLog.d.ts +405 -0
  19. package/dist/commons/events/CompositeFieldValue.d.ts +30 -190
  20. package/dist/commons/events/Conditional.d.ts +26 -38
  21. package/dist/commons/events/Constants.d.ts +1 -1
  22. package/dist/commons/events/CountryConfigQueryInput.d.ts +1592 -4471
  23. package/dist/commons/events/DeduplicationConfig.d.ts +15 -171
  24. package/dist/commons/events/Draft.d.ts +72 -107
  25. package/dist/commons/events/DynamicFieldValue.d.ts +12 -78
  26. package/dist/commons/events/EventConfig.d.ts +37 -2250
  27. package/dist/commons/events/EventConfigInput.d.ts +0 -3
  28. package/dist/commons/events/EventDocument.d.ts +354 -1366
  29. package/dist/commons/events/EventIndex.d.ts +212 -1010
  30. package/dist/commons/events/EventInput.d.ts +3 -8
  31. package/dist/commons/events/EventMetadata.d.ts +130 -357
  32. package/dist/commons/events/FieldConfig.d.ts +2894 -12314
  33. package/dist/commons/events/FieldType.d.ts +26 -4
  34. package/dist/commons/events/FieldTypeMapping.d.ts +314 -906
  35. package/dist/commons/events/FieldValue.d.ts +149 -527
  36. package/dist/commons/events/FileUtils.d.ts +2 -2
  37. package/dist/commons/events/Flag.d.ts +67 -0
  38. package/dist/commons/events/FormConfig.d.ts +54 -721
  39. package/dist/commons/events/PageConfig.d.ts +58 -320
  40. package/dist/commons/events/PlainDate.d.ts +1 -1
  41. package/dist/commons/events/SummaryConfig.d.ts +14 -161
  42. package/dist/commons/events/TemplateConfig.d.ts +2 -3
  43. package/dist/commons/events/TranslationConfig.d.ts +2 -2
  44. package/dist/commons/events/WorkqueueColumnConfig.d.ts +74 -37
  45. package/dist/commons/events/WorkqueueConfig.d.ts +2208 -7553
  46. package/dist/commons/events/deduplication.d.ts +3 -3
  47. package/dist/commons/events/defineConfig.d.ts +2 -233
  48. package/dist/commons/events/eventConfigValidation.d.ts +8 -0
  49. package/dist/commons/events/index.d.ts +3 -0
  50. package/dist/commons/events/locations.d.ts +57 -20
  51. package/dist/commons/events/scopes.d.ts +36 -35
  52. package/dist/commons/events/state/availableActions.d.ts +7 -2
  53. package/dist/commons/events/state/flags.d.ts +21 -3
  54. package/dist/commons/events/state/index.d.ts +30 -27
  55. package/dist/commons/events/state/utils.d.ts +190 -172
  56. package/dist/commons/events/test.utils.d.ts +52 -11
  57. package/dist/commons/events/transactions.d.ts +1 -1
  58. package/dist/commons/events/utils.d.ts +374 -429
  59. package/dist/commons/notification/UserNotifications.d.ts +61 -637
  60. package/dist/conditionals/index.d.ts.map +1 -1
  61. package/dist/conditionals/index.js +302 -14
  62. package/dist/events/deduplication.d.ts +3 -3
  63. package/dist/events/index.js +2875 -2115
  64. package/dist/migrations/v2.0/add-birth-certificate-issuance-flag.d.ts +3 -0
  65. package/dist/migrations/v2.0/add-birth-certificate-issuance-flag.d.ts.map +1 -0
  66. package/dist/migrations/v2.0/add-birth-certificate-issuance-flag.js +404 -0
  67. package/dist/migrations/v2.0/checkout-upstream-files.d.ts +22 -0
  68. package/dist/migrations/v2.0/checkout-upstream-files.d.ts.map +1 -0
  69. package/dist/migrations/v2.0/checkout-upstream-files.js +147 -0
  70. package/dist/migrations/v2.0/convert-config-files-to-ts.d.ts +2 -0
  71. package/dist/migrations/v2.0/convert-config-files-to-ts.d.ts.map +1 -0
  72. package/dist/migrations/v2.0/convert-config-files-to-ts.js +828 -0
  73. package/dist/migrations/v2.0/convert-paragraph-to-heading.d.ts +3 -0
  74. package/dist/migrations/v2.0/convert-paragraph-to-heading.d.ts.map +1 -0
  75. package/dist/migrations/v2.0/convert-paragraph-to-heading.js +158 -0
  76. package/dist/migrations/v2.0/create-events-index.d.ts +3 -0
  77. package/dist/migrations/v2.0/create-events-index.d.ts.map +1 -0
  78. package/dist/migrations/v2.0/create-events-index.js +325 -0
  79. package/dist/migrations/v2.0/delete-infrastructure-directory.d.ts +3 -0
  80. package/dist/migrations/v2.0/delete-infrastructure-directory.d.ts.map +1 -0
  81. package/dist/migrations/v2.0/delete-infrastructure-directory.js +77 -0
  82. package/dist/migrations/v2.0/index.d.ts +11 -0
  83. package/dist/migrations/v2.0/index.d.ts.map +1 -0
  84. package/dist/migrations/v2.0/index.js +4437 -0
  85. package/dist/migrations/v2.0/make-built-in-validate-actions-custom.d.ts +3 -0
  86. package/dist/migrations/v2.0/make-built-in-validate-actions-custom.d.ts.map +1 -0
  87. package/dist/migrations/v2.0/make-built-in-validate-actions-custom.js +343 -0
  88. package/dist/migrations/v2.0/merge-infrastructure-directory.d.ts +3 -0
  89. package/dist/migrations/v2.0/merge-infrastructure-directory.d.ts.map +1 -0
  90. package/dist/migrations/v2.0/merge-infrastructure-directory.js +221 -0
  91. package/dist/migrations/v2.0/migrate-application-config-url.d.ts +3 -0
  92. package/dist/migrations/v2.0/migrate-application-config-url.d.ts.map +1 -0
  93. package/dist/migrations/v2.0/migrate-application-config-url.js +342 -0
  94. package/dist/migrations/v2.0/migrate-scopes.d.ts +3 -0
  95. package/dist/migrations/v2.0/migrate-scopes.d.ts.map +1 -0
  96. package/dist/migrations/v2.0/migrate-scopes.js +281 -0
  97. package/dist/migrations/v2.0/migrate-validated-workqueue-status-to-flag.d.ts +3 -0
  98. package/dist/migrations/v2.0/migrate-validated-workqueue-status-to-flag.d.ts.map +1 -0
  99. package/dist/migrations/v2.0/migrate-validated-workqueue-status-to-flag.js +267 -0
  100. package/dist/migrations/v2.0/migrate-workqueue-configs.d.ts +3 -0
  101. package/dist/migrations/v2.0/migrate-workqueue-configs.d.ts.map +1 -0
  102. package/dist/migrations/v2.0/migrate-workqueue-configs.js +236 -0
  103. package/dist/migrations/v2.0/remove-delete-actions.d.ts +3 -0
  104. package/dist/migrations/v2.0/remove-delete-actions.d.ts.map +1 -0
  105. package/dist/migrations/v2.0/remove-delete-actions.js +156 -0
  106. package/dist/migrations/v2.0/remove-demo-scope.d.ts +3 -0
  107. package/dist/migrations/v2.0/remove-demo-scope.d.ts.map +1 -0
  108. package/dist/migrations/v2.0/remove-demo-scope.js +74 -0
  109. package/dist/migrations/v2.0/remove-deprecated-imports.d.ts +3 -0
  110. package/dist/migrations/v2.0/remove-deprecated-imports.d.ts.map +1 -0
  111. package/dist/migrations/v2.0/remove-deprecated-imports.js +96 -0
  112. package/dist/migrations/v2.0/remove-fhir-url-helpers.d.ts +3 -0
  113. package/dist/migrations/v2.0/remove-fhir-url-helpers.d.ts.map +1 -0
  114. package/dist/migrations/v2.0/remove-fhir-url-helpers.js +163 -0
  115. package/dist/migrations/v2.0/remove-hearth-migrations.d.ts +3 -0
  116. package/dist/migrations/v2.0/remove-hearth-migrations.d.ts.map +1 -0
  117. package/dist/migrations/v2.0/remove-hearth-migrations.js +77 -0
  118. package/dist/migrations/v2.0/remove-old-statistics-service.d.ts +3 -0
  119. package/dist/migrations/v2.0/remove-old-statistics-service.d.ts.map +1 -0
  120. package/dist/migrations/v2.0/remove-old-statistics-service.js +356 -0
  121. package/dist/migrations/v2.0/remove-pending-certification-flag.d.ts +3 -0
  122. package/dist/migrations/v2.0/remove-pending-certification-flag.d.ts.map +1 -0
  123. package/dist/migrations/v2.0/remove-pending-certification-flag.js +109 -0
  124. package/dist/migrations/v2.0/remove-review-from-register-action.d.ts +3 -0
  125. package/dist/migrations/v2.0/remove-review-from-register-action.d.ts.map +1 -0
  126. package/dist/migrations/v2.0/remove-review-from-register-action.js +163 -0
  127. package/dist/migrations/v2.0/remove-unused-environment-variables.d.ts +3 -0
  128. package/dist/migrations/v2.0/remove-unused-environment-variables.d.ts.map +1 -0
  129. package/dist/migrations/v2.0/remove-unused-environment-variables.js +186 -0
  130. package/dist/migrations/v2.0/rename-api-paths.d.ts +3 -0
  131. package/dist/migrations/v2.0/rename-api-paths.d.ts.map +1 -0
  132. package/dist/migrations/v2.0/rename-api-paths.js +187 -0
  133. package/dist/migrations/v2.0/rename-location-parent-id.d.ts +3 -0
  134. package/dist/migrations/v2.0/rename-location-parent-id.d.ts.map +1 -0
  135. package/dist/migrations/v2.0/rename-location-parent-id.js +180 -0
  136. package/dist/migrations/v2.0/simplify-analytics-precalculations.d.ts +3 -0
  137. package/dist/migrations/v2.0/simplify-analytics-precalculations.d.ts.map +1 -0
  138. package/dist/migrations/v2.0/simplify-analytics-precalculations.js +195 -0
  139. package/dist/migrations/v2.0/update-package-json.d.ts +3 -0
  140. package/dist/migrations/v2.0/update-package-json.d.ts.map +1 -0
  141. package/dist/migrations/v2.0/update-package-json.js +105 -0
  142. package/dist/notification/index.d.ts.map +1 -1
  143. package/dist/notification/index.js +2091 -1769
  144. package/dist/scopes/index.d.ts +640 -353
  145. package/dist/scopes/index.d.ts.map +1 -1
  146. package/dist/scopes/index.js +340 -300
  147. package/opencrvs-toolkit-1.9.12-rc.d4e5c22.tgz +0 -0
  148. package/package.json +18 -8
  149. package/tsconfig.json +12 -2
  150. package/tsconfig.tsbuildinfo +1 -1
  151. package/dist/commons/events/CreatedAtLocation.d.ts +0 -2
@@ -0,0 +1,3 @@
1
+ declare function main(): Promise<void>;
2
+ export { main };
3
+ //# sourceMappingURL=remove-demo-scope.d.ts.map
@@ -0,0 +1 @@
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"}
@@ -0,0 +1,74 @@
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
+ const path_1 = __importDefault(require("path"));
27
+ const ts_morph_1 = require("ts-morph");
28
+ const ROLES_HANDLER_RELATIVE_PATH = 'src/data-seeding/roles/handler.ts';
29
+ function main() {
30
+ return __awaiter(this, void 0, void 0, function* () {
31
+ var _a;
32
+ const rolesHandlerPath = path_1.default.join(process.cwd(), ROLES_HANDLER_RELATIVE_PATH);
33
+ const project = new ts_morph_1.Project({
34
+ tsConfigFilePath: path_1.default.resolve(process.cwd(), 'tsconfig.json'),
35
+ skipAddingFilesFromTsConfig: false
36
+ });
37
+ const sourceFile = project.getSourceFile(rolesHandlerPath);
38
+ if (!sourceFile) {
39
+ // eslint-disable-next-line no-console
40
+ console.log(`No roles handler found at '${ROLES_HANDLER_RELATIVE_PATH}'. Nothing to do.`);
41
+ return;
42
+ }
43
+ let changed = false;
44
+ const constantsImport = sourceFile.getImportDeclaration((decl) => decl.getModuleSpecifierValue() === '@countryconfig/constants');
45
+ if (constantsImport) {
46
+ constantsImport.remove();
47
+ changed = true;
48
+ }
49
+ const rolesHandler = sourceFile.getFunction('rolesHandler');
50
+ if (!rolesHandler) {
51
+ // eslint-disable-next-line no-console
52
+ console.log(`No rolesHandler export found in '${ROLES_HANDLER_RELATIVE_PATH}'. Nothing to do.`);
53
+ return;
54
+ }
55
+ const secondParam = rolesHandler.getParameters()[1];
56
+ const secondParamName = secondParam === null || secondParam === void 0 ? void 0 : secondParam.getName();
57
+ const responseToolkitIdentifier = secondParamName || 'h';
58
+ const currentBodyText = rolesHandler.getBodyText();
59
+ const normalizedCurrent = (_a = currentBodyText === null || currentBodyText === void 0 ? void 0 : currentBodyText.replace(/\s+/g, ' ').trim()) !== null && _a !== void 0 ? _a : '';
60
+ const normalizedDesired = `return ${responseToolkitIdentifier}.response(roles)`;
61
+ if (normalizedCurrent !== normalizedDesired) {
62
+ rolesHandler.setBodyText(`return ${responseToolkitIdentifier}.response(roles)`);
63
+ changed = true;
64
+ }
65
+ if (!changed) {
66
+ // eslint-disable-next-line no-console
67
+ console.log(`No changes needed in '${ROLES_HANDLER_RELATIVE_PATH}'.`);
68
+ return;
69
+ }
70
+ yield sourceFile.save();
71
+ // eslint-disable-next-line no-console
72
+ console.log(`Updated '${ROLES_HANDLER_RELATIVE_PATH}' to remove demo scope behavior while preserving file structure.`);
73
+ });
74
+ }
@@ -0,0 +1,3 @@
1
+ declare function main(): Promise<void>;
2
+ export { main };
3
+ //# sourceMappingURL=remove-deprecated-imports.d.ts.map
@@ -0,0 +1 @@
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"}
@@ -0,0 +1,96 @@
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
+ const ts_morph_1 = require("ts-morph");
27
+ const path_1 = __importDefault(require("path"));
28
+ const DEPRECATED_IMPORT = 'SCOPES';
29
+ const TARGET_MODULES = new Set([
30
+ '@opencrvs/toolkit/scopes',
31
+ '@opencrvs/toolkit'
32
+ ]);
33
+ function processFile(filePath, project) {
34
+ const sourceFile = project.getSourceFile(filePath);
35
+ if (!sourceFile)
36
+ return 0;
37
+ let removedCount = 0;
38
+ const importDecls = sourceFile
39
+ .getImportDeclarations()
40
+ .filter((decl) => TARGET_MODULES.has(decl.getModuleSpecifierValue()));
41
+ for (const decl of importDecls) {
42
+ const matchingNamedImports = decl
43
+ .getNamedImports()
44
+ .filter((ni) => ni.getName() === DEPRECATED_IMPORT);
45
+ if (matchingNamedImports.length === 0)
46
+ continue;
47
+ for (const namedImport of matchingNamedImports) {
48
+ namedImport.remove();
49
+ removedCount++;
50
+ }
51
+ const hasAnyNamedImportsLeft = decl.getNamedImports().length > 0;
52
+ const hasDefaultImport = !!decl.getDefaultImport();
53
+ const hasNamespaceImport = !!decl.getNamespaceImport();
54
+ // If the declaration only contained SCOPE, remove the now-empty import line.
55
+ if (!hasAnyNamedImportsLeft && !hasDefaultImport && !hasNamespaceImport) {
56
+ decl.remove();
57
+ }
58
+ console.log(` [${path_1.default.relative(process.cwd(), filePath)}] Removed ${matchingNamedImports.length} deprecated '${DEPRECATED_IMPORT}' import(s) from '${decl.getModuleSpecifierValue()}'`);
59
+ }
60
+ return removedCount;
61
+ }
62
+ function main() {
63
+ return __awaiter(this, void 0, void 0, function* () {
64
+ const srcDir = path_1.default.join(process.cwd(), 'src');
65
+ console.log(`Scanning for deprecated imports in: ${srcDir}\n`);
66
+ const project = new ts_morph_1.Project({
67
+ tsConfigFilePath: path_1.default.resolve(srcDir, '../tsconfig.json'),
68
+ skipAddingFilesFromTsConfig: false
69
+ });
70
+ const sourceFiles = project.getSourceFiles().filter((sf) => {
71
+ const fp = sf.getFilePath();
72
+ return fp.includes('/src/') && !fp.includes('/node_modules/');
73
+ });
74
+ console.log(`Found ${sourceFiles.length} source file(s) to analyse.\n`);
75
+ let totalRemoved = 0;
76
+ const modifiedFiles = [];
77
+ for (const sourceFile of sourceFiles) {
78
+ const filePath = sourceFile.getFilePath();
79
+ const removed = processFile(filePath, project);
80
+ if (removed > 0) {
81
+ totalRemoved += removed;
82
+ modifiedFiles.push(filePath);
83
+ }
84
+ }
85
+ if (modifiedFiles.length === 0) {
86
+ console.log('No deprecated imports found. Nothing to do.');
87
+ return;
88
+ }
89
+ console.log(`\nSaving ${modifiedFiles.length} modified file(s)...`);
90
+ for (const filePath of modifiedFiles) {
91
+ yield project.getSourceFileOrThrow(filePath).save();
92
+ console.log(` Saved: ${path_1.default.relative(process.cwd(), filePath)}`);
93
+ }
94
+ console.log(`\nDone. Removed ${totalRemoved} deprecated import(s).`);
95
+ });
96
+ }
@@ -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
+ }
@@ -0,0 +1,3 @@
1
+ declare function main(): Promise<void>;
2
+ export { main };
3
+ //# sourceMappingURL=remove-hearth-migrations.d.ts.map
@@ -0,0 +1 @@
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"}
@@ -0,0 +1,77 @@
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 (mod) {
29
+ if (mod && mod.__esModule) return mod;
30
+ var result = {};
31
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
32
+ __setModuleDefault(result, mod);
33
+ return result;
34
+ };
35
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
36
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
37
+ return new (P || (P = Promise))(function (resolve, reject) {
38
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
39
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
40
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
41
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
42
+ });
43
+ };
44
+ var __importDefault = (this && this.__importDefault) || function (mod) {
45
+ return (mod && mod.__esModule) ? mod : { "default": mod };
46
+ };
47
+ Object.defineProperty(exports, "__esModule", { value: true });
48
+ exports.main = main;
49
+ const fs = __importStar(require("fs"));
50
+ const path_1 = __importDefault(require("path"));
51
+ const PATHS_TO_REMOVE = [
52
+ {
53
+ relativePath: 'src/migrations/hearth',
54
+ label: 'Hearth migrations directory'
55
+ },
56
+ {
57
+ relativePath: 'src/migrations/user-mgnt',
58
+ label: 'user-mgnt migrations directory'
59
+ },
60
+ { relativePath: 'src/utils/hearth-helpers.ts', label: 'Hearth helpers file' }
61
+ ];
62
+ function main() {
63
+ return __awaiter(this, void 0, void 0, function* () {
64
+ for (const { relativePath, label } of PATHS_TO_REMOVE) {
65
+ const absolutePath = path_1.default.join(process.cwd(), relativePath);
66
+ if (fs.existsSync(absolutePath)) {
67
+ fs.rmSync(absolutePath, { recursive: true, force: true });
68
+ // eslint-disable-next-line no-console
69
+ console.log(`Removed ${label} '${relativePath}'.`);
70
+ }
71
+ else {
72
+ // eslint-disable-next-line no-console
73
+ console.log(`No ${label} found at '${relativePath}'.`);
74
+ }
75
+ }
76
+ });
77
+ }
@@ -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"}