@opencrvs/toolkit 2.1.2 → 2.2.0-rc.045257f

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 (144) hide show
  1. package/build.sh +2 -12
  2. package/create-countryconfig/package.json +1 -1
  3. package/dist/application-config/index.js +41 -9
  4. package/dist/authentication/index.d.ts +1 -0
  5. package/dist/authentication/index.js +30 -6
  6. package/dist/cli.js +944 -2044
  7. package/dist/commons/api/router.d.ts +1546 -243
  8. package/dist/commons/application-config/index.d.ts +2 -2
  9. package/dist/commons/conditionals/conditionals.d.ts +3 -3
  10. package/dist/commons/conditionals/index.d.ts +1 -0
  11. package/dist/commons/conditionals/validate.d.ts +5 -0
  12. package/dist/commons/events/ActionConfig.d.ts +146 -20
  13. package/dist/commons/events/ActionDocument.d.ts +89 -0
  14. package/dist/commons/events/ActionInput.d.ts +56 -4
  15. package/dist/commons/events/ActionType.d.ts +11 -1
  16. package/dist/commons/events/AdvancedSearchConfig.d.ts +12 -0
  17. package/dist/commons/events/AuditLog.d.ts +4 -0
  18. package/dist/commons/events/CompositeFieldValue.d.ts +5 -1
  19. package/dist/commons/events/CountryConfigQueryInput.d.ts +192 -18
  20. package/dist/commons/events/Draft.d.ts +2 -0
  21. package/dist/commons/events/EventConfig.d.ts +27 -6
  22. package/dist/commons/events/EventDocument.d.ts +88 -0
  23. package/dist/commons/events/EventIndex.d.ts +43 -6
  24. package/dist/commons/events/EventMetadata.d.ts +23 -1
  25. package/dist/commons/events/EventStatus.d.ts +1 -0
  26. package/dist/commons/events/FieldConfig.d.ts +11 -1
  27. package/dist/commons/events/FieldTypeMapping.d.ts +6 -6
  28. package/dist/commons/events/Flag.d.ts +1 -7
  29. package/dist/commons/events/PlainDate.d.ts +1 -0
  30. package/dist/commons/events/WorkqueueConfig.d.ts +224 -33
  31. package/dist/commons/events/eventConfigValidation.d.ts +26 -1
  32. package/dist/commons/events/index.d.ts +3 -0
  33. package/dist/commons/events/scopes.d.ts +2 -0
  34. package/dist/commons/events/state/flags.d.ts +1 -1
  35. package/dist/commons/events/state/index.d.ts +10 -2
  36. package/dist/commons/events/state/utils.d.ts +11 -1
  37. package/dist/commons/events/test.utils.d.ts +30 -1
  38. package/dist/commons/events/toNotificationForm.d.ts +17 -0
  39. package/dist/commons/events/utils.d.ts +62 -8
  40. package/dist/conditionals/index.js +16 -4
  41. package/dist/environment/derived-variables.d.ts +16 -4
  42. package/dist/environment/derived-variables.d.ts.map +1 -1
  43. package/dist/environment/derived-variables.js +18 -4
  44. package/dist/environment/dockerhub.d.ts +15 -0
  45. package/dist/environment/dockerhub.d.ts.map +1 -0
  46. package/dist/environment/dockerhub.js +104 -0
  47. package/dist/environment/questions.js +1 -1
  48. package/dist/environment/setup-environment.d.ts.map +1 -1
  49. package/dist/environment/setup-environment.js +67 -18
  50. package/dist/environment/templates.d.ts.map +1 -1
  51. package/dist/events/index.js +496 -129
  52. package/dist/migrations/index.d.ts +9 -0
  53. package/dist/migrations/index.d.ts.map +1 -0
  54. package/dist/migrations/index.js +847 -0
  55. package/dist/migrations/move-declaration-to-declare-action.d.ts +38 -0
  56. package/dist/migrations/move-declaration-to-declare-action.d.ts.map +1 -0
  57. package/dist/migrations/move-declaration-to-declare-action.js +377 -0
  58. package/dist/migrations/{v2.1 → persistent}/add-translations.d.ts +7 -1
  59. package/dist/migrations/persistent/add-translations.d.ts.map +1 -0
  60. package/dist/migrations/{v2.1 → persistent}/add-translations.js +14 -12
  61. package/dist/migrations/persistent/check-upgrade-path.d.ts +36 -0
  62. package/dist/migrations/persistent/check-upgrade-path.d.ts.map +1 -0
  63. package/dist/migrations/persistent/check-upgrade-path.js +105 -0
  64. package/dist/migrations/persistent/update-toolkit-dependency.d.ts +7 -0
  65. package/dist/migrations/persistent/update-toolkit-dependency.d.ts.map +1 -0
  66. package/dist/migrations/persistent/update-toolkit-dependency.js +77 -0
  67. package/dist/migrations/read-declaration-through-helper.d.ts +39 -0
  68. package/dist/migrations/read-declaration-through-helper.d.ts.map +1 -0
  69. package/dist/migrations/read-declaration-through-helper.js +257 -0
  70. package/dist/migrations/replace-incomplete-flag.d.ts +26 -0
  71. package/dist/migrations/replace-incomplete-flag.d.ts.map +1 -0
  72. package/dist/migrations/replace-incomplete-flag.js +126 -0
  73. package/dist/notification/index.js +390 -106
  74. package/dist/scopes/index.d.ts +83 -90
  75. package/dist/scopes/index.js +26 -6
  76. package/dist/templates/charts-values/dependencies/values.yaml +1 -1
  77. package/dist/templates/charts-values/opencrvs-services/values.yaml +3 -5
  78. package/dist/templates/charts-values/traefik/values.yaml +4 -3
  79. package/opencrvs-toolkit-2.2.0-rc.045257f.tgz +0 -0
  80. package/package.json +2 -2
  81. package/tsconfig.build.tsbuildinfo +1 -1
  82. package/dist/migrations/v2.1/add-explicit-correction-flags.d.ts +0 -3
  83. package/dist/migrations/v2.1/add-explicit-correction-flags.d.ts.map +0 -1
  84. package/dist/migrations/v2.1/add-explicit-correction-flags.js +0 -234
  85. package/dist/migrations/v2.1/add-recovery-link-notifications.d.ts +0 -3
  86. package/dist/migrations/v2.1/add-recovery-link-notifications.d.ts.map +0 -1
  87. package/dist/migrations/v2.1/add-recovery-link-notifications.js +0 -511
  88. package/dist/migrations/v2.1/add-translations.d.ts.map +0 -1
  89. package/dist/migrations/v2.1/enable-telemetry.d.ts +0 -3
  90. package/dist/migrations/v2.1/enable-telemetry.d.ts.map +0 -1
  91. package/dist/migrations/v2.1/enable-telemetry.js +0 -455
  92. package/dist/migrations/v2.1/index.d.ts +0 -6
  93. package/dist/migrations/v2.1/index.d.ts.map +0 -1
  94. package/dist/migrations/v2.1/index.js +0 -2170
  95. package/dist/migrations/v2.1/migrate-infrastructure-to-assets.d.ts +0 -14
  96. package/dist/migrations/v2.1/migrate-infrastructure-to-assets.d.ts.map +0 -1
  97. package/dist/migrations/v2.1/migrate-infrastructure-to-assets.js +0 -348
  98. package/dist/migrations/v2.1/remove-metabase-package-installs.d.ts +0 -2
  99. package/dist/migrations/v2.1/remove-metabase-package-installs.d.ts.map +0 -1
  100. package/dist/migrations/v2.1/remove-metabase-package-installs.js +0 -161
  101. package/dist/migrations/v2.1/remove-sentry.d.ts +0 -3
  102. package/dist/migrations/v2.1/remove-sentry.d.ts.map +0 -1
  103. package/dist/migrations/v2.1/remove-sentry.js +0 -354
  104. package/dist/migrations/v2.1/rename-trigger-paths.d.ts +0 -3
  105. package/dist/migrations/v2.1/rename-trigger-paths.d.ts.map +0 -1
  106. package/dist/migrations/v2.1/rename-trigger-paths.js +0 -216
  107. package/dist/migrations/v2.1/template-files.d.ts +0 -8
  108. package/dist/migrations/v2.1/template-files.d.ts.map +0 -1
  109. package/dist/migrations/v2.1/template-files.js +0 -49
  110. package/dist/migrations/v2.1/upgrade-tilt.d.ts +0 -8
  111. package/dist/migrations/v2.1/upgrade-tilt.d.ts.map +0 -1
  112. package/dist/migrations/v2.1/upgrade-tilt.js +0 -139
  113. package/dist/templates/countryconfig-template/.tiltignore +0 -1
  114. package/dist/templates/countryconfig-template/Dockerfile.assets +0 -7
  115. package/dist/templates/countryconfig-template/Tiltfile +0 -112
  116. package/dist/templates/countryconfig-template/assets/README.md +0 -1
  117. package/dist/templates/countryconfig-template/assets/clear-all-data-dev.sh +0 -61
  118. package/dist/templates/countryconfig-template/assets/deployment/deploy.sh +0 -455
  119. package/dist/templates/countryconfig-template/assets/deployment/reindex.sh +0 -168
  120. package/dist/templates/countryconfig-template/assets/deployment/validate-required-variables-in-compose-files.ts +0 -67
  121. package/dist/templates/countryconfig-template/assets/elasticsearch/reindex.sh +0 -168
  122. package/dist/templates/countryconfig-template/assets/metabase/README.md +0 -34
  123. package/dist/templates/countryconfig-template/assets/metabase/environment-configuration.sql +0 -36
  124. package/dist/templates/countryconfig-template/assets/metabase/initialize-database.sh +0 -46
  125. package/dist/templates/countryconfig-template/assets/metabase/metabase.init.db.sql +0 -27737
  126. package/dist/templates/countryconfig-template/assets/metabase/open-shell.sh +0 -21
  127. package/dist/templates/countryconfig-template/assets/metabase/package.json +0 -13
  128. package/dist/templates/countryconfig-template/assets/metabase/run-dev.sh +0 -108
  129. package/dist/templates/countryconfig-template/assets/metabase/run.sh +0 -120
  130. package/dist/templates/countryconfig-template/assets/metabase/update-database.sh +0 -40
  131. package/dist/templates/countryconfig-template/assets/postgres/setup-analytics.sh +0 -135
  132. package/dist/templates/countryconfig-template/assets/postgres/setup-reference-data.sh +0 -108
  133. package/dist/templates/countryconfig-template/tilt/clear-all-data.ps1 +0 -50
  134. package/dist/templates/countryconfig-template/tilt/clear-all-data.sh +0 -35
  135. package/dist/templates/countryconfig-template/tilt/common.tilt +0 -145
  136. package/dist/templates/countryconfig-template/tilt/examples/dependencies/values.yaml +0 -15
  137. package/dist/templates/countryconfig-template/tilt/examples/opencrvs-services/values.yaml +0 -56
  138. package/dist/templates/countryconfig-template/tilt/examples/traefik/values-minikube.yaml +0 -21
  139. package/dist/templates/countryconfig-template/tilt/examples/traefik/values.yaml +0 -38
  140. package/dist/templates/countryconfig-template/tilt/helm/dependencies/values.yaml +0 -17
  141. package/dist/templates/countryconfig-template/tilt/helm/opencrvs-services/values.yaml +0 -16
  142. package/dist/templates/countryconfig-template/tilt/lib.tilt +0 -95
  143. package/dist/templates/countryconfig-template/tilt/opencrvs.tilt +0 -136
  144. package/opencrvs-toolkit-2.1.2.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"}