abstractAModel <S, T>
Hierarchy
Implements
- IModel<S, T>
Index
Constructors
constructor
Type parameters
- S
- T: UnknownModel
Returns AModel<S, T>
Properties
readonlyanchors
The anchors attached to this model, whether declared on it or borrowed from another model.
staticreadonlyinheritedNODE_NAME
The name of the node. All nodes with same name are of the same category.
staticreadonlyinheritedNODE_PACKAGE
The package of the node.
staticreadonlyinheritedNODE_SCHEMA
The schema of the node.
staticreadonlyinheritedNODE_TYPE
The type of the node.
Methods
addAnchor
To attach an AAnchor to this model. An anchor is only added once - re-adding the same anchor, identified by its ID and parent, throws.
Parameters
anchor: MatchingAnchor<BaseAnchorSchema> | UnknownAnchor
Returns void
getAnchor
To get an attached anchor by its ID.
Parameters
anchorId: string
The ID of the anchor.
optionalparent: UnknownModel
The model that declared the anchor. Defaults to self.
Returns UnknownAnchor | undefined
getAnchorIndex
The position of an attached anchor in AModel.anchors, or
-1when it is not attached.Parameters
anchorId: string
The ID of the anchor.
optionalparent: UnknownModel
The model that declared the anchor. Defaults to self.
Returns number
getAnchors
To get all attached anchors, narrowed by anchor class and/or by the value of their properties.
Parameters
filters: { key: string; value: unknown }[] = []
Each filter is a property
keythe anchor must carry with the givenvalue.types: Constructable<MatchingAnchor<BaseAnchorSchema> | UnknownAnchor>[] = []
The anchor classes to keep. An empty list keeps every class.
Returns UnknownAnchor[]
getAnchorsMatchingSchema
To find anchors by their schema rather than by their class.
This is how a module consumes what another module produced without importing its classes - you match on the shape you need, and any anchor satisfying that shape is returned. Anchors that do not satisfy the schema are skipped, not reported as errors.
Type parameters
Parameters
from: Constructable<S>
The anchor schema to match against.
propertyFilters: ObjectKeyValue<S[properties]>[] = []
Each filter is a property
keythe anchor must carry with the givenvalue.options: { searchBoundaryMembers?: boolean } = {}
searchBoundaryMemberssearches the whole boundary this model belongs to. Set it tofalseto search only this model.optionalsearchBoundaryMembers: boolean = true
Returns Promise<MatchingAnchor<S>[]>
getModelsMatchingSchema
To find models by their schema. See AModel.getAnchorsMatchingSchema.
Type parameters
- S: object
Parameters
schema: Constructable<S>
The model schema to match against.
filters: ObjectKeyValue<S>[] = []
Each filter is a schema
keythe model must carry with the givenvalue.options: { searchBoundaryMembers?: boolean } = {}
searchBoundaryMemberssearches the whole boundary this model belongs to. Set it tofalseto search only this model.optionalsearchBoundaryMembers: boolean = true
Returns Promise<MatchingModel<S>[]>
getOverlaysMatchingSchema
To find overlays by their schema. See AModel.getAnchorsMatchingSchema.
Type parameters
Parameters
schema: Constructable<S>
The overlay schema to match against.
propertyFilters: ObjectKeyValue<S[properties]>[] = []
Each filter is a property
keythe overlay must carry with the givenvalue.options: { searchBoundaryMembers?: boolean } = {}
searchBoundaryMemberssearches the whole boundary this model belongs to. Set it tofalseto search only this model.optionalsearchBoundaryMembers: boolean = true
Returns Promise<MatchingModel<S>[]>
getResourcesMatchingSchema
To find resources by their schema. See AModel.getAnchorsMatchingSchema.
Only resources produced by the modules that own the searched models are considered, so this returns another module's resources rather than every resource in the run.
Type parameters
Parameters
schema: Constructable<S>
The resource schema to match against.
propertyFilters: ObjectKeyValue<S[properties]>[] = []
Each filter is a property
keythe resource must carry with the givenvalue.responseFilters: ObjectKeyValue<S[response]>[] = []
Each filter is a response
keythe resource must carry with the givenvalue.options: { searchBoundaryMembers?: boolean } = {}
searchBoundaryMemberssearches the whole boundary this model belongs to. Set it tofalseto search only this model.optionalsearchBoundaryMembers: boolean = true
Returns Promise<MatchingResource<S>[]>
removeAllAnchors
To detach every anchor from this model.
Returns void
removeAnchor
To detach an anchor from this model. Detaching an anchor that is not attached is a no-op.
Parameters
anchor: MatchingAnchor<BaseAnchorSchema> | UnknownAnchor
Returns void
abstractsetContext
Returns string | undefined
abstractsynth
Returns S
The base class of every model - the nodes that describe your infrastructure as intent, before any cloud resource is involved.
You rarely extend
AModeldirectly. Extend one of the base models Octo ships - App, Region, Server, and so on - so that the rest of the ecosystem knows what your model is.AModelis where the behavior common to all of them lives: anchors, and the queries a module uses to find what other modules have already built.Models
Definition of Models.