@opencrvs/toolkit 2.2.0-rc.9042a13 → 2.2.0-rc.9dfc125

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/dist/application-config/index.js +12 -7
  3. package/dist/authentication/index.d.ts +1 -0
  4. package/dist/authentication/index.js +16 -5
  5. package/dist/cli.js +875 -193
  6. package/dist/commons/api/router.d.ts +252 -246
  7. package/dist/commons/application-config/index.d.ts +2 -2
  8. package/dist/commons/conditionals/index.d.ts +1 -0
  9. package/dist/commons/conditionals/validate.d.ts +5 -0
  10. package/dist/commons/events/ActionConfig.d.ts +16 -23
  11. package/dist/commons/events/ActionDocument.d.ts +1 -0
  12. package/dist/commons/events/ActionInput.d.ts +4 -4
  13. package/dist/commons/events/CompositeFieldValue.d.ts +5 -1
  14. package/dist/commons/events/CountryConfigQueryInput.d.ts +60 -18
  15. package/dist/commons/events/EventConfig.d.ts +12 -2
  16. package/dist/commons/events/EventIndex.d.ts +23 -6
  17. package/dist/commons/events/EventMetadata.d.ts +0 -1
  18. package/dist/commons/events/FieldConfig.d.ts +1 -1
  19. package/dist/commons/events/FieldTypeMapping.d.ts +6 -6
  20. package/dist/commons/events/Flag.d.ts +1 -7
  21. package/dist/commons/events/PlainDate.d.ts +1 -0
  22. package/dist/commons/events/WorkqueueConfig.d.ts +74 -27
  23. package/dist/commons/events/eventConfigValidation.d.ts +9 -0
  24. package/dist/commons/events/index.d.ts +2 -0
  25. package/dist/commons/events/notificationFormFallback.d.ts +10 -0
  26. package/dist/commons/events/state/flags.d.ts +1 -1
  27. package/dist/commons/events/test.utils.d.ts +3 -0
  28. package/dist/commons/events/utils.d.ts +85 -56
  29. package/dist/conditionals/index.js +2 -3
  30. package/dist/environment/custom-types.d.ts +1 -0
  31. package/dist/environment/custom-types.d.ts.map +1 -1
  32. package/dist/environment/derived-variables.d.ts +12 -4
  33. package/dist/environment/derived-variables.d.ts.map +1 -1
  34. package/dist/environment/derived-variables.js +13 -4
  35. package/dist/environment/questions.d.ts +14 -2
  36. package/dist/environment/questions.d.ts.map +1 -1
  37. package/dist/environment/questions.js +40 -19
  38. package/dist/environment/registry.d.ts +15 -0
  39. package/dist/environment/registry.d.ts.map +1 -0
  40. package/dist/environment/registry.js +112 -0
  41. package/dist/environment/setup-environment.d.ts.map +1 -1
  42. package/dist/environment/setup-environment.js +111 -24
  43. package/dist/environment/templates.d.ts.map +1 -1
  44. package/dist/events/index.js +251 -67
  45. package/dist/migrations/index.d.ts +9 -0
  46. package/dist/migrations/index.d.ts.map +1 -0
  47. package/dist/migrations/index.js +847 -0
  48. package/dist/migrations/move-declaration-to-declare-action.d.ts +38 -0
  49. package/dist/migrations/move-declaration-to-declare-action.d.ts.map +1 -0
  50. package/dist/migrations/move-declaration-to-declare-action.js +377 -0
  51. package/dist/migrations/{add-translations.d.ts → persistent/add-translations.d.ts} +1 -1
  52. package/dist/migrations/persistent/add-translations.d.ts.map +1 -0
  53. package/dist/migrations/{add-translations.js → persistent/add-translations.js} +2 -2
  54. package/dist/migrations/persistent/check-upgrade-path.d.ts +36 -0
  55. package/dist/migrations/persistent/check-upgrade-path.d.ts.map +1 -0
  56. package/dist/migrations/persistent/check-upgrade-path.js +105 -0
  57. package/dist/migrations/persistent/update-toolkit-dependency.d.ts +7 -0
  58. package/dist/migrations/persistent/update-toolkit-dependency.d.ts.map +1 -0
  59. package/dist/migrations/persistent/update-toolkit-dependency.js +77 -0
  60. package/dist/migrations/{v2.2/read-declaration-through-helper.d.ts → read-declaration-through-helper.d.ts} +1 -1
  61. package/dist/migrations/read-declaration-through-helper.d.ts.map +1 -0
  62. package/dist/migrations/{v2.2/read-declaration-through-helper.js → read-declaration-through-helper.js} +1 -1
  63. package/dist/migrations/replace-incomplete-flag.d.ts +26 -0
  64. package/dist/migrations/replace-incomplete-flag.d.ts.map +1 -0
  65. package/dist/migrations/replace-incomplete-flag.js +126 -0
  66. package/dist/notification/index.js +151 -21
  67. package/dist/scopes/index.d.ts +54 -84
  68. package/dist/scopes/index.js +12 -5
  69. package/dist/templates/charts-values/dependencies/values.yaml +1 -1
  70. package/dist/templates/charts-values/opencrvs-services/values.yaml +4 -6
  71. package/dist/templates/charts-values/traefik/values.yaml +2 -0
  72. package/opencrvs-toolkit-2.2.0-rc.9dfc125.tgz +0 -0
  73. package/package.json +2 -2
  74. package/tsconfig.build.tsbuildinfo +1 -1
  75. package/dist/migrations/add-translations.d.ts.map +0 -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/enable-telemetry.d.ts +0 -3
  83. package/dist/migrations/v2.1/enable-telemetry.d.ts.map +0 -1
  84. package/dist/migrations/v2.1/enable-telemetry.js +0 -455
  85. package/dist/migrations/v2.1/index.d.ts +0 -6
  86. package/dist/migrations/v2.1/index.d.ts.map +0 -1
  87. package/dist/migrations/v2.1/index.js +0 -50
  88. package/dist/migrations/v2.1/migrate-infrastructure-to-assets.d.ts +0 -17
  89. package/dist/migrations/v2.1/migrate-infrastructure-to-assets.d.ts.map +0 -1
  90. package/dist/migrations/v2.1/migrate-infrastructure-to-assets.js +0 -348
  91. package/dist/migrations/v2.1/remove-metabase-package-installs.d.ts +0 -2
  92. package/dist/migrations/v2.1/remove-metabase-package-installs.d.ts.map +0 -1
  93. package/dist/migrations/v2.1/remove-metabase-package-installs.js +0 -161
  94. package/dist/migrations/v2.1/remove-sentry.d.ts +0 -3
  95. package/dist/migrations/v2.1/remove-sentry.d.ts.map +0 -1
  96. package/dist/migrations/v2.1/remove-sentry.js +0 -354
  97. package/dist/migrations/v2.1/rename-trigger-paths.d.ts +0 -3
  98. package/dist/migrations/v2.1/rename-trigger-paths.d.ts.map +0 -1
  99. package/dist/migrations/v2.1/rename-trigger-paths.js +0 -216
  100. package/dist/migrations/v2.1/template-files.d.ts +0 -8
  101. package/dist/migrations/v2.1/template-files.d.ts.map +0 -1
  102. package/dist/migrations/v2.1/template-files.js +0 -49
  103. package/dist/migrations/v2.1/upgrade-tilt.d.ts +0 -11
  104. package/dist/migrations/v2.1/upgrade-tilt.d.ts.map +0 -1
  105. package/dist/migrations/v2.1/upgrade-tilt.js +0 -139
  106. package/dist/migrations/v2.2/index.d.ts +0 -6
  107. package/dist/migrations/v2.2/index.d.ts.map +0 -1
  108. package/dist/migrations/v2.2/index.js +0 -456
  109. package/dist/migrations/v2.2/read-declaration-through-helper.d.ts.map +0 -1
  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.2.0-rc.9042a13.tgz +0 -0
