@mintlify/previewing 4.0.9 → 4.0.11

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.
@@ -1,14 +1,3 @@
1
- var __assign = (this && this.__assign) || function () {
2
- __assign = Object.assign || function(t) {
3
- for (var s, i = 1, n = arguments.length; i < n; i++) {
4
- s = arguments[i];
5
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6
- t[p] = s[p];
7
- }
8
- return t;
9
- };
10
- return __assign.apply(this, arguments);
11
- };
12
1
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
13
2
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
14
3
  return new (P || (P = Promise))(function (resolve, reject) {
@@ -18,74 +7,38 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
18
7
  step((generator = generator.apply(thisArg, _arguments || [])).next());
19
8
  });
20
9
  };
21
- var __generator = (this && this.__generator) || function (thisArg, body) {
22
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
23
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
24
- function verb(n) { return function (v) { return step([n, v]); }; }
25
- function step(op) {
26
- if (f) throw new TypeError("Generator is already executing.");
27
- while (g && (g = 0, op[0] && (_ = 0)), _) try {
28
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
29
- if (y = 0, t) op = [op[0] & 2, t.value];
30
- switch (op[0]) {
31
- case 0: case 1: t = op; break;
32
- case 4: _.label++; return { value: op[1], done: false };
33
- case 5: _.label++; y = op[1]; op = [0]; continue;
34
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
35
- default:
36
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
37
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
38
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
39
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
40
- if (t[2]) _.ops.pop();
41
- _.trys.pop(); continue;
42
- }
43
- op = body.call(thisArg, _);
44
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
45
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
46
- }
47
- };
48
10
  import SwaggerParser from '@apidevtools/swagger-parser';
49
11
  import { promises as _promises } from 'fs';
50
- var stat = _promises.stat;
51
- export var getFileExtension = function (filename) {
12
+ const { stat } = _promises;
13
+ export const getFileExtension = (filename) => {
52
14
  return filename.substring(filename.lastIndexOf('.') + 1, filename.length) || filename;
53
15
  };
54
- export var openApiCheck = function (path) { return __awaiter(void 0, void 0, void 0, function () {
55
- var spec, isOpenApi, _a;
56
- return __generator(this, function (_b) {
57
- switch (_b.label) {
58
- case 0:
59
- isOpenApi = false;
60
- _b.label = 1;
61
- case 1:
62
- _b.trys.push([1, 3, , 4]);
63
- return [4 /*yield*/, SwaggerParser.validate(path)];
64
- case 2:
65
- spec = _b.sent();
66
- isOpenApi = true;
67
- return [3 /*break*/, 4];
68
- case 3:
69
- _a = _b.sent();
70
- return [3 /*break*/, 4];
71
- case 4: return [2 /*return*/, { spec: spec, isOpenApi: isOpenApi }];
72
- }
73
- });
74
- }); };
75
- export var filterOutNullInGroup = function (group) {
76
- var newPages = filterOutNullInPages(group.pages);
77
- var newGroup = __assign(__assign({}, group), { pages: newPages });
16
+ export const openApiCheck = (path) => __awaiter(void 0, void 0, void 0, function* () {
17
+ let spec;
18
+ let isOpenApi = false;
19
+ try {
20
+ spec = yield SwaggerParser.validate(path);
21
+ isOpenApi = true;
22
+ }
23
+ catch (_a) {
24
+ // not valid openApi
25
+ }
26
+ return { spec, isOpenApi };
27
+ });
28
+ export const filterOutNullInGroup = (group) => {
29
+ const newPages = filterOutNullInPages(group.pages);
30
+ const newGroup = Object.assign(Object.assign({}, group), { pages: newPages });
78
31
  return newGroup;
79
32
  };
80
- var filterOutNullInPages = function (pages) {
81
- var newPages = [];
82
- pages.forEach(function (page) {
33
+ const filterOutNullInPages = (pages) => {
34
+ const newPages = [];
35
+ pages.forEach((page) => {
83
36
  if (page == null) {
84
37
  return;
85
38
  }
86
39
  if (page.hasOwnProperty('pages')) {
87
- var group = page;
88
- var newGroup = filterOutNullInGroup(group);
40
+ const group = page;
41
+ const newGroup = filterOutNullInGroup(group);
89
42
  newPages.push(newGroup);
90
43
  }
91
44
  else {
@@ -94,19 +47,11 @@ var filterOutNullInPages = function (pages) {
94
47
  });
95
48
  return newPages;
96
49
  };
97
- export var isFileSizeValid = function (path, maxFileSizeInMb) { return __awaiter(void 0, void 0, void 0, function () {
98
- var maxFileSizeBytes, stats;
99
- return __generator(this, function (_a) {
100
- switch (_a.label) {
101
- case 0:
102
- maxFileSizeBytes = maxFileSizeInMb * 1000000;
103
- return [4 /*yield*/, stat(path)];
104
- case 1:
105
- stats = _a.sent();
106
- return [2 /*return*/, stats.size <= maxFileSizeBytes];
107
- }
108
- });
109
- }); };
50
+ export const isFileSizeValid = (path, maxFileSizeInMb) => __awaiter(void 0, void 0, void 0, function* () {
51
+ const maxFileSizeBytes = maxFileSizeInMb * 1000000;
52
+ const stats = yield stat(path);
53
+ return stats.size <= maxFileSizeBytes;
54
+ });
110
55
  export function isError(obj) {
111
56
  return Object.prototype.toString.call(obj) === '[object Error]';
112
57
  }