UNPKG

entangle.ts

Version:

A declarative, event-driven framework for orchestrating business logic in TypeScript & Node.js applications.

28 lines (27 loc) 1.23 kB
import { Notation } from '../../shared/Notation'; import { CausalityLog, Event } from '../../shared/types/Events.types'; export declare class QueryBuilder { private readonly causalityLogs; private fromClause?; private notationInstance?; constructor(causalityLogs: CausalityLog<unknown[]>[]); /** * Filters the search to only include logs from a specific event. * If not called, the query will search through all events. * @param event The name of the event to filter by. */ from(event: Event): this; /** * Specifies a dot-notation path to access nested data within an event's argument. * This is necessary when an argument is an object or array. * @param notation The dot-notation string (e.g., 'user.profile.name'). */ using(notation?: Notation<any, any>): this; /** * Executes the built query and returns the first result found. * The search is performed from the most recent event to the oldest. * @template TData The expected type of the returned data. * @returns The first piece of data that matches all query clauses, or `undefined` ONLY if no matching log is found. */ get<TData = unknown>(): TData | undefined; }