@@ -0,0 +1,77 @@
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.updateToolkitDependency = updateToolkitDependency;
26
+ exports.main = main;
27
+ /**
28
+ * Upgrade step: Point the country config's `@opencrvs/toolkit` dependency at
29
+ * the toolkit running the upgrade.
30
+ *
31
+ * Why:
32
+ * The upgrade checks which version it upgrades from by the toolkit version
33
+ * the country config depends on. Updating it here, rather than by hand before
34
+ * upgrading, keeps that version the one the country config was on until its
35
+ * steps have run.
36
+ *
37
+ * What it does:
38
+ * - Rewrites the version of `@opencrvs/toolkit` in `package.json`, keeping a
39
+ * `^` or `~` in front of it and the rest of the file as written
40
+ * - Leaves a version without a major.minor alone, as in `workspace:*`
41
+ */
42
+ const fs_1 = __importDefault(require("fs"));
43
+ const path_1 = __importDefault(require("path"));
44
+ const check_upgrade_path_1 = require("./check-upgrade-path");
45
+ const DEPENDENCY_PATTERN = new RegExp(`("${check_upgrade_path_1.TOOLKIT_PACKAGE_NAME}"\\s*:\\s*")([^"]*)(")`, 'g');
46
+ /**
47
+ * Returns the `package.json` text with its toolkit dependency set to the
48
+ * version, or undefined when there is nothing to update.
49
+ */
50
+ function updateToolkitDependency(packageJson, toolkitVersion) {
51
+ const updated = packageJson.replace(DEPENDENCY_PATTERN, (match, before, version, after) => {
52
+ var _a;
53
+ var _b;
54
+ if (!(0, check_upgrade_path_1.findMajorMinor)(version)) {
55
+ return match;
56
+ }
57
+ const range = (_b = (_a = /^[\^~]?/.exec(version)) === null || _a === void 0 ? void 0 : _a[0]) !== null && _b !== void 0 ? _b : '';
58
+ return `${before}${range}${toolkitVersion}${after}`;
59
+ });
60
+ return updated === packageJson ? undefined : updated;
61
+ }
62
+ function main(toolkitVersion) {
63
+ return __awaiter(this, void 0, void 0, function* () {
64
+ const packageJsonPath = path_1.default.join(process.cwd(), 'package.json');
65
+ if (!fs_1.default.existsSync(packageJsonPath)) {
66
+ console.log(`No package.json found. Skipping ${check_upgrade_path_1.TOOLKIT_PACKAGE_NAME}.`);
67
+ return;
68
+ }
69
+ const updated = updateToolkitDependency(fs_1.default.readFileSync(packageJsonPath, 'utf-8'), toolkitVersion);
70
+ if (!updated) {
71
+ console.log(`${check_upgrade_path_1.TOOLKIT_PACKAGE_NAME} in package.json needs no update. Nothing to do.`);
72
+ return;
73
+ }
74
+ fs_1.default.writeFileSync(packageJsonPath, updated);
75
+ console.log(`Updated ${check_upgrade_path_1.TOOLKIT_PACKAGE_NAME} to ${toolkitVersion} in package.json. Install the dependencies again to use it.`);
76
+ });
77
+ }
@@ -3,7 +3,7 @@
3
3
  * `getDeclaration()` instead of the top-level `declaration` property.
