@opencrvs/toolkit 2.1.1-rc.52250d8 → 2.2.0-rc.3af310b

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 (141) hide show
  1. package/build.sh +2 -12
  2. package/create-countryconfig/package.json +1 -1
  3. package/dist/application-config/index.js +36 -4
  4. package/dist/authentication/index.js +14 -2
  5. package/dist/cli.js +833 -2019
  6. package/dist/commons/api/router.d.ts +1374 -71
  7. package/dist/commons/conditionals/conditionals.d.ts +3 -3
  8. package/dist/commons/events/ActionConfig.d.ts +146 -20
  9. package/dist/commons/events/ActionDocument.d.ts +88 -0
  10. package/dist/commons/events/ActionInput.d.ts +52 -0
  11. package/dist/commons/events/ActionType.d.ts +11 -1
  12. package/dist/commons/events/AdvancedSearchConfig.d.ts +12 -0
  13. package/dist/commons/events/AuditLog.d.ts +4 -0
  14. package/dist/commons/events/CountryConfigQueryInput.d.ts +192 -18
  15. package/dist/commons/events/Draft.d.ts +2 -0
  16. package/dist/commons/events/EventConfig.d.ts +36 -6
  17. package/dist/commons/events/EventDocument.d.ts +88 -0
  18. package/dist/commons/events/EventIndex.d.ts +41 -4
  19. package/dist/commons/events/EventMetadata.d.ts +23 -1
  20. package/dist/commons/events/EventStatus.d.ts +1 -0
  21. package/dist/commons/events/FieldConfig.d.ts +10 -0
  22. package/dist/commons/events/Flag.d.ts +0 -6
  23. package/dist/commons/events/WorkqueueConfig.d.ts +224 -33
  24. package/dist/commons/events/eventConfigValidation.d.ts +26 -1
  25. package/dist/commons/events/notificationFormFallback.d.ts +10 -0
  26. package/dist/commons/events/scopes.d.ts +2 -0
  27. package/dist/commons/events/state/flags.d.ts +1 -1
  28. package/dist/commons/events/state/index.d.ts +10 -2
  29. package/dist/commons/events/state/utils.d.ts +11 -1
  30. package/dist/commons/events/test.utils.d.ts +31 -1
  31. package/dist/commons/events/utils.d.ts +53 -20
  32. package/dist/conditionals/index.js +14 -2
  33. package/dist/environment/derived-variables.d.ts +6 -0
  34. package/dist/environment/derived-variables.d.ts.map +1 -1
  35. package/dist/environment/derived-variables.js +7 -0
  36. package/dist/environment/dockerhub.d.ts +15 -0
  37. package/dist/environment/dockerhub.d.ts.map +1 -0
  38. package/dist/environment/dockerhub.js +104 -0
  39. package/dist/environment/questions.d.ts +1 -1
  40. package/dist/environment/questions.d.ts.map +1 -1
  41. package/dist/environment/questions.js +4 -7
  42. package/dist/environment/setup-environment.d.ts.map +1 -1
  43. package/dist/environment/setup-environment.js +41 -2
  44. package/dist/environment/templates.d.ts.map +1 -1
  45. package/dist/events/index.js +461 -83
  46. package/dist/migrations/index.d.ts +9 -0
  47. package/dist/migrations/index.d.ts.map +1 -0
  48. package/dist/migrations/index.js +847 -0
  49. package/dist/migrations/move-declaration-to-declare-action.d.ts +38 -0
  50. package/dist/migrations/move-declaration-to-declare-action.d.ts.map +1 -0
  51. package/dist/migrations/move-declaration-to-declare-action.js +377 -0
  52. package/dist/migrations/{v2.1 → persistent}/add-translations.d.ts +7 -1
  53. package/dist/migrations/persistent/add-translations.d.ts.map +1 -0
  54. package/dist/migrations/{v2.1 → persistent}/add-translations.js +14 -12
  55. package/dist/migrations/persistent/check-upgrade-path.d.ts +36 -0
  56. package/dist/migrations/persistent/check-upgrade-path.d.ts.map +1 -0
  57. package/dist/migrations/persistent/check-upgrade-path.js +105 -0
  58. package/dist/migrations/persistent/update-toolkit-dependency.d.ts +7 -0
  59. package/dist/migrations/persistent/update-toolkit-dependency.d.ts.map +1 -0
  60. package/dist/migrations/persistent/update-toolkit-dependency.js +77 -0
  61. package/dist/migrations/read-declaration-through-helper.d.ts +39 -0
  62. package/dist/migrations/read-declaration-through-helper.d.ts.map +1 -0
  63. package/dist/migrations/read-declaration-through-helper.js +257 -0
  64. package/dist/migrations/replace-incomplete-flag.d.ts +26 -0
  65. package/dist/migrations/replace-incomplete-flag.d.ts.map +1 -0
  66. package/dist/migrations/replace-incomplete-flag.js +126 -0
  67. package/dist/notification/index.js +401 -100
  68. package/dist/scopes/index.d.ts +29 -39
  69. package/dist/scopes/index.js +14 -2
  70. package/dist/templates/charts-values/dependencies/values.yaml +1 -1
  71. package/dist/templates/charts-values/opencrvs-services/values.yaml +1 -2
  72. package/dist/templates/charts-values/traefik/values.yaml +4 -3
  73. package/opencrvs-toolkit-2.2.0-rc.3af310b.tgz +0 -0
  74. package/package.json +1 -1
  75. package/tsconfig.build.tsbuildinfo +1 -1
  76. package/dist/migrations/v2.1/add-explicit-correction-flags.d.ts +0 -3
  77. package/dist/migrations/v2.1/add-explicit-correction-flags.d.ts.map +0 -1
  78. package/dist/migrations/v2.1/add-explicit-correction-flags.js +0 -234
  79. package/dist/migrations/v2.1/add-recovery-link-notifications.d.ts +0 -3
  80. package/dist/migrations/v2.1/add-recovery-link-notifications.d.ts.map +0 -1
  81. package/dist/migrations/v2.1/add-recovery-link-notifications.js +0 -511
  82. package/dist/migrations/v2.1/add-translations.d.ts.map +0 -1
  83. package/dist/migrations/v2.1/enable-telemetry.d.ts +0 -3
  84. package/dist/migrations/v2.1/enable-telemetry.d.ts.map +0 -1
  85. package/dist/migrations/v2.1/enable-telemetry.js +0 -455
  86. package/dist/migrations/v2.1/index.d.ts +0 -6
  87. package/dist/migrations/v2.1/index.d.ts.map +0 -1
  88. package/dist/migrations/v2.1/index.js +0 -2233
  89. package/dist/migrations/v2.1/migrate-infrastructure-to-assets.d.ts +0 -14
  90. package/dist/migrations/v2.1/migrate-infrastructure-to-assets.d.ts.map +0 -1
  91. package/dist/migrations/v2.1/migrate-infrastructure-to-assets.js +0 -348
  92. package/dist/migrations/v2.1/remove-metabase-package-installs.d.ts +0 -2
  93. package/dist/migrations/v2.1/remove-metabase-package-installs.d.ts.map +0 -1
  94. package/dist/migrations/v2.1/remove-metabase-package-installs.js +0 -161
  95. package/dist/migrations/v2.1/remove-sentry.d.ts +0 -3
  96. package/dist/migrations/v2.1/remove-sentry.d.ts.map +0 -1
  97. package/dist/migrations/v2.1/remove-sentry.js +0 -354
  98. package/dist/migrations/v2.1/remove-typings-from-dockerfile.d.ts +0 -3
  99. package/dist/migrations/v2.1/remove-typings-from-dockerfile.d.ts.map +0 -1
  100. package/dist/migrations/v2.1/remove-typings-from-dockerfile.js +0 -121
  101. package/dist/migrations/v2.1/rename-trigger-paths.d.ts +0 -3
  102. package/dist/migrations/v2.1/rename-trigger-paths.d.ts.map +0 -1
  103. package/dist/migrations/v2.1/rename-trigger-paths.js +0 -216
  104. package/dist/migrations/v2.1/template-files.d.ts +0 -8
  105. package/dist/migrations/v2.1/template-files.d.ts.map +0 -1
  106. package/dist/migrations/v2.1/template-files.js +0 -49
  107. package/dist/migrations/v2.1/upgrade-tilt.d.ts +0 -8
  108. package/dist/migrations/v2.1/upgrade-tilt.d.ts.map +0 -1
  109. package/dist/migrations/v2.1/upgrade-tilt.js +0 -139
  110. package/dist/templates/countryconfig-template/.tiltignore +0 -1
  111. package/dist/templates/countryconfig-template/Dockerfile.assets +0 -7
  112. package/dist/templates/countryconfig-template/Tiltfile +0 -112
  113. package/dist/templates/countryconfig-template/assets/README.md +0 -1
  114. package/dist/templates/countryconfig-template/assets/clear-all-data-dev.sh +0 -61
  115. package/dist/templates/countryconfig-template/assets/deployment/deploy.sh +0 -455
  116. package/dist/templates/countryconfig-template/assets/deployment/reindex.sh +0 -168
  117. package/dist/templates/countryconfig-template/assets/deployment/validate-required-variables-in-compose-files.ts +0 -67
  118. package/dist/templates/countryconfig-template/assets/elasticsearch/reindex.sh +0 -168
  119. package/dist/templates/countryconfig-template/assets/metabase/README.md +0 -34
  120. package/dist/templates/countryconfig-template/assets/metabase/environment-configuration.sql +0 -36
  121. package/dist/templates/countryconfig-template/assets/metabase/initialize-database.sh +0 -46
  122. package/dist/templates/countryconfig-template/assets/metabase/metabase.init.db.sql +0 -27737
  123. package/dist/templates/countryconfig-template/assets/metabase/open-shell.sh +0 -21
  124. package/dist/templates/countryconfig-template/assets/metabase/package.json +0 -13
  125. package/dist/templates/countryconfig-template/assets/metabase/run-dev.sh +0 -108
  126. package/dist/templates/countryconfig-template/assets/metabase/run.sh +0 -120
  127. package/dist/templates/countryconfig-template/assets/metabase/update-database.sh +0 -40
  128. package/dist/templates/countryconfig-template/assets/postgres/setup-analytics.sh +0 -135
  129. package/dist/templates/countryconfig-template/assets/postgres/setup-reference-data.sh +0 -108
  130. package/dist/templates/countryconfig-template/tilt/clear-all-data.ps1 +0 -50
  131. package/dist/templates/countryconfig-template/tilt/clear-all-data.sh +0 -35
  132. package/dist/templates/countryconfig-template/tilt/common.tilt +0 -145
  133. package/dist/templates/countryconfig-template/tilt/examples/dependencies/values.yaml +0 -15
  134. package/dist/templates/countryconfig-template/tilt/examples/opencrvs-services/values.yaml +0 -56
  135. package/dist/templates/countryconfig-template/tilt/examples/traefik/values-minikube.yaml +0 -21
  136. package/dist/templates/countryconfig-template/tilt/examples/traefik/values.yaml +0 -38
  137. package/dist/templates/countryconfig-template/tilt/helm/dependencies/values.yaml +0 -17
  138. package/dist/templates/countryconfig-template/tilt/helm/opencrvs-services/values.yaml +0 -16
  139. package/dist/templates/countryconfig-template/tilt/lib.tilt +0 -95
  140. package/dist/templates/countryconfig-template/tilt/opencrvs.tilt +0 -136
  141. package/opencrvs-toolkit-2.1.1-rc.52250d8.tgz +0 -0
