@soda-gql/tsc-transformer 0.1.0 → 0.2.0
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.
- package/dist/index.cjs +598 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +53 -0
- package/dist/index.d.cts.map +1 -0
- package/dist/index.d.mts +53 -0
- package/dist/index.d.mts.map +1 -0
- package/dist/index.mjs +570 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +32 -11
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.mjs","names":["newStatements","sourceFile","ts","bindings: ExportBindingMap","ts","runtimeCallsFromLastTransform: ts.Expression[]"],"sources":["../src/ast/imports.ts","../src/ast/metadata.ts","../src/ast/analysis.ts","../src/ast/ast.ts","../src/ast/runtime.ts","../src/ast/transformer.ts","../src/transformer.ts"],"sourcesContent":["import type { GraphqlSystemIdentifyHelper } from \"@soda-gql/builder\";\nimport ts from \"typescript\";\n\nconst RUNTIME_MODULE = \"@soda-gql/runtime\";\n\n/**\n * Ensure that the gqlRuntime require exists in the source file for CJS output.\n * Injects: const __soda_gql_runtime = require(\"@soda-gql/runtime\");\n * Returns an updated source file with the require added if needed.\n */\nexport const ensureGqlRuntimeRequire = ({\n sourceFile,\n factory,\n}: {\n sourceFile: ts.SourceFile;\n factory: ts.NodeFactory;\n}): ts.SourceFile => {\n // Check if the require already exists\n const existing = sourceFile.statements.find(\n (statement): statement is ts.VariableStatement =>\n ts.isVariableStatement(statement) &&\n statement.declarationList.declarations.some((decl) => {\n if (!ts.isIdentifier(decl.name) || decl.name.text !== \"__soda_gql_runtime\") {\n return false;\n }\n if (!decl.initializer || !ts.isCallExpression(decl.initializer)) {\n return false;\n }\n const callExpr = decl.initializer;\n if (!ts.isIdentifier(callExpr.expression) || callExpr.expression.text !== \"require\") {\n return false;\n }\n const arg = callExpr.arguments[0];\n return arg && ts.isStringLiteral(arg) && arg.text === RUNTIME_MODULE;\n }),\n );\n\n if (existing) {\n return sourceFile;\n }\n\n // Create: const __soda_gql_runtime = require(\"@soda-gql/runtime\");\n const requireCall = factory.createCallExpression(factory.createIdentifier(\"require\"), undefined, [\n factory.createStringLiteral(RUNTIME_MODULE),\n ]);\n\n const variableDeclaration = factory.createVariableDeclaration(\n factory.createIdentifier(\"__soda_gql_runtime\"),\n undefined,\n undefined,\n requireCall,\n );\n\n const variableStatement = factory.createVariableStatement(\n undefined,\n factory.createVariableDeclarationList([variableDeclaration], ts.NodeFlags.Const),\n );\n\n // Insert at the beginning of the file\n const newStatements = [variableStatement, ...sourceFile.statements];\n return factory.updateSourceFile(sourceFile, newStatements);\n};\n\n/**\n * Ensure that the gqlRuntime import exists in the source file.\n * gqlRuntime is always imported from @soda-gql/runtime.\n * Returns an updated source file with the import added or merged.\n */\nexport const ensureGqlRuntimeImport = ({\n sourceFile,\n factory,\n}: {\n sourceFile: ts.SourceFile;\n factory: ts.NodeFactory;\n}): ts.SourceFile => {\n const existing = sourceFile.statements.find(\n (statement): statement is ts.ImportDeclaration =>\n ts.isImportDeclaration(statement) &&\n ts.isStringLiteral(statement.moduleSpecifier) &&\n statement.moduleSpecifier.text === RUNTIME_MODULE,\n );\n\n if (existing?.importClause?.namedBindings && ts.isNamedImports(existing.importClause.namedBindings)) {\n const hasSpecifier = existing.importClause.namedBindings.elements.some(\n (element) => ts.isIdentifier(element.name) && element.name.text === \"gqlRuntime\",\n );\n\n if (hasSpecifier) {\n return sourceFile;\n }\n\n // Add gqlRuntime to existing import\n const newElements = [\n ...existing.importClause.namedBindings.elements,\n factory.createImportSpecifier(false, undefined, factory.createIdentifier(\"gqlRuntime\")),\n ];\n\n const newNamedBindings = factory.createNamedImports(newElements);\n const newImportClause = factory.createImportClause(false, undefined, newNamedBindings);\n const newImportDeclaration = factory.createImportDeclaration(\n undefined,\n newImportClause,\n factory.createStringLiteral(RUNTIME_MODULE),\n undefined,\n );\n\n const newStatements = sourceFile.statements.map((stmt) => (stmt === existing ? newImportDeclaration : stmt));\n return factory.updateSourceFile(sourceFile, newStatements);\n }\n\n // Create new import declaration\n const newImportDeclaration = factory.createImportDeclaration(\n undefined,\n factory.createImportClause(\n false,\n undefined,\n factory.createNamedImports([factory.createImportSpecifier(false, undefined, factory.createIdentifier(\"gqlRuntime\"))]),\n ),\n factory.createStringLiteral(RUNTIME_MODULE),\n undefined,\n );\n\n const newStatements = [newImportDeclaration, ...sourceFile.statements];\n return factory.updateSourceFile(sourceFile, newStatements);\n};\n\n/**\n * Remove the graphql-system import (runtimeModule) and gql-related exports from the source file.\n * After transformation, gqlRuntime is imported from @soda-gql/runtime instead,\n * so the original graphql-system import should be completely removed.\n *\n * This handles both ESM imports and CommonJS require() statements (including interop helpers).\n */\nexport const removeGraphqlSystemImports = ({\n sourceFile,\n factory,\n graphqlSystemIdentifyHelper,\n}: {\n sourceFile: ts.SourceFile;\n factory: ts.NodeFactory;\n graphqlSystemIdentifyHelper: GraphqlSystemIdentifyHelper;\n}): ts.SourceFile => {\n // After transformation, all gql usage should be replaced with gqlRuntime\n // So we can safely remove the graphql-system import and all gql-related exports\n const updatedStatements = Array.from(sourceFile.statements).filter((statement) => {\n // Remove ESM import declarations for the runtimeModule\n // - import { gql } from \"@/graphql-system\";\n // - import * as gql from \"@/graphql-system\";\n // - import gql from \"@/graphql-system\";\n // - import { gql as gqlRuntime } from \"@/graphql-system\";\n // - import * as gqlRuntime from \"@/graphql-system\";\n // - import gqlRuntime from \"@/graphql-system\";\n if (ts.isImportDeclaration(statement) && ts.isStringLiteral(statement.moduleSpecifier)) {\n return !graphqlSystemIdentifyHelper.isGraphqlSystemImportSpecifier({\n filePath: sourceFile.fileName,\n specifier: statement.moduleSpecifier.text,\n });\n }\n\n // Remove CommonJS require() statements for the runtimeModule\n // TypeScript emits these when downleveling ESM to CJS:\n // - const graphql_system_1 = require(\"../../graphql-system\");\n // - const { gql } = require(\"@/graphql-system\");\n // - const foo = __importDefault(require(\"@/graphql-system\"));\n // - const foo = __importStar(require(\"@/graphql-system\"));\n if (ts.isVariableStatement(statement)) {\n return !statement.declarationList.declarations.every((decl) => {\n const specifier = extractRequireTargetSpecifier(decl.initializer);\n if (!specifier) {\n return false;\n }\n\n return graphqlSystemIdentifyHelper.isGraphqlSystemImportSpecifier({\n filePath: sourceFile.fileName,\n specifier: specifier,\n });\n });\n }\n\n return true;\n });\n\n if (updatedStatements.length === sourceFile.statements.length) {\n return sourceFile;\n }\n\n return factory.updateSourceFile(sourceFile, updatedStatements);\n};\n\n/**\n * Create an \"after\" transformer that stubs out require() calls for the runtimeModule.\n * This runs after TypeScript's own transformers (including CommonJS down-leveling),\n * so we can replace `const X = require(\"@/graphql-system\")` with a lightweight stub.\n *\n * This prevents the heavy graphql-system module from being loaded at runtime.\n */\nexport const createAfterStubTransformer = ({\n sourceFile,\n graphqlSystemIdentifyHelper,\n}: {\n sourceFile: ts.SourceFile;\n graphqlSystemIdentifyHelper: GraphqlSystemIdentifyHelper;\n}): ts.TransformerFactory<ts.SourceFile> => {\n return (context) => {\n const factory = context.factory;\n\n const visitor = (node: ts.Node): ts.Node => {\n // Replace variable statements that require the runtimeModule with a stub\n if (ts.isVariableStatement(node)) {\n let transformed = false;\n\n const newDeclarations = node.declarationList.declarations.map((decl) => {\n const specifier = extractRequireTargetSpecifier(decl.initializer);\n if (!specifier) {\n return decl;\n }\n\n const isGraphqlSystemImport = graphqlSystemIdentifyHelper.isGraphqlSystemImportSpecifier({\n filePath: sourceFile.fileName,\n specifier,\n });\n if (!isGraphqlSystemImport) {\n return decl;\n }\n\n // Create stub: const X = /*#__PURE__*/Object.create(null);\n const stub = factory.createCallExpression(\n factory.createPropertyAccessExpression(factory.createIdentifier(\"Object\"), \"create\"),\n undefined,\n [factory.createNull()],\n );\n\n // Add /*#__PURE__*/ comment for tree-shaking\n ts.addSyntheticLeadingComment(stub, ts.SyntaxKind.MultiLineCommentTrivia, \"#__PURE__\", false);\n\n transformed = true;\n\n return factory.updateVariableDeclaration(decl, decl.name, decl.exclamationToken, decl.type, stub);\n });\n\n if (transformed) {\n return factory.updateVariableStatement(\n node,\n node.modifiers,\n factory.updateVariableDeclarationList(node.declarationList, newDeclarations),\n );\n }\n }\n\n return ts.visitEachChild(node, visitor, context);\n };\n\n return (sourceFile) => ts.visitNode(sourceFile, visitor) as ts.SourceFile;\n };\n};\n\n/**\n * Check if an expression is a require() call for the runtimeModule.\n * Handles multiple patterns:\n * - require(\"@/graphql-system\")\n * - __importDefault(require(\"@/graphql-system\"))\n * - __importStar(require(\"@/graphql-system\"))\n */\nconst extractRequireTargetSpecifier = (expr: ts.Expression | undefined): string | undefined => {\n if (!expr) {\n return undefined;\n }\n\n // Direct require(\"@/graphql-system\")\n if (ts.isCallExpression(expr)) {\n if (ts.isIdentifier(expr.expression) && expr.expression.text === \"require\") {\n const arg = expr.arguments[0];\n if (arg && ts.isStringLiteral(arg)) {\n return arg.text;\n }\n }\n\n // __importDefault(require(\"@/graphql-system\")) or __importStar(require(\"@/graphql-system\"))\n if (ts.isIdentifier(expr.expression)) {\n const helperName = expr.expression.text;\n if (helperName === \"__importDefault\" || helperName === \"__importStar\") {\n const arg = expr.arguments[0];\n if (arg && ts.isCallExpression(arg)) {\n if (ts.isIdentifier(arg.expression) && arg.expression.text === \"require\") {\n const requireArg = arg.arguments[0];\n if (requireArg && ts.isStringLiteral(requireArg)) {\n return requireArg.text;\n }\n }\n }\n }\n }\n }\n\n return undefined;\n};\n","import type { CanonicalPathTracker } from \"@soda-gql/common\";\nimport { createCanonicalTracker } from \"@soda-gql/common\";\nimport type { GqlDefinitionMetadata } from \"@soda-gql/plugin-common\";\nimport * as ts from \"typescript\";\n\nexport type GqlDefinitionMetadataMap = WeakMap<ts.CallExpression, GqlDefinitionMetadata>;\n\ntype CanonicalTrackerFactory = typeof createCanonicalTracker;\n\ntype CollectArgs = {\n readonly sourceFile: ts.SourceFile;\n readonly filename: string;\n readonly createTracker?: CanonicalTrackerFactory;\n};\n\ntype ScopeHandle = ReturnType<CanonicalPathTracker[\"enterScope\"]>;\ntype ExportBindingMap = Map<string, string>;\n\nexport const collectGqlDefinitionMetadata = ({ sourceFile, filename, createTracker }: CollectArgs): GqlDefinitionMetadataMap => {\n const exportBindings = collectExportBindings(sourceFile);\n const trackerFactory = createTracker ?? createCanonicalTracker;\n const tracker = trackerFactory({\n filePath: filename,\n getExportName: (localName) => exportBindings.get(localName),\n });\n\n const getAnonymousName = createAnonymousNameFactory();\n const scopeHandles = new WeakMap<ts.Node, ScopeHandle>();\n const metadata = new WeakMap<ts.CallExpression, GqlDefinitionMetadata>();\n\n const visit = (node: ts.Node): void => {\n // Handle GraphQL definition calls\n if (ts.isCallExpression(node) && isGqlDefinitionCall(node, ts)) {\n const depthBeforeRegister = tracker.currentDepth();\n const { astPath } = tracker.registerDefinition();\n const isTopLevel = depthBeforeRegister <= 1;\n const exportInfo = isTopLevel ? resolveTopLevelExport(node, exportBindings, ts) : null;\n\n metadata.set(node, {\n astPath,\n isTopLevel,\n isExported: exportInfo?.isExported ?? false,\n exportBinding: exportInfo?.exportBinding,\n });\n\n // Skip visiting children of gql calls\n return;\n }\n\n // Enter scope if this node creates one\n const handle = maybeEnterScope(node, tracker, getAnonymousName, ts);\n if (handle) {\n scopeHandles.set(node, handle);\n }\n\n // Visit children\n ts.forEachChild(node, visit);\n\n // Exit scope if we entered one\n const scopeHandle = scopeHandles.get(node);\n if (scopeHandle) {\n tracker.exitScope(scopeHandle);\n scopeHandles.delete(node);\n }\n };\n\n visit(sourceFile);\n\n return metadata;\n};\n\nconst collectExportBindings = (sourceFile: ts.SourceFile): ExportBindingMap => {\n const bindings: ExportBindingMap = new Map();\n\n for (const statement of sourceFile.statements) {\n // ESM exports: export const foo = ...\n if (ts.isExportDeclaration(statement) && statement.exportClause && ts.isNamedExports(statement.exportClause)) {\n for (const element of statement.exportClause.elements) {\n const name = element.name.text;\n bindings.set(name, name);\n }\n continue;\n }\n\n // Export variable declaration: export const foo = ...\n if (ts.isVariableStatement(statement) && statement.modifiers?.some((m) => m.kind === ts.SyntaxKind.ExportKeyword)) {\n for (const declaration of statement.declarationList.declarations) {\n if (ts.isIdentifier(declaration.name)) {\n bindings.set(declaration.name.text, declaration.name.text);\n }\n }\n continue;\n }\n\n // Export function/class: export function foo() {} or export class Foo {}\n if (\n (ts.isFunctionDeclaration(statement) || ts.isClassDeclaration(statement)) &&\n statement.modifiers?.some((m) => m.kind === ts.SyntaxKind.ExportKeyword) &&\n statement.name\n ) {\n bindings.set(statement.name.text, statement.name.text);\n continue;\n }\n\n // CommonJS exports: exports.foo = ... or module.exports.foo = ...\n if (ts.isExpressionStatement(statement) && ts.isBinaryExpression(statement.expression)) {\n const exportName = getCommonJsExportName(statement.expression.left);\n if (exportName) {\n bindings.set(exportName, exportName);\n }\n }\n }\n\n return bindings;\n};\n\nconst getCommonJsExportName = (node: ts.Node): string | null => {\n if (!ts.isPropertyAccessExpression(node)) {\n return null;\n }\n\n // Check if it's exports.foo or module.exports.foo\n const isExports = ts.isIdentifier(node.expression) && node.expression.text === \"exports\";\n const isModuleExports =\n ts.isPropertyAccessExpression(node.expression) &&\n ts.isIdentifier(node.expression.expression) &&\n node.expression.expression.text === \"module\" &&\n ts.isIdentifier(node.expression.name) &&\n node.expression.name.text === \"exports\";\n\n if (!isExports && !isModuleExports) {\n return null;\n }\n\n // Extract property name\n if (ts.isIdentifier(node.name)) {\n return node.name.text;\n }\n\n return null;\n};\n\nconst createAnonymousNameFactory = (): ((kind: string) => string) => {\n const counters = new Map<string, number>();\n return (kind) => {\n const count = counters.get(kind) ?? 0;\n counters.set(kind, count + 1);\n return `${kind}#${count}`;\n };\n};\n\nconst isGqlDefinitionCall = (node: ts.Node, typescript: typeof ts): node is ts.CallExpression => {\n if (!typescript.isCallExpression(node)) {\n return false;\n }\n if (!typescript.isPropertyAccessExpression(node.expression)) {\n return false;\n }\n if (!isGqlReference(node.expression.expression, typescript)) {\n return false;\n }\n if (node.arguments.length === 0) {\n return false;\n }\n const firstArg = node.arguments[0];\n if (firstArg === undefined) {\n return false;\n }\n return typescript.isArrowFunction(firstArg);\n};\n\nconst isGqlReference = (expr: ts.Expression, typescript: typeof ts): boolean => {\n if (typescript.isIdentifier(expr) && expr.text === \"gql\") {\n return true;\n }\n if (!typescript.isPropertyAccessExpression(expr)) {\n return false;\n }\n if (typescript.isIdentifier(expr.name) && expr.name.text === \"gql\") {\n return true;\n }\n return isGqlReference(expr.expression, typescript);\n};\n\nconst resolveTopLevelExport = (\n callNode: ts.CallExpression,\n exportBindings: ExportBindingMap,\n typescript: typeof ts,\n): { readonly isExported: true; readonly exportBinding: string } | null => {\n // ESM: const foo = gql.default(...); export { foo };\n const parent = callNode.parent;\n if (!parent) {\n return null;\n }\n\n if (typescript.isVariableDeclaration(parent)) {\n const { name } = parent;\n if (typescript.isIdentifier(name)) {\n const exportBinding = exportBindings.get(name.text);\n if (exportBinding) {\n return { isExported: true, exportBinding };\n }\n }\n }\n\n // CommonJS: exports.foo = gql.default(...);\n if (typescript.isBinaryExpression(parent)) {\n const exportName = getCommonJsExportName(parent.left);\n if (exportName && exportBindings.has(exportName)) {\n return { isExported: true, exportBinding: exportName };\n }\n }\n\n return null;\n};\n\nconst maybeEnterScope = (\n node: ts.Node,\n tracker: CanonicalPathTracker,\n getAnonymousName: (kind: string) => string,\n typescript: typeof ts,\n): ScopeHandle | null => {\n // CommonJS exports: exports.foo = ... or module.exports.foo = ...\n if (typescript.isBinaryExpression(node)) {\n const exportName = getCommonJsExportName(node.left);\n if (exportName) {\n return tracker.enterScope({ segment: exportName, kind: \"variable\", stableKey: `var:${exportName}` });\n }\n }\n\n if (typescript.isVariableDeclaration(node) && typescript.isIdentifier(node.name)) {\n const name = node.name.text;\n return tracker.enterScope({ segment: name, kind: \"variable\", stableKey: `var:${name}` });\n }\n\n if (typescript.isArrowFunction(node)) {\n const name = getAnonymousName(\"arrow\");\n return tracker.enterScope({ segment: name, kind: \"function\", stableKey: \"arrow\" });\n }\n\n if (typescript.isFunctionDeclaration(node) || typescript.isFunctionExpression(node)) {\n const explicitName = node.name?.text;\n const name = explicitName ?? getAnonymousName(\"function\");\n return tracker.enterScope({ segment: name, kind: \"function\", stableKey: `func:${name}` });\n }\n\n if (typescript.isClassDeclaration(node)) {\n const explicitName = node.name?.text;\n const name = explicitName ?? getAnonymousName(\"class\");\n return tracker.enterScope({ segment: name, kind: \"class\", stableKey: `class:${name}` });\n }\n\n if (typescript.isMethodDeclaration(node) && typescript.isIdentifier(node.name)) {\n const name = node.name.text;\n return tracker.enterScope({ segment: name, kind: \"method\", stableKey: `member:${name}` });\n }\n\n if (typescript.isPropertyDeclaration(node) && typescript.isIdentifier(node.name)) {\n const name = node.name.text;\n return tracker.enterScope({ segment: name, kind: \"property\", stableKey: `member:${name}` });\n }\n\n if (typescript.isPropertyAssignment(node)) {\n const key = node.name;\n const name = typescript.isIdentifier(key) ? key.text : typescript.isStringLiteral(key) ? key.text : null;\n if (name) {\n return tracker.enterScope({ segment: name, kind: \"property\", stableKey: `prop:${name}` });\n }\n }\n\n return null;\n};\n","import type { BuilderArtifactElement } from \"@soda-gql/builder\";\nimport type { CanonicalId } from \"@soda-gql/common\";\nimport type {\n GqlCallFragment,\n GqlCallOperation,\n PluginAnalysisArtifactMissingError,\n PluginAnalysisMetadataMissingError,\n PluginAnalysisUnsupportedArtifactTypeError,\n PluginError,\n} from \"@soda-gql/plugin-common\";\nimport { resolveCanonicalId } from \"@soda-gql/plugin-common\";\nimport { err, ok, type Result } from \"neverthrow\";\nimport type * as ts from \"typescript\";\nimport type { GqlDefinitionMetadataMap } from \"./metadata\";\n\nexport type ArtifactLookup = (canonicalId: CanonicalId) => BuilderArtifactElement | undefined;\n\n// TypeScript-specific GqlCall types\nexport type TsGqlCallFragment = GqlCallFragment & { readonly callNode: ts.CallExpression };\nexport type TsGqlCallOperation = GqlCallOperation & { readonly callNode: ts.CallExpression };\n\nexport type TsGqlCall = TsGqlCallFragment | TsGqlCallOperation;\n\nexport type ExtractGqlCallArgs = {\n readonly callNode: ts.CallExpression;\n readonly filename: string;\n readonly metadata: GqlDefinitionMetadataMap;\n readonly getArtifact: ArtifactLookup;\n};\n\nexport const extractGqlCall = ({\n callNode,\n filename,\n metadata,\n getArtifact,\n}: ExtractGqlCallArgs): Result<TsGqlCall, PluginError> => {\n const meta = metadata.get(callNode);\n if (!meta) {\n return err(createMetadataMissingError({ filename }));\n }\n\n const canonicalId = resolveCanonicalId(filename, meta.astPath);\n const artifact = getArtifact(canonicalId);\n\n if (!artifact) {\n return err(createArtifactMissingError({ filename, canonicalId }));\n }\n\n if (artifact.type === \"fragment\") {\n return ok({ callNode, canonicalId, type: \"fragment\", artifact });\n }\n\n if (artifact.type === \"operation\") {\n return ok({ callNode, canonicalId, type: \"operation\", artifact });\n }\n\n return err(\n createUnsupportedArtifactTypeError({\n filename,\n canonicalId,\n artifactType: (artifact as { type: string }).type,\n }),\n );\n};\n\ntype MetadataErrorInput = { readonly filename: string };\ntype ArtifactMissingErrorInput = { readonly filename: string; readonly canonicalId: CanonicalId };\ntype UnsupportedArtifactTypeInput = {\n readonly filename: string;\n readonly canonicalId: CanonicalId;\n readonly artifactType: string;\n};\n\nconst createMetadataMissingError = ({ filename }: MetadataErrorInput): PluginAnalysisMetadataMissingError => ({\n type: \"PluginError\",\n stage: \"analysis\",\n code: \"SODA_GQL_METADATA_NOT_FOUND\",\n message: `No GraphQL metadata found for ${filename}`,\n cause: { filename },\n filename,\n});\n\nconst createArtifactMissingError = ({\n filename,\n canonicalId,\n}: ArtifactMissingErrorInput): PluginAnalysisArtifactMissingError => ({\n type: \"PluginError\",\n stage: \"analysis\",\n code: \"SODA_GQL_ANALYSIS_ARTIFACT_NOT_FOUND\",\n message: `No builder artifact found for canonical ID ${canonicalId}`,\n cause: { filename, canonicalId },\n filename,\n canonicalId,\n});\n\nconst createUnsupportedArtifactTypeError = ({\n filename,\n canonicalId,\n artifactType,\n}: UnsupportedArtifactTypeInput): PluginAnalysisUnsupportedArtifactTypeError => ({\n type: \"PluginError\",\n stage: \"analysis\",\n code: \"SODA_GQL_UNSUPPORTED_ARTIFACT_TYPE\",\n message: `Unsupported builder artifact type \"${artifactType}\" for canonical ID ${canonicalId}`,\n cause: { filename, canonicalId, artifactType },\n filename,\n canonicalId,\n artifactType,\n});\n","import type { PluginError, PluginTransformUnsupportedValueTypeError } from \"@soda-gql/plugin-common\";\nimport { err, ok, type Result } from \"neverthrow\";\nimport * as ts from \"typescript\";\n\nconst createUnsupportedValueTypeError = (valueType: string): PluginTransformUnsupportedValueTypeError => ({\n type: \"PluginError\",\n stage: \"transform\",\n code: \"SODA_GQL_TRANSFORM_UNSUPPORTED_VALUE_TYPE\",\n message: `Unsupported value type: ${valueType}`,\n cause: { valueType },\n valueType,\n});\n\n/**\n * Build a literal expression from a primitive value.\n * Mirrors Babel's buildLiteralFromValue.\n */\nexport const buildLiteralFromValue = (factory: ts.NodeFactory, value: unknown): Result<ts.Expression, PluginError> => {\n if (value === null) {\n return ok(factory.createNull());\n }\n if (typeof value === \"string\") {\n return ok(factory.createStringLiteral(value));\n }\n if (typeof value === \"number\") {\n return ok(factory.createNumericLiteral(value));\n }\n if (typeof value === \"boolean\") {\n return ok(value ? factory.createTrue() : factory.createFalse());\n }\n if (Array.isArray(value)) {\n const elements: ts.Expression[] = [];\n for (const item of value) {\n const result = buildLiteralFromValue(factory, item);\n if (result.isErr()) {\n return result;\n }\n elements.push(result.value);\n }\n return ok(factory.createArrayLiteralExpression(elements));\n }\n if (typeof value === \"object\") {\n const properties: ts.PropertyAssignment[] = [];\n for (const [key, val] of Object.entries(value)) {\n const result = buildLiteralFromValue(factory, val);\n if (result.isErr()) {\n return result;\n }\n properties.push(factory.createPropertyAssignment(factory.createIdentifier(key), result.value));\n }\n return ok(factory.createObjectLiteralExpression(properties));\n }\n return err(createUnsupportedValueTypeError(typeof value));\n};\n\n/**\n * Clone a TypeScript node deeply.\n * TypeScript nodes are immutable, so we need to use visitEachChild for deep cloning.\n */\nexport const clone = <T extends ts.Node>(node: T): T => {\n const cloneVisitor = (n: ts.Node): ts.Node => ts.visitEachChild(n, cloneVisitor, undefined);\n return cloneVisitor(node) as T;\n};\n\n/**\n * Build an object literal expression from a record of properties.\n */\nexport const buildObjectExpression = <K extends string>(\n factory: ts.NodeFactory,\n properties: Record<K, ts.Expression>,\n): ts.ObjectLiteralExpression => {\n const propertyAssignments = Object.entries<ts.Expression>(properties).map(([key, value]) =>\n factory.createPropertyAssignment(factory.createIdentifier(key), value),\n );\n return factory.createObjectLiteralExpression(propertyAssignments);\n};\n\n/**\n * Build a JSON.parse expression from an object value.\n * This is used to emit large objects as JSON strings to reduce the calculation cost of both the compiler and the runtime.\n */\nexport const buildJsonParseExpression = <T extends object>(factory: ts.NodeFactory, value: T): ts.Expression =>\n factory.createCallExpression(\n factory.createPropertyAccessExpression(factory.createIdentifier(\"JSON\"), factory.createIdentifier(\"parse\")),\n undefined,\n [factory.createStringLiteral(JSON.stringify(value))],\n );\n","import type { RuntimeFragmentInput, RuntimeOperationInput } from \"@soda-gql/core/runtime\";\nimport type { PluginError } from \"@soda-gql/plugin-common\";\nimport { ok, type Result } from \"neverthrow\";\nimport type * as ts from \"typescript\";\nimport type { TsGqlCallFragment, TsGqlCallOperation } from \"./analysis\";\nimport { buildJsonParseExpression, buildObjectExpression } from \"./ast\";\n\nconst createRuntimeAccessor = ({ isCJS, factory }: { isCJS: boolean; factory: ts.NodeFactory }) =>\n isCJS\n ? factory.createPropertyAccessExpression(\n factory.createIdentifier(\"__soda_gql_runtime\"),\n factory.createIdentifier(\"gqlRuntime\"),\n )\n : factory.createIdentifier(\"gqlRuntime\");\n\nexport const buildFragmentRuntimeCall = ({\n gqlCall,\n factory,\n isCJS,\n}: {\n gqlCall: TsGqlCallFragment;\n factory: ts.NodeFactory;\n isCJS: boolean;\n filename: string;\n}): Result<ts.Expression, PluginError> => {\n return ok(\n factory.createCallExpression(\n factory.createPropertyAccessExpression(createRuntimeAccessor({ isCJS, factory }), factory.createIdentifier(\"fragment\")),\n undefined,\n [\n buildObjectExpression(factory, {\n prebuild: buildObjectExpression<keyof RuntimeFragmentInput[\"prebuild\"]>(factory, {\n typename: factory.createStringLiteral(gqlCall.artifact.prebuild.typename),\n }),\n }),\n ],\n ),\n );\n};\n\nexport const buildOperationRuntimeComponents = ({\n gqlCall,\n factory,\n isCJS,\n}: {\n gqlCall: TsGqlCallOperation;\n factory: ts.NodeFactory;\n isCJS: boolean;\n}): Result<{ referenceCall: ts.Expression; runtimeCall: ts.Expression }, PluginError> => {\n const runtimeCall = factory.createCallExpression(\n factory.createPropertyAccessExpression(createRuntimeAccessor({ isCJS, factory }), factory.createIdentifier(\"operation\")),\n undefined,\n [\n buildObjectExpression(factory, {\n prebuild: buildJsonParseExpression<RuntimeOperationInput[\"prebuild\"]>(factory, gqlCall.artifact.prebuild),\n runtime: buildObjectExpression(factory, {}),\n }),\n ],\n );\n\n const referenceCall = factory.createCallExpression(\n factory.createPropertyAccessExpression(createRuntimeAccessor({ isCJS, factory }), factory.createIdentifier(\"getOperation\")),\n undefined,\n [factory.createStringLiteral(gqlCall.artifact.prebuild.operationName)],\n );\n\n return ok({\n referenceCall,\n runtimeCall,\n });\n};\n","import type { PluginError } from \"@soda-gql/plugin-common\";\nimport { err, ok, type Result } from \"neverthrow\";\nimport type * as ts from \"typescript\";\nimport type { ArtifactLookup, TsGqlCall } from \"./analysis\";\nimport { extractGqlCall } from \"./analysis\";\nimport type { GqlDefinitionMetadataMap } from \"./metadata\";\nimport { buildFragmentRuntimeCall, buildOperationRuntimeComponents } from \"./runtime\";\n\ntype TransformCallExpressionArgs = {\n readonly callNode: ts.CallExpression;\n readonly filename: string;\n readonly metadata: GqlDefinitionMetadataMap;\n readonly getArtifact: ArtifactLookup;\n readonly factory: ts.NodeFactory;\n readonly isCJS: boolean;\n};\n\ntype TransformCallExpressionResult =\n | { readonly transformed: false }\n | { readonly transformed: true; readonly replacement: ts.Expression; readonly runtimeCall?: ts.Expression };\n\nexport const transformCallExpression = ({\n callNode,\n filename,\n metadata,\n getArtifact,\n factory,\n isCJS,\n}: TransformCallExpressionArgs): Result<TransformCallExpressionResult, PluginError> => {\n // Skip if this call doesn't have GQL metadata\n if (!metadata.has(callNode)) {\n return ok({ transformed: false });\n }\n\n const gqlCallResult = extractGqlCall({\n callNode,\n filename,\n metadata,\n getArtifact,\n });\n\n if (gqlCallResult.isErr()) {\n return err(gqlCallResult.error);\n }\n\n const gqlCall = gqlCallResult.value;\n\n return replaceWithRuntimeCall({ gqlCall, factory, isCJS, filename });\n};\n\nconst replaceWithRuntimeCall = ({\n gqlCall,\n factory,\n isCJS,\n filename,\n}: {\n gqlCall: TsGqlCall;\n factory: ts.NodeFactory;\n isCJS: boolean;\n filename: string;\n}): Result<TransformCallExpressionResult, PluginError> => {\n if (gqlCall.type === \"fragment\") {\n const result = buildFragmentRuntimeCall({ gqlCall, factory, isCJS, filename });\n if (result.isErr()) {\n return err(result.error);\n }\n return ok({ transformed: true, replacement: result.value as ts.Expression });\n }\n\n if (gqlCall.type === \"operation\") {\n const result = buildOperationRuntimeComponents({ gqlCall, factory, isCJS });\n if (result.isErr()) {\n return err(result.error);\n }\n const { referenceCall, runtimeCall } = result.value;\n return ok({ transformed: true, replacement: referenceCall, runtimeCall });\n }\n\n return ok({ transformed: false });\n};\n","/**\n * TypeScript implementation of the TransformAdapter interface.\n */\n\nimport type { BuilderArtifact } from \"@soda-gql/builder\";\nimport { createGraphqlSystemIdentifyHelper } from \"@soda-gql/builder\";\nimport type { CanonicalId } from \"@soda-gql/common\";\nimport type { ResolvedSodaGqlConfig } from \"@soda-gql/config\";\nimport { formatPluginError } from \"@soda-gql/plugin-common\";\nimport * as ts from \"typescript\";\nimport { ensureGqlRuntimeImport, ensureGqlRuntimeRequire, removeGraphqlSystemImports } from \"./ast/imports\";\nimport { collectGqlDefinitionMetadata } from \"./ast/metadata\";\nimport { transformCallExpression } from \"./ast/transformer\";\n\nexport { createAfterStubTransformer } from \"./ast/imports\";\n\n/**\n * TypeScript-specific environment required for the adapter.\n */\nexport type TypeScriptEnv = {\n readonly sourceFile: ts.SourceFile;\n readonly context: ts.TransformationContext;\n};\n\nconst findLastImportIndex = ({ sourceFile }: { sourceFile: ts.SourceFile }): number => {\n let lastIndex = -1;\n const statements = sourceFile.statements;\n\n for (let i = 0; i < statements.length; i++) {\n const statement = statements[i];\n if (statement && ts.isImportDeclaration(statement)) {\n lastIndex = i;\n }\n }\n\n return lastIndex;\n};\n\nexport const createTransformer = ({\n compilerOptions,\n config,\n artifact,\n}: {\n readonly compilerOptions: ts.CompilerOptions;\n readonly config: ResolvedSodaGqlConfig;\n readonly artifact: BuilderArtifact;\n}) => {\n const isCJS = compilerOptions.module === ts.ModuleKind.CommonJS || compilerOptions.target === ts.ScriptTarget.ES5;\n\n // Create graphql system identify helper using builder's implementation\n const graphqlSystemIdentifyHelper = createGraphqlSystemIdentifyHelper(config);\n\n const makeSourceFileEmpty = ({ factory, sourceFile }: { factory: ts.NodeFactory; sourceFile: ts.SourceFile }) => {\n return factory.updateSourceFile(sourceFile, [\n factory.createExportDeclaration(undefined, false, factory.createNamedExports([]), undefined),\n ]);\n };\n\n const transformGqlCalls = ({ sourceFile, context }: { sourceFile: ts.SourceFile; context: ts.TransformationContext }) => {\n let transformed = false;\n\n const metadata = collectGqlDefinitionMetadata({\n sourceFile,\n filename: sourceFile.fileName,\n });\n\n const runtimeCallsFromLastTransform: ts.Expression[] = [];\n const visitor = (node: ts.Node): ts.Node => {\n if (ts.isCallExpression(node)) {\n const result = transformCallExpression({\n callNode: node,\n filename: sourceFile.fileName,\n metadata,\n getArtifact: (canonicalId: CanonicalId) => artifact.elements[canonicalId],\n factory: context.factory,\n isCJS,\n });\n\n if (result.isErr()) {\n // Log error and continue - don't fail the entire build for a single error\n console.error(`[@soda-gql/tsc-plugin] ${formatPluginError(result.error)}`);\n return node;\n }\n\n const transformResult = result.value;\n if (transformResult.transformed) {\n transformed = true;\n\n if (transformResult.runtimeCall) {\n runtimeCallsFromLastTransform.push(transformResult.runtimeCall);\n }\n\n return transformResult.replacement;\n }\n }\n\n return ts.visitEachChild(node, visitor, context);\n };\n\n const visitedNode = ts.visitNode(sourceFile, visitor);\n if (!visitedNode || !ts.isSourceFile(visitedNode)) {\n console.error(`[@soda-gql/tsc-plugin] Failed to transform source file: ${sourceFile.fileName}`);\n return sourceFile;\n }\n\n if (!transformed) {\n return sourceFile;\n }\n\n if (runtimeCallsFromLastTransform.length === 0) {\n return visitedNode;\n }\n\n const lastImportIndex = findLastImportIndex({ sourceFile });\n\n return context.factory.updateSourceFile(visitedNode, [\n ...visitedNode.statements.slice(0, lastImportIndex + 1),\n ...runtimeCallsFromLastTransform.map((expr) => context.factory.createExpressionStatement(expr)),\n ...visitedNode.statements.slice(lastImportIndex + 1),\n ]);\n };\n\n return {\n transform: ({ sourceFile, context }: { sourceFile: ts.SourceFile; context: ts.TransformationContext }) => {\n if (graphqlSystemIdentifyHelper.isGraphqlSystemFile({ filePath: sourceFile.fileName })) {\n const transformedSourceFile = makeSourceFileEmpty({ factory: context.factory, sourceFile: sourceFile });\n return { transformed: true, sourceFile: transformedSourceFile };\n }\n\n const original = sourceFile;\n let current = sourceFile;\n current = transformGqlCalls({ sourceFile: current, context });\n\n if (current !== sourceFile) {\n current = isCJS\n ? ensureGqlRuntimeRequire({ sourceFile: current, factory: context.factory })\n : ensureGqlRuntimeImport({ sourceFile: current, factory: context.factory });\n }\n\n current = removeGraphqlSystemImports({\n sourceFile: current,\n factory: context.factory,\n graphqlSystemIdentifyHelper,\n });\n\n return { transformed: current !== original, sourceFile: current };\n },\n };\n};\n"],"mappings":";;;;;;;;AAGA,MAAM,iBAAiB;;;;;;AAOvB,MAAa,2BAA2B,EACtC,YACA,cAImB;AAqBnB,KAnBiB,WAAW,WAAW,MACpC,cACC,GAAG,oBAAoB,UAAU,IACjC,UAAU,gBAAgB,aAAa,MAAM,SAAS;AACpD,MAAI,CAAC,GAAG,aAAa,KAAK,KAAK,IAAI,KAAK,KAAK,SAAS,qBACpD,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AAa;GACnD,GAAG,YAAY,WAAW,MAAM,GAAG,kBAAkB,EAAE;GACvD,GAAG,8BAA8B,KAAK,SAAS,QAAQ,QAAQ,0BAA0B,KAAK,CAAC;GAC/F,GAAG,YAAY,WAAW,MAAM,kBAAkB,EAAE;GACrD,CAAC;;AAGJ,QAAO,EACL,YAAY,EAAE,YAAY,cAAgF;AACxG,MAAI,4BAA4B,oBAAoB,EAAE,UAAU,WAAW,UAAU,CAAC,CAEpF,QAAO;GAAE,aAAa;GAAM,YADE,oBAAoB;IAAE,SAAS,QAAQ;IAAqB;IAAY,CAAC;GACxC;EAGjE,MAAM,WAAW;EACjB,IAAI,UAAU;AACd,YAAU,kBAAkB;GAAE,YAAY;GAAS;GAAS,CAAC;AAE7D,MAAI,YAAY,WACd,WAAU,QACN,wBAAwB;GAAE,YAAY;GAAS,SAAS,QAAQ;GAAS,CAAC,GAC1E,uBAAuB;GAAE,YAAY;GAAS,SAAS,QAAQ;GAAS,CAAC;AAG/E,YAAU,2BAA2B;GACnC,YAAY;GACZ,SAAS,QAAQ;GACjB;GACD,CAAC;AAEF,SAAO;GAAE,aAAa,YAAY;GAAU,YAAY;GAAS;IAEpE"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@soda-gql/tsc-transformer",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
|
+
"description": "TypeScript AST transformer for soda-gql",
|
|
4
5
|
"type": "module",
|
|
5
6
|
"private": false,
|
|
6
7
|
"license": "MIT",
|
|
@@ -12,32 +13,52 @@
|
|
|
12
13
|
"email": "shota.hatada@whatasoda.me",
|
|
13
14
|
"url": "https://github.com/whatasoda"
|
|
14
15
|
},
|
|
16
|
+
"keywords": [
|
|
17
|
+
"graphql",
|
|
18
|
+
"codegen",
|
|
19
|
+
"zero-runtime",
|
|
20
|
+
"typescript",
|
|
21
|
+
"tsc",
|
|
22
|
+
"transformer"
|
|
23
|
+
],
|
|
24
|
+
"repository": {
|
|
25
|
+
"type": "git",
|
|
26
|
+
"url": "https://github.com/whatasoda/soda-gql.git",
|
|
27
|
+
"directory": "packages/tsc-transformer"
|
|
28
|
+
},
|
|
29
|
+
"homepage": "https://github.com/whatasoda/soda-gql#readme",
|
|
30
|
+
"bugs": {
|
|
31
|
+
"url": "https://github.com/whatasoda/soda-gql/issues"
|
|
32
|
+
},
|
|
33
|
+
"engines": {
|
|
34
|
+
"node": ">=18"
|
|
35
|
+
},
|
|
15
36
|
"main": "./dist/index.mjs",
|
|
16
37
|
"module": "./dist/index.mjs",
|
|
17
38
|
"types": "./dist/index.d.mts",
|
|
18
39
|
"exports": {
|
|
40
|
+
"./test": {
|
|
41
|
+
"@soda-gql": "./@devx-test.ts"
|
|
42
|
+
},
|
|
19
43
|
".": {
|
|
20
|
-
"@soda-gql": "
|
|
44
|
+
"@soda-gql": "./@x-index.ts",
|
|
21
45
|
"types": "./dist/index.d.mts",
|
|
22
46
|
"import": "./dist/index.mjs",
|
|
23
47
|
"require": "./dist/index.cjs",
|
|
24
48
|
"default": "./dist/index.mjs"
|
|
25
49
|
},
|
|
26
|
-
"./test": {
|
|
27
|
-
"@soda-gql": "./test/export.ts"
|
|
28
|
-
},
|
|
29
50
|
"./package.json": "./package.json"
|
|
30
51
|
},
|
|
31
52
|
"dependencies": {
|
|
32
|
-
"@soda-gql/builder": "0.
|
|
33
|
-
"@soda-gql/common": "0.
|
|
34
|
-
"@soda-gql/config": "0.
|
|
35
|
-
"@soda-gql/core": "0.
|
|
36
|
-
"@soda-gql/plugin-common": "0.
|
|
53
|
+
"@soda-gql/builder": "0.2.0",
|
|
54
|
+
"@soda-gql/common": "0.2.0",
|
|
55
|
+
"@soda-gql/config": "0.2.0",
|
|
56
|
+
"@soda-gql/core": "0.2.0",
|
|
57
|
+
"@soda-gql/plugin-common": "0.2.0",
|
|
37
58
|
"neverthrow": "^8.1.1"
|
|
38
59
|
},
|
|
39
60
|
"devDependencies": {
|
|
40
|
-
"@soda-gql/codegen": "0.
|
|
61
|
+
"@soda-gql/codegen": "0.2.0",
|
|
41
62
|
"prettier": "^3.4.2"
|
|
42
63
|
},
|
|
43
64
|
"peerDependencies": {
|