@apollo/client-ai-apps 0.7.3 → 0.7.5
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/CHANGELOG.md +16 -0
- package/dist/vite/apolloClientAiApps.d.ts.map +1 -1
- package/dist/vite/apolloClientAiApps.js +2 -1
- package/dist/vite/apolloClientAiApps.js.map +1 -1
- package/integration-tests/package-lock.json +16 -19
- package/integration-tests/package.json +1 -1
- package/package.json +4 -7
- package/src/vite/__tests__/apolloClientAiApps.test.ts +161 -62
- package/src/vite/apolloClientAiApps.ts +2 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,19 @@
|
|
|
1
|
+
## 0.7.5 (2026-05-29)
|
|
2
|
+
|
|
3
|
+
### Fixes
|
|
4
|
+
|
|
5
|
+
#### Remove unused dependencies
|
|
6
|
+
|
|
7
|
+
Remove unused `crypto-hash` dependency.
|
|
8
|
+
|
|
9
|
+
## 0.7.4 (2026-05-29)
|
|
10
|
+
|
|
11
|
+
### Fixes
|
|
12
|
+
|
|
13
|
+
#### Handle lowercase operation names
|
|
14
|
+
|
|
15
|
+
Fixes tool input type generation when the tool name is set from the operation name and the operation name is lowercase.
|
|
16
|
+
|
|
1
17
|
## 0.7.3 (2026-05-13)
|
|
2
18
|
|
|
3
19
|
### Fixes
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"apolloClientAiApps.d.ts","sourceRoot":"","sources":["../../src/vite/apolloClientAiApps.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,MAAM,EAEZ,MAAM,MAAM,CAAC;AAMd,OAAO,EAA4B,KAAK,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAqB7E,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,oBAAoB,CAAC;AAenE,MAAM,CAAC,OAAO,WAAW,kBAAkB,CAAC;IAC1C,KAAY,MAAM,GAAG,wBAAwB,CAAC,SAAS,CAAC;IAExD,UAAiB,OAAO;QACtB,OAAO,EAAE,MAAM,EAAE,CAAC;QAClB,SAAS,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;QAC/B,UAAU,EAAE,MAAM,CAAC;QACnB,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;KAC7B;CACF;AAgBD,wBAAgB,SAAS,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,gCAOnD;
|
|
1
|
+
{"version":3,"file":"apolloClientAiApps.d.ts","sourceRoot":"","sources":["../../src/vite/apolloClientAiApps.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,MAAM,EAEZ,MAAM,MAAM,CAAC;AAMd,OAAO,EAA4B,KAAK,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAqB7E,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,oBAAoB,CAAC;AAenE,MAAM,CAAC,OAAO,WAAW,kBAAkB,CAAC;IAC1C,KAAY,MAAM,GAAG,wBAAwB,CAAC,SAAS,CAAC;IAExD,UAAiB,OAAO;QACtB,OAAO,EAAE,MAAM,EAAE,CAAC;QAClB,SAAS,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;QAC/B,UAAU,EAAE,MAAM,CAAC;QACnB,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;KAC7B;CACF;AAgBD,wBAAgB,SAAS,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,gCAOnD;AAgUD,wBAAgB,kBAAkB,CAChC,OAAO,EAAE,kBAAkB,CAAC,OAAO,GAClC,MAAM,CAoZR;AAwHD,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,YAAY,GAAG,YAAY,CA2CzE"}
|
|
@@ -165,10 +165,11 @@ async function generateOperationTypes(schema, documents) {
|
|
|
165
165
|
documents,
|
|
166
166
|
generates: {
|
|
167
167
|
"operation-types.d.ts": {
|
|
168
|
-
plugins: ["typescript
|
|
168
|
+
plugins: ["typescript-operations"],
|
|
169
169
|
config: {
|
|
170
170
|
nonOptionalTypename: true,
|
|
171
171
|
skipTypeNameForRoot: true,
|
|
172
|
+
namingConvention: "keep",
|
|
172
173
|
},
|
|
173
174
|
},
|
|
174
175
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"apolloClientAiApps.js","sourceRoot":"","sources":["../../src/vite/apolloClientAiApps.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,uBAAuB,GAGxB,MAAM,MAAM,CAAC;AACd,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,KAAK,MAAM,MAAM,QAAQ,CAAC;AACjC,OAAO,gBAAgB,MAAM,8BAA8B,CAAC;AAC5D,OAAO,EAAE,YAAY,EAAE,UAAU,EAAqB,MAAM,gBAAgB,CAAC;AAC7E,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAC/C,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AACtC,OAAO,EAAE,0BAA0B,EAAE,MAAM,kCAAkC,CAAC;AAC9E,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAC5B,OAAO,EAAE,KAAK,EAAE,MAAM,0BAA0B,CAAC;AACjD,OAAO,EAAE,4BAA4B,EAAE,MAAM,mCAAmC,CAAC;AACjF,OAAO,EAAE,EAAE,EAAE,MAAM,MAAM,CAAC;AAC1B,OAAO,EAAE,IAAI,EAAE,iBAAiB,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAChE,OAAO,EACL,gBAAgB,EAChB,oBAAoB,EACpB,WAAW,EACX,qBAAqB,GACtB,MAAM,wBAAwB,CAAC;AAKhC,OAAO,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AACtD,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAEjD,OAAO,EAAE,8BAA8B,EAAE,MAAM,qBAAqB,CAAC;AACrE,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C,mBAAmB,GAAG,CAAC,KAAK,2BAA2B;KACxE,CAAC;IACF,WAAW,EAAE,CAAC,CAAC,MAAM,EAAE;IACvB,WAAW,EAAE,CAAC,CAAC,QAAQ,CACrB,CAAC,CAAC,KAAK,CACL,CAAC,CAAC,YAAY,CAAC;QACb,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE;QAChB,WAAW,EAAE,CAAC,CAAC,MAAM,EAAE;QACvB,IAAI,EAAE,CAAC,CAAC,OAAO,CAAC,CAAC,QAAQ,EAAE,SAAS,EAAE,QAAQ,CAAC,CAAC;KACjD,CAAC,CACH,CACF;IACD,YAAY,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC;IAC3D,MAAM,EAAE,8BAA8B,CAAC,KAAK,CAAC,MAAM,CAAC,QAAQ,EAAE;CAC/D,CAAC,CAAC","sourcesContent":["import {\n defaultClientConditions,\n type Plugin,\n type ResolvedConfig,\n} from \"vite\";\nimport { createHash } from \"node:crypto\";\nimport path from \"node:path\";\nimport fs from \"node:fs\";\nimport * as recast from \"recast\";\nimport typescriptParser from \"recast/parsers/typescript.js\";\nimport { ApolloClient, ApolloLink, type DocumentNode } from \"@apollo/client\";\nimport { InMemoryCache } from \"@apollo/client\";\nimport { equal } from \"@wry/equality\";\nimport { gqlPluckFromCodeStringSync } from \"@graphql-tools/graphql-tag-pluck\";\nimport { glob } from \"glob\";\nimport { print } from \"@apollo/client/utilities\";\nimport { removeDirectivesFromDocument } from \"@apollo/client/utilities/internal\";\nimport { of } from \"rxjs\";\nimport { Kind, OperationTypeNode, parse, visit } from \"graphql\";\nimport {\n getArgumentValue,\n getDirectiveArgument,\n getTypeName,\n maybeGetArgumentValue,\n} from \"./utilities/graphql.js\";\nimport type {\n ApplicationManifest,\n ManifestOperation,\n} from \"../types/application-manifest\";\nimport { invariant } from \"../utilities/invariant.js\";\nimport { explorer } from \"./utilities/config.js\";\nimport type { ApolloClientAiAppsConfig } from \"../config/index.js\";\nimport { ApolloClientAiAppsConfigSchema } from \"../config/schema.js\";\nimport { z } from \"zod\";\nimport { createFragmentRegistry } from \"@apollo/client/cache\";\nimport {\n buildImportStatement,\n buildPropertySignature,\n buildKeywordLiteral,\n printRecast,\n type TSInterfaceBody,\n} from \"./utilities/recast.js\";\nimport type { TypeScriptDocumentsPluginConfig } from \"@graphql-codegen/typescript-operations\";\n\nconst b = recast.types.builders;\n\nexport declare namespace apolloClientAiApps {\n export type Target = ApolloClientAiAppsConfig.AppTarget;\n\n export interface Options {\n targets: Target[];\n devTarget?: Target | undefined;\n appsOutDir: string;\n schema?: string | undefined;\n }\n}\n\nconst root = process.cwd();\n\nconst VALID_TARGETS: apolloClientAiApps.Target[] = [\"openai\", \"mcp\"];\n\nfunction isValidTarget(target: unknown): target is apolloClientAiApps.Target {\n return VALID_TARGETS.includes(target as apolloClientAiApps.Target);\n}\n\nfunction buildExtensions(target: apolloClientAiApps.Target) {\n return [\".mjs\", \".js\", \".mts\", \".ts\", \".jsx\", \".tsx\", \".json\"].flatMap(\n (ext) => [`.${target}${ext}`, ext]\n );\n}\n\nexport function devTarget(target: string | undefined) {\n invariant(\n target === undefined || isValidTarget(target),\n `devTarget '${target}' is not a valid dev target. Must be one of ${VALID_TARGETS.join(\", \")}.`\n );\n\n return target;\n}\n\ninterface FileCache {\n hash: string;\n sources: DocumentNode[];\n}\n\nfunction md5(contents: string) {\n return createHash(\"md5\").update(contents).digest(\"hex\");\n}\n\n/**\n * Builds the AST for the comment used at the top of a generated file from this\n * plugin.\n *\n * @remarks\n * This comment informs users that generated files from this plugin should not\n * be edited since it is autogenerated by this plugin.\n */\nfunction buildHeaderComment() {\n return b.commentLine(\n \" This file is auto-generated by @apollo/client-ai-apps. Do not edit manually.\",\n true,\n false\n );\n}\n\n/**\n * Builds the `@apollo/client-ai-apps` ambient module declaration for the\n * `register.d.ts` file.\n *\n * @param registerInterfaceBody - The interface body for the `Register`\n * interface\n *\n * @example\n * ```ts\n * buildAmbientModuleDeclaration(interfaceBody);\n * // =>\n * // declare namespace \"@apollo/client-ai-apps\" {\n * // interface Register {\n * // // ...interfaceBody\n * // }\n * // }\n * ```\n */\nfunction buildAmbientModuleDeclaration(registerInterfaceBody: TSInterfaceBody) {\n const interfaceDeclaration = b.tsInterfaceDeclaration(\n b.identifier(\"Register\"),\n b.tsInterfaceBody(registerInterfaceBody)\n );\n\n const moduleDeclaration = b.tsModuleDeclaration(\n b.stringLiteral(\"@apollo/client-ai-apps\"),\n b.tsModuleBlock([interfaceDeclaration])\n );\n moduleDeclaration.declare = true;\n\n return moduleDeclaration;\n}\n\n/**\n * Gets the variables type name for an operation. GraphQL Codegen creates\n * variables types with the combination of operationName + operationType +\n * \"Variables\"\n *\n * @example\n * ```ts\n * getVariablesTypeName({ name: \"GetProduct\", type: \"query\" });\n * // => \"GetProductQueryVariables\"\n * ````\n */\nfunction getVariablesTypeName(operation: ManifestOperation) {\n const { name, type } = operation;\n\n return `${name}${type.charAt(0).toUpperCase()}${type.slice(1)}Variables`;\n}\n\n/**\n * Returns the code string written to the `.apollo-client-ai-apps/types/register.d.ts` files\n * for a given set of operations.\n */\nfunction getRegisteredTypeContents({\n operations,\n schema,\n flagSchemaBuildError = false,\n}: {\n operations: ManifestOperation[];\n schema: string | undefined;\n /**\n * Used during dev to avoid failing the build and instead output the error\n * to the console. When providing an error, the error message is generated as\n * a literal type value in the `register.d.ts` file so that users can see the\n * error message when hovering over the type.\n */\n flagSchemaBuildError?: false | Error;\n}) {\n if (flagSchemaBuildError) {\n const message = `[@apollo/client-ai-apps/vite]: There was an error building generated types. See the vite build output for more details.\\n\\n${flagSchemaBuildError.message}`;\n\n const importBaseStatement = buildImportStatement(\n [],\n \"@apollo/client-ai-apps\"\n );\n importBaseStatement.comments = [buildHeaderComment()];\n\n const typeAnnotation = b.tsLiteralType(b.stringLiteral(message));\n\n return printRecast(\n b.program([\n importBaseStatement,\n buildAmbientModuleDeclaration([\n buildPropertySignature(\"toolName\", typeAnnotation),\n buildPropertySignature(\n \"toolInputs\",\n b.tsTypeLiteral([buildPropertySignature(message, typeAnnotation)])\n ),\n ]),\n ])\n );\n }\n\n const toolNames = operations.flatMap((op) => op.tools.map((t) => t.name));\n\n if (toolNames.length === 0) {\n const emptyExport = b.exportNamedDeclaration(null);\n emptyExport.comments = [buildHeaderComment()];\n return printRecast(b.program([emptyExport]));\n }\n\n const importBaseStatement = buildImportStatement(\n [],\n \"@apollo/client-ai-apps\"\n );\n importBaseStatement.comments = [buildHeaderComment()];\n\n const toolNameProp = buildPropertySignature(\n \"toolName\",\n b.tsUnionType(toolNames.map((n) => b.tsLiteralType(b.stringLiteral(n))))\n );\n\n if (!schema) {\n return printRecast(\n b.program([\n importBaseStatement,\n buildAmbientModuleDeclaration([toolNameProp]),\n ])\n );\n }\n\n const importedVariableTypes = new Set<string>();\n const toolInputsValue: recast.types.namedTypes.TSPropertySignature[] = [];\n\n for (const operation of operations) {\n const variablesTypeName = getVariablesTypeName(operation);\n\n if (operation.tools.length) {\n importedVariableTypes.add(variablesTypeName);\n }\n\n for (const tool of operation.tools) {\n const variablesTypeRef = b.tsTypeReference(\n b.identifier(variablesTypeName)\n );\n let typeExpression:\n | recast.types.namedTypes.TSTypeReference\n | recast.types.namedTypes.TSIntersectionType = variablesTypeRef;\n\n if (tool.extraInputs?.length) {\n const extraInputsType = tool.extraInputs.map((ei) => {\n return buildPropertySignature(\n ei.name,\n buildKeywordLiteral(ei.type),\n true\n );\n });\n\n typeExpression = b.tsIntersectionType([\n variablesTypeRef,\n b.tsTypeLiteral(extraInputsType),\n ]);\n }\n\n toolInputsValue.push(buildPropertySignature(tool.name, typeExpression));\n }\n }\n\n return printRecast(\n b.program([\n importBaseStatement,\n buildImportStatement(\n Array.from(importedVariableTypes),\n \"./operation-types.js\",\n \"type\"\n ),\n buildAmbientModuleDeclaration([\n toolNameProp,\n buildPropertySignature(\"toolInputs\", b.tsTypeLiteral(toolInputsValue)),\n ]),\n ])\n );\n}\n\n/**\n * Generates and returns the code string written to the\n * `.apollo-client-ai-apps/types/operation-types.d.ts` file. Uses GraphQL\n * Codegen to introspect the given schema and extract variable types.\n */\nasync function generateOperationTypes(\n schema: string,\n documents: string[]\n): Promise<string> {\n const { generate } = await import(\"@graphql-codegen/cli\");\n\n if (documents.length === 0) {\n return `// Auto-generated by @apollo/client-ai-apps. Do not edit manually.\\nexport {};\\n`;\n }\n\n const output = await generate(\n {\n schema,\n documents,\n generates: {\n \"operation-types.d.ts\": {\n plugins: [\"typescript\", \"typescript-operations\"],\n config: {\n nonOptionalTypename: true,\n skipTypeNameForRoot: true,\n } satisfies TypeScriptDocumentsPluginConfig,\n },\n },\n silent: true,\n } as Parameters<typeof generate>[0],\n false\n );\n\n const content = (output as { filename: string; content: string }[])[0]\n .content;\n return `// Auto-generated by @apollo/client-ai-apps. Do not edit manually.\\n${content}`;\n}\n\n/**\n * Gets the name of an exported type (e.g. `export type x`) from a TypeScript\n * AST statement.\n */\nfunction getExportedTypeAliasName(\n statement: recast.types.namedTypes.Statement\n): string | undefined {\n if (statement.type !== \"ExportNamedDeclaration\") return;\n\n const declaration = (\n statement as recast.types.namedTypes.ExportNamedDeclaration\n ).declaration;\n\n if (!declaration || declaration.type !== \"TSTypeAliasDeclaration\") return;\n\n const alias = declaration as recast.types.namedTypes.TSTypeAliasDeclaration;\n return typeof alias.id.name === \"string\" ? alias.id.name : undefined;\n}\n\n/**\n * Removes all non-`*Variables` types from the `operation-types.d.ts` file.\n * The `typescript` and `typescript-operations` codegen plugins add full schema\n * types and operation types. This function ensures those unused types are\n * removed.\n */\nfunction filterOperationTypes(\n content: string,\n rootTypeNames: Set<string>\n): string {\n const ast = recast.parse(content, { parser: typescriptParser });\n const statements: recast.types.namedTypes.Statement[] = ast.program.body;\n const typeMap = new Map<\n string,\n recast.types.namedTypes.TSTypeAliasDeclaration\n >();\n\n for (const statement of statements) {\n const name = getExportedTypeAliasName(statement);\n\n if (name) {\n typeMap.set(\n name,\n (statement as recast.types.namedTypes.ExportNamedDeclaration)\n .declaration as recast.types.namedTypes.TSTypeAliasDeclaration\n );\n }\n }\n\n const reachable = new Set<string>(rootTypeNames);\n const queue = Array.from(rootTypeNames);\n\n while (queue.length > 0) {\n const name = queue.shift()!;\n const node = typeMap.get(name);\n\n if (!node) continue;\n\n recast.visit(node, {\n visitTSTypeReference(path) {\n const typeName = path.value.typeName?.name as string | undefined;\n\n if (typeName && !reachable.has(typeName)) {\n reachable.add(typeName);\n queue.push(typeName);\n }\n\n this.traverse(path);\n },\n });\n }\n\n ast.program.body = statements.filter((statement) => {\n const name = getExportedTypeAliasName(statement);\n return name === undefined || reachable.has(name);\n });\n\n return printRecast(ast);\n}\n\nexport function apolloClientAiApps(\n options: apolloClientAiApps.Options\n): Plugin {\n const targets = Array.from(new Set(options.targets));\n const {\n devTarget = targets.length === 1 ? targets[0] : undefined,\n appsOutDir,\n schema,\n } = options;\n let config!: ResolvedConfig;\n\n const fragments = createFragmentRegistry();\n\n invariant(\n Array.isArray(targets) && targets.length > 0,\n \"The `targets` option must be a non-empty array\"\n );\n\n invariant(\n targets.every(isValidTarget),\n `All targets must be one of: ${VALID_TARGETS.join(\", \")}`\n );\n\n invariant(\n path.basename(path.normalize(appsOutDir)) === \"apps\",\n \"`appsOutDir` must end with `apps` as the final path segment (e.g. `path/to/apps`).\"\n );\n\n const client = new ApolloClient({\n cache: new InMemoryCache({ fragments }),\n link: processQueryLink,\n });\n\n let sources: DocumentNode[] = [];\n\n function recomputeSources(cache: Map<string, FileCache>) {\n sources = Array.from(cache.values()).flatMap((entry) => entry.sources);\n }\n\n async function getManifestOperations() {\n if (sources === getManifestOperations.cache.sources) {\n return getManifestOperations.cache.manifestOperations;\n }\n\n const manifestOperations = [];\n for (const source of sources) {\n const operationDef = source.definitions.find(\n (d) => d.kind === Kind.OPERATION_DEFINITION\n );\n\n if (!operationDef) continue;\n\n switch (operationDef.operation) {\n case OperationTypeNode.QUERY: {\n const result = await client.query<ManifestOperation>({\n query: source,\n fetchPolicy: \"no-cache\",\n });\n const data = result.data!;\n\n if (data.tools.length > 0 || data.prefetch) {\n manifestOperations.push(data);\n }\n break;\n }\n case OperationTypeNode.MUTATION: {\n const result = await client.mutate<ManifestOperation>({\n mutation: source,\n fetchPolicy: \"no-cache\",\n });\n const data = result.data!;\n\n if (data.tools.length > 0 || data.prefetch) {\n manifestOperations.push(data);\n }\n break;\n }\n default:\n throw new Error(\n `Found unsupported operation type '${operationDef.operation}'. Only queries and mutations are supported.`\n );\n }\n }\n\n getManifestOperations.cache = { sources, manifestOperations };\n\n return manifestOperations;\n }\n\n getManifestOperations.cache = {\n sources,\n manifestOperations: [] as ManifestOperation[],\n };\n\n async function processFile(file: string) {\n const code = fs.readFileSync(file, \"utf-8\");\n\n if (!code.includes(\"gql\")) return;\n\n const fileHash = md5(code);\n if (processFile.cache.get(file)?.hash === fileHash) return;\n\n const sources = gqlPluckFromCodeStringSync(file, code, {\n modules: [\n { name: \"graphql-tag\", identifier: \"gql\" },\n { name: \"@apollo/client\", identifier: \"gql\" },\n ],\n }).map((source) => parse(source.body));\n\n const previousSources = processFile.cache.get(file)?.sources;\n\n if (previousSources && equal(sources, previousSources)) {\n processFile.cache.set(file, { hash: fileHash, sources: previousSources });\n return;\n }\n\n fragments.register(...sources);\n\n processFile.cache.set(file, { hash: fileHash, sources });\n recomputeSources(processFile.cache);\n }\n\n processFile.cache = new Map<string, FileCache>();\n\n async function generateManifest() {\n const appsConfig = await getAppsConfig();\n const operations = await getManifestOperations();\n\n invariant(\n operations.filter((o) => o.prefetch).length <= 1,\n \"Found multiple operations marked as `@prefetch`. You can only mark 1 operation with `@prefetch`.\"\n );\n\n function getBuildResourceForTarget(target: apolloClientAiApps.Target) {\n const entryPoint = getResourceFromConfig(appsConfig, config.mode, target);\n\n if (entryPoint) {\n return entryPoint;\n }\n\n if (config.mode === \"production\") {\n return `${target}/index.html`;\n }\n\n throw new Error(\n `No entry point found for mode \"${config.mode}\". Entry points other than \"development\" and \"production\" must be defined in package.json file.`\n );\n }\n\n let resource: ApplicationManifest[\"resource\"];\n if (config.command === \"serve\") {\n // Dev mode: resource is a string (dev server URL)\n resource =\n getResourceFromConfig(appsConfig, config.mode, devTarget!) ??\n `http${config.server.https ? \"s\" : \"\"}://${config.server.host ?? \"localhost\"}:${config.server.port}`;\n } else {\n resource = Object.fromEntries(\n targets.map((target) => [target, getBuildResourceForTarget(target)])\n ) as { mcp?: string; openai?: string };\n }\n\n const packageJson = readPackageJson();\n const appName = appsConfig.name ?? packageJson.name;\n\n invariant(\n appName,\n \"Error generating application manifest. Could not determine app name. Set `name` in your apollo-client-ai-apps config or `package.json`.\"\n );\n\n const manifest: ApplicationManifest = {\n format: \"apollo-ai-app-manifest\",\n version: \"1\",\n appVersion: appsConfig.version ?? packageJson.version,\n name: appsConfig.name ?? packageJson.name,\n description: appsConfig.description ?? packageJson.description,\n hash: createHash(\"sha256\").update(Date.now().toString()).digest(\"hex\"),\n operations,\n resource,\n csp: {\n baseUriDomains: appsConfig.csp?.baseUriDomains ?? [],\n connectDomains: appsConfig.csp?.connectDomains ?? [],\n frameDomains: appsConfig.csp?.frameDomains ?? [],\n redirectDomains: appsConfig.csp?.redirectDomains ?? [],\n resourceDomains: appsConfig.csp?.resourceDomains ?? [],\n },\n };\n\n if (isNonEmptyObject(appsConfig.widgetSettings)) {\n manifest.widgetSettings = appsConfig.widgetSettings;\n }\n\n if (isNonEmptyObject(appsConfig.labels)) {\n manifest.labels = appsConfig.labels;\n }\n\n const manifestContents = JSON.stringify(manifest);\n\n // Always write to build directory so the MCP server picks it up\n writeFileSync(\n path.resolve(root, appsOutDir, appName, \".application-manifest.json\"),\n manifestContents\n );\n\n // Always write to the dev location so that the app can bundle the manifest content\n writeFileSync(\".application-manifest.json\", manifestContents);\n\n const manifestTypesFilepath = \".application-manifest.d.json.ts\";\n if (!fs.existsSync(manifestTypesFilepath)) {\n const manifestImport = b.importDeclaration(\n [b.importSpecifier(b.identifier(\"ApplicationManifest\"))],\n b.stringLiteral(\"@apollo/client-ai-apps\"),\n \"type\"\n );\n const manifestId = b.identifier(\"manifest\");\n manifestId.typeAnnotation = b.tsTypeAnnotation(\n b.tsTypeReference(b.identifier(\"ApplicationManifest\"), null)\n );\n const manifestDeclaration = b.variableDeclaration(\"const\", [\n b.variableDeclarator(manifestId, null),\n ]) as recast.types.namedTypes.VariableDeclaration & { declare: boolean };\n manifestDeclaration.declare = true;\n\n const exportDefault = b.exportDefaultDeclaration(\n b.identifier(\"manifest\")\n );\n\n const content = printRecast(\n b.program([manifestImport, manifestDeclaration, exportDefault])\n );\n\n writeFileSync(manifestTypesFilepath, content);\n }\n }\n\n async function generateTypesFiles() {\n let flagSchemaBuildError: false | Error = false;\n const operations = await getManifestOperations();\n\n if (operations === generateTypesFiles.cache) {\n return;\n }\n\n generateTypesFiles.cache = operations;\n\n if (schema) {\n try {\n const opTypesContent = await generateOperationTypes(\n schema,\n operations.map((op) => op.body)\n );\n\n const rootTypeNames = new Set(\n operations.flatMap((op) =>\n op.tools.length > 0 ? [getVariablesTypeName(op)] : []\n )\n );\n\n writeFileSync(\n path.resolve(\n root,\n \".apollo-client-ai-apps/types/operation-types.d.ts\"\n ),\n filterOperationTypes(opTypesContent, rootTypeNames),\n { cache: true }\n );\n } catch (e) {\n if (config.command === \"build\") {\n throw e;\n }\n\n flagSchemaBuildError = e as Error;\n console.error(\"[@apollo/client-ai-apps/vite]:\", e);\n }\n }\n\n const typesFileContents = getRegisteredTypeContents({\n operations,\n schema,\n flagSchemaBuildError,\n });\n\n writeFileSync(\n path.resolve(root, \".apollo-client-ai-apps/types/register.d.ts\"),\n typesFileContents,\n { cache: true }\n );\n }\n\n generateTypesFiles.cache = [] as ManifestOperation[] | undefined;\n\n return {\n name: \"@apollo/client-ai-apps/vite\",\n async buildStart() {\n // Scan all files on startup\n const files = await glob(\"./src/**/*.{ts,tsx,js,jsx}\", { fs });\n\n for (const file of files) {\n const fullPath = path.resolve(root, file);\n await processFile(fullPath);\n }\n\n await Promise.all([generateManifest(), generateTypesFiles()]);\n },\n configResolved(resolvedConfig) {\n config = resolvedConfig;\n },\n async configEnvironment(name) {\n if (!targets.includes(name as any)) return;\n\n const appsConfig = await getAppsConfig();\n const appName = appsConfig.name ?? readPackageJson().name;\n\n invariant(\n appName,\n \"Could not determine app name. Set `name` in your apollo-client-ai-apps config or `package.json`.\"\n );\n\n return {\n build: {\n outDir: path.join(appsOutDir, appName, name),\n },\n };\n },\n configureServer(server) {\n server.watcher.on(\"change\", async (file) => {\n if (file.endsWith(\"package.json\")) {\n readPackageJson.resetCache();\n await generateManifest();\n } else if (file.match(/\\.?apollo-client-ai-apps\\.config\\.\\w+$/)) {\n explorer.clearCaches();\n await generateManifest();\n } else if (file.match(/\\.(jsx?|tsx?)$/)) {\n await processFile(file);\n await Promise.all([generateManifest(), generateTypesFiles()]);\n }\n });\n },\n\n config(userConfig, { command }) {\n if (userConfig.build?.outDir) {\n console.warn(\n \"[@apollo/client-ai-apps/vite] `build.outDir` is set in your Vite config but will be \" +\n \"ignored. Use `appsOutDir` in the plugin options to control the output location.\"\n );\n }\n\n if (command === \"serve\") {\n invariant(\n isValidTarget(devTarget) || targets.length === 1,\n \"`devTarget` must be set for development when using multiple targets.\"\n );\n\n const target = devTarget ?? targets[0];\n\n return {\n resolve: {\n extensions: buildExtensions(target),\n conditions: [target, ...defaultClientConditions],\n },\n };\n }\n\n return {\n environments: Object.fromEntries(\n targets.map((target) => [\n target,\n {\n consumer: \"client\",\n webCompatible: true,\n resolve: {\n extensions: buildExtensions(target),\n conditions: [target, ...defaultClientConditions],\n },\n },\n ])\n ),\n builder: {\n buildApp: async (builder) => {\n await Promise.all(\n targets.map((target) =>\n builder.build(builder.environments[target])\n )\n );\n },\n },\n };\n },\n transformIndexHtml(html, ctx) {\n if (!ctx.server) return html;\n\n let baseUrl = (\n ctx.server.config?.server?.origin ??\n ctx.server.resolvedUrls?.local[0] ??\n \"\"\n ).replace(/\\/$/, \"\");\n baseUrl = baseUrl.replace(/\\/$/, \"\");\n\n return (\n html\n // import \"/@vite/...\" or \"/@react-refresh\"\n .replace(/(from\\s+[\"'])\\/([^\"']+)/g, `$1${baseUrl}/$2`)\n // src=\"/src/...\"\n .replace(/(src=[\"'])\\/([^\"']+)/gi, `$1${baseUrl}/$2`)\n );\n },\n } satisfies Plugin;\n}\n\nconst processQueryLink = new ApolloLink((operation) => {\n const body = print(\n removeOperationDescription(\n removeManifestDirectives(sortTopLevelDefinitions(operation.query))\n )\n );\n const name = operation.operationName;\n const definition = operation.query.definitions.find(\n (d) => d.kind === \"OperationDefinition\"\n );\n\n // Use `operation.query` so that the error reflects the end-user defined\n // document, not our sorted one\n invariant(\n definition,\n `Document does not contain an operation:\\n${print(operation.query)}`\n );\n\n const { directives, operation: type } = definition;\n\n const variables = definition.variableDefinitions?.reduce(\n (obj, varDef) => ({\n ...obj,\n [varDef.variable.name.value]: getTypeName(varDef.type),\n }),\n {}\n );\n\n const prefetch = directives?.some((d) => d.name.value === \"prefetch\");\n const id = createHash(\"sha256\").update(body).digest(\"hex\");\n // TODO: For now, you can only have 1 operation marked as prefetch. In the future, we'll likely support more than 1, and the \"prefetchId\" will be defined on the `@prefetch` itself as an argument\n const prefetchID = prefetch ? \"__anonymous\" : undefined;\n\n const toolDirectives =\n directives?.filter((d) => d.name.value === \"tool\") ?? [];\n\n const tools = toolDirectives.map((directive) => {\n const nameArg = getDirectiveArgument(\"name\", directive);\n const descriptionArg = getDirectiveArgument(\"description\", directive);\n\n let name: string;\n if (nameArg) {\n name = getArgumentValue(nameArg, Kind.STRING);\n } else {\n invariant(\n toolDirectives.length === 1,\n `Operations with multiple @tool directives must provide a 'name' argument on each @tool`\n );\n invariant(\n definition.name?.value,\n `Anonymous operations cannot use @tool without providing a 'name' argument`\n );\n name = definition.name.value;\n }\n\n let description: string;\n if (descriptionArg) {\n description = getArgumentValue(descriptionArg, Kind.STRING);\n } else {\n invariant(\n toolDirectives.length === 1,\n `Operations with multiple @tool directives must provide a 'description' argument on each @tool`\n );\n invariant(\n definition.description?.value,\n `Operations using @tool without a 'description' argument must have a description on the operation definition`\n );\n description = definition.description.value;\n }\n\n const result = ToolDirectiveSchema.safeParse({\n name,\n description,\n extraInputs: maybeGetArgumentValue(\n getDirectiveArgument(\"extraInputs\", directive),\n Kind.LIST\n ),\n extraOutputs: maybeGetArgumentValue(\n getDirectiveArgument(\"extraOutputs\", directive),\n Kind.OBJECT\n ),\n labels: maybeGetArgumentValue(\n getDirectiveArgument(\"labels\", directive),\n Kind.OBJECT\n ),\n });\n\n if (result.error) {\n throw z.prettifyError(result.error);\n }\n\n return result.data;\n });\n\n // TODO: Make this object satisfy the `ManifestOperation` type. Currently\n // it errors because we need more validation on a few of these fields\n return of({\n data: { id, name, type, body, variables, prefetch, prefetchID, tools },\n });\n});\n\nfunction removeOperationDescription(doc: DocumentNode): DocumentNode {\n return visit(doc, {\n OperationDefinition(node) {\n return { ...node, description: undefined };\n },\n });\n}\n\nfunction removeManifestDirectives(doc: DocumentNode) {\n return removeDirectivesFromDocument(\n [{ name: \"prefetch\" }, { name: \"tool\" }],\n doc\n )!;\n}\n\n// Sort the definitions in this document so that operations come before fragments,\n// and so that each kind of definition is sorted by name.\nexport function sortTopLevelDefinitions(query: DocumentNode): DocumentNode {\n const definitions = [...query.definitions];\n // We want to avoid unnecessary dependencies, so write out a comparison\n // function instead of using _.orderBy.\n definitions.sort((a, b) => {\n // This is a reverse sort by kind, so that OperationDefinition precedes FragmentDefinition.\n if (a.kind > b.kind) {\n return -1;\n }\n if (a.kind < b.kind) {\n return 1;\n }\n\n // Extract the name from each definition. Jump through some hoops because\n // non-executable definitions don't have to have names (even though any\n // DocumentNode actually passed here should only have executable\n // definitions).\n const aName =\n a.kind === \"OperationDefinition\" || a.kind === \"FragmentDefinition\" ?\n (a.name?.value ?? \"\")\n : \"\";\n const bName =\n b.kind === \"OperationDefinition\" || b.kind === \"FragmentDefinition\" ?\n (b.name?.value ?? \"\")\n : \"\";\n\n // Sort by name ascending.\n if (aName < bName) {\n return -1;\n }\n if (aName > bName) {\n return 1;\n }\n\n // Assuming that the document is \"valid\", no operation or fragment name can appear\n // more than once, so we don't need to differentiate further to have a deterministic\n // sort.\n return 0;\n });\n return {\n ...query,\n definitions,\n };\n}\n\nfunction isNonEmptyObject<T extends object>(\n obj: T | null | undefined\n): obj is T {\n return !!obj && Object.keys(obj).length > 0;\n}\n\nasync function getAppsConfig() {\n const result = await explorer.search();\n const config = (result?.config ??\n {}) as Partial<ApolloClientAiAppsConfig.Config>;\n\n const parsed = ApolloClientAiAppsConfigSchema.safeParse(config);\n\n if (parsed.error) {\n throw z.prettifyError(parsed.error);\n }\n\n return parsed.data;\n}\n\nfunction getResourceFromConfig(\n appsConfig: z.infer<typeof ApolloClientAiAppsConfigSchema>,\n mode: string,\n target: apolloClientAiApps.Target\n) {\n if (!appsConfig.entry || !appsConfig.entry[mode]) {\n return;\n }\n\n const config = appsConfig.entry[mode];\n\n return typeof config === \"string\" ? config : config[target];\n}\n\nfunction readPackageJson(): Record<string, any> {\n if (readPackageJson.cache) {\n return readPackageJson.cache;\n }\n\n return (readPackageJson.cache = JSON.parse(\n fs.readFileSync(\"package.json\", \"utf-8\")\n ));\n}\n\nreadPackageJson.cache = undefined as Record<string, any> | undefined;\nreadPackageJson.resetCache = () => {\n readPackageJson.cache = undefined;\n};\n\nfunction writeFileSync(\n filepath: string,\n content: string,\n options: { cache?: boolean } = {}\n) {\n function writeFile() {\n fs.mkdirSync(path.dirname(filepath), { recursive: true });\n fs.writeFileSync(filepath, content, \"utf-8\");\n }\n\n if (!options.cache) {\n return writeFile();\n }\n\n const hash = md5(content);\n const cachedHash = writeFileSync.cache.get(filepath);\n\n if (hash !== cachedHash || !fs.existsSync(filepath)) {\n writeFileSync.cache.set(filepath, hash);\n writeFile();\n }\n}\n\nwriteFileSync.cache = new Map<string, string>();\n\nconst ToolDirectiveSchema = z.strictObject({\n name: z.stringFormat(\"toolName\", (value) => value.indexOf(\" \") === -1, {\n error: (iss) => `Tool with name \"${iss.input}\" must not contain spaces`,\n }),\n description: z.string(),\n extraInputs: z.optional(\n z.array(\n z.strictObject({\n name: z.string(),\n description: z.string(),\n type: z.literal([\"string\", \"boolean\", \"number\"]),\n })\n )\n ),\n extraOutputs: z.optional(z.record(z.string(), z.unknown())),\n labels: ApolloClientAiAppsConfigSchema.shape.labels.optional(),\n});\n"]}
|
|
1
|
+
{"version":3,"file":"apolloClientAiApps.js","sourceRoot":"","sources":["../../src/vite/apolloClientAiApps.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,uBAAuB,GAGxB,MAAM,MAAM,CAAC;AACd,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,KAAK,MAAM,MAAM,QAAQ,CAAC;AACjC,OAAO,gBAAgB,MAAM,8BAA8B,CAAC;AAC5D,OAAO,EAAE,YAAY,EAAE,UAAU,EAAqB,MAAM,gBAAgB,CAAC;AAC7E,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAC/C,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AACtC,OAAO,EAAE,0BAA0B,EAAE,MAAM,kCAAkC,CAAC;AAC9E,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAC5B,OAAO,EAAE,KAAK,EAAE,MAAM,0BAA0B,CAAC;AACjD,OAAO,EAAE,4BAA4B,EAAE,MAAM,mCAAmC,CAAC;AACjF,OAAO,EAAE,EAAE,EAAE,MAAM,MAAM,CAAC;AAC1B,OAAO,EAAE,IAAI,EAAE,iBAAiB,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAChE,OAAO,EACL,gBAAgB,EAChB,oBAAoB,EACpB,WAAW,EACX,qBAAqB,GACtB,MAAM,wBA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IACzC,IAAI,EAAE,CAAC,CAAC,YAAY,CAAC,UAAU,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE;QACrE,KAAK,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,mBAAmB,GAAG,CAAC,KAAK,2BAA2B;KACxE,CAAC;IACF,WAAW,EAAE,CAAC,CAAC,MAAM,EAAE;IACvB,WAAW,EAAE,CAAC,CAAC,QAAQ,CACrB,CAAC,CAAC,KAAK,CACL,CAAC,CAAC,YAAY,CAAC;QACb,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE;QAChB,WAAW,EAAE,CAAC,CAAC,MAAM,EAAE;QACvB,IAAI,EAAE,CAAC,CAAC,OAAO,CAAC,CAAC,QAAQ,EAAE,SAAS,EAAE,QAAQ,CAAC,CAAC;KACjD,CAAC,CACH,CACF;IACD,YAAY,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC;IAC3D,MAAM,EAAE,8BAA8B,CAAC,KAAK,CAAC,MAAM,CAAC,QAAQ,EAAE;CAC/D,CAAC,CAAC","sourcesContent":["import {\n defaultClientConditions,\n type Plugin,\n type ResolvedConfig,\n} from \"vite\";\nimport { createHash } from \"node:crypto\";\nimport path from \"node:path\";\nimport fs from \"node:fs\";\nimport * as recast from \"recast\";\nimport typescriptParser from \"recast/parsers/typescript.js\";\nimport { ApolloClient, ApolloLink, type DocumentNode } from \"@apollo/client\";\nimport { InMemoryCache } from \"@apollo/client\";\nimport { equal } from \"@wry/equality\";\nimport { gqlPluckFromCodeStringSync } from \"@graphql-tools/graphql-tag-pluck\";\nimport { glob } from \"glob\";\nimport { print } from \"@apollo/client/utilities\";\nimport { removeDirectivesFromDocument } from \"@apollo/client/utilities/internal\";\nimport { of } from \"rxjs\";\nimport { Kind, OperationTypeNode, parse, visit } from \"graphql\";\nimport {\n getArgumentValue,\n getDirectiveArgument,\n getTypeName,\n maybeGetArgumentValue,\n} from \"./utilities/graphql.js\";\nimport type {\n ApplicationManifest,\n ManifestOperation,\n} from \"../types/application-manifest\";\nimport { invariant } from \"../utilities/invariant.js\";\nimport { explorer } from \"./utilities/config.js\";\nimport type { ApolloClientAiAppsConfig } from \"../config/index.js\";\nimport { ApolloClientAiAppsConfigSchema } from \"../config/schema.js\";\nimport { z } from \"zod\";\nimport { createFragmentRegistry } from \"@apollo/client/cache\";\nimport {\n buildImportStatement,\n buildPropertySignature,\n buildKeywordLiteral,\n printRecast,\n type TSInterfaceBody,\n} from \"./utilities/recast.js\";\nimport type { TypeScriptDocumentsPluginConfig } from \"@graphql-codegen/typescript-operations\";\n\nconst b = recast.types.builders;\n\nexport declare namespace apolloClientAiApps {\n export type Target = ApolloClientAiAppsConfig.AppTarget;\n\n export interface Options {\n targets: Target[];\n devTarget?: Target | undefined;\n appsOutDir: string;\n schema?: string | undefined;\n }\n}\n\nconst root = process.cwd();\n\nconst VALID_TARGETS: apolloClientAiApps.Target[] = [\"openai\", \"mcp\"];\n\nfunction isValidTarget(target: unknown): target is apolloClientAiApps.Target {\n return VALID_TARGETS.includes(target as apolloClientAiApps.Target);\n}\n\nfunction buildExtensions(target: apolloClientAiApps.Target) {\n return [\".mjs\", \".js\", \".mts\", \".ts\", \".jsx\", \".tsx\", \".json\"].flatMap(\n (ext) => [`.${target}${ext}`, ext]\n );\n}\n\nexport function devTarget(target: string | undefined) {\n invariant(\n target === undefined || isValidTarget(target),\n `devTarget '${target}' is not a valid dev target. Must be one of ${VALID_TARGETS.join(\", \")}.`\n );\n\n return target;\n}\n\ninterface FileCache {\n hash: string;\n sources: DocumentNode[];\n}\n\nfunction md5(contents: string) {\n return createHash(\"md5\").update(contents).digest(\"hex\");\n}\n\n/**\n * Builds the AST for the comment used at the top of a generated file from this\n * plugin.\n *\n * @remarks\n * This comment informs users that generated files from this plugin should not\n * be edited since it is autogenerated by this plugin.\n */\nfunction buildHeaderComment() {\n return b.commentLine(\n \" This file is auto-generated by @apollo/client-ai-apps. Do not edit manually.\",\n true,\n false\n );\n}\n\n/**\n * Builds the `@apollo/client-ai-apps` ambient module declaration for the\n * `register.d.ts` file.\n *\n * @param registerInterfaceBody - The interface body for the `Register`\n * interface\n *\n * @example\n * ```ts\n * buildAmbientModuleDeclaration(interfaceBody);\n * // =>\n * // declare namespace \"@apollo/client-ai-apps\" {\n * // interface Register {\n * // // ...interfaceBody\n * // }\n * // }\n * ```\n */\nfunction buildAmbientModuleDeclaration(registerInterfaceBody: TSInterfaceBody) {\n const interfaceDeclaration = b.tsInterfaceDeclaration(\n b.identifier(\"Register\"),\n b.tsInterfaceBody(registerInterfaceBody)\n );\n\n const moduleDeclaration = b.tsModuleDeclaration(\n b.stringLiteral(\"@apollo/client-ai-apps\"),\n b.tsModuleBlock([interfaceDeclaration])\n );\n moduleDeclaration.declare = true;\n\n return moduleDeclaration;\n}\n\n/**\n * Gets the variables type name for an operation. GraphQL Codegen creates\n * variables types with the combination of operationName + operationType +\n * \"Variables\"\n *\n * @example\n * ```ts\n * getVariablesTypeName({ name: \"GetProduct\", type: \"query\" });\n * // => \"GetProductQueryVariables\"\n * ````\n */\nfunction getVariablesTypeName(operation: ManifestOperation) {\n const { name, type } = operation;\n\n return `${name}${type.charAt(0).toUpperCase()}${type.slice(1)}Variables`;\n}\n\n/**\n * Returns the code string written to the `.apollo-client-ai-apps/types/register.d.ts` files\n * for a given set of operations.\n */\nfunction getRegisteredTypeContents({\n operations,\n schema,\n flagSchemaBuildError = false,\n}: {\n operations: ManifestOperation[];\n schema: string | undefined;\n /**\n * Used during dev to avoid failing the build and instead output the error\n * to the console. When providing an error, the error message is generated as\n * a literal type value in the `register.d.ts` file so that users can see the\n * error message when hovering over the type.\n */\n flagSchemaBuildError?: false | Error;\n}) {\n if (flagSchemaBuildError) {\n const message = `[@apollo/client-ai-apps/vite]: There was an error building generated types. See the vite build output for more details.\\n\\n${flagSchemaBuildError.message}`;\n\n const importBaseStatement = buildImportStatement(\n [],\n \"@apollo/client-ai-apps\"\n );\n importBaseStatement.comments = [buildHeaderComment()];\n\n const typeAnnotation = b.tsLiteralType(b.stringLiteral(message));\n\n return printRecast(\n b.program([\n importBaseStatement,\n buildAmbientModuleDeclaration([\n buildPropertySignature(\"toolName\", typeAnnotation),\n buildPropertySignature(\n \"toolInputs\",\n b.tsTypeLiteral([buildPropertySignature(message, typeAnnotation)])\n ),\n ]),\n ])\n );\n }\n\n const toolNames = operations.flatMap((op) => op.tools.map((t) => t.name));\n\n if (toolNames.length === 0) {\n const emptyExport = b.exportNamedDeclaration(null);\n emptyExport.comments = [buildHeaderComment()];\n return printRecast(b.program([emptyExport]));\n }\n\n const importBaseStatement = buildImportStatement(\n [],\n \"@apollo/client-ai-apps\"\n );\n importBaseStatement.comments = [buildHeaderComment()];\n\n const toolNameProp = buildPropertySignature(\n \"toolName\",\n b.tsUnionType(toolNames.map((n) => b.tsLiteralType(b.stringLiteral(n))))\n );\n\n if (!schema) {\n return printRecast(\n b.program([\n importBaseStatement,\n buildAmbientModuleDeclaration([toolNameProp]),\n ])\n );\n }\n\n const importedVariableTypes = new Set<string>();\n const toolInputsValue: recast.types.namedTypes.TSPropertySignature[] = [];\n\n for (const operation of operations) {\n const variablesTypeName = getVariablesTypeName(operation);\n\n if (operation.tools.length) {\n importedVariableTypes.add(variablesTypeName);\n }\n\n for (const tool of operation.tools) {\n const variablesTypeRef = b.tsTypeReference(\n b.identifier(variablesTypeName)\n );\n let typeExpression:\n | recast.types.namedTypes.TSTypeReference\n | recast.types.namedTypes.TSIntersectionType = variablesTypeRef;\n\n if (tool.extraInputs?.length) {\n const extraInputsType = tool.extraInputs.map((ei) => {\n return buildPropertySignature(\n ei.name,\n buildKeywordLiteral(ei.type),\n true\n );\n });\n\n typeExpression = b.tsIntersectionType([\n variablesTypeRef,\n b.tsTypeLiteral(extraInputsType),\n ]);\n }\n\n toolInputsValue.push(buildPropertySignature(tool.name, typeExpression));\n }\n }\n\n return printRecast(\n b.program([\n importBaseStatement,\n buildImportStatement(\n Array.from(importedVariableTypes),\n \"./operation-types.js\",\n \"type\"\n ),\n buildAmbientModuleDeclaration([\n toolNameProp,\n buildPropertySignature(\"toolInputs\", b.tsTypeLiteral(toolInputsValue)),\n ]),\n ])\n );\n}\n\n/**\n * Generates and returns the code string written to the\n * `.apollo-client-ai-apps/types/operation-types.d.ts` file. Uses GraphQL\n * Codegen to introspect the given schema and extract variable types.\n */\nasync function generateOperationTypes(\n schema: string,\n documents: string[]\n): Promise<string> {\n const { generate } = await import(\"@graphql-codegen/cli\");\n\n if (documents.length === 0) {\n return `// Auto-generated by @apollo/client-ai-apps. Do not edit manually.\\nexport {};\\n`;\n }\n\n const output = await generate(\n {\n schema,\n documents,\n generates: {\n \"operation-types.d.ts\": {\n plugins: [\"typescript-operations\"],\n config: {\n nonOptionalTypename: true,\n skipTypeNameForRoot: true,\n namingConvention: \"keep\",\n } satisfies TypeScriptDocumentsPluginConfig,\n },\n },\n silent: true,\n } as Parameters<typeof generate>[0],\n false\n );\n\n const content = (output as { filename: string; content: string }[])[0]\n .content;\n return `// Auto-generated by @apollo/client-ai-apps. Do not edit manually.\\n${content}`;\n}\n\n/**\n * Gets the name of an exported type (e.g. `export type x`) from a TypeScript\n * AST statement.\n */\nfunction getExportedTypeAliasName(\n statement: recast.types.namedTypes.Statement\n): string | undefined {\n if (statement.type !== \"ExportNamedDeclaration\") return;\n\n const declaration = (\n statement as recast.types.namedTypes.ExportNamedDeclaration\n ).declaration;\n\n if (!declaration || declaration.type !== \"TSTypeAliasDeclaration\") return;\n\n const alias = declaration as recast.types.namedTypes.TSTypeAliasDeclaration;\n return typeof alias.id.name === \"string\" ? alias.id.name : undefined;\n}\n\n/**\n * Removes all non-`*Variables` types from the `operation-types.d.ts` file.\n * The `typescript` and `typescript-operations` codegen plugins add full schema\n * types and operation types. This function ensures those unused types are\n * removed.\n */\nfunction filterOperationTypes(\n content: string,\n rootTypeNames: Set<string>\n): string {\n const ast = recast.parse(content, { parser: typescriptParser });\n const statements: recast.types.namedTypes.Statement[] = ast.program.body;\n const typeMap = new Map<\n string,\n recast.types.namedTypes.TSTypeAliasDeclaration\n >();\n\n for (const statement of statements) {\n const name = getExportedTypeAliasName(statement);\n\n if (name) {\n typeMap.set(\n name,\n (statement as recast.types.namedTypes.ExportNamedDeclaration)\n .declaration as recast.types.namedTypes.TSTypeAliasDeclaration\n );\n }\n }\n\n const reachable = new Set<string>(rootTypeNames);\n const queue = Array.from(rootTypeNames);\n\n while (queue.length > 0) {\n const name = queue.shift()!;\n const node = typeMap.get(name);\n\n if (!node) continue;\n\n recast.visit(node, {\n visitTSTypeReference(path) {\n const typeName = path.value.typeName?.name as string | undefined;\n\n if (typeName && !reachable.has(typeName)) {\n reachable.add(typeName);\n queue.push(typeName);\n }\n\n this.traverse(path);\n },\n });\n }\n\n ast.program.body = statements.filter((statement) => {\n const name = getExportedTypeAliasName(statement);\n return name === undefined || reachable.has(name);\n });\n\n return printRecast(ast);\n}\n\nexport function apolloClientAiApps(\n options: apolloClientAiApps.Options\n): Plugin {\n const targets = Array.from(new Set(options.targets));\n const {\n devTarget = targets.length === 1 ? targets[0] : undefined,\n appsOutDir,\n schema,\n } = options;\n let config!: ResolvedConfig;\n\n const fragments = createFragmentRegistry();\n\n invariant(\n Array.isArray(targets) && targets.length > 0,\n \"The `targets` option must be a non-empty array\"\n );\n\n invariant(\n targets.every(isValidTarget),\n `All targets must be one of: ${VALID_TARGETS.join(\", \")}`\n );\n\n invariant(\n path.basename(path.normalize(appsOutDir)) === \"apps\",\n \"`appsOutDir` must end with `apps` as the final path segment (e.g. `path/to/apps`).\"\n );\n\n const client = new ApolloClient({\n cache: new InMemoryCache({ fragments }),\n link: processQueryLink,\n });\n\n let sources: DocumentNode[] = [];\n\n function recomputeSources(cache: Map<string, FileCache>) {\n sources = Array.from(cache.values()).flatMap((entry) => entry.sources);\n }\n\n async function getManifestOperations() {\n if (sources === getManifestOperations.cache.sources) {\n return getManifestOperations.cache.manifestOperations;\n }\n\n const manifestOperations = [];\n for (const source of sources) {\n const operationDef = source.definitions.find(\n (d) => d.kind === Kind.OPERATION_DEFINITION\n );\n\n if (!operationDef) continue;\n\n switch (operationDef.operation) {\n case OperationTypeNode.QUERY: {\n const result = await client.query<ManifestOperation>({\n query: source,\n fetchPolicy: \"no-cache\",\n });\n const data = result.data!;\n\n if (data.tools.length > 0 || data.prefetch) {\n manifestOperations.push(data);\n }\n break;\n }\n case OperationTypeNode.MUTATION: {\n const result = await client.mutate<ManifestOperation>({\n mutation: source,\n fetchPolicy: \"no-cache\",\n });\n const data = result.data!;\n\n if (data.tools.length > 0 || data.prefetch) {\n manifestOperations.push(data);\n }\n break;\n }\n default:\n throw new Error(\n `Found unsupported operation type '${operationDef.operation}'. Only queries and mutations are supported.`\n );\n }\n }\n\n getManifestOperations.cache = { sources, manifestOperations };\n\n return manifestOperations;\n }\n\n getManifestOperations.cache = {\n sources,\n manifestOperations: [] as ManifestOperation[],\n };\n\n async function processFile(file: string) {\n const code = fs.readFileSync(file, \"utf-8\");\n\n if (!code.includes(\"gql\")) return;\n\n const fileHash = md5(code);\n if (processFile.cache.get(file)?.hash === fileHash) return;\n\n const sources = gqlPluckFromCodeStringSync(file, code, {\n modules: [\n { name: \"graphql-tag\", identifier: \"gql\" },\n { name: \"@apollo/client\", identifier: \"gql\" },\n ],\n }).map((source) => parse(source.body));\n\n const previousSources = processFile.cache.get(file)?.sources;\n\n if (previousSources && equal(sources, previousSources)) {\n processFile.cache.set(file, { hash: fileHash, sources: previousSources });\n return;\n }\n\n fragments.register(...sources);\n\n processFile.cache.set(file, { hash: fileHash, sources });\n recomputeSources(processFile.cache);\n }\n\n processFile.cache = new Map<string, FileCache>();\n\n async function generateManifest() {\n const appsConfig = await getAppsConfig();\n const operations = await getManifestOperations();\n\n invariant(\n operations.filter((o) => o.prefetch).length <= 1,\n \"Found multiple operations marked as `@prefetch`. You can only mark 1 operation with `@prefetch`.\"\n );\n\n function getBuildResourceForTarget(target: apolloClientAiApps.Target) {\n const entryPoint = getResourceFromConfig(appsConfig, config.mode, target);\n\n if (entryPoint) {\n return entryPoint;\n }\n\n if (config.mode === \"production\") {\n return `${target}/index.html`;\n }\n\n throw new Error(\n `No entry point found for mode \"${config.mode}\". Entry points other than \"development\" and \"production\" must be defined in package.json file.`\n );\n }\n\n let resource: ApplicationManifest[\"resource\"];\n if (config.command === \"serve\") {\n // Dev mode: resource is a string (dev server URL)\n resource =\n getResourceFromConfig(appsConfig, config.mode, devTarget!) ??\n `http${config.server.https ? \"s\" : \"\"}://${config.server.host ?? \"localhost\"}:${config.server.port}`;\n } else {\n resource = Object.fromEntries(\n targets.map((target) => [target, getBuildResourceForTarget(target)])\n ) as { mcp?: string; openai?: string };\n }\n\n const packageJson = readPackageJson();\n const appName = appsConfig.name ?? packageJson.name;\n\n invariant(\n appName,\n \"Error generating application manifest. Could not determine app name. Set `name` in your apollo-client-ai-apps config or `package.json`.\"\n );\n\n const manifest: ApplicationManifest = {\n format: \"apollo-ai-app-manifest\",\n version: \"1\",\n appVersion: appsConfig.version ?? packageJson.version,\n name: appsConfig.name ?? packageJson.name,\n description: appsConfig.description ?? packageJson.description,\n hash: createHash(\"sha256\").update(Date.now().toString()).digest(\"hex\"),\n operations,\n resource,\n csp: {\n baseUriDomains: appsConfig.csp?.baseUriDomains ?? [],\n connectDomains: appsConfig.csp?.connectDomains ?? [],\n frameDomains: appsConfig.csp?.frameDomains ?? [],\n redirectDomains: appsConfig.csp?.redirectDomains ?? [],\n resourceDomains: appsConfig.csp?.resourceDomains ?? [],\n },\n };\n\n if (isNonEmptyObject(appsConfig.widgetSettings)) {\n manifest.widgetSettings = appsConfig.widgetSettings;\n }\n\n if (isNonEmptyObject(appsConfig.labels)) {\n manifest.labels = appsConfig.labels;\n }\n\n const manifestContents = JSON.stringify(manifest);\n\n // Always write to build directory so the MCP server picks it up\n writeFileSync(\n path.resolve(root, appsOutDir, appName, \".application-manifest.json\"),\n manifestContents\n );\n\n // Always write to the dev location so that the app can bundle the manifest content\n writeFileSync(\".application-manifest.json\", manifestContents);\n\n const manifestTypesFilepath = \".application-manifest.d.json.ts\";\n if (!fs.existsSync(manifestTypesFilepath)) {\n const manifestImport = b.importDeclaration(\n [b.importSpecifier(b.identifier(\"ApplicationManifest\"))],\n b.stringLiteral(\"@apollo/client-ai-apps\"),\n \"type\"\n );\n const manifestId = b.identifier(\"manifest\");\n manifestId.typeAnnotation = b.tsTypeAnnotation(\n b.tsTypeReference(b.identifier(\"ApplicationManifest\"), null)\n );\n const manifestDeclaration = b.variableDeclaration(\"const\", [\n b.variableDeclarator(manifestId, null),\n ]) as recast.types.namedTypes.VariableDeclaration & { declare: boolean };\n manifestDeclaration.declare = true;\n\n const exportDefault = b.exportDefaultDeclaration(\n b.identifier(\"manifest\")\n );\n\n const content = printRecast(\n b.program([manifestImport, manifestDeclaration, exportDefault])\n );\n\n writeFileSync(manifestTypesFilepath, content);\n }\n }\n\n async function generateTypesFiles() {\n let flagSchemaBuildError: false | Error = false;\n const operations = await getManifestOperations();\n\n if (operations === generateTypesFiles.cache) {\n return;\n }\n\n generateTypesFiles.cache = operations;\n\n if (schema) {\n try {\n const opTypesContent = await generateOperationTypes(\n schema,\n operations.map((op) => op.body)\n );\n\n const rootTypeNames = new Set(\n operations.flatMap((op) =>\n op.tools.length > 0 ? [getVariablesTypeName(op)] : []\n )\n );\n\n writeFileSync(\n path.resolve(\n root,\n \".apollo-client-ai-apps/types/operation-types.d.ts\"\n ),\n filterOperationTypes(opTypesContent, rootTypeNames),\n { cache: true }\n );\n } catch (e) {\n if (config.command === \"build\") {\n throw e;\n }\n\n flagSchemaBuildError = e as Error;\n console.error(\"[@apollo/client-ai-apps/vite]:\", e);\n }\n }\n\n const typesFileContents = getRegisteredTypeContents({\n operations,\n schema,\n flagSchemaBuildError,\n });\n\n writeFileSync(\n path.resolve(root, \".apollo-client-ai-apps/types/register.d.ts\"),\n typesFileContents,\n { cache: true }\n );\n }\n\n generateTypesFiles.cache = [] as ManifestOperation[] | undefined;\n\n return {\n name: \"@apollo/client-ai-apps/vite\",\n async buildStart() {\n // Scan all files on startup\n const files = await glob(\"./src/**/*.{ts,tsx,js,jsx}\", { fs });\n\n for (const file of files) {\n const fullPath = path.resolve(root, file);\n await processFile(fullPath);\n }\n\n await Promise.all([generateManifest(), generateTypesFiles()]);\n },\n configResolved(resolvedConfig) {\n config = resolvedConfig;\n },\n async configEnvironment(name) {\n if (!targets.includes(name as any)) return;\n\n const appsConfig = await getAppsConfig();\n const appName = appsConfig.name ?? readPackageJson().name;\n\n invariant(\n appName,\n \"Could not determine app name. Set `name` in your apollo-client-ai-apps config or `package.json`.\"\n );\n\n return {\n build: {\n outDir: path.join(appsOutDir, appName, name),\n },\n };\n },\n configureServer(server) {\n server.watcher.on(\"change\", async (file) => {\n if (file.endsWith(\"package.json\")) {\n readPackageJson.resetCache();\n await generateManifest();\n } else if (file.match(/\\.?apollo-client-ai-apps\\.config\\.\\w+$/)) {\n explorer.clearCaches();\n await generateManifest();\n } else if (file.match(/\\.(jsx?|tsx?)$/)) {\n await processFile(file);\n await Promise.all([generateManifest(), generateTypesFiles()]);\n }\n });\n },\n\n config(userConfig, { command }) {\n if (userConfig.build?.outDir) {\n console.warn(\n \"[@apollo/client-ai-apps/vite] `build.outDir` is set in your Vite config but will be \" +\n \"ignored. Use `appsOutDir` in the plugin options to control the output location.\"\n );\n }\n\n if (command === \"serve\") {\n invariant(\n isValidTarget(devTarget) || targets.length === 1,\n \"`devTarget` must be set for development when using multiple targets.\"\n );\n\n const target = devTarget ?? targets[0];\n\n return {\n resolve: {\n extensions: buildExtensions(target),\n conditions: [target, ...defaultClientConditions],\n },\n };\n }\n\n return {\n environments: Object.fromEntries(\n targets.map((target) => [\n target,\n {\n consumer: \"client\",\n webCompatible: true,\n resolve: {\n extensions: buildExtensions(target),\n conditions: [target, ...defaultClientConditions],\n },\n },\n ])\n ),\n builder: {\n buildApp: async (builder) => {\n await Promise.all(\n targets.map((target) =>\n builder.build(builder.environments[target])\n )\n );\n },\n },\n };\n },\n transformIndexHtml(html, ctx) {\n if (!ctx.server) return html;\n\n let baseUrl = (\n ctx.server.config?.server?.origin ??\n ctx.server.resolvedUrls?.local[0] ??\n \"\"\n ).replace(/\\/$/, \"\");\n baseUrl = baseUrl.replace(/\\/$/, \"\");\n\n return (\n html\n // import \"/@vite/...\" or \"/@react-refresh\"\n .replace(/(from\\s+[\"'])\\/([^\"']+)/g, `$1${baseUrl}/$2`)\n // src=\"/src/...\"\n .replace(/(src=[\"'])\\/([^\"']+)/gi, `$1${baseUrl}/$2`)\n );\n },\n } satisfies Plugin;\n}\n\nconst processQueryLink = new ApolloLink((operation) => {\n const body = print(\n removeOperationDescription(\n removeManifestDirectives(sortTopLevelDefinitions(operation.query))\n )\n );\n const name = operation.operationName;\n const definition = operation.query.definitions.find(\n (d) => d.kind === \"OperationDefinition\"\n );\n\n // Use `operation.query` so that the error reflects the end-user defined\n // document, not our sorted one\n invariant(\n definition,\n `Document does not contain an operation:\\n${print(operation.query)}`\n );\n\n const { directives, operation: type } = definition;\n\n const variables = definition.variableDefinitions?.reduce(\n (obj, varDef) => ({\n ...obj,\n [varDef.variable.name.value]: getTypeName(varDef.type),\n }),\n {}\n );\n\n const prefetch = directives?.some((d) => d.name.value === \"prefetch\");\n const id = createHash(\"sha256\").update(body).digest(\"hex\");\n // TODO: For now, you can only have 1 operation marked as prefetch. In the future, we'll likely support more than 1, and the \"prefetchId\" will be defined on the `@prefetch` itself as an argument\n const prefetchID = prefetch ? \"__anonymous\" : undefined;\n\n const toolDirectives =\n directives?.filter((d) => d.name.value === \"tool\") ?? [];\n\n const tools = toolDirectives.map((directive) => {\n const nameArg = getDirectiveArgument(\"name\", directive);\n const descriptionArg = getDirectiveArgument(\"description\", directive);\n\n let name: string;\n if (nameArg) {\n name = getArgumentValue(nameArg, Kind.STRING);\n } else {\n invariant(\n toolDirectives.length === 1,\n `Operations with multiple @tool directives must provide a 'name' argument on each @tool`\n );\n invariant(\n definition.name?.value,\n `Anonymous operations cannot use @tool without providing a 'name' argument`\n );\n name = definition.name.value;\n }\n\n let description: string;\n if (descriptionArg) {\n description = getArgumentValue(descriptionArg, Kind.STRING);\n } else {\n invariant(\n toolDirectives.length === 1,\n `Operations with multiple @tool directives must provide a 'description' argument on each @tool`\n );\n invariant(\n definition.description?.value,\n `Operations using @tool without a 'description' argument must have a description on the operation definition`\n );\n description = definition.description.value;\n }\n\n const result = ToolDirectiveSchema.safeParse({\n name,\n description,\n extraInputs: maybeGetArgumentValue(\n getDirectiveArgument(\"extraInputs\", directive),\n Kind.LIST\n ),\n extraOutputs: maybeGetArgumentValue(\n getDirectiveArgument(\"extraOutputs\", directive),\n Kind.OBJECT\n ),\n labels: maybeGetArgumentValue(\n getDirectiveArgument(\"labels\", directive),\n Kind.OBJECT\n ),\n });\n\n if (result.error) {\n throw z.prettifyError(result.error);\n }\n\n return result.data;\n });\n\n // TODO: Make this object satisfy the `ManifestOperation` type. Currently\n // it errors because we need more validation on a few of these fields\n return of({\n data: { id, name, type, body, variables, prefetch, prefetchID, tools },\n });\n});\n\nfunction removeOperationDescription(doc: DocumentNode): DocumentNode {\n return visit(doc, {\n OperationDefinition(node) {\n return { ...node, description: undefined };\n },\n });\n}\n\nfunction removeManifestDirectives(doc: DocumentNode) {\n return removeDirectivesFromDocument(\n [{ name: \"prefetch\" }, { name: \"tool\" }],\n doc\n )!;\n}\n\n// Sort the definitions in this document so that operations come before fragments,\n// and so that each kind of definition is sorted by name.\nexport function sortTopLevelDefinitions(query: DocumentNode): DocumentNode {\n const definitions = [...query.definitions];\n // We want to avoid unnecessary dependencies, so write out a comparison\n // function instead of using _.orderBy.\n definitions.sort((a, b) => {\n // This is a reverse sort by kind, so that OperationDefinition precedes FragmentDefinition.\n if (a.kind > b.kind) {\n return -1;\n }\n if (a.kind < b.kind) {\n return 1;\n }\n\n // Extract the name from each definition. Jump through some hoops because\n // non-executable definitions don't have to have names (even though any\n // DocumentNode actually passed here should only have executable\n // definitions).\n const aName =\n a.kind === \"OperationDefinition\" || a.kind === \"FragmentDefinition\" ?\n (a.name?.value ?? \"\")\n : \"\";\n const bName =\n b.kind === \"OperationDefinition\" || b.kind === \"FragmentDefinition\" ?\n (b.name?.value ?? \"\")\n : \"\";\n\n // Sort by name ascending.\n if (aName < bName) {\n return -1;\n }\n if (aName > bName) {\n return 1;\n }\n\n // Assuming that the document is \"valid\", no operation or fragment name can appear\n // more than once, so we don't need to differentiate further to have a deterministic\n // sort.\n return 0;\n });\n return {\n ...query,\n definitions,\n };\n}\n\nfunction isNonEmptyObject<T extends object>(\n obj: T | null | undefined\n): obj is T {\n return !!obj && Object.keys(obj).length > 0;\n}\n\nasync function getAppsConfig() {\n const result = await explorer.search();\n const config = (result?.config ??\n {}) as Partial<ApolloClientAiAppsConfig.Config>;\n\n const parsed = ApolloClientAiAppsConfigSchema.safeParse(config);\n\n if (parsed.error) {\n throw z.prettifyError(parsed.error);\n }\n\n return parsed.data;\n}\n\nfunction getResourceFromConfig(\n appsConfig: z.infer<typeof ApolloClientAiAppsConfigSchema>,\n mode: string,\n target: apolloClientAiApps.Target\n) {\n if (!appsConfig.entry || !appsConfig.entry[mode]) {\n return;\n }\n\n const config = appsConfig.entry[mode];\n\n return typeof config === \"string\" ? config : config[target];\n}\n\nfunction readPackageJson(): Record<string, any> {\n if (readPackageJson.cache) {\n return readPackageJson.cache;\n }\n\n return (readPackageJson.cache = JSON.parse(\n fs.readFileSync(\"package.json\", \"utf-8\")\n ));\n}\n\nreadPackageJson.cache = undefined as Record<string, any> | undefined;\nreadPackageJson.resetCache = () => {\n readPackageJson.cache = undefined;\n};\n\nfunction writeFileSync(\n filepath: string,\n content: string,\n options: { cache?: boolean } = {}\n) {\n function writeFile() {\n fs.mkdirSync(path.dirname(filepath), { recursive: true });\n fs.writeFileSync(filepath, content, \"utf-8\");\n }\n\n if (!options.cache) {\n return writeFile();\n }\n\n const hash = md5(content);\n const cachedHash = writeFileSync.cache.get(filepath);\n\n if (hash !== cachedHash || !fs.existsSync(filepath)) {\n writeFileSync.cache.set(filepath, hash);\n writeFile();\n }\n}\n\nwriteFileSync.cache = new Map<string, string>();\n\nconst ToolDirectiveSchema = z.strictObject({\n name: z.stringFormat(\"toolName\", (value) => value.indexOf(\" \") === -1, {\n error: (iss) => `Tool with name \"${iss.input}\" must not contain spaces`,\n }),\n description: z.string(),\n extraInputs: z.optional(\n z.array(\n z.strictObject({\n name: z.string(),\n description: z.string(),\n type: z.literal([\"string\", \"boolean\", \"number\"]),\n })\n )\n ),\n extraOutputs: z.optional(z.record(z.string(), z.unknown())),\n labels: ApolloClientAiAppsConfigSchema.shape.labels.optional(),\n});\n"]}
|
|
@@ -11,29 +11,27 @@
|
|
|
11
11
|
],
|
|
12
12
|
"devDependencies": {
|
|
13
13
|
"@apollo/mcp-impostor-host": "^0.3.0",
|
|
14
|
-
"@playwright/test": "^1.
|
|
14
|
+
"@playwright/test": "^1.60.0",
|
|
15
15
|
"npm-run-all": "^4.1.5"
|
|
16
16
|
}
|
|
17
17
|
},
|
|
18
18
|
"..": {
|
|
19
19
|
"name": "@apollo/client-ai-apps",
|
|
20
|
-
"version": "0.7.
|
|
20
|
+
"version": "0.7.4",
|
|
21
21
|
"license": "MIT",
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@graphql-codegen/cli": "^
|
|
24
|
-
"@graphql-codegen/typescript": "^
|
|
25
|
-
"@graphql-codegen/typescript-operations": "^5.0.9",
|
|
23
|
+
"@graphql-codegen/cli": "^7.1.0",
|
|
24
|
+
"@graphql-codegen/typescript-operations": "^6.0.3",
|
|
26
25
|
"@graphql-tools/graphql-tag-pluck": "^8.3.23",
|
|
27
26
|
"@wry/equality": "^0.5.7",
|
|
28
27
|
"cosmiconfig": "^9.0.0",
|
|
29
|
-
"crypto-hash": "^4.0.0",
|
|
30
28
|
"glob": "^11.0.3",
|
|
31
29
|
"recast": "^0.23.11",
|
|
32
30
|
"tslib": "^2.8.1",
|
|
33
31
|
"zod": "^4.3.6"
|
|
34
32
|
},
|
|
35
33
|
"devDependencies": {
|
|
36
|
-
"@apollo/client": "^4.0
|
|
34
|
+
"@apollo/client": "^4.2.0",
|
|
37
35
|
"@arethetypeswrong/cli": "^0.18.2",
|
|
38
36
|
"@modelcontextprotocol/ext-apps": "^1.0.1",
|
|
39
37
|
"@testing-library/jest-dom": "^6.9.1",
|
|
@@ -52,7 +50,6 @@
|
|
|
52
50
|
"memfs": "^4.56.10",
|
|
53
51
|
"mock-require": "^3.0.3",
|
|
54
52
|
"prettier": "^3.7.4",
|
|
55
|
-
"react-error-boundary": "^6.1.0",
|
|
56
53
|
"rimraf": "^6.1.2",
|
|
57
54
|
"rxjs": "^7.8.1",
|
|
58
55
|
"typescript": "^5.9.3",
|
|
@@ -1313,13 +1310,13 @@
|
|
|
1313
1310
|
}
|
|
1314
1311
|
},
|
|
1315
1312
|
"node_modules/@playwright/test": {
|
|
1316
|
-
"version": "1.
|
|
1317
|
-
"resolved": "https://registry.npmjs.org/@playwright/test/-/test-1.
|
|
1318
|
-
"integrity": "sha512-
|
|
1313
|
+
"version": "1.60.0",
|
|
1314
|
+
"resolved": "https://registry.npmjs.org/@playwright/test/-/test-1.60.0.tgz",
|
|
1315
|
+
"integrity": "sha512-O71yZIbAh/PxDMNGns37GHBIfrVkEVyn+AXyIa5dOTfb4/xNvRWV+Vv/NMbNCtODB/pO7vLlF2OTmMVLhmr7Ag==",
|
|
1319
1316
|
"dev": true,
|
|
1320
1317
|
"license": "Apache-2.0",
|
|
1321
1318
|
"dependencies": {
|
|
1322
|
-
"playwright": "1.
|
|
1319
|
+
"playwright": "1.60.0"
|
|
1323
1320
|
},
|
|
1324
1321
|
"bin": {
|
|
1325
1322
|
"playwright": "cli.js"
|
|
@@ -4308,13 +4305,13 @@
|
|
|
4308
4305
|
}
|
|
4309
4306
|
},
|
|
4310
4307
|
"node_modules/playwright": {
|
|
4311
|
-
"version": "1.
|
|
4312
|
-
"resolved": "https://registry.npmjs.org/playwright/-/playwright-1.
|
|
4313
|
-
"integrity": "sha512-
|
|
4308
|
+
"version": "1.60.0",
|
|
4309
|
+
"resolved": "https://registry.npmjs.org/playwright/-/playwright-1.60.0.tgz",
|
|
4310
|
+
"integrity": "sha512-hheHdokM8cdqCb0lcE3s+zT4t4W+vvjpGxsZlDnikarzx8tSzMebh3UiFtgqwFwnTnjYQcsyMF8ei2mCO/tpeA==",
|
|
4314
4311
|
"dev": true,
|
|
4315
4312
|
"license": "Apache-2.0",
|
|
4316
4313
|
"dependencies": {
|
|
4317
|
-
"playwright-core": "1.
|
|
4314
|
+
"playwright-core": "1.60.0"
|
|
4318
4315
|
},
|
|
4319
4316
|
"bin": {
|
|
4320
4317
|
"playwright": "cli.js"
|
|
@@ -4327,9 +4324,9 @@
|
|
|
4327
4324
|
}
|
|
4328
4325
|
},
|
|
4329
4326
|
"node_modules/playwright-core": {
|
|
4330
|
-
"version": "1.
|
|
4331
|
-
"resolved": "https://registry.npmjs.org/playwright-core/-/playwright-core-1.
|
|
4332
|
-
"integrity": "sha512-
|
|
4327
|
+
"version": "1.60.0",
|
|
4328
|
+
"resolved": "https://registry.npmjs.org/playwright-core/-/playwright-core-1.60.0.tgz",
|
|
4329
|
+
"integrity": "sha512-9bW6zvX/m0lEbgTKJ6YppOKx8H3VOPBMOCFh2irXFOT4BbHgrx5hPjwJYLT40Lu+4qtD36qKc/Hn56StUW57IA==",
|
|
4333
4330
|
"dev": true,
|
|
4334
4331
|
"license": "Apache-2.0",
|
|
4335
4332
|
"bin": {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://www.schemastore.org/package.json",
|
|
3
3
|
"name": "@apollo/client-ai-apps",
|
|
4
|
-
"version": "0.7.
|
|
4
|
+
"version": "0.7.5",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"apollo",
|
|
7
7
|
"graphql",
|
|
@@ -104,7 +104,7 @@
|
|
|
104
104
|
"attw": "npm run build && attw --pack . --ignore-rules cjs-resolves-to-esm --profile node16"
|
|
105
105
|
},
|
|
106
106
|
"devDependencies": {
|
|
107
|
-
"@apollo/client": "^4.
|
|
107
|
+
"@apollo/client": "^4.2.0",
|
|
108
108
|
"@arethetypeswrong/cli": "^0.18.2",
|
|
109
109
|
"@modelcontextprotocol/ext-apps": "^1.0.1",
|
|
110
110
|
"@testing-library/jest-dom": "^6.9.1",
|
|
@@ -123,7 +123,6 @@
|
|
|
123
123
|
"memfs": "^4.56.10",
|
|
124
124
|
"mock-require": "^3.0.3",
|
|
125
125
|
"prettier": "^3.7.4",
|
|
126
|
-
"react-error-boundary": "^6.1.0",
|
|
127
126
|
"rimraf": "^6.1.2",
|
|
128
127
|
"rxjs": "^7.8.1",
|
|
129
128
|
"typescript": "^5.9.3",
|
|
@@ -145,13 +144,11 @@
|
|
|
145
144
|
}
|
|
146
145
|
},
|
|
147
146
|
"dependencies": {
|
|
148
|
-
"@graphql-codegen/cli": "^
|
|
149
|
-
"@graphql-codegen/typescript": "^
|
|
150
|
-
"@graphql-codegen/typescript-operations": "^5.0.9",
|
|
147
|
+
"@graphql-codegen/cli": "^7.1.0",
|
|
148
|
+
"@graphql-codegen/typescript-operations": "^6.0.3",
|
|
151
149
|
"@graphql-tools/graphql-tag-pluck": "^8.3.23",
|
|
152
150
|
"@wry/equality": "^0.5.7",
|
|
153
151
|
"cosmiconfig": "^9.0.0",
|
|
154
|
-
"crypto-hash": "^4.0.0",
|
|
155
152
|
"glob": "^11.0.3",
|
|
156
153
|
"recast": "^0.23.11",
|
|
157
154
|
"tslib": "^2.8.1",
|
|
@@ -2061,43 +2061,16 @@ describe("tool input types", () => {
|
|
|
2061
2061
|
);
|
|
2062
2062
|
expect(content).toMatchInlineSnapshot(`
|
|
2063
2063
|
"// Auto-generated by @apollo/client-ai-apps. Do not edit manually.
|
|
2064
|
-
|
|
2065
|
-
|
|
2066
|
-
export type InputMaybe<T> = Maybe<T>;
|
|
2067
|
-
|
|
2068
|
-
export type Exact<T extends {
|
|
2064
|
+
/** Internal type. DO NOT USE DIRECTLY. */
|
|
2065
|
+
type Exact<T extends {
|
|
2069
2066
|
[key: string]: unknown;
|
|
2070
2067
|
}> = {
|
|
2071
2068
|
[K in keyof T]: T[K];
|
|
2072
2069
|
};
|
|
2073
2070
|
|
|
2074
|
-
/** All built-in and custom scalars, mapped to their actual values */
|
|
2075
|
-
export type Scalars = {
|
|
2076
|
-
ID: {
|
|
2077
|
-
input: string;
|
|
2078
|
-
output: string;
|
|
2079
|
-
};
|
|
2080
|
-
String: {
|
|
2081
|
-
input: string;
|
|
2082
|
-
output: string;
|
|
2083
|
-
};
|
|
2084
|
-
Boolean: {
|
|
2085
|
-
input: boolean;
|
|
2086
|
-
output: boolean;
|
|
2087
|
-
};
|
|
2088
|
-
Int: {
|
|
2089
|
-
input: number;
|
|
2090
|
-
output: number;
|
|
2091
|
-
};
|
|
2092
|
-
Float: {
|
|
2093
|
-
input: number;
|
|
2094
|
-
output: number;
|
|
2095
|
-
};
|
|
2096
|
-
};
|
|
2097
|
-
|
|
2098
2071
|
export type CreateTodoMutationVariables = Exact<{
|
|
2099
|
-
title:
|
|
2100
|
-
description?:
|
|
2072
|
+
title: string;
|
|
2073
|
+
description?: string | null | undefined;
|
|
2101
2074
|
}>;"
|
|
2102
2075
|
`);
|
|
2103
2076
|
});
|
|
@@ -2126,6 +2099,26 @@ describe("tool input types", () => {
|
|
|
2126
2099
|
});
|
|
2127
2100
|
await server.listen();
|
|
2128
2101
|
|
|
2102
|
+
expect(
|
|
2103
|
+
fs.readFileSync(
|
|
2104
|
+
".apollo-client-ai-apps/types/operation-types.d.ts",
|
|
2105
|
+
"utf-8"
|
|
2106
|
+
)
|
|
2107
|
+
).toMatchInlineSnapshot(`
|
|
2108
|
+
"// Auto-generated by @apollo/client-ai-apps. Do not edit manually.
|
|
2109
|
+
/** Internal type. DO NOT USE DIRECTLY. */
|
|
2110
|
+
type Exact<T extends {
|
|
2111
|
+
[key: string]: unknown;
|
|
2112
|
+
}> = {
|
|
2113
|
+
[K in keyof T]: T[K];
|
|
2114
|
+
};
|
|
2115
|
+
|
|
2116
|
+
export type CreateTodoMutationVariables = Exact<{
|
|
2117
|
+
title: string;
|
|
2118
|
+
description?: string | null | undefined;
|
|
2119
|
+
}>;"
|
|
2120
|
+
`);
|
|
2121
|
+
|
|
2129
2122
|
const content = fs.readFileSync(
|
|
2130
2123
|
".apollo-client-ai-apps/types/register.d.ts",
|
|
2131
2124
|
"utf-8"
|
|
@@ -2147,6 +2140,71 @@ describe("tool input types", () => {
|
|
|
2147
2140
|
`);
|
|
2148
2141
|
});
|
|
2149
2142
|
|
|
2143
|
+
test("uses operation name and description for tool name/description when @tool is used without arguments", async () => {
|
|
2144
|
+
vol.fromJSON({
|
|
2145
|
+
"package.json": mockPackageJson(),
|
|
2146
|
+
"src/my-component.tsx": declareOperation(gql`
|
|
2147
|
+
"""
|
|
2148
|
+
Creates a todo
|
|
2149
|
+
"""
|
|
2150
|
+
mutation CreateTodo($title: String!, $description: String) @tool {
|
|
2151
|
+
createTodo(title: $title, description: $description) {
|
|
2152
|
+
id
|
|
2153
|
+
}
|
|
2154
|
+
}
|
|
2155
|
+
`),
|
|
2156
|
+
});
|
|
2157
|
+
|
|
2158
|
+
await using server = await setupServer({
|
|
2159
|
+
plugins: [
|
|
2160
|
+
apolloClientAiApps({
|
|
2161
|
+
targets: ["mcp"],
|
|
2162
|
+
appsOutDir: "dist/apps",
|
|
2163
|
+
schema,
|
|
2164
|
+
}),
|
|
2165
|
+
],
|
|
2166
|
+
});
|
|
2167
|
+
await server.listen();
|
|
2168
|
+
|
|
2169
|
+
expect(
|
|
2170
|
+
fs.readFileSync(
|
|
2171
|
+
".apollo-client-ai-apps/types/operation-types.d.ts",
|
|
2172
|
+
"utf-8"
|
|
2173
|
+
)
|
|
2174
|
+
).toMatchInlineSnapshot(`
|
|
2175
|
+
"// Auto-generated by @apollo/client-ai-apps. Do not edit manually.
|
|
2176
|
+
/** Internal type. DO NOT USE DIRECTLY. */
|
|
2177
|
+
type Exact<T extends {
|
|
2178
|
+
[key: string]: unknown;
|
|
2179
|
+
}> = {
|
|
2180
|
+
[K in keyof T]: T[K];
|
|
2181
|
+
};
|
|
2182
|
+
|
|
2183
|
+
export type CreateTodoMutationVariables = Exact<{
|
|
2184
|
+
title: string;
|
|
2185
|
+
description?: string | null | undefined;
|
|
2186
|
+
}>;"
|
|
2187
|
+
`);
|
|
2188
|
+
|
|
2189
|
+
expect(
|
|
2190
|
+
fs.readFileSync(".apollo-client-ai-apps/types/register.d.ts", "utf-8")
|
|
2191
|
+
).toMatchInlineSnapshot(`
|
|
2192
|
+
"// This file is auto-generated by @apollo/client-ai-apps. Do not edit manually.
|
|
2193
|
+
import "@apollo/client-ai-apps";
|
|
2194
|
+
|
|
2195
|
+
import type { CreateTodoMutationVariables } from "./operation-types.js";
|
|
2196
|
+
|
|
2197
|
+
declare module "@apollo/client-ai-apps" {
|
|
2198
|
+
interface Register {
|
|
2199
|
+
toolName: "CreateTodo";
|
|
2200
|
+
toolInputs: {
|
|
2201
|
+
CreateTodo: CreateTodoMutationVariables;
|
|
2202
|
+
};
|
|
2203
|
+
}
|
|
2204
|
+
}"
|
|
2205
|
+
`);
|
|
2206
|
+
});
|
|
2207
|
+
|
|
2150
2208
|
test("generates register.d.ts with operations that contain fragments", async () => {
|
|
2151
2209
|
vol.fromJSON({
|
|
2152
2210
|
"package.json": mockPackageJson(),
|
|
@@ -2201,43 +2259,16 @@ describe("tool input types", () => {
|
|
|
2201
2259
|
)
|
|
2202
2260
|
).toMatchInlineSnapshot(`
|
|
2203
2261
|
"// Auto-generated by @apollo/client-ai-apps. Do not edit manually.
|
|
2204
|
-
|
|
2205
|
-
|
|
2206
|
-
export type InputMaybe<T> = Maybe<T>;
|
|
2207
|
-
|
|
2208
|
-
export type Exact<T extends {
|
|
2262
|
+
/** Internal type. DO NOT USE DIRECTLY. */
|
|
2263
|
+
type Exact<T extends {
|
|
2209
2264
|
[key: string]: unknown;
|
|
2210
2265
|
}> = {
|
|
2211
2266
|
[K in keyof T]: T[K];
|
|
2212
2267
|
};
|
|
2213
2268
|
|
|
2214
|
-
/** All built-in and custom scalars, mapped to their actual values */
|
|
2215
|
-
export type Scalars = {
|
|
2216
|
-
ID: {
|
|
2217
|
-
input: string;
|
|
2218
|
-
output: string;
|
|
2219
|
-
};
|
|
2220
|
-
String: {
|
|
2221
|
-
input: string;
|
|
2222
|
-
output: string;
|
|
2223
|
-
};
|
|
2224
|
-
Boolean: {
|
|
2225
|
-
input: boolean;
|
|
2226
|
-
output: boolean;
|
|
2227
|
-
};
|
|
2228
|
-
Int: {
|
|
2229
|
-
input: number;
|
|
2230
|
-
output: number;
|
|
2231
|
-
};
|
|
2232
|
-
Float: {
|
|
2233
|
-
input: number;
|
|
2234
|
-
output: number;
|
|
2235
|
-
};
|
|
2236
|
-
};
|
|
2237
|
-
|
|
2238
2269
|
export type CreateTodoMutationVariables = Exact<{
|
|
2239
|
-
title:
|
|
2240
|
-
description?:
|
|
2270
|
+
title: string;
|
|
2271
|
+
description?: string | null | undefined;
|
|
2241
2272
|
}>;"
|
|
2242
2273
|
`);
|
|
2243
2274
|
});
|
|
@@ -2546,6 +2577,74 @@ describe("tool input types", () => {
|
|
|
2546
2577
|
}"
|
|
2547
2578
|
`);
|
|
2548
2579
|
});
|
|
2580
|
+
|
|
2581
|
+
test("generates matching variable type names for operations with lowercase names", async () => {
|
|
2582
|
+
vol.fromJSON({
|
|
2583
|
+
"package.json": mockPackageJson(),
|
|
2584
|
+
"src/my-component.tsx": declareOperation(gql`
|
|
2585
|
+
"Creates a todo"
|
|
2586
|
+
mutation createTodo($title: String!, $description: String) @tool {
|
|
2587
|
+
createTodo(title: $title, description: $description) {
|
|
2588
|
+
id
|
|
2589
|
+
}
|
|
2590
|
+
}
|
|
2591
|
+
`),
|
|
2592
|
+
});
|
|
2593
|
+
|
|
2594
|
+
await using server = await setupServer({
|
|
2595
|
+
plugins: [
|
|
2596
|
+
apolloClientAiApps({
|
|
2597
|
+
targets: ["mcp"],
|
|
2598
|
+
appsOutDir: "dist/apps",
|
|
2599
|
+
schema,
|
|
2600
|
+
}),
|
|
2601
|
+
],
|
|
2602
|
+
});
|
|
2603
|
+
await server.listen();
|
|
2604
|
+
|
|
2605
|
+
const operationTypes = fs.readFileSync(
|
|
2606
|
+
".apollo-client-ai-apps/types/operation-types.d.ts",
|
|
2607
|
+
"utf-8"
|
|
2608
|
+
);
|
|
2609
|
+
const register = fs.readFileSync(
|
|
2610
|
+
".apollo-client-ai-apps/types/register.d.ts",
|
|
2611
|
+
"utf-8"
|
|
2612
|
+
);
|
|
2613
|
+
|
|
2614
|
+
// operation-types.d.ts should export a variables type for the operation.
|
|
2615
|
+
expect(operationTypes).toMatchInlineSnapshot(`
|
|
2616
|
+
"// Auto-generated by @apollo/client-ai-apps. Do not edit manually.
|
|
2617
|
+
/** Internal type. DO NOT USE DIRECTLY. */
|
|
2618
|
+
type Exact<T extends {
|
|
2619
|
+
[key: string]: unknown;
|
|
2620
|
+
}> = {
|
|
2621
|
+
[K in keyof T]: T[K];
|
|
2622
|
+
};
|
|
2623
|
+
|
|
2624
|
+
export type createTodoMutationVariables = Exact<{
|
|
2625
|
+
title: string;
|
|
2626
|
+
description?: string | null | undefined;
|
|
2627
|
+
}>;"
|
|
2628
|
+
`);
|
|
2629
|
+
|
|
2630
|
+
// register.d.ts must import the same variables type name that
|
|
2631
|
+
// operation-types.d.ts exports.
|
|
2632
|
+
expect(register).toMatchInlineSnapshot(`
|
|
2633
|
+
"// This file is auto-generated by @apollo/client-ai-apps. Do not edit manually.
|
|
2634
|
+
import "@apollo/client-ai-apps";
|
|
2635
|
+
|
|
2636
|
+
import type { createTodoMutationVariables } from "./operation-types.js";
|
|
2637
|
+
|
|
2638
|
+
declare module "@apollo/client-ai-apps" {
|
|
2639
|
+
interface Register {
|
|
2640
|
+
toolName: "createTodo";
|
|
2641
|
+
toolInputs: {
|
|
2642
|
+
createTodo: createTodoMutationVariables;
|
|
2643
|
+
};
|
|
2644
|
+
}
|
|
2645
|
+
}"
|
|
2646
|
+
`);
|
|
2647
|
+
});
|
|
2549
2648
|
});
|
|
2550
2649
|
|
|
2551
2650
|
describe("html transforms", () => {
|
|
@@ -299,10 +299,11 @@ async function generateOperationTypes(
|
|
|
299
299
|
documents,
|
|
300
300
|
generates: {
|
|
301
301
|
"operation-types.d.ts": {
|
|
302
|
-
plugins: ["typescript
|
|
302
|
+
plugins: ["typescript-operations"],
|
|
303
303
|
config: {
|
|
304
304
|
nonOptionalTypename: true,
|
|
305
305
|
skipTypeNameForRoot: true,
|
|
306
|
+
namingConvention: "keep",
|
|
306
307
|
} satisfies TypeScriptDocumentsPluginConfig,
|
|
307
308
|
},
|
|
308
309
|
},
|