mirror of
https://github.com/GitbookIO/gitbook.git
synced 2026-11-24 09:12:05 +00:00
Update @gitbook/api to 0.213.0 (#4826)
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"gitbook": patch
|
||||
---
|
||||
|
||||
Update the GitBook API SDK for site revision responses.
|
||||
@@ -357,7 +357,7 @@
|
||||
},
|
||||
"catalog": {
|
||||
"@base-ui/react": "^1.7.0",
|
||||
"@gitbook/api": "0.211.0",
|
||||
"@gitbook/api": "0.213.0",
|
||||
"@scalar/api-client-react": "^1.3.46",
|
||||
"@tsconfig/node20": "^20.1.6",
|
||||
"@tsconfig/strictest": "^2.0.6",
|
||||
@@ -725,7 +725,7 @@
|
||||
|
||||
"@fortawesome/fontawesome-svg-core": ["@fortawesome/fontawesome-svg-core@7.2.0", "", { "dependencies": { "@fortawesome/fontawesome-common-types": "7.2.0" } }, "sha512-6639htZMjEkwskf3J+e6/iar+4cTNM9qhoWuRfj9F3eJD6r7iCzV1SWnQr2Mdv0QT0suuqU8BoJCZUyCtP9R4Q=="],
|
||||
|
||||
"@gitbook/api": ["@gitbook/api@0.211.0", "", { "dependencies": { "event-iterator": "^2.0.0", "eventsource-parser": "^3.0.0" } }, "sha512-G+rY2m7ZvyR1RA4oilarzrNDABDkYhARoIyfNCE5mYqZQgpgsLShn3rGgzTudO2iqwt/5iK6RcJc2enfj+37Jg=="],
|
||||
"@gitbook/api": ["@gitbook/api@0.213.0", "", { "dependencies": { "event-iterator": "^2.0.0", "eventsource-parser": "^3.0.0" } }, "sha512-c61/FejKsDJFjLuZVgKplQZm21VyVnC4ahX9NBleRVnYbiN8UJ9lijHCch2sEZ2lR9KM42pi5DVvaMKymli8eg=="],
|
||||
|
||||
"@gitbook/browser-types": ["@gitbook/browser-types@workspace:packages/browser-types"],
|
||||
|
||||
|
||||
+1
-1
@@ -48,7 +48,7 @@
|
||||
"@tsconfig/strictest": "^2.0.6",
|
||||
"@tsconfig/node20": "^20.1.6",
|
||||
"@base-ui/react": "^1.7.0",
|
||||
"@gitbook/api": "0.211.0",
|
||||
"@gitbook/api": "0.213.0",
|
||||
"@scalar/api-client-react": "^1.3.46",
|
||||
"@types/react": "^19.0.0",
|
||||
"@types/react-dom": "^19.0.0",
|
||||
|
||||
@@ -5,7 +5,6 @@ import { assert } from 'ts-essentials';
|
||||
import type {
|
||||
ChangeRequest,
|
||||
CustomizationDefaultThemeMode,
|
||||
PublishedSiteContent,
|
||||
Revision,
|
||||
RevisionPageDocument,
|
||||
Site,
|
||||
@@ -32,6 +31,7 @@ import { isPublishedPreviewAllowed } from './preview';
|
||||
import type { AskVisitorAgent } from '@/lib/ask-visitor';
|
||||
import {
|
||||
type GitBookDataFetcher,
|
||||
type PublishedSiteContent,
|
||||
createDataFetcher,
|
||||
getDataOrNull,
|
||||
throwIfDataError,
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { GitBookAPI, PublishedSiteContentLookup, SiteVisitorPayload } from '@gitbook/api';
|
||||
import type * as API from '@gitbook/api';
|
||||
|
||||
import { apiClient } from './api';
|
||||
import { getExposableError } from './errors';
|
||||
@@ -8,13 +8,16 @@ import { tryCatch } from '@/lib/async';
|
||||
import { isPreviewRequest } from '@/lib/preview';
|
||||
import { trace } from '@/lib/tracing';
|
||||
|
||||
type ResolveBody = Parameters<GitBookAPI['urls']['resolvePublishedContentByUrl']>[0];
|
||||
type ResolveBody = Parameters<API.GitBookAPI['urls']['resolvePublishedContentByUrl']>[0];
|
||||
|
||||
export type PublishedSiteContent = API.PublishedSiteContent &
|
||||
Partial<API.PublishedSiteContentAtRevision & API.PublishedSiteContentInChangeRequest>;
|
||||
|
||||
interface LookupPublishedContentByUrlInput {
|
||||
url: string;
|
||||
redirectOnError: boolean;
|
||||
apiToken: string | null;
|
||||
visitorPayload: SiteVisitorPayload;
|
||||
visitorPayload: API.SiteVisitorPayload;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -22,7 +25,7 @@ interface LookupPublishedContentByUrlInput {
|
||||
*/
|
||||
export async function lookupPublishedContentByUrl(
|
||||
input: LookupPublishedContentByUrlInput
|
||||
): Promise<DataFetcherResponse<PublishedSiteContentLookup>> {
|
||||
): Promise<DataFetcherResponse<PublishedSiteContent | API.PublishedContentRedirect>> {
|
||||
const lookupURL = new URL(input.url);
|
||||
const lookup = getURLLookup(stripURLSearch(lookupURL));
|
||||
|
||||
@@ -61,7 +64,11 @@ export async function lookupPublishedContentByUrl(
|
||||
data: { data },
|
||||
} = callResult;
|
||||
|
||||
if ('redirect' in data && data.target === 'application' && isPreviewRequest(lookupURL)) {
|
||||
if (!('redirect' in data)) {
|
||||
return { data };
|
||||
}
|
||||
|
||||
if (data.target === 'application' && isPreviewRequest(lookupURL)) {
|
||||
// The cached lookup omits the query params needed after login.
|
||||
const redirect = new URL(data.redirect);
|
||||
redirect.searchParams.set('redirect', lookupURL.toString());
|
||||
|
||||
@@ -10,7 +10,6 @@ import {
|
||||
ContentType,
|
||||
CustomizationDefaultThemeMode,
|
||||
CustomizationThemeMode,
|
||||
type PublishedSiteContent,
|
||||
SiteInsightsDisplayContext,
|
||||
type SiteInsightsEventLocation,
|
||||
SiteInsightsLLMSVariant,
|
||||
@@ -31,6 +30,7 @@ import { getContentSecurityPolicy } from '@/lib/csp';
|
||||
import { validateSerializedCustomization } from '@/lib/customization';
|
||||
import {
|
||||
DataFetcherError,
|
||||
type PublishedSiteContent,
|
||||
apiClient,
|
||||
getVisitorAuthBasePath,
|
||||
lookupPublishedContentByUrl,
|
||||
|
||||
Reference in New Issue
Block a user