UNPKG

@prismicio/custom-types-client

Version:

JavaScript client to interact with the Prismic Custom Types API

106 lines (105 loc) 3.1 kB
/** * Metadata about the failed Prismic Custom Types API request. */ type PrismicErrorArgs<TResponse> = { /** * The Prismic Custom Types API URL used for the failed request. */ url: string; /** * The Prismic Custom Types API response from the failed request. */ response?: TResponse; }; /** * An error returned from the Prismic Custom Types API. It contains information * about the network request to aid in debugging. */ export declare class PrismicError<TResponse = never> extends Error { /** * The Prismic Custom Types API URL used for the failed request. */ url: string; /** * The Prismic Custom Types API response from the failed request. */ response?: TResponse; /** * Creates a new `PrismicError`. * * @param message - A description of the error. * @param args - Metadata about the failed network request. * * @returns A `PrismicError` for the given error state. */ constructor(message: string, args: PrismicErrorArgs<TResponse>); } /** * The response returned by the Prismic Custom Types API when forbidden. */ export interface ForbiddenErrorAPIResponse { /** * Description of the error. */ message: string; } /** * The response returned by the Prismic Custom Types API bulk update transaction * endpoint when changes contain a deletion operation of custom type(s) with * existing document(s). */ type BulkUpdateHasExistingDocumentsErrorAPIResponse = { /** * Description of the error. */ message: string; /** * Identify if the changes contain a deletion operation of custom type(s) with * existing document(s). */ hasExistingDocuments: true; }; /** * Represents an error when the Prismic Custom Types API response is invalid. */ export declare class InvalidAPIResponse extends PrismicError { } /** * Represents an error when making an unauthorized Prismic Custom Types API * request. */ export declare class UnauthorizedError extends PrismicError<string> { } /** * Represents an error when making a forbidden Prismic Custom Types API request. */ export declare class ForbiddenError extends PrismicError<ForbiddenErrorAPIResponse> { } /** * Represents an error when an entity with the same ID already exists. */ export declare class ConflictError extends PrismicError { } /** * Represents an error when the requested entity could not be found. */ export declare class NotFoundError extends PrismicError { } /** * Represents an error when the provided data is invalid. */ export declare class InvalidPayloadError extends PrismicError<string> { } /** * Represents an error when a bulk update changes contain a deletion operation * of custom type(s) with existing document(s). */ export declare class BulkUpdateHasExistingDocumentsError extends PrismicError<BulkUpdateHasExistingDocumentsErrorAPIResponse> { } /** * Represents an error when a valid `fetch` function is not available to the * Prismic Custom Types API client. */ export declare class MissingFetchError extends Error { } export {};