/**
* Contentful Delivery API SDK. Allows you to create instances of a client
* with access to the Contentful Content Delivery API.
*/
import type { AxiosAdapter, AxiosRequestConfig, AxiosResponse } from 'axios';
import type { ContentfulClientApi } from './types/client.js';
import type { TimelinePreview } from './types/timeline-preview.js';
/**
* @category Client
*/
export type ClientLogLevel = 'error' | 'warning' | 'info' | string;
/**
* Client initialization parameters
* @category Client
*/
export interface CreateClientParams {
/**
* Space ID
*/
space: string;
/**
* Contentful CDA Access Token
*/
accessToken: string;
/**
* Contentful Environment ID
* @defaultValue "master"
*/
environment?: string;
/**
* Requests will be made over http instead of the default https
* @defaultValue true
*/
insecure?: boolean;
/**
* API host. Also usable with preview.contentful.com.
* @defaultValue "cdn.contentful.com"
*/
host?: string;
/**
* Path appended to the host to support gateways/proxies with custom urls
*/
basePath?: string;
/**
* Optional Node.js HTTP agent for proxying
* (see Node.js docs
* and https-proxy-agent)
*/
httpAgent?: AxiosRequestConfig['httpAgent'];
/**
* Optional Node.js HTTP agent for proxying
* (see Node.js docs
* and https-proxy-agent)
*/
httpsAgent?: AxiosRequestConfig['httpsAgent'];
/**
* Optional Axios proxy (see axios docs )
*/
proxy?: AxiosRequestConfig['proxy'];
/**
* Optional additional headers
*/
headers?: Record;
/**
* Optional axios request adapter (see axios docs )
*/
adapter?: AxiosAdapter;
/**
* Application name and version e.g myApp/version
*/
application?: string;
/**
* Integration name and version e.g react/version
*/
integration?: string;
/**
* If we should retry on errors and 429 rate limit exceptions
* @defaultValue true
*/
retryOnError?: boolean;
/**
* A log handler function to process given log messages and errors.
* (The default can be found at: https://github.com/contentful/contentful-sdk-core/blob/master/src/create-http-client.ts)
* @param level - Log level, e.g. error, warning, or info
* @param data - Log data
*/
logHandler?: (level: ClientLogLevel, data?: Record | string) => void;
/**
* connection timeout in milliseconds (default:30000)
*/
timeout?: number;
/**
* Optional number of retries before failure.
* @defaultValue 5
*/
retryLimit?: number;
/**
* Interceptor called on every request. Takes Axios request config as an arg.
*/
requestLogger?: (request: AxiosRequestConfig | Error) => unknown;
/**
* Interceptor called on every response. Takes Axios response object as an arg.
*/
responseLogger?: (response: AxiosResponse | Error) => unknown;
/**
* Enable Content Source Maps.
* @remarks
* This feature is only available when using the Content Preview API.
*/
includeContentSourceMaps?: boolean;
/**
* Enable alpha features.
*/
alphaFeatures?: {
/**
* @deprecated Use the `includeContentSourceMaps` option directly instead.
*/
includeContentSourceMaps?: boolean;
/**
* Enable Timeline Preview.
* @remarks
* This feature is only available in private beta when using the Content Preview API.
*/
timelinePreview?: TimelinePreview;
};
}
/**
* Create a client instance
* @param params - Client initialization parameters
* @category Client
* @example
* ```typescript
* const contentful = require('contentful')
* const client = contentful.createClient({
* accessToken: 'myAccessToken',
* space: 'mySpaceId'
* })
* ```
*/
export declare function createClient(params: CreateClientParams): ContentfulClientApi;