@opencrvs/toolkit 2.1.0-rc.c3b24ba → 2.1.0-rc.c500a81
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/README.md +3 -12
- package/build.sh +12 -4
- package/create-countryconfig/index.js +441 -59
- package/create-countryconfig/node_modules/.bin/degit +21 -0
- package/create-countryconfig/package.json +4 -1
- package/dist/application-config/index.js +347 -283
- package/dist/authentication/index.d.ts +67 -0
- package/dist/authentication/index.d.ts.map +1 -0
- package/dist/authentication/index.js +751 -0
- package/dist/cli.js +3011 -1226
- package/dist/commons/api/router.d.ts +658 -132
- package/dist/commons/application-config/index.d.ts +0 -2
- package/dist/commons/conditionals/conditionals.d.ts +6 -6
- package/dist/commons/conditionals/validate.d.ts +16 -5
- package/dist/commons/events/ActionConfig.d.ts +4 -0
- package/dist/commons/events/ActionDocument.d.ts +35 -15
- package/dist/commons/events/ActionInput.d.ts +4 -4
- package/dist/commons/events/ActionStatus.d.ts +14 -0
- package/dist/commons/events/AdvancedSearchConfig.d.ts +30 -12
- package/dist/commons/events/AuditLog.d.ts +110 -0
- package/dist/commons/events/EventConfig.d.ts +3 -0
- package/dist/commons/events/EventDocument.d.ts +472 -4
- package/dist/commons/events/EventIndex.d.ts +3 -26
- package/dist/commons/events/EventMetadata.d.ts +1 -11
- package/dist/commons/events/EventStatus.d.ts +19 -0
- package/dist/commons/events/FieldConfig.d.ts +94 -63
- package/dist/commons/events/FieldTypeMapping.d.ts +27 -27
- package/dist/commons/events/FieldValue.d.ts +3 -2
- package/dist/commons/events/Flag.d.ts +42 -0
- package/dist/commons/events/FormConfig.d.ts +6 -0
- package/dist/commons/events/PageConfig.d.ts +4 -0
- package/dist/commons/events/PlainDate.d.ts +8 -0
- package/dist/commons/events/SummaryConfig.d.ts +249 -0
- package/dist/commons/events/WorkqueueConfig.d.ts +17 -14
- package/dist/commons/events/event.d.ts +12 -0
- package/dist/commons/events/locations.d.ts +162 -26
- package/dist/commons/events/mocks.test.utils.d.ts +30 -0
- package/dist/commons/events/test.utils.d.ts +73 -18
- package/dist/commons/events/utils.d.ts +34 -4
- package/dist/commons/notification/UserNotifications.d.ts +28 -13
- package/dist/commons/notification/dispatch.d.ts +10 -0
- package/dist/commons/notification/index.d.ts +1 -0
- package/dist/conditionals/index.js +334 -64
- package/dist/csv.d.ts +25 -0
- package/dist/csv.d.ts.map +1 -0
- package/dist/csv.js +120 -0
- package/dist/environment/index.d.ts +1 -0
- package/dist/environment/index.d.ts.map +1 -1
- package/dist/environment/index.js +12 -1
- package/dist/environment/logger.d.ts +15 -3
- package/dist/environment/logger.d.ts.map +1 -1
- package/dist/environment/manage-users.js +1 -1
- package/dist/environment/paths.d.ts +7 -0
- package/dist/environment/paths.d.ts.map +1 -0
- package/dist/environment/paths.js +72 -0
- package/dist/environment/questions.d.ts.map +1 -1
- package/dist/environment/questions.js +20 -14
- package/dist/environment/setup-environment.d.ts +1 -1
- package/dist/environment/setup-environment.d.ts.map +1 -1
- package/dist/environment/setup-environment.js +587 -562
- package/dist/environment/templates.d.ts +0 -1
- package/dist/environment/templates.d.ts.map +1 -1
- package/dist/environment/templates.js +5 -9
- package/dist/environment/update-workflows.d.ts.map +1 -1
- package/dist/environment/update-workflows.js +21 -5
- package/dist/environment/upgrade.d.ts +2 -0
- package/dist/environment/upgrade.d.ts.map +1 -0
- package/dist/environment/upgrade.js +82 -0
- package/dist/environment/users.js +11 -13
- package/dist/environment/utils.d.ts +0 -12
- package/dist/environment/utils.d.ts.map +1 -1
- package/dist/environment/utils.js +1 -28
- package/dist/events/index.js +7597 -7129
- package/dist/migrations/v2.0/checkout-upstream-files.d.ts +2 -2
- package/dist/migrations/v2.0/checkout-upstream-files.d.ts.map +1 -1
- package/dist/migrations/v2.0/checkout-upstream-files.js +2 -2
- 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 +3 -10
- package/dist/migrations/v2.0/merge-infrastructure-directory.js +3 -3
- package/dist/migrations/v2.1/add-recovery-link-notifications.d.ts +3 -0
- package/dist/migrations/v2.1/add-recovery-link-notifications.d.ts.map +1 -0
- package/dist/migrations/v2.1/add-recovery-link-notifications.js +511 -0
- package/dist/migrations/v2.1/add-translations.d.ts +9 -0
- package/dist/migrations/v2.1/add-translations.d.ts.map +1 -0
- package/dist/migrations/v2.1/add-translations.js +149 -0
- package/dist/migrations/v2.1/enable-telemetry.d.ts +3 -0
- package/dist/migrations/v2.1/enable-telemetry.d.ts.map +1 -0
- package/dist/migrations/v2.1/enable-telemetry.js +455 -0
- package/dist/migrations/v2.1/index.d.ts.map +1 -1
- package/dist/migrations/v2.1/index.js +1223 -0
- package/dist/migrations/v2.1/rename-trigger-paths.d.ts +3 -0
- package/dist/migrations/v2.1/rename-trigger-paths.d.ts.map +1 -0
- package/dist/migrations/v2.1/rename-trigger-paths.js +216 -0
- package/dist/notification/index.js +1800 -1454
- package/dist/scopes/index.d.ts +433 -36
- package/dist/scopes/index.js +335 -64
- package/dist/telemetry/index.d.ts +45 -0
- package/dist/telemetry/index.d.ts.map +1 -0
- package/dist/telemetry/index.js +43 -0
- package/dist/templates/charts-values/dependencies/values.yaml +2 -0
- package/dist/templates/charts-values/opencrvs-services/values.yaml +4 -3
- package/dist/templates/charts-values/opentelemetry/values.yaml +102 -0
- package/dist/templates/charts-values/traefik/values.yaml +23 -9
- package/dist/templates/inventory/inventory.template.yml +1 -3
- package/dist/translations/template.d.ts +11 -0
- package/dist/translations/template.d.ts.map +1 -0
- package/dist/translations/template.js +100 -0
- package/dist/verify/endpoints.d.ts +2 -0
- package/dist/verify/endpoints.d.ts.map +1 -0
- package/dist/verify/endpoints.js +510 -0
- package/opencrvs-toolkit-2.1.0-rc.c500a81.tgz +0 -0
- package/package.json +13 -7
- package/tsconfig.build.json +11 -0
- package/tsconfig.build.tsbuildinfo +1 -0
- package/tsconfig.json +3 -0
- package/dist/templates/inventory/production.example.yml +0 -77
- package/dist/templates/inventory/qa.example.yml +0 -48
- package/opencrvs-toolkit-2.1.0-rc.c3b24ba.tgz +0 -0
- package/tsconfig.tsbuildinfo +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rename-trigger-paths.d.ts","sourceRoot":"","sources":["../../../src/migrations/v2.1/rename-trigger-paths.ts"],"names":[],"mappings":"AAiMA,iBAAe,IAAI,kBAiDlB;AAED,OAAO,EAAE,IAAI,EAAE,CAAA"}
|
|
@@ -0,0 +1,216 @@
|
|
|
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: Rename the `/triggers/...` country config routes to `/trigger/...`.
|
|
28
|
+
*
|
|
29
|
+
* Usage:
|
|
30
|
+
* ts-node -r tsconfig-paths/register src/migrations/v2.1/rename-trigger-paths.ts
|
|
31
|
+
*
|
|
32
|
+
* Why:
|
|
33
|
+
* The user-notification and system-ready triggers were served under
|
|
34
|
+
* `/triggers/`, while the event action and telemetry triggers use
|
|
35
|
+
* `/trigger/`. v2.1 settles on the singular prefix for all of them, so core
|
|
36
|
+
* now posts to `/trigger/user/*` and gets `/trigger/system/ready`. A route
|
|
37
|
+
* left on the old path answers 404, which core logs and moves on from — the
|
|
38
|
+
* notification is simply never sent and the country config's integrations
|
|
39
|
+
* are never registered. See CHANGELOG.md ("Country config triggers are all
|
|
40
|
+
* served under /trigger").
|
|
41
|
+
*
|
|
42
|
+
* What it does:
|
|
43
|
+
* - Scans all TypeScript files under `src/`
|
|
44
|
+
* - Finds every object literal that looks like a Hapi route config (a
|
|
45
|
+
* `method` property holding an HTTP verb, or an array of them, plus a
|
|
46
|
+
* string-literal `path`)
|
|
47
|
+
* - Rewrites a `path` starting with any prefix in PATH_PREFIX_RENAMES
|
|
48
|
+
* - Saves the modified files in-place
|
|
49
|
+
* - Warns about every remaining `/triggers/` occurrence under `src/`, which
|
|
50
|
+
* is anything this codemod cannot rewrite safely: a path built from a
|
|
51
|
+
* template literal or variable, a route config it did not recognise, or a
|
|
52
|
+
* test that requests the old path
|
|
53
|
+
*/
|
|
54
|
+
const ts_morph_1 = require("ts-morph");
|
|
55
|
+
const path_1 = __importDefault(require("path"));
|
|
56
|
+
// ─── Path rename table ────────────────────────────────────────────────────────
|
|
57
|
+
// Prefixes rather than whole paths: `/triggers/user/` covers one route per
|
|
58
|
+
// `TriggerEvent`, and a country config may have added its own.
|
|
59
|
+
const PATH_PREFIX_RENAMES = {
|
|
60
|
+
'/triggers/user/': '/trigger/user/',
|
|
61
|
+
'/triggers/system/': '/trigger/system/'
|
|
62
|
+
};
|
|
63
|
+
/** Matched against the remaining source text once the renames are applied. */
|
|
64
|
+
const STALE_PREFIX = '/triggers/';
|
|
65
|
+
// ─── Constants ────────────────────────────────────────────────────────────────
|
|
66
|
+
const METHOD_PROPERTY_NAME = 'method';
|
|
67
|
+
const PATH_PROPERTY_NAME = 'path';
|
|
68
|
+
const HTTP_VERBS = new Set([
|
|
69
|
+
'GET',
|
|
70
|
+
'POST',
|
|
71
|
+
'PUT',
|
|
72
|
+
'PATCH',
|
|
73
|
+
'DELETE',
|
|
74
|
+
'OPTIONS',
|
|
75
|
+
'HEAD',
|
|
76
|
+
'*'
|
|
77
|
+
]);
|
|
78
|
+
// ─── Helpers ──────────────────────────────────────────────────────────────────
|
|
79
|
+
/**
|
|
80
|
+
* Returns true when the given object literal looks like a Hapi route config,
|
|
81
|
+
* i.e. it has a `method` property holding a recognised HTTP verb string (or an
|
|
82
|
+
* array of them) and a string-literal `path` property.
|
|
83
|
+
*/
|
|
84
|
+
function isRouteConfig(obj) {
|
|
85
|
+
const methodProp = obj.getProperty(METHOD_PROPERTY_NAME);
|
|
86
|
+
if (!methodProp || !ts_morph_1.Node.isPropertyAssignment(methodProp))
|
|
87
|
+
return false;
|
|
88
|
+
const methodInit = methodProp.getInitializer();
|
|
89
|
+
if (!methodInit)
|
|
90
|
+
return false;
|
|
91
|
+
if (ts_morph_1.Node.isStringLiteral(methodInit)) {
|
|
92
|
+
if (!HTTP_VERBS.has(methodInit.getLiteralValue().toUpperCase()))
|
|
93
|
+
return false;
|
|
94
|
+
}
|
|
95
|
+
else if (ts_morph_1.Node.isArrayLiteralExpression(methodInit)) {
|
|
96
|
+
const allVerbs = methodInit
|
|
97
|
+
.getElements()
|
|
98
|
+
.every((el) => ts_morph_1.Node.isStringLiteral(el) &&
|
|
99
|
+
HTTP_VERBS.has(el.getLiteralValue().toUpperCase()));
|
|
100
|
+
if (!allVerbs)
|
|
101
|
+
return false;
|
|
102
|
+
}
|
|
103
|
+
else {
|
|
104
|
+
return false;
|
|
105
|
+
}
|
|
106
|
+
const pathProp = obj.getProperty(PATH_PROPERTY_NAME);
|
|
107
|
+
if (!pathProp || !ts_morph_1.Node.isPropertyAssignment(pathProp))
|
|
108
|
+
return false;
|
|
109
|
+
const pathInit = pathProp.getInitializer();
|
|
110
|
+
return !!pathInit && ts_morph_1.Node.isStringLiteral(pathInit);
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Applies PATH_PREFIX_RENAMES to the `path` of a confirmed route config.
|
|
114
|
+
* Returns the new path, or null when no prefix matched.
|
|
115
|
+
*/
|
|
116
|
+
function renameRoutePath(obj) {
|
|
117
|
+
const pathProp = obj.getProperty(PATH_PROPERTY_NAME);
|
|
118
|
+
if (!pathProp || !ts_morph_1.Node.isPropertyAssignment(pathProp))
|
|
119
|
+
return null;
|
|
120
|
+
const pathInit = pathProp.getInitializer();
|
|
121
|
+
if (!pathInit || !ts_morph_1.Node.isStringLiteral(pathInit))
|
|
122
|
+
return null;
|
|
123
|
+
const oldPath = pathInit.getLiteralValue();
|
|
124
|
+
const match = Object.entries(PATH_PREFIX_RENAMES).find(([from]) => oldPath.startsWith(from));
|
|
125
|
+
if (!match)
|
|
126
|
+
return null;
|
|
127
|
+
const [from, to] = match;
|
|
128
|
+
const newPath = to + oldPath.slice(from.length);
|
|
129
|
+
pathInit.replaceWithText(`'${newPath}'`);
|
|
130
|
+
return newPath;
|
|
131
|
+
}
|
|
132
|
+
// ─── File processor ──────────────────────────────────────────────────────────
|
|
133
|
+
function processFile(filePath, project) {
|
|
134
|
+
const sourceFile = project.getSourceFile(filePath);
|
|
135
|
+
if (!sourceFile)
|
|
136
|
+
return 0;
|
|
137
|
+
let renamedCount = 0;
|
|
138
|
+
const relPath = path_1.default.relative(process.cwd(), filePath);
|
|
139
|
+
// Collect candidates first to avoid iterating a mutating tree
|
|
140
|
+
const candidates = sourceFile.getDescendantsOfKind(ts_morph_1.SyntaxKind.ObjectLiteralExpression);
|
|
141
|
+
for (const obj of candidates) {
|
|
142
|
+
if (!isRouteConfig(obj))
|
|
143
|
+
continue;
|
|
144
|
+
const newPath = renameRoutePath(obj);
|
|
145
|
+
if (newPath) {
|
|
146
|
+
renamedCount++;
|
|
147
|
+
console.log(` [${relPath}] Renamed route path → '${newPath}'`);
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
return renamedCount;
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* Reports leftover `/triggers/` occurrences. Rewriting these is guesswork —
|
|
154
|
+
* the path may be assembled at runtime — but leaving them unmentioned would
|
|
155
|
+
* hide a route that still answers on the old path.
|
|
156
|
+
*/
|
|
157
|
+
function warnAboutStalePaths(sourceFiles) {
|
|
158
|
+
const stale = [];
|
|
159
|
+
for (const sourceFile of sourceFiles) {
|
|
160
|
+
const relPath = path_1.default.relative(process.cwd(), sourceFile.getFilePath());
|
|
161
|
+
const lines = sourceFile.getFullText().split('\n');
|
|
162
|
+
lines.forEach((line, index) => {
|
|
163
|
+
if (line.includes(STALE_PREFIX)) {
|
|
164
|
+
stale.push(` ${relPath}:${index + 1}: ${line.trim()}`);
|
|
165
|
+
}
|
|
166
|
+
});
|
|
167
|
+
}
|
|
168
|
+
if (stale.length === 0)
|
|
169
|
+
return;
|
|
170
|
+
console.log(`\nWARNING: ${stale.length} remaining '${STALE_PREFIX}' reference(s) need to be renamed by hand:`);
|
|
171
|
+
console.log(stale.join('\n'));
|
|
172
|
+
}
|
|
173
|
+
// ─── Entry point ─────────────────────────────────────────────────────────────
|
|
174
|
+
function main() {
|
|
175
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
176
|
+
const srcDir = path_1.default.join(process.cwd(), 'src');
|
|
177
|
+
console.log(`Scanning for Hapi route configs in: ${srcDir}\n`);
|
|
178
|
+
console.log('Active path renames:');
|
|
179
|
+
for (const [from, to] of Object.entries(PATH_PREFIX_RENAMES)) {
|
|
180
|
+
console.log(` '${from}*' → '${to}*'`);
|
|
181
|
+
}
|
|
182
|
+
console.log();
|
|
183
|
+
const project = new ts_morph_1.Project({
|
|
184
|
+
tsConfigFilePath: path_1.default.resolve(srcDir, '../tsconfig.json'),
|
|
185
|
+
skipAddingFilesFromTsConfig: false
|
|
186
|
+
});
|
|
187
|
+
const sourceFiles = project.getSourceFiles().filter((sf) => {
|
|
188
|
+
const fp = sf.getFilePath();
|
|
189
|
+
return fp.includes('/src/') && !fp.includes('/node_modules/');
|
|
190
|
+
});
|
|
191
|
+
console.log(`Found ${sourceFiles.length} source file(s) to analyse.\n`);
|
|
192
|
+
let totalRenamed = 0;
|
|
193
|
+
const modifiedFiles = [];
|
|
194
|
+
for (const sourceFile of sourceFiles) {
|
|
195
|
+
const filePath = sourceFile.getFilePath();
|
|
196
|
+
const renamed = processFile(filePath, project);
|
|
197
|
+
if (renamed > 0) {
|
|
198
|
+
totalRenamed += renamed;
|
|
199
|
+
modifiedFiles.push(filePath);
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
if (modifiedFiles.length === 0) {
|
|
203
|
+
console.log('No trigger route paths to rename.');
|
|
204
|
+
}
|
|
205
|
+
else {
|
|
206
|
+
console.log(`\nSaving ${modifiedFiles.length} modified file(s)...`);
|
|
207
|
+
for (const filePath of modifiedFiles) {
|
|
208
|
+
const sourceFile = project.getSourceFileOrThrow(filePath);
|
|
209
|
+
yield sourceFile.save();
|
|
210
|
+
console.log(` Saved: ${path_1.default.relative(process.cwd(), filePath)}`);
|
|
211
|
+
}
|
|
212
|
+
console.log(`\nDone. Renamed ${totalRenamed} route path(s).`);
|
|
213
|
+
}
|
|
214
|
+
warnAboutStalePaths(sourceFiles);
|
|
215
|
+
});
|
|
216
|
+
}
|