Configuration
Providence's configuration options allow you to customize some of its automation. Each state management plugin comes with its own default settings for Providence that handle translating its functionality. Providence tries as much as possible to configure with sane defaults, but you will likely have to override at least a few settings, such as the :js:attr:netCall <ProvidenceClient.netCall>
setting in the :js:class:client <ProvidenceClient>
.
Interface: GlobalOptions
types/GlobalOptions.GlobalOptions
The GlobalOptions object is used to provide context to Providence. Most of the settings (especially those of the transformers) should be provided automatically by the plugin for your state manager. However, some client` functions may need customizing, and you'll want to set up your own validators for any form field validation.
Properties
client
• client: ProvidenceClient
The client contains functions for contacting your API and deriving data from it. In most cases you will want to customize at least the netCall function.
A default implementation, baseCall, is available.
Defined in
src/base/types/GlobalOptions.ts:23
drivers
• drivers: Drivers
The Drivers are the means by which we perform meta-operations with the client store, like adding or removing a module. You should not have to set these settings unless you're making your own state management library adapter.
Defined in
src/base/types/GlobalOptions.ts:39
registries
• registries: () => ProvidenceRegistries
Type declaration
▸ (): ProvidenceRegistries
A function which returns the registries' singleton. We make this a function so it can be ignored as a dependency more easily by reactive client frameworks-- otherwise we might have infinite loop changes.
Returns
Defined in
src/base/types/GlobalOptions.ts:44
transformers
• transformers: Transformers
The transformers are a set of functions that adapt the internal structure of Providence objects into something the client state management libraries can use. Unless you're writing a plugin to support a new state management backend, you should not need to specify these manually. The existing plugin should specify them for you.
However, there may be some edge case, for testing or other instrumentation, where you need to spy on relevant calls on all controllers, or otherwise transform their data. You can do so here if you need such functionality.
Defined in
src/base/types/GlobalOptions.ts:33
validators
• validators: Validators
The set of validators used for field validation. By default, only the example 'email' validator is included. Each key in this object will be used as a reference name for the validators on a field.
Defined in
src/base/types/GlobalOptions.ts:50
Interface: Transformers
types/Transformers.Transformers
Properties
controller
• controller: controller
: T
) => T
Type declaration
▸ <T
>(controller
): T
Transforms a generated providence controller in any way necessary to provide its essential functions to the target state manager.
Type parameters
Name | Type |
---|---|
T |
extends BaseController <any > |
Parameters
Name | Type | Description |
---|---|---|
controller |
T |
Any dynamically generated controller, such as a SingleController, that is built by Providence. |
Returns
T
Defined in
src/base/types/Transformers.ts:22
fielder
• fielder: patcher
: T
) => T
Type declaration
▸ <T
>(patcher
): T
Transforms a generated fielder in any way necessary to provide its essential functions to the target state manager.
Type parameters
Name | Type |
---|---|
T |
extends Fielder <any , any > |
Parameters
Name | Type |
---|---|
patcher |
T |
Returns
T
Defined in
src/base/types/Transformers.ts:36
module
• module: module
: T
) => T
Type declaration
▸ <T
>(module
): T
Transforms a providence module into a pluggable format the target state manager will understand.
Type parameters
Name | Type |
---|---|
T |
extends BaseModule <any , any , any > |
Parameters
Name | Type | Description |
---|---|---|
module |
T |
Any dynamically generated module, such as a Single, that is built by Providence. |
Returns
T
Defined in
src/base/types/Transformers.ts:14
patcher
• patcher: patcher
: T
) => T
Type declaration
▸ <T
>(patcher
): T
Transforms a generated patcher in any way necessary to provide its essential functions to the target state manager.
Type parameters
Name | Type |
---|---|
T |
extends Patcher <any , any > |
Parameters
Name | Type | Description |
---|---|---|
patcher |
T |
A dynamically generated Patcher. |
Returns
T
Defined in
src/base/types/Transformers.ts:29
Interface: ProvidenceClient
types/ProvidenceClient.ProvidenceClient
Properties
paginator
• paginator: Paginator
The paginator is an object full of functions that instruct Providence in how to handle pagination for your API.
Defined in
src/base/types/ProvidenceClient.ts:41
Methods
deriveErrors
▸ deriveErrors<T
>(val
, knownFields
): FormErrorSet
<any
>
A function that takes an error raised by netCall and returns a FormErrorSet.
Type parameters
Name |
---|
T |
Parameters
Name | Type | Description |
---|---|---|
val |
AxiosError <unknown , any > |
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
<any
>
Defined in
src/base/types/ProvidenceClient.ts:37
deriveForm
▸ deriveForm<T
, K
>(args
): K
Takes an AxiosResponse from the server and returns the data from the form endpoint.
Type parameters
Name | Type |
---|---|
T |
T |
K |
T |
Parameters
Name | Type |
---|---|
args |
DeriveFormArgs <T > |
Returns
K
Defined in
src/base/types/ProvidenceClient.ts:28
deriveList
▸ deriveList<T
>(args
): PaginationResult
<T
>
Takes an AxiosResponse from the server and returns a list with pagination info.
Type parameters
Name |
---|
T |
Parameters
Name | Type |
---|---|
args |
DeriveListArgs <T > |
Returns
Defined in
src/base/types/ProvidenceClient.ts:24
deriveSingle
▸ deriveSingle<T
>(args
): T
Given an AxiosResponse and the current state of the single module, derive a single from the response.
Type parameters
Name |
---|
T |
Parameters
Name | Type |
---|---|
args |
DeriveSingleArgs <T > |
Returns
T
Defined in
src/base/types/ProvidenceClient.ts:20
netCall
▸ netCall<T
, K
>(opts
): Promise
<AxiosResponse
<K
, any
>>
A wrapper around Axios's request function. Define this to include things like Authentication headers in your network requests.
Type parameters
Name | Type |
---|---|
T |
T |
K |
T |
Parameters
Name | Type |
---|---|
opts |
NetCallOptions <T > |
Returns
Promise
<AxiosResponse
<K
, any
>>
Defined in
src/base/types/ProvidenceClient.ts:16
Interface: Drivers
types/Drivers.Drivers
Properties
makeModuleFactory
• makeModuleFactory: (store
: any
) => ModuleFactory
Type declaration
▸ (store
): ModuleFactory
The makeModuleFactory
function should take the upstream library's store, whatever shape it may come in, and
create a function which allows you to add a module to this store, if given a
MakeModuleOptions object.
This function should return a function, which takes no arguments and returns nothing, that will remove the module from the store.
Parameters
Name | Type |
---|---|
store |
any |
Returns
Defined in
makeProxyFactory
• makeProxyFactory: (store
: any
) => StoreProxyFactory
Type declaration
▸ (store
): StoreProxyFactory
The makeProxyFactory
function should take the upstream library's store, whatever shape it may come in, and
create a function which builds a proxy BoundStore if given a
MakeModuleOptions object.
Parameters
Name | Type |
---|---|
store |
any |