Skip to main content

abstractAResource <S, T>

@group

Resources

Hierarchy

  • ANode<S, T>
    • AResource

Implements

  • IResource<S, T>

Index

Properties

readonlyparents

parents: (UnknownResource | MatchingResource<BaseResourceSchema>)[] = []

readonlyproperties

properties: S[properties]

readonlyresourceId

resourceId: S[resourceId]

readonlyresponse

response: S[response] = {}

readonlytags

tags: S[tags] = {}

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

addChild

  • addChild(onField: string | keyof T, child: UnknownResource, toField: string): { childToParentDependency: Dependency; parentToChildDependency: Dependency }
  • Parameters

    • onField: string | keyof T
    • child: UnknownResource
    • toField: string

    Returns { childToParentDependency: Dependency; parentToChildDependency: Dependency }

addFieldDependency

  • addFieldDependency(): void
  • @deprecated

    Field dependencies are not supported in resources!


    Returns void

addRelationship

  • @deprecated

    Relationships are not supported in resources!


    Returns { thatToThisDependency: Dependency; thisToThatDependency: Dependency }

clonePropertiesInPlace

  • clonePropertiesInPlace(sourceResource: T): void
  • Parameters

    • sourceResource: T

    Returns void

cloneResourceInPlace

  • cloneResourceInPlace(sourceResource: T, deReferenceResource: (context: string) => Promise<UnknownResource>): Promise<void>
  • Parameters

    • sourceResource: T
    • deReferenceResource: (context: string) => Promise<UnknownResource>

      Returns Promise<void>

    cloneResponseInPlace

    • cloneResponseInPlace(sourceResource: UnknownResource): void
    • Parameters

      • sourceResource: UnknownResource

      Returns void

    cloneTagsInPlace

    • cloneTagsInPlace(sourceResource: UnknownResource): void
    • Parameters

      • sourceResource: UnknownResource

      Returns void

    diff

    • diff(previous: T): Promise<Diff<UnknownNode, unknown>[]>
    • Parameters

      • previous: T

      Returns Promise<Diff<UnknownNode, unknown>[]>

    diffInverse

    • diffInverse(diff: Diff, deReferenceResource: (context: string) => Promise<UnknownResource>): Promise<void>
    • Parameters

      • diff: Diff
      • deReferenceResource: (context: string) => Promise<UnknownResource>

        Returns Promise<void>

      diffProperties

      • diffProperties(previous: T): Promise<Diff<UnknownNode, unknown>[]>
      • Parameters

        • previous: T

        Returns Promise<Diff<UnknownNode, unknown>[]>

      diffTags

      diffUnpack

      • diffUnpack(diff: Diff): Diff<UnknownNode, unknown>[]
      • Parameters

        Returns Diff<UnknownNode, unknown>[]

      findParentsByProperty

      • findParentsByProperty(filters: { key: string; value: unknown }[]): UnknownResource[]
      • Parameters

        • filters: { key: string; value: unknown }[]

        Returns UnknownResource[]

      findParentsByTag

      • findParentsByTag(filters: { key: string; value: string }[]): UnknownResource[]
      • Parameters

        • filters: { key: string; value: string }[]

        Returns UnknownResource[]

      inheritedgetAncestors

      • getAncestors(): UnknownNode[]
      • To get all ancestors of self.

        • Includes parent nodes.
        • Might include sibling nodes, if the dependency behaviors dictate the sibling is necessary for self node to exist.

        Returns UnknownNode[]

      getBoundaryMembers

      • getBoundaryMembers(): UnknownResource[]
      • @deprecated

        Boundary is not supported in resources!


        Returns UnknownResource[]

      inheritedgetChild

      • getChild(name: string, filters?: { key: string; value: any }[]): undefined | UnknownNode
      • To get a child of self that matches the given filters.

        @throws

        NodeError If more than one child is found.


        Parameters

        • name: string

          The NODE_NAME of the child.

        • filters: { key: string; value: any }[] = []

          A set of filters, to be applied on children, where key is the property name and value is the value to filter by.

        Returns undefined | UnknownNode

      inheritedgetChildren

      • getChildren(name?: string): {}
      • To get all children of self.


        Parameters

        • optionalname: string

          The NODE_NAME of the children.

        Returns {}

        All children as an object with the NODE_NAME as the key, and self's dependency to the child as the value.

      inheritedgetContext

      • getContext(): string
      • To get the context of self. A context is a string representation of self that uniquely identifies self in the graph.


        Returns string

      inheritedgetDependencies

      • To get all dependencies of self.

        • Can be filtered to just dependencies with a single node.

        Parameters

        • optionalto: UnknownNode

          The other node. If present, will only return dependencies of self with this node.

        Returns Dependency[]

      inheritedgetDependency

      • To get a dependency of self with another node.


        Parameters

        • to: UnknownNode

          The other node.

        • relationship: DependencyRelationship

          The relationship between self and the other node.

        Returns undefined | Dependency

        The dependency with the other node having the given relationship, or undefined if not found.

      inheritedgetDependencyIndex

      • To get the index of a dependency of self with another node.


        Parameters

        • to: UnknownNode

          The other node.

        • relationship: DependencyRelationship

          The relationship between self and the other node.

        Returns number

        The index of the dependency with the other node having the given relationship, or -1 if not found.

      inheritedgetParents

      • getParents(name?: string): {}
      • To get all parent of self.


        Parameters

        • optionalname: string

          The NODE_NAME of the parent.

        Returns {}

        All parents as an object with the NODE_NAME as the key, and self's dependency to the parent as the value.

      getSiblings

      • getSiblings(): {}
      • @deprecated

        Siblings are not supported in resources!


        Returns {}

      inheritedhasAncestor

      • hasAncestor(node: UnknownNode): boolean
      • To check if given node is an ancestor of self.


        Parameters

        • node: UnknownNode

          The other node.

        Returns boolean

      isDeepEquals

      • isDeepEquals(other?: UnknownResource): boolean
      • Parameters

        • optionalother: UnknownResource

        Returns boolean

      isMarkedDeleted

      • isMarkedDeleted(): boolean
      • To check if self is marked as deleted. A deleted node will be removed from the graph after the transaction.


        Returns boolean

      merge

      • Parameters

        Returns AResource<S, T>

      remove

      • remove(force?: boolean): void
      • To mark self as deleted. A deleted node will be removed from the graph after the transaction.

        • A node cannot be deleted if it has dependencies.
        @throws

        RemoveResourceError If node contains dependencies to other nodes.


        Parameters

        • force: boolean = false

        Returns void

      inheritedremoveDependency

      • removeDependency(dependencyIndex: number): void
      • To remove a dependency from self.


        Parameters

        • dependencyIndex: number

          The index of the dependency to remove.

        Returns void

      inheritedremoveRelationship

      • removeRelationship(node: UnknownNode): void
      • To remove ALL dependencies from self for the given node.


        Parameters

        • node: UnknownNode

          The other node.

        Returns void

      setContext

      • setContext(): string
      • Returns string

      synth

      • synth(): S
      • Returns S

      inheritedtoJSON

      • toJSON(): S
      • Returns S

      staticcloneResource

      • cloneResource<T>(sourceResource: T, deReferenceResource: (context: string) => Promise<UnknownResource>): Promise<T>
      • Type parameters

        • T: UnknownResource

        Parameters

        • sourceResource: T
        • deReferenceResource: (context: string) => Promise<UnknownResource>

          Returns Promise<T>

        staticunSynth

        • unSynth<S, T>(deserializationClass: any, resource: S, deReferenceResource: (context: string) => Promise<UnknownResource>): Promise<T>
        • To create self given its serialized representation.

          • First argument is the serialized representation.
          • Second argument is the deReferenceContext() function to resolve other nodes self depends on.

          Type parameters

          Parameters

          • deserializationClass: any
          • resource: S
          • deReferenceResource: (context: string) => Promise<UnknownResource>

            Returns Promise<T>