설명 없음
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.

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. exports.getTemplate = exports.parseTemplateForTable = void 0;
  4. const api_1 = require("../api");
  5. const apiv2_1 = require("../apiv2");
  6. const logger_1 = require("../logger");
  7. const error_1 = require("../error");
  8. const TIMEOUT = 30000;
  9. const MAX_DISPLAY_ITEMS = 50;
  10. const apiClient = new apiv2_1.Client({
  11. urlPrefix: api_1.remoteConfigApiOrigin,
  12. apiVersion: "v1",
  13. });
  14. function parseTemplateForTable(templateItems) {
  15. let outputStr = "";
  16. let counter = 0;
  17. for (const item in templateItems) {
  18. if (Object.prototype.hasOwnProperty.call(templateItems, item)) {
  19. outputStr = outputStr.concat(item, "\n");
  20. counter++;
  21. if (counter === MAX_DISPLAY_ITEMS) {
  22. outputStr += "+more..." + "\n";
  23. break;
  24. }
  25. }
  26. }
  27. return outputStr;
  28. }
  29. exports.parseTemplateForTable = parseTemplateForTable;
  30. async function getTemplate(projectId, versionNumber) {
  31. try {
  32. const params = new URLSearchParams();
  33. if (versionNumber) {
  34. params.set("versionNumber", versionNumber);
  35. }
  36. const res = await apiClient.request({
  37. method: "GET",
  38. path: `/projects/${projectId}/remoteConfig`,
  39. queryParams: params,
  40. timeout: TIMEOUT,
  41. });
  42. return res.body;
  43. }
  44. catch (err) {
  45. logger_1.logger.debug(err.message);
  46. throw new error_1.FirebaseError(`Failed to get Firebase Remote Config template for project ${projectId}. `, { original: err });
  47. }
  48. }
  49. exports.getTemplate = getTemplate;