firebase-tools 12.6.2 → 12.8.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
  }
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.command = void 0;
4
+ const command_1 = require("../command");
5
+ const projectUtils_1 = require("../projectUtils");
6
+ const requireInteractive_1 = require("../requireInteractive");
7
+ const frameworks_1 = require("../init/features/frameworks");
8
+ exports.command = new command_1.Command("stacks:create")
9
+ .description("Create a stack in a Firebase project")
10
+ .before(requireInteractive_1.default)
11
+ .action(async (options) => {
12
+ const projectId = (0, projectUtils_1.needProjectId)(options);
13
+ await (0, frameworks_1.doSetup)(options, projectId);
14
+ });
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.command = void 0;
4
+ const command_1 = require("../command");
5
+ const projectUtils_1 = require("../projectUtils");
6
+ const error_1 = require("../error");
7
+ const gcp = require("../gcp/frameworks");
8
+ const prompt_1 = require("../prompt");
9
+ const utils = require("../utils");
10
+ exports.command = new command_1.Command("stacks:delete")
11
+ .description("Delete a stack from a Firebase project")
12
+ .option("-l, --location <location>", "App Backend location", "us-central1")
13
+ .option("-s, --stackId <stackId>", "Stack Id", "")
14
+ .withForce()
15
+ .action(async (options) => {
16
+ const projectId = (0, projectUtils_1.needProjectId)(options);
17
+ const location = options.location;
18
+ const stackId = options.stackId;
19
+ if (!stackId) {
20
+ throw new error_1.FirebaseError("Stack id can't be empty.");
21
+ }
22
+ const confirmDeletion = await (0, prompt_1.promptOnce)({
23
+ type: "confirm",
24
+ name: "force",
25
+ default: false,
26
+ message: "You are about to delete the Stack with id: " + stackId + "\n Are you sure?",
27
+ }, options);
28
+ if (!confirmDeletion) {
29
+ throw new error_1.FirebaseError("Deletion aborted.");
30
+ }
31
+ try {
32
+ await gcp.deleteStack(projectId, location, stackId);
33
+ utils.logSuccess(`Successfully deleted the stack: ${stackId}`);
34
+ }
35
+ catch (err) {
36
+ throw new error_1.FirebaseError(`Failed to delete stack: ${stackId}. Please check the parameters you have provided.`, { original: err });
37
+ }
38
+ });
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.command = void 0;
4
+ const command_1 = require("../command");
5
+ const projectUtils_1 = require("../projectUtils");
6
+ const gcp = require("../gcp/frameworks");
7
+ const error_1 = require("../error");
8
+ const logger_1 = require("../logger");
9
+ exports.command = new command_1.Command("stacks:get")
10
+ .description("Get stack details of a Firebase project")
11
+ .option("-l, --location <location>", "App Backend location", "us-central1")
12
+ .option("--s, --stackId <stackId>", "Stack Id", "")
13
+ .action(async (options) => {
14
+ const projectId = (0, projectUtils_1.needProjectId)(options);
15
+ const location = options.location;
16
+ const stackId = options.stackId;
17
+ if (!stackId) {
18
+ throw new error_1.FirebaseError("Stack id can't be empty.");
19
+ }
20
+ let stack;
21
+ try {
22
+ stack = await gcp.getStack(projectId, location, stackId);
23
+ logger_1.logger.info(stack);
24
+ }
25
+ catch (err) {
26
+ throw new error_1.FirebaseError(`Failed to get stack: ${stackId}. Please check the parameters you have provided.`, { original: err });
27
+ }
28
+ return stack;
29
+ });
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.command = void 0;
4
+ const command_1 = require("../command");
5
+ const projectUtils_1 = require("../projectUtils");
6
+ const gcp = require("../gcp/frameworks");
7
+ const error_1 = require("../error");
8
+ const logger_1 = require("../logger");
9
+ exports.command = new command_1.Command("stacks:list")
10
+ .description("List stacks of a Firebase project.")
11
+ .option("-l, --location <location>", "App Backend location", "us-central1")
12
+ .action(async (options) => {
13
+ const projectId = (0, projectUtils_1.needProjectId)(options);
14
+ const location = options.location;
15
+ let stacks;
16
+ try {
17
+ stacks = await gcp.listStack(projectId, location);
18
+ logger_1.logger.info(stacks);
19
+ }
20
+ catch (err) {
21
+ throw new error_1.FirebaseError(`Unable to list stacks present in project: ${projectId}. Please check the parameters you have provided.`, { original: err });
22
+ }
23
+ return stacks;
24
+ });
@@ -145,6 +145,14 @@ function load(client) {
145
145
  client.internaltesting.functions = {};
146
146
  client.internaltesting.functions.discover = loadCommand("internaltesting-functions-discover");
147
147
  }
