@opencrvs/toolkit 2.0.0-rc.21b1468 → 2.0.0-rc.2271200

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 (29) hide show
  1. package/dist/cli.js +185 -180
  2. package/dist/commons/api/router.d.ts +2411 -11637
  3. package/dist/commons/conditionals/validate.d.ts +1 -0
  4. package/dist/commons/events/ActionInput.d.ts +72 -0
  5. package/dist/commons/events/Draft.d.ts +2 -0
  6. package/dist/commons/events/utils.d.ts +1 -1
  7. package/dist/events/index.js +15 -14
  8. package/dist/migrations/v2.0/checkout-upstream-files.d.ts +1 -1
  9. package/dist/migrations/v2.0/checkout-upstream-files.d.ts.map +1 -1
  10. package/dist/migrations/v2.0/checkout-upstream-files.js +1 -2
  11. package/dist/migrations/v2.0/delete-infrastructure-directory.d.ts +9 -1
  12. package/dist/migrations/v2.0/delete-infrastructure-directory.d.ts.map +1 -1
  13. package/dist/migrations/v2.0/delete-infrastructure-directory.js +66 -20
  14. package/dist/migrations/v2.0/index.d.ts +5 -3
  15. package/dist/migrations/v2.0/index.d.ts.map +1 -1
  16. package/dist/migrations/v2.0/index.js +183 -178
  17. package/dist/migrations/v2.0/merge-infrastructure-directory.d.ts +11 -1
  18. package/dist/migrations/v2.0/merge-infrastructure-directory.d.ts.map +1 -1
  19. package/dist/migrations/v2.0/merge-infrastructure-directory.js +17 -16
  20. package/dist/migrations/v2.0/migrate-workqueue-configs.d.ts.map +1 -1
  21. package/dist/migrations/v2.0/migrate-workqueue-configs.js +140 -59
  22. package/dist/notification/index.js +2 -0
  23. package/opencrvs-toolkit-2.0.0-rc.2271200.tgz +0 -0
  24. package/package.json +1 -1
  25. package/tsconfig.tsbuildinfo +1 -1
  26. package/dist/migrations/v2.0/fix-action-confirmation-handler-type.d.ts +0 -3
  27. package/dist/migrations/v2.0/fix-action-confirmation-handler-type.d.ts.map +0 -1
  28. package/dist/migrations/v2.0/fix-action-confirmation-handler-type.js +0 -113
  29. package/opencrvs-toolkit-2.0.0-rc.21b1468.tgz +0 -0
package/dist/cli.js CHANGED
@@ -1883,9 +1883,9 @@ function updateRouteHandlers(sourceFiles, group, srcDir, relCwd) {
1883
1883
  }
1884
1884
  return replacedCount;
1885
1885
  }
