@opencrvs/toolkit 2.1.0-rc.12673aa → 2.1.0-rc.14fb6a5

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 (188) hide show
  1. package/build.sh +14 -4
  2. package/create-countryconfig/index.js +59 -30
  3. package/dist/application-config/index.js +26 -13
  4. package/dist/authentication/index.d.ts +8 -9
  5. package/dist/authentication/index.js +23 -8
  6. package/dist/cli.js +2268 -1385
  7. package/dist/commons/api/router.d.ts +252 -290
  8. package/dist/commons/application-config/index.d.ts +0 -2
  9. package/dist/commons/conditionals/conditionals.d.ts +6 -6
  10. package/dist/commons/conditionals/validate.d.ts +18 -3
  11. package/dist/commons/events/ActionConfig.d.ts +5 -14
  12. package/dist/commons/events/ActionDocument.d.ts +30 -4
  13. package/dist/commons/events/AdvancedSearchConfig.d.ts +24 -12
  14. package/dist/commons/events/AuditLog.d.ts +1 -0
  15. package/dist/commons/events/Draft.d.ts +1 -21
  16. package/dist/commons/events/EventDocument.d.ts +4 -4
  17. package/dist/commons/events/FieldConfig.d.ts +20 -10
  18. package/dist/commons/events/FieldTypeMapping.d.ts +10 -10
  19. package/dist/commons/events/FieldValue.d.ts +1 -0
  20. package/dist/commons/events/FormConfig.d.ts +6 -0
  21. package/dist/commons/events/PageConfig.d.ts +4 -0
  22. package/dist/commons/events/scopes.d.ts +21 -1
  23. package/dist/commons/events/test.utils.d.ts +53 -21
  24. package/dist/commons/events/utils.d.ts +26 -2
  25. package/dist/conditionals/index.js +21 -7
  26. package/dist/environment/index.d.ts.map +1 -1
  27. package/dist/environment/index.js +2 -1
  28. package/dist/environment/setup-environment.d.ts +1 -1
  29. package/dist/environment/setup-environment.d.ts.map +1 -1
  30. package/dist/environment/setup-environment.js +586 -569
  31. package/dist/environment/swarm-to-k8s.js +3 -4
  32. package/dist/events/index.js +282 -138
  33. package/dist/migrations/v2.1/add-recovery-link-notifications.js +4 -4
  34. package/dist/migrations/v2.1/add-translations.d.ts.map +1 -1
  35. package/dist/migrations/v2.1/add-translations.js +4 -68
  36. package/dist/migrations/v2.1/enable-telemetry.d.ts.map +1 -1
  37. package/dist/migrations/v2.1/enable-telemetry.js +30 -13
  38. package/dist/migrations/v2.1/index.d.ts.map +1 -1
  39. package/dist/migrations/v2.1/index.js +927 -33
  40. package/dist/migrations/v2.1/migrate-infrastructure-to-assets.d.ts +14 -0
  41. package/dist/migrations/v2.1/migrate-infrastructure-to-assets.d.ts.map +1 -0
  42. package/dist/migrations/v2.1/migrate-infrastructure-to-assets.js +348 -0
  43. package/dist/migrations/v2.1/remove-metabase-package-installs.d.ts +2 -0
  44. package/dist/migrations/v2.1/remove-metabase-package-installs.d.ts.map +1 -0
  45. package/dist/migrations/v2.1/remove-metabase-package-installs.js +161 -0
  46. package/dist/migrations/{v2.0/migrate-scopes.d.ts → v2.1/remove-sentry.d.ts} +1 -1
  47. package/dist/migrations/v2.1/remove-sentry.d.ts.map +1 -0
  48. package/dist/migrations/v2.1/remove-sentry.js +354 -0
  49. package/dist/migrations/{v2.0/rename-api-paths.d.ts → v2.1/rename-trigger-paths.d.ts} +1 -1
  50. package/dist/migrations/v2.1/rename-trigger-paths.d.ts.map +1 -0
  51. package/dist/migrations/{v2.0/rename-api-paths.js → v2.1/rename-trigger-paths.js} +69 -40
  52. package/dist/migrations/v2.1/template-files.d.ts +8 -0
  53. package/dist/migrations/v2.1/template-files.d.ts.map +1 -0
  54. package/dist/migrations/v2.1/template-files.js +49 -0
  55. package/dist/migrations/v2.1/upgrade-tilt.d.ts +8 -0
  56. package/dist/migrations/v2.1/upgrade-tilt.d.ts.map +1 -0
  57. package/dist/migrations/v2.1/upgrade-tilt.js +139 -0
  58. package/dist/notification/index.js +105 -61
  59. package/dist/scopes/index.d.ts +288 -5
  60. package/dist/scopes/index.js +22 -7
  61. package/dist/telemetry/index.js +4 -0
  62. package/dist/templates/charts-values/dependencies/values.yaml +6 -0
  63. package/dist/templates/charts-values/opencrvs-services/values.yaml +6 -0
  64. package/dist/templates/charts-values/opentelemetry/values.yaml +7 -0
  65. package/dist/templates/countryconfig-template/.tiltignore +1 -0
  66. package/dist/templates/countryconfig-template/Dockerfile.assets +7 -0
  67. package/dist/templates/countryconfig-template/Tiltfile +112 -0
  68. package/dist/templates/countryconfig-template/assets/README.md +1 -0
  69. package/dist/templates/countryconfig-template/assets/clear-all-data-dev.sh +61 -0
  70. package/dist/templates/countryconfig-template/assets/deployment/deploy.sh +455 -0
  71. package/dist/templates/countryconfig-template/assets/deployment/reindex.sh +168 -0
  72. package/dist/templates/countryconfig-template/assets/deployment/validate-required-variables-in-compose-files.ts +67 -0
  73. package/dist/templates/countryconfig-template/assets/elasticsearch/reindex.sh +168 -0
  74. package/dist/templates/countryconfig-template/assets/metabase/README.md +34 -0
  75. package/dist/templates/countryconfig-template/assets/metabase/environment-configuration.sql +36 -0
  76. package/dist/templates/countryconfig-template/assets/metabase/initialize-database.sh +46 -0
  77. package/dist/templates/countryconfig-template/assets/metabase/metabase.init.db.sql +27737 -0
  78. package/dist/templates/countryconfig-template/assets/metabase/open-shell.sh +21 -0
  79. package/dist/templates/countryconfig-template/assets/metabase/package.json +13 -0
  80. package/dist/templates/countryconfig-template/assets/metabase/run-dev.sh +108 -0
  81. package/dist/templates/countryconfig-template/assets/metabase/run.sh +120 -0
  82. package/dist/templates/countryconfig-template/assets/metabase/update-database.sh +40 -0
  83. package/dist/templates/countryconfig-template/assets/postgres/setup-analytics.sh +135 -0
  84. package/dist/templates/countryconfig-template/assets/postgres/setup-reference-data.sh +108 -0
  85. package/dist/templates/countryconfig-template/tilt/clear-all-data.ps1 +50 -0
  86. package/dist/templates/countryconfig-template/tilt/clear-all-data.sh +35 -0
  87. package/dist/templates/countryconfig-template/tilt/common.tilt +145 -0
  88. package/dist/templates/countryconfig-template/tilt/examples/dependencies/values.yaml +15 -0
  89. package/dist/templates/countryconfig-template/tilt/examples/opencrvs-services/values.yaml +56 -0
  90. package/dist/templates/countryconfig-template/tilt/examples/traefik/values-minikube.yaml +21 -0
  91. package/dist/templates/countryconfig-template/tilt/examples/traefik/values.yaml +38 -0
  92. package/dist/templates/countryconfig-template/tilt/helm/dependencies/values.yaml +17 -0
  93. package/dist/templates/countryconfig-template/tilt/helm/opencrvs-services/values.yaml +16 -0
  94. package/dist/templates/countryconfig-template/tilt/lib.tilt +95 -0
  95. package/dist/templates/countryconfig-template/tilt/opencrvs.tilt +136 -0
  96. package/dist/translations/template.d.ts +11 -0
  97. package/dist/translations/template.d.ts.map +1 -0
  98. package/dist/translations/template.js +100 -0
  99. package/dist/verify/endpoints.d.ts.map +1 -1
  100. package/dist/verify/endpoints.js +179 -14
  101. package/opencrvs-toolkit-2.1.0-rc.14fb6a5.tgz +0 -0
  102. package/package.json +2 -1
  103. package/tsconfig.build.tsbuildinfo +1 -1
  104. package/dist/migrations/v2.0/add-birth-certificate-issuance-flag.d.ts +0 -3
  105. package/dist/migrations/v2.0/add-birth-certificate-issuance-flag.d.ts.map +0 -1
  106. package/dist/migrations/v2.0/add-birth-certificate-issuance-flag.js +0 -429
  107. package/dist/migrations/v2.0/add-resend-invite-notification.d.ts +0 -3
  108. package/dist/migrations/v2.0/add-resend-invite-notification.d.ts.map +0 -1
  109. package/dist/migrations/v2.0/add-resend-invite-notification.js +0 -373
  110. package/dist/migrations/v2.0/checkout-upstream-files.d.ts +0 -22
  111. package/dist/migrations/v2.0/checkout-upstream-files.d.ts.map +0 -1
  112. package/dist/migrations/v2.0/checkout-upstream-files.js +0 -146
  113. package/dist/migrations/v2.0/convert-config-files-to-ts.d.ts +0 -2
  114. package/dist/migrations/v2.0/convert-config-files-to-ts.d.ts.map +0 -1
  115. package/dist/migrations/v2.0/convert-config-files-to-ts.js +0 -838
  116. package/dist/migrations/v2.0/convert-paragraph-to-heading.d.ts +0 -3
  117. package/dist/migrations/v2.0/convert-paragraph-to-heading.d.ts.map +0 -1
  118. package/dist/migrations/v2.0/convert-paragraph-to-heading.js +0 -158
  119. package/dist/migrations/v2.0/create-events-index.d.ts +0 -3
  120. package/dist/migrations/v2.0/create-events-index.d.ts.map +0 -1
  121. package/dist/migrations/v2.0/create-events-index.js +0 -325
  122. package/dist/migrations/v2.0/delete-infrastructure-directory.d.ts +0 -11
  123. package/dist/migrations/v2.0/delete-infrastructure-directory.d.ts.map +0 -1
  124. package/dist/migrations/v2.0/delete-infrastructure-directory.js +0 -123
  125. package/dist/migrations/v2.0/fix-accept-requested-registration-function-type.d.ts +0 -3
  126. package/dist/migrations/v2.0/fix-accept-requested-registration-function-type.d.ts.map +0 -1
  127. package/dist/migrations/v2.0/fix-accept-requested-registration-function-type.js +0 -110
  128. package/dist/migrations/v2.0/index.d.ts +0 -13
  129. package/dist/migrations/v2.0/index.d.ts.map +0 -1
  130. package/dist/migrations/v2.0/index.js +0 -103
  131. package/dist/migrations/v2.0/make-built-in-validate-actions-custom.d.ts +0 -3
  132. package/dist/migrations/v2.0/make-built-in-validate-actions-custom.d.ts.map +0 -1
  133. package/dist/migrations/v2.0/make-built-in-validate-actions-custom.js +0 -432
  134. package/dist/migrations/v2.0/merge-infrastructure-directory.d.ts +0 -13
  135. package/dist/migrations/v2.0/merge-infrastructure-directory.d.ts.map +0 -1
  136. package/dist/migrations/v2.0/merge-infrastructure-directory.js +0 -222
  137. package/dist/migrations/v2.0/migrate-application-config-url.d.ts +0 -3
  138. package/dist/migrations/v2.0/migrate-application-config-url.d.ts.map +0 -1
  139. package/dist/migrations/v2.0/migrate-application-config-url.js +0 -343
  140. package/dist/migrations/v2.0/migrate-scopes.d.ts.map +0 -1
  141. package/dist/migrations/v2.0/migrate-scopes.js +0 -305
  142. package/dist/migrations/v2.0/migrate-validated-workqueue-status-to-flag.d.ts +0 -3
  143. package/dist/migrations/v2.0/migrate-validated-workqueue-status-to-flag.d.ts.map +0 -1
  144. package/dist/migrations/v2.0/migrate-validated-workqueue-status-to-flag.js +0 -267
  145. package/dist/migrations/v2.0/migrate-workqueue-configs.d.ts +0 -3
  146. package/dist/migrations/v2.0/migrate-workqueue-configs.d.ts.map +0 -1
  147. package/dist/migrations/v2.0/migrate-workqueue-configs.js +0 -317
  148. package/dist/migrations/v2.0/remove-delete-actions.d.ts +0 -3
  149. package/dist/migrations/v2.0/remove-delete-actions.d.ts.map +0 -1
  150. package/dist/migrations/v2.0/remove-delete-actions.js +0 -156
  151. package/dist/migrations/v2.0/remove-demo-scope.d.ts +0 -3
  152. package/dist/migrations/v2.0/remove-demo-scope.d.ts.map +0 -1
  153. package/dist/migrations/v2.0/remove-demo-scope.js +0 -74
  154. package/dist/migrations/v2.0/remove-deprecated-imports.d.ts +0 -3
  155. package/dist/migrations/v2.0/remove-deprecated-imports.d.ts.map +0 -1
  156. package/dist/migrations/v2.0/remove-deprecated-imports.js +0 -96
  157. package/dist/migrations/v2.0/remove-fhir-url-helpers.d.ts +0 -3
  158. package/dist/migrations/v2.0/remove-fhir-url-helpers.d.ts.map +0 -1
  159. package/dist/migrations/v2.0/remove-fhir-url-helpers.js +0 -163
  160. package/dist/migrations/v2.0/remove-hearth-migrations.d.ts +0 -3
  161. package/dist/migrations/v2.0/remove-hearth-migrations.d.ts.map +0 -1
  162. package/dist/migrations/v2.0/remove-hearth-migrations.js +0 -87
  163. package/dist/migrations/v2.0/remove-old-statistics-service.d.ts +0 -3
  164. package/dist/migrations/v2.0/remove-old-statistics-service.d.ts.map +0 -1
  165. package/dist/migrations/v2.0/remove-old-statistics-service.js +0 -356
  166. package/dist/migrations/v2.0/remove-pending-certification-flag.d.ts +0 -3
  167. package/dist/migrations/v2.0/remove-pending-certification-flag.d.ts.map +0 -1
  168. package/dist/migrations/v2.0/remove-pending-certification-flag.js +0 -109
  169. package/dist/migrations/v2.0/remove-review-from-register-action.d.ts +0 -3
  170. package/dist/migrations/v2.0/remove-review-from-register-action.d.ts.map +0 -1
  171. package/dist/migrations/v2.0/remove-review-from-register-action.js +0 -163
  172. package/dist/migrations/v2.0/remove-unused-environment-variables.d.ts +0 -3
  173. package/dist/migrations/v2.0/remove-unused-environment-variables.d.ts.map +0 -1
  174. package/dist/migrations/v2.0/remove-unused-environment-variables.js +0 -186
  175. package/dist/migrations/v2.0/rename-api-paths.d.ts.map +0 -1
  176. package/dist/migrations/v2.0/rename-location-parent-id.d.ts +0 -3
  177. package/dist/migrations/v2.0/rename-location-parent-id.d.ts.map +0 -1
  178. package/dist/migrations/v2.0/rename-location-parent-id.js +0 -180
  179. package/dist/migrations/v2.0/simplify-analytics-precalculations.d.ts +0 -3
  180. package/dist/migrations/v2.0/simplify-analytics-precalculations.d.ts.map +0 -1
  181. package/dist/migrations/v2.0/simplify-analytics-precalculations.js +0 -195
  182. package/dist/migrations/v2.0/update-package-json.d.ts +0 -3
  183. package/dist/migrations/v2.0/update-package-json.d.ts.map +0 -1
  184. package/dist/migrations/v2.0/update-package-json.js +0 -105
  185. package/dist/translations/check.d.ts +0 -21
  186. package/dist/translations/check.d.ts.map +0 -1
  187. package/dist/translations/check.js +0 -132
  188. package/opencrvs-toolkit-2.1.0-rc.12673aa.tgz +0 -0
