@opencrvs/toolkit 2.0.0-rc.754b1d1 → 2.0.0-rc.764c76e

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 (80) hide show
  1. package/dist/application-config/index.js +11 -39
  2. package/dist/cli.js +317 -1656
  3. package/dist/commons/api/router.d.ts +54 -55
  4. package/dist/commons/application-config/index.d.ts +4 -16
  5. package/dist/commons/conditionals/conditionals.d.ts +3 -3
  6. package/dist/commons/events/FieldConfig.d.ts +0 -5
  7. package/dist/commons/events/locations.d.ts +1 -17
  8. package/dist/conditionals/index.js +7 -35
  9. package/dist/events/index.js +7 -73
  10. package/dist/migrations/v2.0/add-birth-certificate-issuance-flag.d.ts.map +1 -1
  11. package/dist/migrations/v2.0/add-birth-certificate-issuance-flag.js +39 -63
  12. package/dist/migrations/v2.0/checkout-upstream-files.d.ts +0 -19
  13. package/dist/migrations/v2.0/checkout-upstream-files.d.ts.map +1 -1
  14. package/dist/migrations/v2.0/checkout-upstream-files.js +13 -17
  15. package/dist/migrations/v2.0/convert-config-files-to-ts.d.ts.map +1 -1
  16. package/dist/migrations/v2.0/convert-config-files-to-ts.js +5 -4
  17. package/dist/migrations/v2.0/convert-paragraph-to-heading.d.ts.map +1 -1
  18. package/dist/migrations/v2.0/convert-paragraph-to-heading.js +5 -4
  19. package/dist/migrations/v2.0/create-events-index.d.ts.map +1 -1
  20. package/dist/migrations/v2.0/create-events-index.js +2 -1
  21. package/dist/migrations/v2.0/index.d.ts +4 -8
  22. package/dist/migrations/v2.0/index.d.ts.map +1 -1
  23. package/dist/migrations/v2.0/index.js +314 -1624
  24. package/dist/migrations/v2.0/make-built-in-validate-actions-custom.d.ts.map +1 -1
  25. package/dist/migrations/v2.0/make-built-in-validate-actions-custom.js +7 -95
  26. package/dist/migrations/v2.0/migrate-scopes.d.ts.map +1 -1
  27. package/dist/migrations/v2.0/migrate-scopes.js +7 -6
  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 +4 -3
  30. package/dist/migrations/v2.0/migrate-workqueue-configs.d.ts.map +1 -1
  31. package/dist/migrations/v2.0/migrate-workqueue-configs.js +4 -3
  32. package/dist/migrations/v2.0/remove-delete-actions.d.ts.map +1 -1
  33. package/dist/migrations/v2.0/remove-delete-actions.js +4 -3
  34. package/dist/migrations/v2.0/remove-demo-scope.d.ts.map +1 -1
  35. package/dist/migrations/v2.0/remove-demo-scope.js +3 -2
  36. package/dist/migrations/v2.0/remove-deprecated-imports.d.ts.map +1 -1
  37. package/dist/migrations/v2.0/remove-deprecated-imports.js +4 -3
  38. package/dist/migrations/v2.0/remove-hearth-migrations.d.ts.map +1 -1
  39. package/dist/migrations/v2.0/remove-hearth-migrations.js +2 -1
  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 +4 -3
  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 +4 -3
  44. package/dist/migrations/v2.0/rename-api-paths.d.ts.map +1 -1
  45. package/dist/migrations/v2.0/rename-api-paths.js +4 -3
  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 +4 -3
  48. package/dist/migrations/v2.0/simplify-analytics-precalculations.d.ts.map +1 -1
  49. package/dist/migrations/v2.0/simplify-analytics-precalculations.js +2 -1
  50. package/dist/notification/index.js +7 -35
  51. package/dist/scopes/index.d.ts +10 -82
  52. package/dist/scopes/index.js +8 -41
  53. package/opencrvs-toolkit-2.0.0-rc.764c76e.tgz +0 -0
  54. package/package.json +1 -1
  55. package/tsconfig.tsbuildinfo +1 -1
  56. package/dist/migrations/v2.0/add-resend-invite-notification.d.ts +0 -3
  57. package/dist/migrations/v2.0/add-resend-invite-notification.d.ts.map +0 -1
  58. package/dist/migrations/v2.0/add-resend-invite-notification.js +0 -373
  59. package/dist/migrations/v2.0/delete-infrastructure-directory.d.ts +0 -3
  60. package/dist/migrations/v2.0/delete-infrastructure-directory.d.ts.map +0 -1
  61. package/dist/migrations/v2.0/delete-infrastructure-directory.js +0 -77
  62. package/dist/migrations/v2.0/merge-infrastructure-directory.d.ts +0 -3
  63. package/dist/migrations/v2.0/merge-infrastructure-directory.d.ts.map +0 -1
  64. package/dist/migrations/v2.0/merge-infrastructure-directory.js +0 -221
  65. package/dist/migrations/v2.0/migrate-application-config-url.d.ts +0 -3
  66. package/dist/migrations/v2.0/migrate-application-config-url.d.ts.map +0 -1
  67. package/dist/migrations/v2.0/migrate-application-config-url.js +0 -342
  68. package/dist/migrations/v2.0/remove-fhir-url-helpers.d.ts +0 -3
  69. package/dist/migrations/v2.0/remove-fhir-url-helpers.d.ts.map +0 -1
  70. package/dist/migrations/v2.0/remove-fhir-url-helpers.js +0 -163
  71. package/dist/migrations/v2.0/remove-old-statistics-service.d.ts +0 -3
  72. package/dist/migrations/v2.0/remove-old-statistics-service.d.ts.map +0 -1
  73. package/dist/migrations/v2.0/remove-old-statistics-service.js +0 -356
  74. package/dist/migrations/v2.0/remove-unused-environment-variables.d.ts +0 -3
  75. package/dist/migrations/v2.0/remove-unused-environment-variables.d.ts.map +0 -1
  76. package/dist/migrations/v2.0/remove-unused-environment-variables.js +0 -186
  77. package/dist/migrations/v2.0/update-package-json.d.ts +0 -3
  78. package/dist/migrations/v2.0/update-package-json.d.ts.map +0 -1
  79. package/dist/migrations/v2.0/update-package-json.js +0 -105
  80. package/opencrvs-toolkit-2.0.0-rc.754b1d1.tgz +0 -0
@@ -31,6 +31,7 @@ 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,
34
35
  runUpgrade: () => runUpgrade
35
36
  });
36
37
  module.exports = __toCommonJS(v2_exports);
@@ -103,7 +104,7 @@ function processFile(filePath, project) {
103
104
  if (wasRemoved) {
104
105
  removedCount++;
105
106
  console.log(
106
- ` [${import_path.default.relative(process.cwd(), filePath)}] Removed 'review' from REGISTER action`
107
+ ` [${import_path.default.relative(getCwd(), filePath)}] Removed 'review' from REGISTER action`
107
108
  );
108
109
  }
109
110
  }
@@ -111,7 +112,7 @@ function processFile(filePath, project) {
111
112
  return removedCount;
112
113
  }
