Skip to content

breeze-client / BreezeConfig

Class: BreezeConfig ​

Defined in: src/config/config.ts:130

Breeze's global configuration: the adapter registry, the fetch transport, and registries Breeze uses to find functions and objects by name when it deserializes metadata. The single instance is config.

To configure Breeze, use configureBreeze. The adapter methods here (registerAdapter, initializeAdapterInstance, getAdapterInstance and the rest) are the 2.x API. They still work, and adapters' own static register() methods use them, but an application does not normally need to call them.

Constructors ​

Constructor ​

new BreezeConfig(): BreezeConfig

Defined in: src/config/config.ts:198

Creates a configuration with nothing registered. Breeze creates the one instance there is, config; applications do not create their own.

Returns ​

BreezeConfig

Properties ​

fetch? ​

optional fetch?: BreezeFetch

Defined in: src/config/config.ts:182

The function Breeze makes HTTP requests with, unless a (deprecated) ajax adapter is registered. Set it with configureBreeze({ fetch }). When unset, globalThis.fetch.


functionRegistry ​

functionRegistry: Record<string, Function> = {}

Defined in: src/config/config.ts:136

Functions registered by name with BreezeConfig.registerFunction. Breeze looks up validator factories here, under "Validator." + name, when it imports metadata. Applications do not normally need it; use Validator.register and Validator.registerFactory.


interfaceInitialized ​

interfaceInitialized: BreezeEvent<{ instance: BaseAdapter; interfaceName: string; isDefault: boolean; }>

Defined in: src/config/config.ts:155

Published each time an adapter is initialized, with the interface name, the adapter instance and whether it became the default for its interface. Breeze uses it to let adapters that depend on each other recompose (see BaseAdapter.checkForRecomposition); applications do not normally need it.


objectRegistry ​

objectRegistry: Record<string, any> = {}

Defined in: src/config/config.ts:148

Named instances Breeze can find again by name, keyed "<TypeName>.<name>": every JsonResultsAdapter, NamingConvention and LocalQueryComparisonOptions registers itself here when created. Breeze uses it to resolve the names in exported metadata and exported entities. Applications do not normally need it.


stringifyPad ​

stringifyPad: string = ''

Defined in: src/config/config.ts:177

The indentation Breeze passes to JSON.stringify when it serializes exported entities (EntityManager.exportEntities) and exported metadata (MetadataStore.exportMetadata). The default, '', produces compact JSON; set it to, say, ' ' for readable output.


typeRegistry ​

typeRegistry: Record<string, Function> = {}

Defined in: src/config/config.ts:141

Constructors registered by name with BreezeConfig.registerType. Nothing in Breeze 3 reads it; applications do not normally need it.

Methods ​

getAdapter() ​

getAdapter(interfaceName, adapterName?): any

Defined in: src/config/config.ts:233

Returns the ctor function used to implement a specific interface with a specific adapter name.

Parameters ​

interfaceName ​

AdapterType

{String} One of the following interface names: "ajax", "dataService", "modelLibrary", "uriBuilder"

adapterName? ​

string

{String} The name of any previously registered adapter. If this parameter is omitted then this method returns the "default" adapter for this interface. If there is no default adapter, then a null is returned.

Returns ​

any

Returns either a ctor function or null.


getAdapterInstance() ​

getAdapterInstance<T>(interfaceName, adapterName?): T | undefined

Defined in: src/config/config.ts:280

Returns the adapter instance corresponding to the specified interface and adapter names.

Type Parameters ​

T ​

T extends BaseAdapter

Parameters ​

interfaceName ​

AdapterType

{String} The name of the interface.

adapterName? ​

string

{String} - The name of a previously registered adapter. If this parameter is omitted then the default implementation of the specified interface is returned. If there is no defaultInstance of this interface, then the first registered instance of this interface is returned.

Returns ​

T | undefined


getInterfaceDef() ​

getInterfaceDef<T>(interfaceName): InterfaceDef<T>

Defined in: src/config/config.ts:344

Returns the registry entry for one adapter interface, which holds its registered adapters and its default instance. The name is matched without regard to case. Used by the adapter registration methods; applications do not normally need it.

Type Parameters ​

T ​

T extends BaseAdapter

Parameters ​

interfaceName ​

string

'ajax', 'dataService', 'modelLibrary' or 'uriBuilder'.

Returns ​

InterfaceDef<T>

Throws ​

if there is no interface with that name.


getRegisteredFunction() ​

getRegisteredFunction(fnName): Function

Defined in: src/config/config.ts:333

Returns the function registered under the given name with BreezeConfig.registerFunction, or undefined if there is none. Validators are registered as "Validator." + name, so config.getRegisteredFunction('Validator.maxLength') returns the maxLength factory.

Parameters ​

fnName ​

string

The name the function was registered under.

Returns ​

Function


initializeAdapterInstance() ​

initializeAdapterInstance(interfaceName, adapterName, isDefault?): BaseAdapter

Defined in: src/config/config.ts:257

Initializes a single adapter implementation. Initialization means either newing a instance of the specified interface and then calling "initialize" on it or simply calling "initialize" on the instance if it already exists.

Parameters ​

interfaceName ​

AdapterType

{String} The name of the interface to which the adapter to initialize belongs.

adapterName ​

string

{String} - The name of a previously registered adapter to initialize.

isDefault? ​

boolean = true

{Boolean} - Whether to make this the default "adapter" for this interface.

Returns ​

BaseAdapter

Deprecated ​

For configuring an application, use configureBreeze({ ajax: MyAdapter, ... }) instead: the adapter classes are passed directly, so a misspelled name is a compile error rather than a runtime one. An adapter's own static register() still calls this - that is how an adapter registers itself, and is not deprecated. Not scheduled for removal.


registerAdapter() ​

registerAdapter<T>(interfaceName, adapterCtor): void

Defined in: src/config/config.ts:213

Method use to register implementations of standard breeze interfaces. Calls to this method are usually made as the last step within an adapter implementation.

Type Parameters ​

T ​

T extends BaseAdapter

Parameters ​

interfaceName ​

AdapterType

{String} - one of the following interface names: "ajax", "dataService", "modelLibrary", "uriBuilder"

adapterCtor ​

AdapterCtor<T>

{Function} - an ctor function that returns an instance of the specified interface.

Returns ​

void

Deprecated ​

For configuring an application, use configureBreeze({ ajax: MyAdapter, ... }) instead: the adapter classes are passed directly, so a misspelled name is a compile error rather than a runtime one. An adapter's own static register() still calls this - that is how an adapter registers itself, and is not deprecated. Not scheduled for removal.


registerFunction() ​

registerFunction(fn, fnName): void

Defined in: src/config/config.ts:302

this is needed for reflection purposes when deserializing an object that needs a fn or ctor. Used to register validators.

Parameters ​

fn ​

Function

fnName ​

string

Returns ​

void


registerType() ​

registerType(ctor, typeName): void

Defined in: src/config/config.ts:318

Registers a constructor under a type name: stamps the name on its prototype as _$typeName and adds it to BreezeConfig.typeRegistry. Breeze registers KeyGenerator this way; applications do not normally need it.

Parameters ​

ctor ​

Function

The constructor to register.

typeName ​

string

The name to register it under.

Returns ​

void

Released under the MIT License.