firebase-tools
Version:
Command-Line Interface for Firebase
42 lines (41 loc) • 2.16 kB
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
exports.get_sdk_config = void 0;
const zod_1 = require("zod");
const tool_js_1 = require("../../tool.js");
const util_js_1 = require("../../util.js");
const apps_js_1 = require("../../../management/apps.js");
exports.get_sdk_config = (0, tool_js_1.tool)({
name: "get_sdk_config",
description: "Retrieves the Firebase SDK configuration information for the specified platform. You must specify either a platform or an app_id.",
inputSchema: zod_1.z.object({
platform: zod_1.z
.enum(["ios", "android", "web"])
.optional()
.describe("The platform for which you want config. One of 'platform' or 'app_id' must be provided."),
app_id: zod_1.z
.string()
.optional()
.describe("The specific app ID to fetch. One of 'platform' or 'app_id' must be provided."),
}),
annotations: {
title: "Get Firebase SDK Config",
readOnlyHint: true,
},
_meta: {
requiresProject: true,
requiresAuth: true,
},
}, async ({ platform: inputPlatform, app_id: appId }, { projectId }) => {
var _a, _b;
let platform = inputPlatform === null || inputPlatform === void 0 ? void 0 : inputPlatform.toUpperCase();
if (!platform && !appId)
return (0, util_js_1.mcpError)("Must specify one of 'web', 'ios', or 'android' for platform or an app_id for get_sdk_config tool.");
const apps = await (0, apps_js_1.listFirebaseApps)(projectId, platform !== null && platform !== void 0 ? platform : apps_js_1.AppPlatform.ANY);
platform = platform || ((_a = apps.find((app) => app.appId === appId)) === null || _a === void 0 ? void 0 : _a.platform);
appId = appId || ((_b = apps.find((app) => app.platform === platform)) === null || _b === void 0 ? void 0 : _b.appId);
if (!appId)
return (0, util_js_1.mcpError)(`Could not find an app for platform '${inputPlatform}' in project '${projectId}'`);
const sdkConfig = await (0, apps_js_1.getAppConfig)(appId, platform);
return (0, util_js_1.toContent)(sdkConfig, { format: "json" });
});
;