@apollo/client-ai-apps 0.6.3 → 0.6.4

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 CHANGED
@@ -1,3 +1,13 @@
1
+ ## 0.6.4 (2026-03-13)
2
+
3
+ ### Fixes
4
+
5
+ #### Always write the manifest in `buildStart`
6
+
7
+ The Vite plugin currently writes the manifest file in the `writeBundle` phase of the build. This causes issues if you try to build the app before the manifest file is generated since the source code imports the manifest to provide to the `ApolloClient` constructor. This change writes the manifest in `buildStart` to ensure it is available before the build begins.
8
+
9
+ This change makes it easier to add `.application-manifest.json` to `.gitignore` if you find it too noisy to commit to source control.
10
+
1
11
  ## 0.6.3 (2026-03-13)
2
12
 
3
13
  ### 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;AA+TD,wBAAgB,kBAAkB,CAChC,OAAO,EAAE,kBAAkB,CAAC,OAAO,GAClC,MAAM,CAoZR;AAoHD,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,YAAY,GAAG,YAAY,CA2CzE"}
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;AA+TD,wBAAgB,kBAAkB,CAChC,OAAO,EAAE,kBAAkB,CAAC,OAAO,GAClC,MAAM,CA8YR;AAoHD,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,YAAY,GAAG,YAAY,CA2CzE"}
@@ -415,10 +415,7 @@ export function apolloClientAiApps(options) {
415
415
  const fullPath = path.resolve(root, file);
416
416
  await processFile(fullPath);
417
417
  }
418
- // We don't want to do this here on builds cause it just gets overwritten anyways. We'll call it on writeBundle instead.
419
- if (config.command === "serve") {
420
- await Promise.all([generateManifest(), generateTypesFiles()]);
421
- }
418
+ await Promise.all([generateManifest(), generateTypesFiles()]);
422
419
  },
423
420
  configResolved(resolvedConfig) {
424
421
  config = resolvedConfig;
@@ -498,9 +495,6 @@ export function apolloClientAiApps(options) {
498
495
  // src="/src/..."
499
496
  .replace(/(src=["'])\/([^"']+)/gi, `$1${baseUrl}/$2`));
500
497
  },
501
- async writeBundle() {
502
- await Promise.all([generateManifest(), generateTypesFiles()]);
503
- },
504
498
  };
505
499
  }
506
500
  const processQueryLink = new ApolloLink((operation) => {
@@ -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,OAAO,EAAE,CAAC,E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,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,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\n manifestOperations.push(result.data!);\n break;\n }\n case OperationTypeNode.MUTATION: {\n const result = await client.mutate<ManifestOperation>({\n mutation: source,\n fetchPolicy: \"no-cache\",\n });\n\n manifestOperations.push(result.data!);\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 // We don't want to do this here on builds cause it just gets overwritten anyways. We'll call it on writeBundle instead.\n if (config.command === \"serve\") {\n await Promise.all([generateManifest(), generateTypesFiles()]);\n }\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 async writeBundle() {\n await Promise.all([generateManifest(), generateTypesFiles()]);\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 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 labels: ApolloClientAiAppsConfigSchema.shape.labels.optional(),\n});\n"]}
1
+ {"version":3,"file":"apolloClientAiApps.js","sourceRoot":"","sources":["../../src/vite/apolloClientAiApps.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,uB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,CAAC,OAAO,CAAC,CAAC;IAC1B,MAAM,UAAU,GAAG,aAAa,CAAC,KAAK,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;IAErD,IAAI,IAAI,KAAK,UAAU,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,QAAQ,CAAC,EAAE,CAAC;QACpD,aAAa,CAAC,KAAK,CAAC,GAAG,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC;QACxC,SAAS,EAAE,CAAC;IACd,CAAC;AACH,CAAC;AAED,aAAa,CAAC,KAAK,GAAG,IAAI,GAAG,EAAkB,CAAC;AAEhD,MAAM,mBAAmB,GAAG,CAAC,CAAC,YAAY,CAAC;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,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\n manifestOperations.push(result.data!);\n break;\n }\n case OperationTypeNode.MUTATION: {\n const result = await client.mutate<ManifestOperation>({\n mutation: source,\n fetchPolicy: \"no-cache\",\n });\n\n manifestOperations.push(result.data!);\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 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 labels: ApolloClientAiAppsConfigSchema.shape.labels.optional(),\n});\n"]}
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.6.3",
4
+ "version": "0.6.4",
5
5
  "publishConfig": {
6
6
  "access": "public"
7
7
  },
@@ -690,10 +690,7 @@ export function apolloClientAiApps(
690
690
  await processFile(fullPath);
691
691
  }
692
692
 
693
- // We don't want to do this here on builds cause it just gets overwritten anyways. We'll call it on writeBundle instead.
694
- if (config.command === "serve") {
695
- await Promise.all([generateManifest(), generateTypesFiles()]);
696
- }
693
+ await Promise.all([generateManifest(), generateTypesFiles()]);
697
694
  },
698
695
  configResolved(resolvedConfig) {
699
696
  config = resolvedConfig;
@@ -797,9 +794,6 @@ export function apolloClientAiApps(
797
794
  .replace(/(src=["'])\/([^"']+)/gi, `$1${baseUrl}/$2`)
798
795
  );
799
796
  },
800
- async writeBundle() {
801
- await Promise.all([generateManifest(), generateTypesFiles()]);
802
- },
803
797
  } satisfies Plugin;
804
798
  }
805
799