firebase-tools 12.6.2 → 12.7.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.
@@ -12,6 +12,7 @@ exports.command = new command_1.Command("emulators:exec <script>")
12
12
  .option(commandUtils.FLAG_INSPECT_FUNCTIONS, commandUtils.DESC_INSPECT_FUNCTIONS)
13
13
  .option(commandUtils.FLAG_IMPORT, commandUtils.DESC_IMPORT)
14
14
  .option(commandUtils.FLAG_EXPORT_ON_EXIT, commandUtils.DESC_EXPORT_ON_EXIT)
15
+ .option(commandUtils.FLAG_VERBOSITY, commandUtils.DESC_VERBOSITY)
15
16
  .option(commandUtils.FLAG_UI, commandUtils.DESC_UI)
16
17
  .action((script, options) => {
17
18
  return Promise.race([(0, commandUtils_1.shutdownWhenKilled)(options), (0, commandUtils_1.emulatorExec)(script, options)]);
@@ -22,6 +22,7 @@ exports.command = new command_1.Command("emulators:start")
22
22
  .option(commandUtils.FLAG_INSPECT_FUNCTIONS, commandUtils.DESC_INSPECT_FUNCTIONS)
23
23
  .option(commandUtils.FLAG_IMPORT, commandUtils.DESC_IMPORT)
24
24
  .option(commandUtils.FLAG_EXPORT_ON_EXIT, commandUtils.DESC_EXPORT_ON_EXIT)
25
+ .option(commandUtils.FLAG_VERBOSITY, commandUtils.DESC_VERBOSITY)
25
26
  .action((options) => {
26
27
  const killSignalPromise = commandUtils.shutdownWhenKilled(options);
27
28
  return Promise.race([
@@ -13,6 +13,7 @@ exports.command = new command_1.Command("firestore:databases:create <database>")
13
13
  .description("Create a database in your Firebase project.")
14
14
  .option("--location <locationId>", "Region to create database, for example 'nam5'. Run 'firebase firestore:locations' to get a list of eligible locations. (required)")
15
15
  .option("--delete-protection <deleteProtectionState>", "Whether or not to prevent deletion of database, for example 'ENABLED' or 'DISABLED'. Default is 'DISABLED'")
16
+ .option("--point-in-time-recovery <enablement>", "Whether to enable the PITR feature on this database, for example 'ENABLED' or 'DISABLED'. Default is 'DISABLED'")
16
17
  .before(requirePermissions_1.requirePermissions, ["datastore.databases.create"])
17
18
  .before(commandUtils_1.warnEmulatorNotSupported, types_1.Emulators.FIRESTORE)
18
19
  .action(async (database, options) => {
@@ -31,7 +32,16 @@ exports.command = new command_1.Command("firestore:databases:create <database>")
31
32
  const deleteProtectionState = options.deleteProtection === types.DatabaseDeleteProtectionStateOption.ENABLED
32
33
  ? types.DatabaseDeleteProtectionState.ENABLED
33
34
  : types.DatabaseDeleteProtectionState.DISABLED;
34
- const databaseResp = await api.createDatabase(options.project, database, options.location, type, deleteProtectionState);
35
+ if (options.pointInTimeRecovery &&
36
+ options.pointInTimeRecovery !== types.PointInTimeRecoveryEnablementOption.ENABLED &&
37
+ options.pointInTimeRecovery !== types.PointInTimeRecoveryEnablementOption.DISABLED) {
38
+ logger_1.logger.error("Invalid value for flag --point-in-time-recovery. See firebase firestore:databases:create --help for more info.");
39
+ return;
40
+ }
41
+ const pointInTimeRecoveryEnablement = options.pointInTimeRecovery === types.PointInTimeRecoveryEnablementOption.ENABLED
42
+ ? types.PointInTimeRecoveryEnablement.ENABLED
43
+ : types.PointInTimeRecoveryEnablement.DISABLED;
44
+ const databaseResp = await api.createDatabase(options.project, database, options.location, type, deleteProtectionState, pointInTimeRecoveryEnablement);
35
45
  if (options.json) {
36
46
  logger_1.logger.info(JSON.stringify(databaseResp, undefined, 2));
37
47
  }
@@ -13,11 +13,12 @@ exports.command = new command_1.Command("firestore:databases:update <database>")
13
13
  .description("Update a database in your Firebase project. Must specify at least one property to update.")
14
14
  .option("--json", "Prints raw json response of the create API call if specified")
15
15
  .option("--delete-protection <deleteProtectionState>", "Whether or not to prevent deletion of database, for example 'ENABLED' or 'DISABLED'. Default is 'DISABLED'")
16
+ .option("--point-in-time-recovery <enablement>", "Whether to enable the PITR feature on this database, for example 'ENABLED' or 'DISABLED'. Default is 'DISABLED'")
16
17
  .before(requirePermissions_1.requirePermissions, ["datastore.databases.update"])
17
18
  .before(commandUtils_1.warnEmulatorNotSupported, types_1.Emulators.FIRESTORE)
18
19
  .action(async (database, options) => {
19
20
  const api = new fsi.FirestoreApi();
20
- if (!options.type && !options.deleteProtection) {
21
+ if (!options.type && !options.deleteProtection && !options.pointInTimeRecovery) {
21
22
  logger_1.logger.error("Missing properties to update. See firebase firestore:databases:update --help for more info.");
22
23
  return;
23
24
  }
@@ -31,7 +32,16 @@ exports.command = new command_1.Command("firestore:databases:update <database>")
31
32
  const deleteProtectionState = options.deleteProtection === types.DatabaseDeleteProtectionStateOption.ENABLED
32
33
  ? types.DatabaseDeleteProtectionState.ENABLED
33
34
  : types.DatabaseDeleteProtectionState.DISABLED;
34
- const databaseResp = await api.updateDatabase(options.project, database, type, deleteProtectionState);
35
+ if (options.pointInTimeRecovery &&
36
+ options.pointInTimeRecovery !== types.PointInTimeRecoveryEnablementOption.ENABLED &&
37
+ options.pointInTimeRecovery !== types.PointInTimeRecoveryEnablementOption.DISABLED) {
38
+ logger_1.logger.error("Invalid value for flag --point-in-time-recovery. See firebase firestore:databases:update --help for more info.");
39
+ return;
40
+ }
41
+ const pointInTimeRecoveryEnablement = options.pointInTimeRecovery === types.PointInTimeRecoveryEnablementOption.ENABLED
42
+ ? types.PointInTimeRecoveryEnablement.ENABLED
43
+ : types.PointInTimeRecoveryEnablement.DISABLED;
44
+ const databaseResp = await api.updateDatabase(options.project, database, type, deleteProtectionState, pointInTimeRecoveryEnablement);
35
45
  if (options.json) {
36
46
  logger_1.logger.info(JSON.stringify(databaseResp, undefined, 2));
37
47
  }
@@ -69,9 +69,9 @@ const choices = [
69
69
  checked: false,
70
70
  },
71
71
  ];
72
- if ((0, experiments_1.isEnabled)("frameworks")) {
72
+ if ((0, experiments_1.isEnabled)("internalframeworks")) {
73
73
  choices.push({
74
- value: "frameworks",
74
+ value: "internalframeworks",
75
75
  name: "Frameworks: Get started with Frameworks projects.",
76
76
  checked: false,
77
77
  });
@@ -79,7 +79,7 @@ if ((0, experiments_1.isEnabled)("frameworks")) {
79
79
  const featureNames = choices.map((choice) => choice.value);
80
80
  const DESCRIPTION = `Interactively configure the current directory as a Firebase project or initialize new features in an already configured Firebase project directory.
81
81
 
82
- This command will create or update 'firebase.json' and '.firebaserc' configuration files in the current directory.
82
+ This command will create or update 'firebase.json' and '.firebaserc' configuration files in the current directory.
83
83
 
84
84
  To initialize a specific Firebase feature, run 'firebase init [feature]'. Valid features are:
85
85
  ${[...featureNames]
@@ -8,6 +8,7 @@ const params = require("./params");
8
8
  const error_1 = require("../../error");
9
9
  const functional_1 = require("../../functional");
10
10
  const env_1 = require("../../functions/env");
11
+ const cel_1 = require("./cel");
11
12
  function empty() {
12
13
  return {
13
14
  requiredAPIs: [],
@@ -176,9 +177,22 @@ function toBackend(build, paramValues) {
176
177
  if (!bdEndpoint.region) {
177
178
  regions = [api.functionsDefaultRegion];
178
179
  }
179
- else {
180
+ else if (Array.isArray(bdEndpoint.region)) {
180
181
  regions = params.resolveList(bdEndpoint.region, paramValues);
181
182
  }
183
+ else {
184
+ try {
185
+ regions = params.resolveList(bdEndpoint.region, paramValues);
186
+ }
187
+ catch (err) {
188
+ if (err instanceof cel_1.ExprParseError) {
189
+ regions = [params.resolveString(bdEndpoint.region, paramValues)];
190
+ }
191
+ else {
192
+ throw err;
193
+ }
194
+ }
195
+ }
182
196
  for (const region of regions) {
183
197
  const trigger = discoverTrigger(bdEndpoint, region, r);
184
198
  if (typeof bdEndpoint.platform === "undefined") {
@@ -203,10 +217,11 @@ function toBackend(build, paramValues) {
203
217
  r.resolveInts(bkEndpoint, bdEndpoint, "timeoutSeconds", "maxInstances", "minInstances", "concurrency");
204
218
  proto.convertIfPresent(bkEndpoint, bdEndpoint, "cpu", (0, functional_1.nullsafeVisitor)((cpu) => (cpu === "gcf_gen1" ? cpu : r.resolveInt(cpu))));
205
219
  if (bdEndpoint.vpc) {
220
+ bdEndpoint.vpc.connector = params.resolveString(bdEndpoint.vpc.connector, paramValues);
206
221
  if (bdEndpoint.vpc.connector && !bdEndpoint.vpc.connector.includes("/")) {
207
222
  bdEndpoint.vpc.connector = `projects/${bdEndpoint.project}/locations/${region}/connectors/${bdEndpoint.vpc.connector}`;
208
223
  }
209
- bkEndpoint.vpc = { connector: params.resolveString(bdEndpoint.vpc.connector, paramValues) };
224
+ bkEndpoint.vpc = { connector: bdEndpoint.vpc.connector };
210
225
  proto.copyIfPresent(bkEndpoint.vpc, bdEndpoint.vpc, "egressSettings");
211
226
  }
212
227
  else if (bdEndpoint.vpc === null) {
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.JAVA_DEPRECATION_WARNING = exports.MIN_SUPPORTED_JAVA_MAJOR_VERSION = exports.checkJavaMajorVersion = exports.emulatorExec = exports.getListenOverview = exports.shutdownWhenKilled = exports.setExportOnExitOptions = exports.parseInspectionPort = exports.beforeEmulatorCommand = exports.warnEmulatorNotSupported = exports.printNoticeIfEmulated = exports.DEFAULT_CONFIG = exports.DESC_TEST_PARAMS = exports.FLAG_TEST_PARAMS = exports.DESC_TEST_CONFIG = exports.FLAG_TEST_CONFIG = exports.DESC_UI = exports.FLAG_UI = exports.EXPORT_ON_EXIT_CWD_DANGER = exports.EXPORT_ON_EXIT_USAGE_ERROR = exports.DESC_EXPORT_ON_EXIT = exports.FLAG_EXPORT_ON_EXIT = exports.FLAG_EXPORT_ON_EXIT_NAME = exports.DESC_IMPORT = exports.FLAG_IMPORT = exports.DESC_INSPECT_FUNCTIONS = exports.FLAG_INSPECT_FUNCTIONS = exports.DESC_ONLY = exports.FLAG_ONLY = void 0;
3
+ exports.JAVA_DEPRECATION_WARNING = exports.MIN_SUPPORTED_JAVA_MAJOR_VERSION = exports.checkJavaMajorVersion = exports.emulatorExec = exports.getListenOverview = exports.shutdownWhenKilled = exports.setExportOnExitOptions = exports.parseInspectionPort = exports.beforeEmulatorCommand = exports.warnEmulatorNotSupported = exports.printNoticeIfEmulated = exports.DEFAULT_CONFIG = exports.DESC_TEST_PARAMS = exports.FLAG_TEST_PARAMS = exports.DESC_TEST_CONFIG = exports.FLAG_TEST_CONFIG = exports.DESC_UI = exports.FLAG_UI = exports.DESC_VERBOSITY = exports.FLAG_VERBOSITY = exports.FLAG_VERBOSITY_NAME = exports.EXPORT_ON_EXIT_CWD_DANGER = exports.EXPORT_ON_EXIT_USAGE_ERROR = exports.DESC_EXPORT_ON_EXIT = exports.FLAG_EXPORT_ON_EXIT = exports.FLAG_EXPORT_ON_EXIT_NAME = exports.DESC_IMPORT = exports.FLAG_IMPORT = exports.DESC_INSPECT_FUNCTIONS = exports.FLAG_INSPECT_FUNCTIONS = exports.DESC_ONLY = exports.FLAG_ONLY = void 0;
4
4
  const clc = require("colorette");
5
5
  const childProcess = require("child_process");
6
6
  const controller = require("../emulator/controller");
@@ -37,6 +37,9 @@ exports.DESC_EXPORT_ON_EXIT = "automatically export emulator data (emulators:exp
37
37
  exports.EXPORT_ON_EXIT_USAGE_ERROR = `"${exports.FLAG_EXPORT_ON_EXIT_NAME}" must be used with "${exports.FLAG_IMPORT}"` +
38
38
  ` or provide a dir directly to "${exports.FLAG_EXPORT_ON_EXIT}"`;
39
39
  exports.EXPORT_ON_EXIT_CWD_DANGER = `"${exports.FLAG_EXPORT_ON_EXIT_NAME}" must not point to the current directory or parents. Please choose a new/dedicated directory for exports.`;
40
+ exports.FLAG_VERBOSITY_NAME = "--log-verbosity";
41
+ exports.FLAG_VERBOSITY = `${exports.FLAG_VERBOSITY_NAME} <verbosity>`;
42
+ exports.DESC_VERBOSITY = "One of: DEBUG, INFO, QUIET, SILENT. ";
40
43
  exports.FLAG_UI = "--ui";
41
44
  exports.DESC_UI = "run the Emulator UI";
42
45
  exports.FLAG_TEST_CONFIG = "--test-config <firebase.json file>";
@@ -170,6 +170,9 @@ async function startAll(options, showUI = true, runningTestScript = false) {
170
170
  throw new error_1.FirebaseError(commandUtils_1.JAVA_DEPRECATION_WARNING);
171
171
  }
172
172
  }
173
+ if (options.logVerbosity) {
174
+ emulatorLogger_1.EmulatorLogger.setVerbosity(emulatorLogger_1.Verbosity[options.logVerbosity]);
175
+ }
173
176
  const hubLogger = emulatorLogger_1.EmulatorLogger.forEmulator(types_1.Emulators.HUB);
174
177
  hubLogger.logLabeled("BULLET", "emulators", `Starting emulators: ${targets.join(", ")}`);
175
178
  const projectId = (0, projectUtils_1.getProjectId)(options) || "";
@@ -21,12 +21,16 @@ var Verbosity;
21
21
  Verbosity[Verbosity["DEBUG"] = 0] = "DEBUG";
22
22
  Verbosity[Verbosity["INFO"] = 1] = "INFO";
23
23
  Verbosity[Verbosity["QUIET"] = 2] = "QUIET";
24
+ Verbosity[Verbosity["SILENT"] = 3] = "SILENT";
24
25
  })(Verbosity = exports.Verbosity || (exports.Verbosity = {}));
25
26
  class EmulatorLogger {
26
27
  constructor(name, data = {}) {
27
28
  this.name = name;
28
29
  this.data = data;
29
30
  }
31
+ static setVerbosity(verbosity) {
32
+ EmulatorLogger.verbosity = verbosity;
33
+ }
30
34
  static forEmulator(emulator) {
31
35
  return new EmulatorLogger(emulator, {
32
36
  metadata: {
@@ -82,7 +82,7 @@ class FunctionsEmulator {
82
82
  this.multicastTriggers = {};
83
83
  this.blockingFunctionsConfig = {};
84
84
  this.debugMode = false;
85
- emulatorLogger_1.EmulatorLogger.verbosity = this.args.quiet ? emulatorLogger_1.Verbosity.QUIET : emulatorLogger_1.Verbosity.DEBUG;
85
+ emulatorLogger_1.EmulatorLogger.setVerbosity(this.args.quiet ? emulatorLogger_1.Verbosity.QUIET : emulatorLogger_1.Verbosity.DEBUG);
86
86
  if (this.args.debugPort) {
87
87
  this.args.disabledRuntimeFeatures = this.args.disabledRuntimeFeatures || {};
88
88
  this.args.disabledRuntimeFeatures.timeout = true;
@@ -72,7 +72,7 @@ exports.ALL_EXPERIMENTS = experiments({
72
72
  "These commands are not meant for public consumption and may break or disappear " +
73
73
  "without a notice.",
74
74
  },
75
- frameworks: {
75
+ internalframeworks: {
76
76
  shortDescription: "Allow CLI option for Frameworks",
77
77
  default: true,
78
78
  public: false,
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.DatabaseDeleteProtectionState = exports.DatabaseDeleteProtectionStateOption = exports.DatabaseType = exports.StateTtl = exports.State = exports.ArrayConfig = exports.Order = exports.QueryScope = exports.Mode = void 0;
3
+ exports.PointInTimeRecoveryEnablement = exports.PointInTimeRecoveryEnablementOption = exports.DatabaseDeleteProtectionState = exports.DatabaseDeleteProtectionStateOption = exports.DatabaseType = exports.StateTtl = exports.State = exports.ArrayConfig = exports.Order = exports.QueryScope = exports.Mode = void 0;
4
4
  var Mode;
5
5
  (function (Mode) {
6
6
  Mode["ASCENDING"] = "ASCENDING";
@@ -48,3 +48,13 @@ var DatabaseDeleteProtectionState;
48
48
  DatabaseDeleteProtectionState["ENABLED"] = "DELETE_PROTECTION_ENABLED";
49
49
  DatabaseDeleteProtectionState["DISABLED"] = "DELETE_PROTECTION_DISABLED";
50
50
  })(DatabaseDeleteProtectionState = exports.DatabaseDeleteProtectionState || (exports.DatabaseDeleteProtectionState = {}));
51
+ var PointInTimeRecoveryEnablementOption;
52
+ (function (PointInTimeRecoveryEnablementOption) {
53
+ PointInTimeRecoveryEnablementOption["ENABLED"] = "ENABLED";
54
+ PointInTimeRecoveryEnablementOption["DISABLED"] = "DISABLED";
55
+ })(PointInTimeRecoveryEnablementOption = exports.PointInTimeRecoveryEnablementOption || (exports.PointInTimeRecoveryEnablementOption = {}));
56
+ var PointInTimeRecoveryEnablement;
57
+ (function (PointInTimeRecoveryEnablement) {
58
+ PointInTimeRecoveryEnablement["ENABLED"] = "POINT_IN_TIME_RECOVERY_ENABLED";
59
+ PointInTimeRecoveryEnablement["DISABLED"] = "POINT_IN_TIME_RECOVERY_DISABLED";
60
+ })(PointInTimeRecoveryEnablement = exports.PointInTimeRecoveryEnablement || (exports.PointInTimeRecoveryEnablement = {}));
@@ -214,7 +214,7 @@ class FirestoreApi {
214
214
  head: ["Field", "Value"],
215
215
  colWidths: [25, Math.max(50, 5 + database.name.length)],
216
216
  });
217
- table.push(["Name", clc.yellow(database.name)], ["Create Time", clc.yellow(database.createTime)], ["Last Update Time", clc.yellow(database.updateTime)], ["Type", clc.yellow(database.type)], ["Location", clc.yellow(database.locationId)], ["Delete Protection State", clc.yellow(database.deleteProtectionState)]);
217
+ table.push(["Name", clc.yellow(database.name)], ["Create Time", clc.yellow(database.createTime)], ["Last Update Time", clc.yellow(database.updateTime)], ["Type", clc.yellow(database.type)], ["Location", clc.yellow(database.locationId)], ["Delete Protection State", clc.yellow(database.deleteProtectionState)], ["Point In Time Recovery", clc.yellow(database.pointInTimeRecoveryEnablement)], ["Earliest Version Time", clc.yellow(database.earliestVersionTime)], ["Version Retention Period", clc.yellow(database.versionRetentionPeriod)]);
218
218
  logger_1.logger.info(table.toString());
219
219
  }
220
220
  prettyPrintLocations(locations) {
@@ -469,12 +469,13 @@ class FirestoreApi {
469
469
  }
470
470
  return database;
471
471
  }
472
- async createDatabase(project, databaseId, locationId, type, deleteProtectionState) {
472
+ async createDatabase(project, databaseId, locationId, type, deleteProtectionState, pointInTimeRecoveryEnablement) {
473
473
  const url = `/projects/${project}/databases`;
474
474
  const payload = {
475
475
  type,
476
476
  locationId,
477
477
  deleteProtectionState,
478
+ pointInTimeRecoveryEnablement,
478
479
  };
479
480
  const options = { queryParams: { databaseId: databaseId } };
480
481
  const res = await this.apiClient.post(url, payload, options);
@@ -484,11 +485,12 @@ class FirestoreApi {
484
485
  }
485
486
  return database;
486
487
  }
487
- async updateDatabase(project, databaseId, type, deleteProtectionState) {
488
+ async updateDatabase(project, databaseId, type, deleteProtectionState, pointInTimeRecoveryEnablement) {
488
489
  const url = `/projects/${project}/databases/${databaseId}`;
489
490
  const payload = {
490
491
  type,
491
492
  deleteProtectionState,
493
+ pointInTimeRecoveryEnablement,
492
494
  };
493
495
  const res = await this.apiClient.patch(url, payload);
494
496
  const database = res.body.response;
@@ -7,7 +7,7 @@ const logger_1 = require("../logger");
7
7
  const apiClient = new apiv2_1.Client({
8
8
  auth: true,
9
9
  apiVersion: "v1",
10
- urlPrefix: api_1.firestoreOriginOrEmulator,
10
+ urlPrefix: api_1.firestoreOrigin,
11
11
  });
12
12
  async function getDatabase(project, database) {
13
13
  const url = `projects/${project}/databases/${database}`;
package/lib/init/index.js CHANGED
@@ -20,8 +20,8 @@ const featureFns = new Map([
20
20
  ["remoteconfig", features.remoteconfig],
21
21
  ["hosting:github", features.hostingGithub],
22
22
  ]);
23
- if ((0, experiments_1.isEnabled)("frameworks")) {
24
- featureFns.set("frameworks", features.frameworks);
23
+ if ((0, experiments_1.isEnabled)("internalframeworks")) {
24
+ featureFns.set("internalframeworks", features.frameworks);
25
25
  }
26
26
  async function init(setup, config, options) {
27
27
  var _a;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "firebase-tools",
3
- "version": "12.6.2",
3
+ "version": "12.7.0",
4
4
  "description": "Command-Line Interface for Firebase",
5
5
  "main": "./lib/index.js",
6
6
  "bin": {