@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.
Files changed (90) hide show
  1. package/README.md +1 -0
  2. package/build.sh +2 -1
  3. package/create-countryconfig/index.js +114 -66
  4. package/create-countryconfig/node_modules/.bin/degit +21 -0
  5. package/create-countryconfig/package.json +4 -1
  6. package/dist/application-config/index.js +341 -274
  7. package/dist/cli.js +1000 -104
  8. package/dist/commons/api/router.d.ts +691 -76
  9. package/dist/commons/conditionals/conditionals.d.ts +6 -6
  10. package/dist/commons/conditionals/validate.d.ts +16 -5
  11. package/dist/commons/events/ActionDocument.d.ts +5 -11
  12. package/dist/commons/events/ActionInput.d.ts +4 -4
  13. package/dist/commons/events/ActionStatus.d.ts +14 -0
  14. package/dist/commons/events/AdvancedSearchConfig.d.ts +24 -0
  15. package/dist/commons/events/AuditLog.d.ts +147 -0
  16. package/dist/commons/events/EventConfig.d.ts +3 -0
  17. package/dist/commons/events/EventDocument.d.ts +470 -2
  18. package/dist/commons/events/EventIndex.d.ts +3 -26
  19. package/dist/commons/events/EventMetadata.d.ts +1 -11
  20. package/dist/commons/events/EventStatus.d.ts +19 -0
  21. package/dist/commons/events/FieldConfig.d.ts +88 -53
  22. package/dist/commons/events/FieldTypeMapping.d.ts +27 -27
  23. package/dist/commons/events/FieldValue.d.ts +2 -2
  24. package/dist/commons/events/Flag.d.ts +42 -0
  25. package/dist/commons/events/PlainDate.d.ts +8 -0
  26. package/dist/commons/events/SummaryConfig.d.ts +249 -0
  27. package/dist/commons/events/WorkqueueConfig.d.ts +17 -14
  28. package/dist/commons/events/event.d.ts +12 -0
  29. package/dist/commons/events/index.d.ts +1 -0
  30. package/dist/commons/events/locationPayloads.d.ts +95 -0
  31. package/dist/commons/events/locations.d.ts +165 -26
  32. package/dist/commons/events/mocks.test.utils.d.ts +30 -0
  33. package/dist/commons/events/test.utils.d.ts +8 -4
  34. package/dist/commons/events/utils.d.ts +2 -2
  35. package/dist/commons/notification/UserNotifications.d.ts +28 -13
  36. package/dist/commons/notification/dispatch.d.ts +15 -0
  37. package/dist/commons/notification/index.d.ts +1 -0
  38. package/dist/conditionals/index.js +328 -58
  39. package/dist/csv.d.ts +25 -0
  40. package/dist/csv.d.ts.map +1 -0
  41. package/dist/csv.js +115 -0
  42. package/dist/environment/index.d.ts +1 -0
  43. package/dist/environment/index.d.ts.map +1 -1
  44. package/dist/environment/index.js +10 -0
  45. package/dist/environment/logger.d.ts +12 -3
  46. package/dist/environment/logger.d.ts.map +1 -1
  47. package/dist/environment/paths.d.ts +7 -0
  48. package/dist/environment/paths.d.ts.map +1 -0
  49. package/dist/environment/paths.js +72 -0
  50. package/dist/environment/questions.d.ts.map +1 -1
  51. package/dist/environment/questions.js +20 -14
  52. package/dist/environment/setup-environment.js +3 -2
  53. package/dist/environment/templates.d.ts.map +1 -1
  54. package/dist/environment/templates.js +2 -1
  55. package/dist/environment/update-workflows.d.ts.map +1 -1
  56. package/dist/environment/update-workflows.js +17 -5
  57. package/dist/environment/upgrade.d.ts +2 -0
  58. package/dist/environment/upgrade.d.ts.map +1 -0
  59. package/dist/environment/upgrade.js +82 -0
  60. package/dist/environment/users.js +11 -13
  61. package/dist/events/index.js +3688 -3293
  62. package/dist/migrations/v2.0/checkout-upstream-files.d.ts +2 -2
  63. package/dist/migrations/v2.0/checkout-upstream-files.d.ts.map +1 -1
  64. package/dist/migrations/v2.0/checkout-upstream-files.js +2 -2
  65. package/dist/migrations/v2.1/add-recovery-link-notifications.d.ts +3 -0
  66. package/dist/migrations/v2.1/add-recovery-link-notifications.d.ts.map +1 -0
  67. package/dist/migrations/v2.1/add-recovery-link-notifications.js +511 -0
  68. package/dist/migrations/v2.1/add-translations.d.ts +9 -0
  69. package/dist/migrations/v2.1/add-translations.d.ts.map +1 -0
  70. package/dist/migrations/v2.1/add-translations.js +182 -0
  71. package/dist/migrations/v2.1/index.d.ts.map +1 -1
  72. package/dist/migrations/v2.1/index.js +637 -0
  73. package/dist/notification/index.js +1833 -1426
  74. package/dist/scopes/index.d.ts +327 -32
  75. package/dist/scopes/index.js +329 -58
  76. package/dist/templates/charts-values/opencrvs-services/values.yaml +4 -3
  77. package/dist/templates/charts-values/opentelemetry/values.yaml +95 -0
  78. package/dist/templates/charts-values/traefik/values.yaml +23 -9
  79. package/dist/templates/inventory/inventory.template.yml +1 -3
  80. package/dist/translations/check.d.ts +23 -0
  81. package/dist/translations/check.d.ts.map +1 -0
  82. package/dist/translations/check.js +126 -0
  83. package/opencrvs-toolkit-2.1.0-rc.05a1257.tgz +0 -0
  84. package/package.json +9 -6
  85. package/tsconfig.build.json +11 -0
  86. package/tsconfig.build.tsbuildinfo +1 -0
  87. package/dist/templates/inventory/production.example.yml +0 -77
  88. package/dist/templates/inventory/qa.example.yml +0 -48
  89. package/opencrvs-toolkit-2.1.0-rc.03f553a.tgz +0 -0
  90. 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":"AAYA;;;GAGG;AACH,wBAAsB,UAAU,CAAC,WAAW,EAAE,OAAO,iBAEpD"}
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"}