Skip to content

Commit

Permalink
feat(types): all public api typed (#512)
Browse files Browse the repository at this point in the history
  • Loading branch information
marcolink committed Jan 12, 2021
1 parent 6c0a0cd commit d930313
Show file tree
Hide file tree
Showing 4 changed files with 266 additions and 275 deletions.
255 changes: 0 additions & 255 deletions index.d.ts

This file was deleted.

37 changes: 35 additions & 2 deletions lib/contentful.ts
Expand Up @@ -7,9 +7,42 @@

import axios from 'axios'
import { createHttpClient, getUserAgentHeader } from 'contentful-sdk-core'
import createContentfulApi from './create-contentful-api'
import createContentfulApi, { ContentfulClientApi } from './create-contentful-api'
import createGlobalOptions from './create-global-options'

export interface AxiosProxyConfig {
host: string;
port: number;
auth?: {
username: string;
password: string;
};
}

export type ClientLogLevel = 'error' | 'warning' | 'info' | string;

export interface CreateClientParams {
space: string;
accessToken: string;
environment?: string;
insecure?: boolean;
host?: string;
basePath?: string;
httpAgent?: any;
httpsAgent?: any;
proxy?: AxiosProxyConfig;
headers?: any;
adapter?: any;
application?: string;
integration?: string;
resolveLinks?: boolean;
removeUnresolved?: boolean;
retryOnError?: boolean;
logHandler?: (level: ClientLogLevel, data?: any) => void;
timeout?: number;
retryLimit?: number;
}

/**
* Create a client instance
* @func
Expand Down Expand Up @@ -44,7 +77,7 @@ import createGlobalOptions from './create-global-options'
* })
*/

export function createClient (params) {
export function createClient (params: CreateClientParams): ContentfulClientApi {
if (!params.accessToken) {
throw new TypeError('Expected parameter accessToken')
}
Expand Down

0 comments on commit d930313

Please sign in to comment.