1886
- function resolveConfigChain(configObj, path24) {
1886
+ function resolveConfigChain(configObj, path23) {
1887
1887
  let current = configObj;
1888
- for (const key of path24) {
1888
+ for (const key of path23) {
1889
1889
  if (!import_ts_morph10.Node.isObjectLiteralExpression(current)) return null;
1890
1890
  const prop = current.getProperty(key);
1891
1891
  if (!prop || !import_ts_morph10.Node.isPropertyAssignment(prop)) return null;
@@ -3674,6 +3674,10 @@ var ACTION_PROPERTY_NAME2 = "action";
3674
3674
  var CONDITIONALS_PROPERTY_NAME = "conditionals";
3675
3675
  var TYPE_PROPERTY_NAME7 = "type";
3676
3676
  var SLUG_PROPERTY_NAME = "slug";
3677
+ var READ_ACTION_TYPE = "READ";
3678
+ var ACTION_TYPE_IMPORT_NAME = "ActionType";
3679
+ var TOOLKIT_EVENTS_MODULE2 = "@opencrvs/toolkit/events";
3680
+ var READ_ACTION_FALLBACK_INITIALIZER = `{ type: ${ACTION_TYPE_IMPORT_NAME}.${READ_ACTION_TYPE} }`;
3677
3681
  var SUPPORTED_WORKQUEUE_ACTION_TYPES = /* @__PURE__ */ new Set([
3678
3682
  "READ",
3679
3683
  "DELETE",
@@ -3721,91 +3725,137 @@ function isUnsupportedActionType(action) {
3721
3725
  }
3722
3726
  return !SUPPORTED_WORKQUEUE_ACTION_TYPES.has(typeName);
3723
3727
  }
3724
- function migrateWorkqueueActions(workqueue, relPath) {
3725
- const actionsProperty = workqueue.getProperty(ACTIONS_PROPERTY_NAME5);
3726
- if (!actionsProperty || !import_ts_morph17.Node.isPropertyAssignment(actionsProperty)) {
3727
- return 0;
3728
- }
3729
- const actionsInitializer = actionsProperty.getInitializer();
3730
- if (!actionsInitializer || !import_ts_morph17.Node.isArrayLiteralExpression(actionsInitializer)) {
3731
- return 0;
3728
+ function ensureValidAction(workqueue, relPath) {
3729
+ const workqueueLabel = getWorkqueueLabel(workqueue);
3730
+ const actionProperty = workqueue.getProperty(ACTION_PROPERTY_NAME2);
3731
+ if (actionProperty && import_ts_morph17.Node.isPropertyAssignment(actionProperty)) {
3732
+ const initializer = actionProperty.getInitializer();
3733
+ if (initializer && import_ts_morph17.Node.isObjectLiteralExpression(initializer)) {
3734
+ if (!isUnsupportedActionType(initializer)) {
3735
+ return { changed: false, usedReadFallback: false };
3736
+ }
3737
+ actionProperty.set({
3738
+ name: ACTION_PROPERTY_NAME2,
3739
+ initializer: READ_ACTION_FALLBACK_INITIALIZER
3740
+ });
3741
+ console.log(
3742
+ ` [${relPath}] Replaced unsupported 'action' type with '${ACTION_TYPE_IMPORT_NAME}.${READ_ACTION_TYPE}' on workqueue '${workqueueLabel}'`
3743
+ );
3744
+ return { changed: true, usedReadFallback: true };
3745
+ }
3732
3746
  }
3747
+ workqueue.addPropertyAssignment({
3748
+ name: ACTION_PROPERTY_NAME2,
3749
+ initializer: READ_ACTION_FALLBACK_INITIALIZER
3750
+ });
3751
+ console.log(
3752
+ ` [${relPath}] Added default 'action: ${READ_ACTION_FALLBACK_INITIALIZER}' to workqueue '${workqueueLabel}'`
3753
+ );
3754
+ return { changed: true, usedReadFallback: true };
3755
+ }
3756
+ function migrateWorkqueueActions(workqueue, relPath) {
3733
3757
  const workqueueLabel = getWorkqueueLabel(workqueue);
3734
- const existingActionProperty = workqueue.getProperty(ACTION_PROPERTY_NAME2);
3735
- if (existingActionProperty) {
3736
- if (import_ts_morph17.Node.isPropertyAssignment(existingActionProperty)) {
3737
- const existingActionInitializer = existingActionProperty.getInitializer();
3738
- if (existingActionInitializer && import_ts_morph17.Node.isObjectLiteralExpression(existingActionInitializer)) {
3739
- const conditionalsProperty2 = existingActionInitializer.getProperty(
3740
- CONDITIONALS_PROPERTY_NAME
3758
+ const actionsProperty = workqueue.getProperty(ACTIONS_PROPERTY_NAME5);
3759
+ let actionsArrayMigrated = false;
3760
+ if (actionsProperty && import_ts_morph17.Node.isPropertyAssignment(actionsProperty)) {
3761
+ const actionsInitializer = actionsProperty.getInitializer();
3762
+ if (actionsInitializer && import_ts_morph17.Node.isArrayLiteralExpression(actionsInitializer)) {
3763
+ const existingActionProperty = workqueue.getProperty(ACTION_PROPERTY_NAME2);
3764
+ if (existingActionProperty) {
3765
+ if (import_ts_morph17.Node.isPropertyAssignment(existingActionProperty)) {
3766
+ const existingActionInitializer = existingActionProperty.getInitializer();
3767
+ if (existingActionInitializer && import_ts_morph17.Node.isObjectLiteralExpression(existingActionInitializer)) {
3768
+ const conditionalsProperty = existingActionInitializer.getProperty(
3769
+ CONDITIONALS_PROPERTY_NAME
3770
+ );
3771
+ if (conditionalsProperty) {
3772
+ conditionalsProperty.remove();
3773
+ console.log(
3774
+ ` [${relPath}] Removed deprecated 'conditionals' from 'action' on workqueue '${workqueueLabel}'`
3775
+ );
3776
+ }
3777
+ }
3778
+ }
3779
+ actionsProperty.remove();
3780
+ console.log(
3781
+ ` [${relPath}] Removed deprecated 'actions' from workqueue '${workqueueLabel}' (existing 'action' kept)`
3741
3782
  );
3742
- if (conditionalsProperty2) {
3743
- conditionalsProperty2.remove();
3783
+ actionsArrayMigrated = true;
3784
+ } else {
3785
+ const actionCandidates = actionsInitializer.getElements().filter(
3786
+ (element) => import_ts_morph17.Node.isObjectLiteralExpression(element)
3787
+ );
3788
+ if (actionCandidates.length === 0) {
3789
+ actionsProperty.remove();
3744
3790
  console.log(
3745
- ` [${relPath}] Removed deprecated 'conditionals' from 'action' on workqueue '${workqueueLabel}'`
3791
+ ` [${relPath}] Removed empty 'actions' from workqueue '${workqueueLabel}'`
3746
3792
  );
3747
- }
3748
- if (isUnsupportedActionType(existingActionInitializer)) {
3749
- existingActionProperty.remove();
3750
- console.log(
3751
- ` [${relPath}] Removed unsupported 'action' type on workqueue '${workqueueLabel}'`
3793
+ actionsArrayMigrated = true;
3794
+ } else {
3795
+ if (actionCandidates.length > 1) {
3796
+ const droppedCount = actionCandidates.length - 1;
3797
+ console.warn(
3798
+ ` [${relPath}] Workqueue '${workqueueLabel}' has ${actionCandidates.length} actions; keeping first as 'action' and dropping ${droppedCount} extra action(s)`
3799
+ );
3800
+ }
3801
+ const conditionalsProperty = actionCandidates[0].getProperty(
3802
+ CONDITIONALS_PROPERTY_NAME
3752
3803
  );
3804
+ if (conditionalsProperty) {
3805
+ conditionalsProperty.remove();
3806
+ console.log(
3807
+ ` [${relPath}] Removed deprecated 'conditionals' from migrated 'action' on workqueue '${workqueueLabel}'`
3808
+ );
3809
+ }
3810
+ if (isUnsupportedActionType(actionCandidates[0])) {
3811
+ actionsProperty.remove();
3812
+ console.log(
3813
+ ` [${relPath}] Removed deprecated 'actions' from workqueue '${workqueueLabel}' because action type is unsupported`
3814
+ );
3815
+ actionsArrayMigrated = true;
3816
+ } else {
3817
+ const firstActionText = actionCandidates[0].getText();
3818
+ workqueue.addPropertyAssignment({
3819
+ name: ACTION_PROPERTY_NAME2,
3820
+ initializer: firstActionText
3821
+ });
3822
+ actionsProperty.remove();
3823
+ console.log(
3824
+ ` [${relPath}] Replaced 'actions' with 'action' on workqueue '${workqueueLabel}'`
3825
+ );
3826
+ actionsArrayMigrated = true;
3827
+ }
3753
3828
  }
3754
3829
  }
3755
3830
  }
3756
- actionsProperty.remove();
3757
- console.log(
3758
- ` [${relPath}] Removed deprecated 'actions' from workqueue '${workqueueLabel}' (existing 'action' kept)`
3759
- );
3760
- return 1;
3761
- }
3762
- const actionCandidates = actionsInitializer.getElements().filter(
3763
- (element) => import_ts_morph17.Node.isObjectLiteralExpression(element)
3764
- );
3765
- if (actionCandidates.length === 0) {
3766
- actionsProperty.remove();
3767
- console.log(
3768
- ` [${relPath}] Removed empty 'actions' from workqueue '${workqueueLabel}'`
3769
- );
3770
- return 1;
3771
- }
3772
- if (actionCandidates.length > 1) {
3773
- const droppedCount = actionCandidates.length - 1;
3774
- console.warn(
3775
- ` [${relPath}] Workqueue '${workqueueLabel}' has ${actionCandidates.length} actions; keeping first as 'action' and dropping ${droppedCount} extra action(s)`
3776
- );
3777
3831
  }
3778
- const conditionalsProperty = actionCandidates[0].getProperty(
3779
- CONDITIONALS_PROPERTY_NAME
3832
+ const fallback = ensureValidAction(workqueue, relPath);
3833
+ return {
3834
+ changed: actionsArrayMigrated || fallback.changed,
3835
+ usedReadFallback: fallback.usedReadFallback
3836
+ };
3837
+ }
3838
+ function ensureActionTypeImport(sourceFile) {
3839
+ const existingImport = sourceFile.getImportDeclaration(
3840
+ (decl) => decl.getModuleSpecifierValue() === TOOLKIT_EVENTS_MODULE2
3780
3841
  );
3781
- if (conditionalsProperty) {
3782
- conditionalsProperty.remove();
3783
- console.log(
3784
- ` [${relPath}] Removed deprecated 'conditionals' from migrated 'action' on workqueue '${workqueueLabel}'`
3785
- );
3786
- }
3787
- if (isUnsupportedActionType(actionCandidates[0])) {
3788
- actionsProperty.remove();
3789
- console.log(
3790
- ` [${relPath}] Removed deprecated 'actions' from workqueue '${workqueueLabel}' because action type is unsupported`
3791
- );
3792
- return 1;
3842
+ if (existingImport) {
3843
+ const alreadyImported = existingImport.getNamedImports().some((ni) => ni.getName() === ACTION_TYPE_IMPORT_NAME);
3844
+ if (!alreadyImported) {
3845
+ existingImport.addNamedImport(ACTION_TYPE_IMPORT_NAME);
3846
+ }
3847
+ return;
3793
3848
  }
3794
- const firstActionText = actionCandidates[0].getText();
3795
- workqueue.addPropertyAssignment({
3796
- name: ACTION_PROPERTY_NAME2,
3797
- initializer: firstActionText
3849
+ sourceFile.addImportDeclaration({
3850
+ moduleSpecifier: TOOLKIT_EVENTS_MODULE2,
3851
+ namedImports: [ACTION_TYPE_IMPORT_NAME]
3798
3852
  });
3799
- actionsProperty.remove();
3800
- console.log(
3801
- ` [${relPath}] Replaced 'actions' with 'action' on workqueue '${workqueueLabel}'`
3802
- );
3803
- return 1;
3804
3853
  }
3805
3854
  function processFile13(filePath, project) {
3806
3855
  const sourceFile = project.getSourceFile(filePath);
3807
3856
  if (!sourceFile) return 0;
3808
3857
  let migratedWorkqueues = 0;
3858
+ let needsActionTypeImport = false;
3809
3859
  const relPath = import_path18.default.relative(process.cwd(), filePath);
3810
3860
  const callExpressions = sourceFile.getDescendantsOfKind(
3811
3861
  import_ts_morph17.SyntaxKind.CallExpression
@@ -3821,9 +3871,14 @@ function processFile13(filePath, project) {
3821
3871
  if (!import_ts_morph17.Node.isArrayLiteralExpression(workqueuesArg)) continue;
3822
3872
  for (const element of workqueuesArg.getElements()) {
3823
3873
  if (!import_ts_morph17.Node.isObjectLiteralExpression(element)) continue;
3824
- migratedWorkqueues += migrateWorkqueueActions(element, relPath);
3874
+ const result = migrateWorkqueueActions(element, relPath);
3875
+ if (result.changed) migratedWorkqueues++;
3876
+ if (result.usedReadFallback) needsActionTypeImport = true;
3825
3877
  }
3826
3878
  }
3879
+ if (needsActionTypeImport) {
3880
+ ensureActionTypeImport(sourceFile);
3881
+ }
3827
3882
  return migratedWorkqueues;
3828
3883
  }
3829
3884
  async function main18() {
@@ -4158,7 +4213,7 @@ Saved ${handlerRelPath}.`);
4158
4213
  // src/migrations/v2.0/checkout-upstream-files.ts
4159
4214
  var import_child_process = require("child_process");
4160
4215
  var UPSTREAM_URL = "https://github.com/opencrvs/opencrvs-countryconfig.git";
4161
- var UPSTREAM_BRANCH = "develop";
4216
+ var UPSTREAM_BRANCH = "release-v2.0.0";
4162
4217
  var TEMP_REMOTE = "opencrvs-upgrade-v19-v20-codemod";
4163
4218
  var FILES_TO_CHECKOUT = [
4164
4219
  "src/analytics/analytics.ts",
@@ -4697,9 +4752,9 @@ var import_path24 = require("path");
4697
4752
  var TEMP_REMOTE2 = "opencrvs-upgrade-v19-v20-codemod-merge-infra";
4698
4753
  var INFRASTRUCTURE_DIR = "infrastructure";
4699
4754
  var BASE_BRANCH = "release-v1.9";
4700
- function gitShowBytes(ref, path24) {
4755
+ function gitShowBytes(ref, path23) {
4701
4756
  try {
4702
- const buf = (0, import_child_process2.execFileSync)("git", ["show", `${ref}:${path24}`], {
4757
+ const buf = (0, import_child_process2.execFileSync)("git", ["show", `${ref}:${path23}`], {
4703
4758
  cwd: process.cwd(),
4704
4759
  stdio: ["ignore", "pipe", "pipe"]
4705
4760
  });
@@ -4708,9 +4763,13 @@ function gitShowBytes(ref, path24) {
4708
4763
  return null;
4709
4764
  }
4710
4765
  }
4711
- async function main25() {
4766
+ async function main25({
4767
+ subdirs = []
4768
+ } = {}) {
4769
+ const pathspecs = subdirs.length > 0 ? subdirs.map((s) => `${INFRASTRUCTURE_DIR}/${s}/`) : [`${INFRASTRUCTURE_DIR}/`];
4770
+ const scopeLabel = pathspecs.map((p) => `'${p}'`).join(", ");
4712
4771
  console.log(
4713
- `Merging '${INFRASTRUCTURE_DIR}/' from ${UPSTREAM_URL}@${UPSTREAM_BRANCH} (base: ${BASE_BRANCH})...
4772
+ `Merging ${scopeLabel} from ${UPSTREAM_URL}@${UPSTREAM_BRANCH} (base: ${BASE_BRANCH})...
4714
4773
  `
4715
4774
  );
4716
4775
  assertIsGitRepo();
@@ -4725,20 +4784,12 @@ async function main25() {
4725
4784
  const ref = `${TEMP_REMOTE2}/${UPSTREAM_BRANCH}`;
4726
4785
  const baseRef = `${TEMP_REMOTE2}/${BASE_BRANCH}`;
4727
4786
  const upstreamFiles = runGit(
4728
- [
4729
- "ls-tree",
4730
- "-r",
4731
- "--name-only",
4732
- "-z",
4733
- ref,
4734
- "--",
4735
- `${INFRASTRUCTURE_DIR}/`
4736
- ],
4787
+ ["ls-tree", "-r", "--name-only", "-z", ref, "--", ...pathspecs],
4737
4788
  { silent: true }
4738
4789
  ).split("\0").filter(Boolean);
4739
4790
  if (upstreamFiles.length === 0) {
4740
4791
  console.log(
4741
- ` No files found under '${INFRASTRUCTURE_DIR}/' on ${ref}. Nothing to merge.`
4792
+ ` No files found under ${scopeLabel} on ${ref}. Nothing to merge.`
4742
4793
  );
4743
4794
  return;
4744
4795
  }
@@ -4813,7 +4864,9 @@ async function main25() {
4813
4864
  var import_fs6 = require("fs");
4814
4865
  var import_path25 = require("path");
4815
4866
  var INFRASTRUCTURE_DIR2 = "infrastructure";
4816
- async function main26() {
4867
+ async function main26({
4868
+ keep = []
4869
+ } = {}) {
4817
4870
  const fullPath = (0, import_path25.join)(process.cwd(), INFRASTRUCTURE_DIR2);
4818
4871
  if (!(0, import_fs6.existsSync)(fullPath)) {
4819
4872
  console.log(
@@ -4821,112 +4874,64 @@ async function main26() {
4821
4874
  );
4822
4875
  return;
4823
4876
  }
4824
- console.log(`Deleting '${INFRASTRUCTURE_DIR2}/'...
4825
- `);
4826
4877
  assertIsGitRepo();
4827
- runGit(["rm", "-rf", "--ignore-unmatch", "--", `${INFRASTRUCTURE_DIR2}/`], {
4828
- silent: true
4829
- });
4830
- console.log(` Staged deletion of tracked files under '${INFRASTRUCTURE_DIR2}/'.`);
4831
- if ((0, import_fs6.existsSync)(fullPath)) {
4832
- (0, import_fs6.rmSync)(fullPath, { recursive: true, force: true });
4833
- console.log(` Removed remaining untracked files under '${INFRASTRUCTURE_DIR2}/'.`);
4834
- }
4835
- console.log(
4836
- `
4878
+ if (keep.length === 0) {
4879
+ console.log(`Deleting '${INFRASTRUCTURE_DIR2}/'...
4880
+ `);
4881
+ runGit(["rm", "-rf", "--ignore-unmatch", "--", `${INFRASTRUCTURE_DIR2}/`], {
4882
+ silent: true
4883
+ });
4884
+ console.log(
4885
+ ` Staged deletion of tracked files under '${INFRASTRUCTURE_DIR2}/'.`
4886
+ );
4887
+ if ((0, import_fs6.existsSync)(fullPath)) {
4888
+ (0, import_fs6.rmSync)(fullPath, { recursive: true, force: true });
4889
+ console.log(
4890
+ ` Removed remaining untracked files under '${INFRASTRUCTURE_DIR2}/'.`
4891
+ );
4892
+ }
4893
+ console.log(
4894
+ `
4837
4895
  Done. Review the staged deletion with: git diff --cached -- '${INFRASTRUCTURE_DIR2}/'`
4838
- );
4839
- }
4840
-
4841
- // src/migrations/v2.0/fix-action-confirmation-handler-type.ts
4842
- var import_ts_morph22 = require("ts-morph");
4843
- var import_path26 = __toESM(require("path"));
4844
- var TARGET_FUNCTION_NAME = "acceptRequestedRegistration";
4845
- var ACTION_PARAMETER_NAME = "action";
4846
- var OLD_TYPE = "ActionInput";
4847
- var NEW_TYPE = "Extract<ActionInput, { type?: 'REGISTER' }>";
4848
- function isTargetFunctionParameter(parameter) {
4849
- const functionDeclaration = parameter.getFirstAncestorByKind(
4850
- import_ts_morph22.SyntaxKind.FunctionDeclaration
4851
- );
4852
- if (functionDeclaration?.getName() === TARGET_FUNCTION_NAME) {
4853
- return true;
4896
+ );
4897
+ return;
4854
4898
  }
4855
- const arrowFunction = parameter.getFirstAncestorByKind(
4856
- import_ts_morph22.SyntaxKind.ArrowFunction
4857
- );
4858
- const variableDeclaration = arrowFunction?.getFirstAncestorByKind(
4859
- import_ts_morph22.SyntaxKind.VariableDeclaration
4899
+ const keepSet = new Set(keep);
4900
+ console.log(
4901
+ `Deleting contents of '${INFRASTRUCTURE_DIR2}/' except: ${[...keepSet].map((name) => `'${name}'`).join(", ")}
4902
+ `
4860
4903
  );
4861
- return variableDeclaration?.getName() === TARGET_FUNCTION_NAME;
4862
- }
4863
- function processFile14(filePath, project) {
4864
- const sourceFile = project.getSourceFile(filePath);
4865
- if (!sourceFile) return 0;
4866
- let updatedCount = 0;
4867
- const parameters = sourceFile.getDescendantsOfKind(import_ts_morph22.SyntaxKind.Parameter);
4868
- for (const parameter of parameters) {
4869
- if (parameter.getName() !== ACTION_PARAMETER_NAME) {
4904
+ const topLevelEntries = (0, import_fs6.readdirSync)(fullPath, { withFileTypes: true });
4905
+ let deleted = 0;
4906
+ for (const entry of topLevelEntries) {
4907
+ if (keepSet.has(entry.name)) {
4908
+ console.log(` Keeping '${INFRASTRUCTURE_DIR2}/${entry.name}'.`);
4870
4909
  continue;
4871
4910
  }
4872
- if (!isTargetFunctionParameter(parameter)) {
4873
- continue;
4874
- }
4875
- const typeNode = parameter.getTypeNode();
4876
- if (!typeNode) continue;
4877
- if (typeNode.getText() !== OLD_TYPE) {
4878
- continue;
4879
- }
4880
- parameter.setType(NEW_TYPE);
4881
- updatedCount++;
4882
- console.log(
4883
- ` [${import_path26.default.relative(process.cwd(), filePath)}] Updated '${ACTION_PARAMETER_NAME}' parameter type to ${NEW_TYPE}`
4884
- );
4885
- }
4886
- return updatedCount;
4887
- }
4888
- async function main27() {
4889
- const srcDir = import_path26.default.join(process.cwd(), "src");
4890
- console.log(`Scanning for action confirmation handler types in: ${srcDir}
4891
- `);
4892
- const project = new import_ts_morph22.Project({
4893
- tsConfigFilePath: import_path26.default.resolve(srcDir, "../tsconfig.json"),
4894
- skipAddingFilesFromTsConfig: false
4895
- });
4896
- const sourceFiles = project.getSourceFiles().filter((sf) => {
4897
- const filePath = sf.getFilePath();
4898
- return filePath.includes("/src/") && !filePath.includes("/node_modules/");
4899
- });
4900
- let totalUpdated = 0;
4901
- const modifiedFiles = [];
4902
- for (const sourceFile of sourceFiles) {
4903
- const filePath = sourceFile.getFilePath();
4904
- const updated = processFile14(filePath, project);
4905
- if (updated > 0) {
4906
- totalUpdated += updated;
4907
- modifiedFiles.push(filePath);
4911
+ const relPath = `${INFRASTRUCTURE_DIR2}/${entry.name}${entry.isDirectory() ? "/" : ""}`;
4912
+ runGit(["rm", "-rf", "--ignore-unmatch", "--", relPath], { silent: true });
4913
+ const fullEntryPath = (0, import_path25.join)(fullPath, entry.name);
4914
+ if ((0, import_fs6.existsSync)(fullEntryPath)) {
4915
+ (0, import_fs6.rmSync)(fullEntryPath, { recursive: true, force: true });
4908
4916
  }
4917
+ console.log(` Deleted '${relPath}'.`);
4918
+ deleted++;
4909
4919
  }
4910
- if (modifiedFiles.length === 0) {
4911
- console.log(
4912
- `No '${ACTION_PARAMETER_NAME}: ${OLD_TYPE}' parameter signatures found. Nothing to do.`
4920
+ const presentNames = new Set(topLevelEntries.map((e) => e.name));
4921
+ const missingKeeps = [...keepSet].filter((name) => !presentNames.has(name));
4922
+ if (missingKeeps.length > 0) {
4923
+ console.warn(
4924
+ ` [warn] Requested to keep ${missingKeeps.map((n) => `'${n}'`).join(", ")} but they don't exist under '${INFRASTRUCTURE_DIR2}/'.`
4913
4925
  );
4914
- return;
4915
- }
4916
- console.log(`
4917
- Saving ${modifiedFiles.length} modified file(s)...`);
4918
- for (const filePath of modifiedFiles) {
4919
- const sourceFile = project.getSourceFileOrThrow(filePath);
4920
- await sourceFile.save();
4921
- console.log(` Saved: ${import_path26.default.relative(process.cwd(), filePath)}`);
4922
4926
  }
4923
4927
  console.log(
4924
4928
  `
4925
- Done. Updated ${totalUpdated} '${ACTION_PARAMETER_NAME}' parameter type annotation(s).`
4929
+ Done. Deleted ${deleted} top-level entr${deleted === 1 ? "y" : "ies"}. Review the staged deletions with: git diff --cached -- '${INFRASTRUCTURE_DIR2}/'`
4926
4930
  );
4927
4931
  }
4928
4932
 
4929
4933
  // src/migrations/v2.0/index.ts
4934
+ var NON_SWARM_INFRA_SUBDIRS = ["postgres", "metabase"];
4930
4935
  async function runUpgrade(dockerSwarm) {
4931
4936
  await main18();
4932
4937
  await main();
@@ -4948,7 +4953,6 @@ async function runUpgrade(dockerSwarm) {
4948
4953
  await main19();
4949
4954
  await main20();
4950
4955
  await main21();
4951
- await main27();
4952
4956
  await main22();
4953
4957
  await main23();
4954
4958
  await main24();
@@ -4956,7 +4960,8 @@ async function runUpgrade(dockerSwarm) {
4956
4960
  if (dockerSwarm) {
4957
4961
  await main25();
4958
4962
  } else {
4959
- await main26();
4963
+ await main26({ keep: NON_SWARM_INFRA_SUBDIRS });
4964
+ await main25({ subdirs: NON_SWARM_INFRA_SUBDIRS });
4960
4965
  }
4961
4966
  }
4962
4967
 
@@ -4985,7 +4990,7 @@ Options:
4985
4990
  'infrastructure/' directory is deleted (default).
4986
4991
  -h, --help Show this message.
4987
4992
  `.trim();
4988
- function main28() {
4993
+ function main27() {
4989
4994
  const command = args[0];
4990
4995
  if (!command || command === "--help" || command === "-h") {
4991
4996
  console.log(USAGE);
@@ -5060,4 +5065,4 @@ function handleCheckTranslations() {
5060
5065
  console.warn("This command is not implemented yet!");
5061
5066
  process.exit(1);
5062
5067
  }
5063
- main28();
5068
+ main27();