4
4
  *
5
5
  * Usage:
6
- * ts-node -r tsconfig-paths/register src/migrations/v2.2/read-declaration-through-helper.ts
6
+ * ts-node -r tsconfig-paths/register src/migrations/read-declaration-through-helper.ts
7
7
  *
8
8
  * Why:
9
9
  * As of v2.2 the declaration form lives on the DECLARE action. `defineConfig`
@@ -0,0 +1 @@
1
+ {"version":3,"file":"read-declaration-through-helper.d.ts","sourceRoot":"","sources":["../../src/migrations/read-declaration-through-helper.ts"],"names":[],"mappings":"AAWA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAEH,OAAO,EAIL,UAAU,EAGX,MAAM,UAAU,CAAA;AA8LjB;;;;;GAKG;AACH,wBAAgB,uBAAuB,CAAC,UAAU,EAAE,UAAU,GAAG,MAAM,CAqDtE;AAED,iBAAe,IAAI,kBA6ClB;AAED,OAAO,EAAE,IAAI,EAAE,CAAA"}
@@ -29,7 +29,7 @@ exports.main = main;
29
29
  * `getDeclaration()` instead of the top-level `declaration` property.
30
30
  *
31
31
  * Usage:
32
- * ts-node -r tsconfig-paths/register src/migrations/v2.2/read-declaration-through-helper.ts
32
+ * ts-node -r tsconfig-paths/register src/migrations/read-declaration-through-helper.ts
33
33
  *
34
34
  * Why:
35
35
  * As of v2.2 the declaration form lives on the DECLARE action. `defineConfig`
