import PostgrestError from './PostgrestError'; import { ContainsNull } from './select-query-parser/types'; import { SelectQueryError } from './select-query-parser/utils'; export type Fetch = typeof fetch; /** * Response format * * {@link https://github.com/skorpland/powerbase-js/issues/32} */ interface PostgrestResponseBase { status: number; statusText: string; } export interface PostgrestResponseSuccess extends PostgrestResponseBase { error: null; data: T; count: number | null; } export interface PostgrestResponseFailure extends PostgrestResponseBase { error: PostgrestError; data: null; count: null; } export type PostgrestSingleResponse = PostgrestResponseSuccess | PostgrestResponseFailure; export type PostgrestMaybeSingleResponse = PostgrestSingleResponse; export type PostgrestResponse = PostgrestSingleResponse; export type GenericRelationship = { foreignKeyName: string; columns: string[]; isOneToOne?: boolean; referencedRelation: string; referencedColumns: string[]; }; export type GenericTable = { Row: Record; Insert: Record; Update: Record; Relationships: GenericRelationship[]; }; export type GenericUpdatableView = { Row: Record; Insert: Record; Update: Record; Relationships: GenericRelationship[]; }; export type GenericNonUpdatableView = { Row: Record; Relationships: GenericRelationship[]; }; export type GenericView = GenericUpdatableView | GenericNonUpdatableView; export type GenericFunction = { Args: Record; Returns: unknown; }; export type GenericSchema = { Tables: Record; Views: Record; Functions: Record; }; export type Prettify = { [K in keyof T]: T[K]; } & {}; export type SimplifyDeep = ConditionalSimplifyDeep | Map, object>; type ConditionalSimplifyDeep = Type extends ExcludeType ? Type : Type extends IncludeType ? { [TypeKey in keyof Type]: ConditionalSimplifyDeep; } : Type; type NonRecursiveType = BuiltIns | Function | (new (...arguments_: any[]) => unknown); type BuiltIns = Primitive | void | Date | RegExp; type Primitive = null | undefined | string | number | boolean | symbol | bigint; export type IsValidResultOverride = Result extends any[] ? NewResult extends any[] ? true : ErrorResult : NewResult extends any[] ? ErrorNewResult : true; /** * Utility type to check if array types match between Result and NewResult. * Returns either the valid NewResult type or an error message type. */ export type CheckMatchingArrayTypes = Result extends SelectQueryError ? NewResult : IsValidResultOverride> or .returns> (deprecated) for array results or .single() to convert the result to a single object'; }, { Error: 'Type mismatch: Cannot cast single object to array type. Remove Array wrapper from return type or make sure you are not using .single() up in the calling chain'; }> extends infer ValidationResult ? ValidationResult extends true ? ContainsNull extends true ? NewResult | null : NewResult : ValidationResult : never; type Simplify = T extends object ? { [K in keyof T]: T[K]; } : T; type ExplicitKeys = { [K in keyof T]: string extends K ? never : K; }[keyof T]; type MergeExplicit = { [K in ExplicitKeys | ExplicitKeys]: K extends keyof New ? K extends keyof Row ? Row[K] extends SelectQueryError ? New[K] : New[K] extends any[] ? Row[K] extends any[] ? Array, NonNullable>>> : New[K] : IsPlainObject> extends true ? IsPlainObject> extends true ? ContainsNull extends true ? // If the override wants to preserve optionality Simplify, NonNullable>> | null : Simplify>> : New[K] : New[K] : New[K] : K extends keyof Row ? Row[K] : never; }; type MergeDeep = Simplify & (string extends keyof Row ? { [K: string]: Row[string]; } : {})>; type IsPlainObject = T extends any[] ? false : T extends object ? true : false; export type MergePartialResult = Options extends { merge: true; } ? Result extends any[] ? NewResult extends any[] ? Array>> : never : Simplify> : NewResult; export {}; //# sourceMappingURL=types.d.ts.map