@opencrvs/toolkit 1.9.12-rc.c1f8f26 → 1.9.12-rc.ce018e5

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 (79) hide show
  1. package/build.sh +4 -0
  2. package/dist/application-config/index.js +2045 -41
  3. package/dist/cli.js +2362 -4
  4. package/dist/commons/api/router.d.ts +106 -75
  5. package/dist/commons/application-config/index.d.ts +13 -16
  6. package/dist/commons/conditionals/conditionals.d.ts +3 -3
  7. package/dist/commons/events/ActionDocument.d.ts +198 -198
  8. package/dist/commons/events/ActionInput.d.ts +113 -113
  9. package/dist/commons/events/ActionType.d.ts +3 -3
  10. package/dist/commons/events/AdvancedSearchConfig.d.ts +16 -10
  11. package/dist/commons/events/CompositeFieldValue.d.ts +4 -4
  12. package/dist/commons/events/CountryConfigQueryInput.d.ts +443 -172
  13. package/dist/commons/events/Draft.d.ts +15 -15
  14. package/dist/commons/events/DynamicFieldValue.d.ts +37 -19
  15. package/dist/commons/events/EventConfig.d.ts +1 -1
  16. package/dist/commons/events/EventDocument.d.ts +81 -81
  17. package/dist/commons/events/EventIndex.d.ts +35 -27
  18. package/dist/commons/events/EventInput.d.ts +1 -1
  19. package/dist/commons/events/EventMetadata.d.ts +24 -24
  20. package/dist/commons/events/FieldConfig.d.ts +155 -44
  21. package/dist/commons/events/FieldType.d.ts +2 -1
  22. package/dist/commons/events/FieldTypeMapping.d.ts +98 -72
  23. package/dist/commons/events/FieldValue.d.ts +54 -26
  24. package/dist/commons/events/PlainDate.d.ts +1 -1
  25. package/dist/commons/events/WorkqueueColumnConfig.d.ts +16 -16
  26. package/dist/commons/events/WorkqueueConfig.d.ts +438 -194
  27. package/dist/commons/events/defineConfig.d.ts +0 -4
  28. package/dist/commons/events/locations.d.ts +4 -4
  29. package/dist/commons/events/state/index.d.ts +2 -2
  30. package/dist/commons/events/state/utils.d.ts +3 -3
  31. package/dist/commons/events/utils.d.ts +5 -177
  32. package/dist/conditionals/index.js +13 -5
  33. package/dist/events/index.js +142 -33
  34. package/dist/migrations/v2.0/add-birth-certificate-issuance-flag.d.ts +3 -0
  35. package/dist/migrations/v2.0/add-birth-certificate-issuance-flag.d.ts.map +1 -0
  36. package/dist/migrations/v2.0/add-birth-certificate-issuance-flag.js +405 -0
  37. package/dist/migrations/v2.0/convert-config-files-to-ts.d.ts +2 -0
  38. package/dist/migrations/v2.0/convert-config-files-to-ts.d.ts.map +1 -0
  39. package/dist/migrations/v2.0/convert-config-files-to-ts.js +753 -0
  40. package/dist/migrations/v2.0/convert-paragraph-to-heading.d.ts +3 -0
  41. package/dist/migrations/v2.0/convert-paragraph-to-heading.d.ts.map +1 -0
  42. package/dist/migrations/v2.0/convert-paragraph-to-heading.js +159 -0
  43. package/dist/migrations/v2.0/index.d.ts +7 -0
  44. package/dist/migrations/v2.0/index.d.ts.map +1 -0
  45. package/dist/migrations/v2.0/index.js +2361 -0
  46. package/dist/migrations/v2.0/make-built-in-validate-actions-custom.d.ts +3 -0
  47. package/dist/migrations/v2.0/make-built-in-validate-actions-custom.d.ts.map +1 -0
  48. package/dist/migrations/v2.0/make-built-in-validate-actions-custom.js +344 -0
  49. package/dist/migrations/v2.0/migrate-scopes.d.ts +3 -0
  50. package/dist/migrations/v2.0/migrate-scopes.d.ts.map +1 -0
  51. package/dist/migrations/v2.0/migrate-scopes.js +281 -0
  52. package/dist/migrations/v2.0/migrate-validated-workqueue-status-to-flag.d.ts +3 -0
  53. package/dist/migrations/v2.0/migrate-validated-workqueue-status-to-flag.d.ts.map +1 -0
  54. package/dist/migrations/v2.0/migrate-validated-workqueue-status-to-flag.js +268 -0
  55. package/dist/migrations/v2.0/remove-delete-actions.d.ts +3 -0
  56. package/dist/migrations/v2.0/remove-delete-actions.d.ts.map +1 -0
  57. package/dist/migrations/v2.0/remove-delete-actions.js +157 -0
  58. package/dist/migrations/v2.0/remove-deprecated-imports.d.ts +3 -0
  59. package/dist/migrations/v2.0/remove-deprecated-imports.d.ts.map +1 -0
  60. package/dist/migrations/v2.0/remove-deprecated-imports.js +97 -0
  61. package/dist/migrations/v2.0/remove-pending-certification-flag.d.ts +3 -0
  62. package/dist/migrations/v2.0/remove-pending-certification-flag.d.ts.map +1 -0
  63. package/dist/migrations/v2.0/remove-pending-certification-flag.js +110 -0
  64. package/dist/migrations/v2.0/remove-review-from-register-action.d.ts +3 -0
  65. package/dist/migrations/v2.0/remove-review-from-register-action.d.ts.map +1 -0
  66. package/dist/migrations/v2.0/remove-review-from-register-action.js +164 -0
  67. package/dist/migrations/v2.0/rename-api-paths.d.ts +3 -0
  68. package/dist/migrations/v2.0/rename-api-paths.d.ts.map +1 -0
  69. package/dist/migrations/v2.0/rename-api-paths.js +188 -0
  70. package/dist/migrations/v2.0/rename-location-parent-id.d.ts +3 -0
  71. package/dist/migrations/v2.0/rename-location-parent-id.d.ts.map +1 -0
  72. package/dist/migrations/v2.0/rename-location-parent-id.js +181 -0
  73. package/dist/notification/index.js +73 -23
  74. package/dist/scopes/index.d.ts +31 -10
  75. package/dist/scopes/index.js +17 -5
  76. package/opencrvs-toolkit-1.9.12-rc.ce018e5.tgz +0 -0
  77. package/package.json +8 -7
  78. package/tsconfig.tsbuildinfo +1 -1
  79. package/opencrvs-toolkit-1.9.12-rc.c1f8f26.tgz +0 -0
