firebase-tools-with-isolate 15.13.0 → 15.15.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 (75) hide show
  1. package/README.md +17 -17
  2. package/lib/api.js +2 -6
  3. package/lib/apphosting/constants.js +1 -1
  4. package/lib/command.js +7 -0
  5. package/lib/commands/dataconnect-compile.js +6 -6
  6. package/lib/commands/dataconnect-execute.js +1 -1
  7. package/lib/commands/dataconnect-sdk-generate.js +3 -3
  8. package/lib/commands/dataconnect-services-list.js +1 -1
  9. package/lib/commands/dataconnect-sql-diff.js +3 -3
  10. package/lib/commands/dataconnect-sql-grant.js +2 -2
  11. package/lib/commands/dataconnect-sql-migrate.js +4 -4
  12. package/lib/commands/dataconnect-sql-setup.js +2 -2
  13. package/lib/commands/dataconnect-sql-shell.js +4 -4
  14. package/lib/commands/ext-dev-usage.js +0 -2
  15. package/lib/commands/init.js +3 -3
  16. package/lib/commands/open.js +1 -1
  17. package/lib/commands/setup-emulators-dataconnect.js +1 -1
  18. package/lib/dataconnect/freeTrial.js +2 -2
  19. package/lib/dataconnect/load.js +2 -2
  20. package/lib/dataconnect/provisionCloudSql.js +3 -3
  21. package/lib/dataconnect/schemaMigration.js +11 -11
  22. package/lib/dataconnect/webhook.js +1 -1
  23. package/lib/deploy/functions/backend.js +1 -1
  24. package/lib/deploy/functions/build.js +3 -3
  25. package/lib/deploy/functions/deploy.js +5 -2
  26. package/lib/deploy/functions/prepare.js +59 -1
  27. package/lib/deploy/functions/prepareFunctionsUpload.js +25 -9
  28. package/lib/deploy/functions/release/fabricator.js +59 -46
  29. package/lib/deploy/functions/release/index.js +5 -0
  30. package/lib/deploy/functions/release/planner.js +1 -1
  31. package/lib/deploy/functions/runtimes/dart/index.js +3 -1
  32. package/lib/deploy/functions/runtimes/dart/triggerSupport.js +123 -0
  33. package/lib/deploy/functions/runtimes/index.js +1 -4
  34. package/lib/deploy/functions/runtimes/supported/index.js +0 -4
  35. package/lib/deploy/functions/services/ailogic.js +17 -5
  36. package/lib/deploy/functions/services/dataconnect.js +1 -1
  37. package/lib/deploy/functions/services/index.js +2 -2
  38. package/lib/deploy/functions/validate.js +7 -1
  39. package/lib/emulator/constants.js +1 -1
  40. package/lib/emulator/controller.js +13 -2
  41. package/lib/emulator/dataconnectEmulator.js +14 -14
  42. package/lib/emulator/dataconnectToolkitController.js +2 -2
  43. package/lib/emulator/downloadableEmulatorInfo.json +31 -31
  44. package/lib/emulator/downloadableEmulators.js +1 -0
  45. package/lib/emulator/extensionsEmulator.js +1 -2
  46. package/lib/emulator/functionsEmulator.js +20 -6
  47. package/lib/emulator/functionsRuntimeWorker.js +1 -1
  48. package/lib/emulator/hub.js +3 -3
  49. package/lib/emulator/hubExport.js +2 -2
  50. package/lib/emulator/initEmulators.js +1 -1
  51. package/lib/experiments.js +11 -6
  52. package/lib/frameworks/next/constants.js +2 -1
  53. package/lib/frameworks/next/index.js +3 -2
  54. package/lib/frameworks/next/utils.js +50 -12
  55. package/lib/functions/events/v2.js +10 -1
  56. package/lib/gcp/ailogic.js +13 -9
  57. package/lib/gcp/runv2.js +9 -2
  58. package/lib/init/features/dataconnect/index.js +7 -7
  59. package/lib/init/features/dataconnect/resolver.js +2 -2
  60. package/lib/init/features/dataconnect/sdk.js +8 -8
  61. package/lib/init/features/functions/index.js +1 -1
  62. package/lib/mcp/prompts/dataconnect/schema.js +6 -6
  63. package/lib/mcp/resources/guides/init_data_connect.js +2 -2
  64. package/lib/mcp/resources/guides/init_firestore.js +1 -1
  65. package/lib/mcp/tools/core/init.js +9 -9
  66. package/lib/mcp/tools/dataconnect/compile.js +5 -5
  67. package/lib/mcp/tools/dataconnect/execute.js +6 -6
  68. package/lib/mcp/tools/dataconnect/list_services.js +7 -7
  69. package/lib/mcp/util/dataconnect/content.js +19 -19
  70. package/lib/tsconfig.publish.tsbuildinfo +1 -1
  71. package/package.json +19 -6
  72. package/schema/firebase-config.json +3 -0
  73. package/templates/init/functions/dart/pubspec.yaml +6 -7
  74. package/templates/init/functions/dart/server.dart +3 -1
  75. package/lib/shortenUrl.js +0 -28
