import { FunctionInvokeOptions, FunctionRegion, FunctionsClient, FunctionsError, FunctionsFetchError, FunctionsHttpError, FunctionsRelayError } from "@supabase/functions-js"; import { PostgrestClient, PostgrestError, PostgrestError as PostgrestError$1, PostgrestFilterBuilder, PostgrestMaybeSingleResponse, PostgrestQueryBuilder, PostgrestResponse, PostgrestSingleResponse } from "@supabase/postgrest-js"; import { RealtimeChannel, RealtimeChannelOptions, RealtimeClient, RealtimeClientOptions } from "@supabase/realtime-js"; import { StorageClient, StorageClientOptions } from "@supabase/storage-js"; import { AuthClient, GoTrueClientOptions, Session as AuthSession, User as AuthUser } from "@supabase/auth-js"; export * from "@supabase/realtime-js"; export * from "@supabase/auth-js"; //#region src/lib/rest/types/common/common.d.ts type GenericRelationship = { foreignKeyName: string; columns: string[]; isOneToOne?: boolean; referencedRelation: string; referencedColumns: string[]; }; type GenericTable = { Row: Record; Insert: Record; Update: Record; Relationships: GenericRelationship[]; }; type GenericUpdatableView = { Row: Record; Insert: Record; Update: Record; Relationships: GenericRelationship[]; }; type GenericNonUpdatableView = { Row: Record; Relationships: GenericRelationship[]; }; type GenericView = GenericUpdatableView | GenericNonUpdatableView; type GenericSetofOption = { isSetofReturn?: boolean | undefined; isOneToOne?: boolean | undefined; isNotNullable?: boolean | undefined; to: string; from: string; }; type GenericFunction = { Args: Record | never; Returns: unknown; SetofOptions?: GenericSetofOption; }; type GenericSchema = { Tables: Record; Views: Record; Functions: Record; }; //#endregion //#region src/lib/types.d.ts interface SupabaseAuthClientOptions extends GoTrueClientOptions {} type Fetch = typeof fetch; type SupabaseClientOptions = { /** * The Postgres schema which your tables belong to. Must be on the list of exposed schemas in Supabase. Defaults to `public`. */ db?: { schema?: SchemaName; /** * Optional timeout in milliseconds for PostgREST requests. * When set, requests will automatically abort after this duration to prevent indefinite hangs. * * @example * ```ts * const supabase = createClient(url, key, { * db: { timeout: 30000 } // 30 second timeout * }) * ``` */ timeout?: number; /** * Maximum URL length in characters before warnings/errors are triggered. * Defaults to 8000 characters. Used to provide helpful hints when URLs * exceed server limits. * * @example * ```ts * const supabase = createClient(url, key, { * db: { urlLengthLimit: 10000 } // Custom limit * }) * ``` */ urlLengthLimit?: number; }; auth?: { /** * Automatically refreshes the token for logged-in users. Defaults to true. */ autoRefreshToken?: boolean; /** * Optional key name used for storing tokens in local storage. */ storageKey?: string; /** * Whether to persist a logged-in session to storage. Defaults to true. */ persistSession?: boolean; /** * Detect a session from the URL. Used for OAuth login callbacks. Defaults to true. * * Can be set to a function to provide custom logic for determining if a URL contains * a Supabase auth callback. The function receives the current URL and parsed parameters, * and should return true if the URL should be processed as a Supabase auth callback. * * This is useful when your app uses other OAuth providers (e.g., Facebook Login) that * also return access_token in the URL fragment, which would otherwise be incorrectly * intercepted by Supabase Auth. * * @example * ```ts * detectSessionInUrl: (url, params) => { * // Ignore Facebook OAuth redirects * if (url.pathname === '/facebook/redirect') return false * // Use default detection for other URLs * return Boolean(params.access_token || params.error_description) * } * ``` */ detectSessionInUrl?: boolean | ((url: URL, params: { [parameter: string]: string; }) => boolean); /** * A storage provider. Used to store the logged-in session. */ storage?: SupabaseAuthClientOptions['storage']; /** * A storage provider to store the user profile separately from the session. * Useful when you need to store the session information in cookies, * without bloating the data with the redundant user object. * * @experimental */ userStorage?: SupabaseAuthClientOptions['userStorage']; /** * OAuth flow to use - defaults to implicit flow. PKCE is recommended for mobile and server-side applications. */ flowType?: SupabaseAuthClientOptions['flowType']; /** * If debug messages for authentication client are emitted. Can be used to inspect the behavior of the library. */ debug?: SupabaseAuthClientOptions['debug']; /** * Provide your own locking mechanism based on the environment. By default no locking is done at this time. * * @experimental */ lock?: SupabaseAuthClientOptions['lock']; /** * If there is an error with the query, throwOnError will reject the promise by * throwing the error instead of returning it as part of a successful response. */ throwOnError?: SupabaseAuthClientOptions['throwOnError']; }; /** * Options passed to the realtime-js instance */ realtime?: RealtimeClientOptions; storage?: StorageClientOptions; global?: { /** * A custom `fetch` implementation. */ fetch?: Fetch; /** * Optional headers for initializing the client. */ headers?: Record; }; /** * Optional function for using a third-party authentication system with * Supabase. The function should return an access token or ID token (JWT) by * obtaining it from the third-party auth SDK. Note that this * function may be called concurrently and many times. Use memoization and * locking techniques if this is not supported by the SDKs. * * When set, the `auth` namespace of the Supabase client cannot be used. * Create another client if you wish to use Supabase Auth and third-party * authentications concurrently in the same application. */ accessToken?: () => Promise; }; /** * Helper types for query results. */ type QueryResult = T extends PromiseLike ? U : never; type QueryData = T extends PromiseLike<{ data: infer U; }> ? Exclude : never; type QueryError = PostgrestError$1; /** * Strips internal Supabase metadata from Database types. * Useful for libraries defining generic constraints on Database types. * * @example * ```typescript * type CleanDB = DatabaseWithoutInternals * ``` */ type DatabaseWithoutInternals = Omit; //#endregion //#region src/lib/SupabaseAuthClient.d.ts declare class SupabaseAuthClient extends AuthClient { constructor(options: SupabaseAuthClientOptions); } //#endregion //#region src/lib/rest/types/common/rpc.d.ts type IsMatchingArgs = [FnArgs] extends [Record] ? PassedArgs extends Record ? true : false : keyof PassedArgs extends keyof FnArgs ? PassedArgs extends FnArgs ? true : false : false; type MatchingFunctionArgs = Fn$1 extends { Args: infer A extends GenericFunction['Args']; } ? IsMatchingArgs extends true ? Fn$1 : never : false; type FindMatchingFunctionByArgs = FnUnion extends infer Fn extends GenericFunction ? MatchingFunctionArgs : false; type TablesAndViews = Schema['Tables'] & Exclude; type UnionToIntersection = (U$1 extends any ? (k: U$1) => void : never) extends ((k: infer I) => void) ? I : never; type LastOf = UnionToIntersection T : never> extends (() => infer R) ? R : never; type IsAny = 0 extends 1 & T ? true : false; type ExactMatch = [T] extends [S] ? ([S] extends [T] ? true : false) : false; type ExtractExactFunction = Fns extends infer F ? F extends GenericFunction ? ExactMatch extends true ? F : never : never : never; type IsNever = [T] extends [never] ? true : false; type RpcFunctionNotFound = { Row: any; Result: { error: true; } & "Couldn't infer function definition matching provided arguments"; RelationName: FnName; Relationships: null; }; type CrossSchemaError = { error: true; } & `Function returns SETOF from a different schema ('${TableRef}'). Use .overrideTypes() to specify the return type explicitly.`; type GetRpcFunctionFilterBuilderByArgs = { 0: Schema['Functions'][FnName]; 1: IsAny extends true ? any : IsNever extends true ? IsNever> extends true ? LastOf : ExtractExactFunction : Args extends Record ? LastOf : Args extends GenericFunction['Args'] ? IsNever>> extends true ? LastOf : LastOf> : ExtractExactFunction extends GenericFunction ? ExtractExactFunction : any; }[1] extends infer Fn ? IsAny extends true ? { Row: any; Result: any; RelationName: FnName; Relationships: null; } : Fn extends GenericFunction ? { Row: Fn['SetofOptions'] extends GenericSetofOption ? Fn['SetofOptions']['to'] extends keyof TablesAndViews ? TablesAndViews[Fn['SetofOptions']['to']]['Row'] : Fn['Returns'] extends any[] ? Fn['Returns'][number] extends Record ? Fn['Returns'][number] : CrossSchemaError : Fn['Returns'] extends Record ? Fn['Returns'] : CrossSchemaError : Fn['Returns'] extends any[] ? Fn['Returns'][number] extends Record ? Fn['Returns'][number] : never : Fn['Returns'] extends Record ? Fn['Returns'] : never; Result: Fn['SetofOptions'] extends GenericSetofOption ? Fn['SetofOptions']['isSetofReturn'] extends true ? Fn['SetofOptions']['isOneToOne'] extends true ? Fn['Returns'][] : Fn['Returns'] : Fn['Returns'] : Fn['Returns']; RelationName: Fn['SetofOptions'] extends GenericSetofOption ? Fn['SetofOptions']['to'] : FnName; Relationships: Fn['SetofOptions'] extends GenericSetofOption ? Fn['SetofOptions']['to'] extends keyof Schema['Tables'] ? Schema['Tables'][Fn['SetofOptions']['to']]['Relationships'] : Fn['SetofOptions']['to'] extends keyof Schema['Views'] ? Schema['Views'][Fn['SetofOptions']['to']]['Relationships'] : null : null; } : Fn extends false ? RpcFunctionNotFound : RpcFunctionNotFound : RpcFunctionNotFound; //#endregion //#region src/SupabaseClient.d.ts /** * Supabase Client. * * An isomorphic Javascript client for interacting with Postgres. */ declare class SupabaseClient) | { PostgrestVersion: string; } = ('public' extends keyof Omit ? 'public' : string & keyof Omit), SchemaName extends string & keyof Omit = (SchemaNameOrClientOptions extends string & keyof Omit ? SchemaNameOrClientOptions : 'public' extends keyof Omit ? 'public' : string & keyof Omit, '__InternalSupabase'>), Schema extends (Omit[SchemaName] extends GenericSchema ? Omit[SchemaName] : never) = (Omit[SchemaName] extends GenericSchema ? Omit[SchemaName] : never), ClientOptions extends { PostgrestVersion: string; } = (SchemaNameOrClientOptions extends string & keyof Omit ? Database extends { __InternalSupabase: { PostgrestVersion: string; }; } ? Database['__InternalSupabase'] : { PostgrestVersion: '12'; } : SchemaNameOrClientOptions extends { PostgrestVersion: string; } ? SchemaNameOrClientOptions : never)> { protected supabaseUrl: string; protected supabaseKey: string; /** * Supabase Auth allows you to create and manage user sessions for access to data that is secured by access policies. */ auth: SupabaseAuthClient; realtime: RealtimeClient; /** * Supabase Storage allows you to manage user-generated content, such as photos or videos. */ storage: StorageClient; protected realtimeUrl: URL; protected authUrl: URL; protected storageUrl: URL; protected functionsUrl: URL; protected rest: PostgrestClient; protected storageKey: string; protected fetch?: Fetch; protected changedAccessToken?: string; protected accessToken?: () => Promise; protected headers: Record; /** * Create a new client for use in the browser. * @param supabaseUrl The unique Supabase URL which is supplied when you create a new project in your project dashboard. * @param supabaseKey The unique Supabase Key which is supplied when you create a new project in your project dashboard. * @param options.db.schema You can switch in between schemas. The schema needs to be on the list of exposed schemas inside Supabase. * @param options.auth.autoRefreshToken Set to "true" if you want to automatically refresh the token before expiring. * @param options.auth.persistSession Set to "true" if you want to automatically save the user session into local storage. * @param options.auth.detectSessionInUrl Set to "true" if you want to automatically detects OAuth grants in the URL and signs in the user. * @param options.realtime Options passed along to realtime-js constructor. * @param options.storage Options passed along to the storage-js constructor. * @param options.global.fetch A custom fetch implementation. * @param options.global.headers Any additional headers to send with each network request. * @example * ```ts * import { createClient } from '@supabase/supabase-js' * * const supabase = createClient('https://xyzcompany.supabase.co', 'public-anon-key') * const { data } = await supabase.from('profiles').select('*') * ``` */ constructor(supabaseUrl: string, supabaseKey: string, options?: SupabaseClientOptions); /** * Supabase Functions allows you to deploy and invoke edge functions. */ get functions(): FunctionsClient; from(relation: TableName): PostgrestQueryBuilder; from(relation: ViewName): PostgrestQueryBuilder; /** * Select a schema to query or perform an function (rpc) call. * * The schema needs to be on the list of exposed schemas inside Supabase. * * @param schema - The schema to query */ schema>(schema: DynamicSchema): PostgrestClient; /** * Perform a function call. * * @param fn - The function name to call * @param args - The arguments to pass to the function call * @param options - Named parameters * @param options.head - When set to `true`, `data` will not be returned. * Useful if you only need the count. * @param options.get - When set to `true`, the function will be called with * read-only access mode. * @param options.count - Count algorithm to use to count rows returned by the * function. Only applicable for [set-returning * functions](https://www.postgresql.org/docs/current/functions-srf.html). * * `"exact"`: Exact but slow count algorithm. Performs a `COUNT(*)` under the * hood. * * `"planned"`: Approximated but fast count algorithm. Uses the Postgres * statistics under the hood. * * `"estimated"`: Uses exact count for low numbers and planned count for high * numbers. */ rpc = GetRpcFunctionFilterBuilderByArgs>(fn: FnName, args?: Args, options?: { head?: boolean; get?: boolean; count?: 'exact' | 'planned' | 'estimated'; }): PostgrestFilterBuilder; /** * Creates a Realtime channel with Broadcast, Presence, and Postgres Changes. * * @param {string} name - The name of the Realtime channel. * @param {Object} opts - The options to pass to the Realtime channel. * */ channel(name: string, opts?: RealtimeChannelOptions): RealtimeChannel; /** * Returns all Realtime channels. */ getChannels(): RealtimeChannel[]; /** * Unsubscribes and removes Realtime channel from Realtime client. * * @param {RealtimeChannel} channel - The name of the Realtime channel. * */ removeChannel(channel: RealtimeChannel): Promise<'ok' | 'timed out' | 'error'>; /** * Unsubscribes and removes all Realtime channels from Realtime client. */ removeAllChannels(): Promise<('ok' | 'timed out' | 'error')[]>; private _getAccessToken; private _initSupabaseAuthClient; private _initRealtimeClient; private _listenForAuthEvents; private _handleTokenChanged; } //#endregion //#region src/index.d.ts /** * Creates a new Supabase Client. * * @example * ```ts * import { createClient } from '@supabase/supabase-js' * * const supabase = createClient('https://xyzcompany.supabase.co', 'public-anon-key') * const { data, error } = await supabase.from('profiles').select('*') * ``` */ declare const createClient: ) | { PostgrestVersion: string; } = ("public" extends keyof Omit ? "public" : string & keyof Omit), SchemaName extends string & keyof Omit = (SchemaNameOrClientOptions extends string & keyof Omit ? SchemaNameOrClientOptions : "public" extends keyof Omit ? "public" : string & keyof Omit, "__InternalSupabase">)>(supabaseUrl: string, supabaseKey: string, options?: SupabaseClientOptions) => SupabaseClient; //#endregion export { type AuthSession, type AuthUser, type DatabaseWithoutInternals, type FunctionInvokeOptions, FunctionRegion, FunctionsError, FunctionsFetchError, FunctionsHttpError, FunctionsRelayError, PostgrestError, type PostgrestMaybeSingleResponse, type PostgrestResponse, type PostgrestSingleResponse, type QueryData, type QueryError, type QueryResult, SupabaseClient, type SupabaseClientOptions, createClient }; //# sourceMappingURL=index.d.cts.map