Member Junction
    Preparing search index...

    Function ResolveSingleEntityResourceTarget

    • Resolves an API scope rule's ResourcePattern to the single entity name it targets, normalized for lookup (trimmed and lowercased), or null when it cannot be resolved to exactly one entity.

      null is the FAIL-CLOSED answer, and callers must treat it as "this rule may name any entity" rather than "this rule names nothing" — a pattern we cannot map may well name the very entity the caller is about to mirror into an unscoped snapshot. Refusing to materialize is recoverable and loud; mirroring restricted rows is neither.

      Normalization matches the way scope rules are authored and resolved: IsExactResourceName gates the pattern at save time and Metadata.EntityByName resolves it, both case-insensitively.

      Parameters

      • pattern: string | null | undefined

        the rule's raw ResourcePattern (null/undefined/blank all resolve to null).

      Returns string | null

      the trimmed, lowercased entity name, or null when the pattern is not a single exact name.

      ResolveSingleEntityResourceTarget('  Salaries ')   // 'salaries'
      ResolveSingleEntityResourceTarget('MJ: AI Agents') // 'mj: ai agents'
      ResolveSingleEntityResourceTarget('Sk?p') // null (would otherwise fence nothing)
      ResolveSingleEntityResourceTarget('A,B') // null