import type { SchemaParser } from './lib/schema-parer/schema-parser.js'; import type { Expand, Options } from './options.js'; import type { SchemaDeclaration } from './schema.js'; import type { FieldsArrayToUnion } from './lib/type-utils.js'; export type PBResponseType, TMaxDepth extends number, _Obj = TSchema[TTableName]['type']> = (FieldsArrayToUnion extends infer Fields extends keyof _Obj ? Pick<_Obj, Fields> : _Obj) & ProcessExpandArray; type ProcessExpandArray[TTableName] = SchemaParser[TTableName]> = TExpandArr extends Array> ? { expand: { [E in TExpandArr[number] as _Relations[E['key']]['isOptional'] extends true ? E['key'] : never]+?: ProcessSingleExpand; } & { [E in TExpandArr[number] as _Relations[E['key']]['isOptional'] extends false ? E['key'] : never]: ProcessSingleExpand; }; } : unknown; type HandleArray = IsArray extends true ? [T, ...T[]] : T; type ProcessSingleExpand, _Rel extends SchemaParser[TTableName][TExpand['key']] = SchemaParser[TTableName][TExpand['key']], _Obj = _Rel['type']> = HandleArray<(FieldsArrayToUnion extends infer Fields extends keyof _Obj ? Pick<_Obj, Fields> : _Obj) & ProcessExpandArray, _Rel['isToMany']>; export {};