VerdictClient
Connect client for one Verdict instance with an in-memory observed revision. Reads and writes may run concurrently; a session does not serialize calls. RPC failures reject with ConnectError; invalid local inputs can throw TypeError or RangeError. Integer decoding can throw IntegerRepresentationError.
class VerdictClient<M extends IntegerMode = "number">constructor
Section titled “constructor”constructor(options: VerdictClientOptions<M>)Creates a client without making a request.
throws: TypeError For invalid sessionId or integerMode.
throws: RangeError For mutation timeouts outside integer milliseconds 1-55,000.
options: Instance connection, consistency, integer, and retry settings.
sessionId
Section titled “sessionId”Stable routing identifier. Does not carry the session’s observed revision.
readonly sessionId: stringrevision
Section titled “revision”get revision(): string | undefinedHighest observed revision. Undefined when no token has been returned or the observed history is incompatible or malformed.
session
Section titled “session”session(options: SessionOptions = {}): VerdictClient<M>Creates an independent revision scope, inheriting connection and integer settings.
returns: A new client with no observed revision. Calls remain concurrent.
options: Routing identifier and consistency; omitted values use a fresh UUID and session consistency.
batchFacts
Section titled “batchFacts”batchFacts(input: FactBatchInput): Promise<{ deleted: number; inserted: number }>Submits inserts and delete patterns in one stored-fact batch.
returns: Counts reported by the instance for inserted and deleted facts.
throws: TypeError or RangeError For invalid fact or pattern values.
input: Facts to insert and patterns to delete.
insertFact
Section titled “insertFact”insertFact(fact: FactInput): Promise<void>Inserts a stored fact.
returns: Resolves after the instance accepts the mutation.
throws: TypeError or RangeError For invalid fact values.
fact: Predicate and one to three ground terms.
deleteFact
Section titled “deleteFact”deleteFact(pattern: PatternInput): Promise<void>Deletes stored facts matching a pattern.
returns: Resolves after the instance accepts the mutation.
throws: TypeError or RangeError For invalid pattern values.
pattern: Predicate and one to three exact or wildcard terms.
listFacts
Section titled “listFacts”listFacts(filter?: ListFilterInput, options?: Readonly<{ consistency?: Consistency }> & { cursor?: string; limit?: number }): Promise<{ facts: { predicate: string; terms: ResultTerm<M>[] }[]; nextCursor: string | undefined }>Lists stored facts, rather than derived query answers.
returns: Decoded facts and nextCursor, which is undefined when the instance returns no cursor.
throws: IntegerRepresentationError If number mode cannot represent a returned integer.
filter: Optional predicate/terms filter or policy expression. Omit to list all facts.
options: Consistency override, page limit, and opaque continuation cursor. Omitted limit and cursor are sent as zero and an empty string for server defaults.
consistency: Overrides this client’s consistency default for this read. Successful reads still update its revision.
authorize
Section titled “authorize”authorize(actor: Identity, action: string, resource: Identity, options?: Readonly<{ consistency?: Consistency }>): Promise<boolean>Evaluates whether an actor can perform an action on a resource.
returns: The instance authorization decision.
actor: Application identity requesting access.
action: Action name evaluated by the policy.
resource: Application identity receiving the action.
options: Per-call consistency override.
consistency: Overrides this client’s consistency default for this read. Successful reads still update its revision.
query(pattern: PatternInput, options?: Readonly<{ consistency?: Consistency }>): Promise<ResultTerm<M>[][]>Evaluates a policy pattern, including derived answers.
returns: Decoded rows supplied by the instance, preserving their column order.
throws: TypeError or RangeError For invalid pattern values.
throws: IntegerRepresentationError If number mode cannot represent a returned integer.
pattern: Predicate and exact or wildcard terms.
options: Per-call consistency override.
consistency: Overrides this client’s consistency default for this read. Successful reads still update its revision.
setPolicy
Section titled “setPolicy”setPolicy(source: string): Promise<void>Replaces the instance policy using Verdict source text.
returns: Resolves after the instance accepts the replacement.
source: Complete policy source.
getPolicy
Section titled “getPolicy”getPolicy(options?: Readonly<{ consistency?: Consistency }>): Promise<unknown[]>Reads the persisted compiled policy rules.
returns: Rule values with integer constants decoded using this client integer mode; empty when rules are absent.
throws: IntegerRepresentationError If number mode cannot represent a policy integer.
options: Per-call consistency override.
consistency: Overrides this client’s consistency default for this read. Successful reads still update its revision.
getPolicyDocument
Section titled “getPolicyDocument”getPolicyDocument(options?: Readonly<{ consistency?: Consistency }>): Promise<{ rules: unknown[]; source?: string }>Reads the original source together with the persisted compiled policy rules.
returns: Source and decoded rules. Source is absent when the server has not retained it.
throws: IntegerRepresentationError If number mode cannot represent a policy integer.
options: Per-call consistency override.
consistency: Overrides this client’s consistency default for this read. Successful reads still update its revision.
Related API types
Section titled “Related API types”identity · IntegerRepresentationError · VerdictClientOptions · FactBatchInput · Consistency · ReadOptions · SessionOptions · Revision · Identity · GroundTerm · PatternValue · Wildcard · FilterValue · FactInput · PatternInput · ListFilterInput · IntegerMode · IntegerResult · ResultTerm