Skip to main content

MatchingResource <S>

A resource found by schema. See MatchingAnchor.

Pass one wherever a resource parent is expected, and the translation is carried into the graph, so the child keeps reading its parent through the schema it was written against.

@group

Types

Index

Constructors

constructor

Properties

optionalreadonlyschemaTranslator

schemaTranslator?: (synth: BaseResourceSchema) => S

Reads actual as the matched schema, when the two differ.


Type declaration

Methods

getActual

  • getActual(): AResource<Omit<S, properties | response | tags> & { properties: Record<never, never> } & { response: Record<never, never> } & { tags: Record<never, never> }, any>
  • The resource itself, with its schema hidden - read it through MatchingResource.getSchemaInstance.


    Returns AResource<Omit<S, properties | response | tags> & { properties: Record<never, never> } & { response: Record<never, never> } & { tags: Record<never, never> }, any>

getSchemaInstance

  • getSchemaInstance(): S
  • The resource read as the schema you matched on.


    Returns S

getSchemaInstanceInResourceAction

  • getSchemaInstanceInResourceAction(): Omit<S, response> & { response: Required<S[response]> }
  • The resource read as the schema you matched on, with its response typed as fully populated. Only call it from a resource action, where the parent is guaranteed to already exist.


    Returns Omit<S, response> & { response: Required<S[response]> }

hasSchemaTranslator

  • hasSchemaTranslator(): boolean
  • Whether the match went through a schema translation.


    Returns boolean