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.

63 lines
2.3 KiB

2 months ago
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. exports.getResourceRuntime = exports.formatTimestamp = exports.getRandomString = exports.convertOfficialExtensionsToList = exports.convertExtensionOptionToLabeledList = exports.onceWithJoin = void 0;
  4. const prompt_1 = require("../prompt");
  5. const types_1 = require("./types");
  6. async function onceWithJoin(question) {
  7. const response = await (0, prompt_1.promptOnce)(question);
  8. if (Array.isArray(response)) {
  9. return response.join(",");
  10. }
  11. return response;
  12. }
  13. exports.onceWithJoin = onceWithJoin;
  14. function convertExtensionOptionToLabeledList(options) {
  15. return options.map((option) => {
  16. return {
  17. checked: false,
  18. name: option.label,
  19. value: option.value,
  20. };
  21. });
  22. }
  23. exports.convertExtensionOptionToLabeledList = convertExtensionOptionToLabeledList;
  24. function convertOfficialExtensionsToList(officialExts) {
  25. const l = Object.entries(officialExts).map(([key, entry]) => {
  26. return {
  27. checked: false,
  28. value: `${entry.publisher}/${key}`,
  29. };
  30. });
  31. l.sort((a, b) => a.value.localeCompare(b.value));
  32. return l;
  33. }
  34. exports.convertOfficialExtensionsToList = convertOfficialExtensionsToList;
  35. function getRandomString(length) {
  36. const SUFFIX_CHAR_SET = "abcdefghijklmnopqrstuvwxyz0123456789";
  37. let result = "";
  38. for (let i = 0; i < length; i++) {
  39. result += SUFFIX_CHAR_SET.charAt(Math.floor(Math.random() * SUFFIX_CHAR_SET.length));
  40. }
  41. return result;
  42. }
  43. exports.getRandomString = getRandomString;
  44. function formatTimestamp(timestamp) {
  45. if (!timestamp) {
  46. return "";
  47. }
  48. const withoutMs = timestamp.split(".")[0];
  49. return withoutMs.replace("T", " ");
  50. }
  51. exports.formatTimestamp = formatTimestamp;
  52. function getResourceRuntime(resource) {
  53. var _a, _b, _c;
  54. switch (resource.type) {
  55. case types_1.FUNCTIONS_RESOURCE_TYPE:
  56. return (_a = resource.properties) === null || _a === void 0 ? void 0 : _a.runtime;
  57. case types_1.FUNCTIONS_V2_RESOURCE_TYPE:
  58. return (_c = (_b = resource.properties) === null || _b === void 0 ? void 0 : _b.buildConfig) === null || _c === void 0 ? void 0 : _c.runtime;
  59. default:
  60. return undefined;
  61. }
  62. }
  63. exports.getResourceRuntime = getResourceRuntime;