VersionableMixin
Hierarchy
- VersionableMixin
Index
Properties
Methods
- getLegacyTransformer
- getLegacyTransformers
- getSchemaVersion
- hasLegacyTransformer
- overrideLegacyTransformer
- registerLegacyTransformer
- transformLegacyProps
Properties
Optional
schemaVersion
• schemaVersion? : number
Methods
getLegacyTransformer
▸ getLegacyTransformer(schemaVersion
: number): Hook
Returns legacy transformer for schema version.
throws
{LegacyTransformerNotFoundError}
Thrown if transformer for schema version can't be found.
Parameters:
Name | Type | Description |
---|---|---|
schemaVersion | number | Schema version. |
Returns: Hook
Legacy transformer for schema version.
getLegacyTransformers
▸ getLegacyTransformers(): LegacyTransformers
Returns all available legacy transformers.
Returns: LegacyTransformers
Map instance of all registered legacy transformers with number version as a key and transformer function as a value.
getSchemaVersion
▸ getSchemaVersion(): number | undefined
Returns current instance schema version.
Returns: number | undefined
Schema version as a number, else undefined
.
hasLegacyTransformer
▸ hasLegacyTransformer(schemaVersion
: number): boolean
Evaluates is there is registered legacy transformer for schema version.
Parameters:
Name | Type | Description |
---|---|---|
schemaVersion | number | Schema version. |
Returns: boolean
Returns true
if legacy transformer for schema version is registered, else false
.
overrideLegacyTransformer
▸ overrideLegacyTransformer(schemaVersion
: number, transformer
: Hook): void
Overrides registered transformer by schema version or registers a new one.
throws
{InvalidSchemaVersionError}
Thrown if the the schema version argument is not a number.
Parameters:
Name | Type | Description |
---|---|---|
schemaVersion | number | Schema version. |
transformer | Hook | Transformer function. |
Returns: void
registerLegacyTransformer
▸ registerLegacyTransformer(schemaVersion
: number, transformer
: Hook, shouldOverride?
: boolean): void
Registers legacy transformer for version.
throws
{InvalidSchemaVersionError}
Thrown if the the schema version argument is not a number.
throws
{LegacyTransformerAlreadyExistsError}
Thrown if transformer for version would overridden without explicit call.
Parameters:
Name | Type | Description |
---|---|---|
schemaVersion | number | Schema version. |
transformer | Hook | Transformer function. |
shouldOverride? | boolean | Flag indicating that transformer should be overridden if exist. |
Returns: void
transformLegacyProps
▸ transformLegacyProps(props
: Props): Props
Registrable hook for transforming legacy schema.
Parameters:
Name | Type | Description |
---|---|---|
props | Props | Properties object to be transformed. |
Returns: Props
Transformed legacy properties or their unchanged state if up to date.