@opencrvs/toolkit 2.1.0-rc.5617d8e → 2.1.0-rc.562608b

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 (129) hide show
  1. package/README.md +3 -12
  2. package/build.sh +12 -4
  3. package/create-countryconfig/index.js +441 -59
  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 +362 -284
  7. package/dist/authentication/index.d.ts +66 -0
  8. package/dist/authentication/index.d.ts.map +1 -0
  9. package/dist/authentication/index.js +765 -0
  10. package/dist/cli.js +3347 -1229
  11. package/dist/commons/api/router.d.ts +761 -151
  12. package/dist/commons/application-config/index.d.ts +0 -2
  13. package/dist/commons/conditionals/conditionals.d.ts +6 -6
  14. package/dist/commons/conditionals/validate.d.ts +34 -8
  15. package/dist/commons/events/ActionConfig.d.ts +5 -14
  16. package/dist/commons/events/ActionDocument.d.ts +35 -15
  17. package/dist/commons/events/ActionInput.d.ts +4 -4
  18. package/dist/commons/events/ActionStatus.d.ts +14 -0
  19. package/dist/commons/events/AdvancedSearchConfig.d.ts +48 -12
  20. package/dist/commons/events/AuditLog.d.ts +148 -0
  21. package/dist/commons/events/Draft.d.ts +1 -21
  22. package/dist/commons/events/EventConfig.d.ts +3 -0
  23. package/dist/commons/events/EventDocument.d.ts +472 -4
  24. package/dist/commons/events/EventIndex.d.ts +3 -26
  25. package/dist/commons/events/EventMetadata.d.ts +1 -11
  26. package/dist/commons/events/EventStatus.d.ts +19 -0
  27. package/dist/commons/events/FieldConfig.d.ts +109 -63
  28. package/dist/commons/events/FieldTypeMapping.d.ts +17 -17
  29. package/dist/commons/events/FieldValue.d.ts +3 -2
  30. package/dist/commons/events/Flag.d.ts +42 -0
  31. package/dist/commons/events/FormConfig.d.ts +6 -0
  32. package/dist/commons/events/PageConfig.d.ts +4 -0
  33. package/dist/commons/events/PlainDate.d.ts +8 -0
  34. package/dist/commons/events/SummaryConfig.d.ts +249 -0
  35. package/dist/commons/events/WorkqueueConfig.d.ts +17 -14
  36. package/dist/commons/events/event.d.ts +12 -0
  37. package/dist/commons/events/index.d.ts +1 -0
  38. package/dist/commons/events/locationPayloads.d.ts +95 -0
  39. package/dist/commons/events/locations.d.ts +169 -29
  40. package/dist/commons/events/mocks.test.utils.d.ts +30 -2
  41. package/dist/commons/events/scopes.d.ts +21 -1
  42. package/dist/commons/events/test.utils.d.ts +78 -20
  43. package/dist/commons/events/utils.d.ts +34 -4
  44. package/dist/commons/notification/UserNotifications.d.ts +28 -13
  45. package/dist/commons/notification/dispatch.d.ts +10 -0
  46. package/dist/commons/notification/index.d.ts +1 -0
  47. package/dist/conditionals/index.js +349 -65
  48. package/dist/csv.d.ts +25 -0
  49. package/dist/csv.d.ts.map +1 -0
  50. package/dist/csv.js +120 -0
  51. package/dist/environment/index.d.ts +1 -0
  52. package/dist/environment/index.d.ts.map +1 -1
  53. package/dist/environment/index.js +12 -1
  54. package/dist/environment/logger.d.ts +15 -3
  55. package/dist/environment/logger.d.ts.map +1 -1
  56. package/dist/environment/manage-users.js +1 -1
  57. package/dist/environment/paths.d.ts +7 -0
  58. package/dist/environment/paths.d.ts.map +1 -0
  59. package/dist/environment/paths.js +72 -0
  60. package/dist/environment/questions.d.ts.map +1 -1
  61. package/dist/environment/questions.js +20 -14
  62. package/dist/environment/setup-environment.d.ts +1 -1
  63. package/dist/environment/setup-environment.d.ts.map +1 -1
  64. package/dist/environment/setup-environment.js +587 -562
  65. package/dist/environment/templates.d.ts +0 -1
  66. package/dist/environment/templates.d.ts.map +1 -1
  67. package/dist/environment/templates.js +5 -9
  68. package/dist/environment/update-workflows.d.ts.map +1 -1
  69. package/dist/environment/update-workflows.js +21 -5
  70. package/dist/environment/upgrade.d.ts +2 -0
  71. package/dist/environment/upgrade.d.ts.map +1 -0
  72. package/dist/environment/upgrade.js +82 -0
  73. package/dist/environment/users.js +11 -13
  74. package/dist/environment/utils.d.ts +0 -12
  75. package/dist/environment/utils.d.ts.map +1 -1
  76. package/dist/environment/utils.js +1 -28
  77. package/dist/events/index.js +7182 -6611
  78. package/dist/migrations/v2.0/checkout-upstream-files.d.ts +2 -2
  79. package/dist/migrations/v2.0/checkout-upstream-files.d.ts.map +1 -1
  80. package/dist/migrations/v2.0/checkout-upstream-files.js +2 -2
  81. package/dist/migrations/v2.0/convert-config-files-to-ts.d.ts.map +1 -1
  82. package/dist/migrations/v2.0/convert-config-files-to-ts.js +3 -10
  83. package/dist/migrations/v2.0/merge-infrastructure-directory.js +3 -3
  84. package/dist/migrations/v2.1/add-recovery-link-notifications.d.ts +3 -0
  85. package/dist/migrations/v2.1/add-recovery-link-notifications.d.ts.map +1 -0
  86. package/dist/migrations/v2.1/add-recovery-link-notifications.js +511 -0
  87. package/dist/migrations/v2.1/add-translations.d.ts +9 -0
  88. package/dist/migrations/v2.1/add-translations.d.ts.map +1 -0
  89. package/dist/migrations/v2.1/add-translations.js +149 -0
  90. package/dist/migrations/v2.1/enable-telemetry.d.ts +3 -0
  91. package/dist/migrations/v2.1/enable-telemetry.d.ts.map +1 -0
  92. package/dist/migrations/v2.1/enable-telemetry.js +455 -0
  93. package/dist/migrations/v2.1/index.d.ts.map +1 -1
  94. package/dist/migrations/v2.1/index.js +1556 -0
  95. package/dist/migrations/v2.1/remove-metabase-package-installs.d.ts +2 -0
  96. package/dist/migrations/v2.1/remove-metabase-package-installs.d.ts.map +1 -0
  97. package/dist/migrations/v2.1/remove-metabase-package-installs.js +161 -0
  98. package/dist/migrations/v2.1/remove-sentry.d.ts +3 -0
  99. package/dist/migrations/v2.1/remove-sentry.d.ts.map +1 -0
  100. package/dist/migrations/v2.1/remove-sentry.js +354 -0
  101. package/dist/migrations/v2.1/rename-trigger-paths.d.ts +3 -0
  102. package/dist/migrations/v2.1/rename-trigger-paths.d.ts.map +1 -0
  103. package/dist/migrations/v2.1/rename-trigger-paths.js +216 -0
  104. package/dist/notification/index.js +1862 -1448
  105. package/dist/scopes/index.d.ts +614 -36
  106. package/dist/scopes/index.js +351 -65
  107. package/dist/telemetry/index.d.ts +45 -0
  108. package/dist/telemetry/index.d.ts.map +1 -0
  109. package/dist/telemetry/index.js +43 -0
  110. package/dist/templates/charts-values/dependencies/values.yaml +8 -0
  111. package/dist/templates/charts-values/opencrvs-services/values.yaml +10 -3
  112. package/dist/templates/charts-values/opentelemetry/values.yaml +102 -0
  113. package/dist/templates/charts-values/traefik/values.yaml +23 -9
  114. package/dist/templates/inventory/inventory.template.yml +1 -3
  115. package/dist/translations/template.d.ts +11 -0
  116. package/dist/translations/template.d.ts.map +1 -0
  117. package/dist/translations/template.js +100 -0
  118. package/dist/verify/endpoints.d.ts +2 -0
  119. package/dist/verify/endpoints.d.ts.map +1 -0
  120. package/dist/verify/endpoints.js +510 -0
  121. package/opencrvs-toolkit-2.1.0-rc.562608b.tgz +0 -0
  122. package/package.json +13 -6
  123. package/tsconfig.build.json +11 -0
  124. package/tsconfig.build.tsbuildinfo +1 -0
  125. package/tsconfig.json +3 -0
  126. package/dist/templates/inventory/production.example.yml +0 -77
  127. package/dist/templates/inventory/qa.example.yml +0 -48
  128. package/opencrvs-toolkit-2.1.0-rc.5617d8e.tgz +0 -0
  129. package/tsconfig.tsbuildinfo +0 -1
@@ -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
+ }