@mintlify/common 1.0.669 → 1.0.671
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.
- package/dist/exponentialBackoff.d.ts +1 -0
- package/dist/exponentialBackoff.js +23 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/mdx/plugins/remark/remarkExtractTableOfContents.js +5 -2
- package/dist/openapi/getOpenApiDocumentFromUrl.js +8 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +2 -2
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function exponentialBackoff<T>(operation: () => Promise<T>, retries?: number, delay?: number, factor?: number): Promise<T>;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
export function exponentialBackoff(operation_1) {
|
|
11
|
+
return __awaiter(this, arguments, void 0, function* (operation, retries = 3, delay = 1000, factor = 2) {
|
|
12
|
+
try {
|
|
13
|
+
return yield operation();
|
|
14
|
+
}
|
|
15
|
+
catch (error) {
|
|
16
|
+
if (retries > 0) {
|
|
17
|
+
yield new Promise((resolve) => setTimeout(resolve, delay));
|
|
18
|
+
return exponentialBackoff(operation, retries - 1, delay * factor, factor);
|
|
19
|
+
}
|
|
20
|
+
throw error;
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
}
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -55,7 +55,7 @@ export const remarkExtractTableOfContents = (mdxExtracts, pageMetadata) => {
|
|
|
55
55
|
}
|
|
56
56
|
});
|
|
57
57
|
visit(tree, (node) => {
|
|
58
|
-
var _a, _b, _c
|
|
58
|
+
var _a, _b, _c;
|
|
59
59
|
if (excludedNodes.has(node))
|
|
60
60
|
return;
|
|
61
61
|
const currentTabId = tabContentMap.get(node);
|
|
@@ -145,7 +145,10 @@ export const remarkExtractTableOfContents = (mdxExtracts, pageMetadata) => {
|
|
|
145
145
|
// Account if there is no first layer
|
|
146
146
|
let arrToPushInto = contents;
|
|
147
147
|
if (hasTopLayer) {
|
|
148
|
-
|
|
148
|
+
const lastTopLevel = contents.at(-1);
|
|
149
|
+
if (lastTopLevel && lastTopLevel.tabId === currentTabId) {
|
|
150
|
+
arrToPushInto = lastTopLevel.children;
|
|
151
|
+
}
|
|
149
152
|
}
|
|
150
153
|
arrToPushInto.push({
|
|
151
154
|
title,
|
|
@@ -8,9 +8,16 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
});
|
|
9
9
|
};
|
|
10
10
|
import yaml from 'js-yaml';
|
|
11
|
+
import { exponentialBackoff } from '../exponentialBackoff.js';
|
|
11
12
|
import { validate } from './validate.js';
|
|
12
13
|
export const getOpenApiDocumentFromUrl = (url) => __awaiter(void 0, void 0, void 0, function* () {
|
|
13
|
-
const response = yield
|
|
14
|
+
const response = yield exponentialBackoff(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
15
|
+
const res = yield fetch(url);
|
|
16
|
+
if (!res.ok) {
|
|
17
|
+
throw new Error(`${res.status} ${res.statusText}`);
|
|
18
|
+
}
|
|
19
|
+
return res;
|
|
20
|
+
}));
|
|
14
21
|
const data = yield response.text();
|
|
15
22
|
const openApiDocument = yaml.load(data);
|
|
16
23
|
if (openApiDocument == undefined) {
|