@opencrvs/toolkit 2.1.0-rc.12673aa → 2.1.0-rc.14fb6a5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build.sh +14 -4
- package/create-countryconfig/index.js +59 -30
- package/dist/application-config/index.js +26 -13
- package/dist/authentication/index.d.ts +8 -9
- package/dist/authentication/index.js +23 -8
- package/dist/cli.js +2268 -1385
- package/dist/commons/api/router.d.ts +252 -290
- 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 +18 -3
- package/dist/commons/events/ActionConfig.d.ts +5 -14
- package/dist/commons/events/ActionDocument.d.ts +30 -4
- package/dist/commons/events/AdvancedSearchConfig.d.ts +24 -12
- package/dist/commons/events/AuditLog.d.ts +1 -0
- package/dist/commons/events/Draft.d.ts +1 -21
- package/dist/commons/events/EventDocument.d.ts +4 -4
- package/dist/commons/events/FieldConfig.d.ts +20 -10
- package/dist/commons/events/FieldTypeMapping.d.ts +10 -10
- package/dist/commons/events/FieldValue.d.ts +1 -0
- package/dist/commons/events/FormConfig.d.ts +6 -0
- package/dist/commons/events/PageConfig.d.ts +4 -0
- package/dist/commons/events/scopes.d.ts +21 -1
- package/dist/commons/events/test.utils.d.ts +53 -21
- package/dist/commons/events/utils.d.ts +26 -2
- package/dist/conditionals/index.js +21 -7
- package/dist/environment/index.d.ts.map +1 -1
- package/dist/environment/index.js +2 -1
- 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 +586 -569
- package/dist/environment/swarm-to-k8s.js +3 -4
- package/dist/events/index.js +282 -138
- package/dist/migrations/v2.1/add-recovery-link-notifications.js +4 -4
- package/dist/migrations/v2.1/add-translations.d.ts.map +1 -1
- package/dist/migrations/v2.1/add-translations.js +4 -68
- package/dist/migrations/v2.1/enable-telemetry.d.ts.map +1 -1
- package/dist/migrations/v2.1/enable-telemetry.js +30 -13
- package/dist/migrations/v2.1/index.d.ts.map +1 -1
- package/dist/migrations/v2.1/index.js +927 -33
- package/dist/migrations/v2.1/migrate-infrastructure-to-assets.d.ts +14 -0
- package/dist/migrations/v2.1/migrate-infrastructure-to-assets.d.ts.map +1 -0
- package/dist/migrations/v2.1/migrate-infrastructure-to-assets.js +348 -0
- package/dist/migrations/v2.1/remove-metabase-package-installs.d.ts +2 -0
- package/dist/migrations/v2.1/remove-metabase-package-installs.d.ts.map +1 -0
- package/dist/migrations/v2.1/remove-metabase-package-installs.js +161 -0
- package/dist/migrations/{v2.0/migrate-scopes.d.ts → v2.1/remove-sentry.d.ts} +1 -1
- package/dist/migrations/v2.1/remove-sentry.d.ts.map +1 -0
- package/dist/migrations/v2.1/remove-sentry.js +354 -0
- package/dist/migrations/{v2.0/rename-api-paths.d.ts → v2.1/rename-trigger-paths.d.ts} +1 -1
- package/dist/migrations/v2.1/rename-trigger-paths.d.ts.map +1 -0
- package/dist/migrations/{v2.0/rename-api-paths.js → v2.1/rename-trigger-paths.js} +69 -40
- package/dist/migrations/v2.1/template-files.d.ts +8 -0
- package/dist/migrations/v2.1/template-files.d.ts.map +1 -0
- package/dist/migrations/v2.1/template-files.js +49 -0
- package/dist/migrations/v2.1/upgrade-tilt.d.ts +8 -0
- package/dist/migrations/v2.1/upgrade-tilt.d.ts.map +1 -0
- package/dist/migrations/v2.1/upgrade-tilt.js +139 -0
- package/dist/notification/index.js +105 -61
- package/dist/scopes/index.d.ts +288 -5
- package/dist/scopes/index.js +22 -7
- package/dist/telemetry/index.js +4 -0
- package/dist/templates/charts-values/dependencies/values.yaml +6 -0
- package/dist/templates/charts-values/opencrvs-services/values.yaml +6 -0
- package/dist/templates/charts-values/opentelemetry/values.yaml +7 -0
- package/dist/templates/countryconfig-template/.tiltignore +1 -0
- package/dist/templates/countryconfig-template/Dockerfile.assets +7 -0
- package/dist/templates/countryconfig-template/Tiltfile +112 -0
- package/dist/templates/countryconfig-template/assets/README.md +1 -0
- package/dist/templates/countryconfig-template/assets/clear-all-data-dev.sh +61 -0
- package/dist/templates/countryconfig-template/assets/deployment/deploy.sh +455 -0
- package/dist/templates/countryconfig-template/assets/deployment/reindex.sh +168 -0
- package/dist/templates/countryconfig-template/assets/deployment/validate-required-variables-in-compose-files.ts +67 -0
- package/dist/templates/countryconfig-template/assets/elasticsearch/reindex.sh +168 -0
- package/dist/templates/countryconfig-template/assets/metabase/README.md +34 -0
- package/dist/templates/countryconfig-template/assets/metabase/environment-configuration.sql +36 -0
- package/dist/templates/countryconfig-template/assets/metabase/initialize-database.sh +46 -0
- package/dist/templates/countryconfig-template/assets/metabase/metabase.init.db.sql +27737 -0
- package/dist/templates/countryconfig-template/assets/metabase/open-shell.sh +21 -0
- package/dist/templates/countryconfig-template/assets/metabase/package.json +13 -0
- package/dist/templates/countryconfig-template/assets/metabase/run-dev.sh +108 -0
- package/dist/templates/countryconfig-template/assets/metabase/run.sh +120 -0
- package/dist/templates/countryconfig-template/assets/metabase/update-database.sh +40 -0
- package/dist/templates/countryconfig-template/assets/postgres/setup-analytics.sh +135 -0
- package/dist/templates/countryconfig-template/assets/postgres/setup-reference-data.sh +108 -0
- package/dist/templates/countryconfig-template/tilt/clear-all-data.ps1 +50 -0
- package/dist/templates/countryconfig-template/tilt/clear-all-data.sh +35 -0
- package/dist/templates/countryconfig-template/tilt/common.tilt +145 -0
- package/dist/templates/countryconfig-template/tilt/examples/dependencies/values.yaml +15 -0
- package/dist/templates/countryconfig-template/tilt/examples/opencrvs-services/values.yaml +56 -0
- package/dist/templates/countryconfig-template/tilt/examples/traefik/values-minikube.yaml +21 -0
- package/dist/templates/countryconfig-template/tilt/examples/traefik/values.yaml +38 -0
- package/dist/templates/countryconfig-template/tilt/helm/dependencies/values.yaml +17 -0
- package/dist/templates/countryconfig-template/tilt/helm/opencrvs-services/values.yaml +16 -0
- package/dist/templates/countryconfig-template/tilt/lib.tilt +95 -0
- package/dist/templates/countryconfig-template/tilt/opencrvs.tilt +136 -0
- 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.map +1 -1
- package/dist/verify/endpoints.js +179 -14
- package/opencrvs-toolkit-2.1.0-rc.14fb6a5.tgz +0 -0
- package/package.json +2 -1
- package/tsconfig.build.tsbuildinfo +1 -1
- package/dist/migrations/v2.0/add-birth-certificate-issuance-flag.d.ts +0 -3
- package/dist/migrations/v2.0/add-birth-certificate-issuance-flag.d.ts.map +0 -1
- package/dist/migrations/v2.0/add-birth-certificate-issuance-flag.js +0 -429
- package/dist/migrations/v2.0/add-resend-invite-notification.d.ts +0 -3
- package/dist/migrations/v2.0/add-resend-invite-notification.d.ts.map +0 -1
- package/dist/migrations/v2.0/add-resend-invite-notification.js +0 -373
- package/dist/migrations/v2.0/checkout-upstream-files.d.ts +0 -22
- package/dist/migrations/v2.0/checkout-upstream-files.d.ts.map +0 -1
- package/dist/migrations/v2.0/checkout-upstream-files.js +0 -146
- package/dist/migrations/v2.0/convert-config-files-to-ts.d.ts +0 -2
- package/dist/migrations/v2.0/convert-config-files-to-ts.d.ts.map +0 -1
- package/dist/migrations/v2.0/convert-config-files-to-ts.js +0 -838
- package/dist/migrations/v2.0/convert-paragraph-to-heading.d.ts +0 -3
- package/dist/migrations/v2.0/convert-paragraph-to-heading.d.ts.map +0 -1
- package/dist/migrations/v2.0/convert-paragraph-to-heading.js +0 -158
- package/dist/migrations/v2.0/create-events-index.d.ts +0 -3
- package/dist/migrations/v2.0/create-events-index.d.ts.map +0 -1
- package/dist/migrations/v2.0/create-events-index.js +0 -325
- package/dist/migrations/v2.0/delete-infrastructure-directory.d.ts +0 -11
- package/dist/migrations/v2.0/delete-infrastructure-directory.d.ts.map +0 -1
- package/dist/migrations/v2.0/delete-infrastructure-directory.js +0 -123
- package/dist/migrations/v2.0/fix-accept-requested-registration-function-type.d.ts +0 -3
- package/dist/migrations/v2.0/fix-accept-requested-registration-function-type.d.ts.map +0 -1
- package/dist/migrations/v2.0/fix-accept-requested-registration-function-type.js +0 -110
- package/dist/migrations/v2.0/index.d.ts +0 -13
- package/dist/migrations/v2.0/index.d.ts.map +0 -1
- package/dist/migrations/v2.0/index.js +0 -103
- package/dist/migrations/v2.0/make-built-in-validate-actions-custom.d.ts +0 -3
- package/dist/migrations/v2.0/make-built-in-validate-actions-custom.d.ts.map +0 -1
- package/dist/migrations/v2.0/make-built-in-validate-actions-custom.js +0 -432
- package/dist/migrations/v2.0/merge-infrastructure-directory.d.ts +0 -13
- package/dist/migrations/v2.0/merge-infrastructure-directory.d.ts.map +0 -1
- package/dist/migrations/v2.0/merge-infrastructure-directory.js +0 -222
- package/dist/migrations/v2.0/migrate-application-config-url.d.ts +0 -3
- package/dist/migrations/v2.0/migrate-application-config-url.d.ts.map +0 -1
- package/dist/migrations/v2.0/migrate-application-config-url.js +0 -343
- package/dist/migrations/v2.0/migrate-scopes.d.ts.map +0 -1
- package/dist/migrations/v2.0/migrate-scopes.js +0 -305
- package/dist/migrations/v2.0/migrate-validated-workqueue-status-to-flag.d.ts +0 -3
- package/dist/migrations/v2.0/migrate-validated-workqueue-status-to-flag.d.ts.map +0 -1
- package/dist/migrations/v2.0/migrate-validated-workqueue-status-to-flag.js +0 -267
- package/dist/migrations/v2.0/migrate-workqueue-configs.d.ts +0 -3
- package/dist/migrations/v2.0/migrate-workqueue-configs.d.ts.map +0 -1
- package/dist/migrations/v2.0/migrate-workqueue-configs.js +0 -317
- package/dist/migrations/v2.0/remove-delete-actions.d.ts +0 -3
- package/dist/migrations/v2.0/remove-delete-actions.d.ts.map +0 -1
- package/dist/migrations/v2.0/remove-delete-actions.js +0 -156
- package/dist/migrations/v2.0/remove-demo-scope.d.ts +0 -3
- package/dist/migrations/v2.0/remove-demo-scope.d.ts.map +0 -1
- package/dist/migrations/v2.0/remove-demo-scope.js +0 -74
- package/dist/migrations/v2.0/remove-deprecated-imports.d.ts +0 -3
- package/dist/migrations/v2.0/remove-deprecated-imports.d.ts.map +0 -1
- package/dist/migrations/v2.0/remove-deprecated-imports.js +0 -96
- package/dist/migrations/v2.0/remove-fhir-url-helpers.d.ts +0 -3
- package/dist/migrations/v2.0/remove-fhir-url-helpers.d.ts.map +0 -1
- package/dist/migrations/v2.0/remove-fhir-url-helpers.js +0 -163
- package/dist/migrations/v2.0/remove-hearth-migrations.d.ts +0 -3
- package/dist/migrations/v2.0/remove-hearth-migrations.d.ts.map +0 -1
- package/dist/migrations/v2.0/remove-hearth-migrations.js +0 -87
- package/dist/migrations/v2.0/remove-old-statistics-service.d.ts +0 -3
- package/dist/migrations/v2.0/remove-old-statistics-service.d.ts.map +0 -1
- package/dist/migrations/v2.0/remove-old-statistics-service.js +0 -356
- package/dist/migrations/v2.0/remove-pending-certification-flag.d.ts +0 -3
- package/dist/migrations/v2.0/remove-pending-certification-flag.d.ts.map +0 -1
- package/dist/migrations/v2.0/remove-pending-certification-flag.js +0 -109
- package/dist/migrations/v2.0/remove-review-from-register-action.d.ts +0 -3
- package/dist/migrations/v2.0/remove-review-from-register-action.d.ts.map +0 -1
- package/dist/migrations/v2.0/remove-review-from-register-action.js +0 -163
- package/dist/migrations/v2.0/remove-unused-environment-variables.d.ts +0 -3
- package/dist/migrations/v2.0/remove-unused-environment-variables.d.ts.map +0 -1
- package/dist/migrations/v2.0/remove-unused-environment-variables.js +0 -186
- package/dist/migrations/v2.0/rename-api-paths.d.ts.map +0 -1
- package/dist/migrations/v2.0/rename-location-parent-id.d.ts +0 -3
- package/dist/migrations/v2.0/rename-location-parent-id.d.ts.map +0 -1
- package/dist/migrations/v2.0/rename-location-parent-id.js +0 -180
- package/dist/migrations/v2.0/simplify-analytics-precalculations.d.ts +0 -3
- package/dist/migrations/v2.0/simplify-analytics-precalculations.d.ts.map +0 -1
- package/dist/migrations/v2.0/simplify-analytics-precalculations.js +0 -195
- package/dist/migrations/v2.0/update-package-json.d.ts +0 -3
- package/dist/migrations/v2.0/update-package-json.d.ts.map +0 -1
- package/dist/migrations/v2.0/update-package-json.js +0 -105
- package/dist/translations/check.d.ts +0 -21
- package/dist/translations/check.d.ts.map +0 -1
- package/dist/translations/check.js +0 -132
- package/opencrvs-toolkit-2.1.0-rc.12673aa.tgz +0 -0
package/dist/verify/endpoints.js
CHANGED
|
@@ -1,4 +1,37 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
2
35
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
36
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
37
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -22,6 +55,9 @@ exports.runVerifyEndpoints = runVerifyEndpoints;
|
|
|
22
55
|
*/
|
|
23
56
|
/* eslint-disable no-console */
|
|
24
57
|
const colors_1 = require("kleur/colors");
|
|
58
|
+
const z = __importStar(require("zod/v4"));
|
|
59
|
+
const csv_1 = require("../csv");
|
|
60
|
+
const template_1 = require("../translations/template");
|
|
25
61
|
const REQUEST_TIMEOUT_MS = 15000;
|
|
26
62
|
/**
|
|
27
63
|
* The country config service listens on port 3040 locally. This command is
|
|
@@ -85,10 +121,10 @@ const SECURED_TRIGGER_USER_EVENTS = [
|
|
|
85
121
|
const SECURED_ENDPOINTS = [
|
|
86
122
|
...SECURED_TRIGGER_USER_EVENTS.map((event) => ({
|
|
87
123
|
method: 'POST',
|
|
88
|
-
path: `/
|
|
124
|
+
path: `/trigger/user/${event}`
|
|
89
125
|
})),
|
|
90
126
|
{ method: 'POST', path: '/trigger/telemetry' },
|
|
91
|
-
{ method: 'GET', path: '/
|
|
127
|
+
{ method: 'GET', path: '/trigger/system/ready' },
|
|
92
128
|
{
|
|
93
129
|
method: 'GET',
|
|
94
130
|
path: `/certificates/${PROBE_SEGMENT}`,
|
|
@@ -126,12 +162,10 @@ const requiresAuthOrAbsent = (status) => status === 401 || status === 403 || sta
|
|
|
126
162
|
*/
|
|
127
163
|
function requestStatus(url, method) {
|
|
128
164
|
return __awaiter(this, void 0, void 0, function* () {
|
|
129
|
-
const controller = new AbortController();
|
|
130
|
-
const timer = setTimeout(() => controller.abort(), REQUEST_TIMEOUT_MS);
|
|
131
165
|
try {
|
|
132
166
|
const response = yield fetch(url, {
|
|
133
167
|
method,
|
|
134
|
-
signal:
|
|
168
|
+
signal: AbortSignal.timeout(REQUEST_TIMEOUT_MS),
|
|
135
169
|
// Sent without an Authorization header on purpose. A secured route
|
|
136
170
|
// rejects with 401/403 before ever reading the body.
|
|
137
171
|
headers: method === 'POST' ? { 'Content-Type': 'application/json' } : undefined,
|
|
@@ -142,9 +176,6 @@ function requestStatus(url, method) {
|
|
|
142
176
|
catch (_a) {
|
|
143
177
|
return 'error';
|
|
144
178
|
}
|
|
145
|
-
finally {
|
|
146
|
-
clearTimeout(timer);
|
|
147
|
-
}
|
|
148
179
|
});
|
|
149
180
|
}
|
|
150
181
|
function toEventTriggerConfig(value) {
|
|
@@ -175,11 +206,9 @@ function toEventTriggerConfig(value) {
|
|
|
175
206
|
*/
|
|
176
207
|
function fetchEventConfigs(baseUrl) {
|
|
177
208
|
return __awaiter(this, void 0, void 0, function* () {
|
|
178
|
-
const controller = new AbortController();
|
|
179
|
-
const timer = setTimeout(() => controller.abort(), REQUEST_TIMEOUT_MS);
|
|
180
209
|
try {
|
|
181
210
|
const response = yield fetch(`${baseUrl}/config/events`, {
|
|
182
|
-
signal:
|
|
211
|
+
signal: AbortSignal.timeout(REQUEST_TIMEOUT_MS)
|
|
183
212
|
});
|
|
184
213
|
if (!response.ok) {
|
|
185
214
|
return null;
|
|
@@ -195,9 +224,6 @@ function fetchEventConfigs(baseUrl) {
|
|
|
195
224
|
catch (_a) {
|
|
196
225
|
return null;
|
|
197
226
|
}
|
|
198
|
-
finally {
|
|
199
|
-
clearTimeout(timer);
|
|
200
|
-
}
|
|
201
227
|
});
|
|
202
228
|
}
|
|
203
229
|
/**
|
|
@@ -233,6 +259,142 @@ function securedDetail(status) {
|
|
|
233
259
|
}
|
|
234
260
|
return `${describeStatus(status)} — INSECURE: ensure this endpoint requires authentication!`;
|
|
235
261
|
}
|
|
262
|
+
/**
|
|
263
|
+
* The version of the country config template to check against. Bump it with
|
|
264
|
+
* the toolkit's own major.minor: a toolkit release checks that a country config
|
|
265
|
+
* serves the copy core requires *at that version*, which is the same template
|
|
266
|
+
* the `add-translations` codemod adds rows from.
|
|
267
|
+
*/
|
|
268
|
+
const TEMPLATE_VERSION = '2.1';
|
|
269
|
+
/** The translation bundles a country config serves, one per CSV file core owns. */
|
|
270
|
+
const TRANSLATED_APPLICATIONS = ['client', 'login'];
|
|
271
|
+
function readTemplateTranslations(contents) {
|
|
272
|
+
const lines = contents.replace(/\r?\n$/, '').split(/\r?\n/);
|
|
273
|
+
return {
|
|
274
|
+
ids: lines
|
|
275
|
+
.slice(1)
|
|
276
|
+
.filter((line) => line !== '')
|
|
277
|
+
.map(csv_1.idOf),
|
|
278
|
+
languages: (0, csv_1.parseCsvLine)(lines[0]).filter((column) => column !== 'id' && column !== 'description')
|
|
279
|
+
};
|
|
280
|
+
}
|
|
281
|
+
/**
|
|
282
|
+
* What `GET /content/{application}` answers with: one entry per language, each
|
|
283
|
+
* carrying every message id that language has copy for.
|
|
284
|
+
*
|
|
285
|
+
* Parsed rather than cast, because the whole check turns on which ids are
|
|
286
|
+
* present — a bundle that is not this shape cannot be read as "the id is
|
|
287
|
+
* missing", and reporting it as such would be a false failure.
|
|
288
|
+
*/
|
|
289
|
+
const ServedTranslations = z.object({
|
|
290
|
+
languages: z.array(z.object({
|
|
291
|
+
lang: z.string(),
|
|
292
|
+
messages: z.record(z.string(), z.string())
|
|
293
|
+
}))
|
|
294
|
+
});
|
|
295
|
+
/**
|
|
296
|
+
* The bundle `GET /content/{application}` serves, or `null` when it cannot be
|
|
297
|
+
* read. An unreachable endpoint is already a failure in the public-endpoints
|
|
298
|
+
* section above, so it is not counted twice here.
|
|
299
|
+
*/
|
|
300
|
+
function fetchServedTranslations(baseUrl, application) {
|
|
301
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
302
|
+
try {
|
|
303
|
+
const response = yield fetch(`${baseUrl}/content/${application}`, {
|
|
304
|
+
signal: AbortSignal.timeout(REQUEST_TIMEOUT_MS)
|
|
305
|
+
});
|
|
306
|
+
if (!response.ok) {
|
|
307
|
+
return null;
|
|
308
|
+
}
|
|
309
|
+
const parsed = ServedTranslations.safeParse(yield response.json());
|
|
310
|
+
return parsed.success ? parsed.data.languages : null;
|
|
311
|
+
}
|
|
312
|
+
catch (_a) {
|
|
313
|
+
return null;
|
|
314
|
+
}
|
|
315
|
+
});
|
|
316
|
+
}
|
|
317
|
+
/** How many missing ids to print before summarising the rest. */
|
|
318
|
+
const MISSING_IDS_SHOWN = 10;
|
|
319
|
+
/**
|
|
320
|
+
* Checks that every message id the country config template carries is served
|
|
321
|
+
* by the running country config.
|
|
322
|
+
*
|
|
323
|
+
* This is the API-side half of the translation checks: which files the copy is
|
|
324
|
+
* kept in, and what shape they are, is the country config's own business — this
|
|
325
|
+
* only asks whether the copy core needs comes back out of `/content/*`. A
|
|
326
|
+
* country config checks its *own* messages against its *own* files itself; see
|
|
327
|
+
* `check-translations.ts` in the country config template.
|
|
328
|
+
*
|
|
329
|
+
* An id is looked for across every language served rather than in one of them:
|
|
330
|
+
* a row in a CSV yields an entry under each of that file's language columns, so
|
|
331
|
+
* absent everywhere means absent from the files. Whether the copy is written is
|
|
332
|
+
* a separate matter, and an empty cell is legitimate — the template itself ships
|
|
333
|
+
* a few.
|
|
334
|
+
*
|
|
335
|
+
* Returns the number of failures.
|
|
336
|
+
*/
|
|
337
|
+
function verifyTranslations(baseUrl) {
|
|
338
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
339
|
+
let refs;
|
|
340
|
+
try {
|
|
341
|
+
refs = yield (0, template_1.candidateRefs)(TEMPLATE_VERSION);
|
|
342
|
+
}
|
|
343
|
+
catch (error) {
|
|
344
|
+
console.log(' ' +
|
|
345
|
+
(0, colors_1.yellow)(`Could not list the ${TEMPLATE_VERSION} refs on GitHub (${error.message}); translations not checked.`));
|
|
346
|
+
return 0;
|
|
347
|
+
}
|
|
348
|
+
let failures = 0;
|
|
349
|
+
for (const application of TRANSLATED_APPLICATIONS) {
|
|
350
|
+
const endpoint = `GET /content/${application}`;
|
|
351
|
+
let fetched;
|
|
352
|
+
try {
|
|
353
|
+
fetched = yield (0, template_1.fetchTemplate)(refs, application);
|
|
354
|
+
}
|
|
355
|
+
catch (error) {
|
|
356
|
+
console.log(' ' +
|
|
357
|
+
(0, colors_1.yellow)(`Could not read ${application}.csv from the country config template on GitHub (${error.message}); ${endpoint} not checked.`));
|
|
358
|
+
continue;
|
|
359
|
+
}
|
|
360
|
+
if (!fetched) {
|
|
361
|
+
console.log(' ' +
|
|
362
|
+
(0, colors_1.yellow)(`No ${application}.csv in the ${TEMPLATE_VERSION} country config template on GitHub; ${endpoint} not checked.`));
|
|
363
|
+
continue;
|
|
364
|
+
}
|
|
365
|
+
const template = readTemplateTranslations(fetched.contents);
|
|
366
|
+
const served = yield fetchServedTranslations(baseUrl, application);
|
|
367
|
+
if (!served) {
|
|
368
|
+
console.log(' ' + (0, colors_1.yellow)(`Could not read ${endpoint}; translations not checked.`));
|
|
369
|
+
continue;
|
|
370
|
+
}
|
|
371
|
+
const servedIds = new Set(served.flatMap(({ messages }) => Object.keys(messages)));
|
|
372
|
+
const missing = template.ids.filter((id) => !servedIds.has(id));
|
|
373
|
+
const servedLanguages = new Set(served.map(({ lang }) => lang));
|
|
374
|
+
const absentLanguages = template.languages.filter((lang) => !servedLanguages.has(lang));
|
|
375
|
+
if (missing.length === 0) {
|
|
376
|
+
console.log(line(true, endpoint, `all ${template.ids.length} id(s) from the ${fetched.ref} template served`));
|
|
377
|
+
}
|
|
378
|
+
else {
|
|
379
|
+
failures++;
|
|
380
|
+
console.log(line(false, endpoint, `${missing.length} of ${template.ids.length} id(s) from the ${fetched.ref} template not served`));
|
|
381
|
+
for (const id of missing.slice(0, MISSING_IDS_SHOWN)) {
|
|
382
|
+
console.log(` ${(0, colors_1.dim)(id)}`);
|
|
383
|
+
}
|
|
384
|
+
if (missing.length > MISSING_IDS_SHOWN) {
|
|
385
|
+
console.log(` ${(0, colors_1.dim)(`… and ${missing.length - MISSING_IDS_SHOWN} more`)}`);
|
|
386
|
+
}
|
|
387
|
+
}
|
|
388
|
+
// A country dropping a language the template ships is its own decision, so
|
|
389
|
+
// this is worth saying but is not a failure.
|
|
390
|
+
if (absentLanguages.length > 0) {
|
|
391
|
+
console.log(' ' +
|
|
392
|
+
(0, colors_1.yellow)(`${application}: the template carries ${absentLanguages.join(', ')}, which this country config does not serve.`));
|
|
393
|
+
}
|
|
394
|
+
}
|
|
395
|
+
return failures;
|
|
396
|
+
});
|
|
397
|
+
}
|
|
236
398
|
function runVerifyEndpoints() {
|
|
237
399
|
return __awaiter(this, arguments, void 0, function* (target = DEFAULT_TARGET_URL) {
|
|
238
400
|
const baseUrl = resolveBaseUrl(target);
|
|
@@ -335,6 +497,9 @@ function runVerifyEndpoints() {
|
|
|
335
497
|
}
|
|
336
498
|
}
|
|
337
499
|
console.log();
|
|
500
|
+
console.log((0, colors_1.bold)('Translations served (must cover the copy core requires):'));
|
|
501
|
+
failures += yield verifyTranslations(baseUrl);
|
|
502
|
+
console.log();
|
|
338
503
|
if (failures > 0) {
|
|
339
504
|
console.log((0, colors_1.red)((0, colors_1.bold)(`✗ ${failures} check(s) failed.`)) +
|
|
340
505
|
(0, colors_1.yellow)(' See the lines marked ✗ above.'));
|
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@opencrvs/toolkit",
|
|
3
|
-
"version": "2.1.0-rc.
|
|
3
|
+
"version": "2.1.0-rc.14fb6a5",
|
|
4
4
|
"description": "OpenCRVS toolkit for building country configurations",
|
|
5
5
|
"license": "MPL-2.0",
|
|
6
6
|
"bin": {
|
|
@@ -45,6 +45,7 @@
|
|
|
45
45
|
"libsodium-wrappers": "^0.7.13",
|
|
46
46
|
"lodash": "^4.17.10",
|
|
47
47
|
"object-hash": "^3.0.0",
|
|
48
|
+
"pino": "^7.0.0",
|
|
48
49
|
"prompts": "^2.4.2",
|
|
49
50
|
"qs": "6.15.2",
|
|
50
51
|
"ssh2": "^1.17.0",
|