import type { ValueType } from '../../zero-protocol/src/client-schema.ts'; import type { PrimaryKey } from '../../zero-protocol/src/primary-key.ts'; export type { ValueType } from '../../zero-protocol/src/client-schema.ts'; /** * `related` calls need to know what the available relationships are. * The `schema` type encodes this information. */ export type SchemaValue = { type: ValueType; serverName?: string | undefined; optional?: boolean | undefined; } | SchemaValueWithCustomType; export type SchemaValueWithCustomType = { type: ValueType; serverName?: string | undefined; optional?: boolean; customType: T; }; export type TableSchema = { readonly name: string; readonly serverName?: string | undefined; readonly columns: Record; readonly primaryKey: PrimaryKey; }; export type RelationshipsSchema = { readonly [name: string]: Relationship; }; export type TypeNameToTypeMap = { string: string; number: number; boolean: boolean; null: null; json: any; }; export type ColumnTypeName = T extends SchemaValue ? T['type'] : T; /** * Given a schema value, return the TypeScript type. * * This allows us to create the correct return type for a * query that has a selection. */ export type SchemaValueToTSType = T extends ValueType ? TypeNameToTypeMap[T] : T extends { optional: true; } ? (T extends SchemaValueWithCustomType ? V : TypeNameToTypeMap[ColumnTypeName]) | null : T extends SchemaValueWithCustomType ? V : TypeNameToTypeMap[ColumnTypeName]; type Connection = { readonly sourceField: readonly string[]; readonly destField: readonly string[]; readonly destSchema: string; readonly cardinality: Cardinality; }; export type Cardinality = 'one' | 'many'; export type Relationship = readonly [Connection] | readonly [Connection, Connection]; export type LastInTuple = T extends readonly [infer L] ? L : T extends readonly [unknown, infer L] ? L : T extends readonly [unknown, unknown, infer L] ? L : never; export type AtLeastOne = readonly [T, ...T[]]; export declare function atLeastOne(arr: readonly T[]): AtLeastOne; export declare function isOneHop(r: Relationship): r is readonly [Connection]; export declare function isTwoHop(r: Relationship): r is readonly [Connection, Connection]; export type Opaque = BaseType & { readonly [base]: BaseType; readonly [brand]: BrandType; }; declare const base: unique symbol; declare const brand: unique symbol; export type IsOpaque = T extends { readonly [brand]: any; } ? true : false; export type ExpandRecursiveSkipOpaque = IsOpaque extends true ? T : T extends object ? T extends infer O ? { [K in keyof O]: ExpandRecursiveSkipOpaque; } : never : T; //# sourceMappingURL=table-schema.d.ts.map