@opencrvs/toolkit 1.9.13-rc.fc5374d → 2.0.0-rc.e0918cb
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/build.sh +13 -0
- package/dist/api/index.d.ts.map +1 -1
- package/dist/application-config/index.d.ts +2 -0
- package/dist/application-config/index.d.ts.map +1 -0
- package/dist/application-config/index.js +2128 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +3633 -0
- package/dist/commons/api/router.d.ts +3438 -2300
- package/dist/commons/application-config/index.d.ts +84 -0
- package/dist/commons/conditionals/conditionals.d.ts +27 -3
- package/dist/commons/conditionals/validate.d.ts +13 -3
- package/dist/commons/events/ActionConfig.d.ts +415 -1555
- package/dist/commons/events/ActionDocument.d.ts +888 -1941
- package/dist/commons/events/ActionInput.d.ts +277 -1073
- package/dist/commons/events/ActionType.d.ts +91 -11
- package/dist/commons/events/AdvancedSearchConfig.d.ts +294 -1496
- package/dist/commons/events/AuditLog.d.ts +405 -0
- package/dist/commons/events/CompositeFieldValue.d.ts +30 -190
- package/dist/commons/events/Conditional.d.ts +26 -38
- package/dist/commons/events/Constants.d.ts +1 -1
- package/dist/commons/events/CountryConfigQueryInput.d.ts +1592 -4471
- package/dist/commons/events/DeduplicationConfig.d.ts +15 -171
- package/dist/commons/events/Draft.d.ts +72 -107
- package/dist/commons/events/DynamicFieldValue.d.ts +12 -78
- package/dist/commons/events/EventConfig.d.ts +37 -2420
- package/dist/commons/events/EventConfigInput.d.ts +0 -3
- package/dist/commons/events/EventDocument.d.ts +354 -1366
- package/dist/commons/events/EventIndex.d.ts +212 -1010
- package/dist/commons/events/EventInput.d.ts +3 -8
- package/dist/commons/events/EventMetadata.d.ts +130 -357
- package/dist/commons/events/FieldConfig.d.ts +2892 -12892
- package/dist/commons/events/FieldType.d.ts +26 -4
- package/dist/commons/events/FieldTypeMapping.d.ts +314 -906
- package/dist/commons/events/FieldValue.d.ts +149 -527
- package/dist/commons/events/FileUtils.d.ts +2 -2
- package/dist/commons/events/Flag.d.ts +67 -0
- package/dist/commons/events/FormConfig.d.ts +54 -721
- package/dist/commons/events/PageConfig.d.ts +58 -320
- package/dist/commons/events/PlainDate.d.ts +1 -1
- package/dist/commons/events/SummaryConfig.d.ts +14 -161
- package/dist/commons/events/TemplateConfig.d.ts +2 -3
- package/dist/commons/events/TranslationConfig.d.ts +2 -2
- package/dist/commons/events/WorkqueueColumnConfig.d.ts +74 -37
- package/dist/commons/events/WorkqueueConfig.d.ts +2208 -7553
- package/dist/commons/events/deduplication.d.ts +3 -3
- package/dist/commons/events/defineConfig.d.ts +2 -247
- package/dist/commons/events/eventConfigValidation.d.ts +8 -0
- package/dist/commons/events/index.d.ts +3 -0
- package/dist/commons/events/locations.d.ts +57 -20
- package/dist/commons/events/scopes.d.ts +36 -35
- package/dist/commons/events/state/availableActions.d.ts +7 -2
- package/dist/commons/events/state/flags.d.ts +21 -3
- package/dist/commons/events/state/index.d.ts +30 -27
- package/dist/commons/events/state/utils.d.ts +190 -172
- package/dist/commons/events/test.utils.d.ts +52 -11
- package/dist/commons/events/transactions.d.ts +1 -1
- package/dist/commons/events/utils.d.ts +373 -273
- package/dist/commons/notification/UserNotifications.d.ts +61 -637
- package/dist/conditionals/index.d.ts.map +1 -1
- package/dist/conditionals/index.js +302 -14
- package/dist/events/deduplication.d.ts +3 -3
- package/dist/events/index.js +2860 -2115
- package/dist/migrations/v2.0/add-birth-certificate-issuance-flag.d.ts +3 -0
- package/dist/migrations/v2.0/add-birth-certificate-issuance-flag.d.ts.map +1 -0
- package/dist/migrations/v2.0/add-birth-certificate-issuance-flag.js +405 -0
- package/dist/migrations/v2.0/checkout-upstream-files.d.ts +3 -0
- package/dist/migrations/v2.0/checkout-upstream-files.d.ts.map +1 -0
- package/dist/migrations/v2.0/checkout-upstream-files.js +143 -0
- package/dist/migrations/v2.0/convert-config-files-to-ts.d.ts +2 -0
- package/dist/migrations/v2.0/convert-config-files-to-ts.d.ts.map +1 -0
- package/dist/migrations/v2.0/convert-config-files-to-ts.js +829 -0
- package/dist/migrations/v2.0/convert-paragraph-to-heading.d.ts +3 -0
- package/dist/migrations/v2.0/convert-paragraph-to-heading.d.ts.map +1 -0
- package/dist/migrations/v2.0/convert-paragraph-to-heading.js +159 -0
- package/dist/migrations/v2.0/create-events-index.d.ts +3 -0
- package/dist/migrations/v2.0/create-events-index.d.ts.map +1 -0
- package/dist/migrations/v2.0/create-events-index.js +326 -0
- package/dist/migrations/v2.0/index.d.ts +7 -0
- package/dist/migrations/v2.0/index.d.ts.map +1 -0
- package/dist/migrations/v2.0/index.js +3572 -0
- package/dist/migrations/v2.0/make-built-in-validate-actions-custom.d.ts +3 -0
- package/dist/migrations/v2.0/make-built-in-validate-actions-custom.d.ts.map +1 -0
- package/dist/migrations/v2.0/make-built-in-validate-actions-custom.js +344 -0
- package/dist/migrations/v2.0/migrate-scopes.d.ts +3 -0
- package/dist/migrations/v2.0/migrate-scopes.d.ts.map +1 -0
- package/dist/migrations/v2.0/migrate-scopes.js +282 -0
- package/dist/migrations/v2.0/migrate-validated-workqueue-status-to-flag.d.ts +3 -0
- package/dist/migrations/v2.0/migrate-validated-workqueue-status-to-flag.d.ts.map +1 -0
- package/dist/migrations/v2.0/migrate-validated-workqueue-status-to-flag.js +268 -0
- package/dist/migrations/v2.0/migrate-workqueue-configs.d.ts +3 -0
- package/dist/migrations/v2.0/migrate-workqueue-configs.d.ts.map +1 -0
- package/dist/migrations/v2.0/migrate-workqueue-configs.js +237 -0
- package/dist/migrations/v2.0/remove-delete-actions.d.ts +3 -0
- package/dist/migrations/v2.0/remove-delete-actions.d.ts.map +1 -0
- package/dist/migrations/v2.0/remove-delete-actions.js +157 -0
- package/dist/migrations/v2.0/remove-demo-scope.d.ts +3 -0
- package/dist/migrations/v2.0/remove-demo-scope.d.ts.map +1 -0
- package/dist/migrations/v2.0/remove-demo-scope.js +75 -0
- package/dist/migrations/v2.0/remove-deprecated-imports.d.ts +3 -0
- package/dist/migrations/v2.0/remove-deprecated-imports.d.ts.map +1 -0
- package/dist/migrations/v2.0/remove-deprecated-imports.js +97 -0
- package/dist/migrations/v2.0/remove-hearth-migrations.d.ts +3 -0
- package/dist/migrations/v2.0/remove-hearth-migrations.d.ts.map +1 -0
- package/dist/migrations/v2.0/remove-hearth-migrations.js +78 -0
- package/dist/migrations/v2.0/remove-pending-certification-flag.d.ts +3 -0
- package/dist/migrations/v2.0/remove-pending-certification-flag.d.ts.map +1 -0
- package/dist/migrations/v2.0/remove-pending-certification-flag.js +110 -0
- package/dist/migrations/v2.0/remove-review-from-register-action.d.ts +3 -0
- package/dist/migrations/v2.0/remove-review-from-register-action.d.ts.map +1 -0
- package/dist/migrations/v2.0/remove-review-from-register-action.js +164 -0
- package/dist/migrations/v2.0/rename-api-paths.d.ts +3 -0
- package/dist/migrations/v2.0/rename-api-paths.d.ts.map +1 -0
- package/dist/migrations/v2.0/rename-api-paths.js +188 -0
- package/dist/migrations/v2.0/rename-location-parent-id.d.ts +3 -0
- package/dist/migrations/v2.0/rename-location-parent-id.d.ts.map +1 -0
- package/dist/migrations/v2.0/rename-location-parent-id.js +181 -0
- package/dist/migrations/v2.0/simplify-analytics-precalculations.d.ts +3 -0
- package/dist/migrations/v2.0/simplify-analytics-precalculations.d.ts.map +1 -0
- package/dist/migrations/v2.0/simplify-analytics-precalculations.js +196 -0
- package/dist/notification/index.d.ts.map +1 -1
- package/dist/notification/index.js +2076 -1767
- package/dist/scopes/index.d.ts +640 -353
- package/dist/scopes/index.d.ts.map +1 -1
- package/dist/scopes/index.js +340 -300
- package/opencrvs-toolkit-2.0.0-rc.e0918cb.tgz +0 -0
- package/package.json +18 -8
- package/tsconfig.json +12 -2
- package/tsconfig.tsbuildinfo +1 -1
- package/dist/commons/events/CreatedAtLocation.d.ts +0 -2
|
@@ -0,0 +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"}
|
|
@@ -0,0 +1,75 @@
|
|
|
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 _1 = require(".");
|
|
29
|
+
const ROLES_HANDLER_RELATIVE_PATH = 'src/data-seeding/roles/handler.ts';
|
|
30
|
+
function main() {
|
|
31
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
32
|
+
var _a;
|
|
33
|
+
const rolesHandlerPath = path_1.default.join((0, _1.getCwd)(), ROLES_HANDLER_RELATIVE_PATH);
|
|
34
|
+
const project = new ts_morph_1.Project({
|
|
35
|
+
tsConfigFilePath: path_1.default.resolve((0, _1.getCwd)(), 'tsconfig.json'),
|
|
36
|
+
skipAddingFilesFromTsConfig: false
|
|
37
|
+
});
|
|
38
|
+
const sourceFile = project.getSourceFile(rolesHandlerPath);
|
|
39
|
+
if (!sourceFile) {
|
|
40
|
+
// eslint-disable-next-line no-console
|
|
41
|
+
console.log(`No roles handler found at '${ROLES_HANDLER_RELATIVE_PATH}'. Nothing to do.`);
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
let changed = false;
|
|
45
|
+
const constantsImport = sourceFile.getImportDeclaration((decl) => decl.getModuleSpecifierValue() === '@countryconfig/constants');
|
|
46
|
+
if (constantsImport) {
|
|
47
|
+
constantsImport.remove();
|
|
48
|
+
changed = true;
|
|
49
|
+
}
|
|
50
|
+
const rolesHandler = sourceFile.getFunction('rolesHandler');
|
|
51
|
+
if (!rolesHandler) {
|
|
52
|
+
// eslint-disable-next-line no-console
|
|
53
|
+
console.log(`No rolesHandler export found in '${ROLES_HANDLER_RELATIVE_PATH}'. Nothing to do.`);
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
const secondParam = rolesHandler.getParameters()[1];
|
|
57
|
+
const secondParamName = secondParam === null || secondParam === void 0 ? void 0 : secondParam.getName();
|
|
58
|
+
const responseToolkitIdentifier = secondParamName || 'h';
|
|
59
|
+
const currentBodyText = rolesHandler.getBodyText();
|
|
60
|
+
const normalizedCurrent = (_a = currentBodyText === null || currentBodyText === void 0 ? void 0 : currentBodyText.replace(/\s+/g, ' ').trim()) !== null && _a !== void 0 ? _a : '';
|
|
61
|
+
const normalizedDesired = `return ${responseToolkitIdentifier}.response(roles)`;
|
|
62
|
+
if (normalizedCurrent !== normalizedDesired) {
|
|
63
|
+
rolesHandler.setBodyText(`return ${responseToolkitIdentifier}.response(roles)`);
|
|
64
|
+
changed = true;
|
|
65
|
+
}
|
|
66
|
+
if (!changed) {
|
|
67
|
+
// eslint-disable-next-line no-console
|
|
68
|
+
console.log(`No changes needed in '${ROLES_HANDLER_RELATIVE_PATH}'.`);
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
yield sourceFile.save();
|
|
72
|
+
// eslint-disable-next-line no-console
|
|
73
|
+
console.log(`Updated '${ROLES_HANDLER_RELATIVE_PATH}' to remove demo scope behavior while preserving file structure.`);
|
|
74
|
+
});
|
|
75
|
+
}
|
|
@@ -0,0 +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"}
|
|
@@ -0,0 +1,97 @@
|
|
|
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 _1 = require(".");
|
|
29
|
+
const DEPRECATED_IMPORT = 'SCOPES';
|
|
30
|
+
const TARGET_MODULES = new Set([
|
|
31
|
+
'@opencrvs/toolkit/scopes',
|
|
32
|
+
'@opencrvs/toolkit'
|
|
33
|
+
]);
|
|
34
|
+
function processFile(filePath, project) {
|
|
35
|
+
const sourceFile = project.getSourceFile(filePath);
|
|
36
|
+
if (!sourceFile)
|
|
37
|
+
return 0;
|
|
38
|
+
let removedCount = 0;
|
|
39
|
+
const importDecls = sourceFile
|
|
40
|
+
.getImportDeclarations()
|
|
41
|
+
.filter((decl) => TARGET_MODULES.has(decl.getModuleSpecifierValue()));
|
|
42
|
+
for (const decl of importDecls) {
|
|
43
|
+
const matchingNamedImports = decl
|
|
44
|
+
.getNamedImports()
|
|
45
|
+
.filter((ni) => ni.getName() === DEPRECATED_IMPORT);
|
|
46
|
+
if (matchingNamedImports.length === 0)
|
|
47
|
+
continue;
|
|
48
|
+
for (const namedImport of matchingNamedImports) {
|
|
49
|
+
namedImport.remove();
|
|
50
|
+
removedCount++;
|
|
51
|
+
}
|
|
52
|
+
const hasAnyNamedImportsLeft = decl.getNamedImports().length > 0;
|
|
53
|
+
const hasDefaultImport = !!decl.getDefaultImport();
|
|
54
|
+
const hasNamespaceImport = !!decl.getNamespaceImport();
|
|
55
|
+
// If the declaration only contained SCOPE, remove the now-empty import line.
|
|
56
|
+
if (!hasAnyNamedImportsLeft && !hasDefaultImport && !hasNamespaceImport) {
|
|
57
|
+
decl.remove();
|
|
58
|
+
}
|
|
59
|
+
console.log(` [${path_1.default.relative((0, _1.getCwd)(), filePath)}] Removed ${matchingNamedImports.length} deprecated '${DEPRECATED_IMPORT}' import(s) from '${decl.getModuleSpecifierValue()}'`);
|
|
60
|
+
}
|
|
61
|
+
return removedCount;
|
|
62
|
+
}
|
|
63
|
+
function main() {
|
|
64
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
65
|
+
const srcDir = path_1.default.join((0, _1.getCwd)(), 'src');
|
|
66
|
+
console.log(`Scanning for deprecated imports in: ${srcDir}\n`);
|
|
67
|
+
const project = new ts_morph_1.Project({
|
|
68
|
+
tsConfigFilePath: path_1.default.resolve(srcDir, '../tsconfig.json'),
|
|
69
|
+
skipAddingFilesFromTsConfig: false
|
|
70
|
+
});
|
|
71
|
+
const sourceFiles = project.getSourceFiles().filter((sf) => {
|
|
72
|
+
const fp = sf.getFilePath();
|
|
73
|
+
return fp.includes('/src/') && !fp.includes('/node_modules/');
|
|
74
|
+
});
|
|
75
|
+
console.log(`Found ${sourceFiles.length} source file(s) to analyse.\n`);
|
|
76
|
+
let totalRemoved = 0;
|
|
77
|
+
const modifiedFiles = [];
|
|
78
|
+
for (const sourceFile of sourceFiles) {
|
|
79
|
+
const filePath = sourceFile.getFilePath();
|
|
80
|
+
const removed = processFile(filePath, project);
|
|
81
|
+
if (removed > 0) {
|
|
82
|
+
totalRemoved += removed;
|
|
83
|
+
modifiedFiles.push(filePath);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
if (modifiedFiles.length === 0) {
|
|
87
|
+
console.log('No deprecated imports found. Nothing to do.');
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
console.log(`\nSaving ${modifiedFiles.length} modified file(s)...`);
|
|
91
|
+
for (const filePath of modifiedFiles) {
|
|
92
|
+
yield project.getSourceFileOrThrow(filePath).save();
|
|
93
|
+
console.log(` Saved: ${path_1.default.relative((0, _1.getCwd)(), filePath)}`);
|
|
94
|
+
}
|
|
95
|
+
console.log(`\nDone. Removed ${totalRemoved} deprecated import(s).`);
|
|
96
|
+
});
|
|
97
|
+
}
|
|
@@ -0,0 +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"}
|
|
@@ -0,0 +1,78 @@
|
|
|
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 _1 = require(".");
|
|
52
|
+
const PATHS_TO_REMOVE = [
|
|
53
|
+
{
|
|
54
|
+
relativePath: 'src/migrations/hearth',
|
|
55
|
+
label: 'Hearth migrations directory'
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
relativePath: 'src/migrations/user-mgnt',
|
|
59
|
+
label: 'user-mgnt migrations directory'
|
|
60
|
+
},
|
|
61
|
+
{ relativePath: 'src/utils/hearth-helpers.ts', label: 'Hearth helpers file' }
|
|
62
|
+
];
|
|
63
|
+
function main() {
|
|
64
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
65
|
+
for (const { relativePath, label } of PATHS_TO_REMOVE) {
|
|
66
|
+
const absolutePath = path_1.default.join((0, _1.getCwd)(), relativePath);
|
|
67
|
+
if (fs.existsSync(absolutePath)) {
|
|
68
|
+
fs.rmSync(absolutePath, { recursive: true, force: true });
|
|
69
|
+
// eslint-disable-next-line no-console
|
|
70
|
+
console.log(`Removed ${label} '${relativePath}'.`);
|
|
71
|
+
}
|
|
72
|
+
else {
|
|
73
|
+
// eslint-disable-next-line no-console
|
|
74
|
+
console.log(`No ${label} found at '${relativePath}'.`);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"remove-pending-certification-flag.d.ts","sourceRoot":"","sources":["../../../src/migrations/v2.0/remove-pending-certification-flag.ts"],"names":[],"mappings":"AA2EA,iBAAe,IAAI,kBAiDlB;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: Remove `InherentFlags.PENDING_CERTIFICATION` from any array literal.
|
|
28
|
+
*
|
|
29
|
+
* Usage:
|
|
30
|
+
* ts-node -r tsconfig-paths/register src/migrations/v2.0/remove-pending-certification-flag.ts
|
|
31
|
+
*
|
|
32
|
+
* What it does:
|
|
33
|
+
* - Scans all TypeScript files under `src/`
|
|
34
|
+
* - Finds every array literal in every file
|
|
35
|
+
* - Removes any element that is the property access expression
|
|
36
|
+
* `InherentFlags.PENDING_CERTIFICATION`
|
|
37
|
+
* - Saves the modified files in-place
|
|
38
|
+
*/
|
|
39
|
+
const ts_morph_1 = require("ts-morph");
|
|
40
|
+
const path_1 = __importDefault(require("path"));
|
|
41
|
+
const _1 = require(".");
|
|
42
|
+
const INHERENT_FLAGS_ENUM_NAME = 'InherentFlags';
|
|
43
|
+
const PENDING_CERTIFICATION_MEMBER = 'PENDING_CERTIFICATION';
|
|
44
|
+
function isPendingCertificationFlag(node) {
|
|
45
|
+
if (!ts_morph_1.Node.isPropertyAccessExpression(node))
|
|
46
|
+
return false;
|
|
47
|
+
const obj = node.getExpression();
|
|
48
|
+
const member = node.getName();
|
|
49
|
+
return (ts_morph_1.Node.isIdentifier(obj) &&
|
|
50
|
+
obj.getText() === INHERENT_FLAGS_ENUM_NAME &&
|
|
51
|
+
member === PENDING_CERTIFICATION_MEMBER);
|
|
52
|
+
}
|
|
53
|
+
function processFile(filePath, project) {
|
|
54
|
+
const sourceFile = project.getSourceFile(filePath);
|
|
55
|
+
if (!sourceFile)
|
|
56
|
+
return 0;
|
|
57
|
+
let removedCount = 0;
|
|
58
|
+
const arrayLiterals = sourceFile.getDescendantsOfKind(ts_morph_1.SyntaxKind.ArrayLiteralExpression);
|
|
59
|
+
for (const array of arrayLiterals) {
|
|
60
|
+
// Collect indices in reverse order so removal doesn't shift remaining indices
|
|
61
|
+
const indicesToRemove = [];
|
|
62
|
+
array.getElements().forEach((element, index) => {
|
|
63
|
+
if (isPendingCertificationFlag(element)) {
|
|
64
|
+
indicesToRemove.push(index);
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
for (const index of indicesToRemove.reverse()) {
|
|
68
|
+
array.removeElement(index);
|
|
69
|
+
removedCount++;
|
|
70
|
+
console.log(` [${path_1.default.relative((0, _1.getCwd)(), filePath)}] Removed InherentFlags.PENDING_CERTIFICATION from array`);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
return removedCount;
|
|
74
|
+
}
|
|
75
|
+
function main() {
|
|
76
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
77
|
+
const srcDir = path_1.default.join((0, _1.getCwd)(), 'src');
|
|
78
|
+
console.log(`Scanning for InherentFlags.PENDING_CERTIFICATION array elements in: ${srcDir}\n`);
|
|
79
|
+
const project = new ts_morph_1.Project({
|
|
80
|
+
tsConfigFilePath: path_1.default.resolve(srcDir, '../tsconfig.json'),
|
|
81
|
+
skipAddingFilesFromTsConfig: false
|
|
82
|
+
});
|
|
83
|
+
const sourceFiles = project.getSourceFiles().filter((sf) => {
|
|
84
|
+
const fp = sf.getFilePath();
|
|
85
|
+
return fp.includes('/src/') && !fp.includes('/node_modules/');
|
|
86
|
+
});
|
|
87
|
+
console.log(`Found ${sourceFiles.length} source file(s) to analyse.\n`);
|
|
88
|
+
let totalRemoved = 0;
|
|
89
|
+
const modifiedFiles = [];
|
|
90
|
+
for (const sourceFile of sourceFiles) {
|
|
91
|
+
const filePath = sourceFile.getFilePath();
|
|
92
|
+
const removed = processFile(filePath, project);
|
|
93
|
+
if (removed > 0) {
|
|
94
|
+
totalRemoved += removed;
|
|
95
|
+
modifiedFiles.push(filePath);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
if (modifiedFiles.length === 0) {
|
|
99
|
+
console.log('No InherentFlags.PENDING_CERTIFICATION elements found in any array. 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((0, _1.getCwd)(), filePath)}`);
|
|
107
|
+
}
|
|
108
|
+
console.log(`\nDone. Removed ${totalRemoved} InherentFlags.PENDING_CERTIFICATION element(s) from array(s).`);
|
|
109
|
+
});
|
|
110
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"remove-review-from-register-action.d.ts","sourceRoot":"","sources":["../../../src/migrations/v2.0/remove-review-from-register-action.ts"],"names":[],"mappings":"AAoJA,iBAAe,IAAI,kBAkDlB;AAED,OAAO,EAAE,IAAI,EAAE,CAAA"}
|
|
@@ -0,0 +1,164 @@
|
|
|
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 `review` property from `REGISTER` type actions inside `defineConfig` calls.
|
|
28
|
+
*
|
|
29
|
+
* Usage:
|
|
30
|
+
* ts-node -r tsconfig-paths/register src/remove-review-from-register-action.ts
|
|
31
|
+
*
|
|
32
|
+
* What it does:
|
|
33
|
+
* - Scans all TypeScript files under `src/`
|
|
34
|
+
* - Finds every `defineConfig({ ... })` call expression
|
|
35
|
+
* - Inside the `actions` array of that config, locates object literals
|
|
36
|
+
* whose `type` property resolves to `ActionType.REGISTER` or the string literal `"REGISTER"`
|
|
37
|
+
* - Removes the `review` property assignment from those objects
|
|
38
|
+
* - Saves the modified files in-place
|
|
39
|
+
*/
|
|
40
|
+
const ts_morph_1 = require("ts-morph");
|
|
41
|
+
const path_1 = __importDefault(require("path"));
|
|
42
|
+
const _1 = require(".");
|
|
43
|
+
const DEFINE_CONFIG_NAME = 'defineConfig';
|
|
44
|
+
const ACTIONS_PROPERTY_NAME = 'actions';
|
|
45
|
+
const TYPE_PROPERTY_NAME = 'type';
|
|
46
|
+
const REVIEW_PROPERTY_NAME = 'review';
|
|
47
|
+
const REGISTER_ENUM_NAME = 'ActionType';
|
|
48
|
+
const REGISTER_MEMBER_NAME = 'REGISTER';
|
|
49
|
+
const REGISTER_STRING_LITERAL = 'REGISTER';
|
|
50
|
+
function isRegisterType(typeInitializer) {
|
|
51
|
+
// Matches: ActionType.REGISTER
|
|
52
|
+
if (typeInitializer.getKind() === ts_morph_1.SyntaxKind.PropertyAccessExpression) {
|
|
53
|
+
const propAccess = typeInitializer.asKindOrThrow(ts_morph_1.SyntaxKind.PropertyAccessExpression);
|
|
54
|
+
const obj = propAccess.getExpression();
|
|
55
|
+
const member = propAccess.getName();
|
|
56
|
+
return (ts_morph_1.Node.isIdentifier(obj) &&
|
|
57
|
+
obj.getText() === REGISTER_ENUM_NAME &&
|
|
58
|
+
member === REGISTER_MEMBER_NAME);
|
|
59
|
+
}
|
|
60
|
+
// Matches: "REGISTER"
|
|
61
|
+
if (typeInitializer.getKind() === ts_morph_1.SyntaxKind.StringLiteral) {
|
|
62
|
+
return (typeInitializer
|
|
63
|
+
.asKindOrThrow(ts_morph_1.SyntaxKind.StringLiteral)
|
|
64
|
+
.getLiteralValue() === REGISTER_STRING_LITERAL);
|
|
65
|
+
}
|
|
66
|
+
return false;
|
|
67
|
+
}
|
|
68
|
+
function removeReviewFromRegisterActions(obj) {
|
|
69
|
+
const typeProperty = obj.getProperty(TYPE_PROPERTY_NAME);
|
|
70
|
+
if (!typeProperty || !ts_morph_1.Node.isPropertyAssignment(typeProperty)) {
|
|
71
|
+
return false;
|
|
72
|
+
}
|
|
73
|
+
const typeInitializer = typeProperty.getInitializer();
|
|
74
|
+
if (!typeInitializer || !isRegisterType(typeInitializer)) {
|
|
75
|
+
return false;
|
|
76
|
+
}
|
|
77
|
+
const reviewProperty = obj.getProperty(REVIEW_PROPERTY_NAME);
|
|
78
|
+
if (!reviewProperty) {
|
|
79
|
+
return false;
|
|
80
|
+
}
|
|
81
|
+
reviewProperty.remove();
|
|
82
|
+
return true;
|
|
83
|
+
}
|
|
84
|
+
function processFile(filePath, project) {
|
|
85
|
+
const sourceFile = project.getSourceFile(filePath);
|
|
86
|
+
if (!sourceFile)
|
|
87
|
+
return 0;
|
|
88
|
+
let removedCount = 0;
|
|
89
|
+
// Find all call expressions named `defineConfig`
|
|
90
|
+
const callExpressions = sourceFile.getDescendantsOfKind(ts_morph_1.SyntaxKind.CallExpression);
|
|
91
|
+
for (const call of callExpressions) {
|
|
92
|
+
const expression = call.getExpression();
|
|
93
|
+
// Only interested in bare `defineConfig(...)` calls
|
|
94
|
+
if (!ts_morph_1.Node.isIdentifier(expression) ||
|
|
95
|
+
expression.getText() !== DEFINE_CONFIG_NAME) {
|
|
96
|
+
continue;
|
|
97
|
+
}
|
|
98
|
+
const args = call.getArguments();
|
|
99
|
+
if (args.length === 0)
|
|
100
|
+
continue;
|
|
101
|
+
// The first argument should be the config object literal
|
|
102
|
+
const configArg = args[0];
|
|
103
|
+
if (!ts_morph_1.Node.isObjectLiteralExpression(configArg))
|
|
104
|
+
continue;
|
|
105
|
+
// Find the `actions` property inside the config object
|
|
106
|
+
const actionsProperty = configArg.getProperty(ACTIONS_PROPERTY_NAME);
|
|
107
|
+
if (!actionsProperty || !ts_morph_1.Node.isPropertyAssignment(actionsProperty))
|
|
108
|
+
continue;
|
|
109
|
+
const actionsInitializer = actionsProperty.getInitializer();
|
|
110
|
+
if (!actionsInitializer ||
|
|
111
|
+
!ts_morph_1.Node.isArrayLiteralExpression(actionsInitializer))
|
|
112
|
+
continue;
|
|
113
|
+
// Iterate over every element in the `actions` array
|
|
114
|
+
for (const element of actionsInitializer.getElements()) {
|
|
115
|
+
if (!ts_morph_1.Node.isObjectLiteralExpression(element))
|
|
116
|
+
continue;
|
|
117
|
+
const wasRemoved = removeReviewFromRegisterActions(element);
|
|
118
|
+
if (wasRemoved) {
|
|
119
|
+
removedCount++;
|
|
120
|
+
console.log(` [${path_1.default.relative((0, _1.getCwd)(), filePath)}] Removed 'review' from REGISTER action`);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
return removedCount;
|
|
125
|
+
}
|
|
126
|
+
function main() {
|
|
127
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
128
|
+
const srcDir = path_1.default.join((0, _1.getCwd)(), 'src');
|
|
129
|
+
console.log(`Scanning for defineConfig calls in: ${srcDir}\n`);
|
|
130
|
+
const project = new ts_morph_1.Project({
|
|
131
|
+
tsConfigFilePath: path_1.default.resolve(srcDir, '../tsconfig.json'),
|
|
132
|
+
// Do not emit — we only manipulate source files
|
|
133
|
+
skipAddingFilesFromTsConfig: false
|
|
134
|
+
// addFilesFromTsConfig: true
|
|
135
|
+
});
|
|
136
|
+
// Restrict to source files only (exclude node_modules, build artefacts, etc.)
|
|
137
|
+
const sourceFiles = project.getSourceFiles().filter((sf) => {
|
|
138
|
+
const fp = sf.getFilePath();
|
|
139
|
+
return fp.includes('/src/') && !fp.includes('/node_modules/');
|
|
140
|
+
});
|
|
141
|
+
console.log(`Found ${sourceFiles.length} source file(s) to analyse.\n`);
|
|
142
|
+
let totalRemoved = 0;
|
|
143
|
+
const modifiedFiles = [];
|
|
144
|
+
for (const sourceFile of sourceFiles) {
|
|
145
|
+
const filePath = sourceFile.getFilePath();
|
|
146
|
+
const removed = processFile(filePath, project);
|
|
147
|
+
if (removed > 0) {
|
|
148
|
+
totalRemoved += removed;
|
|
149
|
+
modifiedFiles.push(filePath);
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
if (modifiedFiles.length === 0) {
|
|
153
|
+
console.log("No 'review' properties found on REGISTER actions. Nothing to do.");
|
|
154
|
+
return;
|
|
155
|
+
}
|
|
156
|
+
console.log(`\nSaving ${modifiedFiles.length} modified file(s)...`);
|
|
157
|
+
for (const filePath of modifiedFiles) {
|
|
158
|
+
const sourceFile = project.getSourceFileOrThrow(filePath);
|
|
159
|
+
yield sourceFile.save();
|
|
160
|
+
console.log(` Saved: ${path_1.default.relative((0, _1.getCwd)(), filePath)}`);
|
|
161
|
+
}
|
|
162
|
+
console.log(`\nDone. Removed ${totalRemoved} 'review' property assignment(s) from REGISTER action(s).`);
|
|
163
|
+
});
|
|
164
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rename-api-paths.d.ts","sourceRoot":"","sources":["../../../src/migrations/v2.0/rename-api-paths.ts"],"names":[],"mappings":"AAyJA,iBAAe,IAAI,kBAgDlB;AAED,OAAO,EAAE,IAAI,EAAE,CAAA"}
|