alinea
Version:
[](https://npmjs.org/package/alinea) [](https://packagephobia.com/result?p=alinea)
77 lines (76 loc) • 2.93 kB
TypeScript
import { Infer as CInfer, Type as CType } from 'cito';
import { Expand } from '../util/Types.js';
import { CursorData } from './Cursor.js';
import { ExprData } from './ExprData.js';
import { Projection } from './Projection.js';
import { TargetData } from './TargetData.js';
export type Selection<T = any> = Selection.Row | Selection.Record | Selection.Cursor | Selection.Expr | Selection.Count;
export declare namespace Selection {
namespace types {
class Row {
type: CType<"row">;
target: CType<{
name?: string | undefined;
type?: import("../Type.js").TypeTarget | undefined;
}>;
}
class Record {
type: CType<"record">;
fields: CType<([string, Selection<T>] | [{
name?: string | undefined;
type?: import("../Type.js").TypeTarget | undefined;
}])[]>;
}
class Cursor {
type: CType<"cursor">;
cursor: CType<{
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: import("./Cursor.js").OrderDirection;
}[] | undefined;
groupBy?: ExprData[] | undefined;
select?: Selection<T> | undefined;
first?: boolean | undefined;
source?: {
type: import("./Cursor.js").SourceType;
depth?: number | undefined;
} | undefined;
}>;
}
class Expr {
type: CType<"expr">;
expr: CType<ExprData>;
fromParent: CType<boolean>;
}
class Count {
type: CType<"count">;
}
}
export interface Row extends CInfer<types.Row> {
}
export function Row(target: TargetData): Selection.Row;
export interface Record extends CInfer<types.Record> {
}
export function Record(fields: Array<[string, Selection] | [TargetData]>): Selection.Record;
export interface Cursor extends CInfer<types.Cursor> {
}
export function Cursor(cursor: CursorData): Selection.Cursor;
export interface Expr extends CInfer<types.Expr> {
}
export function Expr(expr: ExprData, fromParent?: boolean): Selection.Expr;
export interface Count extends CInfer<types.Count> {
}
export function Count(): Selection.Count;
export const adt: CType<Selection>;
export type Infer<T> = Projection.Infer<T>;
export type Combine<A, B> = Expand<Omit<A, keyof Infer<B>> & Infer<B>>;
export {};
}