@opencrvs/toolkit 1.9.12-rc.bce2e6f → 1.9.12-rc.bf52336
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/dist/application-config/index.js +2038 -45
- package/dist/cli.js +850 -35
- package/dist/commons/api/router.d.ts +86 -79
- package/dist/commons/application-config/index.d.ts +6 -4
- package/dist/commons/events/ActionDocument.d.ts +6 -6
- package/dist/commons/events/ActionType.d.ts +3 -3
- package/dist/commons/events/AdvancedSearchConfig.d.ts +10 -10
- package/dist/commons/events/CountryConfigQueryInput.d.ts +222 -222
- package/dist/commons/events/Draft.d.ts +8 -8
- package/dist/commons/events/EventConfig.d.ts +1 -1
- package/dist/commons/events/EventDocument.d.ts +3 -3
- package/dist/commons/events/EventIndex.d.ts +15 -15
- package/dist/commons/events/EventMetadata.d.ts +12 -12
- package/dist/commons/events/FieldConfig.d.ts +26 -26
- package/dist/commons/events/FieldType.d.ts +1 -1
- package/dist/commons/events/FieldTypeMapping.d.ts +4 -4
- package/dist/commons/events/WorkqueueColumnConfig.d.ts +13 -13
- package/dist/commons/events/WorkqueueConfig.d.ts +239 -239
- package/dist/commons/events/state/index.d.ts +2 -2
- package/dist/commons/events/state/utils.d.ts +3 -3
- package/dist/commons/events/utils.d.ts +3 -3
- 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 +97 -21
- package/dist/migrations/v2.0/index.d.ts.map +1 -1
- package/dist/migrations/v2.0/index.js +848 -33
- package/dist/migrations/v2.0/migrate-scopes.d.ts.map +1 -1
- package/dist/migrations/v2.0/migrate-scopes.js +6 -5
- 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-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-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/opencrvs-toolkit-1.9.12-rc.bf52336.tgz +0 -0
- package/package.json +1 -1
- package/tsconfig.json +3 -0
- package/tsconfig.tsbuildinfo +1 -1
- package/opencrvs-toolkit-1.9.12-rc.bce2e6f.tgz +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"migrate-scopes.d.ts","sourceRoot":"","sources":["../../../src/migrations/v2.0/migrate-scopes.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"migrate-scopes.d.ts","sourceRoot":"","sources":["../../../src/migrations/v2.0/migrate-scopes.ts"],"names":[],"mappings":"AA2VA,iBAAe,IAAI,kBAmDlB;AAED,OAAO,EAAE,IAAI,EAAE,CAAA"}
|
|
@@ -25,7 +25,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
25
25
|
exports.main = main;
|
|
26
26
|
const ts_morph_1 = require("ts-morph");
|
|
27
27
|
const path_1 = __importDefault(require("path"));
|
|
28
|
-
const
|
|
28
|
+
const scopes_1 = require("../commons/scopes");
|
|
29
|
+
const scopes_deprecated_do_not_use_1 = require("../commons/scopes.deprecated.do-not-use");
|
|
29
30
|
const _1 = require(".");
|
|
30
31
|
const ROLES_FILE_RELATIVE_PATH = 'src/data-seeding/roles/roles.ts';
|
|
31
32
|
const SCOPES_PROPERTY_NAME = 'scopes';
|
|
@@ -55,7 +56,7 @@ function resolveLegacyScopeFromElement(element) {
|
|
|
55
56
|
}
|
|
56
57
|
const scopeKey = resolveScopeKeyFromElementAccess(element);
|
|
57
58
|
if (scopeKey) {
|
|
58
|
-
const scopeValue =
|
|
59
|
+
const scopeValue = scopes_deprecated_do_not_use_1.SCOPES[scopeKey];
|
|
59
60
|
return typeof scopeValue === 'string' ? scopeValue : null;
|
|
60
61
|
}
|
|
61
62
|
const expressionType = element.getType();
|
|
@@ -84,7 +85,7 @@ function migrateScopesArrays(rolesFilePath, project) {
|
|
|
84
85
|
if (!ts_morph_1.Node.isExpression(element))
|
|
85
86
|
continue;
|
|
86
87
|
const scopeKey = resolveScopeKeyFromElementAccess(element);
|
|
87
|
-
if (scopeKey && !(scopeKey in
|
|
88
|
+
if (scopeKey && !(scopeKey in scopes_deprecated_do_not_use_1.SCOPES)) {
|
|
88
89
|
// eslint-disable-next-line no-console
|
|
89
90
|
console.warn(` [${path_1.default.relative((0, _1.getCwd)(), rolesFilePath)}] Removing unknown scope reference: SCOPES.${scopeKey}`);
|
|
90
91
|
initializer.removeElement(index);
|
|
@@ -98,8 +99,8 @@ function migrateScopesArrays(rolesFilePath, project) {
|
|
|
98
99
|
continue;
|
|
99
100
|
}
|
|
100
101
|
try {
|
|
101
|
-
const migratedScope = (0,
|
|
102
|
-
const scope = (0,
|
|
102
|
+
const migratedScope = (0, scopes_deprecated_do_not_use_1.legacyScopeToV2Scope)(legacyScope);
|
|
103
|
+
const scope = (0, scopes_1.decodeScope)(migratedScope);
|
|
103
104
|
if (!scope) {
|
|
104
105
|
// eslint-disable-next-line no-console
|
|
105
106
|
console.warn(` [${path_1.default.relative((0, _1.getCwd)(), rolesFilePath)}] Could not decode migrated scope '${migratedScope}'.`);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"migrate-workqueue-configs.d.ts","sourceRoot":"","sources":["../../../src/migrations/v2.0/migrate-workqueue-configs.ts"],"names":[],"mappings":"AAiPA,iBAAe,IAAI,kBAqDlB;AAED,OAAO,EAAE,IAAI,EAAE,CAAA"}
|
|
@@ -0,0 +1,237 @@
|
|
|
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: migrate deprecated workqueue `actions` array to singular `action`.
|
|
28
|
+
*
|
|
29
|
+
* Usage:
|
|
30
|
+
* ts-node -r tsconfig-paths/register src/migrations/v2.0/migrate-workqueue-configs.ts
|
|
31
|
+
*
|
|
32
|
+
* What it does:
|
|
33
|
+
* - Scans TypeScript files under `src/`
|
|
34
|
+
* - Finds `defineWorkqueues([...])` calls
|
|
35
|
+
* - For each workqueue object:
|
|
36
|
+
* - `actions: []` -> removes `actions`
|
|
37
|
+
* - `actions: [{ ... }]` -> replaces with `action: { ... }` if type is supported
|
|
38
|
+
* - `actions: [{ type: 'DEFAULT' }]` -> removes `actions` and does not create `action`
|
|
39
|
+
* - `actions: [{...}, {...}, ...]` -> keeps first as `action`, warns about dropped extras
|
|
40
|
+
* - If `action` already exists, removes deprecated `actions` and keeps `action`
|
|
41
|
+
* - Removes unsupported `action.type` values (`DEFAULT`, `VALIDATE`, etc.)
|
|
42
|
+
* - Saves modified files in-place
|
|
43
|
+
*/
|
|
44
|
+
const ts_morph_1 = require("ts-morph");
|
|
45
|
+
const path_1 = __importDefault(require("path"));
|
|
46
|
+
const _1 = require(".");
|
|
47
|
+
const DEFINE_WORKQUEUES_NAME = 'defineWorkqueues';
|
|
48
|
+
const ACTIONS_PROPERTY_NAME = 'actions';
|
|
49
|
+
const ACTION_PROPERTY_NAME = 'action';
|
|
50
|
+
const CONDITIONALS_PROPERTY_NAME = 'conditionals';
|
|
51
|
+
const TYPE_PROPERTY_NAME = 'type';
|
|
52
|
+
const SLUG_PROPERTY_NAME = 'slug';
|
|
53
|
+
const SUPPORTED_WORKQUEUE_ACTION_TYPES = new Set([
|
|
54
|
+
'READ',
|
|
55
|
+
'DELETE',
|
|
56
|
+
'DECLARE',
|
|
57
|
+
'REGISTER',
|
|
58
|
+
'EDIT',
|
|
59
|
+
'REJECT',
|
|
60
|
+
'MARK_AS_DUPLICATE',
|
|
61
|
+
'ARCHIVE',
|
|
62
|
+
'PRINT_CERTIFICATE',
|
|
63
|
+
'REQUEST_CORRECTION'
|
|
64
|
+
]);
|
|
65
|
+
function getWorkqueueLabel(workqueue) {
|
|
66
|
+
const slugProperty = workqueue.getProperty(SLUG_PROPERTY_NAME);
|
|
67
|
+
if (!slugProperty || !ts_morph_1.Node.isPropertyAssignment(slugProperty)) {
|
|
68
|
+
return '(unknown slug)';
|
|
69
|
+
}
|
|
70
|
+
const slugInitializer = slugProperty.getInitializer();
|
|
71
|
+
if (!slugInitializer || !ts_morph_1.Node.isStringLiteral(slugInitializer)) {
|
|
72
|
+
return '(unknown slug)';
|
|
73
|
+
}
|
|
74
|
+
return slugInitializer.getLiteralValue();
|
|
75
|
+
}
|
|
76
|
+
function getActionTypeName(action) {
|
|
77
|
+
const typeProperty = action.getProperty(TYPE_PROPERTY_NAME);
|
|
78
|
+
if (!typeProperty || !ts_morph_1.Node.isPropertyAssignment(typeProperty)) {
|
|
79
|
+
return null;
|
|
80
|
+
}
|
|
81
|
+
const typeInitializer = typeProperty.getInitializer();
|
|
82
|
+
if (!typeInitializer) {
|
|
83
|
+
return null;
|
|
84
|
+
}
|
|
85
|
+
if (ts_morph_1.Node.isStringLiteral(typeInitializer)) {
|
|
86
|
+
return typeInitializer.getLiteralValue();
|
|
87
|
+
}
|
|
88
|
+
if (ts_morph_1.Node.isPropertyAccessExpression(typeInitializer)) {
|
|
89
|
+
return typeInitializer.getName();
|
|
90
|
+
}
|
|
91
|
+
return null;
|
|
92
|
+
}
|
|
93
|
+
function isUnsupportedActionType(action) {
|
|
94
|
+
const typeName = getActionTypeName(action);
|
|
95
|
+
if (!typeName) {
|
|
96
|
+
return false;
|
|
97
|
+
}
|
|
98
|
+
return !SUPPORTED_WORKQUEUE_ACTION_TYPES.has(typeName);
|
|
99
|
+
}
|
|
100
|
+
function migrateWorkqueueActions(workqueue, relPath) {
|
|
101
|
+
const actionsProperty = workqueue.getProperty(ACTIONS_PROPERTY_NAME);
|
|
102
|
+
if (!actionsProperty || !ts_morph_1.Node.isPropertyAssignment(actionsProperty)) {
|
|
103
|
+
return 0;
|
|
104
|
+
}
|
|
105
|
+
const actionsInitializer = actionsProperty.getInitializer();
|
|
106
|
+
if (!actionsInitializer || !ts_morph_1.Node.isArrayLiteralExpression(actionsInitializer)) {
|
|
107
|
+
return 0;
|
|
108
|
+
}
|
|
109
|
+
const workqueueLabel = getWorkqueueLabel(workqueue);
|
|
110
|
+
const existingActionProperty = workqueue.getProperty(ACTION_PROPERTY_NAME);
|
|
111
|
+
if (existingActionProperty) {
|
|
112
|
+
if (ts_morph_1.Node.isPropertyAssignment(existingActionProperty)) {
|
|
113
|
+
const existingActionInitializer = existingActionProperty.getInitializer();
|
|
114
|
+
if (existingActionInitializer && ts_morph_1.Node.isObjectLiteralExpression(existingActionInitializer)) {
|
|
115
|
+
const conditionalsProperty = existingActionInitializer.getProperty(CONDITIONALS_PROPERTY_NAME);
|
|
116
|
+
if (conditionalsProperty) {
|
|
117
|
+
conditionalsProperty.remove();
|
|
118
|
+
// eslint-disable-next-line no-console
|
|
119
|
+
console.log(` [${relPath}] Removed deprecated 'conditionals' from 'action' on workqueue '${workqueueLabel}'`);
|
|
120
|
+
}
|
|
121
|
+
if (isUnsupportedActionType(existingActionInitializer)) {
|
|
122
|
+
existingActionProperty.remove();
|
|
123
|
+
// eslint-disable-next-line no-console
|
|
124
|
+
console.log(` [${relPath}] Removed unsupported 'action' type on workqueue '${workqueueLabel}'`);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
actionsProperty.remove();
|
|
129
|
+
// eslint-disable-next-line no-console
|
|
130
|
+
console.log(` [${relPath}] Removed deprecated 'actions' from workqueue '${workqueueLabel}' (existing 'action' kept)`);
|
|
131
|
+
return 1;
|
|
132
|
+
}
|
|
133
|
+
const actionCandidates = actionsInitializer
|
|
134
|
+
.getElements()
|
|
135
|
+
.filter((element) => ts_morph_1.Node.isObjectLiteralExpression(element));
|
|
136
|
+
if (actionCandidates.length === 0) {
|
|
137
|
+
actionsProperty.remove();
|
|
138
|
+
// eslint-disable-next-line no-console
|
|
139
|
+
console.log(` [${relPath}] Removed empty 'actions' from workqueue '${workqueueLabel}'`);
|
|
140
|
+
return 1;
|
|
141
|
+
}
|
|
142
|
+
if (actionCandidates.length > 1) {
|
|
143
|
+
const droppedCount = actionCandidates.length - 1;
|
|
144
|
+
// eslint-disable-next-line no-console
|
|
145
|
+
console.warn(` [${relPath}] Workqueue '${workqueueLabel}' has ${actionCandidates.length} actions; keeping first as 'action' and dropping ${droppedCount} extra action(s)`);
|
|
146
|
+
}
|
|
147
|
+
const conditionalsProperty = actionCandidates[0].getProperty(CONDITIONALS_PROPERTY_NAME);
|
|
148
|
+
if (conditionalsProperty) {
|
|
149
|
+
conditionalsProperty.remove();
|
|
150
|
+
// eslint-disable-next-line no-console
|
|
151
|
+
console.log(` [${relPath}] Removed deprecated 'conditionals' from migrated 'action' on workqueue '${workqueueLabel}'`);
|
|
152
|
+
}
|
|
153
|
+
if (isUnsupportedActionType(actionCandidates[0])) {
|
|
154
|
+
actionsProperty.remove();
|
|
155
|
+
// eslint-disable-next-line no-console
|
|
156
|
+
console.log(` [${relPath}] Removed deprecated 'actions' from workqueue '${workqueueLabel}' because action type is unsupported`);
|
|
157
|
+
return 1;
|
|
158
|
+
}
|
|
159
|
+
const firstActionText = actionCandidates[0].getText();
|
|
160
|
+
workqueue.addPropertyAssignment({
|
|
161
|
+
name: ACTION_PROPERTY_NAME,
|
|
162
|
+
initializer: firstActionText
|
|
163
|
+
});
|
|
164
|
+
actionsProperty.remove();
|
|
165
|
+
// eslint-disable-next-line no-console
|
|
166
|
+
console.log(` [${relPath}] Replaced 'actions' with 'action' on workqueue '${workqueueLabel}'`);
|
|
167
|
+
return 1;
|
|
168
|
+
}
|
|
169
|
+
function processFile(filePath, project) {
|
|
170
|
+
const sourceFile = project.getSourceFile(filePath);
|
|
171
|
+
if (!sourceFile)
|
|
172
|
+
return 0;
|
|
173
|
+
let migratedWorkqueues = 0;
|
|
174
|
+
const relPath = path_1.default.relative((0, _1.getCwd)(), filePath);
|
|
175
|
+
const callExpressions = sourceFile.getDescendantsOfKind(ts_morph_1.SyntaxKind.CallExpression);
|
|
176
|
+
for (const call of callExpressions) {
|
|
177
|
+
const expression = call.getExpression();
|
|
178
|
+
if (!ts_morph_1.Node.isIdentifier(expression) ||
|
|
179
|
+
expression.getText() !== DEFINE_WORKQUEUES_NAME) {
|
|
180
|
+
continue;
|
|
181
|
+
}
|
|
182
|
+
const args = call.getArguments();
|
|
183
|
+
if (args.length === 0)
|
|
184
|
+
continue;
|
|
185
|
+
const workqueuesArg = args[0];
|
|
186
|
+
if (!ts_morph_1.Node.isArrayLiteralExpression(workqueuesArg))
|
|
187
|
+
continue;
|
|
188
|
+
for (const element of workqueuesArg.getElements()) {
|
|
189
|
+
if (!ts_morph_1.Node.isObjectLiteralExpression(element))
|
|
190
|
+
continue;
|
|
191
|
+
migratedWorkqueues += migrateWorkqueueActions(element, relPath);
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
return migratedWorkqueues;
|
|
195
|
+
}
|
|
196
|
+
function main() {
|
|
197
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
198
|
+
const srcDir = path_1.default.join((0, _1.getCwd)(), 'src');
|
|
199
|
+
// eslint-disable-next-line no-console
|
|
200
|
+
console.log(`Scanning for defineWorkqueues calls in: ${srcDir}\n`);
|
|
201
|
+
const project = new ts_morph_1.Project({
|
|
202
|
+
tsConfigFilePath: path_1.default.resolve(srcDir, '../tsconfig.json'),
|
|
203
|
+
skipAddingFilesFromTsConfig: false
|
|
204
|
+
});
|
|
205
|
+
const sourceFiles = project.getSourceFiles().filter((sf) => {
|
|
206
|
+
const fp = sf.getFilePath();
|
|
207
|
+
return fp.includes('/src/') && !fp.includes('/node_modules/');
|
|
208
|
+
});
|
|
209
|
+
// eslint-disable-next-line no-console
|
|
210
|
+
console.log(`Found ${sourceFiles.length} source file(s) to analyse.\n`);
|
|
211
|
+
let totalMigrated = 0;
|
|
212
|
+
const modifiedFiles = [];
|
|
213
|
+
for (const sourceFile of sourceFiles) {
|
|
214
|
+
const filePath = sourceFile.getFilePath();
|
|
215
|
+
const migrated = processFile(filePath, project);
|
|
216
|
+
if (migrated > 0) {
|
|
217
|
+
totalMigrated += migrated;
|
|
218
|
+
modifiedFiles.push(filePath);
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
if (modifiedFiles.length === 0) {
|
|
222
|
+
// eslint-disable-next-line no-console
|
|
223
|
+
console.log("No deprecated workqueue 'actions' arrays found inside defineWorkqueues calls. Nothing to do.");
|
|
224
|
+
return;
|
|
225
|
+
}
|
|
226
|
+
// eslint-disable-next-line no-console
|
|
227
|
+
console.log(`\nSaving ${modifiedFiles.length} modified file(s)...`);
|
|
228
|
+
for (const filePath of modifiedFiles) {
|
|
229
|
+
const sourceFile = project.getSourceFileOrThrow(filePath);
|
|
230
|
+
yield sourceFile.save();
|
|
231
|
+
// eslint-disable-next-line no-console
|
|
232
|
+
console.log(` Saved: ${path_1.default.relative((0, _1.getCwd)(), filePath)}`);
|
|
233
|
+
}
|
|
234
|
+
// eslint-disable-next-line no-console
|
|
235
|
+
console.log(`\nDone. Migrated ${totalMigrated} deprecated workqueue 'actions' definition(s) to 'action'.`);
|
|
236
|
+
});
|
|
237
|
+
}
|
|
@@ -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-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
|
+
}
|
|
Binary file
|
package/package.json
CHANGED
package/tsconfig.json
CHANGED
|
@@ -20,6 +20,9 @@
|
|
|
20
20
|
"@opencrvs/commons/events/deduplication": [
|
|
21
21
|
"../commons/src/events/deduplication.ts"
|
|
22
22
|
],
|
|
23
|
+
"@opencrvs/commons/scopes.deprecated.do-not-use": [
|
|
24
|
+
"../commons/src/scopes.deprecated.do-not-use.ts"
|
|
25
|
+
],
|
|
23
26
|
"@opencrvs/commons/notification": [
|
|
24
27
|
"../commons/src/notification/index.ts"
|
|
25
28
|
],
|
package/tsconfig.tsbuildinfo
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"root":["./src/cli.ts","./src/api/index.ts","./src/application-config/index.ts","./src/conditionals/index.ts","./src/events/deduplication.ts","./src/events/index.ts","./src/migrations/v2.0/add-birth-certificate-issuance-flag.ts","./src/migrations/v2.0/convert-config-files-to-ts.ts","./src/migrations/v2.0/convert-paragraph-to-heading.ts","./src/migrations/v2.0/index.ts","./src/migrations/v2.0/make-built-in-validate-actions-custom.ts","./src/migrations/v2.0/migrate-scopes.ts","./src/migrations/v2.0/migrate-validated-workqueue-status-to-flag.ts","./src/migrations/v2.0/remove-delete-actions.ts","./src/migrations/v2.0/remove-deprecated-imports.ts","./src/migrations/v2.0/remove-pending-certification-flag.ts","./src/migrations/v2.0/remove-review-from-register-action.ts","./src/migrations/v2.0/rename-api-paths.ts","./src/migrations/v2.0/rename-location-parent-id.ts","./src/notification/index.ts","./src/scopes/index.ts"],"version":"5.6.3"}
|
|
1
|
+
{"root":["./src/cli.ts","./src/api/index.ts","./src/application-config/index.ts","./src/conditionals/index.ts","./src/events/deduplication.ts","./src/events/index.ts","./src/migrations/v2.0/add-birth-certificate-issuance-flag.ts","./src/migrations/v2.0/convert-config-files-to-ts.ts","./src/migrations/v2.0/convert-paragraph-to-heading.ts","./src/migrations/v2.0/index.ts","./src/migrations/v2.0/make-built-in-validate-actions-custom.ts","./src/migrations/v2.0/migrate-scopes.ts","./src/migrations/v2.0/migrate-validated-workqueue-status-to-flag.ts","./src/migrations/v2.0/migrate-workqueue-configs.ts","./src/migrations/v2.0/remove-delete-actions.ts","./src/migrations/v2.0/remove-demo-scope.ts","./src/migrations/v2.0/remove-deprecated-imports.ts","./src/migrations/v2.0/remove-hearth-migrations.ts","./src/migrations/v2.0/remove-pending-certification-flag.ts","./src/migrations/v2.0/remove-review-from-register-action.ts","./src/migrations/v2.0/rename-api-paths.ts","./src/migrations/v2.0/rename-location-parent-id.ts","./src/notification/index.ts","./src/scopes/index.ts"],"version":"5.6.3"}
|
|
Binary file
|