@opencrvs/toolkit 1.9.12-rc.fdec004 → 1.9.12-rc.ff04697

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 (53) hide show
  1. package/dist/cli.js +246 -80
  2. package/dist/commons/api/router.d.ts +72 -67
  3. package/dist/events/index.js +1 -10
  4. package/dist/migrations/v2.0/add-birth-certificate-issuance-flag.d.ts.map +1 -1
  5. package/dist/migrations/v2.0/add-birth-certificate-issuance-flag.js +3 -4
  6. package/dist/migrations/v2.0/checkout-upstream-files.d.ts +19 -0
  7. package/dist/migrations/v2.0/checkout-upstream-files.d.ts.map +1 -1
  8. package/dist/migrations/v2.0/checkout-upstream-files.js +17 -13
  9. package/dist/migrations/v2.0/convert-config-files-to-ts.d.ts.map +1 -1
  10. package/dist/migrations/v2.0/convert-config-files-to-ts.js +4 -5
  11. package/dist/migrations/v2.0/convert-paragraph-to-heading.d.ts.map +1 -1
  12. package/dist/migrations/v2.0/convert-paragraph-to-heading.js +4 -5
  13. package/dist/migrations/v2.0/create-events-index.d.ts.map +1 -1
  14. package/dist/migrations/v2.0/create-events-index.js +1 -2
  15. package/dist/migrations/v2.0/delete-infrastructure-directory.d.ts +3 -0
  16. package/dist/migrations/v2.0/delete-infrastructure-directory.d.ts.map +1 -0
  17. package/dist/migrations/v2.0/delete-infrastructure-directory.js +77 -0
  18. package/dist/migrations/v2.0/index.d.ts +8 -4
  19. package/dist/migrations/v2.0/index.d.ts.map +1 -1
  20. package/dist/migrations/v2.0/index.js +214 -77
  21. package/dist/migrations/v2.0/make-built-in-validate-actions-custom.d.ts.map +1 -1
  22. package/dist/migrations/v2.0/make-built-in-validate-actions-custom.js +5 -6
  23. package/dist/migrations/v2.0/merge-infrastructure-directory.d.ts +3 -0
  24. package/dist/migrations/v2.0/merge-infrastructure-directory.d.ts.map +1 -0
  25. package/dist/migrations/v2.0/merge-infrastructure-directory.js +221 -0
  26. package/dist/migrations/v2.0/migrate-scopes.d.ts.map +1 -1
  27. package/dist/migrations/v2.0/migrate-scopes.js +6 -7
  28. package/dist/migrations/v2.0/migrate-validated-workqueue-status-to-flag.d.ts.map +1 -1
  29. package/dist/migrations/v2.0/migrate-validated-workqueue-status-to-flag.js +3 -4
  30. package/dist/migrations/v2.0/migrate-workqueue-configs.d.ts.map +1 -1
  31. package/dist/migrations/v2.0/migrate-workqueue-configs.js +3 -4
  32. package/dist/migrations/v2.0/remove-delete-actions.d.ts.map +1 -1
  33. package/dist/migrations/v2.0/remove-delete-actions.js +3 -4
  34. package/dist/migrations/v2.0/remove-demo-scope.d.ts.map +1 -1
  35. package/dist/migrations/v2.0/remove-demo-scope.js +2 -3
  36. package/dist/migrations/v2.0/remove-deprecated-imports.d.ts.map +1 -1
  37. package/dist/migrations/v2.0/remove-deprecated-imports.js +3 -4
  38. package/dist/migrations/v2.0/remove-hearth-migrations.d.ts.map +1 -1
  39. package/dist/migrations/v2.0/remove-hearth-migrations.js +1 -2
  40. package/dist/migrations/v2.0/remove-pending-certification-flag.d.ts.map +1 -1
  41. package/dist/migrations/v2.0/remove-pending-certification-flag.js +3 -4
  42. package/dist/migrations/v2.0/remove-review-from-register-action.d.ts.map +1 -1
  43. package/dist/migrations/v2.0/remove-review-from-register-action.js +3 -4
  44. package/dist/migrations/v2.0/rename-api-paths.d.ts.map +1 -1
  45. package/dist/migrations/v2.0/rename-api-paths.js +3 -4
  46. package/dist/migrations/v2.0/rename-location-parent-id.d.ts.map +1 -1
  47. package/dist/migrations/v2.0/rename-location-parent-id.js +3 -4
  48. package/dist/migrations/v2.0/simplify-analytics-precalculations.d.ts.map +1 -1
  49. package/dist/migrations/v2.0/simplify-analytics-precalculations.js +1 -2
  50. package/opencrvs-toolkit-1.9.12-rc.ff04697.tgz +0 -0
  51. package/package.json +1 -1
  52. package/tsconfig.tsbuildinfo +1 -1
  53. package/opencrvs-toolkit-1.9.12-rc.fdec004.tgz +0 -0
@@ -31,7 +31,6 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
31
31
  // src/migrations/v2.0/index.ts
32
32
  var v2_exports = {};
33
33
  __export(v2_exports, {
34
- getCwd: () => getCwd,
35
34
  runUpgrade: () => runUpgrade
36
35
  });
37
36
  module.exports = __toCommonJS(v2_exports);
@@ -104,7 +103,7 @@ function processFile(filePath, project) {
104
103
  if (wasRemoved) {
105
104
  removedCount++;
106
105
  console.log(
107
- ` [${import_path.default.relative(getCwd(), filePath)}] Removed 'review' from REGISTER action`
106
+ ` [${import_path.default.relative(process.cwd(), filePath)}] Removed 'review' from REGISTER action`
108
107
  );
109
108
  }
110
109
  }
@@ -112,7 +111,7 @@ function processFile(filePath, project) {
112
111
  return removedCount;
113
112
  }
