@opencrvs/toolkit 2.0.0-rc.b4856ad → 2.0.0-rc.b60239a

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 (89) hide show
  1. package/create-countryconfig/index.js +73 -0
  2. package/create-countryconfig/package.json +11 -0
  3. package/dist/application-config/index.js +56 -31
  4. package/dist/cli.js +1784 -349
  5. package/dist/commons/api/router.d.ts +49 -53
  6. package/dist/commons/application-config/index.d.ts +16 -4
  7. package/dist/commons/conditionals/conditionals.d.ts +6 -6
  8. package/dist/commons/events/ActionInput.d.ts +36 -0
  9. package/dist/commons/events/Draft.d.ts +1 -0
  10. package/dist/commons/events/EventIndex.d.ts +1 -0
  11. package/dist/commons/events/EventMetadata.d.ts +1 -0
  12. package/dist/commons/events/FieldConfig.d.ts +10 -0
  13. package/dist/commons/events/locations.d.ts +38 -1
  14. package/dist/commons/events/mocks.test.utils.d.ts +19 -0
  15. package/dist/commons/events/scopes.d.ts +24 -1
  16. package/dist/commons/events/state/index.d.ts +2 -1
  17. package/dist/conditionals/index.js +37 -7
  18. package/dist/events/index.js +146 -27
  19. package/dist/migrations/v2.0/add-birth-certificate-issuance-flag.d.ts.map +1 -1
  20. package/dist/migrations/v2.0/add-birth-certificate-issuance-flag.js +63 -39
  21. package/dist/migrations/v2.0/add-resend-invite-notification.d.ts +3 -0
  22. package/dist/migrations/v2.0/add-resend-invite-notification.d.ts.map +1 -0
  23. package/dist/migrations/v2.0/add-resend-invite-notification.js +373 -0
  24. package/dist/migrations/v2.0/checkout-upstream-files.d.ts +19 -0
  25. package/dist/migrations/v2.0/checkout-upstream-files.d.ts.map +1 -1
  26. package/dist/migrations/v2.0/checkout-upstream-files.js +17 -14
  27. package/dist/migrations/v2.0/convert-config-files-to-ts.d.ts.map +1 -1
  28. package/dist/migrations/v2.0/convert-config-files-to-ts.js +4 -5
  29. package/dist/migrations/v2.0/convert-paragraph-to-heading.d.ts.map +1 -1
  30. package/dist/migrations/v2.0/convert-paragraph-to-heading.js +4 -5
  31. package/dist/migrations/v2.0/create-events-index.d.ts.map +1 -1
  32. package/dist/migrations/v2.0/create-events-index.js +1 -2
  33. package/dist/migrations/v2.0/delete-infrastructure-directory.d.ts +11 -0
  34. package/dist/migrations/v2.0/delete-infrastructure-directory.d.ts.map +1 -0
  35. package/dist/migrations/v2.0/delete-infrastructure-directory.js +123 -0
  36. package/dist/migrations/v2.0/index.d.ts +10 -4
  37. package/dist/migrations/v2.0/index.d.ts.map +1 -1
  38. package/dist/migrations/v2.0/index.js +1752 -346
  39. package/dist/migrations/v2.0/make-built-in-validate-actions-custom.d.ts.map +1 -1
  40. package/dist/migrations/v2.0/make-built-in-validate-actions-custom.js +95 -7
  41. package/dist/migrations/v2.0/merge-infrastructure-directory.d.ts +13 -0
  42. package/dist/migrations/v2.0/merge-infrastructure-directory.d.ts.map +1 -0
  43. package/dist/migrations/v2.0/merge-infrastructure-directory.js +222 -0
  44. package/dist/migrations/v2.0/migrate-application-config-url.d.ts +3 -0
  45. package/dist/migrations/v2.0/migrate-application-config-url.d.ts.map +1 -0
  46. package/dist/migrations/v2.0/migrate-application-config-url.js +342 -0
  47. package/dist/migrations/v2.0/migrate-scopes.d.ts.map +1 -1
  48. package/dist/migrations/v2.0/migrate-scopes.js +6 -7
  49. package/dist/migrations/v2.0/migrate-validated-workqueue-status-to-flag.d.ts.map +1 -1
  50. package/dist/migrations/v2.0/migrate-validated-workqueue-status-to-flag.js +3 -4
  51. package/dist/migrations/v2.0/migrate-workqueue-configs.d.ts.map +1 -1
  52. package/dist/migrations/v2.0/migrate-workqueue-configs.js +143 -63
  53. package/dist/migrations/v2.0/remove-delete-actions.d.ts.map +1 -1
  54. package/dist/migrations/v2.0/remove-delete-actions.js +3 -4
  55. package/dist/migrations/v2.0/remove-demo-scope.d.ts.map +1 -1
  56. package/dist/migrations/v2.0/remove-demo-scope.js +2 -3
  57. package/dist/migrations/v2.0/remove-deprecated-imports.d.ts.map +1 -1
  58. package/dist/migrations/v2.0/remove-deprecated-imports.js +3 -4
  59. package/dist/migrations/v2.0/remove-fhir-url-helpers.d.ts +3 -0
  60. package/dist/migrations/v2.0/remove-fhir-url-helpers.d.ts.map +1 -0
  61. package/dist/migrations/v2.0/remove-fhir-url-helpers.js +163 -0
  62. package/dist/migrations/v2.0/remove-hearth-migrations.d.ts.map +1 -1
  63. package/dist/migrations/v2.0/remove-hearth-migrations.js +1 -2
  64. package/dist/migrations/v2.0/remove-old-statistics-service.d.ts +3 -0
  65. package/dist/migrations/v2.0/remove-old-statistics-service.d.ts.map +1 -0
  66. package/dist/migrations/v2.0/remove-old-statistics-service.js +356 -0
  67. package/dist/migrations/v2.0/remove-pending-certification-flag.d.ts.map +1 -1
  68. package/dist/migrations/v2.0/remove-pending-certification-flag.js +3 -4
  69. package/dist/migrations/v2.0/remove-review-from-register-action.d.ts.map +1 -1
  70. package/dist/migrations/v2.0/remove-review-from-register-action.js +3 -4
  71. package/dist/migrations/v2.0/remove-unused-environment-variables.d.ts +3 -0
  72. package/dist/migrations/v2.0/remove-unused-environment-variables.d.ts.map +1 -0
  73. package/dist/migrations/v2.0/remove-unused-environment-variables.js +186 -0
  74. package/dist/migrations/v2.0/rename-api-paths.d.ts.map +1 -1
  75. package/dist/migrations/v2.0/rename-api-paths.js +3 -4
  76. package/dist/migrations/v2.0/rename-location-parent-id.d.ts.map +1 -1
  77. package/dist/migrations/v2.0/rename-location-parent-id.js +3 -4
  78. package/dist/migrations/v2.0/simplify-analytics-precalculations.d.ts.map +1 -1
  79. package/dist/migrations/v2.0/simplify-analytics-precalculations.js +1 -2
  80. package/dist/migrations/v2.0/update-package-json.d.ts +3 -0
  81. package/dist/migrations/v2.0/update-package-json.d.ts.map +1 -0
  82. package/dist/migrations/v2.0/update-package-json.js +105 -0
  83. package/dist/notification/index.js +53 -27
  84. package/dist/scopes/index.d.ts +87 -10
  85. package/dist/scopes/index.js +43 -8
  86. package/opencrvs-toolkit-2.0.0-rc.b60239a.tgz +0 -0
  87. package/package.json +1 -1
  88. package/tsconfig.tsbuildinfo +1 -1
  89. package/opencrvs-toolkit-2.0.0-rc.b4856ad.tgz +0 -0
