@opencrvs/toolkit 2.0.0-rc.b63fd2e → 2.0.0-rc.bee2b7b

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 (76) hide show
  1. package/dist/application-config/index.js +36 -7
  2. package/dist/cli.js +178 -1390
  3. package/dist/commons/events/locations.d.ts +17 -1
  4. package/dist/conditionals/index.js +36 -7
  5. package/dist/events/index.js +74 -7
  6. package/dist/migrations/v2.0/add-birth-certificate-issuance-flag.d.ts.map +1 -1
  7. package/dist/migrations/v2.0/add-birth-certificate-issuance-flag.js +4 -3
  8. package/dist/migrations/v2.0/checkout-upstream-files.d.ts +0 -19
  9. package/dist/migrations/v2.0/checkout-upstream-files.d.ts.map +1 -1
  10. package/dist/migrations/v2.0/checkout-upstream-files.js +13 -17
  11. package/dist/migrations/v2.0/convert-config-files-to-ts.d.ts.map +1 -1
  12. package/dist/migrations/v2.0/convert-config-files-to-ts.js +5 -4
  13. package/dist/migrations/v2.0/convert-paragraph-to-heading.d.ts.map +1 -1
  14. package/dist/migrations/v2.0/convert-paragraph-to-heading.js +5 -4
  15. package/dist/migrations/v2.0/create-events-index.d.ts.map +1 -1
  16. package/dist/migrations/v2.0/create-events-index.js +2 -1
  17. package/dist/migrations/v2.0/index.d.ts +4 -8
  18. package/dist/migrations/v2.0/index.d.ts.map +1 -1
  19. package/dist/migrations/v2.0/index.js +175 -1358
  20. package/dist/migrations/v2.0/make-built-in-validate-actions-custom.d.ts.map +1 -1
  21. package/dist/migrations/v2.0/make-built-in-validate-actions-custom.js +6 -5
  22. package/dist/migrations/v2.0/migrate-scopes.d.ts.map +1 -1
  23. package/dist/migrations/v2.0/migrate-scopes.js +7 -6
  24. package/dist/migrations/v2.0/migrate-validated-workqueue-status-to-flag.d.ts.map +1 -1
  25. package/dist/migrations/v2.0/migrate-validated-workqueue-status-to-flag.js +4 -3
  26. package/dist/migrations/v2.0/migrate-workqueue-configs.d.ts.map +1 -1
  27. package/dist/migrations/v2.0/migrate-workqueue-configs.js +4 -3
  28. package/dist/migrations/v2.0/remove-delete-actions.d.ts.map +1 -1
  29. package/dist/migrations/v2.0/remove-delete-actions.js +4 -3
  30. package/dist/migrations/v2.0/remove-demo-scope.d.ts.map +1 -1
  31. package/dist/migrations/v2.0/remove-demo-scope.js +3 -2
  32. package/dist/migrations/v2.0/remove-deprecated-imports.d.ts.map +1 -1
  33. package/dist/migrations/v2.0/remove-deprecated-imports.js +4 -3
  34. package/dist/migrations/v2.0/remove-hearth-migrations.d.ts.map +1 -1
  35. package/dist/migrations/v2.0/remove-hearth-migrations.js +2 -1
  36. package/dist/migrations/v2.0/remove-pending-certification-flag.d.ts.map +1 -1
  37. package/dist/migrations/v2.0/remove-pending-certification-flag.js +4 -3
  38. package/dist/migrations/v2.0/remove-review-from-register-action.d.ts.map +1 -1
  39. package/dist/migrations/v2.0/remove-review-from-register-action.js +4 -3
  40. package/dist/migrations/v2.0/rename-api-paths.d.ts.map +1 -1
  41. package/dist/migrations/v2.0/rename-api-paths.js +4 -3
  42. package/dist/migrations/v2.0/rename-location-parent-id.d.ts.map +1 -1
  43. package/dist/migrations/v2.0/rename-location-parent-id.js +4 -3
  44. package/dist/migrations/v2.0/simplify-analytics-precalculations.d.ts.map +1 -1
  45. package/dist/migrations/v2.0/simplify-analytics-precalculations.js +2 -1
  46. package/dist/notification/index.js +36 -7
  47. package/dist/scopes/index.d.ts +80 -10
  48. package/dist/scopes/index.js +42 -8
  49. package/opencrvs-toolkit-2.0.0-rc.bee2b7b.tgz +0 -0
  50. package/package.json +1 -1
  51. package/tsconfig.tsbuildinfo +1 -1
  52. package/dist/migrations/v2.0/add-resend-invite-notification.d.ts +0 -3
  53. package/dist/migrations/v2.0/add-resend-invite-notification.d.ts.map +0 -1
  54. package/dist/migrations/v2.0/add-resend-invite-notification.js +0 -373
  55. package/dist/migrations/v2.0/delete-infrastructure-directory.d.ts +0 -3
  56. package/dist/migrations/v2.0/delete-infrastructure-directory.d.ts.map +0 -1
  57. package/dist/migrations/v2.0/delete-infrastructure-directory.js +0 -77
  58. package/dist/migrations/v2.0/merge-infrastructure-directory.d.ts +0 -3
  59. package/dist/migrations/v2.0/merge-infrastructure-directory.d.ts.map +0 -1
  60. package/dist/migrations/v2.0/merge-infrastructure-directory.js +0 -221
  61. package/dist/migrations/v2.0/migrate-application-config-url.d.ts +0 -3
  62. package/dist/migrations/v2.0/migrate-application-config-url.d.ts.map +0 -1
  63. package/dist/migrations/v2.0/migrate-application-config-url.js +0 -342
  64. package/dist/migrations/v2.0/remove-fhir-url-helpers.d.ts +0 -3
  65. package/dist/migrations/v2.0/remove-fhir-url-helpers.d.ts.map +0 -1
  66. package/dist/migrations/v2.0/remove-fhir-url-helpers.js +0 -163
  67. package/dist/migrations/v2.0/remove-old-statistics-service.d.ts +0 -3
  68. package/dist/migrations/v2.0/remove-old-statistics-service.d.ts.map +0 -1
  69. package/dist/migrations/v2.0/remove-old-statistics-service.js +0 -356
  70. package/dist/migrations/v2.0/remove-unused-environment-variables.d.ts +0 -3
  71. package/dist/migrations/v2.0/remove-unused-environment-variables.d.ts.map +0 -1
  72. package/dist/migrations/v2.0/remove-unused-environment-variables.js +0 -186
  73. package/dist/migrations/v2.0/update-package-json.d.ts +0 -3
  74. package/dist/migrations/v2.0/update-package-json.d.ts.map +0 -1
  75. package/dist/migrations/v2.0/update-package-json.js +0 -105
  76. package/opencrvs-toolkit-2.0.0-rc.b63fd2e.tgz +0 -0
