firebase-tools-with-isolate 15.32.0 → 15.34.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/accountImporter.js +6 -3
- package/lib/api.js +3 -3
- package/lib/apphosting/backend.js +1 -1
- package/lib/apphosting/secrets/index.js +7 -2
- package/lib/checkValidTargetFilters.js +1 -0
- package/lib/command.js +31 -24
- package/lib/commands/apps-create.js +34 -3
- package/lib/commands/crashlytics-heapdumps-disable.js +26 -0
- package/lib/commands/crashlytics-heapdumps-enable.js +54 -0
- package/lib/commands/crashlytics-heapdumps-status.js +32 -0
- package/lib/commands/deploy.js +3 -0
- package/lib/commands/functions-kits-uninstall.js +43 -21
- package/lib/commands/functions-lifecycle-list.js +5 -6
- package/lib/commands/hosting-channel-deploy.js +3 -3
- package/lib/commands/hosting-clone.js +102 -31
- package/lib/commands/hosting-disable.js +5 -1
- package/lib/commands/index.js +9 -0
- package/lib/commands/init.js +7 -0
- package/lib/commands/run-services-update.js +16 -0
- package/lib/config.js +1 -0
- package/lib/crashlytics/alerts.js +122 -0
- package/lib/crashlytics/onboarding.js +71 -3
- package/lib/crashlytics/profilingManager.js +195 -0
- package/lib/crashlytics/sourcemap.js +46 -11
- package/lib/crashlytics/types.js +6 -1
- package/lib/deploy/apphosting/prepare.js +1 -0
- package/lib/deploy/auth/deploy.js +1 -1
- package/lib/deploy/auth/prepare.js +6 -7
- package/lib/deploy/firestore/prepare.js +5 -5
- package/lib/deploy/functions/build.js +3 -0
- package/lib/deploy/functions/cel.js +89 -58
- package/lib/deploy/functions/functionsDeployHelper.js +10 -0
- package/lib/deploy/functions/params.js +4 -2
- package/lib/deploy/functions/prepare.js +25 -8
- package/lib/deploy/functions/release/executor.js +7 -3
- package/lib/deploy/functions/release/fabricator.js +42 -14
- package/lib/deploy/functions/release/planner.js +3 -2
- package/lib/deploy/functions/release/sourceTokenScraper.js +1 -1
- package/lib/deploy/functions/validate.js +16 -0
- package/lib/deploy/hosting/prepare.js +1 -1
- package/lib/deploy/hosting/release.js +2 -2
- package/lib/deploy/index.js +5 -0
- package/lib/deploy/run/args.js +2 -0
- package/lib/deploy/run/buildEnv.js +72 -0
- package/lib/deploy/run/deploy.js +214 -0
- package/lib/deploy/run/index.js +23 -0
- package/lib/deploy/run/prepare.js +47 -0
- package/lib/deploy/run/prereqs.js +32 -0
- package/lib/deploy/run/release.js +9 -0
- package/lib/deploy/run/update.js +50 -0
- package/lib/deploy/run/util.js +73 -0
- package/lib/emulator/apphosting/serve.js +1 -1
- package/lib/emulator/auth/operations.js +8 -4
- package/lib/emulator/auth/utils.js +1 -1
- package/lib/emulator/commandUtils.js +7 -3
- package/lib/emulator/databaseEmulator.js +7 -3
- package/lib/emulator/dataconnect/pgliteServer.js +1 -1
- package/lib/emulator/dataconnectEmulator.js +1 -1
- package/lib/emulator/download.js +1 -1
- package/lib/emulator/downloadableEmulatorInfo.json +31 -31
- package/lib/emulator/downloadableEmulators.js +1 -3
- package/lib/emulator/emulatorLogger.js +2 -1
- package/lib/emulator/eventarcEmulator.js +1 -1
- package/lib/emulator/functionsEmulatorRuntime.js +2 -1
- package/lib/emulator/functionsEmulatorShared.js +1 -41
- package/lib/experiments.js +17 -11
- package/lib/extensions/warnings.js +48 -7
- package/lib/firestore/validator.js +1 -1
- package/lib/frameworks/next/constants.js +20 -12
- package/lib/frameworks/next/index.js +4 -23
- package/lib/frameworks/next/utils.js +28 -0
- package/lib/functions/env.js +4 -2
- package/lib/functions/projectConfig.js +10 -5
- package/lib/gcp/artifactregistry.js +20 -0
- package/lib/gcp/cloudmonitoring.js +80 -3
- package/lib/gcp/cloudsql/permissions.js +21 -32
- package/lib/gcp/cloudsql/permissionsSetup.js +6 -6
- package/lib/gcp/cloudtasks.js +15 -1
- package/lib/gcp/cloudtrace.js +38 -0
- package/lib/gcp/run.js +5 -0
- package/lib/gcp/runv2.js +32 -11
- package/lib/gcp/storage.js +9 -5
- package/lib/hosting/api.js +15 -15
- package/lib/hosting/runTags.js +1 -1
- package/lib/init/features/auth.js +46 -8
- package/lib/init/features/hosting/index.js +4 -2
- package/lib/init/features/index.js +4 -1
- package/lib/init/features/run.js +159 -0
- package/lib/init/index.js +6 -0
- package/lib/management/apps.js +4 -2
- package/lib/mcp/tools/firestore/converter.js +2 -2
- package/lib/mcp/util.js +11 -10
- package/lib/profileReport.js +12 -9
- package/lib/scopes.js +1 -3
- package/lib/streamJson.js +1 -0
- package/lib/throttler/throttler.js +1 -0
- package/lib/tsconfig.publish.tsbuildinfo +1 -1
- package/lib/utils.js +0 -15
- package/package.json +11 -17
- package/schema/firebase-config.json +41 -0
- package/schema/firebaserc.json +133 -0
- package/lib/mcp/resources/guides/init_data_connect.js +0 -30
- package/lib/mcp/resources/guides/init_rtdb.js +0 -30
package/lib/experiments.js
CHANGED
|
@@ -53,10 +53,6 @@ exports.ALL_EXPERIMENTS = experiments({
|
|
|
53
53
|
default: false,
|
|
54
54
|
public: true,
|
|
55
55
|
},
|
|
56
|
-
runfunctions: {
|
|
57
|
-
shortDescription: "Functions created using the V2 API target Cloud Run Functions (not production ready)",
|
|
58
|
-
public: false,
|
|
59
|
-
},
|
|
60
56
|
functionsiac: {
|
|
61
57
|
shortDescription: "Exports functions IaC code",
|
|
62
58
|
public: false,
|
|
@@ -87,10 +83,6 @@ exports.ALL_EXPERIMENTS = experiments({
|
|
|
87
83
|
emulatoruisnapshot: {
|
|
88
84
|
shortDescription: "Load pre-release versions of the emulator UI",
|
|
89
85
|
},
|
|
90
|
-
emulatorapphosting: {
|
|
91
|
-
shortDescription: "App Hosting emulator",
|
|
92
|
-
public: false,
|
|
93
|
-
},
|
|
94
86
|
webframeworks: {
|
|
95
87
|
shortDescription: "Native support for popular web frameworks",
|
|
96
88
|
fullDescription: "Adds support for popular web frameworks such as Next.js " +
|
|
@@ -112,9 +104,6 @@ exports.ALL_EXPERIMENTS = experiments({
|
|
|
112
104
|
public: true,
|
|
113
105
|
default: true,
|
|
114
106
|
},
|
|
115
|
-
crossservicerules: {
|
|
116
|
-
shortDescription: "Allow Firebase Rules to reference resources in other services",
|
|
117
|
-
},
|
|
118
107
|
internaltesting: {
|
|
119
108
|
shortDescription: "Exposes Firebase CLI commands intended for internal testing purposes.",
|
|
120
109
|
fullDescription: "Exposes Firebase CLI commands intended for internal testing purposes. " +
|
|
@@ -150,6 +139,13 @@ exports.ALL_EXPERIMENTS = experiments({
|
|
|
150
139
|
default: true,
|
|
151
140
|
public: true,
|
|
152
141
|
},
|
|
142
|
+
directcloudrun: {
|
|
143
|
+
shortDescription: "Build and deploy web apps directly to Cloud Run services",
|
|
144
|
+
fullDescription: "Enables `firebase init run`, `firebase deploy --only run`, and the " +
|
|
145
|
+
"`firebase run:services:update` command. " +
|
|
146
|
+
"These are in preview and may change.",
|
|
147
|
+
public: false,
|
|
148
|
+
},
|
|
153
149
|
dataconnect: {
|
|
154
150
|
shortDescription: "Deprecated. Previosuly, enabled SQL Connect related features.",
|
|
155
151
|
fullDescription: "Deprecated. Previously, enabled SQL Connect related features.",
|
|
@@ -206,6 +202,16 @@ exports.ALL_EXPERIMENTS = experiments({
|
|
|
206
202
|
default: false,
|
|
207
203
|
public: true,
|
|
208
204
|
},
|
|
205
|
+
crashlyticsWebAlerts: {
|
|
206
|
+
shortDescription: "Enable configuring Crashlytics email alerts during web app onboarding.",
|
|
207
|
+
default: false,
|
|
208
|
+
public: false,
|
|
209
|
+
},
|
|
210
|
+
crashlyticsWebBreadcrumbs: {
|
|
211
|
+
shortDescription: "Enable provisioning Cloud Trace storage during web app onboarding.",
|
|
212
|
+
default: false,
|
|
213
|
+
public: false,
|
|
214
|
+
},
|
|
209
215
|
secretEnvParams: {
|
|
210
216
|
shortDescription: "Enable reading the backing resource binding for a Functions secret param from .env",
|
|
211
217
|
default: true,
|
|
@@ -12,6 +12,9 @@ const planner_1 = require("../deploy/extensions/planner");
|
|
|
12
12
|
const error_1 = require("../error");
|
|
13
13
|
const logger_1 = require("../logger");
|
|
14
14
|
const utils = require("../utils");
|
|
15
|
+
const replacementRegistry_1 = require("./replacementRegistry");
|
|
16
|
+
const manifest = require("./manifest");
|
|
17
|
+
const refs = require("./refs");
|
|
15
18
|
const toListEntry = (i) => {
|
|
16
19
|
const idAndRef = (0, deploymentSummary_1.humanReadable)(i);
|
|
17
20
|
const sourceCodeLink = `\n\t[Source Code](${i.extensionVersion?.buildSourceUri ?? i.extensionVersion?.sourceDownloadUri})`;
|
|
@@ -43,6 +46,7 @@ function outOfBandChangesWarning(instanceIds, isDynamic) {
|
|
|
43
46
|
`\nIf you proceed with this deployment, those changes will be overwritten.${extra}`);
|
|
44
47
|
}
|
|
45
48
|
const FAQ_URL = "https://firebase.google.com/docs/extensions/faq-and-troubleshooting";
|
|
49
|
+
const BANNER_BORDER = "=".repeat(80);
|
|
46
50
|
const WARN_BEFORE_COMMANDS = new Set([
|
|
47
51
|
"ext:install",
|
|
48
52
|
"ext:configure",
|
|
@@ -56,7 +60,7 @@ const WARN_STRONGLY_BEFORE_COMMANDS = new Set([
|
|
|
56
60
|
"ext:dev:usage",
|
|
57
61
|
"ext:dev:undeprecate",
|
|
58
62
|
]);
|
|
59
|
-
const WARN_AFTER_COMMANDS = new Set(["ext:list", "ext:info"]);
|
|
63
|
+
const WARN_AFTER_COMMANDS = new Set(["ext:list", "ext:info", "ext:export"]);
|
|
60
64
|
function isSilenced(options) {
|
|
61
65
|
const opts = options;
|
|
62
66
|
if (opts?.json ||
|
|
@@ -77,7 +81,23 @@ function isSilenced(options) {
|
|
|
77
81
|
}
|
|
78
82
|
return false;
|
|
79
83
|
}
|
|
80
|
-
function
|
|
84
|
+
function resolveExtensionRef(commandName, options, args = []) {
|
|
85
|
+
const firstArg = typeof args[0] === "string" ? args[0] : undefined;
|
|
86
|
+
if (!firstArg || (0, extensionsHelper_1.isLocalPath)(firstArg)) {
|
|
87
|
+
return undefined;
|
|
88
|
+
}
|
|
89
|
+
try {
|
|
90
|
+
const ref = commandName === "ext:configure" || commandName === "ext:update"
|
|
91
|
+
? manifest.getInstanceRef(firstArg, manifest.loadConfig(options))
|
|
92
|
+
: refs.parse(firstArg);
|
|
93
|
+
return refs.toExtensionRef(ref);
|
|
94
|
+
}
|
|
95
|
+
catch (err) {
|
|
96
|
+
logger_1.logger.debug(`Could not resolve extension ref for deprecation warning: ${String(err)}`);
|
|
97
|
+
return undefined;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
async function showDeprecationWarningBefore(commandName, options, args = []) {
|
|
81
101
|
if (commandName === "ext:dev:register") {
|
|
82
102
|
throw new error_1.FirebaseError(`ext:dev:register is disabled. Registering new publisher profile IDs is no longer supported.\n` +
|
|
83
103
|
`The Firebase Extensions service will shut down on March 31, 2027.\n` +
|
|
@@ -87,18 +107,39 @@ function showDeprecationWarningBefore(commandName, options) {
|
|
|
87
107
|
return;
|
|
88
108
|
}
|
|
89
109
|
if (WARN_BEFORE_COMMANDS.has(commandName)) {
|
|
90
|
-
|
|
110
|
+
let actionLine = "We recommend migrating active instances to function kits.";
|
|
111
|
+
const ref = resolveExtensionRef(commandName, options, args);
|
|
112
|
+
if (ref) {
|
|
113
|
+
try {
|
|
114
|
+
const registry = await (0, replacementRegistry_1.getReplacementsRegistry)();
|
|
115
|
+
const npmPackage = (0, replacementRegistry_1.getReplacementPackageName)(ref, registry);
|
|
116
|
+
if (npmPackage) {
|
|
117
|
+
actionLine = `Recommended replacement: ${npmPackage}`;
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
catch (err) {
|
|
121
|
+
logger_1.logger.debug(`Failed to resolve replacement info for warning: ${String(err)}`);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
logger_1.logger.warn(clc.yellow(`${BANNER_BORDER}\n` +
|
|
125
|
+
`⚠ Firebase Extensions will shut down on March 31, 2027.\n` +
|
|
126
|
+
`${actionLine}\n` +
|
|
127
|
+
`Learn more & view migration steps: ${FAQ_URL}\n` +
|
|
128
|
+
`${BANNER_BORDER}`));
|
|
91
129
|
}
|
|
92
130
|
else if (WARN_STRONGLY_BEFORE_COMMANDS.has(commandName)) {
|
|
93
|
-
logger_1.logger.warn(clc.yellow(
|
|
131
|
+
logger_1.logger.warn(clc.yellow(`${BANNER_BORDER}\n` +
|
|
94
132
|
`⚠ Notice for Publishers: Firebase Extensions will shut down on March 31, 2027.\n` +
|
|
95
|
-
`Learn more: ${FAQ_URL}\n` +
|
|
96
|
-
|
|
133
|
+
`Learn more & view migration steps: ${FAQ_URL}\n` +
|
|
134
|
+
`${BANNER_BORDER}`));
|
|
97
135
|
}
|
|
98
136
|
}
|
|
99
137
|
function showDeprecationWarningAfter(commandName, options) {
|
|
100
138
|
if (isSilenced(options) || !WARN_AFTER_COMMANDS.has(commandName)) {
|
|
101
139
|
return;
|
|
102
140
|
}
|
|
103
|
-
|
|
141
|
+
if (commandName === "ext:export" && options.mode === "functions") {
|
|
142
|
+
return;
|
|
143
|
+
}
|
|
144
|
+
logger_1.logger.warn(clc.yellow(`⚠ Notice: Firebase Extensions will shut down on March 31, 2027. Learn more & view migration steps: ${FAQ_URL}`));
|
|
104
145
|
}
|
|
@@ -26,7 +26,7 @@ function assertHasOneOf(obj, props) {
|
|
|
26
26
|
}
|
|
27
27
|
function assertEnum(obj, prop, valid) {
|
|
28
28
|
const objString = clc.cyan(JSON.stringify(obj));
|
|
29
|
-
if (valid.
|
|
29
|
+
if (!valid.includes(obj[prop])) {
|
|
30
30
|
throw new error_1.FirebaseError(`Field "${prop}" must be one of ${valid.join(", ")}: ${objString}`);
|
|
31
31
|
}
|
|
32
32
|
}
|
|
@@ -23,34 +23,42 @@ const WEBPACK_LAYERS_NAMES = {
|
|
|
23
23
|
reactServerComponents: "rsc",
|
|
24
24
|
serverSideRendering: "ssr",
|
|
25
25
|
actionBrowser: "action-browser",
|
|
26
|
-
|
|
26
|
+
apiNode: "api-node",
|
|
27
|
+
apiEdge: "api-edge",
|
|
27
28
|
middleware: "middleware",
|
|
29
|
+
instrument: "instrument",
|
|
28
30
|
edgeAsset: "edge-asset",
|
|
29
31
|
appPagesBrowser: "app-pages-browser",
|
|
30
|
-
|
|
31
|
-
|
|
32
|
+
pagesDirBrowser: "pages-dir-browser",
|
|
33
|
+
pagesDirEdge: "pages-dir-edge",
|
|
34
|
+
pagesDirNode: "pages-dir-node",
|
|
32
35
|
};
|
|
33
36
|
exports.WEBPACK_LAYERS = {
|
|
34
37
|
...WEBPACK_LAYERS_NAMES,
|
|
35
38
|
GROUP: {
|
|
36
|
-
|
|
39
|
+
builtinReact: [WEBPACK_LAYERS_NAMES.reactServerComponents, WEBPACK_LAYERS_NAMES.actionBrowser],
|
|
40
|
+
serverOnly: [
|
|
37
41
|
WEBPACK_LAYERS_NAMES.reactServerComponents,
|
|
38
42
|
WEBPACK_LAYERS_NAMES.actionBrowser,
|
|
39
|
-
WEBPACK_LAYERS_NAMES.
|
|
40
|
-
WEBPACK_LAYERS_NAMES.appRouteHandler,
|
|
41
|
-
],
|
|
42
|
-
nonClientServerTarget: [
|
|
43
|
+
WEBPACK_LAYERS_NAMES.instrument,
|
|
43
44
|
WEBPACK_LAYERS_NAMES.middleware,
|
|
44
|
-
WEBPACK_LAYERS_NAMES.api,
|
|
45
45
|
],
|
|
46
|
-
|
|
46
|
+
neutralTarget: [WEBPACK_LAYERS_NAMES.apiNode, WEBPACK_LAYERS_NAMES.apiEdge],
|
|
47
|
+
clientOnly: [WEBPACK_LAYERS_NAMES.serverSideRendering, WEBPACK_LAYERS_NAMES.appPagesBrowser],
|
|
48
|
+
bundled: [
|
|
47
49
|
WEBPACK_LAYERS_NAMES.reactServerComponents,
|
|
48
50
|
WEBPACK_LAYERS_NAMES.actionBrowser,
|
|
49
|
-
WEBPACK_LAYERS_NAMES.appMetadataRoute,
|
|
50
|
-
WEBPACK_LAYERS_NAMES.appRouteHandler,
|
|
51
51
|
WEBPACK_LAYERS_NAMES.serverSideRendering,
|
|
52
52
|
WEBPACK_LAYERS_NAMES.appPagesBrowser,
|
|
53
53
|
WEBPACK_LAYERS_NAMES.shared,
|
|
54
|
+
WEBPACK_LAYERS_NAMES.instrument,
|
|
55
|
+
WEBPACK_LAYERS_NAMES.middleware,
|
|
56
|
+
],
|
|
57
|
+
appPages: [
|
|
58
|
+
WEBPACK_LAYERS_NAMES.reactServerComponents,
|
|
59
|
+
WEBPACK_LAYERS_NAMES.serverSideRendering,
|
|
60
|
+
WEBPACK_LAYERS_NAMES.appPagesBrowser,
|
|
61
|
+
WEBPACK_LAYERS_NAMES.actionBrowser,
|
|
54
62
|
],
|
|
55
63
|
},
|
|
56
64
|
};
|
|
@@ -16,7 +16,6 @@ const url_1 = require("url");
|
|
|
16
16
|
const semver_1 = require("semver");
|
|
17
17
|
const clc = require("colorette");
|
|
18
18
|
const fsutils_1 = require("../../fsutils");
|
|
19
|
-
const streamJson_1 = require("../../streamJson");
|
|
20
19
|
const prompt_1 = require("../../prompt");
|
|
21
20
|
const error_1 = require("../../error");
|
|
22
21
|
const utils_1 = require("../utils");
|
|
@@ -291,9 +290,12 @@ async function ɵcodegenPublicDirectory(sourceDir, destDir, _, context) {
|
|
|
291
290
|
{
|
|
292
291
|
srcRoute: null,
|
|
293
292
|
initialRevalidateSeconds: false,
|
|
293
|
+
initialExpireSeconds: undefined,
|
|
294
294
|
dataRoute: "",
|
|
295
295
|
experimentalPPR: false,
|
|
296
|
+
renderingMode: undefined,
|
|
296
297
|
prefetchDataRoute: "",
|
|
298
|
+
allowHeader: [],
|
|
297
299
|
},
|
|
298
300
|
];
|
|
299
301
|
}));
|
|
@@ -392,28 +394,7 @@ async function ɵcodegenFunctionsDirectory(sourceDir, destDir, target, context)
|
|
|
392
394
|
if (!esbuild) {
|
|
393
395
|
throw new error_1.FirebaseError(`Failed to load esbuild from path: ${esbuildPath}`);
|
|
394
396
|
}
|
|
395
|
-
const
|
|
396
|
-
const productionDeps = await new Promise((resolve) => {
|
|
397
|
-
const dependencies = [];
|
|
398
|
-
const npmLs = (0, cross_spawn_1.spawn)("npm", ["ls", "--omit=dev", "--all", "--json=true"], {
|
|
399
|
-
cwd: sourceDir,
|
|
400
|
-
timeout: constants_1.NPM_COMMAND_TIMEOUT_MILLIES,
|
|
401
|
-
});
|
|
402
|
-
const pipeline = chain([
|
|
403
|
-
npmLs.stdout,
|
|
404
|
-
parser({ packValues: false, packKeys: true, streamValues: false }),
|
|
405
|
-
pick({ filter: "dependencies" }),
|
|
406
|
-
streamObject(),
|
|
407
|
-
({ key, value }) => [
|
|
408
|
-
key,
|
|
409
|
-
...(0, utils_2.allDependencyNames)(value),
|
|
410
|
-
],
|
|
411
|
-
]);
|
|
412
|
-
pipeline.on("data", (it) => dependencies.push(it));
|
|
413
|
-
pipeline.on("end", () => {
|
|
414
|
-
resolve([...new Set(dependencies)]);
|
|
415
|
-
});
|
|
416
|
-
});
|
|
397
|
+
const productionDeps = await (0, utils_2.getProductionDependencyNames)(sourceDir);
|
|
417
398
|
const esbuildArgs = {
|
|
418
399
|
entryPoints: [(0, path_1.join)(sourceDir, configFile)],
|
|
419
400
|
outfile: (0, path_1.join)(destDir, configFile),
|
|
@@ -18,6 +18,7 @@ exports.isUsingNextImageInServerComponent = isUsingNextImageInServerComponent;
|
|
|
18
18
|
exports.isUsingNextImageInClientComponent = isUsingNextImageInClientComponent;
|
|
19
19
|
exports.isUsingAppDirectory = isUsingAppDirectory;
|
|
20
20
|
exports.allDependencyNames = allDependencyNames;
|
|
21
|
+
exports.getProductionDependencyNames = getProductionDependencyNames;
|
|
21
22
|
exports.getMiddlewareMatcherRegexes = getMiddlewareMatcherRegexes;
|
|
22
23
|
exports.getNonStaticRoutes = getNonStaticRoutes;
|
|
23
24
|
exports.getNonStaticServerComponents = getNonStaticServerComponents;
|
|
@@ -43,6 +44,9 @@ const utils_1 = require("../utils");
|
|
|
43
44
|
const constants_1 = require("./constants");
|
|
44
45
|
const fsutils_1 = require("../../fsutils");
|
|
45
46
|
const utils_2 = require("../../utils");
|
|
47
|
+
const cross_spawn_1 = require("cross-spawn");
|
|
48
|
+
const streamJson_1 = require("../../streamJson");
|
|
49
|
+
const constants_2 = require("../constants");
|
|
46
50
|
const child_process_1 = require("child_process");
|
|
47
51
|
const error_1 = require("../../error");
|
|
48
52
|
exports.I18N_SOURCE = /\/:nextInternalLocale(\([^\)]+\))?/;
|
|
@@ -175,6 +179,30 @@ function allDependencyNames(mod) {
|
|
|
175
179
|
const dependencyNames = Object.keys(mod.dependencies).reduce((acc, it) => [...acc, it, ...allDependencyNames(mod.dependencies[it])], []);
|
|
176
180
|
return dependencyNames;
|
|
177
181
|
}
|
|
182
|
+
async function getProductionDependencyNames(sourceDir) {
|
|
183
|
+
const { chain, many, parser, pick, streamObject } = await (0, streamJson_1.loadStreamJson)();
|
|
184
|
+
return new Promise((resolve, reject) => {
|
|
185
|
+
const dependencies = [];
|
|
186
|
+
const npmLs = (0, cross_spawn_1.spawn)("npm", ["ls", "--omit=dev", "--all", "--json=true"], {
|
|
187
|
+
cwd: sourceDir,
|
|
188
|
+
timeout: constants_2.NPM_COMMAND_TIMEOUT_MILLIES,
|
|
189
|
+
});
|
|
190
|
+
npmLs.on("error", reject);
|
|
191
|
+
if (!npmLs.stdout) {
|
|
192
|
+
return reject(new error_1.FirebaseError("Failed to capture npm ls output"));
|
|
193
|
+
}
|
|
194
|
+
const pipeline = chain([
|
|
195
|
+
npmLs.stdout,
|
|
196
|
+
parser({ packValues: false, packKeys: true, streamValues: false }),
|
|
197
|
+
pick({ filter: "dependencies" }),
|
|
198
|
+
streamObject(),
|
|
199
|
+
({ key, value }) => many([key, ...allDependencyNames(value)]),
|
|
200
|
+
]);
|
|
201
|
+
pipeline.on("data", (it) => dependencies.push(it));
|
|
202
|
+
pipeline.on("error", reject);
|
|
203
|
+
pipeline.on("end", () => resolve([...new Set(dependencies)]));
|
|
204
|
+
});
|
|
205
|
+
}
|
|
178
206
|
function getMiddlewareMatcherRegexes(middlewareManifest, functionsConfigManifest) {
|
|
179
207
|
const middlewareObjectValues = Object.values(middlewareManifest.middleware);
|
|
180
208
|
const middlewareMatchers = [];
|
package/lib/functions/env.js
CHANGED
|
@@ -240,9 +240,11 @@ function writeUserEnvs(toWrite, envOpts) {
|
|
|
240
240
|
}
|
|
241
241
|
function checkForDuplicateKeys(isEmulator, keys, fullEnv, envsWithoutLocal) {
|
|
242
242
|
for (const key of keys) {
|
|
243
|
-
const definedInEnv =
|
|
243
|
+
const definedInEnv = Object.prototype.hasOwnProperty.call(fullEnv, key);
|
|
244
244
|
if (definedInEnv) {
|
|
245
|
-
if (envsWithoutLocal &&
|
|
245
|
+
if (envsWithoutLocal &&
|
|
246
|
+
isEmulator &&
|
|
247
|
+
Object.prototype.hasOwnProperty.call(envsWithoutLocal, key)) {
|
|
246
248
|
(0, utils_1.logWarning)(clc.cyan(clc.yellow("functions: ")) +
|
|
247
249
|
`Writing parameter ${key} to emulator-specific config .env.local. This will overwrite your existing definition only when emulating.`);
|
|
248
250
|
continue;
|
|
@@ -145,11 +145,16 @@ function assertUniqueSourcePrefixPair(config) {
|
|
|
145
145
|
else {
|
|
146
146
|
continue;
|
|
147
147
|
}
|
|
148
|
-
const
|
|
149
|
-
|
|
150
|
-
|
|
148
|
+
const prefixes = isKitConfig(c)
|
|
149
|
+
? Object.keys(c.instances).map((instanceId) => addKitPrefix(instanceId))
|
|
150
|
+
: [c.prefix || ""];
|
|
151
|
+
for (const prefix of prefixes) {
|
|
152
|
+
const key = JSON.stringify({ source: sourceIdentifier, prefix });
|
|
153
|
+
if (sourcePrefixPairs.has(key)) {
|
|
154
|
+
throw new error_1.FirebaseError(`More than one functions config specifies the same ${sourceDescription} and prefix ('${prefix}'). Please use kits with a unique instance ID to resolve this conflict.`);
|
|
155
|
+
}
|
|
156
|
+
sourcePrefixPairs.add(key);
|
|
151
157
|
}
|
|
152
|
-
sourcePrefixPairs.add(key);
|
|
153
158
|
}
|
|
154
159
|
}
|
|
155
160
|
function validateKitInstanceId(instanceId) {
|
|
@@ -194,8 +199,8 @@ function validate(config) {
|
|
|
194
199
|
const validated = config.map((cfg) => validateSingle(cfg));
|
|
195
200
|
assertUnique(validated, "codebase");
|
|
196
201
|
assertUnique(validated, "kit");
|
|
197
|
-
assertUniqueSourcePrefixPair(validated);
|
|
198
202
|
assertUniqueKitInstancesAndCodebases(validated);
|
|
203
|
+
assertUniqueSourcePrefixPair(validated);
|
|
199
204
|
return validated;
|
|
200
205
|
}
|
|
201
206
|
function normalizeAndValidate(config) {
|
|
@@ -5,11 +5,14 @@ exports.ensureApiEnabled = ensureApiEnabled;
|
|
|
5
5
|
exports.deletePackage = deletePackage;
|
|
6
6
|
exports.getRepository = getRepository;
|
|
7
7
|
exports.updateRepository = updateRepository;
|
|
8
|
+
exports.ensureDockerRepository = ensureDockerRepository;
|
|
8
9
|
const apiv2_1 = require("../apiv2");
|
|
9
10
|
const api_1 = require("../api");
|
|
10
11
|
const metaprogramming_1 = require("../metaprogramming");
|
|
11
12
|
const api = require("../ensureApiEnabled");
|
|
12
13
|
const proto = require("./proto");
|
|
14
|
+
const error_1 = require("../error");
|
|
15
|
+
const operation_poller_1 = require("../operation-poller");
|
|
13
16
|
exports.API_VERSION = "v1";
|
|
14
17
|
const client = new apiv2_1.Client({
|
|
15
18
|
urlPrefix: (0, api_1.artifactRegistryDomain)(),
|
|
@@ -39,3 +42,20 @@ async function updateRepository(repo) {
|
|
|
39
42
|
});
|
|
40
43
|
return res.body;
|
|
41
44
|
}
|
|
45
|
+
async function ensureDockerRepository(projectId, location, repositoryId) {
|
|
46
|
+
try {
|
|
47
|
+
await getRepository(`projects/${projectId}/locations/${location}/repositories/${repositoryId}`);
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
catch (err) {
|
|
51
|
+
if ((0, error_1.getErrStatus)(err) !== 404) {
|
|
52
|
+
throw err;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
const res = await client.post(`/projects/${projectId}/locations/${location}/repositories`, { format: "DOCKER" }, { queryParams: { repositoryId } });
|
|
56
|
+
await (0, operation_poller_1.pollOperation)({
|
|
57
|
+
apiOrigin: (0, api_1.artifactRegistryDomain)(),
|
|
58
|
+
apiVersion: exports.API_VERSION,
|
|
59
|
+
operationResourceName: res.body.name,
|
|
60
|
+
});
|
|
61
|
+
}
|
|
@@ -2,6 +2,10 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ValueType = exports.Reducer = exports.MetricKind = exports.Aligner = exports.TimeSeriesView = exports.CLOUD_MONITORING_VERSION = void 0;
|
|
4
4
|
exports.queryTimeSeries = queryTimeSeries;
|
|
5
|
+
exports.listNotificationChannels = listNotificationChannels;
|
|
6
|
+
exports.createNotificationChannel = createNotificationChannel;
|
|
7
|
+
exports.getAlertPolicy = getAlertPolicy;
|
|
8
|
+
exports.updateAlertPolicy = updateAlertPolicy;
|
|
5
9
|
const api_1 = require("../api");
|
|
6
10
|
const apiv2_1 = require("../apiv2");
|
|
7
11
|
const error_1 = require("../error");
|
|
@@ -63,15 +67,88 @@ async function queryTimeSeries(query, project) {
|
|
|
63
67
|
urlPrefix: (0, api_1.cloudMonitoringOrigin)(),
|
|
64
68
|
apiVersion: exports.CLOUD_MONITORING_VERSION,
|
|
65
69
|
});
|
|
70
|
+
const queryParams = {};
|
|
71
|
+
for (const [key, value] of Object.entries(query)) {
|
|
72
|
+
if (typeof value === "string" || typeof value === "number") {
|
|
73
|
+
queryParams[key] = value;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
66
76
|
try {
|
|
67
77
|
const res = await client.get(`/projects/${project}/timeSeries/`, {
|
|
68
|
-
queryParams
|
|
78
|
+
queryParams,
|
|
69
79
|
});
|
|
70
80
|
return res.body.timeSeries;
|
|
71
81
|
}
|
|
72
82
|
catch (err) {
|
|
73
|
-
throw new error_1.FirebaseError(`Failed to get Cloud Monitoring metric: ${err}`, {
|
|
74
|
-
status: err
|
|
83
|
+
throw new error_1.FirebaseError(`Failed to get Cloud Monitoring metric: ${(0, error_1.getErrMsg)(err)}`, {
|
|
84
|
+
status: (0, error_1.getErrStatus)(err),
|
|
85
|
+
original: (0, error_1.getError)(err),
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
async function listNotificationChannels(project, filter) {
|
|
90
|
+
const client = new apiv2_1.Client({
|
|
91
|
+
urlPrefix: (0, api_1.cloudMonitoringOrigin)(),
|
|
92
|
+
apiVersion: exports.CLOUD_MONITORING_VERSION,
|
|
93
|
+
});
|
|
94
|
+
try {
|
|
95
|
+
const res = await client.get(`/projects/${project}/notificationChannels`, filter ? { queryParams: { filter } } : {});
|
|
96
|
+
return res.body?.notificationChannels ?? [];
|
|
97
|
+
}
|
|
98
|
+
catch (err) {
|
|
99
|
+
throw new error_1.FirebaseError(`Failed to list Cloud Monitoring notification channels: ${(0, error_1.getErrMsg)(err)}`, {
|
|
100
|
+
status: (0, error_1.getErrStatus)(err),
|
|
101
|
+
original: (0, error_1.getError)(err),
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
async function createNotificationChannel(project, channel) {
|
|
106
|
+
const client = new apiv2_1.Client({
|
|
107
|
+
urlPrefix: (0, api_1.cloudMonitoringOrigin)(),
|
|
108
|
+
apiVersion: exports.CLOUD_MONITORING_VERSION,
|
|
109
|
+
});
|
|
110
|
+
try {
|
|
111
|
+
const res = await client.post(`/projects/${project}/notificationChannels`, channel);
|
|
112
|
+
return res.body;
|
|
113
|
+
}
|
|
114
|
+
catch (err) {
|
|
115
|
+
throw new error_1.FirebaseError(`Failed to create Cloud Monitoring notification channel: ${(0, error_1.getErrMsg)(err)}`, {
|
|
116
|
+
status: (0, error_1.getErrStatus)(err),
|
|
117
|
+
original: (0, error_1.getError)(err),
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
async function getAlertPolicy(name) {
|
|
122
|
+
const client = new apiv2_1.Client({
|
|
123
|
+
urlPrefix: (0, api_1.cloudMonitoringOrigin)(),
|
|
124
|
+
apiVersion: exports.CLOUD_MONITORING_VERSION,
|
|
125
|
+
});
|
|
126
|
+
const path = name.startsWith("/") ? name : `/${name}`;
|
|
127
|
+
try {
|
|
128
|
+
const res = await client.get(path);
|
|
129
|
+
return res.body;
|
|
130
|
+
}
|
|
131
|
+
catch (err) {
|
|
132
|
+
throw new error_1.FirebaseError(`Failed to get Cloud Monitoring alert policy ${name}: ${(0, error_1.getErrMsg)(err)}`, {
|
|
133
|
+
status: (0, error_1.getErrStatus)(err),
|
|
134
|
+
original: (0, error_1.getError)(err),
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
async function updateAlertPolicy(policy, updateMask) {
|
|
139
|
+
const client = new apiv2_1.Client({
|
|
140
|
+
urlPrefix: (0, api_1.cloudMonitoringOrigin)(),
|
|
141
|
+
apiVersion: exports.CLOUD_MONITORING_VERSION,
|
|
142
|
+
});
|
|
143
|
+
const path = policy.name.startsWith("/") ? policy.name : `/${policy.name}`;
|
|
144
|
+
try {
|
|
145
|
+
const res = await client.patch(path, policy, updateMask ? { queryParams: { updateMask } } : {});
|
|
146
|
+
return res.body;
|
|
147
|
+
}
|
|
148
|
+
catch (err) {
|
|
149
|
+
throw new error_1.FirebaseError(`Failed to update Cloud Monitoring alert policy ${policy.name}: ${(0, error_1.getErrMsg)(err)}`, {
|
|
150
|
+
status: (0, error_1.getErrStatus)(err),
|
|
151
|
+
original: (0, error_1.getError)(err),
|
|
75
152
|
});
|
|
76
153
|
}
|
|
77
154
|
}
|
|
@@ -20,20 +20,27 @@ function firebasereader(databaseId, schema = exports.DEFAULT_SCHEMA) {
|
|
|
20
20
|
function firebasewriter(databaseId, schema = exports.DEFAULT_SCHEMA) {
|
|
21
21
|
return `firebasewriter_${databaseId}_${schema}`;
|
|
22
22
|
}
|
|
23
|
-
function
|
|
24
|
-
|
|
25
|
-
return [
|
|
26
|
-
`do
|
|
23
|
+
function createRoleBypassRLS(role, superuser) {
|
|
24
|
+
return `do
|
|
27
25
|
$$
|
|
28
26
|
begin
|
|
29
27
|
if not exists (select FROM pg_catalog.pg_roles
|
|
30
|
-
WHERE rolname = '${
|
|
31
|
-
CREATE ROLE "${
|
|
28
|
+
WHERE rolname = '${role}') then
|
|
29
|
+
CREATE ROLE "${role}" WITH ADMIN "${superuser}" BYPASSRLS;
|
|
30
|
+
else
|
|
31
|
+
ALTER ROLE "${role}" BYPASSRLS;
|
|
32
32
|
end if;
|
|
33
33
|
end
|
|
34
34
|
$$
|
|
35
|
-
|
|
36
|
-
|
|
35
|
+
;`;
|
|
36
|
+
}
|
|
37
|
+
function ownerRolePermissions(databaseId, superuser, schema) {
|
|
38
|
+
const firebaseOwnerRole = firebaseowner(databaseId, schema);
|
|
39
|
+
return [
|
|
40
|
+
createRoleBypassRLS(firebaseOwnerRole, superuser),
|
|
41
|
+
`REVOKE "${firebaseOwnerRole}" FROM "${exports.CLOUDSQL_SUPER_USER}"`,
|
|
42
|
+
`GRANT "${exports.CLOUDSQL_SUPER_USER}" TO "${firebaseOwnerRole}"`,
|
|
43
|
+
`CREATE SCHEMA IF NOT EXISTS "${schema}" AUTHORIZATION "${firebaseOwnerRole}"`,
|
|
37
44
|
`ALTER SCHEMA "${schema}" OWNER TO "${firebaseOwnerRole}"`,
|
|
38
45
|
`GRANT USAGE ON SCHEMA "${schema}" TO "${firebaseOwnerRole}"`,
|
|
39
46
|
`GRANT ALL PRIVILEGES ON ALL TABLES IN SCHEMA "${schema}" TO "${firebaseOwnerRole}"`,
|
|
@@ -43,19 +50,10 @@ function ownerRolePermissions(databaseId, superuser, schema) {
|
|
|
43
50
|
function writerRolePermissions(databaseId, superuser, schema) {
|
|
44
51
|
const firebaseWriterRole = firebasewriter(databaseId, schema);
|
|
45
52
|
return [
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
begin
|
|
49
|
-
if not exists (select FROM pg_catalog.pg_roles
|
|
50
|
-
WHERE rolname = '${firebaseWriterRole}') then
|
|
51
|
-
CREATE ROLE "${firebaseWriterRole}" WITH ADMIN "${superuser}";
|
|
52
|
-
end if;
|
|
53
|
-
end
|
|
54
|
-
$$
|
|
55
|
-
;`,
|
|
56
|
-
`GRANT "${firebaseWriterRole}" TO "cloudsqlsuperuser"`,
|
|
53
|
+
createRoleBypassRLS(firebaseWriterRole, superuser),
|
|
54
|
+
`GRANT "${firebaseWriterRole}" TO "${exports.CLOUDSQL_SUPER_USER}"`,
|
|
57
55
|
`GRANT USAGE ON SCHEMA "${schema}" TO "${firebaseWriterRole}"`,
|
|
58
|
-
`GRANT SELECT, INSERT, UPDATE, DELETE
|
|
56
|
+
`GRANT SELECT, INSERT, UPDATE, DELETE ON ALL TABLES IN SCHEMA "${schema}" TO "${firebaseWriterRole}"`,
|
|
59
57
|
`GRANT USAGE, SELECT ON ALL SEQUENCES IN SCHEMA "${schema}" TO "${firebaseWriterRole}"`,
|
|
60
58
|
`GRANT EXECUTE ON ALL FUNCTIONS IN SCHEMA "${schema}" TO "${firebaseWriterRole}"`,
|
|
61
59
|
];
|
|
@@ -63,17 +61,8 @@ function writerRolePermissions(databaseId, superuser, schema) {
|
|
|
63
61
|
function readerRolePermissions(databaseId, superuser, schema) {
|
|
64
62
|
const firebaseReaderRole = firebasereader(databaseId, schema);
|
|
65
63
|
return [
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
begin
|
|
69
|
-
if not exists (select FROM pg_catalog.pg_roles
|
|
70
|
-
WHERE rolname = '${firebaseReaderRole}') then
|
|
71
|
-
CREATE ROLE "${firebaseReaderRole}" WITH ADMIN "${superuser}";
|
|
72
|
-
end if;
|
|
73
|
-
end
|
|
74
|
-
$$
|
|
75
|
-
;`,
|
|
76
|
-
`GRANT "${firebaseReaderRole}" TO "cloudsqlsuperuser"`,
|
|
64
|
+
createRoleBypassRLS(firebaseReaderRole, superuser),
|
|
65
|
+
`GRANT "${firebaseReaderRole}" TO "${exports.CLOUDSQL_SUPER_USER}"`,
|
|
77
66
|
`GRANT USAGE ON SCHEMA "${schema}" TO "${firebaseReaderRole}"`,
|
|
78
67
|
`GRANT SELECT ON ALL TABLES IN SCHEMA "${schema}" TO "${firebaseReaderRole}"`,
|
|
79
68
|
`GRANT USAGE, SELECT ON ALL SEQUENCES IN SCHEMA "${schema}" TO "${firebaseReaderRole}"`,
|
|
@@ -87,7 +76,7 @@ function defaultPermissions(databaseId, schema, ownerRole) {
|
|
|
87
76
|
`ALTER DEFAULT PRIVILEGES
|
|
88
77
|
FOR ROLE "${ownerRole}"
|
|
89
78
|
IN SCHEMA "${schema}"
|
|
90
|
-
GRANT SELECT, INSERT, UPDATE, DELETE
|
|
79
|
+
GRANT SELECT, INSERT, UPDATE, DELETE ON TABLES TO "${firebaseWriterRole}";`,
|
|
91
80
|
`ALTER DEFAULT PRIVILEGES
|
|
92
81
|
FOR ROLE "${ownerRole}"
|
|
93
82
|
IN SCHEMA "${schema}"
|
|
@@ -124,15 +124,10 @@ async function setupSQLPermissions(instanceId, databaseId, schemaInfo, options,
|
|
|
124
124
|
}
|
|
125
125
|
}
|
|
126
126
|
async function greenFieldSchemaSetup(instanceId, databaseId, schema, options) {
|
|
127
|
-
const revokes = [];
|
|
128
|
-
if (await checkSQLRoleIsGranted(options, instanceId, databaseId, "cloudsqlsuperuser", (0, permissions_1.firebaseowner)(databaseId, schema))) {
|
|
129
|
-
logger_1.logger.warn("Detected cloudsqlsuperuser was previously given to firebase owner, revoking to improve database security.");
|
|
130
|
-
revokes.push(`REVOKE "cloudsqlsuperuser" FROM "${(0, permissions_1.firebaseowner)(databaseId, schema)}"`);
|
|
131
|
-
}
|
|
132
127
|
const user = (await (0, connect_1.getIAMUser)(options)).user;
|
|
133
128
|
const projectNumber = await (0, projectUtils_1.needProjectNumber)(options);
|
|
134
129
|
const { user: fdcP4SAUser } = (0, connect_2.toDatabaseUser)((0, connect_2.getDataConnectP4SA)(projectNumber));
|
|
135
|
-
const sqlRoleSetupCmds = (0, lodash_1.concat)(
|
|
130
|
+
const sqlRoleSetupCmds = (0, lodash_1.concat)([`CREATE SCHEMA IF NOT EXISTS "${schema}"`], (0, permissions_1.ownerRolePermissions)(databaseId, permissions_1.FIREBASE_SUPER_USER, schema), (0, permissions_1.writerRolePermissions)(databaseId, permissions_1.FIREBASE_SUPER_USER, schema), (0, permissions_1.readerRolePermissions)(databaseId, permissions_1.FIREBASE_SUPER_USER, schema), `GRANT "${(0, permissions_1.firebaseowner)(databaseId, schema)}" TO "${user}"`, `REVOKE "${(0, permissions_1.firebaseowner)(databaseId, schema)}" FROM "${fdcP4SAUser}"`, `GRANT "${(0, permissions_1.firebasewriter)(databaseId, schema)}" TO "${fdcP4SAUser}"`, (0, permissions_1.defaultPermissions)(databaseId, schema, (0, permissions_1.firebaseowner)(databaseId, schema)));
|
|
136
131
|
return sqlRoleSetupCmds;
|
|
137
132
|
}
|
|
138
133
|
async function getSchemaMetadata(instanceId, databaseId, schema, options) {
|
|
@@ -224,7 +219,12 @@ async function brownfieldSqlSetup(instanceId, databaseId, schemaInfo, options, s
|
|
|
224
219
|
}
|
|
225
220
|
async function grantRoleTo(options, instanceId, databaseId, role, email, schema = permissions_1.DEFAULT_SCHEMA) {
|
|
226
221
|
const projectId = (0, projectUtils_1.needProjectId)(options);
|
|
222
|
+
const projectNumber = await (0, projectUtils_1.needProjectNumber)(options);
|
|
227
223
|
const { user, mode } = (0, connect_2.toDatabaseUser)(email);
|
|
224
|
+
const { user: fdcP4SAUser } = (0, connect_2.toDatabaseUser)((0, connect_2.getDataConnectP4SA)(String(projectNumber)));
|
|
225
|
+
if (role === "owner" && user === fdcP4SAUser) {
|
|
226
|
+
throw new error_1.FirebaseError(`Cannot grant the "owner" role to the Data Connect service agent (${email}). The service agent must only hold data-plane roles (writer/reader).`);
|
|
227
|
+
}
|
|
228
228
|
await cloudSqlAdminClient.createUser(projectId, instanceId, mode, user);
|
|
229
229
|
const fdcSqlRole = exports.fdcSqlRoleMap[role](databaseId, schema);
|
|
230
230
|
await (0, connect_1.executeSqlCmdsAsSuperUser)(options, instanceId, databaseId, [`GRANT "${fdcSqlRole}" TO "${user}"`], false);
|