@@ -0,0 +1,139 @@
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. Move chart overrides into ${COUNTRY_OWNED_DIR}`);
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
+ }
@@ -338,7 +338,9 @@ var RecordScopeTypeV2 = z7.enum([
338
338
  "record.request-correction",
339
339
  "record.correct",
340
340
  "record.unassign-others",
341
- "record.custom-action"
341
+ "record.custom-action",
342
+ "record.action.accept",
343
+ "record.action.reject"
342
344
  ]);
343
345
  var PlainScopeType = z7.enum([
344
346
  // Misc. system scopes
@@ -360,10 +362,7 @@ var PlainScopeType = z7.enum([
360
362
  // Performance dashboard
361
363
  "performance.read",
362
364
  "performance.read-dashboards",
363
- "performance.vital-statistics-export",
364
- // Scopes used exclusively by countryconfig integration token
365
- "record.confirm-registration",
366
- "record.reject-registration"
365
+ "performance.vital-statistics-export"
367
366
  ]);
368
367
  var scopeByEvent = z7.preprocess(
369
368
  (val) => val === void 0 ? void 0 : [val].flat(),
@@ -381,7 +380,9 @@ var userRole = z7.preprocess(
381
380
  ).describe("User role, e.g. admin, field agent");
382
381
  var scopeOptionsPlaceEvent = z7.object({
383
382
  event: scopeByEvent,
384
- placeOfEvent: JurisdictionFilter.optional()
383
+ placeOfEvent: JurisdictionFilter.optional(),
384
+ createdBy: UserFilter.optional(),
385
+ createdIn: JurisdictionFilter.optional()
385
386
  }).describe("Options applicable to all record scopes.");
386
387
  var scopeOptionsDeclaredOrNotified = scopeOptionsPlaceEvent.extend({
387
388
  notifiedIn: JurisdictionFilter.optional(),
@@ -424,7 +425,9 @@ var AllScopeOptions = z7.object({
424
425
  var ScopeOptionKey = AllScopeOptions.keyof();
425
426
  var ResolvedScopeOptionsPlaceEvent = z7.object({
426
427
  event: scopeByEvent,
427
- placeOfEvent: UUID.nullish()
428
+ placeOfEvent: UUID.nullish(),
429
+ createdBy: z7.string().optional(),
430
+ createdIn: UUID.nullish()
428
431
  }).describe(
429
432
  "Resolved options applicable to all record scopes, with location ID instead of jurisdiction filter."
430
433
  );
@@ -471,6 +474,13 @@ var ScopeOptionsPrintCertifiedCopies = AllRecordScopeOptions.extend({
471
474
  "Template IDs for certified copies. Controls which certificate templates are returned to the client via the config service. Certificate printing is a client-side operation \u2014 this option is not validated when the printCertificate action is submitted."
472
475
  )
473
476
  });
477
+ var ActionConfirmationScopeType = RecordScopeTypeV2.extract([
478
+ "record.action.accept",
479
+ "record.action.reject"
480
+ ]);
481
+ var ActionConfirmationScopeOptions = AllRecordScopeOptions.describe(
482
+ "Options for confirming (accepting or rejecting) an action."
483
+ );
474
484
  var RecordScopeV2 = z7.discriminatedUnion("type", [
475
485
  z7.object({
476
486
  type: ScopesWithPlaceEventOptions,
@@ -491,6 +501,10 @@ var RecordScopeV2 = z7.discriminatedUnion("type", [
491
501
  z7.object({
492
502
  type: z7.literal("record.print-certified-copies"),
493
503
  options: ScopeOptionsPrintCertifiedCopies.optional()
504
+ }),
505
+ z7.object({
506
+ type: ActionConfirmationScopeType,
507
+ options: ActionConfirmationScopeOptions.optional()
494
508
  })
495
509
  ]).describe(
496
510
  "Scopes used to check user's permission to perform actions on a record."
@@ -766,6 +780,7 @@ var AttachmentUploadEntrySchema = AuditLogEntryBase.extend({
766
780
  operation: z9.literal("attachments.upload"),
767
781
  requestData: z9.object({
768
782
  transactionId: z9.string(),
783
+ eventId: z9.string().optional(),
769
784
  path: z9.string().nullable()
770
785
  }),
771
786
  responseSummary: z9.object({ fileUrl: z9.string() })
@@ -1080,8 +1095,9 @@ var TextValue = z14.string();
1080
1095
  var HiddenFieldValue = z14.string();
1081
1096
  var NonEmptyTextValue = z14.string().trim().min(1);
1082
1097
  var DateValue = z14.iso.date().describe("Date in the format YYYY-MM-DD");
1098
+ var AGE_MAX_VALUE = 999;
1083
1099
  var AgeValue = z14.object({
1084
- age: z14.number(),
1100
+ age: z14.number().int().min(0).max(AGE_MAX_VALUE),
1085
1101
  asOfDateRef: z14.string()
1086
1102
  });
1087
1103
  var AgeUpdateValue = AgeValue.optional().nullable();
@@ -1411,7 +1427,7 @@ var RequestedCorrectionAction = ActionBase.extend(
1411
1427
  var ApprovedCorrectionAction = ActionBase.extend(
1412
1428
  z16.object({
1413
1429
  type: z16.literal(ActionType.APPROVE_CORRECTION),
1414
- requestId: z16.string(),
1430
+ requestId: UUID,
1415
1431
  // TODO move into 'content' property
1416
1432
  content: z16.object({ immediateCorrection: z16.boolean().optional() }).optional()
1417
1433
  }).shape
@@ -1419,7 +1435,7 @@ var ApprovedCorrectionAction = ActionBase.extend(
1419
1435
  var RejectedCorrectionAction = ActionBase.extend(
1420
1436
  z16.object({
1421
1437
  type: z16.literal(ActionType.REJECT_CORRECTION),
1422
- requestId: z16.string(),
1438
+ requestId: UUID,
1423
1439
  // TODO move into 'content' property
1424
1440
  content: ReasonContent
1425
1441
  }).shape
@@ -2665,6 +2681,9 @@ var PageConfigBase = z22.object({
2665
2681
  requireCompletionToContinue: z22.boolean().default(false).describe(
2666
2682
  "If true, all required fields must be filled before continuing to the next page"
2667
2683
  ),
2684
+ showClearButton: z22.boolean().optional().describe(
2685
+ 'If true, a "Clear" button is shown at the top of the page allowing the user to reset all fields on the page to their default state'
2686
+ ),
2668
2687
  fields: z22.array(FieldConfig).describe("Fields to be rendered on the page"),
2669
2688
  conditional: Conditional.optional().describe(
2670
2689
  "Page will be shown if condition is met. If conditional is not defined, the page will be always shown."
@@ -2845,7 +2864,10 @@ var ReadActionConfig = ActionConfigBase.extend(
2845
2864
  review: DeclarationReviewConfig.describe(
2846
2865
  "Configuration of the review page for read-only view."
2847
2866
  ),
2848
- conditionals: z25.never().optional().describe("Read-action can not be disabled or hidden with conditionals.")
2867
+ conditionals: z25.never().optional().describe("Read-action can not be disabled or hidden with conditionals."),
2868
+ flags: z25.never().optional().describe(
2869
+ "READ is a meta action excluded from flag resolution, so flags configured here would never apply."
2870
+ )
2849
2871
  }).shape
2850
2872
  );
2851
2873
  var NotifyConfig = ActionConfigBase.extend(
@@ -3277,7 +3299,7 @@ var ReferenceField = BaseField2.extend({
3277
3299
  var Field = BaseField2.extend({
3278
3300
  id: z29.string().describe("Identifier of the summary field."),
3279
3301
  value: TranslationConfig.describe(
3280
- 'Field value template supporting variables from configuration and EventMetadata (e.g. "{informant.phoneNo} {informant.email}").'
3302
+ 'Field value template supports variables from configuration (e.g. "{informant.phoneNo} {informant.email}") and EventMetadata (e.g. "{event.legalStatuses.REGISTERED.acceptedAt, date, ::dd MMMM yyyy}").'
3281
3303
  ),
3282
3304
  label: TranslationConfig
3283
3305
  }).describe("Custom field defined for the summary view.");
@@ -3467,21 +3489,23 @@ function omitKeyDeep(obj, keyToRemove) {
3467
3489
 
3468
3490
  // ../commons/src/events/state/utils.ts
3469
3491
  var import_lodash = require("lodash");
3470
- var updateActions = ActionTypes.extract([
3471
- ActionType.CREATE,
3472
- ActionType.NOTIFY,
3473
- ActionType.EDIT,
3474
- ActionType.DECLARE,
3475
- ActionType.REGISTER,
3476
- ActionType.REJECT,
3477
- ActionType.ARCHIVE,
3478
- ActionType.UNARCHIVE,
3479
- ActionType.PRINT_CERTIFICATE,
3480
- ActionType.REQUEST_CORRECTION,
3481
- ActionType.APPROVE_CORRECTION,
3482
- ActionType.REJECT_CORRECTION,
3483
- ActionType.CUSTOM
3484
- ]);
3492
+ var updateActions = new Set(
3493
+ ActionTypes.extract([
3494
+ ActionType.CREATE,
3495
+ ActionType.NOTIFY,
3496
+ ActionType.EDIT,
3497
+ ActionType.DECLARE,
3498
+ ActionType.REGISTER,
3499
+ ActionType.REJECT,
3500
+ ActionType.ARCHIVE,
3501
+ ActionType.UNARCHIVE,
3502
+ ActionType.PRINT_CERTIFICATE,
3503
+ ActionType.REQUEST_CORRECTION,
3504
+ ActionType.APPROVE_CORRECTION,
3505
+ ActionType.REJECT_CORRECTION,
3506
+ ActionType.CUSTOM
3507
+ ]).options
3508
+ );
3485
3509
 
3486
3510
  // ../commons/src/events/state/flags.ts
3487
3511
  var import_lodash2 = require("lodash");
@@ -5067,7 +5091,14 @@ var Draft = z40.object({
5067
5091
  "A temporary storage for an action. Stored with details of the event, creator and creation time."
5068
5092
  );
5069
5093
  var DraftInput = BaseActionInput.omit({ waitFor: true }).extend({
5070
- type: ActionTypes.exclude([ActionTypes.enum.DELETE]),
5094
+ /*
5095
+ * A draft can name a file that no action references. Such a file stays until
5096
+ * the record is deleted or the record's next action sweeps its prefix.
5097
+ * DECLARE is available only where one of those is still coming: a created
5098
+ * record, which can still be deleted, and a record part way through an edit,
5099
+ * which is about to be declared or registered.
5100
+ */
5101
+ type: z40.literal(ActionTypes.enum.DECLARE),
5071
5102
  status: z40.enum([
5072
5103
  ActionStatus.Requested,
5073
5104
  ActionStatus.Accepted,
@@ -5105,38 +5136,8 @@ var EventDocumentOnlyLastAction = EventDocument.extend({
5105
5136
  }).brand("EventDocumentOnlyLastAction");
5106
5137
 
5107
5138
  // ../commons/src/events/defineConfig.ts
5108
- var IGNORED_EVENT_TYPES = [
5109
- "FOOTBALL_CLUB_MEMBERSHIP",
5110
- "tennis-club-membership",
5111
- "library-membership",
5112
- "child-onboarding",
5113
- "digital-identity",
5114
- "event-with-optional-address"
5115
- ];
5116
- function warnOnConfigurationIssues(config) {
5117
- const eventId = config.id;
5118
- if (IGNORED_EVENT_TYPES.includes(eventId)) {
5119
- return;
5120
- }
5121
- const validateDeclarationAction = config.actions.find(
5122
- (action) => action.type === ActionType.CUSTOM && action.customActionType === "VALIDATE_DECLARATION"
5123
- );
5124
- if (!validateDeclarationAction) {
5125
- console.warn(
5126
- `
5127
- ************** WARNING **************
5128
- A custom action with customActionType 'VALIDATE_DECLARATION' is not defined for event '${eventId}'!
5129
- For v2.0, we expect this to be defined for all events.
5130
-
5131
- The deprecated v1.9 'ActionType.VALIDATE' actions are migrated to customActionType 'VALIDATE_DECLARATION' in v2.0.
5132
- ************** WARNING **************
5133
- `
5134
- );
5135
- }
5136
- }
5137
5139
  var defineConfig = (config) => {
5138
5140
  const input = EventConfig.parse(config);
5139
- warnOnConfigurationIssues(input);
5140
5141
  return input;
5141
5142
  };
5142
5143
 
@@ -5827,6 +5828,21 @@ var TENNIS_CLUB_DECLARATION_REVIEW = {
5827
5828
  description: "Title of the review page"
5828
5829
  },
5829
5830
  fields: [
5831
+ {
5832
+ id: "annotation.hidden",
5833
+ type: FieldType.TEXT,
5834
+ label: {
5835
+ id: "annotation.hidden.label",
5836
+ defaultMessage: "Show not be visible",
5837
+ description: "Catch for rendering"
5838
+ },
5839
+ conditionals: [
5840
+ {
5841
+ type: ConditionalType.SHOW,
5842
+ conditional: never2()
5843
+ }
5844
+ ]
5845
+ },
5830
5846
  {
5831
5847
  id: "review.comment",
5832
5848
  type: FieldType.TEXTAREA,
@@ -5883,7 +5899,23 @@ var TENNIS_CLUB_DECLARATION_FORM = defineDeclarationForm({
5883
5899
  defaultMessage: "Who is applying for the membership?",
5884
5900
  description: "This is the title of the section"
5885
5901
  },
5902
+ showClearButton: true,
5886
5903
  fields: [
5904
+ {
5905
+ id: "declaration.hidden",
5906
+ type: FieldType.TEXT,
5907
+ label: {
5908
+ id: "declaration.hidden.label",
5909
+ defaultMessage: "Show not be visible",
5910
+ description: "Catch for rendering"
5911
+ },
5912
+ conditionals: [
5913
+ {
5914
+ type: ConditionalType.SHOW,
5915
+ conditional: never2()
5916
+ }
5917
+ ]
5918
+ },
5887
5919
  {
5888
5920
  id: "applicant.name",
5889
5921
  type: FieldType.NAME,
@@ -8029,6 +8061,9 @@ var ACTION_SCOPE_MAP = {
8029
8061
  [ActionType.DUPLICATE_DETECTED]: [],
8030
8062
  [ActionType.CUSTOM]: []
8031
8063
  };
8064
+ var RECORD_WRITE_SCOPES = (0, import_lodash6.uniq)(
8065
+ Object.entries(ACTION_SCOPE_MAP).filter(([action]) => action !== ActionType.READ).flatMap(([, scopes]) => scopes ?? [])
8066
+ );
8032
8067
 
8033
8068
  // ../commons/src/events/state/availableActions.ts
8034
8069
  var AVAILABLE_ACTIONS_BY_EVENT_STATUS = {
@@ -8266,7 +8301,7 @@ function buildLoggerOptions() {
8266
8301
  hooks: { logMethod: filterHealthCheckLogs }
8267
8302
  };
8268
8303
  }
8269
- var logger = false ? (0, import_pino.default)({
8304
+ var logger = process.env.NODE_ENV === "production" ? (0, import_pino.default)({
8270
8305
  level: "info",
8271
8306
  redact: [
8272
8307
  "req.headers.authorization",
@@ -8285,7 +8320,7 @@ var logger = false ? (0, import_pino.default)({
8285
8320
  },
8286
8321
  ...buildLoggerOptions()
8287
8322
  });
8288
- var level = false ? "silent" : process.env.LOG_LEVEL;
8323
+ var level = process.env.NODE_ENV === "test" ? "silent" : process.env.LOG_LEVEL;
8289
8324
  if (level) {
8290
8325
  logger.level = level;
8291
8326
  }
@@ -8298,7 +8333,7 @@ async function triggerUserEventNotification({
8298
8333
  authHeader
8299
8334
  }) {
8300
8335
  const response = await fetch(
8301
- joinUrl(countryConfigUrl, `triggers/user/${event2}`),
8336
+ joinUrl(countryConfigUrl, `trigger/user/${event2}`),
8302
8337
  {
8303
8338
  method: "POST",
8304
8339
  body: JSON.stringify(payload),
@@ -8318,3 +8353,12 @@ async function triggerUserEventNotification({
8318
8353
 
8319
8354
  // src/notification/index.ts
8320
8355
  z47.globalRegistry.clear();
8356
+ // Annotate the CommonJS export names for ESM import in node:
8357
+ 0 && (module.exports = {
8358
+ BasePayload,
8359
+ Recipient,
8360
+ TriggerEvent,
8361
+ TriggerPayload,
8362
+ parseUserEventTrigger,
8363
+ triggerUserEventNotification
8364
+ });