@gql.tada/cli-utils 1.7.1 → 1.7.2

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.
@@ -77,9 +77,9 @@ function resolveModulePath(r, a, t) {
77
77
  return;
78
78
  }
79
79
 
80
- function collectImportsFromSourceFile(r, a, t, i) {
81
- var o = [];
82
- var s = function getTadaOutputPaths(e) {
80
+ function collectImportsFromSourceFile(r, a, t, i, o) {
81
+ var s = [];
82
+ var l = function getTadaOutputPaths(e) {
83
83
  var r = [];
84
84
  if ("schema" in e && e.tadaOutputLocation) {
85
85
  r.push(e.tadaOutputLocation);
@@ -88,7 +88,7 @@ function collectImportsFromSourceFile(r, a, t, i) {
88
88
  }(a);
89
89
  !function visit(a) {
90
90
  if (e.isImportDeclaration(a) && e.isStringLiteral(a.moduleSpecifier)) {
91
- var l = a.moduleSpecifier.text;
91
+ var u = a.moduleSpecifier.text;
92
92
  if (!function isTadaImport(e, r, a) {
93
93
  if (e.startsWith(".")) {
94
94
  var t = n.dirname(r);
@@ -99,27 +99,34 @@ function collectImportsFromSourceFile(r, a, t, i) {
99
99
  }));
100
100
  }
101
101
  return a.some((r => e === r || e.startsWith(r + "/")));
102
- }(l, r.fileName, s)) {
103
- var u = a.getFullText().trim();
102
+ }(u, r.fileName, l)) {
103
+ var c = a.getFullText().trim();
104
104
  if (i) {
105
- var c = t(l, r.fileName, i).replace(/\.ts$/, "").replace(/\.tsx$/, "");
106
- if (c && !c.includes("gql.tada")) {
107
- o.push({
108
- specifier: c,
109
- importClause: u.replace(l, c)
105
+ var p = t(u, r.fileName, i);
106
+ if (o) {
107
+ if (p.endsWith(".ts") || p.endsWith(".tsx")) {
108
+ p = p.replace(/\.ts$/, ".js").replace(/\.tsx$/, ".js");
109
+ }
110
+ } else {
111
+ p = p.replace(/\.ts$/, "").replace(/\.tsx$/, "");
112
+ }
113
+ if (p && !p.includes("gql.tada")) {
114
+ s.push({
115
+ specifier: p,
116
+ importClause: c.replace(u, p)
110
117
  });
111
118
  }
112
119
  } else {
113
- o.push({
114
- specifier: l,
115
- importClause: u
120
+ s.push({
121
+ specifier: u,
122
+ importClause: c
116
123
  });
117
124
  }
118
125
  }
119
126
  }
120
127
  e.forEachChild(a, visit);
121
128
  }(r);
122
- return o;
129
+ return s;
123
130
  }
124
131
 
125
132
  var s = i.expose((async function* _runTurbo(r) {
@@ -172,7 +179,7 @@ var s = i.expose((async function* _runTurbo(r) {
172
179
  var u = c.program.getSourceFile(s);
173
180
  if (u) {
174
181
  var p = Array.isArray(r.turboOutputPath) ? r.turboOutputPath.find((e => e.schemaName === a.schema))?.path : r.turboOutputPath;
175
- var f = collectImportsFromSourceFile(u, r.pluginConfig, n.resolveModuleName.bind(n), p);
182
+ var f = collectImportsFromSourceFile(u, r.pluginConfig, n.resolveModuleName.bind(n), p, !!n.wasOriginallyNodeNext);
176
183
  m.set(s, {
177
184
  absolutePath: s,
178
185
  imports: f
@@ -1 +1 @@
1
- {"version":3,"file":"thread-chunk2.js","sources":["../../src/commands/turbo/thread.ts"],"sourcesContent":["import ts from 'typescript';\nimport * as path from 'node:path';\nimport type { GraphQLSPConfig } from '@gql.tada/internal';\n\nimport { getSchemaNamesFromConfig } from '@gql.tada/internal';\nimport { findAllCallExpressions } from '@0no-co/graphqlsp/api';\n\nimport { programFactory } from '../../ts';\nimport { expose } from '../../threads';\n\nimport type {\n TurboSignal,\n TurboWarning,\n TurboDocument,\n GraphQLSourceFile,\n GraphQLSourceImport,\n TurboPath,\n} from './types';\n\nexport interface TurboParams {\n rootPath: string;\n configPath: string;\n pluginConfig: GraphQLSPConfig;\n turboOutputPath: string | TurboPath[];\n}\n\nfunction traceCallToImportSource(\n callExpression: ts.CallExpression,\n sourceFile: ts.SourceFile,\n program: ts.Program\n): string | undefined {\n const typeChecker = program.getTypeChecker();\n const expression = callExpression.expression;\n\n let identifier: ts.Identifier | undefined;\n if (ts.isIdentifier(expression)) {\n identifier = expression;\n } else if (ts.isPropertyAccessExpression(expression) && ts.isIdentifier(expression.expression)) {\n identifier = expression.expression;\n }\n\n if (!identifier) return undefined;\n\n const symbol = typeChecker.getSymbolAtLocation(identifier);\n if (!symbol || !symbol.declarations) return undefined;\n\n for (const declaration of symbol.declarations) {\n const importDeclaration = findImportDeclaration(declaration);\n if (importDeclaration && ts.isStringLiteral(importDeclaration.moduleSpecifier)) {\n const moduleName = importDeclaration.moduleSpecifier.text;\n return resolveModulePath(moduleName, sourceFile, program);\n }\n }\n\n return undefined;\n}\n\nfunction findImportDeclaration(node: ts.Node): ts.ImportDeclaration | undefined {\n let current: ts.Node | undefined = node;\n\n while (current) {\n if (ts.isImportDeclaration(current)) {\n return current;\n }\n current = current.parent;\n }\n\n return undefined;\n}\n\nfunction resolveModulePath(\n moduleName: string,\n containingFile: ts.SourceFile,\n program: ts.Program\n): string | undefined {\n const compilerOptions = program.getCompilerOptions();\n const host = ts.createCompilerHost(compilerOptions);\n\n const resolved = ts.resolveModuleName(moduleName, containingFile.fileName, compilerOptions, host);\n\n if (resolved.resolvedModule) {\n return resolved.resolvedModule.resolvedFileName;\n }\n\n return undefined;\n}\n\nfunction collectImportsFromSourceFile(\n sourceFile: ts.SourceFile,\n pluginConfig: GraphQLSPConfig,\n resolveModuleName: (importSpecifier: string, fromPath: string, toPath: string) => string,\n turboOutputPath?: string\n): GraphQLSourceImport[] {\n const imports: GraphQLSourceImport[] = [];\n\n const tadaImportPaths = getTadaOutputPaths(pluginConfig);\n\n function visit(node: ts.Node) {\n if (ts.isImportDeclaration(node) && ts.isStringLiteral(node.moduleSpecifier)) {\n const specifier = node.moduleSpecifier.text;\n\n if (!isTadaImport(specifier, sourceFile.fileName, tadaImportPaths)) {\n const importClause = node.getFullText().trim();\n if (turboOutputPath) {\n // Adjust the import specifier to point to the turbo output path\n const adjustedSpecifier = resolveModuleName(\n specifier,\n sourceFile.fileName,\n turboOutputPath\n )\n .replace(/\\.ts$/, '')\n .replace(/\\.tsx$/, '');\n if (adjustedSpecifier && !adjustedSpecifier.includes('gql.tada')) {\n imports.push({\n specifier: adjustedSpecifier,\n importClause: importClause.replace(specifier, adjustedSpecifier),\n });\n }\n } else {\n imports.push({ specifier, importClause });\n }\n }\n }\n ts.forEachChild(node, visit);\n }\n\n visit(sourceFile);\n return imports;\n}\n\nfunction getTadaOutputPaths(pluginConfig: GraphQLSPConfig): string[] {\n const paths: string[] = [];\n\n if ('schema' in pluginConfig && pluginConfig.tadaOutputLocation) {\n paths.push(pluginConfig.tadaOutputLocation);\n } else {\n // Multiple schemas aren't supported in this context\n }\n\n return paths;\n}\n\nfunction isTadaImport(\n importSpecifier: string,\n sourceFilePath: string,\n tadaOutputLocationPaths: string[]\n): boolean {\n if (importSpecifier.startsWith('.')) {\n const sourceDir = path.dirname(sourceFilePath);\n const absoluteImportPath = path.resolve(sourceDir, importSpecifier);\n\n return tadaOutputLocationPaths.some((tadaOutputLocationPath) => {\n const absoluteTadaPath = path.resolve(tadaOutputLocationPath);\n return (\n absoluteImportPath === absoluteTadaPath ||\n absoluteImportPath.startsWith(absoluteTadaPath + path.sep)\n );\n });\n }\n\n return tadaOutputLocationPaths.some(\n (tadaPath) => importSpecifier === tadaPath || importSpecifier.startsWith(tadaPath + '/')\n );\n}\n\nasync function* _runTurbo(params: TurboParams): AsyncIterableIterator<TurboSignal> {\n const schemaNames = getSchemaNamesFromConfig(params.pluginConfig);\n const factory = programFactory(params);\n\n // NOTE: We add our override declaration here before loading all files\n // This sets `__cacheDisabled` on the turbo cache, which disables the cache temporarily\n // If we don't disable the cache then we couldn't regenerate it from inferred types\n factory.addSourceFile({\n fileId: '__gql-tada-override__.d.ts',\n sourceText: DECLARATION_OVERRIDE,\n scriptKind: ts.ScriptKind.TS,\n });\n\n const externalFiles = factory.createExternalFiles();\n if (externalFiles.length) {\n yield { kind: 'EXTERNAL_WARNING' };\n await factory.addVirtualFiles(externalFiles);\n }\n\n const container = factory.build();\n const pluginInfo = container.buildPluginInfo(params.pluginConfig);\n const sourceFiles = container.getSourceFiles();\n\n yield {\n kind: 'FILE_COUNT',\n fileCount: sourceFiles.length,\n };\n\n const checker = container.program.getTypeChecker();\n const uniqueGraphQLSources = new Map<string, GraphQLSourceFile>();\n\n for (const sourceFile of sourceFiles) {\n let filePath = sourceFile.fileName;\n const documents: TurboDocument[] = [];\n const warnings: TurboWarning[] = [];\n\n const calls = findAllCallExpressions(sourceFile, pluginInfo, false).nodes;\n for (const call of calls) {\n const callExpression = call.node.parent;\n if (!ts.isCallExpression(callExpression)) {\n continue;\n }\n\n const position = container.getSourcePosition(sourceFile, callExpression.getStart());\n filePath = position.fileName;\n if (!schemaNames.has(call.schema)) {\n warnings.push({\n message: call.schema\n ? `The '${call.schema}' schema is not in the configuration but was referenced by document.`\n : schemaNames.size > 1\n ? 'The document is not for a known schema. Have you re-generated the output file?'\n : 'Multiple schemas are configured, but the document is not for a specific schema.',\n file: position.fileName,\n line: position.line,\n col: position.col,\n });\n continue;\n }\n\n const graphqlSourcePath = traceCallToImportSource(\n callExpression,\n sourceFile,\n container.program\n );\n\n if (graphqlSourcePath && !uniqueGraphQLSources.has(graphqlSourcePath)) {\n const graphqlSourceFile = container.program.getSourceFile(graphqlSourcePath);\n if (graphqlSourceFile) {\n const turboPath = Array.isArray(params.turboOutputPath)\n ? params.turboOutputPath.find((cfg) => cfg.schemaName === call.schema)?.path\n : params.turboOutputPath;\n const imports = collectImportsFromSourceFile(\n graphqlSourceFile,\n params.pluginConfig,\n factory.resolveModuleName.bind(factory),\n turboPath\n );\n uniqueGraphQLSources.set(graphqlSourcePath, {\n absolutePath: graphqlSourcePath,\n imports,\n });\n }\n }\n\n const returnType = checker.getTypeAtLocation(callExpression);\n const argumentType = checker.getTypeAtLocation(call.node);\n // NOTE: `returnType.symbol` is incorrectly typed and is in fact\n // optional and not always present\n if (!returnType.symbol || returnType.symbol.getEscapedName() !== 'TadaDocumentNode') {\n warnings.push({\n message:\n `The discovered document is not of type \"TadaDocumentNode\".\\n` +\n 'If this is unexpected, please file an issue describing your case.',\n file: position.fileName,\n line: position.line,\n col: position.col,\n });\n continue;\n }\n\n const argumentKey: string =\n 'value' in argumentType &&\n typeof argumentType.value === 'string' &&\n (argumentType.flags & ts.TypeFlags.StringLiteral) === 0\n ? JSON.stringify(argumentType.value)\n : checker.typeToString(argumentType, callExpression, BUILDER_FLAGS);\n const documentType = checker.typeToString(returnType, callExpression, BUILDER_FLAGS);\n\n documents.push({\n schemaName: call.schema,\n argumentKey,\n documentType,\n });\n }\n\n yield {\n kind: 'FILE_TURBO',\n filePath,\n documents,\n warnings,\n };\n }\n\n if (uniqueGraphQLSources.size > 0) {\n yield {\n kind: 'GRAPHQL_SOURCES',\n sources: Array.from(uniqueGraphQLSources.values()),\n };\n }\n}\n\nexport const runTurbo = expose(_runTurbo);\n\nconst BUILDER_FLAGS: ts.TypeFormatFlags =\n ts.TypeFormatFlags.NoTruncation |\n ts.TypeFormatFlags.NoTypeReduction |\n ts.TypeFormatFlags.InTypeAlias |\n ts.TypeFormatFlags.UseFullyQualifiedType |\n ts.TypeFormatFlags.GenerateNamesForShadowedTypeParams |\n ts.TypeFormatFlags.UseAliasDefinedOutsideCurrentScope |\n ts.TypeFormatFlags.AllowUniqueESSymbolType |\n ts.TypeFormatFlags.WriteTypeArgumentsOfSignature;\n\nconst DECLARATION_OVERRIDE = `\nimport * as _gqlTada from 'gql.tada';\ndeclare module 'gql.tada' {\n interface setupCache {\n readonly __cacheDisabled: true;\n }\n}\n`.trim();\n"],"names":["traceCallToImportSource","callExpression","sourceFile","program","typeChecker","getTypeChecker","expression","identifier","ts","isIdentifier","isPropertyAccessExpression","symbol","getSymbolAtLocation","declarations","declaration","importDeclaration","findImportDeclaration","isStringLiteral","moduleSpecifier","resolveModulePath","text","node","current","isImportDeclaration","parent","moduleName","containingFile","compilerOptions","getCompilerOptions","host","createCompilerHost","resolved","resolveModuleName","fileName","resolvedModule","resolvedFileName","collectImportsFromSourceFile","pluginConfig","turboOutputPath","imports","tadaImportPaths","getTadaOutputPaths","paths","tadaOutputLocation","push","visit","specifier","isTadaImport","importSpecifier","sourceFilePath","tadaOutputLocationPaths","startsWith","sourceDir","path","dirname","absoluteImportPath","resolve","some","tadaOutputLocationPath","absoluteTadaPath","sep","tadaPath","importClause","getFullText","trim","adjustedSpecifier","replace","includes","forEachChild","runTurbo","expose","async","_runTurbo","params","schemaNames","getSchemaNamesFromConfig","factory","programFactory","addSourceFile","fileId","sourceText","DECLARATION_OVERRIDE","scriptKind","ScriptKind","TS","externalFiles","createExternalFiles","length","kind","addVirtualFiles","container","build","pluginInfo","buildPluginInfo","sourceFiles","getSourceFiles","fileCount","checker","uniqueGraphQLSources","Map","filePath","documents","warnings","calls","findAllCallExpressions","nodes","_loop","call","isCallExpression","position","getSourcePosition","getStart","has","schema","message","size","file","line","col","graphqlSourcePath","graphqlSourceFile","getSourceFile","turboPath","Array","isArray","find","cfg","schemaName","bind","set","absolutePath","returnType","getTypeAtLocation","argumentType","getEscapedName","argumentKey","value","flags","TypeFlags","StringLiteral","JSON","stringify","typeToString","BUILDER_FLAGS","documentType","sources","from","values","TypeFormatFlags","NoTruncation","NoTypeReduction","InTypeAlias","UseFullyQualifiedType","GenerateNamesForShadowedTypeParams","UseAliasDefinedOutsideCurrentScope","AllowUniqueESSymbolType","WriteTypeArgumentsOfSignature"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0BA,SAASA,wBACPC,GACAC,GACAC;EAEA,IAAMC,IAAcD,EAAQE;EAC5B,IAAMC,IAAaL,EAAeK;EAElC,IAAIC;EACJ,IAAIC,EAAGC,aAAaH;IAClBC,IAAaD;SACR,IAAIE,EAAGE,2BAA2BJ,MAAeE,EAAGC,aAAaH,EAAWA;IACjFC,IAAaD,EAAWA;;EAG1B,KAAKC;IAAY;;EAEjB,IAAMI,IAASP,EAAYQ,oBAAoBL;EAC/C,KAAKI,MAAWA,EAAOE;IAAc;;EAErC,KAAK,IAAMC,KAAeH,EAAOE,cAAc;IAC7C,IAAME,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vC,EAAQ6C,aAAaT,GAAcpI,GAAgB8I;MACzD,IAAMC,IAAe/C,EAAQ6C,aAAaX,GAAYlI,GAAgB8I;MAEtE1C,EAAUzD,KAAK;QACbmF,YAAYpB,EAAKM;QACjBsB;QACAS;;AAEH;IA5ED,KAAK,IAAMrC,KAAQJ;MAAK,IAGpB,cAHoBG,MAAAC;QAGpB;;;UA2EE;MACJnB,MAAM;MACNY;MACAC;MACAC;;AAEJ;EAEA,IAAIJ,EAAqBiB,OAAO;UACxB;MACJ3B,MAAM;MACNyD,SAAStB,MAAMuB,KAAKhD,EAAqBiD;;;AAG/C;;AAIA,IAAMJ,IACJvI,EAAG4I,gBAAgBC,eACnB7I,EAAG4I,gBAAgBE,kBACnB9I,EAAG4I,gBAAgBG,cACnB/I,EAAG4I,gBAAgBI,wBACnBhJ,EAAG4I,gBAAgBK,qCACnBjJ,EAAG4I,gBAAgBM,qCACnBlJ,EAAG4I,gBAAgBO,0BACnBnJ,EAAG4I,gBAAgBQ;;AAErB,IAAM3E,IAAuB,gJAO3BjB;;"}
1
+ {"version":3,"file":"thread-chunk2.js","sources":["../../src/commands/turbo/thread.ts"],"sourcesContent":["import ts from 'typescript';\nimport * as path from 'node:path';\nimport type { GraphQLSPConfig } from '@gql.tada/internal';\n\nimport { getSchemaNamesFromConfig } from '@gql.tada/internal';\nimport { findAllCallExpressions } from '@0no-co/graphqlsp/api';\n\nimport { programFactory } from '../../ts';\nimport { expose } from '../../threads';\n\nimport type {\n TurboSignal,\n TurboWarning,\n TurboDocument,\n GraphQLSourceFile,\n GraphQLSourceImport,\n TurboPath,\n} from './types';\n\nexport interface TurboParams {\n rootPath: string;\n configPath: string;\n pluginConfig: GraphQLSPConfig;\n turboOutputPath: string | TurboPath[];\n}\n\nfunction traceCallToImportSource(\n callExpression: ts.CallExpression,\n sourceFile: ts.SourceFile,\n program: ts.Program\n): string | undefined {\n const typeChecker = program.getTypeChecker();\n const expression = callExpression.expression;\n\n let identifier: ts.Identifier | undefined;\n if (ts.isIdentifier(expression)) {\n identifier = expression;\n } else if (ts.isPropertyAccessExpression(expression) && ts.isIdentifier(expression.expression)) {\n identifier = expression.expression;\n }\n\n if (!identifier) return undefined;\n\n const symbol = typeChecker.getSymbolAtLocation(identifier);\n if (!symbol || !symbol.declarations) return undefined;\n\n for (const declaration of symbol.declarations) {\n const importDeclaration = findImportDeclaration(declaration);\n if (importDeclaration && ts.isStringLiteral(importDeclaration.moduleSpecifier)) {\n const moduleName = importDeclaration.moduleSpecifier.text;\n return resolveModulePath(moduleName, sourceFile, program);\n }\n }\n\n return undefined;\n}\n\nfunction findImportDeclaration(node: ts.Node): ts.ImportDeclaration | undefined {\n let current: ts.Node | undefined = node;\n\n while (current) {\n if (ts.isImportDeclaration(current)) {\n return current;\n }\n current = current.parent;\n }\n\n return undefined;\n}\n\nfunction resolveModulePath(\n moduleName: string,\n containingFile: ts.SourceFile,\n program: ts.Program\n): string | undefined {\n const compilerOptions = program.getCompilerOptions();\n const host = ts.createCompilerHost(compilerOptions);\n\n const resolved = ts.resolveModuleName(moduleName, containingFile.fileName, compilerOptions, host);\n\n if (resolved.resolvedModule) {\n return resolved.resolvedModule.resolvedFileName;\n }\n\n return undefined;\n}\n\nfunction collectImportsFromSourceFile(\n sourceFile: ts.SourceFile,\n pluginConfig: GraphQLSPConfig,\n resolveModuleName: (importSpecifier: string, fromPath: string, toPath: string) => string,\n turboOutputPath?: string,\n shouldTreatImportsAsNodeNext?: boolean\n): GraphQLSourceImport[] {\n const imports: GraphQLSourceImport[] = [];\n\n const tadaImportPaths = getTadaOutputPaths(pluginConfig);\n\n function visit(node: ts.Node) {\n if (ts.isImportDeclaration(node) && ts.isStringLiteral(node.moduleSpecifier)) {\n const specifier = node.moduleSpecifier.text;\n\n if (!isTadaImport(specifier, sourceFile.fileName, tadaImportPaths)) {\n const importClause = node.getFullText().trim();\n if (turboOutputPath) {\n // Adjust the import specifier to point to the turbo output path\n let adjustedSpecifier = resolveModuleName(\n specifier,\n sourceFile.fileName,\n turboOutputPath\n );\n\n if (shouldTreatImportsAsNodeNext) {\n if (adjustedSpecifier.endsWith('.ts') || adjustedSpecifier.endsWith('.tsx')) {\n adjustedSpecifier = adjustedSpecifier\n .replace(/\\.ts$/, '.js')\n .replace(/\\.tsx$/, '.js');\n }\n } else {\n adjustedSpecifier = adjustedSpecifier.replace(/\\.ts$/, '').replace(/\\.tsx$/, '');\n }\n\n if (adjustedSpecifier && !adjustedSpecifier.includes('gql.tada')) {\n imports.push({\n specifier: adjustedSpecifier,\n importClause: importClause.replace(specifier, adjustedSpecifier),\n });\n }\n } else {\n imports.push({ specifier, importClause });\n }\n }\n }\n ts.forEachChild(node, visit);\n }\n\n visit(sourceFile);\n return imports;\n}\n\nfunction getTadaOutputPaths(pluginConfig: GraphQLSPConfig): string[] {\n const paths: string[] = [];\n\n if ('schema' in pluginConfig && pluginConfig.tadaOutputLocation) {\n paths.push(pluginConfig.tadaOutputLocation);\n } else {\n // Multiple schemas aren't supported in this context\n }\n\n return paths;\n}\n\nfunction isTadaImport(\n importSpecifier: string,\n sourceFilePath: string,\n tadaOutputLocationPaths: string[]\n): boolean {\n if (importSpecifier.startsWith('.')) {\n const sourceDir = path.dirname(sourceFilePath);\n const absoluteImportPath = path.resolve(sourceDir, importSpecifier);\n\n return tadaOutputLocationPaths.some((tadaOutputLocationPath) => {\n const absoluteTadaPath = path.resolve(tadaOutputLocationPath);\n return (\n absoluteImportPath === absoluteTadaPath ||\n absoluteImportPath.startsWith(absoluteTadaPath + path.sep)\n );\n });\n }\n\n return tadaOutputLocationPaths.some(\n (tadaPath) => importSpecifier === tadaPath || importSpecifier.startsWith(tadaPath + '/')\n );\n}\n\nasync function* _runTurbo(params: TurboParams): AsyncIterableIterator<TurboSignal> {\n const schemaNames = getSchemaNamesFromConfig(params.pluginConfig);\n const factory = programFactory(params);\n\n // NOTE: We add our override declaration here before loading all files\n // This sets `__cacheDisabled` on the turbo cache, which disables the cache temporarily\n // If we don't disable the cache then we couldn't regenerate it from inferred types\n factory.addSourceFile({\n fileId: '__gql-tada-override__.d.ts',\n sourceText: DECLARATION_OVERRIDE,\n scriptKind: ts.ScriptKind.TS,\n });\n\n const externalFiles = factory.createExternalFiles();\n if (externalFiles.length) {\n yield { kind: 'EXTERNAL_WARNING' };\n await factory.addVirtualFiles(externalFiles);\n }\n\n const container = factory.build();\n const pluginInfo = container.buildPluginInfo(params.pluginConfig);\n const sourceFiles = container.getSourceFiles();\n\n yield {\n kind: 'FILE_COUNT',\n fileCount: sourceFiles.length,\n };\n\n const checker = container.program.getTypeChecker();\n const uniqueGraphQLSources = new Map<string, GraphQLSourceFile>();\n\n for (const sourceFile of sourceFiles) {\n let filePath = sourceFile.fileName;\n const documents: TurboDocument[] = [];\n const warnings: TurboWarning[] = [];\n\n const calls = findAllCallExpressions(sourceFile, pluginInfo, false).nodes;\n for (const call of calls) {\n const callExpression = call.node.parent;\n if (!ts.isCallExpression(callExpression)) {\n continue;\n }\n\n const position = container.getSourcePosition(sourceFile, callExpression.getStart());\n filePath = position.fileName;\n if (!schemaNames.has(call.schema)) {\n warnings.push({\n message: call.schema\n ? `The '${call.schema}' schema is not in the configuration but was referenced by document.`\n : schemaNames.size > 1\n ? 'The document is not for a known schema. Have you re-generated the output file?'\n : 'Multiple schemas are configured, but the document is not for a specific schema.',\n file: position.fileName,\n line: position.line,\n col: position.col,\n });\n continue;\n }\n\n const graphqlSourcePath = traceCallToImportSource(\n callExpression,\n sourceFile,\n container.program\n );\n\n if (graphqlSourcePath && !uniqueGraphQLSources.has(graphqlSourcePath)) {\n const graphqlSourceFile = container.program.getSourceFile(graphqlSourcePath);\n if (graphqlSourceFile) {\n const turboPath = Array.isArray(params.turboOutputPath)\n ? params.turboOutputPath.find((cfg) => cfg.schemaName === call.schema)?.path\n : params.turboOutputPath;\n const imports = collectImportsFromSourceFile(\n graphqlSourceFile,\n params.pluginConfig,\n factory.resolveModuleName.bind(factory),\n turboPath,\n !!factory.wasOriginallyNodeNext\n );\n uniqueGraphQLSources.set(graphqlSourcePath, {\n absolutePath: graphqlSourcePath,\n imports,\n });\n }\n }\n\n const returnType = checker.getTypeAtLocation(callExpression);\n const argumentType = checker.getTypeAtLocation(call.node);\n // NOTE: `returnType.symbol` is incorrectly typed and is in fact\n // optional and not always present\n if (!returnType.symbol || returnType.symbol.getEscapedName() !== 'TadaDocumentNode') {\n warnings.push({\n message:\n `The discovered document is not of type \"TadaDocumentNode\".\\n` +\n 'If this is unexpected, please file an issue describing your case.',\n file: position.fileName,\n line: position.line,\n col: position.col,\n });\n continue;\n }\n\n const argumentKey: string =\n 'value' in argumentType &&\n typeof argumentType.value === 'string' &&\n (argumentType.flags & ts.TypeFlags.StringLiteral) === 0\n ? JSON.stringify(argumentType.value)\n : checker.typeToString(argumentType, callExpression, BUILDER_FLAGS);\n const documentType = checker.typeToString(returnType, callExpression, BUILDER_FLAGS);\n\n documents.push({\n schemaName: call.schema,\n argumentKey,\n documentType,\n });\n }\n\n yield {\n kind: 'FILE_TURBO',\n filePath,\n documents,\n warnings,\n };\n }\n\n if (uniqueGraphQLSources.size > 0) {\n yield {\n kind: 'GRAPHQL_SOURCES',\n sources: Array.from(uniqueGraphQLSources.values()),\n };\n }\n}\n\nexport const runTurbo = expose(_runTurbo);\n\nconst BUILDER_FLAGS: ts.TypeFormatFlags =\n ts.TypeFormatFlags.NoTruncation |\n ts.TypeFormatFlags.NoTypeReduction |\n ts.TypeFormatFlags.InTypeAlias |\n ts.TypeFormatFlags.UseFullyQualifiedType |\n ts.TypeFormatFlags.GenerateNamesForShadowedTypeParams |\n ts.TypeFormatFlags.UseAliasDefinedOutsideCurrentScope |\n ts.TypeFormatFlags.AllowUniqueESSymbolType |\n ts.TypeFormatFlags.WriteTypeArgumentsOfSignature;\n\nconst DECLARATION_OVERRIDE = `\nimport * as _gqlTada from 'gql.tada';\ndeclare module 'gql.tada' {\n interface setupCache {\n readonly __cacheDisabled: true;\n }\n}\n`.trim();\n"],"names":["traceCallToImportSource","callExpression","sourceFile","program","typeChecker","getTypeChecker","expression","identifier","ts","isIdentifier","isPropertyAccessExpression","symbol","getSymbolAtLocation","declarations","declaration","importDeclaration","findImportDeclaration","isStringLiteral","moduleSpecifier","resolveModulePath","text","node","current","isImportDeclaration","parent","moduleName","containingFile","compilerOptions","getCompilerOptions","host","createCompilerHost","resolved","resolveModuleName","fileName","resolvedModule","resolvedFileName","collectImportsFromSourceFile","pluginConfig","turboOutputPath","shouldTreatImportsAsNodeNext","imports","tadaImportPaths","getTadaOutputPaths","paths","tadaOutputLocation","push","visit","specifier","isTadaImport","importSpecifier","sourceFilePath","tadaOutputLocationPaths","startsWith","sourceDir","path","dirname","absoluteImportPath","resolve","some","tadaOutputLocationPath","absoluteTadaPath","sep","tadaPath","importClause","getFullText","trim","adjustedSpecifier","endsWith","replace","includes","forEachChild","runTurbo","expose","async","_runTurbo","params","schemaNames","getSchemaNamesFromConfig","factory","programFactory","addSourceFile","fileId","sourceText","DECLARATION_OVERRIDE","scriptKind","ScriptKind","TS","externalFiles","createExternalFiles","length","kind","addVirtualFiles","container","build","pluginInfo","buildPluginInfo","sourceFiles","getSourceFiles","fileCount","checker","uniqueGraphQLSources","Map","filePath","documents","warnings","calls","findAllCallExpressions","nodes","_loop","call","isCallExpression","position","getSourcePosition","getStart","has","schema","message","size","file","line","col","graphqlSourcePath","graphqlSourceFile","getSourceFile","turboPath","Array","isArray","find","cfg","schemaName","bind","wasOriginallyNodeNext","set","absolutePath","returnType","getTypeAtLocation","argumentType","getEscapedName","argumentKey","value","flags","TypeFlags","StringLiteral","JSON","stringify","typeToString","BUILDER_FLAGS","documentType","sources","from","values","TypeFormatFlags","NoTruncation","NoTypeReduction","InTypeAlias","UseFullyQualifiedType","GenerateNamesForShadowedTypeParams","UseAliasDefinedOutsideCurrentScope","AllowUniqueESSymbolType","WriteTypeArgumentsOfSignature"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0BA,SAASA,wBACPC,GACAC,GACAC;EAE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14
14
  var i = t.getTypeChecker();
15
15
  var o = r.expression;
16
- var n;
16
+ var s;
17
17
  if (e.isIdentifier(o)) {
18
- n = o;
18
+ s = o;
19
19
  } else if (e.isPropertyAccessExpression(o) && e.isIdentifier(o.expression)) {
20
- n = o.expression;
20
+ s = o.expression;
21
21
  }
22
- if (!n) {
22
+ if (!s) {
23
23
  return;
24
24
  }
25
- var s = i.getSymbolAtLocation(n);
26
- if (!s || !s.declarations) {
25
+ var n = i.getSymbolAtLocation(s);
26
+ if (!n || !n.declarations) {
27
27
  return;
28
28
  }
29
- for (var l of s.declarations) {
29
+ for (var l of n.declarations) {
30
30
  var u = findImportDeclaration(l);
31
31
  if (u && e.isStringLiteral(u.moduleSpecifier)) {
32
32
  return resolveModulePath(u.moduleSpecifier.text, a, t);
@@ -49,16 +49,16 @@ function findImportDeclaration(r) {
49
49
  function resolveModulePath(r, a, t) {
50
50
  var i = t.getCompilerOptions();
51
51
  var o = e.createCompilerHost(i);
52
- var n = e.resolveModuleName(r, a.fileName, i, o);
53
- if (n.resolvedModule) {
54
- return n.resolvedModule.resolvedFileName;
52
+ var s = e.resolveModuleName(r, a.fileName, i, o);
53
+ if (s.resolvedModule) {
54
+ return s.resolvedModule.resolvedFileName;
55
55
  }
56
56
  return;
57
57
  }
58
58
 
59
- function collectImportsFromSourceFile(a, t, i, o) {
59
+ function collectImportsFromSourceFile(a, t, i, o, s) {
60
60
  var n = [];
61
- var s = function getTadaOutputPaths(e) {
61
+ var l = function getTadaOutputPaths(e) {
62
62
  var r = [];
63
63
  if ("schema" in e && e.tadaOutputLocation) {
64
64
  r.push(e.tadaOutputLocation);
@@ -67,7 +67,7 @@ function collectImportsFromSourceFile(a, t, i, o) {
67
67
  }(t);
68
68
  !function visit(t) {
69
69
  if (e.isImportDeclaration(t) && e.isStringLiteral(t.moduleSpecifier)) {
70
- var l = t.moduleSpecifier.text;
70
+ var u = t.moduleSpecifier.text;
71
71
  if (!function isTadaImport(e, a, t) {
72
72
  if (e.startsWith(".")) {
73
73
  var i = r.dirname(a);
@@ -78,20 +78,27 @@ function collectImportsFromSourceFile(a, t, i, o) {
78
78
  }));
79
79
  }
80
80
  return t.some((r => e === r || e.startsWith(r + "/")));
81
- }(l, a.fileName, s)) {
82
- var u = t.getFullText().trim();
81
+ }(u, a.fileName, l)) {
82
+ var c = t.getFullText().trim();
83
83
  if (o) {
84
- var c = i(l, a.fileName, o).replace(/\.ts$/, "").replace(/\.tsx$/, "");
85
- if (c && !c.includes("gql.tada")) {
84
+ var p = i(u, a.fileName, o);
85
+ if (s) {
86
+ if (p.endsWith(".ts") || p.endsWith(".tsx")) {
87
+ p = p.replace(/\.ts$/, ".js").replace(/\.tsx$/, ".js");
88
+ }
89
+ } else {
90
+ p = p.replace(/\.ts$/, "").replace(/\.tsx$/, "");
91
+ }
92
+ if (p && !p.includes("gql.tada")) {
86
93
  n.push({
87
- specifier: c,
88
- importClause: u.replace(l, c)
94
+ specifier: p,
95
+ importClause: c.replace(u, p)
89
96
  });
90
97
  }
91
98
  } else {
92
99
  n.push({
93
- specifier: l,
94
- importClause: u
100
+ specifier: u,
101
+ importClause: c
95
102
  });
96
103
  }
97
104
  }
@@ -101,30 +108,30 @@ function collectImportsFromSourceFile(a, t, i, o) {
101
108
  return n;
102
109
  }
103
110
 
104
- var n = i((async function* _runTurbo(r) {
111
+ var s = i((async function* _runTurbo(r) {
105
112
  var i = a(r.pluginConfig);
106
- var n = o(r);
107
- n.addSourceFile({
113
+ var s = o(r);
114
+ s.addSourceFile({
108
115
  fileId: "__gql-tada-override__.d.ts",
109
116
  sourceText: l,
110
117
  scriptKind: e.ScriptKind.TS
111
118
  });
112
- var u = n.createExternalFiles();
119
+ var u = s.createExternalFiles();
113
120
  if (u.length) {
114
121
  yield {
115
122
  kind: "EXTERNAL_WARNING"
116
123
  };
117
- await n.addVirtualFiles(u);
124
+ await s.addVirtualFiles(u);
118
125
  }
119
- var c = n.build();
126
+ var c = s.build();
120
127
  var p = c.buildPluginInfo(r.pluginConfig);
121
128
  var m = c.getSourceFiles();
122
129
  yield {
123
130
  kind: "FILE_COUNT",
124
131
  fileCount: m.length
125
132
  };
126
- var f = c.program.getTypeChecker();
127
- var d = new Map;
133
+ var d = c.program.getTypeChecker();
134
+ var f = new Map;
128
135
  for (var v of m) {
129
136
  var g = v.fileName;
130
137
  var h = [];
@@ -147,19 +154,19 @@ var n = i((async function* _runTurbo(r) {
147
154
  return 0;
148
155
  }
149
156
  var l = traceCallToImportSource(t, v, c.program);
150
- if (l && !d.has(l)) {
157
+ if (l && !f.has(l)) {
151
158
  var u = c.program.getSourceFile(l);
152
159
  if (u) {
153
160
  var p = Array.isArray(r.turboOutputPath) ? r.turboOutputPath.find((e => e.schemaName === a.schema))?.path : r.turboOutputPath;
154
- var m = collectImportsFromSourceFile(u, r.pluginConfig, n.resolveModuleName.bind(n), p);
155
- d.set(l, {
161
+ var m = collectImportsFromSourceFile(u, r.pluginConfig, s.resolveModuleName.bind(s), p, !!s.wasOriginallyNodeNext);
162
+ f.set(l, {
156
163
  absolutePath: l,
157
164
  imports: m
158
165
  });
159
166
  }
160
167
  }
161
- var T = f.getTypeAtLocation(t);
162
- var F = f.getTypeAtLocation(a.node);
168
+ var T = d.getTypeAtLocation(t);
169
+ var F = d.getTypeAtLocation(a.node);
163
170
  if (!T.symbol || "TadaDocumentNode" !== T.symbol.getEscapedName()) {
164
171
  y.push({
165
172
  message: 'The discovered document is not of type "TadaDocumentNode".\nIf this is unexpected, please file an issue describing your case.',
@@ -169,8 +176,8 @@ var n = i((async function* _runTurbo(r) {
169
176
  });
170
177
  return 0;
171
178
  }
172
- var S = "value" in F && "string" == typeof F.value && !(F.flags & e.TypeFlags.StringLiteral) ? JSON.stringify(F.value) : f.typeToString(F, t, s);
173
- var N = f.typeToString(T, t, s);
179
+ var S = "value" in F && "string" == typeof F.value && !(F.flags & e.TypeFlags.StringLiteral) ? JSON.stringify(F.value) : d.typeToString(F, t, n);
180
+ var N = d.typeToString(T, t, n);
174
181
  h.push({
175
182
  schemaName: a.schema,
176
183
  argumentKey: S,
@@ -189,17 +196,17 @@ var n = i((async function* _runTurbo(r) {
189
196
  warnings: y
190
197
  };
191
198
  }
192
- if (d.size > 0) {
199
+ if (f.size > 0) {
193
200
  yield {
194
201
  kind: "GRAPHQL_SOURCES",
195
- sources: Array.from(d.values())
202
+ sources: Array.from(f.values())
196
203
  };
197
204
  }
198
205
  }));
199
206
 
200
- var s = e.TypeFormatFlags.NoTruncation | e.TypeFormatFlags.NoTypeReduction | e.TypeFormatFlags.InTypeAlias | e.TypeFormatFlags.UseFullyQualifiedType | e.TypeFormatFlags.GenerateNamesForShadowedTypeParams | e.TypeFormatFlags.UseAliasDefinedOutsideCurrentScope | e.TypeFormatFlags.AllowUniqueESSymbolType | e.TypeFormatFlags.WriteTypeArgumentsOfSignature;
207
+ var n = e.TypeFormatFlags.NoTruncation | e.TypeFormatFlags.NoTypeReduction | e.TypeFormatFlags.InTypeAlias | e.TypeFormatFlags.UseFullyQualifiedType | e.TypeFormatFlags.GenerateNamesForShadowedTypeParams | e.TypeFormatFlags.UseAliasDefinedOutsideCurrentScope | e.TypeFormatFlags.AllowUniqueESSymbolType | e.TypeFormatFlags.WriteTypeArgumentsOfSignature;
201
208
 
202
209
  var l = "\nimport * as _gqlTada from 'gql.tada';\ndeclare module 'gql.tada' {\n interface setupCache {\n readonly __cacheDisabled: true;\n }\n}\n".trim();
203
210
 
204
- export { n as runTurbo };
211
+ export { s as runTurbo };
205
212
  //# sourceMappingURL=thread-chunk2.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"thread-chunk2.mjs","sources":["../../src/commands/turbo/thread.ts"],"sourcesContent":["import ts from 'typescript';\nimport * as path from 'node:path';\nimport type { GraphQLSPConfig } from '@gql.tada/internal';\n\nimport { getSchemaNamesFromConfig } from '@gql.tada/internal';\nimport { findAllCallExpressions } from '@0no-co/graphqlsp/api';\n\nimport { programFactory } from '../../ts';\nimport { expose } from '../../threads';\n\nimport type {\n TurboSignal,\n TurboWarning,\n TurboDocument,\n GraphQLSourceFile,\n GraphQLSourceImport,\n TurboPath,\n} from './types';\n\nexport interface TurboParams {\n rootPath: string;\n configPath: string;\n pluginConfig: GraphQLSPConfig;\n turboOutputPath: string | TurboPath[];\n}\n\nfunction traceCallToImportSource(\n callExpression: ts.CallExpression,\n sourceFile: ts.SourceFile,\n program: ts.Program\n): string | undefined {\n const typeChecker = program.getTypeChecker();\n const expression = callExpression.expression;\n\n let identifier: ts.Identifier | undefined;\n if (ts.isIdentifier(expression)) {\n identifier = expression;\n } else if (ts.isPropertyAccessExpression(expression) && ts.isIdentifier(expression.expression)) {\n identifier = expression.expression;\n }\n\n if (!identifier) return undefined;\n\n const symbol = typeChecker.getSymbolAtLocation(identifier);\n if (!symbol || !symbol.declarations) return undefined;\n\n for (const declaration of symbol.declarations) {\n const importDeclaration = findImportDeclaration(declaration);\n if (importDeclaration && ts.isStringLiteral(importDeclaration.moduleSpecifier)) {\n const moduleName = importDeclaration.moduleSpecifier.text;\n return resolveModulePath(moduleName, sourceFile, program);\n }\n }\n\n return undefined;\n}\n\nfunction findImportDeclaration(node: ts.Node): ts.ImportDeclaration | undefined {\n let current: ts.Node | undefined = node;\n\n while (current) {\n if (ts.isImportDeclaration(current)) {\n return current;\n }\n current = current.parent;\n }\n\n return undefined;\n}\n\nfunction resolveModulePath(\n moduleName: string,\n containingFile: ts.SourceFile,\n program: ts.Program\n): string | undefined {\n const compilerOptions = program.getCompilerOptions();\n const host = ts.createCompilerHost(compilerOptions);\n\n const resolved = ts.resolveModuleName(moduleName, containingFile.fileName, compilerOptions, host);\n\n if (resolved.resolvedModule) {\n return resolved.resolvedModule.resolvedFileName;\n }\n\n return undefined;\n}\n\nfunction collectImportsFromSourceFile(\n sourceFile: ts.SourceFile,\n pluginConfig: GraphQLSPConfig,\n resolveModuleName: (importSpecifier: string, fromPath: string, toPath: string) => string,\n turboOutputPath?: string\n): GraphQLSourceImport[] {\n const imports: GraphQLSourceImport[] = [];\n\n const tadaImportPaths = getTadaOutputPaths(pluginConfig);\n\n function visit(node: ts.Node) {\n if (ts.isImportDeclaration(node) && ts.isStringLiteral(node.moduleSpecifier)) {\n const specifier = node.moduleSpecifier.text;\n\n if (!isTadaImport(specifier, sourceFile.fileName, tadaImportPaths)) {\n const importClause = node.getFullText().trim();\n if (turboOutputPath) {\n // Adjust the import specifier to point to the turbo output path\n const adjustedSpecifier = resolveModuleName(\n specifier,\n sourceFile.fileName,\n turboOutputPath\n )\n .replace(/\\.ts$/, '')\n .replace(/\\.tsx$/, '');\n if (adjustedSpecifier && !adjustedSpecifier.includes('gql.tada')) {\n imports.push({\n specifier: adjustedSpecifier,\n importClause: importClause.replace(specifier, adjustedSpecifier),\n });\n }\n } else {\n imports.push({ specifier, importClause });\n }\n }\n }\n ts.forEachChild(node, visit);\n }\n\n visit(sourceFile);\n return imports;\n}\n\nfunction getTadaOutputPaths(pluginConfig: GraphQLSPConfig): string[] {\n const paths: string[] = [];\n\n if ('schema' in pluginConfig && pluginConfig.tadaOutputLocation) {\n paths.push(pluginConfig.tadaOutputLocation);\n } else {\n // Multiple schemas aren't supported in this context\n }\n\n return paths;\n}\n\nfunction isTadaImport(\n importSpecifier: string,\n sourceFilePath: string,\n tadaOutputLocationPaths: string[]\n): boolean {\n if (importSpecifier.startsWith('.')) {\n const sourceDir = path.dirname(sourceFilePath);\n const absoluteImportPath = path.resolve(sourceDir, importSpecifier);\n\n return tadaOutputLocationPaths.some((tadaOutputLocationPath) => {\n const absoluteTadaPath = path.resolve(tadaOutputLocationPath);\n return (\n absoluteImportPath === absoluteTadaPath ||\n absoluteImportPath.startsWith(absoluteTadaPath + path.sep)\n );\n });\n }\n\n return tadaOutputLocationPaths.some(\n (tadaPath) => importSpecifier === tadaPath || importSpecifier.startsWith(tadaPath + '/')\n );\n}\n\nasync function* _runTurbo(params: TurboParams): AsyncIterableIterator<TurboSignal> {\n const schemaNames = getSchemaNamesFromConfig(params.pluginConfig);\n const factory = programFactory(params);\n\n // NOTE: We add our override declaration here before loading all files\n // This sets `__cacheDisabled` on the turbo cache, which disables the cache temporarily\n // If we don't disable the cache then we couldn't regenerate it from inferred types\n factory.addSourceFile({\n fileId: '__gql-tada-override__.d.ts',\n sourceText: DECLARATION_OVERRIDE,\n scriptKind: ts.ScriptKind.TS,\n });\n\n const externalFiles = factory.createExternalFiles();\n if (externalFiles.length) {\n yield { kind: 'EXTERNAL_WARNING' };\n await factory.addVirtualFiles(externalFiles);\n }\n\n const container = factory.build();\n const pluginInfo = container.buildPluginInfo(params.pluginConfig);\n const sourceFiles = container.getSourceFiles();\n\n yield {\n kind: 'FILE_COUNT',\n fileCount: sourceFiles.length,\n };\n\n const checker = container.program.getTypeChecker();\n const uniqueGraphQLSources = new Map<string, GraphQLSourceFile>();\n\n for (const sourceFile of sourceFiles) {\n let filePath = sourceFile.fileName;\n const documents: TurboDocument[] = [];\n const warnings: TurboWarning[] = [];\n\n const calls = findAllCallExpressions(sourceFile, pluginInfo, false).nodes;\n for (const call of calls) {\n const callExpression = call.node.parent;\n if (!ts.isCallExpression(callExpression)) {\n continue;\n }\n\n const position = container.getSourcePosition(sourceFile, callExpression.getStart());\n filePath = position.fileName;\n if (!schemaNames.has(call.schema)) {\n warnings.push({\n message: call.schema\n ? `The '${call.schema}' schema is not in the configuration but was referenced by document.`\n : schemaNames.size > 1\n ? 'The document is not for a known schema. Have you re-generated the output file?'\n : 'Multiple schemas are configured, but the document is not for a specific schema.',\n file: position.fileName,\n line: position.line,\n col: position.col,\n });\n continue;\n }\n\n const graphqlSourcePath = traceCallToImportSource(\n callExpression,\n sourceFile,\n container.program\n );\n\n if (graphqlSourcePath && !uniqueGraphQLSources.has(graphqlSourcePath)) {\n const graphqlSourceFile = container.program.getSourceFile(graphqlSourcePath);\n if (graphqlSourceFile) {\n const turboPath = Array.isArray(params.turboOutputPath)\n ? params.turboOutputPath.find((cfg) => cfg.schemaName === call.schema)?.path\n : params.turboOutputPath;\n const imports = collectImportsFromSourceFile(\n graphqlSourceFile,\n params.pluginConfig,\n factory.resolveModuleName.bind(factory),\n turboPath\n );\n uniqueGraphQLSources.set(graphqlSourcePath, {\n absolutePath: graphqlSourcePath,\n imports,\n });\n }\n }\n\n const returnType = checker.getTypeAtLocation(callExpression);\n const argumentType = checker.getTypeAtLocation(call.node);\n // NOTE: `returnType.symbol` is incorrectly typed and is in fact\n // optional and not always present\n if (!returnType.symbol || returnType.symbol.getEscapedName() !== 'TadaDocumentNode') {\n warnings.push({\n message:\n `The discovered document is not of type \"TadaDocumentNode\".\\n` +\n 'If this is unexpected, please file an issue describing your case.',\n file: position.fileName,\n line: position.line,\n col: position.col,\n });\n continue;\n }\n\n const argumentKey: string =\n 'value' in argumentType &&\n typeof argumentType.value === 'string' &&\n (argumentType.flags & ts.TypeFlags.StringLiteral) === 0\n ? JSON.stringify(argumentType.value)\n : checker.typeToString(argumentType, callExpression, BUILDER_FLAGS);\n const documentType = checker.typeToString(returnType, callExpression, BUILDER_FLAGS);\n\n documents.push({\n schemaName: call.schema,\n argumentKey,\n documentType,\n });\n }\n\n yield {\n kind: 'FILE_TURBO',\n filePath,\n documents,\n warnings,\n };\n }\n\n if (uniqueGraphQLSources.size > 0) {\n yield {\n kind: 'GRAPHQL_SOURCES',\n sources: Array.from(uniqueGraphQLSources.values()),\n };\n }\n}\n\nexport const runTurbo = expose(_runTurbo);\n\nconst BUILDER_FLAGS: ts.TypeFormatFlags =\n ts.TypeFormatFlags.NoTruncation |\n ts.TypeFormatFlags.NoTypeReduction |\n ts.TypeFormatFlags.InTypeAlias |\n ts.TypeFormatFlags.UseFullyQualifiedType |\n ts.TypeFormatFlags.GenerateNamesForShadowedTypeParams |\n ts.TypeFormatFlags.UseAliasDefinedOutsideCurrentScope |\n ts.TypeFormatFlags.AllowUniqueESSymbolType |\n ts.TypeFormatFlags.WriteTypeArgumentsOfSignature;\n\nconst DECLARATION_OVERRIDE = `\nimport * as _gqlTada from 'gql.tada';\ndeclare module 'gql.tada' {\n interface setupCache {\n readonly __cacheDisabled: true;\n }\n}\n`.trim();\n"],"names":["traceCallToImportSource","callExpression","sourceFile","program","typeChecker","getTypeChecker","expression","identifier","ts","isIdentifier","isPropertyAccessExpression","symbol","getSymbolAtLocation","declarations","declaration","importDeclaration","findImportDeclaration","isStringLiteral","moduleSpecifier","resolveModulePath","text","node","current","isImportDeclaration","parent","moduleName","containingFile","compilerOptions","getCompilerOptions","host","createCompilerHost","resolved","resolveModuleName","fileName","resolvedModule","resolvedFileName","collectImportsFromSourceFile","pluginConfig","turboOutputPath","imports","tadaImportPaths","getTadaOutputPaths","paths","tadaOutputLocation","push","visit","specifier","isTadaImport","importSpecifier","sourceFilePath","tadaOutputLocationPaths","startsWith","sourceDir","path","dirname","absoluteImportPath","resolve","some","tadaOutputLocationPath","absoluteTadaPath","sep","tadaPath","importClause","getFullText","trim","adjustedSpecifier","replace","includes","forEachChild","runTurbo","expose","async","_runTurbo","params","schemaNames","getSchemaNamesFromConfig","factory","programFactory","addSourceFile","fileId","sourceText","DECLARATION_OVERRIDE","scriptKind","ScriptKind","TS","externalFiles","createExternalFiles","length","kind","addVirtualFiles","container","build","pluginInfo","buildPluginInfo","sourceFiles","getSourceFiles","fileCount","checker","uniqueGraphQLSources","Map","filePath","documents","warnings","calls","findAllCallExpressions","nodes","_loop","call","isCallExpression","position","getSourcePosition","getStart","has","schema","message","size","file","line","col","graphqlSourcePath","graphqlSourceFile","getSourceFile","turboPath","Array","isArray","find","cfg","schemaName","bind","set","absolutePath","returnType","getTypeAtLocation","argumentType","getEscapedName","argumentKey","value","flags","TypeFlags","StringLiteral","JSON","stringify","typeToString","BUILDER_FLAGS","documentType","sources","from","values","TypeFormatFlags","NoTruncation","NoTypeReduction","InTypeAlias","UseFullyQualifiedType","GenerateNamesForShadowedTypeParams","UseAliasDefinedOutsideCurrentScope","AllowUniqueESSymbolType","WriteTypeArgumentsOfSignature"],"mappings":";;;;;;;;;;;;AA0BA,SAASA,wBACPC,GACAC,GACAC;EA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KtF;MAGpD,KAAK8G,EAAWxH,UAAiD,uBAAvCwH,EAAWxH,OAAO2H,kBAAyC;QACnFhC,EAAS1D,KAAK;UACZsE,SACE;UAEFE,MAAMP,EAAS5E;UACfoF,MAAMR,EAASQ;UACfC,KAAKT,EAASS;;QACb,OAAA;AAEL;MAEA,IAAMiB,IACJ,WAAWF,KACmB,mBAAvBA,EAAaG,WACnBH,EAAaI,QAAQjI,EAAGkI,UAAUC,iBAC/BC,KAAKC,UAAUR,EAAaG,SAC5BvC,EAAQ6C,aAAaT,GAAcpI,GAAgB8I;MACzD,IAAMC,IAAe/C,EAAQ6C,aAAaX,GAAYlI,GAAgB8I;MAEtE1C,EAAUzD,KAAK;QACbmF,YAAYpB,EAAKM;QACjBsB;QACAS;;AAEH;IA5ED,KAAK,IAAMrC,KAAQJ;MAAK,IAGpB,cAHoBG,MAAAC;QAGpB;;;UA2EE;MACJnB,MAAM;MACNY;MACAC;MACAC;;AAEJ;EAEA,IAAIJ,EAAqBiB,OAAO;UACxB;MACJ3B,MAAM;MACNyD,SAAStB,MAAMuB,KAAKhD,EAAqBiD;;;AAG/C;;AAIA,IAAMJ,IACJvI,EAAG4I,gBAAgBC,eACnB7I,EAAG4I,gBAAgBE,kBACnB9I,EAAG4I,gBAAgBG,cACnB/I,EAAG4I,gBAAgBI,wBACnBhJ,EAAG4I,gBAAgBK,qCACnBjJ,EAAG4I,gBAAgBM,qCACnBlJ,EAAG4I,gBAAgBO,0BACnBnJ,EAAG4I,gBAAgBQ;;AAErB,IAAM3E,IAAuB,gJAO3BjB;;"}
1
+ {"version":3,"file":"thread-chunk2.mjs","sources":["../../src/commands/turbo/thread.ts"],"sourcesContent":["import ts from 'typescript';\nimport * as path from 'node:path';\nimport type { GraphQLSPConfig } from '@gql.tada/internal';\n\nimport { getSchemaNamesFromConfig } from '@gql.tada/internal';\nimport { findAllCallExpressions } from '@0no-co/graphqlsp/api';\n\nimport { programFactory } from '../../ts';\nimport { expose } from '../../threads';\n\nimport type {\n TurboSignal,\n TurboWarning,\n TurboDocument,\n GraphQLSourceFile,\n GraphQLSourceImport,\n TurboPath,\n} from './types';\n\nexport interface TurboParams {\n rootPath: string;\n configPath: string;\n pluginConfig: GraphQLSPConfig;\n turboOutputPath: string | TurboPath[];\n}\n\nfunction traceCallToImportSource(\n callExpression: ts.CallExpression,\n sourceFile: ts.SourceFile,\n program: ts.Program\n): string | undefined {\n const typeChecker = program.getTypeChecker();\n const expression = callExpression.expression;\n\n let identifier: ts.Identifier | undefined;\n if (ts.isIdentifier(expression)) {\n identifier = expression;\n } else if (ts.isPropertyAccessExpression(expression) && ts.isIdentifier(expression.expression)) {\n identifier = expression.expression;\n }\n\n if (!identifier) return undefined;\n\n const symbol = typeChecker.getSymbolAtLocation(identifier);\n if (!symbol || !symbol.declarations) return undefined;\n\n for (const declaration of symbol.declarations) {\n const importDeclaration = findImportDeclaration(declaration);\n if (importDeclaration && ts.isStringLiteral(importDeclaration.moduleSpecifier)) {\n const moduleName = importDeclaration.moduleSpecifier.text;\n return resolveModulePath(moduleName, sourceFile, program);\n }\n }\n\n return undefined;\n}\n\nfunction findImportDeclaration(node: ts.Node): ts.ImportDeclaration | undefined {\n let current: ts.Node | undefined = node;\n\n while (current) {\n if (ts.isImportDeclaration(current)) {\n return current;\n }\n current = current.parent;\n }\n\n return undefined;\n}\n\nfunction resolveModulePath(\n moduleName: string,\n containingFile: ts.SourceFile,\n program: ts.Program\n): string | undefined {\n const compilerOptions = program.getCompilerOptions();\n const host = ts.createCompilerHost(compilerOptions);\n\n const resolved = ts.resolveModuleName(moduleName, containingFile.fileName, compilerOptions, host);\n\n if (resolved.resolvedModule) {\n return resolved.resolvedModule.resolvedFileName;\n }\n\n return undefined;\n}\n\nfunction collectImportsFromSourceFile(\n sourceFile: ts.SourceFile,\n pluginConfig: GraphQLSPConfig,\n resolveModuleName: (importSpecifier: string, fromPath: string, toPath: string) => string,\n turboOutputPath?: string,\n shouldTreatImportsAsNodeNext?: boolean\n): GraphQLSourceImport[] {\n const imports: GraphQLSourceImport[] = [];\n\n const tadaImportPaths = getTadaOutputPaths(pluginConfig);\n\n function visit(node: ts.Node) {\n if (ts.isImportDeclaration(node) && ts.isStringLiteral(node.moduleSpecifier)) {\n const specifier = node.moduleSpecifier.text;\n\n if (!isTadaImport(specifier, sourceFile.fileName, tadaImportPaths)) {\n const importClause = node.getFullText().trim();\n if (turboOutputPath) {\n // Adjust the import specifier to point to the turbo output path\n let adjustedSpecifier = resolveModuleName(\n specifier,\n sourceFile.fileName,\n turboOutputPath\n );\n\n if (shouldTreatImportsAsNodeNext) {\n if (adjustedSpecifier.endsWith('.ts') || adjustedSpecifier.endsWith('.tsx')) {\n adjustedSpecifier = adjustedSpecifier\n .replace(/\\.ts$/, '.js')\n .replace(/\\.tsx$/, '.js');\n }\n } else {\n adjustedSpecifier = adjustedSpecifier.replace(/\\.ts$/, '').replace(/\\.tsx$/, '');\n }\n\n if (adjustedSpecifier && !adjustedSpecifier.includes('gql.tada')) {\n imports.push({\n specifier: adjustedSpecifier,\n importClause: importClause.replace(specifier, adjustedSpecifier),\n });\n }\n } else {\n imports.push({ specifier, importClause });\n }\n }\n }\n ts.forEachChild(node, visit);\n }\n\n visit(sourceFile);\n return imports;\n}\n\nfunction getTadaOutputPaths(pluginConfig: GraphQLSPConfig): string[] {\n const paths: string[] = [];\n\n if ('schema' in pluginConfig && pluginConfig.tadaOutputLocation) {\n paths.push(pluginConfig.tadaOutputLocation);\n } else {\n // Multiple schemas aren't supported in this context\n }\n\n return paths;\n}\n\nfunction isTadaImport(\n importSpecifier: string,\n sourceFilePath: string,\n tadaOutputLocationPaths: string[]\n): boolean {\n if (importSpecifier.startsWith('.')) {\n const sourceDir = path.dirname(sourceFilePath);\n const absoluteImportPath = path.resolve(sourceDir, importSpecifier);\n\n return tadaOutputLocationPaths.some((tadaOutputLocationPath) => {\n const absoluteTadaPath = path.resolve(tadaOutputLocationPath);\n return (\n absoluteImportPath === absoluteTadaPath ||\n absoluteImportPath.startsWith(absoluteTadaPath + path.sep)\n );\n });\n }\n\n return tadaOutputLocationPaths.some(\n (tadaPath) => importSpecifier === tadaPath || importSpecifier.startsWith(tadaPath + '/')\n );\n}\n\nasync function* _runTurbo(params: TurboParams): AsyncIterableIterator<TurboSignal> {\n const schemaNames = getSchemaNamesFromConfig(params.pluginConfig);\n const factory = programFactory(params);\n\n // NOTE: We add our override declaration here before loading all files\n // This sets `__cacheDisabled` on the turbo cache, which disables the cache temporarily\n // If we don't disable the cache then we couldn't regenerate it from inferred types\n factory.addSourceFile({\n fileId: '__gql-tada-override__.d.ts',\n sourceText: DECLARATION_OVERRIDE,\n scriptKind: ts.ScriptKind.TS,\n });\n\n const externalFiles = factory.createExternalFiles();\n if (externalFiles.length) {\n yield { kind: 'EXTERNAL_WARNING' };\n await factory.addVirtualFiles(externalFiles);\n }\n\n const container = factory.build();\n const pluginInfo = container.buildPluginInfo(params.pluginConfig);\n const sourceFiles = container.getSourceFiles();\n\n yield {\n kind: 'FILE_COUNT',\n fileCount: sourceFiles.length,\n };\n\n const checker = container.program.getTypeChecker();\n const uniqueGraphQLSources = new Map<string, GraphQLSourceFile>();\n\n for (const sourceFile of sourceFiles) {\n let filePath = sourceFile.fileName;\n const documents: TurboDocument[] = [];\n const warnings: TurboWarning[] = [];\n\n const calls = findAllCallExpressions(sourceFile, pluginInfo, false).nodes;\n for (const call of calls) {\n const callExpression = call.node.parent;\n if (!ts.isCallExpression(callExpression)) {\n continue;\n }\n\n const position = container.getSourcePosition(sourceFile, callExpression.getStart());\n filePath = position.fileName;\n if (!schemaNames.has(call.schema)) {\n warnings.push({\n message: call.schema\n ? `The '${call.schema}' schema is not in the configuration but was referenced by document.`\n : schemaNames.size > 1\n ? 'The document is not for a known schema. Have you re-generated the output file?'\n : 'Multiple schemas are configured, but the document is not for a specific schema.',\n file: position.fileName,\n line: position.line,\n col: position.col,\n });\n continue;\n }\n\n const graphqlSourcePath = traceCallToImportSource(\n callExpression,\n sourceFile,\n container.program\n );\n\n if (graphqlSourcePath && !uniqueGraphQLSources.has(graphqlSourcePath)) {\n const graphqlSourceFile = container.program.getSourceFile(graphqlSourcePath);\n if (graphqlSourceFile) {\n const turboPath = Array.isArray(params.turboOutputPath)\n ? params.turboOutputPath.find((cfg) => cfg.schemaName === call.schema)?.path\n : params.turboOutputPath;\n const imports = collectImportsFromSourceFile(\n graphqlSourceFile,\n params.pluginConfig,\n factory.resolveModuleName.bind(factory),\n turboPath,\n !!factory.wasOriginallyNodeNext\n );\n uniqueGraphQLSources.set(graphqlSourcePath, {\n absolutePath: graphqlSourcePath,\n imports,\n });\n }\n }\n\n const returnType = checker.getTypeAtLocation(callExpression);\n const argumentType = checker.getTypeAtLocation(call.node);\n // NOTE: `returnType.symbol` is incorrectly typed and is in fact\n // optional and not always present\n if (!returnType.symbol || returnType.symbol.getEscapedName() !== 'TadaDocumentNode') {\n warnings.push({\n message:\n `The discovered document is not of type \"TadaDocumentNode\".\\n` +\n 'If this is unexpected, please file an issue describing your case.',\n file: position.fileName,\n line: position.line,\n col: position.col,\n });\n continue;\n }\n\n const argumentKey: string =\n 'value' in argumentType &&\n typeof argumentType.value === 'string' &&\n (argumentType.flags & ts.TypeFlags.StringLiteral) === 0\n ? JSON.stringify(argumentType.value)\n : checker.typeToString(argumentType, callExpression, BUILDER_FLAGS);\n const documentType = checker.typeToString(returnType, callExpression, BUILDER_FLAGS);\n\n documents.push({\n schemaName: call.schema,\n argumentKey,\n documentType,\n });\n }\n\n yield {\n kind: 'FILE_TURBO',\n filePath,\n documents,\n warnings,\n };\n }\n\n if (uniqueGraphQLSources.size > 0) {\n yield {\n kind: 'GRAPHQL_SOURCES',\n sources: Array.from(uniqueGraphQLSources.values()),\n };\n }\n}\n\nexport const runTurbo = expose(_runTurbo);\n\nconst BUILDER_FLAGS: ts.TypeFormatFlags =\n ts.TypeFormatFlags.NoTruncation |\n ts.TypeFormatFlags.NoTypeReduction |\n ts.TypeFormatFlags.InTypeAlias |\n ts.TypeFormatFlags.UseFullyQualifiedType |\n ts.TypeFormatFlags.GenerateNamesForShadowedTypeParams |\n ts.TypeFormatFlags.UseAliasDefinedOutsideCurrentScope |\n ts.TypeFormatFlags.AllowUniqueESSymbolType |\n ts.TypeFormatFlags.WriteTypeArgumentsOfSignature;\n\nconst DECLARATION_OVERRIDE = `\nimport * as _gqlTada from 'gql.tada';\ndeclare module 'gql.tada' {\n interface setupCache {\n readonly __cacheDisabled: true;\n }\n}\n`.trim();\n"],"names":["traceCallToImportSource","callExpression","sourceFile","program","typeChecker","getTypeChecker","expression","identifier","ts","isIdentifier","isPropertyAccessExpression","symbol","getSymbolAtLocation","declarations","declaration","importDeclaration","findImportDeclaration","isStringLiteral","moduleSpecifier","resolveModulePath","text","node","current","isImportDeclaration","parent","moduleName","containingFile","compilerOptions","getCompilerOptions","host","createCompilerHost","resolved","resolveModuleName","fileName","resolvedModule","resolvedFileName","collectImportsFromSourceFile","pluginConfig","turboOutputPath","shouldTreatImportsAsNodeNext","imports","tadaImportPaths","getTadaOutputPaths","paths","tadaOutputLocation","push","visit","specifier","isTadaImport","importSpecifier","sourceFilePath","tadaOutputLocationPaths","startsWith","sourceDir","path","dirname","absoluteImportPath","resolve","some","tadaOutputLocationPath","absoluteTadaPath","sep","tadaPath","importClause","getFullText","trim","adjustedSpecifier","endsWith","replace","includes","forEachChild","runTurbo","expose","async","_runTurbo","params","schemaNames","getSchemaNamesFromConfig","factory","programFactory","addSourceFile","fileId","sourceText","DECLARATION_OVERRIDE","scriptKind","ScriptKind","TS","externalFiles","createExternalFiles","length","kind","addVirtualFiles","container","build","pluginInfo","buildPluginInfo","sourceFiles","getSourceFiles","fileCount","checker","uniqueGraphQLSources","Map","filePath","documents","warnings","calls","findAllCallExpressions","nodes","_loop","call","isCallExpression","position","getSourcePosition","getStart","has","schema","message","size","file","line","col","graphqlSourcePath","graphqlSourceFile","getSourceFile","turboPath","Array","isArray","find","cfg","schemaName","bind","wasOriginallyNodeNext","set","absolutePath","returnType","getTypeAtLocation","argumentType","getEscapedName","argumentKey","value","flags","TypeFlags","StringLiteral","JSON","stringify","typeToString","BUILDER_FLAGS","documentType","sources","from","values","TypeFormatFlags","NoTruncation","NoTypeReduction","InTypeAlias","UseFullyQualifiedType","GenerateNamesForShadowedTypeParams","UseAliasDefinedOutsideCurrentScope","AllowUniqueESSymbolType","WriteTypeArgumentsOfSignature"],"mappings":";;;;;;;;;;;;AA0BA,SAASA,wBACPC,GACAC,GACAC;EAEA,IAAMC,IAAcD,EAAQE;EAC5B,IAAMC,IAAaL,EAAeK;EAElC,IAAIC;EACJ,IAAIC,EAAGC,aAAaH;IAClBC,IAAaD;SACR,IAAIE,EAAGE,2BAA2BJ,MAAeE,EAAGC,aAAaH,EAAWA;IACjFC,IAAaD,EAAWA;;EAG1B,KAAKC;IAAY;;EAEjB,IAAMI,IAASP,EAAYQ,oBAAoBL;EAC/C,KAAKI,MAAWA,EAAOE;IAAc;;EAErC,KAAK,IAAMC,KAAeH,EAAOE,cAAc;IAC7C,IAAME,IAAoBC,sBAAsBF;IAChD,IAAIC,KAAqBP,EAAGS,gBAAgBF,EAAkBG,kBAAkB;MAE9E,OAAOC,kBADYJ,EAAkBG,gBAAgBE,MAChBlB,GAAYC;AACnD;AACF;EAEA;AACF;;AAEA,SAASa,sBAAsBK;EAC7B,IAAIC,IAA+BD;EAEnC,OAAOC,GAAS;IACd,IAAId,EAAGe,oBAAoBD;MACzB,OAAOA;;IAETA,IAAUA,EAAQE;AACpB;EAEA;AACF;;AAEA,SAASL,kBACPM,GACAC,GACAvB;EAEA,IAAMwB,IAAkBxB,EAAQyB;EAChC,IAAMC,IAAOrB,EAAGsB,mBAAmBH;EAEnC,IAAMI,IAAWvB,EAAGwB,kBAAkBP,GAAYC,EAAeO,UAAUN,GAAiBE;EAE5F,IAAIE,EAASG;IACX,OAAOH,EAASG,eAAeC;;EAGjC;AACF;;AAEA,SAASC,6BACPlC,GACAmC,GACAL,GACAM,GACAC;EAEA,IAAMC,IAAiC;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I,gBAAgBG,cACnBlJ,EAAG+I,gBAAgBI,wBACnBnJ,EAAG+I,gBAAgBK,qCACnBpJ,EAAG+I,gBAAgBM,qCACnBrJ,EAAG+I,gBAAgBO,0BACnBtJ,EAAG+I,gBAAgBQ;;AAErB,IAAM5E,IAAuB,gJAO3BlB;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gql.tada/cli-utils",
3
- "version": "1.7.1",
3
+ "version": "1.7.2",
4
4
  "public": true,
5
5
  "description": "Main logic for gql.tada’s CLI tool.",
6
6
  "author": "0no.co <hi@0no.co>",