firebase-tools-with-isolate 13.26.0 → 13.29.1-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.
Files changed (61) hide show
  1. package/lib/appdistribution/client.js +2 -1
  2. package/lib/appdistribution/options-parser-util.js +5 -5
  3. package/lib/apphosting/config.js +86 -1
  4. package/lib/apphosting/secrets/index.js +1 -39
  5. package/lib/apphosting/yaml.js +3 -0
  6. package/lib/auth.js +13 -3
  7. package/lib/bin/firebase.js +4 -3
  8. package/lib/commands/appdistribution-distribute.js +55 -31
  9. package/lib/commands/apphosting-config-export.js +3 -26
  10. package/lib/commands/firestore-indexes-list.js +4 -2
  11. package/lib/commands/index.js +4 -6
  12. package/lib/dataconnect/fileUtils.js +3 -0
  13. package/lib/dataconnect/schemaMigration.js +10 -16
  14. package/lib/dataconnect/types.js +1 -1
  15. package/lib/deploy/extensions/tasks.js +2 -2
  16. package/lib/deploy/functions/backend.js +1 -3
  17. package/lib/deploy/functions/build.js +3 -1
  18. package/lib/deploy/functions/prepare.js +23 -20
  19. package/lib/deploy/functions/prepareFunctionsUpload.js +19 -16
  20. package/lib/deploy/functions/release/fabricator.js +1 -1
  21. package/lib/deploy/functions/release/planner.js +4 -4
  22. package/lib/deploy/functions/runtimes/discovery/v1alpha1.js +4 -0
  23. package/lib/deploy/functions/runtimes/supported/types.js +1 -1
  24. package/lib/emulator/apphosting/developmentServer.js +32 -0
  25. package/lib/emulator/apphosting/index.js +5 -4
  26. package/lib/emulator/apphosting/serve.js +7 -7
  27. package/lib/emulator/auth/operations.js +8 -5
  28. package/lib/emulator/commandUtils.js +2 -1
  29. package/lib/emulator/controller.js +46 -18
  30. package/lib/emulator/dataconnect/pgliteServer.js +76 -19
  31. package/lib/emulator/dataconnectEmulator.js +43 -2
  32. package/lib/emulator/downloadableEmulators.js +21 -10
  33. package/lib/emulator/eventarcEmulator.js +1 -0
  34. package/lib/emulator/hub.js +16 -0
  35. package/lib/emulator/hubExport.js +23 -0
  36. package/lib/emulator/initEmulators.js +63 -0
  37. package/lib/emulator/types.js +2 -2
  38. package/lib/error.js +11 -1
  39. package/lib/experiments.js +0 -6
  40. package/lib/extensions/localHelper.js +2 -2
  41. package/lib/extensions/runtimes/node.js +16 -15
  42. package/lib/extensions/types.js +6 -9
  43. package/lib/functions/events/v2.js +7 -3
  44. package/lib/gcp/cloudfunctionsv2.js +7 -0
  45. package/lib/init/features/dataconnect/index.js +8 -5
  46. package/lib/init/features/emulators.js +11 -0
  47. package/lib/init/features/genkit/index.js +13 -5
  48. package/lib/init/spawn.js +37 -7
  49. package/lib/management/projects.js +23 -1
  50. package/lib/requireAuth.js +2 -1
  51. package/lib/utils.js +16 -1
  52. package/package.json +7 -3
  53. package/schema/firebase-config.json +6 -0
  54. package/templates/init/dataconnect/dataconnect.yaml +1 -0
  55. package/templates/init/functions/javascript/package.lint.json +1 -1
  56. package/templates/init/functions/javascript/package.nolint.json +1 -1
  57. package/templates/init/functions/typescript/package.lint.json +1 -1
  58. package/templates/init/functions/typescript/package.nolint.json +1 -1
  59. package/templates/init/functions/typescript/tsconfig.json +3 -1
  60. package/lib/emulator/apphosting/utils.js +0 -18
  61. package/templates/init/dataconnect/dataconnect-fdccompatiblemode.yaml +0 -12
@@ -2,8 +2,10 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.DataConnectEmulatorClient = exports.DataConnectEmulator = exports.dataConnectEmulatorEvents = void 0;
4
4
  const childProcess = require("child_process");
