UNPKG

firebase-tools

Version:
32 lines (31 loc) 1.5 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.get_schema = void 0; const zod_1 = require("zod"); const tool_js_1 = require("../../tool.js"); const util_js_1 = require("../../util.js"); const client = require("../../../dataconnect/client.js"); const fileUtils_js_1 = require("../../../dataconnect/fileUtils.js"); const converter_js_1 = require("./converter.js"); exports.get_schema = (0, tool_js_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_js_1.pickService)(projectId, config, service_id || undefined); const schemas = await client.listSchemas(serviceInfo.serviceName, ["*"]); return (0, util_js_1.toContent)(schemas === null || schemas === void 0 ? void 0 : schemas.map(converter_js_1.schemaToText).join("\n\n")); });