@opencrvs/toolkit 2.1.0-rc.03f553a → 2.1.0-rc.05a1257
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 +1 -0
- package/build.sh +2 -1
- package/create-countryconfig/index.js +114 -66
- package/create-countryconfig/node_modules/.bin/degit +21 -0
- package/create-countryconfig/package.json +4 -1
- package/dist/application-config/index.js +341 -274
- package/dist/cli.js +1000 -104
- package/dist/commons/api/router.d.ts +691 -76
- package/dist/commons/conditionals/conditionals.d.ts +6 -6
- package/dist/commons/conditionals/validate.d.ts +16 -5
- package/dist/commons/events/ActionDocument.d.ts +5 -11
- 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 +24 -0
- package/dist/commons/events/AuditLog.d.ts +147 -0
- package/dist/commons/events/EventConfig.d.ts +3 -0
- package/dist/commons/events/EventDocument.d.ts +470 -2
- 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 +88 -53
- package/dist/commons/events/FieldTypeMapping.d.ts +27 -27
- package/dist/commons/events/FieldValue.d.ts +2 -2
- package/dist/commons/events/Flag.d.ts +42 -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/index.d.ts +1 -0
- package/dist/commons/events/locationPayloads.d.ts +95 -0
- package/dist/commons/events/locations.d.ts +165 -26
- package/dist/commons/events/mocks.test.utils.d.ts +30 -0
- package/dist/commons/events/test.utils.d.ts +8 -4
- package/dist/commons/events/utils.d.ts +2 -2
- package/dist/commons/notification/UserNotifications.d.ts +28 -13
- package/dist/commons/notification/dispatch.d.ts +15 -0
- package/dist/commons/notification/index.d.ts +1 -0
- package/dist/conditionals/index.js +328 -58
- package/dist/csv.d.ts +25 -0
- package/dist/csv.d.ts.map +1 -0
- package/dist/csv.js +115 -0
- package/dist/environment/index.d.ts +1 -0
- package/dist/environment/index.d.ts.map +1 -1
- package/dist/environment/index.js +10 -0
- package/dist/environment/logger.d.ts +12 -3
- package/dist/environment/logger.d.ts.map +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.js +3 -2
- package/dist/environment/templates.d.ts.map +1 -1
- package/dist/environment/templates.js +2 -1
- package/dist/environment/update-workflows.d.ts.map +1 -1
- package/dist/environment/update-workflows.js +17 -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/events/index.js +3688 -3293
- 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.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 +182 -0
- package/dist/migrations/v2.1/index.d.ts.map +1 -1
- package/dist/migrations/v2.1/index.js +637 -0
- package/dist/notification/index.js +1833 -1426
- package/dist/scopes/index.d.ts +327 -32
- package/dist/scopes/index.js +329 -58
- package/dist/templates/charts-values/opencrvs-services/values.yaml +4 -3
- package/dist/templates/charts-values/opentelemetry/values.yaml +95 -0
- package/dist/templates/charts-values/traefik/values.yaml +23 -9
- package/dist/templates/inventory/inventory.template.yml +1 -3
- package/dist/translations/check.d.ts +23 -0
- package/dist/translations/check.d.ts.map +1 -0
- package/dist/translations/check.js +126 -0
- package/opencrvs-toolkit-2.1.0-rc.05a1257.tgz +0 -0
- package/package.json +9 -6
- package/tsconfig.build.json +11 -0
- package/tsconfig.build.tsbuildinfo +1 -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.03f553a.tgz +0 -0
- package/tsconfig.tsbuildinfo +0 -1
|
@@ -0,0 +1,182 @@
|
|
|
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.rowsToAdd = rowsToAdd;
|
|
26
|
+
exports.main = main;
|
|
27
|
+
/**
|
|
28
|
+
* Codemod: copy the translation keys core gained this version into this country
|
|
29
|
+
* config.
|
|
30
|
+
*
|
|
31
|
+
* Unlike every other codemod, this one carries no list of what it changes, and
|
|
32
|
+
* should not need editing again. Its input is `client.csv` and `login.csv` from
|
|
33
|
+
* the country config template of the version being upgraded to, fetched from
|
|
34
|
+
* GitHub; whatever rows those files have gained, this adds. A pull request that
|
|
35
|
+
* introduces a translation key therefore only has to add it to the template —
|
|
36
|
+
* `packages/countryconfig-template/src/translations/` — which the
|
|
37
|
+
* check-missing-translation workflow makes it do anyway.
|
|
38
|
+
*
|
|
39
|
+
* `countryconfig.csv` is deliberately left alone. It holds the copy the country
|
|
40
|
+
* config declares itself, which is nobody's business but the country's.
|
|
41
|
+
*
|
|
42
|
+
* Rows are rebuilt against the local file's own columns rather than copied
|
|
43
|
+
* across, so a country config with languages the template does not have keeps
|
|
44
|
+
* its shape: the template's value is used for a language they share, and an
|
|
45
|
+
* empty cell for one it has nothing for.
|
|
46
|
+
*/
|
|
47
|
+
const path_1 = __importDefault(require("path"));
|
|
48
|
+
const csv_1 = require("../../csv");
|
|
49
|
+
const REPOSITORY = 'opencrvs/opencrvs-core';
|
|
50
|
+
const TEMPLATE_TRANSLATIONS = 'packages/countryconfig-template/src/translations';
|
|
51
|
+
const APPLICATIONS = ['client', 'login'];
|
|
52
|
+
/** The version this folder upgrades a country config to. */
|
|
53
|
+
const TARGET_VERSION = '2.1';
|
|
54
|
+
const skipped = [];
|
|
55
|
+
function warnSkipped(message) {
|
|
56
|
+
skipped.push(message);
|
|
57
|
+
console.warn(` ⚠️ ${message}`);
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* The refs matching a prefix, newest patch first.
|
|
61
|
+
*
|
|
62
|
+
* Every patch gets its own release branch — `release/2.1.0`, `release/2.1.1` —
|
|
63
|
+
* and a translation key added in a patch only exists on that patch's branch, so
|
|
64
|
+
* the newest one is the one worth reading.
|
|
65
|
+
*/
|
|
66
|
+
function matchingRefs(namespace, prefix) {
|
|
67
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
68
|
+
const url = `https://api.github.com/repos/${REPOSITORY}/git/matching-refs/${namespace}/${prefix}`;
|
|
69
|
+
const response = yield fetch(url, {
|
|
70
|
+
headers: { accept: 'application/vnd.github+json' }
|
|
71
|
+
});
|
|
72
|
+
if (!response.ok) {
|
|
73
|
+
return [];
|
|
74
|
+
}
|
|
75
|
+
const refs = (yield response.json());
|
|
76
|
+
const patchOf = (ref) => Number(ref.split('.').pop()) || 0;
|
|
77
|
+
return refs
|
|
78
|
+
.map(({ ref }) => ref.replace(/^refs\/(heads|tags)\//, ''))
|
|
79
|
+
.sort((a, b) => patchOf(b) - patchOf(a));
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Where to read the template from, most specific first: the newest release
|
|
84
|
+
* branch of the target version, then its newest tag, then `develop` for anyone
|
|
85
|
+
* running the codemod before the version has been cut.
|
|
86
|
+
*/
|
|
87
|
+
function candidateRefs() {
|
|
88
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
89
|
+
return [
|
|
90
|
+
...(yield matchingRefs('heads', `release/${TARGET_VERSION}.`)),
|
|
91
|
+
...(yield matchingRefs('tags', `v${TARGET_VERSION}.`)),
|
|
92
|
+
'develop'
|
|
93
|
+
];
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
function fetchTemplate(refs, application) {
|
|
97
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
98
|
+
for (const ref of refs) {
|
|
99
|
+
const url = `https://raw.githubusercontent.com/${REPOSITORY}/${ref}/${TEMPLATE_TRANSLATIONS}/${application}.csv`;
|
|
100
|
+
const response = yield fetch(url);
|
|
101
|
+
if (response.ok) {
|
|
102
|
+
return { ref, contents: yield response.text() };
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
warnSkipped(`No ${application}.csv found in the ${TARGET_VERSION} country config template on GitHub; ${application}.csv not updated`);
|
|
106
|
+
return undefined;
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* The rows of the template that the local file has no id for, expressed in the
|
|
111
|
+
* local file's columns.
|
|
112
|
+
*/
|
|
113
|
+
function rowsToAdd(local, template) {
|
|
114
|
+
const localColumns = (0, csv_1.parseCsvLine)(local.header);
|
|
115
|
+
const templateColumns = (0, csv_1.parseCsvLine)(template.header);
|
|
116
|
+
return template.body
|
|
117
|
+
.filter((line) => line !== '')
|
|
118
|
+
.map((line) => {
|
|
119
|
+
const values = (0, csv_1.parseCsvLine)(line);
|
|
120
|
+
return (0, csv_1.toCsvLine)(localColumns.map((column) => {
|
|
121
|
+
var _a;
|
|
122
|
+
const index = templateColumns.indexOf(column);
|
|
123
|
+
return index === -1 ? '' : ((_a = values[index]) !== null && _a !== void 0 ? _a : '');
|
|
124
|
+
}));
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
function updateApplication(cwd, refs, application) {
|
|
128
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
129
|
+
const relativePath = `src/translations/${application}.csv`;
|
|
130
|
+
const local = (0, csv_1.readCsvFile)(path_1.default.join(cwd, relativePath));
|
|
131
|
+
if (!local) {
|
|
132
|
+
warnSkipped(`${relativePath} not found; translations not added`);
|
|
133
|
+
return;
|
|
134
|
+
}
|
|
135
|
+
const fetched = yield fetchTemplate(refs, application);
|
|
136
|
+
if (!fetched) {
|
|
137
|
+
return;
|
|
138
|
+
}
|
|
139
|
+
const template = readTemplate(fetched.contents);
|
|
140
|
+
const added = (0, csv_1.addRows)(local, rowsToAdd(local, template));
|
|
141
|
+
if (added.length === 0) {
|
|
142
|
+
return;
|
|
143
|
+
}
|
|
144
|
+
(0, csv_1.writeCsvFile)(path_1.default.join(cwd, relativePath), local);
|
|
145
|
+
for (const id of added) {
|
|
146
|
+
console.log(` ✓ ${relativePath}: ${id}`);
|
|
147
|
+
}
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
function readTemplate(contents) {
|
|
151
|
+
const lines = contents.replace(/\r?\n$/, '').split(/\r?\n/);
|
|
152
|
+
return {
|
|
153
|
+
header: lines[0],
|
|
154
|
+
body: lines.slice(1),
|
|
155
|
+
newline: '\n',
|
|
156
|
+
trailingNewline: true
|
|
157
|
+
};
|
|
158
|
+
}
|
|
159
|
+
function main() {
|
|
160
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
161
|
+
const cwd = process.cwd();
|
|
162
|
+
console.log('Adding the translation keys core gained this version...\n');
|
|
163
|
+
try {
|
|
164
|
+
const refs = yield candidateRefs();
|
|
165
|
+
for (const application of APPLICATIONS) {
|
|
166
|
+
yield updateApplication(cwd, refs, application);
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
catch (error) {
|
|
170
|
+
// An upgrade run on a machine that cannot reach GitHub should report what
|
|
171
|
+
// it could not do and let the rest of the upgrade finish, rather than
|
|
172
|
+
// failing the whole thing on a network error.
|
|
173
|
+
warnSkipped(`Could not read the country config template from GitHub (${error.message}); translations not added`);
|
|
174
|
+
}
|
|
175
|
+
if (skipped.length > 0) {
|
|
176
|
+
console.warn(`\n⚠️ ${skipped.length} step(s) were skipped. Add the missing translations by hand before upgrading:`);
|
|
177
|
+
for (const message of skipped) {
|
|
178
|
+
console.warn(` - ${message}`);
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
});
|
|
182
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/migrations/v2.1/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/migrations/v2.1/index.ts"],"names":[],"mappings":"AAcA;;;GAGG;AACH,wBAAsB,UAAU,CAAC,WAAW,EAAE,OAAO,iBAIpD"}
|