firebase-tools-with-isolate 13.6.4 → 13.9.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/README.md +4 -6
- package/lib/api.js +18 -8
- package/lib/apiv2.js +19 -13
- package/lib/apphosting/app.js +69 -0
- package/lib/apphosting/config.js +97 -0
- package/lib/{init/features/apphosting → apphosting}/constants.js +2 -2
- package/lib/apphosting/githubConnections.js +263 -0
- package/lib/apphosting/index.js +319 -0
- package/lib/{init/features/apphosting → apphosting}/repo.js +12 -12
- package/lib/apphosting/secrets/dialogs.js +170 -0
- package/lib/apphosting/secrets/index.js +103 -0
- package/lib/checkValidTargetFilters.js +8 -1
- package/lib/commands/apphosting-backends-create.js +9 -4
- package/lib/commands/apphosting-backends-delete.js +27 -30
- package/lib/commands/apphosting-backends-get.js +8 -8
- package/lib/commands/apphosting-backends-list.js +6 -7
- package/lib/commands/apphosting-secrets-access.js +24 -0
- package/lib/commands/apphosting-secrets-describe.js +29 -0
- package/lib/commands/apphosting-secrets-grantaccess.js +49 -0
- package/lib/commands/apphosting-secrets-set.js +56 -0
- package/lib/commands/dataconnect-sdk-generate.js +37 -0
- package/lib/commands/dataconnect-services-list.js +80 -0
- package/lib/commands/dataconnect-sql-diff.js +25 -0
- package/lib/commands/dataconnect-sql-migrate.js +45 -0
- package/lib/commands/deploy.js +27 -1
- package/lib/commands/firestore-databases-create.js +1 -0
- package/lib/commands/firestore-databases-restore.js +1 -0
- package/lib/commands/functions-secrets-access.js +2 -2
- package/lib/commands/functions-secrets-describe.js +14 -0
- package/lib/commands/functions-secrets-destroy.js +2 -2
- package/lib/commands/functions-secrets-get.js +3 -17
- package/lib/commands/functions-secrets-prune.js +2 -1
- package/lib/commands/functions-secrets-set.js +3 -19
- package/lib/commands/index.js +25 -6
- package/lib/commands/init.js +10 -3
- package/lib/commands/setup-emulators-dataconnect.js +12 -0
- package/lib/config.js +1 -0
- package/lib/dataconnect/build.js +22 -0
- package/lib/dataconnect/checkIam.js +30 -0
- package/lib/dataconnect/client.js +112 -0
- package/lib/dataconnect/dataplaneClient.js +16 -0
- package/lib/dataconnect/ensureApis.js +12 -0
- package/lib/dataconnect/errors.js +29 -0
- package/lib/dataconnect/fileUtils.js +92 -0
- package/lib/dataconnect/filters.js +45 -0
- package/lib/dataconnect/freeTrial.js +22 -0
- package/lib/dataconnect/graphqlError.js +12 -0
- package/lib/dataconnect/load.js +40 -0
- package/lib/dataconnect/names.js +46 -0
- package/lib/dataconnect/prompts.js +20 -0
- package/lib/dataconnect/provisionCloudSql.js +74 -0
- package/lib/dataconnect/schemaMigration.js +246 -0
- package/lib/dataconnect/types.js +22 -0
- package/lib/deploy/dataconnect/deploy.js +75 -0
- package/lib/deploy/dataconnect/index.js +9 -0
- package/lib/deploy/dataconnect/prepare.js +33 -0
- package/lib/deploy/dataconnect/release.js +65 -0
- package/lib/deploy/firestore/prepare.js +4 -2
- package/lib/deploy/functions/checkIam.js +6 -39
- package/lib/deploy/functions/containerCleaner.js +1 -15
- package/lib/deploy/functions/deploy.js +2 -2
- package/lib/deploy/functions/params.js +2 -2
- package/lib/deploy/functions/prepare.js +13 -3
- package/lib/deploy/functions/pricing.js +2 -2
- package/lib/deploy/functions/prompts.js +39 -7
- package/lib/deploy/functions/release/fabricator.js +12 -7
- package/lib/deploy/functions/release/index.js +17 -2
- package/lib/deploy/functions/release/planner.js +11 -3
- package/lib/deploy/functions/runtimes/discovery/index.js +3 -3
- package/lib/deploy/functions/runtimes/index.js +6 -43
- package/lib/deploy/functions/runtimes/node/index.js +3 -2
- package/lib/deploy/functions/runtimes/node/parseRuntimeAndValidateSDK.js +15 -34
- package/lib/deploy/functions/runtimes/python/index.js +10 -7
- package/lib/deploy/functions/runtimes/supported/index.js +80 -0
- package/lib/deploy/functions/runtimes/supported/types.js +74 -0
- package/lib/deploy/functions/services/index.js +4 -0
- package/lib/deploy/index.js +2 -0
- package/lib/downloadUtils.js +3 -2
- package/lib/emulator/constants.js +3 -0
- package/lib/emulator/controller.js +44 -13
- package/lib/emulator/dataconnectEmulator.js +95 -0
- package/lib/emulator/download.js +1 -1
- package/lib/emulator/downloadableEmulators.js +57 -8
- package/lib/emulator/functionsEmulator.js +2 -2
- package/lib/emulator/hub.js +5 -0
- package/lib/emulator/portUtils.js +3 -3
- package/lib/emulator/registry.js +6 -1
- package/lib/emulator/types.js +3 -0
- package/lib/experiments.js +31 -6
- package/lib/extensions/emulator/specHelper.js +9 -42
- package/lib/extensions/extensionsApi.js +2 -2
- package/lib/extensions/localHelper.js +3 -3
- package/lib/firestore/pretty-print.js +5 -0
- package/lib/frameworks/astro/index.js +1 -1
- package/lib/frameworks/flutter/index.js +2 -2
- package/lib/frameworks/next/constants.js +2 -1
- package/lib/frameworks/next/index.js +27 -15
- package/lib/frameworks/next/utils.js +33 -3
- package/lib/functional.js +2 -2
- package/lib/functions/events/v2.js +7 -1
- package/lib/functions/python.js +4 -3
- package/lib/functions/secrets.js +40 -22
- package/lib/gcp/apphosting.js +25 -3
- package/lib/gcp/cloudbuild.js +7 -3
- package/lib/gcp/cloudfunctions.js +5 -5
- package/lib/gcp/cloudfunctionsv2.js +3 -3
- package/lib/gcp/cloudscheduler.js +2 -2
- package/lib/gcp/cloudsql/cloudsqladmin.js +174 -0
- package/lib/gcp/cloudsql/connect.js +144 -0
- package/lib/gcp/cloudsql/fbToolsAuthClient.js +44 -0
- package/lib/gcp/computeEngine.js +7 -0
- package/lib/gcp/devConnect.js +25 -12
- package/lib/gcp/firedata.js +27 -0
- package/lib/gcp/iam.js +41 -1
- package/lib/gcp/secretManager.js +55 -7
- package/lib/gcp/serviceusage.js +24 -5
- package/lib/hosting/interactive.js +4 -0
- package/lib/init/features/dataconnect/index.js +166 -0
- package/lib/init/features/emulators.js +13 -1
- package/lib/init/features/functions/index.js +19 -3
- package/lib/init/features/functions/npm-dependencies.js +12 -23
- package/lib/init/features/functions/python.js +4 -3
- package/lib/init/features/genkit.js +53 -0
- package/lib/init/features/hosting/github.js +4 -5
- package/lib/init/features/index.js +6 -2
- package/lib/init/index.js +2 -0
- package/lib/init/spawn.js +23 -0
- package/lib/logger.js +22 -2
- package/lib/operation-poller.js +8 -2
- package/lib/rc.js +9 -1
- package/lib/requireAuth.js +1 -8
- package/lib/requireTosAcceptance.js +22 -0
- package/lib/utils.js +76 -8
- package/package.json +11 -5
- package/schema/connector-yaml.json +54 -0
- package/schema/dataconnect-yaml.json +72 -0
- package/schema/firebase-config.json +115 -2
- package/templates/extensions/javascript/package.lint.json +2 -2
- package/templates/extensions/javascript/package.nolint.json +2 -2
- package/templates/extensions/typescript/package.lint.json +2 -2
- package/templates/extensions/typescript/package.nolint.json +2 -2
- package/templates/init/dataconnect/connector.yaml +2 -0
- package/templates/init/dataconnect/dataconnect.yaml +10 -0
- package/templates/init/dataconnect/mutations.gql +30 -0
- package/templates/init/dataconnect/queries.gql +51 -0
- package/templates/init/dataconnect/schema.gql +28 -0
- package/templates/init/functions/javascript/_gitignore +2 -1
- package/templates/init/functions/javascript/package.lint.json +2 -2
- package/templates/init/functions/javascript/package.nolint.json +2 -2
- package/templates/init/functions/python/_gitignore +1 -0
- package/templates/init/functions/typescript/_eslintrc +1 -0
- package/templates/init/functions/typescript/_gitignore +1 -0
- package/templates/init/functions/typescript/package.lint.json +2 -2
- package/templates/init/functions/typescript/package.nolint.json +2 -2
- package/lib/init/features/apphosting/index.js +0 -229
- package/lib/monospace/index.js +0 -82
- /package/lib/{monospace/interfaces.js → gcp/cloudsql/types.js} +0 -0
|
@@ -1,31 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getRuntimeChoice = exports.
|
|
3
|
+
exports.getRuntimeChoice = exports.RUNTIME_NOT_SET = void 0;
|
|
4
4
|
const path = require("path");
|
|
5
|
-
const clc = require("colorette");
|
|
6
5
|
const error_1 = require("../../../../error");
|
|
7
|
-
const
|
|
6
|
+
const supported = require("../supported");
|
|
8
7
|
const cjson = require("cjson");
|
|
9
|
-
const
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
14: "nodejs14",
|
|
15
|
-
16: "nodejs16",
|
|
16
|
-
18: "nodejs18",
|
|
17
|
-
20: "nodejs20",
|
|
18
|
-
};
|
|
19
|
-
const ENGINE_RUNTIMES_NAMES = Object.values(ENGINE_RUNTIMES);
|
|
20
|
-
exports.RUNTIME_NOT_SET = "`runtime` field is required but was not found in firebase.json.\n" +
|
|
8
|
+
const supportedNodeVersions = Object.keys(supported.RUNTIMES)
|
|
9
|
+
.filter((s) => supported.runtimeIsLanguage(s, "nodejs"))
|
|
10
|
+
.filter((s) => !supported.isDecommissioned(s))
|
|
11
|
+
.map((s) => s.substring("nodejs".length));
|
|
12
|
+
exports.RUNTIME_NOT_SET = "`runtime` field is required but was not found in firebase.json or package.json.\n" +
|
|
21
13
|
"To fix this, add the following lines to the `functions` section of your firebase.json:\n" +
|
|
22
|
-
|
|
23
|
-
exports.UNSUPPORTED_NODE_VERSION_FIREBASE_JSON_MSG = clc.bold(`functions.runtime value is unsupported. ` +
|
|
24
|
-
`Valid choices are: ${clc.bold("nodejs{10|12|14|16|18|20}")}.`);
|
|
25
|
-
exports.UNSUPPORTED_NODE_VERSION_PACKAGE_JSON_MSG = clc.bold(`package.json in functions directory has an engines field which is unsupported. ` +
|
|
26
|
-
`Valid choices are: ${clc.bold('{"node": 10|12|14|16|18|20}')}`);
|
|
27
|
-
exports.DEPRECATED_NODE_VERSION_INFO = `\n\nDeploys to runtimes below Node.js 10 are now disabled in the Firebase CLI. ` +
|
|
28
|
-
`${clc.bold(`Existing Node.js 8 functions ${clc.underline("will stop executing at a future date")}`)}. Update existing functions to Node.js 10 or greater as soon as possible.`;
|
|
14
|
+
`"runtime": "${supported.latest("nodejs")}" or set the "engine" field in package.json\n`;
|
|
29
15
|
function getRuntimeChoiceFromPackageJson(sourceDir) {
|
|
30
16
|
const packageJsonPath = path.join(sourceDir, "package.json");
|
|
31
17
|
let loaded;
|
|
@@ -39,19 +25,14 @@ function getRuntimeChoiceFromPackageJson(sourceDir) {
|
|
|
39
25
|
if (!engines || !engines.node) {
|
|
40
26
|
throw new error_1.FirebaseError(exports.RUNTIME_NOT_SET);
|
|
41
27
|
}
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
const errorMessage = (runtimeFromConfig
|
|
47
|
-
? exports.UNSUPPORTED_NODE_VERSION_FIREBASE_JSON_MSG
|
|
48
|
-
: exports.UNSUPPORTED_NODE_VERSION_PACKAGE_JSON_MSG) + exports.DEPRECATED_NODE_VERSION_INFO;
|
|
49
|
-
if (!runtime || !ENGINE_RUNTIMES_NAMES.includes(runtime)) {
|
|
50
|
-
throw new error_1.FirebaseError(errorMessage, { exit: 1 });
|
|
51
|
-
}
|
|
52
|
-
if (runtimes.isDeprecatedRuntime(runtime) || !runtimes.isValidRuntime(runtime)) {
|
|
53
|
-
throw new error_1.FirebaseError(errorMessage, { exit: 1 });
|
|
28
|
+
const runtime = `nodejs${engines.node}`;
|
|
29
|
+
if (!supported.isRuntime(runtime)) {
|
|
30
|
+
throw new error_1.FirebaseError(`Detected node engine ${engines.node} in package.json, which is not a ` +
|
|
31
|
+
`supported version. Valid versions are ${supportedNodeVersions.join(", ")}`);
|
|
54
32
|
}
|
|
55
33
|
return runtime;
|
|
56
34
|
}
|
|
35
|
+
function getRuntimeChoice(sourceDir, runtimeFromConfig) {
|
|
36
|
+
return runtimeFromConfig || getRuntimeChoiceFromPackageJson(sourceDir);
|
|
37
|
+
}
|
|
57
38
|
exports.getRuntimeChoice = getRuntimeChoice;
|
|
@@ -1,27 +1,30 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Delegate = exports.getPythonBinary = exports.tryCreateDelegate =
|
|
3
|
+
exports.Delegate = exports.getPythonBinary = exports.tryCreateDelegate = void 0;
|
|
4
4
|
const fs = require("fs");
|
|
5
5
|
const path = require("path");
|
|
6
6
|
const node_fetch_1 = require("node-fetch");
|
|
7
7
|
const util_1 = require("util");
|
|
8
8
|
const portfinder = require("portfinder");
|
|
9
|
-
const runtimes = require("..");
|
|
10
9
|
const discovery = require("../discovery");
|
|
10
|
+
const supported = require("../supported");
|
|
11
11
|
const logger_1 = require("../../../../logger");
|
|
12
12
|
const python_1 = require("../../../../functions/python");
|
|
13
13
|
const error_1 = require("../../../../error");
|
|
14
|
-
|
|
14
|
+
const functional_1 = require("../../../../functional");
|
|
15
15
|
async function tryCreateDelegate(context) {
|
|
16
16
|
const requirementsTextPath = path.join(context.sourceDir, "requirements.txt");
|
|
17
17
|
if (!(await (0, util_1.promisify)(fs.exists)(requirementsTextPath))) {
|
|
18
18
|
logger_1.logger.debug("Customer code is not Python code.");
|
|
19
19
|
return;
|
|
20
20
|
}
|
|
21
|
-
const runtime = context.runtime
|
|
22
|
-
if (!
|
|
21
|
+
const runtime = context.runtime ?? supported.latest("python");
|
|
22
|
+
if (!supported.isRuntime(runtime)) {
|
|
23
23
|
throw new error_1.FirebaseError(`Runtime ${runtime} is not a valid Python runtime`);
|
|
24
24
|
}
|
|
25
|
+
if (!supported.runtimeIsLanguage(runtime, "python")) {
|
|
26
|
+
throw new error_1.FirebaseError(`Internal error. Trying to construct a python runtime delegate for runtime ${runtime}`, { exit: 1 });
|
|
27
|
+
}
|
|
25
28
|
return Promise.resolve(new Delegate(context.projectId, context.sourceDir, runtime));
|
|
26
29
|
}
|
|
27
30
|
exports.tryCreateDelegate = tryCreateDelegate;
|
|
@@ -38,7 +41,7 @@ function getPythonBinary(runtime) {
|
|
|
38
41
|
else if (runtime === "python312") {
|
|
39
42
|
return "python3.12";
|
|
40
43
|
}
|
|
41
|
-
|
|
44
|
+
(0, functional_1.assertExhaustive)(runtime, `Unhandled python runtime ${runtime}`);
|
|
42
45
|
}
|
|
43
46
|
exports.getPythonBinary = getPythonBinary;
|
|
44
47
|
class Delegate {
|
|
@@ -46,7 +49,7 @@ class Delegate {
|
|
|
46
49
|
this.projectId = projectId;
|
|
47
50
|
this.sourceDir = sourceDir;
|
|
48
51
|
this.runtime = runtime;
|
|
49
|
-
this.
|
|
52
|
+
this.language = "python";
|
|
50
53
|
this._bin = "";
|
|
51
54
|
this._modulesDir = "";
|
|
52
55
|
}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.guardVersionSupport = exports.isDecommissioned = exports.latest = exports.runtimeIsLanguage = exports.isRuntime = void 0;
|
|
18
|
+
const error_1 = require("../../../../error");
|
|
19
|
+
const utils = require("../../../../utils");
|
|
20
|
+
const types_1 = require("./types");
|
|
21
|
+
__exportStar(require("./types"), exports);
|
|
22
|
+
function isRuntime(maybe) {
|
|
23
|
+
return maybe in types_1.RUNTIMES;
|
|
24
|
+
}
|
|
25
|
+
exports.isRuntime = isRuntime;
|
|
26
|
+
function runtimeIsLanguage(runtime, language) {
|
|
27
|
+
return runtime.startsWith(language);
|
|
28
|
+
}
|
|
29
|
+
exports.runtimeIsLanguage = runtimeIsLanguage;
|
|
30
|
+
function latest(language, runtimes = Object.keys(types_1.RUNTIMES)) {
|
|
31
|
+
const sorted = runtimes
|
|
32
|
+
.filter((s) => runtimeIsLanguage(s, language))
|
|
33
|
+
.sort((left, right) => {
|
|
34
|
+
const leftVersion = +left.substring(language.length);
|
|
35
|
+
const rightVersion = +right.substring(language.length);
|
|
36
|
+
if (isNaN(leftVersion) || isNaN(rightVersion)) {
|
|
37
|
+
throw new error_1.FirebaseError("Internal error. Runtime or language names are malformed", {
|
|
38
|
+
exit: 1,
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
return leftVersion - rightVersion;
|
|
42
|
+
});
|
|
43
|
+
const latest = utils.last(sorted);
|
|
44
|
+
if (!latest) {
|
|
45
|
+
throw new error_1.FirebaseError(`Internal error trying to find the latest supported runtime for ${language}`, { exit: 1 });
|
|
46
|
+
}
|
|
47
|
+
return latest;
|
|
48
|
+
}
|
|
49
|
+
exports.latest = latest;
|
|
50
|
+
function isDecommissioned(runtime, now = new Date()) {
|
|
51
|
+
const cutoff = new Date(types_1.RUNTIMES[runtime].decommissionDate);
|
|
52
|
+
return cutoff < now;
|
|
53
|
+
}
|
|
54
|
+
exports.isDecommissioned = isDecommissioned;
|
|
55
|
+
function guardVersionSupport(runtime, now = new Date()) {
|
|
56
|
+
const { deprecationDate, decommissionDate } = types_1.RUNTIMES[runtime];
|
|
57
|
+
const decommission = new Date(decommissionDate);
|
|
58
|
+
if (now >= decommission) {
|
|
59
|
+
throw new error_1.FirebaseError(`Runtime ${types_1.RUNTIMES[runtime].friendly} was decommissioned on ${decommissionDate}. To deploy ` +
|
|
60
|
+
"you must first upgrade your runtime version.", { exit: 1 });
|
|
61
|
+
}
|
|
62
|
+
const deprecation = new Date(deprecationDate);
|
|
63
|
+
if (now >= deprecation) {
|
|
64
|
+
utils.logLabeledWarning("functions", `Runtime ${types_1.RUNTIMES[runtime].friendly} was deprecated on ${deprecationDate} and will be ` +
|
|
65
|
+
`decommissioned on ${decommissionDate}, after which you will not be able ` +
|
|
66
|
+
"to deploy without upgrading. Consider upgrading now to avoid disruption. See " +
|
|
67
|
+
"https://cloud.google.com/functions/docs/runtime-support for full " +
|
|
68
|
+
"details on the lifecycle policy");
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
const warning = new Date(deprecation.getTime() - 90 * 24 * 60 * 60 * 1000);
|
|
72
|
+
if (now >= warning) {
|
|
73
|
+
utils.logLabeledWarning("functions", `Runtime ${types_1.RUNTIMES[runtime].friendly} will be deprecated on ${deprecationDate} and will be ` +
|
|
74
|
+
`decommissioned on ${decommissionDate}, after which you will not be able ` +
|
|
75
|
+
"to deploy without upgrading. Consider upgrading now to avoid disruption. See " +
|
|
76
|
+
"https://cloud.google.com/functions/docs/runtime-support for full " +
|
|
77
|
+
"details on the lifecycle policy");
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
exports.guardVersionSupport = guardVersionSupport;
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.RUNTIMES = void 0;
|
|
4
|
+
function runtimes(r) {
|
|
5
|
+
return r;
|
|
6
|
+
}
|
|
7
|
+
exports.RUNTIMES = runtimes({
|
|
8
|
+
nodejs6: {
|
|
9
|
+
friendly: "Node.js 6",
|
|
10
|
+
status: "decommissioned",
|
|
11
|
+
deprecationDate: "2019-04-17",
|
|
12
|
+
decommissionDate: "2020-08-01",
|
|
13
|
+
},
|
|
14
|
+
nodejs8: {
|
|
15
|
+
friendly: "Node.js 8",
|
|
16
|
+
status: "decommissioned",
|
|
17
|
+
deprecationDate: "2020-06-05",
|
|
18
|
+
decommissionDate: "2021-02-01",
|
|
19
|
+
},
|
|
20
|
+
nodejs10: {
|
|
21
|
+
friendly: "Node.js 10",
|
|
22
|
+
status: "GA",
|
|
23
|
+
deprecationDate: "2024-01-30",
|
|
24
|
+
decommissionDate: "2025-01-30",
|
|
25
|
+
},
|
|
26
|
+
nodejs12: {
|
|
27
|
+
friendly: "Node.js 12",
|
|
28
|
+
status: "GA",
|
|
29
|
+
deprecationDate: "2024-01-30",
|
|
30
|
+
decommissionDate: "2025-01-30",
|
|
31
|
+
},
|
|
32
|
+
nodejs14: {
|
|
33
|
+
friendly: "Node.js 14",
|
|
34
|
+
status: "GA",
|
|
35
|
+
deprecationDate: "2024-01-30",
|
|
36
|
+
decommissionDate: "2025-01-30",
|
|
37
|
+
},
|
|
38
|
+
nodejs16: {
|
|
39
|
+
friendly: "Node.js 16",
|
|
40
|
+
status: "GA",
|
|
41
|
+
deprecationDate: "2024-01-30",
|
|
42
|
+
decommissionDate: "2025-01-30",
|
|
43
|
+
},
|
|
44
|
+
nodejs18: {
|
|
45
|
+
friendly: "Node.js 18",
|
|
46
|
+
status: "GA",
|
|
47
|
+
deprecationDate: "2025-04-30",
|
|
48
|
+
decommissionDate: "2025-10-31",
|
|
49
|
+
},
|
|
50
|
+
nodejs20: {
|
|
51
|
+
friendly: "Node.js 20",
|
|
52
|
+
status: "GA",
|
|
53
|
+
deprecationDate: "2026-04-30",
|
|
54
|
+
decommissionDate: "2026-10-31",
|
|
55
|
+
},
|
|
56
|
+
python310: {
|
|
57
|
+
friendly: "Python 3.10",
|
|
58
|
+
status: "GA",
|
|
59
|
+
deprecationDate: "2026-10-04",
|
|
60
|
+
decommissionDate: "2027-04-30",
|
|
61
|
+
},
|
|
62
|
+
python311: {
|
|
63
|
+
friendly: "Python 3.11",
|
|
64
|
+
status: "GA",
|
|
65
|
+
deprecationDate: "2027-10-24",
|
|
66
|
+
decommissionDate: "2028-04-30",
|
|
67
|
+
},
|
|
68
|
+
python312: {
|
|
69
|
+
friendly: "Python 3.12",
|
|
70
|
+
status: "GA",
|
|
71
|
+
deprecationDate: "2028-10-02",
|
|
72
|
+
decommissionDate: "2029-04-30",
|
|
73
|
+
},
|
|
74
|
+
});
|
|
@@ -104,6 +104,10 @@ const EVENT_SERVICE_MAPPING = {
|
|
|
104
104
|
"google.cloud.firestore.document.v1.created": firestoreService,
|
|
105
105
|
"google.cloud.firestore.document.v1.updated": firestoreService,
|
|
106
106
|
"google.cloud.firestore.document.v1.deleted": firestoreService,
|
|
107
|
+
"google.cloud.firestore.document.v1.written.withAuthContext": firestoreService,
|
|
108
|
+
"google.cloud.firestore.document.v1.created.withAuthContext": firestoreService,
|
|
109
|
+
"google.cloud.firestore.document.v1.updated.withAuthContext": firestoreService,
|
|
110
|
+
"google.cloud.firestore.document.v1.deleted.withAuthContext": firestoreService,
|
|
107
111
|
};
|
|
108
112
|
function serviceForEndpoint(endpoint) {
|
|
109
113
|
if (backend.isEventTriggered(endpoint)) {
|
package/lib/deploy/index.js
CHANGED
|
@@ -19,6 +19,7 @@ const FunctionsTarget = require("./functions");
|
|
|
19
19
|
const StorageTarget = require("./storage");
|
|
20
20
|
const RemoteConfigTarget = require("./remoteconfig");
|
|
21
21
|
const ExtensionsTarget = require("./extensions");
|
|
22
|
+
const DataConnectTarget = require("./dataconnect");
|
|
22
23
|
const frameworks_1 = require("../frameworks");
|
|
23
24
|
const prepare_1 = require("./hosting/prepare");
|
|
24
25
|
const github_1 = require("../init/features/hosting/github");
|
|
@@ -32,6 +33,7 @@ const TARGETS = {
|
|
|
32
33
|
storage: StorageTarget,
|
|
33
34
|
remoteconfig: RemoteConfigTarget,
|
|
34
35
|
extensions: ExtensionsTarget,
|
|
36
|
+
dataconnect: DataConnectTarget,
|
|
35
37
|
};
|
|
36
38
|
const chain = async function (fns, context, options, payload) {
|
|
37
39
|
for (const latest of fns) {
|
package/lib/downloadUtils.js
CHANGED
|
@@ -7,12 +7,13 @@ const ProgressBar = require("progress");
|
|
|
7
7
|
const tmp = require("tmp");
|
|
8
8
|
const apiv2_1 = require("./apiv2");
|
|
9
9
|
const error_1 = require("./error");
|
|
10
|
-
async function downloadToTmp(remoteUrl) {
|
|
10
|
+
async function downloadToTmp(remoteUrl, auth = false) {
|
|
11
11
|
const u = new url_1.URL(remoteUrl);
|
|
12
|
-
const c = new apiv2_1.Client({ urlPrefix: u.origin, auth
|
|
12
|
+
const c = new apiv2_1.Client({ urlPrefix: u.origin, auth });
|
|
13
13
|
const tmpfile = tmp.fileSync();
|
|
14
14
|
const writeStream = fs.createWriteStream(tmpfile.name);
|
|
15
15
|
const res = await c.request({
|
|
16
|
+
ignoreQuotaProject: true,
|
|
16
17
|
method: "GET",
|
|
17
18
|
path: u.pathname,
|
|
18
19
|
queryParams: u.searchParams,
|
|
@@ -14,6 +14,7 @@ exports.DEFAULT_PORTS = {
|
|
|
14
14
|
auth: 9099,
|
|
15
15
|
storage: 9199,
|
|
16
16
|
eventarc: 9299,
|
|
17
|
+
dataconnect: 9399,
|
|
17
18
|
};
|
|
18
19
|
exports.FIND_AVAILBLE_PORT_BY_DEFAULT = {
|
|
19
20
|
ui: true,
|
|
@@ -28,6 +29,7 @@ exports.FIND_AVAILBLE_PORT_BY_DEFAULT = {
|
|
|
28
29
|
storage: false,
|
|
29
30
|
extensions: false,
|
|
30
31
|
eventarc: true,
|
|
32
|
+
dataconnect: true,
|
|
31
33
|
};
|
|
32
34
|
exports.EMULATOR_DESCRIPTION = {
|
|
33
35
|
ui: "Emulator UI",
|
|
@@ -42,6 +44,7 @@ exports.EMULATOR_DESCRIPTION = {
|
|
|
42
44
|
storage: "Storage Emulator",
|
|
43
45
|
extensions: "Extensions Emulator",
|
|
44
46
|
eventarc: "Eventarc Emulator",
|
|
47
|
+
dataconnect: "Data Connect Emulator",
|
|
45
48
|
};
|
|
46
49
|
exports.DEFAULT_HOST = "localhost";
|
|
47
50
|
class Constants {
|
|
@@ -12,14 +12,8 @@ const registry_1 = require("./registry");
|
|
|
12
12
|
const types_1 = require("./types");
|
|
13
13
|
const constants_1 = require("./constants");
|
|
14
14
|
const functionsEmulator_1 = require("./functionsEmulator");
|
|
15
|
-
const auth_1 = require("./auth");
|
|
16
|
-
const databaseEmulator_1 = require("./databaseEmulator");
|
|
17
|
-
const firestoreEmulator_1 = require("./firestoreEmulator");
|
|
18
|
-
const hostingEmulator_1 = require("./hostingEmulator");
|
|
19
|
-
const eventarcEmulator_1 = require("./eventarcEmulator");
|
|
20
15
|
const error_1 = require("../error");
|
|
21
16
|
const projectUtils_1 = require("../projectUtils");
|
|
22
|
-
const pubsubEmulator_1 = require("./pubsubEmulator");
|
|
23
17
|
const commandUtils = require("./commandUtils");
|
|
24
18
|
const hub_1 = require("./hub");
|
|
25
19
|
const hubExport_1 = require("./hubExport");
|
|
@@ -31,16 +25,25 @@ const hubClient_1 = require("./hubClient");
|
|
|
31
25
|
const prompt_1 = require("../prompt");
|
|
32
26
|
const commandUtils_1 = require("./commandUtils");
|
|
33
27
|
const fsutils_1 = require("../fsutils");
|
|
34
|
-
const storage_1 = require("./storage");
|
|
35
28
|
const config_1 = require("./storage/rules/config");
|
|
36
29
|
const getDefaultDatabaseInstance_1 = require("../getDefaultDatabaseInstance");
|
|
37
|
-
const
|
|
30
|
+
const auth_1 = require("../auth");
|
|
38
31
|
const extensionsEmulator_1 = require("./extensionsEmulator");
|
|
39
32
|
const projectConfig_1 = require("../functions/projectConfig");
|
|
40
33
|
const downloadableEmulators_1 = require("./downloadableEmulators");
|
|
41
34
|
const frameworks_1 = require("../frameworks");
|
|
42
35
|
const experiments = require("../experiments");
|
|
43
36
|
const portUtils_1 = require("./portUtils");
|
|
37
|
+
const supported_1 = require("../deploy/functions/runtimes/supported");
|
|
38
|
+
const auth_2 = require("./auth");
|
|
39
|
+
const databaseEmulator_1 = require("./databaseEmulator");
|
|
40
|
+
const eventarcEmulator_1 = require("./eventarcEmulator");
|
|
41
|
+
const dataconnectEmulator_1 = require("./dataconnectEmulator");
|
|
42
|
+
const firestoreEmulator_1 = require("./firestoreEmulator");
|
|
43
|
+
const hostingEmulator_1 = require("./hostingEmulator");
|
|
44
|
+
const pubsubEmulator_1 = require("./pubsubEmulator");
|
|
45
|
+
const storage_1 = require("./storage");
|
|
46
|
+
const fileUtils_1 = require("../dataconnect/fileUtils");
|
|
44
47
|
const START_LOGGING_EMULATOR = utils.envOverride("START_LOGGING_EMULATOR", "false", (val) => val === "true");
|
|
45
48
|
async function exportOnExit(options) {
|
|
46
49
|
const exportOnExitDir = options.exportOnExit;
|
|
@@ -306,7 +309,10 @@ async function startAll(options, showUI = true, runningTestScript = false) {
|
|
|
306
309
|
utils.assertIsStringOrUndefined(options.extDevDir);
|
|
307
310
|
for (const cfg of functionsCfg) {
|
|
308
311
|
const functionsDir = path.join(projectDir, cfg.source);
|
|
309
|
-
const runtime = options.extDevRuntime ?? cfg.runtime;
|
|
312
|
+
const runtime = (options.extDevRuntime ?? cfg.runtime);
|
|
313
|
+
if (runtime && !(0, supported_1.isRuntime)(runtime)) {
|
|
314
|
+
throw new error_1.FirebaseError(`Cannot load functions from ${functionsDir} because it has invalid runtime ${runtime}`);
|
|
315
|
+
}
|
|
310
316
|
emulatableBackends.push({
|
|
311
317
|
functionsDir,
|
|
312
318
|
runtime,
|
|
@@ -346,7 +352,7 @@ async function startAll(options, showUI = true, runningTestScript = false) {
|
|
|
346
352
|
if (emulatorsNotRunning.length > 0 && !constants_1.Constants.isDemoProject(projectId)) {
|
|
347
353
|
functionsLogger.logLabeled("WARN", "functions", `The following emulators are not running, calls to these services from the Functions emulator will affect production: ${clc.bold(emulatorsNotRunning.join(", "))}`);
|
|
348
354
|
}
|
|
349
|
-
const account = (0,
|
|
355
|
+
const account = (0, auth_1.getProjectDefaultAccount)(options.projectRoot);
|
|
350
356
|
const functionsEmulator = new functionsEmulator_1.FunctionsEmulator({
|
|
351
357
|
projectId,
|
|
352
358
|
projectDir,
|
|
@@ -486,13 +492,13 @@ async function startAll(options, showUI = true, runningTestScript = false) {
|
|
|
486
492
|
throw new error_1.FirebaseError(`Cannot start the ${constants_1.Constants.description(types_1.Emulators.AUTH)} without a project: run 'firebase init' or provide the --project flag`);
|
|
487
493
|
}
|
|
488
494
|
const authAddr = legacyGetFirstAddr(types_1.Emulators.AUTH);
|
|
489
|
-
const authEmulator = new
|
|
495
|
+
const authEmulator = new auth_2.AuthEmulator({
|
|
490
496
|
host: authAddr.host,
|
|
491
497
|
port: authAddr.port,
|
|
492
498
|
projectId,
|
|
493
499
|
singleProjectMode: singleProjectModeEnabled
|
|
494
|
-
?
|
|
495
|
-
:
|
|
500
|
+
? auth_2.SingleProjectMode.WARNING
|
|
501
|
+
: auth_2.SingleProjectMode.NO_WARNING,
|
|
496
502
|
});
|
|
497
503
|
await startEmulator(authEmulator);
|
|
498
504
|
if (exportMetadata.auth) {
|
|
@@ -515,6 +521,31 @@ async function startAll(options, showUI = true, runningTestScript = false) {
|
|
|
515
521
|
});
|
|
516
522
|
await startEmulator(pubsubEmulator);
|
|
517
523
|
}
|
|
524
|
+
if (listenForEmulator.dataconnect) {
|
|
525
|
+
const dataConnectAddr = legacyGetFirstAddr(types_1.Emulators.DATACONNECT);
|
|
526
|
+
const config = (0, fileUtils_1.readFirebaseJson)(options.config);
|
|
527
|
+
if (!config.length) {
|
|
528
|
+
throw new error_1.FirebaseError("No Data Connect service found in firebase.json");
|
|
529
|
+
}
|
|
530
|
+
else if (config.length > 1) {
|
|
531
|
+
logger_1.logger.warn(`TODO: Add support for multiple services in the Data Connect emulator. Currently emulating first service ${config[0].source}`);
|
|
532
|
+
}
|
|
533
|
+
let configDir = config[0].source;
|
|
534
|
+
if (!path.isAbsolute(configDir)) {
|
|
535
|
+
const cwd = options.cwd || process.cwd();
|
|
536
|
+
configDir = path.resolve(path.join(cwd), configDir);
|
|
537
|
+
}
|
|
538
|
+
const dataConnectEmulator = new dataconnectEmulator_1.DataConnectEmulator({
|
|
539
|
+
host: dataConnectAddr.host,
|
|
540
|
+
port: dataConnectAddr.port,
|
|
541
|
+
projectId,
|
|
542
|
+
auto_download: true,
|
|
543
|
+
configDir,
|
|
544
|
+
locationId: config[0].location,
|
|
545
|
+
rc: options.rc,
|
|
546
|
+
});
|
|
547
|
+
await startEmulator(dataConnectEmulator);
|
|
548
|
+
}
|
|
518
549
|
if (listenForEmulator.storage) {
|
|
519
550
|
const storageAddr = legacyGetFirstAddr(types_1.Emulators.STORAGE);
|
|
520
551
|
const storageEmulator = new storage_1.StorageEmulator({
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DataConnectEmulator = void 0;
|
|
4
|
+
const childProcess = require("child_process");
|
|
5
|
+
const api_1 = require("../api");
|
|
6
|
+
const constants_1 = require("./constants");
|
|
7
|
+
const downloadableEmulators_1 = require("./downloadableEmulators");
|
|
8
|
+
const types_1 = require("./types");
|
|
9
|
+
const error_1 = require("../error");
|
|
10
|
+
const emulatorLogger_1 = require("./emulatorLogger");
|
|
11
|
+
const types_2 = require("../dataconnect/types");
|
|
12
|
+
const grpcDefaultPort = 9510;
|
|
13
|
+
class DataConnectEmulator {
|
|
14
|
+
constructor(args) {
|
|
15
|
+
this.args = args;
|
|
16
|
+
this.logger = emulatorLogger_1.EmulatorLogger.forEmulator(types_1.Emulators.DATACONNECT);
|
|
17
|
+
}
|
|
18
|
+
async start() {
|
|
19
|
+
const port = this.args.port || constants_1.Constants.getDefaultPort(types_1.Emulators.DATACONNECT);
|
|
20
|
+
this.logger.log("DEBUG", `Using Postgres connection string: ${this.getLocalConectionString()}`);
|
|
21
|
+
const info = await this.build();
|
|
22
|
+
if ((0, types_2.requiresVector)(info.metadata)) {
|
|
23
|
+
if (constants_1.Constants.isDemoProject(this.args.projectId)) {
|
|
24
|
+
this.logger.logLabeled("WARN", "Data Connect", "Detected a 'demo-' project, but vector embeddings require a real project. Operations that use vector_embed will fail.");
|
|
25
|
+
}
|
|
26
|
+
else {
|
|
27
|
+
this.logger.logLabeled("WARN", "Data Connect", "Operations that use vector_embed will make calls to production Vertex AI");
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
return (0, downloadableEmulators_1.start)(types_1.Emulators.DATACONNECT, {
|
|
31
|
+
...this.args,
|
|
32
|
+
http_port: port,
|
|
33
|
+
grpc_port: grpcDefaultPort,
|
|
34
|
+
config_dir: this.args.configDir,
|
|
35
|
+
local_connection_string: this.getLocalConectionString(),
|
|
36
|
+
project_id: this.args.projectId,
|
|
37
|
+
service_location: this.args.locationId,
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
connect() {
|
|
41
|
+
return Promise.resolve();
|
|
42
|
+
}
|
|
43
|
+
stop() {
|
|
44
|
+
return (0, downloadableEmulators_1.stop)(types_1.Emulators.DATACONNECT);
|
|
45
|
+
}
|
|
46
|
+
getInfo() {
|
|
47
|
+
const host = this.args.host || constants_1.Constants.getDefaultHost();
|
|
48
|
+
const port = this.args.port || constants_1.Constants.getDefaultPort(types_1.Emulators.DATACONNECT);
|
|
49
|
+
return {
|
|
50
|
+
name: this.getName(),
|
|
51
|
+
host,
|
|
52
|
+
port,
|
|
53
|
+
pid: (0, downloadableEmulators_1.getPID)(types_1.Emulators.DATACONNECT),
|
|
54
|
+
timeout: 10000,
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
getName() {
|
|
58
|
+
return types_1.Emulators.DATACONNECT;
|
|
59
|
+
}
|
|
60
|
+
async generate(connectorId) {
|
|
61
|
+
const commandInfo = await (0, downloadableEmulators_1.downloadIfNecessary)(types_1.Emulators.DATACONNECT);
|
|
62
|
+
const cmd = [
|
|
63
|
+
"generate",
|
|
64
|
+
`--service_location=${this.args.locationId}`,
|
|
65
|
+
`--config_dir=${this.args.configDir}`,
|
|
66
|
+
`--connector_id=${connectorId}`,
|
|
67
|
+
];
|
|
68
|
+
const res = childProcess.spawnSync(commandInfo.binary, cmd, { encoding: "utf-8" });
|
|
69
|
+
if (res.error) {
|
|
70
|
+
throw new error_1.FirebaseError(`Error starting up Data Connect emulator: ${res.error}`);
|
|
71
|
+
}
|
|
72
|
+
return res.stdout;
|
|
73
|
+
}
|
|
74
|
+
async build() {
|
|
75
|
+
const commandInfo = await (0, downloadableEmulators_1.downloadIfNecessary)(types_1.Emulators.DATACONNECT);
|
|
76
|
+
const cmd = ["build", `--config_dir=${this.args.configDir}`];
|
|
77
|
+
const res = childProcess.spawnSync(commandInfo.binary, cmd, { encoding: "utf-8" });
|
|
78
|
+
if (res.stderr) {
|
|
79
|
+
throw new error_1.FirebaseError(`Unable to build your Data Connect schema and connectors: ${res.stderr}`);
|
|
80
|
+
}
|
|
81
|
+
try {
|
|
82
|
+
return JSON.parse(res.stdout);
|
|
83
|
+
}
|
|
84
|
+
catch (err) {
|
|
85
|
+
throw new error_1.FirebaseError(`Unable to parse 'fdc build' output: ${res.stdout ?? res.stderr}`);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
getLocalConectionString() {
|
|
89
|
+
if ((0, api_1.dataConnectLocalConnString)()) {
|
|
90
|
+
return (0, api_1.dataConnectLocalConnString)();
|
|
91
|
+
}
|
|
92
|
+
return this.args.rc.getDataconnect()?.postgres?.localConnectionString;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
exports.DataConnectEmulator = DataConnectEmulator;
|
package/lib/emulator/download.js
CHANGED
|
@@ -15,7 +15,7 @@ async function downloadEmulator(name) {
|
|
|
15
15
|
const emulator = downloadableEmulators.getDownloadDetails(name);
|
|
16
16
|
emulatorLogger_1.EmulatorLogger.forEmulator(name).logLabeled("BULLET", name, `downloading ${path.basename(emulator.downloadPath)}...`);
|
|
17
17
|
fs.ensureDirSync(emulator.opts.cacheDir);
|
|
18
|
-
const tmpfile = await downloadUtils.downloadToTmp(emulator.opts.remoteUrl);
|
|
18
|
+
const tmpfile = await downloadUtils.downloadToTmp(emulator.opts.remoteUrl, !!emulator.opts.auth);
|
|
19
19
|
if (!emulator.opts.skipChecksumAndSize) {
|
|
20
20
|
await validateSize(tmpfile, emulator.opts.expectedSize);
|
|
21
21
|
await validateChecksum(tmpfile, emulator.opts.expectedChecksum);
|