@opencrvs/toolkit 1.9.12-rc.d22cc55 → 1.9.12-rc.d4e5c22

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 (151) hide show
  1. package/build.sh +13 -0
  2. package/dist/api/index.d.ts.map +1 -1
  3. package/dist/application-config/index.d.ts +2 -0
  4. package/dist/application-config/index.d.ts.map +1 -0
  5. package/dist/application-config/index.js +2128 -0
  6. package/dist/cli.d.ts +2 -0
  7. package/dist/cli.d.ts.map +1 -0
  8. package/dist/cli.js +4527 -0
  9. package/dist/commons/api/router.d.ts +3435 -2288
  10. package/dist/commons/application-config/index.d.ts +84 -0
  11. package/dist/commons/conditionals/conditionals.d.ts +27 -3
  12. package/dist/commons/conditionals/validate.d.ts +13 -2
  13. package/dist/commons/events/ActionConfig.d.ts +415 -1555
  14. package/dist/commons/events/ActionDocument.d.ts +888 -1941
  15. package/dist/commons/events/ActionInput.d.ts +277 -1073
  16. package/dist/commons/events/ActionType.d.ts +91 -11
  17. package/dist/commons/events/AdvancedSearchConfig.d.ts +294 -1238
  18. package/dist/commons/events/AuditLog.d.ts +405 -0
  19. package/dist/commons/events/CompositeFieldValue.d.ts +30 -190
  20. package/dist/commons/events/Conditional.d.ts +26 -38
  21. package/dist/commons/events/Constants.d.ts +1 -1
  22. package/dist/commons/events/CountryConfigQueryInput.d.ts +1592 -4471
  23. package/dist/commons/events/DeduplicationConfig.d.ts +15 -171
  24. package/dist/commons/events/Draft.d.ts +72 -107
  25. package/dist/commons/events/DynamicFieldValue.d.ts +12 -78
  26. package/dist/commons/events/EventConfig.d.ts +37 -2250
  27. package/dist/commons/events/EventConfigInput.d.ts +0 -3
  28. package/dist/commons/events/EventDocument.d.ts +354 -1366
  29. package/dist/commons/events/EventIndex.d.ts +212 -1010
  30. package/dist/commons/events/EventInput.d.ts +3 -8
  31. package/dist/commons/events/EventMetadata.d.ts +130 -357
  32. package/dist/commons/events/FieldConfig.d.ts +2894 -12548
  33. package/dist/commons/events/FieldType.d.ts +26 -4
  34. package/dist/commons/events/FieldTypeMapping.d.ts +314 -906
  35. package/dist/commons/events/FieldValue.d.ts +149 -527
  36. package/dist/commons/events/FileUtils.d.ts +2 -2
  37. package/dist/commons/events/Flag.d.ts +67 -0
  38. package/dist/commons/events/FormConfig.d.ts +54 -721
  39. package/dist/commons/events/PageConfig.d.ts +58 -320
  40. package/dist/commons/events/PlainDate.d.ts +1 -1
  41. package/dist/commons/events/SummaryConfig.d.ts +14 -161
  42. package/dist/commons/events/TemplateConfig.d.ts +2 -3
  43. package/dist/commons/events/TranslationConfig.d.ts +2 -2
  44. package/dist/commons/events/WorkqueueColumnConfig.d.ts +74 -37
  45. package/dist/commons/events/WorkqueueConfig.d.ts +2208 -7553
  46. package/dist/commons/events/deduplication.d.ts +3 -3
  47. package/dist/commons/events/defineConfig.d.ts +2 -233
  48. package/dist/commons/events/eventConfigValidation.d.ts +8 -0
  49. package/dist/commons/events/index.d.ts +3 -0
  50. package/dist/commons/events/locations.d.ts +57 -20
  51. package/dist/commons/events/scopes.d.ts +36 -35
  52. package/dist/commons/events/state/availableActions.d.ts +7 -2
  53. package/dist/commons/events/state/flags.d.ts +21 -3
  54. package/dist/commons/events/state/index.d.ts +30 -27
  55. package/dist/commons/events/state/utils.d.ts +190 -172
  56. package/dist/commons/events/test.utils.d.ts +52 -11
  57. package/dist/commons/events/transactions.d.ts +1 -1
  58. package/dist/commons/events/utils.d.ts +374 -429
  59. package/dist/commons/notification/UserNotifications.d.ts +61 -637
  60. package/dist/conditionals/index.d.ts.map +1 -1
  61. package/dist/conditionals/index.js +302 -14
  62. package/dist/events/deduplication.d.ts +3 -3
  63. package/dist/events/index.js +2874 -2135
  64. package/dist/migrations/v2.0/add-birth-certificate-issuance-flag.d.ts +3 -0
  65. package/dist/migrations/v2.0/add-birth-certificate-issuance-flag.d.ts.map +1 -0
  66. package/dist/migrations/v2.0/add-birth-certificate-issuance-flag.js +404 -0
  67. package/dist/migrations/v2.0/checkout-upstream-files.d.ts +22 -0
  68. package/dist/migrations/v2.0/checkout-upstream-files.d.ts.map +1 -0
  69. package/dist/migrations/v2.0/checkout-upstream-files.js +147 -0
  70. package/dist/migrations/v2.0/convert-config-files-to-ts.d.ts +2 -0
  71. package/dist/migrations/v2.0/convert-config-files-to-ts.d.ts.map +1 -0
  72. package/dist/migrations/v2.0/convert-config-files-to-ts.js +828 -0
  73. package/dist/migrations/v2.0/convert-paragraph-to-heading.d.ts +3 -0
  74. package/dist/migrations/v2.0/convert-paragraph-to-heading.d.ts.map +1 -0
  75. package/dist/migrations/v2.0/convert-paragraph-to-heading.js +158 -0
  76. package/dist/migrations/v2.0/create-events-index.d.ts +3 -0
  77. package/dist/migrations/v2.0/create-events-index.d.ts.map +1 -0
  78. package/dist/migrations/v2.0/create-events-index.js +325 -0
  79. package/dist/migrations/v2.0/delete-infrastructure-directory.d.ts +3 -0
  80. package/dist/migrations/v2.0/delete-infrastructure-directory.d.ts.map +1 -0
  81. package/dist/migrations/v2.0/delete-infrastructure-directory.js +77 -0
  82. package/dist/migrations/v2.0/index.d.ts +11 -0
  83. package/dist/migrations/v2.0/index.d.ts.map +1 -0
  84. package/dist/migrations/v2.0/index.js +4437 -0
  85. package/dist/migrations/v2.0/make-built-in-validate-actions-custom.d.ts +3 -0
  86. package/dist/migrations/v2.0/make-built-in-validate-actions-custom.d.ts.map +1 -0
  87. package/dist/migrations/v2.0/make-built-in-validate-actions-custom.js +343 -0
  88. package/dist/migrations/v2.0/merge-infrastructure-directory.d.ts +3 -0
  89. package/dist/migrations/v2.0/merge-infrastructure-directory.d.ts.map +1 -0
  90. package/dist/migrations/v2.0/merge-infrastructure-directory.js +221 -0
  91. package/dist/migrations/v2.0/migrate-application-config-url.d.ts +3 -0
  92. package/dist/migrations/v2.0/migrate-application-config-url.d.ts.map +1 -0
  93. package/dist/migrations/v2.0/migrate-application-config-url.js +342 -0
  94. package/dist/migrations/v2.0/migrate-scopes.d.ts +3 -0
  95. package/dist/migrations/v2.0/migrate-scopes.d.ts.map +1 -0
  96. package/dist/migrations/v2.0/migrate-scopes.js +281 -0
  97. package/dist/migrations/v2.0/migrate-validated-workqueue-status-to-flag.d.ts +3 -0
  98. package/dist/migrations/v2.0/migrate-validated-workqueue-status-to-flag.d.ts.map +1 -0
  99. package/dist/migrations/v2.0/migrate-validated-workqueue-status-to-flag.js +267 -0
  100. package/dist/migrations/v2.0/migrate-workqueue-configs.d.ts +3 -0
  101. package/dist/migrations/v2.0/migrate-workqueue-configs.d.ts.map +1 -0
  102. package/dist/migrations/v2.0/migrate-workqueue-configs.js +236 -0
  103. package/dist/migrations/v2.0/remove-delete-actions.d.ts +3 -0
  104. package/dist/migrations/v2.0/remove-delete-actions.d.ts.map +1 -0
  105. package/dist/migrations/v2.0/remove-delete-actions.js +156 -0
  106. package/dist/migrations/v2.0/remove-demo-scope.d.ts +3 -0
  107. package/dist/migrations/v2.0/remove-demo-scope.d.ts.map +1 -0
  108. package/dist/migrations/v2.0/remove-demo-scope.js +74 -0
  109. package/dist/migrations/v2.0/remove-deprecated-imports.d.ts +3 -0
  110. package/dist/migrations/v2.0/remove-deprecated-imports.d.ts.map +1 -0
  111. package/dist/migrations/v2.0/remove-deprecated-imports.js +96 -0
  112. package/dist/migrations/v2.0/remove-fhir-url-helpers.d.ts +3 -0
  113. package/dist/migrations/v2.0/remove-fhir-url-helpers.d.ts.map +1 -0
  114. package/dist/migrations/v2.0/remove-fhir-url-helpers.js +163 -0
  115. package/dist/migrations/v2.0/remove-hearth-migrations.d.ts +3 -0
  116. package/dist/migrations/v2.0/remove-hearth-migrations.d.ts.map +1 -0
  117. package/dist/migrations/v2.0/remove-hearth-migrations.js +77 -0
  118. package/dist/migrations/v2.0/remove-old-statistics-service.d.ts +3 -0
  119. package/dist/migrations/v2.0/remove-old-statistics-service.d.ts.map +1 -0
  120. package/dist/migrations/v2.0/remove-old-statistics-service.js +356 -0
  121. package/dist/migrations/v2.0/remove-pending-certification-flag.d.ts +3 -0
  122. package/dist/migrations/v2.0/remove-pending-certification-flag.d.ts.map +1 -0
  123. package/dist/migrations/v2.0/remove-pending-certification-flag.js +109 -0
  124. package/dist/migrations/v2.0/remove-review-from-register-action.d.ts +3 -0
  125. package/dist/migrations/v2.0/remove-review-from-register-action.d.ts.map +1 -0
  126. package/dist/migrations/v2.0/remove-review-from-register-action.js +163 -0
  127. package/dist/migrations/v2.0/remove-unused-environment-variables.d.ts +3 -0
  128. package/dist/migrations/v2.0/remove-unused-environment-variables.d.ts.map +1 -0
  129. package/dist/migrations/v2.0/remove-unused-environment-variables.js +186 -0
  130. package/dist/migrations/v2.0/rename-api-paths.d.ts +3 -0
  131. package/dist/migrations/v2.0/rename-api-paths.d.ts.map +1 -0
  132. package/dist/migrations/v2.0/rename-api-paths.js +187 -0
  133. package/dist/migrations/v2.0/rename-location-parent-id.d.ts +3 -0
  134. package/dist/migrations/v2.0/rename-location-parent-id.d.ts.map +1 -0
  135. package/dist/migrations/v2.0/rename-location-parent-id.js +180 -0
  136. package/dist/migrations/v2.0/simplify-analytics-precalculations.d.ts +3 -0
  137. package/dist/migrations/v2.0/simplify-analytics-precalculations.d.ts.map +1 -0
  138. package/dist/migrations/v2.0/simplify-analytics-precalculations.js +195 -0
  139. package/dist/migrations/v2.0/update-package-json.d.ts +3 -0
  140. package/dist/migrations/v2.0/update-package-json.d.ts.map +1 -0
  141. package/dist/migrations/v2.0/update-package-json.js +105 -0
  142. package/dist/notification/index.d.ts.map +1 -1
  143. package/dist/notification/index.js +2091 -1790
  144. package/dist/scopes/index.d.ts +640 -353
  145. package/dist/scopes/index.d.ts.map +1 -1
  146. package/dist/scopes/index.js +340 -300
  147. package/opencrvs-toolkit-1.9.12-rc.d4e5c22.tgz +0 -0
  148. package/package.json +18 -8
  149. package/tsconfig.json +12 -2
  150. package/tsconfig.tsbuildinfo +1 -1
  151. package/dist/commons/events/CreatedAtLocation.d.ts +0 -2
