import { QuerySource } from "./query-source.js"; import { ContractTypeOrderBy, ContractTypeResult, ContractTypeSelect, ContractTypeUnique, ContractTypeWhere, ContractTypeGroupByArgs, ContractTypeGroupRow, ContractCountArgs, ContractFindManyArgs, ContractFindUniqueArgs, ContractGroupByArgs, ContractGroupRow, ContractResult, EventOrderBy, EventResult, EventGroupByArgs, EventGroupRow, EventSelect, EventUnique, EventWhere, ExerciseOrderBy, ExerciseResult, ExerciseSelect, ExerciseTypeOrderBy, ExerciseTypeResult, ExerciseTypeSelect, ExerciseTypeUnique, ExerciseTypeWhere, ExerciseTypeGroupByArgs, ExerciseTypeGroupRow, ExerciseWhere, ExerciseGroupByArgs, ExerciseGroupRow, PackageOrderBy, PackageResult, PackageSelect, PackageUnique, PackageWhere, PackageGroupByArgs, PackageGroupRow, TransactionOrderBy, TransactionResult, TransactionSelect, TransactionUnique, TransactionWhere, TransactionGroupByArgs, TransactionGroupRow, WatermarkOrderBy, WatermarkRow, WatermarkSelect, WatermarkUnique, WatermarkWhere, WatermarkGroupByArgs, WatermarkGroupRow, ContractTypeInclude, EventInclude, ExerciseInclude, ExerciseTypeInclude, PackageInclude, TransactionInclude, JsonProjectionResult } from "./model-types.js"; /** `take: 0` returns all matching rows (no limit), matching `skip: 0`'s "no offset" meaning. */ export interface FindManyArgs { readonly where?: TWhere; readonly select?: TSelect; readonly orderBy?: TOrderBy; readonly skip?: number; readonly take?: number; readonly include?: TInclude; } export interface ContractCacheArgs { readonly parties?: readonly string[]; } export type ContractCacheResult = { readonly source: QuerySource.grpc; readonly cached: true; readonly activeAtOffset: string; readonly contractCount: number; readonly expiresAt: Date; /** * How this prewarm was satisfied: "full" downloaded the ACS, "delta" patched the previous snapshot * forward from the update stream, "noop" found the ledger unchanged and only re-stamped the TTL. */ readonly refresh: "full" | "delta" | "noop"; /** Ledger-end minus the previous snapshot's offset at refresh time; undefined on a cold prewarm. */ readonly offsetGap?: string; /** Update count applied by a "delta" refresh. */ readonly deltaUpdateCount?: number; } | { readonly source: QuerySource.pqs; readonly cached: false; }; /** Measurement of a cached ACS snapshot against the current ledger end, for deciding when to re-warm. */ export interface ContractCacheInspection { readonly activeAtOffset: string; readonly ledgerEndOffset: string; /** ledgerEndOffset - activeAtOffset: how far the ledger has run past the snapshot. */ readonly offsetGap: string; readonly contractCount: number; readonly expiresAt: Date; } export interface QueryDelegate { findMany>(args?: TArgs): Promise)[]>; findUnique(args: TArgs): Promise<(TRow & JsonProjectionResult) | undefined>; count(args?: { readonly where?: TWhere; }): Promise; aggregate(args: { readonly where?: TWhere; readonly count?: true; readonly min?: readonly (keyof TRow)[]; readonly max?: readonly (keyof TRow)[]; readonly sum?: readonly (keyof TRow)[]; }): Promise<{ readonly count?: number; readonly min?: Readonly>; readonly max?: Readonly>; readonly sum?: Readonly>; }>; groupBy(args: TGroupBy): Promise; } export type QueryCollectionDelegate = Omit, "findUnique">; export interface QueryClient { readonly source: QuerySource; $queryRaw(sql: string, values?: readonly unknown[]): Promise; cacheContracts(args?: ContractCacheArgs): Promise; invalidateContractsCache(args?: ContractCacheArgs): Promise; /** Measures a warmed snapshot against the current ledger end (undefined when cold or not cache-backed). */ inspectContractsCache(args?: ContractCacheArgs): Promise; readonly contracts: { findMany(args?: TArgs): Promise)[]>; findUnique(args: TArgs): Promise<(ContractResult & JsonProjectionResult) | undefined>; count(args?: ContractCountArgs): Promise; aggregate(args: { readonly where?: ContractCountArgs["where"]; readonly count?: true; readonly min?: readonly ContractNumericField[]; readonly max?: readonly ContractNumericField[]; readonly sum?: readonly ContractNumericField[]; }): Promise<{ readonly count?: number; readonly min?: Readonly>>; readonly max?: Readonly>>; readonly sum?: Readonly>>; }>; groupBy(args: ContractGroupByArgs): Promise; }; readonly contractTypes: QueryDelegate; readonly events: QueryDelegate; readonly exercises: QueryCollectionDelegate; readonly exerciseTypes: QueryDelegate; readonly packages: QueryDelegate; readonly transactions: QueryDelegate; readonly watermark: QueryDelegate; } export type ContractNumericField = "createdEventOffset" | "archivedEventOffset";