UNPKG

alinea

Version:

[![npm](https://img.shields.io/npm/v/alinea.svg)](https://npmjs.org/package/alinea) [![install size](https://packagephobia.com/badge?p=alinea)](https://packagephobia.com/result?p=alinea)

110 lines (109 loc) 3.7 kB
import { Type } from '../Type.js'; import { EV, Expr } from './Expr.js'; import { ExprData } from './ExprData.js'; import { Projection } from './Projection.js'; import { Selection } from './Selection.js'; export declare enum OrderDirection { Asc = "Asc", Desc = "Desc" } export type OrderBy = typeof OrderBy.infer; export declare const OrderBy: import("cito").Type<{ expr: ExprData; order: OrderDirection; }>; export type CursorData = typeof CursorData.infer; export declare const CursorData: import("cito").Type<{ target?: { name?: string | undefined; type?: import("../Type.js").TypeTarget | undefined; } | undefined; where?: ExprData | undefined; searchTerms?: string[] | undefined; skip?: number | undefined; take?: number | undefined; orderBy?: { expr: ExprData; order: OrderDirection; }[] | undefined; groupBy?: ExprData[] | undefined; select?: Selection<T> | undefined; first?: boolean | undefined; source?: { type: SourceType; depth?: number | undefined; } | undefined; }>; export declare enum SourceType { Children = "Children", Siblings = "Siblings", Translations = "Translations", Parents = "Parents", Parent = "Parent", Next = "Next", Previous = "Previous" } export type CursorSource = typeof CursorSource.infer; export declare const CursorSource: import("cito").Type<{ type: SourceType; depth?: number | undefined; }>; export interface Cursor<T> { [Cursor.Data]: CursorData; } declare const brand: unique symbol; export declare class Cursor<T> { [brand]: T; constructor(data: CursorData); protected with(data: Partial<CursorData>): CursorData; static isCursor<T>(input: any): input is Cursor<T>; toJSON(): { target?: { name?: string | undefined; type?: import("../Type.js").TypeTarget | undefined; } | undefined; where?: ExprData | undefined; searchTerms?: string[] | undefined; skip?: number | undefined; take?: number | undefined; orderBy?: { expr: ExprData; order: OrderDirection; }[] | undefined; groupBy?: ExprData[] | undefined; select?: Selection<T_1> | undefined; first?: boolean | undefined; source?: { type: SourceType; depth?: number | undefined; } | undefined; }; } export declare namespace Cursor { const Data: unique symbol; class Find<Row> extends Cursor<Array<Row>> { where(...where: Array<EV<boolean>>): Find<Row>; search(...searchTerms: Array<string>): Find<Row>; get<S extends Projection>(select: S): Get<Selection.Infer<S>>; count(): Cursor<number>; first(): Get<Row>; maybeFirst(): Get<Row | undefined>; select<S extends Projection>(select: S): Find<Selection.Infer<S>>; groupBy(...groupBy: Array<Expr<any>>): Find<Row>; orderBy(...orderBy: Array<OrderBy>): Find<Row>; skip(skip: number): Find<Row>; take(take: number): Find<Row>; } class Partial<Definition> extends Find<Type.Infer<Definition>> { type: Type<Definition>; partial: Partial<Type.Infer<Definition>>; constructor(type: Type<Definition>, partial: Partial<Type.Infer<Definition>>); static condition(type: Type, input: Record<string, any>): ExprData | undefined; } class Get<Row> extends Cursor<Row> { where(...where: Array<EV<boolean>>): Get<Row>; search(...searchTerms: Array<string>): Get<Row>; select<S extends Projection>(select: S): Get<Selection.Infer<S>>; } } export {};