firebase-tools 15.36.0 → 15.36.1-main.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/accountExporter.js +1 -1
- package/lib/accountImporter.js +7 -6
- package/lib/apiv2.js +0 -1
- package/lib/apptesting/parseTestFiles.js +1 -1
- package/lib/auth.js +1 -1
- package/lib/bin/progressiveHelp.js +1 -1
- package/lib/command.js +1 -2
- package/lib/commands/crashlytics-events-get.js +48 -0
- package/lib/commands/crashlytics-events-list.js +70 -0
- package/lib/commands/crashlytics-heapdumps-enable.js +3 -4
- package/lib/commands/crashlytics-heapdumps-status.js +5 -3
- package/lib/commands/crashlytics-issues-get.js +61 -0
- package/lib/commands/crashlytics-reports-get.js +179 -0
- package/lib/commands/crashlytics-reports-list.js +42 -0
- package/lib/commands/ext-dev-init.js +1 -1
- package/lib/commands/hosting-channel-open.js +4 -1
- package/lib/commands/index.js +10 -0
- package/lib/commands/open.js +3 -1
- package/lib/commands/serve.js +1 -1
- package/lib/commands/use.js +1 -1
- package/lib/config.js +1 -1
- package/lib/crashlytics/commandUtils.js +194 -0
- package/lib/crashlytics/events.js +8 -8
- package/lib/crashlytics/filters.js +1 -1
- package/lib/crashlytics/profilingManager.js +63 -16
- package/lib/crashlytics/reports.js +5 -1
- package/lib/deploy/firestore/prepare.js +21 -3
- package/lib/deploy/functions/cel.js +1 -1
- package/lib/deploy/functions/deploy.js +2 -1
- package/lib/deploy/functions/release/fabricator.js +9 -2
- package/lib/deploy/functions/release/planner.js +3 -0
- package/lib/deploy/functions/runtimes/discovery/parsing.js +1 -1
- package/lib/emulator/downloadableEmulatorInfo.json +31 -31
- package/lib/emulator/functionsEmulatorRuntime.js +2 -2
- package/lib/experiments.js +5 -0
- package/lib/extensions/listExtensions.js +1 -1
- package/lib/firestore/delete.js +2 -3
- package/lib/frameworks/next/constants.js +17 -14
- package/lib/frameworks/next/index.js +25 -3
- package/lib/frameworks/next/utils.js +6 -8
- package/lib/gcp/cloudbilling.js +2 -2
- package/lib/gcp/cloudbuild.js +0 -77
- package/lib/gcp/cloudtasks.js +0 -4
- package/lib/gcp/devConnect.js +0 -6
- package/lib/gcp/iam.js +15 -1
- package/lib/gcp/resourceManager.js +1 -14
- package/lib/gcp/storage.js +87 -4
- package/lib/hosting/api.js +0 -7
- package/lib/hosting/implicitInit.js +1 -1
- package/lib/hosting/proxy.js +1 -1
- package/lib/init/features/firestore/rules.js +1 -1
- package/lib/init/features/functions/index.js +2 -2
- package/lib/init/features/functions/npm-dependencies.js +1 -1
- package/lib/init/features/storage/rules.js +1 -1
- package/lib/localFunction.js +3 -3
- package/lib/management/database.js +1 -1
- package/lib/mcp/apps/init/mcp-app.js +1 -1
- package/lib/mcp/apps/update_environment/mcp-app.js +1 -1
- package/lib/mcp/index.js +6 -2
- package/lib/mcp/tools/crashlytics/reports.js +2 -2
- package/lib/mcp/util/dataconnect/converter.js +1 -1
- package/lib/profileReport.js +1 -1
- package/lib/profiler.js +1 -1
- package/lib/rulesDeploy.js +0 -1
- package/lib/throttler/throttler.js +1 -1
- package/lib/tsconfig.compile.tsbuildinfo +1 -1
- package/lib/tsconfig.publish.tsbuildinfo +1 -1
- package/lib/utils.js +1 -1
- package/package.json +4 -4
package/lib/commands/use.js
CHANGED
|
@@ -123,7 +123,7 @@ async function genericUse(options) {
|
|
|
123
123
|
return utils.reject("No active project");
|
|
124
124
|
}
|
|
125
125
|
if (options.projectAlias) {
|
|
126
|
-
logger_1.logger.info("Active Project:", clc.bold(clc.cyan(options.projectAlias
|
|
126
|
+
logger_1.logger.info("Active Project:", clc.bold(clc.cyan(`${String(options.projectAlias)} (${String(options.project)})`)));
|
|
127
127
|
}
|
|
128
128
|
else if (options.project) {
|
|
129
129
|
logger_1.logger.info("Active Project:", clc.bold(clc.cyan(options.project)));
|
package/lib/config.js
CHANGED
|
@@ -268,7 +268,7 @@ class Config {
|
|
|
268
268
|
return new Config(data, options);
|
|
269
269
|
}
|
|
270
270
|
catch (e) {
|
|
271
|
-
throw new error_1.FirebaseError(`There was an error loading ${filename}:\n\n
|
|
271
|
+
throw new error_1.FirebaseError(`There was an error loading ${filename}:\n\n${(0, error_1.getErrMsg)(e)}`, {
|
|
272
272
|
exit: 1,
|
|
273
273
|
});
|
|
274
274
|
}
|
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.VALID_FORM_FACTORS = exports.VALID_SIGNALS = exports.VALID_ERROR_TYPES = void 0;
|
|
4
|
+
exports.requireAppId = requireAppId;
|
|
5
|
+
exports.parsePositiveIntOption = parsePositiveIntOption;
|
|
6
|
+
exports.writeOutputFileIfRequested = writeOutputFileIfRequested;
|
|
7
|
+
exports.withEventFilterOptions = withEventFilterOptions;
|
|
8
|
+
exports.parseEventFilters = parseEventFilters;
|
|
9
|
+
const fs = require("fs-extra");
|
|
10
|
+
const error_1 = require("../error");
|
|
11
|
+
const logger_1 = require("../logger");
|
|
12
|
+
const prompt = require("../prompt");
|
|
13
|
+
const apps_1 = require("../management/apps");
|
|
14
|
+
const utils_1 = require("./utils");
|
|
15
|
+
const filters_1 = require("./filters");
|
|
16
|
+
exports.VALID_ERROR_TYPES = ["FATAL", "NON_FATAL", "ANR"];
|
|
17
|
+
exports.VALID_SIGNALS = [
|
|
18
|
+
"SIGNAL_EARLY",
|
|
19
|
+
"SIGNAL_FRESH",
|
|
20
|
+
"SIGNAL_REGRESSED",
|
|
21
|
+
"SIGNAL_REPETITIVE",
|
|
22
|
+
];
|
|
23
|
+
exports.VALID_FORM_FACTORS = ["PHONE", "TABLET", "DESKTOP", "TV", "WATCH"];
|
|
24
|
+
function requireAppId(options) {
|
|
25
|
+
const appId = typeof options.app === "string" ? options.app.trim() : "";
|
|
26
|
+
if (!appId) {
|
|
27
|
+
throw new error_1.FirebaseError("Must specify '--app <appId>'. Run 'firebase apps:list' to find your Firebase App ID.", { exit: 1 });
|
|
28
|
+
}
|
|
29
|
+
return appId;
|
|
30
|
+
}
|
|
31
|
+
function parsePositiveIntOption(value, flagName, bounds) {
|
|
32
|
+
const { defaultValue, max } = bounds;
|
|
33
|
+
if (value === undefined || value === "") {
|
|
34
|
+
return defaultValue;
|
|
35
|
+
}
|
|
36
|
+
const parsed = typeof value === "number" ? value : Number(String(value).trim());
|
|
37
|
+
if (!Number.isInteger(parsed) || parsed < 1) {
|
|
38
|
+
throw new error_1.FirebaseError(`'${flagName}' must be a positive integer.`, { exit: 1 });
|
|
39
|
+
}
|
|
40
|
+
if (max !== undefined && parsed > max) {
|
|
41
|
+
throw new error_1.FirebaseError(`'${flagName}' must be between 1 and ${max}.`, { exit: 1 });
|
|
42
|
+
}
|
|
43
|
+
return parsed;
|
|
44
|
+
}
|
|
45
|
+
async function writeOutputFileIfRequested(data, options) {
|
|
46
|
+
if (!options.output) {
|
|
47
|
+
return false;
|
|
48
|
+
}
|
|
49
|
+
if (typeof options.output !== "string" || !options.output.trim()) {
|
|
50
|
+
throw new error_1.FirebaseError("Must specify a file path for '-o, --output <path>'.", { exit: 1 });
|
|
51
|
+
}
|
|
52
|
+
const outputPath = options.output.trim();
|
|
53
|
+
if (fs.existsSync(outputPath)) {
|
|
54
|
+
const shouldOverwrite = await prompt.confirm({
|
|
55
|
+
message: `File ${outputPath} already exists. Overwrite?`,
|
|
56
|
+
force: options.force,
|
|
57
|
+
nonInteractive: options.nonInteractive,
|
|
58
|
+
});
|
|
59
|
+
if (!shouldOverwrite) {
|
|
60
|
+
logger_1.logger.info("Aborted writing output file.");
|
|
61
|
+
return true;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
try {
|
|
65
|
+
fs.outputFileSync(outputPath, `${JSON.stringify(data, null, 2)}\n`, "utf8");
|
|
66
|
+
}
|
|
67
|
+
catch (err) {
|
|
68
|
+
throw new error_1.FirebaseError(`Failed to write output to ${outputPath}: ${(0, error_1.getErrMsg)(err)}`, {
|
|
69
|
+
exit: 1,
|
|
70
|
+
original: (0, error_1.getError)(err),
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
logger_1.logger.info(`Wrote output to ${outputPath}`);
|
|
74
|
+
return true;
|
|
75
|
+
}
|
|
76
|
+
function splitCommaSeparatedList(raw) {
|
|
77
|
+
if (!raw) {
|
|
78
|
+
return undefined;
|
|
79
|
+
}
|
|
80
|
+
const items = String(raw)
|
|
81
|
+
.split(",")
|
|
82
|
+
.map((item) => item.trim())
|
|
83
|
+
.filter(Boolean);
|
|
84
|
+
return items.length > 0 ? items : undefined;
|
|
85
|
+
}
|
|
86
|
+
function validateEnumList(values, validValues, flagName) {
|
|
87
|
+
if (!values) {
|
|
88
|
+
return undefined;
|
|
89
|
+
}
|
|
90
|
+
for (const val of values) {
|
|
91
|
+
if (!validValues.includes(val)) {
|
|
92
|
+
throw new error_1.FirebaseError(`Invalid value '${val}' for '${flagName}'. Valid values are: ${validValues.join(", ")}.`, { exit: 1 });
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
return values;
|
|
96
|
+
}
|
|
97
|
+
const ISO_DATE_ONLY = /^\d{4}-\d{2}-\d{2}$/;
|
|
98
|
+
const ISO_DATE_TIME_WITH_TZ = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}(:\d{2}(\.\d+)?)?(Z|[+-]\d{2}:\d{2})$/i;
|
|
99
|
+
function parseTimeOption(raw, flagName) {
|
|
100
|
+
const value = raw?.trim();
|
|
101
|
+
if (!value) {
|
|
102
|
+
return undefined;
|
|
103
|
+
}
|
|
104
|
+
const isDateOnly = ISO_DATE_ONLY.test(value);
|
|
105
|
+
const date = isDateOnly || ISO_DATE_TIME_WITH_TZ.test(value)
|
|
106
|
+
? new Date(isDateOnly ? `${value}T00:00:00Z` : value)
|
|
107
|
+
: undefined;
|
|
108
|
+
if (!date || isNaN(date.getTime())) {
|
|
109
|
+
throw new error_1.FirebaseError(`Invalid ${flagName} '${value}'. Use an ISO 8601 date or timestamp, ` +
|
|
110
|
+
`e.g. "2026-11-01" or "2026-11-01T08:00:00Z".`, { exit: 1 });
|
|
111
|
+
}
|
|
112
|
+
return date.toISOString();
|
|
113
|
+
}
|
|
114
|
+
function withEventFilterOptions(command) {
|
|
115
|
+
return command
|
|
116
|
+
.option("--issue-id <id>", "filter by Crashlytics issue ID")
|
|
117
|
+
.option("--variant-id <id>", "filter by issue variant ID (mobile only)")
|
|
118
|
+
.option("--versions <list>", 'comma-separated version display names (mobile: "2.4.0 (240)", web: "2.4.0")')
|
|
119
|
+
.option("--error-types <list>", "comma-separated error types: FATAL, NON_FATAL, ANR")
|
|
120
|
+
.option("--signals <list>", "comma-separated issue signals: SIGNAL_EARLY, SIGNAL_FRESH, SIGNAL_REGRESSED, SIGNAL_REPETITIVE (mobile only)")
|
|
121
|
+
.option("--os-names <list>", 'comma-separated operating system display names (e.g. "Android (14)")')
|
|
122
|
+
.option("--device-names <list>", 'comma-separated device display names (e.g. "Google (Pixel 8)", mobile only)')
|
|
123
|
+
.option("--device-form-factors <list>", "comma-separated device form factors: PHONE, TABLET, DESKTOP, TV, WATCH (mobile only)")
|
|
124
|
+
.option("--browser-names <list>", 'comma-separated browser display names (e.g. "Chrome (123)", web only)')
|
|
125
|
+
.option("--start-time <iso>", 'start of the time interval as an ISO 8601 date or timestamp (e.g. "2026-11-01" or "2026-11-01T08:00:00Z"); within the last 90 days, default: 7 days ago')
|
|
126
|
+
.option("--end-time <iso>", "end of the time interval as an ISO 8601 date or timestamp; requires --start-time (default: now)");
|
|
127
|
+
}
|
|
128
|
+
const MOBILE_ONLY_FLAGS = [
|
|
129
|
+
["variantId", "--variant-id"],
|
|
130
|
+
["signals", "--signals"],
|
|
131
|
+
["deviceNames", "--device-names"],
|
|
132
|
+
["deviceFormFactors", "--device-form-factors"],
|
|
133
|
+
];
|
|
134
|
+
const WEB_ONLY_FLAGS = [
|
|
135
|
+
["browserNames", "--browser-names"],
|
|
136
|
+
];
|
|
137
|
+
function validatePlatformSpecificFlags(options, appId) {
|
|
138
|
+
const platform = (0, utils_1.parseAppPlatform)(appId);
|
|
139
|
+
if (!platform) {
|
|
140
|
+
return;
|
|
141
|
+
}
|
|
142
|
+
const isWeb = platform === apps_1.AppPlatform.WEB;
|
|
143
|
+
const used = (isWeb ? MOBILE_ONLY_FLAGS : WEB_ONLY_FLAGS)
|
|
144
|
+
.filter(([key]) => {
|
|
145
|
+
const value = options[key];
|
|
146
|
+
return typeof value === "string" && value.trim() !== "";
|
|
147
|
+
})
|
|
148
|
+
.map(([, flag]) => flag);
|
|
149
|
+
if (used.length > 0) {
|
|
150
|
+
throw new error_1.FirebaseError(`${used.join(", ")} ${used.length === 1 ? "is" : "are"} only supported for ` +
|
|
151
|
+
`${isWeb ? "Android and Apple" : "web"} apps, but ${appId} is ` +
|
|
152
|
+
`${isWeb ? "a web" : "an Android or Apple"} app.`, { exit: 1 });
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
function parseEventFilters(options, appId) {
|
|
156
|
+
validatePlatformSpecificFlags(options, appId);
|
|
157
|
+
const intervalStartTime = parseTimeOption(options.startTime, "--start-time");
|
|
158
|
+
const intervalEndTime = parseTimeOption(options.endTime, "--end-time");
|
|
159
|
+
if (intervalStartTime && intervalEndTime && intervalStartTime >= intervalEndTime) {
|
|
160
|
+
throw new error_1.FirebaseError("'--start-time' must be before '--end-time'.", { exit: 1 });
|
|
161
|
+
}
|
|
162
|
+
if (intervalEndTime && !intervalStartTime) {
|
|
163
|
+
throw new error_1.FirebaseError("'--end-time' requires '--start-time'.", { exit: 1 });
|
|
164
|
+
}
|
|
165
|
+
const filter = {
|
|
166
|
+
intervalStartTime,
|
|
167
|
+
intervalEndTime,
|
|
168
|
+
versionDisplayNames: splitCommaSeparatedList(options.versions),
|
|
169
|
+
issueId: options.issueId?.trim() || undefined,
|
|
170
|
+
issueVariantId: options.variantId?.trim() || undefined,
|
|
171
|
+
issueErrorTypes: validateEnumList(splitCommaSeparatedList(options.errorTypes), exports.VALID_ERROR_TYPES, "--error-types"),
|
|
172
|
+
issueSignals: validateEnumList(splitCommaSeparatedList(options.signals), exports.VALID_SIGNALS, "--signals"),
|
|
173
|
+
operatingSystemDisplayNames: splitCommaSeparatedList(options.osNames),
|
|
174
|
+
deviceDisplayNames: splitCommaSeparatedList(options.deviceNames),
|
|
175
|
+
deviceFormFactors: validateEnumList(splitCommaSeparatedList(options.deviceFormFactors), exports.VALID_FORM_FACTORS, "--device-form-factors"),
|
|
176
|
+
browserFilterDisplayNames: splitCommaSeparatedList(options.browserNames),
|
|
177
|
+
};
|
|
178
|
+
try {
|
|
179
|
+
return (0, filters_1.validateEventFilters)(filter, appId);
|
|
180
|
+
}
|
|
181
|
+
catch (err) {
|
|
182
|
+
if (err instanceof error_1.FirebaseError) {
|
|
183
|
+
if (err.message.includes("topVersions report")) {
|
|
184
|
+
throw new error_1.FirebaseError(`--versions must match pattern 'version (build)' (e.g. "2.4.0 (240)"). Run 'firebase crashlytics:reports:get --app ${appId} topVersions' to list valid version display names.`, { exit: 1 });
|
|
185
|
+
}
|
|
186
|
+
const message = err.message
|
|
187
|
+
.replace("intervalStartTime must be less than 90 days in the past", "'--start-time' must be within the last 90 days")
|
|
188
|
+
.replace(/^deviceDisplayNames/, "--device-names")
|
|
189
|
+
.replace(/^operatingSystemDisplayNames/, "--os-names");
|
|
190
|
+
throw new error_1.FirebaseError(message, { exit: 1 });
|
|
191
|
+
}
|
|
192
|
+
throw err;
|
|
193
|
+
}
|
|
194
|
+
}
|
|
@@ -37,23 +37,23 @@ async function listEvents(appId, filter, pageSize = 1, filterExpression) {
|
|
|
37
37
|
(_a = response.body).events ?? (_a.events = []);
|
|
38
38
|
return response.body;
|
|
39
39
|
}
|
|
40
|
+
function escapeRegExp(value) {
|
|
41
|
+
return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
42
|
+
}
|
|
40
43
|
function normalizeEventResourceName(appId, eventIdOrName) {
|
|
41
44
|
const trimmed = eventIdOrName.trim();
|
|
42
45
|
if (!trimmed) {
|
|
43
46
|
throw new error_1.FirebaseError("Event ID cannot be empty.");
|
|
44
47
|
}
|
|
45
48
|
const requestProjectNumber = (0, utils_1.parseProjectNumber)(appId);
|
|
46
|
-
const
|
|
47
|
-
if (
|
|
48
|
-
|
|
49
|
-
if (eventId && !eventId.includes("/")) {
|
|
50
|
-
return trimmed;
|
|
51
|
-
}
|
|
49
|
+
const fullNamePattern = new RegExp(`^projects/[^/]+/apps/${escapeRegExp(appId)}/events/[^/]+$`);
|
|
50
|
+
if (fullNamePattern.test(trimmed)) {
|
|
51
|
+
return trimmed;
|
|
52
52
|
}
|
|
53
53
|
if (trimmed.includes("/")) {
|
|
54
|
-
throw new error_1.FirebaseError(`Invalid event resource name '${trimmed}'. Expected an event ID or '
|
|
54
|
+
throw new error_1.FirebaseError(`Invalid event resource name '${trimmed}'. Expected an event ID or 'projects/{project}/apps/${appId}/events/{event_id}'.`);
|
|
55
55
|
}
|
|
56
|
-
return
|
|
56
|
+
return `projects/${requestProjectNumber}/apps/${appId}/events/${trimmed}`;
|
|
57
57
|
}
|
|
58
58
|
async function batchGetEvents(appId, eventNames) {
|
|
59
59
|
var _a;
|
|
@@ -61,7 +61,7 @@ exports.EventFilterSchema = zod_1.z
|
|
|
61
61
|
exports.FilterExpressionSchema = zod_1.z
|
|
62
62
|
.string()
|
|
63
63
|
.optional()
|
|
64
|
-
.describe(`An AIP-160 filter expression for custom keys (e.g. 'custom_keys.env = "prod"', 'custom_keys.experiment_id:*', or combined with 'AND' across different keys and 'OR' across values of one key).`);
|
|
64
|
+
.describe(`An AIP-160 filter expression for custom keys (e.g. 'custom_keys.env = "prod"', 'custom_keys.experiment_id:*', or combined with 'AND' across different keys and 'OR' across values of one key). For reports, only supported on web apps; check the report's usage to see whether it supports filter_expression.`);
|
|
65
65
|
const toolToParamMap = {
|
|
66
66
|
intervalStartTime: "filter.interval.start_time",
|
|
67
67
|
intervalEndTime: "filter.interval.end_time",
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.DEFAULT_LIFECYCLE_RULES = exports.DEFAULT_CORS_RULES = exports.DEFAULT_FILE_TTL_DAYS = exports.DEFAULT_BUCKET_LOCATION = exports.DEFAULT_CORS_ORIGINS = exports.HEAP_DUMP_BUCKET_PREFIX = exports.STORAGE_OBJECT_CREATOR_ROLE = exports.CRASHLYTICS_SERVICE_NAME = void 0;
|
|
3
|
+
exports.DEFAULT_IAM_CONFIGURATION = exports.DEFAULT_LIFECYCLE_RULES = exports.DEFAULT_CORS_RULES = exports.DEFAULT_FILE_TTL_DAYS = exports.DEFAULT_BUCKET_LOCATION = exports.DEFAULT_CORS_ORIGINS = exports.HEAP_DUMP_BUCKET_PREFIX = exports.STORAGE_OBJECT_CREATOR_ROLE = exports.CRASHLYTICS_SERVICE_NAME = void 0;
|
|
4
4
|
exports.parseAndroidHashedId = parseAndroidHashedId;
|
|
5
5
|
exports.createBucketName = createBucketName;
|
|
6
6
|
exports.getCrashlyticsP4sa = getCrashlyticsP4sa;
|
|
7
|
+
exports.getCrashlyticsConsoleUrl = getCrashlyticsConsoleUrl;
|
|
8
|
+
exports.resolveAndroidApp = resolveAndroidApp;
|
|
7
9
|
exports.resolveAndroidAppId = resolveAndroidAppId;
|
|
8
10
|
exports.getProfilingManagerConfig = getProfilingManagerConfig;
|
|
9
11
|
exports.updateProfilingManagerConfig = updateProfilingManagerConfig;
|
|
@@ -16,7 +18,6 @@ const logger_1 = require("../logger");
|
|
|
16
18
|
const utils_1 = require("../utils");
|
|
17
19
|
const utils_2 = require("./utils");
|
|
18
20
|
const storage = require("../gcp/storage");
|
|
19
|
-
const resourceManager = require("../gcp/resourceManager");
|
|
20
21
|
const serviceusage = require("../gcp/serviceusage");
|
|
21
22
|
const apps_1 = require("../management/apps");
|
|
22
23
|
exports.CRASHLYTICS_SERVICE_NAME = "firebasecrashlytics.googleapis.com";
|
|
@@ -38,8 +39,24 @@ exports.DEFAULT_LIFECYCLE_RULES = [
|
|
|
38
39
|
condition: { age: exports.DEFAULT_FILE_TTL_DAYS },
|
|
39
40
|
},
|
|
40
41
|
];
|
|
42
|
+
exports.DEFAULT_IAM_CONFIGURATION = {
|
|
43
|
+
publicAccessPrevention: "enforced",
|
|
44
|
+
uniformBucketLevelAccess: { enabled: true },
|
|
45
|
+
};
|
|
41
46
|
const ANDROID_APP_ID_REGEX = /^\d+:(\d+):android:([a-fA-F0-9]+)$/;
|
|
42
47
|
const GCS_BUCKET_RESOURCE_PREFIX = "projects/_/buckets/";
|
|
48
|
+
function isAndroidAppMetadata(app) {
|
|
49
|
+
return (app.platform === apps_1.AppPlatform.ANDROID &&
|
|
50
|
+
"packageName" in app &&
|
|
51
|
+
typeof app.packageName === "string");
|
|
52
|
+
}
|
|
53
|
+
function toResolvedAndroidApp(app) {
|
|
54
|
+
const packageName = isAndroidAppMetadata(app) ? app.packageName.trim() : "";
|
|
55
|
+
return {
|
|
56
|
+
appId: app.appId,
|
|
57
|
+
...(packageName ? { packageName } : {}),
|
|
58
|
+
};
|
|
59
|
+
}
|
|
43
60
|
function parseAndroidHashedId(appId) {
|
|
44
61
|
const match = ANDROID_APP_ID_REGEX.exec(appId);
|
|
45
62
|
if (!match) {
|
|
@@ -55,18 +72,33 @@ function createBucketName(appId) {
|
|
|
55
72
|
function getCrashlyticsP4sa(projectNumber) {
|
|
56
73
|
return `service-${projectNumber}@gcp-sa-crashlytics.iam.gserviceaccount.com`;
|
|
57
74
|
}
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
return
|
|
75
|
+
function getCrashlyticsConsoleUrl(projectId, packageName) {
|
|
76
|
+
const trimmedPackageName = packageName?.trim();
|
|
77
|
+
if (!trimmedPackageName) {
|
|
78
|
+
return (0, utils_1.consoleUrl)(projectId, "/crashlytics");
|
|
79
|
+
}
|
|
80
|
+
return (0, utils_1.consoleUrl)(projectId, `/crashlytics/app/android:${trimmedPackageName}/issues`);
|
|
81
|
+
}
|
|
82
|
+
async function resolveAndroidApp(projectId, options) {
|
|
83
|
+
const requestedAppId = options.app;
|
|
84
|
+
if (requestedAppId) {
|
|
85
|
+
parseAndroidHashedId(requestedAppId);
|
|
62
86
|
}
|
|
63
87
|
const apps = await (0, apps_1.listFirebaseApps)(projectId, apps_1.AppPlatform.ANDROID);
|
|
88
|
+
if (requestedAppId) {
|
|
89
|
+
const matchedApp = apps.find((app) => app.appId.toLowerCase() === requestedAppId.toLowerCase());
|
|
90
|
+
if (!matchedApp) {
|
|
91
|
+
throw new error_1.FirebaseError(`Android app '${requestedAppId}' was not found in project '${projectId}'. ` +
|
|
92
|
+
"Run 'firebase apps:list ANDROID' to view valid Android app IDs for your project.", { exit: 1 });
|
|
93
|
+
}
|
|
94
|
+
return toResolvedAndroidApp(matchedApp);
|
|
95
|
+
}
|
|
64
96
|
if (apps.length === 0) {
|
|
65
97
|
throw new error_1.FirebaseError(`No Android apps found in project '${projectId}'. Heap dump collection is only supported for Android apps.\n` +
|
|
66
98
|
"You can register an Android app using 'firebase apps:create ANDROID <package-name>'");
|
|
67
99
|
}
|
|
68
100
|
if (apps.length === 1) {
|
|
69
|
-
return apps[0]
|
|
101
|
+
return toResolvedAndroidApp(apps[0]);
|
|
70
102
|
}
|
|
71
103
|
if (options.nonInteractive) {
|
|
72
104
|
throw new error_1.FirebaseError(`Project '${projectId}' has multiple Android apps. Please specify an app ID with '--app <appID>'.`);
|
|
@@ -74,7 +106,11 @@ async function resolveAndroidAppId(projectId, options) {
|
|
|
74
106
|
const selectedApp = await (0, apps_1.selectAppInteractively)(apps, apps_1.AppPlatform.ANDROID, {
|
|
75
107
|
message: "Select an Android app:",
|
|
76
108
|
});
|
|
77
|
-
return selectedApp
|
|
109
|
+
return toResolvedAndroidApp(selectedApp);
|
|
110
|
+
}
|
|
111
|
+
async function resolveAndroidAppId(projectId, options) {
|
|
112
|
+
const app = await resolveAndroidApp(projectId, options);
|
|
113
|
+
return app.appId;
|
|
78
114
|
}
|
|
79
115
|
async function getProfilingManagerConfig(appId) {
|
|
80
116
|
const projectNumber = (0, utils_2.parseProjectNumber)(appId);
|
|
@@ -111,6 +147,9 @@ async function ensureHeapDumpStorageBucket(projectId, appId, location = exports.
|
|
|
111
147
|
if (bucket.projectNumber && String(bucket.projectNumber) !== projectNumber) {
|
|
112
148
|
throw new error_1.FirebaseError(`Cloud Storage bucket '${bucketName}' already exists and is owned by another project.`);
|
|
113
149
|
}
|
|
150
|
+
if (bucket.location && bucket.location.trim().toLowerCase() !== location.trim().toLowerCase()) {
|
|
151
|
+
(0, utils_1.logLabeledWarning)("crashlytics", `Cloud Storage bucket '${bucketName}' already exists in ${bucket.location}; its location cannot be changed to '${location}' and will remain ${bucket.location}.`);
|
|
152
|
+
}
|
|
114
153
|
const patchPayload = {};
|
|
115
154
|
const hasConsoleCors = bucket.cors?.some((rule) => exports.DEFAULT_CORS_ORIGINS.every((origin) => rule.origin?.includes(origin)));
|
|
116
155
|
if (!hasConsoleCors) {
|
|
@@ -122,6 +161,14 @@ async function ensureHeapDumpStorageBucket(projectId, appId, location = exports.
|
|
|
122
161
|
rule: [...(bucket.lifecycle?.rule ?? []), ...exports.DEFAULT_LIFECYCLE_RULES],
|
|
123
162
|
};
|
|
124
163
|
}
|
|
164
|
+
const needsUbla = !bucket.iamConfiguration?.uniformBucketLevelAccess?.enabled;
|
|
165
|
+
const needsPap = bucket.iamConfiguration?.publicAccessPrevention !== "enforced";
|
|
166
|
+
if (needsUbla || needsPap) {
|
|
167
|
+
patchPayload.iamConfiguration = {
|
|
168
|
+
...(needsPap ? { publicAccessPrevention: "enforced" } : {}),
|
|
169
|
+
...(needsUbla ? { uniformBucketLevelAccess: { enabled: true } } : {}),
|
|
170
|
+
};
|
|
171
|
+
}
|
|
125
172
|
if (Object.keys(patchPayload).length > 0) {
|
|
126
173
|
logger_1.logger.debug(`[crashlytics] Bucket ${bucketName} found without full configuration. Patching ${Object.keys(patchPayload).join(", ")}.`);
|
|
127
174
|
await storage.patchBucket(bucketName, patchPayload);
|
|
@@ -140,24 +187,24 @@ async function ensureHeapDumpStorageBucket(projectId, appId, location = exports.
|
|
|
140
187
|
location,
|
|
141
188
|
cors: exports.DEFAULT_CORS_RULES,
|
|
142
189
|
lifecycle: { rule: exports.DEFAULT_LIFECYCLE_RULES },
|
|
143
|
-
|
|
190
|
+
iamConfiguration: exports.DEFAULT_IAM_CONFIGURATION,
|
|
191
|
+
});
|
|
144
192
|
return bucketName;
|
|
145
193
|
}
|
|
146
|
-
async function ensureHeapDumpP4saRole(
|
|
194
|
+
async function ensureHeapDumpP4saRole(projectNumber, bucketName) {
|
|
147
195
|
await serviceusage.generateServiceIdentityAndPoll(projectNumber, exports.CRASHLYTICS_SERVICE_NAME, "crashlytics");
|
|
148
196
|
const p4saEmail = getCrashlyticsP4sa(projectNumber);
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
}
|
|
197
|
+
logger_1.logger.debug(`[crashlytics] Ensuring ${exports.STORAGE_OBJECT_CREATOR_ROLE} on bucket ${bucketName} for ${p4saEmail}...`);
|
|
198
|
+
await storage.addServiceAccountToBucketRoles(bucketName, p4saEmail, [
|
|
199
|
+
exports.STORAGE_OBJECT_CREATOR_ROLE,
|
|
200
|
+
]);
|
|
154
201
|
}
|
|
155
202
|
async function enableHeapDumpCollection(projectId, appId, location = exports.DEFAULT_BUCKET_LOCATION) {
|
|
156
203
|
const projectNumber = (0, utils_2.parseProjectNumber)(appId);
|
|
157
204
|
(0, utils_1.logLabeledBullet)("crashlytics", "Configuring Google Cloud Storage bucket...");
|
|
158
205
|
const bucketName = await ensureHeapDumpStorageBucket(projectId, appId, location);
|
|
159
206
|
(0, utils_1.logLabeledBullet)("crashlytics", "Configuring service agent permissions...");
|
|
160
|
-
await ensureHeapDumpP4saRole(
|
|
207
|
+
await ensureHeapDumpP4saRole(projectNumber, bucketName);
|
|
161
208
|
(0, utils_1.logLabeledBullet)("crashlytics", "Enabling Crashlytics heap dump collection...");
|
|
162
209
|
await updateProfilingManagerConfig(appId, {
|
|
163
210
|
bucket: `${GCS_BUCKET_RESOURCE_PREFIX}${bucketName}`,
|
|
@@ -21,6 +21,7 @@ exports.ReportInputSchema = zod_1.z.object({
|
|
|
21
21
|
appId: filters_1.ApplicationIdSchema,
|
|
22
22
|
report: exports.CrashlyticsReportSchema,
|
|
23
23
|
filter: filters_1.EventFilterSchema,
|
|
24
|
+
filterExpression: filters_1.FilterExpressionSchema,
|
|
24
25
|
pageSize: zod_1.z.number().optional().describe("Number of rows to return").default(DEFAULT_PAGE_SIZE),
|
|
25
26
|
granularity: exports.TimeGranularitySchema,
|
|
26
27
|
});
|
|
@@ -60,7 +61,7 @@ async function listReports(appId) {
|
|
|
60
61
|
(_a = response.body).reports ?? (_a.reports = []);
|
|
61
62
|
return response.body;
|
|
62
63
|
}
|
|
63
|
-
async function getReport(reportName, appId, filter, pageSize = DEFAULT_PAGE_SIZE, granularity) {
|
|
64
|
+
async function getReport(reportName, appId, filter, pageSize = DEFAULT_PAGE_SIZE, granularity, filterExpression) {
|
|
64
65
|
const requestProjectNumber = (0, utils_1.parseProjectNumber)(appId);
|
|
65
66
|
let availableReports = exports.reportsCache.get(appId);
|
|
66
67
|
if (!availableReports) {
|
|
@@ -84,6 +85,9 @@ async function getReport(reportName, appId, filter, pageSize = DEFAULT_PAGE_SIZE
|
|
|
84
85
|
if (granularity) {
|
|
85
86
|
queryParams.set("granularity", granularity);
|
|
86
87
|
}
|
|
88
|
+
if (filterExpression) {
|
|
89
|
+
queryParams.set("filter_expression", filterExpression);
|
|
90
|
+
}
|
|
87
91
|
logger_1.logger.debug(`[crashlytics] report ${reportName} called with appId: ${appId} filter: ${queryParams.toString()}, page_size: ${pageSize}`);
|
|
88
92
|
const response = await utils_1.CRASHLYTICS_API_CLIENT.request({
|
|
89
93
|
method: "GET",
|
|
@@ -12,6 +12,7 @@ const api_1 = require("../../api");
|
|
|
12
12
|
const error_1 = require("../../error");
|
|
13
13
|
const types = require("../../firestore/api-types");
|
|
14
14
|
const api_2 = require("../../firestore/api");
|
|
15
|
+
const DEFAULT_FIRESTORE_LOCATION = "nam5";
|
|
15
16
|
function prepareRules(context, rulesDeploy, databaseId, rulesFile) {
|
|
16
17
|
rulesDeploy.addFile(rulesFile, databaseId);
|
|
17
18
|
context.firestore.rules.push({
|
|
@@ -73,11 +74,18 @@ async function createDatabase(context, options) {
|
|
|
73
74
|
}
|
|
74
75
|
catch (e) {
|
|
75
76
|
if (e.status === 404) {
|
|
77
|
+
const locationId = firestoreCfg.location || DEFAULT_FIRESTORE_LOCATION;
|
|
78
|
+
if (options.dryRun) {
|
|
79
|
+
utils.logLabeledWarning("firestore", `Database ${clc.bold(firestoreCfg.database)} does not exist. A deploy would create it in ` +
|
|
80
|
+
`${clc.bold(locationId)}${firestoreCfg.location ? "" : " (the default, because firebase.json sets no location)"}. ` +
|
|
81
|
+
"Skipping database creation because this is a dry run.");
|
|
82
|
+
return true;
|
|
83
|
+
}
|
|
76
84
|
utils.logLabeledBullet("firestore", `Creating the new Firestore database ${firestoreCfg.database}...`);
|
|
77
85
|
const createDatabaseReq = {
|
|
78
86
|
project: options.projectId,
|
|
79
87
|
databaseId: firestoreCfg.database,
|
|
80
|
-
locationId
|
|
88
|
+
locationId,
|
|
81
89
|
type: types.DatabaseType.FIRESTORE_NATIVE,
|
|
82
90
|
databaseEdition: edition,
|
|
83
91
|
deleteProtectionState: types.DatabaseDeleteProtectionState.DISABLED,
|
|
@@ -88,6 +96,7 @@ async function createDatabase(context, options) {
|
|
|
88
96
|
await api.createDatabase(createDatabaseReq);
|
|
89
97
|
}
|
|
90
98
|
}
|
|
99
|
+
return false;
|
|
91
100
|
}
|
|
92
101
|
async function default_1(context, options) {
|
|
93
102
|
await (0, ensureApiEnabled_1.ensure)(context.projectId, (0, api_1.firestoreOrigin)(), "firestore");
|
|
@@ -115,7 +124,7 @@ async function default_1(context, options) {
|
|
|
115
124
|
context.firestore.rules = [];
|
|
116
125
|
const rulesDeploy = new rulesDeploy_1.RulesDeploy(options, rulesDeploy_1.RulesetServiceType.CLOUD_FIRESTORE);
|
|
117
126
|
context.firestore.rulesDeploy = rulesDeploy;
|
|
118
|
-
await createDatabase(context, options);
|
|
127
|
+
const skippedDatabaseCreation = await createDatabase(context, options);
|
|
119
128
|
for (const firestoreConfig of firestoreConfigs) {
|
|
120
129
|
if (firestoreConfig.indexes) {
|
|
121
130
|
prepareIndexes(context, options, firestoreConfig.database, firestoreConfig.indexes);
|
|
@@ -125,7 +134,16 @@ async function default_1(context, options) {
|
|
|
125
134
|
}
|
|
126
135
|
}
|
|
127
136
|
if (context.firestore.rules.length > 0) {
|
|
128
|
-
|
|
137
|
+
try {
|
|
138
|
+
await rulesDeploy.compile();
|
|
139
|
+
}
|
|
140
|
+
catch (err) {
|
|
141
|
+
if (!skippedDatabaseCreation || (0, error_1.getErrStatus)(err) !== 403) {
|
|
142
|
+
throw err;
|
|
143
|
+
}
|
|
144
|
+
utils.logLabeledWarning("firestore", "Could not check the rules for compilation errors (HTTP 403), most likely because the " +
|
|
145
|
+
"project has no Firestore database yet. A deploy creates the database before it checks the rules.");
|
|
146
|
+
}
|
|
129
147
|
}
|
|
130
148
|
const rulesContext = context?.firestore?.rules;
|
|
131
149
|
for (const ruleContext of rulesContext) {
|
|
@@ -100,7 +100,7 @@ function resolveExpression(wantType, expr, params) {
|
|
|
100
100
|
return resolveComparison(expr, params);
|
|
101
101
|
}
|
|
102
102
|
else {
|
|
103
|
-
throw new ExprParseError(
|
|
103
|
+
throw new ExprParseError(`CEL expression '${String(expr)}' is of an unsupported form`);
|
|
104
104
|
}
|
|
105
105
|
}
|
|
106
106
|
function preprocessLists(wantType, expr, params) {
|
|
@@ -18,6 +18,7 @@ const experiments = require("../../experiments");
|
|
|
18
18
|
const supported = require("./runtimes/supported");
|
|
19
19
|
const backend_1 = require("./backend");
|
|
20
20
|
const extensions_1 = require("../extensions");
|
|
21
|
+
const error_1 = require("../../error");
|
|
21
22
|
const getProjectNumber_1 = require("../../getProjectNumber");
|
|
22
23
|
const path = require("path");
|
|
23
24
|
(0, tmp_1.setGracefulCleanup)();
|
|
@@ -115,7 +116,7 @@ async function uploadCodebase(context, projectNumber, codebase, wantBackend) {
|
|
|
115
116
|
}
|
|
116
117
|
}
|
|
117
118
|
catch (err) {
|
|
118
|
-
(0, utils_1.logWarning)(clc.yellow("functions:")
|
|
119
|
+
(0, utils_1.logWarning)(`${clc.yellow("functions:")} Upload Error: ${(0, error_1.getErrMsg)(err)}`);
|
|
119
120
|
throw err;
|
|
120
121
|
}
|
|
121
122
|
}
|
|
@@ -321,7 +321,7 @@ class Fabricator {
|
|
|
321
321
|
await this.updateV1Function(update.endpoint, scraperV1);
|
|
322
322
|
}
|
|
323
323
|
else if (update.endpoint.platform === "gcfv2") {
|
|
324
|
-
await this.updateV2Function(update.endpoint, scraperV2);
|
|
324
|
+
await this.updateV2Function(update.endpoint, scraperV2, update.failedCreate);
|
|
325
325
|
}
|
|
326
326
|
else if (update.endpoint.platform === "run") {
|
|
327
327
|
await this.updateRunFunction(update);
|
|
@@ -496,6 +496,9 @@ class Fabricator {
|
|
|
496
496
|
utils.logLabeledWarning("functions", "Updated function is not associated with a service. This deployment is in an unexpected state - please re-deploy your functions.");
|
|
497
497
|
return;
|
|
498
498
|
}
|
|
499
|
+
await this.setV2InvokerCreate(endpoint, serviceName);
|
|
500
|
+
}
|
|
501
|
+
async setV2InvokerCreate(endpoint, serviceName) {
|
|
499
502
|
if (backend.isHttpsTriggered(endpoint)) {
|
|
500
503
|
const invoker = endpoint.httpsTrigger.invoker || ["public"];
|
|
501
504
|
if (!invoker.includes("private")) {
|
|
@@ -584,7 +587,7 @@ class Fabricator {
|
|
|
584
587
|
.catch(rethrowAs(endpoint, "set invoker"));
|
|
585
588
|
}
|
|
586
589
|
}
|
|
587
|
-
async updateV2Function(endpoint, scraper) {
|
|
590
|
+
async updateV2Function(endpoint, scraper, failedCreate = false) {
|
|
588
591
|
const storageSource = this.sources[endpoint.codebase]?.storage;
|
|
589
592
|
if (!storageSource) {
|
|
590
593
|
logger_1.logger.debug("Precondition failed. Cannot update a GCFv2 function without storage");
|
|
@@ -628,6 +631,10 @@ class Fabricator {
|
|
|
628
631
|
utils.logLabeledWarning("functions", "Updated function is not associated with a service. This deployment is in an unexpected state - please re-deploy your functions.");
|
|
629
632
|
return;
|
|
630
633
|
}
|
|
634
|
+
if (failedCreate) {
|
|
635
|
+
await this.setV2InvokerCreate(endpoint, serviceName);
|
|
636
|
+
return;
|
|
637
|
+
}
|
|
631
638
|
let invoker;
|
|
632
639
|
if (backend.isHttpsTriggered(endpoint)) {
|
|
633
640
|
invoker = endpoint.httpsTrigger.invoker === null ? ["public"] : endpoint.httpsTrigger.invoker;
|
|
@@ -74,6 +74,9 @@ function calculateUpdate(want, have) {
|
|
|
74
74
|
if (needsDelete) {
|
|
75
75
|
update.deleteAndRecreate = have;
|
|
76
76
|
}
|
|
77
|
+
else if (have.platform === "gcfv2" && have.state === "FAILED" && !have.runServiceId) {
|
|
78
|
+
update.failedCreate = true;
|
|
79
|
+
}
|
|
77
80
|
return update;
|
|
78
81
|
}
|
|
79
82
|
async function createDeploymentPlan(args) {
|
|
@@ -88,7 +88,7 @@ function assertKeyTypes(prefix, yaml, schema) {
|
|
|
88
88
|
}
|
|
89
89
|
}
|
|
90
90
|
else {
|
|
91
|
-
throw new error_1.FirebaseError(
|
|
91
|
+
throw new error_1.FirebaseError(`YAML validation is missing a handled type ${String(schema[key])}`);
|
|
92
92
|
}
|
|
93
93
|
}
|
|
94
94
|
}
|