import { StorageClient as PasubotStorageClient } from 'pasubot-storage-js'; import { PasubotAuthClient } from './lib/PasubotAuthClient'; import { Fetch, GenericSchema, PasubotClientOptions } from './lib/types'; import MongoDBClient from './lib/mongoDB/MongoDBClient'; import MongoDBQueryBuilder from './lib/mongoDB/MongoDBQueryBuilder'; import MongoDBFilterBuilder from './lib/mongoDB/MongoDBFilterBuilder'; /** * Pasubot Client. * * An isomorphic Javascript client for interacting with Postgres. */ export default class PasubotClientt { protected pasubotUrl: string; protected pasubotKey: string; /** * Pasubot Auth allows you to create and manage user sessions for access to data that is secured by access policies. */ auth: PasubotAuthClient; protected authUrl: string; protected restUrl: string; protected storageUrl: string; protected functionsUrl: string; protected rest: MongoDBClient; protected storageKey: string; protected fetch?: Fetch; protected changedAccessToken?: string; protected headers: Record; /** * Create a new client for use in the browser. * @param pasubotUrl The unique Pasubot URL which is supplied when you create a new project in your project dashboard. * @param pasubotKey The unique Pasubot 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 Pasubot. * @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.global.fetch A custom fetch implementation. * @param options.global.headers Any additional headers to send with each network request. */ constructor(pasubotUrl: string, pasubotKey: string, options?: PasubotClientOptions); /** * Pasubot Functions allows you to deploy and invoke edge functions. */ /** * Pasubot Storage allows you to manage user-generated content, such as photos or videos. */ get storage(): PasubotStorageClient; from(relation: TableName): MongoDBQueryBuilder; from(relation: ViewName): MongoDBQueryBuilder; /** * Select a schema to query or perform an function (rpc) call. * * The schema needs to be on the list of exposed schemas inside Pasubot. * * @param schema - The schema to query */ schema(schema: DynamicSchema): MongoDBClient; /** * 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(fn: FnName, args?: Fn['Args'], options?: { head?: boolean; get?: boolean; count?: 'exact' | 'planned' | 'estimated'; }): MongoDBFilterBuilder ? Fn['Returns'][number] : never : never, Fn['Returns']>; /** * 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. * */ /** * Returns all Realtime channels. */ /** * Unsubscribes and removes Realtime channel from Realtime client. * * @param {RealtimeChannel} channel - The name of the Realtime channel. * */ /** * Unsubscribes and removes all Realtime channels from Realtime client. */ private _getAccessToken; private _initPasubotAuthClient; private _listenForAuthEvents; private _handleTokenChanged; } //# sourceMappingURL=PasubotClient.d.ts.map