@opencrvs/toolkit 2.0.0-rc.bee2b7b → 2.0.0-rc.c14c17b
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 +73 -0
- package/create-countryconfig/package.json +11 -0
- package/dist/application-config/index.js +10 -11
- package/dist/cli.js +1640 -330
- package/dist/commons/api/router.d.ts +55 -54
- package/dist/commons/application-config/index.d.ts +16 -4
- package/dist/commons/conditionals/conditionals.d.ts +3 -3
- package/dist/commons/events/FieldConfig.d.ts +5 -0
- package/dist/commons/events/locations.d.ts +21 -0
- package/dist/commons/events/mocks.test.utils.d.ts +19 -0
- package/dist/commons/events/scopes.d.ts +24 -1
- package/dist/conditionals/index.js +6 -7
- package/dist/events/index.js +61 -7
- 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 -13
- 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 +3 -0
- package/dist/migrations/v2.0/delete-infrastructure-directory.d.ts.map +1 -0
- package/dist/migrations/v2.0/delete-infrastructure-directory.js +77 -0
- package/dist/migrations/v2.0/index.d.ts +8 -4
- package/dist/migrations/v2.0/index.d.ts.map +1 -1
- package/dist/migrations/v2.0/index.js +1467 -186
- 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 +3 -0
- package/dist/migrations/v2.0/merge-infrastructure-directory.d.ts.map +1 -0
- package/dist/migrations/v2.0/merge-infrastructure-directory.js +221 -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 +6 -7
- 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 +3 -4
- 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 +6 -7
- package/dist/scopes/index.d.ts +2 -0
- package/dist/scopes/index.js +6 -7
- package/opencrvs-toolkit-2.0.0-rc.c14c17b.tgz +0 -0
- package/package.json +1 -1
- package/tsconfig.tsbuildinfo +1 -1
- package/opencrvs-toolkit-2.0.0-rc.bee2b7b.tgz +0 -0
|
@@ -0,0 +1,186 @@
|
|
|
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 environment variables that are no longer consumed by
|
|
28
|
+
* country config code in v2.0.
|
|
29
|
+
*
|
|
30
|
+
* Targets:
|
|
31
|
+
* - APPLICATION_CONFIG_URL
|
|
32
|
+
* - FHIR_URL
|
|
33
|
+
* - CONFIRM_REGISTRATION_URL
|
|
34
|
+
*
|
|
35
|
+
* What it does:
|
|
36
|
+
* 1. In `src/environment.ts`, removes the matching properties from the
|
|
37
|
+
* `cleanEnv(process.env, { ... })` schema object.
|
|
38
|
+
* 2. In `src/constants.ts`, removes the matching top-level `const`
|
|
39
|
+
* declarations — by name OR by `env.<NAME>` reference (so that
|
|
40
|
+
* country forks that renamed the constant but still read the same env
|
|
41
|
+
* var are also cleaned up).
|
|
42
|
+
*
|
|
43
|
+
* Caveats:
|
|
44
|
+
* - Removing these constants may produce TypeScript errors at usage
|
|
45
|
+
* sites elsewhere in `src/` (e.g. files that imported `FHIR_URL` from
|
|
46
|
+
* `@countryconfig/constants`). Those usages are intentionally left
|
|
47
|
+
* for the developer to resolve, since the right replacement is
|
|
48
|
+
* country-specific.
|
|
49
|
+
* - The codemod is a no-op when the target files or properties don't
|
|
50
|
+
* exist (e.g. the country config has already removed them).
|
|
51
|
+
*/
|
|
52
|
+
const path_1 = __importDefault(require("path"));
|
|
53
|
+
const ts_morph_1 = require("ts-morph");
|
|
54
|
+
const UNUSED_ENV_VARS = new Set([
|
|
55
|
+
'APPLICATION_CONFIG_URL',
|
|
56
|
+
'FHIR_URL',
|
|
57
|
+
'CONFIRM_REGISTRATION_URL'
|
|
58
|
+
]);
|
|
59
|
+
const ENVIRONMENT_FILE_RELATIVE = 'src/environment.ts';
|
|
60
|
+
const CONSTANTS_FILE_RELATIVE = 'src/constants.ts';
|
|
61
|
+
/**
|
|
62
|
+
* Strip matching properties from the `cleanEnv(process.env, { ... })` call
|
|
63
|
+
* in `src/environment.ts`. Returns the names that were removed.
|
|
64
|
+
*/
|
|
65
|
+
function cleanEnvironmentFile(project, filePath) {
|
|
66
|
+
var _a;
|
|
67
|
+
const sourceFile = project.getSourceFile(filePath);
|
|
68
|
+
if (!sourceFile)
|
|
69
|
+
return [];
|
|
70
|
+
const removed = [];
|
|
71
|
+
// IMPORTANT: never iterate all call expressions while mutating this object.
|
|
72
|
+
// Removing a property deletes nested `url(...)` nodes, and touching those
|
|
73
|
+
// forgotten nodes later causes `InvalidOperationError`.
|
|
74
|
+
const cleanEnvCall = sourceFile.getDescendantsOfKind(ts_morph_1.SyntaxKind.CallExpression).find((call) => {
|
|
75
|
+
const expr = call.getExpression();
|
|
76
|
+
return ts_morph_1.Node.isIdentifier(expr) && expr.getText() === 'cleanEnv';
|
|
77
|
+
});
|
|
78
|
+
if (!cleanEnvCall)
|
|
79
|
+
return removed;
|
|
80
|
+
const schemaArg = (_a = cleanEnvCall
|
|
81
|
+
.getArguments()[1]) === null || _a === void 0 ? void 0 : _a.asKind(ts_morph_1.SyntaxKind.ObjectLiteralExpression);
|
|
82
|
+
if (!schemaArg)
|
|
83
|
+
return removed;
|
|
84
|
+
// Remove by explicit property-name lookup to avoid iterating over a live
|
|
85
|
+
// node list while mutating the object literal.
|
|
86
|
+
for (const name of UNUSED_ENV_VARS) {
|
|
87
|
+
const prop = schemaArg.getProperty(name);
|
|
88
|
+
if (!prop)
|
|
89
|
+
continue;
|
|
90
|
+
if (prop.isKind(ts_morph_1.SyntaxKind.PropertyAssignment) ||
|
|
91
|
+
prop.isKind(ts_morph_1.SyntaxKind.ShorthandPropertyAssignment)) {
|
|
92
|
+
prop.remove();
|
|
93
|
+
removed.push(name);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
return removed;
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Match `env.<NAME>` in an initializer (allowing surrounding parens / `as`
|
|
100
|
+
* casts that ts-morph emits in `getText()` as e.g. `(env.X as string)`).
|
|
101
|
+
* Returns the env var name if matched, or null.
|
|
102
|
+
*/
|
|
103
|
+
function extractEnvAccess(initText) {
|
|
104
|
+
if (!initText)
|
|
105
|
+
return null;
|
|
106
|
+
const match = /\benv\.([A-Z][A-Z0-9_]*)\b/.exec(initText);
|
|
107
|
+
return match ? match[1] : null;
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Strip top-level `const` declarations in `src/constants.ts` whose name is
|
|
111
|
+
* in `UNUSED_ENV_VARS` OR whose initializer reads `env.<NAME>` for one of
|
|
112
|
+
* those names. Returns the declaration names that were removed.
|
|
113
|
+
*/
|
|
114
|
+
function cleanConstantsFile(project, filePath) {
|
|
115
|
+
const sourceFile = project.getSourceFile(filePath);
|
|
116
|
+
if (!sourceFile)
|
|
117
|
+
return [];
|
|
118
|
+
const removed = [];
|
|
119
|
+
for (const stmt of [...sourceFile.getVariableStatements()]) {
|
|
120
|
+
const declarations = [...stmt.getDeclarations()];
|
|
121
|
+
const declarationsToRemove = declarations.filter((decl) => {
|
|
122
|
+
var _a;
|
|
123
|
+
const name = decl.getName();
|
|
124
|
+
const accessedEnvVar = extractEnvAccess((_a = decl.getInitializer()) === null || _a === void 0 ? void 0 : _a.getText());
|
|
125
|
+
return (UNUSED_ENV_VARS.has(name) ||
|
|
126
|
+
(accessedEnvVar !== null && UNUSED_ENV_VARS.has(accessedEnvVar)));
|
|
127
|
+
});
|
|
128
|
+
if (declarationsToRemove.length === 0)
|
|
129
|
+
continue;
|
|
130
|
+
// Resolve all names before mutating the AST; once a declaration or its
|
|
131
|
+
// parent statement is removed, ts-morph marks old nodes as forgotten.
|
|
132
|
+
const namesToRemove = declarationsToRemove.map((decl) => decl.getName());
|
|
133
|
+
removed.push(...namesToRemove);
|
|
134
|
+
if (declarationsToRemove.length === declarations.length) {
|
|
135
|
+
// All declarations in this statement are unused → drop the whole line
|
|
136
|
+
// (handles the dominant pattern: `export const X = env.X`).
|
|
137
|
+
stmt.remove();
|
|
138
|
+
}
|
|
139
|
+
else {
|
|
140
|
+
// Mixed statement (e.g. `const A = env.A, B = somethingElse`) — keep
|
|
141
|
+
// the survivors by removing matching declarators in place.
|
|
142
|
+
for (const decl of declarationsToRemove) {
|
|
143
|
+
decl.remove();
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
return removed;
|
|
148
|
+
}
|
|
149
|
+
function main() {
|
|
150
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
151
|
+
const project = new ts_morph_1.Project({
|
|
152
|
+
tsConfigFilePath: path_1.default.resolve(process.cwd(), 'tsconfig.json'),
|
|
153
|
+
skipAddingFilesFromTsConfig: false
|
|
154
|
+
});
|
|
155
|
+
console.log(`Removing unused environment variable(s) (${[...UNUSED_ENV_VARS].join(', ')})...\n`);
|
|
156
|
+
const envFilePath = path_1.default.join(process.cwd(), ENVIRONMENT_FILE_RELATIVE);
|
|
157
|
+
const constsFilePath = path_1.default.join(process.cwd(), CONSTANTS_FILE_RELATIVE);
|
|
158
|
+
const envRemoved = cleanEnvironmentFile(project, envFilePath);
|
|
159
|
+
if (envRemoved.length > 0) {
|
|
160
|
+
yield project.getSourceFileOrThrow(envFilePath).save();
|
|
161
|
+
console.log(` [${ENVIRONMENT_FILE_RELATIVE}] Removed schema entr${envRemoved.length === 1 ? 'y' : 'ies'}: ${envRemoved.join(', ')}`);
|
|
162
|
+
}
|
|
163
|
+
else if (project.getSourceFile(envFilePath)) {
|
|
164
|
+
console.log(` [${ENVIRONMENT_FILE_RELATIVE}] No matching schema entries — nothing to remove.`);
|
|
165
|
+
}
|
|
166
|
+
else {
|
|
167
|
+
console.log(` [${ENVIRONMENT_FILE_RELATIVE}] File not found — skipping.`);
|
|
168
|
+
}
|
|
169
|
+
const constsRemoved = cleanConstantsFile(project, constsFilePath);
|
|
170
|
+
if (constsRemoved.length > 0) {
|
|
171
|
+
yield project.getSourceFileOrThrow(constsFilePath).save();
|
|
172
|
+
console.log(` [${CONSTANTS_FILE_RELATIVE}] Removed declaration(s): ${constsRemoved.join(', ')}`);
|
|
173
|
+
}
|
|
174
|
+
else if (project.getSourceFile(constsFilePath)) {
|
|
175
|
+
console.log(` [${CONSTANTS_FILE_RELATIVE}] No matching declarations — nothing to remove.`);
|
|
176
|
+
}
|
|
177
|
+
else {
|
|
178
|
+
console.log(` [${CONSTANTS_FILE_RELATIVE}] File not found — skipping.`);
|
|
179
|
+
}
|
|
180
|
+
if (envRemoved.length === 0 && constsRemoved.length === 0) {
|
|
181
|
+
console.log('\nNothing to do.');
|
|
182
|
+
return;
|
|
183
|
+
}
|
|
184
|
+
console.log(`\nDone. NOTE: usages of these constants elsewhere in 'src/' may now produce TypeScript errors and need manual review.`);
|
|
185
|
+
});
|
|
186
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rename-api-paths.d.ts","sourceRoot":"","sources":["../../../src/migrations/v2.0/rename-api-paths.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"rename-api-paths.d.ts","sourceRoot":"","sources":["../../../src/migrations/v2.0/rename-api-paths.ts"],"names":[],"mappings":"AAuJA,iBAAe,IAAI,kBAgDlB;AAED,OAAO,EAAE,IAAI,EAAE,CAAA"}
|
|
@@ -43,7 +43,6 @@ exports.main = main;
|
|
|
43
43
|
*/
|
|
44
44
|
const ts_morph_1 = require("ts-morph");
|
|
45
45
|
const path_1 = __importDefault(require("path"));
|
|
46
|
-
const _1 = require(".");
|
|
47
46
|
// ─── Path rename table ────────────────────────────────────────────────────────
|
|
48
47
|
// Add new renames here as further API paths are changed between versions.
|
|
49
48
|
const PATH_RENAMES = {
|
|
@@ -130,7 +129,7 @@ function processFile(filePath, project) {
|
|
|
130
129
|
if (!sourceFile)
|
|
131
130
|
return 0;
|
|
132
131
|
let renamedCount = 0;
|
|
133
|
-
const relPath = path_1.default.relative(
|
|
132
|
+
const relPath = path_1.default.relative(process.cwd(), filePath);
|
|
134
133
|
// Collect candidates first to avoid iterating a mutating tree
|
|
135
134
|
const candidates = sourceFile.getDescendantsOfKind(ts_morph_1.SyntaxKind.ObjectLiteralExpression);
|
|
136
135
|
for (const obj of candidates) {
|
|
@@ -147,7 +146,7 @@ function processFile(filePath, project) {
|
|
|
147
146
|
// ─── Entry point ─────────────────────────────────────────────────────────────
|
|
148
147
|
function main() {
|
|
149
148
|
return __awaiter(this, void 0, void 0, function* () {
|
|
150
|
-
const srcDir = path_1.default.join(
|
|
149
|
+
const srcDir = path_1.default.join(process.cwd(), 'src');
|
|
151
150
|
console.log(`Scanning for Hapi route configs in: ${srcDir}\n`);
|
|
152
151
|
console.log('Active path renames:');
|
|
153
152
|
for (const [from, to] of Object.entries(PATH_RENAMES)) {
|
|
@@ -181,7 +180,7 @@ function main() {
|
|
|
181
180
|
for (const filePath of modifiedFiles) {
|
|
182
181
|
const sourceFile = project.getSourceFileOrThrow(filePath);
|
|
183
182
|
yield sourceFile.save();
|
|
184
|
-
console.log(` Saved: ${path_1.default.relative(
|
|
183
|
+
console.log(` Saved: ${path_1.default.relative(process.cwd(), filePath)}`);
|
|
185
184
|
}
|
|
186
185
|
console.log(`\nDone. Renamed ${totalRenamed} route path(s).`);
|
|
187
186
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rename-location-parent-id.d.ts","sourceRoot":"","sources":["../../../src/migrations/v2.0/rename-location-parent-id.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"rename-location-parent-id.d.ts","sourceRoot":"","sources":["../../../src/migrations/v2.0/rename-location-parent-id.ts"],"names":[],"mappings":"AAmJA,iBAAe,IAAI,kBAiDlB;AAED,OAAO,EAAE,IAAI,EAAE,CAAA"}
|
|
@@ -45,7 +45,6 @@ exports.main = main;
|
|
|
45
45
|
*/
|
|
46
46
|
const ts_morph_1 = require("ts-morph");
|
|
47
47
|
const path_1 = __importDefault(require("path"));
|
|
48
|
-
const _1 = require(".");
|
|
49
48
|
const OLD_PROPERTY_NAME = 'parentId';
|
|
50
49
|
const NEW_PROPERTY_NAME = 'administrativeAreaId';
|
|
51
50
|
const LOCATION_TYPE_NAME = 'Location';
|
|
@@ -138,14 +137,14 @@ function processFile(filePath, project) {
|
|
|
138
137
|
// surrounding whitespace and optional-chain tokens (?.)
|
|
139
138
|
propAccess.getNameNode().replaceWithText(NEW_PROPERTY_NAME);
|
|
140
139
|
renamedCount++;
|
|
141
|
-
console.log(` [${path_1.default.relative(
|
|
140
|
+
console.log(` [${path_1.default.relative(process.cwd(), filePath)}] Renamed Location.${OLD_PROPERTY_NAME} → Location.${NEW_PROPERTY_NAME}`);
|
|
142
141
|
}
|
|
143
142
|
return renamedCount;
|
|
144
143
|
}
|
|
145
144
|
// ─── Entry point ─────────────────────────────────────────────────────────────
|
|
146
145
|
function main() {
|
|
147
146
|
return __awaiter(this, void 0, void 0, function* () {
|
|
148
|
-
const srcDir = path_1.default.join(
|
|
147
|
+
const srcDir = path_1.default.join(process.cwd(), 'src');
|
|
149
148
|
console.log(`Scanning for Location.${OLD_PROPERTY_NAME} references in: ${srcDir}\n`);
|
|
150
149
|
const project = new ts_morph_1.Project({
|
|
151
150
|
tsConfigFilePath: path_1.default.resolve(srcDir, '../tsconfig.json'),
|
|
@@ -174,7 +173,7 @@ function main() {
|
|
|
174
173
|
for (const filePath of modifiedFiles) {
|
|
175
174
|
const sourceFile = project.getSourceFileOrThrow(filePath);
|
|
176
175
|
yield sourceFile.save();
|
|
177
|
-
console.log(` Saved: ${path_1.default.relative(
|
|
176
|
+
console.log(` Saved: ${path_1.default.relative(process.cwd(), filePath)}`);
|
|
178
177
|
}
|
|
179
178
|
console.log(`\nDone. Renamed ${totalRenamed} Location.${OLD_PROPERTY_NAME} reference(s) to Location.${NEW_PROPERTY_NAME}.`);
|
|
180
179
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"simplify-analytics-precalculations.d.ts","sourceRoot":"","sources":["../../../src/migrations/v2.0/simplify-analytics-precalculations.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"simplify-analytics-precalculations.d.ts","sourceRoot":"","sources":["../../../src/migrations/v2.0/simplify-analytics-precalculations.ts"],"names":[],"mappings":"AAqLA,iBAAe,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,CAyCnC;AAED,OAAO,EAAE,IAAI,EAAE,CAAA"}
|
|
@@ -51,7 +51,6 @@ exports.main = main;
|
|
|
51
51
|
const ts_morph_1 = require("ts-morph");
|
|
52
52
|
const fs_1 = __importDefault(require("fs"));
|
|
53
53
|
const path_1 = __importDefault(require("path"));
|
|
54
|
-
const _1 = require(".");
|
|
55
54
|
const ANALYTICS_FILE_REL = 'src/analytics/analytics.ts';
|
|
56
55
|
const FUNCTION_NAME = 'precalculateAdditionalAnalytics';
|
|
57
56
|
const IMPORT_NAMES_TO_REMOVE = new Set(['Event', 'precalculateBirthEvent']);
|
|
@@ -164,7 +163,7 @@ function simplifyPrecalculateFunction(sourceFile) {
|
|
|
164
163
|
// ─── Entry point ─────────────────────────────────────────────────────────────
|
|
165
164
|
function main() {
|
|
166
165
|
return __awaiter(this, void 0, void 0, function* () {
|
|
167
|
-
const cwd =
|
|
166
|
+
const cwd = process.cwd();
|
|
168
167
|
const absPath = path_1.default.join(cwd, ANALYTICS_FILE_REL);
|
|
169
168
|
if (!fs_1.default.existsSync(absPath)) {
|
|
170
169
|
console.log(`[${ANALYTICS_FILE_REL}] does not exist — nothing to clean up.`);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"update-package-json.d.ts","sourceRoot":"","sources":["../../../src/migrations/v2.0/update-package-json.ts"],"names":[],"mappings":"AA2CA,iBAAe,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,CAyEnC;AAED,OAAO,EAAE,IAAI,EAAE,CAAA"}
|
|
@@ -0,0 +1,105 @@
|
|
|
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: Update root `package.json` for the v1.9 → v2.0 upgrade.
|
|
28
|
+
*
|
|
29
|
+
* Changes applied:
|
|
30
|
+
* 1. Sets `version` to `2.0.0`.
|
|
31
|
+
* 2. Sets `zod` to `^4.2.1` in `dependencies` (or `devDependencies` if it
|
|
32
|
+
* already lives there). If `zod` is absent from both, it's added to
|
|
33
|
+
* `dependencies`.
|
|
34
|
+
*
|
|
35
|
+
* Caveats:
|
|
36
|
+
* - The codemod preserves the file's existing 2-space indentation and
|
|
37
|
+
* trailing newline. Any non-standard formatting (e.g. tabs) will be
|
|
38
|
+
* replaced with 2-space indentation.
|
|
39
|
+
* - No-op when `package.json` is missing.
|
|
40
|
+
* - No automatic `yarn install` is run; the developer should reinstall
|
|
41
|
+
* dependencies after the codemods complete.
|
|
42
|
+
*/
|
|
43
|
+
const fs_1 = require("fs");
|
|
44
|
+
const path_1 = __importDefault(require("path"));
|
|
45
|
+
const PACKAGE_JSON_RELATIVE = 'package.json';
|
|
46
|
+
const TARGET_VERSION = '2.0.0';
|
|
47
|
+
const TARGET_ZOD_RANGE = '^4.2.1';
|
|
48
|
+
function main() {
|
|
49
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
50
|
+
const packageJsonPath = path_1.default.join(process.cwd(), PACKAGE_JSON_RELATIVE);
|
|
51
|
+
if (!(0, fs_1.existsSync)(packageJsonPath)) {
|
|
52
|
+
console.log(`'${PACKAGE_JSON_RELATIVE}' not found in ${process.cwd()} — skipping.`);
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
const raw = (0, fs_1.readFileSync)(packageJsonPath, 'utf8');
|
|
56
|
+
let parsed;
|
|
57
|
+
try {
|
|
58
|
+
parsed = JSON.parse(raw);
|
|
59
|
+
}
|
|
60
|
+
catch (error) {
|
|
61
|
+
console.warn(` [${PACKAGE_JSON_RELATIVE}] Failed to parse JSON — skipping update. ${error.message}`);
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
console.log(`Updating '${PACKAGE_JSON_RELATIVE}'...`);
|
|
65
|
+
const previousVersion = parsed.version;
|
|
66
|
+
const versionChanged = previousVersion !== TARGET_VERSION;
|
|
67
|
+
parsed.version = TARGET_VERSION;
|
|
68
|
+
if (versionChanged) {
|
|
69
|
+
console.log(` Set version: ${previousVersion !== null && previousVersion !== void 0 ? previousVersion : '<unset>'} → ${TARGET_VERSION}`);
|
|
70
|
+
}
|
|
71
|
+
else {
|
|
72
|
+
console.log(` Version already ${TARGET_VERSION} — no change.`);
|
|
73
|
+
}
|
|
74
|
+
// Resolve which dependency bucket already holds zod, defaulting to
|
|
75
|
+
// `dependencies` when absent.
|
|
76
|
+
let zodBucket = 'dependencies';
|
|
77
|
+
if (parsed.devDependencies && 'zod' in parsed.devDependencies) {
|
|
78
|
+
zodBucket = 'devDependencies';
|
|
79
|
+
}
|
|
80
|
+
if (!parsed[zodBucket]) {
|
|
81
|
+
parsed[zodBucket] = {};
|
|
82
|
+
}
|
|
83
|
+
const bucket = parsed[zodBucket];
|
|
84
|
+
const previousZod = bucket.zod;
|
|
85
|
+
const zodChanged = previousZod !== TARGET_ZOD_RANGE;
|
|
86
|
+
bucket.zod = TARGET_ZOD_RANGE;
|
|
87
|
+
if (zodChanged) {
|
|
88
|
+
console.log(` Set ${zodBucket}.zod: ${previousZod !== null && previousZod !== void 0 ? previousZod : '<absent>'} → ${TARGET_ZOD_RANGE}`);
|
|
89
|
+
}
|
|
90
|
+
else {
|
|
91
|
+
console.log(` ${zodBucket}.zod already ${TARGET_ZOD_RANGE} — no change.`);
|
|
92
|
+
}
|
|
93
|
+
// Preserve trailing newline if the source had one (default to LF since
|
|
94
|
+
// most repos commit JSON with a trailing newline).
|
|
95
|
+
const trailingNewline = raw.endsWith('\n') ? '\n' : '';
|
|
96
|
+
const next = JSON.stringify(parsed, null, 2) + trailingNewline;
|
|
97
|
+
if (next === raw) {
|
|
98
|
+
console.log('\n No changes to write.');
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
(0, fs_1.writeFileSync)(packageJsonPath, next, 'utf8');
|
|
102
|
+
console.log(`\n Saved '${PACKAGE_JSON_RELATIVE}'.`);
|
|
103
|
+
console.log(` NOTE: run \`yarn install\` (or your package manager equivalent) to install the updated dependency versions.`);
|
|
104
|
+
});
|
|
105
|
+
}
|
|
@@ -137,6 +137,9 @@ var CustomActionScopeOptions = AllRecordScopeOptions.extend({
|
|
|
137
137
|
var AccessLevelOptions = z2.object({
|
|
138
138
|
accessLevel: JurisdictionFilter.optional()
|
|
139
139
|
});
|
|
140
|
+
var AllUserScopeOptions = AccessLevelOptions.extend({
|
|
141
|
+
role: userRole.optional()
|
|
142
|
+
});
|
|
140
143
|
var WorkqueueOrDashboardOptions = z2.object({
|
|
141
144
|
ids: z2.preprocess(
|
|
142
145
|
(val) => val === void 0 ? void 0 : [val].flat(),
|
|
@@ -146,6 +149,7 @@ var WorkqueueOrDashboardOptions = z2.object({
|
|
|
146
149
|
var AllScopeOptions = z2.object({
|
|
147
150
|
...AllRecordScopeOptions.shape,
|
|
148
151
|
...AccessLevelOptions.shape,
|
|
152
|
+
...AllUserScopeOptions.shape,
|
|
149
153
|
...WorkqueueOrDashboardOptions.shape
|
|
150
154
|
});
|
|
151
155
|
var ScopeOptionKey = AllScopeOptions.keyof();
|
|
@@ -233,16 +237,11 @@ var ScopesWithRoleOption = UserScopeType.extract(["user.edit", "user.create"]);
|
|
|
233
237
|
var UserScopeV2 = z2.discriminatedUnion("type", [
|
|
234
238
|
z2.object({
|
|
235
239
|
type: ScopesWithRoleOption,
|
|
236
|
-
options:
|
|
237
|
-
accessLevel: JurisdictionFilter.optional(),
|
|
238
|
-
role: userRole.optional()
|
|
239
|
-
}).optional()
|
|
240
|
+
options: AllUserScopeOptions.optional()
|
|
240
241
|
}),
|
|
241
242
|
z2.object({
|
|
242
243
|
type: UserScopeType.extract(["user.read"]),
|
|
243
|
-
options:
|
|
244
|
-
accessLevel: JurisdictionFilter.optional()
|
|
245
|
-
}).optional()
|
|
244
|
+
options: AccessLevelOptions.optional()
|
|
246
245
|
})
|
|
247
246
|
]);
|
|
248
247
|
var ResolvedRecordScopeV2 = z2.discriminatedUnion("type", [
|
package/dist/scopes/index.d.ts
CHANGED
|
@@ -41,6 +41,7 @@ declare const AllScopeOptions: z.ZodObject<{
|
|
|
41
41
|
location: "location";
|
|
42
42
|
all: "all";
|
|
43
43
|
}>>;
|
|
44
|
+
role: z.ZodOptional<z.ZodPipe<z.ZodTransform<({} | null)[] | undefined, unknown>, z.ZodOptional<z.ZodArray<z.ZodString>>>>;
|
|
44
45
|
event: z.ZodPipe<z.ZodTransform<({} | null)[] | undefined, unknown>, z.ZodOptional<z.ZodArray<z.ZodString>>>;
|
|
45
46
|
placeOfEvent: z.ZodOptional<z.ZodEnum<{
|
|
46
47
|
administrativeArea: "administrativeArea";
|
|
@@ -66,6 +67,7 @@ declare const AllScopeOptions: z.ZodObject<{
|
|
|
66
67
|
}, z.core.$strip>;
|
|
67
68
|
type AllScopeOptions = z.infer<typeof AllScopeOptions>;
|
|
68
69
|
export declare const ScopeOptionKey: z.ZodEnum<{
|
|
70
|
+
role: "role";
|
|
69
71
|
event: "event";
|
|
70
72
|
placeOfEvent: "placeOfEvent";
|
|
71
73
|
declaredIn: "declaredIn";
|
package/dist/scopes/index.js
CHANGED
|
@@ -168,6 +168,9 @@ var CustomActionScopeOptions = AllRecordScopeOptions.extend({
|
|
|
168
168
|
var AccessLevelOptions = z3.object({
|
|
169
169
|
accessLevel: JurisdictionFilter.optional()
|
|
170
170
|
});
|
|
171
|
+
var AllUserScopeOptions = AccessLevelOptions.extend({
|
|
172
|
+
role: userRole.optional()
|
|
173
|
+
});
|
|
171
174
|
var WorkqueueOrDashboardOptions = z3.object({
|
|
172
175
|
ids: z3.preprocess(
|
|
173
176
|
(val) => val === void 0 ? void 0 : [val].flat(),
|
|
@@ -177,6 +180,7 @@ var WorkqueueOrDashboardOptions = z3.object({
|
|
|
177
180
|
var AllScopeOptions = z3.object({
|
|
178
181
|
...AllRecordScopeOptions.shape,
|
|
179
182
|
...AccessLevelOptions.shape,
|
|
183
|
+
...AllUserScopeOptions.shape,
|
|
180
184
|
...WorkqueueOrDashboardOptions.shape
|
|
181
185
|
});
|
|
182
186
|
var ScopeOptionKey = AllScopeOptions.keyof();
|
|
@@ -264,16 +268,11 @@ var ScopesWithRoleOption = UserScopeType.extract(["user.edit", "user.create"]);
|
|
|
264
268
|
var UserScopeV2 = z3.discriminatedUnion("type", [
|
|
265
269
|
z3.object({
|
|
266
270
|
type: ScopesWithRoleOption,
|
|
267
|
-
options:
|
|
268
|
-
accessLevel: JurisdictionFilter.optional(),
|
|
269
|
-
role: userRole.optional()
|
|
270
|
-
}).optional()
|
|
271
|
+
options: AllUserScopeOptions.optional()
|
|
271
272
|
}),
|
|
272
273
|
z3.object({
|
|
273
274
|
type: UserScopeType.extract(["user.read"]),
|
|
274
|
-
options:
|
|
275
|
-
accessLevel: JurisdictionFilter.optional()
|
|
276
|
-
}).optional()
|
|
275
|
+
options: AccessLevelOptions.optional()
|
|
277
276
|
})
|
|
278
277
|
]);
|
|
279
278
|
function scopeUsesRoleOptions(scope) {
|
|
Binary file
|
package/package.json
CHANGED
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/checkout-upstream-files.ts","./src/migrations/v2.0/convert-config-files-to-ts.ts","./src/migrations/v2.0/convert-paragraph-to-heading.ts","./src/migrations/v2.0/create-events-index.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/migrations/v2.0/simplify-analytics-precalculations.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/add-resend-invite-notification.ts","./src/migrations/v2.0/checkout-upstream-files.ts","./src/migrations/v2.0/convert-config-files-to-ts.ts","./src/migrations/v2.0/convert-paragraph-to-heading.ts","./src/migrations/v2.0/create-events-index.ts","./src/migrations/v2.0/delete-infrastructure-directory.ts","./src/migrations/v2.0/index.ts","./src/migrations/v2.0/make-built-in-validate-actions-custom.ts","./src/migrations/v2.0/merge-infrastructure-directory.ts","./src/migrations/v2.0/migrate-application-config-url.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-fhir-url-helpers.ts","./src/migrations/v2.0/remove-hearth-migrations.ts","./src/migrations/v2.0/remove-old-statistics-service.ts","./src/migrations/v2.0/remove-pending-certification-flag.ts","./src/migrations/v2.0/remove-review-from-register-action.ts","./src/migrations/v2.0/remove-unused-environment-variables.ts","./src/migrations/v2.0/rename-api-paths.ts","./src/migrations/v2.0/rename-location-parent-id.ts","./src/migrations/v2.0/simplify-analytics-precalculations.ts","./src/migrations/v2.0/update-package-json.ts","./src/notification/index.ts","./src/scopes/index.ts"],"version":"5.6.3"}
|
|
Binary file
|