@@ -0,0 +1,26 @@
1
+ /**
2
+ * Codemod: replace the removed `incomplete` flag with the NOTIFIED status.
3
+ *
4
+ * Why:
5
+ * `InherentFlags.INCOMPLETE` mirrored the NOTIFIED status and has been
6
+ * removed. See CHANGELOG.md ("The `incomplete` flag is removed").
7
+ *
8
+ * What it does:
9
+ * - In every query object of the form
10
+ * `{ flags: { anyOf: [InherentFlags.INCOMPLETE, ...] }, ... }`, removes
11
+ * the flag (and `anyOf` / `flags` if left empty) and adds
12
+ * `status: { type: 'exact', term: EventStatus.enum.NOTIFIED }`
13
+ * - Imports `EventStatus` next to `InherentFlags` when missing
14
+ * - Lists any other `InherentFlags.INCOMPLETE` reference for manual update
15
+ */
16
+ import { SourceFile } from 'ts-morph';
17
+ /**
18
+ * Rewrites `flags.anyOf` uses of the incomplete flag in place.
19
+ * Returns the line numbers of references it could not rewrite.
20
+ */
21
+ export declare function replaceIncompleteFlag(sourceFile: SourceFile): {
22
+ changed: boolean;
23
+ remaining: number[];
24
+ };
25
+ export declare function main(): Promise<void>;
26
+ //# sourceMappingURL=replace-incomplete-flag.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"replace-incomplete-flag.d.ts","sourceRoot":"","sources":["../../src/migrations/replace-incomplete-flag.ts"],"names":[],"mappings":"AAWA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAiB,UAAU,EAAc,MAAM,UAAU,CAAA;AAsBhE;;;GAGG;AACH,wBAAgB,qBAAqB,CAAC,UAAU,EAAE,UAAU;;;EAuD3D;AAED,wBAAsB,IAAI,kBAwBzB"}
@@ -0,0 +1,126 @@
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.replaceIncompleteFlag = replaceIncompleteFlag;
26
+ exports.main = main;
27
+ /**
28
+ * Codemod: replace the removed `incomplete` flag with the NOTIFIED status.
29
+ *
30
+ * Why:
31
+ * `InherentFlags.INCOMPLETE` mirrored the NOTIFIED status and has been
32
+ * removed. See CHANGELOG.md ("The `incomplete` flag is removed").
33
+ *
34
+ * What it does:
35
+ * - In every query object of the form
36
+ * `{ flags: { anyOf: [InherentFlags.INCOMPLETE, ...] }, ... }`, removes
37
+ * the flag (and `anyOf` / `flags` if left empty) and adds
38
+ * `status: { type: 'exact', term: EventStatus.enum.NOTIFIED }`
39
+ * - Imports `EventStatus` next to `InherentFlags` when missing
40
+ * - Lists any other `InherentFlags.INCOMPLETE` reference for manual update
41
+ */
42
+ const ts_morph_1 = require("ts-morph");
43
+ const path_1 = __importDefault(require("path"));
44
+ const INCOMPLETE = 'InherentFlags.INCOMPLETE';
45
+ const NOTIFIED_STATUS = `{ type: 'exact', term: EventStatus.enum.NOTIFIED }`;
46
+ function ensureEventStatusImport(sourceFile) {
47
+ const importDeclaration = sourceFile
48
+ .getImportDeclarations()
49
+ .find((declaration) => declaration
50
+ .getNamedImports()
51
+ .some((named) => named.getName() === 'InherentFlags'));
52
+ const hasEventStatus = importDeclaration === null || importDeclaration === void 0 ? void 0 : importDeclaration.getNamedImports().some((named) => named.getName() === 'EventStatus');
53
+ if (importDeclaration && !hasEventStatus) {
54
+ importDeclaration.addNamedImport('EventStatus');
55
+ }
56
+ }
57
+ /**
58
+ * Rewrites `flags.anyOf` uses of the incomplete flag in place.
59
+ * Returns the line numbers of references it could not rewrite.
60
+ */
61
+ function replaceIncompleteFlag(sourceFile) {
62
+ let changed = false;
63
+ const anyOfIncomplete = sourceFile
64
+ .getDescendantsOfKind(ts_morph_1.SyntaxKind.PropertyAccessExpression)
65
+ .filter((node) => node.getText() === INCOMPLETE)
66
+ .map((node) => node.getParent())
67
+ .filter(ts_morph_1.Node.isArrayLiteralExpression)
68
+ .filter((array) => {
69
+ var _a;
70
+ const anyOf = array.getParent();
71
+ const flags = (_a = anyOf === null || anyOf === void 0 ? void 0 : anyOf.getParent()) === null || _a === void 0 ? void 0 : _a.getParent();
72
+ return (ts_morph_1.Node.isPropertyAssignment(anyOf) &&
73
+ anyOf.getName() === 'anyOf' &&
74
+ ts_morph_1.Node.isPropertyAssignment(flags) &&
75
+ flags.getName() === 'flags');
76
+ });
77
+ for (const array of anyOfIncomplete) {
78
+ const anyOf = array.getParentIfKindOrThrow(ts_morph_1.SyntaxKind.PropertyAssignment);
79
+ const flagsObject = anyOf.getParentIfKindOrThrow(ts_morph_1.SyntaxKind.ObjectLiteralExpression);
80
+ const flags = flagsObject.getParentIfKindOrThrow(ts_morph_1.SyntaxKind.PropertyAssignment);
81
+ const query = flags.getParentIfKindOrThrow(ts_morph_1.SyntaxKind.ObjectLiteralExpression);
82
+ array
83
+ .getElements()
84
+ .filter((element) => element.getText() === INCOMPLETE)
85
+ .forEach((element) => array.removeElement(element));
86
+ if (array.getElements().length === 0)
87
+ anyOf.remove();
88
+ if (flagsObject.getProperties().length === 0)
89
+ flags.remove();
90
+ if (!query.getProperty('status')) {
91
+ query.addPropertyAssignment({
92
+ name: 'status',
93
+ initializer: NOTIFIED_STATUS
94
+ });
95
+ }
96
+ changed = true;
97
+ }
98
+ if (changed)
99
+ ensureEventStatusImport(sourceFile);
100
+ const remaining = sourceFile
101
+ .getDescendantsOfKind(ts_morph_1.SyntaxKind.PropertyAccessExpression)
102
+ .filter((node) => node.getText() === INCOMPLETE)
103
+ .map((node) => node.getStartLineNumber());
104
+ return { changed, remaining };
105
+ }
106
+ function main() {
107
+ return __awaiter(this, void 0, void 0, function* () {
108
+ const project = new ts_morph_1.Project({
109
+ tsConfigFilePath: path_1.default.join(process.cwd(), 'tsconfig.json')
110
+ });
111
+ const sourceFiles = project
112
+ .getSourceFiles()
113
+ .filter((sf) => !sf.getFilePath().includes('/node_modules/'));
114
+ for (const sourceFile of sourceFiles) {
115
+ const relPath = path_1.default.relative(process.cwd(), sourceFile.getFilePath());
116
+ const { changed, remaining } = replaceIncompleteFlag(sourceFile);
117
+ if (changed) {
118
+ yield sourceFile.save();
119
+ console.log(` [${relPath}] Replaced the incomplete flag with the NOTIFIED status`);
120
+ }
121
+ for (const line of remaining) {
122
+ console.warn(` [${relPath}:${line}] ${INCOMPLETE} was removed, update this reference to use the NOTIFIED status`);
123
+ }
124
+ }
125
+ });
126
+ }
@@ -40,6 +40,9 @@ __export(notification_exports, {
40
40
  module.exports = __toCommonJS(notification_exports);
41
41
  var z48 = __toESM(require("zod/v4"));
42
42
 
43
+ // ../commons/src/events/index.ts
44
+ var import_compile = require("zod/compile");
45
+
43
46
  // ../commons/src/events/AuditLog.ts
44
47
  var z9 = __toESM(require("zod/v4"));
45
48
 
@@ -186,7 +189,7 @@ var ActionStatus = {
186
189
  };
187
190
 
188
191
  // ../commons/src/events/Flag.ts
189
- var z5 = __toESM(require("zod/v4"));
192
+ var z5 = __toESM(require("zod"));
190
193
 
191
194
  // ../commons/src/events/TranslationConfig.ts
192
195
  var z3 = __toESM(require("zod/v4"));
@@ -255,7 +258,6 @@ var FieldConditional = z4.discriminatedUnion("type", [
255
258
 
256
259
  // ../commons/src/events/Flag.ts
257
260
  var InherentFlags = {
258
- INCOMPLETE: "incomplete",
259
261
  REJECTED: "rejected",
260
262
  CORRECTION_REQUESTED: "correction-requested",
261
263
  POTENTIAL_DUPLICATE: "potential-duplicate",
@@ -283,7 +285,7 @@ var CustomFlag = z5.string().refine((val) => !Object.values(InherentFlags).inclu
283
285
  message: `Custom flag cannot be one of the inherent flags: ${Object.values(
284
286
  InherentFlags
285
287
  ).join(", ")}`
286
- }).refine((val) => !ActionFlag.safeParse(val).success, {
288
+ }).refine((val) => !ActionFlag.validate(val), {
287
289
  message: "Custom flag cannot match the ActionFlag pattern (ActionType:ActionStatus)."
288
290
  }).describe("Custom flag identifier defined by the country config.");
289
291
  var Flag = ActionFlag.or(z5.enum(InherentFlags)).or(CustomFlag);
@@ -997,7 +999,7 @@ var z14 = __toESM(require("zod/v4"));
997
999
  // ../commons/src/documents.ts
998
1000
  var z11 = __toESM(require("zod/v4"));
999
1001
  var FullDocumentUrl = z11.string().brand("FullDocumentUrl").describe(
1000
- "A full url with protocol, host, bucket name, starting from the root of the S3 server, https://minio.opencrvs.com/bucket-name/document-id.jpg"
1002
+ "A full url with protocol, host, bucket name, starting from the root of the S3 server, https://s3.opencrvs.com/bucket-name/document-id.jpg"
1001
1003
  );
1002
1004
  var FullDocumentPath = z11.string().overwrite((val) => val.startsWith("/") ? val : `/${val}`).meta({ effectType: "input", type: "string" }).describe(
1003
1005
  "A full absolute path with bucket name, starting from the root of the S3 server, /bucket-name/document-id.jpg"
@@ -1007,7 +1009,7 @@ var DocumentPath = z11.string().brand("DocumentPath").describe(
1007
1009
  );
1008
1010
 
1009
1011
  // ../commons/src/events/CompositeFieldValue.ts
1010
- var z12 = __toESM(require("zod/v4"));
1012
+ var z12 = __toESM(require("zod"));
1011
1013
  var AddressType = {
1012
1014
  DOMESTIC: "DOMESTIC",
1013
1015
  INTERNATIONAL: "INTERNATIONAL"
@@ -1212,7 +1214,7 @@ function safeUnion(schemas) {
1212
1214
  );
1213
1215
  return z14.any().superRefine((val, ctx) => {
1214
1216
  for (const schema of sortedSchemas) {
1215
- if (schema.safeParse(val).success) {
1217
+ if (schema.validate(val)) {
1216
1218
  return;
1217
1219
  }
1218
1220
  }
@@ -1655,6 +1657,12 @@ var AnyOfStatus = import_v4.z.object({
1655
1657
  }).meta({
1656
1658
  id: "AnyOfStatus"
1657
1659
  });
1660
+ var NoneOfStatus = import_v4.z.object({
1661
+ type: import_v4.z.literal("noneOf"),
1662
+ terms: import_v4.z.array(EventStatus)
1663
+ }).meta({
1664
+ id: "NoneOfStatus"
1665
+ });
1658
1666
  var Range = import_v4.z.object({
1659
1667
  type: import_v4.z.literal("range"),
1660
1668
  gte: import_v4.z.string(),
@@ -1695,7 +1703,7 @@ var QueryInput = import_v4.z.lazy(
1695
1703
  var QueryExpression = import_v4.z.object({
1696
1704
  id: import_v4.z.optional(import_v4.z.string()),
1697
1705
  eventType: import_v4.z.string(),
1698
- status: import_v4.z.optional(import_v4.z.union([AnyOfStatus, ExactStatus])),
1706
+ status: import_v4.z.optional(import_v4.z.union([AnyOfStatus, NoneOfStatus, ExactStatus])),
1699
1707
  createdAt: import_v4.z.optional(DateCondition),
1700
1708
  updatedAt: import_v4.z.optional(DateCondition),
1701
1709
  "legalStatuses.DECLARED.createdAtLocation": import_v4.z.optional(Within).nullable(),
@@ -2902,6 +2910,12 @@ var ReadActionConfig = ActionConfigBase.extend(
2902
2910
  var NotifyConfig = ActionConfigBase.extend(
2903
2911
  z25.object({
2904
2912
  type: z25.literal(ActionType.NOTIFY),
2913
+ notificationForm: DeclarationFormConfig.optional().describe(
2914
+ "Notification form configuration. Its fields must be a subset of the declaration form fields, with matching types. The values submitted on the notification form pre-fill the declaration. If not defined, the declare action's declaration is used (with all fields optional)."
2915
+ ),
2916
+ review: DeclarationReviewConfig.describe(
2917
+ "Review page configuration for the notify action. Values of its fields are stored as the NOTIFY action annotation. If not defined, defineConfig generates it from the declare action's review (with all fields optional)."
2918
+ ),
2905
2919
  form: actionConfirmationForm
2906
2920
  }).shape
2907
2921
  );
@@ -3083,11 +3097,11 @@ var ActionConfig = z25.discriminatedUnion("type", [
3083
3097
  }),
3084
3098
  NotifyConfig.meta({
3085
3099
  id: "NotifyActionConfig",
3086
- description: "Configuration for the notify action. When present, NOTIFY uses this config independently from DECLARE. When absent, NOTIFY falls back to the DeclareActionConfig."
3100
+ description: "Configuration for the notify action, including the notification form and its review page. When undefined, it is generated using the DeclareActionConfig."
3087
3101
  }),
3088
3102
  DeclareConfig.meta({
3089
3103
  id: "DeclareActionConfig",
3090
- description: "Configuration for the declare action. Includes review-page fields. NOTIFY falls back to this config when no dedicated NotifyActionConfig is provided."
3104
+ description: "Configuration for the declare action. Includes the declaration form and review-page fields."
3091
3105
  }),
3092
3106
  DuplicateDetectedConfig.meta({
3093
3107
  id: "DuplicateDetectedActionConfig",
@@ -3570,15 +3584,6 @@ var INHERENT_FLAG_RULES = [
3570
3584
  setOn: [ActionType.REQUEST_CORRECTION],
3571
3585
  resetOn: [ActionType.APPROVE_CORRECTION, ActionType.REJECT_CORRECTION]
3572
3586
  },
3573
- {
3574
- // INCOMPLETE mirrors the NOTIFIED status: set by NOTIFY, cleared by any
3575
- // other status-changing action (see getStatusFromActions). ARCHIVE/UNARCHIVE
3576
- // are deliberately excluded so the flag freezes across an archive/unarchive
3577
- // round trip and comes back exactly as it was.
3578
- flag: InherentFlags.INCOMPLETE,
3579
- setOn: [ActionType.NOTIFY],
3580
- resetOn: [ActionType.CREATE, ActionType.DECLARE, ActionType.REGISTER]
3581
- },
3582
3587
  {
3583
3588
  flag: InherentFlags.REJECTED,
3584
3589
  setOn: [ActionType.REJECT],
@@ -4374,6 +4379,25 @@ function isOnline() {
4374
4379
  return true;
4375
4380
  }
4376
4381
 
4382
+ // ../commons/src/events/notificationFormFallback.ts
4383
+ function toOptionalField(field3) {
4384
+ const { validation: _validation, ...rest } = field3;
4385
+ if (rest.type === FieldType.FIELD_GROUP && "fields" in rest) {
4386
+ return {
4387
+ ...rest,
4388
+ required: false,
4389
+ fields: rest.fields.map(toOptionalField)
4390
+ };
4391
+ }
4392
+ return { ...rest, required: false };
4393
+ }
4394
+ function generateNotifyReview(declareReview) {
4395
+ return {
4396
+ ...declareReview,
4397
+ fields: declareReview.fields.map(toOptionalField)
4398
+ };
4399
+ }
4400
+
4377
4401
  // ../commons/src/events/utils.ts
4378
4402
  var import_date_fns3 = require("date-fns");
4379
4403
  function getDeclaration(configuration) {
@@ -4393,6 +4417,12 @@ function getDeclarationPages(configuration) {
4393
4417
  function getDeclarationFields(configuration) {
4394
4418
  return getDeclarationPages(configuration).flatMap(({ fields }) => fields);
4395
4419
  }
4420
+ function getConfiguredNotificationForm(configuration) {
4421
+ const notifyAction = configuration.actions.find(
4422
+ (action) => action.type === ActionType.NOTIFY
4423
+ );
4424
+ return notifyAction?.type === ActionType.NOTIFY ? notifyAction.notificationForm : void 0;
4425
+ }
4396
4426
  var getActionAnnotationFields = (actionConfig) => {
4397
4427
  if (actionConfig.type === ActionType.REQUEST_CORRECTION) {
4398
4428
  return actionConfig.correctionForm.pages.flatMap(({ fields }) => fields);
@@ -4410,6 +4440,10 @@ function getAllAnnotationFields(config) {
4410
4440
  var findAllFields = (config) => {
4411
4441
  return (0, import_lodash4.flattenDeep)([
4412
4442
  ...getDeclarationFields(config),
4443
+ // Only a configured notification form: a derived one repeats the declaration fields.
4444
+ ...getConfiguredNotificationForm(config)?.pages.flatMap(
4445
+ ({ fields }) => fields
4446
+ ) ?? [],
4413
4447
  ...getAllAnnotationFields(config)
4414
4448
  ]);
4415
4449
  };
@@ -4574,6 +4608,50 @@ function validateDeclarationGivenExactlyOnce(config, ctx) {
4574
4608
  });
4575
4609
  }
4576
4610
  }
4611
+ function validateNotificationForm(event2, ctx) {
4612
+ const declarationFields = getDeclarationPages(event2).flatMap(
4613
+ (page) => page.fields.map((field3) => ({ field: field3, pageId: page.id }))
4614
+ );
4615
+ event2.actions.forEach((action, actionIndex) => {
4616
+ if (action.type !== ActionType.NOTIFY || !action.notificationForm) {
4617
+ return;
4618
+ }
4619
+ action.notificationForm.pages.forEach((page, pageIndex) => {
4620
+ page.fields.forEach((field3, fieldIndex) => {
4621
+ const path = [
4622
+ "actions",
4623
+ actionIndex,
4624
+ "notificationForm",
4625
+ "pages",
4626
+ pageIndex,
4627
+ "fields",
4628
+ fieldIndex
4629
+ ];
4630
+ const matchingFields = declarationFields.filter(
4631
+ (declarationField) => declarationField.field.id === field3.id
4632
+ );
4633
+ if (matchingFields.length === 0) {
4634
+ ctx.addIssue({
4635
+ code: "custom",
4636
+ message: `Notification form field '${field3.id}' does not exist in the declaration form of event '${event2.id}'. Notification form fields must also be defined in the ${ActionType.DECLARE} action's declaration.`,
4637
+ path
4638
+ });
4639
+ return;
4640
+ }
4641
+ if (!matchingFields.some(
4642
+ (declarationField) => declarationField.field.type === field3.type
4643
+ )) {
4644
+ const [declarationField] = matchingFields;
4645
+ ctx.addIssue({
4646
+ code: "custom",
4647
+ message: `Notification form field '${field3.id}' on page '${page.id}' is of type ${field3.type}, but the declaration form field with the same id in event '${event2.id}' (${ActionType.DECLARE} declaration, page '${declarationField.pageId}') is of type ${declarationField.field.type}.`,
4648
+ path
4649
+ });
4650
+ }
4651
+ });
4652
+ });
4653
+ });
4654
+ }
4577
4655
 
4578
4656
  // ../commons/src/events/EventConfig.ts
4579
4657
  var EventFieldReference = z35.object({ $$event: EventMetadataDateFieldIdInput }).describe(
@@ -4624,6 +4702,7 @@ var EventConfig = _EventConfigBase.superRefine((event2, ctx) => {
4624
4702
  if (!validateExactlyOneDeclareAction(event2, ctx)) {
4625
4703
  return;
4626
4704
  }
4705
+ validateNotificationForm(event2, ctx);
4627
4706
  validateAdvancedSearchConfig(event2, ctx);
4628
4707
  validateDateOfEvent(event2, ctx);
4629
4708
  validatePlaceOfEvent(event2, ctx);
@@ -4704,7 +4783,7 @@ function createSearchConfig(baseField) {
4704
4783
 
4705
4784
  // ../commons/src/event-config/event-configuration.ts
4706
4785
  function isNonSearchableEventMetadataTimeFieldId(fieldId) {
4707
- return !EventFieldIdInput.safeParse(fieldId).success;
4786
+ return !EventFieldIdInput.validate(fieldId);
4708
4787
  }
4709
4788
  function createEventFieldConfig(fieldId) {
4710
4789
  const baseField = {
@@ -4886,7 +4965,7 @@ var SerializableWithin = z37.object({
4886
4965
  });
4887
4966
  var SerializedQueryExpression = z37.object({
4888
4967
  eventType: z37.string(),
4889
- status: z37.optional(z37.union([AnyOfStatus, ExactStatus])),
4968
+ status: z37.optional(z37.union([AnyOfStatus, NoneOfStatus, ExactStatus])),
4890
4969
  createdAt: z37.optional(DateCondition),
4891
4970
  updatedAt: z37.optional(DateCondition),
4892
4971
  "legalStatuses.DECLARED.createdAtLocation": z37.optional(SerializableWithin),
@@ -5035,6 +5114,12 @@ var RegisterActionInput = BaseActionInput.extend(
5035
5114
  var NotifyActionInput = BaseActionInput.extend(
5036
5115
  z39.object({
5037
5116
  type: z39.literal(ActionType.NOTIFY).default(ActionType.NOTIFY),
5117
+ declaration: BaseActionInput.shape.declaration.describe(
5118
+ "Values for fields of the notification form, keyed by field id. Fields outside the notification form are rejected. Only these values become part of the record declaration, so any id that needs to be searchable must be a declaration field."
5119
+ ),
5120
+ annotation: BaseActionInput.shape.annotation.describe(
5121
+ "Values for notify-only fields (NOTIFY review and form fields), keyed by field id. These are stored on the NOTIFY action, not in the record declaration."
5122
+ ),
5038
5123
  // For normal users, the createdAtLocation is resolved on the backend from the user's primaryOfficeId.
5039
5124
  createdAtLocation: UUID.nullish().describe(
5040
5125
  "A valid office location ID. This is required for system users performing actions. The provided location must be a leaf-location, i.e. it must not have any children locations."
@@ -5277,11 +5362,56 @@ function moveDeclarationToDeclareAction({
5277
5362
  )
5278
5363
  };
5279
5364
  }
5365
+ function generateNotificationFormFallback(config) {
5366
+ const declareAction = config.actions.find(
5367
+ (action) => action.type === ActionType.DECLARE
5368
+ );
5369
+ const notifyAction = config.actions.find(
5370
+ (action) => action.type === ActionType.NOTIFY
5371
+ );
5372
+ if (!notifyAction?.notificationForm) {
5373
+ console.warn(
5374
+ `Event '${config.id}' has no ${ActionType.NOTIFY} form. Using the ${ActionType.DECLARE} form with all fields optional. Configure \`actions[${ActionType.NOTIFY}].notificationForm\`. This fallback will be removed in a future release.`
5375
+ );
5376
+ }
5377
+ if (notifyAction?.review) {
5378
+ return config;
5379
+ }
5380
+ if (!declareAction?.declaration) {
5381
+ throw new Error(
5382
+ `Event '${config.id}' has no ${ActionType.DECLARE} form. Configure \`actions[${ActionType.DECLARE}].declaration\`.`
5383
+ );
5384
+ }
5385
+ const review = generateNotifyReview(declareAction.review);
5386
+ if (notifyAction) {
5387
+ return {
5388
+ ...config,
5389
+ actions: config.actions.map(
5390
+ (action) => action === notifyAction ? { ...notifyAction, review } : action
5391
+ )
5392
+ };
5393
+ }
5394
+ const notifyFromDeclare = {
5395
+ type: ActionType.NOTIFY,
5396
+ label: declareAction.label,
5397
+ icon: declareAction.icon,
5398
+ conditionals: declareAction.conditionals,
5399
+ flags: declareAction.flags,
5400
+ supportingCopy: declareAction.dialogCopy?.notify,
5401
+ review
5402
+ };
5403
+ return {
5404
+ ...config,
5405
+ actions: config.actions.flatMap(
5406
+ (action) => action === declareAction ? [notifyFromDeclare, action] : [action]
5407
+ )
5408
+ };
5409
+ }
5280
5410
  var EventConfigDefinition = z43.custom().superRefine((config, ctx) => {
5281
5411
  if (validateExactlyOneDeclareAction(config, ctx)) {
5282
5412
  validateDeclarationGivenExactlyOnce(config, ctx);
5283
5413
  }
5284
- }).transform(moveDeclarationToDeclareAction).pipe(EventConfig);
5414
+ }).transform(moveDeclarationToDeclareAction).transform(generateNotificationFormFallback).pipe(EventConfig);
5285
5415
  var defineConfig = (config) => EventConfigDefinition.parse(config);
5286
5416
 
5287
5417
  // ../commons/src/events/test.utils.ts