113
114
  async function main() {
114
- const srcDir = import_path.default.join(process.cwd(), "src");
115
+ const srcDir = import_path.default.join(getCwd(), "src");
115
116
  console.log(`Scanning for defineConfig calls in: ${srcDir}
116
117
  `);
117
118
  const project = new import_ts_morph.Project({
@@ -147,7 +148,7 @@ Saving ${modifiedFiles.length} modified file(s)...`);
147
148
  for (const filePath of modifiedFiles) {
148
149
  const sourceFile = project.getSourceFileOrThrow(filePath);
149
150
  await sourceFile.save();
150
- console.log(` Saved: ${import_path.default.relative(process.cwd(), filePath)}`);
151
+ console.log(` Saved: ${import_path.default.relative(getCwd(), filePath)}`);
151
152
  }
152
153
  console.log(
153
154
  `
@@ -190,8 +191,6 @@ function ensureImports(sourceFile) {
190
191
  var DEFINE_CONFIG_NAME2 = "defineConfig";
191
192
  var ACTIONS_PROPERTY_NAME2 = "actions";
192
193
  var TYPE_PROPERTY_NAME2 = "type";
193
- var ID_PROPERTY_NAME = "id";
194
- var FLAGS_PROPERTY_NAME = "flags";
195
194
  var CUSTOM_ACTION_TYPE_PROPERTY_NAME = "customActionType";
196
195
  var AUDIT_HISTORY_LABEL_PROPERTY_NAME = "auditHistoryLabel";
197
196
  var DEDUPLICATION_PROPERTY_NAME = "deduplication";
@@ -201,12 +200,9 @@ var FORM_PROPERTY_NAME = "form";
201
200
  var ACTION_TYPE_ENUM_NAME = "ActionType";
202
201
  var VALIDATE_MEMBER_NAME = "VALIDATE";
203
202
  var CUSTOM_MEMBER_NAME = "CUSTOM";
204
- var REGISTER_MEMBER_NAME2 = "REGISTER";
205
203
  var VALIDATE_STRING_LITERAL = "VALIDATE";
206
204
  var CUSTOM_STRING_LITERAL = "CUSTOM";
207
- var REGISTER_STRING_LITERAL2 = "REGISTER";
208
205
  var VALIDATE_DECLARATION_VALUE = "VALIDATE_DECLARATION";
209
- var VALIDATED_FLAG_VALUE = "validated";
210
206
  function isValidateType(typeInitializer) {
211
207
  if (typeInitializer.getKind() === import_ts_morph2.SyntaxKind.PropertyAccessExpression) {
212
208
  const propAccess = typeInitializer.asKindOrThrow(
@@ -330,50 +326,6 @@ function transformValidateActionToCustom(obj, eventType) {
330
326
  }
331
327
  return true;
332
328
  }
333
- function isRegisterAction(action) {
334
- const typeProperty = action.getProperty(TYPE_PROPERTY_NAME2);
335
- if (!typeProperty || !import_ts_morph2.Node.isPropertyAssignment(typeProperty)) return false;
336
- const typeInit = typeProperty.getInitializer();
337
- if (!typeInit) return false;
338
- if (import_ts_morph2.Node.isPropertyAccessExpression(typeInit)) {
339
- const enumExpr = typeInit.getExpression();
340
- return import_ts_morph2.Node.isIdentifier(enumExpr) && enumExpr.getText() === ACTION_TYPE_ENUM_NAME && typeInit.getName() === REGISTER_MEMBER_NAME2;
341
- }
342
- if (import_ts_morph2.Node.isStringLiteral(typeInit)) {
343
- return typeInit.getLiteralValue() === REGISTER_STRING_LITERAL2;
344
- }
345
- return false;
346
- }
347
- function arrayHasElementWithId(array3, id) {
348
- for (const el of array3.getElements()) {
349
- if (!import_ts_morph2.Node.isObjectLiteralExpression(el)) continue;
350
- const idProp = el.getProperty(ID_PROPERTY_NAME);
351
- if (!idProp || !import_ts_morph2.Node.isPropertyAssignment(idProp)) continue;
352
- const idInit = idProp.getInitializer();
353
- if (idInit && import_ts_morph2.Node.isStringLiteral(idInit) && idInit.getLiteralValue() === id) {
354
- return true;
355
- }
356
- }
357
- return false;
358
- }
359
- function ensureRegisterRemovesValidatedFlag(action) {
360
- const entry = `{ id: '${VALIDATED_FLAG_VALUE}', operation: 'remove' }`;
361
- const flagsProp = action.getProperty(FLAGS_PROPERTY_NAME);
362
- if (flagsProp && import_ts_morph2.Node.isPropertyAssignment(flagsProp)) {
363
- const flagsInit = flagsProp.getInitializer();
364
- if (flagsInit && import_ts_morph2.Node.isArrayLiteralExpression(flagsInit)) {
365
- if (arrayHasElementWithId(flagsInit, VALIDATED_FLAG_VALUE)) return false;
366
- flagsInit.addElement(entry);
367
- return true;
368
- }
369
- return false;
370
- }
371
- action.addPropertyAssignment({
372
- name: FLAGS_PROPERTY_NAME,
373
- initializer: `[${entry}]`
374
- });
375
- return true;
376
- }
377
329
  function processFile2(filePath, project) {
378
330
  const sourceFile = project.getSourceFile(filePath);
379
331
  if (!sourceFile) return 0;
@@ -399,7 +351,7 @@ function processFile2(filePath, project) {
399
351
  const eventType = resolveEventType(configArg);
400
352
  if (!eventType) {
401
353
  console.warn(
402
- ` [${import_path2.default.relative(process.cwd(), configArg.getSourceFile().getFilePath())}] Could not resolve root 'type' from defineConfig \u2014 skipping auditHistoryLabel id generation`
354
+ ` [${import_path2.default.relative(getCwd(), configArg.getSourceFile().getFilePath())}] Could not resolve root 'type' from defineConfig \u2014 skipping auditHistoryLabel id generation`
403
355
  );
404
356
  }
405
357
  let fileNeedsImports = false;
@@ -415,7 +367,7 @@ function processFile2(filePath, project) {
415
367
  fileNeedsImports = true;
416
368
  configHadValidateAction = true;
417
369
  console.log(
418
- ` [${import_path2.default.relative(process.cwd(), filePath)}] Transformed VALIDATE action to CUSTOM with customActionType: '${VALIDATE_DECLARATION_VALUE}'`
370
+ ` [${import_path2.default.relative(getCwd(), filePath)}] Transformed VALIDATE action to CUSTOM with customActionType: '${VALIDATE_DECLARATION_VALUE}'`
419
371
  );
420
372
  }
421
373
  }
@@ -436,21 +388,9 @@ function processFile2(filePath, project) {
436
388
  ]`
437
389
  });
438
390
  console.log(
439
- ` [${import_path2.default.relative(process.cwd(), filePath)}] Added top-level 'flags' array to defineConfig`
391
+ ` [${import_path2.default.relative(getCwd(), filePath)}] Added top-level 'flags' array to defineConfig`
440
392
  );
441
393
  }
442
- if (configHadValidateAction) {
443
- for (const element of actionsInitializer.getElements()) {
444
- if (!import_ts_morph2.Node.isObjectLiteralExpression(element)) continue;
445
- if (!isRegisterAction(element)) continue;
446
- if (ensureRegisterRemovesValidatedFlag(element)) {
447
- transformedCount++;
448
- console.log(
449
- ` [${import_path2.default.relative(process.cwd(), filePath)}] Added '${VALIDATED_FLAG_VALUE}' remove-flag to REGISTER action`
450
- );
451
- }
452
- }
453
- }
454
394
  if (fileNeedsImports) {
455
395
  ensureImports(sourceFile);
456
396
  }
@@ -458,7 +398,7 @@ function processFile2(filePath, project) {
458
398
  return transformedCount;
459
399
  }
460
400
  async function main2() {
461
- const srcDir = import_path2.default.join(process.cwd(), "src");
401
+ const srcDir = import_path2.default.join(getCwd(), "src");
462
402
  console.log(`Scanning for defineConfig calls in: ${srcDir}
463
403
  `);
464
404
  const project = new import_ts_morph2.Project({
@@ -493,11 +433,11 @@ Saving ${modifiedFiles.length} modified file(s)...`);
493
433
  for (const filePath of modifiedFiles) {
494
434
  const sourceFile = project.getSourceFileOrThrow(filePath);
495
435
  await sourceFile.save();
496
- console.log(` Saved: ${import_path2.default.relative(process.cwd(), filePath)}`);
436
+ console.log(` Saved: ${import_path2.default.relative(getCwd(), filePath)}`);
497
437
  }
498
438
  console.log(
499
439
  `
500
- Done. Applied ${totalTransformed} change(s): VALIDATE \u2192 CUSTOM (${VALIDATE_DECLARATION_VALUE}) and '${VALIDATED_FLAG_VALUE}' remove-flag on matching REGISTER actions.`
440
+ Done. Transformed ${totalTransformed} VALIDATE action(s) to CUSTOM with customActionType: '${VALIDATE_DECLARATION_VALUE}'.`
501
441
  );
502
442
  }
503
443
 
@@ -564,14 +504,14 @@ function processFile3(filePath, project) {
564
504
  actionsInitializer.removeElement(index);
565
505
  removedCount++;
566
506
  console.log(
567
- ` [${import_path3.default.relative(process.cwd(), filePath)}] Removed DELETE action at index ${index}`
507
+ ` [${import_path3.default.relative(getCwd(), filePath)}] Removed DELETE action at index ${index}`
568
508
  );
569
509
  }
570
510
  }
571
511
  return removedCount;
572
512
  }
573
513
  async function main3() {
574
- const srcDir = import_path3.default.join(process.cwd(), "src");
514
+ const srcDir = import_path3.default.join(getCwd(), "src");
575
515
  console.log(`Scanning for defineConfig calls in: ${srcDir}
576
516
  `);
577
517
  const project = new import_ts_morph3.Project({
@@ -606,7 +546,7 @@ Saving ${modifiedFiles.length} modified file(s)...`);
606
546
  for (const filePath of modifiedFiles) {
607
547
  const sourceFile = project.getSourceFileOrThrow(filePath);
608
548
  await sourceFile.save();
609
- console.log(` Saved: ${import_path3.default.relative(process.cwd(), filePath)}`);
549
+ console.log(` Saved: ${import_path3.default.relative(getCwd(), filePath)}`);
610
550
  }
611
551
  console.log(
612
552
  `
@@ -680,19 +620,19 @@ function processFile4(filePath, project) {
680
620
  if (result === "converted-to-heading") {
681
621
  changedCount++;
682
622
  console.log(
683
- ` [${import_path4.default.relative(process.cwd(), filePath)}] Converted PARAGRAPH with heading fontVariant to HEADING`
623
+ ` [${import_path4.default.relative(getCwd(), filePath)}] Converted PARAGRAPH with heading fontVariant to HEADING`
684
624
  );
685
625
  } else if (result === "removed-font-variant") {
686
626
  changedCount++;
687
627
  console.log(
688
- ` [${import_path4.default.relative(process.cwd(), filePath)}] Removed non-heading fontVariant from PARAGRAPH`
628
+ ` [${import_path4.default.relative(getCwd(), filePath)}] Removed non-heading fontVariant from PARAGRAPH`
689
629
  );
690
630
  }
691
631
  }
692
632
  return changedCount;
693
633
  }
694
634
  async function main4() {
695
- const srcDir = import_path4.default.join(process.cwd(), "src");
635
+ const srcDir = import_path4.default.join(getCwd(), "src");
696
636
  console.log(`Scanning for FieldType.PARAGRAPH fields in: ${srcDir}
697
637
  `);
698
638
  const project = new import_ts_morph4.Project({
@@ -726,7 +666,7 @@ Saving ${modifiedFiles.length} modified file(s)...`);
726
666
  for (const filePath of modifiedFiles) {
727
667
  const sourceFile = project.getSourceFileOrThrow(filePath);
728
668
  await sourceFile.save();
729
- console.log(` Saved: ${import_path4.default.relative(process.cwd(), filePath)}`);
669
+ console.log(` Saved: ${import_path4.default.relative(getCwd(), filePath)}`);
730
670
  }
731
671
  console.log(`
732
672
  Done. Processed ${totalChanged} FieldType.PARAGRAPH field(s).`);
@@ -740,14 +680,14 @@ var QUERY_PROPERTY_NAME = "query";
740
680
  var TYPE_PROPERTY_NAME5 = "type";
741
681
  var CLAUSES_PROPERTY_NAME = "clauses";
742
682
  var STATUS_PROPERTY_NAME = "status";
743
- var FLAGS_PROPERTY_NAME2 = "flags";
683
+ var FLAGS_PROPERTY_NAME = "flags";
744
684
  var TERMS_PROPERTY_NAME = "terms";
745
685
  var TERM_PROPERTY_NAME = "term";
746
686
  var ANY_OF_PROPERTY_NAME = "anyOf";
747
687
  var VALIDATED_STATUS_VALUE = "VALIDATED";
748
- var VALIDATED_FLAG_VALUE2 = "validated";
688
+ var VALIDATED_FLAG_VALUE = "validated";
749
689
  function addValidatedFlag(clause) {
750
- const flagsProperty = clause.getProperty(FLAGS_PROPERTY_NAME2);
690
+ const flagsProperty = clause.getProperty(FLAGS_PROPERTY_NAME);
751
691
  if (flagsProperty && import_ts_morph5.Node.isPropertyAssignment(flagsProperty)) {
752
692
  const flagsInit = flagsProperty.getInitializer();
753
693
  if (flagsInit && import_ts_morph5.Node.isObjectLiteralExpression(flagsInit)) {
@@ -755,19 +695,19 @@ function addValidatedFlag(clause) {
755
695
  if (anyOfProperty && import_ts_morph5.Node.isPropertyAssignment(anyOfProperty)) {
756
696
  const anyOfInit = anyOfProperty.getInitializer();
757
697
  if (anyOfInit && import_ts_morph5.Node.isArrayLiteralExpression(anyOfInit)) {
758
- anyOfInit.addElement(`'${VALIDATED_FLAG_VALUE2}'`);
698
+ anyOfInit.addElement(`'${VALIDATED_FLAG_VALUE}'`);
759
699
  }
760
700
  } else {
761
701
  flagsInit.addPropertyAssignment({
762
702
  name: ANY_OF_PROPERTY_NAME,
763
- initializer: `['${VALIDATED_FLAG_VALUE2}']`
703
+ initializer: `['${VALIDATED_FLAG_VALUE}']`
764
704
  });
765
705
  }
766
706
  }
767
707
  } else {
768
708
  clause.addPropertyAssignment({
769
- name: FLAGS_PROPERTY_NAME2,
770
- initializer: `{ ${ANY_OF_PROPERTY_NAME}: ['${VALIDATED_FLAG_VALUE2}'] }`
709
+ name: FLAGS_PROPERTY_NAME,
710
+ initializer: `{ ${ANY_OF_PROPERTY_NAME}: ['${VALIDATED_FLAG_VALUE}'] }`
771
711
  });
772
712
  }
773
713
  }
@@ -876,7 +816,7 @@ function processFile5(filePath, project) {
876
816
  if (changed > 0) {
877
817
  migratedCount += changed;
878
818
  console.log(
879
- ` [${import_path5.default.relative(process.cwd(), filePath)}] Migrated ${changed} clause(s): VALIDATED status \u2192 flags.anyOf`
819
+ ` [${import_path5.default.relative(getCwd(), filePath)}] Migrated ${changed} clause(s): VALIDATED status \u2192 flags.anyOf`
880
820
  );
881
821
  }
882
822
  }
@@ -884,7 +824,7 @@ function processFile5(filePath, project) {
884
824
  return migratedCount;
885
825
  }
886
826
  async function main5() {
887
- const srcDir = import_path5.default.join(process.cwd(), "src");
827
+ const srcDir = import_path5.default.join(getCwd(), "src");
888
828
  console.log(`Scanning for defineWorkqueues calls in: ${srcDir}
889
829
  `);
890
830
  const project = new import_ts_morph5.Project({
@@ -918,7 +858,7 @@ Saving ${modifiedFiles.length} modified file(s)...`);
918
858
  for (const filePath of modifiedFiles) {
919
859
  const sourceFile = project.getSourceFileOrThrow(filePath);
920
860
  await sourceFile.save();
921
- console.log(` Saved: ${import_path5.default.relative(process.cwd(), filePath)}`);
861
+ console.log(` Saved: ${import_path5.default.relative(getCwd(), filePath)}`);
922
862
  }
923
863
  console.log(
924
864
  `
@@ -933,26 +873,23 @@ var DEFINE_CONFIG_NAME4 = "defineConfig";
933
873
  var DEFINE_WORKQUEUES_NAME2 = "defineWorkqueues";
934
874
  var ACTIONS_PROPERTY_NAME4 = "actions";
935
875
  var ACTION_PROPERTY_NAME = "action";
936
- var FLAGS_PROPERTY_NAME3 = "flags";
876
+ var FLAGS_PROPERTY_NAME2 = "flags";
937
877
  var QUERY_PROPERTY_NAME2 = "query";
938
878
  var TYPE_PROPERTY_NAME6 = "type";
939
- var ID_PROPERTY_NAME2 = "id";
940
879
  var CLAUSES_PROPERTY_NAME2 = "clauses";
941
880
  var ANY_OF_PROPERTY_NAME2 = "anyOf";
942
881
  var FLAG_ID = "pending-first-certificate-issuance";
943
882
  var REGISTER_TYPE = "REGISTER";
944
883
  var PRINT_CERTIFICATE_TYPE = "PRINT_CERTIFICATE";
945
- function flagDefinitionInitializer(eventType) {
946
- return `{
884
+ var FLAG_DEFINITION_INITIALIZER = `{
947
885
  id: '${FLAG_ID}',
948
886
  label: {
949
- id: 'event.${eventType}.flag.${FLAG_ID}',
887
+ id: 'event.birth.flag.${FLAG_ID}',
950
888
  defaultMessage: 'Pending first certificate issuance',
951
889
  description: 'Flag label for first certificate issuance'
952
890
  },
953
891
  requiresAction: true
954
892
  }`;
955
- }
956
893
  function isActionOfType(obj, typeName) {
957
894
  const typeProperty = obj.getProperty(TYPE_PROPERTY_NAME6);
958
895
  if (!typeProperty || !import_ts_morph6.Node.isPropertyAssignment(typeProperty)) return false;
@@ -966,20 +903,18 @@ function isActionOfType(obj, typeName) {
966
903
  }
967
904
  return false;
968
905
  }
969
- function getEventType(configArg) {
970
- for (const propName of [TYPE_PROPERTY_NAME6, ID_PROPERTY_NAME2]) {
971
- const prop = configArg.getProperty(propName);
972
- if (!prop || !import_ts_morph6.Node.isPropertyAssignment(prop)) continue;
973
- const initializer = prop.getInitializer();
974
- if (!initializer) continue;
975
- if (import_ts_morph6.Node.isStringLiteral(initializer)) {
976
- return initializer.getLiteralValue().toLowerCase();
977
- }
978
- if (import_ts_morph6.Node.isPropertyAccessExpression(initializer)) {
979
- return initializer.getName().toLowerCase();
980
- }
906
+ function isBirthConfig(configArg) {
907
+ const typeProperty = configArg.getProperty(TYPE_PROPERTY_NAME6);
908
+ if (!typeProperty || !import_ts_morph6.Node.isPropertyAssignment(typeProperty)) return false;
909
+ const initializer = typeProperty.getInitializer();
910
+ if (!initializer) return false;
911
+ if (import_ts_morph6.Node.isStringLiteral(initializer)) {
912
+ return initializer.getLiteralValue().toLowerCase() === "birth";
981
913
  }
982
- return null;
914
+ if (import_ts_morph6.Node.isPropertyAccessExpression(initializer)) {
915
+ return initializer.getName().toLowerCase() === "birth";
916
+ }
917
+ return false;
983
918
  }
984
919
  function hasElementWithId(array3, id) {
985
920
  for (const el of array3.getElements()) {
@@ -993,28 +928,27 @@ function hasElementWithId(array3, id) {
993
928
  }
994
929
  return false;
995
930
  }
996
- function ensureTopLevelFlagDefinition(configArg, eventType) {
997
- const initializer = flagDefinitionInitializer(eventType);
998
- const flagsProp = configArg.getProperty(FLAGS_PROPERTY_NAME3);
931
+ function ensureTopLevelFlagDefinition(configArg) {
932
+ const flagsProp = configArg.getProperty(FLAGS_PROPERTY_NAME2);
999
933
  if (flagsProp && import_ts_morph6.Node.isPropertyAssignment(flagsProp)) {
1000
934
  const flagsInit = flagsProp.getInitializer();
1001
935
  if (flagsInit && import_ts_morph6.Node.isArrayLiteralExpression(flagsInit)) {
1002
936
  if (hasElementWithId(flagsInit, FLAG_ID)) return false;
1003
- flagsInit.addElement(initializer);
937
+ flagsInit.addElement(FLAG_DEFINITION_INITIALIZER);
1004
938
  return true;
1005
939
  }
1006
940
  return false;
1007
941
  }
1008
942
  configArg.addPropertyAssignment({
1009
- name: FLAGS_PROPERTY_NAME3,
943
+ name: FLAGS_PROPERTY_NAME2,
1010
944
  initializer: `[
1011
- ${initializer}
945
+ ${FLAG_DEFINITION_INITIALIZER}
1012
946
  ]`
1013
947
  });
1014
948
  return true;
1015
949
  }
1016
950
  function ensureActionOperationFlag(action, operation) {
1017
- const flagsProp = action.getProperty(FLAGS_PROPERTY_NAME3);
951
+ const flagsProp = action.getProperty(FLAGS_PROPERTY_NAME2);
1018
952
  const entry = `{ id: '${FLAG_ID}', operation: '${operation}' }`;
1019
953
  if (flagsProp && import_ts_morph6.Node.isPropertyAssignment(flagsProp)) {
1020
954
  const flagsInit = flagsProp.getInitializer();
@@ -1026,18 +960,16 @@ function ensureActionOperationFlag(action, operation) {
1026
960
  return false;
1027
961
  }
1028
962
  action.addPropertyAssignment({
1029
- name: FLAGS_PROPERTY_NAME3,
963
+ name: FLAGS_PROPERTY_NAME2,
1030
964
  initializer: `[${entry}]`
1031
965
  });
1032
966
  return true;
1033
967
  }
1034
- function processConfig(configArg, eventType, relPath) {
968
+ function processBirthConfig(configArg, relPath) {
1035
969
  let changes = 0;
1036
- if (ensureTopLevelFlagDefinition(configArg, eventType)) {
970
+ if (ensureTopLevelFlagDefinition(configArg)) {
1037
971
  changes++;
1038
- console.log(
1039
- ` [${relPath}] (${eventType}) Added '${FLAG_ID}' to top-level flags`
1040
- );
972
+ console.log(` [${relPath}] Added '${FLAG_ID}' to top-level flags`);
1041
973
  }
1042
974
  const actionsProp = configArg.getProperty(ACTIONS_PROPERTY_NAME4);
1043
975
  if (!actionsProp || !import_ts_morph6.Node.isPropertyAssignment(actionsProp)) return changes;
@@ -1051,7 +983,7 @@ function processConfig(configArg, eventType, relPath) {
1051
983
  if (ensureActionOperationFlag(element, "add")) {
1052
984
  changes++;
1053
985
  console.log(
1054
- ` [${relPath}] (${eventType}) Added '${FLAG_ID}' add-flag to REGISTER action`
986
+ ` [${relPath}] Added '${FLAG_ID}' add-flag to REGISTER action`
1055
987
  );
1056
988
  }
1057
989
  }
@@ -1059,7 +991,7 @@ function processConfig(configArg, eventType, relPath) {
1059
991
  if (ensureActionOperationFlag(element, "remove")) {
1060
992
  changes++;
1061
993
  console.log(
1062
- ` [${relPath}] (${eventType}) Added '${FLAG_ID}' remove-flag to PRINT_CERTIFICATE action`
994
+ ` [${relPath}] Added '${FLAG_ID}' remove-flag to PRINT_CERTIFICATE action`
1063
995
  );
1064
996
  }
1065
997
  }
@@ -1088,7 +1020,7 @@ function hasPrintCertificateAction(workqueue) {
1088
1020
  return false;
1089
1021
  }
1090
1022
  function addFlagToQueryClause(clause) {
1091
- const flagsProp = clause.getProperty(FLAGS_PROPERTY_NAME3);
1023
+ const flagsProp = clause.getProperty(FLAGS_PROPERTY_NAME2);
1092
1024
  if (flagsProp && import_ts_morph6.Node.isPropertyAssignment(flagsProp)) {
1093
1025
  const flagsInit = flagsProp.getInitializer();
1094
1026
  if (flagsInit && import_ts_morph6.Node.isObjectLiteralExpression(flagsInit)) {
@@ -1113,7 +1045,7 @@ function addFlagToQueryClause(clause) {
1113
1045
  }
1114
1046
  } else {
1115
1047
  clause.addPropertyAssignment({
1116
- name: FLAGS_PROPERTY_NAME3,
1048
+ name: FLAGS_PROPERTY_NAME2,
1117
1049
  initializer: `{ ${ANY_OF_PROPERTY_NAME2}: ['${FLAG_ID}'] }`
1118
1050
  });
1119
1051
  return true;
@@ -1144,7 +1076,7 @@ function processFile6(filePath, project) {
1144
1076
  const sourceFile = project.getSourceFile(filePath);
1145
1077
  if (!sourceFile) return 0;
1146
1078
  let totalChanges = 0;
1147
- const relPath = import_path6.default.relative(process.cwd(), filePath);
1079
+ const relPath = import_path6.default.relative(getCwd(), filePath);
1148
1080
  const callExpressions = sourceFile.getDescendantsOfKind(
1149
1081
  import_ts_morph6.SyntaxKind.CallExpression
1150
1082
  );
@@ -1157,9 +1089,8 @@ function processFile6(filePath, project) {
1157
1089
  if (args.length === 0) continue;
1158
1090
  const configArg = args[0];
1159
1091
  if (!import_ts_morph6.Node.isObjectLiteralExpression(configArg)) continue;
1160
- const eventType = getEventType(configArg);
1161
- if (!eventType) continue;
1162
- totalChanges += processConfig(configArg, eventType, relPath);
1092
+ if (!isBirthConfig(configArg)) continue;
1093
+ totalChanges += processBirthConfig(configArg, relPath);
1163
1094
  }
1164
1095
  if (calleeName === DEFINE_WORKQUEUES_NAME2) {
1165
1096
  const args = call.getArguments();
@@ -1186,9 +1117,9 @@ function processFile6(filePath, project) {
1186
1117
  return totalChanges;
1187
1118
  }
1188
1119
  async function main6() {
1189
- const srcDir = import_path6.default.join(process.cwd(), "src");
1120
+ const srcDir = import_path6.default.join(getCwd(), "src");
1190
1121
  console.log(
1191
- `Scanning for defineConfig and PRINT_CERTIFICATE workqueues in: ${srcDir}
1122
+ `Scanning for birth defineConfig and PRINT_CERTIFICATE workqueues in: ${srcDir}
1192
1123
  `
1193
1124
  );
1194
1125
  const project = new import_ts_morph6.Project({
@@ -1213,7 +1144,7 @@ async function main6() {
1213
1144
  }
1214
1145
  if (modifiedFiles.length === 0) {
1215
1146
  console.log(
1216
- "No event configs or PRINT_CERTIFICATE workqueues found. Nothing to do."
1147
+ "No birth configs or PRINT_CERTIFICATE workqueues found. Nothing to do."
1217
1148
  );
1218
1149
  return;
1219
1150
  }
@@ -1222,7 +1153,7 @@ Saving ${modifiedFiles.length} modified file(s)...`);
1222
1153
  for (const filePath of modifiedFiles) {
1223
1154
  const sourceFile = project.getSourceFileOrThrow(filePath);
1224
1155
  await sourceFile.save();
1225
- console.log(` Saved: ${import_path6.default.relative(process.cwd(), filePath)}`);
1156
+ console.log(` Saved: ${import_path6.default.relative(getCwd(), filePath)}`);
1226
1157
  }
1227
1158
  console.log(
1228
1159
  `
@@ -1259,14 +1190,14 @@ function processFile7(filePath, project) {
1259
1190
  array3.removeElement(index);
1260
1191
  removedCount++;
1261
1192
  console.log(
1262
- ` [${import_path7.default.relative(process.cwd(), filePath)}] Removed InherentFlags.PENDING_CERTIFICATION from array`
1193
+ ` [${import_path7.default.relative(getCwd(), filePath)}] Removed InherentFlags.PENDING_CERTIFICATION from array`
1263
1194
  );
1264
1195
  }
1265
1196
  }
1266
1197
  return removedCount;
1267
1198
  }
1268
1199
  async function main7() {
1269
- const srcDir = import_path7.default.join(process.cwd(), "src");
1200
+ const srcDir = import_path7.default.join(getCwd(), "src");
1270
1201
  console.log(
1271
1202
  `Scanning for InherentFlags.PENDING_CERTIFICATION array elements in: ${srcDir}
1272
1203
  `
@@ -1302,7 +1233,7 @@ Saving ${modifiedFiles.length} modified file(s)...`);
1302
1233
  for (const filePath of modifiedFiles) {
1303
1234
  const sourceFile = project.getSourceFileOrThrow(filePath);
1304
1235
  await sourceFile.save();
1305
- console.log(` Saved: ${import_path7.default.relative(process.cwd(), filePath)}`);
1236
+ console.log(` Saved: ${import_path7.default.relative(getCwd(), filePath)}`);
1306
1237
  }
1307
1238
  console.log(
1308
1239
  `
@@ -1360,13 +1291,13 @@ function processFile8(filePath, project) {
1360
1291
  propAccess.getNameNode().replaceWithText(NEW_PROPERTY_NAME);
1361
1292
  renamedCount++;
1362
1293
  console.log(
1363
- ` [${import_path8.default.relative(process.cwd(), filePath)}] Renamed Location.${OLD_PROPERTY_NAME} \u2192 Location.${NEW_PROPERTY_NAME}`
1294
+ ` [${import_path8.default.relative(getCwd(), filePath)}] Renamed Location.${OLD_PROPERTY_NAME} \u2192 Location.${NEW_PROPERTY_NAME}`
1364
1295
  );
1365
1296
  }
1366
1297
  return renamedCount;
1367
1298
  }
1368
1299
  async function main8() {
1369
- const srcDir = import_path8.default.join(process.cwd(), "src");
1300
+ const srcDir = import_path8.default.join(getCwd(), "src");
1370
1301
  console.log(
1371
1302
  `Scanning for Location.${OLD_PROPERTY_NAME} references in: ${srcDir}
1372
1303
  `
@@ -1402,7 +1333,7 @@ Saving ${modifiedFiles.length} modified file(s)...`);
1402
1333
  for (const filePath of modifiedFiles) {
1403
1334
  const sourceFile = project.getSourceFileOrThrow(filePath);
1404
1335
  await sourceFile.save();
1405
- console.log(` Saved: ${import_path8.default.relative(process.cwd(), filePath)}`);
1336
+ console.log(` Saved: ${import_path8.default.relative(getCwd(), filePath)}`);
1406
1337
  }
1407
1338
  console.log(
1408
1339
  `
@@ -1469,7 +1400,7 @@ function processFile9(filePath, project) {
1469
1400
  const sourceFile = project.getSourceFile(filePath);
1470
1401
  if (!sourceFile) return 0;
1471
1402
  let renamedCount = 0;
1472
- const relPath = import_path9.default.relative(process.cwd(), filePath);
1403
+ const relPath = import_path9.default.relative(getCwd(), filePath);
1473
1404
  const candidates = sourceFile.getDescendantsOfKind(
1474
1405
  import_ts_morph9.SyntaxKind.ObjectLiteralExpression
1475
1406
  );
@@ -1484,7 +1415,7 @@ function processFile9(filePath, project) {
1484
1415
  return renamedCount;
1485
1416
  }
1486
1417
  async function main9() {
1487
- const srcDir = import_path9.default.join(process.cwd(), "src");
1418
+ const srcDir = import_path9.default.join(getCwd(), "src");
1488
1419
  console.log(`Scanning for Hapi route configs in: ${srcDir}
1489
1420
  `);
1490
1421
  console.log("Active path renames:");
@@ -1521,7 +1452,7 @@ Saving ${modifiedFiles.length} modified file(s)...`);
1521
1452
  for (const filePath of modifiedFiles) {
1522
1453
  const sourceFile = project.getSourceFileOrThrow(filePath);
1523
1454
  await sourceFile.save();
1524
- console.log(` Saved: ${import_path9.default.relative(process.cwd(), filePath)}`);
1455
+ console.log(` Saved: ${import_path9.default.relative(getCwd(), filePath)}`);
1525
1456
  }
1526
1457
  console.log(`
1527
1458
  Done. Renamed ${totalRenamed} route path(s).`);
@@ -1895,9 +1826,9 @@ function updateRouteHandlers(sourceFiles, group, srcDir, relCwd) {
1895
1826
  }
1896
1827
  return replacedCount;
1897
1828
  }
1898
- function resolveConfigChain(configObj, path23) {
1829
+ function resolveConfigChain(configObj, path17) {
1899
1830
  let current = configObj;
1900
- for (const key of path23) {
1831
+ for (const key of path17) {
1901
1832
  if (!import_ts_morph10.Node.isObjectLiteralExpression(current)) return null;
1902
1833
  const prop = current.getProperty(key);
1903
1834
  if (!prop || !import_ts_morph10.Node.isPropertyAssignment(prop)) return null;
@@ -1942,8 +1873,8 @@ function ensureJoinImport(sf) {
1942
1873
  });
1943
1874
  }
1944
1875
  async function main10() {
1945
- const srcDir = import_path10.default.join(process.cwd(), "src");
1946
- const relCwd = (fp) => import_path10.default.relative(process.cwd(), fp);
1876
+ const srcDir = import_path10.default.join(getCwd(), "src");
1877
+ const relCwd = (fp) => import_path10.default.relative(getCwd(), fp);
1947
1878
  console.log("Phase 1: Converting JS config files to TypeScript...\n");
1948
1879
  let convertedCount = 0;
1949
1880
  for (const group of CONFIG_GROUPS) {
@@ -2031,7 +1962,7 @@ async function main10() {
2031
1962
  ensureJoinImport(sf);
2032
1963
  }
2033
1964
  console.log(
2034
- ` Inlined applicationConfig.${accessPath.join(".")} \u2192 ${adjustedValue} in ${import_path10.default.relative(process.cwd(), sf.getFilePath())}`
1965
+ ` Inlined applicationConfig.${accessPath.join(".")} \u2192 ${adjustedValue} in ${import_path10.default.relative(getCwd(), sf.getFilePath())}`
2035
1966
  );
2036
1967
  filesToSaveAfterInlining.add(sf);
2037
1968
  madeReplacement = true;
@@ -2043,7 +1974,7 @@ async function main10() {
2043
1974
  for (const sf of Array.from(filesToSaveAfterInlining)) {
2044
1975
  await sf.save();
2045
1976
  console.log(
2046
- ` Saved (inlined): ${import_path10.default.relative(process.cwd(), sf.getFilePath())}`
1977
+ ` Saved (inlined): ${import_path10.default.relative(getCwd(), sf.getFilePath())}`
2047
1978
  );
2048
1979
  }
2049
1980
  for (const prop of [...propsToRemove].reverse()) {
@@ -2192,10 +2123,6 @@ var scopeByEvent = z3.preprocess(
2192
2123
  (val) => val === void 0 ? void 0 : [val].flat(),
2193
2124
  z3.array(z3.string()).optional()
2194
2125
  ).describe("Event type, e.g. birth, death");
2195
- var userRole = z3.preprocess(
2196
- (val) => val === void 0 ? void 0 : [val].flat(),
2197
- z3.array(z3.string()).optional()
2198
- ).describe("User role, e.g. admin, field agent");
2199
2126
  var scopeOptionsPlaceEvent = z3.object({
2200
2127
  event: scopeByEvent,
2201
2128
  placeOfEvent: JurisdictionFilter.optional()
@@ -2219,9 +2146,6 @@ var CustomActionScopeOptions = AllRecordScopeOptions.extend({
2219
2146
  var AccessLevelOptions = z3.object({
2220
2147
  accessLevel: JurisdictionFilter.optional()
2221
2148
  });
2222
- var AllUserScopeOptions = AccessLevelOptions.extend({
2223
- role: userRole.optional()
2224
- });
2225
2149
  var WorkqueueOrDashboardOptions = z3.object({
2226
2150
  ids: z3.preprocess(
2227
2151
  (val) => val === void 0 ? void 0 : [val].flat(),
@@ -2231,7 +2155,6 @@ var WorkqueueOrDashboardOptions = z3.object({
2231
2155
  var AllScopeOptions = z3.object({
2232
2156
  ...AllRecordScopeOptions.shape,
2233
2157
  ...AccessLevelOptions.shape,
2234
- ...AllUserScopeOptions.shape,
2235
2158
  ...WorkqueueOrDashboardOptions.shape
2236
2159
  });
2237
2160
  var ScopeOptionKey = AllScopeOptions.keyof();
@@ -2304,28 +2227,6 @@ var RecordScopeV2 = z3.discriminatedUnion("type", [
2304
2227
  ]).describe(
2305
2228
  "Scopes used to check user's permission to perform actions on a record."
2306
2229
  );
2307
- var SystemScopeType = z3.enum([
2308
- "organisation.read-locations",
2309
- "user.read",
2310
- "user.create",
2311
- "user.edit"
2312
- ]);
2313
- var UserScopeType = SystemScopeType.extract([
2314
- "user.read",
2315
- "user.create",
2316
- "user.edit"
2317
- ]);
2318
- var ScopesWithRoleOption = UserScopeType.extract(["user.edit", "user.create"]);
2319
- var UserScopeV2 = z3.discriminatedUnion("type", [
2320
- z3.object({
2321
- type: ScopesWithRoleOption,
2322
- options: AllUserScopeOptions.optional()
2323
- }),
2324
- z3.object({
2325
- type: UserScopeType.extract(["user.read"]),
2326
- options: AccessLevelOptions.optional()
2327
- })
2328
- ]);
2329
2230
  var ResolvedRecordScopeV2 = z3.discriminatedUnion("type", [
2330
2231
  z3.object({
2331
2232
  type: ScopesWithPlaceEventOptions,
@@ -2346,14 +2247,16 @@ var ResolvedRecordScopeV2 = z3.discriminatedUnion("type", [
2346
2247
  }).optional()
2347
2248
  })
2348
2249
  ]).describe("Resolved scope with location/user IDs instead of filters.");
2250
+ var SystemScopeType = z3.enum([
2251
+ "organisation.read-locations",
2252
+ "user.read",
2253
+ "user.create",
2254
+ "user.edit"
2255
+ ]);
2349
2256
  var Scope2 = z3.discriminatedUnion("type", [
2350
2257
  z3.object({ type: PlainScopeType }),
2351
2258
  ...RecordScopeV2.options,
2352
- ...UserScopeV2.options,
2353
- z3.object({
2354
- type: z3.literal("organisation.read-locations"),
2355
- options: AccessLevelOptions.optional()
2356
- }),
2259
+ z3.object({ type: SystemScopeType, options: AccessLevelOptions.optional() }),
2357
2260
  z3.object({
2358
2261
  type: z3.literal("workqueue"),
2359
2262
  options: WorkqueueOrDashboardOptions
@@ -2688,7 +2591,7 @@ function migrateScopesArrays(rolesFilePath, project) {
2688
2591
  const scopeKey = resolveScopeKeyFromElementAccess(element);
2689
2592
  if (scopeKey && !(scopeKey in SCOPES)) {
2690
2593
  console.warn(
2691
- ` [${import_path11.default.relative(process.cwd(), rolesFilePath)}] Removing unknown scope reference: SCOPES.${scopeKey}`
2594
+ ` [${import_path11.default.relative(getCwd(), rolesFilePath)}] Removing unknown scope reference: SCOPES.${scopeKey}`
2692
2595
  );
2693
2596
  initializer.removeElement(index);
2694
2597
  removedCount++;
@@ -2697,7 +2600,7 @@ function migrateScopesArrays(rolesFilePath, project) {
2697
2600
  const legacyScope = resolveLegacyScopeFromElement(element);
2698
2601
  if (!legacyScope) {
2699
2602
  console.warn(
2700
- ` [${import_path11.default.relative(process.cwd(), rolesFilePath)}] Skipping non-literal scope expression: ${element.getText()}`
2603
+ ` [${import_path11.default.relative(getCwd(), rolesFilePath)}] Skipping non-literal scope expression: ${element.getText()}`
2701
2604
  );
2702
2605
  continue;
2703
2606
  }
@@ -2706,7 +2609,7 @@ function migrateScopesArrays(rolesFilePath, project) {
2706
2609
  const scope = decodeScope(migratedScope);
2707
2610
  if (!scope) {
2708
2611
  console.warn(
2709
- ` [${import_path11.default.relative(process.cwd(), rolesFilePath)}] Could not decode migrated scope '${migratedScope}'.`
2612
+ ` [${import_path11.default.relative(getCwd(), rolesFilePath)}] Could not decode migrated scope '${migratedScope}'.`
2710
2613
  );
2711
2614
  continue;
2712
2615
  }
@@ -2714,14 +2617,14 @@ function migrateScopesArrays(rolesFilePath, project) {
2714
2617
  migratedCount++;
2715
2618
  } catch (error) {
2716
2619
  console.warn(
2717
- ` [${import_path11.default.relative(process.cwd(), rolesFilePath)}] Could not migrate scope '${legacyScope}': ${error}`
2620
+ ` [${import_path11.default.relative(getCwd(), rolesFilePath)}] Could not migrate scope '${legacyScope}': ${error}`
2718
2621
  );
2719
2622
  }
2720
2623
  }
2721
2624
  }
2722
2625
  if (removedCount > 0) {
2723
2626
  console.log(
2724
- ` Removed ${removedCount} unknown SCOPES reference(s) from '${import_path11.default.relative(process.cwd(), rolesFilePath)}'.`
2627
+ ` Removed ${removedCount} unknown SCOPES reference(s) from '${import_path11.default.relative(getCwd(), rolesFilePath)}'.`
2725
2628
  );
2726
2629
  }
2727
2630
  return { migratedCount, removedCount };
@@ -2843,9 +2746,9 @@ function removeRoleTypeDefinitionAndUnusedImports(rolesFilePath, project) {
2843
2746
  return removed;
2844
2747
  }
2845
2748
  async function main11() {
2846
- const cwd = process.cwd();
2847
- const srcDir = import_path11.default.join(cwd, "src");
2848
- const rolesFilePath = import_path11.default.join(cwd, ROLES_FILE_RELATIVE_PATH);
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);
2849
2752
  console.log(`Scanning roles scopes in: ${rolesFilePath}`);
2850
2753
  const project = new import_ts_morph11.Project({
2851
2754
  tsConfigFilePath: import_path11.default.resolve(srcDir, "../tsconfig.json"),
@@ -2909,13 +2812,13 @@ function processFile10(filePath, project) {
2909
2812
  decl.remove();
2910
2813
  }
2911
2814
  console.log(
2912
- ` [${import_path12.default.relative(process.cwd(), filePath)}] Removed ${matchingNamedImports.length} deprecated '${DEPRECATED_IMPORT}' import(s) from '${decl.getModuleSpecifierValue()}'`
2815
+ ` [${import_path12.default.relative(getCwd(), filePath)}] Removed ${matchingNamedImports.length} deprecated '${DEPRECATED_IMPORT}' import(s) from '${decl.getModuleSpecifierValue()}'`
2913
2816
  );
2914
2817
  }
2915
2818
  return removedCount;
2916
2819
  }
2917
2820
  async function main12() {
2918
- const srcDir = import_path12.default.join(process.cwd(), "src");
2821
+ const srcDir = import_path12.default.join(getCwd(), "src");
2919
2822
  console.log(`Scanning for deprecated imports in: ${srcDir}
2920
2823
  `);
2921
2824
  const project = new import_ts_morph12.Project({
@@ -2946,924 +2849,201 @@ async function main12() {
2946
2849
  Saving ${modifiedFiles.length} modified file(s)...`);
2947
2850
  for (const filePath of modifiedFiles) {
2948
2851
  await project.getSourceFileOrThrow(filePath).save();
2949
- console.log(` Saved: ${import_path12.default.relative(process.cwd(), filePath)}`);
2852
+ console.log(` Saved: ${import_path12.default.relative(getCwd(), filePath)}`);
2950
2853
  }
2951
2854
  console.log(`
2952
2855
  Done. Removed ${totalRemoved} deprecated import(s).`);
2953
2856
  }
2954
2857
 
2955
- // src/migrations/v2.0/remove-unused-environment-variables.ts
2956
- var import_path13 = __toESM(require("path"));
2858
+ // src/migrations/v2.0/migrate-workqueue-configs.ts
2957
2859
  var import_ts_morph13 = require("ts-morph");
2958
- var UNUSED_ENV_VARS = /* @__PURE__ */ new Set([
2959
- "APPLICATION_CONFIG_URL",
2960
- "FHIR_URL",
2961
- "CONFIRM_REGISTRATION_URL"
2860
+ var import_path13 = __toESM(require("path"));
2861
+ var DEFINE_WORKQUEUES_NAME3 = "defineWorkqueues";
2862
+ var ACTIONS_PROPERTY_NAME5 = "actions";
2863
+ var ACTION_PROPERTY_NAME2 = "action";
2864
+ var CONDITIONALS_PROPERTY_NAME = "conditionals";
2865
+ var TYPE_PROPERTY_NAME7 = "type";
2866
+ var SLUG_PROPERTY_NAME = "slug";
2867
+ var SUPPORTED_WORKQUEUE_ACTION_TYPES = /* @__PURE__ */ new Set([
2868
+ "READ",
2869
+ "DELETE",
2870
+ "DECLARE",
2871
+ "REGISTER",
2872
+ "EDIT",
2873
+ "REJECT",
2874
+ "MARK_AS_DUPLICATE",
2875
+ "ARCHIVE",
2876
+ "PRINT_CERTIFICATE",
2877
+ "REQUEST_CORRECTION"
2962
2878
  ]);
2963
- var ENVIRONMENT_FILE_RELATIVE = "src/environment.ts";
2964
- var CONSTANTS_FILE_RELATIVE = "src/constants.ts";
2965
- function cleanEnvironmentFile(project, filePath) {
2966
- const sourceFile = project.getSourceFile(filePath);
2967
- if (!sourceFile) return [];
2968
- const removed = [];
2969
- const cleanEnvCall = sourceFile.getDescendantsOfKind(import_ts_morph13.SyntaxKind.CallExpression).find((call) => {
2970
- const expr = call.getExpression();
2971
- return import_ts_morph13.Node.isIdentifier(expr) && expr.getText() === "cleanEnv";
2972
- });
2973
- if (!cleanEnvCall) return removed;
2974
- const schemaArg = cleanEnvCall.getArguments()[1]?.asKind(import_ts_morph13.SyntaxKind.ObjectLiteralExpression);
2975
- if (!schemaArg) return removed;
2976
- for (const name of UNUSED_ENV_VARS) {
2977
- const prop = schemaArg.getProperty(name);
2978
- if (!prop) continue;
2979
- if (prop.isKind(import_ts_morph13.SyntaxKind.PropertyAssignment) || prop.isKind(import_ts_morph13.SyntaxKind.ShorthandPropertyAssignment)) {
2980
- prop.remove();
2981
- removed.push(name);
2982
- }
2879
+ function getWorkqueueLabel(workqueue) {
2880
+ const slugProperty = workqueue.getProperty(SLUG_PROPERTY_NAME);
2881
+ if (!slugProperty || !import_ts_morph13.Node.isPropertyAssignment(slugProperty)) {
2882
+ return "(unknown slug)";
2983
2883
  }
2984
- return removed;
2884
+ const slugInitializer = slugProperty.getInitializer();
2885
+ if (!slugInitializer || !import_ts_morph13.Node.isStringLiteral(slugInitializer)) {
2886
+ return "(unknown slug)";
2887
+ }
2888
+ return slugInitializer.getLiteralValue();
2985
2889
  }
2986
- function extractEnvAccess(initText) {
2987
- if (!initText) return null;
2988
- const match = /\benv\.([A-Z][A-Z0-9_]*)\b/.exec(initText);
2989
- return match ? match[1] : null;
2890
+ function getActionTypeName(action) {
2891
+ const typeProperty = action.getProperty(TYPE_PROPERTY_NAME7);
2892
+ if (!typeProperty || !import_ts_morph13.Node.isPropertyAssignment(typeProperty)) {
2893
+ return null;
2894
+ }
2895
+ const typeInitializer = typeProperty.getInitializer();
2896
+ if (!typeInitializer) {
2897
+ return null;
2898
+ }
2899
+ if (import_ts_morph13.Node.isStringLiteral(typeInitializer)) {
2900
+ return typeInitializer.getLiteralValue();
2901
+ }
2902
+ if (import_ts_morph13.Node.isPropertyAccessExpression(typeInitializer)) {
2903
+ return typeInitializer.getName();
2904
+ }
2905
+ return null;
2990
2906
  }
2991
- function cleanConstantsFile(project, filePath) {
2992
- const sourceFile = project.getSourceFile(filePath);
2993
- if (!sourceFile) return [];
2994
- const removed = [];
2995
- for (const stmt of [...sourceFile.getVariableStatements()]) {
2996
- const declarations = [...stmt.getDeclarations()];
2997
- const declarationsToRemove = declarations.filter((decl) => {
2998
- const name = decl.getName();
2999
- const accessedEnvVar = extractEnvAccess(decl.getInitializer()?.getText());
3000
- return UNUSED_ENV_VARS.has(name) || accessedEnvVar !== null && UNUSED_ENV_VARS.has(accessedEnvVar);
3001
- });
3002
- if (declarationsToRemove.length === 0) continue;
3003
- const namesToRemove = declarationsToRemove.map((decl) => decl.getName());
3004
- removed.push(...namesToRemove);
3005
- if (declarationsToRemove.length === declarations.length) {
3006
- stmt.remove();
3007
- } else {
3008
- for (const decl of declarationsToRemove) {
3009
- decl.remove();
3010
- }
3011
- }
2907
+ function isUnsupportedActionType(action) {
2908
+ const typeName = getActionTypeName(action);
2909
+ if (!typeName) {
2910
+ return false;
3012
2911
  }
3013
- return removed;
2912
+ return !SUPPORTED_WORKQUEUE_ACTION_TYPES.has(typeName);
3014
2913
  }
3015
- async function main13() {
3016
- const project = new import_ts_morph13.Project({
3017
- tsConfigFilePath: import_path13.default.resolve(process.cwd(), "tsconfig.json"),
3018
- skipAddingFilesFromTsConfig: false
3019
- });
3020
- console.log(
3021
- `Removing unused environment variable(s) (${[...UNUSED_ENV_VARS].join(", ")})...
3022
- `
3023
- );
3024
- const envFilePath = import_path13.default.join(process.cwd(), ENVIRONMENT_FILE_RELATIVE);
3025
- const constsFilePath = import_path13.default.join(process.cwd(), CONSTANTS_FILE_RELATIVE);
3026
- const envRemoved = cleanEnvironmentFile(project, envFilePath);
3027
- if (envRemoved.length > 0) {
3028
- await project.getSourceFileOrThrow(envFilePath).save();
2914
+ function migrateWorkqueueActions(workqueue, relPath) {
2915
+ const actionsProperty = workqueue.getProperty(ACTIONS_PROPERTY_NAME5);
2916
+ if (!actionsProperty || !import_ts_morph13.Node.isPropertyAssignment(actionsProperty)) {
2917
+ return 0;
2918
+ }
2919
+ const actionsInitializer = actionsProperty.getInitializer();
2920
+ if (!actionsInitializer || !import_ts_morph13.Node.isArrayLiteralExpression(actionsInitializer)) {
2921
+ return 0;
2922
+ }
2923
+ const workqueueLabel = getWorkqueueLabel(workqueue);
2924
+ const existingActionProperty = workqueue.getProperty(ACTION_PROPERTY_NAME2);
2925
+ if (existingActionProperty) {
2926
+ if (import_ts_morph13.Node.isPropertyAssignment(existingActionProperty)) {
2927
+ const existingActionInitializer = existingActionProperty.getInitializer();
2928
+ if (existingActionInitializer && import_ts_morph13.Node.isObjectLiteralExpression(existingActionInitializer)) {
2929
+ const conditionalsProperty2 = existingActionInitializer.getProperty(
2930
+ CONDITIONALS_PROPERTY_NAME
2931
+ );
2932
+ if (conditionalsProperty2) {
2933
+ conditionalsProperty2.remove();
2934
+ console.log(
2935
+ ` [${relPath}] Removed deprecated 'conditionals' from 'action' on workqueue '${workqueueLabel}'`
2936
+ );
2937
+ }
2938
+ if (isUnsupportedActionType(existingActionInitializer)) {
2939
+ existingActionProperty.remove();
2940
+ console.log(
2941
+ ` [${relPath}] Removed unsupported 'action' type on workqueue '${workqueueLabel}'`
2942
+ );
2943
+ }
2944
+ }
2945
+ }
2946
+ actionsProperty.remove();
3029
2947
  console.log(
3030
- ` [${ENVIRONMENT_FILE_RELATIVE}] Removed schema entr${envRemoved.length === 1 ? "y" : "ies"}: ${envRemoved.join(", ")}`
2948
+ ` [${relPath}] Removed deprecated 'actions' from workqueue '${workqueueLabel}' (existing 'action' kept)`
3031
2949
  );
3032
- } else if (project.getSourceFile(envFilePath)) {
2950
+ return 1;
2951
+ }
2952
+ const actionCandidates = actionsInitializer.getElements().filter(
2953
+ (element) => import_ts_morph13.Node.isObjectLiteralExpression(element)
2954
+ );
2955
+ if (actionCandidates.length === 0) {
2956
+ actionsProperty.remove();
3033
2957
  console.log(
3034
- ` [${ENVIRONMENT_FILE_RELATIVE}] No matching schema entries \u2014 nothing to remove.`
2958
+ ` [${relPath}] Removed empty 'actions' from workqueue '${workqueueLabel}'`
3035
2959
  );
3036
- } else {
3037
- console.log(
3038
- ` [${ENVIRONMENT_FILE_RELATIVE}] File not found \u2014 skipping.`
2960
+ return 1;
2961
+ }
2962
+ if (actionCandidates.length > 1) {
2963
+ const droppedCount = actionCandidates.length - 1;
2964
+ console.warn(
2965
+ ` [${relPath}] Workqueue '${workqueueLabel}' has ${actionCandidates.length} actions; keeping first as 'action' and dropping ${droppedCount} extra action(s)`
3039
2966
  );
3040
2967
  }
3041
- const constsRemoved = cleanConstantsFile(project, constsFilePath);
3042
- if (constsRemoved.length > 0) {
3043
- await project.getSourceFileOrThrow(constsFilePath).save();
2968
+ const conditionalsProperty = actionCandidates[0].getProperty(
2969
+ CONDITIONALS_PROPERTY_NAME
2970
+ );
2971
+ if (conditionalsProperty) {
2972
+ conditionalsProperty.remove();
3044
2973
  console.log(
3045
- ` [${CONSTANTS_FILE_RELATIVE}] Removed declaration(s): ${constsRemoved.join(", ")}`
2974
+ ` [${relPath}] Removed deprecated 'conditionals' from migrated 'action' on workqueue '${workqueueLabel}'`
3046
2975
  );
3047
- } else if (project.getSourceFile(constsFilePath)) {
2976
+ }
2977
+ if (isUnsupportedActionType(actionCandidates[0])) {
2978
+ actionsProperty.remove();
3048
2979
  console.log(
3049
- ` [${CONSTANTS_FILE_RELATIVE}] No matching declarations \u2014 nothing to remove.`
2980
+ ` [${relPath}] Removed deprecated 'actions' from workqueue '${workqueueLabel}' because action type is unsupported`
3050
2981
  );
3051
- } else {
3052
- console.log(` [${CONSTANTS_FILE_RELATIVE}] File not found \u2014 skipping.`);
3053
- }
3054
- if (envRemoved.length === 0 && constsRemoved.length === 0) {
3055
- console.log("\nNothing to do.");
3056
- return;
2982
+ return 1;
3057
2983
  }
2984
+ const firstActionText = actionCandidates[0].getText();
2985
+ workqueue.addPropertyAssignment({
2986
+ name: ACTION_PROPERTY_NAME2,
2987
+ initializer: firstActionText
2988
+ });
2989
+ actionsProperty.remove();
3058
2990
  console.log(
3059
- `
3060
- Done. NOTE: usages of these constants elsewhere in 'src/' may now produce TypeScript errors and need manual review.`
2991
+ ` [${relPath}] Replaced 'actions' with 'action' on workqueue '${workqueueLabel}'`
3061
2992
  );
2993
+ return 1;
3062
2994
  }
3063
-
3064
- // src/migrations/v2.0/remove-fhir-url-helpers.ts
3065
- var import_path14 = __toESM(require("path"));
3066
- var import_ts_morph14 = require("ts-morph");
3067
- var FHIR_IMPORT = "FHIR_URL";
3068
- var HELPER_NAMES = /* @__PURE__ */ new Set([
3069
- "getFromFhir",
3070
- "updateResourceFromHearth",
3071
- "updateResourceInHearth"
3072
- ]);
3073
- function removeHelpers(sourceFilePath, project) {
3074
- const sourceFile = project.getSourceFile(sourceFilePath);
3075
- if (!sourceFile) {
3076
- return {
3077
- removedHelpers: [],
3078
- removedImportCount: 0,
3079
- remainingFhirReferences: 0
3080
- };
3081
- }
3082
- const removedHelpers = [];
3083
- let removedImportCount = 0;
3084
- for (const fn of sourceFile.getFunctions()) {
3085
- const name = fn.getName();
3086
- if (!name || !HELPER_NAMES.has(name)) continue;
3087
- removedHelpers.push(name);
3088
- fn.remove();
3089
- }
3090
- for (const stmt of [...sourceFile.getVariableStatements()]) {
3091
- const declarations = [...stmt.getDeclarations()];
3092
- const toRemove = declarations.filter((decl) => HELPER_NAMES.has(decl.getName()));
3093
- if (toRemove.length === 0) continue;
3094
- removedHelpers.push(...toRemove.map((decl) => decl.getName()));
3095
- if (toRemove.length === declarations.length) {
3096
- stmt.remove();
3097
- } else {
3098
- for (const decl of toRemove) decl.remove();
3099
- }
3100
- }
3101
- for (const decl of sourceFile.getImportDeclarations()) {
3102
- const matches = decl.getNamedImports().filter((ni) => ni.getName() === FHIR_IMPORT);
3103
- if (matches.length === 0) continue;
3104
- for (const named of matches) {
3105
- named.remove();
3106
- removedImportCount++;
2995
+ function processFile11(filePath, project) {
2996
+ const sourceFile = project.getSourceFile(filePath);
2997
+ if (!sourceFile) return 0;
2998
+ let migratedWorkqueues = 0;
2999
+ const relPath = import_path13.default.relative(getCwd(), filePath);
3000
+ const callExpressions = sourceFile.getDescendantsOfKind(
3001
+ import_ts_morph13.SyntaxKind.CallExpression
3002
+ );
3003
+ for (const call of callExpressions) {
3004
+ const expression = call.getExpression();
3005
+ if (!import_ts_morph13.Node.isIdentifier(expression) || expression.getText() !== DEFINE_WORKQUEUES_NAME3) {
3006
+ continue;
3107
3007
  }
3108
- const hasAnyNamedImportsLeft = decl.getNamedImports().length > 0;
3109
- const hasDefaultImport = !!decl.getDefaultImport();
3110
- const hasNamespaceImport = !!decl.getNamespaceImport();
3111
- if (!hasAnyNamedImportsLeft && !hasDefaultImport && !hasNamespaceImport) {
3112
- decl.remove();
3008
+ const args = call.getArguments();
3009
+ if (args.length === 0) continue;
3010
+ const workqueuesArg = args[0];
3011
+ if (!import_ts_morph13.Node.isArrayLiteralExpression(workqueuesArg)) continue;
3012
+ for (const element of workqueuesArg.getElements()) {
3013
+ if (!import_ts_morph13.Node.isObjectLiteralExpression(element)) continue;
3014
+ migratedWorkqueues += migrateWorkqueueActions(element, relPath);
3113
3015
  }
3114
3016
  }
3115
- const remainingFhirReferences = sourceFile.getDescendantsOfKind(import_ts_morph14.SyntaxKind.Identifier).filter((id) => id.getText() === FHIR_IMPORT).filter((id) => !id.getFirstAncestorByKind(import_ts_morph14.SyntaxKind.ImportDeclaration)).length;
3116
- return { removedHelpers, removedImportCount, remainingFhirReferences };
3017
+ return migratedWorkqueues;
3117
3018
  }
3118
- async function main14() {
3119
- const project = new import_ts_morph14.Project({
3120
- tsConfigFilePath: import_path14.default.resolve(process.cwd(), "tsconfig.json"),
3019
+ async function main13() {
3020
+ const srcDir = import_path13.default.join(getCwd(), "src");
3021
+ console.log(`Scanning for defineWorkqueues calls in: ${srcDir}
3022
+ `);
3023
+ const project = new import_ts_morph13.Project({
3024
+ tsConfigFilePath: import_path13.default.resolve(srcDir, "../tsconfig.json"),
3121
3025
  skipAddingFilesFromTsConfig: false
3122
3026
  });
3123
3027
  const sourceFiles = project.getSourceFiles().filter((sf) => {
3124
3028
  const fp = sf.getFilePath();
3125
3029
  return fp.includes("/src/") && !fp.includes("/node_modules/");
3126
3030
  });
3127
- console.log(`Removing legacy FHIR_URL helpers in ${sourceFiles.length} source file(s)...
3031
+ console.log(`Found ${sourceFiles.length} source file(s) to analyse.
3128
3032
  `);
3129
- let totalRemovedImports = 0;
3130
- let totalRemovedHelpers = 0;
3033
+ let totalMigrated = 0;
3131
3034
  const modifiedFiles = [];
3132
- const warnings = [];
3133
3035
  for (const sourceFile of sourceFiles) {
3134
3036
  const filePath = sourceFile.getFilePath();
3135
- const rel = import_path14.default.relative(process.cwd(), filePath);
3136
- const result = removeHelpers(filePath, project);
3137
- const changed = result.removedImportCount > 0 || result.removedHelpers.length > 0;
3138
- if (changed) {
3037
+ const migrated = processFile11(filePath, project);
3038
+ if (migrated > 0) {
3039
+ totalMigrated += migrated;
3139
3040
  modifiedFiles.push(filePath);
3140
- totalRemovedImports += result.removedImportCount;
3141
- totalRemovedHelpers += result.removedHelpers.length;
3142
- if (result.removedHelpers.length > 0) {
3143
- console.log(
3144
- ` [${rel}] Removed helper(s): ${result.removedHelpers.join(", ")}`
3145
- );
3146
- }
3147
- if (result.removedImportCount > 0) {
3148
- console.log(
3149
- ` [${rel}] Removed ${result.removedImportCount} '${FHIR_IMPORT}' import(s)`
3150
- );
3151
- }
3152
- }
3153
- if (result.remainingFhirReferences > 0) {
3154
- warnings.push(
3155
- `${rel}: ${result.remainingFhirReferences} remaining '${FHIR_IMPORT}' reference(s)`
3156
- );
3157
3041
  }
3158
3042
  }
3159
- if (modifiedFiles.length === 0 && warnings.length === 0) {
3160
- console.log("No FHIR_URL imports/helpers found. Nothing to do.");
3161
- return;
3162
- }
3163
- if (modifiedFiles.length > 0) {
3164
- console.log(`
3165
- Saving ${modifiedFiles.length} modified file(s)...`);
3166
- for (const filePath of modifiedFiles) {
3167
- await project.getSourceFileOrThrow(filePath).save();
3168
- console.log(` Saved: ${import_path14.default.relative(process.cwd(), filePath)}`);
3169
- }
3170
- }
3171
- if (warnings.length > 0) {
3172
- console.warn(
3173
- `
3174
- WARNING: Some '${FHIR_IMPORT}' usages remain and need manual cleanup:
3175
- ` + warnings.map((line) => ` - ${line}`).join("\n")
3176
- );
3177
- }
3178
- console.log(
3179
- `
3180
- Done. Removed ${totalRemovedHelpers} helper declaration(s) and ${totalRemovedImports} '${FHIR_IMPORT}' import(s).`
3181
- );
3182
- }
3183
-
3184
- // src/migrations/v2.0/migrate-application-config-url.ts
3185
- var import_path15 = __toESM(require("path"));
3186
- var import_ts_morph15 = require("ts-morph");
3187
- var TARGET_IDENTIFIER = "APPLICATION_CONFIG_URL";
3188
- var REPLACEMENT_IDENTIFIER = "applicationConfig";
3189
- var REPLACEMENT_MODULE = "@countryconfig/api/application/application-config";
3190
- var FUNCTION_LIKE_KINDS = [
3191
- import_ts_morph15.SyntaxKind.FunctionDeclaration,
3192
- import_ts_morph15.SyntaxKind.FunctionExpression,
3193
- import_ts_morph15.SyntaxKind.ArrowFunction,
3194
- import_ts_morph15.SyntaxKind.MethodDeclaration
3195
- ];
3196
- function describeFunction(node) {
3197
- if (import_ts_morph15.Node.isFunctionDeclaration(node) || import_ts_morph15.Node.isMethodDeclaration(node)) {
3198
- return node.getName() ?? "<anonymous>";
3199
- }
3200
- const parent = node.getParent();
3201
- if (parent && import_ts_morph15.Node.isVariableDeclaration(parent)) {
3202
- return parent.getName();
3203
- }
3204
- if (parent && import_ts_morph15.Node.isPropertyAssignment(parent)) {
3205
- return parent.getName();
3206
- }
3207
- if (import_ts_morph15.Node.isFunctionExpression(node) && node.getNameNode() !== void 0) {
3208
- return node.getNameNode()?.getText() ?? "<anonymous>";
3209
- }
3210
- return "<anonymous>";
3211
- }
3212
- function hasBlockBody(node) {
3213
- if (import_ts_morph15.Node.isFunctionDeclaration(node) || import_ts_morph15.Node.isFunctionExpression(node) || import_ts_morph15.Node.isMethodDeclaration(node)) {
3214
- return node.getBody() !== void 0;
3215
- }
3216
- if (import_ts_morph15.Node.isArrowFunction(node)) {
3217
- return node.getBody().getKind() === import_ts_morph15.SyntaxKind.Block;
3218
- }
3219
- return false;
3220
- }
3221
- function isConfigFetcher(node) {
3222
- let referencesTarget = false;
3223
- let callsFetch = false;
3224
- for (const id of node.getDescendantsOfKind(import_ts_morph15.SyntaxKind.Identifier)) {
3225
- const text = id.getText();
3226
- if (!referencesTarget && text === TARGET_IDENTIFIER) referencesTarget = true;
3227
- if (!callsFetch && text === "fetch") {
3228
- const parent = id.getParent();
3229
- if (import_ts_morph15.Node.isCallExpression(parent) && parent.getExpression() === id) {
3230
- callsFetch = true;
3231
- }
3232
- }
3233
- if (referencesTarget && callsFetch) return true;
3234
- }
3235
- return false;
3236
- }
3237
- function processFile11(sourceFile) {
3238
- const importsWithTarget = sourceFile.getImportDeclarations().filter(
3239
- (decl) => decl.getNamedImports().some((ni) => ni.getName() === TARGET_IDENTIFIER)
3240
- );
3241
- if (importsWithTarget.length === 0) {
3242
- return { changed: false, rewrittenFunctions: [], renamedReferences: 0 };
3243
- }
3244
- const collidingLocals = sourceFile.getDescendantsOfKind(import_ts_morph15.SyntaxKind.Identifier).filter((id) => id.getText() === REPLACEMENT_IDENTIFIER).filter((id) => {
3245
- const parent = id.getParent();
3246
- const kind = parent.getKind();
3247
- return kind === import_ts_morph15.SyntaxKind.VariableDeclaration || kind === import_ts_morph15.SyntaxKind.FunctionDeclaration || kind === import_ts_morph15.SyntaxKind.ClassDeclaration || kind === import_ts_morph15.SyntaxKind.Parameter;
3248
- });
3249
- if (collidingLocals.length > 0) {
3250
- return {
3251
- changed: false,
3252
- rewrittenFunctions: [],
3253
- renamedReferences: 0,
3254
- skippedReason: `local declaration named '${REPLACEMENT_IDENTIFIER}' would collide`
3255
- };
3256
- }
3257
- const candidateFunctions = FUNCTION_LIKE_KINDS.flatMap(
3258
- (kind) => sourceFile.getDescendantsOfKind(kind)
3259
- );
3260
- candidateFunctions.sort((a, b) => a.getStart() - b.getStart());
3261
- const rewrittenFunctions = [];
3262
- const rewrittenSet = /* @__PURE__ */ new Set();
3263
- for (const fn of candidateFunctions) {
3264
- if (!hasBlockBody(fn)) continue;
3265
- if (!isConfigFetcher(fn)) continue;
3266
- let inRewrittenAncestor = false;
3267
- let cursor = fn.getParent();
3268
- while (cursor) {
3269
- if (rewrittenSet.has(cursor)) {
3270
- inRewrittenAncestor = true;
3271
- break;
3272
- }
3273
- cursor = cursor.getParent();
3274
- }
3275
- if (inRewrittenAncestor) continue;
3276
- const start = fn.getStart();
3277
- const line = sourceFile.getLineAndColumnAtPos(start).line;
3278
- const name = describeFunction(fn);
3279
- if (import_ts_morph15.Node.isFunctionDeclaration(fn) || import_ts_morph15.Node.isFunctionExpression(fn) || import_ts_morph15.Node.isMethodDeclaration(fn) || import_ts_morph15.Node.isArrowFunction(fn)) {
3280
- fn.setBodyText(`return ${REPLACEMENT_IDENTIFIER}`);
3281
- }
3282
- rewrittenFunctions.push({ name, line });
3283
- rewrittenSet.add(fn);
3284
- }
3285
- for (const decl of importsWithTarget) {
3286
- const targetNamed = decl.getNamedImports().find((ni) => ni.getName() === TARGET_IDENTIFIER);
3287
- targetNamed?.remove();
3288
- const isNowEmpty = decl.getNamedImports().length === 0 && !decl.getDefaultImport() && !decl.getNamespaceImport();
3289
- if (isNowEmpty) decl.remove();
3290
- }
3291
- const existing = sourceFile.getImportDeclaration(
3292
- (decl) => decl.getModuleSpecifierValue() === REPLACEMENT_MODULE
3293
- );
3294
- if (existing) {
3295
- const alreadyImported = existing.getNamedImports().some((ni) => ni.getName() === REPLACEMENT_IDENTIFIER);
3296
- if (!alreadyImported) existing.addNamedImport(REPLACEMENT_IDENTIFIER);
3297
- } else {
3298
- sourceFile.addImportDeclaration({
3299
- moduleSpecifier: REPLACEMENT_MODULE,
3300
- namedImports: [REPLACEMENT_IDENTIFIER]
3301
- });
3302
- }
3303
- const renameTargets = sourceFile.getDescendantsOfKind(import_ts_morph15.SyntaxKind.Identifier).filter((id) => id.getText() === TARGET_IDENTIFIER).filter((id) => !id.getFirstAncestorByKind(import_ts_morph15.SyntaxKind.ImportDeclaration)).filter((id) => {
3304
- const parent = id.getParent();
3305
- const parentKind = parent.getKind();
3306
- if (parentKind === import_ts_morph15.SyntaxKind.PropertyAccessExpression) {
3307
- const pae = parent.asKind(import_ts_morph15.SyntaxKind.PropertyAccessExpression);
3308
- if (pae.getNameNode() === id) return false;
3309
- }
3310
- if (parentKind === import_ts_morph15.SyntaxKind.PropertyAssignment) {
3311
- const pa = parent.asKind(import_ts_morph15.SyntaxKind.PropertyAssignment);
3312
- if (pa.getNameNode() === id) return false;
3313
- }
3314
- if (parentKind === import_ts_morph15.SyntaxKind.ShorthandPropertyAssignment) {
3315
- return false;
3316
- }
3317
- return true;
3318
- }).sort((a, b) => b.getPos() - a.getPos());
3319
- for (const id of renameTargets) {
3320
- id.replaceWithText(REPLACEMENT_IDENTIFIER);
3321
- }
3322
- return {
3323
- changed: true,
3324
- rewrittenFunctions,
3325
- renamedReferences: renameTargets.length
3326
- };
3327
- }
3328
- async function main15() {
3329
- const project = new import_ts_morph15.Project({
3330
- tsConfigFilePath: import_path15.default.resolve(process.cwd(), "tsconfig.json"),
3331
- skipAddingFilesFromTsConfig: false
3332
- });
3333
- const sourceFiles = project.getSourceFiles().filter((sf) => {
3334
- const fp = sf.getFilePath();
3335
- return fp.includes("/src/") && !fp.includes("/node_modules/");
3336
- });
3337
- console.log(
3338
- `Migrating '${TARGET_IDENTIFIER}' \u2192 '${REPLACEMENT_IDENTIFIER}' across ${sourceFiles.length} source file(s)...
3339
- `
3340
- );
3341
- let changedFiles = 0;
3342
- let totalRewrittenFunctions = 0;
3343
- let totalRenamedReferences = 0;
3344
- const skipped = [];
3345
- for (const sourceFile of sourceFiles) {
3346
- const filePath = sourceFile.getFilePath();
3347
- const rel = import_path15.default.relative(process.cwd(), filePath);
3348
- const result = processFile11(sourceFile);
3349
- if (result.skippedReason) {
3350
- skipped.push(`${rel} (${result.skippedReason})`);
3351
- continue;
3352
- }
3353
- if (!result.changed) continue;
3354
- await sourceFile.save();
3355
- changedFiles++;
3356
- totalRewrittenFunctions += result.rewrittenFunctions.length;
3357
- totalRenamedReferences += result.renamedReferences;
3358
- for (const fn of result.rewrittenFunctions) {
3359
- console.log(
3360
- ` [${rel}:${fn.line}] Rewrote '${fn.name}' body \u2192 'return ${REPLACEMENT_IDENTIFIER}' (config fetch eliminated)`
3361
- );
3362
- }
3363
- if (result.renamedReferences > 0) {
3364
- console.log(
3365
- ` [${rel}] Renamed ${result.renamedReferences} stray reference(s) ${TARGET_IDENTIFIER} \u2192 ${REPLACEMENT_IDENTIFIER}`
3366
- );
3367
- }
3368
- }
3369
- if (skipped.length > 0) {
3370
- console.warn(
3371
- `
3372
- ${skipped.length} file(s) skipped:
3373
- ` + skipped.map((s) => ` - ${s}`).join("\n")
3374
- );
3375
- }
3376
- if (changedFiles === 0) {
3377
- console.log(`
3378
- No files reference '${TARGET_IDENTIFIER}'. Nothing to do.`);
3379
- return;
3380
- }
3381
- console.log(
3382
- `
3383
- Done. Updated ${changedFiles} file(s): ${totalRewrittenFunctions} fetch function(s) rewritten, ${totalRenamedReferences} bare reference(s) renamed.`
3384
- );
3385
- if (totalRewrittenFunctions > 0) {
3386
- console.log(
3387
- `NOTE: rewriting fetch functions discards any custom logic that lived inside them. Review the diff and re-apply any country-specific adjustments on top of '${REPLACEMENT_IDENTIFIER}'.`
3388
- );
3389
- }
3390
- }
3391
-
3392
- // src/migrations/v2.0/remove-old-statistics-service.ts
3393
- var import_path16 = __toESM(require("path"));
3394
- var import_ts_morph16 = require("ts-morph");
3395
- var ROUTE_PATH = "/statistics";
3396
- var HANDLER_NAME = "statisticsHandler";
3397
- function isStatisticsRouteObject(obj) {
3398
- const pathProp = obj.getProperty("path");
3399
- if (!pathProp || !import_ts_morph16.Node.isPropertyAssignment(pathProp)) return false;
3400
- const init = pathProp.getInitializer();
3401
- if (!init) return false;
3402
- if (import_ts_morph16.Node.isStringLiteral(init) || import_ts_morph16.Node.isNoSubstitutionTemplateLiteral(init)) {
3403
- return init.getLiteralValue() === ROUTE_PATH;
3404
- }
3405
- return false;
3406
- }
3407
- function removeStatisticsRoutes(sourceFile) {
3408
- let removed = 0;
3409
- const callExpressions = [
3410
- ...sourceFile.getDescendantsOfKind(import_ts_morph16.SyntaxKind.CallExpression)
3411
- ];
3412
- for (const call of callExpressions) {
3413
- if (call.wasForgotten()) continue;
3414
- const expr = call.getExpression();
3415
- if (!import_ts_morph16.Node.isPropertyAccessExpression(expr)) continue;
3416
- if (expr.getName() !== "route") continue;
3417
- const args = call.getArguments();
3418
- if (args.length === 0) continue;
3419
- const firstArg = args[0];
3420
- if (import_ts_morph16.Node.isObjectLiteralExpression(firstArg)) {
3421
- if (!isStatisticsRouteObject(firstArg)) continue;
3422
- const stmt = call.getFirstAncestorByKind(import_ts_morph16.SyntaxKind.ExpressionStatement);
3423
- if (stmt) {
3424
- stmt.remove();
3425
- removed++;
3426
- } else {
3427
- call.replaceWithText("");
3428
- removed++;
3429
- }
3430
- continue;
3431
- }
3432
- if (import_ts_morph16.Node.isArrayLiteralExpression(firstArg)) {
3433
- const matchingIndexes = firstArg.getElements().map((el, idx) => ({ el, idx })).filter(
3434
- ({ el }) => import_ts_morph16.Node.isObjectLiteralExpression(el) && isStatisticsRouteObject(el)
3435
- ).map(({ idx }) => idx);
3436
- matchingIndexes.sort((a, b) => b - a).forEach((idx) => {
3437
- firstArg.removeElement(idx);
3438
- removed++;
3439
- });
3440
- }
3441
- }
3442
- return removed;
3443
- }
3444
- function removeStatisticsHandlerImports(sourceFile) {
3445
- let changed = false;
3446
- for (const decl of sourceFile.getImportDeclarations()) {
3447
- const targetNamed = decl.getNamedImports().find((ni) => ni.getName() === HANDLER_NAME);
3448
- if (!targetNamed) continue;
3449
- targetNamed.remove();
3450
- changed = true;
3451
- const isNowEmpty = decl.getNamedImports().length === 0 && !decl.getDefaultImport() && !decl.getNamespaceImport();
3452
- if (isNowEmpty) decl.remove();
3453
- }
3454
- return changed;
3455
- }
3456
- function processFile12(sourceFile) {
3457
- const routesRemoved = removeStatisticsRoutes(sourceFile);
3458
- const importsCleaned = removeStatisticsHandlerImports(sourceFile);
3459
- return { routesRemoved, importsCleaned };
3460
- }
3461
- function collectLocalImportsInSubtree(sourceFile, subtreeRoot) {
3462
- const result = [];
3463
- for (const decl of sourceFile.getImportDeclarations()) {
3464
- const moduleSf = decl.getModuleSpecifierSourceFile();
3465
- if (!moduleSf) continue;
3466
- const fp = moduleSf.getFilePath();
3467
- if (!fp.startsWith(subtreeRoot)) continue;
3468
- result.push(fp);
3469
- }
3470
- return result;
3471
- }
3472
- function deleteOrphanedDescendants(project, startingFile, subtreeRoot) {
3473
- const initialCandidates = collectLocalImportsInSubtree(
3474
- startingFile,
3475
- subtreeRoot
3476
- );
3477
- const startingPath = startingFile.getFilePath();
3478
- const deleted = /* @__PURE__ */ new Set([startingPath]);
3479
- const seen = /* @__PURE__ */ new Set();
3480
- const worklist = [...initialCandidates];
3481
- const orphans = [];
3482
- while (worklist.length > 0) {
3483
- const candidate = worklist.shift();
3484
- if (seen.has(candidate)) continue;
3485
- seen.add(candidate);
3486
- if (deleted.has(candidate)) continue;
3487
- if (!candidate.startsWith(subtreeRoot)) continue;
3488
- const candidateSf = project.getSourceFile(candidate);
3489
- if (!candidateSf) continue;
3490
- const stillImported = project.getSourceFiles().some((sf) => {
3491
- const sfPath = sf.getFilePath();
3492
- if (deleted.has(sfPath)) return false;
3493
- if (sfPath === candidate) return false;
3494
- return sf.getImportDeclarations().some(
3495
- (decl) => decl.getModuleSpecifierSourceFile()?.getFilePath() === candidate
3496
- );
3497
- });
3498
- if (stillImported) continue;
3499
- const next = collectLocalImportsInSubtree(candidateSf, subtreeRoot);
3500
- worklist.push(...next);
3501
- candidateSf.delete();
3502
- deleted.add(candidate);
3503
- orphans.push(candidate);
3504
- }
3505
- return orphans;
3506
- }
3507
- function processHandlerFile(project) {
3508
- const sourceFiles = project.getSourceFiles().filter((sf) => {
3509
- const fp = sf.getFilePath();
3510
- return fp.includes("/src/") && !fp.includes("/node_modules/");
3511
- });
3512
- for (const sf of sourceFiles) {
3513
- const fn = sf.getFunction(HANDLER_NAME);
3514
- if (!fn) continue;
3515
- const filePath = sf.getFilePath();
3516
- const exportsByName = [...sf.getExportedDeclarations().keys()];
3517
- const otherExports = exportsByName.filter((name) => name !== HANDLER_NAME);
3518
- if (otherExports.length === 0) {
3519
- const subtreeRoot = import_path16.default.dirname(filePath) + import_path16.default.sep;
3520
- const orphansDeleted = deleteOrphanedDescendants(
3521
- project,
3522
- sf,
3523
- subtreeRoot
3524
- );
3525
- sf.delete();
3526
- return { filePath, action: "deleted", orphansDeleted };
3527
- }
3528
- fn.remove();
3529
- return {
3530
- filePath,
3531
- action: "function-removed",
3532
- remainingExports: otherExports,
3533
- orphansDeleted: []
3534
- };
3535
- }
3536
- return { filePath: "", action: "not-found", orphansDeleted: [] };
3537
- }
3538
- async function main16() {
3539
- const project = new import_ts_morph16.Project({
3540
- tsConfigFilePath: import_path16.default.resolve(process.cwd(), "tsconfig.json"),
3541
- skipAddingFilesFromTsConfig: false
3542
- });
3543
- const sourceFiles = project.getSourceFiles().filter((sf) => {
3544
- const fp = sf.getFilePath();
3545
- return fp.includes("/src/") && !fp.includes("/node_modules/");
3546
- });
3547
- console.log(
3548
- `Removing legacy 'GET ${ROUTE_PATH}' route and '${HANDLER_NAME}' across ${sourceFiles.length} source file(s)...
3549
- `
3550
- );
3551
- let totalRoutesRemoved = 0;
3552
- let totalFilesWithImportsCleaned = 0;
3553
- let totalFilesWithRoutesRemoved = 0;
3554
- for (const sourceFile of sourceFiles) {
3555
- const filePath = sourceFile.getFilePath();
3556
- const rel = import_path16.default.relative(process.cwd(), filePath);
3557
- const result = processFile12(sourceFile);
3558
- if (result.routesRemoved > 0) {
3559
- console.log(
3560
- ` [${rel}] Removed ${result.routesRemoved} '${ROUTE_PATH}' route(s)`
3561
- );
3562
- totalRoutesRemoved += result.routesRemoved;
3563
- totalFilesWithRoutesRemoved++;
3564
- }
3565
- if (result.importsCleaned) {
3566
- console.log(` [${rel}] Cleaned up '${HANDLER_NAME}' import`);
3567
- totalFilesWithImportsCleaned++;
3568
- }
3569
- if (result.routesRemoved > 0 || result.importsCleaned) {
3570
- await sourceFile.save();
3571
- }
3572
- }
3573
- const handlerResult = processHandlerFile(project);
3574
- switch (handlerResult.action) {
3575
- case "deleted": {
3576
- const rel = import_path16.default.relative(process.cwd(), handlerResult.filePath);
3577
- console.log(
3578
- ` [${rel}] Deleted handler file ('${HANDLER_NAME}' was the sole export).`
3579
- );
3580
- for (const orphanPath of handlerResult.orphansDeleted) {
3581
- const orphanRel = import_path16.default.relative(process.cwd(), orphanPath);
3582
- console.log(
3583
- ` [${orphanRel}] Deleted (no remaining importers in the project after handler removal).`
3584
- );
3585
- }
3586
- await project.save();
3587
- break;
3588
- }
3589
- case "function-removed": {
3590
- const rel = import_path16.default.relative(process.cwd(), handlerResult.filePath);
3591
- console.warn(
3592
- ` [${rel}] Removed '${HANDLER_NAME}' function but kept the file (other exports remain: ${handlerResult.remainingExports?.join(", ")}). Review whether the file is still needed.`
3593
- );
3594
- const sf = project.getSourceFile(handlerResult.filePath);
3595
- if (sf) await sf.save();
3596
- break;
3597
- }
3598
- case "not-found":
3599
- break;
3600
- }
3601
- if (totalRoutesRemoved === 0 && totalFilesWithImportsCleaned === 0 && handlerResult.action === "not-found") {
3602
- console.log(`
3603
- No legacy '${ROUTE_PATH}' route or handler found. Nothing to do.`);
3604
- return;
3605
- }
3606
- const orphansSummary = handlerResult.orphansDeleted.length > 0 ? ` and ${handlerResult.orphansDeleted.length} orphaned helper file(s)` : "";
3607
- console.log(
3608
- `
3609
- Done. Removed ${totalRoutesRemoved} route(s) across ${totalFilesWithRoutesRemoved} file(s); cleaned ${HANDLER_NAME} import in ${totalFilesWithImportsCleaned} file(s)${orphansSummary}.`
3610
- );
3611
- }
3612
-
3613
- // src/migrations/v2.0/update-package-json.ts
3614
- var import_fs = require("fs");
3615
- var import_path17 = __toESM(require("path"));
3616
- var PACKAGE_JSON_RELATIVE = "package.json";
3617
- var TARGET_VERSION = "2.0.0";
3618
- var TARGET_ZOD_RANGE = "^4.2.1";
3619
- async function main17() {
3620
- const packageJsonPath = import_path17.default.join(process.cwd(), PACKAGE_JSON_RELATIVE);
3621
- if (!(0, import_fs.existsSync)(packageJsonPath)) {
3622
- console.log(`'${PACKAGE_JSON_RELATIVE}' not found in ${process.cwd()} \u2014 skipping.`);
3623
- return;
3624
- }
3625
- const raw = (0, import_fs.readFileSync)(packageJsonPath, "utf8");
3626
- let parsed;
3627
- try {
3628
- parsed = JSON.parse(raw);
3629
- } catch (error) {
3630
- console.warn(
3631
- ` [${PACKAGE_JSON_RELATIVE}] Failed to parse JSON \u2014 skipping update. ${error.message}`
3632
- );
3633
- return;
3634
- }
3635
- console.log(`Updating '${PACKAGE_JSON_RELATIVE}'...`);
3636
- const previousVersion = parsed.version;
3637
- const versionChanged = previousVersion !== TARGET_VERSION;
3638
- parsed.version = TARGET_VERSION;
3639
- if (versionChanged) {
3640
- console.log(
3641
- ` Set version: ${previousVersion ?? "<unset>"} \u2192 ${TARGET_VERSION}`
3642
- );
3643
- } else {
3644
- console.log(` Version already ${TARGET_VERSION} \u2014 no change.`);
3645
- }
3646
- let zodBucket = "dependencies";
3647
- if (parsed.devDependencies && "zod" in parsed.devDependencies) {
3648
- zodBucket = "devDependencies";
3649
- }
3650
- if (!parsed[zodBucket]) {
3651
- parsed[zodBucket] = {};
3652
- }
3653
- const bucket = parsed[zodBucket];
3654
- const previousZod = bucket.zod;
3655
- const zodChanged = previousZod !== TARGET_ZOD_RANGE;
3656
- bucket.zod = TARGET_ZOD_RANGE;
3657
- if (zodChanged) {
3658
- console.log(
3659
- ` Set ${zodBucket}.zod: ${previousZod ?? "<absent>"} \u2192 ${TARGET_ZOD_RANGE}`
3660
- );
3661
- } else {
3662
- console.log(` ${zodBucket}.zod already ${TARGET_ZOD_RANGE} \u2014 no change.`);
3663
- }
3664
- const trailingNewline = raw.endsWith("\n") ? "\n" : "";
3665
- const next = JSON.stringify(parsed, null, 2) + trailingNewline;
3666
- if (next === raw) {
3667
- console.log("\n No changes to write.");
3668
- return;
3669
- }
3670
- (0, import_fs.writeFileSync)(packageJsonPath, next, "utf8");
3671
- console.log(`
3672
- Saved '${PACKAGE_JSON_RELATIVE}'.`);
3673
- console.log(
3674
- ` NOTE: run \`yarn install\` (or your package manager equivalent) to install the updated dependency versions.`
3675
- );
3676
- }
3677
-
3678
- // src/migrations/v2.0/migrate-workqueue-configs.ts
3679
- var import_ts_morph17 = require("ts-morph");
3680
- var import_path18 = __toESM(require("path"));
3681
- var DEFINE_WORKQUEUES_NAME3 = "defineWorkqueues";
3682
- var ACTIONS_PROPERTY_NAME5 = "actions";
3683
- var ACTION_PROPERTY_NAME2 = "action";
3684
- var CONDITIONALS_PROPERTY_NAME = "conditionals";
3685
- var TYPE_PROPERTY_NAME7 = "type";
3686
- var SLUG_PROPERTY_NAME = "slug";
3687
- var SUPPORTED_WORKQUEUE_ACTION_TYPES = /* @__PURE__ */ new Set([
3688
- "READ",
3689
- "DELETE",
3690
- "DECLARE",
3691
- "REGISTER",
3692
- "EDIT",
3693
- "REJECT",
3694
- "MARK_AS_DUPLICATE",
3695
- "ARCHIVE",
3696
- "PRINT_CERTIFICATE",
3697
- "REQUEST_CORRECTION"
3698
- ]);
3699
- function getWorkqueueLabel(workqueue) {
3700
- const slugProperty = workqueue.getProperty(SLUG_PROPERTY_NAME);
3701
- if (!slugProperty || !import_ts_morph17.Node.isPropertyAssignment(slugProperty)) {
3702
- return "(unknown slug)";
3703
- }
3704
- const slugInitializer = slugProperty.getInitializer();
3705
- if (!slugInitializer || !import_ts_morph17.Node.isStringLiteral(slugInitializer)) {
3706
- return "(unknown slug)";
3707
- }
3708
- return slugInitializer.getLiteralValue();
3709
- }
3710
- function getActionTypeName(action) {
3711
- const typeProperty = action.getProperty(TYPE_PROPERTY_NAME7);
3712
- if (!typeProperty || !import_ts_morph17.Node.isPropertyAssignment(typeProperty)) {
3713
- return null;
3714
- }
3715
- const typeInitializer = typeProperty.getInitializer();
3716
- if (!typeInitializer) {
3717
- return null;
3718
- }
3719
- if (import_ts_morph17.Node.isStringLiteral(typeInitializer)) {
3720
- return typeInitializer.getLiteralValue();
3721
- }
3722
- if (import_ts_morph17.Node.isPropertyAccessExpression(typeInitializer)) {
3723
- return typeInitializer.getName();
3724
- }
3725
- return null;
3726
- }
3727
- function isUnsupportedActionType(action) {
3728
- const typeName = getActionTypeName(action);
3729
- if (!typeName) {
3730
- return false;
3731
- }
3732
- return !SUPPORTED_WORKQUEUE_ACTION_TYPES.has(typeName);
3733
- }
3734
- function migrateWorkqueueActions(workqueue, relPath) {
3735
- const actionsProperty = workqueue.getProperty(ACTIONS_PROPERTY_NAME5);
3736
- if (!actionsProperty || !import_ts_morph17.Node.isPropertyAssignment(actionsProperty)) {
3737
- return 0;
3738
- }
3739
- const actionsInitializer = actionsProperty.getInitializer();
3740
- if (!actionsInitializer || !import_ts_morph17.Node.isArrayLiteralExpression(actionsInitializer)) {
3741
- return 0;
3742
- }
3743
- const workqueueLabel = getWorkqueueLabel(workqueue);
3744
- const existingActionProperty = workqueue.getProperty(ACTION_PROPERTY_NAME2);
3745
- if (existingActionProperty) {
3746
- if (import_ts_morph17.Node.isPropertyAssignment(existingActionProperty)) {
3747
- const existingActionInitializer = existingActionProperty.getInitializer();
3748
- if (existingActionInitializer && import_ts_morph17.Node.isObjectLiteralExpression(existingActionInitializer)) {
3749
- const conditionalsProperty2 = existingActionInitializer.getProperty(
3750
- CONDITIONALS_PROPERTY_NAME
3751
- );
3752
- if (conditionalsProperty2) {
3753
- conditionalsProperty2.remove();
3754
- console.log(
3755
- ` [${relPath}] Removed deprecated 'conditionals' from 'action' on workqueue '${workqueueLabel}'`
3756
- );
3757
- }
3758
- if (isUnsupportedActionType(existingActionInitializer)) {
3759
- existingActionProperty.remove();
3760
- console.log(
3761
- ` [${relPath}] Removed unsupported 'action' type on workqueue '${workqueueLabel}'`
3762
- );
3763
- }
3764
- }
3765
- }
3766
- actionsProperty.remove();
3767
- console.log(
3768
- ` [${relPath}] Removed deprecated 'actions' from workqueue '${workqueueLabel}' (existing 'action' kept)`
3769
- );
3770
- return 1;
3771
- }
3772
- const actionCandidates = actionsInitializer.getElements().filter(
3773
- (element) => import_ts_morph17.Node.isObjectLiteralExpression(element)
3774
- );
3775
- if (actionCandidates.length === 0) {
3776
- actionsProperty.remove();
3777
- console.log(
3778
- ` [${relPath}] Removed empty 'actions' from workqueue '${workqueueLabel}'`
3779
- );
3780
- return 1;
3781
- }
3782
- if (actionCandidates.length > 1) {
3783
- const droppedCount = actionCandidates.length - 1;
3784
- console.warn(
3785
- ` [${relPath}] Workqueue '${workqueueLabel}' has ${actionCandidates.length} actions; keeping first as 'action' and dropping ${droppedCount} extra action(s)`
3786
- );
3787
- }
3788
- const conditionalsProperty = actionCandidates[0].getProperty(
3789
- CONDITIONALS_PROPERTY_NAME
3790
- );
3791
- if (conditionalsProperty) {
3792
- conditionalsProperty.remove();
3793
- console.log(
3794
- ` [${relPath}] Removed deprecated 'conditionals' from migrated 'action' on workqueue '${workqueueLabel}'`
3795
- );
3796
- }
3797
- if (isUnsupportedActionType(actionCandidates[0])) {
3798
- actionsProperty.remove();
3799
- console.log(
3800
- ` [${relPath}] Removed deprecated 'actions' from workqueue '${workqueueLabel}' because action type is unsupported`
3801
- );
3802
- return 1;
3803
- }
3804
- const firstActionText = actionCandidates[0].getText();
3805
- workqueue.addPropertyAssignment({
3806
- name: ACTION_PROPERTY_NAME2,
3807
- initializer: firstActionText
3808
- });
3809
- actionsProperty.remove();
3810
- console.log(
3811
- ` [${relPath}] Replaced 'actions' with 'action' on workqueue '${workqueueLabel}'`
3812
- );
3813
- return 1;
3814
- }
3815
- function processFile13(filePath, project) {
3816
- const sourceFile = project.getSourceFile(filePath);
3817
- if (!sourceFile) return 0;
3818
- let migratedWorkqueues = 0;
3819
- const relPath = import_path18.default.relative(process.cwd(), filePath);
3820
- const callExpressions = sourceFile.getDescendantsOfKind(
3821
- import_ts_morph17.SyntaxKind.CallExpression
3822
- );
3823
- for (const call of callExpressions) {
3824
- const expression = call.getExpression();
3825
- if (!import_ts_morph17.Node.isIdentifier(expression) || expression.getText() !== DEFINE_WORKQUEUES_NAME3) {
3826
- continue;
3827
- }
3828
- const args = call.getArguments();
3829
- if (args.length === 0) continue;
3830
- const workqueuesArg = args[0];
3831
- if (!import_ts_morph17.Node.isArrayLiteralExpression(workqueuesArg)) continue;
3832
- for (const element of workqueuesArg.getElements()) {
3833
- if (!import_ts_morph17.Node.isObjectLiteralExpression(element)) continue;
3834
- migratedWorkqueues += migrateWorkqueueActions(element, relPath);
3835
- }
3836
- }
3837
- return migratedWorkqueues;
3838
- }
3839
- async function main18() {
3840
- const srcDir = import_path18.default.join(process.cwd(), "src");
3841
- console.log(`Scanning for defineWorkqueues calls in: ${srcDir}
3842
- `);
3843
- const project = new import_ts_morph17.Project({
3844
- tsConfigFilePath: import_path18.default.resolve(srcDir, "../tsconfig.json"),
3845
- skipAddingFilesFromTsConfig: false
3846
- });
3847
- const sourceFiles = project.getSourceFiles().filter((sf) => {
3848
- const fp = sf.getFilePath();
3849
- return fp.includes("/src/") && !fp.includes("/node_modules/");
3850
- });
3851
- console.log(`Found ${sourceFiles.length} source file(s) to analyse.
3852
- `);
3853
- let totalMigrated = 0;
3854
- const modifiedFiles = [];
3855
- for (const sourceFile of sourceFiles) {
3856
- const filePath = sourceFile.getFilePath();
3857
- const migrated = processFile13(filePath, project);
3858
- if (migrated > 0) {
3859
- totalMigrated += migrated;
3860
- modifiedFiles.push(filePath);
3861
- }
3862
- }
3863
- if (modifiedFiles.length === 0) {
3864
- console.log(
3865
- "No deprecated workqueue 'actions' arrays found inside defineWorkqueues calls. Nothing to do."
3866
- );
3043
+ if (modifiedFiles.length === 0) {
3044
+ console.log(
3045
+ "No deprecated workqueue 'actions' arrays found inside defineWorkqueues calls. Nothing to do."
3046
+ );
3867
3047
  return;
3868
3048
  }
3869
3049
  console.log(`
@@ -3871,7 +3051,7 @@ Saving ${modifiedFiles.length} modified file(s)...`);
3871
3051
  for (const filePath of modifiedFiles) {
3872
3052
  const sourceFile = project.getSourceFileOrThrow(filePath);
3873
3053
  await sourceFile.save();
3874
- console.log(` Saved: ${import_path18.default.relative(process.cwd(), filePath)}`);
3054
+ console.log(` Saved: ${import_path13.default.relative(getCwd(), filePath)}`);
3875
3055
  }
3876
3056
  console.log(
3877
3057
  `
@@ -3880,13 +3060,13 @@ Done. Migrated ${totalMigrated} deprecated workqueue 'actions' definition(s) to
3880
3060
  }
3881
3061
 
3882
3062
  // src/migrations/v2.0/remove-demo-scope.ts
3883
- var import_path19 = __toESM(require("path"));
3884
- var import_ts_morph18 = require("ts-morph");
3063
+ var import_path14 = __toESM(require("path"));
3064
+ var import_ts_morph14 = require("ts-morph");
3885
3065
  var ROLES_HANDLER_RELATIVE_PATH = "src/data-seeding/roles/handler.ts";
3886
- async function main19() {
3887
- const rolesHandlerPath = import_path19.default.join(process.cwd(), ROLES_HANDLER_RELATIVE_PATH);
3888
- const project = new import_ts_morph18.Project({
3889
- tsConfigFilePath: import_path19.default.resolve(process.cwd(), "tsconfig.json"),
3066
+ async function main14() {
3067
+ const rolesHandlerPath = import_path14.default.join(getCwd(), ROLES_HANDLER_RELATIVE_PATH);
3068
+ const project = new import_ts_morph14.Project({
3069
+ tsConfigFilePath: import_path14.default.resolve(getCwd(), "tsconfig.json"),
3890
3070
  skipAddingFilesFromTsConfig: false
3891
3071
  });
3892
3072
  const sourceFile = project.getSourceFile(rolesHandlerPath);
@@ -3935,7 +3115,7 @@ async function main19() {
3935
3115
 
3936
3116
  // src/migrations/v2.0/remove-hearth-migrations.ts
3937
3117
  var fs2 = __toESM(require("fs"));
3938
- var import_path20 = __toESM(require("path"));
3118
+ var import_path15 = __toESM(require("path"));
3939
3119
  var PATHS_TO_REMOVE = [
3940
3120
  {
3941
3121
  relativePath: "src/migrations/hearth",
@@ -3947,9 +3127,9 @@ var PATHS_TO_REMOVE = [
3947
3127
  },
3948
3128
  { relativePath: "src/utils/hearth-helpers.ts", label: "Hearth helpers file" }
3949
3129
  ];
3950
- async function main20() {
3130
+ async function main15() {
3951
3131
  for (const { relativePath, label } of PATHS_TO_REMOVE) {
3952
- const absolutePath = import_path20.default.join(process.cwd(), relativePath);
3132
+ const absolutePath = import_path15.default.join(getCwd(), relativePath);
3953
3133
  if (fs2.existsSync(absolutePath)) {
3954
3134
  fs2.rmSync(absolutePath, { recursive: true, force: true });
3955
3135
  console.log(`Removed ${label} '${relativePath}'.`);
@@ -3960,9 +3140,9 @@ async function main20() {
3960
3140
  }
3961
3141
 
3962
3142
  // src/migrations/v2.0/create-events-index.ts
3963
- var import_ts_morph19 = require("ts-morph");
3964
- var import_fs2 = __toESM(require("fs"));
3965
- var import_path21 = __toESM(require("path"));
3143
+ var import_ts_morph15 = require("ts-morph");
3144
+ var import_fs = __toESM(require("fs"));
3145
+ var import_path16 = __toESM(require("path"));
3966
3146
  var DEFINE_CONFIG_NAME5 = "defineConfig";
3967
3147
  var HANDLER_FUNCTION_NAMES = /* @__PURE__ */ new Set([
3968
3148
  "getCustomEventsHandler",
@@ -3984,7 +3164,7 @@ var LICENSE_HEADER = `/*
3984
3164
  `;
3985
3165
  function findEventConfigExports(project, srcDir) {
3986
3166
  const found = [];
3987
- const eventsIndexAbs = import_path21.default.join(srcDir, "events", "index.ts");
3167
+ const eventsIndexAbs = import_path16.default.join(srcDir, "events", "index.ts");
3988
3168
  for (const sourceFile of project.getSourceFiles()) {
3989
3169
  const filePath = sourceFile.getFilePath();
3990
3170
  if (!filePath.startsWith(srcDir) || filePath.includes("/node_modules/")) {
@@ -3996,10 +3176,10 @@ function findEventConfigExports(project, srcDir) {
3996
3176
  for (const decl of statement.getDeclarations()) {
3997
3177
  const initializer = decl.getInitializer();
3998
3178
  if (!initializer) continue;
3999
- const unwrapped = import_ts_morph19.Node.isAsExpression(initializer) ? initializer.getExpression() : initializer;
4000
- if (!import_ts_morph19.Node.isCallExpression(unwrapped)) continue;
3179
+ const unwrapped = import_ts_morph15.Node.isAsExpression(initializer) ? initializer.getExpression() : initializer;
3180
+ if (!import_ts_morph15.Node.isCallExpression(unwrapped)) continue;
4001
3181
  const callee = unwrapped.getExpression();
4002
- if (!import_ts_morph19.Node.isIdentifier(callee)) continue;
3182
+ if (!import_ts_morph15.Node.isIdentifier(callee)) continue;
4003
3183
  if (callee.getText() !== DEFINE_CONFIG_NAME5) continue;
4004
3184
  found.push({ name: decl.getName(), filePath });
4005
3185
  }
@@ -4008,8 +3188,8 @@ function findEventConfigExports(project, srcDir) {
4008
3188
  return found;
4009
3189
  }
4010
3190
  function buildIndexImportSpecifier(eventConfigFilePath, srcDir) {
4011
- const eventsIndexDir = import_path21.default.join(srcDir, "events");
4012
- let rel = import_path21.default.relative(eventsIndexDir, eventConfigFilePath).split(import_path21.default.sep).join("/");
3191
+ const eventsIndexDir = import_path16.default.join(srcDir, "events");
3192
+ let rel = import_path16.default.relative(eventsIndexDir, eventConfigFilePath).split(import_path16.default.sep).join("/");
4013
3193
  if (rel.endsWith(".ts")) rel = rel.slice(0, -".ts".length);
4014
3194
  if (rel.endsWith("/index")) rel = rel.slice(0, -"/index".length);
4015
3195
  if (!rel.startsWith(".")) rel = "./" + rel;
@@ -4086,17 +3266,17 @@ function modifyHandler(sourceFile, exportNames) {
4086
3266
  );
4087
3267
  }
4088
3268
  for (const call of sourceFile.getDescendantsOfKind(
4089
- import_ts_morph19.SyntaxKind.CallExpression
3269
+ import_ts_morph15.SyntaxKind.CallExpression
4090
3270
  )) {
4091
3271
  const callee = call.getExpression();
4092
- if (!import_ts_morph19.Node.isPropertyAccessExpression(callee)) continue;
3272
+ if (!import_ts_morph15.Node.isPropertyAccessExpression(callee)) continue;
4093
3273
  if (callee.getName() !== RESPONSE_METHOD_NAME) continue;
4094
3274
  const args = call.getArguments();
4095
3275
  if (args.length !== 1) continue;
4096
3276
  const [arg] = args;
4097
- if (!import_ts_morph19.Node.isArrayLiteralExpression(arg)) continue;
3277
+ if (!import_ts_morph15.Node.isArrayLiteralExpression(arg)) continue;
4098
3278
  if (arg.getElements().length === 0) continue;
4099
- if (!arg.getElements().every((el) => import_ts_morph19.Node.isIdentifier(el))) continue;
3279
+ if (!arg.getElements().every((el) => import_ts_morph15.Node.isIdentifier(el))) continue;
4100
3280
  arg.replaceWithText(EVENT_CONFIGS_IDENTIFIER);
4101
3281
  changes.push(
4102
3282
  `rewrote h.response([...]) \u2192 h.response(${EVENT_CONFIGS_IDENTIFIER})`
@@ -4104,13 +3284,13 @@ function modifyHandler(sourceFile, exportNames) {
4104
3284
  }
4105
3285
  return changes;
4106
3286
  }
4107
- async function main21() {
4108
- const cwd = process.cwd();
4109
- const srcDir = import_path21.default.join(cwd, "src");
3287
+ async function main16() {
3288
+ const cwd2 = getCwd();
3289
+ const srcDir = import_path16.default.join(cwd2, "src");
4110
3290
  console.log(`Scanning for defineConfig event exports in: ${srcDir}
4111
3291
  `);
4112
- const project = new import_ts_morph19.Project({
4113
- tsConfigFilePath: import_path21.default.resolve(srcDir, "../tsconfig.json"),
3292
+ const project = new import_ts_morph15.Project({
3293
+ tsConfigFilePath: import_path16.default.resolve(srcDir, "../tsconfig.json"),
4114
3294
  skipAddingFilesFromTsConfig: false
4115
3295
  });
4116
3296
  const eventConfigExports = findEventConfigExports(project, srcDir);
@@ -4122,15 +3302,15 @@ async function main21() {
4122
3302
  }
4123
3303
  console.log(`Found ${eventConfigExports.length} event config export(s):`);
4124
3304
  for (const e of eventConfigExports) {
4125
- console.log(` ${e.name} \u2190 ${import_path21.default.relative(cwd, e.filePath)}`);
3305
+ console.log(` ${e.name} \u2190 ${import_path16.default.relative(cwd2, e.filePath)}`);
4126
3306
  }
4127
- const eventsIndexAbs = import_path21.default.join(srcDir, "events", "index.ts");
4128
- const eventsIndexRel = import_path21.default.relative(cwd, eventsIndexAbs);
4129
- if (import_fs2.default.existsSync(eventsIndexAbs)) {
3307
+ const eventsIndexAbs = import_path16.default.join(srcDir, "events", "index.ts");
3308
+ const eventsIndexRel = import_path16.default.relative(cwd2, eventsIndexAbs);
3309
+ if (import_fs.default.existsSync(eventsIndexAbs)) {
4130
3310
  console.log(`
4131
3311
  [${eventsIndexRel}] already exists \u2014 leaving untouched.`);
4132
3312
  } else {
4133
- import_fs2.default.mkdirSync(import_path21.default.dirname(eventsIndexAbs), { recursive: true });
3313
+ import_fs.default.mkdirSync(import_path16.default.dirname(eventsIndexAbs), { recursive: true });
4134
3314
  const source = buildEventsIndexSource(eventConfigExports, srcDir);
4135
3315
  const eventsIndexFile = project.createSourceFile(eventsIndexAbs, source, {
4136
3316
  overwrite: false
@@ -4151,7 +3331,7 @@ No event-config handler file found (looked for exported function(s): ${Array.fro
4151
3331
  );
4152
3332
  return;
4153
3333
  }
4154
- const handlerRelPath = import_path21.default.relative(cwd, handler.getFilePath());
3334
+ const handlerRelPath = import_path16.default.relative(cwd2, handler.getFilePath());
4155
3335
  const exportNameSet = new Set(eventConfigExports.map((e) => e.name));
4156
3336
  const changes = modifyHandler(handler, exportNameSet);
4157
3337
  if (changes.length === 0) {
@@ -4171,13 +3351,12 @@ var UPSTREAM_URL = "https://github.com/opencrvs/opencrvs-countryconfig.git";
4171
3351
  var UPSTREAM_BRANCH = "develop";
4172
3352
  var TEMP_REMOTE = "opencrvs-upgrade-v19-v20-codemod";
4173
3353
  var FILES_TO_CHECKOUT = [
4174
- "src/analytics/analytics.ts",
4175
- "Dockerfile",
4176
- "Dockerfile.assets"
3354
+ "infrastructure/postgres/setup-analytics.sh",
3355
+ "src/analytics/analytics.ts"
4177
3356
  ];
4178
3357
  function runGit(args, { silent = false } = {}) {
4179
3358
  return (0, import_child_process.execFileSync)("git", args, {
4180
- cwd: process.cwd(),
3359
+ cwd: getCwd(),
4181
3360
  encoding: "utf8",
4182
3361
  stdio: silent ? ["ignore", "pipe", "pipe"] : ["ignore", "pipe", "inherit"]
4183
3362
  });
@@ -4193,11 +3372,11 @@ function tryGit(args) {
4193
3372
  function assertIsGitRepo() {
4194
3373
  if (!tryGit(["rev-parse", "--is-inside-work-tree"])) {
4195
3374
  throw new Error(
4196
- `${process.cwd()} is not a git repository. Initialise git (or run the upgrade inside a git checkout) before re-running.`
3375
+ `checkout-upstream-files: ${getCwd()} is not a git repository. Initialise git (or run the upgrade inside a git checkout) before re-running.`
4197
3376
  );
4198
3377
  }
4199
3378
  }
4200
- async function main22() {
3379
+ async function main17() {
4201
3380
  console.log(
4202
3381
  `Checking out ${FILES_TO_CHECKOUT.length} file(s) from ${UPSTREAM_URL}@${UPSTREAM_BRANCH}...
4203
3382
  `
@@ -4245,356 +3424,10 @@ async function main22() {
4245
3424
  }
4246
3425
  }
4247
3426
 
4248
- // src/migrations/v2.0/add-resend-invite-notification.ts
4249
- var import_fs3 = require("fs");
4250
- var import_path22 = __toESM(require("path"));
4251
- var import_ts_morph20 = require("ts-morph");
4252
- var TS_MORPH_PROJECT_OPTIONS = {
4253
- skipAddingFilesFromTsConfig: true,
4254
- manipulationSettings: {
4255
- indentationText: import_ts_morph20.IndentationText.TwoSpaces
4256
- }
4257
- };
4258
- var EMAIL_TEMPLATES_INDEX = "src/api/notification/email-templates/index.ts";
4259
- var NOTIFICATION_HANDLER = "src/api/notification/handler.ts";
4260
- var USER_NOTIFICATION_ROUTES = "src/config/routes/userNotificationRoutes.ts";
4261
- var SMS_SERVICE = "src/api/notification/sms-service.ts";
4262
- var NOTIFICATION_CSV = "src/translations/notification.csv";
4263
- var RESEND_INVITE_HTML = "src/api/notification/email-templates/other/resend-invite.html";
4264
- var RESEND_INVITE_HTML_CONTENT = `<!doctype html>
4265
- <html>
4266
- <head>
4267
- <link
4268
- href="https://fonts.googleapis.com/css2?family=Noto+Sans:wght@400;700&display=swap"
4269
- rel="stylesheet"
4270
- />
4271
- <style type="text/css">
4272
- body {
4273
- font-family: 'Noto Sans', sans-serif;
4274
- color: #222;
4275
- padding: 16px 24px;
4276
- }
4277
-
4278
- h1 {
4279
- font-size: 21px;
4280
- margin-top: 32px;
4281
- margin-bottom: 36px;
4282
- font-weight: 700;
4283
- }
4284
-
4285
- p {
4286
- font-weight: 400;
4287
- font-size: 16px;
4288
- line-height: 1.8;
4289
- margin-bottom: 24px;
4290
- }
4291
-
4292
- i {
4293
- color: #666;
4294
- font-weight: 400;
4295
- font-size: 16px;
4296
- }
4297
- </style>
4298
- </head>
4299
-
4300
- <body>
4301
- <img
4302
- src="{{countryLogo}}"
4303
- alt="country_logo"
4304
- style="max-height: 88px; max-width: 100%"
4305
- />
4306
- <h1>Your {{applicationName}} account invitation</h1>
4307
- <p>Hello {{firstname}},</p>
4308
- <p>Your account invitation has been resent. Please use the following credentials to access your account:</p>
4309
- <p>
4310
- Username: <strong>{{username}}</strong><br />
4311
- Password: <strong>{{temporaryPassword}}</strong>
4312
- </p>
4313
- <p>
4314
- Please click the link below to complete your account setup and start using
4315
- {{applicationName}}.
4316
- </p>
4317
-
4318
- <div style="margin-top: 32px; margin-bottom: 32px">
4319
- <a href="{{loginURL}}">Complete setup</a>
4320
- </div>
4321
- <br />
4322
- <p>
4323
- Best regards, <br />
4324
- {{applicationName}} Team
4325
- </p>
4326
- </body>
4327
- </html>
4328
- `;
4329
- var CSV_ROW = "resendInviteNotification,The SMS message that is sent when a user invitation is resent,Your OpenCRVS account invitation was resent. Please login with your username: {{username}} and temporary password: {{temporaryPassword}},Votre invitation de compte OpenCRVS a \xE9t\xE9 renvoy\xE9e. Veuillez vous connecter avec votre nom d'utilisateur : {{username}} et votre mot de passe temporaire : {{temporaryPassword}}.\n";
4330
- function getObjectLiteralFromConst(declaration) {
4331
- if (!declaration) {
4332
- return;
4333
- }
4334
- const initializer = declaration.getInitializer();
4335
- if (!initializer) {
4336
- return;
4337
- }
4338
- if (import_ts_morph20.Node.isObjectLiteralExpression(initializer)) {
4339
- return initializer;
4340
- }
4341
- if (import_ts_morph20.Node.isAsExpression(initializer)) {
4342
- const expression = initializer.getExpression();
4343
- if (import_ts_morph20.Node.isObjectLiteralExpression(expression)) {
4344
- return expression;
4345
- }
4346
- }
4347
- if (import_ts_morph20.Node.isSatisfiesExpression(initializer)) {
4348
- const expression = initializer.getExpression();
4349
- if (import_ts_morph20.Node.isObjectLiteralExpression(expression)) {
4350
- return expression;
4351
- }
4352
- }
4353
- }
4354
- function patchEmailTemplatesIndex() {
4355
- const full = import_path22.default.join(process.cwd(), EMAIL_TEMPLATES_INDEX);
4356
- if (!(0, import_fs3.existsSync)(full)) {
4357
- console.log(` '${EMAIL_TEMPLATES_INDEX}' missing \u2014 skipping.`);
4358
- return false;
4359
- }
4360
- const project = new import_ts_morph20.Project(TS_MORPH_PROJECT_OPTIONS);
4361
- const sourceFile = project.addSourceFileAtPath(full);
4362
- let changed = false;
4363
- const triggerVariableObject = getObjectLiteralFromConst(
4364
- sourceFile.getVariableDeclaration("TriggerVariable")
4365
- );
4366
- if (triggerVariableObject) {
4367
- const hasResendInviteVariable = triggerVariableObject.getProperties().some((prop) => prop.getText().includes("[TriggerEvent.RESEND_INVITE]"));
4368
- if (!hasResendInviteVariable) {
4369
- const properties = triggerVariableObject.getProperties();
4370
- const lastProperty = properties[properties.length - 1];
4371
- if (lastProperty) {
4372
- sourceFile.insertText(
4373
- lastProperty.getEnd(),
4374
- `,
4375
- [TriggerEvent.RESEND_INVITE]: z.object({
4376
- firstname: z.string(),
4377
- username: z.string(),
4378
- temporaryPassword: z.string(),
4379
- completeSetupUrl: z.string(),
4380
- loginURL: z.string()
4381
- })`
4382
- );
4383
- changed = true;
4384
- }
4385
- }
4386
- }
4387
- const templatesObject = getObjectLiteralFromConst(
4388
- sourceFile.getVariableDeclaration("templates")
4389
- );
4390
- if (templatesObject) {
4391
- const hasResendInviteTemplate = templatesObject.getProperties().some(
4392
- (prop) => prop.getText().includes("readOtherTemplate<TriggerVariable['resend-invite']>")
4393
- );
4394
- if (!hasResendInviteTemplate) {
4395
- const userCreatedProp = templatesObject.getProperties().find((prop) => prop.getText().includes("[TriggerEvent.USER_CREATED]"));
4396
- const anchor = userCreatedProp ?? templatesObject.getProperties()[templatesObject.getProperties().length - 1];
4397
- if (anchor) {
4398
- sourceFile.insertText(
4399
- anchor.getEnd(),
4400
- `,
4401
- [TriggerEvent.RESEND_INVITE]: {
4402
- type: 'resend-invite',
4403
- subject: 'Your OpenCRVS account invitation',
4404
- template:
4405
- readOtherTemplate<TriggerVariable['resend-invite']>('resend-invite')
4406
- }`
4407
- );
4408
- changed = true;
4409
- }
4410
- }
4411
- }
4412
- if (changed) {
4413
- sourceFile.saveSync();
4414
- }
4415
- return changed;
4416
- }
4417
- function patchNotificationHandler() {
4418
- const full = import_path22.default.join(process.cwd(), NOTIFICATION_HANDLER);
4419
- if (!(0, import_fs3.existsSync)(full)) {
4420
- return false;
4421
- }
4422
- const project = new import_ts_morph20.Project(TS_MORPH_PROJECT_OPTIONS);
4423
- const sourceFile = project.addSourceFileAtPath(full);
4424
- const convertFn = sourceFile.getFunction("convertPayloadToVariable");
4425
- if (!convertFn) {
4426
- return false;
4427
- }
4428
- const switchStmt = convertFn.getFirstDescendantByKind(
4429
- import_ts_morph20.SyntaxKind.SwitchStatement
4430
- );
4431
- if (!switchStmt) {
4432
- return false;
4433
- }
4434
- const clauses = switchStmt.getCaseBlock().getClauses();
4435
- const hasResendInvite = clauses.some(
4436
- (clause) => import_ts_morph20.Node.isCaseClause(clause) && clause.getExpression().getText() === "TriggerEvent.RESEND_INVITE"
4437
- );
4438
- if (hasResendInvite) {
4439
- return false;
4440
- }
4441
- const userCreatedClauseIndex = clauses.findIndex(
4442
- (clause) => import_ts_morph20.Node.isCaseClause(clause) && clause.getExpression().getText() === "TriggerEvent.USER_CREATED"
4443
- );
4444
- if (userCreatedClauseIndex < 0) {
4445
- return false;
4446
- }
4447
- const userCreatedClause = clauses[userCreatedClauseIndex];
4448
- sourceFile.insertText(
4449
- userCreatedClause.getEnd(),
4450
- `
4451
-
4452
- case TriggerEvent.RESEND_INVITE:
4453
- return {
4454
- firstname,
4455
- username: payload.username,
4456
- temporaryPassword: payload.temporaryPassword,
4457
- completeSetupUrl: LOGIN_URL,
4458
- loginURL: LOGIN_URL
4459
- }`
4460
- );
4461
- sourceFile.saveSync();
4462
- return true;
4463
- }
4464
- function getReturnedArrayLiteral(functionFilePath, fnName) {
4465
- const project = new import_ts_morph20.Project(TS_MORPH_PROJECT_OPTIONS);
4466
- const sourceFile = project.addSourceFileAtPath(functionFilePath);
4467
- const fn = sourceFile.getFunction(fnName);
4468
- const returnStmt = fn?.getFirstDescendantByKind(import_ts_morph20.SyntaxKind.ReturnStatement);
4469
- const expr = returnStmt?.getExpression();
4470
- if (!expr || !import_ts_morph20.Node.isArrayLiteralExpression(expr)) {
4471
- return { sourceFile, arrayLiteral: void 0 };
4472
- }
4473
- return { sourceFile, arrayLiteral: expr };
4474
- }
4475
- function patchUserNotificationRoutes() {
4476
- const full = import_path22.default.join(process.cwd(), USER_NOTIFICATION_ROUTES);
4477
- if (!(0, import_fs3.existsSync)(full)) {
4478
- return false;
4479
- }
4480
- const { sourceFile, arrayLiteral } = getReturnedArrayLiteral(
4481
- full,
4482
- "getUserNotificationRoutes"
4483
- );
4484
- if (!arrayLiteral) {
4485
- return false;
4486
- }
4487
- const elements = arrayLiteral.getElements();
4488
- const routeExists = elements.some(
4489
- (element) => element.getText().includes(`path: '/triggers/user/resend-invite'`)
4490
- );
4491
- if (routeExists) {
4492
- return false;
4493
- }
4494
- const anchor = elements.find(
4495
- (element) => element.getText().includes(`path: '/triggers/user/user-created'`)
4496
- ) ?? elements[elements.length - 1];
4497
- if (!anchor) {
4498
- return false;
4499
- }
4500
- sourceFile.insertText(
4501
- anchor.getEnd(),
4502
- `,
4503
- {
4504
- method: 'POST',
4505
- path: '/triggers/user/resend-invite',
4506
- handler: makeNotificationHandler('resend-invite'),
4507
- options: {
4508
- auth: false,
4509
- tags: ['api'],
4510
- description: 'Handles notification for resent user invite'
4511
- }
4512
- }`
4513
- );
4514
- sourceFile.saveSync();
4515
- return true;
4516
- }
4517
- function patchSmsService() {
4518
- const full = import_path22.default.join(process.cwd(), SMS_SERVICE);
4519
- if (!(0, import_fs3.existsSync)(full)) {
4520
- return false;
4521
- }
4522
- const project = new import_ts_morph20.Project(TS_MORPH_PROJECT_OPTIONS);
4523
- const sourceFile = project.addSourceFileAtPath(full);
4524
- let changed = false;
4525
- const otherTemplatesObject = getObjectLiteralFromConst(
4526
- sourceFile.getVariableDeclaration("otherTemplates")
4527
- );
4528
- if (otherTemplatesObject) {
4529
- const hasResendTemplate = otherTemplatesObject.getProperties().some((prop) => prop.getText().includes("resendInviteNotification"));
4530
- if (!hasResendTemplate) {
4531
- const userCredentialsIndex = otherTemplatesObject.getProperties().findIndex((prop) => prop.getText().includes("userCredentialsNotification"));
4532
- otherTemplatesObject.insertPropertyAssignment(
4533
- userCredentialsIndex >= 0 ? userCredentialsIndex + 1 : otherTemplatesObject.getProperties().length,
4534
- {
4535
- name: "resendInviteNotification",
4536
- initializer: `'resendInviteNotification'`
4537
- }
4538
- );
4539
- changed = true;
4540
- }
4541
- }
4542
- const triggerToSmsTemplateObject = getObjectLiteralFromConst(
4543
- sourceFile.getVariableDeclaration("TriggerToSMSTemplate")
4544
- );
4545
- if (triggerToSmsTemplateObject) {
4546
- const hasResendInviteMap = triggerToSmsTemplateObject.getProperties().some((prop) => prop.getText().includes(`['resend-invite']`));
4547
- if (!hasResendInviteMap) {
4548
- const userCreatedIndex = triggerToSmsTemplateObject.getProperties().findIndex((prop) => prop.getText().includes(`['user-created']`));
4549
- triggerToSmsTemplateObject.insertPropertyAssignment(
4550
- userCreatedIndex >= 0 ? userCreatedIndex + 1 : triggerToSmsTemplateObject.getProperties().length,
4551
- {
4552
- name: `['resend-invite']`,
4553
- initializer: `'resendInviteNotification'`
4554
- }
4555
- );
4556
- changed = true;
4557
- }
4558
- }
4559
- if (changed) {
4560
- sourceFile.saveSync();
4561
- }
4562
- return changed;
4563
- }
4564
- async function main23() {
4565
- console.log("Adding RESEND_INVITE notification wiring\u2026");
4566
- const touched = [];
4567
- if (patchEmailTemplatesIndex()) touched.push(EMAIL_TEMPLATES_INDEX);
4568
- if (patchNotificationHandler()) touched.push(NOTIFICATION_HANDLER);
4569
- if (patchUserNotificationRoutes()) touched.push(USER_NOTIFICATION_ROUTES);
4570
- if (patchSmsService()) touched.push(SMS_SERVICE);
4571
- const csvPath = import_path22.default.join(process.cwd(), NOTIFICATION_CSV);
4572
- if ((0, import_fs3.existsSync)(csvPath)) {
4573
- let t = (0, import_fs3.readFileSync)(csvPath, "utf8");
4574
- if (!/^resendInviteNotification,/m.test(t)) {
4575
- if (!t.endsWith("\n")) t += "\n";
4576
- (0, import_fs3.writeFileSync)(csvPath, t + CSV_ROW);
4577
- touched.push(NOTIFICATION_CSV);
4578
- }
4579
- }
4580
- const htmlPath = import_path22.default.join(process.cwd(), RESEND_INVITE_HTML);
4581
- (0, import_fs3.mkdirSync)(import_path22.default.dirname(htmlPath), { recursive: true });
4582
- if (!(0, import_fs3.existsSync)(htmlPath)) {
4583
- (0, import_fs3.writeFileSync)(htmlPath, RESEND_INVITE_HTML_CONTENT);
4584
- touched.push(RESEND_INVITE_HTML);
4585
- }
4586
- if (touched.length === 0) {
4587
- console.log(" Nothing to update (already present or anchors not found).");
4588
- return;
4589
- }
4590
- console.log(` Updated:
4591
- ${touched.map((f) => ` - ${f}`).join("\n")}`);
4592
- }
4593
-
4594
3427
  // src/migrations/v2.0/simplify-analytics-precalculations.ts
4595
- var import_ts_morph21 = require("ts-morph");
4596
- var import_fs4 = __toESM(require("fs"));
4597
- var import_path23 = __toESM(require("path"));
3428
+ var import_ts_morph16 = require("ts-morph");
3429
+ var import_fs2 = __toESM(require("fs"));
3430
+ var import_path17 = __toESM(require("path"));
4598
3431
  var ANALYTICS_FILE_REL = "src/analytics/analytics.ts";
4599
3432
  var FUNCTION_NAME = "precalculateAdditionalAnalytics";
4600
3433
  var IMPORT_NAMES_TO_REMOVE = /* @__PURE__ */ new Set(["Event", "precalculateBirthEvent"]);
@@ -4630,10 +3463,10 @@ function findPrecalculateFunction(sourceFile) {
4630
3463
  return void 0;
4631
3464
  }
4632
3465
  function getFunctionBodyBlock(fn) {
4633
- if (import_ts_morph21.Node.isFunctionDeclaration(fn)) return fn.getBody();
3466
+ if (import_ts_morph16.Node.isFunctionDeclaration(fn)) return fn.getBody();
4634
3467
  const initializer = fn.getInitializer();
4635
3468
  if (!initializer) return void 0;
4636
- if (!import_ts_morph21.Node.isArrowFunction(initializer) && !import_ts_morph21.Node.isFunctionExpression(initializer)) {
3469
+ if (!import_ts_morph16.Node.isArrowFunction(initializer) && !import_ts_morph16.Node.isFunctionExpression(initializer)) {
4637
3470
  return void 0;
4638
3471
  }
4639
3472
  return initializer.getBody();
@@ -4643,9 +3476,9 @@ function simplifyPrecalculateFunction(sourceFile) {
4643
3476
  const fn = findPrecalculateFunction(sourceFile);
4644
3477
  if (!fn) return log;
4645
3478
  const body = getFunctionBodyBlock(fn);
4646
- if (!body || !import_ts_morph21.Node.isBlock(body)) return log;
3479
+ if (!body || !import_ts_morph16.Node.isBlock(body)) return log;
4647
3480
  for (const statement of [...body.getStatements()]) {
4648
- const references = statement.getDescendantsOfKind(import_ts_morph21.SyntaxKind.Identifier).some((id) => IMPORT_NAMES_TO_REMOVE.has(id.getText()));
3481
+ const references = statement.getDescendantsOfKind(import_ts_morph16.SyntaxKind.Identifier).some((id) => IMPORT_NAMES_TO_REMOVE.has(id.getText()));
4649
3482
  if (references) {
4650
3483
  statement.remove();
4651
3484
  log.push(`removed statement in ${FUNCTION_NAME} referencing removed imports`);
@@ -4653,7 +3486,7 @@ function simplifyPrecalculateFunction(sourceFile) {
4653
3486
  }
4654
3487
  const remaining = body.getStatements();
4655
3488
  const last = remaining[remaining.length - 1];
4656
- const alreadyCorrect = last && import_ts_morph21.Node.isReturnStatement(last) && last.getExpression()?.getText() === RETURN_EXPRESSION_TEXT;
3489
+ const alreadyCorrect = last && import_ts_morph16.Node.isReturnStatement(last) && last.getExpression()?.getText() === RETURN_EXPRESSION_TEXT;
4657
3490
  if (!alreadyCorrect) {
4658
3491
  body.addStatements(`return ${RETURN_EXPRESSION_TEXT}`);
4659
3492
  log.push(
@@ -4662,17 +3495,17 @@ function simplifyPrecalculateFunction(sourceFile) {
4662
3495
  }
4663
3496
  return log;
4664
3497
  }
4665
- async function main24() {
4666
- const cwd = process.cwd();
4667
- const absPath = import_path23.default.join(cwd, ANALYTICS_FILE_REL);
4668
- if (!import_fs4.default.existsSync(absPath)) {
3498
+ async function main18() {
3499
+ const cwd2 = getCwd();
3500
+ const absPath = import_path17.default.join(cwd2, ANALYTICS_FILE_REL);
3501
+ if (!import_fs2.default.existsSync(absPath)) {
4669
3502
  console.log(
4670
3503
  `[${ANALYTICS_FILE_REL}] does not exist \u2014 nothing to clean up.`
4671
3504
  );
4672
3505
  return;
4673
3506
  }
4674
- const project = new import_ts_morph21.Project({
4675
- tsConfigFilePath: import_path23.default.resolve(cwd, "tsconfig.json"),
3507
+ const project = new import_ts_morph16.Project({
3508
+ tsConfigFilePath: import_path17.default.resolve(cwd2, "tsconfig.json"),
4676
3509
  skipAddingFilesFromTsConfig: false
4677
3510
  });
4678
3511
  const sourceFile = project.getSourceFile(absPath);
@@ -4699,158 +3532,26 @@ async function main24() {
4699
3532
  Saved ${ANALYTICS_FILE_REL}.`);
4700
3533
  }
4701
3534
 
4702
- // src/migrations/v2.0/merge-infrastructure-directory.ts
4703
- var import_child_process2 = require("child_process");
4704
- var import_fs5 = require("fs");
4705
- var import_os = require("os");
4706
- var import_path24 = require("path");
4707
- var TEMP_REMOTE2 = "opencrvs-upgrade-v19-v20-codemod-merge-infra";
4708
- var INFRASTRUCTURE_DIR = "infrastructure";
4709
- var BASE_BRANCH = "release-v1.9";
4710
- function gitShowBytes(ref, path23) {
4711
- try {
4712
- const buf = (0, import_child_process2.execFileSync)("git", ["show", `${ref}:${path23}`], {
4713
- cwd: process.cwd(),
4714
- stdio: ["ignore", "pipe", "pipe"]
4715
- });
4716
- return new Uint8Array(buf.buffer, buf.byteOffset, buf.byteLength);
4717
- } catch {
4718
- return null;
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.");
4719
3540
  }
3541
+ return cwd;
4720
3542
  }
4721
- async function main25() {
4722
- console.log(
4723
- `Merging '${INFRASTRUCTURE_DIR}/' from ${UPSTREAM_URL}@${UPSTREAM_BRANCH} (base: ${BASE_BRANCH})...
4724
- `
4725
- );
4726
- assertIsGitRepo();
4727
- tryGit(["remote", "remove", TEMP_REMOTE2]);
4728
- try {
4729
- console.log(` Adding temporary remote '${TEMP_REMOTE2}' \u2192 ${UPSTREAM_URL}`);
4730
- runGit(["remote", "add", TEMP_REMOTE2, UPSTREAM_URL], { silent: true });
4731
- console.log(
4732
- ` Fetching ${TEMP_REMOTE2}/{${UPSTREAM_BRANCH},${BASE_BRANCH}} (depth 1)...`
4733
- );
4734
- runGit(["fetch", "--depth=1", TEMP_REMOTE2, UPSTREAM_BRANCH, BASE_BRANCH]);
4735
- const ref = `${TEMP_REMOTE2}/${UPSTREAM_BRANCH}`;
4736
- const baseRef = `${TEMP_REMOTE2}/${BASE_BRANCH}`;
4737
- const upstreamFiles = runGit(
4738
- [
4739
- "ls-tree",
4740
- "-r",
4741
- "--name-only",
4742
- "-z",
4743
- ref,
4744
- "--",
4745
- `${INFRASTRUCTURE_DIR}/`
4746
- ],
4747
- { silent: true }
4748
- ).split("\0").filter(Boolean);
4749
- if (upstreamFiles.length === 0) {
4750
- console.log(
4751
- ` No files found under '${INFRASTRUCTURE_DIR}/' on ${ref}. Nothing to merge.`
4752
- );
4753
- return;
4754
- }
4755
- const tmpDir = (0, import_fs5.mkdtempSync)((0, import_path24.join)((0, import_os.tmpdir)(), "opencrvs-merge-infra-"));
4756
- const baseTmp = (0, import_path24.join)(tmpDir, "base");
4757
- const theirsTmp = (0, import_path24.join)(tmpDir, "theirs");
4758
- let added = 0;
4759
- let merged = 0;
4760
- const conflictedFiles = [];
4761
- for (const file of upstreamFiles) {
4762
- const fullPath = (0, import_path24.join)(process.cwd(), file);
4763
- if (!(0, import_fs5.existsSync)(fullPath)) {
4764
- if (tryGit(["checkout", ref, "--", file])) {
4765
- console.log(` + ${file} (new from upstream)`);
4766
- added++;
4767
- } else {
4768
- console.warn(` [warn] failed to add new file ${file}`);
4769
- }
4770
- continue;
4771
- }
4772
- const theirContents = gitShowBytes(ref, file);
4773
- if (theirContents === null) {
4774
- console.warn(` [warn] could not read ${file} from ${ref} \u2014 skipping.`);
4775
- continue;
4776
- }
4777
- (0, import_fs5.writeFileSync)(theirsTmp, theirContents);
4778
- const baseContents = gitShowBytes(baseRef, file);
4779
- (0, import_fs5.writeFileSync)(baseTmp, baseContents ?? new Uint8Array(0));
4780
- try {
4781
- (0, import_child_process2.execFileSync)("git", ["merge-file", fullPath, baseTmp, theirsTmp], {
4782
- cwd: process.cwd(),
4783
- stdio: ["ignore", "pipe", "pipe"]
4784
- });
4785
- runGit(["add", "--", file], { silent: true });
4786
- merged++;
4787
- } catch (err) {
4788
- const status = err.status;
4789
- if (typeof status === "number" && status > 0) {
4790
- conflictedFiles.push(file);
4791
- console.warn(
4792
- ` ! ${file} (${status} conflict${status > 1 ? "s" : ""})`
4793
- );
4794
- } else {
4795
- conflictedFiles.push(file);
4796
- console.warn(
4797
- ` [warn] merge failed for ${file} (likely binary or unreadable) \u2014 left untouched.`
4798
- );
4799
- }
4800
- }
4801
- }
4802
- console.log(
4803
- `
4804
- Done. ${added} added, ${merged} merged cleanly, ${conflictedFiles.length} with conflicts.`
4805
- );
4806
- if (conflictedFiles.length > 0) {
4807
- console.warn(
4808
- `
4809
- NOTE: ${conflictedFiles.length} file(s) under '${INFRASTRUCTURE_DIR}/' have merge conflicts that you must resolve manually.
4810
- Look for the standard conflict markers (<<<<<<<, =======, >>>>>>>) in:
4811
- ` + conflictedFiles.map((f) => ` - ${f}`).join("\n") + `
4812
- After resolving, stage the fixes with: git add ${INFRASTRUCTURE_DIR}/`
4813
- );
4814
- }
4815
- } finally {
4816
- if (tryGit(["remote", "remove", TEMP_REMOTE2])) {
4817
- console.log(` Removed temporary remote '${TEMP_REMOTE2}'.`);
4818
- }
3543
+ async function runUpgrade(ccwd) {
3544
+ if (ccwd) {
3545
+ console.log("Country config working directory:", ccwd);
3546
+ cwd = ccwd;
4819
3547
  }
4820
- }
4821
-
4822
- // src/migrations/v2.0/delete-infrastructure-directory.ts
4823
- var import_fs6 = require("fs");
4824
- var import_path25 = require("path");
4825
- var INFRASTRUCTURE_DIR2 = "infrastructure";
4826
- async function main26() {
4827
- const fullPath = (0, import_path25.join)(process.cwd(), INFRASTRUCTURE_DIR2);
4828
- if (!(0, import_fs6.existsSync)(fullPath)) {
3548
+ if (!ccwd) {
4829
3549
  console.log(
4830
- `'${INFRASTRUCTURE_DIR2}/' not found in ${process.cwd()} \u2014 nothing to delete.`
3550
+ "Will use current working directory as country config working directory."
4831
3551
  );
4832
- return;
3552
+ cwd = process.cwd();
4833
3553
  }
4834
- console.log(`Deleting '${INFRASTRUCTURE_DIR2}/'...
4835
- `);
4836
- assertIsGitRepo();
4837
- runGit(["rm", "-rf", "--ignore-unmatch", "--", `${INFRASTRUCTURE_DIR2}/`], {
4838
- silent: true
4839
- });
4840
- console.log(` Staged deletion of tracked files under '${INFRASTRUCTURE_DIR2}/'.`);
4841
- if ((0, import_fs6.existsSync)(fullPath)) {
4842
- (0, import_fs6.rmSync)(fullPath, { recursive: true, force: true });
4843
- console.log(` Removed remaining untracked files under '${INFRASTRUCTURE_DIR2}/'.`);
4844
- }
4845
- console.log(
4846
- `
4847
- Done. Review the staged deletion with: git diff --cached -- '${INFRASTRUCTURE_DIR2}/'`
4848
- );
4849
- }
4850
-
4851
- // src/migrations/v2.0/index.ts
4852
- async function runUpgrade(dockerSwarm) {
4853
- await main18();
3554
+ await main13();
4854
3555
  await main();
4855
3556
  await main2();
4856
3557
  await main3();
@@ -4863,20 +3564,9 @@ async function runUpgrade(dockerSwarm) {
4863
3564
  await main10();
4864
3565
  await main11();
4865
3566
  await main12();
4866
- await main13();
4867
3567
  await main14();
4868
3568
  await main15();
4869
3569
  await main16();
4870
- await main19();
4871
- await main20();
4872
- await main21();
4873
- await main22();
4874
- await main23();
4875
- await main24();
4876
3570
  await main17();
4877
- if (dockerSwarm) {
4878
- await main25();
4879
- } else {
4880
- await main26();
4881
- }
3571
+ await main18();
4882
3572
  }