{"version":3,"file":"client-sdk-types.mjs","names":[],"sources":["../../../src/codemods/v1/client-sdk-types.ts"],"sourcesContent":["import { createTransformer } from '../lib/create-transformer';\n\n/**\n * Renames Client SDK types from Get* to List* pattern.\n * This aligns type names with the method naming convention.\n *\n * Before:\n * import type { GetWorkflowRunsParams, GetMemoryThreadParams } from '@mastra/client-js';\n *\n * After:\n * import type { ListWorkflowRunsParams, ListMemoryThreadsParams } from '@mastra/client-js';\n */\nexport default createTransformer((fileInfo, api, options, context) => {\n  const { j, root } = context;\n\n  // Map of old type names to new type names\n  const typeRenames: Record<string, string> = {\n    GetWorkflowRunsParams: 'ListWorkflowRunsParams',\n    GetWorkflowRunsResponse: 'ListWorkflowRunsResponse',\n    GetMemoryThreadParams: 'ListMemoryThreadsParams',\n  };\n\n  // Track which types were actually imported from @mastra/client-js\n  const importedTypes = new Set<string>();\n\n  // Transform import specifiers and track what was imported\n  root\n    .find(j.ImportDeclaration)\n    .filter(path => {\n      const source = path.value.source.value;\n      return typeof source === 'string' && source === '@mastra/client-js';\n    })\n    .forEach(path => {\n      path.value.specifiers?.forEach(specifier => {\n        if (specifier.type === 'ImportSpecifier' && specifier.imported.type === 'Identifier') {\n          const oldName = specifier.imported.name;\n          const newName = typeRenames[oldName];\n\n          if (newName) {\n            // Track the local name that was imported (could be aliased)\n            const localName = typeof specifier.local?.name === 'string' ? specifier.local.name : oldName;\n            importedTypes.add(localName);\n\n            specifier.imported.name = newName;\n            // Also update the local name if it matches the imported name\n            if (specifier.local && specifier.local.name === oldName) {\n              specifier.local.name = newName;\n            }\n            context.hasChanges = true;\n          }\n        }\n      });\n    });\n\n  // Only transform type references if they were imported from @mastra/client-js\n  if (importedTypes.size > 0) {\n    root.find(j.Identifier).forEach(path => {\n      const name = path.value.name;\n\n      // Only transform if this identifier was imported from @mastra/client-js\n      if (importedTypes.has(name)) {\n        const newName = typeRenames[name];\n\n        if (newName) {\n          // Check if this identifier is a type reference (not a variable declaration)\n          const parent = path.parent.value;\n\n          // Only rename if it's used as a type reference, not a variable name\n          if (parent.type === 'TSTypeReference' || parent.type === 'TSTypeAnnotation') {\n            path.value.name = newName;\n            context.hasChanges = true;\n          }\n        }\n      }\n    });\n  }\n\n  if (context.hasChanges) {\n    context.messages.push('Renamed Client SDK types from Get* to List* pattern');\n  }\n});\n"],"mappings":";;;;;;;;;;;;AAYA,IAAA,2BAAe,mBAAmB,UAAU,KAAK,SAAS,YAAY;CACpE,MAAM,EAAE,GAAG,SAAS;CAGpB,MAAM,cAAsC;EAC1C,uBAAuB;EACvB,yBAAyB;EACzB,uBAAuB;CACzB;CAGA,MAAM,gCAAgB,IAAI,IAAY;CAGtC,KACG,KAAK,EAAE,iBAAiB,CAAC,CACzB,QAAO,SAAQ;EACd,MAAM,SAAS,KAAK,MAAM,OAAO;EACjC,OAAO,OAAO,WAAW,YAAY,WAAW;CAClD,CAAC,CAAC,CACD,SAAQ,SAAQ;EACf,KAAK,MAAM,YAAY,SAAQ,cAAa;GAC1C,IAAI,UAAU,SAAS,qBAAqB,UAAU,SAAS,SAAS,cAAc;IACpF,MAAM,UAAU,UAAU,SAAS;IACnC,MAAM,UAAU,YAAY;IAE5B,IAAI,SAAS;KAEX,MAAM,YAAY,OAAO,UAAU,OAAO,SAAS,WAAW,UAAU,MAAM,OAAO;KACrF,cAAc,IAAI,SAAS;KAE3B,UAAU,SAAS,OAAO;KAE1B,IAAI,UAAU,SAAS,UAAU,MAAM,SAAS,SAC9C,UAAU,MAAM,OAAO;KAEzB,QAAQ,aAAa;IACvB;GACF;EACF,CAAC;CACH,CAAC;CAGH,IAAI,cAAc,OAAO,GACvB,KAAK,KAAK,EAAE,UAAU,CAAC,CAAC,SAAQ,SAAQ;EACtC,MAAM,OAAO,KAAK,MAAM;EAGxB,IAAI,cAAc,IAAI,IAAI,GAAG;GAC3B,MAAM,UAAU,YAAY;GAE5B,IAAI,SAAS;IAEX,MAAM,SAAS,KAAK,OAAO;IAG3B,IAAI,OAAO,SAAS,qBAAqB,OAAO,SAAS,oBAAoB;KAC3E,KAAK,MAAM,OAAO;KAClB,QAAQ,aAAa;IACvB;GACF;EACF;CACF,CAAC;CAGH,IAAI,QAAQ,YACV,QAAQ,SAAS,KAAK,qDAAqD;AAE/E,CAAC"}