/** * Copyright (c) 2026, Salesforce, Inc., * All rights reserved. * For full license text, see the LICENSE.txt file */ import path from "node:path"; import { type GraphQLSchema, introspectionFromSchema } from "graphql"; import { atomicWriteJson } from "../../lib/fs-utils.js"; import { schemaCacheKeyForInstanceUrl, schemaDir, type SchemaMetadata, } from "../../lib/introspect.js"; import { type PrimeDeps } from "../../lib/prime-schema.js"; /** * Build a `PrimeDeps` whose `downloadSchema` writes the supplied schema to * `schemaDir()` — redirected to a tmpdir by the global test setup — so * intent-layer tests exercise the priming hook without keychain or network * access. Mirrors the real `downloadSchema` contract. */ export function makeNoopPrimeDeps(org: string, orgUrl: string, schema: GraphQLSchema): PrimeDeps { return { getOrgAuth: async () => ({ alias: org, username: "u", instanceUrl: orgUrl, accessToken: "t", orgId: "00D", }), downloadSchema: async (auth) => { const cacheKey = schemaCacheKeyForInstanceUrl(auth.instanceUrl); const filePath = path.join(schemaDir(), `${cacheKey}.json`); atomicWriteJson(filePath, { data: introspectionFromSchema(schema) }); const meta: SchemaMetadata = { cacheKey, instanceUrl: auth.instanceUrl, typeCount: 0, downloadedAt: new Date().toISOString(), filePath, }; return meta; }, }; }