Skip to main content

abstractAOverlay <S, T>

The base class of every overlay - a model that spans other models.

Some infrastructure belongs to no single model. Mounting a filesystem into a subnet, for instance, is a fact about both, and forcing it into either one distorts that model. An overlay holds that fact instead, keeping the models it joins clean.

An overlay takes AAnchors rather than models, so it depends on the shape of what it joins and not on another library's classes. Otherwise it behaves like any other model: it has actions, it is diffed, and it is serialized.

@example
@Overlay<MyOverlay>('@example', 'my-overlay', MyOverlaySchema)
export class MyOverlay extends AOverlay<MyOverlaySchema, MyOverlay> { ... }
@group

Overlays

@see

Definition of Overlays.

Hierarchy

Implements

  • IOverlay<S, T>

Index

Properties

readonlyinheritedanchors

anchors: (MatchingAnchor<BaseAnchorSchema> | UnknownAnchor)[] = []

The anchors attached to this model, whether declared on it or borrowed from another model.

readonlyoverlayId

overlayId: S[overlayId]

The ID of the overlay, unique across the infrastructure.

readonlyproperties

properties: S[properties]

The properties of the overlay.

staticreadonlyinheritedNODE_NAME

NODE_NAME: string

The name of the node. All nodes with same name are of the same category.

staticreadonlyinheritedNODE_PACKAGE

NODE_PACKAGE: string

The package of the node.

staticreadonlyinheritedNODE_SCHEMA

NODE_SCHEMA: unknown

The schema of the node.

staticreadonlyinheritedNODE_TYPE

NODE_TYPE: NodeType

The type of the node.

Methods

getAnchor

  • getAnchor(anchorId: string, parent: UnknownModel): UnknownAnchor | undefined
  • To get one of the anchors this overlay joins. Unlike AModel.getAnchor, parent is required - an overlay's anchors are always declared by another model.


    Parameters

    • anchorId: string
    • parent: UnknownModel

    Returns UnknownAnchor | undefined

getAnchorIndex

  • getAnchorIndex(anchorId: string, parent: UnknownModel): number
  • The position of one of the joined anchors. See AOverlay.getAnchor.


    Parameters

    • anchorId: string
    • parent: UnknownModel

    Returns number

inheritedgetAnchors

  • 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 key the anchor must carry with the given value.

    • types: Constructable<MatchingAnchor<BaseAnchorSchema> | UnknownAnchor>[] = []

      The anchor classes to keep. An empty list keeps every class.

    Returns UnknownAnchor[]

inheritedgetAnchorsMatchingSchema

  • getAnchorsMatchingSchema<S>(from: Constructable<S>, propertyFilters?: ObjectKeyValue<S[properties]>[], options?: { searchBoundaryMembers?: boolean }): Promise<MatchingAnchor<S>[]>
  • 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.

    @see

    Definition of Anchors.


    Type parameters

    Parameters

    • from: Constructable<S>

      The anchor schema to match against.

    • propertyFilters: ObjectKeyValue<S[properties]>[] = []

      Each filter is a property key the anchor must carry with the given value.

    • options: { searchBoundaryMembers?: boolean } = {}

      searchBoundaryMembers searches the whole boundary this model belongs to. Set it to false to search only this model.

      • optionalsearchBoundaryMembers: boolean = true

    Returns Promise<MatchingAnchor<S>[]>

inheritedgetModelsMatchingSchema

  • getModelsMatchingSchema<S>(schema: Constructable<S>, filters?: ObjectKeyValue<S>[], options?: { searchBoundaryMembers?: boolean }): Promise<MatchingModel<S>[]>
  • 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 key the model must carry with the given value.

    • options: { searchBoundaryMembers?: boolean } = {}

      searchBoundaryMembers searches the whole boundary this model belongs to. Set it to false to search only this model.

      • optionalsearchBoundaryMembers: boolean = true

    Returns Promise<MatchingModel<S>[]>

inheritedgetOverlaysMatchingSchema

  • getOverlaysMatchingSchema<S>(schema: Constructable<S>, propertyFilters?: ObjectKeyValue<S[properties]>[], options?: { searchBoundaryMembers?: boolean }): Promise<MatchingModel<S>[]>
  • 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 key the overlay must carry with the given value.

    • options: { searchBoundaryMembers?: boolean } = {}

      searchBoundaryMembers searches the whole boundary this model belongs to. Set it to false to search only this model.

      • optionalsearchBoundaryMembers: boolean = true

    Returns Promise<MatchingModel<S>[]>

inheritedgetResourcesMatchingSchema

  • getResourcesMatchingSchema<S>(schema: Constructable<S>, propertyFilters?: ObjectKeyValue<S[properties]>[], responseFilters?: ObjectKeyValue<S[response]>[], options?: { searchBoundaryMembers?: boolean }): Promise<MatchingResource<S>[]>
  • 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 key the resource must carry with the given value.

    • responseFilters: ObjectKeyValue<S[response]>[] = []

      Each filter is a response key the resource must carry with the given value.

    • options: { searchBoundaryMembers?: boolean } = {}

      searchBoundaryMembers searches the whole boundary this model belongs to. Set it to false to search only this model.

      • optionalsearchBoundaryMembers: boolean = true

    Returns Promise<MatchingResource<S>[]>

inheritedremoveAllAnchors

  • removeAllAnchors(): void
  • To detach every anchor from this model.


    Returns void

removeAnchor

  • To stop joining an anchor, which also drops this overlay's dependency on the anchor's parent.

    • The dependency survives while another joined anchor still shares that parent.

    Parameters

    Returns void