Skip to content

Commit 404c8df

Browse files
committed
Upgrade API client
1 parent 05e1d8c commit 404c8df

File tree

4 files changed

+14
-50
lines changed

4 files changed

+14
-50
lines changed

bun.lock

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
},
2525
"packages/colors": {
2626
"name": "@gitbook/colors",
27-
"version": "0.1.0",
27+
"version": "0.2.0",
2828
"devDependencies": {
2929
"typescript": "^5.5.3",
3030
},
@@ -38,9 +38,9 @@
3838
},
3939
"packages/gitbook": {
4040
"name": "gitbook",
41-
"version": "0.6.1",
41+
"version": "0.6.2",
4242
"dependencies": {
43-
"@gitbook/api": "^0.94.0",
43+
"@gitbook/api": "^0.95.0",
4444
"@gitbook/cache-do": "workspace:*",
4545
"@gitbook/colors": "workspace:*",
4646
"@gitbook/emoji-codepoints": "workspace:*",
@@ -155,7 +155,7 @@
155155
},
156156
"packages/openapi-parser": {
157157
"name": "@gitbook/openapi-parser",
158-
"version": "1.0.0",
158+
"version": "1.0.1",
159159
"dependencies": {
160160
"@scalar/openapi-parser": "^0.10.4",
161161
"@scalar/openapi-types": "^0.1.6",
@@ -211,7 +211,7 @@
211211
},
212212
"packages/react-openapi": {
213213
"name": "@gitbook/react-openapi",
214-
"version": "1.0.1",
214+
"version": "1.0.2",
215215
"dependencies": {
216216
"@gitbook/openapi-parser": "workspace:*",
217217
"@scalar/api-client-react": "1.0.87",
@@ -4651,7 +4651,7 @@
46514651

46524652
"gaxios/https-proxy-agent": ["[email protected]", "", { "dependencies": { "agent-base": "6", "debug": "4" } }, "sha512-dFcAjpTQFgoLMzC2VwU+C/CbS7uRL0lWmxDITmqm7C+7F0Odmj6s9l6alZc6AELXhrnggM2CeWSXHGOdX2YtwA=="],
46534653

4654-
"gitbook/@gitbook/api": ["@gitbook/api@0.94.0", "", { "dependencies": { "event-iterator": "^2.0.0", "eventsource-parser": "^3.0.0" } }, "sha512-jOvqUSdyXeuPpBiujkQLb14uVQA5A0XL+P89MmC/53hV7v/8gR8WlJN9RJVDrP0LX51dsLT+/zYN8xWp19nPwA=="],
4654+
"gitbook/@gitbook/api": ["@gitbook/api@0.95.0", "", { "dependencies": { "event-iterator": "^2.0.0", "eventsource-parser": "^3.0.0" } }, "sha512-9KAbt27Ile6cqAch7QEbiJHALQHojYlhsPzilgdQ5wpHgLwsrd7Smd58A3/8bWBKq4KV0vP4rh3oYhIw+LlWFw=="],
46554655

46564656
"gitbook-v2/next": ["[email protected]", "", { "dependencies": { "@next/env": "15.2.0-canary.45", "@swc/counter": "0.1.3", "@swc/helpers": "0.5.15", "busboy": "1.6.0", "caniuse-lite": "^1.0.30001579", "postcss": "8.4.31", "styled-jsx": "5.1.6" }, "optionalDependencies": { "@next/swc-darwin-arm64": "15.2.0-canary.45", "@next/swc-darwin-x64": "15.2.0-canary.45", "@next/swc-linux-arm64-gnu": "15.2.0-canary.45", "@next/swc-linux-arm64-musl": "15.2.0-canary.45", "@next/swc-linux-x64-gnu": "15.2.0-canary.45", "@next/swc-linux-x64-musl": "15.2.0-canary.45", "@next/swc-win32-arm64-msvc": "15.2.0-canary.45", "@next/swc-win32-x64-msvc": "15.2.0-canary.45", "sharp": "^0.33.5" }, "peerDependencies": { "@opentelemetry/api": "^1.1.0", "@playwright/test": "^1.41.2", "babel-plugin-react-compiler": "*", "react": "^18.2.0 || 19.0.0-rc-de68d2f4-20241204 || ^19.0.0", "react-dom": "^18.2.0 || 19.0.0-rc-de68d2f4-20241204 || ^19.0.0", "sass": "^1.3.0" }, "optionalPeers": ["@opentelemetry/api", "@playwright/test", "babel-plugin-react-compiler", "sass"], "bin": { "next": "dist/bin/next" } }, "sha512-UsneTQn9tntbiAaXpvoXhhsTBb58Q2XIs2Dfka+qWA8motBz0ZvW297YHLxhdur4xN0IJvknnZKl5Bs7wAGlOg=="],
46574657

packages/gitbook/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
"clean": "rm -rf ./.next && rm -rf ./public/~gitbook/static/icons && rm -rf ./public/~gitbook/static/math"
1818
},
1919
"dependencies": {
20-
"@gitbook/api": "^0.94.0",
20+
"@gitbook/api": "^0.95.0",
2121
"@gitbook/cache-do": "workspace:*",
2222
"@gitbook/colors": "workspace:*",
2323
"@gitbook/emoji-codepoints": "workspace:*",

packages/gitbook/src/lib/api.ts

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -208,42 +208,6 @@ export const getUserById = cache({
208208
},
209209
});
210210

211-
/**
212-
* Get the latest version of an OpenAPI spec by its slug.
213-
*/
214-
export const getLatestOpenAPISpecVersion = cache({
215-
name: 'api.getLatestOpenApiSpecVersion',
216-
tag: (organization, openAPISpec) =>
217-
getAPICacheTag({
218-
tag: 'openapi',
219-
organization,
220-
openAPISpec,
221-
}),
222-
get: async (organizationId: string, slug: string, options: CacheFunctionOptions) => {
223-
try {
224-
const apiCtx = await api();
225-
const response = await apiCtx.client.orgs.getLatestOpenApiSpecVersion(
226-
organizationId,
227-
slug,
228-
{
229-
...noCacheFetchOptions,
230-
signal: options.signal,
231-
},
232-
);
233-
return cacheResponse(response, { revalidateBefore: 60 * 60 });
234-
} catch (error) {
235-
if (checkHasErrorCode(error, 404)) {
236-
return {
237-
revalidateBefore: 5,
238-
data: null,
239-
};
240-
}
241-
242-
throw error;
243-
}
244-
},
245-
});
246-
247211
/**
248212
* Get the latest version of an OpenAPI spec by its slug.
249213
*/

packages/gitbook/src/lib/references.tsx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -282,19 +282,19 @@ export async function resolveContentRef(
282282
return null;
283283
}
284284
const { organizationId } = siteContext;
285-
const [openAPISpecVersion, openAPISpecVersionContent] = await Promise.all([
286-
getLatestOpenAPISpecVersion(organizationId, contentRef.spec),
287-
getLatestOpenAPISpecVersionContent(organizationId, contentRef.spec),
288-
]);
285+
const openAPISpecVersionContent = await getLatestOpenAPISpecVersionContent(
286+
organizationId,
287+
contentRef.spec,
288+
);
289289

290-
if (!openAPISpecVersion || !openAPISpecVersionContent) {
290+
if (!openAPISpecVersionContent) {
291291
return null;
292292
}
293293
return {
294-
href: openAPISpecVersion.url,
294+
href: openAPISpecVersionContent.url,
295295
text: contentRef.spec,
296296
active: false,
297-
openAPIFilesystem: openAPISpecVersionContent as Filesystem,
297+
openAPIFilesystem: openAPISpecVersionContent.filesystem as Filesystem,
298298
};
299299
}
300300

0 commit comments

Comments
 (0)