firebase-tools-with-isolate 15.25.1 → 15.27.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/ailogic/templates.js +124 -0
- package/lib/api.js +6 -2
- package/lib/appcheck/api.js +52 -0
- package/lib/appcheck/providers.js +240 -0
- package/lib/appcheck/services.js +135 -0
- package/lib/auth.js +33 -15
- package/lib/checkValidTargetFilters.js +1 -0
- package/lib/command.js +4 -1
- package/lib/commands/ailogic-templates-delete.js +53 -0
- package/lib/commands/ailogic-templates-get.js +33 -0
- package/lib/commands/ailogic-templates-list.js +49 -0
- package/lib/commands/ailogic-templates-lock.js +30 -0
- package/lib/commands/ailogic-templates-unlock.js +30 -0
- package/lib/commands/appcheck-apps-list.js +78 -0
- package/lib/commands/appcheck-debugtokens-create.js +2 -2
- package/lib/commands/appcheck-debugtokens-delete.js +2 -2
- package/lib/commands/appcheck-debugtokens-list.js +2 -2
- package/lib/commands/appcheck-prompts.js +55 -0
- package/lib/commands/appcheck-providers-get.js +73 -0
- package/lib/commands/appcheck-providers-list.js +67 -0
- package/lib/commands/appcheck-providers-set.js +96 -0
- package/lib/commands/appcheck-services-get.js +40 -0
- package/lib/commands/appcheck-services-list.js +52 -0
- package/lib/commands/appcheck-services-set.js +90 -0
- package/lib/commands/crashlytics-onboard-web.js +56 -0
- package/lib/commands/deploy.js +3 -0
- package/lib/commands/ext-export.js +75 -3
- package/lib/commands/firestore-locations.js +3 -1
- package/lib/commands/functions-kits-install.js +294 -0
- package/lib/commands/index.js +24 -0
- package/lib/commands/login.js +53 -6
- package/lib/config.js +1 -0
- package/lib/crashlytics/filters.js +12 -4
- package/lib/crashlytics/firebasetelemetry.js +36 -0
- package/lib/crashlytics/onboarding.js +41 -0
- package/lib/crashlytics/reports.js +2 -0
- package/lib/crashlytics/sourcemap.js +102 -12
- package/lib/crashlytics/types.js +8 -1
- package/lib/deploy/ailogic/index.js +19 -0
- package/lib/deploy/ailogic/prepare.js +78 -0
- package/lib/deploy/ailogic/release.js +60 -0
- package/lib/deploy/functions/backend.js +11 -1
- package/lib/deploy/functions/build.js +1 -1
- package/lib/deploy/functions/params.js +5 -1
- package/lib/deploy/functions/prepare.js +26 -13
- package/lib/deploy/functions/prompts.js +1 -1
- package/lib/deploy/functions/release/lifecycle.js +11 -0
- package/lib/deploy/functions/release/planner.js +5 -2
- package/lib/deploy/index.js +9 -0
- package/lib/emulator/controller.js +1 -0
- package/lib/emulator/downloadableEmulatorInfo.json +24 -24
- package/lib/emulator/functionsEmulator.js +3 -1
- package/lib/experiments.js +13 -0
- package/lib/extensions/checkProjectBilling.js +3 -73
- package/lib/extensions/export.js +47 -0
- package/lib/functions/env.js +20 -7
- package/lib/functions/projectConfig.js +19 -11
- package/lib/functions/python.js +1 -1
- package/lib/gcp/ailogic.js +70 -1
- package/lib/gcp/cloudbilling.js +74 -0
- package/lib/gcp/cloudlogging.js +54 -0
- package/lib/gcp/runv2.js +1 -0
- package/lib/management/apps.js +1 -2
- package/lib/mcp/onemcp/index.js +2 -1
- package/lib/mcp/onemcp/onemcp_server.js +38 -11
- package/lib/mcp/prompts/crashlytics/connect.js +1 -1
- package/lib/mcp/resources/guides/crashlytics_issues.js +3 -3
- package/lib/mcp/resources/guides/crashlytics_reports.js +32 -11
- package/lib/mcp/tool.js +5 -0
- package/lib/mcp/tools/crashlytics/notes.js +3 -3
- package/lib/mcp/tools/crashlytics/reports.js +2 -0
- package/lib/mcp/util/crashlytics/availability.js +54 -1
- package/lib/prompt.js +10 -1
- package/lib/requirePermissions.js +1 -1
- package/lib/serve/functions.js +1 -1
- package/lib/tsconfig.publish.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/schema/firebase-config.json +42 -3
- package/templates/init/functions/typescript/index-kit-migration.ts +49 -0
- package/templates/init/functions/typescript/index-kit.ts +35 -0
- package/lib/appcheck/prompts.js +0 -41
|
@@ -54,36 +54,36 @@
|
|
|
54
54
|
},
|
|
55
55
|
"dataconnect": {
|
|
56
56
|
"darwin": {
|
|
57
|
-
"version": "3.4.
|
|
58
|
-
"expectedSize":
|
|
59
|
-
"expectedChecksum": "
|
|
60
|
-
"expectedChecksumSHA256": "
|
|
61
|
-
"remoteUrl": "https://storage.googleapis.com/firemat-preview-drop/emulator/dataconnect-emulator-macos-amd64-v3.4.
|
|
62
|
-
"downloadPathRelativeToCacheDir": "dataconnect-emulator-3.4.
|
|
57
|
+
"version": "3.4.17",
|
|
58
|
+
"expectedSize": 32968592,
|
|
59
|
+
"expectedChecksum": "2658cdff6b7584aea118250a56217464",
|
|
60
|
+
"expectedChecksumSHA256": "43d5755fdeb51c6a66725ba45cf3355531bf3516367e54574080b17e2ab5f5b5",
|
|
61
|
+
"remoteUrl": "https://storage.googleapis.com/firemat-preview-drop/emulator/dataconnect-emulator-macos-amd64-v3.4.17",
|
|
62
|
+
"downloadPathRelativeToCacheDir": "dataconnect-emulator-3.4.17"
|
|
63
63
|
},
|
|
64
64
|
"darwin_arm64": {
|
|
65
|
-
"version": "3.4.
|
|
66
|
-
"expectedSize":
|
|
67
|
-
"expectedChecksum": "
|
|
68
|
-
"expectedChecksumSHA256": "
|
|
69
|
-
"remoteUrl": "https://storage.googleapis.com/firemat-preview-drop/emulator/dataconnect-emulator-macos-arm64-v3.4.
|
|
70
|
-
"downloadPathRelativeToCacheDir": "dataconnect-emulator-3.4.
|
|
65
|
+
"version": "3.4.17",
|
|
66
|
+
"expectedSize": 31079394,
|
|
67
|
+
"expectedChecksum": "fe73494081e3a0319dad298b7d05ff7c",
|
|
68
|
+
"expectedChecksumSHA256": "10ef4602874824ecb5ba655e016f44b856ce37374d64a03d58e7c70c75c67f83",
|
|
69
|
+
"remoteUrl": "https://storage.googleapis.com/firemat-preview-drop/emulator/dataconnect-emulator-macos-arm64-v3.4.17",
|
|
70
|
+
"downloadPathRelativeToCacheDir": "dataconnect-emulator-3.4.17"
|
|
71
71
|
},
|
|
72
72
|
"win32": {
|
|
73
|
-
"version": "3.4.
|
|
74
|
-
"expectedSize":
|
|
75
|
-
"expectedChecksum": "
|
|
76
|
-
"expectedChecksumSHA256": "
|
|
77
|
-
"remoteUrl": "https://storage.googleapis.com/firemat-preview-drop/emulator/dataconnect-emulator-windows-amd64-v3.4.
|
|
78
|
-
"downloadPathRelativeToCacheDir": "dataconnect-emulator-3.4.
|
|
73
|
+
"version": "3.4.17",
|
|
74
|
+
"expectedSize": 33011200,
|
|
75
|
+
"expectedChecksum": "8648cad58f7f2c0f9854825f4811cc03",
|
|
76
|
+
"expectedChecksumSHA256": "7bab1aba01d16dfbea53f476fc50b49000abe123387208dc3584c9486ac9c73a",
|
|
77
|
+
"remoteUrl": "https://storage.googleapis.com/firemat-preview-drop/emulator/dataconnect-emulator-windows-amd64-v3.4.17",
|
|
78
|
+
"downloadPathRelativeToCacheDir": "dataconnect-emulator-3.4.17.exe"
|
|
79
79
|
},
|
|
80
80
|
"linux": {
|
|
81
|
-
"version": "3.4.
|
|
82
|
-
"expectedSize":
|
|
83
|
-
"expectedChecksum": "
|
|
84
|
-
"expectedChecksumSHA256": "
|
|
85
|
-
"remoteUrl": "https://storage.googleapis.com/firemat-preview-drop/emulator/dataconnect-emulator-linux-amd64-v3.4.
|
|
86
|
-
"downloadPathRelativeToCacheDir": "dataconnect-emulator-3.4.
|
|
81
|
+
"version": "3.4.17",
|
|
82
|
+
"expectedSize": 32121016,
|
|
83
|
+
"expectedChecksum": "da3601940de713b05e783f40799db567",
|
|
84
|
+
"expectedChecksumSHA256": "9878cd2116d03fedd5085d8233563920c2fbf2b0926319aeaff21b81293b7330",
|
|
85
|
+
"remoteUrl": "https://storage.googleapis.com/firemat-preview-drop/emulator/dataconnect-emulator-linux-amd64-v3.4.17",
|
|
86
|
+
"downloadPathRelativeToCacheDir": "dataconnect-emulator-3.4.17"
|
|
87
87
|
}
|
|
88
88
|
}
|
|
89
89
|
}
|
|
@@ -367,6 +367,7 @@ class FunctionsEmulator {
|
|
|
367
367
|
projectAlias: this.args.projectAlias,
|
|
368
368
|
isEmulator: true,
|
|
369
369
|
configDir: emulatableBackend.configDir,
|
|
370
|
+
projectDir: this.args.projectDir,
|
|
370
371
|
};
|
|
371
372
|
const userEnvs = functionsEnv.loadUserEnvs(userEnvOpt);
|
|
372
373
|
const discoveredBuild = await runtimeDelegate.discoverBuild(runtimeConfig, environment);
|
|
@@ -379,6 +380,7 @@ class FunctionsEmulator {
|
|
|
379
380
|
build: discoveredBuild,
|
|
380
381
|
firebaseConfig: JSON.parse(firebaseConfig),
|
|
381
382
|
userEnvs,
|
|
383
|
+
codebase: emulatableBackend.codebase,
|
|
382
384
|
nonInteractive: false,
|
|
383
385
|
isEmulator: true,
|
|
384
386
|
});
|
|
@@ -957,6 +959,7 @@ class FunctionsEmulator {
|
|
|
957
959
|
projectId: this.args.projectId,
|
|
958
960
|
projectAlias: this.args.projectAlias,
|
|
959
961
|
isEmulator: true,
|
|
962
|
+
projectDir: this.args.projectDir,
|
|
960
963
|
};
|
|
961
964
|
if (functionsEnv.hasUserEnvs(projectInfo)) {
|
|
962
965
|
try {
|
|
@@ -1134,7 +1137,6 @@ class FunctionsEmulator {
|
|
|
1134
1137
|
port: 8081 + (0, utils_1.randomInt)(0, 1000),
|
|
1135
1138
|
});
|
|
1136
1139
|
const childProcess = (0, python_1.runWithVirtualEnv)(args, backend.functionsDir, {
|
|
1137
|
-
...process.env,
|
|
1138
1140
|
...envs,
|
|
1139
1141
|
PYTHONUNBUFFERED: "1",
|
|
1140
1142
|
DEBUG: "False",
|
package/lib/experiments.js
CHANGED
|
@@ -121,6 +121,14 @@ exports.ALL_EXPERIMENTS = experiments({
|
|
|
121
121
|
"These commands are not meant for public consumption and may break or disappear " +
|
|
122
122
|
"without a notice.",
|
|
123
123
|
},
|
|
124
|
+
appcheckadmin: {
|
|
125
|
+
shortDescription: "Manage App Check enforcement and attestation providers from the CLI.",
|
|
126
|
+
fullDescription: "Enables the `firebase appcheck:services`, `firebase appcheck:providers` and " +
|
|
127
|
+
"`firebase appcheck:apps` commands for reading and changing App Check enforcement per " +
|
|
128
|
+
"service and the attestation providers of each app. These commands are in preview and " +
|
|
129
|
+
"may change until the surface is API council approved. The `firebase appcheck:debugtokens` " +
|
|
130
|
+
"commands are generally available and are not affected by this experiment.",
|
|
131
|
+
},
|
|
124
132
|
ailogic: {
|
|
125
133
|
shortDescription: "Manage Firebase AI Logic from the CLI.",
|
|
126
134
|
fullDescription: "Enables the `firebase ailogic` command surface for managing Firebase AI Logic, " +
|
|
@@ -208,6 +216,11 @@ exports.ALL_EXPERIMENTS = experiments({
|
|
|
208
216
|
default: true,
|
|
209
217
|
public: true,
|
|
210
218
|
},
|
|
219
|
+
extMigrationFeatures: {
|
|
220
|
+
shortDescription: "Enable features intended to assist with the migration of Extension instances to Kits.",
|
|
221
|
+
default: false,
|
|
222
|
+
public: false,
|
|
223
|
+
},
|
|
211
224
|
});
|
|
212
225
|
function isValidExperiment(name) {
|
|
213
226
|
return Object.keys(exports.ALL_EXPERIMENTS).includes(name);
|
|
@@ -1,75 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.enableBilling =
|
|
4
|
-
const
|
|
5
|
-
|
|
6
|
-
const cloudbilling = require("../gcp/cloudbilling");
|
|
7
|
-
const error_1 = require("../error");
|
|
8
|
-
const logger_1 = require("../logger");
|
|
9
|
-
const extensionsHelper_1 = require("./extensionsHelper");
|
|
10
|
-
const prompt = require("../prompt");
|
|
11
|
-
const utils = require("../utils");
|
|
12
|
-
const ADD_BILLING_ACCOUNT = "Add new billing account";
|
|
13
|
-
function logBillingStatus(enabled, projectId) {
|
|
14
|
-
if (!enabled) {
|
|
15
|
-
throw new error_1.FirebaseError(`${extensionsHelper_1.logPrefix}: ${clc.bold(projectId)} could not be upgraded. Please add a billing account via the Firebase console before proceeding.`);
|
|
16
|
-
}
|
|
17
|
-
utils.logLabeledSuccess(extensionsHelper_1.logPrefix, `${clc.bold(projectId)} has successfully been upgraded.`);
|
|
18
|
-
}
|
|
19
|
-
async function openBillingAccount(projectId, url, open) {
|
|
20
|
-
if (open) {
|
|
21
|
-
try {
|
|
22
|
-
opn(url);
|
|
23
|
-
}
|
|
24
|
-
catch (err) {
|
|
25
|
-
logger_1.logger.debug("Unable to open billing URL: " + err.stack);
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
await prompt.confirm({
|
|
29
|
-
message: "Press enter when finished upgrading your project to continue setting up your extension.",
|
|
30
|
-
default: true,
|
|
31
|
-
});
|
|
32
|
-
return cloudbilling.checkBillingEnabled(projectId, true);
|
|
33
|
-
}
|
|
34
|
-
async function chooseBillingAccount(projectId, accounts) {
|
|
35
|
-
const choices = accounts.map((m) => m.displayName);
|
|
36
|
-
choices.push(ADD_BILLING_ACCOUNT);
|
|
37
|
-
const answer = await prompt.select({
|
|
38
|
-
message: `Extensions require your project to be upgraded to the Blaze plan. You have access to the following billing accounts.
|
|
39
|
-
Please select the one that you would like to associate with this project:`,
|
|
40
|
-
choices: choices,
|
|
41
|
-
});
|
|
42
|
-
let billingEnabled;
|
|
43
|
-
if (answer === ADD_BILLING_ACCOUNT) {
|
|
44
|
-
const billingURL = `https://console.cloud.google.com/billing/linkedaccount?project=${projectId}`;
|
|
45
|
-
billingEnabled = await openBillingAccount(projectId, billingURL, true);
|
|
46
|
-
}
|
|
47
|
-
else {
|
|
48
|
-
const billingAccount = accounts.find((a) => a.displayName === answer);
|
|
49
|
-
billingEnabled = await cloudbilling.setBillingAccount(projectId, billingAccount.name);
|
|
50
|
-
}
|
|
51
|
-
return logBillingStatus(billingEnabled, projectId);
|
|
52
|
-
}
|
|
53
|
-
async function setUpBillingAccount(projectId) {
|
|
54
|
-
const billingURL = `https://console.cloud.google.com/billing/linkedaccount?project=${projectId}`;
|
|
55
|
-
logger_1.logger.info();
|
|
56
|
-
logger_1.logger.info(`Extension require your project to be upgraded to the Blaze plan. Please visit the following link to add a billing account:`);
|
|
57
|
-
logger_1.logger.info();
|
|
58
|
-
logger_1.logger.info(clc.bold(clc.underline(billingURL)));
|
|
59
|
-
logger_1.logger.info();
|
|
60
|
-
const open = await prompt.confirm({
|
|
61
|
-
message: "Press enter to open the URL.",
|
|
62
|
-
default: true,
|
|
63
|
-
});
|
|
64
|
-
const billingEnabled = await openBillingAccount(projectId, billingURL, open);
|
|
65
|
-
return logBillingStatus(billingEnabled, projectId);
|
|
66
|
-
}
|
|
67
|
-
async function enableBilling(projectId) {
|
|
68
|
-
const billingAccounts = await cloudbilling.listBillingAccounts(projectId);
|
|
69
|
-
if (billingAccounts) {
|
|
70
|
-
const accounts = billingAccounts.filter((account) => account.open);
|
|
71
|
-
return accounts.length > 0
|
|
72
|
-
? chooseBillingAccount(projectId, accounts)
|
|
73
|
-
: setUpBillingAccount(projectId);
|
|
74
|
-
}
|
|
75
|
-
}
|
|
3
|
+
exports.enableBilling = void 0;
|
|
4
|
+
const cloudbilling_1 = require("../gcp/cloudbilling");
|
|
5
|
+
Object.defineProperty(exports, "enableBilling", { enumerable: true, get: function () { return cloudbilling_1.enableBilling; } });
|
package/lib/extensions/export.js
CHANGED
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.parameterizeProject = parameterizeProject;
|
|
4
4
|
exports.setSecretParamsToLatest = setSecretParamsToLatest;
|
|
5
5
|
exports.displayExportInfo = displayExportInfo;
|
|
6
|
+
exports.functionsEnvFromInstance = functionsEnvFromInstance;
|
|
6
7
|
const planner_1 = require("../deploy/extensions/planner");
|
|
7
8
|
const deploymentSummary_1 = require("../deploy/extensions/deploymentSummary");
|
|
8
9
|
const logger_1 = require("../logger");
|
|
@@ -60,3 +61,49 @@ function displaySpecs(specs) {
|
|
|
60
61
|
logger_1.logger.info("");
|
|
61
62
|
}
|
|
62
63
|
}
|
|
64
|
+
function functionsEnvFromInstance(instance) {
|
|
65
|
+
const liveParams = instance.config?.params || {};
|
|
66
|
+
const liveSystemParams = instance.config?.systemParams || {};
|
|
67
|
+
const specParams = instance.config?.source?.spec?.params || {};
|
|
68
|
+
const specSystemParams = instance.config?.source?.spec?.systemParams || {};
|
|
69
|
+
const envs = {};
|
|
70
|
+
specParams.forEach((specParam) => {
|
|
71
|
+
if (specParam.type === "SECRET") {
|
|
72
|
+
const renamed = "FIREBASE_SECRET_REF_" + specParam.param;
|
|
73
|
+
envs[renamed] = liveParams[specParam.param];
|
|
74
|
+
}
|
|
75
|
+
else if (specParam.param in liveParams) {
|
|
76
|
+
envs[specParam.param] = liveParams[specParam.param];
|
|
77
|
+
}
|
|
78
|
+
else {
|
|
79
|
+
envs[specParam.param] = specParam.default ?? "";
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
for (const [sysParamName, sysParamValue] of Object.entries(liveSystemParams)) {
|
|
83
|
+
let renamed = sysParamName
|
|
84
|
+
.replace(/^firebaseextensions\.v1beta\.(v2)?function\//, "EXT_MIGRATED_SYSTEM_")
|
|
85
|
+
.toUpperCase();
|
|
86
|
+
if (renamed === "EXT_MIGRATED_SYSTEM_LOCATION") {
|
|
87
|
+
renamed = "DEFAULT_FUNCTION_REGION";
|
|
88
|
+
}
|
|
89
|
+
envs[renamed] = sysParamValue;
|
|
90
|
+
}
|
|
91
|
+
for (const specSystemParam of Object.values(specSystemParams)) {
|
|
92
|
+
if (specSystemParam.param in liveSystemParams) {
|
|
93
|
+
continue;
|
|
94
|
+
}
|
|
95
|
+
if ("default" in specSystemParam) {
|
|
96
|
+
const renamed = specSystemParam.param
|
|
97
|
+
.replace(/^firebaseextensions\.v1beta\.(v2)?function\//, "EXT_MIGRATED_SYSTEM_")
|
|
98
|
+
.toUpperCase();
|
|
99
|
+
envs[renamed] = specSystemParam.default ?? "";
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
if (typeof instance.config.allowedEventTypes !== "undefined") {
|
|
103
|
+
envs["EXT_SELECTED_EVENTS"] = instance.config.allowedEventTypes.toString();
|
|
104
|
+
}
|
|
105
|
+
if (typeof instance.config.eventarcChannel !== "undefined") {
|
|
106
|
+
envs["EVENTARC_CHANNEL"] = instance.config.eventarcChannel;
|
|
107
|
+
}
|
|
108
|
+
return envs;
|
|
109
|
+
}
|
package/lib/functions/env.js
CHANGED
|
@@ -19,7 +19,11 @@ const logger_1 = require("../logger");
|
|
|
19
19
|
const utils_1 = require("../utils");
|
|
20
20
|
const FUNCTIONS_EMULATOR_DOTENV = ".env.local";
|
|
21
21
|
const RESERVED_PREFIXES = ["X_GOOGLE_", "FIREBASE_", "EXT_", "KIT_"];
|
|
22
|
-
const RESERVED_PREFIX_ALLOWLIST = [
|
|
22
|
+
const RESERVED_PREFIX_ALLOWLIST = [
|
|
23
|
+
"FIREBASE_SECRET_REF_",
|
|
24
|
+
"EXT_MIGRATED_SYSTEM_",
|
|
25
|
+
"EXT_SELECTED_EVENTS",
|
|
26
|
+
];
|
|
23
27
|
const RESERVED_KEYS = [
|
|
24
28
|
"FIREBASE_CONFIG",
|
|
25
29
|
"CLOUD_RUNTIME_CONFIG",
|
|
@@ -183,10 +187,12 @@ function writeUserEnvs(toWrite, envOpts) {
|
|
|
183
187
|
? FUNCTIONS_EMULATOR_DOTENV
|
|
184
188
|
: `.env.${envOpts.projectId}`;
|
|
185
189
|
const targetEnvFileExists = allEnvFiles.includes(targetEnvFile);
|
|
190
|
+
const targetEnvFilePath = path.join(configDir, targetEnvFile);
|
|
191
|
+
const relativeTargetEnvFilePath = path.relative(envOpts.projectDir, targetEnvFilePath);
|
|
186
192
|
if (!targetEnvFileExists) {
|
|
187
|
-
fs.writeFileSync(
|
|
193
|
+
fs.writeFileSync(targetEnvFilePath, "", { flag: "wx" });
|
|
188
194
|
(0, utils_1.logBullet)(clc.yellow(clc.bold("functions: ")) +
|
|
189
|
-
`Created new local file ${
|
|
195
|
+
`Created new local file ${relativeTargetEnvFilePath} to store param values. We suggest explicitly adding or excluding this file from version control.`);
|
|
190
196
|
}
|
|
191
197
|
const fullEnvs = loadUserEnvs(envOpts);
|
|
192
198
|
const prodEnvs = isEmulator
|
|
@@ -196,7 +202,8 @@ function writeUserEnvs(toWrite, envOpts) {
|
|
|
196
202
|
for (const k of Object.keys(toWrite)) {
|
|
197
203
|
validateKey(k);
|
|
198
204
|
}
|
|
199
|
-
(0, utils_1.logBullet)(clc.cyan(clc.bold("functions: ")) +
|
|
205
|
+
(0, utils_1.logBullet)(clc.cyan(clc.bold("functions: ")) +
|
|
206
|
+
`Writing new parameter values to disk: ${relativeTargetEnvFilePath}`);
|
|
200
207
|
let lines = "";
|
|
201
208
|
for (const k of Object.keys(toWrite)) {
|
|
202
209
|
lines += formatUserEnvForWrite(k, toWrite[k]);
|
|
@@ -249,14 +256,20 @@ function loadUserEnvs(opts) {
|
|
|
249
256
|
});
|
|
250
257
|
}
|
|
251
258
|
}
|
|
252
|
-
|
|
259
|
+
const relativeEnvFiles = envFiles.map((f) => path.relative(opts.projectDir, path.join(configDir, f)));
|
|
260
|
+
(0, utils_1.logBullet)(clc.cyan(clc.bold("functions: ")) +
|
|
261
|
+
`Loaded environment variables from ${relativeEnvFiles.join(", ")}`);
|
|
253
262
|
return envs;
|
|
254
263
|
}
|
|
255
|
-
function loadFirebaseEnvs(firebaseConfig, projectId) {
|
|
256
|
-
|
|
264
|
+
function loadFirebaseEnvs(firebaseConfig, projectId, kitInstanceId) {
|
|
265
|
+
const envs = {
|
|
257
266
|
FIREBASE_CONFIG: JSON.stringify(firebaseConfig),
|
|
258
267
|
GCLOUD_PROJECT: projectId,
|
|
259
268
|
};
|
|
269
|
+
if (kitInstanceId) {
|
|
270
|
+
envs.FIREBASE_KIT_INSTANCE_ID = kitInstanceId;
|
|
271
|
+
}
|
|
272
|
+
return envs;
|
|
260
273
|
}
|
|
261
274
|
function writeResolvedParams(resolvedEnvs, userEnvs, userEnvOpt) {
|
|
262
275
|
const toWrite = {};
|
|
@@ -6,7 +6,8 @@ exports.validateCodebase = validateCodebase;
|
|
|
6
6
|
exports.validateKit = validateKit;
|
|
7
7
|
exports.validatePrefix = validatePrefix;
|
|
8
8
|
exports.assertUnique = assertUnique;
|
|
9
|
-
exports.
|
|
9
|
+
exports.validateKitInstanceId = validateKitInstanceId;
|
|
10
|
+
exports.validateAndAddKitInstances = validateAndAddKitInstances;
|
|
10
11
|
exports.validate = validate;
|
|
11
12
|
exports.normalizeAndValidate = normalizeAndValidate;
|
|
12
13
|
exports.configForCodebase = configForCodebase;
|
|
@@ -151,17 +152,24 @@ function assertUniqueSourcePrefixPair(config) {
|
|
|
151
152
|
sourcePrefixPairs.add(key);
|
|
152
153
|
}
|
|
153
154
|
}
|
|
154
|
-
function
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
155
|
+
function validateKitInstanceId(instanceId) {
|
|
156
|
+
if (instanceId.length === 0 ||
|
|
157
|
+
instanceId.length > 40 ||
|
|
158
|
+
!/^[a-z0-9_](?:[a-z0-9_-]*[a-z0-9_])?$/.test(instanceId)) {
|
|
159
|
+
throw new error_1.FirebaseError(`Invalid kit instance ID '${instanceId}'. Instance ID must be 40 characters or less, ` +
|
|
160
|
+
"can contain only lowercase letters, numeric characters, underscores, and dashes, and cannot start or end with a dash.");
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
function validateAndAddKitInstances(instanceIds, allProjectInstanceIds) {
|
|
164
|
+
const seenInBatch = new Set();
|
|
165
|
+
for (const instanceId of instanceIds) {
|
|
166
|
+
validateKitInstanceId(instanceId);
|
|
167
|
+
if (seenInBatch.has(instanceId) || allProjectInstanceIds.has(instanceId)) {
|
|
163
168
|
throw new error_1.FirebaseError(`functions kit instance ID must be unique across all kits, but '${instanceId}' was used more than once.`);
|
|
164
169
|
}
|
|
170
|
+
seenInBatch.add(instanceId);
|
|
171
|
+
}
|
|
172
|
+
for (const instanceId of seenInBatch) {
|
|
165
173
|
allProjectInstanceIds.add(instanceId);
|
|
166
174
|
}
|
|
167
175
|
}
|
|
@@ -173,7 +181,7 @@ function assertUniqueKitInstancesAndCodebases(config) {
|
|
|
173
181
|
codebases.add(c.codebase);
|
|
174
182
|
}
|
|
175
183
|
if ("instances" in c && c.instances) {
|
|
176
|
-
|
|
184
|
+
validateAndAddKitInstances(Object.keys(c.instances), instanceIds);
|
|
177
185
|
}
|
|
178
186
|
}
|
|
179
187
|
for (const instanceId of instanceIds) {
|
package/lib/functions/python.js
CHANGED
package/lib/gcp/ailogic.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.PROVIDER_TYPES = exports.WRITABLE_CONFIG_PATHS = exports.client = exports.AI_LOGIC_TRIGGERS_TO_EVENTS = exports.AI_LOGIC_EVENTS_TO_TRIGGER = exports.AI_LOGIC_AFTER_GENERATE_CONTENT = exports.AI_LOGIC_BEFORE_GENERATE_CONTENT = exports.GLOBAL_LOCATION = exports.AILOGIC_LOGGING_PREFIX = exports.API_VERSION = void 0;
|
|
3
|
+
exports.PROVIDER_TYPES = exports.WRITABLE_CONFIG_PATHS = exports.TEMPLATE_ID_REGEX = exports.client = exports.AI_LOGIC_TRIGGERS_TO_EVENTS = exports.AI_LOGIC_EVENTS_TO_TRIGGER = exports.AI_LOGIC_AFTER_GENERATE_CONTENT = exports.AI_LOGIC_BEFORE_GENERATE_CONTENT = exports.GLOBAL_LOCATION = exports.AILOGIC_LOGGING_PREFIX = exports.API_VERSION = void 0;
|
|
4
4
|
exports.createTrigger = createTrigger;
|
|
5
5
|
exports.getTrigger = getTrigger;
|
|
6
6
|
exports.updateTrigger = updateTrigger;
|
|
@@ -8,9 +8,17 @@ exports.deleteTrigger = deleteTrigger;
|
|
|
8
8
|
exports.listTriggers = listTriggers;
|
|
9
9
|
exports.upsertBlockingFunction = upsertBlockingFunction;
|
|
10
10
|
exports.deleteBlockingFunction = deleteBlockingFunction;
|
|
11
|
+
exports.templateIdFromName = templateIdFromName;
|
|
12
|
+
exports.assertValidTemplateId = assertValidTemplateId;
|
|
11
13
|
exports.assertKnownConfigPath = assertKnownConfigPath;
|
|
14
|
+
exports.withTemplate404 = withTemplate404;
|
|
12
15
|
exports.isProviderType = isProviderType;
|
|
13
16
|
exports.parseProviderType = parseProviderType;
|
|
17
|
+
exports.getTemplate = getTemplate;
|
|
18
|
+
exports.updateTemplate = updateTemplate;
|
|
19
|
+
exports.deleteTemplate = deleteTemplate;
|
|
20
|
+
exports.setTemplateLocked = setTemplateLocked;
|
|
21
|
+
exports.listTemplates = listTemplates;
|
|
14
22
|
exports.getConfig = getConfig;
|
|
15
23
|
exports.updateConfig = updateConfig;
|
|
16
24
|
exports.enableProvider = enableProvider;
|
|
@@ -129,6 +137,15 @@ async function deleteBlockingFunction(endpoint) {
|
|
|
129
137
|
const location = endpoint.blockingTrigger.options?.regionalWebhook ? endpoint.region : "global";
|
|
130
138
|
await deleteTrigger(endpoint.project, location, triggerId, true);
|
|
131
139
|
}
|
|
140
|
+
function templateIdFromName(name) {
|
|
141
|
+
return name.split("/").pop() ?? "";
|
|
142
|
+
}
|
|
143
|
+
exports.TEMPLATE_ID_REGEX = /^[A-Za-z0-9][A-Za-z0-9._-]*$/;
|
|
144
|
+
function assertValidTemplateId(templateId) {
|
|
145
|
+
if (!exports.TEMPLATE_ID_REGEX.test(templateId)) {
|
|
146
|
+
throw new error_1.FirebaseError(`Invalid template id: ${(0, colorette_1.bold)(templateId)}. Template ids must start with a letter or digit and contain only letters, digits, '.', '_', and '-'.`);
|
|
147
|
+
}
|
|
148
|
+
}
|
|
132
149
|
exports.WRITABLE_CONFIG_PATHS = [
|
|
133
150
|
"security.auth-only",
|
|
134
151
|
"security.template-only",
|
|
@@ -141,6 +158,20 @@ function assertKnownConfigPath(path, validPaths) {
|
|
|
141
158
|
validPaths.map((p) => ` ${p}`).join("\n"));
|
|
142
159
|
}
|
|
143
160
|
}
|
|
161
|
+
function templateName(projectId, templateId) {
|
|
162
|
+
return `projects/${projectId}/locations/${exports.GLOBAL_LOCATION}/templates/${templateId}`;
|
|
163
|
+
}
|
|
164
|
+
async function withTemplate404(templateId, fn) {
|
|
165
|
+
try {
|
|
166
|
+
return await fn();
|
|
167
|
+
}
|
|
168
|
+
catch (err) {
|
|
169
|
+
if ((0, error_1.getErrStatus)(err) === 404) {
|
|
170
|
+
throw new error_1.FirebaseError(`Template ${(0, colorette_1.bold)(templateId)} does not exist.`);
|
|
171
|
+
}
|
|
172
|
+
throw err;
|
|
173
|
+
}
|
|
174
|
+
}
|
|
144
175
|
exports.PROVIDER_TYPES = ["gemini-developer-api", "gemini-agent-platform-api"];
|
|
145
176
|
function isProviderType(value) {
|
|
146
177
|
return exports.PROVIDER_TYPES.some((p) => p === value);
|
|
@@ -151,6 +182,44 @@ function parseProviderType(value) {
|
|
|
151
182
|
}
|
|
152
183
|
return value;
|
|
153
184
|
}
|
|
185
|
+
async function getTemplate(projectId, templateId) {
|
|
186
|
+
const res = await exports.client.get(templateName(projectId, templateId));
|
|
187
|
+
return res.body;
|
|
188
|
+
}
|
|
189
|
+
async function updateTemplate(projectId, templateId, template, updateMask, allowMissing = true) {
|
|
190
|
+
const queryParams = {
|
|
191
|
+
allowMissing: allowMissing ? "true" : "false",
|
|
192
|
+
};
|
|
193
|
+
if (updateMask && updateMask.length > 0) {
|
|
194
|
+
queryParams.updateMask = updateMask.join(",");
|
|
195
|
+
}
|
|
196
|
+
const res = await exports.client.patch(templateName(projectId, templateId), template, { queryParams });
|
|
197
|
+
return res.body;
|
|
198
|
+
}
|
|
199
|
+
async function deleteTemplate(projectId, templateId, etag) {
|
|
200
|
+
const queryParams = {};
|
|
201
|
+
if (etag) {
|
|
202
|
+
queryParams.etag = etag;
|
|
203
|
+
}
|
|
204
|
+
await exports.client.delete(templateName(projectId, templateId), { queryParams });
|
|
205
|
+
}
|
|
206
|
+
async function setTemplateLocked(projectId, templateId, locked) {
|
|
207
|
+
await exports.client.post(`${templateName(projectId, templateId)}:modifyLock`, { locked });
|
|
208
|
+
}
|
|
209
|
+
async function listTemplates(projectId) {
|
|
210
|
+
const parent = `projects/${projectId}/locations/${exports.GLOBAL_LOCATION}`;
|
|
211
|
+
let pageToken;
|
|
212
|
+
const templates = [];
|
|
213
|
+
do {
|
|
214
|
+
const queryParams = pageToken ? { pageToken } : {};
|
|
215
|
+
const res = await exports.client.get(`${parent}/templates`, { queryParams });
|
|
216
|
+
if (res.body?.templates) {
|
|
217
|
+
templates.push(...res.body.templates);
|
|
218
|
+
}
|
|
219
|
+
pageToken = res.body?.nextPageToken;
|
|
220
|
+
} while (pageToken);
|
|
221
|
+
return templates;
|
|
222
|
+
}
|
|
154
223
|
async function getConfig(projectId) {
|
|
155
224
|
const name = `projects/${projectId}/locations/${exports.GLOBAL_LOCATION}/config`;
|
|
156
225
|
const res = await exports.client.get(name);
|
package/lib/gcp/cloudbilling.js
CHANGED
|
@@ -5,8 +5,14 @@ exports.clearCache = clearCache;
|
|
|
5
5
|
exports.checkBillingEnabled = checkBillingEnabled;
|
|
6
6
|
exports.setBillingAccount = setBillingAccount;
|
|
7
7
|
exports.listBillingAccounts = listBillingAccounts;
|
|
8
|
+
exports.enableBilling = enableBilling;
|
|
9
|
+
const clc = require("colorette");
|
|
10
|
+
const opn = require("open");
|
|
8
11
|
const api_1 = require("../api");
|
|
9
12
|
const apiv2_1 = require("../apiv2");
|
|
13
|
+
const error_1 = require("../error");
|
|
14
|
+
const logger_1 = require("../logger");
|
|
15
|
+
const prompt = require("../prompt");
|
|
10
16
|
const utils = require("../utils");
|
|
11
17
|
const ensureApiEnabled_1 = require("../ensureApiEnabled");
|
|
12
18
|
const API_VERSION = "v1";
|
|
@@ -69,3 +75,71 @@ async function listBillingAccounts(projectId) {
|
|
|
69
75
|
});
|
|
70
76
|
return res.body.billingAccounts || [];
|
|
71
77
|
}
|
|
78
|
+
const ADD_BILLING_ACCOUNT = "Add new billing account";
|
|
79
|
+
function logBillingStatus(enabled, projectId, featureName) {
|
|
80
|
+
const prefix = featureName === "Extensions" ? "extensions" : featureName.toLowerCase();
|
|
81
|
+
if (!enabled) {
|
|
82
|
+
throw new error_1.FirebaseError(`${prefix}: ${clc.bold(projectId)} could not be upgraded. Please add a billing account via the Firebase console before proceeding.`);
|
|
83
|
+
}
|
|
84
|
+
utils.logLabeledSuccess(prefix, `${clc.bold(projectId)} has successfully been upgraded.`);
|
|
85
|
+
}
|
|
86
|
+
async function openBillingAccount(projectId, url, open, featureName = "Extensions") {
|
|
87
|
+
if (open) {
|
|
88
|
+
try {
|
|
89
|
+
opn(url);
|
|
90
|
+
}
|
|
91
|
+
catch (err) {
|
|
92
|
+
logger_1.logger.debug("Unable to open billing URL: " + err.stack);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
const target = featureName === "Extensions" ? "your extension" : featureName.toLowerCase();
|
|
96
|
+
await prompt.confirm({
|
|
97
|
+
message: `Press enter when finished upgrading your project to continue setting up ${target}.`,
|
|
98
|
+
default: true,
|
|
99
|
+
});
|
|
100
|
+
return exports.checkBillingEnabled(projectId, true);
|
|
101
|
+
}
|
|
102
|
+
async function chooseBillingAccount(projectId, accounts, featureName) {
|
|
103
|
+
const choices = accounts.map((m) => m.displayName);
|
|
104
|
+
choices.push(ADD_BILLING_ACCOUNT);
|
|
105
|
+
const verb = featureName === "Extensions" ? "require" : "requires";
|
|
106
|
+
const answer = await prompt.select({
|
|
107
|
+
message: `${featureName} ${verb} your project to be upgraded to the Blaze plan. You have access to the following billing accounts.
|
|
108
|
+
Please select the one that you would like to associate with this project:`,
|
|
109
|
+
choices: choices,
|
|
110
|
+
});
|
|
111
|
+
let billingEnabled;
|
|
112
|
+
if (answer === ADD_BILLING_ACCOUNT) {
|
|
113
|
+
const billingURL = `https://console.cloud.google.com/billing/linkedaccount?project=${projectId}`;
|
|
114
|
+
billingEnabled = await openBillingAccount(projectId, billingURL, true, featureName);
|
|
115
|
+
}
|
|
116
|
+
else {
|
|
117
|
+
const billingAccount = accounts.find((a) => a.displayName === answer);
|
|
118
|
+
billingEnabled = await exports.setBillingAccount(projectId, billingAccount.name);
|
|
119
|
+
}
|
|
120
|
+
return logBillingStatus(billingEnabled, projectId, featureName);
|
|
121
|
+
}
|
|
122
|
+
async function setUpBillingAccount(projectId, featureName) {
|
|
123
|
+
const billingURL = `https://console.cloud.google.com/billing/linkedaccount?project=${projectId}`;
|
|
124
|
+
const verb = featureName === "Extensions" ? "require" : "requires";
|
|
125
|
+
logger_1.logger.info();
|
|
126
|
+
logger_1.logger.info(`${featureName} ${verb} your project to be upgraded to the Blaze plan. Please visit the following link to add a billing account:`);
|
|
127
|
+
logger_1.logger.info();
|
|
128
|
+
logger_1.logger.info(clc.bold(clc.underline(billingURL)));
|
|
129
|
+
logger_1.logger.info();
|
|
130
|
+
const open = await prompt.confirm({
|
|
131
|
+
message: "Press enter to open the URL.",
|
|
132
|
+
default: true,
|
|
133
|
+
});
|
|
134
|
+
const billingEnabled = await openBillingAccount(projectId, billingURL, open, featureName);
|
|
135
|
+
return logBillingStatus(billingEnabled, projectId, featureName);
|
|
136
|
+
}
|
|
137
|
+
async function enableBilling(projectId, featureName = "Extensions") {
|
|
138
|
+
const billingAccounts = await exports.listBillingAccounts(projectId);
|
|
139
|
+
if (billingAccounts) {
|
|
140
|
+
const accounts = billingAccounts.filter((account) => account.open);
|
|
141
|
+
return accounts.length > 0
|
|
142
|
+
? chooseBillingAccount(projectId, accounts, featureName)
|
|
143
|
+
: setUpBillingAccount(projectId, featureName);
|
|
144
|
+
}
|
|
145
|
+
}
|
package/lib/gcp/cloudlogging.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
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;
|
|
4
6
|
const api_1 = require("../api");
|
|
5
7
|
const apiv2_1 = require("../apiv2");
|
|
6
8
|
const error_1 = require("../error");
|
|
@@ -29,3 +31,55 @@ async function listEntries(projectId, filter, pageSize, order, pageToken) {
|
|
|
29
31
|
});
|
|
30
32
|
}
|
|
31
33
|
}
|
|
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/runv2.js
CHANGED
|
@@ -154,6 +154,7 @@ function endpointFromService(service) {
|
|
|
154
154
|
? proto.secondsFromDuration(service.template.timeout)
|
|
155
155
|
: 60,
|
|
156
156
|
serviceAccount: service.template.serviceAccount || null,
|
|
157
|
+
runServiceId: svcId,
|
|
157
158
|
ingressSettings: (service.annotations?.["run.googleapis.com/ingress"] === "internal"
|
|
158
159
|
? "ALLOW_INTERNAL_ONLY"
|
|
159
160
|
: service.annotations?.["run.googleapis.com/ingress"] === "internal-and-cloud-load-balancing"
|