148
+ if (experiments.isEnabled("internalframeworks")) {
149
+ client.frameworks = {};
150
+ client.frameworks.stacks = {};
151
+ client.frameworks.stacks.list = loadCommand("frameworks-stacks-list");
152
+ client.frameworks.stacks.create = loadCommand("frameworks-stacks-create");
153
+ client.frameworks.stacks.create = loadCommand("frameworks-stacks-get");
154
+ client.frameworks.stacks.create = loadCommand("frameworks-stacks-delete");
155
+ }
148
156
  client.login = loadCommand("login");
149
157
  client.login.add = loadCommand("login-add");
150
158
  client.login.ci = loadCommand("login-ci");
@@ -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;
@@ -241,6 +241,7 @@ function loadFirebaseEnvs(firebaseConfig, projectId) {
241
241
  return {
242
242
  FIREBASE_CONFIG: JSON.stringify(firebaseConfig),
243
243
  GCLOUD_PROJECT: projectId,
244
+ FIRESTORE_PREFER_REST: "true",
244
245
  };
245
246
  }
246
247
  exports.loadFirebaseEnvs = loadFirebaseEnvs;
@@ -304,7 +304,8 @@ function endpointFromFunction(gcfFunction) {
304
304
  else if (gcfFunction.eventTrigger) {
305
305
  const eventFilters = {};
306
306
  const eventFilterPathPatterns = {};
307
- if (gcfFunction.eventTrigger.pubsubTopic) {
307
+ if (gcfFunction.eventTrigger.pubsubTopic &&
308
+ gcfFunction.eventTrigger.eventType === v2_1.PUBSUB_PUBLISH_EVENT) {
308
309
  eventFilters.topic = gcfFunction.eventTrigger.pubsubTopic;
309
310
  }
310
311
  else {
@@ -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}`;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createBuild = exports.getStack = exports.createStack = exports.API_VERSION = void 0;
3
+ exports.createBuild = exports.deleteStack = exports.listStack = exports.getStack = exports.createStack = exports.API_VERSION = void 0;
4
4
  const apiv2_1 = require("../apiv2");
5
5
  const api_1 = require("../api");
6
6
  exports.API_VERSION = "v1alpha";
@@ -9,21 +9,32 @@ const client = new apiv2_1.Client({
9
9
  auth: true,
10
10
  apiVersion: exports.API_VERSION,
11
11
  });
12
- async function createStack(projectId, location, stackInput) {
13
- const stackId = stackInput.name;
14
- const res = await client.post(`projects/${projectId}/locations/${location}/stacks`, stackInput, { queryParams: { stackId } });
12
+ async function createStack(projectId, location, stackReqBoby, backendId) {
13
+ const res = await client.post(`projects/${projectId}/locations/${location}/backends`, stackReqBoby, { queryParams: { backendId } });
15
14
  return res.body;
16
15
  }
17
16
  exports.createStack = createStack;
18
17
  async function getStack(projectId, location, stackId) {
19
- const name = `projects/${projectId}/locations/${location}/stacks/${stackId}`;
18
+ const name = `projects/${projectId}/locations/${location}/backends/${stackId}`;
20
19
  const res = await client.get(name);
21
20
  return res.body;
22
21
  }
23
22
  exports.getStack = getStack;
23
+ async function listStack(projectId, location) {
24
+ const name = `projects/${projectId}/locations/${location}/backends`;
25
+ const res = await client.get(name);
26
+ return res.body;
27
+ }
28
+ exports.listStack = listStack;
29
+ async function deleteStack(projectId, location, stackId) {
30
+ const name = `projects/${projectId}/locations/${location}/backends/${stackId}`;
31
+ const res = await client.delete(name);
32
+ return res.body;
33
+ }
34
+ exports.deleteStack = deleteStack;
24
35
  async function createBuild(projectId, location, stackId, buildInput) {
25
36
  const buildId = buildInput.name;
26
- const res = await client.post(`projects/${projectId}/locations/${location}/stacks/${stackId}/builds`, buildInput, { queryParams: { buildId } });
37
+ const res = await client.post(`projects/${projectId}/locations/${location}/backends/${stackId}/builds`, buildInput, { queryParams: { buildId } });
27
38
  return res.body;
28
39
  }
29
40
  exports.createBuild = createBuild;
@@ -217,7 +217,7 @@ async function getCleanDomains(project, site) {
217
217
  acc[current] = true;
218
218
  return acc;
219
219
  }, {});
220
- const siteMatch = new RegExp(`${site}--`, "i");
220
+ const siteMatch = new RegExp(`^${site}--`, "i");
221
221
  const firebaseAppMatch = new RegExp(/firebaseapp.com$/);
222
222
  const domains = await (0, auth_1.getAuthDomains)(project);
223
223
  const authDomains = [];
@@ -18,9 +18,7 @@ const frameworksPollerOptions = {
18
18
  masterTimeout: 25 * 60 * 1000,
19
19
  maxBackoff: 10000,
20
20
  };
21
- async function doSetup(setup) {
22
- var _a, _b;
23
- const projectId = (_b = (_a = setup === null || setup === void 0 ? void 0 : setup.rcfile) === null || _a === void 0 ? void 0 : _a.projects) === null || _b === void 0 ? void 0 : _b.default;
21
+ async function doSetup(setup, projectId) {
24
22
  setup.frameworks = {};
25
23
  utils.logBullet("First we need a few details to create your service.");
26
24
  await (0, prompt_1.promptOnce)({
@@ -46,12 +44,18 @@ async function doSetup(setup) {
46
44
  message: "How do you want to deploy",
47
45
  choices: constants_1.ALLOWED_DEPLOY_METHODS,
48
46
  }, setup.frameworks);
49
- await getOrCreateStack(projectId, setup);
47
+ const stack = await getOrCreateStack(projectId, setup);
48
+ if (stack) {
49
+ utils.logSuccess(`Successfully created a stack: ${stack.name}`);
50
+ }
50
51
  }
51
52
  exports.doSetup = doSetup;
52
- function toStack(cloudBuildConnRepo, stackId) {
53
+ function toStack(cloudBuildConnRepo) {
53
54
  return {
54
- name: stackId,
55
+ codebase: {
56
+ repository: `${cloudBuildConnRepo.name}`,
57
+ rootDirectory: "/",
58
+ },
55
59
  labels: {},
56
60
  };
57
61
  }
@@ -65,9 +69,9 @@ async function getOrCreateStack(projectId, setup) {
65
69
  if (err.status === 404) {
66
70
  logger_1.logger.info("Creating new stack.");
67
71
  if (deployMethod === "github") {
68
- const cloudBuildConnRepo = await repo.linkGitHubRepository(projectId, location, setup.frameworks.serviceName);
69
- const stackDetails = toStack(cloudBuildConnRepo, setup.frameworks.serviceName);
70
- return await createStack(projectId, location, stackDetails);
72
+ const cloudBuildConnRepo = await repo.linkGitHubRepository(projectId, location);
73
+ const stackDetails = toStack(cloudBuildConnRepo);
74
+ return await createStack(projectId, location, stackDetails, setup.frameworks.serviceName);
71
75
  }
72
76
  }
73
77
  else {
@@ -102,9 +106,9 @@ async function getExistingStack(projectId, setup, location) {
102
106
  }
103
107
  return stack;
104
108
  }
105
- async function createStack(projectId, location, stackInput) {
106
- const op = await gcp.createStack(projectId, location, stackInput);
107
- const stack = await poller.pollOperation(Object.assign(Object.assign({}, frameworksPollerOptions), { pollerName: `create-${projectId}-${location}-${stackInput.name}`, operationResourceName: op.name }));
109
+ async function createStack(projectId, location, stackReqBoby, stackId) {
110
+ const op = await gcp.createStack(projectId, location, stackReqBoby, stackId);
111
+ const stack = await poller.pollOperation(Object.assign(Object.assign({}, frameworksPollerOptions), { pollerName: `create-${projectId}-${location}-${stackId}`, operationResourceName: op.name }));
108
112
  return stack;
109
113
  }
110
114
  exports.createStack = createStack;
@@ -21,11 +21,15 @@ function extractRepoSlugFromURI(remoteUri) {
21
21
  }
22
22
  return match[1];
23
23
  }
24
- function generateRepositoryId() {
25
- return `composer-repo`;
24
+ function generateRepositoryId(remoteUri) {
25
+ var _a;
26
+ return (_a = extractRepoSlugFromURI(remoteUri)) === null || _a === void 0 ? void 0 : _a.replaceAll("/", "-");
26
27
  }
27
- async function linkGitHubRepository(projectId, location, stackId) {
28
- const connectionId = stackId;
28
+ function generateConnectionId(location) {
29
+ return `frameworks-${location}`;
30
+ }
31
+ async function linkGitHubRepository(projectId, location) {
32
+ const connectionId = generateConnectionId(location);
29
33
  await getOrCreateConnection(projectId, location, connectionId);
30
34
  let remoteUri = await promptRepositoryURI(projectId, location, connectionId);
31
35
  while (remoteUri === "") {
@@ -92,7 +96,7 @@ async function getOrCreateConnection(projectId, location, connectionId) {
92
96
  }
93
97
  exports.getOrCreateConnection = getOrCreateConnection;
94
98
  async function getOrCreateRepository(projectId, location, connectionId, remoteUri) {
95
- const repositoryId = generateRepositoryId();
99
+ const repositoryId = generateRepositoryId(remoteUri);
96
100
  if (!repositoryId) {
97
101
  throw new error_1.FirebaseError(`Failed to generate repositoryId for URI "${remoteUri}".`);
98
102
  }
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.8.0",
4
4
  "description": "Command-Line Interface for Firebase",
5
5
  "main": "./lib/index.js",
6
6
  "bin": {