Member Junction
    Preparing search index...

    Class EntityDocumentTemplateParserBaseAbstract

    Abstract base class for entity document template parsing. Use EntityDocumentTemplateParser or a subclass thereof.

    Hierarchy (View Summary)

    Index

    Constructors

    Properties

    _provider?: IMetadataProvider

    Optional provider override; falls back to Metadata.Provider when not set.

    __cache: Map<string, string> = ...

    Resolved placeholders by cache key, in least-recently-used-first order.

    MaxCachedPlaceholders: 10000 = 10_000

    The most resolved placeholders kept at once. Every record version adds entries (the key includes a hash of the record values), so the least recently used entry is evicted once the cache is full.

    Accessors

    Methods

    • Evaluates a single placeholder argument: either a function call like Relationship(...) or a field/path reference like Name or __Parent.Title.

      Parameters

      • argument: string
      • entityID: string
      • entityRecord: Record<string, unknown>
      • ContextUser: UserInfo

      Returns Promise<string>

    • Parses an entity document template and replaces values within ${} placeholders with actual values from the entity record. If template uses Nunjucks {{ }} syntax, it is pre-rendered with the MJ TemplateEngine first.

      Parameters

      • Template: string

        the document template to parse

      • EntityID: string

        the ID of the entity

      • EntityRecord: Record<string, unknown>

        the values for the entity record (may contain __Parent context)

      • ContextUser: UserInfo

        the current user

      Returns Promise<string>

      the evaluated value of the template incorporating fields, nested contexts, and function call(s)

    • Builds the key a resolved placeholder is cached under. Placeholders such as Relationship() load rows under the caller's permissions, so the key includes the user. It also includes a hash of the record values the placeholder was resolved from: a caller that strips restricted fields from a record must not be served a value resolved earlier from the full record, and a record whose values changed must not be served the old value. Returns null when there is no user ID, in which case the placeholder is resolved without caching.

      Parameters

      • EntityID: string
      • EntityRecordPrimaryKey: string
      • Content: string
      • UserID: string
      • RecordValuesHash: string = ''

        a hash of the record values, from HashRecordValues

      Returns string

    • A hash of a record's values (nested objects such as __Parent included), independent of key order, so two records with the same values hash alike however they were built.

      Parameters

      • EntityRecord: Record<string, unknown>

      Returns string