firebase-tools 15.23.0 → 15.25.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/api.js +4 -2
- package/lib/appcheck/api.js +42 -0
- package/lib/appcheck/prompts.js +41 -0
- package/lib/appcheck/types.js +2 -0
- package/lib/bin/cli.js +9 -2
- package/lib/bin/progressiveHelp.js +126 -0
- package/lib/checkValidTargetFilters.js +1 -1
- package/lib/command.js +11 -10
- package/lib/commands/ailogic-config-get.js +75 -0
- package/lib/commands/ailogic-config-set.js +109 -0
- package/lib/commands/ailogic-providers-disable.js +39 -0
- package/lib/commands/ailogic-providers-enable.js +28 -0
- package/lib/commands/ailogic-providers-list.js +29 -0
- package/lib/commands/appcheck-debugtokens-create.js +95 -0
- package/lib/commands/appcheck-debugtokens-delete.js +48 -0
- package/lib/commands/appcheck-debugtokens-list.js +35 -0
- package/lib/commands/apps-sdkconfig.js +2 -23
- package/lib/commands/database-get.js +1 -1
- package/lib/commands/dataconnect-execute.js +1 -1
- package/lib/commands/deploy.js +27 -64
- package/lib/commands/index.js +15 -0
- package/lib/deploy/apphosting/index.js +26 -1
- package/lib/deploy/auth/index.js +18 -1
- package/lib/deploy/database/index.js +16 -1
- package/lib/deploy/dataconnect/index.js +19 -1
- package/lib/deploy/extensions/index.js +9 -1
- package/lib/deploy/firestore/index.js +20 -1
- package/lib/deploy/functions/build.js +93 -3
- package/lib/deploy/functions/index.js +33 -1
- package/lib/deploy/functions/params.js +68 -26
- package/lib/deploy/functions/prepare.js +34 -8
- package/lib/deploy/functions/prompts.js +19 -0
- package/lib/deploy/functions/release/index.js +19 -12
- package/lib/deploy/functions/release/lifecycle.js +38 -5
- package/lib/deploy/functions/release/planner.js +3 -1
- package/lib/deploy/functions/runtimes/node/index.js +8 -7
- package/lib/deploy/functions/runtimes/node/versioning.js +8 -3
- package/lib/deploy/functions/validate.js +5 -2
- package/lib/deploy/hosting/index.js +30 -1
- package/lib/deploy/hosting/uploader.js +2 -1
- package/lib/deploy/index.js +68 -8
- package/lib/deploy/remoteconfig/index.js +9 -1
- package/lib/deploy/storage/index.js +16 -1
- package/lib/emulator/dataconnect/pgliteServer.js +2 -1
- package/lib/emulator/downloadableEmulatorInfo.json +30 -30
- package/lib/emulator/downloadableEmulators.js +1 -0
- package/lib/emulator/hubExport.js +2 -1
- package/lib/emulator/storage/apis/firebase.js +24 -5
- package/lib/emulator/storage/apis/gcloud.js +16 -6
- package/lib/emulator/storage/rules/runtime.js +45 -33
- package/lib/emulator/storage/server.js +2 -5
- package/lib/emulator/storage/upload.js +1 -0
- package/lib/ensureApiEnabled.js +8 -0
- package/lib/experiments.js +16 -0
- package/lib/extensions/warnings.js +64 -0
- package/lib/frameworks/utils.js +50 -1
- package/lib/functions/env.js +22 -2
- package/lib/functions/secrets.js +4 -1
- package/lib/gcp/ailogic.js +165 -1
- package/lib/gcp/cloudfunctionsv2.js +7 -0
- package/lib/gcp/firedata.js +5 -1
- package/lib/gcp/serviceusage.js +26 -0
- package/lib/hosting/proxy.js +15 -3
- package/lib/index.js +0 -1
- package/lib/init/features/ailogic/index.js +3 -29
- package/lib/init/features/database.js +1 -1
- package/lib/management/apps.js +16 -5
- package/lib/mcp/onemcp/onemcp_server.js +28 -9
- package/lib/mcp/tools/core/get_security_rules.js +2 -1
- package/lib/profiler.js +1 -1
- package/lib/streamUtils.js +3 -0
- package/lib/tsconfig.compile.tsbuildinfo +1 -1
- package/lib/tsconfig.publish.tsbuildinfo +1 -1
- package/package.json +2 -2
package/lib/gcp/serviceusage.js
CHANGED
|
@@ -3,12 +3,15 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.apiClient = void 0;
|
|
4
4
|
exports.generateServiceIdentity = generateServiceIdentity;
|
|
5
5
|
exports.generateServiceIdentityAndPoll = generateServiceIdentityAndPoll;
|
|
6
|
+
exports.disableService = disableService;
|
|
7
|
+
exports.disableServiceAndPoll = disableServiceAndPoll;
|
|
6
8
|
const colorette_1 = require("colorette");
|
|
7
9
|
const api_1 = require("../api");
|
|
8
10
|
const apiv2_1 = require("../apiv2");
|
|
9
11
|
const error_1 = require("../error");
|
|
10
12
|
const utils = require("../utils");
|
|
11
13
|
const poller = require("../operation-poller");
|
|
14
|
+
const ensureApiEnabled = require("../ensureApiEnabled");
|
|
12
15
|
const API_VERSION = "v1beta1";
|
|
13
16
|
const SERVICE_USAGE_ORIGIN = (0, api_1.serviceUsageOrigin)();
|
|
14
17
|
exports.apiClient = new apiv2_1.Client({
|
|
@@ -42,3 +45,26 @@ async function generateServiceIdentityAndPoll(projectNumber, service, prefix) {
|
|
|
42
45
|
headers: { "x-goog-user-project": `${projectNumber}` },
|
|
43
46
|
});
|
|
44
47
|
}
|
|
48
|
+
async function disableService(projectId, service) {
|
|
49
|
+
try {
|
|
50
|
+
const res = await exports.apiClient.post(`projects/${projectId}/services/${service}:disable`, {}, { headers: { "x-goog-user-project": `${projectId}` } });
|
|
51
|
+
return res.body;
|
|
52
|
+
}
|
|
53
|
+
catch (err) {
|
|
54
|
+
throw new error_1.FirebaseError(`Error disabling service ${service}.`, {
|
|
55
|
+
original: err,
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
async function disableServiceAndPoll(projectId, service, loggingPrefix) {
|
|
60
|
+
utils.logLabeledBullet(loggingPrefix, `disabling service ${(0, colorette_1.bold)(service)}...`);
|
|
61
|
+
const op = await disableService(projectId, service);
|
|
62
|
+
if (!op.done) {
|
|
63
|
+
await poller.pollOperation({
|
|
64
|
+
...serviceUsagePollerOptions,
|
|
65
|
+
operationResourceName: op.name,
|
|
66
|
+
headers: { "x-goog-user-project": `${projectId}` },
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
ensureApiEnabled.uncacheEnabledAPI(projectId, service);
|
|
70
|
+
}
|
package/lib/hosting/proxy.js
CHANGED
|
@@ -35,10 +35,18 @@ function proxyRequestHandler(url, rewriteIdentifier, options = {}) {
|
|
|
35
35
|
});
|
|
36
36
|
const u = new url_1.URL(url + req.url);
|
|
37
37
|
const c = new apiv2_1.Client({ urlPrefix: u.origin, auth: false });
|
|
38
|
+
let body;
|
|
38
39
|
let passThrough;
|
|
39
40
|
if (req.method && !["GET", "HEAD"].includes(req.method)) {
|
|
40
|
-
|
|
41
|
-
|
|
41
|
+
const rawBody = req.rawBody;
|
|
42
|
+
if (rawBody !== undefined) {
|
|
43
|
+
body = rawBody;
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
46
|
+
passThrough = new stream_1.PassThrough();
|
|
47
|
+
req.pipe(passThrough);
|
|
48
|
+
body = passThrough;
|
|
49
|
+
}
|
|
42
50
|
}
|
|
43
51
|
const headers = new Headers({
|
|
44
52
|
"X-Forwarded-Host": req.headers.host || "",
|
|
@@ -48,6 +56,10 @@ function proxyRequestHandler(url, rewriteIdentifier, options = {}) {
|
|
|
48
56
|
Cookie: sessionCookie || "",
|
|
49
57
|
});
|
|
50
58
|
const headersToSkip = new Set(["host"]);
|
|
59
|
+
if (Buffer.isBuffer(body)) {
|
|
60
|
+
headersToSkip.add("content-length");
|
|
61
|
+
headersToSkip.add("transfer-encoding");
|
|
62
|
+
}
|
|
51
63
|
for (const key of Object.keys(req.headers)) {
|
|
52
64
|
if (headersToSkip.has(key)) {
|
|
53
65
|
continue;
|
|
@@ -76,7 +88,7 @@ function proxyRequestHandler(url, rewriteIdentifier, options = {}) {
|
|
|
76
88
|
resolveOnHTTPError: true,
|
|
77
89
|
responseType: "stream",
|
|
78
90
|
redirect: "manual",
|
|
79
|
-
body
|
|
91
|
+
body,
|
|
80
92
|
timeout: 60000,
|
|
81
93
|
compress: false,
|
|
82
94
|
});
|
package/lib/index.js
CHANGED
|
@@ -97,7 +97,6 @@ program.action((_, args) => {
|
|
|
97
97
|
client.cli.parse(process.argv);
|
|
98
98
|
return;
|
|
99
99
|
}
|
|
100
|
-
(0, logger_1.useConsoleLoggers)();
|
|
101
100
|
logger_1.logger.error(clc.bold(clc.red("Error:")), clc.bold(cmd), "is not a Firebase command");
|
|
102
101
|
if (RENAMED_COMMANDS[cmd]) {
|
|
103
102
|
logger_1.logger.error();
|
|
@@ -2,44 +2,18 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.askQuestions = askQuestions;
|
|
4
4
|
exports.actuate = actuate;
|
|
5
|
-
const prompt_1 = require("../../../prompt");
|
|
6
5
|
const error_1 = require("../../../error");
|
|
7
6
|
const utils_1 = require("./utils");
|
|
8
7
|
const apps_1 = require("../../../management/apps");
|
|
9
8
|
const provision_1 = require("../../../management/provisioning/provision");
|
|
10
|
-
function checkForApps(apps) {
|
|
11
|
-
if (!apps.length) {
|
|
12
|
-
throw new error_1.FirebaseError("No Firebase apps found in this project. Please create an app first using the Firebase Console or 'firebase apps:create'.", { exit: 1 });
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
async function selectAppInteractively(apps) {
|
|
16
|
-
checkForApps(apps);
|
|
17
|
-
const choices = apps.map((app) => {
|
|
18
|
-
let displayText = app.displayName || app.appId;
|
|
19
|
-
if (!app.displayName) {
|
|
20
|
-
if (app.platform === apps_1.AppPlatform.IOS && "bundleId" in app) {
|
|
21
|
-
displayText = app.bundleId;
|
|
22
|
-
}
|
|
23
|
-
else if (app.platform === apps_1.AppPlatform.ANDROID && "packageName" in app) {
|
|
24
|
-
displayText = app.packageName;
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
return {
|
|
28
|
-
name: `${displayText} - ${app.appId} (${app.platform})`,
|
|
29
|
-
value: app,
|
|
30
|
-
};
|
|
31
|
-
});
|
|
32
|
-
return await (0, prompt_1.select)({
|
|
33
|
-
message: "Select the Firebase app to enable AI Logic for:",
|
|
34
|
-
choices,
|
|
35
|
-
});
|
|
36
|
-
}
|
|
37
9
|
async function askQuestions(setup) {
|
|
38
10
|
if (!setup.projectId) {
|
|
39
11
|
throw new error_1.FirebaseError("No project ID found. Please ensure you are in a Firebase project directory or specify a project.", { exit: 1 });
|
|
40
12
|
}
|
|
41
13
|
const apps = await (0, apps_1.listFirebaseApps)(setup.projectId, apps_1.AppPlatform.ANY);
|
|
42
|
-
const selectedApp = await selectAppInteractively(apps
|
|
14
|
+
const selectedApp = await (0, apps_1.selectAppInteractively)(apps, apps_1.AppPlatform.ANY, {
|
|
15
|
+
message: "Select the Firebase app to enable AI Logic for:",
|
|
16
|
+
});
|
|
43
17
|
if (!setup.featureInfo) {
|
|
44
18
|
setup.featureInfo = {};
|
|
45
19
|
}
|
|
@@ -30,7 +30,7 @@ async function getDBRules(instanceDetails) {
|
|
|
30
30
|
if (response.status !== 200) {
|
|
31
31
|
throw new error_1.FirebaseError(`Failed to fetch current rules. Code: ${response.status}`);
|
|
32
32
|
}
|
|
33
|
-
return await
|
|
33
|
+
return await utils.streamToString(response.body);
|
|
34
34
|
}
|
|
35
35
|
function writeDBRules(rules, filename, config) {
|
|
36
36
|
config.writeProjectFile(filename, rules);
|
package/lib/management/apps.js
CHANGED
|
@@ -5,6 +5,7 @@ exports.getPlatform = getPlatform;
|
|
|
5
5
|
exports.sdkInit = sdkInit;
|
|
6
6
|
exports.getSdkOutputPath = getSdkOutputPath;
|
|
7
7
|
exports.checkForApps = checkForApps;
|
|
8
|
+
exports.selectAppInteractively = selectAppInteractively;
|
|
8
9
|
exports.getSdkConfig = getSdkConfig;
|
|
9
10
|
exports.getAppPlatform = getAppPlatform;
|
|
10
11
|
exports.createIosApp = createIosApp;
|
|
@@ -186,18 +187,28 @@ function checkForApps(apps, appPlatform) {
|
|
|
186
187
|
"You can create an app for this project with 'firebase apps:create'");
|
|
187
188
|
}
|
|
188
189
|
}
|
|
189
|
-
async function selectAppInteractively(apps, appPlatform) {
|
|
190
|
+
async function selectAppInteractively(apps, appPlatform = AppPlatform.ANY, options) {
|
|
190
191
|
checkForApps(apps, appPlatform);
|
|
191
192
|
const choices = apps.map((app) => {
|
|
193
|
+
let displayText = app.displayName || app.appId;
|
|
194
|
+
if (!app.displayName) {
|
|
195
|
+
if (app.platform === AppPlatform.IOS && "bundleId" in app) {
|
|
196
|
+
displayText = app.bundleId;
|
|
197
|
+
}
|
|
198
|
+
else if (app.platform === AppPlatform.ANDROID && "packageName" in app) {
|
|
199
|
+
displayText = app.packageName;
|
|
200
|
+
}
|
|
201
|
+
}
|
|
192
202
|
return {
|
|
193
|
-
name: `${
|
|
194
|
-
` - ${app.appId} (${app.platform})`,
|
|
203
|
+
name: `${displayText} - ${app.appId} (${app.platform})`,
|
|
195
204
|
value: app,
|
|
196
205
|
};
|
|
197
206
|
});
|
|
207
|
+
const message = options?.message ??
|
|
208
|
+
`Select the ${appPlatform === AppPlatform.ANY ? "" : appPlatform + " "}` +
|
|
209
|
+
"app to get the configuration data:";
|
|
198
210
|
return await (0, prompt_1.select)({
|
|
199
|
-
message
|
|
200
|
-
"app to get the configuration data:",
|
|
211
|
+
message,
|
|
201
212
|
choices,
|
|
202
213
|
});
|
|
203
214
|
}
|
|
@@ -6,10 +6,11 @@ const apiv2_1 = require("../../apiv2");
|
|
|
6
6
|
const error_1 = require("../../error");
|
|
7
7
|
const ensureApiEnabled_1 = require("../../ensureApiEnabled");
|
|
8
8
|
class OneMcpServer {
|
|
9
|
-
constructor(feature, serverUrl, meta) {
|
|
9
|
+
constructor(feature, serverUrl, meta, options = {}) {
|
|
10
10
|
this.feature = feature;
|
|
11
11
|
this.serverUrl = serverUrl;
|
|
12
12
|
this.meta = meta;
|
|
13
|
+
this.options = options;
|
|
13
14
|
this.listClient = new apiv2_1.Client({
|
|
14
15
|
urlPrefix: this.serverUrl,
|
|
15
16
|
auth: false,
|
|
@@ -25,9 +26,21 @@ class OneMcpServer {
|
|
|
25
26
|
method: "tools/list",
|
|
26
27
|
jsonrpc: "2.0",
|
|
27
28
|
id: 1,
|
|
29
|
+
}, {
|
|
30
|
+
headers: {
|
|
31
|
+
"MCP-Protocol-Version": types_js_1.LATEST_PROTOCOL_VERSION,
|
|
32
|
+
"Mcp-Method": "tools/list",
|
|
33
|
+
},
|
|
28
34
|
});
|
|
29
35
|
const parsed = types_js_1.ListToolsResultSchema.parse(res.body.result);
|
|
30
|
-
|
|
36
|
+
const tools = parsed.tools.filter((mcpTool) => {
|
|
37
|
+
if (!this.options.allowedTools?.length) {
|
|
38
|
+
return true;
|
|
39
|
+
}
|
|
40
|
+
return (this.options.allowedTools.includes(mcpTool.name) ||
|
|
41
|
+
this.options.allowedTools.includes(`${this.feature}_${mcpTool.name}`));
|
|
42
|
+
});
|
|
43
|
+
return tools.map((mcpTool) => ({
|
|
31
44
|
mcp: {
|
|
32
45
|
...mcpTool,
|
|
33
46
|
name: `${this.feature}_${mcpTool.name}`,
|
|
@@ -42,6 +55,11 @@ class OneMcpServer {
|
|
|
42
55
|
}
|
|
43
56
|
}
|
|
44
57
|
async callTool(toolName, args, ctx) {
|
|
58
|
+
if (this.options.allowedTools?.length &&
|
|
59
|
+
!this.options.allowedTools.includes(toolName) &&
|
|
60
|
+
!this.options.allowedTools.includes(`${this.feature}_${toolName}`)) {
|
|
61
|
+
throw new error_1.FirebaseError(`Tool '${toolName}' is not allowed on remote server for feature '${this.feature}'.`);
|
|
62
|
+
}
|
|
45
63
|
await (0, ensureApiEnabled_1.ensure)(ctx.projectId, this.serverUrl, this.feature, true);
|
|
46
64
|
try {
|
|
47
65
|
const res = await this.callClient.post("/mcp", {
|
|
@@ -52,13 +70,14 @@ class OneMcpServer {
|
|
|
52
70
|
},
|
|
53
71
|
jsonrpc: "2.0",
|
|
54
72
|
id: 1,
|
|
55
|
-
},
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
73
|
+
}, {
|
|
74
|
+
headers: {
|
|
75
|
+
"MCP-Protocol-Version": types_js_1.LATEST_PROTOCOL_VERSION,
|
|
76
|
+
"Mcp-Method": "tools/call",
|
|
77
|
+
"Mcp-Name": toolName,
|
|
78
|
+
...(ctx.projectId ? { "x-goog-user-project": ctx.projectId } : {}),
|
|
79
|
+
},
|
|
80
|
+
});
|
|
62
81
|
return types_js_1.CallToolResultSchema.parse(res.body.result);
|
|
63
82
|
}
|
|
64
83
|
catch (error) {
|
|
@@ -7,6 +7,7 @@ const tool_1 = require("../../tool");
|
|
|
7
7
|
const util_1 = require("../../util");
|
|
8
8
|
const rules_1 = require("../../../gcp/rules");
|
|
9
9
|
const getDefaultDatabaseInstance_1 = require("../../../getDefaultDatabaseInstance");
|
|
10
|
+
const streamUtils_1 = require("../../../streamUtils");
|
|
10
11
|
exports.get_security_rules = (0, tool_1.tool)("core", {
|
|
11
12
|
name: "get_security_rules",
|
|
12
13
|
description: "Use this to retrieve the security rules for a specified Firebase service. " +
|
|
@@ -38,7 +39,7 @@ exports.get_security_rules = (0, tool_1.tool)("core", {
|
|
|
38
39
|
if (response.status !== 200) {
|
|
39
40
|
return (0, util_1.mcpError)(`Failed to fetch current rules. Code: ${response.status}`);
|
|
40
41
|
}
|
|
41
|
-
const rules = await
|
|
42
|
+
const rules = await (0, streamUtils_1.streamToString)(response.body);
|
|
42
43
|
return (0, util_1.toContent)(rules);
|
|
43
44
|
}
|
|
44
45
|
const serviceInfo = {
|
package/lib/profiler.js
CHANGED
|
@@ -55,7 +55,7 @@ async function profiler(options) {
|
|
|
55
55
|
signal: controller.signal,
|
|
56
56
|
});
|
|
57
57
|
if (res.response.status >= 400) {
|
|
58
|
-
throw (0, responseToError_1.responseToError)(res.response, await res.
|
|
58
|
+
throw (0, responseToError_1.responseToError)(res.response, await utils.streamToString(res.body));
|
|
59
59
|
}
|
|
60
60
|
if (!options.duration) {
|
|
61
61
|
spinner.start();
|