firebase-tools 15.34.1 → 15.35.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.
Files changed (73) hide show
  1. package/lib/api.js +2 -4
  2. package/lib/apphosting/constants.js +1 -4
  3. package/lib/apphosting/utils.js +0 -26
  4. package/lib/commands/apps-android-sha-create.js +1 -1
  5. package/lib/commands/apps-android-sha-delete.js +1 -1
  6. package/lib/commands/apps-android-sha-list.js +1 -1
  7. package/lib/commands/{crashlytics-onboard-web.js → crashlytics-setup.js} +5 -5
  8. package/lib/commands/crashlytics-sourcemap-upload.js +4 -0
  9. package/lib/commands/emulators-start.js +2 -2
  10. package/lib/commands/index.js +5 -6
  11. package/lib/commands/run-services-get.js +19 -0
  12. package/lib/commands/run-services-list.js +11 -0
  13. package/lib/crashlytics/alerts.js +1 -0
  14. package/lib/crashlytics/firebasetelemetry.js +5 -3
  15. package/lib/crashlytics/onboarding.js +15 -23
  16. package/lib/crashlytics/reports.js +46 -17
  17. package/lib/crashlytics/sourcemap.js +19 -5
  18. package/lib/dataconnect/dataplaneClient.js +0 -10
  19. package/lib/deploy/apphosting/deploy.js +20 -41
  20. package/lib/deploy/apphosting/localBuild.js +49 -0
  21. package/lib/deploy/apphosting/prepare.js +12 -25
  22. package/lib/deploy/apphosting/release.js +1 -1
  23. package/lib/deploy/apphosting/util.js +27 -4
  24. package/lib/deploy/functions/containerCleaner.js +1 -142
  25. package/lib/deploy/functions/functionsDeployHelper.js +0 -4
  26. package/lib/deploy/functions/release/fabricator.js +6 -3
  27. package/lib/deploy/functions/validate.js +1 -1
  28. package/lib/deploy/run/deploy.js +26 -43
  29. package/lib/deploy/run/get.js +30 -0
  30. package/lib/deploy/run/list.js +38 -0
  31. package/lib/deploy/run/prereqs.js +0 -3
  32. package/lib/deploy/run/util.js +9 -0
  33. package/lib/emulator/commandUtils.js +105 -23
  34. package/lib/emulator/dataconnect/pgliteServer.js +1 -0
  35. package/lib/emulator/downloadableEmulatorInfo.json +22 -22
  36. package/lib/emulator/downloadableEmulators.js +43 -5
  37. package/lib/emulator/firestoreEmulator.js +5 -0
  38. package/lib/emulator/functionsEmulator.js +22 -7
  39. package/lib/emulator/pubsubEmulator.js +64 -11
  40. package/lib/emulator/storage/rules/manager.js +31 -15
  41. package/lib/emulator/storage/rules/runtime.js +1 -0
  42. package/lib/emulator/taskQueue.js +5 -4
  43. package/lib/experiments.js +0 -5
  44. package/lib/extensions/emulator/specHelper.js +0 -4
  45. package/lib/extensions/extensionsApi.js +0 -8
  46. package/lib/extensions/extensionsHelper.js +1 -71
  47. package/lib/extensions/runtimes/common.js +0 -12
  48. package/lib/extensions/secretsUtils.js +0 -24
  49. package/lib/extensions/updateHelper.js +2 -88
  50. package/lib/frameworks/angular/utils.js +3 -2
  51. package/lib/frameworks/next/utils.js +0 -11
  52. package/lib/fsAsync.js +34 -20
  53. package/lib/functions/kits/install.js +37 -337
  54. package/lib/functions/kits/sources/directory.js +59 -0
  55. package/lib/functions/kits/sources/index.js +19 -0
  56. package/lib/functions/kits/sources/npm.js +274 -0
  57. package/lib/functions/kits/sources/types.js +12 -0
  58. package/lib/gcp/artifactregistry.js +0 -5
  59. package/lib/gcp/cloudlogging.js +0 -54
  60. package/lib/gcp/iam.js +0 -4
  61. package/lib/gcp/pubsub.js +0 -14
  62. package/lib/gcp/storage.js +2 -1
  63. package/lib/init/features/aitools/promptUpdater.js +3 -2
  64. package/lib/init/features/run.js +3 -7
  65. package/lib/mcp/errors.js +1 -1
  66. package/lib/mcp/resources/guides/crashlytics_reports.js +33 -71
  67. package/lib/mcp/tools/crashlytics/reports.js +25 -30
  68. package/lib/mcp/util/dataconnect/converter.js +0 -29
  69. package/lib/tsconfig.compile.tsbuildinfo +1 -1
  70. package/lib/tsconfig.publish.tsbuildinfo +1 -1
  71. package/package.json +9 -6
  72. package/lib/apphosting/repo.js +0 -243
  73. package/lib/deploy/hosting/args.js +0 -2
