GSI - Employe Self Service Mobile
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

46 lines
2.3 KiB

2 months ago
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. exports.command = void 0;
  4. const command_1 = require("../command");
  5. const requireDatabaseInstance_1 = require("../requireDatabaseInstance");
  6. const database_1 = require("../management/database");
  7. const requirePermissions_1 = require("../requirePermissions");
  8. const utils = require("../utils");
  9. const profiler_1 = require("../profiler");
  10. const types_1 = require("../emulator/types");
  11. const commandUtils_1 = require("../emulator/commandUtils");
  12. const description = "profile the Realtime Database and generate a usage report";
  13. exports.command = new command_1.Command("database:profile")
  14. .description(description)
  15. .option("-o, --output <filename>", "save the output to the specified file")
  16. .option("-d, --duration <seconds>", "collect database usage information for the specified number of seconds")
  17. .option("--raw", "output the raw stats collected as newline delimited json")
  18. .option("--no-collapse", "prevent collapsing similar paths into $wildcard locations")
  19. .option("-i, --input <filename>", "generate the report based on the specified file instead " +
  20. "of streaming logs from the database")
  21. .option("--instance <instance>", "use the database <instance>.firebaseio.com (if omitted, use default database instance)")
  22. .before(requirePermissions_1.requirePermissions, ["firebasedatabase.instances.update"])
  23. .before(requireDatabaseInstance_1.requireDatabaseInstance)
  24. .before(database_1.populateInstanceDetails)
  25. .before(commandUtils_1.warnEmulatorNotSupported, types_1.Emulators.DATABASE)
  26. .action((options) => {
  27. if (options.raw && options.input) {
  28. return utils.reject("Cannot specify both an input file and raw format", {
  29. exit: 1,
  30. });
  31. }
  32. else if (options.parent.json && options.raw) {
  33. return utils.reject("Cannot output raw data in json format", { exit: 1 });
  34. }
  35. else if (options.input && options.duration !== undefined) {
  36. return utils.reject("Cannot specify a duration for input files", {
  37. exit: 1,
  38. });
  39. }
  40. else if (options.duration !== undefined && options.duration <= 0) {
  41. return utils.reject("Must specify a positive number of seconds", {
  42. exit: 1,
  43. });
  44. }
  45. return (0, profiler_1.profiler)(options);
  46. });