firebase-tools-with-isolate 13.27.0 → 13.29.1-1
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/appdistribution/client.js +2 -1
- package/lib/appdistribution/options-parser-util.js +5 -5
- package/lib/auth.js +13 -3
- package/lib/bin/firebase.js +4 -3
- package/lib/commands/appdistribution-distribute.js +55 -31
- package/lib/commands/firestore-indexes-list.js +4 -2
- package/lib/commands/index.js +2 -2
- package/lib/dataconnect/fileUtils.js +3 -0
- package/lib/dataconnect/schemaMigration.js +10 -16
- package/lib/dataconnect/types.js +1 -1
- package/lib/deploy/extensions/tasks.js +2 -2
- package/lib/deploy/functions/backend.js +1 -3
- package/lib/deploy/functions/build.js +3 -1
- package/lib/deploy/functions/prepare.js +1 -1
- package/lib/deploy/functions/prepareFunctionsUpload.js +9 -5
- package/lib/deploy/functions/release/planner.js +4 -4
- package/lib/deploy/functions/runtimes/discovery/v1alpha1.js +4 -0
- package/lib/deploy/functions/runtimes/supported/types.js +1 -1
- package/lib/deploy/lifecycleHooks.js +4 -9
- package/lib/emulator/apphosting/developmentServer.js +1 -1
- package/lib/emulator/apphosting/index.js +1 -1
- package/lib/emulator/auth/operations.js +8 -5
- package/lib/emulator/controller.js +20 -1
- package/lib/emulator/dataconnect/pgliteServer.js +36 -12
- package/lib/emulator/dataconnectEmulator.js +18 -1
- package/lib/emulator/downloadableEmulators.js +21 -10
- package/lib/emulator/eventarcEmulator.js +1 -0
- package/lib/emulator/initEmulators.js +17 -2
- package/lib/error.js +11 -1
- package/lib/experiments.js +0 -6
- package/lib/extensions/localHelper.js +2 -2
- package/lib/extensions/runtimes/node.js +16 -15
- package/lib/extensions/types.js +6 -9
- package/lib/functions/events/v2.js +7 -3
- package/lib/gcp/cloudfunctionsv2.js +6 -0
- package/lib/init/features/dataconnect/index.js +8 -5
- package/lib/init/features/emulators.js +1 -1
- package/lib/init/features/genkit/index.js +13 -5
- package/lib/init/spawn.js +37 -7
- package/lib/management/projects.js +23 -1
- package/lib/requireAuth.js +2 -1
- package/package.json +7 -3
- package/schema/firebase-config.json +3 -0
- package/templates/init/dataconnect/dataconnect.yaml +1 -0
- package/templates/init/functions/javascript/package.lint.json +1 -1
- package/templates/init/functions/javascript/package.nolint.json +1 -1
- package/templates/init/functions/typescript/package.lint.json +1 -1
- package/templates/init/functions/typescript/package.nolint.json +1 -1
- package/templates/init/functions/typescript/tsconfig.json +3 -1
- package/templates/init/dataconnect/dataconnect-fdccompatiblemode.yaml +0 -12
|
@@ -577,11 +577,26 @@ async function startAll(options, showUI = true, runningTestScript = false) {
|
|
|
577
577
|
postgresListen: listenForEmulator["dataconnect.postgres"],
|
|
578
578
|
enable_output_generated_sdk: true,
|
|
579
579
|
enable_output_schema_extensions: true,
|
|
580
|
+
debug: options.debug,
|
|
580
581
|
};
|
|
581
582
|
if (exportMetadata.dataconnect) {
|
|
582
583
|
utils.assertIsString(options.import);
|
|
583
584
|
const importDirAbsPath = path.resolve(options.import);
|
|
584
585
|
const exportMetadataFilePath = path.resolve(importDirAbsPath, exportMetadata.dataconnect.path);
|
|
586
|
+
const dataDirectory = options.config.get("emulators.dataconnect.dataDir");
|
|
587
|
+
if (exportMetadataFilePath && dataDirectory) {
|
|
588
|
+
emulatorLogger_1.EmulatorLogger.forEmulator(types_1.Emulators.DATACONNECT).logLabeled("WARN", "dataconnect", "'firebase.json#emulators.dataconnect.dataDir' is set and `--import` flag was passed. " +
|
|
589
|
+
"This will overwrite any data saved from previous runs.");
|
|
590
|
+
if (!options.nonInteractive &&
|
|
591
|
+
!(await (0, prompt_1.promptOnce)({
|
|
592
|
+
type: "confirm",
|
|
593
|
+
message: `Do you wish to continue and overwrite data in ${dataDirectory}?`,
|
|
594
|
+
default: false,
|
|
595
|
+
}))) {
|
|
596
|
+
await cleanShutdown();
|
|
597
|
+
return { deprecationNotices: [] };
|
|
598
|
+
}
|
|
599
|
+
}
|
|
585
600
|
emulatorLogger_1.EmulatorLogger.forEmulator(types_1.Emulators.DATACONNECT).logLabeled("BULLET", "dataconnect", `Importing data from ${exportMetadataFilePath}`);
|
|
586
601
|
args.importPath = exportMetadataFilePath;
|
|
587
602
|
void (0, track_1.trackEmulator)("emulator_import", {
|
|
@@ -620,10 +635,14 @@ async function startAll(options, showUI = true, runningTestScript = false) {
|
|
|
620
635
|
const apphostingConfig = options.config.src.emulators?.[types_1.Emulators.APPHOSTING];
|
|
621
636
|
if (listenForEmulator.apphosting) {
|
|
622
637
|
const apphostingAddr = legacyGetFirstAddr(types_1.Emulators.APPHOSTING);
|
|
638
|
+
if (apphostingConfig?.startCommandOverride) {
|
|
639
|
+
const apphostingLogger = emulatorLogger_1.EmulatorLogger.forEmulator(types_1.Emulators.APPHOSTING);
|
|
640
|
+
apphostingLogger.logLabeled("WARN", types_1.Emulators.APPHOSTING, "The `firebase.json#emulators.apphosting.startCommandOverride` config is deprecated, please use `firebase.json#emulators.apphosting.startCommand` to set a custom start command instead");
|
|
641
|
+
}
|
|
623
642
|
const apphostingEmulator = new apphosting_1.AppHostingEmulator({
|
|
624
643
|
host: apphostingAddr.host,
|
|
625
644
|
port: apphostingAddr.port,
|
|
626
|
-
|
|
645
|
+
startCommand: apphostingConfig?.startCommand || apphostingConfig?.startCommandOverride,
|
|
627
646
|
rootDirectory: apphostingConfig?.rootDirectory,
|
|
628
647
|
options,
|
|
629
648
|
});
|
|
@@ -8,15 +8,17 @@ const fs = require("fs");
|
|
|
8
8
|
const index_1 = require("./pg-gateway/index");
|
|
9
9
|
const node_1 = require("./pg-gateway/platforms/node");
|
|
10
10
|
const logger_1 = require("../../logger");
|
|
11
|
+
const error_1 = require("../../error");
|
|
11
12
|
exports.TRUNCATE_TABLES_SQL = `
|
|
12
13
|
DO $do$
|
|
14
|
+
DECLARE _clear text;
|
|
13
15
|
BEGIN
|
|
14
|
-
|
|
15
|
-
(SELECT 'TRUNCATE TABLE ' || string_agg(oid::regclass::text, ', ') || ' CASCADE'
|
|
16
|
+
SELECT 'TRUNCATE TABLE ' || string_agg(oid::regclass::text, ', ') || ' CASCADE'
|
|
16
17
|
FROM pg_class
|
|
17
18
|
WHERE relkind = 'r'
|
|
18
19
|
AND relnamespace = 'public'::regnamespace
|
|
19
|
-
|
|
20
|
+
INTO _clear;
|
|
21
|
+
EXECUTE COALESCE(_clear, 'select now()');
|
|
20
22
|
END
|
|
21
23
|
$do$;`;
|
|
22
24
|
class PostgresServer {
|
|
@@ -43,6 +45,7 @@ class PostgresServer {
|
|
|
43
45
|
server.emit("error", err);
|
|
44
46
|
});
|
|
45
47
|
});
|
|
48
|
+
this.server = server;
|
|
46
49
|
const listeningPromise = new Promise((resolve) => {
|
|
47
50
|
server.listen(port, host, () => {
|
|
48
51
|
resolve();
|
|
@@ -56,9 +59,7 @@ class PostgresServer {
|
|
|
56
59
|
const vector = (await dynamicImport("@electric-sql/pglite/vector")).vector;
|
|
57
60
|
const uuidOssp = (await dynamicImport("@electric-sql/pglite/contrib/uuid_ossp")).uuid_ossp;
|
|
58
61
|
const pgliteArgs = {
|
|
59
|
-
|
|
60
|
-
database: this.database,
|
|
61
|
-
debug: 0,
|
|
62
|
+
debug: this.debug,
|
|
62
63
|
extensions: {
|
|
63
64
|
vector,
|
|
64
65
|
uuidOssp,
|
|
@@ -71,7 +72,7 @@ class PostgresServer {
|
|
|
71
72
|
const file = new File([rf], this.importPath);
|
|
72
73
|
pgliteArgs.loadDataDir = file;
|
|
73
74
|
}
|
|
74
|
-
this.db = await
|
|
75
|
+
this.db = await this.forceCreateDB(pgliteArgs);
|
|
75
76
|
await this.db.waitReady;
|
|
76
77
|
}
|
|
77
78
|
return this.db;
|
|
@@ -86,12 +87,35 @@ class PostgresServer {
|
|
|
86
87
|
const arrayBuff = await dump.arrayBuffer();
|
|
87
88
|
fs.writeFileSync(exportPath, new Uint8Array(arrayBuff));
|
|
88
89
|
}
|
|
89
|
-
|
|
90
|
+
async forceCreateDB(pgliteArgs) {
|
|
91
|
+
try {
|
|
92
|
+
const db = await pglite_1.PGlite.create(pgliteArgs);
|
|
93
|
+
return db;
|
|
94
|
+
}
|
|
95
|
+
catch (err) {
|
|
96
|
+
if (pgliteArgs.dataDir && (0, error_1.hasMessage)(err) && /Database already exists/.test(err.message)) {
|
|
97
|
+
fs.rmSync(pgliteArgs.dataDir, { force: true, recursive: true });
|
|
98
|
+
const db = await pglite_1.PGlite.create(pgliteArgs);
|
|
99
|
+
return db;
|
|
100
|
+
}
|
|
101
|
+
throw err;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
async stop() {
|
|
105
|
+
if (this.db) {
|
|
106
|
+
await this.db.close();
|
|
107
|
+
}
|
|
108
|
+
if (this.server) {
|
|
109
|
+
this.server.close();
|
|
110
|
+
}
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
113
|
+
constructor(args) {
|
|
90
114
|
this.db = undefined;
|
|
91
|
-
this.
|
|
92
|
-
this.
|
|
93
|
-
this.
|
|
94
|
-
this.
|
|
115
|
+
this.server = undefined;
|
|
116
|
+
this.dataDirectory = args.dataDirectory;
|
|
117
|
+
this.importPath = args.importPath;
|
|
118
|
+
this.debug = args.debug ? 5 : 0;
|
|
95
119
|
}
|
|
96
120
|
}
|
|
97
121
|
exports.PostgresServer = PostgresServer;
|
|
@@ -68,7 +68,11 @@ class DataConnectEmulator {
|
|
|
68
68
|
const postgresDumpPath = this.args.importPath
|
|
69
69
|
? path.join(this.args.importPath, "postgres.tar.gz")
|
|
70
70
|
: undefined;
|
|
71
|
-
this.postgresServer = new pgliteServer_1.PostgresServer(
|
|
71
|
+
this.postgresServer = new pgliteServer_1.PostgresServer({
|
|
72
|
+
dataDirectory,
|
|
73
|
+
importPath: postgresDumpPath,
|
|
74
|
+
debug: this.args.debug,
|
|
75
|
+
});
|
|
72
76
|
const server = await this.postgresServer.createPGServer(pgHost, pgPort);
|
|
73
77
|
const connectableHost = (0, utils_1.connectableHostname)(pgHost);
|
|
74
78
|
connStr = `postgres://${connectableHost}:${pgPort}/${dbId}?sslmode=disable`;
|
|
@@ -100,6 +104,9 @@ class DataConnectEmulator {
|
|
|
100
104
|
this.logger.logLabeled("INFO", "dataconnect", "Skipping cleanup of Data Connect emulator, as it was not started by this process.");
|
|
101
105
|
return;
|
|
102
106
|
}
|
|
107
|
+
if (this.postgresServer) {
|
|
108
|
+
await this.postgresServer.stop();
|
|
109
|
+
}
|
|
103
110
|
return (0, downloadableEmulators_1.stop)(types_1.Emulators.DATACONNECT);
|
|
104
111
|
}
|
|
105
112
|
getInfo() {
|
|
@@ -146,6 +153,11 @@ class DataConnectEmulator {
|
|
|
146
153
|
cmd.push("--watch");
|
|
147
154
|
}
|
|
148
155
|
const res = childProcess.spawnSync(commandInfo.binary, cmd, { encoding: "utf-8" });
|
|
156
|
+
if ((0, downloadableEmulators_1.isIncomaptibleArchError)(res.error)) {
|
|
157
|
+
throw new error_1.FirebaseError(`Unknown system error when running the Data Connect toolkit. ` +
|
|
158
|
+
`You may be able to fix this by installing Rosetta: ` +
|
|
159
|
+
`softwareupdate --install-rosetta`);
|
|
160
|
+
}
|
|
149
161
|
logger_1.logger.info(res.stderr);
|
|
150
162
|
if (res.error) {
|
|
151
163
|
throw new error_1.FirebaseError(`Error starting up Data Connect generate: ${res.error.message}`, {
|
|
@@ -161,6 +173,11 @@ class DataConnectEmulator {
|
|
|
161
173
|
const commandInfo = await (0, downloadableEmulators_1.downloadIfNecessary)(types_1.Emulators.DATACONNECT);
|
|
162
174
|
const cmd = ["--logtostderr", "-v=2", "build", `--config_dir=${args.configDir}`];
|
|
163
175
|
const res = childProcess.spawnSync(commandInfo.binary, cmd, { encoding: "utf-8" });
|
|
176
|
+
if ((0, downloadableEmulators_1.isIncomaptibleArchError)(res.error)) {
|
|
177
|
+
throw new error_1.FirebaseError(`Unkown system error when running the Data Connect toolkit. ` +
|
|
178
|
+
`You may be able to fix this by installing Rosetta: ` +
|
|
179
|
+
`softwareupdate --install-rosetta`);
|
|
180
|
+
}
|
|
164
181
|
if (res.error) {
|
|
165
182
|
throw new error_1.FirebaseError(`Error starting up Data Connect build: ${res.error.message}`, {
|
|
166
183
|
original: res.error,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.start = exports.downloadIfNecessary = exports.stop = exports.getPID = exports.get = exports.getDownloadDetails = exports.requiresJava = exports.handleEmulatorProcessError = exports._getCommand = exports.getLogFileName = exports.DownloadDetails = void 0;
|
|
3
|
+
exports.isIncomaptibleArchError = exports.start = exports.downloadIfNecessary = exports.stop = exports.getPID = exports.get = exports.getDownloadDetails = exports.requiresJava = exports.handleEmulatorProcessError = exports._getCommand = exports.getLogFileName = exports.DownloadDetails = void 0;
|
|
4
4
|
const lsofi = require("lsofi");
|
|
5
5
|
const types_1 = require("./types");
|
|
6
6
|
const constants_1 = require("./constants");
|
|
@@ -48,20 +48,20 @@ const EMULATOR_UPDATE_DETAILS = {
|
|
|
48
48
|
},
|
|
49
49
|
dataconnect: process.platform === "darwin"
|
|
50
50
|
? {
|
|
51
|
-
version: "1.7.
|
|
52
|
-
expectedSize:
|
|
53
|
-
expectedChecksum: "
|
|
51
|
+
version: "1.7.5",
|
|
52
|
+
expectedSize: 25281280,
|
|
53
|
+
expectedChecksum: "85d0de96b5c08b553fd8506a2bc381bb",
|
|
54
54
|
}
|
|
55
55
|
: process.platform === "win32"
|
|
56
56
|
? {
|
|
57
|
-
version: "1.7.
|
|
58
|
-
expectedSize:
|
|
59
|
-
expectedChecksum: "
|
|
57
|
+
version: "1.7.5",
|
|
58
|
+
expectedSize: 25711616,
|
|
59
|
+
expectedChecksum: "c99d67fa8e74d41760b96122b055b8e2",
|
|
60
60
|
}
|
|
61
61
|
: {
|
|
62
|
-
version: "1.7.
|
|
63
|
-
expectedSize:
|
|
64
|
-
expectedChecksum: "
|
|
62
|
+
version: "1.7.5",
|
|
63
|
+
expectedSize: 25190552,
|
|
64
|
+
expectedChecksum: "61d966b781e6f2887f8b38ec271b54e2",
|
|
65
65
|
},
|
|
66
66
|
};
|
|
67
67
|
exports.DownloadDetails = {
|
|
@@ -354,6 +354,11 @@ async function _runBinary(emulator, command, extraEnv) {
|
|
|
354
354
|
if (e.code === "EACCES") {
|
|
355
355
|
logger.logLabeled("WARN", emulator.name, `Could not spawn child process for emulator, check that java is installed and on your $PATH.`);
|
|
356
356
|
}
|
|
357
|
+
else if (isIncomaptibleArchError(e)) {
|
|
358
|
+
logger.logLabeled("WARN", emulator.name, `Unknown system error when starting emulator binary. ` +
|
|
359
|
+
`You may be able to fix this by installing Rosetta: ` +
|
|
360
|
+
`softwareupdate --install-rosetta`);
|
|
361
|
+
}
|
|
357
362
|
_fatal(emulator.name, e);
|
|
358
363
|
}
|
|
359
364
|
const description = constants_1.Constants.description(emulator.name);
|
|
@@ -467,3 +472,9 @@ async function start(targetName, args, extraEnv = {}) {
|
|
|
467
472
|
return _runBinary(emulator, command, extraEnv);
|
|
468
473
|
}
|
|
469
474
|
exports.start = start;
|
|
475
|
+
function isIncomaptibleArchError(err) {
|
|
476
|
+
return ((0, error_1.hasMessage)(err) &&
|
|
477
|
+
/Unknown system error/.test(err.message ?? "") &&
|
|
478
|
+
process.platform === "darwin");
|
|
479
|
+
}
|
|
480
|
+
exports.isIncomaptibleArchError = isIncomaptibleArchError;
|
|
@@ -140,6 +140,7 @@ class EventarcEmulator {
|
|
|
140
140
|
.request({
|
|
141
141
|
method: "POST",
|
|
142
142
|
path: `/functions/projects/${trigger.projectId}/triggers/${trigger.triggerName}`,
|
|
143
|
+
headers: { "Content-Type": "application/json" },
|
|
143
144
|
body: JSON.stringify(event),
|
|
144
145
|
responseType: "stream",
|
|
145
146
|
resolveOnHTTPError: true,
|
|
@@ -24,10 +24,10 @@ exports.AdditionalInitFns = {
|
|
|
24
24
|
const backendRoot = (0, path_1.join)(cwd, backendRelativeDir);
|
|
25
25
|
try {
|
|
26
26
|
const startCommand = await (0, developmentServer_1.detectStartCommand)(backendRoot);
|
|
27
|
-
additionalConfigs.set("
|
|
27
|
+
additionalConfigs.set("startCommand", startCommand);
|
|
28
28
|
}
|
|
29
29
|
catch (e) {
|
|
30
|
-
logger.log("WARN", "Failed to auto-detect your project's start command. Consider manually setting the start command by setting `firebase.json#emulators.apphosting.
|
|
30
|
+
logger.log("WARN", "Failed to auto-detect your project's start command. Consider manually setting the start command by setting `firebase.json#emulators.apphosting.startCommand`");
|
|
31
31
|
}
|
|
32
32
|
try {
|
|
33
33
|
const projectRoot = (0, detectProjectRoot_1.detectProjectRoot)({}) ?? backendRoot;
|
|
@@ -38,6 +38,21 @@ exports.AdditionalInitFns = {
|
|
|
38
38
|
}
|
|
39
39
|
return mapToObject(additionalConfigs);
|
|
40
40
|
},
|
|
41
|
+
[types_1.Emulators.DATACONNECT]: async (config) => {
|
|
42
|
+
const additionalConfig = {};
|
|
43
|
+
const defaultDataConnectDir = config.get("dataconnect.source", "dataconnect");
|
|
44
|
+
const defaultDataDir = config.get("emulators.dataconnect.dataDir", `${defaultDataConnectDir}/.dataconnect/pgliteData`);
|
|
45
|
+
if (await (0, prompt_1.promptOnce)({
|
|
46
|
+
name: "dataDir",
|
|
47
|
+
type: "confirm",
|
|
48
|
+
message: "Do you want to persist Postgres data from the Data Connect emulator between runs? " +
|
|
49
|
+
`Data will be saved to ${defaultDataDir}. ` +
|
|
50
|
+
`You can change this directory by editing 'firebase.json#emulators.dataconnect.dataDir'.`,
|
|
51
|
+
})) {
|
|
52
|
+
additionalConfig["dataDir"] = defaultDataDir;
|
|
53
|
+
}
|
|
54
|
+
return additionalConfig;
|
|
55
|
+
},
|
|
41
56
|
};
|
|
42
57
|
function mapToObject(map) {
|
|
43
58
|
const newObject = {};
|
package/lib/error.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isBillingError = exports.getError = exports.getErrStatus = exports.getErrMsg = exports.FirebaseError = void 0;
|
|
3
|
+
exports.hasMessage = exports.isBillingError = exports.getError = exports.getErrStatus = exports.isObject = exports.getErrStack = exports.getErrMsg = exports.FirebaseError = void 0;
|
|
4
4
|
const lodash_1 = require("lodash");
|
|
5
5
|
const DEFAULT_CHILDREN = [];
|
|
6
6
|
const DEFAULT_EXIT = 1;
|
|
@@ -31,9 +31,17 @@ function getErrMsg(err, defaultMsg) {
|
|
|
31
31
|
return JSON.stringify(err);
|
|
32
32
|
}
|
|
33
33
|
exports.getErrMsg = getErrMsg;
|
|
34
|
+
function getErrStack(err) {
|
|
35
|
+
if (err instanceof Error) {
|
|
36
|
+
return err.stack || err.message;
|
|
37
|
+
}
|
|
38
|
+
return getErrMsg(err);
|
|
39
|
+
}
|
|
40
|
+
exports.getErrStack = getErrStack;
|
|
34
41
|
function isObject(value) {
|
|
35
42
|
return typeof value === "object" && value !== null;
|
|
36
43
|
}
|
|
44
|
+
exports.isObject = isObject;
|
|
37
45
|
function getErrStatus(err, defaultStatus) {
|
|
38
46
|
if (isObject(err) && err.status && typeof err.status === "number") {
|
|
39
47
|
return err.status;
|
|
@@ -55,3 +63,5 @@ function isBillingError(e) {
|
|
|
55
63
|
});
|
|
56
64
|
}
|
|
57
65
|
exports.isBillingError = isBillingError;
|
|
66
|
+
const hasMessage = (e) => !!e?.message;
|
|
67
|
+
exports.hasMessage = hasMessage;
|
package/lib/experiments.js
CHANGED
|
@@ -106,12 +106,6 @@ exports.ALL_EXPERIMENTS = experiments({
|
|
|
106
106
|
default: true,
|
|
107
107
|
public: false,
|
|
108
108
|
},
|
|
109
|
-
fdccompatiblemode: {
|
|
110
|
-
shortDescription: "Enable Data Connect schema migrations in Compatible Mode",
|
|
111
|
-
fullDescription: "Enable Data Connect schema migrations in Compatible Mode",
|
|
112
|
-
default: true,
|
|
113
|
-
public: false,
|
|
114
|
-
},
|
|
115
109
|
});
|
|
116
110
|
function isValidExperiment(name) {
|
|
117
111
|
return Object.keys(exports.ALL_EXPERIMENTS).includes(name);
|
|
@@ -38,9 +38,9 @@ function fixLifecycleEvents(lifecycleEvents) {
|
|
|
38
38
|
stageUnspecified: "STAGE_UNSPECIFIED",
|
|
39
39
|
};
|
|
40
40
|
const arrayLifecycle = [];
|
|
41
|
-
if ((0,
|
|
41
|
+
if ((0, error_1.isObject)(lifecycleEvents)) {
|
|
42
42
|
for (const [key, val] of Object.entries(lifecycleEvents)) {
|
|
43
|
-
if ((0,
|
|
43
|
+
if ((0, error_1.isObject)(val) &&
|
|
44
44
|
typeof val.function === "string" &&
|
|
45
45
|
typeof val.processingMessage === "string") {
|
|
46
46
|
arrayLifecycle.push({
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.writeSDK = exports.TYPESCRIPT_VERSION = exports.FIREBASE_FUNCTIONS_VERSION = exports.SDK_GENERATION_VERSION = void 0;
|
|
4
4
|
const path = require("path");
|
|
5
|
-
const child_process_1 = require("child_process");
|
|
6
5
|
const marked_terminal_1 = require("marked-terminal");
|
|
7
6
|
const marked_1 = require("marked");
|
|
7
|
+
const error_1 = require("../../error");
|
|
8
8
|
const types_1 = require("../types");
|
|
9
9
|
const prompt_1 = require("../../prompt");
|
|
10
10
|
const secretsUtils = require("../secretsUtils");
|
|
@@ -12,7 +12,8 @@ const utils_1 = require("../../utils");
|
|
|
12
12
|
const common_1 = require("./common");
|
|
13
13
|
const askUserForEventsConfig_1 = require("../askUserForEventsConfig");
|
|
14
14
|
const extensionsHelper_1 = require("../extensionsHelper");
|
|
15
|
-
const
|
|
15
|
+
const error_2 = require("../../error");
|
|
16
|
+
const spawn_1 = require("../../init/spawn");
|
|
16
17
|
marked_1.marked.use((0, marked_terminal_1.markedTerminal)());
|
|
17
18
|
exports.SDK_GENERATION_VERSION = "1.0.0";
|
|
18
19
|
exports.FIREBASE_FUNCTIONS_VERSION = ">=5.1.0";
|
|
@@ -91,8 +92,8 @@ function addPeerDependency(pkgJson, dependency, version) {
|
|
|
91
92
|
if (!pkgJson.peerDependencies) {
|
|
92
93
|
pkgJson.peerDependencies = {};
|
|
93
94
|
}
|
|
94
|
-
if (!(0,
|
|
95
|
-
throw new
|
|
95
|
+
if (!(0, error_1.isObject)(pkgJson.peerDependencies)) {
|
|
96
|
+
throw new error_2.FirebaseError("Internal error generating peer dependencies.");
|
|
96
97
|
}
|
|
97
98
|
pkgJson.peerDependencies[dependency] = version;
|
|
98
99
|
}
|
|
@@ -117,7 +118,7 @@ async function writeSDK(extensionRef, localPath, spec, options) {
|
|
|
117
118
|
}
|
|
118
119
|
}
|
|
119
120
|
if (!dirPath) {
|
|
120
|
-
throw new
|
|
121
|
+
throw new error_2.FirebaseError("Invalid extension definition. Must have either extensionRef or localPath");
|
|
121
122
|
}
|
|
122
123
|
const packageName = makePackageName(extensionRef, spec.name);
|
|
123
124
|
const pkgJson = {
|
|
@@ -291,7 +292,7 @@ async function writeSDK(extensionRef, localPath, spec, options) {
|
|
|
291
292
|
sdkLines.push(` ${sysParam.param}${opt}: string;`);
|
|
292
293
|
break;
|
|
293
294
|
default:
|
|
294
|
-
throw new
|
|
295
|
+
throw new error_2.FirebaseError(`Error: Unknown systemParam type: ${sysParam.type || "undefined"}.`);
|
|
295
296
|
}
|
|
296
297
|
sdkLines.push("");
|
|
297
298
|
}
|
|
@@ -346,19 +347,19 @@ async function writeSDK(extensionRef, localPath, spec, options) {
|
|
|
346
347
|
await (0, common_1.writeFile)(`${dirPath}/tsconfig.json`, JSON.stringify(tsconfigJson, null, 2), options);
|
|
347
348
|
(0, utils_1.logLabeledBullet)("extensions", `running 'npm --prefix ${shortDirPath} install'`);
|
|
348
349
|
try {
|
|
349
|
-
(0,
|
|
350
|
+
await (0, spawn_1.spawnWithOutput)("npm", ["--prefix", dirPath, "install"]);
|
|
350
351
|
}
|
|
351
352
|
catch (err) {
|
|
352
|
-
const errMsg = (0,
|
|
353
|
-
throw new
|
|
353
|
+
const errMsg = (0, error_2.getErrMsg)(err, "unknown error");
|
|
354
|
+
throw new error_2.FirebaseError(`Error during npm install in ${shortDirPath}: ${errMsg}`);
|
|
354
355
|
}
|
|
355
356
|
(0, utils_1.logLabeledBullet)("extensions", `running 'npm --prefix ${shortDirPath} run build'`);
|
|
356
357
|
try {
|
|
357
|
-
(0,
|
|
358
|
+
await (0, spawn_1.spawnWithOutput)("npm", ["--prefix", dirPath, "run", "build"]);
|
|
358
359
|
}
|
|
359
360
|
catch (err) {
|
|
360
|
-
const errMsg = (0,
|
|
361
|
-
throw new
|
|
361
|
+
const errMsg = (0, error_2.getErrMsg)(err, "unknown error");
|
|
362
|
+
throw new error_2.FirebaseError(`Error during npm run build in ${shortDirPath}: ${errMsg}`);
|
|
362
363
|
}
|
|
363
364
|
const codebaseDir = (0, common_1.getCodebaseDir)(options);
|
|
364
365
|
const shortCodebaseDir = codebaseDir.replace(process.cwd(), ".");
|
|
@@ -371,11 +372,11 @@ async function writeSDK(extensionRef, localPath, spec, options) {
|
|
|
371
372
|
})) {
|
|
372
373
|
(0, utils_1.logLabeledBullet)("extensions", `running 'npm --prefix ${shortCodebaseDir} install --save ${shortDirPath}'`);
|
|
373
374
|
try {
|
|
374
|
-
(0,
|
|
375
|
+
await (0, spawn_1.spawnWithOutput)("npm", ["--prefix", codebaseDir, "install", "--save", dirPath]);
|
|
375
376
|
}
|
|
376
377
|
catch (err) {
|
|
377
|
-
const errMsg = (0,
|
|
378
|
-
throw new
|
|
378
|
+
const errMsg = (0, error_2.getErrMsg)(err, "unknown error");
|
|
379
|
+
throw new error_2.FirebaseError(`Error during npm install in ${codebaseDir}: ${errMsg}`);
|
|
379
380
|
}
|
|
380
381
|
}
|
|
381
382
|
else {
|
package/lib/extensions/types.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isExtensionSpec = exports.isResource = exports.isParam = exports.
|
|
3
|
+
exports.isExtensionSpec = exports.isResource = exports.isParam = exports.ParamType = exports.FUNCTIONS_V2_RESOURCE_TYPE = exports.FUNCTIONS_RESOURCE_TYPE = exports.isExtensionInstance = exports.Visibility = exports.RegistryLaunchStage = void 0;
|
|
4
|
+
const error_1 = require("../error");
|
|
4
5
|
var RegistryLaunchStage;
|
|
5
6
|
(function (RegistryLaunchStage) {
|
|
6
7
|
RegistryLaunchStage["EXPERIMENTAL"] = "EXPERIMENTAL";
|
|
@@ -23,7 +24,7 @@ const extensionInstanceState = [
|
|
|
23
24
|
"PAUSED",
|
|
24
25
|
];
|
|
25
26
|
const isExtensionInstance = (value) => {
|
|
26
|
-
if (!isObject(value) || typeof value.name !== "string") {
|
|
27
|
+
if (!(0, error_1.isObject)(value) || typeof value.name !== "string") {
|
|
27
28
|
return false;
|
|
28
29
|
}
|
|
29
30
|
return true;
|
|
@@ -40,20 +41,16 @@ var ParamType;
|
|
|
40
41
|
ParamType["SELECT_RESOURCE"] = "SELECT_RESOURCE";
|
|
41
42
|
ParamType["SECRET"] = "SECRET";
|
|
42
43
|
})(ParamType = exports.ParamType || (exports.ParamType = {}));
|
|
43
|
-
function isObject(value) {
|
|
44
|
-
return typeof value === "object" && value !== null;
|
|
45
|
-
}
|
|
46
|
-
exports.isObject = isObject;
|
|
47
44
|
const isParam = (param) => {
|
|
48
|
-
return (isObject(param) && typeof param["param"] === "string" && typeof param["label"] === "string");
|
|
45
|
+
return ((0, error_1.isObject)(param) && typeof param["param"] === "string" && typeof param["label"] === "string");
|
|
49
46
|
};
|
|
50
47
|
exports.isParam = isParam;
|
|
51
48
|
const isResource = (res) => {
|
|
52
|
-
return isObject(res) && typeof res["name"] === "string";
|
|
49
|
+
return (0, error_1.isObject)(res) && typeof res["name"] === "string";
|
|
53
50
|
};
|
|
54
51
|
exports.isResource = isResource;
|
|
55
52
|
const isExtensionSpec = (spec) => {
|
|
56
|
-
if (!isObject(spec) || typeof spec.name !== "string" || typeof spec.version !== "string") {
|
|
53
|
+
if (!(0, error_1.isObject)(spec) || typeof spec.name !== "string" || typeof spec.version !== "string") {
|
|
57
54
|
return false;
|
|
58
55
|
}
|
|
59
56
|
if (spec.resources && Array.isArray(spec.resources)) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.CONVERTABLE_EVENTS = exports.FIREALERTS_EVENT = exports.FIRESTORE_EVENTS = exports.TEST_LAB_EVENT = exports.REMOTE_CONFIG_EVENT = exports.DATABASE_EVENTS = exports.FIREBASE_ALERTS_PUBLISH_EVENT = exports.STORAGE_EVENTS = exports.PUBSUB_PUBLISH_EVENT = void 0;
|
|
4
4
|
exports.PUBSUB_PUBLISH_EVENT = "google.cloud.pubsub.topic.v1.messagePublished";
|
|
5
5
|
exports.STORAGE_EVENTS = [
|
|
6
6
|
"google.cloud.storage.object.v1.finalized",
|
|
@@ -28,5 +28,9 @@ exports.FIRESTORE_EVENTS = [
|
|
|
28
28
|
"google.cloud.firestore.document.v1.deleted.withAuthContext",
|
|
29
29
|
];
|
|
30
30
|
exports.FIREALERTS_EVENT = "google.firebase.firebasealerts.alerts.v1.published";
|
|
31
|
-
exports.
|
|
32
|
-
|
|
31
|
+
exports.CONVERTABLE_EVENTS = {
|
|
32
|
+
"google.cloud.firestore.document.v1.created": "google.cloud.firestore.document.v1.created.withAuthContext",
|
|
33
|
+
"google.cloud.firestore.document.v1.updated": "google.cloud.firestore.document.v1.updated.withAuthContext",
|
|
34
|
+
"google.cloud.firestore.document.v1.deleted": "google.cloud.firestore.document.v1.deleted.withAuthContext",
|
|
35
|
+
"google.cloud.firestore.document.v1.written": "google.cloud.firestore.document.v1.written.withAuthContext",
|
|
36
|
+
};
|
|
@@ -272,6 +272,9 @@ function functionFromEndpoint(endpoint) {
|
|
|
272
272
|
}
|
|
273
273
|
else if (backend.isCallableTriggered(endpoint)) {
|
|
274
274
|
gcfFunction.labels = { ...gcfFunction.labels, "deployment-callable": "true" };
|
|
275
|
+
if (endpoint.callableTrigger.genkitAction) {
|
|
276
|
+
gcfFunction.labels["genkit-action"] = endpoint.callableTrigger.genkitAction;
|
|
277
|
+
}
|
|
275
278
|
}
|
|
276
279
|
else if (backend.isBlockingTriggered(endpoint)) {
|
|
277
280
|
gcfFunction.labels = {
|
|
@@ -315,6 +318,9 @@ function endpointFromFunction(gcfFunction) {
|
|
|
315
318
|
trigger = {
|
|
316
319
|
callableTrigger: {},
|
|
317
320
|
};
|
|
321
|
+
if (gcfFunction.labels["genkit-action"]) {
|
|
322
|
+
trigger.callableTrigger.genkitAction = gcfFunction.labels["genkit-action"];
|
|
323
|
+
}
|
|
318
324
|
}
|
|
319
325
|
else if (gcfFunction.labels?.[constants_1.BLOCKING_LABEL]) {
|
|
320
326
|
trigger = {
|
|
@@ -3,12 +3,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.actuate = exports.doSetup = void 0;
|
|
4
4
|
const path_1 = require("path");
|
|
5
5
|
const clc = require("colorette");
|
|
6
|
+
const fs = require("fs-extra");
|
|
6
7
|
const prompt_1 = require("../../../prompt");
|
|
7
8
|
const provisionCloudSql_1 = require("../../../dataconnect/provisionCloudSql");
|
|
8
9
|
const freeTrial_1 = require("../../../dataconnect/freeTrial");
|
|
9
10
|
const cloudsql = require("../../../gcp/cloudsql/cloudsqladmin");
|
|
10
11
|
const ensureApis_1 = require("../../../dataconnect/ensureApis");
|
|
11
|
-
const experiments = require("../../../experiments");
|
|
12
12
|
const client_1 = require("../../../dataconnect/client");
|
|
13
13
|
const types_1 = require("../../../dataconnect/types");
|
|
14
14
|
const names_1 = require("../../../dataconnect/names");
|
|
@@ -19,7 +19,6 @@ const cloudbilling_1 = require("../../../gcp/cloudbilling");
|
|
|
19
19
|
const sdk = require("./sdk");
|
|
20
20
|
const fileUtils_1 = require("../../../dataconnect/fileUtils");
|
|
21
21
|
const DATACONNECT_YAML_TEMPLATE = (0, templates_1.readTemplateSync)("init/dataconnect/dataconnect.yaml");
|
|
22
|
-
const DATACONNECT_YAML_COMPAT_EXPERIMENT_TEMPLATE = (0, templates_1.readTemplateSync)("init/dataconnect/dataconnect-fdccompatiblemode.yaml");
|
|
23
22
|
const CONNECTOR_YAML_TEMPLATE = (0, templates_1.readTemplateSync)("init/dataconnect/connector.yaml");
|
|
24
23
|
const SCHEMA_TEMPLATE = (0, templates_1.readTemplateSync)("init/dataconnect/schema.gql");
|
|
25
24
|
const QUERIES_TEMPLATE = (0, templates_1.readTemplateSync)("init/dataconnect/queries.gql");
|
|
@@ -50,6 +49,9 @@ async function doSetup(setup, config) {
|
|
|
50
49
|
isBillingEnabled ? await (0, ensureApis_1.ensureApis)(setup.projectId) : await (0, ensureApis_1.ensureSparkApis)(setup.projectId);
|
|
51
50
|
}
|
|
52
51
|
const info = await askQuestions(setup, isBillingEnabled);
|
|
52
|
+
const dir = config.get("dataconnect.source", "dataconnect");
|
|
53
|
+
const dataDir = config.get("emulators.dataconnect.dataDir", `${dir}/.dataconnect/pgliteData`);
|
|
54
|
+
config.set("emulators.dataconnect.dataDir", dataDir);
|
|
53
55
|
await actuate(setup, config, info);
|
|
54
56
|
const cwdPlatformGuess = await (0, fileUtils_1.getPlatformFromFolder)(process.cwd());
|
|
55
57
|
if (cwdPlatformGuess !== types_1.Platform.NONE) {
|
|
@@ -139,6 +141,9 @@ async function writeFiles(config, info) {
|
|
|
139
141
|
await config.askWriteProjectFile((0, path_1.join)(dir, "schema", f.path), f.content);
|
|
140
142
|
}
|
|
141
143
|
}
|
|
144
|
+
else {
|
|
145
|
+
fs.ensureFileSync((0, path_1.join)(dir, "schema", "schema.gql"));
|
|
146
|
+
}
|
|
142
147
|
for (const c of info.connectors) {
|
|
143
148
|
await writeConnectorFiles(config, c);
|
|
144
149
|
}
|
|
@@ -159,9 +164,7 @@ function subDataconnectYamlValues(replacementValues) {
|
|
|
159
164
|
connectorDirs: "__connectorDirs__",
|
|
160
165
|
locationId: "__location__",
|
|
161
166
|
};
|
|
162
|
-
let replaced =
|
|
163
|
-
? DATACONNECT_YAML_COMPAT_EXPERIMENT_TEMPLATE
|
|
164
|
-
: DATACONNECT_YAML_TEMPLATE;
|
|
167
|
+
let replaced = DATACONNECT_YAML_TEMPLATE;
|
|
165
168
|
for (const [k, v] of Object.entries(replacementValues)) {
|
|
166
169
|
replaced = replaced.replace(replacements[k], JSON.stringify(v));
|
|
167
170
|
}
|
|
@@ -48,7 +48,7 @@ async function doSetup(setup, config) {
|
|
|
48
48
|
}
|
|
49
49
|
const additionalInitFn = initEmulators_1.AdditionalInitFns[selected];
|
|
50
50
|
if (additionalInitFn) {
|
|
51
|
-
const additionalOptions = await additionalInitFn();
|
|
51
|
+
const additionalOptions = await additionalInitFn(config);
|
|
52
52
|
if (additionalOptions) {
|
|
53
53
|
setup.config.emulators[selected] = {
|
|
54
54
|
...setup.config.emulators[selected],
|
|
@@ -6,7 +6,6 @@ const inquirer = require("inquirer");
|
|
|
6
6
|
const path = require("path");
|
|
7
7
|
const semver = require("semver");
|
|
8
8
|
const clc = require("colorette");
|
|
9
|
-
const child_process_1 = require("child_process");
|
|
10
9
|
const functions_1 = require("../functions");
|
|
11
10
|
const prompt_1 = require("../../../prompt");
|
|
12
11
|
const spawn_1 = require("../../spawn");
|
|
@@ -15,7 +14,6 @@ const ensureApiEnabled_1 = require("../../../ensureApiEnabled");
|
|
|
15
14
|
const logger_1 = require("../../../logger");
|
|
16
15
|
const error_1 = require("../../../error");
|
|
17
16
|
const utils_1 = require("../../../utils");
|
|
18
|
-
const types_1 = require("../../../extensions/types");
|
|
19
17
|
async function getGenkitVersion() {
|
|
20
18
|
let genkitVersion;
|
|
21
19
|
let templateVersion = "0.9.0";
|
|
@@ -26,7 +24,17 @@ async function getGenkitVersion() {
|
|
|
26
24
|
genkitVersion = process.env.GENKIT_DEV_VERSION;
|
|
27
25
|
}
|
|
28
26
|
else {
|
|
29
|
-
|
|
27
|
+
try {
|
|
28
|
+
genkitVersion = await (0, spawn_1.spawnWithOutput)("npm", ["view", "genkit", "version"]);
|
|
29
|
+
}
|
|
30
|
+
catch (err) {
|
|
31
|
+
throw new error_1.FirebaseError("Unable to determine which genkit version to install.\n" +
|
|
32
|
+
`npm Error: ${(0, error_1.getErrMsg)(err)}\n\n` +
|
|
33
|
+
"For a possible workaround run\n npm view genkit version\n" +
|
|
34
|
+
"and then set an environment variable:\n" +
|
|
35
|
+
" export GENKIT_DEV_VERSION=<output from previous command>\n" +
|
|
36
|
+
"and run `firebase init genkit` again");
|
|
37
|
+
}
|
|
30
38
|
}
|
|
31
39
|
if (!genkitVersion) {
|
|
32
40
|
throw new error_1.FirebaseError("Unable to determine genkit version to install");
|
|
@@ -234,7 +242,7 @@ async function genkitSetup(options, genkitInfo, projectDir) {
|
|
|
234
242
|
}
|
|
235
243
|
exports.genkitSetup = genkitSetup;
|
|
236
244
|
const isTsConfig = (value) => {
|
|
237
|
-
if (!(0,
|
|
245
|
+
if (!(0, error_1.isObject)(value) || (value.compilerOptions && !(0, error_1.isObject)(value.compilerOptions))) {
|
|
238
246
|
return false;
|
|
239
247
|
}
|
|
240
248
|
return true;
|
|
@@ -351,7 +359,7 @@ function generateSampleFile(modelPlugin, configPlugins, projectDir, templateVers
|
|
|
351
359
|
}
|
|
352
360
|
}
|
|
353
361
|
const isPackageJson = (value) => {
|
|
354
|
-
if (!(0,
|
|
362
|
+
if (!(0, error_1.isObject)(value) || (value.scripts && !(0, error_1.isObject)(value.scripts))) {
|
|
355
363
|
return false;
|
|
356
364
|
}
|
|
357
365
|
return true;
|