firebase-tools-with-isolate 13.9.0 → 13.15.0-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 (125) hide show
  1. package/lib/api.js +4 -2
  2. package/lib/apphosting/githubConnections.js +125 -37
  3. package/lib/apphosting/index.js +3 -8
  4. package/lib/auth.js +14 -15
  5. package/lib/bin/firebase.js +7 -5
  6. package/lib/commands/dataconnect-sdk-generate.js +17 -15
  7. package/lib/commands/dataconnect-services-list.js +2 -8
  8. package/lib/commands/dataconnect-sql-migrate.js +0 -1
  9. package/lib/commands/deploy.js +7 -1
  10. package/lib/commands/ext-configure.js +1 -6
  11. package/lib/commands/ext-dev-init.js +27 -30
  12. package/lib/commands/ext-dev-upload.js +4 -6
  13. package/lib/commands/ext-info.js +3 -5
  14. package/lib/commands/ext-install.js +0 -5
  15. package/lib/commands/ext-uninstall.js +0 -5
  16. package/lib/commands/ext-update.js +0 -5
  17. package/lib/commands/firestore-backups-schedules-create.js +11 -14
  18. package/lib/commands/firestore-backups-schedules-list.js +1 -1
  19. package/lib/commands/firestore-backups-schedules-update.js +4 -3
  20. package/lib/commands/firestore-databases-create.js +24 -7
  21. package/lib/commands/firestore-databases-restore.js +4 -4
  22. package/lib/commands/firestore-databases-update.js +5 -6
  23. package/lib/commands/functions-secrets-set.js +9 -6
  24. package/lib/commands/help.js +2 -0
  25. package/lib/commands/hosting-channel-create.js +1 -1
  26. package/lib/commands/hosting-channel-delete.js +1 -1
  27. package/lib/commands/hosting-channel-deploy.js +1 -1
  28. package/lib/commands/hosting-clone.js +1 -2
  29. package/lib/commands/index.js +9 -11
  30. package/lib/commands/init.js +16 -12
  31. package/lib/commands/login.js +1 -2
  32. package/lib/commands/setup-emulators-dataconnect.js +22 -3
  33. package/lib/config.js +5 -0
  34. package/lib/crashlytics/buildToolsJarHelper.js +2 -1
  35. package/lib/dataconnect/build.js +1 -9
  36. package/lib/dataconnect/client.js +67 -28
  37. package/lib/dataconnect/errors.js +17 -9
  38. package/lib/dataconnect/fileUtils.js +30 -7
  39. package/lib/dataconnect/filters.js +12 -1
  40. package/lib/dataconnect/graphqlError.js +6 -3
  41. package/lib/dataconnect/load.js +9 -7
  42. package/lib/dataconnect/names.js +21 -1
  43. package/lib/dataconnect/provisionCloudSql.js +37 -20
  44. package/lib/dataconnect/schemaMigration.js +119 -66
  45. package/lib/dataconnect/types.js +8 -1
  46. package/lib/deploy/dataconnect/deploy.js +1 -0
  47. package/lib/deploy/dataconnect/prepare.js +16 -2
  48. package/lib/deploy/dataconnect/release.js +0 -1
  49. package/lib/deploy/functions/build.js +10 -1
  50. package/lib/deploy/functions/prepare.js +1 -1
  51. package/lib/deploy/functions/runtimes/discovery/index.js +2 -1
  52. package/lib/deploy/functions/runtimes/supported/types.js +6 -0
  53. package/lib/emulator/adminSdkConfig.test.js +16 -0
  54. package/lib/emulator/constants.js +1 -0
  55. package/lib/emulator/controller.js +4 -9
  56. package/lib/emulator/dataconnectEmulator.js +181 -35
  57. package/lib/emulator/download.js +4 -0
  58. package/lib/emulator/downloadableEmulators.js +54 -28
  59. package/lib/emulator/eventarcEmulator.js +68 -18
  60. package/lib/emulator/functionsEmulator.js +89 -0
  61. package/lib/emulator/functionsEmulatorShared.js +4 -0
  62. package/lib/emulator/hub.js +1 -1
  63. package/lib/emulator/portUtils.js +20 -2
  64. package/lib/emulator/pubsubEmulator.js +1 -1
  65. package/lib/emulator/registry.js +1 -1
  66. package/lib/emulator/storage/apis/shared.js +2 -1
  67. package/lib/emulator/storage/persistence.js +5 -13
  68. package/lib/emulator/storage/rfc.js +9 -0
  69. package/lib/emulator/storage/rules/config.js +4 -2
  70. package/lib/emulator/storage/rules/runtime.js +1 -1
  71. package/lib/experiments.js +8 -3
  72. package/lib/extensions/askUserForParam.js +1 -1
  73. package/lib/extensions/change-log.js +2 -4
  74. package/lib/extensions/displayExtensionInfo.js +0 -5
  75. package/lib/extensions/extensionsHelper.js +5 -7
  76. package/lib/extensions/provisioningHelper.js +1 -1
  77. package/lib/extensions/updateHelper.js +1 -2
  78. package/lib/extensions/warnings.js +2 -7
  79. package/lib/firestore/api-sort.test.js +74 -0
  80. package/lib/firestore/api.js +8 -7
  81. package/lib/firestore/backupUtils.test.js +18 -0
  82. package/lib/firestore/pretty-print.js +21 -1
  83. package/lib/firestore/pretty-print.test.js +61 -0
  84. package/lib/firestore/util.test.js +42 -0
  85. package/lib/frameworks/angular/utils.js +21 -8
  86. package/lib/frameworks/compose/discover/mockFileSystem.js +36 -0
  87. package/lib/frameworks/index.js +2 -6
  88. package/lib/frameworks/next/utils.js +2 -9
  89. package/lib/frameworks/nuxt/index.js +3 -3
  90. package/lib/functions/events/v2.js +2 -1
  91. package/lib/gcp/cloudsql/cloudsqladmin.js +20 -2
  92. package/lib/gcp/cloudsql/connect.js +6 -6
  93. package/lib/gcp/devConnect.js +36 -1
  94. package/lib/hosting/implicitInit.js +2 -2
  95. package/lib/init/features/dataconnect/index.js +252 -124
  96. package/lib/init/features/dataconnect/sdk.js +131 -0
  97. package/lib/init/features/firestore/indexes.js +2 -2
  98. package/lib/init/features/firestore/rules.js +2 -2
  99. package/lib/init/features/functions/javascript.js +6 -8
  100. package/lib/init/features/functions/python.js +4 -6
  101. package/lib/init/features/functions/typescript.js +8 -10
  102. package/lib/init/features/hosting/github.js +43 -21
  103. package/lib/init/features/hosting/index.js +3 -3
  104. package/lib/init/features/index.js +3 -1
  105. package/lib/init/features/storage.js +2 -2
  106. package/lib/init/index.js +1 -0
  107. package/lib/listFiles.js +1 -1
  108. package/lib/management/apps.js +2 -2
  109. package/lib/rc.js +2 -3
  110. package/lib/requireAuth.js +8 -0
  111. package/lib/rulesDeploy.js +14 -12
  112. package/lib/templates.js +23 -0
  113. package/lib/track.js +29 -2
  114. package/lib/utils.js +2 -2
  115. package/package.json +25 -24
  116. package/schema/connector-yaml.json +36 -4
  117. package/schema/dataconnect-yaml.json +4 -0
  118. package/schema/firebase-config.json +2 -8
  119. package/templates/_gitignore +3 -0
  120. package/templates/init/dataconnect/connector.yaml +11 -0
  121. package/templates/init/dataconnect/dataconnect.yaml +2 -1
  122. package/templates/init/dataconnect/mutations.gql +18 -13
  123. package/templates/init/dataconnect/queries.gql +34 -29
  124. package/templates/init/dataconnect/schema.gql +1 -1
  125. package/lib/extensions/billingMigrationHelper.js +0 -61
