Skip to content

@opencraft/providence


Interface: ProvidenceClient

Defined in: types/ProvidenceClient.ts:11

Properties

paginator

paginator: Paginator

Defined in: types/ProvidenceClient.ts:41

The paginator is an object full of functions that instruct Providence in how to handle pagination for your API.

Methods

deriveErrors()

deriveErrors\<T>(val, knownFields): FormErrorSet

Defined in: types/ProvidenceClient.ts:37

A function that takes an error raised by netCall and returns a FormErrorSet.

Type Parameters

T

T

Parameters

val

AxiosError

An error raised by netCall when making a network request.

knownFields

keyof T[]

The fields the current interface is aware of. This makes it easy to notice missing fields your frontend doesn't know about but you received an error for-- the ones you don't provide are put into a global error section instead so your users can report them to you.

Returns

FormErrorSet


deriveForm()

deriveForm\<T, K>(args): K

Defined in: types/ProvidenceClient.ts:28

Takes an AxiosResponse from the server and returns the data from the form endpoint.

Type Parameters

T

T

K

K = T

Parameters

args

DeriveFormArgs\<T>

Returns

K


deriveList()

deriveList\<T>(args): PaginationResult\<T>

Defined in: types/ProvidenceClient.ts:24

Takes an AxiosResponse from the server and returns a list with pagination info.

Type Parameters

T

T

Parameters

args

DeriveListArgs\<T>

Returns

PaginationResult\<T>


deriveSingle()

deriveSingle\<T>(args): T

Defined in: types/ProvidenceClient.ts:20

Given an AxiosResponse and the current state of the single module, derive a single from the response.

Type Parameters

T

T

Parameters

args

DeriveSingleArgs\<T>

Returns

T


netCall()

netCall\<T, K>(opts): Promise\<AxiosResponse\<K, any, { }, any>>

Defined in: types/ProvidenceClient.ts:16

A wrapper around Axios's request function. Define this to include things like Authentication headers in your network requests.

Type Parameters

T

T

K

K = T

Parameters

opts

NetCallOptions\<T>

Returns

Promise\<AxiosResponse\<K, any, { }, any>>