import "../validators-BcQFm1oY.js"; import { Jn as ConvexTextBuilderInitial, Ot as ConvexCustomBuilderInitial, in as ConvexTableWithColumns, vt as ConvexNumberBuilderInitial, xt as ConvexIdBuilderInitial } from "../where-clause-compiler-CUzMH_BM.js"; import "../query-context-ji7By8u0.js"; import "../orm/index.js"; import * as convex_values0 from "convex/values"; import { GenericId, Infer, Value } from "convex/values"; import { DocumentByName, GenericDataModel, GenericDatabaseReader, GenericDatabaseWriter, TableNamesInDataModel } from "convex/server"; //#region src/aggregate-core/schema.d.ts declare const aggregateStorageTables: { readonly aggregate_rank_node: ConvexTableWithColumns<{ name: "aggregate_rank_node"; columns: { aggregate: ConvexCustomBuilderInitial<"", convex_values0.VObject<{ count: number; sum: number; }, { count: convex_values0.VFloat64; sum: convex_values0.VFloat64; }, "required", "count" | "sum">> & { _: { tableName: "aggregate_rank_node"; }; } & { _: { fieldName: "aggregate"; }; }; items: ConvexCustomBuilderInitial<"", convex_values0.VArray<{ k: any; v: any; s: number; }[], convex_values0.VObject<{ k: any; v: any; s: number; }, { k: convex_values0.VAny; v: convex_values0.VAny; s: convex_values0.VFloat64; }, "required", "k" | "v" | "s" | `k.${string}` | `v.${string}`>, "required">> & { _: { notNull: true; }; } & { _: { tableName: "aggregate_rank_node"; }; } & { _: { fieldName: "items"; }; }; subtrees: ConvexCustomBuilderInitial<"", convex_values0.VArray, "required">> & { _: { notNull: true; }; } & { _: { tableName: "aggregate_rank_node"; }; } & { _: { fieldName: "subtrees"; }; }; }; }, { by_creation_time: ["_creationTime"]; }, {}, {}, {}>; readonly aggregate_rank_tree: ConvexTableWithColumns<{ name: "aggregate_rank_tree"; columns: { aggregateName: ConvexTextBuilderInitial<""> & { _: { notNull: true; }; } & { _: { tableName: "aggregate_rank_tree"; }; } & { _: { fieldName: "aggregateName"; }; }; maxNodeSize: ConvexNumberBuilderInitial<""> & { _: { notNull: true; }; } & { _: { tableName: "aggregate_rank_tree"; }; } & { _: { fieldName: "maxNodeSize"; }; }; namespace: ConvexCustomBuilderInitial<"", convex_values0.VAny> & { _: { tableName: "aggregate_rank_tree"; }; } & { _: { fieldName: "namespace"; }; }; root: ConvexIdBuilderInitial<"", "aggregate_rank_node"> & { _: { notNull: true; }; } & { _: { tableName: "aggregate_rank_tree"; }; } & { _: { fieldName: "root"; }; }; }; }, { by_creation_time: ["_creationTime"]; by_namespace: ["namespace", "_creationTime"]; by_aggregate_name: ["aggregateName", "_creationTime"]; }, {}, {}, {}>; }; //#endregion //#region src/aggregate-core/btree.d.ts type Key$2 = Value; //#endregion //#region src/aggregate-core/positions.d.ts type Bound$1 = { key: K; id?: ID; inclusive: boolean; }; type SideBounds = { lower?: Bound$1; upper?: Bound$1; }; type TuplePrefix = P['length'] extends K['length'] ? P : P | TuplePrefix; type Bounds$1 = SideBounds | (K extends unknown[] ? { prefix: TuplePrefix>; } : never) | { eq: K; }; //#endregion //#region src/aggregate-core/runtime.d.ts type Key = Key$2; type Bound = Bound$1; type Bounds = Bounds$1; type AggregateQueryCtx = { db: GenericDatabaseReader; orm: unknown; }; type AggregateMutationCtx = { db: GenericDatabaseWriter; orm: unknown; }; type RunQueryCtx = AggregateQueryCtx; type RunMutationCtx = AggregateMutationCtx; type Item = { id: ID; key: K; sumValue: number; }; /** * Write data to be aggregated, and read aggregated data. */ declare class Aggregate { protected readonly aggregateName: string; constructor(aggregateName: string); count(ctx: RunQueryCtx, ...opts: NamespacedOpts<{ bounds?: Bounds; }, TNamespace>): Promise; countBatch(ctx: RunQueryCtx, queries: NamespacedOptsBatch<{ bounds?: Bounds; }, TNamespace>): Promise; sum(ctx: RunQueryCtx, ...opts: NamespacedOpts<{ bounds?: Bounds; }, TNamespace>): Promise; sumBatch(ctx: RunQueryCtx, queries: NamespacedOptsBatch<{ bounds?: Bounds; }, TNamespace>): Promise; at(ctx: RunQueryCtx, offset: number, ...opts: NamespacedOpts<{ bounds?: Bounds; }, TNamespace>): Promise>; atBatch(ctx: RunQueryCtx, queries: NamespacedOptsBatch<{ offset: number; bounds?: Bounds; }, TNamespace>): Promise[]>; indexOf(ctx: RunQueryCtx, key: K, ...opts: NamespacedOpts<{ bounds?: Bounds; id?: ID; order?: 'asc' | 'desc'; }, TNamespace>): Promise; offsetOf(ctx: RunQueryCtx, key: K, namespace: TNamespace, id?: ID, bounds?: Bounds): Promise; offsetUntil(ctx: RunQueryCtx, key: K, namespace: TNamespace, id?: ID, bounds?: Bounds): Promise; min(ctx: RunQueryCtx, ...opts: NamespacedOpts<{ bounds?: Bounds; }, TNamespace>): Promise | null>; max(ctx: RunQueryCtx, ...opts: NamespacedOpts<{ bounds?: Bounds; }, TNamespace>): Promise | null>; random(ctx: RunQueryCtx, ...opts: NamespacedOpts<{ bounds?: Bounds; }, TNamespace>): Promise | null>; paginate(ctx: RunQueryCtx, ...opts: NamespacedOpts<{ bounds?: Bounds; cursor?: string; order?: 'asc' | 'desc'; pageSize?: number; }, TNamespace>): Promise<{ cursor: string; isDone: boolean; page: Item[]; }>; iter(ctx: RunQueryCtx, ...opts: NamespacedOpts<{ bounds?: Bounds; order?: 'asc' | 'desc'; pageSize?: number; }, TNamespace>): AsyncGenerator, void, undefined>; _insert(ctx: RunMutationCtx, namespace: TNamespace, key: K, id: ID, summand?: number): Promise; _delete(ctx: RunMutationCtx, namespace: TNamespace, key: K, id: ID): Promise; _replace(ctx: RunMutationCtx, currentNamespace: TNamespace, currentKey: K, newNamespace: TNamespace, newKey: K, id: ID, summand?: number): Promise; _insertIfDoesNotExist(ctx: RunMutationCtx, namespace: TNamespace, key: K, id: ID, summand?: number): Promise; _deleteIfExists(ctx: RunMutationCtx, namespace: TNamespace, key: K, id: ID): Promise; _replaceOrInsert(ctx: RunMutationCtx, currentNamespace: TNamespace, currentKey: K, newNamespace: TNamespace, newKey: K, id: ID, summand?: number): Promise; clear(ctx: RunMutationCtx, ...opts: NamespacedOpts<{ maxNodeSize?: number; rootLazy?: boolean; }, TNamespace>): Promise; makeRootLazy(ctx: RunMutationCtx, namespace: TNamespace): Promise; paginateNamespaces(ctx: RunQueryCtx, cursor?: string, pageSize?: number): Promise<{ cursor: string; isDone: boolean; page: TNamespace[]; }>; iterNamespaces(ctx: RunQueryCtx, pageSize?: number): AsyncGenerator; clearAll(ctx: RunMutationCtx & RunQueryCtx, opts?: { maxNodeSize?: number; rootLazy?: boolean; }): Promise; makeAllRootsLazy(ctx: RunMutationCtx & RunQueryCtx): Promise; } type DirectAggregateType = { Key: K; Id: ID; Namespace?: TNamespace; }; type AnyDirectAggregateType$1 = DirectAggregateType; type DirectAggregateNamespace = 'Namespace' extends keyof T ? T['Namespace'] : undefined; declare class DirectAggregate$1 extends Aggregate> { constructor(config: { name: string; }); insert(ctx: RunMutationCtx, args: NamespacedArgs<{ id: T['Id']; key: T['Key']; sumValue?: number; }, DirectAggregateNamespace>): Promise; delete(ctx: RunMutationCtx, args: NamespacedArgs<{ id: T['Id']; key: T['Key']; }, DirectAggregateNamespace>): Promise; replace(ctx: RunMutationCtx, currentItem: NamespacedArgs<{ id: T['Id']; key: T['Key']; }, DirectAggregateNamespace>, newItem: NamespacedArgs<{ key: T['Key']; sumValue?: number; }, DirectAggregateNamespace>): Promise; insertIfDoesNotExist(ctx: RunMutationCtx, args: NamespacedArgs<{ id: T['Id']; key: T['Key']; sumValue?: number; }, DirectAggregateNamespace>): Promise; deleteIfExists(ctx: RunMutationCtx, args: NamespacedArgs<{ id: T['Id']; key: T['Key']; }, DirectAggregateNamespace>): Promise; replaceOrInsert(ctx: RunMutationCtx, currentItem: NamespacedArgs<{ id: T['Id']; key: T['Key']; }, DirectAggregateNamespace>, newItem: NamespacedArgs<{ key: T['Key']; sumValue?: number; }, DirectAggregateNamespace>): Promise; } type TableAggregateType, TNamespace extends Value | undefined = undefined> = { DataModel: DataModel; Key: K; Namespace?: TNamespace; TableName: TableName; }; type AnyTableAggregateType$1 = TableAggregateType, Value | undefined>; type TableAggregateNamespace = 'Namespace' extends keyof T ? T['Namespace'] : undefined; type TableAggregateDocument = DocumentByName; type TableAggregateId = GenericId; type TableAggregateTrigger = Trigger; declare class TableAggregate$1 extends Aggregate, TableAggregateNamespace> { constructor(options: { name: string; table: T['TableName']; sortKey: (d: TableAggregateDocument) => T['Key']; sumValue?: (d: TableAggregateDocument) => number; } & (undefined extends TableAggregateNamespace ? { namespace?: (d: TableAggregateDocument) => TableAggregateNamespace; } : { namespace: (d: TableAggregateDocument) => TableAggregateNamespace; })); private readonly options; insert(ctx: RunMutationCtx, doc: TableAggregateDocument): Promise; delete(ctx: RunMutationCtx, doc: TableAggregateDocument): Promise; replace(ctx: RunMutationCtx, oldDoc: TableAggregateDocument, newDoc: TableAggregateDocument): Promise; insertIfDoesNotExist(ctx: RunMutationCtx, doc: TableAggregateDocument): Promise; deleteIfExists(ctx: RunMutationCtx, doc: TableAggregateDocument): Promise; replaceOrInsert(ctx: RunMutationCtx, oldDoc: TableAggregateDocument, newDoc: TableAggregateDocument): Promise; indexOfDoc(ctx: RunQueryCtx, doc: TableAggregateDocument, opts?: { id?: TableAggregateId; bounds?: Bounds>; order?: 'asc' | 'desc'; }): Promise; trigger(): TableAggregateTrigger; idempotentTrigger(): TableAggregateTrigger; } type Trigger> = (ctx: Ctx, change: Change) => Promise; type Change> = { id: GenericId | string; } & ({ operation: 'insert'; oldDoc: null; newDoc: DocumentByName; } | { operation: 'update'; oldDoc: DocumentByName; newDoc: DocumentByName; } | { operation: 'delete'; oldDoc: DocumentByName; newDoc: null; }); type NamespacedArgs = (Args & { namespace: TNamespace; }) | (TNamespace extends undefined ? Args : never); type NamespacedOpts = [{ namespace: TNamespace; } & Opts] | (undefined extends TNamespace ? [Opts?] : never); type NamespacedOptsBatch = Array; //#endregion //#region src/orm/aggregate.d.ts type AggregateTriggerFactoryLike = { trigger: () => (ctx: unknown, change: unknown) => Promise; }; type AggregateTriggerCtx = Parameters>[0]; type AggregateTriggerChange = Parameters>[1]; type AggregateTriggerOverload = { (): ReturnType; (change: TChange, ctx: TCtx): Promise; }; type OrmCompatibleAggregate = Omit & { trigger: AggregateTriggerOverload; }; //#endregion //#region src/aggregate/index.d.ts type Key$1 = Key; type AnyDirectAggregateType = DirectAggregateType; type AnyTableAggregateType = TableAggregateType; type CoreTrigger = ReturnType['trigger']>; type CoreIdempotentTrigger = ReturnType['idempotentTrigger']>; declare class TableAggregate extends TableAggregate$1 { trigger: { (): CoreTrigger; (change: TChange, ctx: TCtx): Promise; }; idempotentTrigger: { (): CoreIdempotentTrigger; (change: TChange, ctx: TCtx): Promise; }; constructor(...args: ConstructorParameters); } declare class DirectAggregate extends DirectAggregate$1 {} declare function createDirectAggregate(config: { name: string; }): DirectAggregate; //#endregion export { type AggregateTriggerChange, type AggregateTriggerCtx, type AggregateTriggerFactoryLike, type Bound, type Bounds, DirectAggregate, type DirectAggregateType, type Item, type Key, type OrmCompatibleAggregate, type RunMutationCtx, type RunQueryCtx, TableAggregate, type TableAggregateType, aggregateStorageTables, createDirectAggregate };