@@ -11,53 +11,56 @@ const logger_1 = require("../logger");
11
11
  const error_1 = require("../error");
12
12
  const projectUtils_1 = require("../projectUtils");
13
13
  const utils_1 = require("../utils");
14
+ const experiments = require("../experiments");
14
15
  const errors = require("./errors");
15
16
  async function diffSchema(schema) {
16
17
  const { serviceName, instanceName, databaseId } = getIdentifiers(schema);
17
- await ensureServiceIsConnectedToCloudSql(serviceName, instanceName, databaseId);
18
+ await ensureServiceIsConnectedToCloudSql(serviceName, instanceName, databaseId, false);
19
+ setCompatibleMode(schema, databaseId, instanceName);
18
20
  try {
19
21
  await (0, client_1.upsertSchema)(schema, true);
22
+ (0, utils_1.logLabeledSuccess)("dataconnect", `Database schema is up to date.`);
20
23
  }
21
24
  catch (err) {
25
+ if (err.status !== 400) {
26
+ throw err;
27
+ }
22
28
  const invalidConnectors = errors.getInvalidConnectors(err);
29
+ const incompatible = errors.getIncompatibleSchemaError(err);
30
+ if (!incompatible && !invalidConnectors.length) {
31
+ throw err;
32
+ }
23
33
  if (invalidConnectors.length) {
24
34
  displayInvalidConnectors(invalidConnectors);
25
35
  }
26
- const incompatible = errors.getIncompatibleSchemaError(err);
27
36
  if (incompatible) {
28
37
  displaySchemaChanges(incompatible);
29
38
  return incompatible.diffs;
30
39
  }
31
40
  }
32
- (0, utils_1.logLabeledSuccess)("dataconnect", `Database schema is up to date.`);
33
41
  return [];
34
42
  }