@@ -1,216 +0,0 @@
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
- }
@@ -1,8 +0,0 @@
1
- /**
2
- * Where the bundled template files are: next to the built CLI in `dist/`, or
3
- * the template package itself when running from source (tests, ts-node).
4
- */
5
- export declare function findTemplateDir(): string;
6
- /** Every file under `dir`, relative to `root`, with forward slashes. */
7
- export declare function listFiles(root: string, dir: string): string[];
8
- //# sourceMappingURL=template-files.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"template-files.d.ts","sourceRoot":"","sources":["../../../src/migrations/v2.1/template-files.ts"],"names":[],"mappings":"AAmBA;;;GAGG;AACH,wBAAgB,eAAe,WAiB9B;AAED,wEAAwE;AACxE,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,EAAE,CAW7D"}
@@ -1,49 +0,0 @@
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 __importDefault = (this && this.__importDefault) || function (mod) {
13
- return (mod && mod.__esModule) ? mod : { "default": mod };
14
- };
15
- Object.defineProperty(exports, "__esModule", { value: true });
16
- exports.findTemplateDir = findTemplateDir;
17
- exports.listFiles = listFiles;
18
- /**
19
- * Country config template files bundled into the toolkit by `build.sh`, shared
20
- * by the codemods that copy them into a country config.
21
- */
22
- const fs_1 = require("fs");
23
- const path_1 = __importDefault(require("path"));
24
- /**
25
- * Where the bundled template files are: next to the built CLI in `dist/`, or
26
- * the template package itself when running from source (tests, ts-node).
27
- */
28
- function findTemplateDir() {
29
- const candidates = [
30
- path_1.default.resolve(__dirname, 'templates', 'countryconfig-template'),
31
- path_1.default.resolve(__dirname, '../../../../countryconfig-template')
32
- ];
33
- const templateDir = candidates.find((candidate) => (0, fs_1.existsSync)(path_1.default.join(candidate, 'Tiltfile')));
34
- if (!templateDir) {
35
- throw new Error(`Country config template files not found in any of: ${candidates.join(', ')}`);
36
- }
37
- return templateDir;
38
- }
39
- /** Every file under `dir`, relative to `root`, with forward slashes. */
40
- function listFiles(root, dir) {
41
- const absolute = path_1.default.join(root, dir);
42
- if (!(0, fs_1.existsSync)(absolute)) {
43
- return [];
44
- }
45
- return (0, fs_1.readdirSync)(absolute, { withFileTypes: true }).flatMap((entry) => {
46
- const relative = path_1.default.posix.join(dir, entry.name);
47
- return entry.isDirectory() ? listFiles(root, relative) : [relative];
48
- });
49
- }
@@ -1,8 +0,0 @@
1
- /** TODO: ????? The template Tiltfile, keeping the image name the country already uses. */
2
- export declare function renderTiltfile(template: string, existing?: string): string;
3
- /** `contents` with `line` appended, unless an equivalent entry is there already. */
4
- export declare function withIgnoreEntry(contents: string, line: string): string;
5
- export declare function upgradeTilt(cwd: string, templateDir: string): void;
6
- declare function main(): Promise<void>;
7
- export { main };
8
- //# sourceMappingURL=upgrade-tilt.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"upgrade-tilt.d.ts","sourceRoot":"","sources":["../../../src/migrations/v2.1/upgrade-tilt.ts"],"names":[],"mappings":"AAyFA,0FAA0F;AAC1F,wBAAgB,cAAc,CAAC,QAAQ,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,UAYjE;AAED,oFAAoF;AACpF,wBAAgB,eAAe,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,UAc7D;AAQD,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,QA0D3D;AAED,iBAAe,IAAI,kBAQlB;AAED,OAAO,EAAE,IAAI,EAAE,CAAA"}
@@ -1,139 +0,0 @@
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.renderTiltfile = renderTiltfile;
26
- exports.withIgnoreEntry = withIgnoreEntry;
27
- exports.upgradeTilt = upgradeTilt;
28
- exports.main = main;
29
- /**
30
- * Codemod: bring the local Tilt setup in line with the country config template.
31
- *
32
- * Up to v2.0 the Tiltfile cloned opencrvs/opencrvs-helm-charts into a sibling
33
- * `../opencrvs-helm-charts` directory and loaded its `tilt/opencrvs.tilt`. The
34
- * charts now live in opencrvs-core, and the Tilt helpers ship with the country
35
- * config itself under `tilt/`.
36
- *
37
- * What it does:
38
- * 1. Replaces `Tiltfile` with the template's, carrying over the country's
39
- * `countryconfig_image_name`.
40
- * 2. Replaces every file under `tilt/` that core owns (the helpers and
41
- * `tilt/examples/`) with the template's.
42
- * 3. Creates `tilt/helm/<chart>/values.yaml` when missing. These hold the
43
- * country's own overrides and are never overwritten.
44
- * 4. Adds `.opencrvs-core-charts/` (the Tiltfile's charts checkout) to
45
- * `.tiltignore` and `.gitignore`.
46
- *
47
- * The template files are bundled into the toolkit at build time, so they always
48
- * match the toolkit version being run.
49
- *
50
- * Caveats:
51
- * - Local changes to the Tiltfile or to core owned files under `tilt/` are
52
- * overwritten. Review them with `git diff -- Tiltfile tilt/` and move
53
- * chart overrides into `tilt/helm/`.
54
- * - Files under `tilt/` that the template does not have are left in place.
55
- */
56
- const fs_1 = require("fs");
57
- const path_1 = __importDefault(require("path"));
58
- const template_files_1 = require("./template-files");
59
- /** Paths under `tilt/` the country owns: created when missing, never replaced. */
60
- const COUNTRY_OWNED_DIR = 'tilt/helm/';
61
- const CHARTS_CHECKOUT_DIR = '.opencrvs-core-charts';
62
- const IMAGE_NAME_PATTERN = /^countryconfig_image_name\s*=\s*(["'])(.*?)\1/m;
63
- function writeIfChanged(cwd, relativePath, contents, mode) {
64
- const target = path_1.default.join(cwd, relativePath);
65
- const existed = (0, fs_1.existsSync)(target);
66
- if (existed && (0, fs_1.readFileSync)(target, 'utf8') === contents) {
67
- return 'unchanged';
68
- }
69
- (0, fs_1.mkdirSync)(path_1.default.dirname(target), { recursive: true });
70
- (0, fs_1.writeFileSync)(target, contents);
71
- // Keeps shell scripts such as clear-all-data.sh executable
72
- if (mode !== undefined) {
73
- (0, fs_1.chmodSync)(target, mode & 0o777);
74
- }
75
- return existed ? 'updated' : 'created';
76
- }
77
- function report(relativePath, change) {
78
- if (change !== 'unchanged') {
79
- console.log(` ✓ ${change} ${relativePath}`);
80
- }
81
- }
82
- /** TODO: ????? The template Tiltfile, keeping the image name the country already uses. */
83
- function renderTiltfile(template, existing) {
84
- var _a;
85
- const imageName = (_a = existing === null || existing === void 0 ? void 0 : existing.match(IMAGE_NAME_PATTERN)) === null || _a === void 0 ? void 0 : _a[2];
86
- if (!imageName) {
87
- return template;
88
- }
89
- return template.replace(IMAGE_NAME_PATTERN, (_line, quote) => `countryconfig_image_name=${quote}${imageName}${quote}`);
90
- }
91
- /** `contents` with `line` appended, unless an equivalent entry is there already. */
92
- function withIgnoreEntry(contents, line) {
93
- const normalise = (entry) => entry.trim().replace(/^\//, '').replace(/\/$/, '');
94
- const alreadyIgnored = contents
95
- .split(/\r?\n/)
96
- .some((entry) => normalise(entry) === normalise(line));
97
- if (alreadyIgnored) {
98
- return contents;
99
- }
100
- const separator = contents === '' || contents.endsWith('\n') ? '' : '\n';
101
- return `${contents}${separator}${line}\n`;
102
- }
103
- function ensureIgnored(cwd, file, line) {
104
- const target = path_1.default.join(cwd, file);
105
- const contents = (0, fs_1.existsSync)(target) ? (0, fs_1.readFileSync)(target, 'utf8') : '';
106
- report(file, writeIfChanged(cwd, file, withIgnoreEntry(contents, line)));
107
- }
108
- function upgradeTilt(cwd, templateDir) {
109
- const tiltfilePath = path_1.default.join(cwd, 'Tiltfile');
110
- const existingTiltfile = (0, fs_1.existsSync)(tiltfilePath)
111
- ? (0, fs_1.readFileSync)(tiltfilePath, 'utf8')
112
- : undefined;
113
- report('Tiltfile', writeIfChanged(cwd, 'Tiltfile', renderTiltfile((0, fs_1.readFileSync)(path_1.default.join(templateDir, 'Tiltfile'), 'utf8'), existingTiltfile)));
114
- const templateFiles = (0, template_files_1.listFiles)(templateDir, 'tilt');
115
- for (const file of templateFiles) {
116
- const source = path_1.default.join(templateDir, file);
117
- const countryOwned = file.startsWith(COUNTRY_OWNED_DIR);
118
- if (countryOwned && (0, fs_1.existsSync)(path_1.default.join(cwd, file))) {
119
- continue;
120
- }
121
- report(file, writeIfChanged(cwd, file, (0, fs_1.readFileSync)(source, 'utf8'), (0, fs_1.statSync)(source).mode));
122
- }
123
- const unknownFiles = (0, template_files_1.listFiles)(cwd, 'tilt').filter((file) => !file.startsWith(COUNTRY_OWNED_DIR) && !templateFiles.includes(file));
124
- for (const file of unknownFiles) {
125
- console.warn(` ⚠️ ${file} is not part of the template and was left in place.`);
126
- }
127
- ensureIgnored(cwd, '.tiltignore', `${CHARTS_CHECKOUT_DIR}/`);
128
- ensureIgnored(cwd, '.gitignore', CHARTS_CHECKOUT_DIR);
129
- if (existingTiltfile === null || existingTiltfile === void 0 ? void 0 : existingTiltfile.includes('opencrvs-helm-charts')) {
130
- console.log(` ℹ️ The Tiltfile no longer uses ../opencrvs-helm-charts; charts are cloned into ${CHARTS_CHECKOUT_DIR}/ instead. The old checkout can be deleted.`);
131
- }
132
- }
133
- function main() {
134
- return __awaiter(this, void 0, void 0, function* () {
135
- console.log('Upgrading the local Tilt setup...\n');
136
- upgradeTilt(process.cwd(), (0, template_files_1.findTemplateDir)());
137
- console.log('\n Review local customisations with: git diff -- Tiltfile tilt/ .tiltignore .gitignore\n');
138
- });
139
- }
@@ -1 +0,0 @@
1
- .opencrvs-core-charts/
@@ -1,7 +0,0 @@
1
- FROM alpine:3.24
2
-
3
- # Directory inside the assets image
4
- WORKDIR /assets
5
-
6
- # Copy assets
7
- COPY --chmod=755 assets /assets
@@ -1,112 +0,0 @@
1
- ##########################################################################
2
- # Tiltfile: OpenCRVS Country config developer
3
- # For more information about variables, please check:
4
- # https://github.com/opencrvs/infrastructure/blob/develop/Tiltfile
5
-
6
- # OpenCRVS core images tag:
7
- core_images_tag = os.getenv("OPENCRVS_CORE_IMAGE_TAG", "v2.1.1")
8
-
9
- core_ref = os.getenv("OPENCRVS_CORE_REF", "release/2.1.1")
10
-
11
- # Build countryconfig image in local registry (use any name and tag you want)
12
- countryconfig_image_name="opencrvs/ocrvs-countryconfig"
13
- countryconfig_image_tag="local"
14
-
15
-
16
- # Internal variable for helm charts checkout
17
- core_charts_dir = ".opencrvs-core-charts"
18
-
19
- core_repo_url = 'https://github.com/opencrvs/opencrvs-core.git'
20
-
21
- # Tilt re-evaluates this file on every reload, so clone only once per ref.
22
- # Delete the directory (or change OPENCRVS_CORE_REF) to fetch the charts again.
23
- core_charts_marker = "{}/.tilt-ref-{}".format(core_charts_dir, core_ref.replace("/", "_"))
24
- if not os.path.exists(core_charts_marker):
25
- print("Cloning OpenCRVS Helm charts ({}) from {}...".format(core_ref, core_repo_url))
26
- # set -e and git -C: a failed clone must never leave git running in the country config repository
27
- local("""
28
- set -e
29
- rm -rf {core_charts_dir}
30
- git clone \
31
- --depth 1 \
32
- --filter=blob:none \
33
- --sparse \
34
- --branch {core_ref} \
35
- {core_repo_url} \
36
- {core_charts_dir}
37
- git -C {core_charts_dir} sparse-checkout set charts
38
- touch {core_charts_marker}
39
- """.format(
40
- core_ref=core_ref,
41
- core_charts_dir=core_charts_dir,
42
- core_repo_url=core_repo_url,
43
- core_charts_marker=core_charts_marker
44
- ))
45
- else:
46
- print("Using OpenCRVS Helm charts ({}) from {}".format(core_ref, core_charts_dir))
47
-
48
- if not os.path.exists('{core_charts_dir}/charts/dependencies'.format(core_charts_dir=core_charts_dir)) or not os.path.exists('{core_charts_dir}/charts/opencrvs-services'.format(core_charts_dir=core_charts_dir)):
49
- fail('Something went wrong while cloning infrastructure repository!')
50
-
51
- load('./tilt/opencrvs.tilt', 'setup_opencrvs')
52
-
53
- # FIXME: in future releases remove this check and require pnpm only, as yarn is deprecated
54
- # Package manager follows the lockfile, so country configs still on yarn keep working
55
- if os.path.exists('pnpm-lock.yaml'):
56
- package_manager = 'pnpm'
57
- startup_command = 'start:tilt'
58
- lockfile = 'pnpm-lock.yaml'
59
- elif os.path.exists('yarn.lock'):
60
- package_manager = 'yarn'
61
- startup_command = 'start:prod'
62
- lockfile = 'yarn.lock'
63
- else:
64
- fail('No pnpm-lock.yaml or yarn.lock found, install dependencies before running Tilt')
65
-
66
- dependency_files = ['./' + lockfile]
67
- if os.path.exists('.pnpmfile.cjs'):
68
- dependency_files.append('./.pnpmfile.cjs')
69
-
70
- # Build countryconfig image
71
- docker_build(
72
- "{0}:{1}".format(countryconfig_image_name, countryconfig_image_tag),
73
- ".",
74
- dockerfile="Dockerfile",
75
- network="host",
76
- entrypoint=[package_manager, startup_command],
77
- only=[
78
- './src',
79
- './package.json',
80
- './tsconfig.json',
81
- './Dockerfile'
82
- ] + dependency_files,
83
- live_update=[
84
- # Fallback to full rebuild if dependencies change
85
- fall_back_on(['package.json', lockfile, 'Dockerfile']),
86
- # Sync source code changes
87
- sync('./src', '/usr/src/app/src'),
88
- ]
89
- )
90
-
91
-
92
- # Build image with postgres and metabase assets
93
- docker_build("{0}:{1}-assets".format(countryconfig_image_name, countryconfig_image_tag), ".",
94
- dockerfile="Dockerfile.assets",
95
- network="host",
96
- only=[
97
- 'assets/metabase',
98
- 'assets/postgres',
99
- 'assets/deployment',
100
- 'assets/elasticsearch',
101
- './Dockerfile.assets'
102
- ]
103
- )
104
-
105
- setup_opencrvs(
106
- opencrvs_chart_repo=core_charts_dir,
107
- core_images_tag=core_images_tag,
108
- countryconfig_image_name=countryconfig_image_name,
109
- countryconfig_image_tag=countryconfig_image_tag,
110
- )
111
-
112
- print("✅ Tiltfile configuration loaded successfully.")
@@ -1 +0,0 @@
1
- Put custom assets and scripts to extend Country Configuration
@@ -1,61 +0,0 @@
1
- #!/bin/bash
2
- # This Source Code Form is subject to the terms of the Mozilla Public
3
- # License, v. 2.0. If a copy of the MPL was not distributed with this
4
- # file, You can obtain one at https://mozilla.org/MPL/2.0/.
5
- #
6
- # OpenCRVS is also distributed under the terms of the Civil Registration
7
- # & Healthcare Disclaimer located at http://opencrvs.org/license.
8
- #
9
- # Copyright (C) The OpenCRVS Authors located at https://github.com/opencrvs/opencrvs-core/blob/master/AUTHORS.
10
-
11
- set -e
12
-
13
- echo "🧹 Clearing all development data..."
14
-
15
- # Default PostgreSQL connection parameters for development
16
- POSTGRES_HOST=${POSTGRES_HOST:-localhost}
17
- POSTGRES_PORT=${POSTGRES_PORT:-5432}
18
- POSTGRES_USER=${POSTGRES_USER:-postgres}
19
- POSTGRES_PASSWORD=${POSTGRES_PASSWORD:-postgres}
20
- ANALYTICS_POSTGRES_USER=${ANALYTICS_POSTGRES_USER:-events_analytics}
21
-
22
- print_usage_and_exit() {
23
- echo 'Usage: ./clear-all-data-dev.sh'
24
- echo ""
25
- echo "Environment variables (with defaults for development):"
26
- echo "POSTGRES_HOST=${POSTGRES_HOST}"
27
- echo "POSTGRES_PORT=${POSTGRES_PORT}"
28
- echo "POSTGRES_USER=${POSTGRES_USER}"
29
- echo "POSTGRES_PASSWORD=${POSTGRES_PASSWORD}"
30
- echo "ANALYTICS_POSTGRES_USER=${ANALYTICS_POSTGRES_USER}"
31
- echo ""
32
- echo "This script clears all development databases including:"
33
- echo "- PostgreSQL analytics schema and data"
34
- echo "- Metabase configuration database (H2)"
35
- echo "- Any additional custom databases (can be extended by country configurations)"
36
- exit 1
37
- }
38
-
39
- # Check if PostgreSQL is accessible
40
- if ! PGPASSWORD="$POSTGRES_PASSWORD" psql -h "$POSTGRES_HOST" -p "$POSTGRES_PORT" -U "$POSTGRES_USER" -d postgres -c '\q' 2>/dev/null; then
41
- echo "❌ Cannot connect to PostgreSQL at ${POSTGRES_HOST}:${POSTGRES_PORT}"
42
- echo " Make sure PostgreSQL is running and credentials are correct."
43
- print_usage_and_exit
44
- fi
45
-
46
- # Clear PostgreSQL analytics schema
47
- echo "🗑️ Clearing PostgreSQL analytics schema..."
48
- PGPASSWORD="$POSTGRES_PASSWORD" psql -h "$POSTGRES_HOST" -p "$POSTGRES_PORT" -U "$POSTGRES_USER" -d events -v ON_ERROR_STOP=1 <<EOSQL || echo "⚠️ Analytics schema may not exist yet"
49
- -- Drop analytics schema and recreate it
50
- DROP SCHEMA IF EXISTS analytics CASCADE;
51
- CREATE SCHEMA analytics;
52
-
53
- -- Drop and recreate analytics user
54
- DROP ROLE IF EXISTS "$ANALYTICS_POSTGRES_USER";
55
- EOSQL
56
-
57
- echo "✅ PostgreSQL analytics data cleared"
58
-
59
- echo ""
60
- echo "🎉 All development data cleared successfully!"
61
- echo ""