@@ -0,0 +1,268 @@
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: Migrate `VALIDATED` status references to flags inside `defineWorkqueues` calls.
28
+ *
29
+ * Usage:
30
+ * ts-node -r tsconfig-paths/register src/migrations/v2.0/migrate-validated-workqueue-status-to-flag.ts
31
+ *
32
+ * What it does:
33
+ * - Scans all TypeScript files under `src/`
34
+ * - Finds every `defineWorkqueues([...])` call expression
35
+ * - For each workqueue config's `query`, recursively walks `or`/`and` containers
36
+ * and processes every leaf clause object
37
+ * - In each clause:
38
+ * - `status: { type: 'anyOf', terms: [..., 'VALIDATED', ...] }`
39
+ * → removes `'VALIDATED'` from `terms`; removes `status` entirely if `terms`
40
+ * becomes empty; adds `'validated'` to `flags.anyOf`
41
+ * - `status: { type: 'exact', term: 'VALIDATED' }`
42
+ * → removes `status` entirely; adds `'validated'` to `flags.anyOf`
43
+ * - When adding to `flags.anyOf`, merges with an existing `flags` object if present
44
+ * - Saves the modified files in-place
45
+ */
46
+ const ts_morph_1 = require("ts-morph");
47
+ const path_1 = __importDefault(require("path"));
48
+ const _1 = require(".");
49
+ const DEFINE_WORKQUEUES_NAME = 'defineWorkqueues';
50
+ const QUERY_PROPERTY_NAME = 'query';
51
+ const TYPE_PROPERTY_NAME = 'type';
52
+ const CLAUSES_PROPERTY_NAME = 'clauses';
53
+ const STATUS_PROPERTY_NAME = 'status';
54
+ const FLAGS_PROPERTY_NAME = 'flags';
55
+ const TERMS_PROPERTY_NAME = 'terms';
56
+ const TERM_PROPERTY_NAME = 'term';
57
+ const ANY_OF_PROPERTY_NAME = 'anyOf';
58
+ const VALIDATED_STATUS_VALUE = 'VALIDATED';
59
+ const VALIDATED_FLAG_VALUE = 'validated';
60
+ // ─── Helpers ─────────────────────────────────────────────────────────────────
61
+ /**
62
+ * Adds `'validated'` to `flags.anyOf` on a clause object, merging with
63
+ * whatever `flags` shape already exists.
64
+ */
65
+ function addValidatedFlag(clause) {
66
+ const flagsProperty = clause.getProperty(FLAGS_PROPERTY_NAME);
67
+ if (flagsProperty && ts_morph_1.Node.isPropertyAssignment(flagsProperty)) {
68
+ const flagsInit = flagsProperty.getInitializer();
69
+ if (flagsInit && ts_morph_1.Node.isObjectLiteralExpression(flagsInit)) {
70
+ const anyOfProperty = flagsInit.getProperty(ANY_OF_PROPERTY_NAME);
71
+ if (anyOfProperty && ts_morph_1.Node.isPropertyAssignment(anyOfProperty)) {
72
+ // Append to existing anyOf array
73
+ const anyOfInit = anyOfProperty.getInitializer();
74
+ if (anyOfInit && ts_morph_1.Node.isArrayLiteralExpression(anyOfInit)) {
75
+ anyOfInit.addElement(`'${VALIDATED_FLAG_VALUE}'`);
76
+ }
77
+ }
78
+ else {
79
+ // flags exists but has no anyOf — add it
80
+ flagsInit.addPropertyAssignment({
81
+ name: ANY_OF_PROPERTY_NAME,
82
+ initializer: `['${VALIDATED_FLAG_VALUE}']`
83
+ });
84
+ }
85
+ }
86
+ }
87
+ else {
88
+ // No flags property at all — add one
89
+ clause.addPropertyAssignment({
90
+ name: FLAGS_PROPERTY_NAME,
91
+ initializer: `{ ${ANY_OF_PROPERTY_NAME}: ['${VALIDATED_FLAG_VALUE}'] }`
92
+ });
93
+ }
94
+ }
95
+ /**
96
+ * Processes a single leaf clause object.
97
+ * Returns true if any change was made.
98
+ */
99
+ function migrateClause(clause) {
100
+ const statusProperty = clause.getProperty(STATUS_PROPERTY_NAME);
101
+ if (!statusProperty || !ts_morph_1.Node.isPropertyAssignment(statusProperty)) {
102
+ return false;
103
+ }
104
+ const statusInit = statusProperty.getInitializer();
105
+ if (!statusInit || !ts_morph_1.Node.isObjectLiteralExpression(statusInit)) {
106
+ return false;
107
+ }
108
+ const statusTypeProperty = statusInit.getProperty(TYPE_PROPERTY_NAME);
109
+ if (!statusTypeProperty || !ts_morph_1.Node.isPropertyAssignment(statusTypeProperty)) {
110
+ return false;
111
+ }
112
+ const statusTypeInit = statusTypeProperty.getInitializer();
113
+ if (!statusTypeInit || !ts_morph_1.Node.isStringLiteral(statusTypeInit)) {
114
+ return false;
115
+ }
116
+ const statusType = statusTypeInit.getLiteralValue();
117
+ // ── anyOf case ──────────────────────────────────────────────────────────────
118
+ if (statusType === 'anyOf') {
119
+ const termsProperty = statusInit.getProperty(TERMS_PROPERTY_NAME);
120
+ if (!termsProperty || !ts_morph_1.Node.isPropertyAssignment(termsProperty)) {
121
+ return false;
122
+ }
123
+ const termsInit = termsProperty.getInitializer();
124
+ if (!termsInit || !ts_morph_1.Node.isArrayLiteralExpression(termsInit)) {
125
+ return false;
126
+ }
127
+ const elements = termsInit.getElements();
128
+ const validatedIndex = elements.findIndex((el) => ts_morph_1.Node.isStringLiteral(el) &&
129
+ el.getLiteralValue() === VALIDATED_STATUS_VALUE);
130
+ if (validatedIndex === -1)
131
+ return false;
132
+ // Remove 'VALIDATED' from terms
133
+ termsInit.removeElement(validatedIndex);
134
+ // If terms is now empty, drop the whole status property
135
+ if (termsInit.getElements().length === 0) {
136
+ statusProperty.remove();
137
+ }
138
+ addValidatedFlag(clause);
139
+ return true;
140
+ }
141
+ // ── exact case ──────────────────────────────────────────────────────────────
142
+ if (statusType === 'exact') {
143
+ const termProperty = statusInit.getProperty(TERM_PROPERTY_NAME);
144
+ if (!termProperty || !ts_morph_1.Node.isPropertyAssignment(termProperty)) {
145
+ return false;
146
+ }
147
+ const termInit = termProperty.getInitializer();
148
+ if (!termInit || !ts_morph_1.Node.isStringLiteral(termInit)) {
149
+ return false;
150
+ }
151
+ if (termInit.getLiteralValue() !== VALIDATED_STATUS_VALUE)
152
+ return false;
153
+ // Remove the entire status property
154
+ statusProperty.remove();
155
+ addValidatedFlag(clause);
156
+ return true;
157
+ }
158
+ return false;
159
+ }
160
+ /**
161
+ * Recursively walks a query node.
162
+ * - If it is an `or`/`and` container, recurses into `clauses`
163
+ * - Otherwise treats it as a leaf clause and calls `migrateClause`
164
+ * Returns the number of clauses changed.
165
+ */
166
+ function walkQuery(queryObj) {
167
+ const typeProperty = queryObj.getProperty(TYPE_PROPERTY_NAME);
168
+ if (typeProperty && ts_morph_1.Node.isPropertyAssignment(typeProperty)) {
169
+ const typeInit = typeProperty.getInitializer();
170
+ if (typeInit &&
171
+ ts_morph_1.Node.isStringLiteral(typeInit) &&
172
+ (typeInit.getLiteralValue() === 'or' ||
173
+ typeInit.getLiteralValue() === 'and')) {
174
+ const clausesProperty = queryObj.getProperty(CLAUSES_PROPERTY_NAME);
175
+ if (!clausesProperty || !ts_morph_1.Node.isPropertyAssignment(clausesProperty)) {
176
+ return 0;
177
+ }
178
+ const clausesInit = clausesProperty.getInitializer();
179
+ if (!clausesInit || !ts_morph_1.Node.isArrayLiteralExpression(clausesInit)) {
180
+ return 0;
181
+ }
182
+ let changed = 0;
183
+ for (const clause of clausesInit.getElements()) {
184
+ if (ts_morph_1.Node.isObjectLiteralExpression(clause)) {
185
+ changed += walkQuery(clause);
186
+ }
187
+ }
188
+ return changed;
189
+ }
190
+ }
191
+ // Leaf clause
192
+ return migrateClause(queryObj) ? 1 : 0;
193
+ }
194
+ // ─── File processor ──────────────────────────────────────────────────────────
195
+ function processFile(filePath, project) {
196
+ const sourceFile = project.getSourceFile(filePath);
197
+ if (!sourceFile)
198
+ return 0;
199
+ let migratedCount = 0;
200
+ const callExpressions = sourceFile.getDescendantsOfKind(ts_morph_1.SyntaxKind.CallExpression);
201
+ for (const call of callExpressions) {
202
+ const expression = call.getExpression();
203
+ if (!ts_morph_1.Node.isIdentifier(expression) ||
204
+ expression.getText() !== DEFINE_WORKQUEUES_NAME) {
205
+ continue;
206
+ }
207
+ const args = call.getArguments();
208
+ if (args.length === 0)
209
+ continue;
210
+ // The argument must be an array literal of workqueue config objects
211
+ const workqueuesArg = args[0];
212
+ if (!ts_morph_1.Node.isArrayLiteralExpression(workqueuesArg))
213
+ continue;
214
+ for (const workqueueElement of workqueuesArg.getElements()) {
215
+ if (!ts_morph_1.Node.isObjectLiteralExpression(workqueueElement))
216
+ continue;
217
+ const queryProperty = workqueueElement.getProperty(QUERY_PROPERTY_NAME);
218
+ if (!queryProperty || !ts_morph_1.Node.isPropertyAssignment(queryProperty))
219
+ continue;
220
+ const queryInit = queryProperty.getInitializer();
221
+ if (!queryInit || !ts_morph_1.Node.isObjectLiteralExpression(queryInit))
222
+ continue;
223
+ const changed = walkQuery(queryInit);
224
+ if (changed > 0) {
225
+ migratedCount += changed;
226
+ console.log(` [${path_1.default.relative((0, _1.getCwd)(), filePath)}] Migrated ${changed} clause(s): VALIDATED status → flags.anyOf`);
227
+ }
228
+ }
229
+ }
230
+ return migratedCount;
231
+ }
232
+ // ─── Entry point ─────────────────────────────────────────────────────────────
233
+ function main() {
234
+ return __awaiter(this, void 0, void 0, function* () {
235
+ const srcDir = path_1.default.join((0, _1.getCwd)(), 'src');
236
+ console.log(`Scanning for defineWorkqueues calls in: ${srcDir}\n`);
237
+ const project = new ts_morph_1.Project({
238
+ tsConfigFilePath: path_1.default.resolve(srcDir, '../tsconfig.json'),
239
+ skipAddingFilesFromTsConfig: false
240
+ });
241
+ const sourceFiles = project.getSourceFiles().filter((sf) => {
242
+ const fp = sf.getFilePath();
243
+ return fp.includes('/src/') && !fp.includes('/node_modules/');
244
+ });
245
+ console.log(`Found ${sourceFiles.length} source file(s) to analyse.\n`);
246
+ let totalMigrated = 0;
247
+ const modifiedFiles = [];
248
+ for (const sourceFile of sourceFiles) {
249
+ const filePath = sourceFile.getFilePath();
250
+ const migrated = processFile(filePath, project);
251
+ if (migrated > 0) {
252
+ totalMigrated += migrated;
253
+ modifiedFiles.push(filePath);
254
+ }
255
+ }
256
+ if (modifiedFiles.length === 0) {
257
+ console.log('No VALIDATED status references found in defineWorkqueues calls. Nothing to do.');
258
+ return;
259
+ }
260
+ console.log(`\nSaving ${modifiedFiles.length} modified file(s)...`);
261
+ for (const filePath of modifiedFiles) {
262
+ const sourceFile = project.getSourceFileOrThrow(filePath);
263
+ yield sourceFile.save();
264
+ console.log(` Saved: ${path_1.default.relative((0, _1.getCwd)(), filePath)}`);
265
+ }
266
+ console.log(`\nDone. Migrated ${totalMigrated} clause(s) from VALIDATED status to flags.anyOf['validated'].`);
267
+ });
268
+ }
@@ -0,0 +1,3 @@
1
+ declare function main(): Promise<void>;
2
+ export { main };
3
+ //# sourceMappingURL=remove-delete-actions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"remove-delete-actions.d.ts","sourceRoot":"","sources":["../../../src/migrations/v2.0/remove-delete-actions.ts"],"names":[],"mappings":"AA2IA,iBAAe,IAAI,kBAiDlB;AAED,OAAO,EAAE,IAAI,EAAE,CAAA"}
@@ -0,0 +1,157 @@
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: Remove `DELETE` type actions from the `actions` array inside `defineConfig` calls.
28
+ *
29
+ * Usage:
30
+ * ts-node -r tsconfig-paths/register src/migrations/v2.0/remove-delete-actions.ts
31
+ *
32
+ * What it does:
33
+ * - Scans all TypeScript files under `src/`
34
+ * - Finds every `defineConfig({ ... })` call expression
35
+ * - Inside the `actions` array of that config, locates object literals
36
+ * whose `type` property resolves to `ActionType.DELETE` or the string literal `"DELETE"`
37
+ * - Removes those action objects entirely from the array
38
+ * - Saves the modified files in-place
39
+ */
40
+ const ts_morph_1 = require("ts-morph");
41
+ const path_1 = __importDefault(require("path"));
42
+ const _1 = require(".");
43
+ const DEFINE_CONFIG_NAME = 'defineConfig';
44
+ const ACTIONS_PROPERTY_NAME = 'actions';
45
+ const TYPE_PROPERTY_NAME = 'type';
46
+ const ACTION_TYPE_ENUM_NAME = 'ActionType';
47
+ const DELETE_MEMBER_NAME = 'DELETE';
48
+ const DELETE_STRING_LITERAL = 'DELETE';
49
+ function isDeleteType(typeInitializer) {
50
+ // Matches: ActionType.DELETE
51
+ if (typeInitializer.getKind() === ts_morph_1.SyntaxKind.PropertyAccessExpression) {
52
+ const propAccess = typeInitializer.asKindOrThrow(ts_morph_1.SyntaxKind.PropertyAccessExpression);
53
+ const obj = propAccess.getExpression();
54
+ const member = propAccess.getName();
55
+ return (ts_morph_1.Node.isIdentifier(obj) &&
56
+ obj.getText() === ACTION_TYPE_ENUM_NAME &&
57
+ member === DELETE_MEMBER_NAME);
58
+ }
59
+ // Matches: "DELETE"
60
+ if (typeInitializer.getKind() === ts_morph_1.SyntaxKind.StringLiteral) {
61
+ return (typeInitializer
62
+ .asKindOrThrow(ts_morph_1.SyntaxKind.StringLiteral)
63
+ .getLiteralValue() === DELETE_STRING_LITERAL);
64
+ }
65
+ return false;
66
+ }
67
+ function isDeleteAction(obj) {
68
+ const typeProperty = obj.getProperty(TYPE_PROPERTY_NAME);
69
+ if (!typeProperty || !ts_morph_1.Node.isPropertyAssignment(typeProperty)) {
70
+ return false;
71
+ }
72
+ const typeInitializer = typeProperty.getInitializer();
73
+ return !!typeInitializer && isDeleteType(typeInitializer);
74
+ }
75
+ function processFile(filePath, project) {
76
+ const sourceFile = project.getSourceFile(filePath);
77
+ if (!sourceFile)
78
+ return 0;
79
+ let removedCount = 0;
80
+ // Find all call expressions named `defineConfig`
81
+ const callExpressions = sourceFile.getDescendantsOfKind(ts_morph_1.SyntaxKind.CallExpression);
82
+ for (const call of callExpressions) {
83
+ const expression = call.getExpression();
84
+ // Only interested in bare `defineConfig(...)` calls
85
+ if (!ts_morph_1.Node.isIdentifier(expression) ||
86
+ expression.getText() !== DEFINE_CONFIG_NAME) {
87
+ continue;
88
+ }
89
+ const args = call.getArguments();
90
+ if (args.length === 0)
91
+ continue;
92
+ // The first argument should be the config object literal
93
+ const configArg = args[0];
94
+ if (!ts_morph_1.Node.isObjectLiteralExpression(configArg))
95
+ continue;
96
+ // Find the `actions` property inside the config object
97
+ const actionsProperty = configArg.getProperty(ACTIONS_PROPERTY_NAME);
98
+ if (!actionsProperty || !ts_morph_1.Node.isPropertyAssignment(actionsProperty))
99
+ continue;
100
+ const actionsInitializer = actionsProperty.getInitializer();
101
+ if (!actionsInitializer ||
102
+ !ts_morph_1.Node.isArrayLiteralExpression(actionsInitializer))
103
+ continue;
104
+ // Collect indices of DELETE actions in reverse order so removal doesn't
105
+ // shift the indices of elements yet to be processed
106
+ const indicesToRemove = [];
107
+ actionsInitializer.getElements().forEach((element, index) => {
108
+ if (ts_morph_1.Node.isObjectLiteralExpression(element) && isDeleteAction(element)) {
109
+ indicesToRemove.push(index);
110
+ }
111
+ });
112
+ for (const index of indicesToRemove.reverse()) {
113
+ actionsInitializer.removeElement(index);
114
+ removedCount++;
115
+ console.log(` [${path_1.default.relative((0, _1.getCwd)(), filePath)}] Removed DELETE action at index ${index}`);
116
+ }
117
+ }
118
+ return removedCount;
119
+ }
120
+ function main() {
121
+ return __awaiter(this, void 0, void 0, function* () {
122
+ const srcDir = path_1.default.join((0, _1.getCwd)(), 'src');
123
+ console.log(`Scanning for defineConfig calls in: ${srcDir}\n`);
124
+ const project = new ts_morph_1.Project({
125
+ tsConfigFilePath: path_1.default.resolve(srcDir, '../tsconfig.json'),
126
+ // Do not emit — we only manipulate source files
127
+ skipAddingFilesFromTsConfig: false
128
+ });
129
+ // Restrict to source files only (exclude node_modules, build artefacts, etc.)
130
+ const sourceFiles = project.getSourceFiles().filter((sf) => {
131
+ const fp = sf.getFilePath();
132
+ return fp.includes('/src/') && !fp.includes('/node_modules/');
133
+ });
134
+ console.log(`Found ${sourceFiles.length} source file(s) to analyse.\n`);
135
+ let totalRemoved = 0;
136
+ const modifiedFiles = [];
137
+ for (const sourceFile of sourceFiles) {
138
+ const filePath = sourceFile.getFilePath();
139
+ const removed = processFile(filePath, project);
140
+ if (removed > 0) {
141
+ totalRemoved += removed;
142
+ modifiedFiles.push(filePath);
143
+ }
144
+ }
145
+ if (modifiedFiles.length === 0) {
146
+ console.log('No DELETE actions found inside defineConfig calls. Nothing to do.');
147
+ return;
148
+ }
149
+ console.log(`\nSaving ${modifiedFiles.length} modified file(s)...`);
150
+ for (const filePath of modifiedFiles) {
151
+ const sourceFile = project.getSourceFileOrThrow(filePath);
152
+ yield sourceFile.save();
153
+ console.log(` Saved: ${path_1.default.relative((0, _1.getCwd)(), filePath)}`);
154
+ }
155
+ console.log(`\nDone. Removed ${totalRemoved} DELETE action(s) from defineConfig call(s).`);
156
+ });
157
+ }
@@ -0,0 +1,3 @@
1
+ declare function main(): Promise<void>;
2
+ export { main };
3
+ //# sourceMappingURL=remove-deprecated-imports.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"remove-deprecated-imports.d.ts","sourceRoot":"","sources":["../../../src/migrations/v2.0/remove-deprecated-imports.ts"],"names":[],"mappings":"AA2DA,iBAAe,IAAI,kBAyClB;AAED,OAAO,EAAE,IAAI,EAAE,CAAA"}
@@ -0,0 +1,97 @@
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
+ const ts_morph_1 = require("ts-morph");
27
+ const path_1 = __importDefault(require("path"));
28
+ const _1 = require(".");
29
+ const DEPRECATED_IMPORT = 'SCOPES';
30
+ const TARGET_MODULES = new Set([
31
+ '@opencrvs/toolkit/scopes',
32
+ '@opencrvs/toolkit'
33
+ ]);
34
+ function processFile(filePath, project) {
35
+ const sourceFile = project.getSourceFile(filePath);
36
+ if (!sourceFile)
37
+ return 0;
38
+ let removedCount = 0;
39
+ const importDecls = sourceFile
40
+ .getImportDeclarations()
41
+ .filter((decl) => TARGET_MODULES.has(decl.getModuleSpecifierValue()));
42
+ for (const decl of importDecls) {
43
+ const matchingNamedImports = decl
44
+ .getNamedImports()
45
+ .filter((ni) => ni.getName() === DEPRECATED_IMPORT);
46
+ if (matchingNamedImports.length === 0)
47
+ continue;
48
+ for (const namedImport of matchingNamedImports) {
49
+ namedImport.remove();
50
+ removedCount++;
51
+ }
52
+ const hasAnyNamedImportsLeft = decl.getNamedImports().length > 0;
53
+ const hasDefaultImport = !!decl.getDefaultImport();
54
+ const hasNamespaceImport = !!decl.getNamespaceImport();
55
+ // If the declaration only contained SCOPE, remove the now-empty import line.
56
+ if (!hasAnyNamedImportsLeft && !hasDefaultImport && !hasNamespaceImport) {
57
+ decl.remove();
58
+ }
59
+ console.log(` [${path_1.default.relative((0, _1.getCwd)(), filePath)}] Removed ${matchingNamedImports.length} deprecated '${DEPRECATED_IMPORT}' import(s) from '${decl.getModuleSpecifierValue()}'`);
60
+ }
61
+ return removedCount;
62
+ }
63
+ function main() {
64
+ return __awaiter(this, void 0, void 0, function* () {
65
+ const srcDir = path_1.default.join((0, _1.getCwd)(), 'src');
66
+ console.log(`Scanning for deprecated imports in: ${srcDir}\n`);
67
+ const project = new ts_morph_1.Project({
68
+ tsConfigFilePath: path_1.default.resolve(srcDir, '../tsconfig.json'),
69
+ skipAddingFilesFromTsConfig: false
70
+ });
71
+ const sourceFiles = project.getSourceFiles().filter((sf) => {
72
+ const fp = sf.getFilePath();
73
+ return fp.includes('/src/') && !fp.includes('/node_modules/');
74
+ });
75
+ console.log(`Found ${sourceFiles.length} source file(s) to analyse.\n`);
76
+ let totalRemoved = 0;
77
+ const modifiedFiles = [];
78
+ for (const sourceFile of sourceFiles) {
79
+ const filePath = sourceFile.getFilePath();
80
+ const removed = processFile(filePath, project);
81
+ if (removed > 0) {
82
+ totalRemoved += removed;
83
+ modifiedFiles.push(filePath);
84
+ }
85
+ }
86
+ if (modifiedFiles.length === 0) {
87
+ console.log('No deprecated imports found. Nothing to do.');
88
+ return;
89
+ }
90
+ console.log(`\nSaving ${modifiedFiles.length} modified file(s)...`);
91
+ for (const filePath of modifiedFiles) {
92
+ yield project.getSourceFileOrThrow(filePath).save();
93
+ console.log(` Saved: ${path_1.default.relative((0, _1.getCwd)(), filePath)}`);
94
+ }
95
+ console.log(`\nDone. Removed ${totalRemoved} deprecated import(s).`);
96
+ });
97
+ }
@@ -0,0 +1,3 @@
1
+ declare function main(): Promise<void>;
2
+ export { main };
3
+ //# sourceMappingURL=remove-pending-certification-flag.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"remove-pending-certification-flag.d.ts","sourceRoot":"","sources":["../../../src/migrations/v2.0/remove-pending-certification-flag.ts"],"names":[],"mappings":"AA2EA,iBAAe,IAAI,kBAiDlB;AAED,OAAO,EAAE,IAAI,EAAE,CAAA"}
@@ -0,0 +1,110 @@
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: Remove `InherentFlags.PENDING_CERTIFICATION` from any array literal.
28
+ *
29
+ * Usage:
30
+ * ts-node -r tsconfig-paths/register src/migrations/v2.0/remove-pending-certification-flag.ts
31
+ *
32
+ * What it does:
33
+ * - Scans all TypeScript files under `src/`
34
+ * - Finds every array literal in every file
35
+ * - Removes any element that is the property access expression
36
+ * `InherentFlags.PENDING_CERTIFICATION`
37
+ * - Saves the modified files in-place
38
+ */
39
+ const ts_morph_1 = require("ts-morph");
40
+ const path_1 = __importDefault(require("path"));
41
+ const _1 = require(".");
42
+ const INHERENT_FLAGS_ENUM_NAME = 'InherentFlags';
43
+ const PENDING_CERTIFICATION_MEMBER = 'PENDING_CERTIFICATION';
44
+ function isPendingCertificationFlag(node) {
45
+ if (!ts_morph_1.Node.isPropertyAccessExpression(node))
46
+ return false;
47
+ const obj = node.getExpression();
48
+ const member = node.getName();
49
+ return (ts_morph_1.Node.isIdentifier(obj) &&
50
+ obj.getText() === INHERENT_FLAGS_ENUM_NAME &&
51
+ member === PENDING_CERTIFICATION_MEMBER);
52
+ }
53
+ function processFile(filePath, project) {
54
+ const sourceFile = project.getSourceFile(filePath);
55
+ if (!sourceFile)
56
+ return 0;
57
+ let removedCount = 0;
58
+ const arrayLiterals = sourceFile.getDescendantsOfKind(ts_morph_1.SyntaxKind.ArrayLiteralExpression);
59
+ for (const array of arrayLiterals) {
60
+ // Collect indices in reverse order so removal doesn't shift remaining indices
61
+ const indicesToRemove = [];
62
+ array.getElements().forEach((element, index) => {
63
+ if (isPendingCertificationFlag(element)) {
64
+ indicesToRemove.push(index);
65
+ }
66
+ });
67
+ for (const index of indicesToRemove.reverse()) {
68
+ array.removeElement(index);
69
+ removedCount++;
70
+ console.log(` [${path_1.default.relative((0, _1.getCwd)(), filePath)}] Removed InherentFlags.PENDING_CERTIFICATION from array`);
71
+ }
72
+ }
73
+ return removedCount;
74
+ }
75
+ function main() {
76
+ return __awaiter(this, void 0, void 0, function* () {
77
+ const srcDir = path_1.default.join((0, _1.getCwd)(), 'src');
78
+ console.log(`Scanning for InherentFlags.PENDING_CERTIFICATION array elements in: ${srcDir}\n`);
79
+ const project = new ts_morph_1.Project({
80
+ tsConfigFilePath: path_1.default.resolve(srcDir, '../tsconfig.json'),
81
+ skipAddingFilesFromTsConfig: false
82
+ });
83
+ const sourceFiles = project.getSourceFiles().filter((sf) => {
84
+ const fp = sf.getFilePath();
85
+ return fp.includes('/src/') && !fp.includes('/node_modules/');
86
+ });
87
+ console.log(`Found ${sourceFiles.length} source file(s) to analyse.\n`);
88
+ let totalRemoved = 0;
89
+ const modifiedFiles = [];
90
+ for (const sourceFile of sourceFiles) {
91
+ const filePath = sourceFile.getFilePath();
92
+ const removed = processFile(filePath, project);
93
+ if (removed > 0) {
94
+ totalRemoved += removed;
95
+ modifiedFiles.push(filePath);
96
+ }
97
+ }
98
+ if (modifiedFiles.length === 0) {
99
+ console.log('No InherentFlags.PENDING_CERTIFICATION elements found in any array. Nothing to do.');
100
+ return;
101
+ }
102
+ console.log(`\nSaving ${modifiedFiles.length} modified file(s)...`);
103
+ for (const filePath of modifiedFiles) {
104
+ const sourceFile = project.getSourceFileOrThrow(filePath);
105
+ yield sourceFile.save();
106
+ console.log(` Saved: ${path_1.default.relative((0, _1.getCwd)(), filePath)}`);
107
+ }
108
+ console.log(`\nDone. Removed ${totalRemoved} InherentFlags.PENDING_CERTIFICATION element(s) from array(s).`);
109
+ });
110
+ }
@@ -0,0 +1,3 @@
1
+ declare function main(): Promise<void>;
2
+ export { main };
3
+ //# sourceMappingURL=remove-review-from-register-action.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"remove-review-from-register-action.d.ts","sourceRoot":"","sources":["../../../src/migrations/v2.0/remove-review-from-register-action.ts"],"names":[],"mappings":"AAoJA,iBAAe,IAAI,kBAkDlB;AAED,OAAO,EAAE,IAAI,EAAE,CAAA"}