35
43
  exports.diffSchema = diffSchema;
36
44
  async function migrateSchema(args) {
37
- const { options, schema, allowNonInteractiveMigration, validateOnly } = args;
45
+ const { options, schema, validateOnly } = args;
38
46
  const { serviceName, instanceId, instanceName, databaseId } = getIdentifiers(schema);
39
- await ensureServiceIsConnectedToCloudSql(serviceName, instanceName, databaseId);
47
+ await ensureServiceIsConnectedToCloudSql(serviceName, instanceName, databaseId, true);
48
+ setCompatibleMode(schema, databaseId, instanceName);
40
49
  try {
41
50
  await (0, client_1.upsertSchema)(schema, validateOnly);
42
51
  logger_1.logger.debug(`Database schema was up to date for ${instanceId}:${databaseId}`);
43
52
  }
44
53
  catch (err) {
54
+ if (err.status !== 400) {
55
+ throw err;
56
+ }
45
57
  const incompatible = errors.getIncompatibleSchemaError(err);
46
58
  const invalidConnectors = errors.getInvalidConnectors(err);
47
59
  if (!incompatible && !invalidConnectors.length) {
48
60
  throw err;
49
61
  }
50
- const shouldDeleteInvalidConnectors = await promptForInvalidConnectorError(options, invalidConnectors, validateOnly);
51
- if (!shouldDeleteInvalidConnectors && invalidConnectors.length) {
52
- const cmd = suggestedCommand(serviceName, invalidConnectors);
53
- throw new error_1.FirebaseError(`Command aborted. Try deploying compatible connectors first with ${clc.bold(cmd)}`);
54
- }
55
- const migrationMode = incompatible
56
- ? await promptForSchemaMigration(options, databaseId, incompatible, allowNonInteractiveMigration)
57
- : "none";
58
- if (migrationMode === "none" && incompatible) {
59
- throw new error_1.FirebaseError("Command aborted.");
60
- }
62
+ const migrationMode = await promptForSchemaMigration(options, databaseId, incompatible, validateOnly);
63
+ const shouldDeleteInvalidConnectors = await promptForInvalidConnectorError(options, serviceName, invalidConnectors, validateOnly);
61
64
  let diffs = [];
62
65
  if (incompatible) {
63
66
  diffs = await handleIncompatibleSchemaError({
@@ -68,15 +71,35 @@ async function migrateSchema(args) {
68
71
  choice: migrationMode,
69
72
  });
70
73
  }
71
- if (invalidConnectors.length) {
74
+ if (shouldDeleteInvalidConnectors) {
72
75
  await deleteInvalidConnectors(invalidConnectors);
73
76
  }
74
- await (0, client_1.upsertSchema)(schema, validateOnly);
77
+ if (!validateOnly) {
78
+ await (0, client_1.upsertSchema)(schema, validateOnly);
79
+ }
75
80
  return diffs;
76
81
  }
77
82
  return [];
78
83
  }
79
84
  exports.migrateSchema = migrateSchema;
85
+ function setCompatibleMode(schema, databaseId, instanceName) {
86
+ if (experiments.isEnabled("fdccompatiblemode")) {
87
+ if (schema.primaryDatasource.postgresql?.schemaValidation) {
88
+ schema.primaryDatasource.postgresql.schemaValidation = "COMPATIBLE";
89
+ }
90
+ else {
91
+ schema.primaryDatasource = {
92
+ postgresql: {
93
+ database: databaseId,
94
+ cloudSql: {
95
+ instance: instanceName,
96
+ },
97
+ schemaValidation: "COMPATIBLE",
98
+ },
99
+ };
100
+ }
101
+ }
102
+ }
80
103
  function getIdentifiers(schema) {
81
104
  const databaseId = schema.primaryDatasource.postgresql?.database;
82
105
  if (!databaseId) {
@@ -135,16 +158,22 @@ async function handleIncompatibleSchemaError(args) {
135
158
  }
136
159
  return [];
137
160
  }
138
- async function promptForSchemaMigration(options, databaseName, err, allowNonInteractiveMigration) {
161
+ async function promptForSchemaMigration(options, databaseName, err, validateOnly) {
162
+ if (!err) {
163
+ return "none";
164
+ }
139
165
  displaySchemaChanges(err);
140
166
  if (!options.nonInteractive) {
167
+ if (validateOnly && options.force) {
168
+ return "all";
169
+ }
141
170
  const choices = err.destructive
142
171
  ? [
143
172
  { name: "Execute all changes (including destructive changes)", value: "all" },
144
173
  { name: "Abort changes", value: "none" },
145
174
  ]
146
175
  : [
147
- { name: "Execute changes", value: "safe" },
176
+ { name: "Execute changes", value: "all" },
148
177
  { name: "Abort changes", value: "none" },
149
178
  ];
150
179
  return await (0, prompt_1.promptOnce)({
@@ -153,38 +182,42 @@ async function promptForSchemaMigration(options, databaseName, err, allowNonInte
153
182
  choices,
154
183
  });
155
184
  }
156
- else if (!allowNonInteractiveMigration) {
157
- logger_1.logger.error("Your database schema is incompatible with your Data Connect schema. Run `firebase dataconnect:sql:migrate` to migrate your database schema");
158
- return "none";
185
+ if (!validateOnly) {
186
+ throw new error_1.FirebaseError("Command aborted. Your database schema is incompatible with your Data Connect schema. Run `firebase dataconnect:sql:migrate` to migrate your database schema");
159
187
  }
160
188
  else if (options.force) {
161
189
  return "all";
162
190
  }
163
191
  else if (!err.destructive) {
164
- return "safe";
192
+ return "all";
165
193
  }
166
194
  else {
167
- logger_1.logger.error("This schema migration includes potentially destructive changes. If you'd like to execute it anyway, rerun this command with --force");
168
- return "none";
195
+ throw new error_1.FirebaseError("Command aborted. This schema migration includes potentially destructive changes. If you'd like to execute it anyway, rerun this command with --force");
169
196
  }
170
197
  }
171
- async function promptForInvalidConnectorError(options, invalidConnectors, validateOnly) {
198
+ async function promptForInvalidConnectorError(options, serviceName, invalidConnectors, validateOnly) {
172
199
  if (!invalidConnectors.length) {
173
200
  return false;
174
201
  }
175
202
  displayInvalidConnectors(invalidConnectors);
176
203
  if (validateOnly) {
177
- return false;
204
+ if (options.force) {
205
+ return false;
206
+ }
207
+ throw new error_1.FirebaseError(`Command aborted. If you'd like to migrate it anyway, you may override with --force.`);
208
+ }
209
+ if (options.force) {
210
+ return true;
178
211
  }
179
- else if (options.force ||
180
- (!options.nonInteractive &&
181
- (await (0, prompt_1.confirm)({
182
- ...options,
183
- message: "Would you like to delete and recreate these connectors?",
184
- })))) {
212
+ if (!options.nonInteractive &&
213
+ (await (0, prompt_1.confirm)({
214
+ ...options,
215
+ message: `Would you like to delete and recreate these connectors? This will cause ${clc.red(`downtime.`)}.`,
216
+ }))) {
185
217
  return true;
186
218
  }
187
- return false;
219
+ const cmd = suggestedCommand(serviceName, invalidConnectors);
220
+ throw new error_1.FirebaseError(`Command aborted. Try deploying those connectors first with ${clc.bold(cmd)}`);
188
221
  }
189
222
  async function deleteInvalidConnectors(invalidConnectors) {
190
223
  return Promise.all(invalidConnectors.map(client_1.deleteConnector));
@@ -192,39 +225,42 @@ async function deleteInvalidConnectors(invalidConnectors) {
192
225
  function displayInvalidConnectors(invalidConnectors) {
193
226
  const connectorIds = invalidConnectors.map((i) => i.split("/").pop()).join(", ");
194
227
  (0, utils_1.logLabeledWarning)("dataconnect", `The schema you are deploying is incompatible with the following existing connectors: ${connectorIds}.`);
195
- (0, utils_1.logLabeledWarning)("dataconnect", `This is a ${clc.red("breaking")} change and will cause a brief downtime.`);
228
+ (0, utils_1.logLabeledWarning)("dataconnect", `This is a ${clc.red("breaking")} change and may break existing apps.`);
196
229
  }
197
- async function ensureServiceIsConnectedToCloudSql(serviceName, instanceId, databaseId) {
198
- let currentSchema;
199
- try {
200
- currentSchema = await (0, client_1.getSchema)(serviceName);
201
- }
202
- catch (err) {
203
- if (err.status === 404) {
204
- currentSchema = {
205
- name: `${serviceName}/schemas/${types_1.SCHEMA_ID}`,
206
- source: {
207
- files: [],
208
- },
209
- primaryDatasource: {
210
- postgresql: {
211
- database: databaseId,
212
- cloudSql: {
213
- instance: instanceId,
214
- },
230
+ async function ensureServiceIsConnectedToCloudSql(serviceName, instanceId, databaseId, linkIfNotConnected) {
231
+ let currentSchema = await (0, client_1.getSchema)(serviceName);
232
+ if (!currentSchema) {
233
+ if (!linkIfNotConnected) {
234
+ (0, utils_1.logLabeledWarning)("dataconnect", `Not yet linked to the Cloud SQL instance.`);
235
+ return;
236
+ }
237
+ (0, utils_1.logLabeledBullet)("dataconnect", `Linking the Cloud SQL instance...`);
238
+ currentSchema = {
239
+ name: `${serviceName}/schemas/${types_1.SCHEMA_ID}`,
240
+ source: {
241
+ files: [],
242
+ },
243
+ primaryDatasource: {
244
+ postgresql: {
245
+ database: databaseId,
246
+ cloudSql: {
247
+ instance: instanceId,
215
248
  },
216
249
  },
217
- };
218
- }
219
- else {
220
- throw err;
221
- }
250
+ },
251
+ };
252
+ }
253
+ const postgresql = currentSchema.primaryDatasource.postgresql;
254
+ if (postgresql?.cloudSql.instance !== instanceId) {
255
+ (0, utils_1.logLabeledWarning)("dataconnect", `Switching connected Cloud SQL instance\nFrom ${postgresql?.cloudSql.instance}\nTo ${instanceId}`);
222
256
  }
223
- if (!currentSchema.primaryDatasource.postgresql ||
224
- currentSchema.primaryDatasource.postgresql.schemaValidation === "STRICT") {
257
+ if (postgresql?.database !== databaseId) {
258
+ (0, utils_1.logLabeledWarning)("dataconnect", `Switching connected Postgres database from ${postgresql?.database} to ${databaseId}`);
259
+ }
260
+ if (!postgresql || postgresql.schemaValidation === "STRICT") {
225
261
  return;
226
262
  }
227
- currentSchema.primaryDatasource.postgresql.schemaValidation = "STRICT";
263
+ postgresql.schemaValidation = "STRICT";
228
264
  try {
229
265
  await (0, client_1.upsertSchema)(currentSchema, false);
230
266
  }
@@ -236,10 +272,27 @@ async function ensureServiceIsConnectedToCloudSql(serviceName, instanceId, datab
236
272
  }
237
273
  }
238
274
  function displaySchemaChanges(error) {
239
- const message = "Your new schema is incompatible with the schema of your CloudSQL database. " +
240
- "The following SQL statements will migrate your database schema to match your new Data Connect schema.\n" +
241
- error.diffs.map(toString).join("\n");
242
- (0, utils_1.logLabeledWarning)("dataconnect", message);
275
+ switch (error.violationType) {
276
+ case "INCOMPATIBLE_SCHEMA":
277
+ {
278
+ const message = "Your new schema is incompatible with the schema of your CloudSQL database. " +
279
+ "The following SQL statements will migrate your database schema to match your new Data Connect schema.\n" +
280
+ error.diffs.map(toString).join("\n");
281
+ (0, utils_1.logLabeledWarning)("dataconnect", message);
282
+ }
283
+ break;
284
+ case "INACCESSIBLE_SCHEMA":
285
+ {
286
+ const message = "Cannot access your CloudSQL database to validate schema. " +
287
+ "The following SQL statements can setup a new database schema.\n" +
288
+ error.diffs.map(toString).join("\n");
289
+ (0, utils_1.logLabeledWarning)("dataconnect", message);
290
+ (0, utils_1.logLabeledWarning)("dataconnect", "Some SQL resources may already exist.");
291
+ }
292
+ break;
293
+ default:
294
+ throw new error_1.FirebaseError(`Unknown schema violation type: ${error.violationType}, IncompatibleSqlSchemaError: ${error}`);
295
+ }
243
296
  }
244
297
  function toString(diff) {
245
298
  return `\/** ${diff.destructive ? clc.red("Destructive: ") : ""}${diff.description}*\/\n${(0, sql_formatter_1.format)(diff.sql, { language: "postgresql" })}`;
@@ -1,11 +1,18 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.toDatasource = exports.requiresVector = exports.SCHEMA_ID = void 0;
3
+ exports.toDatasource = exports.Platform = exports.requiresVector = exports.SCHEMA_ID = void 0;
4
4
  exports.SCHEMA_ID = "main";
5
5
  function requiresVector(dm) {
6
6
  return dm?.primaryDataSource?.postgres?.requiredExtensions?.includes("vector") ?? false;
7
7
  }
8
8
  exports.requiresVector = requiresVector;
9
+ var Platform;
10
+ (function (Platform) {
11
+ Platform["ANDROID"] = "ANDROID";
12
+ Platform["WEB"] = "WEB";
13
+ Platform["IOS"] = "IOS";
14
+ Platform["UNDETERMINED"] = "UNDETERMINED";
15
+ })(Platform = exports.Platform || (exports.Platform = {}));
9
16
  function toDatasource(projectId, locationId, ds) {
10
17
  if (ds.postgresql) {
11
18
  return {
@@ -57,6 +57,7 @@ async function default_1(context, options) {
57
57
  instanceId,
58
58
  databaseId,
59
59
  enableGoogleMlIntegration,
60
+ waitForCreation: true,
60
61
  });
61
62
  }));
62
63
  return;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- const path = require("path");
3
+ const clc = require("colorette");
4
4
  const load_1 = require("../../dataconnect/load");
5
5
  const fileUtils_1 = require("../../dataconnect/fileUtils");
6
6
  const logger_1 = require("../../logger");
@@ -11,6 +11,7 @@ const build_1 = require("../../dataconnect/build");
11
11
  const ensureApis_1 = require("../../dataconnect/ensureApis");
12
12
  const requireTosAcceptance_1 = require("../../requireTosAcceptance");
13
13
  const firedata_1 = require("../../gcp/firedata");
14
+ const error_1 = require("../../error");
14
15
  async function default_1(context, options) {
15
16
  const projectId = (0, projectUtils_1.needProjectId)(options);
16
17
  await (0, ensureApis_1.ensureApis)(projectId);
@@ -18,10 +19,23 @@ async function default_1(context, options) {
18
19
  const serviceCfgs = (0, fileUtils_1.readFirebaseJson)(options.config);
19
20
  utils.logLabeledBullet("dataconnect", `Preparing to deploy`);
20
21
  const filters = (0, filters_1.getResourceFilters)(options);
21
- const serviceInfos = await Promise.all(serviceCfgs.map((c) => (0, load_1.load)(projectId, c.location, path.join(options.cwd || process.cwd(), c.source))));
22
+ const serviceInfos = await Promise.all(serviceCfgs.map((c) => (0, load_1.load)(projectId, options.config, c.source)));
22
23
  for (const si of serviceInfos) {
23
24
  si.deploymentMetadata = await (0, build_1.build)(options, si.sourceDirectory);
24
25
  }
26
+ const unmatchedFilters = filters?.filter((f) => {
27
+ const serviceMatched = serviceInfos.some((s) => s.dataConnectYaml.serviceId === f.serviceId);
28
+ const connectorMatched = f.connectorId
29
+ ? serviceInfos.some((s) => {
30
+ return (s.dataConnectYaml.serviceId === f.serviceId &&
31
+ s.connectorInfo.some((c) => c.connectorYaml.connectorId === f.connectorId));
32
+ })
33
+ : true;
34
+ return !serviceMatched || !connectorMatched;
35
+ });
36
+ if (unmatchedFilters?.length) {
37
+ throw new error_1.FirebaseError(`The following filters were specified in --only but didn't match anything in this project: ${unmatchedFilters.map(filters_1.toString).map(clc.bold).join(", ")}`);
38
+ }
25
39
  context.dataconnect = {
26
40
  serviceInfos,
27
41
  filters,
@@ -21,7 +21,6 @@ async function default_1(context, options) {
21
21
  await (0, schemaMigration_1.migrateSchema)({
22
22
  options,
23
23
  schema: s,
24
- allowNonInteractiveMigration: false,
25
24
  validateOnly: false,
26
25
  });
27
26
  }
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.toBackend = exports.resolveBackend = exports.AllIngressSettings = exports.AllVpcEgressSettings = exports.AllFunctionsPlatforms = exports.isBlockingTriggered = exports.isTaskQueueTriggered = exports.isScheduleTriggered = exports.isEventTriggered = exports.isCallableTriggered = exports.isHttpsTriggered = exports.of = exports.empty = void 0;
3
+ exports.toBackend = exports.envWithTypes = exports.resolveBackend = exports.AllIngressSettings = exports.AllVpcEgressSettings = exports.AllFunctionsPlatforms = exports.isBlockingTriggered = exports.isTaskQueueTriggered = exports.isScheduleTriggered = exports.isEventTriggered = exports.isCallableTriggered = exports.isHttpsTriggered = exports.of = exports.empty = void 0;
4
4
  const backend = require("./backend");
5
5
  const proto = require("../../gcp/proto");
6
6
  const api = require("../../.../../api");
@@ -114,12 +114,21 @@ function envWithTypes(definedParams, rawEnvs) {
114
114
  list: true,
115
115
  };
116
116
  }
117
+ else if (param.type === "secret") {
118
+ providedType = {
119
+ string: true,
120
+ boolean: false,
121
+ number: false,
122
+ list: false,
123
+ };
124
+ }
117
125
  }
118
126
  }
119
127
  out[envName] = new params.ParamValue(value, false, providedType);
120
128
  }
121
129
  return out;
122
130
  }
131
+ exports.envWithTypes = envWithTypes;
123
132
  class Resolver {
124
133
  constructor(paramValues) {
125
134
  this.paramValues = paramValues;
@@ -290,7 +290,7 @@ async function loadCodebases(config, options, firebaseConfig, runtimeConfig, fil
290
290
  const firebaseJsonRuntime = codebaseConfig.runtime;
291
291
  if (firebaseJsonRuntime && !supported.isRuntime(firebaseJsonRuntime)) {
292
292
  throw new error_1.FirebaseError(`Functions codebase ${codebase} has invalid runtime ` +
293
- `${firebaseJsonRuntime} specified in firebase.json. Valid values are: ` +
293
+ `${firebaseJsonRuntime} specified in firebase.json. Valid values are: \n` +
294
294
  Object.keys(supported.RUNTIMES)
295
295
  .map((s) => `- ${s}`)
296
296
  .join("\n"));
@@ -11,6 +11,7 @@ const api = require("../../.../../../../api");
11
11
  const v1alpha1 = require("./v1alpha1");
12
12
  const error_1 = require("../../../../error");
13
13
  exports.readFileAsync = (0, util_1.promisify)(fs.readFile);
14
+ const TIMEOUT_OVERRIDE_ENV_VAR = "FUNCTIONS_DISCOVERY_TIMEOUT";
14
15
  function yamlToBuild(yaml, project, region, runtime) {
15
16
  try {
16
17
  if (!yaml.specVersion) {
@@ -50,7 +51,7 @@ async function detectFromPort(port, project, runtime, timeout = 10000) {
50
51
  const timedOut = new Promise((resolve, reject) => {
51
52
  setTimeout(() => {
52
53
  reject(new error_1.FirebaseError("User code failed to load. Cannot determine backend specification"));
53
- }, timeout);
54
+ }, +(process.env[TIMEOUT_OVERRIDE_ENV_VAR] || 0) * 1000 || timeout);
54
55
  });
55
56
  while (true) {
56
57
  try {
@@ -53,6 +53,12 @@ exports.RUNTIMES = runtimes({
53
53
  deprecationDate: "2026-04-30",
54
54
  decommissionDate: "2026-10-31",
55
55
  },
56
+ nodejs22: {
57
+ friendly: "Node.js 22",
58
+ status: "beta",
59
+ deprecationDate: "2027-04-30",
60
+ decommissionDate: "2027-10-31",
61
+ },
56
62
  python310: {
57
63
  friendly: "Python 3.10",
58
64
  status: "GA",
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const chai_1 = require("chai");
4
+ const adminSdkConfig_1 = require("./adminSdkConfig");
5
+ describe("adminSdkConfig", () => {
6
+ describe("getProjectAdminSdkConfigOrCached", () => {
7
+ it("should return a fake config for a demo project id", async () => {
8
+ const projectId = "demo-project-1234";
9
+ await (0, chai_1.expect)((0, adminSdkConfig_1.getProjectAdminSdkConfigOrCached)(projectId)).to.eventually.deep.equal({
10
+ projectId: "demo-project-1234",
11
+ databaseURL: "https://demo-project-1234.firebaseio.com",
12
+ storageBucket: "demo-project-1234.appspot.com",
13
+ });
14
+ });
15
+ });
16
+ });
@@ -106,6 +106,7 @@ Constants.SERVICE_FIRESTORE = "firestore.googleapis.com";
106
106
  Constants.SERVICE_REALTIME_DATABASE = "firebaseio.com";
107
107
  Constants.SERVICE_PUBSUB = "pubsub.googleapis.com";
108
108
  Constants.SERVICE_EVENTARC = "eventarc.googleapis.com";
109
+ Constants.SERVICE_FIREALERTS = "firebasealerts.googleapis.com";
109
110
  Constants.SERVICE_ANALYTICS = "app-measurement.com";
110
111
  Constants.SERVICE_AUTH = "firebaseauth.googleapis.com";
111
112
  Constants.SERVICE_CRASHLYTICS = "fabric.io";
@@ -322,6 +322,7 @@ async function startAll(options, showUI = true, runningTestScript = false) {
322
322
  },
323
323
  secretEnv: [],
324
324
  predefinedTriggers: options.extDevTriggers,
325
+ ignore: cfg.ignore,
325
326
  });
326
327
  }
327
328
  }
@@ -522,7 +523,6 @@ async function startAll(options, showUI = true, runningTestScript = false) {
522
523
  await startEmulator(pubsubEmulator);
523
524
  }
524
525
  if (listenForEmulator.dataconnect) {
525
- const dataConnectAddr = legacyGetFirstAddr(types_1.Emulators.DATACONNECT);
526
526
  const config = (0, fileUtils_1.readFirebaseJson)(options.config);
527
527
  if (!config.length) {
528
528
  throw new error_1.FirebaseError("No Data Connect service found in firebase.json");
@@ -530,19 +530,14 @@ async function startAll(options, showUI = true, runningTestScript = false) {
530
530
  else if (config.length > 1) {
531
531
  logger_1.logger.warn(`TODO: Add support for multiple services in the Data Connect emulator. Currently emulating first service ${config[0].source}`);
532
532
  }
533
- let configDir = config[0].source;
534
- if (!path.isAbsolute(configDir)) {
535
- const cwd = options.cwd || process.cwd();
536
- configDir = path.resolve(path.join(cwd), configDir);
537
- }
533
+ const configDir = config[0].source;
538
534
  const dataConnectEmulator = new dataconnectEmulator_1.DataConnectEmulator({
539
- host: dataConnectAddr.host,
540
- port: dataConnectAddr.port,
535
+ listen: listenForEmulator.dataconnect,
541
536
  projectId,
542
537
  auto_download: true,
543
538
  configDir,
544
- locationId: config[0].location,
545
539
  rc: options.rc,
540
+ config: options.config,
546
541
  });
547
542
  await startEmulator(dataConnectEmulator);
548
543
  }