@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
@@ -1,234 +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: Add explicit `APPROVE_CORRECTION` / `REJECT_CORRECTION` action
28
- * configs when `REQUEST_CORRECTION` has `flags` and/or `conditionals`.
29
- *
30
- * Usage:
31
- * ts-node -r tsconfig-paths/register src/migrations/v2.1/add-explicit-correction-flags.ts
32
- *
33
- * Why:
34
- * `getActionConfig()` used to alias `APPROVE_CORRECTION` and
35
- * `REJECT_CORRECTION` to whatever was configured on `REQUEST_CORRECTION`
36
- * (label, flags, conditionals). As of v2.1, each resolves to its own
37
- * independent config, so `flags`/`conditionals` configured only on
38
- * `REQUEST_CORRECTION` would silently stop applying when an
39
- * `APPROVE_CORRECTION`/`REJECT_CORRECTION` action is accepted. See
40
- * CHANGELOG.md ("APPROVE_CORRECTION / REJECT_CORRECTION no longer inherit
41
- * REQUEST_CORRECTION's config").
42
- *
43
- * What it does:
44
- * - Scans all TypeScript files under `src/`
45
- * - Finds every `defineConfig({ ... })` call expression
46
- * - Inside the `actions` array, locates the `REQUEST_CORRECTION` action
47
- * - If it has a non-empty `flags` and/or `conditionals` array, inserts
48
- * sibling `APPROVE_CORRECTION` and `REJECT_CORRECTION` action objects
49
- * (carrying over the same `flags`/`conditionals`) immediately after it,
50
- * unless an action of that type already exists in the array
51
- * - Saves the modified files in-place
52
- */
53
- const ts_morph_1 = require("ts-morph");
54
- const path_1 = __importDefault(require("path"));
55
- const DEFINE_CONFIG_NAME = 'defineConfig';
56
- const ACTIONS_PROPERTY_NAME = 'actions';
57
- const TYPE_PROPERTY_NAME = 'type';
58
- const FLAGS_PROPERTY_NAME = 'flags';
59
- const CONDITIONALS_PROPERTY_NAME = 'conditionals';
60
- const ACTION_TYPE_ENUM_NAME = 'ActionType';
61
- const REQUEST_CORRECTION_TYPE = 'REQUEST_CORRECTION';
62
- const CORRECTION_ACTIONS_TO_ADD = [
63
- {
64
- actionType: 'APPROVE_CORRECTION',
65
- labelId: 'v2.events.correction.approve.label',
66
- defaultMessage: 'Approve correction',
67
- description: 'Label for the approve correction action'
68
- },
69
- {
70
- actionType: 'REJECT_CORRECTION',
71
- labelId: 'v2.events.correction.reject.label',
72
- defaultMessage: 'Reject correction',
73
- description: 'Label for the reject correction action'
74
- }
75
- ];
76
- /**
77
- * Returns true if the object's `type` property matches the given type name.
78
- * Handles both `ActionType.X` and the string literal `'X'` forms.
79
- */
80
- function isActionOfType(obj, typeName) {
81
- const typeProperty = obj.getProperty(TYPE_PROPERTY_NAME);
82
- if (!typeProperty || !ts_morph_1.Node.isPropertyAssignment(typeProperty))
83
- return false;
84
- const typeInit = typeProperty.getInitializer();
85
- if (!typeInit)
86
- return false;
87
- if (ts_morph_1.Node.isPropertyAccessExpression(typeInit)) {
88
- return (typeInit.getExpression().getText() === ACTION_TYPE_ENUM_NAME &&
89
- typeInit.getName() === typeName);
90
- }
91
- if (ts_morph_1.Node.isStringLiteral(typeInit)) {
92
- return typeInit.getLiteralValue() === typeName;
93
- }
94
- return false;
95
- }
96
- /**
97
- * Returns whether `type` is written as `ActionType.X` (enum access) or as a
98
- * bare string literal, so newly inserted actions can mirror the same style.
99
- */
100
- function getTypeInitializerStyle(obj) {
101
- const typeProperty = obj.getProperty(TYPE_PROPERTY_NAME);
102
- if (typeProperty && ts_morph_1.Node.isPropertyAssignment(typeProperty)) {
103
- const typeInit = typeProperty.getInitializer();
104
- if (typeInit && ts_morph_1.Node.isPropertyAccessExpression(typeInit))
105
- return 'enum';
106
- }
107
- return 'string';
108
- }
109
- /**
110
- * Returns the source text of `obj[propName]` if it's an array literal with
111
- * at least one element, otherwise undefined.
112
- */
113
- function getNonEmptyArrayPropertyText(obj, propName) {
114
- const prop = obj.getProperty(propName);
115
- if (!prop || !ts_morph_1.Node.isPropertyAssignment(prop))
116
- return undefined;
117
- const init = prop.getInitializer();
118
- if (!init || !ts_morph_1.Node.isArrayLiteralExpression(init))
119
- return undefined;
120
- if (init.getElements().length === 0)
121
- return undefined;
122
- return init.getText();
123
- }
124
- function buildCorrectionActionText(spec, typeStyle, flagsText, conditionalsText) {
125
- const typeText = typeStyle === 'enum'
126
- ? `${ACTION_TYPE_ENUM_NAME}.${spec.actionType}`
127
- : `'${spec.actionType}'`;
128
- const lines = [
129
- `type: ${typeText}`,
130
- `label: {
131
- id: '${spec.labelId}',
132
- defaultMessage: '${spec.defaultMessage}',
133
- description: '${spec.description}'
134
- }`
135
- ];
136
- if (flagsText) {
137
- lines.push(`${FLAGS_PROPERTY_NAME}: ${flagsText}`);
138
- }
139
- if (conditionalsText) {
140
- lines.push(`${CONDITIONALS_PROPERTY_NAME}: ${conditionalsText}`);
141
- }
142
- return `{\n ${lines.join(',\n ')}\n}`;
143
- }
144
- function processFile(filePath, project) {
145
- const sourceFile = project.getSourceFile(filePath);
146
- if (!sourceFile)
147
- return 0;
148
- let changes = 0;
149
- const relPath = path_1.default.relative(process.cwd(), filePath);
150
- const callExpressions = sourceFile.getDescendantsOfKind(ts_morph_1.SyntaxKind.CallExpression);
151
- for (const call of callExpressions) {
152
- const expression = call.getExpression();
153
- if (!ts_morph_1.Node.isIdentifier(expression) ||
154
- expression.getText() !== DEFINE_CONFIG_NAME) {
155
- continue;
156
- }
157
- const args = call.getArguments();
158
- if (args.length === 0)
159
- continue;
160
- const configArg = args[0];
161
- if (!ts_morph_1.Node.isObjectLiteralExpression(configArg))
162
- continue;
163
- const actionsProperty = configArg.getProperty(ACTIONS_PROPERTY_NAME);
164
- if (!actionsProperty || !ts_morph_1.Node.isPropertyAssignment(actionsProperty))
165
- continue;
166
- const actionsInitializer = actionsProperty.getInitializer();
167
- if (!actionsInitializer ||
168
- !ts_morph_1.Node.isArrayLiteralExpression(actionsInitializer))
169
- continue;
170
- const elements = actionsInitializer.getElements();
171
- const requestCorrectionIndex = elements.findIndex((el) => ts_morph_1.Node.isObjectLiteralExpression(el) &&
172
- isActionOfType(el, REQUEST_CORRECTION_TYPE));
173
- if (requestCorrectionIndex === -1)
174
- continue;
175
- const requestCorrection = elements[requestCorrectionIndex];
176
- const flagsText = getNonEmptyArrayPropertyText(requestCorrection, FLAGS_PROPERTY_NAME);
177
- const conditionalsText = getNonEmptyArrayPropertyText(requestCorrection, CONDITIONALS_PROPERTY_NAME);
178
- // Nothing on REQUEST_CORRECTION that approve/reject would need to inherit.
179
- if (!flagsText && !conditionalsText)
180
- continue;
181
- const typeStyle = getTypeInitializerStyle(requestCorrection);
182
- let insertAt = requestCorrectionIndex + 1;
183
- for (const spec of CORRECTION_ACTIONS_TO_ADD) {
184
- const alreadyPresent = actionsInitializer
185
- .getElements()
186
- .some((el) => ts_morph_1.Node.isObjectLiteralExpression(el) &&
187
- isActionOfType(el, spec.actionType));
188
- if (alreadyPresent)
189
- continue;
190
- const text = buildCorrectionActionText(spec, typeStyle, flagsText, conditionalsText);
191
- actionsInitializer.insertElement(insertAt, text);
192
- insertAt++;
193
- changes++;
194
- console.log(` [${relPath}] Added ${spec.actionType} action carrying over REQUEST_CORRECTION's flags/conditionals`);
195
- }
196
- }
197
- return changes;
198
- }
199
- function main() {
200
- return __awaiter(this, void 0, void 0, function* () {
201
- const srcDir = path_1.default.join(process.cwd(), 'src');
202
- console.log(`Scanning for defineConfig calls in: ${srcDir}\n`);
203
- const project = new ts_morph_1.Project({
204
- tsConfigFilePath: path_1.default.resolve(srcDir, '../tsconfig.json'),
205
- skipAddingFilesFromTsConfig: false
206
- });
207
- const sourceFiles = project.getSourceFiles().filter((sf) => {
208
- const fp = sf.getFilePath();
209
- return fp.includes('/src/') && !fp.includes('/node_modules/');
210
- });
211
- console.log(`Found ${sourceFiles.length} source file(s) to analyse.\n`);
212
- let totalChanges = 0;
213
- const modifiedFiles = [];
214
- for (const sourceFile of sourceFiles) {
215
- const filePath = sourceFile.getFilePath();
216
- const changes = processFile(filePath, project);
217
- if (changes > 0) {
218
- totalChanges += changes;
219
- modifiedFiles.push(filePath);
220
- }
221
- }
222
- if (modifiedFiles.length === 0) {
223
- console.log('No REQUEST_CORRECTION actions with flags/conditionals found. Nothing to do.');
224
- return;
225
- }
226
- console.log(`\nSaving ${modifiedFiles.length} modified file(s)...`);
227
- for (const filePath of modifiedFiles) {
228
- const sourceFile = project.getSourceFileOrThrow(filePath);
229
- yield sourceFile.save();
230
- console.log(` Saved: ${path_1.default.relative(process.cwd(), filePath)}`);
231
- }
232
- console.log(`\nDone. Added ${totalChanges} correction action config(s) across ${modifiedFiles.length} file(s).`);
233
- });
234
- }
@@ -1,3 +0,0 @@
1
- declare function main(): Promise<void>;
2
- export { main };
3
- //# sourceMappingURL=add-recovery-link-notifications.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"add-recovery-link-notifications.d.ts","sourceRoot":"","sources":["../../../src/migrations/v2.1/add-recovery-link-notifications.ts"],"names":[],"mappings":"AAopBA,iBAAe,IAAI,kBA0ClB;AAED,OAAO,EAAE,IAAI,EAAE,CAAA"}