@prismicio/client
Advanced tools
Comparing version 7.3.0 to 7.3.1
@@ -21,5 +21,7 @@ var __defProp = Object.defineProperty; | ||
import { ParsingError } from "./errors/ParsingError.js"; | ||
import { PreviewTokenExpiredError } from "./errors/PreviewTokenExpired.js"; | ||
import { PrismicError } from "./errors/PrismicError.js"; | ||
import { RefExpiredError } from "./errors/RefExpiredError.js"; | ||
import { RefNotFoundError } from "./errors/RefNotFoundError.js"; | ||
import { RepositoryNotFoundError } from "./errors/RepositoryNotFoundError.js"; | ||
import { asLink } from "./helpers/asLink.js"; | ||
@@ -1184,6 +1186,12 @@ import { buildQueryURL } from "./buildQueryURL.js"; | ||
case 404: { | ||
if (res.json && res.json.type === "api_notfound_error") { | ||
if (res.json === void 0) { | ||
throw new RepositoryNotFoundError(`Prismic repository not found. Check that "${this.endpoint}" is pointing to the correct repository.`, url, void 0); | ||
} | ||
if (res.json.type === "api_notfound_error") { | ||
throw new RefNotFoundError(res.json.message, url, res.json); | ||
} | ||
throw new NotFoundError(`Prismic repository not found. Check that "${this.endpoint}" is pointing to the correct repository.`, url, void 0); | ||
if (res.json.type === "api_security_error" && /preview token.*expired/i.test(res.json.message)) { | ||
throw new PreviewTokenExpiredError(res.json.message, url, res.json); | ||
} | ||
throw new NotFoundError(res.json.message, url, res.json); | ||
} | ||
@@ -1190,0 +1198,0 @@ case 410: { |
@@ -79,3 +79,5 @@ import type { CustomTypeModelIntegrationField } from "./types/model/integration"; | ||
export { RefExpiredError } from "./errors/RefExpiredError"; | ||
export { PreviewTokenExpiredError } from "./errors/PreviewTokenExpired"; | ||
export { ParsingError } from "./errors/ParsingError"; | ||
export { RepositoryNotFoundError } from "./errors/RepositoryNotFoundError"; | ||
/** | ||
@@ -82,0 +84,0 @@ * @deprecated Use {@link RichTextNodeType} instead. |
@@ -28,3 +28,5 @@ import { RichTextNodeType } from "./types/value/richText.js"; | ||
import { RefExpiredError } from "./errors/RefExpiredError.js"; | ||
import { PreviewTokenExpiredError } from "./errors/PreviewTokenExpired.js"; | ||
import { ParsingError } from "./errors/ParsingError.js"; | ||
import { RepositoryNotFoundError } from "./errors/RepositoryNotFoundError.js"; | ||
import { LinkType } from "./types/value/link.js"; | ||
@@ -51,5 +53,7 @@ import { OEmbedType } from "./types/value/embed.js"; | ||
ParsingError, | ||
PreviewTokenExpiredError, | ||
PrismicError, | ||
RefExpiredError, | ||
RefNotFoundError, | ||
RepositoryNotFoundError, | ||
RichTextNodeType, | ||
@@ -56,0 +60,0 @@ WebhookType, |
@@ -1,2 +0,2 @@ | ||
const version = "7.3.0"; | ||
const version = "7.3.1"; | ||
export { | ||
@@ -3,0 +3,0 @@ version |
{ | ||
"name": "@prismicio/client", | ||
"version": "7.3.0", | ||
"version": "7.3.1", | ||
"description": "The official JavaScript + TypeScript client library for Prismic", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -21,5 +21,7 @@ import { appendFilters } from "./lib/appendFilters"; | ||
import { ParsingError } from "./errors/ParsingError"; | ||
import { PreviewTokenExpiredError } from "./errors/PreviewTokenExpired"; | ||
import { PrismicError } from "./errors/PrismicError"; | ||
import { RefExpiredError } from "./errors/RefExpiredError"; | ||
import { RefNotFoundError } from "./errors/RefNotFoundError"; | ||
import { RepositoryNotFoundError } from "./errors/RepositoryNotFoundError"; | ||
@@ -1915,12 +1917,24 @@ import { LinkResolverFunction, asLink } from "./helpers/asLink"; | ||
// - Ref does not exist | ||
// - Preview token is expired | ||
case 404: { | ||
if (res.json && res.json.type === "api_notfound_error") { | ||
if (res.json === undefined) { | ||
throw new RepositoryNotFoundError( | ||
`Prismic repository not found. Check that "${this.endpoint}" is pointing to the correct repository.`, | ||
url, | ||
undefined, | ||
); | ||
} | ||
if (res.json.type === "api_notfound_error") { | ||
throw new RefNotFoundError(res.json.message, url, res.json); | ||
} | ||
throw new NotFoundError( | ||
`Prismic repository not found. Check that "${this.endpoint}" is pointing to the correct repository.`, | ||
url, | ||
undefined, // res.json is empty | ||
); | ||
if ( | ||
res.json.type === "api_security_error" && | ||
/preview token.*expired/i.test(res.json.message) | ||
) { | ||
throw new PreviewTokenExpiredError(res.json.message, url, res.json); | ||
} | ||
throw new NotFoundError(res.json.message, url, res.json); | ||
} | ||
@@ -1927,0 +1941,0 @@ |
@@ -106,3 +106,5 @@ // Imports are used for deprecations. | ||
export { RefExpiredError } from "./errors/RefExpiredError"; | ||
export { PreviewTokenExpiredError } from "./errors/PreviewTokenExpired"; | ||
export { ParsingError } from "./errors/ParsingError"; | ||
export { RepositoryNotFoundError } from "./errors/RepositoryNotFoundError"; | ||
@@ -109,0 +111,0 @@ //============================================================================= |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
1140472
471
17638