Нет описания
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. exports.command = void 0;
  4. const url_1 = require("url");
  5. const apiv2_1 = require("../apiv2");
  6. const command_1 = require("../command");
  7. const settings_1 = require("../database/settings");
  8. const types_1 = require("../emulator/types");
  9. const error_1 = require("../error");
  10. const database_1 = require("../management/database");
  11. const api_1 = require("../database/api");
  12. const requirePermissions_1 = require("../requirePermissions");
  13. const commandUtils_1 = require("../emulator/commandUtils");
  14. const requireDatabaseInstance_1 = require("../requireDatabaseInstance");
  15. const utils = require("../utils");
  16. exports.command = new command_1.Command("database:settings:set <path> <value>")
  17. .description("set the realtime database setting at path.")
  18. .option("--instance <instance>", "use the database <instance>.firebaseio.com (if omitted, use default database instance)")
  19. .help(settings_1.HELP_TEXT)
  20. .before(requirePermissions_1.requirePermissions, ["firebasedatabase.instances.update"])
  21. .before(requireDatabaseInstance_1.requireDatabaseInstance)
  22. .before(database_1.populateInstanceDetails)
  23. .before(commandUtils_1.warnEmulatorNotSupported, types_1.Emulators.DATABASE)
  24. .action(async (path, value, options) => {
  25. const setting = settings_1.DATABASE_SETTINGS.get(path);
  26. if (setting === undefined) {
  27. return utils.reject(settings_1.INVALID_PATH_ERROR, { exit: 1 });
  28. }
  29. const parsedValue = setting.parseInput(value);
  30. if (parsedValue === undefined) {
  31. return utils.reject(setting.parseInputErrorMessge, { exit: 1 });
  32. }
  33. const u = new url_1.URL(utils.getDatabaseUrl((0, api_1.realtimeOriginOrCustomUrl)(options.instanceDetails.databaseUrl), options.instance, `/.settings/${path}.json`));
  34. const c = new apiv2_1.Client({ urlPrefix: u.origin, auth: true });
  35. try {
  36. await c.put(u.pathname, JSON.stringify(parsedValue));
  37. }
  38. catch (err) {
  39. throw new error_1.FirebaseError(`Unexpected error fetching configs at ${path}`, {
  40. exit: 2,
  41. original: err,
  42. });
  43. }
  44. utils.logSuccess("Successfully set setting.");
  45. utils.logSuccess(`For database instance ${options.instance}\n\t ${path} = ${JSON.stringify(parsedValue)}`);
  46. });