@@ -1 +1 @@
1
- {"version":3,"file":"make-built-in-validate-actions-custom.d.ts","sourceRoot":"","sources":["../../../src/migrations/v2.0/make-built-in-validate-actions-custom.ts"],"names":[],"mappings":"AA2WA,iBAAe,IAAI,kBAiDlB;AAED,OAAO,EAAE,IAAI,EAAE,CAAA"}
1
+ {"version":3,"file":"make-built-in-validate-actions-custom.d.ts","sourceRoot":"","sources":["../../../src/migrations/v2.0/make-built-in-validate-actions-custom.ts"],"names":[],"mappings":"AA6WA,iBAAe,IAAI,kBAiDlB;AAED,OAAO,EAAE,IAAI,EAAE,CAAA"}
@@ -45,6 +45,7 @@ exports.main = main;
45
45
  */
46
46
  const ts_morph_1 = require("ts-morph");
47
47
  const path_1 = __importDefault(require("path"));
48
+ const _1 = require(".");
48
49
  const TOOLKIT_EVENTS_MODULE = '@opencrvs/toolkit/events';
49
50
  const REQUIRED_SYMBOLS = [
50
51
  'ConditionalType',
@@ -262,7 +263,7 @@ function processFile(filePath, project) {
262
263
  // Resolve the root event type for use in the auditHistoryLabel id
263
264
  const eventType = resolveEventType(configArg);
264
265
  if (!eventType) {
265
- console.warn(` [${path_1.default.relative(process.cwd(), configArg.getSourceFile().getFilePath())}] Could not resolve root 'type' from defineConfig — skipping auditHistoryLabel id generation`);
266
+ console.warn(` [${path_1.default.relative((0, _1.getCwd)(), configArg.getSourceFile().getFilePath())}] Could not resolve root 'type' from defineConfig — skipping auditHistoryLabel id generation`);
266
267
  }
267
268
  // Iterate over every element in the `actions` array
268
269
  let fileNeedsImports = false;
@@ -275,7 +276,7 @@ function processFile(filePath, project) {
275
276
  transformedCount++;
276
277
  fileNeedsImports = true;
277
278
  configHadValidateAction = true;
278
- console.log(` [${path_1.default.relative(process.cwd(), filePath)}] Transformed VALIDATE action to CUSTOM with customActionType: '${VALIDATE_DECLARATION_VALUE}'`);
279
+ console.log(` [${path_1.default.relative((0, _1.getCwd)(), filePath)}] Transformed VALIDATE action to CUSTOM with customActionType: '${VALIDATE_DECLARATION_VALUE}'`);
279
280
  }
280
281
  }
281
282
  // Add top-level flags array to the config object if a VALIDATE action was found
@@ -295,7 +296,7 @@ function processFile(filePath, project) {
295
296
  }
296
297
  ]`
297
298
  });
298
- console.log(` [${path_1.default.relative(process.cwd(), filePath)}] Added top-level 'flags' array to defineConfig`);
299
+ console.log(` [${path_1.default.relative((0, _1.getCwd)(), filePath)}] Added top-level 'flags' array to defineConfig`);
299
300
  }
300
301
  if (fileNeedsImports) {
301
302
  ensureImports(sourceFile);
@@ -305,7 +306,7 @@ function processFile(filePath, project) {
305
306
  }
306
307
  function main() {
307
308
  return __awaiter(this, void 0, void 0, function* () {
308
- const srcDir = path_1.default.join(process.cwd(), 'src');
309
+ const srcDir = path_1.default.join((0, _1.getCwd)(), 'src');
309
310
  console.log(`Scanning for defineConfig calls in: ${srcDir}\n`);
310
311
  const project = new ts_morph_1.Project({
311
312
  tsConfigFilePath: path_1.default.resolve(srcDir, '../tsconfig.json'),
@@ -336,7 +337,7 @@ function main() {
336
337
  for (const filePath of modifiedFiles) {
337
338
  const sourceFile = project.getSourceFileOrThrow(filePath);
338
339
  yield sourceFile.save();
339
- console.log(` Saved: ${path_1.default.relative(process.cwd(), filePath)}`);
340
+ console.log(` Saved: ${path_1.default.relative((0, _1.getCwd)(), filePath)}`);
340
341
  }
341
342
  console.log(`\nDone. Transformed ${totalTransformed} VALIDATE action(s) to CUSTOM with customActionType: '${VALIDATE_DECLARATION_VALUE}'.`);
342
343
  });
@@ -1 +1 @@
1
- {"version":3,"file":"migrate-scopes.d.ts","sourceRoot":"","sources":["../../../src/migrations/v2.0/migrate-scopes.ts"],"names":[],"mappings":"AAyVA,iBAAe,IAAI,kBAmDlB;AAED,OAAO,EAAE,IAAI,EAAE,CAAA"}
1
+ {"version":3,"file":"migrate-scopes.d.ts","sourceRoot":"","sources":["../../../src/migrations/v2.0/migrate-scopes.ts"],"names":[],"mappings":"AA2VA,iBAAe,IAAI,kBAmDlB;AAED,OAAO,EAAE,IAAI,EAAE,CAAA"}
@@ -27,6 +27,7 @@ const ts_morph_1 = require("ts-morph");
27
27
  const path_1 = __importDefault(require("path"));
28
28
  const scopes_1 = require("../commons/scopes");
29
29
  const scopes_deprecated_do_not_use_1 = require("../commons/scopes.deprecated.do-not-use");
30
+ const _1 = require(".");
30
31
  const ROLES_FILE_RELATIVE_PATH = 'src/data-seeding/roles/roles.ts';
31
32
  const SCOPES_PROPERTY_NAME = 'scopes';
32
33
  const TOOLKIT_SCOPES_MODULE = '@opencrvs/toolkit/scopes';
@@ -86,7 +87,7 @@ function migrateScopesArrays(rolesFilePath, project) {
86
87
  const scopeKey = resolveScopeKeyFromElementAccess(element);
87
88
  if (scopeKey && !(scopeKey in scopes_deprecated_do_not_use_1.SCOPES)) {
88
89
  // eslint-disable-next-line no-console
89
- console.warn(` [${path_1.default.relative(process.cwd(), rolesFilePath)}] Removing unknown scope reference: SCOPES.${scopeKey}`);
90
+ console.warn(` [${path_1.default.relative((0, _1.getCwd)(), rolesFilePath)}] Removing unknown scope reference: SCOPES.${scopeKey}`);
90
91
  initializer.removeElement(index);
91
92
  removedCount++;
92
93
  continue;
@@ -94,7 +95,7 @@ function migrateScopesArrays(rolesFilePath, project) {
94
95
  const legacyScope = resolveLegacyScopeFromElement(element);
95
96
  if (!legacyScope) {
96
97
  // eslint-disable-next-line no-console
97
- console.warn(` [${path_1.default.relative(process.cwd(), rolesFilePath)}] Skipping non-literal scope expression: ${element.getText()}`);
98
+ console.warn(` [${path_1.default.relative((0, _1.getCwd)(), rolesFilePath)}] Skipping non-literal scope expression: ${element.getText()}`);
98
99
  continue;
99
100
  }
100
101
  try {
@@ -102,7 +103,7 @@ function migrateScopesArrays(rolesFilePath, project) {
102
103
  const scope = (0, scopes_1.decodeScope)(migratedScope);
103
104
  if (!scope) {
104
105
  // eslint-disable-next-line no-console
105
- console.warn(` [${path_1.default.relative(process.cwd(), rolesFilePath)}] Could not decode migrated scope '${migratedScope}'.`);
106
+ console.warn(` [${path_1.default.relative((0, _1.getCwd)(), rolesFilePath)}] Could not decode migrated scope '${migratedScope}'.`);
106
107
  continue;
107
108
  }
108
109
  element.replaceWithText(JSON.stringify(scope));
@@ -110,13 +111,13 @@ function migrateScopesArrays(rolesFilePath, project) {
110
111
  }
111
112
  catch (error) {
112
113
  // eslint-disable-next-line no-console
113
- console.warn(` [${path_1.default.relative(process.cwd(), rolesFilePath)}] Could not migrate scope '${legacyScope}': ${error}`);
114
+ console.warn(` [${path_1.default.relative((0, _1.getCwd)(), rolesFilePath)}] Could not migrate scope '${legacyScope}': ${error}`);
114
115
  }
115
116
  }
116
117
  }
117
118
  if (removedCount > 0) {
118
119
  // eslint-disable-next-line no-console
119
- console.log(` Removed ${removedCount} unknown SCOPES reference(s) from '${path_1.default.relative(process.cwd(), rolesFilePath)}'.`);
120
+ console.log(` Removed ${removedCount} unknown SCOPES reference(s) from '${path_1.default.relative((0, _1.getCwd)(), rolesFilePath)}'.`);
120
121
  }
121
122
  return { migratedCount, removedCount };
122
123
  }
@@ -248,7 +249,7 @@ function removeRoleTypeDefinitionAndUnusedImports(rolesFilePath, project) {
248
249
  }
249
250
  function main() {
250
251
  return __awaiter(this, void 0, void 0, function* () {
251
- const cwd = process.cwd();
252
+ const cwd = (0, _1.getCwd)();
252
253
  const srcDir = path_1.default.join(cwd, 'src');
253
254
  const rolesFilePath = path_1.default.join(cwd, ROLES_FILE_RELATIVE_PATH);
254
255
  console.log(`Scanning roles scopes in: ${rolesFilePath}`);
@@ -1 +1 @@
1
- {"version":3,"file":"migrate-validated-workqueue-status-to-flag.d.ts","sourceRoot":"","sources":["../../../src/migrations/v2.0/migrate-validated-workqueue-status-to-flag.ts"],"names":[],"mappings":"AAyQA,iBAAe,IAAI,kBA+ClB;AAED,OAAO,EAAE,IAAI,EAAE,CAAA"}
1
+ {"version":3,"file":"migrate-validated-workqueue-status-to-flag.d.ts","sourceRoot":"","sources":["../../../src/migrations/v2.0/migrate-validated-workqueue-status-to-flag.ts"],"names":[],"mappings":"AA2QA,iBAAe,IAAI,kBA+ClB;AAED,OAAO,EAAE,IAAI,EAAE,CAAA"}
@@ -45,6 +45,7 @@ exports.main = main;
45
45
  */
46
46
  const ts_morph_1 = require("ts-morph");
47
47
  const path_1 = __importDefault(require("path"));
48
+ const _1 = require(".");
48
49
  const DEFINE_WORKQUEUES_NAME = 'defineWorkqueues';
49
50
  const QUERY_PROPERTY_NAME = 'query';
50
51
  const TYPE_PROPERTY_NAME = 'type';
@@ -222,7 +223,7 @@ function processFile(filePath, project) {
222
223
  const changed = walkQuery(queryInit);
223
224
  if (changed > 0) {
224
225
  migratedCount += changed;
225
- console.log(` [${path_1.default.relative(process.cwd(), filePath)}] Migrated ${changed} clause(s): VALIDATED status → flags.anyOf`);
226
+ console.log(` [${path_1.default.relative((0, _1.getCwd)(), filePath)}] Migrated ${changed} clause(s): VALIDATED status → flags.anyOf`);
226
227
  }
227
228
  }
228
229
  }
@@ -231,7 +232,7 @@ function processFile(filePath, project) {
231
232
  // ─── Entry point ─────────────────────────────────────────────────────────────
232
233
  function main() {
233
234
  return __awaiter(this, void 0, void 0, function* () {
234
- const srcDir = path_1.default.join(process.cwd(), 'src');
235
+ const srcDir = path_1.default.join((0, _1.getCwd)(), 'src');
235
236
  console.log(`Scanning for defineWorkqueues calls in: ${srcDir}\n`);
236
237
  const project = new ts_morph_1.Project({
237
238
  tsConfigFilePath: path_1.default.resolve(srcDir, '../tsconfig.json'),
@@ -260,7 +261,7 @@ function main() {
260
261
  for (const filePath of modifiedFiles) {
261
262
  const sourceFile = project.getSourceFileOrThrow(filePath);
262
263
  yield sourceFile.save();
263
- console.log(` Saved: ${path_1.default.relative(process.cwd(), filePath)}`);
264
+ console.log(` Saved: ${path_1.default.relative((0, _1.getCwd)(), filePath)}`);
264
265
  }
265
266
  console.log(`\nDone. Migrated ${totalMigrated} clause(s) from VALIDATED status to flags.anyOf['validated'].`);
266
267
  });
@@ -1 +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"}
1
+ {"version":3,"file":"migrate-workqueue-configs.d.ts","sourceRoot":"","sources":["../../../src/migrations/v2.0/migrate-workqueue-configs.ts"],"names":[],"mappings":"AAiPA,iBAAe,IAAI,kBAqDlB;AAED,OAAO,EAAE,IAAI,EAAE,CAAA"}
@@ -43,6 +43,7 @@ exports.main = main;
43
43
  */
44
44
  const ts_morph_1 = require("ts-morph");
45
45
  const path_1 = __importDefault(require("path"));
46
+ const _1 = require(".");
46
47
  const DEFINE_WORKQUEUES_NAME = 'defineWorkqueues';
47
48
  const ACTIONS_PROPERTY_NAME = 'actions';
48
49
  const ACTION_PROPERTY_NAME = 'action';
@@ -170,7 +171,7 @@ function processFile(filePath, project) {
170
171
  if (!sourceFile)
171
172
  return 0;
172
173
  let migratedWorkqueues = 0;
173
- const relPath = path_1.default.relative(process.cwd(), filePath);
174
+ const relPath = path_1.default.relative((0, _1.getCwd)(), filePath);
174
175
  const callExpressions = sourceFile.getDescendantsOfKind(ts_morph_1.SyntaxKind.CallExpression);
175
176
  for (const call of callExpressions) {
176
177
  const expression = call.getExpression();
@@ -194,7 +195,7 @@ function processFile(filePath, project) {
194
195
  }
195
196
  function main() {
196
197
  return __awaiter(this, void 0, void 0, function* () {
197
- const srcDir = path_1.default.join(process.cwd(), 'src');
198
+ const srcDir = path_1.default.join((0, _1.getCwd)(), 'src');
198
199
  // eslint-disable-next-line no-console
199
200
  console.log(`Scanning for defineWorkqueues calls in: ${srcDir}\n`);
200
201
  const project = new ts_morph_1.Project({
@@ -228,7 +229,7 @@ function main() {
228
229
  const sourceFile = project.getSourceFileOrThrow(filePath);
229
230
  yield sourceFile.save();
230
231
  // eslint-disable-next-line no-console
231
- console.log(` Saved: ${path_1.default.relative(process.cwd(), filePath)}`);
232
+ console.log(` Saved: ${path_1.default.relative((0, _1.getCwd)(), filePath)}`);
232
233
  }
233
234
  // eslint-disable-next-line no-console
234
235
  console.log(`\nDone. Migrated ${totalMigrated} deprecated workqueue 'actions' definition(s) to 'action'.`);
@@ -1 +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"}
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"}
@@ -39,6 +39,7 @@ exports.main = main;
39
39
  */
40
40
  const ts_morph_1 = require("ts-morph");
41
41
  const path_1 = __importDefault(require("path"));
42
+ const _1 = require(".");
42
43
  const DEFINE_CONFIG_NAME = 'defineConfig';
43
44
  const ACTIONS_PROPERTY_NAME = 'actions';
44
45
  const TYPE_PROPERTY_NAME = 'type';
@@ -111,14 +112,14 @@ function processFile(filePath, project) {
111
112
  for (const index of indicesToRemove.reverse()) {
112
113
  actionsInitializer.removeElement(index);
113
114
  removedCount++;
114
- console.log(` [${path_1.default.relative(process.cwd(), filePath)}] Removed DELETE action at index ${index}`);
115
+ console.log(` [${path_1.default.relative((0, _1.getCwd)(), filePath)}] Removed DELETE action at index ${index}`);
115
116
  }
116
117
  }
117
118
  return removedCount;
118
119
  }
119
120
  function main() {
120
121
  return __awaiter(this, void 0, void 0, function* () {
121
- const srcDir = path_1.default.join(process.cwd(), 'src');
122
+ const srcDir = path_1.default.join((0, _1.getCwd)(), 'src');
122
123
  console.log(`Scanning for defineConfig calls in: ${srcDir}\n`);
123
124
  const project = new ts_morph_1.Project({
124
125
  tsConfigFilePath: path_1.default.resolve(srcDir, '../tsconfig.json'),
@@ -149,7 +150,7 @@ function main() {
149
150
  for (const filePath of modifiedFiles) {
150
151
  const sourceFile = project.getSourceFileOrThrow(filePath);
151
152
  yield sourceFile.save();
152
- console.log(` Saved: ${path_1.default.relative(process.cwd(), filePath)}`);
153
+ console.log(` Saved: ${path_1.default.relative((0, _1.getCwd)(), filePath)}`);
153
154
  }
154
155
  console.log(`\nDone. Removed ${totalRemoved} DELETE action(s) from defineConfig call(s).`);
155
156
  });
@@ -1 +1 @@
1
- {"version":3,"file":"remove-demo-scope.d.ts","sourceRoot":"","sources":["../../../src/migrations/v2.0/remove-demo-scope.ts"],"names":[],"mappings":"AAeA,iBAAe,IAAI,kBA8DlB;AAED,OAAO,EAAE,IAAI,EAAE,CAAA"}
1
+ {"version":3,"file":"remove-demo-scope.d.ts","sourceRoot":"","sources":["../../../src/migrations/v2.0/remove-demo-scope.ts"],"names":[],"mappings":"AAiBA,iBAAe,IAAI,kBA8DlB;AAED,OAAO,EAAE,IAAI,EAAE,CAAA"}
@@ -25,13 +25,14 @@ Object.defineProperty(exports, "__esModule", { value: true });
25
25
  exports.main = main;
26
26
  const path_1 = __importDefault(require("path"));
27
27
  const ts_morph_1 = require("ts-morph");
28
+ const _1 = require(".");
28
29
  const ROLES_HANDLER_RELATIVE_PATH = 'src/data-seeding/roles/handler.ts';
29
30
  function main() {
30
31
  return __awaiter(this, void 0, void 0, function* () {
31
32
  var _a;
32
- const rolesHandlerPath = path_1.default.join(process.cwd(), ROLES_HANDLER_RELATIVE_PATH);
33
+ const rolesHandlerPath = path_1.default.join((0, _1.getCwd)(), ROLES_HANDLER_RELATIVE_PATH);
33
34
  const project = new ts_morph_1.Project({
34
- tsConfigFilePath: path_1.default.resolve(process.cwd(), 'tsconfig.json'),
35
+ tsConfigFilePath: path_1.default.resolve((0, _1.getCwd)(), 'tsconfig.json'),
35
36
  skipAddingFilesFromTsConfig: false
36
37
  });
37
38
  const sourceFile = project.getSourceFile(rolesHandlerPath);
@@ -1 +1 @@
1
- {"version":3,"file":"remove-deprecated-imports.d.ts","sourceRoot":"","sources":["../../../src/migrations/v2.0/remove-deprecated-imports.ts"],"names":[],"mappings":"AAyDA,iBAAe,IAAI,kBAyClB;AAED,OAAO,EAAE,IAAI,EAAE,CAAA"}
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"}
@@ -25,6 +25,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
25
25
  exports.main = main;
26
26
  const ts_morph_1 = require("ts-morph");
27
27
  const path_1 = __importDefault(require("path"));
28
+ const _1 = require(".");
28
29
  const DEPRECATED_IMPORT = 'SCOPES';
29
30
  const TARGET_MODULES = new Set([
30
31
  '@opencrvs/toolkit/scopes',
@@ -55,13 +56,13 @@ function processFile(filePath, project) {
55
56
  if (!hasAnyNamedImportsLeft && !hasDefaultImport && !hasNamespaceImport) {
56
57
  decl.remove();
57
58
  }
58
- console.log(` [${path_1.default.relative(process.cwd(), filePath)}] Removed ${matchingNamedImports.length} deprecated '${DEPRECATED_IMPORT}' import(s) from '${decl.getModuleSpecifierValue()}'`);
59
+ console.log(` [${path_1.default.relative((0, _1.getCwd)(), filePath)}] Removed ${matchingNamedImports.length} deprecated '${DEPRECATED_IMPORT}' import(s) from '${decl.getModuleSpecifierValue()}'`);
59
60
  }
60
61
  return removedCount;
61
62
  }
62
63
  function main() {
63
64
  return __awaiter(this, void 0, void 0, function* () {
64
- const srcDir = path_1.default.join(process.cwd(), 'src');
65
+ const srcDir = path_1.default.join((0, _1.getCwd)(), 'src');
65
66
  console.log(`Scanning for deprecated imports in: ${srcDir}\n`);
66
67
  const project = new ts_morph_1.Project({
67
68
  tsConfigFilePath: path_1.default.resolve(srcDir, '../tsconfig.json'),
@@ -89,7 +90,7 @@ function main() {
89
90
  console.log(`\nSaving ${modifiedFiles.length} modified file(s)...`);
90
91
  for (const filePath of modifiedFiles) {
91
92
  yield project.getSourceFileOrThrow(filePath).save();
92
- console.log(` Saved: ${path_1.default.relative(process.cwd(), filePath)}`);
93
+ console.log(` Saved: ${path_1.default.relative((0, _1.getCwd)(), filePath)}`);
93
94
  }
94
95
  console.log(`\nDone. Removed ${totalRemoved} deprecated import(s).`);
95
96
  });
@@ -1 +1 @@
1
- {"version":3,"file":"remove-hearth-migrations.d.ts","sourceRoot":"","sources":["../../../src/migrations/v2.0/remove-hearth-migrations.ts"],"names":[],"mappings":"AAyBA,iBAAe,IAAI,kBAalB;AAED,OAAO,EAAE,IAAI,EAAE,CAAA"}
1
+ {"version":3,"file":"remove-hearth-migrations.d.ts","sourceRoot":"","sources":["../../../src/migrations/v2.0/remove-hearth-migrations.ts"],"names":[],"mappings":"AA2BA,iBAAe,IAAI,kBAalB;AAED,OAAO,EAAE,IAAI,EAAE,CAAA"}
@@ -48,6 +48,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
48
48
  exports.main = main;
49
49
  const fs = __importStar(require("fs"));
50
50
  const path_1 = __importDefault(require("path"));
51
+ const _1 = require(".");
51
52
  const PATHS_TO_REMOVE = [
52
53
  {
53
54
  relativePath: 'src/migrations/hearth',
@@ -62,7 +63,7 @@ const PATHS_TO_REMOVE = [
62
63
  function main() {
63
64
  return __awaiter(this, void 0, void 0, function* () {
64
65
  for (const { relativePath, label } of PATHS_TO_REMOVE) {
65
- const absolutePath = path_1.default.join(process.cwd(), relativePath);
66
+ const absolutePath = path_1.default.join((0, _1.getCwd)(), relativePath);
66
67
  if (fs.existsSync(absolutePath)) {
67
68
  fs.rmSync(absolutePath, { recursive: true, force: true });
68
69
  // eslint-disable-next-line no-console
@@ -1 +1 @@
1
- {"version":3,"file":"remove-pending-certification-flag.d.ts","sourceRoot":"","sources":["../../../src/migrations/v2.0/remove-pending-certification-flag.ts"],"names":[],"mappings":"AAyEA,iBAAe,IAAI,kBAiDlB;AAED,OAAO,EAAE,IAAI,EAAE,CAAA"}
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"}
@@ -38,6 +38,7 @@ exports.main = main;
38
38
  */
39
39
  const ts_morph_1 = require("ts-morph");
40
40
  const path_1 = __importDefault(require("path"));
41
+ const _1 = require(".");
41
42
  const INHERENT_FLAGS_ENUM_NAME = 'InherentFlags';
42
43
  const PENDING_CERTIFICATION_MEMBER = 'PENDING_CERTIFICATION';
43
44
  function isPendingCertificationFlag(node) {
@@ -66,14 +67,14 @@ function processFile(filePath, project) {
66
67
  for (const index of indicesToRemove.reverse()) {
67
68
  array.removeElement(index);
68
69
  removedCount++;
69
- console.log(` [${path_1.default.relative(process.cwd(), filePath)}] Removed InherentFlags.PENDING_CERTIFICATION from array`);
70
+ console.log(` [${path_1.default.relative((0, _1.getCwd)(), filePath)}] Removed InherentFlags.PENDING_CERTIFICATION from array`);
70
71
  }
71
72
  }
72
73
  return removedCount;
73
74
  }
74
75
  function main() {
75
76
  return __awaiter(this, void 0, void 0, function* () {
76
- const srcDir = path_1.default.join(process.cwd(), 'src');
77
+ const srcDir = path_1.default.join((0, _1.getCwd)(), 'src');
77
78
  console.log(`Scanning for InherentFlags.PENDING_CERTIFICATION array elements in: ${srcDir}\n`);
78
79
  const project = new ts_morph_1.Project({
79
80
  tsConfigFilePath: path_1.default.resolve(srcDir, '../tsconfig.json'),
@@ -102,7 +103,7 @@ function main() {
102
103
  for (const filePath of modifiedFiles) {
103
104
  const sourceFile = project.getSourceFileOrThrow(filePath);
104
105
  yield sourceFile.save();
105
- console.log(` Saved: ${path_1.default.relative(process.cwd(), filePath)}`);
106
+ console.log(` Saved: ${path_1.default.relative((0, _1.getCwd)(), filePath)}`);
106
107
  }
107
108
  console.log(`\nDone. Removed ${totalRemoved} InherentFlags.PENDING_CERTIFICATION element(s) from array(s).`);
108
109
  });
@@ -1 +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":"AAkJA,iBAAe,IAAI,kBAkDlB;AAED,OAAO,EAAE,IAAI,EAAE,CAAA"}
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"}
@@ -39,6 +39,7 @@ exports.main = main;
39
39
  */
40
40
  const ts_morph_1 = require("ts-morph");
41
41
  const path_1 = __importDefault(require("path"));
42
+ const _1 = require(".");
42
43
  const DEFINE_CONFIG_NAME = 'defineConfig';
43
44
  const ACTIONS_PROPERTY_NAME = 'actions';
44
45
  const TYPE_PROPERTY_NAME = 'type';
@@ -116,7 +117,7 @@ function processFile(filePath, project) {
116
117
  const wasRemoved = removeReviewFromRegisterActions(element);
117
118
  if (wasRemoved) {
118
119
  removedCount++;
119
- console.log(` [${path_1.default.relative(process.cwd(), filePath)}] Removed 'review' from REGISTER action`);
120
+ console.log(` [${path_1.default.relative((0, _1.getCwd)(), filePath)}] Removed 'review' from REGISTER action`);
120
121
  }
121
122
  }
122
123
  }
@@ -124,7 +125,7 @@ function processFile(filePath, project) {
124
125
  }
125
126
  function main() {
126
127
  return __awaiter(this, void 0, void 0, function* () {
127
- const srcDir = path_1.default.join(process.cwd(), 'src');
128
+ const srcDir = path_1.default.join((0, _1.getCwd)(), 'src');
128
129
  console.log(`Scanning for defineConfig calls in: ${srcDir}\n`);
129
130
  const project = new ts_morph_1.Project({
130
131
  tsConfigFilePath: path_1.default.resolve(srcDir, '../tsconfig.json'),
@@ -156,7 +157,7 @@ function main() {
156
157
  for (const filePath of modifiedFiles) {
157
158
  const sourceFile = project.getSourceFileOrThrow(filePath);
158
159
  yield sourceFile.save();
159
- console.log(` Saved: ${path_1.default.relative(process.cwd(), filePath)}`);
160
+ console.log(` Saved: ${path_1.default.relative((0, _1.getCwd)(), filePath)}`);
160
161
  }
161
162
  console.log(`\nDone. Removed ${totalRemoved} 'review' property assignment(s) from REGISTER action(s).`);
162
163
  });
@@ -1 +1 @@
1
- {"version":3,"file":"rename-api-paths.d.ts","sourceRoot":"","sources":["../../../src/migrations/v2.0/rename-api-paths.ts"],"names":[],"mappings":"AAuJA,iBAAe,IAAI,kBAgDlB;AAED,OAAO,EAAE,IAAI,EAAE,CAAA"}
1
+ {"version":3,"file":"rename-api-paths.d.ts","sourceRoot":"","sources":["../../../src/migrations/v2.0/rename-api-paths.ts"],"names":[],"mappings":"AAyJA,iBAAe,IAAI,kBAgDlB;AAED,OAAO,EAAE,IAAI,EAAE,CAAA"}
@@ -43,6 +43,7 @@ exports.main = main;
43
43
  */
44
44
  const ts_morph_1 = require("ts-morph");
45
45
  const path_1 = __importDefault(require("path"));
46
+ const _1 = require(".");
46
47
  // ─── Path rename table ────────────────────────────────────────────────────────
47
48
  // Add new renames here as further API paths are changed between versions.
48
49
  const PATH_RENAMES = {
@@ -129,7 +130,7 @@ function processFile(filePath, project) {
129
130
  if (!sourceFile)
130
131
  return 0;
131
132
  let renamedCount = 0;
132
- const relPath = path_1.default.relative(process.cwd(), filePath);
133
+ const relPath = path_1.default.relative((0, _1.getCwd)(), filePath);
133
134
  // Collect candidates first to avoid iterating a mutating tree
134
135
  const candidates = sourceFile.getDescendantsOfKind(ts_morph_1.SyntaxKind.ObjectLiteralExpression);
135
136
  for (const obj of candidates) {
@@ -146,7 +147,7 @@ function processFile(filePath, project) {
146
147
  // ─── Entry point ─────────────────────────────────────────────────────────────
147
148
  function main() {
148
149
  return __awaiter(this, void 0, void 0, function* () {
149
- const srcDir = path_1.default.join(process.cwd(), 'src');
150
+ const srcDir = path_1.default.join((0, _1.getCwd)(), 'src');
150
151
  console.log(`Scanning for Hapi route configs in: ${srcDir}\n`);
151
152
  console.log('Active path renames:');
152
153
  for (const [from, to] of Object.entries(PATH_RENAMES)) {
@@ -180,7 +181,7 @@ function main() {
180
181
  for (const filePath of modifiedFiles) {
181
182
  const sourceFile = project.getSourceFileOrThrow(filePath);
182
183
  yield sourceFile.save();
183
- console.log(` Saved: ${path_1.default.relative(process.cwd(), filePath)}`);
184
+ console.log(` Saved: ${path_1.default.relative((0, _1.getCwd)(), filePath)}`);
184
185
  }
185
186
  console.log(`\nDone. Renamed ${totalRenamed} route path(s).`);
186
187
  });
@@ -1 +1 @@
1
- {"version":3,"file":"rename-location-parent-id.d.ts","sourceRoot":"","sources":["../../../src/migrations/v2.0/rename-location-parent-id.ts"],"names":[],"mappings":"AAmJA,iBAAe,IAAI,kBAiDlB;AAED,OAAO,EAAE,IAAI,EAAE,CAAA"}
1
+ {"version":3,"file":"rename-location-parent-id.d.ts","sourceRoot":"","sources":["../../../src/migrations/v2.0/rename-location-parent-id.ts"],"names":[],"mappings":"AAqJA,iBAAe,IAAI,kBAiDlB;AAED,OAAO,EAAE,IAAI,EAAE,CAAA"}
@@ -45,6 +45,7 @@ exports.main = main;
45
45
  */
46
46
  const ts_morph_1 = require("ts-morph");
47
47
  const path_1 = __importDefault(require("path"));
48
+ const _1 = require(".");
48
49
  const OLD_PROPERTY_NAME = 'parentId';
49
50
  const NEW_PROPERTY_NAME = 'administrativeAreaId';
50
51
  const LOCATION_TYPE_NAME = 'Location';
@@ -137,14 +138,14 @@ function processFile(filePath, project) {
137
138
  // surrounding whitespace and optional-chain tokens (?.)
138
139
  propAccess.getNameNode().replaceWithText(NEW_PROPERTY_NAME);
139
140
  renamedCount++;
140
- console.log(` [${path_1.default.relative(process.cwd(), filePath)}] Renamed Location.${OLD_PROPERTY_NAME} → Location.${NEW_PROPERTY_NAME}`);
141
+ console.log(` [${path_1.default.relative((0, _1.getCwd)(), filePath)}] Renamed Location.${OLD_PROPERTY_NAME} → Location.${NEW_PROPERTY_NAME}`);
141
142
  }
142
143
  return renamedCount;
143
144
  }
144
145
  // ─── Entry point ─────────────────────────────────────────────────────────────
145
146
  function main() {
146
147
  return __awaiter(this, void 0, void 0, function* () {
147
- const srcDir = path_1.default.join(process.cwd(), 'src');
148
+ const srcDir = path_1.default.join((0, _1.getCwd)(), 'src');
148
149
  console.log(`Scanning for Location.${OLD_PROPERTY_NAME} references in: ${srcDir}\n`);
149
150
  const project = new ts_morph_1.Project({
150
151
  tsConfigFilePath: path_1.default.resolve(srcDir, '../tsconfig.json'),
@@ -173,7 +174,7 @@ function main() {
173
174
  for (const filePath of modifiedFiles) {
174
175
  const sourceFile = project.getSourceFileOrThrow(filePath);
175
176
  yield sourceFile.save();
176
- console.log(` Saved: ${path_1.default.relative(process.cwd(), filePath)}`);
177
+ console.log(` Saved: ${path_1.default.relative((0, _1.getCwd)(), filePath)}`);
177
178
  }
178
179
  console.log(`\nDone. Renamed ${totalRenamed} Location.${OLD_PROPERTY_NAME} reference(s) to Location.${NEW_PROPERTY_NAME}.`);
179
180
  });
@@ -1 +1 @@
1
- {"version":3,"file":"simplify-analytics-precalculations.d.ts","sourceRoot":"","sources":["../../../src/migrations/v2.0/simplify-analytics-precalculations.ts"],"names":[],"mappings":"AAqLA,iBAAe,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,CAyCnC;AAED,OAAO,EAAE,IAAI,EAAE,CAAA"}
1
+ {"version":3,"file":"simplify-analytics-precalculations.d.ts","sourceRoot":"","sources":["../../../src/migrations/v2.0/simplify-analytics-precalculations.ts"],"names":[],"mappings":"AAuLA,iBAAe,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,CAyCnC;AAED,OAAO,EAAE,IAAI,EAAE,CAAA"}
@@ -51,6 +51,7 @@ exports.main = main;
51
51
  const ts_morph_1 = require("ts-morph");
52
52
  const fs_1 = __importDefault(require("fs"));
53
53
  const path_1 = __importDefault(require("path"));
54
+ const _1 = require(".");
54
55
  const ANALYTICS_FILE_REL = 'src/analytics/analytics.ts';
55
56
  const FUNCTION_NAME = 'precalculateAdditionalAnalytics';
56
57
  const IMPORT_NAMES_TO_REMOVE = new Set(['Event', 'precalculateBirthEvent']);
@@ -163,7 +164,7 @@ function simplifyPrecalculateFunction(sourceFile) {
163
164
  // ─── Entry point ─────────────────────────────────────────────────────────────
164
165
  function main() {
165
166
  return __awaiter(this, void 0, void 0, function* () {
166
- const cwd = process.cwd();
167
+ const cwd = (0, _1.getCwd)();
167
168
  const absPath = path_1.default.join(cwd, ANALYTICS_FILE_REL);
168
169
  if (!fs_1.default.existsSync(absPath)) {
169
170
  console.log(`[${ANALYTICS_FILE_REL}] does not exist — nothing to clean up.`);
@@ -110,6 +110,10 @@ var scopeByEvent = z2.preprocess(
110
110
  (val) => val === void 0 ? void 0 : [val].flat(),
111
111
  z2.array(z2.string()).optional()
112
112
  ).describe("Event type, e.g. birth, death");
113
+ var userRole = z2.preprocess(
114
+ (val) => val === void 0 ? void 0 : [val].flat(),
115
+ z2.array(z2.string()).optional()
116
+ ).describe("User role, e.g. admin, field agent");
113
117
  var scopeOptionsPlaceEvent = z2.object({
114
118
  event: scopeByEvent,
115
119
  placeOfEvent: JurisdictionFilter.optional()
@@ -214,6 +218,33 @@ var RecordScopeV2 = z2.discriminatedUnion("type", [
214
218
  ]).describe(
215
219
  "Scopes used to check user's permission to perform actions on a record."
216
220
  );
221
+ var SystemScopeType = z2.enum([
222
+ "organisation.read-locations",
223
+ "user.read",
224
+ "user.create",
225
+ "user.edit"
226
+ ]);
227
+ var UserScopeType = SystemScopeType.extract([
228
+ "user.read",
229
+ "user.create",
230
+ "user.edit"
231
+ ]);
232
+ var ScopesWithRoleOption = UserScopeType.extract(["user.edit", "user.create"]);
233
+ var UserScopeV2 = z2.discriminatedUnion("type", [
234
+ z2.object({
235
+ type: ScopesWithRoleOption,
236
+ options: z2.object({
237
+ accessLevel: JurisdictionFilter.optional(),
238
+ role: userRole.optional()
239
+ }).optional()
240
+ }),
241
+ z2.object({
242
+ type: UserScopeType.extract(["user.read"]),
243
+ options: z2.object({
244
+ accessLevel: JurisdictionFilter.optional()
245
+ }).optional()
246
+ })
247
+ ]);
217
248
  var ResolvedRecordScopeV2 = z2.discriminatedUnion("type", [
218
249
  z2.object({
219
250
  type: ScopesWithPlaceEventOptions,
@@ -234,16 +265,14 @@ var ResolvedRecordScopeV2 = z2.discriminatedUnion("type", [
234
265
  }).optional()
235
266
  })
236
267
  ]).describe("Resolved scope with location/user IDs instead of filters.");
237
- var SystemScopeType = z2.enum([
238
- "organisation.read-locations",
239
- "user.read",
240
- "user.create",
241
- "user.edit"
242
- ]);
243
268
  var Scope = z2.discriminatedUnion("type", [
244
269
  z2.object({ type: PlainScopeType }),
245
270
  ...RecordScopeV2.options,
246
- z2.object({ type: SystemScopeType, options: AccessLevelOptions.optional() }),
271
+ ...UserScopeV2.options,
272
+ z2.object({
273
+ type: z2.literal("organisation.read-locations"),
274
+ options: AccessLevelOptions.optional()
275
+ }),
247
276
  z2.object({
248
277
  type: z2.literal("workqueue"),
249
278
  options: WorkqueueOrDashboardOptions