5
+ const pg = require("pg");
5
6
  const events_1 = require("events");
6
7
  const clc = require("colorette");
8
+ const path = require("path");
7
9
  const api_1 = require("../api");
8
10
  const constants_1 = require("./constants");
9
11
  const downloadableEmulators_1 = require("./downloadableEmulators");
@@ -62,8 +64,16 @@ class DataConnectEmulator {
62
64
  this.logger.logLabeled("INFO", "dataconnect", `FIREBASE_DATACONNECT_POSTGRESQL_STRING is set to ${clc.bold(connStr)} - using that instead of starting a new database`);
63
65
  }
64
66
  else if (pgHost && pgPort) {
65
- const pgServer = new pgliteServer_1.PostgresServer(dbId, "postgres");
66
- const server = await pgServer.createPGServer(pgHost, pgPort);
67
+ const dataDirectory = this.args.config.get("emulators.dataconnect.dataDir");
68
+ const postgresDumpPath = this.args.importPath
69
+ ? path.join(this.args.importPath, "postgres.tar.gz")
70
+ : undefined;
71
+ this.postgresServer = new pgliteServer_1.PostgresServer({
72
+ dataDirectory,
73
+ importPath: postgresDumpPath,
74
+ debug: this.args.debug,
75
+ });
76
+ const server = await this.postgresServer.createPGServer(pgHost, pgPort);
67
77
  const connectableHost = (0, utils_1.connectableHostname)(pgHost);
68
78
  connStr = `postgres://${connectableHost}:${pgPort}/${dbId}?sslmode=disable`;
69
79
  server.on("error", (err) => {
@@ -94,6 +104,9 @@ class DataConnectEmulator {
94
104
  this.logger.logLabeled("INFO", "dataconnect", "Skipping cleanup of Data Connect emulator, as it was not started by this process.");
95
105
  return;
96
106
  }
107
+ if (this.postgresServer) {
108
+ await this.postgresServer.stop();
109
+ }
97
110
  return (0, downloadableEmulators_1.stop)(types_1.Emulators.DATACONNECT);
98
111
  }
99
112
  getInfo() {
@@ -109,6 +122,24 @@ class DataConnectEmulator {
109
122
  getName() {
110
123
  return types_1.Emulators.DATACONNECT;
111
124
  }
125
+ async clearData() {
126
+ if (this.postgresServer) {
127
+ await this.postgresServer.clearDb();
128
+ }
129
+ else {
130
+ const conn = new pg.Client((0, api_1.dataConnectLocalConnString)());
131
+ await conn.query(pgliteServer_1.TRUNCATE_TABLES_SQL);
132
+ await conn.end();
133
+ }
134
+ }
135
+ async exportData(exportPath) {
136
+ if (this.postgresServer) {
137
+ await this.postgresServer.exportData(path.join(exportPath, "postgres.tar.gz"));
138
+ }
139
+ else {
140
+ throw new error_1.FirebaseError("The Data Connect emulator is currently connected to a separate Postgres instance. Export is not supported.");
141
+ }
142
+ }
112
143
  static async generate(args) {
113
144
  const commandInfo = await (0, downloadableEmulators_1.downloadIfNecessary)(types_1.Emulators.DATACONNECT);
114
145
  const cmd = [
@@ -122,6 +153,11 @@ class DataConnectEmulator {
122
153
  cmd.push("--watch");
123
154
  }
124
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
+ }
125
161
  logger_1.logger.info(res.stderr);
126
162
  if (res.error) {
127
163
  throw new error_1.FirebaseError(`Error starting up Data Connect generate: ${res.error.message}`, {
@@ -137,6 +173,11 @@ class DataConnectEmulator {
137
173
  const commandInfo = await (0, downloadableEmulators_1.downloadIfNecessary)(types_1.Emulators.DATACONNECT);
138
174
  const cmd = ["--logtostderr", "-v=2", "build", `--config_dir=${args.configDir}`];
139
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
+ }
140
181
  if (res.error) {
141
182
  throw new error_1.FirebaseError(`Error starting up Data Connect build: ${res.error.message}`, {
142
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.3",
52
- expectedSize: 25211648,
53
- expectedChecksum: "8410794304b2ae340c3facf07d7edc16",
51
+ version: "1.7.5",
52
+ expectedSize: 25281280,
53
+ expectedChecksum: "85d0de96b5c08b553fd8506a2bc381bb",
54
54
  }
55
55
  : process.platform === "win32"
56
56
  ? {
57
- version: "1.7.3",
58
- expectedSize: 25641984,
59
- expectedChecksum: "a4bd0f9d9d884528fa4494e4d7918c08",
57
+ version: "1.7.5",
58
+ expectedSize: 25711616,
59
+ expectedChecksum: "c99d67fa8e74d41760b96122b055b8e2",
60
60
  }
61
61
  : {
62
- version: "1.7.3",
63
- expectedSize: 25125016,
64
- expectedChecksum: "48660e6370aeed973f33c3420c3255fb",
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,
@@ -112,6 +112,21 @@ class EmulatorHub extends ExpressBasedEmulator_1.ExpressBasedEmulator {
112
112
  await emu.reloadTriggers();
113
113
  res.status(200).json({ enabled: true });
114
114
  });
115
+ app.post(EmulatorHub.PATH_CLEAR_DATA_CONNECT, async (req, res) => {
116
+ if (req.headers.origin) {
117
+ res.status(403).json({
118
+ message: `Clear Data Connect cannot be triggered by external callers.`,
119
+ });
120
+ }
121
+ utils.logLabeledBullet("emulators", `Clearing data from Data Connect data sources.`);
122
+ const instance = registry_1.EmulatorRegistry.get(types_1.Emulators.DATACONNECT);
123
+ if (!instance) {
124
+ res.status(400).json({ error: "The Data Connect emulator is not running." });
125
+ return;
126
+ }
127
+ await instance.clearData();
128
+ res.status(200).send("Data cleared");
129
+ });
115
130
  return app;
116
131
  }
117
132
  async stop() {
@@ -176,3 +191,4 @@ EmulatorHub.PATH_EXPORT = "/_admin/export";
176
191
  EmulatorHub.PATH_DISABLE_FUNCTIONS = "/functions/disableBackgroundTriggers";
177
192
  EmulatorHub.PATH_ENABLE_FUNCTIONS = "/functions/enableBackgroundTriggers";
178
193
  EmulatorHub.PATH_EMULATORS = "/emulators";
194
+ EmulatorHub.PATH_CLEAR_DATA_CONNECT = "/dataconnect/clearData";
@@ -71,6 +71,13 @@ class HubExport {
71
71
  };
72
72
  await this.exportStorage(metadata);
73
73
  }
74
+ if (shouldExport(types_1.Emulators.DATACONNECT)) {
75
+ metadata.dataconnect = {
76
+ version: hub_1.EmulatorHub.CLI_VERSION,
77
+ path: "dataconnect_export",
78
+ };
79
+ await this.exportDataConnect(metadata);
80
+ }
74
81
  if (!fs.existsSync(this.exportPath)) {
75
82
  fs.mkdirSync(this.exportPath);
76
83
  }
@@ -197,6 +204,22 @@ class HubExport {
197
204
  throw new error_1.FirebaseError(`Failed to export storage: ${await res.response.text()}`);
198
205
  }
199
206
  }
207
+ async exportDataConnect(metadata) {
208
+ void (0, track_1.trackEmulator)("emulator_export", {
209
+ initiated_by: this.options.initiatedBy,
210
+ emulator_name: types_1.Emulators.DATACONNECT,
211
+ });
212
+ const instance = registry_1.EmulatorRegistry.get(types_1.Emulators.DATACONNECT);
213
+ if (!instance) {
214
+ throw new error_1.FirebaseError("Unable to export Data Connect emulator data: the Data Connect emulator is not running.");
215
+ }
216
+ const dataconnectExportPath = path.join(this.tmpDir, metadata.dataconnect.path);
217
+ if (fs.existsSync(dataconnectExportPath)) {
218
+ fse.removeSync(dataconnectExportPath);
219
+ }
220
+ fs.mkdirSync(dataconnectExportPath);
221
+ await instance.exportData(dataconnectExportPath);
222
+ }
200
223
  }
201
224
  exports.HubExport = HubExport;
202
225
  HubExport.METADATA_FILE_NAME = "firebase-export-metadata.json";
@@ -0,0 +1,63 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AdditionalInitFns = void 0;
4
+ const path_1 = require("path");
5
+ const prompt_1 = require("../prompt");
6
+ const developmentServer_1 = require("./apphosting/developmentServer");
7
+ const emulatorLogger_1 = require("./emulatorLogger");
8
+ const types_1 = require("./types");
9
+ const config_1 = require("../apphosting/config");
10
+ const detectProjectRoot_1 = require("../detectProjectRoot");
11
+ exports.AdditionalInitFns = {
12
+ [types_1.Emulators.APPHOSTING]: async () => {
13
+ const cwd = process.cwd();
14
+ const additionalConfigs = new Map();
15
+ const logger = emulatorLogger_1.EmulatorLogger.forEmulator(types_1.Emulators.APPHOSTING);
16
+ logger.logLabeled("INFO", "Initializing Emulator");
17
+ const backendRelativeDir = await (0, prompt_1.promptOnce)({
18
+ name: "rootDir",
19
+ type: "input",
20
+ default: "./",
21
+ message: "Specify your app's root directory relative to your repository",
22
+ });
23
+ additionalConfigs.set("rootDirectory", backendRelativeDir);
24
+ const backendRoot = (0, path_1.join)(cwd, backendRelativeDir);
25
+ try {
26
+ const startCommand = await (0, developmentServer_1.detectStartCommand)(backendRoot);
27
+ additionalConfigs.set("startCommand", startCommand);
28
+ }
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.startCommand`");
31
+ }
32
+ try {
33
+ const projectRoot = (0, detectProjectRoot_1.detectProjectRoot)({}) ?? backendRoot;
34
+ await (0, config_1.exportConfig)(cwd, projectRoot, backendRoot);
35
+ }
36
+ catch (e) {
37
+ logger.log("WARN", "failed to export app hosting configs");
38
+ }
39
+ return mapToObject(additionalConfigs);
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
+ },
56
+ };
57
+ function mapToObject(map) {
58
+ const newObject = {};
59
+ for (const [key, value] of map) {
60
+ newObject[key] = value;
61
+ }
62
+ return newObject;
63
+ }
@@ -1,7 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Severity = exports.EmulatorLog = exports.FunctionsExecutionMode = exports.isEmulator = exports.isDownloadableEmulator = exports.ALL_EMULATORS = exports.EMULATORS_SUPPORTED_BY_USE_EMULATOR = exports.EMULATORS_SUPPORTED_BY_UI = exports.EMULATORS_SUPPORTED_BY_FUNCTIONS = exports.ALL_SERVICE_EMULATORS = exports.IMPORT_EXPORT_EMULATORS = exports.DOWNLOADABLE_EMULATORS = exports.Emulators = void 0;
4
- const experiments = require("../experiments");
5
4
  var Emulators;
6
5
  (function (Emulators) {
7
6
  Emulators["AUTH"] = "auth";
@@ -33,9 +32,10 @@ exports.IMPORT_EXPORT_EMULATORS = [
33
32
  Emulators.DATABASE,
34
33
  Emulators.AUTH,
35
34
  Emulators.STORAGE,
35
+ Emulators.DATACONNECT,
36
36
  ];
37
37
  exports.ALL_SERVICE_EMULATORS = [
38
- ...(experiments.isEnabled("emulatorapphosting") ? [Emulators.APPHOSTING] : []),
38
+ Emulators.APPHOSTING,
39
39
  Emulators.AUTH,
40
40
  Emulators.FUNCTIONS,
41
41
  Emulators.FIRESTORE,
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;
@@ -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, types_1.isObject)(lifecycleEvents)) {
41
+ if ((0, error_1.isObject)(lifecycleEvents)) {
42
42
  for (const [key, val] of Object.entries(lifecycleEvents)) {
43
- if ((0, types_1.isObject)(val) &&
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 error_1 = require("../../error");
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, types_1.isObject)(pkgJson.peerDependencies)) {
95
- throw new error_1.FirebaseError("Internal error generating peer dependencies.");
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 error_1.FirebaseError("Invalid extension definition. Must have either extensionRef or localPath");
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 error_1.FirebaseError(`Error: Unknown systemParam type: ${sysParam.type || "undefined"}.`);
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, child_process_1.execFileSync)("npm", ["--prefix", dirPath, "install"]);
350
+ await (0, spawn_1.spawnWithOutput)("npm", ["--prefix", dirPath, "install"]);
350
351
  }
351
352
  catch (err) {
352
- const errMsg = (0, error_1.getErrMsg)(err, "unknown error");
353
- throw new error_1.FirebaseError(`Error during npm install in ${shortDirPath}: ${errMsg}`);
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, child_process_1.execFileSync)("npm", ["--prefix", dirPath, "run", "build"]);
358
+ await (0, spawn_1.spawnWithOutput)("npm", ["--prefix", dirPath, "run", "build"]);
358
359
  }
359
360
  catch (err) {
360
- const errMsg = (0, error_1.getErrMsg)(err, "unknown error");
361
- throw new error_1.FirebaseError(`Error during npm run build in ${shortDirPath}: ${errMsg}`);
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, child_process_1.execFileSync)("npm", ["--prefix", codebaseDir, "install", "--save", dirPath]);
375
+ await (0, spawn_1.spawnWithOutput)("npm", ["--prefix", codebaseDir, "install", "--save", dirPath]);
375
376
  }
376
377
  catch (err) {
377
- const errMsg = (0, error_1.getErrMsg)(err, "unknown error");
378
- throw new error_1.FirebaseError(`Error during npm install in ${codebaseDir}: ${errMsg}`);
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 {
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isExtensionSpec = exports.isResource = exports.isParam = exports.isObject = exports.ParamType = exports.FUNCTIONS_V2_RESOURCE_TYPE = exports.FUNCTIONS_RESOURCE_TYPE = exports.isExtensionInstance = exports.Visibility = exports.RegistryLaunchStage = void 0;
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.FIRESTORE_EVENT_WITH_AUTH_CONTEXT_REGEX = exports.FIRESTORE_EVENT_REGEX = 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;
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.FIRESTORE_EVENT_REGEX = /^google\.cloud\.firestore\.document\.v1\.[^\.]*$/;
32
- exports.FIRESTORE_EVENT_WITH_AUTH_CONTEXT_REGEX = /^google\.cloud\.firestore\.document\.v1\..*\.withAuthContext$/;
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 = {
@@ -409,6 +415,7 @@ function endpointFromFunction(gcfFunction) {
409
415
  endpoint.runServiceId = utils.last(serviceName.split("/"));
410
416
  }
411
417
  }
418
+ proto.renameIfPresent(endpoint, gcfFunction, "uri", "url");
412
419
  endpoint.codebase = gcfFunction.labels?.[constants_1.CODEBASE_LABEL] || projectConfig.DEFAULT_CODEBASE;
413
420
  if (gcfFunction.labels?.[constants_1.HASH_LABEL]) {
414
421
  endpoint.hash = gcfFunction.labels[constants_1.HASH_LABEL];
@@ -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 = experiments.isEnabled("fdccompatiblemode")
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
  }
@@ -7,6 +7,7 @@ const prompt_1 = require("../../prompt");
7
7
  const types_1 = require("../../emulator/types");
8
8
  const constants_1 = require("../../emulator/constants");
9
9
  const downloadableEmulators_1 = require("../../emulator/downloadableEmulators");
10
+ const initEmulators_1 = require("../../emulator/initEmulators");
10
11
  async function doSetup(setup, config) {
11
12
  const choices = types_1.ALL_SERVICE_EMULATORS.map((e) => {
12
13
  return {
@@ -45,6 +46,16 @@ async function doSetup(setup, config) {
45
46
  },
46
47
  ]);
47
48
  }
49
+ const additionalInitFn = initEmulators_1.AdditionalInitFns[selected];
50
+ if (additionalInitFn) {
51
+ const additionalOptions = await additionalInitFn(config);
52
+ if (additionalOptions) {
53
+ setup.config.emulators[selected] = {
54
+ ...setup.config.emulators[selected],
55
+ ...additionalOptions,
56
+ };
57
+ }
58
+ }
48
59
  }
49
60
  if (selections.emulators.length) {
50
61
  const uiDesc = constants_1.Constants.description(types_1.Emulators.UI);