@@ -0,0 +1,274 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DEFAULT_TEMPLATE = exports.TEMPLATES = void 0;
4
+ exports.parseNpmPackageSpecifier = parseNpmPackageSpecifier;
5
+ exports.validateNpmPackageName = validateNpmPackageName;
6
+ exports.validateNpmPackageExists = validateNpmPackageExists;
7
+ exports.sanitizePackageNameToKitName = sanitizePackageNameToKitName;
8
+ exports.isThirdPartyPackage = isThirdPartyPackage;
9
+ exports.checkPackageHasShrinkwrap = checkPackageHasShrinkwrap;
10
+ exports.promptSecurityConfirmation = promptSecurityConfirmation;
11
+ exports.writeKitPackageJson = writeKitPackageJson;
12
+ exports.writeKitIndexTs = writeKitIndexTs;
13
+ exports.scaffoldKitFiles = scaffoldKitFiles;
14
+ exports.resolveSdkSpecifierToSave = resolveSdkSpecifierToSave;
15
+ exports.getKitPackagesToSave = getKitPackagesToSave;
16
+ exports.buildAndInstallKit = buildAndInstallKit;
17
+ const path = require("path");
18
+ const clc = require("colorette");
19
+ const fs = require("fs-extra");
20
+ const semver = require("semver");
21
+ const error_1 = require("../../../error");
22
+ const spawn_1 = require("../../../init/spawn");
23
+ const logger_1 = require("../../../logger");
24
+ const prompt_1 = require("../../../prompt");
25
+ const templates_1 = require("../../../templates");
26
+ const utils_1 = require("../../../utils");
27
+ const supported = require("../../../deploy/functions/runtimes/supported");
28
+ const types_1 = require("./types");
29
+ exports.TEMPLATES = {
30
+ installation: "init/functions/typescript/index-kit.ts",
31
+ migration: "init/functions/typescript/index-kit-migration.ts",
32
+ };
33
+ exports.DEFAULT_TEMPLATE = "installation";
34
+ function parseNpmPackageSpecifier(rawPkg) {
35
+ const lastAt = rawPkg.lastIndexOf("@");
36
+ if (lastAt > 0) {
37
+ const version = rawPkg.substring(lastAt + 1);
38
+ return {
39
+ packageName: rawPkg.substring(0, lastAt),
40
+ ...(version ? { version } : {}),
41
+ };
42
+ }
43
+ return { packageName: rawPkg };
44
+ }
45
+ function validateNpmPackageName(packageNameOrSpecifier) {
46
+ const { packageName, version } = parseNpmPackageSpecifier(packageNameOrSpecifier);
47
+ const npmPackageRegex = /^(?:@[a-z0-9_.-]+\/[a-z0-9_.-]+|[a-z0-9_.-]+)$/i;
48
+ if (!packageName ||
49
+ packageName.length > 214 ||
50
+ !npmPackageRegex.test(packageName) ||
51
+ (packageNameOrSpecifier.lastIndexOf("@") > 0 && !version)) {
52
+ throw new error_1.FirebaseError(`Invalid NPM package name '${packageNameOrSpecifier}'. Package names must be valid npm package specifiers (e.g. 'my-kit' or '@scope/my-kit').`);
53
+ }
54
+ }
55
+ async function validateNpmPackageExists(rawPkgName) {
56
+ validateNpmPackageName(rawPkgName);
57
+ try {
58
+ const output = await (0, spawn_1.spawnWithOutput)("npm", ["view", rawPkgName, "version"]);
59
+ if (!output.trim()) {
60
+ throw new Error(`No version found for '${rawPkgName}'`);
61
+ }
62
+ }
63
+ catch (err) {
64
+ throw new error_1.FirebaseError(`NPM package '${rawPkgName}' could not be found in the npm registry. Please verify the package name and version.`, { original: err instanceof Error ? err : undefined });
65
+ }
66
+ }
67
+ function sanitizePackageNameToKitName(packageNameOrSpecifier) {
68
+ const { packageName } = parseNpmPackageSpecifier(packageNameOrSpecifier);
69
+ const parts = packageName.split("/");
70
+ const nameWithoutScope = parts[parts.length - 1] || packageName;
71
+ return (0, types_1.sanitizeToKitId)(nameWithoutScope);
72
+ }
73
+ function isThirdPartyPackage(packageNameOrSpecifier) {
74
+ const { packageName } = parseNpmPackageSpecifier(packageNameOrSpecifier);
75
+ return !packageName.startsWith("@firebase-function-kits/");
76
+ }
77
+ async function checkPackageHasShrinkwrap(rawPkgName) {
78
+ try {
79
+ const output = await (0, spawn_1.spawnWithOutput)("npm", ["pack", rawPkgName, "--dry-run", "--json"]);
80
+ const parsed = JSON.parse(output);
81
+ if (Array.isArray(parsed) && parsed.length > 0) {
82
+ const pkgInfo = parsed[0];
83
+ if (pkgInfo.hasShrinkwrap) {
84
+ return true;
85
+ }
86
+ if (Array.isArray(pkgInfo.files)) {
87
+ return pkgInfo.files.some((f) => f.path === "npm-shrinkwrap.json" || f.path === "npm-shrinkwrap.js");
88
+ }
89
+ }
90
+ }
91
+ catch (err) {
92
+ logger_1.logger.debug(`Failed to inspect package shrinkwrap for ${rawPkgName}: ${(0, error_1.getErrMsg)(err)}`);
93
+ }
94
+ return false;
95
+ }
96
+ async function promptSecurityConfirmation(options) {
97
+ const { rawPkgName, packageName, nonInteractive, force } = options;
98
+ const isThirdParty = isThirdPartyPackage(packageName);
99
+ if (isThirdParty) {
100
+ (0, utils_1.logLabeledWarning)("functions", `Package ${clc.bold(packageName)} is a third-party kit (outside the @firebase-function-kits scope).`);
101
+ }
102
+ const hasShrinkwrap = await checkPackageHasShrinkwrap(rawPkgName);
103
+ if (!hasShrinkwrap) {
104
+ (0, utils_1.logLabeledWarning)("functions", `Package ${clc.bold(packageName)} does not have an npm-shrinkwrap.json file. npm-shrinkwrap guarantees that you deploy the same version of dependencies that the publisher tested against. Since this kit does not have an npm-shrinkwrap, it is possible that deploys or updates may introduce bugs or vulnerabilities in newer dependency versions that the publisher did not test against.`);
105
+ }
106
+ if (isThirdParty || !hasShrinkwrap) {
107
+ let confirmMessage;
108
+ if (isThirdParty && !hasShrinkwrap) {
109
+ confirmMessage = `Are you sure you want to install the third-party kit ${packageName} without locked dependencies?`;
110
+ }
111
+ else if (isThirdParty) {
112
+ confirmMessage = `Are you sure you want to install the third-party kit ${packageName}?`;
113
+ }
114
+ else {
115
+ confirmMessage = `Are you sure you want to install ${packageName} without locked dependencies?`;
116
+ }
117
+ const confirmInstallation = await (0, prompt_1.confirm)({
118
+ message: confirmMessage,
119
+ default: false,
120
+ nonInteractive,
121
+ force,
122
+ });
123
+ if (!confirmInstallation) {
124
+ throw new error_1.FirebaseError("Installation cancelled.");
125
+ }
126
+ }
127
+ return isThirdParty;
128
+ }
129
+ async function writeKitPackageJson(config, sourcePath, kitId) {
130
+ const relPackageJsonPath = path.join(sourcePath, "package.json");
131
+ const absPackageJsonPath = config.path(relPackageJsonPath);
132
+ let pkgJson = {};
133
+ if (await fs.pathExists(absPackageJsonPath)) {
134
+ try {
135
+ pkgJson = (await fs.readJson(absPackageJsonPath)) || {};
136
+ }
137
+ catch (err) {
138
+ logger_1.logger.debug(`Failed to read existing package.json: ${(0, error_1.getErrMsg)(err)}`);
139
+ }
140
+ }
141
+ else {
142
+ const latestNodeVersion = supported.latest("nodejs").replace("nodejs", "");
143
+ const packageKitTemplate = (0, templates_1.readTemplateSync)("init/functions/typescript/package-kit.json");
144
+ const subbedTemplate = packageKitTemplate.replace(/{{RUNTIME}}/g, latestNodeVersion);
145
+ try {
146
+ pkgJson = JSON.parse(subbedTemplate);
147
+ }
148
+ catch (err) {
149
+ throw new error_1.FirebaseError("Failed to parse package-kit.json template: " + (0, error_1.getErrMsg)(err), {
150
+ original: err instanceof Error ? err : undefined,
151
+ });
152
+ }
153
+ }
154
+ pkgJson.name = `${kitId}-wrapper`;
155
+ await config.askWriteProjectFile(relPackageJsonPath, pkgJson);
156
+ }
157
+ async function writeKitIndexTs(options) {
158
+ const { config, sourcePath, packageName, templateType } = options;
159
+ const relIndexTsPath = path.join(sourcePath, "src", "index.ts");
160
+ const absIndexTsPath = config.path(relIndexTsPath);
161
+ if (!(await fs.pathExists(absIndexTsPath))) {
162
+ const template = (0, templates_1.readTemplateSync)(exports.TEMPLATES[templateType]);
163
+ const indexContent = template.replace(/{{PACKAGE_NAME}}/g, packageName);
164
+ await config.askWriteProjectFile(relIndexTsPath, indexContent);
165
+ }
166
+ }
167
+ async function scaffoldKitFiles(config, kitId, instanceId, packageName, templateType = exports.DEFAULT_TEMPLATE) {
168
+ const sourcePath = path.join(types_1.FUNCTION_KITS_DIR, kitId, "source");
169
+ const configDirPath = path.join(types_1.FUNCTION_KITS_DIR, kitId, `config-${instanceId}`);
170
+ const absSourcePath = config.path(sourcePath);
171
+ const absConfigDirPath = config.path(configDirPath);
172
+ await fs.ensureDir(absSourcePath);
173
+ await fs.ensureDir(absConfigDirPath);
174
+ await writeKitPackageJson(config, sourcePath, kitId);
175
+ await config.askWriteProjectFile(path.join(sourcePath, "tsconfig.json"), (0, templates_1.readTemplateSync)("init/functions/typescript/tsconfig.json"));
176
+ await config.askWriteProjectFile(path.join(sourcePath, ".gitignore"), (0, templates_1.readTemplateSync)("init/functions/typescript/_gitignore"));
177
+ await writeKitIndexTs({ config, sourcePath, packageName, templateType });
178
+ return { sourcePath, configDirPath, absSourcePath, absConfigDirPath };
179
+ }
180
+ function resolveSdkSpecifierToSave(packageName, declaredVer, installedVer) {
181
+ const cleanVer = semver.clean(declaredVer);
182
+ if (cleanVer) {
183
+ return `${packageName}@=${installedVer || cleanVer}`;
184
+ }
185
+ if (declaredVer.trim().startsWith("~")) {
186
+ return installedVer ? `${packageName}@~${installedVer}` : `${packageName}@${declaredVer}`;
187
+ }
188
+ if (installedVer) {
189
+ return `${packageName}@^${installedVer}`;
190
+ }
191
+ return `${packageName}@${declaredVer}`;
192
+ }
193
+ async function getKitPackagesToSave(absSourcePath, packageName) {
194
+ const lockfilePath = path.join(absSourcePath, "package-lock.json");
195
+ let peerDeps = {};
196
+ let directDeps = {};
197
+ let installedFunctionsVer;
198
+ let installedAdminVer;
199
+ if (await fs.pathExists(lockfilePath)) {
200
+ try {
201
+ const lockfile = (await fs.readJson(lockfilePath));
202
+ const packages = lockfile?.packages || {};
203
+ const kitEntry = packages[`node_modules/${packageName}`] || {};
204
+ peerDeps = kitEntry.peerDependencies || {};
205
+ directDeps = kitEntry.dependencies || {};
206
+ installedFunctionsVer = packages["node_modules/firebase-functions"]?.version;
207
+ installedAdminVer = packages["node_modules/firebase-admin"]?.version;
208
+ }
209
+ catch (err) {
210
+ logger_1.logger.debug(`Failed to read package-lock.json: ${(0, error_1.getErrMsg)(err)}`);
211
+ }
212
+ }
213
+ if (Object.keys(peerDeps).length === 0 && Object.keys(directDeps).length === 0) {
214
+ const kitPkgJsonPath = path.join(absSourcePath, "node_modules", packageName, "package.json");
215
+ if (await fs.pathExists(kitPkgJsonPath)) {
216
+ try {
217
+ const kitPkgJson = (await fs.readJson(kitPkgJsonPath));
218
+ peerDeps = kitPkgJson?.peerDependencies || {};
219
+ directDeps = kitPkgJson?.dependencies || {};
220
+ }
221
+ catch (err) {
222
+ logger_1.logger.debug(`Failed to read kit package.json: ${(0, error_1.getErrMsg)(err)}`);
223
+ }
224
+ }
225
+ }
226
+ const declaredFunctionsVer = peerDeps["firebase-functions"] || directDeps["firebase-functions"];
227
+ if (!declaredFunctionsVer) {
228
+ throw new error_1.FirebaseError(`Package '${packageName}' is not a valid Function Kit: it must declare 'firebase-functions' as a dependency or peer dependency.`);
229
+ }
230
+ const packagesToSave = [
231
+ resolveSdkSpecifierToSave("firebase-functions", declaredFunctionsVer, installedFunctionsVer),
232
+ ];
233
+ const declaredAdminVer = peerDeps["firebase-admin"] || directDeps["firebase-admin"];
234
+ if (declaredAdminVer) {
235
+ packagesToSave.push(resolveSdkSpecifierToSave("firebase-admin", declaredAdminVer, installedAdminVer));
236
+ }
237
+ return packagesToSave;
238
+ }
239
+ async function buildAndInstallKit(absSourcePath, rawPkgName, isThirdParty) {
240
+ const { packageName } = parseNpmPackageSpecifier(rawPkgName);
241
+ const installArgs = ["install", rawPkgName, "--save-prefix=^"];
242
+ if (isThirdParty) {
243
+ installArgs.push("--ignore-scripts");
244
+ }
245
+ (0, utils_1.logLabeledBullet)("functions", `Running npm ${installArgs.join(" ")}...`);
246
+ try {
247
+ await (0, spawn_1.wrapSpawn)("npm", installArgs, absSourcePath);
248
+ }
249
+ catch (err) {
250
+ throw new error_1.FirebaseError(`NPM install failed: ${(0, error_1.getErrMsg)(err)}`);
251
+ }
252
+ const packagesToSave = await getKitPackagesToSave(absSourcePath, packageName);
253
+ if (packagesToSave.length > 0) {
254
+ (0, utils_1.logLabeledBullet)("functions", `Saving resolved SDK dependencies: ${clc.bold(packagesToSave.join(", "))}...`);
255
+ const saveArgs = ["install", ...packagesToSave, "--save-prefix=^"];
256
+ if (isThirdParty) {
257
+ saveArgs.push("--ignore-scripts");
258
+ }
259
+ try {
260
+ await (0, spawn_1.wrapSpawn)("npm", saveArgs, absSourcePath);
261
+ }
262
+ catch (err) {
263
+ throw new error_1.FirebaseError(`Failed to install required SDK dependencies (${packagesToSave.join(", ")}): ${(0, error_1.getErrMsg)(err)}. ` +
264
+ "Verify that the kit's dependencies are compatible with the resolved Firebase SDK versions.", { original: err instanceof Error ? err : undefined });
265
+ }
266
+ }
267
+ (0, utils_1.logLabeledBullet)("functions", "Building TypeScript source...");
268
+ try {
269
+ await (0, spawn_1.wrapSpawn)("npm", ["run", "build"], absSourcePath);
270
+ }
271
+ catch (err) {
272
+ throw new error_1.FirebaseError(`TypeScript build failed: ${(0, error_1.getErrMsg)(err)}`);
273
+ }
274
+ }
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.MAX_KIT_ID_LENGTH = exports.FUNCTION_KITS_DIR = void 0;
4
+ exports.sanitizeToKitId = sanitizeToKitId;
5
+ exports.FUNCTION_KITS_DIR = "function-kits";
6
+ exports.MAX_KIT_ID_LENGTH = 40;
7
+ function sanitizeToKitId(name) {
8
+ return name
9
+ .toLowerCase()
10
+ .replace(/[^a-z0-9_-]/g, "")
11
+ .slice(0, exports.MAX_KIT_ID_LENGTH);
12
+ }
@@ -2,7 +2,6 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.API_VERSION = void 0;
4
4
  exports.ensureApiEnabled = ensureApiEnabled;
