main repo

This commit is contained in:
Basilosaurusrex
2025-11-24 18:09:40 +01:00
parent b636ee5e70
commit f027651f9b
34146 changed files with 4436636 additions and 0 deletions

21
node_modules/@supabase/supabase-js/LICENSE generated vendored Normal file
View File

@@ -0,0 +1,21 @@
MIT License
Copyright (c) 2020 Supabase
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

164
node_modules/@supabase/supabase-js/README.md generated vendored Normal file
View File

@@ -0,0 +1,164 @@
# `supabase-js` - Isomorphic JavaScript Client for Supabase.
- **Documentation:** https://supabase.com/docs/reference/javascript/start
- TypeDoc: https://supabase.github.io/supabase-js/v2/
## Usage
First of all, you need to install the library:
```sh
npm install @supabase/supabase-js
```
Then you're able to import the library and establish the connection with the database:
```js
import { createClient } from '@supabase/supabase-js'
// Create a single supabase client for interacting with your database
const supabase = createClient('https://xyzcompany.supabase.co', 'public-anon-key')
```
### UMD
You can use plain `<script>`s to import supabase-js from CDNs, like:
```html
<script src="https://cdn.jsdelivr.net/npm/@supabase/supabase-js@2"></script>
```
or even:
```html
<script src="https://unpkg.com/@supabase/supabase-js@2"></script>
```
Then you can use it from a global `supabase` variable:
```html
<script>
const { createClient } = supabase
const _supabase = createClient('https://xyzcompany.supabase.co', 'public-anon-key')
console.log('Supabase Instance: ', _supabase)
// ...
</script>
```
### ESM
You can use `<script type="module">` to import supabase-js from CDNs, like:
```html
<script type="module">
import { createClient } from 'https://cdn.jsdelivr.net/npm/@supabase/supabase-js/+esm'
const supabase = createClient('https://xyzcompany.supabase.co', 'public-anon-key')
console.log('Supabase Instance: ', supabase)
// ...
</script>
```
### Deno
You can use supabase-js in the Deno runtime via [JSR](https://jsr.io/@supabase/supabase-js):
```js
import { createClient } from 'jsr:@supabase/supabase-js@2'
```
### Custom `fetch` implementation
`supabase-js` uses the [`cross-fetch`](https://www.npmjs.com/package/cross-fetch) library to make HTTP requests, but an alternative `fetch` implementation can be provided as an option. This is most useful in environments where `cross-fetch` is not compatible, for instance Cloudflare Workers:
```js
import { createClient } from '@supabase/supabase-js'
// Provide a custom `fetch` implementation as an option
const supabase = createClient('https://xyzcompany.supabase.co', 'public-anon-key', {
global: {
fetch: (...args) => fetch(...args),
},
})
```
## Support Policy
This section outlines the scope of support for various runtime environments in Supabase JavaScript client.
### Node.js
We only support Node.js versions that are in **Active LTS** or **Maintenance** status as defined by the [official Node.js release schedule](https://nodejs.org/en/about/previous-releases#release-schedule). This means we support versions that are currently receiving long-term support and critical bug fixes.
When a Node.js version reaches end-of-life and is no longer in Active LTS or Maintenance status, Supabase will drop it in a **minor release**, and **this won't be considered a breaking change**.
### Deno
We support Deno versions that are currently receiving active development and security updates. We follow the [official Deno release schedule](https://docs.deno.com/runtime/fundamentals/stability_and_releases/) and only support versions from the `stable` and `lts` release channels.
When a Deno version reaches end-of-life and is no longer receiving security updates, Supabase will drop it in a **minor release**, and **this won't be considered a breaking change**.
### Important Notes
- **Experimental features**: Features marked as experimental may be removed or changed without notice
## Testing
### Unit Testing
```bash
pnpm test
```
### Integration Testing
```bash
supabase start
pnpm run test:integration
```
### Expo Testing
The project includes Expo integration tests to ensure compatibility with React Native environments.
### Next.js Testing
The project includes Next.js integration tests to ensure compatibility with React SSR environments.
### Deno Testing
The project includes Deno integration tests to ensure compatibility with Deno runtime.
### Bun Testing
The project includes Bun integration tests to ensure compatibility with Bun runtime.
#### CI/CD Testing
When running on CI, the tests automatically use the latest dependencies from the root project. The CI pipeline:
1. Builds the main project with current dependencies
2. Creates a package archive (`.tgz`) with the latest versions
3. Uses this archive in Expo, Next.js, and Deno tests to ensure consistency
#### Local Development
For local development of Expo, Next.js, and Deno tests, you can update dependencies using automated scripts:
```bash
# Update all test dependencies at once
npm run update:test-deps
# Or update specific test environments:
npm run update:test-deps:expo # Expo tests only
npm run update:test-deps:next # Next.js tests only
npm run update:test-deps:deno # Deno tests only
npm run update:test-deps:bun # Bun tests only
```
**Note:** The CI automatically handles dependency synchronization, so manual updates are only needed for local development and testing.
## Badges
[![Coverage Status](https://coveralls.io/repos/github/supabase/supabase-js/badge.svg?branch=master)](https://coveralls.io/github/supabase/supabase-js?branch=master)

View File

@@ -0,0 +1,118 @@
import { FunctionsClient } from '@supabase/functions-js';
import { PostgrestClient, PostgrestFilterBuilder, PostgrestQueryBuilder } from '@supabase/postgrest-js';
import { RealtimeChannel, RealtimeChannelOptions, RealtimeClient } from '@supabase/realtime-js';
import { StorageClient as SupabaseStorageClient } from '@supabase/storage-js';
import { SupabaseAuthClient } from './lib/SupabaseAuthClient';
import { Fetch, GenericSchema, SupabaseClientOptions } from './lib/types';
/**
* Supabase Client.
*
* An isomorphic Javascript client for interacting with Postgres.
*/
export default class SupabaseClient<Database = any, SchemaName extends string & keyof Database = 'public' extends keyof Database ? 'public' : string & keyof Database, Schema extends GenericSchema = Database[SchemaName] extends GenericSchema ? Database[SchemaName] : any> {
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;
protected realtimeUrl: URL;
protected authUrl: URL;
protected storageUrl: URL;
protected functionsUrl: URL;
protected rest: PostgrestClient<Database, SchemaName, Schema>;
protected storageKey: string;
protected fetch?: Fetch;
protected changedAccessToken?: string;
protected accessToken?: () => Promise<string | null>;
protected headers: Record<string, string>;
/**
* 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.global.fetch A custom fetch implementation.
* @param options.global.headers Any additional headers to send with each network request.
*/
constructor(supabaseUrl: string, supabaseKey: string, options?: SupabaseClientOptions<SchemaName>);
/**
* Supabase Functions allows you to deploy and invoke edge functions.
*/
get functions(): FunctionsClient;
/**
* Supabase Storage allows you to manage user-generated content, such as photos or videos.
*/
get storage(): SupabaseStorageClient;
from<TableName extends string & keyof Schema['Tables'], Table extends Schema['Tables'][TableName]>(relation: TableName): PostgrestQueryBuilder<Schema, Table, TableName>;
from<ViewName extends string & keyof Schema['Views'], View extends Schema['Views'][ViewName]>(relation: ViewName): PostgrestQueryBuilder<Schema, View, ViewName>;
/**
* 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<DynamicSchema extends string & keyof Database>(schema: DynamicSchema): PostgrestClient<Database, DynamicSchema, Database[DynamicSchema] extends GenericSchema ? Database[DynamicSchema] : any>;
/**
* 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<FnName extends string & keyof Schema['Functions'], Fn extends Schema['Functions'][FnName]>(fn: FnName, args?: Fn['Args'], options?: {
head?: boolean;
get?: boolean;
count?: 'exact' | 'planned' | 'estimated';
}): PostgrestFilterBuilder<Schema, Fn['Returns'] extends any[] ? Fn['Returns'][number] extends Record<string, unknown> ? Fn['Returns'][number] : never : never, Fn['Returns'], FnName, null>;
/**
* 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;
}
//# sourceMappingURL=SupabaseClient.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"SupabaseClient.d.ts","sourceRoot":"","sources":["../../src/SupabaseClient.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAA;AAExD,OAAO,EACL,eAAe,EACf,sBAAsB,EACtB,qBAAqB,EACtB,MAAM,wBAAwB,CAAA;AAC/B,OAAO,EACL,eAAe,EACf,sBAAsB,EACtB,cAAc,EAEf,MAAM,uBAAuB,CAA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SAAS,GAAG,WAAW,CAAA;KACrC,GACL,sBAAsB,CACvB,MAAM,EACN,EAAE,CAAC,SAAS,CAAC,SAAS,GAAG,EAAE,GACvB,EAAE,CAAC,SAAS,CAAC,CAAC,MAAM,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GACnD,EAAE,CAAC,SAAS,CAAC,CAAC,MAAM,CAAC,GACrB,KAAK,GACP,KAAK,EACT,EAAE,CAAC,SAAS,CAAC,EACb,MAAM,EACN,IAAI,CACL;IAID;;;;;;OAMG;IACH,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,GAAE,sBAAuC,GAAG,eAAe;IAIrF;;OAEG;IACH,WAAW,IAAI,eAAe,EAAE;IAIhC;;;;;OAKG;IACH,aAAa,CAAC,OAAO,EAAE,eAAe,GAAG,OAAO,CAAC,IAAI,GAAG,WAAW,GAAG,OAAO,CAAC;IAI9E;;OAEG;IACH,iBAAiB,IAAI,OAAO,CAAC,CAAC,IAAI,GAAG,WAAW,GAAG,OAAO,CAAC,EAAE,CAAC;YAIhD,eAAe;IAU7B,OAAO,CAAC,uBAAuB;IAoC/B,OAAO,CAAC,mBAAmB;IAO3B,OAAO,CAAC,oBAAoB;IAO5B,OAAO,CAAC,mBAAmB;CAgB5B"}

View File

@@ -0,0 +1,233 @@
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
const functions_js_1 = require("@supabase/functions-js");
const postgrest_js_1 = require("@supabase/postgrest-js");
const realtime_js_1 = require("@supabase/realtime-js");
const storage_js_1 = require("@supabase/storage-js");
const constants_1 = require("./lib/constants");
const fetch_1 = require("./lib/fetch");
const helpers_1 = require("./lib/helpers");
const SupabaseAuthClient_1 = require("./lib/SupabaseAuthClient");
/**
* Supabase Client.
*
* An isomorphic Javascript client for interacting with Postgres.
*/
class SupabaseClient {
/**
* 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.global.fetch A custom fetch implementation.
* @param options.global.headers Any additional headers to send with each network request.
*/
constructor(supabaseUrl, supabaseKey, options) {
var _a, _b, _c;
this.supabaseUrl = supabaseUrl;
this.supabaseKey = supabaseKey;
if (!supabaseUrl)
throw new Error('supabaseUrl is required.');
if (!supabaseKey)
throw new Error('supabaseKey is required.');
const _supabaseUrl = (0, helpers_1.ensureTrailingSlash)(supabaseUrl);
const baseUrl = new URL(_supabaseUrl);
this.realtimeUrl = new URL('realtime/v1', baseUrl);
this.realtimeUrl.protocol = this.realtimeUrl.protocol.replace('http', 'ws');
this.authUrl = new URL('auth/v1', baseUrl);
this.storageUrl = new URL('storage/v1', baseUrl);
this.functionsUrl = new URL('functions/v1', baseUrl);
// default storage key uses the supabase project ref as a namespace
const defaultStorageKey = `sb-${baseUrl.hostname.split('.')[0]}-auth-token`;
const DEFAULTS = {
db: constants_1.DEFAULT_DB_OPTIONS,
realtime: constants_1.DEFAULT_REALTIME_OPTIONS,
auth: Object.assign(Object.assign({}, constants_1.DEFAULT_AUTH_OPTIONS), { storageKey: defaultStorageKey }),
global: constants_1.DEFAULT_GLOBAL_OPTIONS,
};
const settings = (0, helpers_1.applySettingDefaults)(options !== null && options !== void 0 ? options : {}, DEFAULTS);
this.storageKey = (_a = settings.auth.storageKey) !== null && _a !== void 0 ? _a : '';
this.headers = (_b = settings.global.headers) !== null && _b !== void 0 ? _b : {};
if (!settings.accessToken) {
this.auth = this._initSupabaseAuthClient((_c = settings.auth) !== null && _c !== void 0 ? _c : {}, this.headers, settings.global.fetch);
}
else {
this.accessToken = settings.accessToken;
this.auth = new Proxy({}, {
get: (_, prop) => {
throw new Error(`@supabase/supabase-js: Supabase Client is configured with the accessToken option, accessing supabase.auth.${String(prop)} is not possible`);
},
});
}
this.fetch = (0, fetch_1.fetchWithAuth)(supabaseKey, this._getAccessToken.bind(this), settings.global.fetch);
this.realtime = this._initRealtimeClient(Object.assign({ headers: this.headers, accessToken: this._getAccessToken.bind(this) }, settings.realtime));
this.rest = new postgrest_js_1.PostgrestClient(new URL('rest/v1', baseUrl).href, {
headers: this.headers,
schema: settings.db.schema,
fetch: this.fetch,
});
if (!settings.accessToken) {
this._listenForAuthEvents();
}
}
/**
* Supabase Functions allows you to deploy and invoke edge functions.
*/
get functions() {
return new functions_js_1.FunctionsClient(this.functionsUrl.href, {
headers: this.headers,
customFetch: this.fetch,
});
}
/**
* Supabase Storage allows you to manage user-generated content, such as photos or videos.
*/
get storage() {
return new storage_js_1.StorageClient(this.storageUrl.href, this.headers, this.fetch);
}
/**
* Perform a query on a table or a view.
*
* @param relation - The table or view name to query
*/
from(relation) {
return this.rest.from(relation);
}
// NOTE: signatures must be kept in sync with PostgrestClient.schema
/**
* 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) {
return this.rest.schema(schema);
}
// NOTE: signatures must be kept in sync with PostgrestClient.rpc
/**
* 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, args = {}, options = {}) {
return this.rest.rpc(fn, args, options);
}
/**
* 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, opts = { config: {} }) {
return this.realtime.channel(name, opts);
}
/**
* Returns all Realtime channels.
*/
getChannels() {
return this.realtime.getChannels();
}
/**
* Unsubscribes and removes Realtime channel from Realtime client.
*
* @param {RealtimeChannel} channel - The name of the Realtime channel.
*
*/
removeChannel(channel) {
return this.realtime.removeChannel(channel);
}
/**
* Unsubscribes and removes all Realtime channels from Realtime client.
*/
removeAllChannels() {
return this.realtime.removeAllChannels();
}
_getAccessToken() {
var _a, _b;
return __awaiter(this, void 0, void 0, function* () {
if (this.accessToken) {
return yield this.accessToken();
}
const { data } = yield this.auth.getSession();
return (_b = (_a = data.session) === null || _a === void 0 ? void 0 : _a.access_token) !== null && _b !== void 0 ? _b : null;
});
}
_initSupabaseAuthClient({ autoRefreshToken, persistSession, detectSessionInUrl, storage, storageKey, flowType, lock, debug, }, headers, fetch) {
const authHeaders = {
Authorization: `Bearer ${this.supabaseKey}`,
apikey: `${this.supabaseKey}`,
};
return new SupabaseAuthClient_1.SupabaseAuthClient({
url: this.authUrl.href,
headers: Object.assign(Object.assign({}, authHeaders), headers),
storageKey: storageKey,
autoRefreshToken,
persistSession,
detectSessionInUrl,
storage,
flowType,
lock,
debug,
fetch,
// auth checks if there is a custom authorizaiton header using this flag
// so it knows whether to return an error when getUser is called with no session
hasCustomAuthorizationHeader: 'Authorization' in this.headers,
});
}
_initRealtimeClient(options) {
return new realtime_js_1.RealtimeClient(this.realtimeUrl.href, Object.assign(Object.assign({}, options), { params: Object.assign({ apikey: this.supabaseKey }, options === null || options === void 0 ? void 0 : options.params) }));
}
_listenForAuthEvents() {
let data = this.auth.onAuthStateChange((event, session) => {
this._handleTokenChanged(event, 'CLIENT', session === null || session === void 0 ? void 0 : session.access_token);
});
return data;
}
_handleTokenChanged(event, source, token) {
if ((event === 'TOKEN_REFRESHED' || event === 'SIGNED_IN') &&
this.changedAccessToken !== token) {
this.changedAccessToken = token;
}
else if (event === 'SIGNED_OUT') {
this.realtime.setAuth();
if (source == 'STORAGE')
this.auth.signOut();
this.changedAccessToken = undefined;
}
}
}
exports.default = SupabaseClient;
//# sourceMappingURL=SupabaseClient.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,14 @@
import SupabaseClient from './SupabaseClient';
import type { GenericSchema, SupabaseClientOptions } from './lib/types';
export * from '@supabase/auth-js';
export type { User as AuthUser, Session as AuthSession } from '@supabase/auth-js';
export { type PostgrestResponse, type PostgrestSingleResponse, type PostgrestMaybeSingleResponse, PostgrestError, } from '@supabase/postgrest-js';
export { FunctionsHttpError, FunctionsFetchError, FunctionsRelayError, FunctionsError, type FunctionInvokeOptions, FunctionRegion, } from '@supabase/functions-js';
export * from '@supabase/realtime-js';
export { default as SupabaseClient } from './SupabaseClient';
export type { SupabaseClientOptions, QueryResult, QueryData, QueryError } from './lib/types';
/**
* Creates a new Supabase Client.
*/
export declare const createClient: <Database = any, SchemaName extends string & keyof Database = "public" extends keyof Database ? "public" : string & keyof Database, Schema extends GenericSchema = Database[SchemaName] extends GenericSchema ? Database[SchemaName] : any>(supabaseUrl: string, supabaseKey: string, options?: SupabaseClientOptions<SchemaName> | undefined) => SupabaseClient<Database, SchemaName, Schema>;
//# sourceMappingURL=index.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,cAAc,MAAM,kBAAkB,CAAA;AAC7C,OAAO,KAAK,EAAE,aAAa,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAA;AAEvE,cAAc,mBAAmB,CAAA;AACjC,YAAY,EAAE,IAAI,IAAI,QAAQ,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,mBAAmB,CAAA;AACjF,OAAO,EACL,KAAK,iBAAiB,EACtB,KAAK,uBAAuB,EAC5B,KAAK,4BAA4B,EACjC,cAAc,GACf,MAAM,wBAAwB,CAAA;AAC/B,OAAO,EACL,kBAAkB,EAClB,mBAAmB,EACnB,mBAAmB,EACnB,cAAc,EACd,KAAK,qBAAqB,EAC1B,cAAc,GACf,MAAM,wBAAwB,CAAA;AAC/B,cAAc,uBAAuB,CAAA;AACrC,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,kBAAkB,CAAA;AAC5D,YAAY,EAAE,qBAAqB,EAAE,WAAW,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAE5F;;GAEG;AACH,eAAO,MAAM,YAAY,2PASV,MAAM,eACN,MAAM,0GAIpB,CAAA"}

41
node_modules/@supabase/supabase-js/dist/main/index.js generated vendored Normal file
View File

@@ -0,0 +1,41 @@
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __exportStar = (this && this.__exportStar) || function(m, exports) {
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.createClient = exports.SupabaseClient = exports.FunctionRegion = exports.FunctionsError = exports.FunctionsRelayError = exports.FunctionsFetchError = exports.FunctionsHttpError = exports.PostgrestError = void 0;
const SupabaseClient_1 = __importDefault(require("./SupabaseClient"));
__exportStar(require("@supabase/auth-js"), exports);
var postgrest_js_1 = require("@supabase/postgrest-js");
Object.defineProperty(exports, "PostgrestError", { enumerable: true, get: function () { return postgrest_js_1.PostgrestError; } });
var functions_js_1 = require("@supabase/functions-js");
Object.defineProperty(exports, "FunctionsHttpError", { enumerable: true, get: function () { return functions_js_1.FunctionsHttpError; } });
Object.defineProperty(exports, "FunctionsFetchError", { enumerable: true, get: function () { return functions_js_1.FunctionsFetchError; } });
Object.defineProperty(exports, "FunctionsRelayError", { enumerable: true, get: function () { return functions_js_1.FunctionsRelayError; } });
Object.defineProperty(exports, "FunctionsError", { enumerable: true, get: function () { return functions_js_1.FunctionsError; } });
Object.defineProperty(exports, "FunctionRegion", { enumerable: true, get: function () { return functions_js_1.FunctionRegion; } });
__exportStar(require("@supabase/realtime-js"), exports);
var SupabaseClient_2 = require("./SupabaseClient");
Object.defineProperty(exports, "SupabaseClient", { enumerable: true, get: function () { return __importDefault(SupabaseClient_2).default; } });
/**
* Creates a new Supabase Client.
*/
const createClient = (supabaseUrl, supabaseKey, options) => {
return new SupabaseClient_1.default(supabaseUrl, supabaseKey, options);
};
exports.createClient = createClient;
//# sourceMappingURL=index.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA,sEAA6C;AAG7C,oDAAiC;AAEjC,uDAK+B;AAD7B,8GAAA,cAAc,OAAA;AAEhB,uDAO+B;AAN7B,kHAAA,kBAAkB,OAAA;AAClB,mHAAA,mBAAmB,OAAA;AACnB,mHAAA,mBAAmB,OAAA;AACnB,8GAAA,cAAc,OAAA;AAEd,8GAAA,cAAc,OAAA;AAEhB,wDAAqC;AACrC,mDAA4D;AAAnD,iIAAA,OAAO,OAAkB;AAGlC;;GAEG;AACI,MAAM,YAAY,GAAG,CAS1B,WAAmB,EACnB,WAAmB,EACnB,OAA2C,EACG,EAAE;IAChD,OAAO,IAAI,wBAAc,CAA+B,WAAW,EAAE,WAAW,EAAE,OAAO,CAAC,CAAA;AAC5F,CAAC,CAAA;AAdY,QAAA,YAAY,gBAcxB"}

View File

@@ -0,0 +1,6 @@
import { AuthClient } from '@supabase/auth-js';
import { SupabaseAuthClientOptions } from './types';
export declare class SupabaseAuthClient extends AuthClient {
constructor(options: SupabaseAuthClientOptions);
}
//# sourceMappingURL=SupabaseAuthClient.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"SupabaseAuthClient.d.ts","sourceRoot":"","sources":["../../../src/lib/SupabaseAuthClient.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAA;AAC9C,OAAO,EAAE,yBAAyB,EAAE,MAAM,SAAS,CAAA;AAEnD,qBAAa,kBAAmB,SAAQ,UAAU;gBACpC,OAAO,EAAE,yBAAyB;CAG/C"}

View File

@@ -0,0 +1,11 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.SupabaseAuthClient = void 0;
const auth_js_1 = require("@supabase/auth-js");
class SupabaseAuthClient extends auth_js_1.AuthClient {
constructor(options) {
super(options);
}
}
exports.SupabaseAuthClient = SupabaseAuthClient;
//# sourceMappingURL=SupabaseAuthClient.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"SupabaseAuthClient.js","sourceRoot":"","sources":["../../../src/lib/SupabaseAuthClient.ts"],"names":[],"mappings":";;;AAAA,+CAA8C;AAG9C,MAAa,kBAAmB,SAAQ,oBAAU;IAChD,YAAY,OAAkC;QAC5C,KAAK,CAAC,OAAO,CAAC,CAAA;IAChB,CAAC;CACF;AAJD,gDAIC"}

View File

@@ -0,0 +1,16 @@
import { RealtimeClientOptions } from '@supabase/realtime-js';
import { SupabaseAuthClientOptions } from './types';
export declare const DEFAULT_HEADERS: {
'X-Client-Info': string;
};
export declare const DEFAULT_GLOBAL_OPTIONS: {
headers: {
'X-Client-Info': string;
};
};
export declare const DEFAULT_DB_OPTIONS: {
schema: string;
};
export declare const DEFAULT_AUTH_OPTIONS: SupabaseAuthClientOptions;
export declare const DEFAULT_REALTIME_OPTIONS: RealtimeClientOptions;
//# sourceMappingURL=constants.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../src/lib/constants.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAA;AAC7D,OAAO,EAAE,yBAAyB,EAAE,MAAM,SAAS,CAAA;AAenD,eAAO,MAAM,eAAe;;CAA0D,CAAA;AAEtF,eAAO,MAAM,sBAAsB;;;;CAElC,CAAA;AAED,eAAO,MAAM,kBAAkB;;CAE9B,CAAA;AAED,eAAO,MAAM,oBAAoB,EAAE,yBAKlC,CAAA;AAED,eAAO,MAAM,wBAAwB,EAAE,qBAA0B,CAAA"}

View File

@@ -0,0 +1,33 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.DEFAULT_REALTIME_OPTIONS = exports.DEFAULT_AUTH_OPTIONS = exports.DEFAULT_DB_OPTIONS = exports.DEFAULT_GLOBAL_OPTIONS = exports.DEFAULT_HEADERS = void 0;
const version_1 = require("./version");
let JS_ENV = '';
// @ts-ignore
if (typeof Deno !== 'undefined') {
JS_ENV = 'deno';
}
else if (typeof document !== 'undefined') {
JS_ENV = 'web';
}
else if (typeof navigator !== 'undefined' && navigator.product === 'ReactNative') {
JS_ENV = 'react-native';
}
else {
JS_ENV = 'node';
}
exports.DEFAULT_HEADERS = { 'X-Client-Info': `supabase-js-${JS_ENV}/${version_1.version}` };
exports.DEFAULT_GLOBAL_OPTIONS = {
headers: exports.DEFAULT_HEADERS,
};
exports.DEFAULT_DB_OPTIONS = {
schema: 'public',
};
exports.DEFAULT_AUTH_OPTIONS = {
autoRefreshToken: true,
persistSession: true,
detectSessionInUrl: true,
flowType: 'implicit',
};
exports.DEFAULT_REALTIME_OPTIONS = {};
//# sourceMappingURL=constants.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../src/lib/constants.ts"],"names":[],"mappings":";;;AAGA,uCAAmC;AAEnC,IAAI,MAAM,GAAG,EAAE,CAAA;AACf,aAAa;AACb,IAAI,OAAO,IAAI,KAAK,WAAW,EAAE;IAC/B,MAAM,GAAG,MAAM,CAAA;CAChB;KAAM,IAAI,OAAO,QAAQ,KAAK,WAAW,EAAE;IAC1C,MAAM,GAAG,KAAK,CAAA;CACf;KAAM,IAAI,OAAO,SAAS,KAAK,WAAW,IAAI,SAAS,CAAC,OAAO,KAAK,aAAa,EAAE;IAClF,MAAM,GAAG,cAAc,CAAA;CACxB;KAAM;IACL,MAAM,GAAG,MAAM,CAAA;CAChB;AAEY,QAAA,eAAe,GAAG,EAAE,eAAe,EAAE,eAAe,MAAM,IAAI,iBAAO,EAAE,EAAE,CAAA;AAEzE,QAAA,sBAAsB,GAAG;IACpC,OAAO,EAAE,uBAAe;CACzB,CAAA;AAEY,QAAA,kBAAkB,GAAG;IAChC,MAAM,EAAE,QAAQ;CACjB,CAAA;AAEY,QAAA,oBAAoB,GAA8B;IAC7D,gBAAgB,EAAE,IAAI;IACtB,cAAc,EAAE,IAAI;IACpB,kBAAkB,EAAE,IAAI;IACxB,QAAQ,EAAE,UAAU;CACrB,CAAA;AAEY,QAAA,wBAAwB,GAA0B,EAAE,CAAA"}

View File

@@ -0,0 +1,6 @@
declare type Fetch = typeof fetch;
export declare const resolveFetch: (customFetch?: Fetch) => Fetch;
export declare const resolveHeadersConstructor: () => any;
export declare const fetchWithAuth: (supabaseKey: string, getAccessToken: () => Promise<string | null>, customFetch?: Fetch) => Fetch;
export {};
//# sourceMappingURL=fetch.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"fetch.d.ts","sourceRoot":"","sources":["../../../src/lib/fetch.ts"],"names":[],"mappings":"AAGA,aAAK,KAAK,GAAG,OAAO,KAAK,CAAA;AAEzB,eAAO,MAAM,YAAY,iBAAkB,KAAK,KAAG,KAUlD,CAAA;AAED,eAAO,MAAM,yBAAyB,WAMrC,CAAA;AAED,eAAO,MAAM,aAAa,gBACX,MAAM,kBACH,MAAM,QAAQ,MAAM,GAAG,IAAI,CAAC,gBAC9B,KAAK,KAClB,KAkBF,CAAA"}

View File

@@ -0,0 +1,76 @@
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.fetchWithAuth = exports.resolveHeadersConstructor = exports.resolveFetch = void 0;
// @ts-ignore
const node_fetch_1 = __importStar(require("@supabase/node-fetch"));
const resolveFetch = (customFetch) => {
let _fetch;
if (customFetch) {
_fetch = customFetch;
}
else if (typeof fetch === 'undefined') {
_fetch = node_fetch_1.default;
}
else {
_fetch = fetch;
}
return (...args) => _fetch(...args);
};
exports.resolveFetch = resolveFetch;
const resolveHeadersConstructor = () => {
if (typeof Headers === 'undefined') {
return node_fetch_1.Headers;
}
return Headers;
};
exports.resolveHeadersConstructor = resolveHeadersConstructor;
const fetchWithAuth = (supabaseKey, getAccessToken, customFetch) => {
const fetch = (0, exports.resolveFetch)(customFetch);
const HeadersConstructor = (0, exports.resolveHeadersConstructor)();
return (input, init) => __awaiter(void 0, void 0, void 0, function* () {
var _a;
const accessToken = (_a = (yield getAccessToken())) !== null && _a !== void 0 ? _a : supabaseKey;
let headers = new HeadersConstructor(init === null || init === void 0 ? void 0 : init.headers);
if (!headers.has('apikey')) {
headers.set('apikey', supabaseKey);
}
if (!headers.has('Authorization')) {
headers.set('Authorization', `Bearer ${accessToken}`);
}
return fetch(input, Object.assign(Object.assign({}, init), { headers }));
});
};
exports.fetchWithAuth = fetchWithAuth;
//# sourceMappingURL=fetch.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"fetch.js","sourceRoot":"","sources":["../../../src/lib/fetch.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,aAAa;AACb,mEAA6E;AAItE,MAAM,YAAY,GAAG,CAAC,WAAmB,EAAS,EAAE;IACzD,IAAI,MAAa,CAAA;IACjB,IAAI,WAAW,EAAE;QACf,MAAM,GAAG,WAAW,CAAA;KACrB;SAAM,IAAI,OAAO,KAAK,KAAK,WAAW,EAAE;QACvC,MAAM,GAAG,oBAA6B,CAAA;KACvC;SAAM;QACL,MAAM,GAAG,KAAK,CAAA;KACf;IACD,OAAO,CAAC,GAAG,IAAuB,EAAE,EAAE,CAAC,MAAM,CAAC,GAAG,IAAI,CAAC,CAAA;AACxD,CAAC,CAAA;AAVY,QAAA,YAAY,gBAUxB;AAEM,MAAM,yBAAyB,GAAG,GAAG,EAAE;IAC5C,IAAI,OAAO,OAAO,KAAK,WAAW,EAAE;QAClC,OAAO,oBAAgB,CAAA;KACxB;IAED,OAAO,OAAO,CAAA;AAChB,CAAC,CAAA;AANY,QAAA,yBAAyB,6BAMrC;AAEM,MAAM,aAAa,GAAG,CAC3B,WAAmB,EACnB,cAA4C,EAC5C,WAAmB,EACZ,EAAE;IACT,MAAM,KAAK,GAAG,IAAA,oBAAY,EAAC,WAAW,CAAC,CAAA;IACvC,MAAM,kBAAkB,GAAG,IAAA,iCAAyB,GAAE,CAAA;IAEtD,OAAO,CAAO,KAAK,EAAE,IAAI,EAAE,EAAE;;QAC3B,MAAM,WAAW,GAAG,MAAA,CAAC,MAAM,cAAc,EAAE,CAAC,mCAAI,WAAW,CAAA;QAC3D,IAAI,OAAO,GAAG,IAAI,kBAAkB,CAAC,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,OAAO,CAAC,CAAA;QAEnD,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,EAAE;YAC1B,OAAO,CAAC,GAAG,CAAC,QAAQ,EAAE,WAAW,CAAC,CAAA;SACnC;QAED,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,eAAe,CAAC,EAAE;YACjC,OAAO,CAAC,GAAG,CAAC,eAAe,EAAE,UAAU,WAAW,EAAE,CAAC,CAAA;SACtD;QAED,OAAO,KAAK,CAAC,KAAK,kCAAO,IAAI,KAAE,OAAO,IAAG,CAAA;IAC3C,CAAC,CAAA,CAAA;AACH,CAAC,CAAA;AAtBY,QAAA,aAAa,iBAsBzB"}

View File

@@ -0,0 +1,6 @@
import { SupabaseClientOptions } from './types';
export declare function uuid(): string;
export declare function ensureTrailingSlash(url: string): string;
export declare const isBrowser: () => boolean;
export declare function applySettingDefaults<Database = any, SchemaName extends string & keyof Database = 'public' extends keyof Database ? 'public' : string & keyof Database>(options: SupabaseClientOptions<SchemaName>, defaults: SupabaseClientOptions<any>): Required<SupabaseClientOptions<SchemaName>>;
//# sourceMappingURL=helpers.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../../src/lib/helpers.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAA;AAE/C,wBAAgB,IAAI,WAMnB;AAED,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAEvD;AAED,eAAO,MAAM,SAAS,eAAsC,CAAA;AAE5D,wBAAgB,oBAAoB,CAClC,QAAQ,GAAG,GAAG,EACd,UAAU,SAAS,MAAM,GAAG,MAAM,QAAQ,GAAG,QAAQ,SAAS,MAAM,QAAQ,GACxE,QAAQ,GACR,MAAM,GAAG,MAAM,QAAQ,EAE3B,OAAO,EAAE,qBAAqB,CAAC,UAAU,CAAC,EAC1C,QAAQ,EAAE,qBAAqB,CAAC,GAAG,CAAC,GACnC,QAAQ,CAAC,qBAAqB,CAAC,UAAU,CAAC,CAAC,CA8C7C"}

View File

@@ -0,0 +1,47 @@
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.applySettingDefaults = exports.isBrowser = exports.ensureTrailingSlash = exports.uuid = void 0;
function uuid() {
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
var r = (Math.random() * 16) | 0, v = c == 'x' ? r : (r & 0x3) | 0x8;
return v.toString(16);
});
}
exports.uuid = uuid;
function ensureTrailingSlash(url) {
return url.endsWith('/') ? url : url + '/';
}
exports.ensureTrailingSlash = ensureTrailingSlash;
const isBrowser = () => typeof window !== 'undefined';
exports.isBrowser = isBrowser;
function applySettingDefaults(options, defaults) {
var _a, _b;
const { db: dbOptions, auth: authOptions, realtime: realtimeOptions, global: globalOptions, } = options;
const { db: DEFAULT_DB_OPTIONS, auth: DEFAULT_AUTH_OPTIONS, realtime: DEFAULT_REALTIME_OPTIONS, global: DEFAULT_GLOBAL_OPTIONS, } = defaults;
const result = {
db: Object.assign(Object.assign({}, DEFAULT_DB_OPTIONS), dbOptions),
auth: Object.assign(Object.assign({}, DEFAULT_AUTH_OPTIONS), authOptions),
realtime: Object.assign(Object.assign({}, DEFAULT_REALTIME_OPTIONS), realtimeOptions),
global: Object.assign(Object.assign(Object.assign({}, DEFAULT_GLOBAL_OPTIONS), globalOptions), { headers: Object.assign(Object.assign({}, ((_a = DEFAULT_GLOBAL_OPTIONS === null || DEFAULT_GLOBAL_OPTIONS === void 0 ? void 0 : DEFAULT_GLOBAL_OPTIONS.headers) !== null && _a !== void 0 ? _a : {})), ((_b = globalOptions === null || globalOptions === void 0 ? void 0 : globalOptions.headers) !== null && _b !== void 0 ? _b : {})) }),
accessToken: () => __awaiter(this, void 0, void 0, function* () { return ''; }),
};
if (options.accessToken) {
result.accessToken = options.accessToken;
}
else {
// hack around Required<>
delete result.accessToken;
}
return result;
}
exports.applySettingDefaults = applySettingDefaults;
//# sourceMappingURL=helpers.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../../src/lib/helpers.ts"],"names":[],"mappings":";;;;;;;;;;;;AAGA,SAAgB,IAAI;IAClB,OAAO,sCAAsC,CAAC,OAAO,CAAC,OAAO,EAAE,UAAU,CAAC;QACxE,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,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OAAO,mCAAI,EAAE,CAAC,IAEpC;QACD,WAAW,EAAE,GAAS,EAAE,gDAAC,OAAA,EAAE,CAAA,GAAA;KAC5B,CAAA;IAED,IAAI,OAAO,CAAC,WAAW,EAAE;QACvB,MAAM,CAAC,WAAW,GAAG,OAAO,CAAC,WAAW,CAAA;KACzC;SAAM;QACL,yBAAyB;QACzB,OAAQ,MAAc,CAAC,WAAW,CAAA;KACnC;IAED,OAAO,MAAM,CAAA;AACf,CAAC;AAtDD,oDAsDC"}

View File

@@ -0,0 +1,115 @@
import { AuthClient } from '@supabase/auth-js';
import { RealtimeClientOptions } from '@supabase/realtime-js';
import { PostgrestError } from '@supabase/postgrest-js';
declare type AuthClientOptions = ConstructorParameters<typeof AuthClient>[0];
export interface SupabaseAuthClientOptions extends AuthClientOptions {
}
export declare type Fetch = typeof fetch;
export declare type SupabaseClientOptions<SchemaName> = {
/**
* The Postgres schema which your tables belong to. Must be on the list of exposed schemas in Supabase. Defaults to `public`.
*/
db?: {
schema?: SchemaName;
};
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.
*/
detectSessionInUrl?: boolean;
/**
* A storage provider. Used to store the logged-in session.
*/
storage?: SupabaseAuthClientOptions['storage'];
/**
* 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'];
};
/**
* Options passed to the realtime-js instance
*/
realtime?: RealtimeClientOptions;
global?: {
/**
* A custom `fetch` implementation.
*/
fetch?: Fetch;
/**
* Optional headers for initializing the client.
*/
headers?: Record<string, string>;
};
/**
* 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 client library. Note that this
* function may be called concurrently and many times. Use memoization and
* locking techniques if this is not supported by the client libraries.
*
* 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<string | null>;
};
export declare type GenericRelationship = {
foreignKeyName: string;
columns: string[];
isOneToOne?: boolean;
referencedRelation: string;
referencedColumns: string[];
};
export declare type GenericTable = {
Row: Record<string, unknown>;
Insert: Record<string, unknown>;
Update: Record<string, unknown>;
Relationships: GenericRelationship[];
};
export declare type GenericUpdatableView = GenericTable;
export declare type GenericNonUpdatableView = {
Row: Record<string, unknown>;
Relationships: GenericRelationship[];
};
export declare type GenericView = GenericUpdatableView | GenericNonUpdatableView;
export declare type GenericFunction = {
Args: Record<string, unknown>;
Returns: unknown;
};
export declare type GenericSchema = {
Tables: Record<string, GenericTable>;
Views: Record<string, GenericView>;
Functions: Record<string, GenericFunction>;
};
/**
* Helper types for query results.
*/
export declare type QueryResult<T> = T extends PromiseLike<infer U> ? U : never;
export declare type QueryData<T> = T extends PromiseLike<{
data: infer U;
}> ? Exclude<U, null> : never;
export declare type QueryError = PostgrestError;
export {};
//# sourceMappingURL=types.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/lib/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAA;AAC9C,OAAO,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAA;AAC7D,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAA;AAEvD,aAAK,iBAAiB,GAAG,qBAAqB,CAAC,OAAO,UAAU,CAAC,CAAC,CAAC,CAAC,CAAA;AAEpE,MAAM,WAAW,yBAA0B,SAAQ,i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appingURL=types.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/lib/types.ts"],"names":[],"mappings":""}

View File

@@ -0,0 +1,2 @@
export declare const version = "2.52.0";
//# sourceMappingURL=version.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../../../src/lib/version.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,OAAO,oBAAoB,CAAA"}

View File

@@ -0,0 +1,5 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.version = void 0;
exports.version = '2.52.0';
//# sourceMappingURL=version.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"version.js","sourceRoot":"","sources":["../../../src/lib/version.ts"],"names":[],"mappings":";;;AAAa,QAAA,OAAO,GAAG,iBAAiB,CAAA"}

View File

@@ -0,0 +1,118 @@
import { FunctionsClient } from '@supabase/functions-js';
import { PostgrestClient, PostgrestFilterBuilder, PostgrestQueryBuilder } from '@supabase/postgrest-js';
import { RealtimeChannel, RealtimeChannelOptions, RealtimeClient } from '@supabase/realtime-js';
import { StorageClient as SupabaseStorageClient } from '@supabase/storage-js';
import { SupabaseAuthClient } from './lib/SupabaseAuthClient';
import { Fetch, GenericSchema, SupabaseClientOptions } from './lib/types';
/**
* Supabase Client.
*
* An isomorphic Javascript client for interacting with Postgres.
*/
export default class SupabaseClient<Database = any, SchemaName extends string & keyof Database = 'public' extends keyof Database ? 'public' : string & keyof Database, Schema extends GenericSchema = Database[SchemaName] extends GenericSchema ? Database[SchemaName] : any> {
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;
protected realtimeUrl: URL;
protected authUrl: URL;
protected storageUrl: URL;
protected functionsUrl: URL;
protected rest: PostgrestClient<Database, SchemaName, Schema>;
protected storageKey: string;
protected fetch?: Fetch;
protected changedAccessToken?: string;
protected accessToken?: () => Promise<string | null>;
protected headers: Record<string, string>;
/**
* 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.global.fetch A custom fetch implementation.
* @param options.global.headers Any additional headers to send with each network request.
*/
constructor(supabaseUrl: string, supabaseKey: string, options?: SupabaseClientOptions<SchemaName>);
/**
* Supabase Functions allows you to deploy and invoke edge functions.
*/
get functions(): FunctionsClient;
/**
* Supabase Storage allows you to manage user-generated content, such as photos or videos.
*/
get storage(): SupabaseStorageClient;
from<TableName extends string & keyof Schema['Tables'], Table extends Schema['Tables'][TableName]>(relation: TableName): PostgrestQueryBuilder<Schema, Table, TableName>;
from<ViewName extends string & keyof Schema['Views'], View extends Schema['Views'][ViewName]>(relation: ViewName): PostgrestQueryBuilder<Schema, View, ViewName>;
/**
* 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<DynamicSchema extends string & keyof Database>(schema: DynamicSchema): PostgrestClient<Database, DynamicSchema, Database[DynamicSchema] extends GenericSchema ? Database[DynamicSchema] : any>;
/**
* 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<FnName extends string & keyof Schema['Functions'], Fn extends Schema['Functions'][FnName]>(fn: FnName, args?: Fn['Args'], options?: {
head?: boolean;
get?: boolean;
count?: 'exact' | 'planned' | 'estimated';
}): PostgrestFilterBuilder<Schema, Fn['Returns'] extends any[] ? Fn['Returns'][number] extends Record<string, unknown> ? Fn['Returns'][number] : never : never, Fn['Returns'], FnName, null>;
/**
* 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;
}
//# sourceMappingURL=SupabaseClient.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"SupabaseClient.d.ts","sourceRoot":"","sources":["../../src/SupabaseClient.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAA;AAExD,OAAO,EACL,eAAe,EACf,sBAAsB,EACtB,qBAAqB,EACtB,MAAM,wBAAwB,CAAA;AAC/B,OAAO,EACL,eAAe,EACf,sBAAsB,EACtB,cAAc,EAEf,MAAM,uBAAuB,CAAA;AAC9B,OAAO,EAAE,aAAa,IAAI,qBAAqB,EAAE,MAAM,sBAAsB,CAAA;AAS7E,OAAO,EAA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AAS,GAAG,EAAE,GACvB,EAAE,CAAC,SAAS,CAAC,CAAC,MAAM,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GACnD,EAAE,CAAC,SAAS,CAAC,CAAC,MAAM,CAAC,GACrB,KAAK,GACP,KAAK,EACT,EAAE,CAAC,SAAS,CAAC,EACb,MAAM,EACN,IAAI,CACL;IAID;;;;;;OAMG;IACH,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,GAAE,sBAAuC,GAAG,eAAe;IAIrF;;OAEG;IACH,WAAW,IAAI,eAAe,EAAE;IAIhC;;;;;OAKG;IACH,aAAa,CAAC,OAAO,EAAE,eAAe,GAAG,OAAO,CAAC,IAAI,GAAG,WAAW,GAAG,OAAO,CAAC;IAI9E;;OAEG;IACH,iBAAiB,IAAI,OAAO,CAAC,CAAC,IAAI,GAAG,WAAW,GAAG,OAAO,CAAC,EAAE,CAAC;YAIhD,eAAe;IAU7B,OAAO,CAAC,uBAAuB;IAoC/B,OAAO,CAAC,mBAAmB;IAO3B,OAAO,CAAC,oBAAoB;IAO5B,OAAO,CAAC,mBAAmB;CAgB5B"}

View File

@@ -0,0 +1,230 @@
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
import { FunctionsClient } from '@supabase/functions-js';
import { PostgrestClient, } from '@supabase/postgrest-js';
import { RealtimeClient, } from '@supabase/realtime-js';
import { StorageClient as SupabaseStorageClient } from '@supabase/storage-js';
import { DEFAULT_GLOBAL_OPTIONS, DEFAULT_DB_OPTIONS, DEFAULT_AUTH_OPTIONS, DEFAULT_REALTIME_OPTIONS, } from './lib/constants';
import { fetchWithAuth } from './lib/fetch';
import { ensureTrailingSlash, applySettingDefaults } from './lib/helpers';
import { SupabaseAuthClient } from './lib/SupabaseAuthClient';
/**
* Supabase Client.
*
* An isomorphic Javascript client for interacting with Postgres.
*/
export default class SupabaseClient {
/**
* 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.global.fetch A custom fetch implementation.
* @param options.global.headers Any additional headers to send with each network request.
*/
constructor(supabaseUrl, supabaseKey, options) {
var _a, _b, _c;
this.supabaseUrl = supabaseUrl;
this.supabaseKey = supabaseKey;
if (!supabaseUrl)
throw new Error('supabaseUrl is required.');
if (!supabaseKey)
throw new Error('supabaseKey is required.');
const _supabaseUrl = ensureTrailingSlash(supabaseUrl);
const baseUrl = new URL(_supabaseUrl);
this.realtimeUrl = new URL('realtime/v1', baseUrl);
this.realtimeUrl.protocol = this.realtimeUrl.protocol.replace('http', 'ws');
this.authUrl = new URL('auth/v1', baseUrl);
this.storageUrl = new URL('storage/v1', baseUrl);
this.functionsUrl = new URL('functions/v1', baseUrl);
// default storage key uses the supabase project ref as a namespace
const defaultStorageKey = `sb-${baseUrl.hostname.split('.')[0]}-auth-token`;
const DEFAULTS = {
db: DEFAULT_DB_OPTIONS,
realtime: DEFAULT_REALTIME_OPTIONS,
auth: Object.assign(Object.assign({}, DEFAULT_AUTH_OPTIONS), { storageKey: defaultStorageKey }),
global: DEFAULT_GLOBAL_OPTIONS,
};
const settings = applySettingDefaults(options !== null && options !== void 0 ? options : {}, DEFAULTS);
this.storageKey = (_a = settings.auth.storageKey) !== null && _a !== void 0 ? _a : '';
this.headers = (_b = settings.global.headers) !== null && _b !== void 0 ? _b : {};
if (!settings.accessToken) {
this.auth = this._initSupabaseAuthClient((_c = settings.auth) !== null && _c !== void 0 ? _c : {}, this.headers, settings.global.fetch);
}
else {
this.accessToken = settings.accessToken;
this.auth = new Proxy({}, {
get: (_, prop) => {
throw new Error(`@supabase/supabase-js: Supabase Client is configured with the accessToken option, accessing supabase.auth.${String(prop)} is not possible`);
},
});
}
this.fetch = fetchWithAuth(supabaseKey, this._getAccessToken.bind(this), settings.global.fetch);
this.realtime = this._initRealtimeClient(Object.assign({ headers: this.headers, accessToken: this._getAccessToken.bind(this) }, settings.realtime));
this.rest = new PostgrestClient(new URL('rest/v1', baseUrl).href, {
headers: this.headers,
schema: settings.db.schema,
fetch: this.fetch,
});
if (!settings.accessToken) {
this._listenForAuthEvents();
}
}
/**
* Supabase Functions allows you to deploy and invoke edge functions.
*/
get functions() {
return new FunctionsClient(this.functionsUrl.href, {
headers: this.headers,
customFetch: this.fetch,
});
}
/**
* Supabase Storage allows you to manage user-generated content, such as photos or videos.
*/
get storage() {
return new SupabaseStorageClient(this.storageUrl.href, this.headers, this.fetch);
}
/**
* Perform a query on a table or a view.
*
* @param relation - The table or view name to query
*/
from(relation) {
return this.rest.from(relation);
}
// NOTE: signatures must be kept in sync with PostgrestClient.schema
/**
* 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) {
return this.rest.schema(schema);
}
// NOTE: signatures must be kept in sync with PostgrestClient.rpc
/**
* 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, args = {}, options = {}) {
return this.rest.rpc(fn, args, options);
}
/**
* 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, opts = { config: {} }) {
return this.realtime.channel(name, opts);
}
/**
* Returns all Realtime channels.
*/
getChannels() {
return this.realtime.getChannels();
}
/**
* Unsubscribes and removes Realtime channel from Realtime client.
*
* @param {RealtimeChannel} channel - The name of the Realtime channel.
*
*/
removeChannel(channel) {
return this.realtime.removeChannel(channel);
}
/**
* Unsubscribes and removes all Realtime channels from Realtime client.
*/
removeAllChannels() {
return this.realtime.removeAllChannels();
}
_getAccessToken() {
var _a, _b;
return __awaiter(this, void 0, void 0, function* () {
if (this.accessToken) {
return yield this.accessToken();
}
const { data } = yield this.auth.getSession();
return (_b = (_a = data.session) === null || _a === void 0 ? void 0 : _a.access_token) !== null && _b !== void 0 ? _b : null;
});
}
_initSupabaseAuthClient({ autoRefreshToken, persistSession, detectSessionInUrl, storage, storageKey, flowType, lock, debug, }, headers, fetch) {
const authHeaders = {
Authorization: `Bearer ${this.supabaseKey}`,
apikey: `${this.supabaseKey}`,
};
return new SupabaseAuthClient({
url: this.authUrl.href,
headers: Object.assign(Object.assign({}, authHeaders), headers),
storageKey: storageKey,
autoRefreshToken,
persistSession,
detectSessionInUrl,
storage,
flowType,
lock,
debug,
fetch,
// auth checks if there is a custom authorizaiton header using this flag
// so it knows whether to return an error when getUser is called with no session
hasCustomAuthorizationHeader: 'Authorization' in this.headers,
});
}
_initRealtimeClient(options) {
return new RealtimeClient(this.realtimeUrl.href, Object.assign(Object.assign({}, options), { params: Object.assign({ apikey: this.supabaseKey }, options === null || options === void 0 ? void 0 : options.params) }));
}
_listenForAuthEvents() {
let data = this.auth.onAuthStateChange((event, session) => {
this._handleTokenChanged(event, 'CLIENT', session === null || session === void 0 ? void 0 : session.access_token);
});
return data;
}
_handleTokenChanged(event, source, token) {
if ((event === 'TOKEN_REFRESHED' || event === 'SIGNED_IN') &&
this.changedAccessToken !== token) {
this.changedAccessToken = token;
}
else if (event === 'SIGNED_OUT') {
this.realtime.setAuth();
if (source == 'STORAGE')
this.auth.signOut();
this.changedAccessToken = undefined;
}
}
}
//# sourceMappingURL=SupabaseClient.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,14 @@
import SupabaseClient from './SupabaseClient';
import type { GenericSchema, SupabaseClientOptions } from './lib/types';
export * from '@supabase/auth-js';
export type { User as AuthUser, Session as AuthSession } from '@supabase/auth-js';
export { type PostgrestResponse, type PostgrestSingleResponse, type PostgrestMaybeSingleResponse, PostgrestError, } from '@supabase/postgrest-js';
export { FunctionsHttpError, FunctionsFetchError, FunctionsRelayError, FunctionsError, type FunctionInvokeOptions, FunctionRegion, } from '@supabase/functions-js';
export * from '@supabase/realtime-js';
export { default as SupabaseClient } from './SupabaseClient';
export type { SupabaseClientOptions, QueryResult, QueryData, QueryError } from './lib/types';
/**
* Creates a new Supabase Client.
*/
export declare const createClient: <Database = any, SchemaName extends string & keyof Database = "public" extends keyof Database ? "public" : string & keyof Database, Schema extends GenericSchema = Database[SchemaName] extends GenericSchema ? Database[SchemaName] : any>(supabaseUrl: string, supabaseKey: string, options?: SupabaseClientOptions<SchemaName> | undefined) => SupabaseClient<Database, SchemaName, Schema>;
//# sourceMappingURL=index.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,cAAc,MAAM,kBAAkB,CAAA;AAC7C,OAAO,KAAK,EAAE,aAAa,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAA;AAEvE,cAAc,mBAAmB,CAAA;AACjC,YAAY,EAAE,IAAI,IAAI,QAAQ,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,mBAAmB,CAAA;AACjF,OAAO,EACL,KAAK,iBAAiB,EACtB,KAAK,uBAAuB,EAC5B,KAAK,4BAA4B,EACjC,cAAc,GACf,MAAM,wBAAwB,CAAA;AAC/B,OAAO,EACL,kBAAkB,EAClB,mBAAmB,EACnB,mBAAmB,EACnB,cAAc,EACd,KAAK,qBAAqB,EAC1B,cAAc,GACf,MAAM,wBAAwB,CAAA;AAC/B,cAAc,uBAAuB,CAAA;AACrC,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,kBAAkB,CAAA;AAC5D,YAAY,EAAE,qBAAqB,EAAE,WAAW,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAE5F;;GAEG;AACH,eAAO,MAAM,YAAY,2PASV,MAAM,eACN,MAAM,0GAIpB,CAAA"}

View File

@@ -0,0 +1,13 @@
import SupabaseClient from './SupabaseClient';
export * from '@supabase/auth-js';
export { PostgrestError, } from '@supabase/postgrest-js';
export { FunctionsHttpError, FunctionsFetchError, FunctionsRelayError, FunctionsError, FunctionRegion, } from '@supabase/functions-js';
export * from '@supabase/realtime-js';
export { default as SupabaseClient } from './SupabaseClient';
/**
* Creates a new Supabase Client.
*/
export const createClient = (supabaseUrl, supabaseKey, options) => {
return new SupabaseClient(supabaseUrl, supabaseKey, options);
};
//# sourceMappingURL=index.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,cAAc,MAAM,kBAAkB,CAAA;AAG7C,cAAc,mBAAmB,CAAA;AAEjC,OAAO,EAIL,cAAc,GACf,MAAM,wBAAwB,CAAA;AAC/B,OAAO,EACL,kBAAkB,EAClB,mBAAmB,EACnB,mBAAmB,EACnB,cAAc,EAEd,cAAc,GACf,MAAM,wBAAwB,CAAA;AAC/B,cAAc,uBAAuB,CAAA;AACrC,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,kBAAkB,CAAA;AAG5D;;GAEG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,CAS1B,WAAmB,EACnB,WAAmB,EACnB,OAA2C,EACG,EAAE;IAChD,OAAO,IAAI,cAAc,CAA+B,WAAW,EAAE,WAAW,EAAE,OAAO,CAAC,CAAA;AAC5F,CAAC,CAAA"}

View File

@@ -0,0 +1,6 @@
import { AuthClient } from '@supabase/auth-js';
import { SupabaseAuthClientOptions } from './types';
export declare class SupabaseAuthClient extends AuthClient {
constructor(options: SupabaseAuthClientOptions);
}
//# sourceMappingURL=SupabaseAuthClient.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"SupabaseAuthClient.d.ts","sourceRoot":"","sources":["../../../src/lib/SupabaseAuthClient.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAA;AAC9C,OAAO,EAAE,yBAAyB,EAAE,MAAM,SAAS,CAAA;AAEnD,qBAAa,kBAAmB,SAAQ,UAAU;gBACpC,OAAO,EAAE,yBAAyB;CAG/C"}

View File

@@ -0,0 +1,7 @@
import { AuthClient } from '@supabase/auth-js';
export class SupabaseAuthClient extends AuthClient {
constructor(options) {
super(options);
}
}
//# sourceMappingURL=SupabaseAuthClient.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"SupabaseAuthClient.js","sourceRoot":"","sources":["../../../src/lib/SupabaseAuthClient.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAA;AAG9C,MAAM,OAAO,kBAAmB,SAAQ,UAAU;IAChD,YAAY,OAAkC;QAC5C,KAAK,CAAC,OAAO,CAAC,CAAA;IAChB,CAAC;CACF"}

View File

@@ -0,0 +1,16 @@
import { RealtimeClientOptions } from '@supabase/realtime-js';
import { SupabaseAuthClientOptions } from './types';
export declare const DEFAULT_HEADERS: {
'X-Client-Info': string;
};
export declare const DEFAULT_GLOBAL_OPTIONS: {
headers: {
'X-Client-Info': string;
};
};
export declare const DEFAULT_DB_OPTIONS: {
schema: string;
};
export declare const DEFAULT_AUTH_OPTIONS: SupabaseAuthClientOptions;
export declare const DEFAULT_REALTIME_OPTIONS: RealtimeClientOptions;
//# sourceMappingURL=constants.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../src/lib/constants.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAA;AAC7D,OAAO,EAAE,yBAAyB,EAAE,MAAM,SAAS,CAAA;AAenD,eAAO,MAAM,eAAe;;CAA0D,CAAA;AAEtF,eAAO,MAAM,sBAAsB;;;;CAElC,CAAA;AAED,eAAO,MAAM,kBAAkB;;CAE9B,CAAA;AAED,eAAO,MAAM,oBAAoB,EAAE,yBAKlC,CAAA;AAED,eAAO,MAAM,wBAAwB,EAAE,qBAA0B,CAAA"}

View File

@@ -0,0 +1,30 @@
import { version } from './version';
let JS_ENV = '';
// @ts-ignore
if (typeof Deno !== 'undefined') {
JS_ENV = 'deno';
}
else if (typeof document !== 'undefined') {
JS_ENV = 'web';
}
else if (typeof navigator !== 'undefined' && navigator.product === 'ReactNative') {
JS_ENV = 'react-native';
}
else {
JS_ENV = 'node';
}
export const DEFAULT_HEADERS = { 'X-Client-Info': `supabase-js-${JS_ENV}/${version}` };
export const DEFAULT_GLOBAL_OPTIONS = {
headers: DEFAULT_HEADERS,
};
export const DEFAULT_DB_OPTIONS = {
schema: 'public',
};
export const DEFAULT_AUTH_OPTIONS = {
autoRefreshToken: true,
persistSession: true,
detectSessionInUrl: true,
flowType: 'implicit',
};
export const DEFAULT_REALTIME_OPTIONS = {};
//# sourceMappingURL=constants.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../src/lib/constants.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAEnC,IAAI,MAAM,GAAG,EAAE,CAAA;AACf,aAAa;AACb,IAAI,OAAO,IAAI,KAAK,WAAW,EAAE;IAC/B,MAAM,GAAG,MAAM,CAAA;CAChB;KAAM,IAAI,OAAO,QAAQ,KAAK,WAAW,EAAE;IAC1C,MAAM,GAAG,KAAK,CAAA;CACf;KAAM,IAAI,OAAO,SAAS,KAAK,WAAW,IAAI,SAAS,CAAC,OAAO,KAAK,aAAa,EAAE;IAClF,MAAM,GAAG,cAAc,CAAA;CACxB;KAAM;IACL,MAAM,GAAG,MAAM,CAAA;CAChB;AAED,MAAM,CAAC,MAAM,eAAe,GAAG,EAAE,eAAe,EAAE,eAAe,MAAM,IAAI,OAAO,EAAE,EAAE,CAAA;AAEtF,MAAM,CAAC,MAAM,sBAAsB,GAAG;IACpC,OAAO,EAAE,eAAe;CACzB,CAAA;AAED,MAAM,CAAC,MAAM,kBAAkB,GAAG;IAChC,MAAM,EAAE,QAAQ;CACjB,CAAA;AAED,MAAM,CAAC,MAAM,oBAAoB,GAA8B;IAC7D,gBAAgB,EAAE,IAAI;IACtB,cAAc,EAAE,IAAI;IACpB,kBAAkB,EAAE,IAAI;IACxB,QAAQ,EAAE,UAAU;CACrB,CAAA;AAED,MAAM,CAAC,MAAM,wBAAwB,GAA0B,EAAE,CAAA"}

View File

@@ -0,0 +1,6 @@
declare type Fetch = typeof fetch;
export declare const resolveFetch: (customFetch?: Fetch) => Fetch;
export declare const resolveHeadersConstructor: () => any;
export declare const fetchWithAuth: (supabaseKey: string, getAccessToken: () => Promise<string | null>, customFetch?: Fetch) => Fetch;
export {};
//# sourceMappingURL=fetch.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"fetch.d.ts","sourceRoot":"","sources":["../../../src/lib/fetch.ts"],"names":[],"mappings":"AAGA,aAAK,KAAK,GAAG,OAAO,KAAK,CAAA;AAEzB,eAAO,MAAM,YAAY,iBAAkB,KAAK,KAAG,KAUlD,CAAA;AAED,eAAO,MAAM,yBAAyB,WAMrC,CAAA;AAED,eAAO,MAAM,aAAa,gBACX,MAAM,kBACH,MAAM,QAAQ,MAAM,GAAG,IAAI,CAAC,gBAC9B,KAAK,KAClB,KAkBF,CAAA"}

View File

@@ -0,0 +1,47 @@
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
// @ts-ignore
import nodeFetch, { Headers as NodeFetchHeaders } from '@supabase/node-fetch';
export const resolveFetch = (customFetch) => {
let _fetch;
if (customFetch) {
_fetch = customFetch;
}
else if (typeof fetch === 'undefined') {
_fetch = nodeFetch;
}
else {
_fetch = fetch;
}
return (...args) => _fetch(...args);
};
export const resolveHeadersConstructor = () => {
if (typeof Headers === 'undefined') {
return NodeFetchHeaders;
}
return Headers;
};
export const fetchWithAuth = (supabaseKey, getAccessToken, customFetch) => {
const fetch = resolveFetch(customFetch);
const HeadersConstructor = resolveHeadersConstructor();
return (input, init) => __awaiter(void 0, void 0, void 0, function* () {
var _a;
const accessToken = (_a = (yield getAccessToken())) !== null && _a !== void 0 ? _a : supabaseKey;
let headers = new HeadersConstructor(init === null || init === void 0 ? void 0 : init.headers);
if (!headers.has('apikey')) {
headers.set('apikey', supabaseKey);
}
if (!headers.has('Authorization')) {
headers.set('Authorization', `Bearer ${accessToken}`);
}
return fetch(input, Object.assign(Object.assign({}, init), { headers }));
});
};
//# sourceMappingURL=fetch.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"fetch.js","sourceRoot":"","sources":["../../../src/lib/fetch.ts"],"names":[],"mappings":";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CAAC,EAAE;YACjC,OAAO,CAAC,GAAG,CAAC,eAAe,EAAE,UAAU,WAAW,EAAE,CAAC,CAAA;SACtD;QAED,OAAO,KAAK,CAAC,KAAK,kCAAO,IAAI,KAAE,OAAO,IAAG,CAAA;IAC3C,CAAC,CAAA,CAAA;AACH,CAAC,CAAA"}

View File

@@ -0,0 +1,6 @@
import { SupabaseClientOptions } from './types';
export declare function uuid(): string;
export declare function ensureTrailingSlash(url: string): string;
export declare const isBrowser: () => boolean;
export declare function applySettingDefaults<Database = any, SchemaName extends string & keyof Database = 'public' extends keyof Database ? 'public' : string & keyof Database>(options: SupabaseClientOptions<SchemaName>, defaults: SupabaseClientOptions<any>): Required<SupabaseClientOptions<SchemaName>>;
//# sourceMappingURL=helpers.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../../src/lib/helpers.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAA;AAE/C,wBAAgB,IAAI,WAMnB;AAED,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAEvD;AAED,eAAO,MAAM,SAAS,eAAsC,CAAA;AAE5D,wBAAgB,oBAAoB,CAClC,QAAQ,GAAG,GAAG,EACd,UAAU,SAAS,MAAM,GAAG,MAAM,QAAQ,GAAG,QAAQ,SAAS,MAAM,QAAQ,GACxE,QAAQ,GACR,MAAM,GAAG,MAAM,QAAQ,EAE3B,OAAO,EAAE,qBAAqB,CAAC,UAAU,CAAC,EAC1C,QAAQ,EAAE,qBAAqB,CAAC,GAAG,CAAC,GACnC,QAAQ,CAAC,qBAAqB,CAAC,UAAU,CAAC,CAAC,CA8C7C"}

View File

@@ -0,0 +1,40 @@
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
export function uuid() {
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
var r = (Math.random() * 16) | 0, v = c == 'x' ? r : (r & 0x3) | 0x8;
return v.toString(16);
});
}
export function ensureTrailingSlash(url) {
return url.endsWith('/') ? url : url + '/';
}
export const isBrowser = () => typeof window !== 'undefined';
export function applySettingDefaults(options, defaults) {
var _a, _b;
const { db: dbOptions, auth: authOptions, realtime: realtimeOptions, global: globalOptions, } = options;
const { db: DEFAULT_DB_OPTIONS, auth: DEFAULT_AUTH_OPTIONS, realtime: DEFAULT_REALTIME_OPTIONS, global: DEFAULT_GLOBAL_OPTIONS, } = defaults;
const result = {
db: Object.assign(Object.assign({}, DEFAULT_DB_OPTIONS), dbOptions),
auth: Object.assign(Object.assign({}, DEFAULT_AUTH_OPTIONS), authOptions),
realtime: Object.assign(Object.assign({}, DEFAULT_REALTIME_OPTIONS), realtimeOptions),
global: Object.assign(Object.assign(Object.assign({}, DEFAULT_GLOBAL_OPTIONS), globalOptions), { headers: Object.assign(Object.assign({}, ((_a = DEFAULT_GLOBAL_OPTIONS === null || DEFAULT_GLOBAL_OPTIONS === void 0 ? void 0 : DEFAULT_GLOBAL_OPTIONS.headers) !== null && _a !== void 0 ? _a : {})), ((_b = globalOptions === null || globalOptions === void 0 ? void 0 : globalOptions.headers) !== null && _b !== void 0 ? _b : {})) }),
accessToken: () => __awaiter(this, void 0, void 0, function* () { return ''; }),
};
if (options.accessToken) {
result.accessToken = options.accessToken;
}
else {
// hack around Required<>
delete result.accessToken;
}
return result;
}
//# sourceMappingURL=helpers.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../../src/lib/helpers.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AAsB,aAAtB,sBAAsB,uBAAtB,sBAAsB,CAAE,OAAO,mCAAI,EAAE,CAAC,GACvC,CAAC,MAAA,aAAa,aAAb,aAAa,uBAAb,aAAa,CAAE,OAAO,mCAAI,EAAE,CAAC,IAEpC;QACD,WAAW,EAAE,GAAS,EAAE,gDAAC,OAAA,EAAE,CAAA,GAAA;KAC5B,CAAA;IAED,IAAI,OAAO,CAAC,WAAW,EAAE;QACvB,MAAM,CAAC,WAAW,GAAG,OAAO,CAAC,WAAW,CAAA;KACzC;SAAM;QACL,yBAAyB;QACzB,OAAQ,MAAc,CAAC,WAAW,CAAA;KACnC;IAED,OAAO,MAAM,CAAA;AACf,CAAC"}

View File

@@ -0,0 +1,115 @@
import { AuthClient } from '@supabase/auth-js';
import { RealtimeClientOptions } from '@supabase/realtime-js';
import { PostgrestError } from '@supabase/postgrest-js';
declare type AuthClientOptions = ConstructorParameters<typeof AuthClient>[0];
export interface SupabaseAuthClientOptions extends AuthClientOptions {
}
export declare type Fetch = typeof fetch;
export declare type SupabaseClientOptions<SchemaName> = {
/**
* The Postgres schema which your tables belong to. Must be on the list of exposed schemas in Supabase. Defaults to `public`.
*/
db?: {
schema?: SchemaName;
};
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.
*/
detectSessionInUrl?: boolean;
/**
* A storage provider. Used to store the logged-in session.
*/
storage?: SupabaseAuthClientOptions['storage'];
/**
* 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'];
};
/**
* Options passed to the realtime-js instance
*/
realtime?: RealtimeClientOptions;
global?: {
/**
* A custom `fetch` implementation.
*/
fetch?: Fetch;
/**
* Optional headers for initializing the client.
*/
headers?: Record<string, string>;
};
/**
* 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 client library. Note that this
* function may be called concurrently and many times. Use memoization and
* locking techniques if this is not supported by the client libraries.
*
* 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<string | null>;
};
export declare type GenericRelationship = {
foreignKeyName: string;
columns: string[];
isOneToOne?: boolean;
referencedRelation: string;
referencedColumns: string[];
};
export declare type GenericTable = {
Row: Record<string, unknown>;
Insert: Record<string, unknown>;
Update: Record<string, unknown>;
Relationships: GenericRelationship[];
};
export declare type GenericUpdatableView = GenericTable;
export declare type GenericNonUpdatableView = {
Row: Record<string, unknown>;
Relationships: GenericRelationship[];
};
export declare type GenericView = GenericUpdatableView | GenericNonUpdatableView;
export declare type GenericFunction = {
Args: Record<string, unknown>;
Returns: unknown;
};
export declare type GenericSchema = {
Tables: Record<string, GenericTable>;
Views: Record<string, GenericView>;
Functions: Record<string, GenericFunction>;
};
/**
* Helper types for query results.
*/
export declare type QueryResult<T> = T extends PromiseLike<infer U> ? U : never;
export declare type QueryData<T> = T extends PromiseLike<{
data: infer U;
}> ? Exclude<U, null> : never;
export declare type QueryError = PostgrestError;
export {};
//# sourceMappingURL=types.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/lib/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAA;AAC9C,OAAO,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAA;AAC7D,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAA;AAEvD,aAA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A;AAC9F,oBAAY,UAAU,GAAG,cAAc,CAAA"}

View File

@@ -0,0 +1,2 @@
export {};
//# sourceMappingURL=types.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/lib/types.ts"],"names":[],"mappings":""}

View File

@@ -0,0 +1,2 @@
export declare const version = "2.52.0";
//# sourceMappingURL=version.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../../../src/lib/version.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,OAAO,oBAAoB,CAAA"}

View File

@@ -0,0 +1,2 @@
export const version = '2.52.0';
//# sourceMappingURL=version.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"version.js","sourceRoot":"","sources":["../../../src/lib/version.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,OAAO,GAAG,iBAAiB,CAAA"}

File diff suppressed because one or more lines are too long

90
node_modules/@supabase/supabase-js/package.json generated vendored Normal file
View File

@@ -0,0 +1,90 @@
{
"name": "@supabase/supabase-js",
"version": "2.52.0",
"description": "Isomorphic Javascript client for Supabase",
"keywords": [
"javascript",
"typescript",
"supabase"
],
"homepage": "https://github.com/supabase/supabase-js",
"bugs": "https://github.com/supabase/supabase-js/issues",
"license": "MIT",
"author": "Supabase",
"files": [
"dist",
"src"
],
"main": "dist/main/index.js",
"module": "dist/module/index.js",
"types": "dist/module/index.d.ts",
"sideEffects": false,
"repository": "supabase/supabase-js",
"scripts": {
"clean": "rimraf dist docs/v2",
"format": "prettier --write \"{src,test}/**/*.ts\"",
"build": "run-s clean format build:*",
"build:main": "tsc -p tsconfig.json",
"build:module": "tsc -p tsconfig.module.json",
"build:umd": "webpack --env mode=production",
"types-generate": "dts-gen -m '@supabase/supabase-js' -s",
"test": "run-s test:types test:run",
"test:all": "run-s test:types test:run test:integration test:integration:browser",
"test:run": "jest --runInBand --detectOpenHandles",
"test:unit": "jest --runInBand --detectOpenHandles test/unit",
"test:coverage": "jest --runInBand --coverage --testPathIgnorePatterns=\"test/integration|test/deno\"",
"test:integration": "jest --runInBand --detectOpenHandles test/integration.test.ts",
"test:integration:browser": "deno test --allow-all test/integration.browser.test.ts",
"test:watch": "jest --watch --verbose false --silent false",
"test:node:playwright": "cd test/integration/node-browser && npm install && cp ../../../dist/umd/supabase.js . && npm run test",
"test:bun": "cd test/integration/bun && bun install && bun test",
"test:types": "run-s build:module && tsd --files test/types/*.test-d.ts && jsr publish --dry-run",
"docs": "typedoc --entryPoints src/index.ts --out docs/v2 --includes src/**/*.ts",
"docs:json": "typedoc --entryPoints src/index.ts --includes src/**/*.ts --json docs/v2/spec.json --excludeExternals",
"serve:coverage": "npm run test:coverage && serve test/coverage",
"update:test-deps": "npm run build && npm pack && cp supabase-supabase-js-*.tgz test/integration/expo/supabase-supabase-js-0.0.0-automated.tgz && cp supabase-supabase-js-*.tgz test/integration/next/supabase-supabase-js-0.0.0-automated.tgz && cp supabase-supabase-js-*.tgz test/deno/supabase-supabase-js-0.0.0-automated.tgz && cp supabase-supabase-js-*.tgz test/integration/bun/supabase-supabase-js-0.0.0-automated.tgz && cd test/integration/expo && npm install && cd ../next && npm install --legacy-peer-deps && cd ../../deno && npm install && cd ../integration/bun && bun install",
"update:test-deps:expo": "npm run build && npm pack && cp supabase-supabase-js-*.tgz test/integration/expo/supabase-supabase-js-0.0.0-automated.tgz && cd test/integration/expo && npm install",
"update:test-deps:next": "npm run build && npm pack && cp supabase-supabase-js-*.tgz test/integration/next/supabase-supabase-js-0.0.0-automated.tgz && cd test/integration/next && npm install --legacy-peer-deps",
"update:test-deps:deno": "npm run build && npm pack && cp supabase-supabase-js-*.tgz test/deno/supabase-supabase-js-0.0.0-automated.tgz && cd test/deno && npm install",
"update:test-deps:bun": "npm run build && npm pack && cp supabase-supabase-js-*.tgz test/integration/bun/supabase-supabase-js-0.0.0-automated.tgz && cd test/integration/bun && bun install"
},
"dependencies": {
"@supabase/auth-js": "2.71.1",
"@supabase/functions-js": "2.4.5",
"@supabase/node-fetch": "2.6.15",
"@supabase/postgrest-js": "1.19.4",
"@supabase/realtime-js": "2.11.15",
"@supabase/storage-js": "2.7.1"
},
"devDependencies": {
"@sebbo2002/semantic-release-jsr": "^1.0.0",
"@solana/wallet-standard-features": "^1.3.0",
"@types/jest": "^29.2.5",
"husky": "^4.3.8",
"jest": "^29.3.1",
"jsr": "^0.13.5",
"npm-run-all": "^4.1.5",
"prettier": "^2.5.1",
"pretty-quick": "^3.1.3",
"puppeteer": "^24.9.0",
"rimraf": "^3.0.2",
"semantic-release-plugin-update-version-in-files": "^1.1.0",
"serve": "^14.2.1",
"ts-jest": "^29.0.5",
"ts-loader": "^8.0.11",
"ts-node": "^10.9.1",
"tsd": "^0.30.4",
"typedoc": "^0.22.16",
"typescript": "^4.5.5",
"webpack": "^5.69.1",
"webpack-cli": "^4.9.2"
},
"husky": {
"hooks": {
"pre-commit": "pretty-quick --staged"
}
},
"jsdelivr": "dist/umd/supabase.js",
"unpkg": "dist/umd/supabase.js",
"packageManager": "pnpm@10.11.0+sha512.6540583f41cc5f628eb3d9773ecee802f4f9ef9923cc45b69890fb47991d4b092964694ec3a4f738a420c918a333062c8b925d312f42e4f0c263eb603551f977"
}

View File

@@ -0,0 +1,347 @@
import { FunctionsClient } from '@supabase/functions-js'
import { AuthChangeEvent } from '@supabase/auth-js'
import {
PostgrestClient,
PostgrestFilterBuilder,
PostgrestQueryBuilder,
} from '@supabase/postgrest-js'
import {
RealtimeChannel,
RealtimeChannelOptions,
RealtimeClient,
RealtimeClientOptions,
} from '@supabase/realtime-js'
import { StorageClient as SupabaseStorageClient } from '@supabase/storage-js'
import {
DEFAULT_GLOBAL_OPTIONS,
DEFAULT_DB_OPTIONS,
DEFAULT_AUTH_OPTIONS,
DEFAULT_REALTIME_OPTIONS,
} from './lib/constants'
import { fetchWithAuth } from './lib/fetch'
import { ensureTrailingSlash, applySettingDefaults } from './lib/helpers'
import { SupabaseAuthClient } from './lib/SupabaseAuthClient'
import { Fetch, GenericSchema, SupabaseClientOptions, SupabaseAuthClientOptions } from './lib/types'
/**
* Supabase Client.
*
* An isomorphic Javascript client for interacting with Postgres.
*/
export default class SupabaseClient<
Database = any,
SchemaName extends string & keyof Database = 'public' extends keyof Database
? 'public'
: string & keyof Database,
Schema extends GenericSchema = Database[SchemaName] extends GenericSchema
? Database[SchemaName]
: any
> {
/**
* Supabase Auth allows you to create and manage user sessions for access to data that is secured by access policies.
*/
auth: SupabaseAuthClient
realtime: RealtimeClient
protected realtimeUrl: URL
protected authUrl: URL
protected storageUrl: URL
protected functionsUrl: URL
protected rest: PostgrestClient<Database, SchemaName, Schema>
protected storageKey: string
protected fetch?: Fetch
protected changedAccessToken?: string
protected accessToken?: () => Promise<string | null>
protected headers: Record<string, string>
/**
* 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.global.fetch A custom fetch implementation.
* @param options.global.headers Any additional headers to send with each network request.
*/
constructor(
protected supabaseUrl: string,
protected supabaseKey: string,
options?: SupabaseClientOptions<SchemaName>
) {
if (!supabaseUrl) throw new Error('supabaseUrl is required.')
if (!supabaseKey) throw new Error('supabaseKey is required.')
const _supabaseUrl = ensureTrailingSlash(supabaseUrl)
const baseUrl = new URL(_supabaseUrl)
this.realtimeUrl = new URL('realtime/v1', baseUrl)
this.realtimeUrl.protocol = this.realtimeUrl.protocol.replace('http', 'ws')
this.authUrl = new URL('auth/v1', baseUrl)
this.storageUrl = new URL('storage/v1', baseUrl)
this.functionsUrl = new URL('functions/v1', baseUrl)
// default storage key uses the supabase project ref as a namespace
const defaultStorageKey = `sb-${baseUrl.hostname.split('.')[0]}-auth-token`
const DEFAULTS = {
db: DEFAULT_DB_OPTIONS,
realtime: DEFAULT_REALTIME_OPTIONS,
auth: { ...DEFAULT_AUTH_OPTIONS, storageKey: defaultStorageKey },
global: DEFAULT_GLOBAL_OPTIONS,
}
const settings = applySettingDefaults(options ?? {}, DEFAULTS)
this.storageKey = settings.auth.storageKey ?? ''
this.headers = settings.global.headers ?? {}
if (!settings.accessToken) {
this.auth = this._initSupabaseAuthClient(
settings.auth ?? {},
this.headers,
settings.global.fetch
)
} else {
this.accessToken = settings.accessToken
this.auth = new Proxy<SupabaseAuthClient>({} as any, {
get: (_, prop) => {
throw new Error(
`@supabase/supabase-js: Supabase Client is configured with the accessToken option, accessing supabase.auth.${String(
prop
)} is not possible`
)
},
})
}
this.fetch = fetchWithAuth(supabaseKey, this._getAccessToken.bind(this), settings.global.fetch)
this.realtime = this._initRealtimeClient({
headers: this.headers,
accessToken: this._getAccessToken.bind(this),
...settings.realtime,
})
this.rest = new PostgrestClient(new URL('rest/v1', baseUrl).href, {
headers: this.headers,
schema: settings.db.schema,
fetch: this.fetch,
})
if (!settings.accessToken) {
this._listenForAuthEvents()
}
}
/**
* Supabase Functions allows you to deploy and invoke edge functions.
*/
get functions(): FunctionsClient {
return new FunctionsClient(this.functionsUrl.href, {
headers: this.headers,
customFetch: this.fetch,
})
}
/**
* Supabase Storage allows you to manage user-generated content, such as photos or videos.
*/
get storage(): SupabaseStorageClient {
return new SupabaseStorageClient(this.storageUrl.href, this.headers, this.fetch)
}
// NOTE: signatures must be kept in sync with PostgrestClient.from
from<
TableName extends string & keyof Schema['Tables'],
Table extends Schema['Tables'][TableName]
>(relation: TableName): PostgrestQueryBuilder<Schema, Table, TableName>
from<ViewName extends string & keyof Schema['Views'], View extends Schema['Views'][ViewName]>(
relation: ViewName
): PostgrestQueryBuilder<Schema, View, ViewName>
/**
* Perform a query on a table or a view.
*
* @param relation - The table or view name to query
*/
from(relation: string): PostgrestQueryBuilder<Schema, any, any> {
return this.rest.from(relation)
}
// NOTE: signatures must be kept in sync with PostgrestClient.schema
/**
* 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<DynamicSchema extends string & keyof Database>(
schema: DynamicSchema
): PostgrestClient<
Database,
DynamicSchema,
Database[DynamicSchema] extends GenericSchema ? Database[DynamicSchema] : any
> {
return this.rest.schema<DynamicSchema>(schema)
}
// NOTE: signatures must be kept in sync with PostgrestClient.rpc
/**
* 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<FnName extends string & keyof Schema['Functions'], Fn extends Schema['Functions'][FnName]>(
fn: FnName,
args: Fn['Args'] = {},
options: {
head?: boolean
get?: boolean
count?: 'exact' | 'planned' | 'estimated'
} = {}
): PostgrestFilterBuilder<
Schema,
Fn['Returns'] extends any[]
? Fn['Returns'][number] extends Record<string, unknown>
? Fn['Returns'][number]
: never
: never,
Fn['Returns'],
FnName,
null
> {
return this.rest.rpc(fn, args, options)
}
/**
* 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 = { config: {} }): RealtimeChannel {
return this.realtime.channel(name, opts)
}
/**
* Returns all Realtime channels.
*/
getChannels(): RealtimeChannel[] {
return this.realtime.getChannels()
}
/**
* 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'> {
return this.realtime.removeChannel(channel)
}
/**
* Unsubscribes and removes all Realtime channels from Realtime client.
*/
removeAllChannels(): Promise<('ok' | 'timed out' | 'error')[]> {
return this.realtime.removeAllChannels()
}
private async _getAccessToken() {
if (this.accessToken) {
return await this.accessToken()
}
const { data } = await this.auth.getSession()
return data.session?.access_token ?? null
}
private _initSupabaseAuthClient(
{
autoRefreshToken,
persistSession,
detectSessionInUrl,
storage,
storageKey,
flowType,
lock,
debug,
}: SupabaseAuthClientOptions,
headers?: Record<string, string>,
fetch?: Fetch
) {
const authHeaders = {
Authorization: `Bearer ${this.supabaseKey}`,
apikey: `${this.supabaseKey}`,
}
return new SupabaseAuthClient({
url: this.authUrl.href,
headers: { ...authHeaders, ...headers },
storageKey: storageKey,
autoRefreshToken,
persistSession,
detectSessionInUrl,
storage,
flowType,
lock,
debug,
fetch,
// auth checks if there is a custom authorizaiton header using this flag
// so it knows whether to return an error when getUser is called with no session
hasCustomAuthorizationHeader: 'Authorization' in this.headers,
})
}
private _initRealtimeClient(options: RealtimeClientOptions) {
return new RealtimeClient(this.realtimeUrl.href, {
...options,
params: { ...{ apikey: this.supabaseKey }, ...options?.params },
})
}
private _listenForAuthEvents() {
let data = this.auth.onAuthStateChange((event, session) => {
this._handleTokenChanged(event, 'CLIENT', session?.access_token)
})
return data
}
private _handleTokenChanged(
event: AuthChangeEvent,
source: 'CLIENT' | 'STORAGE',
token?: string
) {
if (
(event === 'TOKEN_REFRESHED' || event === 'SIGNED_IN') &&
this.changedAccessToken !== token
) {
this.changedAccessToken = token
} else if (event === 'SIGNED_OUT') {
this.realtime.setAuth()
if (source == 'STORAGE') this.auth.signOut()
this.changedAccessToken = undefined
}
}
}

41
node_modules/@supabase/supabase-js/src/index.ts generated vendored Normal file
View File

@@ -0,0 +1,41 @@
import SupabaseClient from './SupabaseClient'
import type { GenericSchema, SupabaseClientOptions } from './lib/types'
export * from '@supabase/auth-js'
export type { User as AuthUser, Session as AuthSession } from '@supabase/auth-js'
export {
type PostgrestResponse,
type PostgrestSingleResponse,
type PostgrestMaybeSingleResponse,
PostgrestError,
} from '@supabase/postgrest-js'
export {
FunctionsHttpError,
FunctionsFetchError,
FunctionsRelayError,
FunctionsError,
type FunctionInvokeOptions,
FunctionRegion,
} from '@supabase/functions-js'
export * from '@supabase/realtime-js'
export { default as SupabaseClient } from './SupabaseClient'
export type { SupabaseClientOptions, QueryResult, QueryData, QueryError } from './lib/types'
/**
* Creates a new Supabase Client.
*/
export const createClient = <
Database = any,
SchemaName extends string & keyof Database = 'public' extends keyof Database
? 'public'
: string & keyof Database,
Schema extends GenericSchema = Database[SchemaName] extends GenericSchema
? Database[SchemaName]
: any
>(
supabaseUrl: string,
supabaseKey: string,
options?: SupabaseClientOptions<SchemaName>
): SupabaseClient<Database, SchemaName, Schema> => {
return new SupabaseClient<Database, SchemaName, Schema>(supabaseUrl, supabaseKey, options)
}

View File

@@ -0,0 +1,8 @@
import { AuthClient } from '@supabase/auth-js'
import { SupabaseAuthClientOptions } from './types'
export class SupabaseAuthClient extends AuthClient {
constructor(options: SupabaseAuthClientOptions) {
super(options)
}
}

View File

@@ -0,0 +1,35 @@
// constants.ts
import { RealtimeClientOptions } from '@supabase/realtime-js'
import { SupabaseAuthClientOptions } from './types'
import { version } from './version'
let JS_ENV = ''
// @ts-ignore
if (typeof Deno !== 'undefined') {
JS_ENV = 'deno'
} else if (typeof document !== 'undefined') {
JS_ENV = 'web'
} else if (typeof navigator !== 'undefined' && navigator.product === 'ReactNative') {
JS_ENV = 'react-native'
} else {
JS_ENV = 'node'
}
export const DEFAULT_HEADERS = { 'X-Client-Info': `supabase-js-${JS_ENV}/${version}` }
export const DEFAULT_GLOBAL_OPTIONS = {
headers: DEFAULT_HEADERS,
}
export const DEFAULT_DB_OPTIONS = {
schema: 'public',
}
export const DEFAULT_AUTH_OPTIONS: SupabaseAuthClientOptions = {
autoRefreshToken: true,
persistSession: true,
detectSessionInUrl: true,
flowType: 'implicit',
}
export const DEFAULT_REALTIME_OPTIONS: RealtimeClientOptions = {}

48
node_modules/@supabase/supabase-js/src/lib/fetch.ts generated vendored Normal file
View File

@@ -0,0 +1,48 @@
// @ts-ignore
import nodeFetch, { Headers as NodeFetchHeaders } from '@supabase/node-fetch'
type Fetch = typeof fetch
export const resolveFetch = (customFetch?: Fetch): Fetch => {
let _fetch: Fetch
if (customFetch) {
_fetch = customFetch
} else if (typeof fetch === 'undefined') {
_fetch = nodeFetch as unknown as Fetch
} else {
_fetch = fetch
}
return (...args: Parameters<Fetch>) => _fetch(...args)
}
export const resolveHeadersConstructor = () => {
if (typeof Headers === 'undefined') {
return NodeFetchHeaders
}
return Headers
}
export const fetchWithAuth = (
supabaseKey: string,
getAccessToken: () => Promise<string | null>,
customFetch?: Fetch
): Fetch => {
const fetch = resolveFetch(customFetch)
const HeadersConstructor = resolveHeadersConstructor()
return async (input, init) => {
const accessToken = (await getAccessToken()) ?? supabaseKey
let headers = new HeadersConstructor(init?.headers)
if (!headers.has('apikey')) {
headers.set('apikey', supabaseKey)
}
if (!headers.has('Authorization')) {
headers.set('Authorization', `Bearer ${accessToken}`)
}
return fetch(input, { ...init, headers })
}
}

72
node_modules/@supabase/supabase-js/src/lib/helpers.ts generated vendored Normal file
View File

@@ -0,0 +1,72 @@
// helpers.ts
import { SupabaseClientOptions } from './types'
export function uuid() {
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
var r = (Math.random() * 16) | 0,
v = c == 'x' ? r : (r & 0x3) | 0x8
return v.toString(16)
})
}
export function ensureTrailingSlash(url: string): string {
return url.endsWith('/') ? url : url + '/'
}
export const isBrowser = () => typeof window !== 'undefined'
export function applySettingDefaults<
Database = any,
SchemaName extends string & keyof Database = 'public' extends keyof Database
? 'public'
: string & keyof Database
>(
options: SupabaseClientOptions<SchemaName>,
defaults: SupabaseClientOptions<any>
): Required<SupabaseClientOptions<SchemaName>> {
const {
db: dbOptions,
auth: authOptions,
realtime: realtimeOptions,
global: globalOptions,
} = options
const {
db: DEFAULT_DB_OPTIONS,
auth: DEFAULT_AUTH_OPTIONS,
realtime: DEFAULT_REALTIME_OPTIONS,
global: DEFAULT_GLOBAL_OPTIONS,
} = defaults
const result: Required<SupabaseClientOptions<SchemaName>> = {
db: {
...DEFAULT_DB_OPTIONS,
...dbOptions,
},
auth: {
...DEFAULT_AUTH_OPTIONS,
...authOptions,
},
realtime: {
...DEFAULT_REALTIME_OPTIONS,
...realtimeOptions,
},
global: {
...DEFAULT_GLOBAL_OPTIONS,
...globalOptions,
headers: {
...(DEFAULT_GLOBAL_OPTIONS?.headers ?? {}),
...(globalOptions?.headers ?? {}),
},
},
accessToken: async () => '',
}
if (options.accessToken) {
result.accessToken = options.accessToken
} else {
// hack around Required<>
delete (result as any).accessToken
}
return result
}

123
node_modules/@supabase/supabase-js/src/lib/types.ts generated vendored Normal file
View File

@@ -0,0 +1,123 @@
import { AuthClient } from '@supabase/auth-js'
import { RealtimeClientOptions } from '@supabase/realtime-js'
import { PostgrestError } from '@supabase/postgrest-js'
type AuthClientOptions = ConstructorParameters<typeof AuthClient>[0]
export interface SupabaseAuthClientOptions extends AuthClientOptions {}
export type Fetch = typeof fetch
export type SupabaseClientOptions<SchemaName> = {
/**
* The Postgres schema which your tables belong to. Must be on the list of exposed schemas in Supabase. Defaults to `public`.
*/
db?: {
schema?: SchemaName
}
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.
*/
detectSessionInUrl?: boolean
/**
* A storage provider. Used to store the logged-in session.
*/
storage?: SupabaseAuthClientOptions['storage']
/**
* 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']
}
/**
* Options passed to the realtime-js instance
*/
realtime?: RealtimeClientOptions
global?: {
/**
* A custom `fetch` implementation.
*/
fetch?: Fetch
/**
* Optional headers for initializing the client.
*/
headers?: Record<string, string>
}
/**
* 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 client library. Note that this
* function may be called concurrently and many times. Use memoization and
* locking techniques if this is not supported by the client libraries.
*
* 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<string | null>
}
export type GenericRelationship = {
foreignKeyName: string
columns: string[]
isOneToOne?: boolean
referencedRelation: string
referencedColumns: string[]
}
export type GenericTable = {
Row: Record<string, unknown>
Insert: Record<string, unknown>
Update: Record<string, unknown>
Relationships: GenericRelationship[]
}
export type GenericUpdatableView = GenericTable
export type GenericNonUpdatableView = {
Row: Record<string, unknown>
Relationships: GenericRelationship[]
}
export type GenericView = GenericUpdatableView | GenericNonUpdatableView
export type GenericFunction = {
Args: Record<string, unknown>
Returns: unknown
}
export type GenericSchema = {
Tables: Record<string, GenericTable>
Views: Record<string, GenericView>
Functions: Record<string, GenericFunction>
}
/**
* Helper types for query results.
*/
export type QueryResult<T> = T extends PromiseLike<infer U> ? U : never
export type QueryData<T> = T extends PromiseLike<{ data: infer U }> ? Exclude<U, null> : never
export type QueryError = PostgrestError

View File

@@ -0,0 +1 @@
export const version = '2.52.0'