UNPKG

@backland/schema

Version:

TypeScript schema declaration and validation library with static type inference

31 lines (30 loc) 1.14 kB
import { Aggregation, ObjectDotNotations } from '@backland/utils'; import { Infer } from '../Infer'; import { FieldComposer, FieldType, FieldTypeParser, TAnyFieldType } from './FieldType'; import { FieldInput } from './_parseFields'; export type AliasFieldAggregation<Parent = any> = { type: FieldInput; } & ({ from: ObjectDotNotations<Parent>; aggregate: Aggregation<Parent> | Readonly<Aggregation<Parent>>; } | { aggregate: Aggregation<Parent> | Readonly<Aggregation<Parent>>; from?: undefined; } | { from: ObjectDotNotations<Parent>; aggregate?: undefined; }); export type AliasFieldDef = string | AliasFieldAggregation; export declare class AliasField<InputDef extends AliasFieldDef = any> extends FieldType<InputDef extends { type: infer T; } ? Infer<T> : any, 'alias', AliasFieldDef> { parse: FieldTypeParser<any>; utils: { fieldType: TAnyFieldType; }; composer: FieldComposer; static is(input: any): input is AliasField; static assert(input: any): asserts input is AliasField; constructor(def: AliasFieldDef); static create: (def: AliasFieldDef) => AliasField; }