5
- exports.deletePackage = deletePackage;
6
5
  exports.getRepository = getRepository;
7
6
  exports.updateRepository = updateRepository;
8
7
  exports.ensureDockerRepository = ensureDockerRepository;
@@ -23,10 +22,6 @@ function ensureApiEnabled(projectId) {
23
22
  return api.ensure(projectId, (0, api_1.artifactRegistryDomain)(), "artifactregistry", true);
24
23
  }
25
24
  (0, metaprogramming_1.assertImplements)();
26
- async function deletePackage(name) {
27
- const res = await client.delete(name);
28
- return res.body;
29
- }
30
25
  async function getRepository(repoPath) {
31
26
  const res = await client.get(repoPath);
32
27
  return res.body;
@@ -1,8 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.listEntries = listEntries;
4
- exports.createOrUpdateLogBucket = createOrUpdateLogBucket;
5
- exports.createOrUpdateLogSink = createOrUpdateLogSink;
6
4
  const api_1 = require("../api");
7
5
  const apiv2_1 = require("../apiv2");
8
6
  const error_1 = require("../error");
@@ -31,55 +29,3 @@ async function listEntries(projectId, filter, pageSize, order, pageToken) {
31
29
  });
32
30
  }
33
31
  }
34
- async function createOrUpdateLogBucket(projectId, bucketId, location = "global", analyticsEnabled = true) {
35
- const client = new apiv2_1.Client({ urlPrefix: (0, api_1.cloudloggingOrigin)(), apiVersion: API_VERSION });
36
- const path = `/projects/${projectId}/locations/${location}/buckets`;
37
- try {
38
- const res = await client.post(`${path}?bucketId=${bucketId}`, { analyticsEnabled });
39
- return res.body;
40
- }
41
- catch (err) {
42
- if (err.status === 409) {
43
- try {
44
- const patchRes = await client.patch(`${path}/${bucketId}?updateMask=analyticsEnabled`, { analyticsEnabled });
45
- return patchRes.body;
46
- }
47
- catch (patchErr) {
48
- const msg = patchErr.message || JSON.stringify(patchErr.body) || patchErr;
49
- throw new error_1.FirebaseError(`Failed to patch log bucket ${bucketId} (status ${patchErr.status}): ${msg}`, { original: patchErr });
50
- }
51
- }
52
- const msg = err.message || JSON.stringify(err.body) || err;
53
- if (typeof msg === "string" && msg.toLowerCase().includes("billing account")) {
54
- throw new error_1.FirebaseError(`Creating a Cloud Logging bucket requires a valid linked billing account (Blaze plan). Please attach a billing account to project ${projectId} and try again.`, { original: err });
55
- }
56
- throw new error_1.FirebaseError(`Failed to create or update log bucket ${bucketId} (status ${err.status}): ${msg}`, { original: err });
57
- }
58
- }
59
- async function createOrUpdateLogSink(projectId, sinkName, destination, filter) {
60
- const client = new apiv2_1.Client({ urlPrefix: (0, api_1.cloudloggingOrigin)(), apiVersion: API_VERSION });
61
- const path = `/projects/${projectId}/sinks`;
62
- const body = {
63
- name: sinkName,
64
- destination,
65
- filter,
66
- };
67
- try {
68
- const res = await client.post(path, body);
69
- return res.body;
70
- }
71
- catch (err) {
72
- if (err.status === 409) {
73
- try {
74
- const putRes = await client.put(`${path}/${sinkName}`, body);
75
- return putRes.body;
76
- }
77
- catch (putErr) {
78
- const msg = putErr.message || JSON.stringify(putErr.body) || putErr;
79
- throw new error_1.FirebaseError(`Failed to update log sink ${sinkName} (status ${putErr.status}): ${msg}`, { original: putErr });
80
- }
81
- }
82
- const msg = err.message || JSON.stringify(err.body) || err;
83
- throw new error_1.FirebaseError(`Failed to create or update log sink ${sinkName} (status ${err.status}): ${msg}`, { original: err });
84
- }
85
- }
package/lib/gcp/iam.js CHANGED
@@ -1,6 +1,5 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getDefaultCloudBuildServiceAgent = getDefaultCloudBuildServiceAgent;
4
3
  exports.createServiceAccount = createServiceAccount;
