Config
Type parameters
▪ T: SuperConstructor
▪ T: SuperConstructor
Hierarchy
↳ Struct
Struct
↳ Config
Implements
- Definable
- Hookable
- Configurable
- Definable
- Hookable
- Configurable
Index
Constructors
Properties
Methods
- assign
- equals
- get
- getActions
- getDefault
- getExact
- getHook
- getHookOrThrow
- getHooks
- getPropTypes
- getPropertyInitializers
- has
- hasAction
- hasDefault
- hasHook
- include
- isConfigurable
- merge
- overrideHook
- registerHook
- removeHook
- set
- toPlainObject
- validateProps
- from
- getPropTypes
- getPropertyInitializers
Constructors
constructor
+ new Config(): Config
Overrides Struct.constructor
Creates an instance of Config. Creates an instance of Config.
example
example
Returns: Config
Properties
Optional
included
• included? : Record‹string, Configurable›
Optional
merged
• merged? : Record‹string, Configurable›
Methods
assign
▸ assign(props
: Props): void
Implementation of Configurable
Assign collection of values to configuration.
throws
{ValidationError}
Thrown if the provided properties does not match prop types.
example
Parameters:
Name | Type | Description |
---|---|---|
props | Props | Properties with relation path: value matching prop types. |
Returns: void
equals
▸ equals(other
: any): boolean
Implementation of Configurable
Inherited from DefinableMixin.equals
Overrides CreateEmployee.equals
Parameters:
Name | Type |
---|---|
other | any |
Returns: boolean
get
▸ get‹T›(path
: string, runtimeDefaultValue?
: T): T | any
Returns value from configuration, included ones or default fallbacks.
example
Type parameters:
▪ T: any
Parameters:
Name | Type | Description |
---|---|---|
path | string | Configuration path using dotted notation for nested objects. |
runtimeDefaultValue? | T | Value that will be returned as default if no value is set on configuration. |
Returns: T | any
Resolved value from instance if its found on path; value from other included configurations; the runtime default value(if provided) or undefined.
getActions
▸ getActions(): Actions
Implementation of Hookable
Inherited from HookableMixin.getActions
Overrides CreateEmployee.getActions
Returns: Actions
getDefault
▸ getDefault‹T›(path
: string): T | any
Implementation of Configurable
Returns default value for configuration(if property initializers are set) or included ones.
Type parameters:
▪ T: any
Parameters:
Name | Type | Description |
---|---|---|
path | string | Configuration path using dotted notation for nested objects. |
Returns: T | any
Resolved default value or undefined.
getExact
▸ getExact‹T›(path
: string): T | any
Implementation of Configurable
Returns exact value set on configuration or included ones(without any fallback in place).
Type parameters:
▪ T: any
Parameters:
Name | Type | Description |
---|---|---|
path | string | Configuration path using dotted notation for nested objects. |
Returns: T | any
Resolved value if its found over provided path or value from other included configurations.
getHook
▸ getHook(action
: string, id
: string): Hook | undefined
Implementation of Hookable
Inherited from HookableMixin.getHook
Overrides CreateEmployee.getHook
Parameters:
Name | Type |
---|---|
action | string |
id | string |
Returns: Hook | undefined
getHookOrThrow
▸ getHookOrThrow(action
: string, id
: string): Hook
Implementation of Hookable
Inherited from HookableMixin.getHookOrThrow
Overrides CreateEmployee.getHookOrThrow
Parameters:
Name | Type |
---|---|
action | string |
id | string |
Returns: Hook
getHooks
▸ getHooks(action
: string): Mappings
Implementation of Hookable
Inherited from HookableMixin.getHooks
Overrides CreateEmployee.getHooks
Parameters:
Name | Type |
---|---|
action | string |
Returns: Mappings
getPropTypes
▸ getPropTypes(): Props
Implementation of Configurable
Overrides DefinableMixin.getPropTypes
Returns all prop types from whole inheritance tree and other included configurations.
Returns: Props
Plain object representation of prop types.
getPropertyInitializers
▸ getPropertyInitializers(): Props
Implementation of Configurable
Inherited from DefinableMixin.getPropertyInitializers
Overrides CreateEmployee.getPropertyInitializers
Returns: Props
has
▸ has(path
: string): boolean
Implementation of Configurable
Evaluates if value is set on configuration or included ones.
example
Parameters:
Name | Type | Description |
---|---|---|
path | string | Configuration path using dotted notation for nested objects. |
Returns: boolean
Returns true
if configuration is set under questioned path, else false
.
hasAction
▸ hasAction(action
: string): boolean
Implementation of Hookable
Inherited from HookableMixin.hasAction
Overrides CreateEmployee.hasAction
Parameters:
Name | Type |
---|---|
action | string |
Returns: boolean
hasDefault
▸ hasDefault(path
: string): boolean
Implementation of Configurable
Evaluates if there is default value set for path on configuration or included ones.
Parameters:
Name | Type | Description |
---|---|---|
path | string | Configuration path using dotted notation for nested objects. |
Returns: boolean
Returns true
if default value is set on configuration, else false
.
hasHook
▸ hasHook(action
: string, id
: string): boolean
Implementation of Hookable
Inherited from HookableMixin.hasHook
Overrides CreateEmployee.hasHook
Parameters:
Name | Type |
---|---|
action | string |
id | string |
Returns: boolean
include
▸ include(config
: Configurable): void
Implementation of Configurable
Attaches another configuration instance to current configuration.
throws
{InvalidConfigError}
Thrown if the passed configuration is not implementation of Configurable
interface.
example
Parameters:
Name | Type | Description |
---|---|---|
config | Configurable | Instance implementing Configurable interface. |
Returns: void
isConfigurable
▸ isConfigurable(path
: string): boolean
Implementation of Configurable
Evaluates if value can be configured on specific path.
example
Parameters:
Name | Type | Description |
---|---|---|
path | string | Configuration path using dotted notation for nested objects. |
Returns: boolean
Returns true
if property on path is configurable on configuration, else false
.
merge
▸ merge(config
: Configurable): void
Implementation of Configurable
Attaches another configuration instance to current configuration and merges all properties. Parent configuration merging child will always have precedence in values assigned on same paths.
throws
{InvalidConfigError}
Thrown if the passed configuration is not implementation of Configurable
interface.
Parameters:
Name | Type | Description |
---|---|---|
config | Configurable | Instance implementing Configurable interface. |
Returns: void
overrideHook
▸ overrideHook(action
: string, id
: string, hook
: Hook): void
Implementation of Hookable
Inherited from HookableMixin.overrideHook
Overrides CreateEmployee.overrideHook
Parameters:
Name | Type |
---|---|
action | string |
id | string |
hook | Hook |
Returns: void
registerHook
▸ registerHook(action
: string, id
: string, hook
: Hook, shouldOverride?
: boolean): void
Implementation of Hookable
Inherited from HookableMixin.registerHook
Overrides CreateEmployee.registerHook
Parameters:
Name | Type |
---|---|
action | string |
id | string |
hook | Hook |
shouldOverride? | boolean |
Returns: void
removeHook
▸ removeHook(action
: string, id
: string): void
Implementation of Hookable
Inherited from HookableMixin.removeHook
Overrides CreateEmployee.removeHook
Parameters:
Name | Type |
---|---|
action | string |
id | string |
Returns: void
set
▸ set‹T›(path
: string, value
: T): void
Implementation of Configurable
Sets a value on configuration.
throws
{ValidationError}
Thrown if the provided value does not match the prop types.
example
Type parameters:
▪ T: any
Parameters:
Name | Type | Description |
---|---|---|
path | string | Configuration path using dotted notation for nested objects. |
value | T | Value to be set on configuration. |
Returns: void
toPlainObject
▸ toPlainObject(): Props
Implementation of Configurable
Inherited from DefinableMixin.toPlainObject
Overrides CreateEmployee.toPlainObject
Returns: Props
validateProps
▸ validateProps(props
: Record‹string | number | symbol, any› | undefined, propTypes
: PropTypes, isStrict?
: boolean): boolean
Inherited from DefinableMixin.validateProps
Overrides CreateEmployee.validateProps
Parameters:
Name | Type |
---|---|
props | Record‹string | number | symbol, any› | undefined |
propTypes | PropTypes |
isStrict? | boolean |
Returns: boolean
Static
from
▸ from‹T›(props
: Record‹string, any›): T
Create an Config
from plain object source of properties.
throws
{ValidationError}
Thrown if the passed properties does not match config property types.
Type parameters:
▪ T
Parameters:
Name | Type | Description |
---|---|---|
props | Record‹string, any› | Properties as object that can contains other nested configurations. |
Returns: T
New instance of Config
with assigned properties.
Static
getPropTypes
▸ getPropTypes(): Props
Inherited from DefinableMixin.getPropTypes
Overrides CreateEmployee.getPropTypes
Returns: Props
Static
getPropertyInitializers
▸ getPropertyInitializers(): Props
Inherited from DefinableMixin.getPropertyInitializers
Overrides CreateEmployee.getPropertyInitializers
Returns: Props