{"version":3,"file":"ogs-gmbh-ngx-template-engine.mjs","sources":["../../../src/ast.ts","../../../src/chars.ts","../../../src/utils.ts","../../../src/transformer.ts","../../../src/parser.ts","../../../src/token.ts","../../../src/pipes/template.ts","../../../src/ogs-gmbh-ngx-template-engine.ts"],"sourcesContent":["/**\n * Represents an Abstract Syntax Tree (AST) for the template engine.\n * @category AST\n *\n * @since 1.0.0\n * @author Simon Kovtyk\n */\ntype Ast = {\n  /**\n   * The mode of the AST, indicating whether it uses index-based or property-based template variables.\n   *\n   * @since 1.0.0\n   * @author Simon Kovtyk\n   */\n  mode: AstMode;\n  /**\n   * The list of nodes that make up the AST.\n   *\n   * @since 1.0.0\n   * @author Simon Kovtyk\n   */\n  nodes: AstNodes;\n};\n\n/**\n * A list of {@link AstNode} elements. Typically used to represent the children of an {@link Ast}.\n * @category AST\n *\n * @since 1.0.0\n * @author Simon Kovtyk\n */\ntype AstNodes = AstNode[];\n\n/**\n * Specifies the mode of an AST. When the first template variable is {0} (index-based), every following\n * template variable must be index-based. Same applies to {property} (property-based).\n * This result in only having one mode for the ast to work with.\n * @category AST\n *\n * @since 1.0.0\n * @author Simon Kovtyk\n */\ntype AstMode = \"index\" | \"property\";\n\n/**\n * Represents a single node in an Abstract Syntax Tree (AST).\n * @category AST\n *\n * @since 1.0.0\n * @author Simon Kovtyk\n */\ntype AstNode = {\n  kind: AstKind;\n};\n\n/**\n * Represents an AST node that refers to a template property.\n * Extends {@link AstNode} by adding a \"property\" field for property-based access.\n * @category AST\n *\n * @since 1.0.0\n * @author Simon Kovtyk\n */\ntype AstTemplatePropertyNode = AstNode & {\n  property: string;\n};\n\n/**\n * Represents an AST node that refers to a template index. Extends {@link AstNode} by adding an \"index\" field for index-based access.\n * @category AST\n *\n * @since 1.0.0\n * @author Simon Kovtyk\n */\ntype AstTemplateIndexNode = AstNode & {\n  index: number;\n};\n\n/**\n * Represents an AST node that contains plain text. Extends {@link AstNode} by adding a \"value\" field for the text content.\n * @category AST\n *\n * @since 1.0.0\n * @author Simon Kovtyk\n */\ntype AstTextNode = AstNode & {\n  value: string;\n};\n\n/**\n * Enumerates the kinds of AST nodes used by the template engine.\n * @category AST\n *\n * @since 1.0.0\n * @author Simon Kovtyk\n */\nenum AstKind {\n  TEMPLATE_PROPERTY = \"template-property\",\n  TEMPLATE_INDEX = \"template-index\",\n  TEXT = \"text\"\n}\n\n/**\n * Creates an AST node representing a property access expression.\n * @category AST\n *\n * @param property - The name of the template property to access.\n * @returns A new {@link AstTemplatePropertyNode} with the given property name.\n *\n * @since 1.0.0\n * @author Simon Kovtyk\n */\nfunction createAstTemplatePropertyNode (property: string): AstTemplatePropertyNode {\n  return {\n    kind: AstKind.TEMPLATE_PROPERTY,\n    property\n  };\n}\n\n/**\n * Creates an AST node representing an indexed access expression.\n * @category AST\n *\n * @param index - The numeric index to access.\n * @returns A new {@link AstTemplateIndexNode} with the given index.\n *\n * @since 1.0.0\n * @author Simon Kovtyk\n */\nfunction createAstTemplateIndexNode (index: number): AstTemplateIndexNode {\n  return {\n    kind: AstKind.TEMPLATE_INDEX,\n    index\n  };\n}\n\n/**\n * Creates an AST node representing a plain text segment in the template.\n * @category AST\n *\n * @param value - The text content to store in the node.\n * @returns A new {@link AstTextNode} instance.\n *\n * @since 1.0.0\n * @author Simon Kovtyk\n */\nfunction createAstTextNode (value: string): AstTextNode {\n  return {\n    kind: AstKind.TEXT,\n    value\n  };\n}\n\nexport type {\n  Ast,\n  AstNodes,\n  AstNode,\n  AstMode,\n  AstTemplatePropertyNode,\n  AstTemplateIndexNode,\n  AstTextNode\n};\nexport {\n  AstKind,\n  createAstTemplatePropertyNode,\n  createAstTemplateIndexNode,\n  createAstTextNode\n};\n","/**\n * Defines the template manipulation char properties\n * @category AST\n *\n * @since 1.0.0\n * @author Simon Kovtyk\n */\nenum CharKind {\n  /**\n   * Indicates the starting character of a template expression.\n   *\n   * @since 1.0.0\n   * @author Simon Kovtyk\n   */\n  START = \"start\",\n  /**\n   * Initiates the ending character of a template expression.\n   *\n   * @since 1.0.0\n   * @author Simon Kovtyk\n   */\n  END = \"end\"\n}\n\n/**\n * Describes a template manipulation character and its kind\n * @category AST\n *\n * @since 1.0.0\n * @author Simon Kovtyk\n */\ntype CharDescriptor = {\n  /**\n   * Character used in template manipulation\n   *\n   * @since 1.0.0\n   * @author Simon Kovtyk\n   */\n  \"char\": string;\n  /**\n   * Indicates the kind of template character\n   *\n   * @since 1.0.0\n   * @author Simon Kovtyk\n   */\n  kind: CharKind;\n};\n\n/**\n * An representation of template manipulation characters\n * @category AST\n *\n * @since 1.0.0\n * @author Simon Kovtyk\n */\nconst TEMPLATE_CHARS: Record<string, CharDescriptor> = {\n  /**\n   * A {@link CharDescriptor} for the opening template manipulation character\n   * @since 1.0.0\n   * @author Simon Kovtyk\n   */\n  CURLY_LEFT: {\n    \"char\": \"{\",\n    kind: CharKind.START\n  },\n  /**\n   * A {@link CharDescriptor} for the closing template manipulation character\n   * @since 1.0.0\n   * @author Simon Kovtyk\n   */\n  CURLY_RIGHT: {\n    \"char\": \"}\",\n    kind: CharKind.END\n  }\n};\n\nexport type {\n  CharDescriptor\n};\nexport {\n  CharKind,\n  TEMPLATE_CHARS\n};\n","import { CharDescriptor, TEMPLATE_CHARS } from \"./chars\";\n\n/**\n * Retrieves the character descriptor for a given template manipulation character\n * @category AST\n * @param char - The character to retrieve the descriptor for.\n * @returns The corresponding {@link CharDescriptor} if found, otherwise null.\n *\n * @since 1.0.0\n * @author Simon Kovtyk\n */\nfunction getCharDescriptor (char: string): CharDescriptor | null {\n  const templateCharKeys: string[] = Object.keys(TEMPLATE_CHARS);\n\n  let charDescriptor: CharDescriptor | null = null;\n\n  templateCharKeys.forEach((templateCharKey: string): void => {\n    const templateChar: CharDescriptor | undefined = TEMPLATE_CHARS[ templateCharKey ];\n\n    if (templateChar?.[ \"char\" ] !== char)\n      return;\n\n    charDescriptor = templateChar;\n  });\n\n  return charDescriptor;\n}\n\nfunction isObject (value: unknown): boolean {\n  return typeof value === \"object\" && !Array.isArray(value) && value !== null;\n}\n\nexport {\n  getCharDescriptor,\n  isObject\n};\n","import { Ast, AstKind, AstNode, AstTemplatePropertyNode, AstTextNode, AstTemplateIndexNode } from \"./ast\";\nimport { isObject } from \"./utils\";\n\n/**\n * A record of key-value pairs where the keys are strings and the values are either strings or numbers.\n * @category AST\n *\n * @since 1.0.0\n * @author Simon Kovtyk\n */\ntype DataRecord = Record<string, string | number>;\n\n/**\n * An array of values where each item is either a string or a number.\n * @category AST\n *\n * @since 1.0.0\n * @author Simon Kovtyk\n */\ntype DataArray = Array<string | number>;\n\n/**\n * Evaluates an {@link Ast} using the provided data and returns the transformed string.\n * @category AST\n *\n * @param ast - The AST produced by {@link parseAst}.\n * @param data - The data record or array used to replace template placeholders.\n * @returns The transformed string.\n * @throws If the data type does not match the AST mode or if required data is missing.\n *\n * @since 1.0.0\n * @author Simon Kovtyk\n */\nfunction transformAst (ast: Ast, data: DataRecord | DataArray): string {\n  if (Array.isArray(data) && ast.mode !== \"index\" || isObject(data) && ast.mode !== \"property\")\n    throw new Error(`Expected an appropiate data type matching to ${ ast.mode }-based template variables`);\n\n  /* eslint-disable-next-line array-callback-return */\n  return ast.nodes.map((node: AstNode): string => {\n    if (node.kind === AstKind.TEXT)\n      return (node as AstTextNode).value;\n\n    switch (ast.mode) {\n      case \"property\": {\n        const dataIndex: string = (node as AstTemplatePropertyNode).property;\n        const dataValue: string | number | undefined = (data as DataRecord)[ dataIndex ];\n\n        if (dataValue === undefined)\n          throw new Error(`Expected data for key ${ dataIndex }`);\n\n        return dataValue.toString();\n      }\n\n      case \"index\": {\n        const dataIndex: number = (node as AstTemplateIndexNode).index;\n        const dataValue: string | number | undefined = (data as DataArray)[ dataIndex ];\n\n        if (dataValue === undefined)\n          throw new Error(`Expected data for key ${ dataIndex }`);\n\n        return dataValue.toString();\n      }\n    }\n  }).join(\"\");\n}\n\nexport type {\n  DataRecord,\n  DataArray\n};\nexport {\n  transformAst\n};\n","import { CharDescriptor, CharKind } from \"./chars\";\nimport { Ast, AstMode, AstNodes, createAstTemplateIndexNode, createAstTemplatePropertyNode, createAstTextNode } from \"./ast\";\nimport { getCharDescriptor } from \"./utils\";\n\n/**\n * Parses a string and returns its AST representation.\n * @category AST\n *\n * @param value - The string input to parse.\n * @returns The parsed AST.\n * @throws If the input string cannot be parsed into a valid AST.\n *\n * @since 1.0.0\n * @author Simon Kovtyk\n */\nfunction parseAst (value: string): Ast {\n  const splittedValue: string[] = [...value];\n\n  if (splittedValue.length === 0)\n    throw new Error(\"Error processing a zero length data sequence\");\n\n  const astNodes: AstNodes = [];\n\n  let sequence: string | null = null;\n  let lastCharKind: CharKind | null = null;\n  let detectedAstMode: AstMode | null = null;\n\n  splittedValue.forEach((char: string, index: number): void => {\n    const charDescriptor: CharDescriptor | null = getCharDescriptor(char);\n\n    // Got a char so just append it\n    if (charDescriptor === null) {\n      sequence === null ? sequence = char : sequence += char;\n\n      if (index === splittedValue.length - 1) {\n        astNodes.push(\n          createAstTextNode(sequence)\n        );\n        sequence = null;\n      }\n\n      return;\n    }\n\n    // Got a char descriptor, so handle it\n    switch (charDescriptor.kind) {\n      case CharKind.START: {\n        // When no char kind ended before start char kind then its a syntax error\n        if (lastCharKind !== null && lastCharKind !== CharKind.END)\n          throw new Error(`Expected an end char kind, but got a start char kind at index ${ index } instead`);\n\n        if (sequence !== null) {\n          astNodes.push(\n            createAstTextNode(sequence)\n          );\n          sequence = null;\n        }\n\n        break;\n      }\n\n      case CharKind.END: {\n        // When no property inside text is found, char kinds job is not fullfilled\n        if (sequence === null)\n          throw new Error(`Unexpected end at index ${ index }. Expected a index or keyword property`);\n\n        // End char kind is only possible when start char kind was the previous char kind\n        if (lastCharKind !== CharKind.START)\n          throw new Error(`Expected start char kind to be ${ CharKind.START }, but got ${ lastCharKind } instead`);\n\n        const indexSequence: number = Number(sequence);\n        const nodeAstMode: AstMode = Number.isNaN(indexSequence) ? \"property\" : \"index\";\n\n        // If current template variable is based differently than detected ast mode its a syntax error\n        if (detectedAstMode !== null && detectedAstMode !== nodeAstMode)\n          throw new Error(`Expected to have only ${ detectedAstMode }-based template variables, but got a ${ nodeAstMode }-based instead`);\n\n        detectedAstMode ??= nodeAstMode;\n        astNodes.push(\n          detectedAstMode === \"index\"\n            ? createAstTemplateIndexNode(indexSequence)\n            : createAstTemplatePropertyNode(sequence)\n        );\n        sequence = null;\n\n        break;\n      }\n    }\n\n    lastCharKind = charDescriptor.kind;\n  });\n\n  // When ast mode could not be detected, then why is someone using this on a value only char sequence?\n  /* eslint-disable-next-line @tseslint/no-unnecessary-condition */\n  if (detectedAstMode === null)\n    throw new Error(`Expected template to have at least 1 index- or property-based variable`);\n\n  return {\n    mode: detectedAstMode,\n    nodes: astNodes\n  };\n}\n\nexport {\n  parseAst\n};\n","import { InjectionToken, ValueProvider } from \"@angular/core\";\n\n/**\n * Configuration options for the template engine.\n * @category NG interop\n * @property fallbackOnError - Optional flag to return the last successful result when a transformation fails.\n *\n * @since 1.1.0\n * @author Simon Kovtyk\n */\nexport type TemplateEngineConfig = {\n  fallbackOnError?: boolean;\n};\n/**\n * Injection token for providing template engine configuration.\n * @category NG interop\n * @readonly\n *\n * @since 1.1.0\n * @author Simon Kovtyk\n */\nexport const TEMPLATE_ENGINE_CONFIG_TOKEN: InjectionToken<TemplateEngineConfig> = new InjectionToken<TemplateEngineConfig>(\"template-engine-config\");\n/**\n * Creates a value provider for supplying a {@link TemplateEngineConfig} to the dependency injection system.\n * @category NG interop\n *\n * @param config - The template engine configuration to provide.\n * @returns A `ValueProvider` that binds the configuration to {@link TEMPLATE_ENGINE_CONFIG_TOKEN}.\n *\n * @since 1.1.0\n * @author Simon Kovtyk\n */\nexport function provideTemplateEngineConfig (config: TemplateEngineConfig): ValueProvider {\n  return {\n    provide: TEMPLATE_ENGINE_CONFIG_TOKEN,\n    useValue: config\n  };\n}\n","import { inject, Pipe, PipeTransform } from \"@angular/core\";\nimport { DataArray, DataRecord, transformAst } from \"../transformer\";\nimport { Ast } from \"../ast\";\nimport { parseAst } from \"../parser\";\nimport { TEMPLATE_ENGINE_CONFIG_TOKEN, TemplateEngineConfig } from \"../token\";\n\n/**\n * Angular pipe that transforms template strings by replacing placeholders with provided data.\n * @category NG interop\n * @remarks\n * This pipe parses the template into an {@link Ast} and evaluates it using {@link transformAst},\n * supports optional fallback behavior: If an error occurs during transformation and fallback is enabled, the pipe\n * returns the last successfully transformed value instead of throwing an error.\n * Fallback behavior may be enabled explicitly via the \"fallbackOnError\" parameter or globally through {@link TemplateEngineConfig}.\n *\n * @since 1.1.0\n * @author Simon Kovtyk\n */\n@Pipe({\n  name: \"template\"\n})\nexport class TemplatePipe implements PipeTransform {\n  private readonly _config: TemplateEngineConfig | null = inject(TEMPLATE_ENGINE_CONFIG_TOKEN, { optional: true });\n\n  private _boostrapValue: string | null = null;\n \n  /* eslint-disable-next-line @tseslint/class-methods-use-this */\n  private _parseAndTransform (value: string, data: DataRecord | DataArray): string {\n    const ast: Ast = parseAst(value);\n\n    return transformAst(ast, data);\n  }\n\n  private _updateBoostrapValue (value: string): void {\n    if (this._boostrapValue !== null)\n      return;\n\n    this._boostrapValue = value;\n  }\n\n  /**\n   * Transforms a template string using the provided data.\n   * @param value - The template string to transform.\n   * @param data - Object or array of values to replace placeholders.\n   * @param fallbackOnError - Optional flag to return the last successful result on error.\n   *\n   * @returns The transformed template string.\n   * @throws If transformation fails and no fallback value is available.\n   *\n   * @since 1.0.0\n   * @author Simon Kovtyk\n   */\n  public transform(value: string, data: DataRecord | DataArray, fallbackOnError?: boolean): string {\n    const shouldFallbackOnError: boolean | undefined = fallbackOnError ?? this._config?.fallbackOnError;\n\n    if (!shouldFallbackOnError) {\n      const transformedValue: string = this._parseAndTransform(value, data);\n\n      this._updateBoostrapValue(transformedValue);\n\n      return transformedValue;\n    }\n\n    try {\n      const transformedValue: string = this._parseAndTransform(value, data);\n\n      this._updateBoostrapValue(transformedValue);\n\n      return transformedValue;\n    } catch {\n      if (this._boostrapValue === null)\n        throw new Error(\"Expected an initial fallback value\");\n\n      return this._boostrapValue;\n    }\n  }\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;AAyFA;;;;;;AAMG;AACH,IAAK;AAAL,CAAA,UAAK,OAAO,EAAA;AACV,IAAA,OAAA,CAAA,mBAAA,CAAA,GAAA,mBAAuC;AACvC,IAAA,OAAA,CAAA,gBAAA,CAAA,GAAA,gBAAiC;AACjC,IAAA,OAAA,CAAA,MAAA,CAAA,GAAA,MAAa;AACf,CAAC,EAJI,OAAO,KAAP,OAAO,GAAA,EAAA,CAAA,CAAA;AAMZ;;;;;;;;;AASG;AACH,SAAS,6BAA6B,CAAE,QAAgB,EAAA;IACtD,OAAO;QACL,IAAI,EAAE,OAAO,CAAC,iBAAiB;QAC/B;KACD;AACH;AAEA;;;;;;;;;AASG;AACH,SAAS,0BAA0B,CAAE,KAAa,EAAA;IAChD,OAAO;QACL,IAAI,EAAE,OAAO,CAAC,cAAc;QAC5B;KACD;AACH;AAEA;;;;;;;;;AASG;AACH,SAAS,iBAAiB,CAAE,KAAa,EAAA;IACvC,OAAO;QACL,IAAI,EAAE,OAAO,CAAC,IAAI;QAClB;KACD;AACH;;ACvJA;;;;;;AAMG;AACH,IAAK,QAeJ;AAfD,CAAA,UAAK,QAAQ,EAAA;AACX;;;;;AAKG;AACH,IAAA,QAAA,CAAA,OAAA,CAAA,GAAA,OAAe;AACf;;;;;AAKG;AACH,IAAA,QAAA,CAAA,KAAA,CAAA,GAAA,KAAW;AACb,CAAC,EAfI,QAAQ,KAAR,QAAQ,GAAA,EAAA,CAAA,CAAA;AAyCb;;;;;;AAMG;AACH,MAAM,cAAc,GAAmC;AACrD;;;;AAIG;AACH,IAAA,UAAU,EAAE;AACV,QAAA,MAAM,EAAE,GAAG;QACX,IAAI,EAAE,QAAQ,CAAC;AAChB,KAAA;AACD;;;;AAIG;AACH,IAAA,WAAW,EAAE;AACX,QAAA,MAAM,EAAE,GAA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