@@ -87,10 +87,10 @@ class DataConnectEmulator {
87
87
  connStr = `postgres://${connectableHost}:${pgPort}/${dbId}?sslmode=disable`;
88
88
  server.on("error", (err) => {
89
89
  if (err instanceof error_1.FirebaseError) {
90
- this.logger.logLabeled("ERROR", "Data Connect", `${err}`);
90
+ this.logger.logLabeled("ERROR", "SQL Connect", `${err}`);
91
91
  }
92
92
  else {
93
- this.logger.logLabeled("ERROR", "dataconnect", `Postgres threw an unexpected error, shutting down the Data Connect emulator: ${err}`);
93
+ this.logger.logLabeled("ERROR", "dataconnect", `Postgres threw an unexpected error, shutting down the SQL Connect emulator: ${err}`);
94
94
  }
95
95
  void (0, controller_1.cleanShutdown)();
96
96
  });
@@ -103,14 +103,14 @@ class DataConnectEmulator {
103
103
  async connect() {
104
104
  const emuInfo = await this.emulatorClient.getInfo();
105
105
  if (!emuInfo) {
106
- this.logger.logLabeled("ERROR", "dataconnect", "Could not connect to Data Connect emulator. Check dataconnect-debug.log for more details.");
106
+ this.logger.logLabeled("ERROR", "dataconnect", "Could not connect to SQL Connect emulator. Check dataconnect-debug.log for more details.");
107
107
  return Promise.reject();
108
108
  }
109
109
  return Promise.resolve();
110
110
  }
111
111
  async stop() {
112
112
  if (this.usingExistingEmulator) {
113
- this.logger.logLabeled("INFO", "dataconnect", "Skipping cleanup of Data Connect emulator, as it was not started by this process.");
113
+ this.logger.logLabeled("INFO", "dataconnect", "Skipping cleanup of SQL Connect emulator, as it was not started by this process.");
114
114
  return;
115
115
  }
116
116
  if (this.postgresServer) {
@@ -149,7 +149,7 @@ class DataConnectEmulator {
149
149
  await this.postgresServer.exportData(path.join(this.args.config.path(exportPath), "postgres.tar.gz"));
150
150
  }
151
151
  else {
152
- throw new error_1.FirebaseError("The Data Connect emulator is currently connected to a separate Postgres instance. Export is not supported.");
152
+ throw new error_1.FirebaseError("The SQL Connect emulator is currently connected to a separate Postgres instance. Export is not supported.");
153
153
  }
154
154
  }
155
155
  static async generate(args) {
@@ -176,7 +176,7 @@ class DataConnectEmulator {
176
176
  }
177
177
  catch (e) {
178
178
  if ((0, downloadableEmulators_1.isIncomaptibleArchError)(e)) {
179
- reject(new error_1.FirebaseError(`Unknown system error when running the Data Connect toolkit. ` +
179
+ reject(new error_1.FirebaseError(`Unknown system error when running the SQL Connect toolkit. ` +
180
180
  `You may be able to fix this by installing Rosetta: ` +
181
181
  `softwareupdate --install-rosetta`));
182
182
  }
@@ -195,17 +195,17 @@ class DataConnectEmulator {
195
195
  const env = await DataConnectEmulator.getEnv(args.account);
196
196
  const res = childProcess.spawnSync(commandInfo.binary, cmd, { encoding: "utf-8", env });
197
197
  if ((0, downloadableEmulators_1.isIncomaptibleArchError)(res.error)) {
198
- throw new error_1.FirebaseError(`Unkown system error when running the Data Connect toolkit. ` +
198
+ throw new error_1.FirebaseError(`Unkown system error when running the SQL Connect toolkit. ` +
199
199
  `You may be able to fix this by installing Rosetta: ` +
200
200
  `softwareupdate --install-rosetta`);
201
201
  }
202
202
  if (res.error) {
203
- throw new error_1.FirebaseError(`Error starting up Data Connect build: ${res.error.message}`, {
203
+ throw new error_1.FirebaseError(`Error starting up SQL Connect build: ${res.error.message}`, {
204
204
  original: res.error,
205
205
  });
206
206
  }
207
207
  if (res.status !== 0) {
208
- throw new error_1.FirebaseError(`Unable to build your Data Connect schema and connectors (exit code ${res.status}): ${res.stderr}`);
208
+ throw new error_1.FirebaseError(`Unable to build your SQL Connect schema and connectors (exit code ${res.status}): ${res.stderr}`);
209
209
  }
210
210
  if (res.stderr) {
211
211
  emulatorLogger_1.EmulatorLogger.forEmulator(types_1.Emulators.DATACONNECT).log("DEBUG", res.stderr);
@@ -219,27 +219,27 @@ class DataConnectEmulator {
219
219
  }
220
220
  async connectToPostgres(connectionString, database, serviceId) {
221
221
  if (!connectionString) {
222
- const msg = `No Postgres connection found. The Data Connect emulator will not be able to execute operations.`;
222
+ const msg = `No Postgres connection found. The SQL Connect emulator will not be able to execute operations.`;
223
223
  throw new error_1.FirebaseError(msg);
224
224
  }
225
225
  const MAX_RETRIES = 3;
226
226
  for (let i = 1; i <= MAX_RETRIES; i++) {
227
227
  try {
228
- this.logger.logLabeled("DEBUG", "Data Connect", `Connecting to ${connectionString}}...`);
228
+ this.logger.logLabeled("DEBUG", "SQL Connect", `Connecting to ${connectionString}}...`);
229
229
  connectionString.toString();
230
230
  await this.emulatorClient.configureEmulator({
231
231
  connectionString: connectionString.toString(),
232
232
  database,
233
233
  serviceId,
234
234
  });
235
- this.logger.logLabeled("DEBUG", "Data Connect", `Successfully connected to ${connectionString}}`);
235
+ this.logger.logLabeled("DEBUG", "SQL Connect", `Successfully connected to ${connectionString}}`);
236
236
  return true;
237
237
  }
238
238
  catch (err) {
239
239
  if (i === MAX_RETRIES) {
240
240
  throw err;
241
241
  }
242
- this.logger.logLabeled("DEBUG", "Data Connect", `Retrying connectToPostgress call (${i} of ${MAX_RETRIES} attempts): ${err}`);
242
+ this.logger.logLabeled("DEBUG", "SQL Connect", `Retrying connectToPostgress call (${i} of ${MAX_RETRIES} attempts): ${err}`);
243
243
  await new Promise((resolve) => setTimeout(resolve, 2000));
244
244
  }
245
245
  }
@@ -271,7 +271,7 @@ class DataConnectEmulatorClient {
271
271
  }
272
272
  catch (err) {
273
273
  if (err.status === 500) {
274
- throw new error_1.FirebaseError(`Data Connect emulator: ${err?.context?.body?.message}`);
274
+ throw new error_1.FirebaseError(`SQL Connect emulator: ${err?.context?.body?.message}`);
275
275
  }
276
276
  throw err;
277
277
  }
@@ -7,7 +7,7 @@ const portUtils = require("./portUtils");
7
7
  const utils_1 = require("../utils");
8
8
  const dataconnectEmulator_1 = require("./dataconnectEmulator");
9
9
  const downloadableEmulators_1 = require("./downloadableEmulators");
10
- const name = "Data Connect Toolkit";
10
+ const name = "SQL Connect Toolkit";
11
11
  class DataConnectToolkitController {
12
12
  static async start(args) {
13
13
  if (this.isRunning || this.instance) {
@@ -28,7 +28,7 @@ class DataConnectToolkitController {
28
28
  this.isRunning = false;
29
29
  }
30
30
  catch (e) {
31
- throw new error_1.FirebaseError(`Data Connect Toolkit failed to stop with error: ${e}`);
31
+ throw new error_1.FirebaseError(`SQL Connect Toolkit failed to stop with error: ${e}`);
32
32
  }
33
33
  }
34
34
  static getVersion() {
@@ -44,46 +44,46 @@
44
44
  }
45
45
  },
46
46
  "pubsub": {
47
- "version": "0.8.29",
48
- "expectedSize": 52906482,
49
- "expectedChecksum": "8345b0a923dda5634dd56a25f913cf37",
50
- "expectedChecksumSHA256": "31228112fb95a6818d13a88e801f4be6fb5ea5b601175b74528cc61823ea5507",
51
- "remoteUrl": "https://storage.googleapis.com/firebase-preview-drop/emulator/pubsub-emulator-0.8.29.zip",
52
- "downloadPathRelativeToCacheDir": "pubsub-emulator-0.8.29.zip",
53
- "binaryPathRelativeToCacheDir": "pubsub-emulator-0.8.29/pubsub-emulator/bin/cloud-pubsub-emulator"
47
+ "version": "0.8.30",
48
+ "expectedSize": 52917173,
49
+ "expectedChecksum": "f7935320d11894d0c4cd26dd064ee42f",
50
+ "expectedChecksumSHA256": "aabf028a55ec3f06fe2223471dad26623be542848abebd7563f8f0b8697dd2a3",
51
+ "remoteUrl": "https://storage.googleapis.com/firebase-preview-drop/emulator/pubsub-emulator-0.8.30.zip",
52
+ "downloadPathRelativeToCacheDir": "pubsub-emulator-0.8.30.zip",
53
+ "binaryPathRelativeToCacheDir": "pubsub-emulator-0.8.30/pubsub-emulator/bin/cloud-pubsub-emulator"
54
54
  },
55
55
  "dataconnect": {
56
56
  "darwin": {
57
- "version": "3.3.1",
58
- "expectedSize": 32105392,
59
- "expectedChecksum": "dfe6ff725864c37889c238aac24be304",
60
- "expectedChecksumSHA256": "1ccfebb4c0ff85f0503b907aa589658774bb6d4fac0180c3fa6bdff3a865090d",
61
- "remoteUrl": "https://storage.googleapis.com/firemat-preview-drop/emulator/dataconnect-emulator-macos-amd64-v3.3.1",
62
- "downloadPathRelativeToCacheDir": "dataconnect-emulator-3.3.1"
57
+ "version": "3.4.5",
58
+ "expectedSize": 32269984,
59
+ "expectedChecksum": "5c50dbd6f508998f748195691b5b0678",
60
+ "expectedChecksumSHA256": "2053e5c47dbe52c923be196cfd7ff70b31f9e2fbde0e7eaeb20c31ee91e8a8b2",
61
+ "remoteUrl": "https://storage.googleapis.com/firemat-preview-drop/emulator/dataconnect-emulator-macos-amd64-v3.4.5",
62
+ "downloadPathRelativeToCacheDir": "dataconnect-emulator-3.4.5"
63
63
  },
64
64
  "darwin_arm64": {
65
- "version": "3.3.1",
66
- "expectedSize": 30287922,
67
- "expectedChecksum": "59af3cb51c78e8114d634afea811f8cc",
68
- "expectedChecksumSHA256": "75bde31d15c4cc14de7071ff50cdd0d8fb644491e0c9ee3c1da82fdaf8d976a9",
69
- "remoteUrl": "https://storage.googleapis.com/firemat-preview-drop/emulator/dataconnect-emulator-macos-arm64-v3.3.1",
70
- "downloadPathRelativeToCacheDir": "dataconnect-emulator-3.3.1"
65
+ "version": "3.4.5",
66
+ "expectedSize": 30437250,
67
+ "expectedChecksum": "40f531afa3664284bc319f9721388816",
68
+ "expectedChecksumSHA256": "8dd59223a43b0e07ac2c7e40abb5e1a56ea7b7b787d23ceed20f8fe9af9c88e0",
69
+ "remoteUrl": "https://storage.googleapis.com/firemat-preview-drop/emulator/dataconnect-emulator-macos-arm64-v3.4.5",
70
+ "downloadPathRelativeToCacheDir": "dataconnect-emulator-3.4.5"
71
71
  },
72
72
  "win32": {
73
- "version": "3.3.1",
74
- "expectedSize": 32148992,
75
- "expectedChecksum": "3205dc92bbc7edb4c5821641486dc70c",
76
- "expectedChecksumSHA256": "fa7796077728414b0682f6ccf1df0fc7b2f56bb590f1e62698dbb7c1ddaf0fb0",
77
- "remoteUrl": "https://storage.googleapis.com/firemat-preview-drop/emulator/dataconnect-emulator-windows-amd64-v3.3.1",
78
- "downloadPathRelativeToCacheDir": "dataconnect-emulator-3.3.1.exe"
73
+ "version": "3.4.5",
74
+ "expectedSize": 32311296,
75
+ "expectedChecksum": "406caa49a4d48c03ade3da4a4a6b08b3",
76
+ "expectedChecksumSHA256": "e6e392f5bc3c32faa95d9b1139497492e51c46cb354e30e65c20d575ee3ba9cf",
77
+ "remoteUrl": "https://storage.googleapis.com/firemat-preview-drop/emulator/dataconnect-emulator-windows-amd64-v3.4.5",
78
+ "downloadPathRelativeToCacheDir": "dataconnect-emulator-3.4.5.exe"
79
79
  },
80
80
  "linux": {
81
- "version": "3.3.1",
82
- "expectedSize": 31264952,
83
- "expectedChecksum": "85ffdef78810e0074ac94c453a200daa",
84
- "expectedChecksumSHA256": "f232e03165c28f72bc99dfbd2dde1bcaf8298045817b60d72d407da7dae9e9f1",
85
- "remoteUrl": "https://storage.googleapis.com/firemat-preview-drop/emulator/dataconnect-emulator-linux-amd64-v3.3.1",
86
- "downloadPathRelativeToCacheDir": "dataconnect-emulator-3.3.1"
81
+ "version": "3.4.5",
82
+ "expectedSize": 31428792,
83
+ "expectedChecksum": "2e09522cff69142b6882e71516ad0e3c",
84
+ "expectedChecksumSHA256": "86565d7724762e45a76a4627791b60248cfea81f332d45709d69be0e71a3c6ec",
85
+ "remoteUrl": "https://storage.googleapis.com/firemat-preview-drop/emulator/dataconnect-emulator-linux-amd64-v3.4.5",
86
+ "downloadPathRelativeToCacheDir": "dataconnect-emulator-3.4.5"
87
87
  }
88
88
  }
89
89
  }
@@ -199,6 +199,7 @@ const Commands = {
199
199
  "host",
200
200
  "rules",
201
201
  "websocket_port",
202
+ "database-edition",
202
203
  "functions_emulator",
203
204
  "seed_from_export",
204
205
  "project_id",
@@ -12,7 +12,6 @@ const ensureApiEnabled_1 = require("../ensureApiEnabled");
12
12
  const error_1 = require("../error");
13
13
  const optionsHelper_1 = require("../extensions/emulator/optionsHelper");
14
14
  const refs_1 = require("../extensions/refs");
15
- const shortenUrl_1 = require("../shortenUrl");
16
15
  const constants_1 = require("./constants");
17
16
  const download_1 = require("./download");
18
17
  const emulatorLogger_1 = require("./emulatorLogger");
@@ -218,7 +217,7 @@ class ExtensionsEmulator {
218
217
  style: { head: ["yellow"] },
219
218
  });
220
219
  for (const apiToWarn of apisToWarn) {
221
- const enablementUri = await (0, shortenUrl_1.shortenUrl)((0, ensureApiEnabled_1.enableApiURI)(this.args.projectId, apiToWarn.apiName));
220
+ const enablementUri = (0, ensureApiEnabled_1.enableApiURI)(this.args.projectId, apiToWarn.apiName);
222
221
  table.push([
223
222
  apiToWarn.apiName,
224
223
  apiToWarn.instanceIds.join(", "),
@@ -37,6 +37,7 @@ const env_1 = require("./env");
37
37
  const python_1 = require("../functions/python");
38
38
  const supported_1 = require("../deploy/functions/runtimes/supported");
39
39
  const dart_1 = require("../deploy/functions/runtimes/dart");
40
+ const triggerSupport_1 = require("../deploy/functions/runtimes/dart/triggerSupport");
40
41
  const EVENT_INVOKE_GA4 = "functions_invoke";
41
42
  const DATABASE_PATH_PATTERN = new RegExp("^projects/[^/]+/instances/([^/]+)/refs(/.*)$");
42
43
  class IPCConn {
@@ -232,7 +233,7 @@ class FunctionsEmulator {
232
233
  "Content-Type": "application/json",
233
234
  "Content-Length": `${reqBody.length}`,
234
235
  };
235
- const isDart = (0, supported_1.isLanguageRuntime)(record.backend.runtime, "dart");
236
+ const isDart = (0, supported_1.runtimeIsLanguage)(record.backend.runtime, "dart");
236
237
  const path = isDart ? `/${trigger.entryPoint}` : `/`;
237
238
  return new Promise((resolve, reject) => {
238
239
  const req = http.request({
@@ -271,7 +272,7 @@ class FunctionsEmulator {
271
272
  for (const backend of this.staticBackends) {
272
273
  this.logger.logLabeled("BULLET", "functions", `Watching "${backend.functionsDir}" for Cloud Functions...`);
273
274
  await this.loadTriggers(backend, true);
274
- const isDart = (0, supported_1.isLanguageRuntime)(backend.runtime, "dart");
275
+ const isDart = (0, supported_1.runtimeIsLanguage)(backend.runtime, "dart");
275
276
  if (isDart) {
276
277
  const runtimeDelegateContext = {
277
278
  projectId: this.args.projectId,
@@ -388,6 +389,7 @@ class FunctionsEmulator {
388
389
  for (const e of endpoints) {
389
390
  e.codebase = emulatableBackend.codebase;
390
391
  }
392
+ this.logDartTriggerSupportWarnings(endpoints);
391
393
  return (0, functionsEmulatorShared_1.emulatedFunctionsFromEndpoints)(endpoints);
392
394
  }
393
395
  }
@@ -525,6 +527,19 @@ class FunctionsEmulator {
525
527
  }
526
528
  }
527
529
  }
530
+ logDartTriggerSupportWarnings(endpoints) {
531
+ const dartEndpoints = endpoints.filter(triggerSupport_1.isDartEndpoint);
532
+ if (dartEndpoints.length === 0) {
533
+ return;
534
+ }
535
+ const { emulatorOnly, experimental } = (0, triggerSupport_1.classifyNonProductionEndpoints)(dartEndpoints);
536
+ (0, triggerSupport_1.groupByTriggerLabel)(emulatorOnly).forEach((ids, label) => {
537
+ this.logger.logLabeled("WARN", "functions", `Dart ${clc.bold(label)} triggers work in the emulator but cannot be deployed to production yet: ${ids.join(", ")}`);
538
+ });
539
+ (0, triggerSupport_1.groupByTriggerLabel)(experimental).forEach((ids, label) => {
540
+ this.logger.logLabeled("WARN", "functions", `Dart ${clc.bold(label)} triggers are experimental and not yet fully supported: ${ids.join(", ")}`);
541
+ });
542
+ }
528
543
  async removeTriggers(toRemove) {
529
544
  for (const triggerKey of toRemove) {
530
545
  const definition = this.triggers[triggerKey].def;
@@ -1168,10 +1183,10 @@ class FunctionsEmulator {
1168
1183
  const runtimeEnv = this.getRuntimeEnvs(backend, trigger);
1169
1184
  const secretEnvs = await this.resolveSecretEnvs(backend, trigger);
1170
1185
  let runtime;
1171
- if ((0, supported_1.isLanguageRuntime)(backend.runtime, "python")) {
1186
+ if ((0, supported_1.runtimeIsLanguage)(backend.runtime, "python")) {
1172
1187
  runtime = await this.startPython(backend, { ...runtimeEnv, ...secretEnvs });
1173
1188
  }
1174
- else if ((0, supported_1.isLanguageRuntime)(backend.runtime, "dart")) {
1189
+ else if ((0, supported_1.runtimeIsLanguage)(backend.runtime, "dart")) {
1175
1190
  runtime = await this.startDart(backend, { ...runtimeEnv, ...secretEnvs });
1176
1191
  }
1177
1192
  else {
@@ -1242,8 +1257,7 @@ class FunctionsEmulator {
1242
1257
  this.logger.log("DEBUG", `[functions] Runtime ready! Sending request!`);
1243
1258
  const url = new url_1.URL(`${req.protocol}://${req.hostname}${req.url}`);
1244
1259
  let path = `${url.pathname}${url.search}`.replace(new RegExp(`\/${this.args.projectId}\/[^\/]*\/${req.params.trigger_name}\/?`), "/");
1245
- const isDart = (0, supported_1.isLanguageRuntime)(record.backend.runtime, "dart");
1246
- if (isDart) {
1260
+ if ((0, supported_1.runtimeIsLanguage)(record.backend.runtime, "dart")) {
1247
1261
  const isBackgroundRoute = req.url.startsWith("/functions/projects/");
1248
1262
  if (isBackgroundRoute || path === "/") {
1249
1263
  path = `/${trigger.entryPoint}`;
@@ -231,7 +231,7 @@ class RuntimeWorkerPool {
231
231
  if (this.mode === types_1.FunctionsExecutionMode.SEQUENTIAL) {
232
232
  return "~shared~";
233
233
  }
234
- if ((0, supported_1.isLanguageRuntime)(runtime, "dart")) {
234
+ if ((0, supported_1.runtimeIsLanguage)(runtime, "dart")) {
235
235
  return "~dart-shared~";
236
236
  }
237
237
  return triggerId || "~diagnostic~";
@@ -117,13 +117,13 @@ class EmulatorHub extends ExpressBasedEmulator_1.ExpressBasedEmulator {
117
117
  app.post(EmulatorHub.PATH_CLEAR_DATA_CONNECT, async (req, res) => {
118
118
  if (req.headers.origin) {
119
119
  res.status(403).json({
120
- message: `Clear Data Connect cannot be triggered by external callers.`,
120
+ message: `Clear SQL Connect cannot be triggered by external callers.`,
121
121
  });
122
122
  }
123
- utils.logLabeledBullet("emulators", `Clearing data from Data Connect data sources.`);
123
+ utils.logLabeledBullet("emulators", `Clearing data from SQL Connect data sources.`);
124
124
  const instance = registry_1.EmulatorRegistry.get(types_1.Emulators.DATACONNECT);
125
125
  if (!instance) {
126
- res.status(400).json({ error: "The Data Connect emulator is not running." });
126
+ res.status(400).json({ error: "The SQL Connect emulator is not running." });
127
127
  return;
128
128
  }
129
129
  await instance.clearData();
@@ -227,7 +227,7 @@ class HubExport {
227
227
  });
228
228
  const instance = registry_1.EmulatorRegistry.get(types_1.Emulators.DATACONNECT);
229
229
  if (!instance) {
230
- throw new error_1.FirebaseError("Unable to export Data Connect emulator data: the Data Connect emulator is not running.");
230
+ throw new error_1.FirebaseError("Unable to export SQL Connect emulator data: the SQL Connect emulator is not running.");
231
231
  }
232
232
  const dataconnectExportPath = path.join(this.tmpDir, metadata.dataconnect.path);
233
233
  if (fs.existsSync(dataconnectExportPath)) {
@@ -251,7 +251,7 @@ function fetchToFile(options, path) {
251
251
  }
252
252
  function shouldExport(e) {
253
253
  if (e === types_1.Emulators.DATACONNECT && (0, api_1.dataConnectLocalConnString)()) {
254
- logger_1.logger.info("Skipping export for Data Connect because FIREBASE_DATACONNECT_POSTGRESQL_STRING is set.");
254
+ logger_1.logger.info("Skipping export for SQL Connect because FIREBASE_DATACONNECT_POSTGRESQL_STRING is set.");
255
255
  return false;
256
256
  }
257
257
  return types_1.IMPORT_EXPORT_EMULATORS.includes(e) && registry_1.EmulatorRegistry.isRunning(e);
@@ -60,7 +60,7 @@ exports.AdditionalInitFns = {
60
60
  const additionalConfig = {};
61
61
  const defaultDataConnectDir = config.get("dataconnect.source", "dataconnect");
62
62
  const defaultDataDir = config.get("emulators.dataconnect.dataDir", `${defaultDataConnectDir}/.dataconnect/pgliteData`);
63
- if (await (0, prompt_1.confirm)("Do you want to persist Postgres data from the Data Connect emulator between runs? " +
63
+ if (await (0, prompt_1.confirm)("Do you want to persist Postgres data from the SQL Connect emulator between runs? " +
64
64
  `Data will be saved to ${defaultDataDir}. ` +
65
65
  `You can change this directory by editing 'firebase.json#emulators.dataconnect.dataDir'.`)) {
66
66
  additionalConfig["dataDir"] = defaultDataDir;
@@ -74,6 +74,11 @@ exports.ALL_EXPERIMENTS = experiments({
74
74
  public: false,
75
75
  default: false,
76
76
  },
77
+ dartfunctions: {
78
+ shortDescription: "Enable Dart Functions.",
79
+ public: false,
80
+ default: false,
81
+ },
77
82
  emulatoruisnapshot: {
78
83
  shortDescription: "Load pre-release versions of the emulator UI",
79
84
  },
@@ -127,8 +132,8 @@ exports.ALL_EXPERIMENTS = experiments({
127
132
  public: false,
128
133
  },
129
134
  dataconnect: {
130
- shortDescription: "Deprecated. Previosuly, enabled Data Connect related features.",
131
- fullDescription: "Deprecated. Previously, enabled Data Connect related features.",
135
+ shortDescription: "Deprecated. Previosuly, enabled SQL Connect related features.",
136
+ fullDescription: "Deprecated. Previously, enabled SQL Connect related features.",
132
137
  public: false,
133
138
  },
134
139
  genkit: {
@@ -154,7 +159,7 @@ exports.ALL_EXPERIMENTS = experiments({
154
159
  public: true,
155
160
  },
156
161
  fdcift: {
157
- shortDescription: "Enable instrumentless trial for Data Connect",
162
+ shortDescription: "Enable instrumentless trial for SQL Connect",
158
163
  default: true,
159
164
  public: false,
160
165
  },
@@ -163,13 +168,13 @@ exports.ALL_EXPERIMENTS = experiments({
163
168
  public: true,
164
169
  },
165
170
  fdcwebhooks: {
166
- shortDescription: "Enable Firebase Data Connect webhooks feature.",
171
+ shortDescription: "Enable Firebase SQL Connect webhooks feature.",
167
172
  default: true,
168
173
  public: false,
169
174
  },
170
175
  fdcrealtime: {
171
- shortDescription: "Enable Firebase Data Connect realtime feature.",
172
- default: false,
176
+ shortDescription: "Enable Firebase SQL Connect realtime feature.",
177
+ default: true,
173
178
  public: false,
174
179
  },
175
180
  });
@@ -1,10 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.WEBPACK_LAYERS = exports.ESBUILD_VERSION = exports.CONFIG_FILES = exports.SERVER_REFERENCE_MANIFEST = exports.APP_PATHS_MANIFEST = exports.ROUTES_MANIFEST = exports.PRERENDER_MANIFEST = exports.PAGES_MANIFEST = exports.MIDDLEWARE_MANIFEST = exports.IMAGES_MANIFEST = exports.EXPORT_MARKER = exports.APP_PATH_ROUTES_MANIFEST = void 0;
3
+ exports.WEBPACK_LAYERS = exports.ESBUILD_VERSION = exports.CONFIG_FILES = exports.SERVER_REFERENCE_MANIFEST = exports.APP_PATHS_MANIFEST = exports.ROUTES_MANIFEST = exports.PRERENDER_MANIFEST = exports.PAGES_MANIFEST = exports.FUNCTIONS_CONFIG_MANIFEST = exports.MIDDLEWARE_MANIFEST = exports.IMAGES_MANIFEST = exports.EXPORT_MARKER = exports.APP_PATH_ROUTES_MANIFEST = void 0;
4
4
  exports.APP_PATH_ROUTES_MANIFEST = "app-path-routes-manifest.json";
5
5
  exports.EXPORT_MARKER = "export-marker.json";
6
6
  exports.IMAGES_MANIFEST = "images-manifest.json";
7
7
  exports.MIDDLEWARE_MANIFEST = "middleware-manifest.json";
8
+ exports.FUNCTIONS_CONFIG_MANIFEST = "functions-config-manifest.json";
8
9
  exports.PAGES_MANIFEST = "pages-manifest.json";
9
10
  exports.PRERENDER_MANIFEST = "prerender-manifest.json";
10
11
  exports.ROUTES_MANIFEST = "routes-manifest.json";
@@ -255,16 +255,17 @@ async function ɵcodegenPublicDirectory(sourceDir, destDir, _, context) {
255
255
  await (0, fs_extra_1.copy)(publicPath, (0, path_1.join)(destDir, basePath));
256
256
  }
257
257
  await (0, fs_extra_1.copy)((0, path_1.join)(sourceDir, distDir, "static"), (0, path_1.join)(destDir, basePath, "_next", "static"));
258
- const [middlewareManifest, prerenderManifest, routesManifest, pagesManifest, appPathRoutesManifest, serverReferenceManifest,] = await Promise.all([
258
+ const [middlewareManifest, prerenderManifest, routesManifest, pagesManifest, appPathRoutesManifest, serverReferenceManifest, functionsConfigManifest,] = await Promise.all([
259
259
  (0, utils_1.readJSON)((0, path_1.join)(sourceDir, distDir, "server", constants_2.MIDDLEWARE_MANIFEST)),
260
260
  (0, utils_1.readJSON)((0, path_1.join)(sourceDir, distDir, constants_2.PRERENDER_MANIFEST)),
261
261
  (0, utils_1.readJSON)((0, path_1.join)(sourceDir, distDir, constants_2.ROUTES_MANIFEST)),
262
262
  (0, utils_1.readJSON)((0, path_1.join)(sourceDir, distDir, "server", constants_2.PAGES_MANIFEST)),
263
263
  (0, utils_1.readJSON)((0, path_1.join)(sourceDir, distDir, constants_2.APP_PATH_ROUTES_MANIFEST)).catch(() => ({})),
264
264
  (0, utils_1.readJSON)((0, path_1.join)(sourceDir, distDir, "server", constants_2.SERVER_REFERENCE_MANIFEST)).catch(() => ({ node: {}, edge: {}, encryptionKey: "" })),
265
+ (0, utils_1.readJSON)((0, path_1.join)(sourceDir, distDir, "server", constants_2.FUNCTIONS_CONFIG_MANIFEST)).catch(() => ({ version: 0, functions: {} })),
265
266
  ]);
266
267
  const appPathRoutesEntries = Object.entries(appPathRoutesManifest);
267
- const middlewareMatcherRegexes = (0, utils_2.getMiddlewareMatcherRegexes)(middlewareManifest);
268
+ const middlewareMatcherRegexes = (0, utils_2.getMiddlewareMatcherRegexes)(middlewareManifest, functionsConfigManifest);
268
269
  const { redirects = [], rewrites = [], headers = [] } = routesManifest;
269
270
  const rewritesRegexesNotSupportedByHosting = (0, utils_2.getNextjsRewritesToUse)(rewrites)
270
271
  .filter((rewrite) => !(0, utils_2.isRewriteSupportedByHosting)(rewrite))
@@ -14,6 +14,8 @@ exports.hasUnoptimizedImage = hasUnoptimizedImage;
14
14
  exports.isUsingMiddleware = isUsingMiddleware;
15
15
  exports.isUsingImageOptimization = isUsingImageOptimization;
16
16
  exports.isUsingNextImageInAppDirectory = isUsingNextImageInAppDirectory;
17
+ exports.isUsingNextImageInServerComponent = isUsingNextImageInServerComponent;
18
+ exports.isUsingNextImageInClientComponent = isUsingNextImageInClientComponent;
17
19
  exports.isUsingAppDirectory = isUsingAppDirectory;
18
20
  exports.allDependencyNames = allDependencyNames;
19
21
  exports.getMiddlewareMatcherRegexes = getMiddlewareMatcherRegexes;
@@ -100,23 +102,33 @@ async function hasUnoptimizedImage(sourceDir, distDir) {
100
102
  }
101
103
  async function isUsingMiddleware(dir, isDevMode) {
102
104
  if (isDevMode) {
103
- const [middlewareJs, middlewareTs] = await Promise.all([
105
+ const middlewareFiles = await Promise.all([
104
106
  (0, fs_extra_1.pathExists)((0, path_1.join)(dir, "middleware.js")),
105
107
  (0, fs_extra_1.pathExists)((0, path_1.join)(dir, "middleware.ts")),
108
+ (0, fs_extra_1.pathExists)((0, path_1.join)(dir, "proxy.js")),
109
+ (0, fs_extra_1.pathExists)((0, path_1.join)(dir, "proxy.ts")),
110
+ (0, fs_extra_1.pathExists)((0, path_1.join)(dir, "src", "middleware.js")),
111
+ (0, fs_extra_1.pathExists)((0, path_1.join)(dir, "src", "middleware.ts")),
112
+ (0, fs_extra_1.pathExists)((0, path_1.join)(dir, "src", "proxy.js")),
113
+ (0, fs_extra_1.pathExists)((0, path_1.join)(dir, "src", "proxy.ts")),
106
114
  ]);
107
- return middlewareJs || middlewareTs;
115
+ return middlewareFiles.some((file) => file);
108
116
  }
109
117
  else {
110
118
  const middlewareManifest = await (0, utils_1.readJSON)((0, path_1.join)(dir, "server", constants_1.MIDDLEWARE_MANIFEST));
119
+ if (middlewareManifest.version === 3) {
120
+ const functionsConfigManifest = await (0, utils_1.readJSON)((0, path_1.join)(dir, "server", constants_1.FUNCTIONS_CONFIG_MANIFEST)).catch(() => undefined);
121
+ if ((functionsConfigManifest?.functions?.["/_middleware"]?.matchers || [])?.length > 0) {
122
+ return true;
123
+ }
124
+ }
111
125
  return Object.keys(middlewareManifest.middleware).length > 0;
112
126
  }
113
127
  }
114
128
  async function isUsingImageOptimization(projectDir, distDir) {
115
129
  let isNextImageImported = await usesNextImage(projectDir, distDir);
116
130
  if (!isNextImageImported && isUsingAppDirectory((0, path_1.join)(projectDir, distDir))) {
117
- if (await isUsingNextImageInAppDirectory(projectDir, distDir)) {
118
- isNextImageImported = true;
119
- }
131
+ isNextImageImported = await isUsingNextImageInAppDirectory(projectDir, distDir);
120
132
  }
121
133
  if (isNextImageImported) {
122
134
  const imagesManifest = await (0, utils_1.readJSON)((0, path_1.join)(projectDir, distDir, constants_1.IMAGES_MANIFEST));
@@ -124,7 +136,11 @@ async function isUsingImageOptimization(projectDir, distDir) {
124
136
  }
125
137
  return false;
126
138
  }
127
- async function isUsingNextImageInAppDirectory(projectDir, nextDir) {
139
+ async function isUsingNextImageInAppDirectory(projectDir, distDir) {
140
+ return ((await isUsingNextImageInServerComponent(projectDir, distDir)) ||
141
+ isUsingNextImageInClientComponent(projectDir, distDir));
142
+ }
143
+ async function isUsingNextImageInServerComponent(projectDir, nextDir) {
128
144
  const nextImagePath = ["node_modules", "next", "dist", "client", "image"];
129
145
  const nextImageString = utils_2.IS_WINDOWS
130
146
  ?
@@ -139,6 +155,16 @@ async function isUsingNextImageInAppDirectory(projectDir, nextDir) {
139
155
  }
140
156
  return false;
141
157
  }
158
+ async function isUsingNextImageInClientComponent(projectDir, distDir) {
159
+ const htmlFiles = await (0, glob_1.glob)((0, path_1.join)(projectDir, distDir, "server", "app", "**", "*.html"));
160
+ for (const filepath of htmlFiles) {
161
+ const contents = await (0, promises_1.readFile)(filepath, "utf-8");
162
+ if (contents.includes('data-nimg="')) {
163
+ return true;
164
+ }
165
+ }
166
+ return false;
167
+ }
142
168
  function isUsingAppDirectory(dir) {
143
169
  const appPathRoutesManifestPath = (0, path_1.join)(dir, constants_1.APP_PATH_ROUTES_MANIFEST);
144
170
  return (0, fsutils_1.fileExistsSync)(appPathRoutesManifestPath);
@@ -149,16 +175,28 @@ function allDependencyNames(mod) {
149
175
  const dependencyNames = Object.keys(mod.dependencies).reduce((acc, it) => [...acc, it, ...allDependencyNames(mod.dependencies[it])], []);
150
176
  return dependencyNames;
151
177
  }
152
- function getMiddlewareMatcherRegexes(middlewareManifest) {
178
+ function getMiddlewareMatcherRegexes(middlewareManifest, functionsConfigManifest) {
153
179
  const middlewareObjectValues = Object.values(middlewareManifest.middleware);
154
- let middlewareMatchers;
180
+ const middlewareMatchers = [];
155
181
  if (middlewareManifest.version === 1) {
156
- middlewareMatchers = middlewareObjectValues.map((page) => ({ regexp: page.regexp }));
182
+ middlewareMatchers.push(...middlewareObjectValues.map((page) => ({
183
+ regexp: page.regexp,
184
+ })));
157
185
  }
158
- else {
159
- middlewareMatchers = middlewareObjectValues
186
+ else if (middlewareManifest.version === 2) {
187
+ middlewareMatchers.push(...middlewareObjectValues
160
188
  .map((page) => page.matchers)
161
- .flat();
189
+ .flat());
190
+ }
191
+ else if (middlewareManifest.version === 3) {
192
+ if (functionsConfigManifest?.functions?.["/_middleware"]) {
193
+ middlewareMatchers.push(...(functionsConfigManifest.functions["/_middleware"].matchers || []));
194
+ }
195
+ else {
196
+ middlewareMatchers.push(...middlewareObjectValues
197
+ .map((page) => page.matchers)
198
+ .flat());
199
+ }
162
200
  }
163
201
  return middlewareMatchers.map((matcher) => new RegExp(matcher.regexp));
164
202
  }
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.CONVERTABLE_EVENTS = exports.DATACONNECT_EVENT = 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.AI_LOGIC_TRIGGERS_TO_EVENTS = exports.AI_LOGIC_EVENTS_TO_TRIGGER = exports.CONVERTABLE_EVENTS = exports.DATACONNECT_EVENT = 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
+ const ailogic_1 = require("../../deploy/functions/services/ailogic");
4
5
  exports.PUBSUB_PUBLISH_EVENT = "google.cloud.pubsub.topic.v1.messagePublished";
5
6
  exports.STORAGE_EVENTS = [
6
7
  "google.cloud.storage.object.v1.finalized",
@@ -35,3 +36,11 @@ exports.CONVERTABLE_EVENTS = {
35
36
  "google.cloud.firestore.document.v1.deleted": "google.cloud.firestore.document.v1.deleted.withAuthContext",
36
37
  "google.cloud.firestore.document.v1.written": "google.cloud.firestore.document.v1.written.withAuthContext",
37
38
  };
39
+ exports.AI_LOGIC_EVENTS_TO_TRIGGER = {
40
+ [ailogic_1.AI_LOGIC_BEFORE_GENERATE_CONTENT]: "before-generate-content",
41
+ [ailogic_1.AI_LOGIC_AFTER_GENERATE_CONTENT]: "after-generate-content",
42
+ };
43
+ exports.AI_LOGIC_TRIGGERS_TO_EVENTS = {
44
+ "before-generate-content": ailogic_1.AI_LOGIC_BEFORE_GENERATE_CONTENT,
45
+ "after-generate-content": ailogic_1.AI_LOGIC_AFTER_GENERATE_CONTENT,
46
+ };