114
113
  async function main() {
115
- const srcDir = import_path.default.join(getCwd(), "src");
114
+ const srcDir = import_path.default.join(process.cwd(), "src");
116
115
  console.log(`Scanning for defineConfig calls in: ${srcDir}
117
116
  `);
118
117
  const project = new import_ts_morph.Project({
@@ -148,7 +147,7 @@ Saving ${modifiedFiles.length} modified file(s)...`);
148
147
  for (const filePath of modifiedFiles) {
149
148
  const sourceFile = project.getSourceFileOrThrow(filePath);
150
149
  await sourceFile.save();
151
- console.log(` Saved: ${import_path.default.relative(getCwd(), filePath)}`);
150
+ console.log(` Saved: ${import_path.default.relative(process.cwd(), filePath)}`);
152
151
  }
153
152
  console.log(
154
153
  `
@@ -351,7 +350,7 @@ function processFile2(filePath, project) {
351
350
  const eventType = resolveEventType(configArg);
352
351
  if (!eventType) {
353
352
  console.warn(
354
- ` [${import_path2.default.relative(getCwd(), configArg.getSourceFile().getFilePath())}] Could not resolve root 'type' from defineConfig \u2014 skipping auditHistoryLabel id generation`
353
+ ` [${import_path2.default.relative(process.cwd(), configArg.getSourceFile().getFilePath())}] Could not resolve root 'type' from defineConfig \u2014 skipping auditHistoryLabel id generation`
355
354
  );
356
355
  }
357
356
  let fileNeedsImports = false;
@@ -367,7 +366,7 @@ function processFile2(filePath, project) {
367
366
  fileNeedsImports = true;
368
367
  configHadValidateAction = true;
369
368
  console.log(
370
- ` [${import_path2.default.relative(getCwd(), filePath)}] Transformed VALIDATE action to CUSTOM with customActionType: '${VALIDATE_DECLARATION_VALUE}'`
369
+ ` [${import_path2.default.relative(process.cwd(), filePath)}] Transformed VALIDATE action to CUSTOM with customActionType: '${VALIDATE_DECLARATION_VALUE}'`
371
370
  );
372
371
  }
373
372
  }
@@ -388,7 +387,7 @@ function processFile2(filePath, project) {
388
387
  ]`
389
388
  });
390
389
  console.log(
391
- ` [${import_path2.default.relative(getCwd(), filePath)}] Added top-level 'flags' array to defineConfig`
390
+ ` [${import_path2.default.relative(process.cwd(), filePath)}] Added top-level 'flags' array to defineConfig`
392
391
  );
393
392
  }
394
393
  if (fileNeedsImports) {
@@ -398,7 +397,7 @@ function processFile2(filePath, project) {
398
397
  return transformedCount;
399
398
  }
400
399
  async function main2() {
401
- const srcDir = import_path2.default.join(getCwd(), "src");
400
+ const srcDir = import_path2.default.join(process.cwd(), "src");
402
401
  console.log(`Scanning for defineConfig calls in: ${srcDir}
403
402
  `);
404
403
  const project = new import_ts_morph2.Project({
@@ -433,7 +432,7 @@ Saving ${modifiedFiles.length} modified file(s)...`);
433
432
  for (const filePath of modifiedFiles) {
434
433
  const sourceFile = project.getSourceFileOrThrow(filePath);
435
434
  await sourceFile.save();
436
- console.log(` Saved: ${import_path2.default.relative(getCwd(), filePath)}`);
435
+ console.log(` Saved: ${import_path2.default.relative(process.cwd(), filePath)}`);
437
436
  }
438
437
  console.log(
439
438
  `
@@ -504,14 +503,14 @@ function processFile3(filePath, project) {
504
503
  actionsInitializer.removeElement(index);
505
504
  removedCount++;
506
505
  console.log(
507
- ` [${import_path3.default.relative(getCwd(), filePath)}] Removed DELETE action at index ${index}`
506
+ ` [${import_path3.default.relative(process.cwd(), filePath)}] Removed DELETE action at index ${index}`
508
507
  );
509
508
  }
510
509
  }
511
510
  return removedCount;
512
511
  }
513
512
  async function main3() {
514
- const srcDir = import_path3.default.join(getCwd(), "src");
513
+ const srcDir = import_path3.default.join(process.cwd(), "src");
515
514
  console.log(`Scanning for defineConfig calls in: ${srcDir}
516
515
  `);
517
516
  const project = new import_ts_morph3.Project({
@@ -546,7 +545,7 @@ Saving ${modifiedFiles.length} modified file(s)...`);
546
545
  for (const filePath of modifiedFiles) {
547
546
  const sourceFile = project.getSourceFileOrThrow(filePath);
548
547
  await sourceFile.save();
549
- console.log(` Saved: ${import_path3.default.relative(getCwd(), filePath)}`);
548
+ console.log(` Saved: ${import_path3.default.relative(process.cwd(), filePath)}`);
550
549
  }
551
550
  console.log(
552
551
  `
@@ -620,19 +619,19 @@ function processFile4(filePath, project) {
620
619
  if (result === "converted-to-heading") {
621
620
  changedCount++;
622
621
  console.log(
623
- ` [${import_path4.default.relative(getCwd(), filePath)}] Converted PARAGRAPH with heading fontVariant to HEADING`
622
+ ` [${import_path4.default.relative(process.cwd(), filePath)}] Converted PARAGRAPH with heading fontVariant to HEADING`
624
623
  );
625
624
  } else if (result === "removed-font-variant") {
626
625
  changedCount++;
627
626
  console.log(
628
- ` [${import_path4.default.relative(getCwd(), filePath)}] Removed non-heading fontVariant from PARAGRAPH`
627
+ ` [${import_path4.default.relative(process.cwd(), filePath)}] Removed non-heading fontVariant from PARAGRAPH`
629
628
  );
630
629
  }
631
630
  }
632
631
  return changedCount;
633
632
  }
634
633
  async function main4() {
635
- const srcDir = import_path4.default.join(getCwd(), "src");
634
+ const srcDir = import_path4.default.join(process.cwd(), "src");
636
635
  console.log(`Scanning for FieldType.PARAGRAPH fields in: ${srcDir}
637
636
  `);
638
637
  const project = new import_ts_morph4.Project({
@@ -666,7 +665,7 @@ Saving ${modifiedFiles.length} modified file(s)...`);
666
665
  for (const filePath of modifiedFiles) {
667
666
  const sourceFile = project.getSourceFileOrThrow(filePath);
668
667
  await sourceFile.save();
669
- console.log(` Saved: ${import_path4.default.relative(getCwd(), filePath)}`);
668
+ console.log(` Saved: ${import_path4.default.relative(process.cwd(), filePath)}`);
670
669
  }
671
670
  console.log(`
672
671
  Done. Processed ${totalChanged} FieldType.PARAGRAPH field(s).`);
@@ -816,7 +815,7 @@ function processFile5(filePath, project) {
816
815
  if (changed > 0) {
817
816
  migratedCount += changed;
818
817
  console.log(
819
- ` [${import_path5.default.relative(getCwd(), filePath)}] Migrated ${changed} clause(s): VALIDATED status \u2192 flags.anyOf`
818
+ ` [${import_path5.default.relative(process.cwd(), filePath)}] Migrated ${changed} clause(s): VALIDATED status \u2192 flags.anyOf`
820
819
  );
821
820
  }
822
821
  }
@@ -824,7 +823,7 @@ function processFile5(filePath, project) {
824
823
  return migratedCount;
825
824
  }
826
825
  async function main5() {
827
- const srcDir = import_path5.default.join(getCwd(), "src");
826
+ const srcDir = import_path5.default.join(process.cwd(), "src");
828
827
  console.log(`Scanning for defineWorkqueues calls in: ${srcDir}
829
828
  `);
830
829
  const project = new import_ts_morph5.Project({
@@ -858,7 +857,7 @@ Saving ${modifiedFiles.length} modified file(s)...`);
858
857
  for (const filePath of modifiedFiles) {
859
858
  const sourceFile = project.getSourceFileOrThrow(filePath);
860
859
  await sourceFile.save();
861
- console.log(` Saved: ${import_path5.default.relative(getCwd(), filePath)}`);
860
+ console.log(` Saved: ${import_path5.default.relative(process.cwd(), filePath)}`);
862
861
  }
863
862
  console.log(
864
863
  `
@@ -1076,7 +1075,7 @@ function processFile6(filePath, project) {
1076
1075
  const sourceFile = project.getSourceFile(filePath);
1077
1076
  if (!sourceFile) return 0;
1078
1077
  let totalChanges = 0;
1079
- const relPath = import_path6.default.relative(getCwd(), filePath);
1078
+ const relPath = import_path6.default.relative(process.cwd(), filePath);
1080
1079
  const callExpressions = sourceFile.getDescendantsOfKind(
1081
1080
  import_ts_morph6.SyntaxKind.CallExpression
1082
1081
  );
@@ -1117,7 +1116,7 @@ function processFile6(filePath, project) {
1117
1116
  return totalChanges;
1118
1117
  }
1119
1118
  async function main6() {
1120
- const srcDir = import_path6.default.join(getCwd(), "src");
1119
+ const srcDir = import_path6.default.join(process.cwd(), "src");
1121
1120
  console.log(
1122
1121
  `Scanning for birth defineConfig and PRINT_CERTIFICATE workqueues in: ${srcDir}
1123
1122
  `
@@ -1153,7 +1152,7 @@ Saving ${modifiedFiles.length} modified file(s)...`);
1153
1152
  for (const filePath of modifiedFiles) {
1154
1153
  const sourceFile = project.getSourceFileOrThrow(filePath);
1155
1154
  await sourceFile.save();
1156
- console.log(` Saved: ${import_path6.default.relative(getCwd(), filePath)}`);
1155
+ console.log(` Saved: ${import_path6.default.relative(process.cwd(), filePath)}`);
1157
1156
  }
1158
1157
  console.log(
1159
1158
  `
@@ -1190,14 +1189,14 @@ function processFile7(filePath, project) {
1190
1189
  array3.removeElement(index);
1191
1190
  removedCount++;
1192
1191
  console.log(
1193
- ` [${import_path7.default.relative(getCwd(), filePath)}] Removed InherentFlags.PENDING_CERTIFICATION from array`
1192
+ ` [${import_path7.default.relative(process.cwd(), filePath)}] Removed InherentFlags.PENDING_CERTIFICATION from array`
1194
1193
  );
1195
1194
  }
1196
1195
  }
1197
1196
  return removedCount;
1198
1197
  }
1199
1198
  async function main7() {
1200
- const srcDir = import_path7.default.join(getCwd(), "src");
1199
+ const srcDir = import_path7.default.join(process.cwd(), "src");
1201
1200
  console.log(
1202
1201
  `Scanning for InherentFlags.PENDING_CERTIFICATION array elements in: ${srcDir}
1203
1202
  `
@@ -1233,7 +1232,7 @@ Saving ${modifiedFiles.length} modified file(s)...`);
1233
1232
  for (const filePath of modifiedFiles) {
1234
1233
  const sourceFile = project.getSourceFileOrThrow(filePath);
1235
1234
  await sourceFile.save();
1236
- console.log(` Saved: ${import_path7.default.relative(getCwd(), filePath)}`);
1235
+ console.log(` Saved: ${import_path7.default.relative(process.cwd(), filePath)}`);
1237
1236
  }
1238
1237
  console.log(
1239
1238
  `
@@ -1291,13 +1290,13 @@ function processFile8(filePath, project) {
1291
1290
  propAccess.getNameNode().replaceWithText(NEW_PROPERTY_NAME);
1292
1291
  renamedCount++;
1293
1292
  console.log(
1294
- ` [${import_path8.default.relative(getCwd(), filePath)}] Renamed Location.${OLD_PROPERTY_NAME} \u2192 Location.${NEW_PROPERTY_NAME}`
1293
+ ` [${import_path8.default.relative(process.cwd(), filePath)}] Renamed Location.${OLD_PROPERTY_NAME} \u2192 Location.${NEW_PROPERTY_NAME}`
1295
1294
  );
1296
1295
  }
1297
1296
  return renamedCount;
1298
1297
  }
1299
1298
  async function main8() {
1300
- const srcDir = import_path8.default.join(getCwd(), "src");
1299
+ const srcDir = import_path8.default.join(process.cwd(), "src");
1301
1300
  console.log(
1302
1301
  `Scanning for Location.${OLD_PROPERTY_NAME} references in: ${srcDir}
1303
1302
  `
@@ -1333,7 +1332,7 @@ Saving ${modifiedFiles.length} modified file(s)...`);
1333
1332
  for (const filePath of modifiedFiles) {
1334
1333
  const sourceFile = project.getSourceFileOrThrow(filePath);
1335
1334
  await sourceFile.save();
1336
- console.log(` Saved: ${import_path8.default.relative(getCwd(), filePath)}`);
1335
+ console.log(` Saved: ${import_path8.default.relative(process.cwd(), filePath)}`);
1337
1336
  }
1338
1337
  console.log(
1339
1338
  `
@@ -1400,7 +1399,7 @@ function processFile9(filePath, project) {
1400
1399
  const sourceFile = project.getSourceFile(filePath);
1401
1400
  if (!sourceFile) return 0;
1402
1401
  let renamedCount = 0;
1403
- const relPath = import_path9.default.relative(getCwd(), filePath);
1402
+ const relPath = import_path9.default.relative(process.cwd(), filePath);
1404
1403
  const candidates = sourceFile.getDescendantsOfKind(
1405
1404
  import_ts_morph9.SyntaxKind.ObjectLiteralExpression
1406
1405
  );
@@ -1415,7 +1414,7 @@ function processFile9(filePath, project) {
1415
1414
  return renamedCount;
1416
1415
  }
1417
1416
  async function main9() {
1418
- const srcDir = import_path9.default.join(getCwd(), "src");
1417
+ const srcDir = import_path9.default.join(process.cwd(), "src");
1419
1418
  console.log(`Scanning for Hapi route configs in: ${srcDir}
1420
1419
  `);
1421
1420
  console.log("Active path renames:");
@@ -1452,7 +1451,7 @@ Saving ${modifiedFiles.length} modified file(s)...`);
1452
1451
  for (const filePath of modifiedFiles) {
1453
1452
  const sourceFile = project.getSourceFileOrThrow(filePath);
1454
1453
  await sourceFile.save();
1455
- console.log(` Saved: ${import_path9.default.relative(getCwd(), filePath)}`);
1454
+ console.log(` Saved: ${import_path9.default.relative(process.cwd(), filePath)}`);
1456
1455
  }
1457
1456
  console.log(`
1458
1457
  Done. Renamed ${totalRenamed} route path(s).`);
@@ -1873,8 +1872,8 @@ function ensureJoinImport(sf) {
1873
1872
  });
1874
1873
  }
1875
1874
  async function main10() {
1876
- const srcDir = import_path10.default.join(getCwd(), "src");
1877
- const relCwd = (fp) => import_path10.default.relative(getCwd(), fp);
1875
+ const srcDir = import_path10.default.join(process.cwd(), "src");
1876
+ const relCwd = (fp) => import_path10.default.relative(process.cwd(), fp);
1878
1877
  console.log("Phase 1: Converting JS config files to TypeScript...\n");
1879
1878
  let convertedCount = 0;
1880
1879
  for (const group of CONFIG_GROUPS) {
@@ -1962,7 +1961,7 @@ async function main10() {
1962
1961
  ensureJoinImport(sf);
1963
1962
  }
1964
1963
  console.log(
1965
- ` Inlined applicationConfig.${accessPath.join(".")} \u2192 ${adjustedValue} in ${import_path10.default.relative(getCwd(), sf.getFilePath())}`
1964
+ ` Inlined applicationConfig.${accessPath.join(".")} \u2192 ${adjustedValue} in ${import_path10.default.relative(process.cwd(), sf.getFilePath())}`
1966
1965
  );
1967
1966
  filesToSaveAfterInlining.add(sf);
1968
1967
  madeReplacement = true;
@@ -1974,7 +1973,7 @@ async function main10() {
1974
1973
  for (const sf of Array.from(filesToSaveAfterInlining)) {
1975
1974
  await sf.save();
1976
1975
  console.log(
1977
- ` Saved (inlined): ${import_path10.default.relative(getCwd(), sf.getFilePath())}`
1976
+ ` Saved (inlined): ${import_path10.default.relative(process.cwd(), sf.getFilePath())}`
1978
1977
  );
1979
1978
  }
1980
1979
  for (const prop of [...propsToRemove].reverse()) {
@@ -2591,7 +2590,7 @@ function migrateScopesArrays(rolesFilePath, project) {
2591
2590
  const scopeKey = resolveScopeKeyFromElementAccess(element);
2592
2591
  if (scopeKey && !(scopeKey in SCOPES)) {
2593
2592
  console.warn(
2594
- ` [${import_path11.default.relative(getCwd(), rolesFilePath)}] Removing unknown scope reference: SCOPES.${scopeKey}`
2593
+ ` [${import_path11.default.relative(process.cwd(), rolesFilePath)}] Removing unknown scope reference: SCOPES.${scopeKey}`
2595
2594
  );
2596
2595
  initializer.removeElement(index);
2597
2596
  removedCount++;
@@ -2600,7 +2599,7 @@ function migrateScopesArrays(rolesFilePath, project) {
2600
2599
  const legacyScope = resolveLegacyScopeFromElement(element);
2601
2600
  if (!legacyScope) {
2602
2601
  console.warn(
2603
- ` [${import_path11.default.relative(getCwd(), rolesFilePath)}] Skipping non-literal scope expression: ${element.getText()}`
2602
+ ` [${import_path11.default.relative(process.cwd(), rolesFilePath)}] Skipping non-literal scope expression: ${element.getText()}`
2604
2603
  );
2605
2604
  continue;
2606
2605
  }
@@ -2609,7 +2608,7 @@ function migrateScopesArrays(rolesFilePath, project) {
2609
2608
  const scope = decodeScope(migratedScope);
2610
2609
  if (!scope) {
2611
2610
  console.warn(
2612
- ` [${import_path11.default.relative(getCwd(), rolesFilePath)}] Could not decode migrated scope '${migratedScope}'.`
2611
+ ` [${import_path11.default.relative(process.cwd(), rolesFilePath)}] Could not decode migrated scope '${migratedScope}'.`
2613
2612
  );
2614
2613
  continue;
2615
2614
  }
@@ -2617,14 +2616,14 @@ function migrateScopesArrays(rolesFilePath, project) {
2617
2616
  migratedCount++;
2618
2617
  } catch (error) {
2619
2618
  console.warn(
2620
- ` [${import_path11.default.relative(getCwd(), rolesFilePath)}] Could not migrate scope '${legacyScope}': ${error}`
2619
+ ` [${import_path11.default.relative(process.cwd(), rolesFilePath)}] Could not migrate scope '${legacyScope}': ${error}`
2621
2620
  );
2622
2621
  }
2623
2622
  }
2624
2623
  }
2625
2624
  if (removedCount > 0) {
2626
2625
  console.log(
2627
- ` Removed ${removedCount} unknown SCOPES reference(s) from '${import_path11.default.relative(getCwd(), rolesFilePath)}'.`
2626
+ ` Removed ${removedCount} unknown SCOPES reference(s) from '${import_path11.default.relative(process.cwd(), rolesFilePath)}'.`
2628
2627
  );
2629
2628
  }
2630
2629
  return { migratedCount, removedCount };
@@ -2746,9 +2745,9 @@ function removeRoleTypeDefinitionAndUnusedImports(rolesFilePath, project) {
2746
2745
  return removed;
2747
2746
  }
2748
2747
  async function main11() {
2749
- const cwd2 = getCwd();
2750
- const srcDir = import_path11.default.join(cwd2, "src");
2751
- const rolesFilePath = import_path11.default.join(cwd2, ROLES_FILE_RELATIVE_PATH);
2748
+ const cwd = process.cwd();
2749
+ const srcDir = import_path11.default.join(cwd, "src");
2750
+ const rolesFilePath = import_path11.default.join(cwd, ROLES_FILE_RELATIVE_PATH);
2752
2751
  console.log(`Scanning roles scopes in: ${rolesFilePath}`);
2753
2752
  const project = new import_ts_morph11.Project({
2754
2753
  tsConfigFilePath: import_path11.default.resolve(srcDir, "../tsconfig.json"),
@@ -2812,13 +2811,13 @@ function processFile10(filePath, project) {
2812
2811
  decl.remove();
2813
2812
  }
2814
2813
  console.log(
2815
- ` [${import_path12.default.relative(getCwd(), filePath)}] Removed ${matchingNamedImports.length} deprecated '${DEPRECATED_IMPORT}' import(s) from '${decl.getModuleSpecifierValue()}'`
2814
+ ` [${import_path12.default.relative(process.cwd(), filePath)}] Removed ${matchingNamedImports.length} deprecated '${DEPRECATED_IMPORT}' import(s) from '${decl.getModuleSpecifierValue()}'`
2816
2815
  );
2817
2816
  }
2818
2817
  return removedCount;
2819
2818
  }
2820
2819
  async function main12() {
2821
- const srcDir = import_path12.default.join(getCwd(), "src");
2820
+ const srcDir = import_path12.default.join(process.cwd(), "src");
2822
2821
  console.log(`Scanning for deprecated imports in: ${srcDir}
2823
2822
  `);
2824
2823
  const project = new import_ts_morph12.Project({
@@ -2849,7 +2848,7 @@ async function main12() {
2849
2848
  Saving ${modifiedFiles.length} modified file(s)...`);
2850
2849
  for (const filePath of modifiedFiles) {
2851
2850
  await project.getSourceFileOrThrow(filePath).save();
2852
- console.log(` Saved: ${import_path12.default.relative(getCwd(), filePath)}`);
2851
+ console.log(` Saved: ${import_path12.default.relative(process.cwd(), filePath)}`);
2853
2852
  }
2854
2853
  console.log(`
2855
2854
  Done. Removed ${totalRemoved} deprecated import(s).`);
@@ -2996,7 +2995,7 @@ function processFile11(filePath, project) {
2996
2995
  const sourceFile = project.getSourceFile(filePath);
2997
2996
  if (!sourceFile) return 0;
2998
2997
  let migratedWorkqueues = 0;
2999
- const relPath = import_path13.default.relative(getCwd(), filePath);
2998
+ const relPath = import_path13.default.relative(process.cwd(), filePath);
3000
2999
  const callExpressions = sourceFile.getDescendantsOfKind(
3001
3000
  import_ts_morph13.SyntaxKind.CallExpression
3002
3001
  );
@@ -3017,7 +3016,7 @@ function processFile11(filePath, project) {
3017
3016
  return migratedWorkqueues;
3018
3017
  }
3019
3018
  async function main13() {
3020
- const srcDir = import_path13.default.join(getCwd(), "src");
3019
+ const srcDir = import_path13.default.join(process.cwd(), "src");
3021
3020
  console.log(`Scanning for defineWorkqueues calls in: ${srcDir}
3022
3021
  `);
3023
3022
  const project = new import_ts_morph13.Project({
@@ -3051,7 +3050,7 @@ Saving ${modifiedFiles.length} modified file(s)...`);
3051
3050
  for (const filePath of modifiedFiles) {
3052
3051
  const sourceFile = project.getSourceFileOrThrow(filePath);
3053
3052
  await sourceFile.save();
3054
- console.log(` Saved: ${import_path13.default.relative(getCwd(), filePath)}`);
3053
+ console.log(` Saved: ${import_path13.default.relative(process.cwd(), filePath)}`);
3055
3054
  }
3056
3055
  console.log(
3057
3056
  `
@@ -3064,9 +3063,9 @@ var import_path14 = __toESM(require("path"));
3064
3063
  var import_ts_morph14 = require("ts-morph");
3065
3064
  var ROLES_HANDLER_RELATIVE_PATH = "src/data-seeding/roles/handler.ts";
3066
3065
  async function main14() {
3067
- const rolesHandlerPath = import_path14.default.join(getCwd(), ROLES_HANDLER_RELATIVE_PATH);
3066
+ const rolesHandlerPath = import_path14.default.join(process.cwd(), ROLES_HANDLER_RELATIVE_PATH);
3068
3067
  const project = new import_ts_morph14.Project({
3069
- tsConfigFilePath: import_path14.default.resolve(getCwd(), "tsconfig.json"),
3068
+ tsConfigFilePath: import_path14.default.resolve(process.cwd(), "tsconfig.json"),
3070
3069
  skipAddingFilesFromTsConfig: false
3071
3070
  });
3072
3071
  const sourceFile = project.getSourceFile(rolesHandlerPath);
@@ -3129,7 +3128,7 @@ var PATHS_TO_REMOVE = [
3129
3128
  ];
3130
3129
  async function main15() {
3131
3130
  for (const { relativePath, label } of PATHS_TO_REMOVE) {
3132
- const absolutePath = import_path15.default.join(getCwd(), relativePath);
3131
+ const absolutePath = import_path15.default.join(process.cwd(), relativePath);
3133
3132
  if (fs2.existsSync(absolutePath)) {
3134
3133
  fs2.rmSync(absolutePath, { recursive: true, force: true });
3135
3134
  console.log(`Removed ${label} '${relativePath}'.`);
@@ -3285,8 +3284,8 @@ function modifyHandler(sourceFile, exportNames) {
3285
3284
  return changes;
3286
3285
  }
3287
3286
  async function main16() {
3288
- const cwd2 = getCwd();
3289
- const srcDir = import_path16.default.join(cwd2, "src");
3287
+ const cwd = process.cwd();
3288
+ const srcDir = import_path16.default.join(cwd, "src");
3290
3289
  console.log(`Scanning for defineConfig event exports in: ${srcDir}
3291
3290
  `);
3292
3291
  const project = new import_ts_morph15.Project({
@@ -3302,10 +3301,10 @@ async function main16() {
3302
3301
  }
3303
3302
  console.log(`Found ${eventConfigExports.length} event config export(s):`);
3304
3303
  for (const e of eventConfigExports) {
3305
- console.log(` ${e.name} \u2190 ${import_path16.default.relative(cwd2, e.filePath)}`);
3304
+ console.log(` ${e.name} \u2190 ${import_path16.default.relative(cwd, e.filePath)}`);
3306
3305
  }
3307
3306
  const eventsIndexAbs = import_path16.default.join(srcDir, "events", "index.ts");
3308
- const eventsIndexRel = import_path16.default.relative(cwd2, eventsIndexAbs);
3307
+ const eventsIndexRel = import_path16.default.relative(cwd, eventsIndexAbs);
3309
3308
  if (import_fs.default.existsSync(eventsIndexAbs)) {
3310
3309
  console.log(`
3311
3310
  [${eventsIndexRel}] already exists \u2014 leaving untouched.`);
@@ -3331,7 +3330,7 @@ No event-config handler file found (looked for exported function(s): ${Array.fro
3331
3330
  );
3332
3331
  return;
3333
3332
  }
3334
- const handlerRelPath = import_path16.default.relative(cwd2, handler.getFilePath());
3333
+ const handlerRelPath = import_path16.default.relative(cwd, handler.getFilePath());
3335
3334
  const exportNameSet = new Set(eventConfigExports.map((e) => e.name));
3336
3335
  const changes = modifyHandler(handler, exportNameSet);
3337
3336
  if (changes.length === 0) {
@@ -3351,12 +3350,13 @@ var UPSTREAM_URL = "https://github.com/opencrvs/opencrvs-countryconfig.git";
3351
3350
  var UPSTREAM_BRANCH = "develop";
3352
3351
  var TEMP_REMOTE = "opencrvs-upgrade-v19-v20-codemod";
3353
3352
  var FILES_TO_CHECKOUT = [
3354
- "infrastructure/postgres/setup-analytics.sh",
3355
- "src/analytics/analytics.ts"
3353
+ "src/analytics/analytics.ts",
3354
+ "Dockerfile",
3355
+ "Dockerfile.assets"
3356
3356
  ];
3357
3357
  function runGit(args, { silent = false } = {}) {
3358
3358
  return (0, import_child_process.execFileSync)("git", args, {
3359
- cwd: getCwd(),
3359
+ cwd: process.cwd(),
3360
3360
  encoding: "utf8",
3361
3361
  stdio: silent ? ["ignore", "pipe", "pipe"] : ["ignore", "pipe", "inherit"]
3362
3362
  });
@@ -3372,7 +3372,7 @@ function tryGit(args) {
3372
3372
  function assertIsGitRepo() {
3373
3373
  if (!tryGit(["rev-parse", "--is-inside-work-tree"])) {
3374
3374
  throw new Error(
3375
- `checkout-upstream-files: ${getCwd()} is not a git repository. Initialise git (or run the upgrade inside a git checkout) before re-running.`
3375
+ `${process.cwd()} is not a git repository. Initialise git (or run the upgrade inside a git checkout) before re-running.`
3376
3376
  );
3377
3377
  }
3378
3378
  }
@@ -3496,8 +3496,8 @@ function simplifyPrecalculateFunction(sourceFile) {
3496
3496
  return log;
3497
3497
  }
3498
3498
  async function main18() {
3499
- const cwd2 = getCwd();
3500
- const absPath = import_path17.default.join(cwd2, ANALYTICS_FILE_REL);
3499
+ const cwd = process.cwd();
3500
+ const absPath = import_path17.default.join(cwd, ANALYTICS_FILE_REL);
3501
3501
  if (!import_fs2.default.existsSync(absPath)) {
3502
3502
  console.log(
3503
3503
  `[${ANALYTICS_FILE_REL}] does not exist \u2014 nothing to clean up.`
@@ -3505,7 +3505,7 @@ async function main18() {
3505
3505
  return;
3506
3506
  }
3507
3507
  const project = new import_ts_morph16.Project({
3508
- tsConfigFilePath: import_path17.default.resolve(cwd2, "tsconfig.json"),
3508
+ tsConfigFilePath: import_path17.default.resolve(cwd, "tsconfig.json"),
3509
3509
  skipAddingFilesFromTsConfig: false
3510
3510
  });
3511
3511
  const sourceFile = project.getSourceFile(absPath);
@@ -3532,25 +3532,157 @@ async function main18() {
3532
3532
  Saved ${ANALYTICS_FILE_REL}.`);
3533
3533
  }
3534
3534
 
3535
- // src/migrations/v2.0/index.ts
3536
- var cwd;
3537
- function getCwd() {
3538
- if (!cwd) {
3539
- throw new Error("Country config working directory not set.");
3535
+ // src/migrations/v2.0/merge-infrastructure-directory.ts
3536
+ var import_child_process2 = require("child_process");
3537
+ var import_fs3 = require("fs");
3538
+ var import_os = require("os");
3539
+ var import_path18 = require("path");
3540
+ var TEMP_REMOTE2 = "opencrvs-upgrade-v19-v20-codemod-merge-infra";
3541
+ var INFRASTRUCTURE_DIR = "infrastructure";
3542
+ var BASE_BRANCH = "release-v1.9";
3543
+ function gitShowBytes(ref, path17) {
3544
+ try {
3545
+ const buf = (0, import_child_process2.execFileSync)("git", ["show", `${ref}:${path17}`], {
3546
+ cwd: process.cwd(),
3547
+ stdio: ["ignore", "pipe", "pipe"]
3548
+ });
3549
+ return new Uint8Array(buf.buffer, buf.byteOffset, buf.byteLength);
3550
+ } catch {
3551
+ return null;
3540
3552
  }
3541
- return cwd;
3542
3553
  }
3543
- async function runUpgrade(ccwd) {
3544
- if (ccwd) {
3545
- console.log("Country config working directory:", ccwd);
3546
- cwd = ccwd;
3554
+ async function main19() {
3555
+ console.log(
3556
+ `Merging '${INFRASTRUCTURE_DIR}/' from ${UPSTREAM_URL}@${UPSTREAM_BRANCH} (base: ${BASE_BRANCH})...
3557
+ `
3558
+ );
3559
+ assertIsGitRepo();
3560
+ tryGit(["remote", "remove", TEMP_REMOTE2]);
3561
+ try {
3562
+ console.log(` Adding temporary remote '${TEMP_REMOTE2}' \u2192 ${UPSTREAM_URL}`);
3563
+ runGit(["remote", "add", TEMP_REMOTE2, UPSTREAM_URL], { silent: true });
3564
+ console.log(
3565
+ ` Fetching ${TEMP_REMOTE2}/{${UPSTREAM_BRANCH},${BASE_BRANCH}} (depth 1)...`
3566
+ );
3567
+ runGit(["fetch", "--depth=1", TEMP_REMOTE2, UPSTREAM_BRANCH, BASE_BRANCH]);
3568
+ const ref = `${TEMP_REMOTE2}/${UPSTREAM_BRANCH}`;
3569
+ const baseRef = `${TEMP_REMOTE2}/${BASE_BRANCH}`;
3570
+ const upstreamFiles = runGit(
3571
+ [
3572
+ "ls-tree",
3573
+ "-r",
3574
+ "--name-only",
3575
+ "-z",
3576
+ ref,
3577
+ "--",
3578
+ `${INFRASTRUCTURE_DIR}/`
3579
+ ],
3580
+ { silent: true }
3581
+ ).split("\0").filter(Boolean);
3582
+ if (upstreamFiles.length === 0) {
3583
+ console.log(
3584
+ ` No files found under '${INFRASTRUCTURE_DIR}/' on ${ref}. Nothing to merge.`
3585
+ );
3586
+ return;
3587
+ }
3588
+ const tmpDir = (0, import_fs3.mkdtempSync)((0, import_path18.join)((0, import_os.tmpdir)(), "opencrvs-merge-infra-"));
3589
+ const baseTmp = (0, import_path18.join)(tmpDir, "base");
3590
+ const theirsTmp = (0, import_path18.join)(tmpDir, "theirs");
3591
+ let added = 0;
3592
+ let merged = 0;
3593
+ const conflictedFiles = [];
3594
+ for (const file of upstreamFiles) {
3595
+ const fullPath = (0, import_path18.join)(process.cwd(), file);
3596
+ if (!(0, import_fs3.existsSync)(fullPath)) {
3597
+ if (tryGit(["checkout", ref, "--", file])) {
3598
+ console.log(` + ${file} (new from upstream)`);
3599
+ added++;
3600
+ } else {
3601
+ console.warn(` [warn] failed to add new file ${file}`);
3602
+ }
3603
+ continue;
3604
+ }
3605
+ const theirContents = gitShowBytes(ref, file);
3606
+ if (theirContents === null) {
3607
+ console.warn(` [warn] could not read ${file} from ${ref} \u2014 skipping.`);
3608
+ continue;
3609
+ }
3610
+ (0, import_fs3.writeFileSync)(theirsTmp, theirContents);
3611
+ const baseContents = gitShowBytes(baseRef, file);
3612
+ (0, import_fs3.writeFileSync)(baseTmp, baseContents ?? new Uint8Array(0));
3613
+ try {
3614
+ (0, import_child_process2.execFileSync)("git", ["merge-file", fullPath, baseTmp, theirsTmp], {
3615
+ cwd: process.cwd(),
3616
+ stdio: ["ignore", "pipe", "pipe"]
3617
+ });
3618
+ runGit(["add", "--", file], { silent: true });
3619
+ merged++;
3620
+ } catch (err) {
3621
+ const status = err.status;
3622
+ if (typeof status === "number" && status > 0) {
3623
+ conflictedFiles.push(file);
3624
+ console.warn(
3625
+ ` ! ${file} (${status} conflict${status > 1 ? "s" : ""})`
3626
+ );
3627
+ } else {
3628
+ conflictedFiles.push(file);
3629
+ console.warn(
3630
+ ` [warn] merge failed for ${file} (likely binary or unreadable) \u2014 left untouched.`
3631
+ );
3632
+ }
3633
+ }
3634
+ }
3635
+ console.log(
3636
+ `
3637
+ Done. ${added} added, ${merged} merged cleanly, ${conflictedFiles.length} with conflicts.`
3638
+ );
3639
+ if (conflictedFiles.length > 0) {
3640
+ console.warn(
3641
+ `
3642
+ NOTE: ${conflictedFiles.length} file(s) under '${INFRASTRUCTURE_DIR}/' have merge conflicts that you must resolve manually.
3643
+ Look for the standard conflict markers (<<<<<<<, =======, >>>>>>>) in:
3644
+ ` + conflictedFiles.map((f) => ` - ${f}`).join("\n") + `
3645
+ After resolving, stage the fixes with: git add ${INFRASTRUCTURE_DIR}/`
3646
+ );
3647
+ }
3648
+ } finally {
3649
+ if (tryGit(["remote", "remove", TEMP_REMOTE2])) {
3650
+ console.log(` Removed temporary remote '${TEMP_REMOTE2}'.`);
3651
+ }
3547
3652
  }
3548
- if (!ccwd) {
3653
+ }
3654
+
3655
+ // src/migrations/v2.0/delete-infrastructure-directory.ts
3656
+ var import_fs4 = require("fs");
3657
+ var import_path19 = require("path");
3658
+ var INFRASTRUCTURE_DIR2 = "infrastructure";
3659
+ async function main20() {
3660
+ const fullPath = (0, import_path19.join)(process.cwd(), INFRASTRUCTURE_DIR2);
3661
+ if (!(0, import_fs4.existsSync)(fullPath)) {
3549
3662
  console.log(
3550
- "Will use current working directory as country config working directory."
3663
+ `'${INFRASTRUCTURE_DIR2}/' not found in ${process.cwd()} \u2014 nothing to delete.`
3551
3664
  );
3552
- cwd = process.cwd();
3665
+ return;
3553
3666
  }
3667
+ console.log(`Deleting '${INFRASTRUCTURE_DIR2}/'...
3668
+ `);
3669
+ assertIsGitRepo();
3670
+ runGit(["rm", "-rf", "--ignore-unmatch", "--", `${INFRASTRUCTURE_DIR2}/`], {
3671
+ silent: true
3672
+ });
3673
+ console.log(` Staged deletion of tracked files under '${INFRASTRUCTURE_DIR2}/'.`);
3674
+ if ((0, import_fs4.existsSync)(fullPath)) {
3675
+ (0, import_fs4.rmSync)(fullPath, { recursive: true, force: true });
3676
+ console.log(` Removed remaining untracked files under '${INFRASTRUCTURE_DIR2}/'.`);
3677
+ }
3678
+ console.log(
3679
+ `
3680
+ Done. Review the staged deletion with: git diff --cached -- '${INFRASTRUCTURE_DIR2}/'`
3681
+ );
3682
+ }
3683
+
3684
+ // src/migrations/v2.0/index.ts
3685
+ async function runUpgrade(dockerSwarm) {
3554
3686
  await main13();
3555
3687
  await main();
3556
3688
  await main2();
@@ -3569,4 +3701,9 @@ async function runUpgrade(ccwd) {
3569
3701
  await main16();
3570
3702
  await main17();
3571
3703
  await main18();
3704
+ if (dockerSwarm) {
3705
+ await main19();
3706
+ } else {
3707
+ await main20();
3708
+ }
3572
3709
  }
@@ -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":"AA6WA,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":"AA2WA,iBAAe,IAAI,kBAiDlB;AAED,OAAO,EAAE,IAAI,EAAE,CAAA"}