UNPKG

firebase-tools

Version:
34 lines (33 loc) 1.32 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.list_collections = void 0; const zod_1 = require("zod"); const tool_1 = require("../../tool"); const util_1 = require("../../util"); const firestore_1 = require("../../../gcp/firestore"); const types_1 = require("../../../emulator/types"); exports.list_collections = (0, tool_1.tool)("firestore", { name: "list_collections", description: "Use this to retrieve a list of collections from a Firestore database in the current project.", inputSchema: zod_1.z.object({ database: zod_1.z .string() .optional() .describe("Database id to use. Defaults to `(default)` if unspecified."), use_emulator: zod_1.z.boolean().default(false).describe("Target the Firestore emulator if true."), }), annotations: { title: "List Firestore collections", readOnlyHint: true, }, _meta: { requiresAuth: true, requiresProject: true, }, }, async ({ database, use_emulator }, { projectId, host }) => { let emulatorUrl; if (use_emulator) { emulatorUrl = await host.getEmulatorUrl(types_1.Emulators.FIRESTORE); } return (0, util_1.toContent)(await (0, firestore_1.listCollectionIds)(projectId, database, emulatorUrl)); });