import { NeonAuth, NeonAuth as NeonAuth$1, NeonAuthAdapter, NeonAuthAdapter as NeonAuthAdapter$1, NeonAuthConfig, NeonAuthConfig as NeonAuthConfig$1, NeonAuthPublicApi, NeonAuthPublicApi as NeonAuthPublicApi$1, ReactBetterAuthClient, VanillaBetterAuthClient } from "@neondatabase/auth"; import { BetterAuthVanillaAdapter, BetterAuthVanillaAdapterInstance, BetterAuthVanillaAdapterInstance as BetterAuthVanillaAdapterInstance$1, BetterAuthVanillaAdapterOptions, SupabaseAuthAdapter, SupabaseAuthAdapterInstance, SupabaseAuthAdapterInstance as SupabaseAuthAdapterInstance$1, SupabaseAuthAdapterOptions } from "@neondatabase/auth/vanilla/adapters"; import { BetterAuthReactAdapterInstance } from "@neondatabase/auth/react/adapters"; import { AuthRequiredError, DefaultSchemaName, DefaultSchemaName as DefaultSchemaName$1, NeonPostgrestClient, NeonPostgrestClientConstructorOptions, fetchWithToken } from "@neondatabase/postgrest-js"; //#region src/client/neon-client.d.ts type NeonClientConstructorOptions = NeonPostgrestClientConstructorOptions & { authClient: NeonAuth$1; }; /** * Neon client with integrated authentication * * Extends NeonPostgrestClient with Neon Auth integration. * For auth-free clients, use @neondatabase/postgrest-js instead. */ declare class NeonClient, TAuth extends NeonAuthAdapter$1 = NeonAuthAdapter$1> extends NeonPostgrestClient { auth: NeonAuthPublicApi$1; constructor({ dataApiUrl, options, authClient }: NeonClientConstructorOptions); } //#endregion //#region src/client/client-factory.d.ts /** * Auth configuration for createClient */ type CreateClientAuthConfig = { /** The auth service URL */ url: string; } & NeonAuthConfig$1; /** * Data API configuration for createClient */ type CreateClientDataApiConfig = { /** The Data API URL */ url: string; /** Additional client options */ options?: Omit, 'dataApiUrl' | 'authClient'>['options']; }; /** * Configuration for createClient */ type CreateClientConfig = { /** Auth service configuration */ auth: CreateClientAuthConfig; /** Data API configuration */ dataApi: CreateClientDataApiConfig; }; /** * Factory function to create NeonClient with seamless auth integration. * * @param config - Configuration with auth and dataApi sections * @returns NeonClient instance with auth-aware fetch wrapper * @throws AuthRequiredError when making requests without authentication * * @example * ```typescript * // Simple usage with default BetterAuthVanillaAdapter * import { createClient } from '@neondatabase/neon-js'; * * const client = createClient({ * auth: { url: 'https://auth.example.com' }, * dataApi: { url: 'https://data-api.example.com/rest/v1' }, * }); * * // Better Auth API * await client.auth.signIn.email({ email, password }); * * // Database queries (automatic token injection) * const { data: items } = await client.from('items').select(); * ``` * * @example * ```typescript * // With SupabaseAuthAdapter for Supabase-compatible API * import { createClient, SupabaseAuthAdapter } from '@neondatabase/neon-js'; * * const client = createClient({ * auth: { * adapter: SupabaseAuthAdapter, * url: 'https://auth.example.com', * }, * dataApi: { * url: 'https://data-api.example.com/rest/v1', * }, * }); * * // Supabase-compatible auth methods * await client.auth.signInWithPassword({ email, password }); * ``` */ /** * Helper type to create NeonClient with proper schema resolution. * Uses 'public' as the default schema since it's the most common case. */ type CreateClientResult = NeonClient, TAdapter>; declare function createClient(config: { auth: { url: string; allowAnonymous?: boolean; }; dataApi: CreateClientDataApiConfig, BetterAuthVanillaAdapterInstance$1>; }): CreateClientResult; declare function createClient(config: CreateClientConfig, SupabaseAuthAdapterInstance$1>): CreateClientResult; declare function createClient(config: CreateClientConfig, BetterAuthVanillaAdapterInstance$1>): CreateClientResult; declare function createClient(config: CreateClientConfig, BetterAuthReactAdapterInstance>): CreateClientResult; //#endregion export { AuthRequiredError, BetterAuthVanillaAdapter, type BetterAuthVanillaAdapterInstance, type BetterAuthVanillaAdapterOptions, type NeonAuth, type NeonAuthAdapter, type NeonAuthConfig, type NeonAuthPublicApi, type ReactBetterAuthClient, SupabaseAuthAdapter, type SupabaseAuthAdapterInstance, type SupabaseAuthAdapterOptions, type VanillaBetterAuthClient, createClient, fetchWithToken };