@opencrvs/toolkit 2.0.0-rc.ea62921 → 2.0.0-rc.eaad4e6
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.
- package/create-countryconfig/index.js +103 -0
- package/create-countryconfig/package.json +21 -0
- package/dist/application-config/index.js +306 -130
- package/dist/cli.js +1961 -350
- package/dist/commons/api/router.d.ts +3401 -269
- package/dist/commons/application-config/index.d.ts +17 -4
- package/dist/commons/conditionals/conditionals.d.ts +360 -10
- package/dist/commons/conditionals/validate.d.ts +52 -2
- package/dist/commons/events/ActionDocument.d.ts +6 -0
- package/dist/commons/events/ActionInput.d.ts +114 -0
- package/dist/commons/events/AdvancedSearchConfig.d.ts +342 -0
- package/dist/commons/events/Draft.d.ts +4 -2
- package/dist/commons/events/EventDocument.d.ts +3 -0
- package/dist/commons/events/EventIndex.d.ts +0 -3
- package/dist/commons/events/EventMetadata.d.ts +0 -7
- package/dist/commons/events/FieldConfig.d.ts +387 -50
- package/dist/commons/events/FieldValue.d.ts +6 -0
- package/dist/commons/events/WorkqueueConfig.d.ts +150 -150
- package/dist/commons/events/field.d.ts +53 -1
- package/dist/commons/events/index.d.ts +2 -0
- package/dist/commons/events/locations.d.ts +38 -1
- package/dist/commons/events/mocks.test.utils.d.ts +19 -0
- package/dist/commons/events/scopes.d.ts +24 -1
- package/dist/commons/events/state/flags.d.ts +16 -0
- package/dist/commons/events/state/index.d.ts +0 -4
- package/dist/commons/events/state/utils.d.ts +12 -289
- package/dist/commons/events/utils.d.ts +13 -2
- package/dist/conditionals/index.js +92 -9
- package/dist/events/index.js +1085 -262
- package/dist/migrations/v2.0/add-birth-certificate-issuance-flag.d.ts.map +1 -1
- package/dist/migrations/v2.0/add-birth-certificate-issuance-flag.js +63 -39
- package/dist/migrations/v2.0/add-resend-invite-notification.d.ts +3 -0
- package/dist/migrations/v2.0/add-resend-invite-notification.d.ts.map +1 -0
- package/dist/migrations/v2.0/add-resend-invite-notification.js +373 -0
- package/dist/migrations/v2.0/checkout-upstream-files.d.ts +19 -0
- package/dist/migrations/v2.0/checkout-upstream-files.d.ts.map +1 -1
- package/dist/migrations/v2.0/checkout-upstream-files.js +17 -14
- package/dist/migrations/v2.0/convert-config-files-to-ts.d.ts.map +1 -1
- package/dist/migrations/v2.0/convert-config-files-to-ts.js +4 -5
- package/dist/migrations/v2.0/convert-paragraph-to-heading.d.ts.map +1 -1
- package/dist/migrations/v2.0/convert-paragraph-to-heading.js +4 -5
- package/dist/migrations/v2.0/create-events-index.d.ts.map +1 -1
- package/dist/migrations/v2.0/create-events-index.js +1 -2
- package/dist/migrations/v2.0/delete-infrastructure-directory.d.ts +11 -0
- package/dist/migrations/v2.0/delete-infrastructure-directory.d.ts.map +1 -0
- package/dist/migrations/v2.0/delete-infrastructure-directory.js +123 -0
- package/dist/migrations/v2.0/fix-accept-requested-registration-function-type.d.ts +3 -0
- package/dist/migrations/v2.0/fix-accept-requested-registration-function-type.d.ts.map +1 -0
- package/dist/migrations/v2.0/fix-accept-requested-registration-function-type.js +110 -0
- package/dist/migrations/v2.0/index.d.ts +10 -4
- package/dist/migrations/v2.0/index.d.ts.map +1 -1
- package/dist/migrations/v2.0/index.js +1929 -347
- package/dist/migrations/v2.0/make-built-in-validate-actions-custom.d.ts.map +1 -1
- package/dist/migrations/v2.0/make-built-in-validate-actions-custom.js +95 -7
- package/dist/migrations/v2.0/merge-infrastructure-directory.d.ts +13 -0
- package/dist/migrations/v2.0/merge-infrastructure-directory.d.ts.map +1 -0
- package/dist/migrations/v2.0/merge-infrastructure-directory.js +222 -0
- package/dist/migrations/v2.0/migrate-application-config-url.d.ts +3 -0
- package/dist/migrations/v2.0/migrate-application-config-url.d.ts.map +1 -0
- package/dist/migrations/v2.0/migrate-application-config-url.js +342 -0
- package/dist/migrations/v2.0/migrate-scopes.d.ts.map +1 -1
- package/dist/migrations/v2.0/migrate-scopes.js +55 -32
- package/dist/migrations/v2.0/migrate-validated-workqueue-status-to-flag.d.ts.map +1 -1
- package/dist/migrations/v2.0/migrate-validated-workqueue-status-to-flag.js +3 -4
- package/dist/migrations/v2.0/migrate-workqueue-configs.d.ts.map +1 -1
- package/dist/migrations/v2.0/migrate-workqueue-configs.js +143 -63
- package/dist/migrations/v2.0/remove-delete-actions.d.ts.map +1 -1
- package/dist/migrations/v2.0/remove-delete-actions.js +3 -4
- package/dist/migrations/v2.0/remove-demo-scope.d.ts.map +1 -1
- package/dist/migrations/v2.0/remove-demo-scope.js +2 -3
- package/dist/migrations/v2.0/remove-deprecated-imports.d.ts.map +1 -1
- package/dist/migrations/v2.0/remove-deprecated-imports.js +3 -4
- package/dist/migrations/v2.0/remove-fhir-url-helpers.d.ts +3 -0
- package/dist/migrations/v2.0/remove-fhir-url-helpers.d.ts.map +1 -0
- package/dist/migrations/v2.0/remove-fhir-url-helpers.js +163 -0
- package/dist/migrations/v2.0/remove-hearth-migrations.d.ts.map +1 -1
- package/dist/migrations/v2.0/remove-hearth-migrations.js +1 -2
- package/dist/migrations/v2.0/remove-old-statistics-service.d.ts +3 -0
- package/dist/migrations/v2.0/remove-old-statistics-service.d.ts.map +1 -0
- package/dist/migrations/v2.0/remove-old-statistics-service.js +356 -0
- package/dist/migrations/v2.0/remove-pending-certification-flag.d.ts.map +1 -1
- package/dist/migrations/v2.0/remove-pending-certification-flag.js +3 -4
- package/dist/migrations/v2.0/remove-review-from-register-action.d.ts.map +1 -1
- package/dist/migrations/v2.0/remove-review-from-register-action.js +3 -4
- package/dist/migrations/v2.0/remove-unused-environment-variables.d.ts +3 -0
- package/dist/migrations/v2.0/remove-unused-environment-variables.d.ts.map +1 -0
- package/dist/migrations/v2.0/remove-unused-environment-variables.js +186 -0
- package/dist/migrations/v2.0/rename-api-paths.d.ts.map +1 -1
- package/dist/migrations/v2.0/rename-api-paths.js +3 -4
- package/dist/migrations/v2.0/rename-location-parent-id.d.ts.map +1 -1
- package/dist/migrations/v2.0/rename-location-parent-id.js +3 -4
- package/dist/migrations/v2.0/simplify-analytics-precalculations.d.ts.map +1 -1
- package/dist/migrations/v2.0/simplify-analytics-precalculations.js +1 -2
- package/dist/migrations/v2.0/update-package-json.d.ts +3 -0
- package/dist/migrations/v2.0/update-package-json.d.ts.map +1 -0
- package/dist/migrations/v2.0/update-package-json.js +105 -0
- package/dist/notification/index.js +842 -161
- package/dist/scopes/index.d.ts +91 -16
- package/dist/scopes/index.js +55 -12
- package/opencrvs-toolkit-2.0.0-rc.eaad4e6.tgz +0 -0
- package/package.json +6 -2
- package/tsconfig.tsbuildinfo +1 -1
- package/opencrvs-toolkit-2.0.0-rc.ea62921.tgz +0 -0
|
@@ -19,6 +19,10 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
19
19
|
});
|
|
20
20
|
};
|
|
21
21
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
|
+
exports.UPSTREAM_BRANCH = exports.UPSTREAM_URL = void 0;
|
|
23
|
+
exports.runGit = runGit;
|
|
24
|
+
exports.tryGit = tryGit;
|
|
25
|
+
exports.assertIsGitRepo = assertIsGitRepo;
|
|
22
26
|
exports.main = main;
|
|
23
27
|
/**
|
|
24
28
|
* Codemod: Replace selected files with their upstream v2.0 versions from
|
|
@@ -54,16 +58,15 @@ exports.main = main;
|
|
|
54
58
|
* - Requires the country config working directory to be a git repo.
|
|
55
59
|
*/
|
|
56
60
|
const child_process_1 = require("child_process");
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
// @TODO: This needs to be changed to 'release-v2.0.0' once the branch is created
|
|
60
|
-
const UPSTREAM_BRANCH = 'develop';
|
|
61
|
+
exports.UPSTREAM_URL = 'https://github.com/opencrvs/opencrvs-countryconfig.git';
|
|
62
|
+
exports.UPSTREAM_BRANCH = 'release-v2.0.0';
|
|
61
63
|
// Remote name used only for the duration of this codemod. Prefixed to avoid
|
|
62
64
|
// clashing with remotes the user may have (origin, upstream, etc.).
|
|
63
65
|
const TEMP_REMOTE = 'opencrvs-upgrade-v19-v20-codemod';
|
|
64
66
|
const FILES_TO_CHECKOUT = [
|
|
65
|
-
'
|
|
66
|
-
'
|
|
67
|
+
'src/analytics/analytics.ts',
|
|
68
|
+
'Dockerfile',
|
|
69
|
+
'Dockerfile.assets'
|
|
67
70
|
];
|
|
68
71
|
// ─── Git helpers ─────────────────────────────────────────────────────────────
|
|
69
72
|
/**
|
|
@@ -75,7 +78,7 @@ const FILES_TO_CHECKOUT = [
|
|
|
75
78
|
*/
|
|
76
79
|
function runGit(args, { silent = false } = {}) {
|
|
77
80
|
return (0, child_process_1.execFileSync)('git', args, {
|
|
78
|
-
cwd:
|
|
81
|
+
cwd: process.cwd(),
|
|
79
82
|
encoding: 'utf8',
|
|
80
83
|
stdio: silent ? ['ignore', 'pipe', 'pipe'] : ['ignore', 'pipe', 'inherit']
|
|
81
84
|
});
|
|
@@ -96,22 +99,22 @@ function tryGit(args) {
|
|
|
96
99
|
}
|
|
97
100
|
function assertIsGitRepo() {
|
|
98
101
|
if (!tryGit(['rev-parse', '--is-inside-work-tree'])) {
|
|
99
|
-
throw new Error(
|
|
102
|
+
throw new Error(`${process.cwd()} is not a git repository. Initialise git (or run the upgrade inside a git checkout) before re-running.`);
|
|
100
103
|
}
|
|
101
104
|
}
|
|
102
105
|
// ─── Entry point ─────────────────────────────────────────────────────────────
|
|
103
106
|
function main() {
|
|
104
107
|
return __awaiter(this, void 0, void 0, function* () {
|
|
105
|
-
console.log(`Checking out ${FILES_TO_CHECKOUT.length} file(s) from ${UPSTREAM_URL}@${UPSTREAM_BRANCH}...\n`);
|
|
108
|
+
console.log(`Checking out ${FILES_TO_CHECKOUT.length} file(s) from ${exports.UPSTREAM_URL}@${exports.UPSTREAM_BRANCH}...\n`);
|
|
106
109
|
assertIsGitRepo();
|
|
107
110
|
// Best-effort cleanup of a stale temp remote from a previous aborted run.
|
|
108
111
|
tryGit(['remote', 'remove', TEMP_REMOTE]);
|
|
109
112
|
try {
|
|
110
|
-
console.log(` Adding temporary remote '${TEMP_REMOTE}' → ${UPSTREAM_URL}`);
|
|
111
|
-
runGit(['remote', 'add', TEMP_REMOTE, UPSTREAM_URL], { silent: true });
|
|
112
|
-
console.log(` Fetching ${TEMP_REMOTE}/${UPSTREAM_BRANCH} (depth 1)...`);
|
|
113
|
-
runGit(['fetch', '--depth=1', TEMP_REMOTE, UPSTREAM_BRANCH]);
|
|
114
|
-
const ref = `${TEMP_REMOTE}/${UPSTREAM_BRANCH}`;
|
|
113
|
+
console.log(` Adding temporary remote '${TEMP_REMOTE}' → ${exports.UPSTREAM_URL}`);
|
|
114
|
+
runGit(['remote', 'add', TEMP_REMOTE, exports.UPSTREAM_URL], { silent: true });
|
|
115
|
+
console.log(` Fetching ${TEMP_REMOTE}/${exports.UPSTREAM_BRANCH} (depth 1)...`);
|
|
116
|
+
runGit(['fetch', '--depth=1', TEMP_REMOTE, exports.UPSTREAM_BRANCH]);
|
|
117
|
+
const ref = `${TEMP_REMOTE}/${exports.UPSTREAM_BRANCH}`;
|
|
115
118
|
const missing = [];
|
|
116
119
|
let checkedOut = 0;
|
|
117
120
|
for (const file of FILES_TO_CHECKOUT) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"convert-config-files-to-ts.d.ts","sourceRoot":"","sources":["../../../src/migrations/v2.0/convert-config-files-to-ts.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"convert-config-files-to-ts.d.ts","sourceRoot":"","sources":["../../../src/migrations/v2.0/convert-config-files-to-ts.ts"],"names":[],"mappings":"AAuuBA,wBAAsB,IAAI,kBAyPzB"}
|
|
@@ -87,7 +87,6 @@ exports.main = main;
|
|
|
87
87
|
const fs = __importStar(require("fs"));
|
|
88
88
|
const ts_morph_1 = require("ts-morph");
|
|
89
89
|
const path_1 = __importDefault(require("path"));
|
|
90
|
-
const _1 = require(".");
|
|
91
90
|
// ─── Schema-valid keys per config type ───────────────────────────────────────
|
|
92
91
|
const CLIENT_VALID_KEYS = new Set([
|
|
93
92
|
'COUNTRY',
|
|
@@ -634,8 +633,8 @@ function ensureJoinImport(sf) {
|
|
|
634
633
|
function main() {
|
|
635
634
|
return __awaiter(this, void 0, void 0, function* () {
|
|
636
635
|
var _a;
|
|
637
|
-
const srcDir = path_1.default.join(
|
|
638
|
-
const relCwd = (fp) => path_1.default.relative(
|
|
636
|
+
const srcDir = path_1.default.join(process.cwd(), 'src');
|
|
637
|
+
const relCwd = (fp) => path_1.default.relative(process.cwd(), fp);
|
|
639
638
|
// ── Phase 1: Convert JS config files to TypeScript ────────────────────────
|
|
640
639
|
console.log('Phase 1: Converting JS config files to TypeScript...\n');
|
|
641
640
|
let convertedCount = 0;
|
|
@@ -741,7 +740,7 @@ function main() {
|
|
|
741
740
|
if (/\bjoin\s*\(/.test(adjustedValue)) {
|
|
742
741
|
ensureJoinImport(sf);
|
|
743
742
|
}
|
|
744
|
-
console.log(` Inlined applicationConfig.${accessPath.join('.')} → ${adjustedValue} in ${path_1.default.relative(
|
|
743
|
+
console.log(` Inlined applicationConfig.${accessPath.join('.')} → ${adjustedValue} in ${path_1.default.relative(process.cwd(), sf.getFilePath())}`);
|
|
745
744
|
filesToSaveAfterInlining.add(sf);
|
|
746
745
|
madeReplacement = true;
|
|
747
746
|
break; // restart — tree has changed
|
|
@@ -752,7 +751,7 @@ function main() {
|
|
|
752
751
|
// Persist files that received inline replacements
|
|
753
752
|
for (const sf of Array.from(filesToSaveAfterInlining)) {
|
|
754
753
|
yield sf.save();
|
|
755
|
-
console.log(` Saved (inlined): ${path_1.default.relative(
|
|
754
|
+
console.log(` Saved (inlined): ${path_1.default.relative(process.cwd(), sf.getFilePath())}`);
|
|
756
755
|
}
|
|
757
756
|
// Remove in reverse order to avoid index shifting
|
|
758
757
|
for (const prop of [...propsToRemove].reverse()) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"convert-paragraph-to-heading.d.ts","sourceRoot":"","sources":["../../../src/migrations/v2.0/convert-paragraph-to-heading.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"convert-paragraph-to-heading.d.ts","sourceRoot":"","sources":["../../../src/migrations/v2.0/convert-paragraph-to-heading.ts"],"names":[],"mappings":"AAsJA,iBAAe,IAAI,kBA6ClB;AAED,OAAO,EAAE,IAAI,EAAE,CAAA"}
|
|
@@ -42,7 +42,6 @@ exports.main = main;
|
|
|
42
42
|
*/
|
|
43
43
|
const ts_morph_1 = require("ts-morph");
|
|
44
44
|
const path_1 = __importDefault(require("path"));
|
|
45
|
-
const _1 = require(".");
|
|
46
45
|
const FIELD_TYPE_ENUM_NAME = 'FieldType';
|
|
47
46
|
const PARAGRAPH_MEMBER_NAME = 'PARAGRAPH';
|
|
48
47
|
const HEADING_MEMBER_NAME = 'HEADING';
|
|
@@ -112,18 +111,18 @@ function processFile(filePath, project) {
|
|
|
112
111
|
const result = transformParagraphField(obj);
|
|
113
112
|
if (result === 'converted-to-heading') {
|
|
114
113
|
changedCount++;
|
|
115
|
-
console.log(` [${path_1.default.relative(
|
|
114
|
+
console.log(` [${path_1.default.relative(process.cwd(), filePath)}] Converted PARAGRAPH with heading fontVariant to HEADING`);
|
|
116
115
|
}
|
|
117
116
|
else if (result === 'removed-font-variant') {
|
|
118
117
|
changedCount++;
|
|
119
|
-
console.log(` [${path_1.default.relative(
|
|
118
|
+
console.log(` [${path_1.default.relative(process.cwd(), filePath)}] Removed non-heading fontVariant from PARAGRAPH`);
|
|
120
119
|
}
|
|
121
120
|
}
|
|
122
121
|
return changedCount;
|
|
123
122
|
}
|
|
124
123
|
function main() {
|
|
125
124
|
return __awaiter(this, void 0, void 0, function* () {
|
|
126
|
-
const srcDir = path_1.default.join(
|
|
125
|
+
const srcDir = path_1.default.join(process.cwd(), 'src');
|
|
127
126
|
console.log(`Scanning for FieldType.PARAGRAPH fields in: ${srcDir}\n`);
|
|
128
127
|
const project = new ts_morph_1.Project({
|
|
129
128
|
tsConfigFilePath: path_1.default.resolve(srcDir, '../tsconfig.json'),
|
|
@@ -152,7 +151,7 @@ function main() {
|
|
|
152
151
|
for (const filePath of modifiedFiles) {
|
|
153
152
|
const sourceFile = project.getSourceFileOrThrow(filePath);
|
|
154
153
|
yield sourceFile.save();
|
|
155
|
-
console.log(` Saved: ${path_1.default.relative(
|
|
154
|
+
console.log(` Saved: ${path_1.default.relative(process.cwd(), filePath)}`);
|
|
156
155
|
}
|
|
157
156
|
console.log(`\nDone. Processed ${totalChanged} FieldType.PARAGRAPH field(s).`);
|
|
158
157
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-events-index.d.ts","sourceRoot":"","sources":["../../../src/migrations/v2.0/create-events-index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"create-events-index.d.ts","sourceRoot":"","sources":["../../../src/migrations/v2.0/create-events-index.ts"],"names":[],"mappings":"AAmTA,iBAAe,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,CAmEnC;AAED,OAAO,EAAE,IAAI,EAAE,CAAA"}
|
|
@@ -63,7 +63,6 @@ exports.main = main;
|
|
|
63
63
|
const ts_morph_1 = require("ts-morph");
|
|
64
64
|
const fs_1 = __importDefault(require("fs"));
|
|
65
65
|
const path_1 = __importDefault(require("path"));
|
|
66
|
-
const _1 = require(".");
|
|
67
66
|
const DEFINE_CONFIG_NAME = 'defineConfig';
|
|
68
67
|
const HANDLER_FUNCTION_NAMES = new Set([
|
|
69
68
|
'getCustomEventsHandler',
|
|
@@ -274,7 +273,7 @@ function modifyHandler(sourceFile, exportNames) {
|
|
|
274
273
|
// ─── Entry point ─────────────────────────────────────────────────────────────
|
|
275
274
|
function main() {
|
|
276
275
|
return __awaiter(this, void 0, void 0, function* () {
|
|
277
|
-
const cwd =
|
|
276
|
+
const cwd = process.cwd();
|
|
278
277
|
const srcDir = path_1.default.join(cwd, 'src');
|
|
279
278
|
console.log(`Scanning for defineConfig event exports in: ${srcDir}\n`);
|
|
280
279
|
const project = new ts_morph_1.Project({
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
interface DeleteInfrastructureOptions {
|
|
2
|
+
/**
|
|
3
|
+
* Top-level entries directly under `infrastructure/` to preserve. Names
|
|
4
|
+
* match against the basename of each entry (file or directory). When
|
|
5
|
+
* empty (the default), the whole `infrastructure/` directory is deleted.
|
|
6
|
+
*/
|
|
7
|
+
keep?: string[];
|
|
8
|
+
}
|
|
9
|
+
declare function main({ keep }?: DeleteInfrastructureOptions): Promise<void>;
|
|
10
|
+
export { main };
|
|
11
|
+
//# sourceMappingURL=delete-infrastructure-directory.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"delete-infrastructure-directory.d.ts","sourceRoot":"","sources":["../../../src/migrations/v2.0/delete-infrastructure-directory.ts"],"names":[],"mappings":"AAoDA,UAAU,2BAA2B;IACnC;;;;OAIG;IACH,IAAI,CAAC,EAAE,MAAM,EAAE,CAAA;CAChB;AAED,iBAAe,IAAI,CAAC,EAClB,IAAS,EACV,GAAE,2BAAgC,GAAG,OAAO,CAAC,IAAI,CAAC,CA4FlD;AAED,OAAO,EAAE,IAAI,EAAE,CAAA"}
|
|
@@ -0,0 +1,123 @@
|
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
|
+
exports.main = main;
|
|
23
|
+
/**
|
|
24
|
+
* Codemod: Remove the local `infrastructure/` directory.
|
|
25
|
+
*
|
|
26
|
+
* Used by the v1.9 → v2.0 upgrade when the country config does NOT deploy
|
|
27
|
+
* via Docker Swarm. In that case the `infrastructure/` directory shipped
|
|
28
|
+
* with opencrvs-countryconfig is no longer needed and can be removed.
|
|
29
|
+
*
|
|
30
|
+
* Some non-Swarm deployments still need a small subset of
|
|
31
|
+
* `infrastructure/` (e.g. `postgres/` and `metabase/`). Pass `keep` to
|
|
32
|
+
* preserve those top-level subdirectories — everything else under
|
|
33
|
+
* `infrastructure/` is deleted, and the kept subdirectories can then be
|
|
34
|
+
* refreshed from upstream by `merge-infrastructure-directory.ts` with the
|
|
35
|
+
* matching `subdirs` option.
|
|
36
|
+
*
|
|
37
|
+
* Usage:
|
|
38
|
+
* ts-node -r tsconfig-paths/register src/migrations/v2.0/delete-infrastructure-directory.ts
|
|
39
|
+
*
|
|
40
|
+
* What it does:
|
|
41
|
+
* 1. Stages deletion of all tracked files under `infrastructure/` via
|
|
42
|
+
* `git rm -rf --ignore-unmatch -- <path>`. This both removes the
|
|
43
|
+
* files from the working tree and records the deletion in the
|
|
44
|
+
* index, so it shows up in the upgrade commit alongside the other
|
|
45
|
+
* codemod changes. When `keep` is provided, deletion is scoped to
|
|
46
|
+
* the top-level entries that are NOT in `keep`.
|
|
47
|
+
* 2. Cleans up any untracked files / empty directory that `git rm` left
|
|
48
|
+
* behind, so the deleted paths are fully gone from the working tree.
|
|
49
|
+
*
|
|
50
|
+
* Caveats:
|
|
51
|
+
* - Destructive: any local edits to deleted paths are lost. Run on a
|
|
52
|
+
* clean working tree (or after committing your local changes).
|
|
53
|
+
* - If `infrastructure/` doesn't exist, this codemod is a no-op.
|
|
54
|
+
* - Requires git to be installed and the country config working directory
|
|
55
|
+
* to be a git repo.
|
|
56
|
+
*/
|
|
57
|
+
const fs_1 = require("fs");
|
|
58
|
+
const path_1 = require("path");
|
|
59
|
+
const checkout_upstream_files_1 = require("./checkout-upstream-files");
|
|
60
|
+
const INFRASTRUCTURE_DIR = 'infrastructure';
|
|
61
|
+
function main() {
|
|
62
|
+
return __awaiter(this, arguments, void 0, function* ({ keep = [] } = {}) {
|
|
63
|
+
const fullPath = (0, path_1.join)(process.cwd(), INFRASTRUCTURE_DIR);
|
|
64
|
+
if (!(0, fs_1.existsSync)(fullPath)) {
|
|
65
|
+
console.log(`'${INFRASTRUCTURE_DIR}/' not found in ${process.cwd()} — nothing to delete.`);
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
(0, checkout_upstream_files_1.assertIsGitRepo)();
|
|
69
|
+
// ─── Whole-directory delete (legacy behavior) ────────────────────────
|
|
70
|
+
if (keep.length === 0) {
|
|
71
|
+
console.log(`Deleting '${INFRASTRUCTURE_DIR}/'...\n`);
|
|
72
|
+
// `git rm -rf --ignore-unmatch` removes tracked files (working tree +
|
|
73
|
+
// index) and is a no-op for paths with no tracked entries, so it's
|
|
74
|
+
// safe to run even when `infrastructure/` exists only as untracked
|
|
75
|
+
// files.
|
|
76
|
+
(0, checkout_upstream_files_1.runGit)(['rm', '-rf', '--ignore-unmatch', '--', `${INFRASTRUCTURE_DIR}/`], {
|
|
77
|
+
silent: true
|
|
78
|
+
});
|
|
79
|
+
console.log(` Staged deletion of tracked files under '${INFRASTRUCTURE_DIR}/'.`);
|
|
80
|
+
// `git rm` leaves untracked files (and any now-empty directory) on
|
|
81
|
+
// disk; remove whatever's left so the path is fully gone.
|
|
82
|
+
if ((0, fs_1.existsSync)(fullPath)) {
|
|
83
|
+
(0, fs_1.rmSync)(fullPath, { recursive: true, force: true });
|
|
84
|
+
console.log(` Removed remaining untracked files under '${INFRASTRUCTURE_DIR}/'.`);
|
|
85
|
+
}
|
|
86
|
+
console.log(`\n Done. Review the staged deletion with: git diff --cached -- '${INFRASTRUCTURE_DIR}/'`);
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
// ─── Selective delete: keep listed top-level entries ─────────────────
|
|
90
|
+
const keepSet = new Set(keep);
|
|
91
|
+
console.log(`Deleting contents of '${INFRASTRUCTURE_DIR}/' except: ${[...keepSet]
|
|
92
|
+
.map((name) => `'${name}'`)
|
|
93
|
+
.join(', ')}\n`);
|
|
94
|
+
const topLevelEntries = (0, fs_1.readdirSync)(fullPath, { withFileTypes: true });
|
|
95
|
+
let deleted = 0;
|
|
96
|
+
for (const entry of topLevelEntries) {
|
|
97
|
+
if (keepSet.has(entry.name)) {
|
|
98
|
+
console.log(` Keeping '${INFRASTRUCTURE_DIR}/${entry.name}'.`);
|
|
99
|
+
continue;
|
|
100
|
+
}
|
|
101
|
+
// Append a trailing slash for directories so git treats it as a tree
|
|
102
|
+
// pathspec (matches the recursive behavior of `git rm -rf`).
|
|
103
|
+
const relPath = `${INFRASTRUCTURE_DIR}/${entry.name}${entry.isDirectory() ? '/' : ''}`;
|
|
104
|
+
(0, checkout_upstream_files_1.runGit)(['rm', '-rf', '--ignore-unmatch', '--', relPath], { silent: true });
|
|
105
|
+
const fullEntryPath = (0, path_1.join)(fullPath, entry.name);
|
|
106
|
+
if ((0, fs_1.existsSync)(fullEntryPath)) {
|
|
107
|
+
(0, fs_1.rmSync)(fullEntryPath, { recursive: true, force: true });
|
|
108
|
+
}
|
|
109
|
+
console.log(` Deleted '${relPath}'.`);
|
|
110
|
+
deleted++;
|
|
111
|
+
}
|
|
112
|
+
// Note any requested keeps that weren't actually present, so the dev
|
|
113
|
+
// notices typos / missing directories.
|
|
114
|
+
const presentNames = new Set(topLevelEntries.map((e) => e.name));
|
|
115
|
+
const missingKeeps = [...keepSet].filter((name) => !presentNames.has(name));
|
|
116
|
+
if (missingKeeps.length > 0) {
|
|
117
|
+
console.warn(` [warn] Requested to keep ${missingKeeps
|
|
118
|
+
.map((n) => `'${n}'`)
|
|
119
|
+
.join(', ')} but they don't exist under '${INFRASTRUCTURE_DIR}/'.`);
|
|
120
|
+
}
|
|
121
|
+
console.log(`\n Done. Deleted ${deleted} top-level entr${deleted === 1 ? 'y' : 'ies'}. Review the staged deletions with: git diff --cached -- '${INFRASTRUCTURE_DIR}/'`);
|
|
122
|
+
});
|
|
123
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fix-accept-requested-registration-function-type.d.ts","sourceRoot":"","sources":["../../../src/migrations/v2.0/fix-accept-requested-registration-function-type.ts"],"names":[],"mappings":"AAuFA,iBAAe,IAAI,kBA6ClB;AAED,OAAO,EAAE,IAAI,EAAE,CAAA"}
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
4
|
+
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
5
|
+
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
|
6
|
+
*
|
|
7
|
+
* OpenCRVS is also distributed under the terms of the Civil Registration
|
|
8
|
+
* & Healthcare Disclaimer located at http://opencrvs.org/license.
|
|
9
|
+
*
|
|
10
|
+
* Copyright (C) The OpenCRVS Authors located at https://github.com/opencrvs/opencrvs-core/blob/master/AUTHORS.
|
|
11
|
+
*/
|
|
12
|
+
var __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: In `acceptRequestedRegistration`, update the `action` parameter type from:
|
|
28
|
+
* action: ActionInput
|
|
29
|
+
* to:
|
|
30
|
+
* action: Extract<ActionInput, { type?: 'REGISTER' }>
|
|
31
|
+
*
|
|
32
|
+
* What it does:
|
|
33
|
+
* - Scans all TypeScript files under `src/`
|
|
34
|
+
* - Finds `acceptRequestedRegistration` (function declaration or const assignment)
|
|
35
|
+
* - Rewrites only the `action` parameter when its type is exactly `ActionInput`
|
|
36
|
+
* - Saves modified files in-place
|
|
37
|
+
*/
|
|
38
|
+
/* eslint-disable no-console */
|
|
39
|
+
const ts_morph_1 = require("ts-morph");
|
|
40
|
+
const path_1 = __importDefault(require("path"));
|
|
41
|
+
const TARGET_FUNCTION_NAME = 'acceptRequestedRegistration';
|
|
42
|
+
const ACTION_PARAMETER_NAME = 'action';
|
|
43
|
+
const OLD_TYPE = 'ActionInput';
|
|
44
|
+
const NEW_TYPE = "Extract<ActionInput, { type?: 'REGISTER' }>";
|
|
45
|
+
function isAcceptRequestedRegistrationParameter(parameter) {
|
|
46
|
+
const functionDeclaration = parameter.getFirstAncestorByKind(ts_morph_1.SyntaxKind.FunctionDeclaration);
|
|
47
|
+
if ((functionDeclaration === null || functionDeclaration === void 0 ? void 0 : functionDeclaration.getName()) === TARGET_FUNCTION_NAME) {
|
|
48
|
+
return true;
|
|
49
|
+
}
|
|
50
|
+
const arrowFunction = parameter.getFirstAncestorByKind(ts_morph_1.SyntaxKind.ArrowFunction);
|
|
51
|
+
const variableDeclaration = arrowFunction === null || arrowFunction === void 0 ? void 0 : arrowFunction.getFirstAncestorByKind(ts_morph_1.SyntaxKind.VariableDeclaration);
|
|
52
|
+
return (variableDeclaration === null || variableDeclaration === void 0 ? void 0 : variableDeclaration.getName()) === TARGET_FUNCTION_NAME;
|
|
53
|
+
}
|
|
54
|
+
function processFile(filePath, project) {
|
|
55
|
+
const sourceFile = project.getSourceFile(filePath);
|
|
56
|
+
if (!sourceFile)
|
|
57
|
+
return 0;
|
|
58
|
+
let updatedCount = 0;
|
|
59
|
+
for (const parameter of sourceFile.getDescendantsOfKind(ts_morph_1.SyntaxKind.Parameter)) {
|
|
60
|
+
if (parameter.getName() !== ACTION_PARAMETER_NAME) {
|
|
61
|
+
continue;
|
|
62
|
+
}
|
|
63
|
+
if (!isAcceptRequestedRegistrationParameter(parameter)) {
|
|
64
|
+
continue;
|
|
65
|
+
}
|
|
66
|
+
const typeNode = parameter.getTypeNode();
|
|
67
|
+
if (!typeNode || typeNode.getText() !== OLD_TYPE) {
|
|
68
|
+
continue;
|
|
69
|
+
}
|
|
70
|
+
parameter.setType(NEW_TYPE);
|
|
71
|
+
updatedCount++;
|
|
72
|
+
console.log(` [${path_1.default.relative(process.cwd(), filePath)}] Updated '${ACTION_PARAMETER_NAME}' in ${TARGET_FUNCTION_NAME} to ${NEW_TYPE}`);
|
|
73
|
+
}
|
|
74
|
+
return updatedCount;
|
|
75
|
+
}
|
|
76
|
+
function main() {
|
|
77
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
78
|
+
const srcDir = path_1.default.join(process.cwd(), 'src');
|
|
79
|
+
console.log(`Scanning for ${TARGET_FUNCTION_NAME} in: ${srcDir}\n`);
|
|
80
|
+
const project = new ts_morph_1.Project({
|
|
81
|
+
tsConfigFilePath: path_1.default.resolve(srcDir, '../tsconfig.json'),
|
|
82
|
+
skipAddingFilesFromTsConfig: false
|
|
83
|
+
});
|
|
84
|
+
const sourceFiles = project.getSourceFiles().filter((sf) => {
|
|
85
|
+
const filePath = sf.getFilePath();
|
|
86
|
+
return filePath.includes('/src/') && !filePath.includes('/node_modules/');
|
|
87
|
+
});
|
|
88
|
+
let totalUpdated = 0;
|
|
89
|
+
const modifiedFiles = [];
|
|
90
|
+
for (const sourceFile of sourceFiles) {
|
|
91
|
+
const filePath = sourceFile.getFilePath();
|
|
92
|
+
const updated = processFile(filePath, project);
|
|
93
|
+
if (updated > 0) {
|
|
94
|
+
totalUpdated += updated;
|
|
95
|
+
modifiedFiles.push(filePath);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
if (modifiedFiles.length === 0) {
|
|
99
|
+
console.log(`No '${ACTION_PARAMETER_NAME}: ${OLD_TYPE}' parameter in ${TARGET_FUNCTION_NAME} found. Nothing to do.`);
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
102
|
+
console.log(`\nSaving ${modifiedFiles.length} modified file(s)...`);
|
|
103
|
+
for (const filePath of modifiedFiles) {
|
|
104
|
+
const sourceFile = project.getSourceFileOrThrow(filePath);
|
|
105
|
+
yield sourceFile.save();
|
|
106
|
+
console.log(` Saved: ${path_1.default.relative(process.cwd(), filePath)}`);
|
|
107
|
+
}
|
|
108
|
+
console.log(`\nDone. Updated ${totalUpdated} parameter type annotation(s) in ${TARGET_FUNCTION_NAME}.`);
|
|
109
|
+
});
|
|
110
|
+
}
|
|
@@ -1,7 +1,13 @@
|
|
|
1
|
-
export declare function getCwd(): string;
|
|
2
1
|
/**
|
|
3
|
-
* Run the upgrade process for
|
|
4
|
-
*
|
|
2
|
+
* Run the upgrade process for the country config in the current working
|
|
3
|
+
* directory.
|
|
4
|
+
*
|
|
5
|
+
* @param dockerSwarm - When true, the local `infrastructure/` directory is
|
|
6
|
+
* merged with upstream changes in its entirety (Docker Swarm deployments
|
|
7
|
+
* still need it all). When false (the default), everything under
|
|
8
|
+
* `infrastructure/` is deleted EXCEPT the subdirectories listed in
|
|
9
|
+
* `NON_SWARM_INFRA_SUBDIRS`, and those preserved subdirectories are then
|
|
10
|
+
* merged with upstream.
|
|
5
11
|
*/
|
|
6
|
-
export declare function runUpgrade(
|
|
12
|
+
export declare function runUpgrade(dockerSwarm: boolean): Promise<void>;
|
|
7
13
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/migrations/v2.0/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/migrations/v2.0/index.ts"],"names":[],"mappings":"AA8CA;;;;;;;;;;GAUG;AACH,wBAAsB,UAAU,CAAC,WAAW,EAAE,OAAO,iBAiCpD"}
|