ModelTypeResolver
Class: ModelTypeResolver
Defined in: packages/models/lib/types-resolver.d.ts:53
Resolve the __type stored in a row (Webda 3 short, lower-case or renamed forms included) to a model
Resolution order, first match wins:
- the exact identifier (or a map key that is not the identifier);
- a
@WebdaAlias, exact, then case-insensitive; - an identifier, case-insensitive;
- for a value without
/:<namespace>/<value>thenWebda/<value>, case-insensitive, identifiers then aliases; - otherwise unknown.
Two different models matching at the same step make the value ambiguous: it resolves to nothing.
Constructors
Constructor
new ModelTypeResolver(
models,options?):ModelTypeResolver
Defined in: packages/models/lib/types-resolver.d.ts:80
Parameters
models
ModelClass<Storable<any, any>>[] | Record<string, ModelClass<Storable<any, any>>>
models by identifier (an application model map), or a list of classes carrying Metadata
options?
ModelTypeResolverOptions
namespace and exact mode
Returns
ModelTypeResolver
Properties
accepted
protectedreadonlyaccepted:Map<ModelClass<Storable<any,any>>,string[]>
Defined in: packages/models/lib/types-resolver.d.ts:75
Cache of accepted types
aliases
protectedreadonlyaliases:Map<string,Set<ModelClass<Storable<any,any>>>>
Defined in: packages/models/lib/types-resolver.d.ts:67
Aliases
byName
protectedreadonlybyName:Map<string,ModelClass<Storable<any,any>>>
Defined in: packages/models/lib/types-resolver.d.ts:59
Exact names (identifiers and extra map keys) to class
exactOnly
readonlyexactOnly:boolean
Defined in: packages/models/lib/types-resolver.d.ts:57
Only exact identifiers match
extraNames
protectedreadonlyextraNames:Map<ModelClass<Storable<any,any>>,string[]>
Defined in: packages/models/lib/types-resolver.d.ts:63
Map keys of a class that are not its identifier
families
protectedreadonlyfamilies:Map<ModelClass<Storable<any,any>>,ModelClass<Storable<any,any>>[]>
Defined in: packages/models/lib/types-resolver.d.ts:73
Cache of families
identifiers
protectedreadonlyidentifiers:Map<ModelClass<Storable<any,any>>,string>
Defined in: packages/models/lib/types-resolver.d.ts:61
Current identifier of each class
lowerAliases
protectedreadonlylowerAliases:Map<string,Set<ModelClass<Storable<any,any>>>>
Defined in: packages/models/lib/types-resolver.d.ts:69
Lower-case aliases
lowerNames
protectedreadonlylowerNames:Map<string,Set<ModelClass<Storable<any,any>>>>
Defined in: packages/models/lib/types-resolver.d.ts:65
Lower-case identifiers and extra names
namespace
readonlynamespace:string
Defined in: packages/models/lib/types-resolver.d.ts:55
Application namespace
resolutions
protectedreadonlyresolutions:Map<string,TypeResolution>
Defined in: packages/models/lib/types-resolver.d.ts:71
Cache of resolutions
Methods
acceptedTypes()
acceptedTypes(
model):string[]
Defined in: packages/models/lib/types-resolver.d.ts:147
Every stored string that resolves to the model or one of its transitive subclasses: identifiers, short names, lower-case forms, aliases and their short and lower-case forms
Parameters
model
the model
Returns
string[]
the strings, deduplicated
addName()
protectedaddName(name,clazz,extra):void
Defined in: packages/models/lib/types-resolver.d.ts:87
Index a name of a class
Parameters
name
string
identifier or extra name
clazz
the class
extra
boolean
true for a map key that is not the identifier
Returns
void
belongsToModel()
belongsToModel(
model,stored,tableRoot?):boolean
Defined in: packages/models/lib/types-resolver.d.ts:157
Whether a stored row belongs to a model
Parameters
model
the model queried
stored
string
the stored __type, undefined for an untyped row
tableRoot?
the model owning the untyped rows of the table, when known
Returns
boolean
true when the row resolves to the model or one of its transitive subclasses; an untyped row belongs to the table root and its ancestors (to every model when the root is not known), and so does a row typed as a strict ancestor of the table root
computeResolution()
protectedcomputeResolution(stored):TypeResolution
Defined in: packages/models/lib/types-resolver.d.ts:122
Run the resolution steps
Parameters
stored
string
the stored value
Returns
the resolution
family()
family(
model):ModelClass<Storable<any,any>>[]
Defined in: packages/models/lib/types-resolver.d.ts:135
The model and all its transitive subclasses: from Metadata.Subclasses (direct only), then any known class
extending the model that the metadata does not list
Parameters
model
the model
Returns
ModelClass<Storable<any, any>>[]
the model first, then its subclasses
found()
protectedfound(stored,model):TypeResolution
Defined in: packages/models/lib/types-resolver.d.ts:128
Parameters
stored
string
the stored value
model
the matched model
Returns
the resolution of a match
getIdentifier()
getIdentifier(
model):string
Defined in: packages/models/lib/types-resolver.d.ts:105
Parameters
model
a class
Returns
string
its current identifier, undefined when the class is not known
identifiersOf()
identifiersOf(
model):string[]
Defined in: packages/models/lib/types-resolver.d.ts:140
Parameters
model
the model
Returns
string[]
the current identifiers of the model and its transitive subclasses
knows()
knows(
model):boolean
Defined in: packages/models/lib/types-resolver.d.ts:100
Parameters
model
a class
Returns
boolean
true when the class is one of the models of this resolver
resolve()
resolve(
stored):TypeResolution
Defined in: packages/models/lib/types-resolver.d.ts:111
Resolve a stored __type
Parameters
stored
string
the stored value
Returns
the resolution
resolveStoredType()
resolveStoredType(
stored):ModelClass<Storable<any,any>>
Defined in: packages/models/lib/types-resolver.d.ts:116
Parameters
stored
string
the stored value
Returns
ModelClass<Storable<any, any>>
the model, undefined when unknown or ambiguous
forHierarchy()
staticforHierarchy(model):ModelTypeResolver
Defined in: packages/models/lib/types-resolver.d.ts:95
Resolver of the hierarchy of a model only, exact identifiers only
Used for repositories whose model is not part of the installed application: today's exact matching.
Parameters
model
the model
Returns
ModelTypeResolver
the resolver