5
4
  exports.getServiceAccount = getServiceAccount;
6
5
  exports.createServiceAccountKey = createServiceAccountKey;
@@ -22,9 +21,6 @@ const error_1 = require("../error");
22
21
  const knownRoles = require("./knownRoles.json");
23
22
  const crypto = require("crypto");
24
23
  const apiClient = new apiv2_1.Client({ urlPrefix: (0, api_1.iamOrigin)(), apiVersion: "v1" });
25
- function getDefaultCloudBuildServiceAgent(projectNumber) {
26
- return `${projectNumber}@cloudbuild.gserviceaccount.com`;
27
- }
28
24
  async function createServiceAccount(projectId, accountId, description, displayName) {
29
25
  const response = await apiClient.post(`/projects/${projectId}/serviceAccounts`, {
30
26
  accountId,
package/lib/gcp/pubsub.js CHANGED
@@ -1,12 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.createTopic = createTopic;
4
- exports.getTopic = getTopic;
5
- exports.updateTopic = updateTopic;
6
4
  exports.deleteTopic = deleteTopic;
7
5
  const apiv2_1 = require("../apiv2");
8
6
  const api_1 = require("../api");
9
- const proto = require("./proto");
10
7
  const API_VERSION = "v1";
11
8
  const client = new apiv2_1.Client({
12
9
  urlPrefix: (0, api_1.pubsubOrigin)(),
@@ -17,17 +14,6 @@ async function createTopic(topic) {
17
14
  const result = await client.put(topic.name, topic);
18
15
  return result.body;
19
16
  }
20
- async function getTopic(name) {
21
- const result = await client.get(name);
22
- return result.body;
23
- }
24
- async function updateTopic(topic) {
25
- const queryParams = {
26
- updateMask: proto.fieldMasks(topic).join(","),
27
- };
28
- const result = await client.patch(topic.name, topic, { queryParams });
29
- return result.body;
30
- }
31
17
  async function deleteTopic(name) {
32
18
  await client.delete(name);
33
19
  }
@@ -149,7 +149,7 @@ async function createBucket(projectId, req, projectPrivate) {
149
149
  async function patchBucket(bucketName, metadata) {
150
150
  try {
151
151
  const localAPIClient = new apiv2_1.Client({ urlPrefix: (0, api_1.storageOrigin)() });
152
- const mask = (0, proto_1.fieldMasks)(metadata, "labels", "acl", "defaultObjectAcl", "lifecycle", "cors");
152
+ const mask = (0, proto_1.fieldMasks)(metadata, "labels", "acl", "defaultObjectAcl", "lifecycle", "cors", "autoclass");
153
153
  const result = await localAPIClient.patch(`/storage/v1/b/${bucketName}`, metadata, { queryParams: { updateMask: mask.join(",") } });
154
154
  return result.body;
155
155
  }
@@ -197,6 +197,7 @@ async function upsertBucket(opts) {
197
197
  labels: {
198
198
  [opts.req.purposeLabel]: "true",
199
199
  },
200
+ ...(opts.req.autoclass ? { autoclass: opts.req.autoclass } : {}),
200
201
  }, true);
201
202
  return name;
202
203
  }
@@ -66,10 +66,11 @@ async function updateFirebaseSection(config, filePath, enabledFeatures, options)
66
66
  finalContent = options?.header ? `${options.header}\n\n${newSection}` : newSection;
67
67
  }
68
68
  else if (match) {
69
+ const start = match.index;
69
70
  finalContent =
70
- currentContent.substring(0, match.index) +
71
+ currentContent.substring(0, start) +
71
72
  newSection +
72
- currentContent.substring(match.index + match[0].length);
73
+ currentContent.substring(start + match[0].length);
73
74
  }
74
75
  else {
75
76
  const separator = currentContent.endsWith("\n") ? "\n" : "\n\n";
@@ -40,7 +40,7 @@ async function askQuestions(setup, config, options) {
40
40
  let serviceId;
41
41
  let region;
42
42
  if (existing) {
43
- ({ region, serviceId } = parseServiceName(existing.name));
43
+ ({ region, serviceId } = (0, util_1.parseServiceName)(existing.name));
44
44
  }
45
45
  else {
46
46
  region = await (0, prompt_1.select)({
@@ -101,13 +101,13 @@ async function promptWebApp(projectId) {
101
101
  }
102
102
  async function promptExistingService(projectId) {
103
103
  const allServices = await runv2.listServices(projectId, false);
104
- const services = allServices.filter((s) => !s.labels?.[runv2.CLIENT_NAME_LABEL]);
104
+ const services = allServices.filter((s) => !(0, util_1.isManagedByAnotherProduct)(s));
105
105
  if (services.length === 0) {
106
106
  (0, utils_1.logBullet)("No Cloud Run services to update. Creating a new service instead.");
107
107
  return undefined;
108
108
  }
109
109
  const choices = services.map((service) => {
110
- const { serviceId, region } = parseServiceName(service.name);
110
+ const { serviceId, region } = (0, util_1.parseServiceName)(service.name);
111
111
  return { name: `${serviceId} (${region})`, value: service };
112
112
  });
113
113
  return (0, prompt_1.select)({
@@ -115,10 +115,6 @@ async function promptExistingService(projectId) {
115
115
  choices,
116
116
  });
117
117
  }
118
- function parseServiceName(name) {
119
- const parts = name.split("/");
120
- return { region: parts[3], serviceId: parts[5] };
121
- }
122
118
  async function promptNewServiceId(projectId, region) {
123
119
  return (0, prompt_1.input)({
124
120
  message: "Please enter a unique ID for your service",
package/lib/mcp/errors.js CHANGED
@@ -6,7 +6,7 @@ exports.mcpAuthError = mcpAuthError;
6
6
  const util_1 = require("./util");
7
7
  exports.NO_PROJECT_ERROR = (0, util_1.mcpError)("To proceed requires an active project. Use the `firebase_update_environment` tool to set a project ID", "PRECONDITION_FAILED");
8
8
  function noProjectDirectory(projectRoot) {
9
- return (0, util_1.mcpError)(`The current project directory '${projectRoot || "<NO PROJECT DIRECTORY FOUND>"}' does not exist. Please use the 'update_firebase_environment' tool to target a different project directory.`);
9
+ return (0, util_1.mcpError)(`The current project directory '${projectRoot || "<NO PROJECT DIRECTORY FOUND>"}' does not exist. Please use the 'firebase_update_environment' tool to target a different project directory.`);
10
10
  }
11
11
  function mcpAuthError(skipADC) {
12
12
  if (skipADC) {
@@ -5,74 +5,36 @@ const resource_1 = require("../../resource");
5
5
  const RESOURCE_CONTENT = `
6
6
  ### Crashlytics Reports
7
7
 
8
- Aggregate metrics for all of the events sent to Crashlytics are available as reports.
9
- The following reports are available for all Crashlytics applications.
10
-
11
- - name: "topIssues"
12
- display_name: "Top Issues"
13
- usage: |
14
- Counts events and distinct impacted users, grouped by issue.
15
- Issue groups are sorted by event count, in descending order.
16
-
17
- - name: "topVersions"
18
- display_name: "Top Versions"
19
- usage: |
20
- Counts events, grouped by app version.
21
- Versions are sorted by event count, in descending order.
22
-
23
- - name: "topOperatingSystems"
24
- display_name: "Top Operating Systems"
25
- usage: |
26
- Counts events, grouped by device operating systems and their versions.
27
- Operating systems are sorted by event count, in descending order.
28
-
29
- Mobile apps have the following report available:
30
-
31
- - name: "topVariants"
32
- display_name: "Top Variants"
33
- usage: |
34
- Counts events and distinct impacted users, grouped by issue variant.
35
- Issue variant groups are sorted by event count, in descending order.
36
- required: |
37
- An issue filter including an issue id is required.
38
-
39
- Mobile apps also have one of the following reports available, depending on the platform.
40
-
41
- - name: "topAndroidDevices"
42
- display_name: "Top Android Devices"
43
- usage: |
44
- Counts events, grouped by android device.
45
- Devices are sorted by event count, in descending order.
46
-
47
- - name: "topAppleDevices"
48
- display_name: "Top Apple Devices"
49
- usage:
50
- Counts events, grouped by operating system and Apple device.
51
- Devices are sorted by event count, in descending order.
52
-
53
- Web apps have the following additional reports available.
54
-
55
- - name: "topBrowsers"
56
- display_name: "Top Browsers"
57
- usage: |
58
- Counts events, grouped by browser.
59
- Browsers are sorted by event count, in descending order.
60
- required: |
61
- An issue filter including an issue id is required.
62
-
63
- - name: "webMetrics"
64
- display_name: "Web Metrics"
65
- usage: |
66
- Counts events and distinct impacted users, grouped by error type.
67
- Error types are sorted by event count, in descending order.
8
+ Aggregate metrics for all of the events sent to Crashlytics are available as reports.
9
+
10
+ ### Useful Reports
11
+
12
+ * The "appSummary" report provides overall app health metrics, including crash-free users and crash-free sessions percentages.
13
+ Combine it with \`granularity\` (such as \`TIME_GRANULARITY_DAY\` or \`TIME_GRANULARITY_HOUR\`) to analyze stability trends over time.
14
+
15
+ * The "releaseVersions" report groups metrics by the latest semantic release versions, making it ideal for comparing adoption and crash-free rates across recent releases.
16
+
17
+ * The "topIssues" report is comparable to the default view on the Crashlytics web dashboard.
18
+ Use this report to prioritize which issues are impacting the most users.
19
+ Apply appropriate filters for time interval based on the user's query.
20
+ Report responses grouped by issue will include a sample event URI.
21
+ Use the "crashlytics_batch_get_events" tool to fetch the complete record for any sample event.
22
+ When investigating an issue, use the appropriate top devices and top operating systems reports to understand what systems are impacted by the problem.
23
+ Pass the "issueId" in the filter to narrow any report to a specific issue.
24
+
25
+ Agents can retrieve a full list of available reports by passing an empty report name.
68
26
 
69
27
  Report responses contain the following metrics:
70
28
 
71
29
  - eventsCount: the number of events matching
72
- - impactedUsers: the number of distinct end users in all the matching events
73
- - sessionsCount: the number of distinct sessions in all the matching events. Only available for web apps.
30
+ - impactedUsersCount: the number of distinct end users in all the matching events
31
+ - impactedSessionsCount: the number of distinct sessions in all the matching events
32
+ - totalUsersCount: the total number of distinct active users
33
+ - totalSessionsCount: the total number of distinct active sessions
34
+ - crashFreeUsersPercentage: percentage of crash-free users (mobile only)
35
+ - crashFreeSessionsPercentage: percentage of crash-free sessions (mobile only)
74
36
 
75
- Report responses are always grouped by one of the following dimensions:
37
+ Report responses are grouped by one of the following dimensions (or cover the entire app for \`appSummary\`):
76
38
 
77
39
  - app version
78
40
  - issue
@@ -82,6 +44,14 @@ Report responses are always grouped by one of the following dimensions:
82
44
  - browser (web only)
83
45
  - error type (web only)
84
46
 
47
+ ### Time Granularity
48
+
49
+ The \`granularity\` parameter controls how metrics are bucketed over the requested time interval:
50
+
51
+ * \`TIME_GRANULARITY_NONE\`: Returns a single aggregated interval covering the entire requested time range (default when \`granularity\` is omitted).
52
+ * \`TIME_GRANULARITY_HOUR\`: Returns one metrics entry per hour across the requested time range.
53
+ * \`TIME_GRANULARITY_DAY\`: Returns one metrics entry per day across the requested time range.
54
+
85
55
  ### Filters
86
56
 
87
57
  When setting report filters adhere to the following instructions.
@@ -104,14 +74,6 @@ When setting report filters adhere to the following instructions.
104
74
  * Operating System: 'os (version)'
105
75
  * App Version: 'version (build)'
106
76
 
107
- ### Useful Reports
108
-
109
- * The "topIssues" report is comparable to the default view on the Crashlytics web dashboard. Use this report first to prioritize which issues are impacting the most users. Apply appropriate filters for time interval based on the user's query.
110
-
111
- * Report responses grouped by issue will include a sample event URI. Use the "crashlytics_batch_get_events" tool to fetch the complete record for any sample event.
112
-
113
- * When investigating an issue, use the appropriate top devices and top operating systems reports to understand what systems are impacted by the problem. Pass the "issueId" in the filter to narrow any report to a specific issue.
114
-
115
77
  ### How to Display Issues
116
78
 
117
79
  When displaying a list of issues, use the following format: