@opencrvs/toolkit 2.1.0-rc.a434ca3 → 2.1.0-rc.a4ec5a4

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 (63) hide show
  1. package/build.sh +5 -1
  2. package/create-countryconfig/index.js +284 -97
  3. package/create-countryconfig/node_modules/.bin/degit +21 -0
  4. package/create-countryconfig/package.json +4 -1
  5. package/dist/application-config/index.js +244 -209
  6. package/dist/cli.js +1287 -84
  7. package/dist/commons/api/router.d.ts +407 -50
  8. package/dist/commons/conditionals/conditionals.d.ts +6 -6
  9. package/dist/commons/conditionals/validate.d.ts +6 -2
  10. package/dist/commons/events/ActionDocument.d.ts +4 -4
  11. package/dist/commons/events/ActionInput.d.ts +4 -4
  12. package/dist/commons/events/AdvancedSearchConfig.d.ts +12 -0
  13. package/dist/commons/events/EventDocument.d.ts +470 -2
  14. package/dist/commons/events/EventMetadata.d.ts +1 -11
  15. package/dist/commons/events/EventStatus.d.ts +19 -0
  16. package/dist/commons/events/FieldConfig.d.ts +18 -0
  17. package/dist/commons/events/FieldTypeMapping.d.ts +15 -15
  18. package/dist/commons/events/locations.d.ts +59 -10
  19. package/dist/commons/events/test.utils.d.ts +8 -4
  20. package/dist/commons/events/utils.d.ts +2 -2
  21. package/dist/commons/notification/UserNotifications.d.ts +28 -13
  22. package/dist/commons/notification/dispatch.d.ts +15 -0
  23. package/dist/commons/notification/index.d.ts +1 -0
  24. package/dist/conditionals/index.js +79 -57
  25. package/dist/csv.d.ts +25 -0
  26. package/dist/csv.d.ts.map +1 -0
  27. package/dist/csv.js +120 -0
  28. package/dist/environment/questions.d.ts.map +1 -1
  29. package/dist/environment/questions.js +20 -14
  30. package/dist/environment/setup-environment.js +1 -1
  31. package/dist/events/index.js +841 -777
  32. package/dist/migrations/v2.1/add-recovery-link-notifications.d.ts +3 -0
  33. package/dist/migrations/v2.1/add-recovery-link-notifications.d.ts.map +1 -0
  34. package/dist/migrations/v2.1/add-recovery-link-notifications.js +511 -0
  35. package/dist/migrations/v2.1/add-translations.d.ts +9 -0
  36. package/dist/migrations/v2.1/add-translations.d.ts.map +1 -0
  37. package/dist/migrations/v2.1/add-translations.js +213 -0
  38. package/dist/migrations/v2.1/enable-telemetry.d.ts +3 -0
  39. package/dist/migrations/v2.1/enable-telemetry.d.ts.map +1 -0
  40. package/dist/migrations/v2.1/enable-telemetry.js +438 -0
  41. package/dist/migrations/v2.1/index.d.ts.map +1 -1
  42. package/dist/migrations/v2.1/index.js +1058 -0
  43. package/dist/notification/index.js +938 -1361
  44. package/dist/scopes/index.d.ts +77 -7
  45. package/dist/scopes/index.js +79 -57
  46. package/dist/telemetry/index.d.ts +45 -0
  47. package/dist/telemetry/index.d.ts.map +1 -0
  48. package/dist/telemetry/index.js +39 -0
  49. package/dist/templates/charts-values/opencrvs-services/values.yaml +1 -1
  50. package/dist/templates/charts-values/opentelemetry/values.yaml +22 -0
  51. package/dist/templates/charts-values/traefik/values.yaml +23 -9
  52. package/dist/templates/inventory/inventory.template.yml +1 -3
  53. package/dist/translations/check.d.ts +19 -0
  54. package/dist/translations/check.d.ts.map +1 -0
  55. package/dist/translations/check.js +127 -0
  56. package/opencrvs-toolkit-2.1.0-rc.a4ec5a4.tgz +0 -0
  57. package/package.json +7 -3
  58. package/tsconfig.build.json +11 -0
  59. package/tsconfig.build.tsbuildinfo +1 -0
  60. package/dist/templates/inventory/production.example.yml +0 -77
  61. package/dist/templates/inventory/qa.example.yml +0 -48
  62. package/opencrvs-toolkit-2.1.0-rc.a434ca3.tgz +0 -0
  63. package/tsconfig.tsbuildinfo +0 -1
package/dist/csv.js ADDED
@@ -0,0 +1,120 @@
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
+ Object.defineProperty(exports, "__esModule", { value: true });
13
+ exports.parseCsvLine = parseCsvLine;
14
+ exports.toCsvLine = toCsvLine;
15
+ exports.idOf = idOf;
16
+ exports.readCsvFile = readCsvFile;
17
+ exports.writeCsvFile = writeCsvFile;
18
+ exports.addRows = addRows;
19
+ /**
20
+ * Just enough CSV for the translation files codemods edit. They are read and
21
+ * written a line at a time rather than through a parser, so that adding two
22
+ * rows to a file of sixteen hundred produces a diff of two lines instead of a
23
+ * re-quoted rewrite of the whole thing.
24
+ *
25
+ * Rows spanning multiple lines are not supported, and none of the translation
26
+ * files contain any.
27
+ */
28
+ const fs_1 = require("fs");
29
+ function parseCsvLine(line) {
30
+ const values = [];
31
+ let value = '';
32
+ let quoted = false;
33
+ for (let index = 0; index < line.length; index++) {
34
+ const character = line[index];
35
+ if (quoted) {
36
+ if (character !== '"') {
37
+ value += character;
38
+ }
39
+ else if (line[index + 1] === '"') {
40
+ value += '"';
41
+ index++;
42
+ }
43
+ else {
44
+ quoted = false;
45
+ }
46
+ continue;
47
+ }
48
+ if (character === '"') {
49
+ quoted = true;
50
+ }
51
+ else if (character === ',') {
52
+ values.push(value);
53
+ value = '';
54
+ }
55
+ else {
56
+ value += character;
57
+ }
58
+ }
59
+ values.push(value);
60
+ return values;
61
+ }
62
+ function toCsvLine(values) {
63
+ return values
64
+ .map((value) => /["\n,]/.test(value) ? `"${value.replace(/"/g, '""')}"` : value)
65
+ .join(',');
66
+ }
67
+ /**
68
+ * The id of a row, which is its first column. Translation ids never contain a
69
+ * comma or a quote, so this does not need the parser.
70
+ */
71
+ function idOf(line) {
72
+ const comma = line.indexOf(',');
73
+ // No comma: `slice(0, -1)` would eat the last character.
74
+ return comma === -1 ? line : line.slice(0, comma);
75
+ }
76
+ function readCsvFile(path) {
77
+ if (!(0, fs_1.existsSync)(path)) {
78
+ return undefined;
79
+ }
80
+ const contents = (0, fs_1.readFileSync)(path, 'utf8');
81
+ const newline = contents.includes('\r\n') ? '\r\n' : '\n';
82
+ const trailingNewline = /\r?\n$/.test(contents);
83
+ const lines = contents.replace(/\r?\n$/, '').split(/\r?\n/);
84
+ // Trailing blank line leaves an empty entry. It sorts before every id, so
85
+ // the file reads as unsorted.
86
+ const body = lines.slice(1).filter((line) => line !== '');
87
+ return { header: lines[0], body, newline, trailingNewline };
88
+ }
89
+ function writeCsvFile(path, file) {
90
+ (0, fs_1.writeFileSync)(path, [file.header, ...file.body].join(file.newline) +
91
+ (file.trailingNewline ? file.newline : ''));
92
+ }
93
+ /**
94
+ * Adds the rows the file does not already have an id for, in place. Rows go in
95
+ * sorted position when the file is sorted by id, and at the end when it is not,
96
+ * so a country config that keeps its own order keeps it.
97
+ *
98
+ * Returns the ids that were added.
99
+ */
100
+ function addRows(file, rows) {
101
+ const isSorted = file.body.every((line, index) => index === 0 || idOf(file.body[index - 1]) <= idOf(line));
102
+ const added = [];
103
+ for (const row of rows) {
104
+ const id = idOf(row);
105
+ if (file.body.some((line) => idOf(line) === id)) {
106
+ continue;
107
+ }
108
+ const insertAt = isSorted
109
+ ? file.body.findIndex((line) => idOf(line) > id)
110
+ : -1;
111
+ if (insertAt === -1) {
112
+ file.body.push(row);
113
+ }
114
+ else {
115
+ file.body.splice(insertAt, 0, row);
116
+ }
117
+ added.push(id);
118
+ }
119
+ return added;
120
+ }
@@ -1 +1 @@
1
- {"version":3,"file":"questions.d.ts","sourceRoot":"","sources":["../../src/environment/questions.ts"],"names":[],"mappings":"AAeA,QAAA,MAAM,QAAQ,UAAW,MAAM,GAAG,MAAM,kCAC4B,CAAA;AAepE,iBAAS,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,MAAM,CAgBnD;AAED,eAAO,MAAM,kBAAkB;;UAGrB,MAAM;;eAED,QAAQ;;;;WAIZ,YAAY;GAiCtB,CAAA;AAED,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eAAO,MAAM,cAAc;;;UAGjB,MAAM;;eAED,QAAQ;;;;WAIZ,aAAa;;;UAkCd,QAAQ;;;;;;eAYH,QAAQ;;;;WAIZ,aAAa;IAuBvB,CAAA;AAED,eAAO,MAAM,eAAe;;UAGlB,MAAM;;eAED,QAAQ;;;;WAIZ,aAAa;GAEvB,CAAA;AAED,eAAO,MAAM,sBAAsB;eAEpB,QAAQ;;UAEb,MAAM;;;WAIL,aAAa;;GAYvB,CAAA"}
@@ -166,11 +166,28 @@ exports.infrastructureQuestions = [
166
166
  scope: 'ENVIRONMENT'
167
167
  },
168
168
  {
169
- name: 'kubeAPIHost',
169
+ name: 'kubeMasterNode',
170
170
  type: 'text',
171
- message: `Kubernetes API endpoint (default: auto-detect)`,
171
+ message: `Kubernetes master node hostnames or IP (default: auto-detect)`,
172
+ valueType: 'VARIABLE',
173
+ valueLabel: 'KUBE_MASTER_NODE',
174
+ initial: process.env.KUBE_MASTER_NODE,
175
+ scope: 'ENVIRONMENT'
176
+ },
177
+ {
178
+ name: 'kubeWorkerNodes',
179
+ type: 'text',
180
+ message: `Kubernetes worker node hostnames or IPs (comma-separated, default: no worker nodes)`,
181
+ valueType: 'VARIABLE',
182
+ valueLabel: 'KUBE_WORKER_NODES',
183
+ initial: process.env.KUBE_WORKER_NODES || '',
184
+ scope: 'ENVIRONMENT'
185
+ },
186
+ {
187
+ name: 'kubeApiHost',
188
+ type: 'text',
189
+ message: `Kubernetes API endpoint IP (default: KUBE_MASTER_NODE)`,
172
190
  valueType: 'VARIABLE',
173
- // validate: notEmpty,
174
191
  valueLabel: 'KUBE_API_HOST',
175
192
  initial: process.env.KUBE_API_HOST,
176
193
  scope: 'ENVIRONMENT'
@@ -185,16 +202,6 @@ exports.infrastructureQuestions = [
185
202
  initial: process.env.KUBE_API_ALLOWED_CIDRS || '',
186
203
  scope: 'ENVIRONMENT'
187
204
  },
188
- {
189
- name: 'kubeWorkerNodes',
190
- type: 'text',
191
- message: `Kubernetes worker node hostnames or IPs (comma-separated, default: no worker nodes)`,
192
- valueType: 'VARIABLE',
193
- // validate: notEmpty,
194
- valueLabel: 'KUBE_WORKER_NODES',
195
- initial: process.env.KUBE_WORKER_NODES || '',
196
- scope: 'ENVIRONMENT'
197
- }
198
205
  ];
199
206
  exports.staticSSLCertQuestions = [
200
207
  {
@@ -224,7 +231,6 @@ exports.backupQuestions = [
224
231
  type: 'text',
225
232
  message: `Please enter backup server host/IP address, (default: no backup):`,
226
233
  valueType: 'VARIABLE',
227
- // validate: notEmpty,
228
234
  valueLabel: 'BACKUP_HOST',
229
235
  initial: process.env.BACKUP_HOST || '',
230
236
  scope: 'ENVIRONMENT'
@@ -717,7 +717,7 @@ ALL_QUESTIONS.push(...questions_1.githubTokenQuestion, ...questions_1.githubOthe
717
717
  (0, logger_1.log)('\n', kleur_1.default.bold().underline('Running configuration files updates'));
718
718
  (0, templates_1.generateInventory)(environment, {
719
719
  kube_worker_nodes: kubeWorkerNodes,
720
- kube_api_host: infrastructure.kubeAPIHost || '',
720
+ kube_api_host: infrastructure.kubeApiHost || '',
721
721
  backup_host: backupHost || '',
722
722
  users: users
723
723
  });