UNPKG

firebase-tools

Version:
32 lines (31 loc) 1.46 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.get_schema = void 0; const zod_1 = require("zod"); const tool_1 = require("../../tool"); const util_1 = require("../../util"); const client = require("../../../dataconnect/client"); const fileUtils_1 = require("../../../dataconnect/fileUtils"); const converter_1 = require("./converter"); exports.get_schema = (0, tool_1.tool)({ name: "get_schema", description: "Retrieve information about the Firebase Data Connect Schema in the project, including Cloud SQL data sources and the GraphQL Schema describing the data model.", inputSchema: zod_1.z.object({ service_id: zod_1.z .string() .nullable() .describe("The Firebase Data Connect service ID to look for. If there is only one service defined in firebase.json, this can be omitted and that will be used."), }), annotations: { title: "Get Data Connect Schemas", readOnlyHint: true, }, _meta: { requiresProject: true, requiresAuth: true, }, }, async ({ service_id }, { projectId, config }) => { const serviceInfo = await (0, fileUtils_1.pickService)(projectId, config, service_id || undefined); const schemas = await client.listSchemas(serviceInfo.serviceName, ["*"]); return (0, util_1.toContent)(schemas === null || schemas === void 0 ? void 0 : schemas.map(converter_1.schemaToText).join("\n\n")); });