@@ -0,0 +1,123 @@
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
+ Object.defineProperty(exports, "__esModule", { value: true });
22
+ exports.main = main;
23
+ /**
24
+ * Codemod: Remove the local `infrastructure/` directory.
25
+ *
26
+ * Used by the v1.9 → v2.0 upgrade when the country config does NOT deploy
27
+ * via Docker Swarm. In that case the `infrastructure/` directory shipped
28
+ * with opencrvs-countryconfig is no longer needed and can be removed.
29
+ *
30
+ * Some non-Swarm deployments still need a small subset of
31
+ * `infrastructure/` (e.g. `postgres/` and `metabase/`). Pass `keep` to
32
+ * preserve those top-level subdirectories — everything else under
33
+ * `infrastructure/` is deleted, and the kept subdirectories can then be
34
+ * refreshed from upstream by `merge-infrastructure-directory.ts` with the
35
+ * matching `subdirs` option.
36
+ *
37
+ * Usage:
38
+ * ts-node -r tsconfig-paths/register src/migrations/v2.0/delete-infrastructure-directory.ts
39
+ *
40
+ * What it does:
41
+ * 1. Stages deletion of all tracked files under `infrastructure/` via
42
+ * `git rm -rf --ignore-unmatch -- <path>`. This both removes the
43
+ * files from the working tree and records the deletion in the
44
+ * index, so it shows up in the upgrade commit alongside the other
45
+ * codemod changes. When `keep` is provided, deletion is scoped to
46
+ * the top-level entries that are NOT in `keep`.
47
+ * 2. Cleans up any untracked files / empty directory that `git rm` left
48
+ * behind, so the deleted paths are fully gone from the working tree.
49
+ *
50
+ * Caveats:
51
+ * - Destructive: any local edits to deleted paths are lost. Run on a
52
+ * clean working tree (or after committing your local changes).
53
+ * - If `infrastructure/` doesn't exist, this codemod is a no-op.
54
+ * - Requires git to be installed and the country config working directory
55
+ * to be a git repo.
56
+ */
57
+ const fs_1 = require("fs");
58
+ const path_1 = require("path");
59
+ const checkout_upstream_files_1 = require("./checkout-upstream-files");
60
+ const INFRASTRUCTURE_DIR = 'infrastructure';
61
+ function main() {
62
+ return __awaiter(this, arguments, void 0, function* ({ keep = [] } = {}) {
63
+ const fullPath = (0, path_1.join)(process.cwd(), INFRASTRUCTURE_DIR);
64
+ if (!(0, fs_1.existsSync)(fullPath)) {
65
+ console.log(`'${INFRASTRUCTURE_DIR}/' not found in ${process.cwd()} — nothing to delete.`);
66
+ return;
67
+ }
68
+ (0, checkout_upstream_files_1.assertIsGitRepo)();
69
+ // ─── Whole-directory delete (legacy behavior) ────────────────────────
70
+ if (keep.length === 0) {
71
+ console.log(`Deleting '${INFRASTRUCTURE_DIR}/'...\n`);
72
+ // `git rm -rf --ignore-unmatch` removes tracked files (working tree +
73
+ // index) and is a no-op for paths with no tracked entries, so it's
74
+ // safe to run even when `infrastructure/` exists only as untracked
75
+ // files.
76
+ (0, checkout_upstream_files_1.runGit)(['rm', '-rf', '--ignore-unmatch', '--', `${INFRASTRUCTURE_DIR}/`], {
77
+ silent: true
78
+ });
79
+ console.log(` Staged deletion of tracked files under '${INFRASTRUCTURE_DIR}/'.`);
80
+ // `git rm` leaves untracked files (and any now-empty directory) on
81
+ // disk; remove whatever's left so the path is fully gone.
82
+ if ((0, fs_1.existsSync)(fullPath)) {
83
+ (0, fs_1.rmSync)(fullPath, { recursive: true, force: true });
84
+ console.log(` Removed remaining untracked files under '${INFRASTRUCTURE_DIR}/'.`);
85
+ }
86
+ console.log(`\n Done. Review the staged deletion with: git diff --cached -- '${INFRASTRUCTURE_DIR}/'`);
87
+ return;
88
+ }
89
+ // ─── Selective delete: keep listed top-level entries ─────────────────
90
+ const keepSet = new Set(keep);
91
+ console.log(`Deleting contents of '${INFRASTRUCTURE_DIR}/' except: ${[...keepSet]
92
+ .map((name) => `'${name}'`)
93
+ .join(', ')}\n`);
94
+ const topLevelEntries = (0, fs_1.readdirSync)(fullPath, { withFileTypes: true });
95
+ let deleted = 0;
96
+ for (const entry of topLevelEntries) {
97
+ if (keepSet.has(entry.name)) {
98
+ console.log(` Keeping '${INFRASTRUCTURE_DIR}/${entry.name}'.`);
99
+ continue;
100
+ }
101
+ // Append a trailing slash for directories so git treats it as a tree
102
+ // pathspec (matches the recursive behavior of `git rm -rf`).
103
+ const relPath = `${INFRASTRUCTURE_DIR}/${entry.name}${entry.isDirectory() ? '/' : ''}`;
104
+ (0, checkout_upstream_files_1.runGit)(['rm', '-rf', '--ignore-unmatch', '--', relPath], { silent: true });
105
+ const fullEntryPath = (0, path_1.join)(fullPath, entry.name);
106
+ if ((0, fs_1.existsSync)(fullEntryPath)) {
107
+ (0, fs_1.rmSync)(fullEntryPath, { recursive: true, force: true });
108
+ }
109
+ console.log(` Deleted '${relPath}'.`);
110
+ deleted++;
111
+ }
112
+ // Note any requested keeps that weren't actually present, so the dev
113
+ // notices typos / missing directories.
114
+ const presentNames = new Set(topLevelEntries.map((e) => e.name));
115
+ const missingKeeps = [...keepSet].filter((name) => !presentNames.has(name));
116
+ if (missingKeeps.length > 0) {
117
+ console.warn(` [warn] Requested to keep ${missingKeeps
118
+ .map((n) => `'${n}'`)
119
+ .join(', ')} but they don't exist under '${INFRASTRUCTURE_DIR}/'.`);
120
+ }
121
+ console.log(`\n Done. Deleted ${deleted} top-level entr${deleted === 1 ? 'y' : 'ies'}. Review the staged deletions with: git diff --cached -- '${INFRASTRUCTURE_DIR}/'`);
122
+ });
123
+ }
@@ -1,7 +1,13 @@
1
- export declare function getCwd(): string;
2
1
  /**
3
- * Run the upgrade process for a given country config directory.
4
- * @param ccwd - The country config working directory.
2
+ * Run the upgrade process for the country config in the current working
3
+ * directory.
4
+ *
5
+ * @param dockerSwarm - When true, the local `infrastructure/` directory is
6
+ * merged with upstream changes in its entirety (Docker Swarm deployments
7
+ * still need it all). When false (the default), everything under
8
+ * `infrastructure/` is deleted EXCEPT the subdirectories listed in
9
+ * `NON_SWARM_INFRA_SUBDIRS`, and those preserved subdirectories are then
10
+ * merged with upstream.
5
11
  */
6
- export declare function runUpgrade(ccwd: string | undefined): Promise<void>;
12
+ export declare function runUpgrade(dockerSwarm: boolean): Promise<void>;
7
13
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/migrations/v2.0/index.ts"],"names":[],"mappings":"AA+BA,wBAAgB,MAAM,WAMrB;AAED;;;GAGG;AACH,wBAAsB,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,iBA8BxD"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/migrations/v2.0/index.ts"],"names":[],"mappings":"AA6CA;;;;;;;;;;GAUG;AACH,wBAAsB,UAAU,CAAC,WAAW,EAAE,OAAO,iBAgCpD"}