@@ -0,0 +1,267 @@
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 DEFINE_WORKQUEUES_NAME = 'defineWorkqueues';
49
+ const QUERY_PROPERTY_NAME = 'query';
50
+ const TYPE_PROPERTY_NAME = 'type';
51
+ const CLAUSES_PROPERTY_NAME = 'clauses';
52
+ const STATUS_PROPERTY_NAME = 'status';
53
+ const FLAGS_PROPERTY_NAME = 'flags';
54
+ const TERMS_PROPERTY_NAME = 'terms';
55
+ const TERM_PROPERTY_NAME = 'term';
56
+ const ANY_OF_PROPERTY_NAME = 'anyOf';
57
+ const VALIDATED_STATUS_VALUE = 'VALIDATED';
58
+ const VALIDATED_FLAG_VALUE = 'validated';
59
+ // ─── Helpers ─────────────────────────────────────────────────────────────────
60
+ /**
61
+ * Adds `'validated'` to `flags.anyOf` on a clause object, merging with
62
+ * whatever `flags` shape already exists.
63
+ */
64
+ function addValidatedFlag(clause) {
65
+ const flagsProperty = clause.getProperty(FLAGS_PROPERTY_NAME);
66
+ if (flagsProperty && ts_morph_1.Node.isPropertyAssignment(flagsProperty)) {
67
+ const flagsInit = flagsProperty.getInitializer();
68
+ if (flagsInit && ts_morph_1.Node.isObjectLiteralExpression(flagsInit)) {
69
+ const anyOfProperty = flagsInit.getProperty(ANY_OF_PROPERTY_NAME);
70
+ if (anyOfProperty && ts_morph_1.Node.isPropertyAssignment(anyOfProperty)) {
71
+ // Append to existing anyOf array
72
+ const anyOfInit = anyOfProperty.getInitializer();
73
+ if (anyOfInit && ts_morph_1.Node.isArrayLiteralExpression(anyOfInit)) {
74
+ anyOfInit.addElement(`'${VALIDATED_FLAG_VALUE}'`);
75
+ }
76
+ }
77
+ else {
78
+ // flags exists but has no anyOf — add it
79
+ flagsInit.addPropertyAssignment({
80
+ name: ANY_OF_PROPERTY_NAME,
81
+ initializer: `['${VALIDATED_FLAG_VALUE}']`
82
+ });
83
+ }
84
+ }
85
+ }
86
+ else {
87
+ // No flags property at all — add one
88
+ clause.addPropertyAssignment({
89
+ name: FLAGS_PROPERTY_NAME,
90
+ initializer: `{ ${ANY_OF_PROPERTY_NAME}: ['${VALIDATED_FLAG_VALUE}'] }`
91
+ });
92
+ }
93
+ }
94
+ /**
95
+ * Processes a single leaf clause object.
96
+ * Returns true if any change was made.
97
+ */
98
+ function migrateClause(clause) {
99
+ const statusProperty = clause.getProperty(STATUS_PROPERTY_NAME);
100
+ if (!statusProperty || !ts_morph_1.Node.isPropertyAssignment(statusProperty)) {
101
+ return false;
102
+ }
103
+ const statusInit = statusProperty.getInitializer();
104
+ if (!statusInit || !ts_morph_1.Node.isObjectLiteralExpression(statusInit)) {
105
+ return false;
106
+ }
107
+ const statusTypeProperty = statusInit.getProperty(TYPE_PROPERTY_NAME);
108
+ if (!statusTypeProperty || !ts_morph_1.Node.isPropertyAssignment(statusTypeProperty)) {
109
+ return false;
110
+ }
111
+ const statusTypeInit = statusTypeProperty.getInitializer();
112
+ if (!statusTypeInit || !ts_morph_1.Node.isStringLiteral(statusTypeInit)) {
113
+ return false;
114
+ }
115
+ const statusType = statusTypeInit.getLiteralValue();
116
+ // ── anyOf case ──────────────────────────────────────────────────────────────
117
+ if (statusType === 'anyOf') {
118
+ const termsProperty = statusInit.getProperty(TERMS_PROPERTY_NAME);
119
+ if (!termsProperty || !ts_morph_1.Node.isPropertyAssignment(termsProperty)) {
120
+ return false;
121
+ }
122
+ const termsInit = termsProperty.getInitializer();
123
+ if (!termsInit || !ts_morph_1.Node.isArrayLiteralExpression(termsInit)) {
124
+ return false;
125
+ }
126
+ const elements = termsInit.getElements();
127
+ const validatedIndex = elements.findIndex((el) => ts_morph_1.Node.isStringLiteral(el) &&
128
+ el.getLiteralValue() === VALIDATED_STATUS_VALUE);
129
+ if (validatedIndex === -1)
130
+ return false;
131
+ // Remove 'VALIDATED' from terms
132
+ termsInit.removeElement(validatedIndex);
133
+ // If terms is now empty, drop the whole status property
134
+ if (termsInit.getElements().length === 0) {
135
+ statusProperty.remove();
136
+ }
137
+ addValidatedFlag(clause);
138
+ return true;
139
+ }
140
+ // ── exact case ──────────────────────────────────────────────────────────────
141
+ if (statusType === 'exact') {
142
+ const termProperty = statusInit.getProperty(TERM_PROPERTY_NAME);
143
+ if (!termProperty || !ts_morph_1.Node.isPropertyAssignment(termProperty)) {
144
+ return false;
145
+ }
146
+ const termInit = termProperty.getInitializer();
147
+ if (!termInit || !ts_morph_1.Node.isStringLiteral(termInit)) {
148
+ return false;
149
+ }
150
+ if (termInit.getLiteralValue() !== VALIDATED_STATUS_VALUE)
151
+ return false;
152
+ // Remove the entire status property
153
+ statusProperty.remove();
154
+ addValidatedFlag(clause);
155
+ return true;
156
+ }
157
+ return false;
158
+ }
159
+ /**
160
+ * Recursively walks a query node.
161
+ * - If it is an `or`/`and` container, recurses into `clauses`
162
+ * - Otherwise treats it as a leaf clause and calls `migrateClause`
163
+ * Returns the number of clauses changed.
164
+ */
165
+ function walkQuery(queryObj) {
166
+ const typeProperty = queryObj.getProperty(TYPE_PROPERTY_NAME);
167
+ if (typeProperty && ts_morph_1.Node.isPropertyAssignment(typeProperty)) {
168
+ const typeInit = typeProperty.getInitializer();
169
+ if (typeInit &&
170
+ ts_morph_1.Node.isStringLiteral(typeInit) &&
171
+ (typeInit.getLiteralValue() === 'or' ||
172
+ typeInit.getLiteralValue() === 'and')) {
173
+ const clausesProperty = queryObj.getProperty(CLAUSES_PROPERTY_NAME);
174
+ if (!clausesProperty || !ts_morph_1.Node.isPropertyAssignment(clausesProperty)) {
175
+ return 0;
176
+ }
177
+ const clausesInit = clausesProperty.getInitializer();
178
+ if (!clausesInit || !ts_morph_1.Node.isArrayLiteralExpression(clausesInit)) {
179
+ return 0;
180
+ }
181
+ let changed = 0;
182
+ for (const clause of clausesInit.getElements()) {
183
+ if (ts_morph_1.Node.isObjectLiteralExpression(clause)) {
184
+ changed += walkQuery(clause);
185
+ }
186
+ }
187
+ return changed;
188
+ }
189
+ }
190
+ // Leaf clause
191
+ return migrateClause(queryObj) ? 1 : 0;
192
+ }
193
+ // ─── File processor ──────────────────────────────────────────────────────────
194
+ function processFile(filePath, project) {
195
+ const sourceFile = project.getSourceFile(filePath);
196
+ if (!sourceFile)
197
+ return 0;
198
+ let migratedCount = 0;
199
+ const callExpressions = sourceFile.getDescendantsOfKind(ts_morph_1.SyntaxKind.CallExpression);
200
+ for (const call of callExpressions) {
201
+ const expression = call.getExpression();
202
+ if (!ts_morph_1.Node.isIdentifier(expression) ||
203
+ expression.getText() !== DEFINE_WORKQUEUES_NAME) {
204
+ continue;
205
+ }
206
+ const args = call.getArguments();
207
+ if (args.length === 0)
208
+ continue;
209
+ // The argument must be an array literal of workqueue config objects
210
+ const workqueuesArg = args[0];
211
+ if (!ts_morph_1.Node.isArrayLiteralExpression(workqueuesArg))
212
+ continue;
213
+ for (const workqueueElement of workqueuesArg.getElements()) {
214
+ if (!ts_morph_1.Node.isObjectLiteralExpression(workqueueElement))
215
+ continue;
216
+ const queryProperty = workqueueElement.getProperty(QUERY_PROPERTY_NAME);
217
+ if (!queryProperty || !ts_morph_1.Node.isPropertyAssignment(queryProperty))
218
+ continue;
219
+ const queryInit = queryProperty.getInitializer();
220
+ if (!queryInit || !ts_morph_1.Node.isObjectLiteralExpression(queryInit))
221
+ continue;
222
+ const changed = walkQuery(queryInit);
223
+ if (changed > 0) {
224
+ migratedCount += changed;
225
+ console.log(` [${path_1.default.relative(process.cwd(), filePath)}] Migrated ${changed} clause(s): VALIDATED status → flags.anyOf`);
226
+ }
227
+ }
228
+ }
229
+ return migratedCount;
230
+ }
231
+ // ─── Entry point ─────────────────────────────────────────────────────────────
232
+ function main() {
233
+ return __awaiter(this, void 0, void 0, function* () {
234
+ const srcDir = path_1.default.join(process.cwd(), 'src');
235
+ console.log(`Scanning for defineWorkqueues calls in: ${srcDir}\n`);
236
+ const project = new ts_morph_1.Project({
237
+ tsConfigFilePath: path_1.default.resolve(srcDir, '../tsconfig.json'),
238
+ skipAddingFilesFromTsConfig: false
239
+ });
240
+ const sourceFiles = project.getSourceFiles().filter((sf) => {
241
+ const fp = sf.getFilePath();
242
+ return fp.includes('/src/') && !fp.includes('/node_modules/');
243
+ });
244
+ console.log(`Found ${sourceFiles.length} source file(s) to analyse.\n`);
245
+ let totalMigrated = 0;
246
+ const modifiedFiles = [];
247
+ for (const sourceFile of sourceFiles) {
248
+ const filePath = sourceFile.getFilePath();
249
+ const migrated = processFile(filePath, project);
250
+ if (migrated > 0) {
251
+ totalMigrated += migrated;
252
+ modifiedFiles.push(filePath);
253
+ }
254
+ }
255
+ if (modifiedFiles.length === 0) {
256
+ console.log('No VALIDATED status references found in defineWorkqueues calls. Nothing to do.');
257
+ return;
258
+ }
259
+ console.log(`\nSaving ${modifiedFiles.length} modified file(s)...`);
260
+ for (const filePath of modifiedFiles) {
261
+ const sourceFile = project.getSourceFileOrThrow(filePath);
262
+ yield sourceFile.save();
263
+ console.log(` Saved: ${path_1.default.relative(process.cwd(), filePath)}`);
264
+ }
265
+ console.log(`\nDone. Migrated ${totalMigrated} clause(s) from VALIDATED status to flags.anyOf['validated'].`);
266
+ });
267
+ }
@@ -0,0 +1,3 @@
1
+ declare function main(): Promise<void>;
2
+ export { main };
3
+ //# sourceMappingURL=migrate-workqueue-configs.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"migrate-workqueue-configs.d.ts","sourceRoot":"","sources":["../../../src/migrations/v2.0/migrate-workqueue-configs.ts"],"names":[],"mappings":"AA+OA,iBAAe,IAAI,kBAqDlB;AAED,OAAO,EAAE,IAAI,EAAE,CAAA"}
@@ -0,0 +1,236 @@
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 deprecated workqueue `actions` array to singular `action`.
28
+ *
29
+ * Usage:
30
+ * ts-node -r tsconfig-paths/register src/migrations/v2.0/migrate-workqueue-configs.ts
31
+ *
32
+ * What it does:
33
+ * - Scans TypeScript files under `src/`
34
+ * - Finds `defineWorkqueues([...])` calls
35
+ * - For each workqueue object:
36
+ * - `actions: []` -> removes `actions`
37
+ * - `actions: [{ ... }]` -> replaces with `action: { ... }` if type is supported
38
+ * - `actions: [{ type: 'DEFAULT' }]` -> removes `actions` and does not create `action`
39
+ * - `actions: [{...}, {...}, ...]` -> keeps first as `action`, warns about dropped extras
40
+ * - If `action` already exists, removes deprecated `actions` and keeps `action`
41
+ * - Removes unsupported `action.type` values (`DEFAULT`, `VALIDATE`, etc.)
42
+ * - Saves modified files in-place
43
+ */
44
+ const ts_morph_1 = require("ts-morph");
45
+ const path_1 = __importDefault(require("path"));
46
+ const DEFINE_WORKQUEUES_NAME = 'defineWorkqueues';
47
+ const ACTIONS_PROPERTY_NAME = 'actions';
48
+ const ACTION_PROPERTY_NAME = 'action';
49
+ const CONDITIONALS_PROPERTY_NAME = 'conditionals';
50
+ const TYPE_PROPERTY_NAME = 'type';
51
+ const SLUG_PROPERTY_NAME = 'slug';
52
+ const SUPPORTED_WORKQUEUE_ACTION_TYPES = new Set([
53
+ 'READ',
54
+ 'DELETE',
55
+ 'DECLARE',
56
+ 'REGISTER',
57
+ 'EDIT',
58
+ 'REJECT',
59
+ 'MARK_AS_DUPLICATE',
60
+ 'ARCHIVE',
61
+ 'PRINT_CERTIFICATE',
62
+ 'REQUEST_CORRECTION'
63
+ ]);
64
+ function getWorkqueueLabel(workqueue) {
65
+ const slugProperty = workqueue.getProperty(SLUG_PROPERTY_NAME);
66
+ if (!slugProperty || !ts_morph_1.Node.isPropertyAssignment(slugProperty)) {
67
+ return '(unknown slug)';
68
+ }
69
+ const slugInitializer = slugProperty.getInitializer();
70
+ if (!slugInitializer || !ts_morph_1.Node.isStringLiteral(slugInitializer)) {
71
+ return '(unknown slug)';
72
+ }
73
+ return slugInitializer.getLiteralValue();
74
+ }
75
+ function getActionTypeName(action) {
76
+ const typeProperty = action.getProperty(TYPE_PROPERTY_NAME);
77
+ if (!typeProperty || !ts_morph_1.Node.isPropertyAssignment(typeProperty)) {
78
+ return null;
79
+ }
80
+ const typeInitializer = typeProperty.getInitializer();
81
+ if (!typeInitializer) {
82
+ return null;
83
+ }
84
+ if (ts_morph_1.Node.isStringLiteral(typeInitializer)) {
85
+ return typeInitializer.getLiteralValue();
86
+ }
87
+ if (ts_morph_1.Node.isPropertyAccessExpression(typeInitializer)) {
88
+ return typeInitializer.getName();
89
+ }
90
+ return null;
91
+ }
92
+ function isUnsupportedActionType(action) {
93
+ const typeName = getActionTypeName(action);
94
+ if (!typeName) {
95
+ return false;
96
+ }
97
+ return !SUPPORTED_WORKQUEUE_ACTION_TYPES.has(typeName);
98
+ }
99
+ function migrateWorkqueueActions(workqueue, relPath) {
100
+ const actionsProperty = workqueue.getProperty(ACTIONS_PROPERTY_NAME);
101
+ if (!actionsProperty || !ts_morph_1.Node.isPropertyAssignment(actionsProperty)) {
102
+ return 0;
103
+ }
104
+ const actionsInitializer = actionsProperty.getInitializer();
105
+ if (!actionsInitializer || !ts_morph_1.Node.isArrayLiteralExpression(actionsInitializer)) {
106
+ return 0;
107
+ }
108
+ const workqueueLabel = getWorkqueueLabel(workqueue);
109
+ const existingActionProperty = workqueue.getProperty(ACTION_PROPERTY_NAME);
110
+ if (existingActionProperty) {
111
+ if (ts_morph_1.Node.isPropertyAssignment(existingActionProperty)) {
112
+ const existingActionInitializer = existingActionProperty.getInitializer();
113
+ if (existingActionInitializer && ts_morph_1.Node.isObjectLiteralExpression(existingActionInitializer)) {
114
+ const conditionalsProperty = existingActionInitializer.getProperty(CONDITIONALS_PROPERTY_NAME);
115
+ if (conditionalsProperty) {
116
+ conditionalsProperty.remove();
117
+ // eslint-disable-next-line no-console
118
+ console.log(` [${relPath}] Removed deprecated 'conditionals' from 'action' on workqueue '${workqueueLabel}'`);
119
+ }
120
+ if (isUnsupportedActionType(existingActionInitializer)) {
121
+ existingActionProperty.remove();
122
+ // eslint-disable-next-line no-console
123
+ console.log(` [${relPath}] Removed unsupported 'action' type on workqueue '${workqueueLabel}'`);
124
+ }
125
+ }
126
+ }
127
+ actionsProperty.remove();
128
+ // eslint-disable-next-line no-console
129
+ console.log(` [${relPath}] Removed deprecated 'actions' from workqueue '${workqueueLabel}' (existing 'action' kept)`);
130
+ return 1;
131
+ }
132
+ const actionCandidates = actionsInitializer
133
+ .getElements()
134
+ .filter((element) => ts_morph_1.Node.isObjectLiteralExpression(element));
135
+ if (actionCandidates.length === 0) {
136
+ actionsProperty.remove();
137
+ // eslint-disable-next-line no-console
138
+ console.log(` [${relPath}] Removed empty 'actions' from workqueue '${workqueueLabel}'`);
139
+ return 1;
140
+ }
141
+ if (actionCandidates.length > 1) {
142
+ const droppedCount = actionCandidates.length - 1;
143
+ // eslint-disable-next-line no-console
144
+ console.warn(` [${relPath}] Workqueue '${workqueueLabel}' has ${actionCandidates.length} actions; keeping first as 'action' and dropping ${droppedCount} extra action(s)`);
145
+ }
146
+ const conditionalsProperty = actionCandidates[0].getProperty(CONDITIONALS_PROPERTY_NAME);
147
+ if (conditionalsProperty) {
148
+ conditionalsProperty.remove();
149
+ // eslint-disable-next-line no-console
150
+ console.log(` [${relPath}] Removed deprecated 'conditionals' from migrated 'action' on workqueue '${workqueueLabel}'`);
151
+ }
152
+ if (isUnsupportedActionType(actionCandidates[0])) {
153
+ actionsProperty.remove();
154
+ // eslint-disable-next-line no-console
155
+ console.log(` [${relPath}] Removed deprecated 'actions' from workqueue '${workqueueLabel}' because action type is unsupported`);
156
+ return 1;
157
+ }
158
+ const firstActionText = actionCandidates[0].getText();
159
+ workqueue.addPropertyAssignment({
160
+ name: ACTION_PROPERTY_NAME,
161
+ initializer: firstActionText
162
+ });
163
+ actionsProperty.remove();
164
+ // eslint-disable-next-line no-console
165
+ console.log(` [${relPath}] Replaced 'actions' with 'action' on workqueue '${workqueueLabel}'`);
166
+ return 1;
167
+ }
168
+ function processFile(filePath, project) {
169
+ const sourceFile = project.getSourceFile(filePath);
170
+ if (!sourceFile)
171
+ return 0;
172
+ let migratedWorkqueues = 0;
173
+ const relPath = path_1.default.relative(process.cwd(), filePath);
174
+ const callExpressions = sourceFile.getDescendantsOfKind(ts_morph_1.SyntaxKind.CallExpression);
175
+ for (const call of callExpressions) {
176
+ const expression = call.getExpression();
177
+ if (!ts_morph_1.Node.isIdentifier(expression) ||
178
+ expression.getText() !== DEFINE_WORKQUEUES_NAME) {
179
+ continue;
180
+ }
181
+ const args = call.getArguments();
182
+ if (args.length === 0)
183
+ continue;
184
+ const workqueuesArg = args[0];
185
+ if (!ts_morph_1.Node.isArrayLiteralExpression(workqueuesArg))
186
+ continue;
187
+ for (const element of workqueuesArg.getElements()) {
188
+ if (!ts_morph_1.Node.isObjectLiteralExpression(element))
189
+ continue;
190
+ migratedWorkqueues += migrateWorkqueueActions(element, relPath);
191
+ }
192
+ }
193
+ return migratedWorkqueues;
194
+ }
195
+ function main() {
196
+ return __awaiter(this, void 0, void 0, function* () {
197
+ const srcDir = path_1.default.join(process.cwd(), 'src');
198
+ // eslint-disable-next-line no-console
199
+ console.log(`Scanning for defineWorkqueues calls in: ${srcDir}\n`);
200
+ const project = new ts_morph_1.Project({
201
+ tsConfigFilePath: path_1.default.resolve(srcDir, '../tsconfig.json'),
202
+ skipAddingFilesFromTsConfig: false
203
+ });
204
+ const sourceFiles = project.getSourceFiles().filter((sf) => {
205
+ const fp = sf.getFilePath();
206
+ return fp.includes('/src/') && !fp.includes('/node_modules/');
207
+ });
208
+ // eslint-disable-next-line no-console
209
+ console.log(`Found ${sourceFiles.length} source file(s) to analyse.\n`);
210
+ let totalMigrated = 0;
211
+ const modifiedFiles = [];
212
+ for (const sourceFile of sourceFiles) {
213
+ const filePath = sourceFile.getFilePath();
214
+ const migrated = processFile(filePath, project);
215
+ if (migrated > 0) {
216
+ totalMigrated += migrated;
217
+ modifiedFiles.push(filePath);
218
+ }
219
+ }
220
+ if (modifiedFiles.length === 0) {
221
+ // eslint-disable-next-line no-console
222
+ console.log("No deprecated workqueue 'actions' arrays found inside defineWorkqueues calls. Nothing to do.");
223
+ return;
224
+ }
225
+ // eslint-disable-next-line no-console
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
+ // eslint-disable-next-line no-console
231
+ console.log(` Saved: ${path_1.default.relative(process.cwd(), filePath)}`);
232
+ }
233
+ // eslint-disable-next-line no-console
234
+ console.log(`\nDone. Migrated ${totalMigrated} deprecated workqueue 'actions' definition(s) to 'action'.`);
235
+ });
236
+ }
@@ -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":"AAyIA,iBAAe,IAAI,kBAiDlB;AAED,OAAO,EAAE,IAAI,EAAE,CAAA"}
@@ -0,0 +1,156 @@
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 DEFINE_CONFIG_NAME = 'defineConfig';
43
+ const ACTIONS_PROPERTY_NAME = 'actions';
44
+ const TYPE_PROPERTY_NAME = 'type';
45
+ const ACTION_TYPE_ENUM_NAME = 'ActionType';
46
+ const DELETE_MEMBER_NAME = 'DELETE';
47
+ const DELETE_STRING_LITERAL = 'DELETE';
48
+ function isDeleteType(typeInitializer) {
49
+ // Matches: ActionType.DELETE
50
+ if (typeInitializer.getKind() === ts_morph_1.SyntaxKind.PropertyAccessExpression) {
51
+ const propAccess = typeInitializer.asKindOrThrow(ts_morph_1.SyntaxKind.PropertyAccessExpression);
52
+ const obj = propAccess.getExpression();
53
+ const member = propAccess.getName();
54
+ return (ts_morph_1.Node.isIdentifier(obj) &&
55
+ obj.getText() === ACTION_TYPE_ENUM_NAME &&
56
+ member === DELETE_MEMBER_NAME);
57
+ }
58
+ // Matches: "DELETE"
59
+ if (typeInitializer.getKind() === ts_morph_1.SyntaxKind.StringLiteral) {
60
+ return (typeInitializer
61
+ .asKindOrThrow(ts_morph_1.SyntaxKind.StringLiteral)
62
+ .getLiteralValue() === DELETE_STRING_LITERAL);
63
+ }
64
+ return false;
65
+ }
66
+ function isDeleteAction(obj) {
67
+ const typeProperty = obj.getProperty(TYPE_PROPERTY_NAME);
68
+ if (!typeProperty || !ts_morph_1.Node.isPropertyAssignment(typeProperty)) {
69
+ return false;
70
+ }
71
+ const typeInitializer = typeProperty.getInitializer();
72
+ return !!typeInitializer && isDeleteType(typeInitializer);
73
+ }
74
+ function processFile(filePath, project) {
75
+ const sourceFile = project.getSourceFile(filePath);
76
+ if (!sourceFile)
77
+ return 0;
78
+ let removedCount = 0;
79
+ // Find all call expressions named `defineConfig`
80
+ const callExpressions = sourceFile.getDescendantsOfKind(ts_morph_1.SyntaxKind.CallExpression);
81
+ for (const call of callExpressions) {
82
+ const expression = call.getExpression();
83
+ // Only interested in bare `defineConfig(...)` calls
84
+ if (!ts_morph_1.Node.isIdentifier(expression) ||
85
+ expression.getText() !== DEFINE_CONFIG_NAME) {
86
+ continue;
87
+ }
88
+ const args = call.getArguments();
89
+ if (args.length === 0)
90
+ continue;
91
+ // The first argument should be the config object literal
92
+ const configArg = args[0];
93
+ if (!ts_morph_1.Node.isObjectLiteralExpression(configArg))
94
+ continue;
95
+ // Find the `actions` property inside the config object
96
+ const actionsProperty = configArg.getProperty(ACTIONS_PROPERTY_NAME);
97
+ if (!actionsProperty || !ts_morph_1.Node.isPropertyAssignment(actionsProperty))
98
+ continue;
99
+ const actionsInitializer = actionsProperty.getInitializer();
100
+ if (!actionsInitializer ||
101
+ !ts_morph_1.Node.isArrayLiteralExpression(actionsInitializer))
102
+ continue;
103
+ // Collect indices of DELETE actions in reverse order so removal doesn't
104
+ // shift the indices of elements yet to be processed
105
+ const indicesToRemove = [];
106
+ actionsInitializer.getElements().forEach((element, index) => {
107
+ if (ts_morph_1.Node.isObjectLiteralExpression(element) && isDeleteAction(element)) {
108
+ indicesToRemove.push(index);
109
+ }
110
+ });
111
+ for (const index of indicesToRemove.reverse()) {
112
+ actionsInitializer.removeElement(index);
113
+ removedCount++;
114
+ console.log(` [${path_1.default.relative(process.cwd(), filePath)}] Removed DELETE action at index ${index}`);
115
+ }
116
+ }
117
+ return removedCount;
118
+ }
119
+ function main() {
120
+ return __awaiter(this, void 0, void 0, function* () {
121
+ const srcDir = path_1.default.join(process.cwd(), 'src');
122
+ console.log(`Scanning for defineConfig calls in: ${srcDir}\n`);
123
+ const project = new ts_morph_1.Project({
124
+ tsConfigFilePath: path_1.default.resolve(srcDir, '../tsconfig.json'),
125
+ // Do not emit — we only manipulate source files
126
+ skipAddingFilesFromTsConfig: false
127
+ });
128
+ // Restrict to source files only (exclude node_modules, build artefacts, etc.)
129
+ const sourceFiles = project.getSourceFiles().filter((sf) => {
130
+ const fp = sf.getFilePath();
131
+ return fp.includes('/src/') && !fp.includes('/node_modules/');
132
+ });
133
+ console.log(`Found ${sourceFiles.length} source file(s) to analyse.\n`);
134
+ let totalRemoved = 0;
135
+ const modifiedFiles = [];
136
+ for (const sourceFile of sourceFiles) {
137
+ const filePath = sourceFile.getFilePath();
138
+ const removed = processFile(filePath, project);
139
+ if (removed > 0) {
140
+ totalRemoved += removed;
141
+ modifiedFiles.push(filePath);
142
+ }
143
+ }
144
+ if (modifiedFiles.length === 0) {
145
+ console.log('No DELETE actions found inside defineConfig calls. Nothing to do.');
146
+ return;
147
+ }
148
+ console.log(`\nSaving ${modifiedFiles.length} modified file(s)...`);
149
+ for (const filePath of modifiedFiles) {
150
+ const sourceFile = project.getSourceFileOrThrow(filePath);
151
+ yield sourceFile.save();
152
+ console.log(` Saved: ${path_1.default.relative(process.cwd(), filePath)}`);
153
+ }
154
+ console.log(`\nDone. Removed ${totalRemoved} DELETE action(s) from defineConfig call(s).`);
155
+ });
156
+ }