@motherbase/client 1.3.1 → 1.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +284 -265
- package/dist/auth.d.ts +143 -14
- package/dist/auth.d.ts.map +1 -1
- package/dist/auth.js +317 -14
- package/dist/auth.js.map +1 -1
- package/dist/channel.d.ts +15 -12
- package/dist/channel.d.ts.map +1 -1
- package/dist/channel.js.map +1 -1
- package/dist/compat.d.ts +40 -0
- package/dist/compat.d.ts.map +1 -0
- package/dist/compat.js +98 -0
- package/dist/compat.js.map +1 -0
- package/dist/cookie.d.ts +10 -2
- package/dist/cookie.d.ts.map +1 -1
- package/dist/cookie.js +13 -5
- package/dist/cookie.js.map +1 -1
- package/dist/database.d.ts +20 -1
- package/dist/database.d.ts.map +1 -1
- package/dist/functions.d.ts +36 -0
- package/dist/functions.d.ts.map +1 -1
- package/dist/functions.js +56 -5
- package/dist/functions.js.map +1 -1
- package/dist/http.d.ts +27 -0
- package/dist/http.d.ts.map +1 -1
- package/dist/http.js +57 -9
- package/dist/http.js.map +1 -1
- package/dist/index.d.ts +72 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +163 -12
- package/dist/index.js.map +1 -1
- package/dist/postgrest.d.ts +88 -1
- package/dist/postgrest.d.ts.map +1 -1
- package/dist/postgrest.js +179 -17
- package/dist/postgrest.js.map +1 -1
- package/dist/query.d.ts +97 -0
- package/dist/query.d.ts.map +1 -0
- package/dist/query.js +94 -0
- package/dist/query.js.map +1 -0
- package/dist/session.d.ts +12 -1
- package/dist/session.d.ts.map +1 -1
- package/dist/session.js +49 -3
- package/dist/session.js.map +1 -1
- package/dist/storage.d.ts +172 -5
- package/dist/storage.d.ts.map +1 -1
- package/dist/storage.js +249 -6
- package/dist/storage.js.map +1 -1
- package/dist/testing.d.ts +38 -0
- package/dist/testing.d.ts.map +1 -0
- package/dist/testing.js +50 -0
- package/dist/testing.js.map +1 -0
- package/dist/types.d.ts +257 -20
- package/dist/types.d.ts.map +1 -1
- package/dist/warn.d.ts +4 -0
- package/dist/warn.d.ts.map +1 -0
- package/dist/warn.js +27 -0
- package/dist/warn.js.map +1 -0
- package/package.json +10 -2
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { RequestObserver } from './http.js';
|
|
2
|
+
import { memoryStorage, localStorageStorage, keyValueStorage } from './session.js';
|
|
2
3
|
import { AuthClient } from './auth.js';
|
|
3
4
|
import { StorageClient } from './storage.js';
|
|
4
5
|
import { FunctionsClient } from './functions.js';
|
|
@@ -6,6 +7,17 @@ import { RealtimeModule } from './realtime.js';
|
|
|
6
7
|
import { RealtimeChannel, type RealtimeChannelOptions } from './channel.js';
|
|
7
8
|
import type { PostgrestCount, PostgrestResponse } from './postgrest.js';
|
|
8
9
|
import type { ClientOptions } from './types.js';
|
|
10
|
+
/**
|
|
11
|
+
* What the `client.transaction()` callback is handed.
|
|
12
|
+
*
|
|
13
|
+
* Typed loosely on purpose: the relation names come from the generated
|
|
14
|
+
* `Database` on `client.from()`, and reproducing that overload pair here for a
|
|
15
|
+
* callback that returns nothing buys inference no one reads at the cost of a
|
|
16
|
+
* signature nobody can follow.
|
|
17
|
+
*/
|
|
18
|
+
export interface TransactionContext {
|
|
19
|
+
from<Row extends object = Record<string, unknown>>(table: string): TypedQuery<Row, Partial<Row>, Partial<Row>>;
|
|
20
|
+
}
|
|
9
21
|
/** Options for `client.rpc(fn, args, options)`, mirroring supabase-js. */
|
|
10
22
|
export interface RpcOptions {
|
|
11
23
|
/** Send the request as HEAD: no rows, only the count. */
|
|
@@ -40,6 +52,9 @@ export declare class MotherbaseClient<Database = GenericDatabase, SchemaName = D
|
|
|
40
52
|
private readonly store;
|
|
41
53
|
private readonly channels;
|
|
42
54
|
private static warnedAboutStorage;
|
|
55
|
+
/** `options.compat === 'supabase'`, read by every query builder this client makes. */
|
|
56
|
+
private readonly compat;
|
|
57
|
+
private readonly requestObservers;
|
|
43
58
|
constructor(url: string,
|
|
44
59
|
/** Accepted for supabase-js signature parity; sent as an `apikey` header when set. */
|
|
45
60
|
key?: string | undefined, options?: ClientOptions);
|
|
@@ -66,8 +81,58 @@ export declare class MotherbaseClient<Database = GenericDatabase, SchemaName = D
|
|
|
66
81
|
* as query parameters rather than as a body, exactly as supabase-js does.
|
|
67
82
|
*/
|
|
68
83
|
rpc<Name extends FunctionName<Schema>>(fn: Name, args?: FunctionArgs<Schema, Name>, options?: RpcOptions): Promise<PostgrestResponse<FunctionReturns<Schema, Name>>>;
|
|
84
|
+
/**
|
|
85
|
+
* Watch every HTTP request this client makes.
|
|
86
|
+
*
|
|
87
|
+
* One event per round trip, with method, path, status, duration and the
|
|
88
|
+
* `x-request-id` the server logged it under. That id is the whole point: it
|
|
89
|
+
* is what turns "a query was slow for a user yesterday" into a line in the
|
|
90
|
+
* project's logs.
|
|
91
|
+
*
|
|
92
|
+
* ```ts
|
|
93
|
+
* client.on('request', e => console.log(e.method, e.path, e.status, e.durationMs))
|
|
94
|
+
* ```
|
|
95
|
+
*
|
|
96
|
+
* Returns the unsubscribe function. An observer that throws is ignored: it is
|
|
97
|
+
* a spectator, and a broken logger must not fail the request it was logging.
|
|
98
|
+
*/
|
|
99
|
+
on(event: 'request', listener: RequestObserver): () => void;
|
|
100
|
+
private syncRequestObserver;
|
|
101
|
+
/**
|
|
102
|
+
* Several writes, applied in one database transaction, all or nothing.
|
|
103
|
+
*
|
|
104
|
+
* supabase-js has no equivalent. What people write instead is a sequence of
|
|
105
|
+
* awaited writes inside a `try`, which is not a rollback: whatever already
|
|
106
|
+
* committed stays committed, and the catch block is left holding half a
|
|
107
|
+
* change it cannot undo.
|
|
108
|
+
*
|
|
109
|
+
* The callback does not await anything. It DESCRIBES the writes; they are
|
|
110
|
+
* sent together and applied together:
|
|
111
|
+
*
|
|
112
|
+
* ```ts
|
|
113
|
+
* const { data, error } = await client.transaction(tx => {
|
|
114
|
+
* tx.from('orders').insert({ id, total })
|
|
115
|
+
* tx.from('stock').update({ count: 4 }).eq('sku', sku)
|
|
116
|
+
* })
|
|
117
|
+
* ```
|
|
118
|
+
*
|
|
119
|
+
* `data` is one result array per operation, in the order they were declared.
|
|
120
|
+
* Reads are refused: a batch exists to make writes atomic, and a read in the
|
|
121
|
+
* middle of one invites expectations about ordering that nothing guarantees.
|
|
122
|
+
*/
|
|
123
|
+
transaction(build: (tx: TransactionContext) => void): Promise<PostgrestResponse<unknown[][]>>;
|
|
69
124
|
/** Create (or reuse) a realtime channel. */
|
|
70
125
|
channel(name: string, opts?: RealtimeChannelOptions): RealtimeChannel;
|
|
126
|
+
/** Every channel this client created, as supabase-js reports them. */
|
|
127
|
+
getChannels(): RealtimeChannel[];
|
|
128
|
+
/**
|
|
129
|
+
* supabase-js's schema switcher.
|
|
130
|
+
*
|
|
131
|
+
* The Motherbase REST layer serves `public` and nothing else, so this returns
|
|
132
|
+
* the client for `'public'` and throws for anything else rather than issuing
|
|
133
|
+
* a request that would silently read the wrong tables.
|
|
134
|
+
*/
|
|
135
|
+
schema(name: string): this;
|
|
71
136
|
/** Unsubscribe and drop a channel. */
|
|
72
137
|
removeChannel(channel: RealtimeChannel): Promise<'ok'>;
|
|
73
138
|
/** Unsubscribe and drop every channel. */
|
|
@@ -95,9 +160,11 @@ export declare class MotherbaseClient<Database = GenericDatabase, SchemaName = D
|
|
|
95
160
|
*/
|
|
96
161
|
export declare function createClient<Database = GenericDatabase, SchemaName = DefaultSchemaName<Database>, Schema extends GenericSchema = SchemaOf<Database, SchemaName>>(url: string, key?: string, options?: ClientOptions): MotherbaseClient<Database, SchemaName, Schema>;
|
|
97
162
|
export { BackendError } from './http.js';
|
|
98
|
-
export { memoryStorage, localStorageStorage };
|
|
163
|
+
export { memoryStorage, localStorageStorage, keyValueStorage };
|
|
164
|
+
export { normalizeSession, normalizeUser } from './compat.js';
|
|
99
165
|
export { cookieStorage, serverCookieStorage, SESSION_COOKIE_KEY } from './cookie.js';
|
|
100
166
|
export { PostgrestQueryBuilder } from './postgrest.js';
|
|
167
|
+
export type { RequestEvent, RequestObserver } from './http.js';
|
|
101
168
|
export type { PostgrestSingleBuilder, PostgrestTextBuilder, PostgrestExplainBuilder, PostgrestResponse, PostgrestPrimitive, PostgrestArrayOperand, PostgrestFilterOperator, PostgrestIsValue, PostgrestCount, TextSearchType, ReferencedTableOption, OrderOptions, SelectOptions, InsertOptions, UpsertOptions, MutateOptions, ExplainOptions, } from './postgrest.js';
|
|
102
169
|
export type { GenericDatabase, GenericSchema, GenericTable, GenericView, GenericFunction, DefaultSchemaName, SchemaOf, Relations, RelationName, RowOf, InsertOf, UpdateOf, FunctionName, FunctionArgs, FunctionReturns, TypedQuery, TypedSingleQuery, SelectResult, ValidateSelect, UnknownSelectColumns, EmbeddedSelectSeam, ColumnName, FilterValue, } from './database.js';
|
|
103
170
|
export { AuthClient } from './auth.js';
|
|
@@ -107,12 +174,12 @@ export type { AdminListUsersParams, AdminUserList, AdminCreateUserParams, AdminC
|
|
|
107
174
|
export type { MfaFactor, MfaEnrollResponse, MfaChallengeResponse } from './mfa.js';
|
|
108
175
|
export type { SignUpCredentials, SignInWithPasswordCredentials, SignInWithOtpCredentials, VerifyOtpParams, SignInWithOAuthCredentials, UpdateUserAttributes, DeleteUserAttributes, Subscription, } from './auth.js';
|
|
109
176
|
export { StorageClient, StorageBucket } from './storage.js';
|
|
110
|
-
export type { UploadOptions, UploadResult } from './storage.js';
|
|
111
|
-
export { FunctionsClient } from './functions.js';
|
|
177
|
+
export type { UploadOptions, UploadResult, ObjectInfo, ListOptions, BucketInfo } from './storage.js';
|
|
178
|
+
export { FunctionsClient, FunctionsError, FunctionsHttpError, FunctionsRelayError, FunctionsFetchError } from './functions.js';
|
|
112
179
|
export type { FunctionInvokeAuth, FunctionInvokeOptions } from './functions.js';
|
|
113
180
|
export { RealtimeChannel } from './channel.js';
|
|
114
181
|
export type { PostgresChangeEvent, PostgresChangeFilter, PostgresChangePayload, ChannelStatus, BroadcastFilter, PresenceFilter, BroadcastMessage, BroadcastReceived, RealtimeChannelOptions, PresenceEntry, PresenceState, PresenceJoinPayload, PresenceLeavePayload, } from './channel.js';
|
|
115
182
|
export type { CookieMethods, CookieToSet, CookieOptions } from './cookie.js';
|
|
116
|
-
export type { ApiEnvelope, User, Tokens, Session, FileObject, FileVisibility, StorageUploadResponse, StorageRemoveResponse, UploadInput, SessionStorageAdapter, ClientOptions, MotherbaseResponse, MotherbaseError, AuthChangeEvent, AuthChangeListener, } from './types.js';
|
|
183
|
+
export type { ApiEnvelope, User, UserIdentity, UserMetadata, BetterAuthUserFields, MotherbaseUserFields, SupabaseUserAliases, Timestamp, Tokens, Session, FileObject, StoredFile, FileStatus, FileVisibility, StorageUploadResponse, StorageRemoveResponse, UploadInput, SessionStorageAdapter, ClientOptions, SupabaseStyleOptions, KeyValueStorageAdapter, MotherbaseResponse, MotherbaseError, AuthChangeEvent, AuthChangeListener, } from './types.js';
|
|
117
184
|
export type { RealtimeConnectOptions, RealtimeStatus, RealtimeStatusListener, RealtimeWatchEvent, RealtimeWatchOptions, IoFactory, SocketLike, } from './realtime.js';
|
|
118
185
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAgB,eAAe,EAAE,MAAM,WAAW,CAAC;AAE/D,OAAO,EAAgB,aAAa,EAAE,mBAAmB,EAAE,eAAe,EAAqB,MAAM,cAAc,CAAC;AACpH,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AACvC,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAC7C,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AACjD,OAAO,EAAE,cAAc,E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E,MAAM,cAAc,CAAC;AAC5D,YAAY,EAAE,aAAa,EAAE,YAAY,EAAE,UAAU,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AACrG,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAC/H,YAAY,EAAE,kBAAkB,EAAE,qBAAqB,EAAE,MAAM,gBAAgB,CAAC;AAChF,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAC/C,YAAY,EACV,mBAAmB,EACnB,oBAAoB,EACpB,qBAAqB,EACrB,aAAa,EACb,eAAe,EACf,cAAc,EACd,gBAAgB,EAChB,iBAAiB,EACjB,sBAAsB,EACtB,aAAa,EACb,aAAa,EACb,mBAAmB,EACnB,oBAAoB,GACrB,MAAM,cAAc,CAAC;AACtB,YAAY,EAAE,aAAa,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC7E,YAAY,EACV,WAAW,EACX,IAAI,EACJ,YAAY,EACZ,YAAY,EACZ,oBAAoB,EACpB,oBAAoB,EACpB,mBAAmB,EACnB,SAAS,EACT,MAAM,EACN,OAAO,EACP,UAAU,EACV,UAAU,EACV,UAAU,EACV,cAAc,EACd,qBAAqB,EACrB,qBAAqB,EACrB,WAAW,EACX,qBAAqB,EACrB,aAAa,EACb,oBAAoB,EACpB,sBAAsB,EACtB,kBAAkB,EAClB,eAAe,EACf,eAAe,EACf,kBAAkB,GACnB,MAAM,YAAY,CAAC;AACpB,YAAY,EACV,sBAAsB,EACtB,cAAc,EACd,sBAAsB,EACtB,kBAAkB,EAClB,oBAAoB,EACpB,SAAS,EACT,UAAU,GACX,MAAM,eAAe,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { HttpClient, toError } from './http.js';
|
|
2
2
|
import { contractPath } from '@motherbase/contracts';
|
|
3
|
-
import { SessionStore, memoryStorage, localStorageStorage } from './session.js';
|
|
3
|
+
import { SessionStore, memoryStorage, localStorageStorage, keyValueStorage, isKeyValueStorage } from './session.js';
|
|
4
4
|
import { AuthClient } from './auth.js';
|
|
5
5
|
import { StorageClient } from './storage.js';
|
|
6
6
|
import { FunctionsClient } from './functions.js';
|
|
@@ -8,6 +8,29 @@ import { RealtimeModule } from './realtime.js';
|
|
|
8
8
|
import { RealtimeChannel } from './channel.js';
|
|
9
9
|
import { PostgrestQueryBuilder } from './postgrest.js';
|
|
10
10
|
import { isProduction } from './cookie.js';
|
|
11
|
+
/**
|
|
12
|
+
* Pick the session storage from either options shape.
|
|
13
|
+
*
|
|
14
|
+
* Precedence: the native `storage` (explicit and already the right shape), then
|
|
15
|
+
* supabase-js's `auth.storage` (wrapped if it is a key/value store), then
|
|
16
|
+
* `auth.persistSession` on its own, which in supabase-js means localStorage.
|
|
17
|
+
* Returns `undefined` when nothing was asked for, so the caller can tell "no
|
|
18
|
+
* choice made" from "memory was chosen" and warn accordingly.
|
|
19
|
+
*/
|
|
20
|
+
function resolveStorage(options) {
|
|
21
|
+
if (options.storage)
|
|
22
|
+
return options.storage;
|
|
23
|
+
const key = options.auth?.storageKey;
|
|
24
|
+
const provided = options.auth?.storage;
|
|
25
|
+
if (provided) {
|
|
26
|
+
return isKeyValueStorage(provided) ? keyValueStorage(provided, key) : provided;
|
|
27
|
+
}
|
|
28
|
+
if (options.auth?.persistSession === true)
|
|
29
|
+
return localStorageStorage(key);
|
|
30
|
+
if (options.auth?.persistSession === false)
|
|
31
|
+
return memoryStorage();
|
|
32
|
+
return undefined;
|
|
33
|
+
}
|
|
11
34
|
/**
|
|
12
35
|
* Supabase-js-compatible client for a Motherbase backend.
|
|
13
36
|
*
|
|
@@ -27,18 +50,29 @@ export class MotherbaseClient {
|
|
|
27
50
|
this.url = url;
|
|
28
51
|
this.key = key;
|
|
29
52
|
this.channels = new Map();
|
|
53
|
+
this.requestObservers = new Set();
|
|
30
54
|
// `globalThis.fetch` is a native function that requires `this === window`
|
|
31
|
-
// (or an equivalent global) when invoked
|
|
55
|
+
// (or an equivalent global) when invoked: copying the reference without
|
|
32
56
|
// binding it throws "Illegal invocation" the moment it's called as
|
|
33
57
|
// `this.opts.fetch(...)` inside HttpClient. Bind it once here.
|
|
34
|
-
const fetchImpl = options.fetch ?? globalThis.fetch?.bind(globalThis);
|
|
58
|
+
const fetchImpl = options.fetch ?? options.global?.fetch ?? globalThis.fetch?.bind(globalThis);
|
|
35
59
|
if (!fetchImpl) {
|
|
36
60
|
throw new Error('No fetch implementation found. Pass `fetch` in options for this runtime.');
|
|
37
61
|
}
|
|
38
|
-
const autoRefresh = options.autoRefresh ?? true;
|
|
39
|
-
const headers = { ...options.headers };
|
|
62
|
+
const autoRefresh = options.autoRefresh ?? options.auth?.autoRefreshToken ?? true;
|
|
63
|
+
const headers = { ...options.global?.headers, ...options.headers };
|
|
40
64
|
if (key)
|
|
41
65
|
headers['apikey'] = key;
|
|
66
|
+
this.compat = options.compat === 'supabase';
|
|
67
|
+
// Only `public` is exposed by the REST layer. A ported app that asked for
|
|
68
|
+
// another schema would otherwise read `public` under a different name and
|
|
69
|
+
// find the wrong rows (or none), which is far harder to diagnose than the
|
|
70
|
+
// error it gets here.
|
|
71
|
+
const schema = options.db?.schema;
|
|
72
|
+
if (schema && schema !== 'public') {
|
|
73
|
+
throw new Error(`db.schema: '${schema}' is not exposed. The Motherbase REST API serves the public schema only. `
|
|
74
|
+
+ 'Move the tables to public, or expose them through a view or an RPC.');
|
|
75
|
+
}
|
|
42
76
|
// A secret key runs every request as service_role, which bypasses row level
|
|
43
77
|
// security. In a browser it is readable by anyone who opens devtools, so it
|
|
44
78
|
// is not "a key that leaked", it is the whole database published. Warn
|
|
@@ -50,12 +84,13 @@ export class MotherbaseClient {
|
|
|
50
84
|
+ 'Secret keys bypass row level security and must stay server side. '
|
|
51
85
|
+ 'Use the publishable key here.');
|
|
52
86
|
}
|
|
87
|
+
const storageAdapter = resolveStorage(options);
|
|
53
88
|
// The default adapter keeps the session in memory only: it does not survive
|
|
54
89
|
// a reload, and the server never sees it. That is the right default for a
|
|
55
|
-
// script or a test, and a bug in a browser app
|
|
90
|
+
// script or a test, and a bug in a browser app, and it presents as
|
|
56
91
|
// "getUser() returns null everywhere", which reads like an auth problem
|
|
57
92
|
// rather than a storage one. Point at the fix once, in development.
|
|
58
|
-
if (!
|
|
93
|
+
if (!storageAdapter && typeof window !== 'undefined' && !MotherbaseClient.warnedAboutStorage) {
|
|
59
94
|
MotherbaseClient.warnedAboutStorage = true;
|
|
60
95
|
if (!isProduction()) {
|
|
61
96
|
console.warn('[motherbase] createClient() was called in a browser without a `storage` adapter, so the '
|
|
@@ -64,7 +99,7 @@ export class MotherbaseClient {
|
|
|
64
99
|
+ 'writes the cookie the server needs to read.');
|
|
65
100
|
}
|
|
66
101
|
}
|
|
67
|
-
this.store = new SessionStore(
|
|
102
|
+
this.store = new SessionStore(storageAdapter ?? memoryStorage());
|
|
68
103
|
// auth needs the http client, and http needs auth._refresh for the 401 path,
|
|
69
104
|
// so wire them in two steps with a late-bound refresh callback.
|
|
70
105
|
// prefer-const cannot see the closure above: `auth` is read by the refresh
|
|
@@ -74,12 +109,22 @@ export class MotherbaseClient {
|
|
|
74
109
|
this.http = new HttpClient(url, this.store, { autoRefresh, fetch: fetchImpl, headers }, () => auth._refresh());
|
|
75
110
|
auth = new AuthClient(this.http, this.store);
|
|
76
111
|
this.auth = auth;
|
|
77
|
-
this.storage = new StorageClient(this.http, url);
|
|
112
|
+
this.storage = new StorageClient(this.http, url, fetchImpl);
|
|
78
113
|
this.functions = new FunctionsClient(this.http);
|
|
79
114
|
this.realtime = new RealtimeModule(url, this.store, fetchImpl, options.realtimeIoFactory);
|
|
115
|
+
// supabase-js finishes an OAuth redirect on its own (detectSessionInUrl
|
|
116
|
+
// defaults to true), so ported code never calls anything after the provider
|
|
117
|
+
// sends the browser back. Do the same, and only when there is actually a
|
|
118
|
+
// token in the fragment: on every other page load this is a no-op with no
|
|
119
|
+
// network call. Opt out with `auth: { detectSessionInUrl: false }`.
|
|
120
|
+
if (options.auth?.detectSessionInUrl !== false
|
|
121
|
+
&& typeof window !== 'undefined'
|
|
122
|
+
&& window.location?.hash?.includes('access_token=')) {
|
|
123
|
+
void this.auth.getSessionFromUrl();
|
|
124
|
+
}
|
|
80
125
|
}
|
|
81
126
|
from(table) {
|
|
82
|
-
return new PostgrestQueryBuilder(this.http, table);
|
|
127
|
+
return new PostgrestQueryBuilder(this.http, table, this.compat);
|
|
83
128
|
}
|
|
84
129
|
/**
|
|
85
130
|
* Call a database function, typed from the generated `Functions` map.
|
|
@@ -119,6 +164,93 @@ export class MotherbaseClient {
|
|
|
119
164
|
return { data: null, error: toError(err), count: null };
|
|
120
165
|
}
|
|
121
166
|
}
|
|
167
|
+
/**
|
|
168
|
+
* Watch every HTTP request this client makes.
|
|
169
|
+
*
|
|
170
|
+
* One event per round trip, with method, path, status, duration and the
|
|
171
|
+
* `x-request-id` the server logged it under. That id is the whole point: it
|
|
172
|
+
* is what turns "a query was slow for a user yesterday" into a line in the
|
|
173
|
+
* project's logs.
|
|
174
|
+
*
|
|
175
|
+
* ```ts
|
|
176
|
+
* client.on('request', e => console.log(e.method, e.path, e.status, e.durationMs))
|
|
177
|
+
* ```
|
|
178
|
+
*
|
|
179
|
+
* Returns the unsubscribe function. An observer that throws is ignored: it is
|
|
180
|
+
* a spectator, and a broken logger must not fail the request it was logging.
|
|
181
|
+
*/
|
|
182
|
+
on(event, listener) {
|
|
183
|
+
if (event !== 'request')
|
|
184
|
+
throw new Error(`Unknown client event '${String(event)}'. Only 'request' exists.`);
|
|
185
|
+
this.requestObservers.add(listener);
|
|
186
|
+
this.syncRequestObserver();
|
|
187
|
+
return () => {
|
|
188
|
+
this.requestObservers.delete(listener);
|
|
189
|
+
this.syncRequestObserver();
|
|
190
|
+
};
|
|
191
|
+
}
|
|
192
|
+
syncRequestObserver() {
|
|
193
|
+
this.http.setRequestObserver(this.requestObservers.size
|
|
194
|
+
? (event) => {
|
|
195
|
+
for (const listener of this.requestObservers)
|
|
196
|
+
listener(event);
|
|
197
|
+
}
|
|
198
|
+
: undefined);
|
|
199
|
+
}
|
|
200
|
+
/**
|
|
201
|
+
* Several writes, applied in one database transaction, all or nothing.
|
|
202
|
+
*
|
|
203
|
+
* supabase-js has no equivalent. What people write instead is a sequence of
|
|
204
|
+
* awaited writes inside a `try`, which is not a rollback: whatever already
|
|
205
|
+
* committed stays committed, and the catch block is left holding half a
|
|
206
|
+
* change it cannot undo.
|
|
207
|
+
*
|
|
208
|
+
* The callback does not await anything. It DESCRIBES the writes; they are
|
|
209
|
+
* sent together and applied together:
|
|
210
|
+
*
|
|
211
|
+
* ```ts
|
|
212
|
+
* const { data, error } = await client.transaction(tx => {
|
|
213
|
+
* tx.from('orders').insert({ id, total })
|
|
214
|
+
* tx.from('stock').update({ count: 4 }).eq('sku', sku)
|
|
215
|
+
* })
|
|
216
|
+
* ```
|
|
217
|
+
*
|
|
218
|
+
* `data` is one result array per operation, in the order they were declared.
|
|
219
|
+
* Reads are refused: a batch exists to make writes atomic, and a read in the
|
|
220
|
+
* middle of one invites expectations about ordering that nothing guarantees.
|
|
221
|
+
*/
|
|
222
|
+
async transaction(build) {
|
|
223
|
+
const recorded = [];
|
|
224
|
+
const tx = {
|
|
225
|
+
from: ((table) => {
|
|
226
|
+
const builder = new PostgrestQueryBuilder(this.http, table, this.compat);
|
|
227
|
+
recorded.push(builder);
|
|
228
|
+
return builder;
|
|
229
|
+
}),
|
|
230
|
+
};
|
|
231
|
+
try {
|
|
232
|
+
build(tx);
|
|
233
|
+
const operations = recorded.map(builder => {
|
|
234
|
+
const request = builder.toRequest();
|
|
235
|
+
if (request.method === 'GET' || request.method === 'HEAD') {
|
|
236
|
+
throw new Error(`transaction(): '${request.model}' was read, not written. A transaction takes writes only `
|
|
237
|
+
+ '(insert, upsert, update, delete).');
|
|
238
|
+
}
|
|
239
|
+
return request;
|
|
240
|
+
});
|
|
241
|
+
if (!operations.length) {
|
|
242
|
+
throw new Error('transaction(): the callback declared no writes.');
|
|
243
|
+
}
|
|
244
|
+
const result = await this.http.request(`${contractPath.rest('batch')}`, {
|
|
245
|
+
method: 'POST',
|
|
246
|
+
body: { operations },
|
|
247
|
+
});
|
|
248
|
+
return { data: result.results, error: null, count: null };
|
|
249
|
+
}
|
|
250
|
+
catch (err) {
|
|
251
|
+
return { data: null, error: toError(err), count: null };
|
|
252
|
+
}
|
|
253
|
+
}
|
|
122
254
|
/** Create (or reuse) a realtime channel. */
|
|
123
255
|
channel(name, opts = {}) {
|
|
124
256
|
const existing = this.channels.get(name);
|
|
@@ -128,6 +260,24 @@ export class MotherbaseClient {
|
|
|
128
260
|
this.channels.set(name, channel);
|
|
129
261
|
return channel;
|
|
130
262
|
}
|
|
263
|
+
/** Every channel this client created, as supabase-js reports them. */
|
|
264
|
+
getChannels() {
|
|
265
|
+
return Array.from(this.channels.values());
|
|
266
|
+
}
|
|
267
|
+
/**
|
|
268
|
+
* supabase-js's schema switcher.
|
|
269
|
+
*
|
|
270
|
+
* The Motherbase REST layer serves `public` and nothing else, so this returns
|
|
271
|
+
* the client for `'public'` and throws for anything else rather than issuing
|
|
272
|
+
* a request that would silently read the wrong tables.
|
|
273
|
+
*/
|
|
274
|
+
schema(name) {
|
|
275
|
+
if (name !== 'public') {
|
|
276
|
+
throw new Error(`schema('${name}') is not supported: the Motherbase REST API exposes the public schema only. `
|
|
277
|
+
+ 'Expose the data through a view or an RPC in public instead.');
|
|
278
|
+
}
|
|
279
|
+
return this;
|
|
280
|
+
}
|
|
131
281
|
/** Unsubscribe and drop a channel. */
|
|
132
282
|
async removeChannel(channel) {
|
|
133
283
|
await channel.unsubscribe();
|
|
@@ -168,13 +318,14 @@ export function createClient(url, key, options = {}) {
|
|
|
168
318
|
return new MotherbaseClient(url, key, options);
|
|
169
319
|
}
|
|
170
320
|
export { BackendError } from './http.js';
|
|
171
|
-
export { memoryStorage, localStorageStorage };
|
|
321
|
+
export { memoryStorage, localStorageStorage, keyValueStorage };
|
|
322
|
+
export { normalizeSession, normalizeUser } from './compat.js';
|
|
172
323
|
export { cookieStorage, serverCookieStorage, SESSION_COOKIE_KEY } from './cookie.js';
|
|
173
324
|
export { PostgrestQueryBuilder } from './postgrest.js';
|
|
174
325
|
export { AuthClient } from './auth.js';
|
|
175
326
|
export { MfaClient } from './mfa.js';
|
|
176
327
|
export { AuthAdminClient } from './admin.js';
|
|
177
328
|
export { StorageClient, StorageBucket } from './storage.js';
|
|
178
|
-
export { FunctionsClient } from './functions.js';
|
|
329
|
+
export { FunctionsClient, FunctionsError, FunctionsHttpError, FunctionsRelayError, FunctionsFetchError } from './functions.js';
|
|
179
330
|
export { RealtimeChannel } from './channel.js';
|
|
180
331
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEhD,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AACrD,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,mBAAmB,EAAE,eAAe,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AACpH,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AACvC,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAC7C,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AACjD,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAC/C,OAAO,EAAE,eAAe,EAA+B,MAAM,cAAc,CAAC;AAC5E,OAAO,EAAE,qBAAqB,EAAE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AmB,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AACrF,OAAO,EAAE,qBAAqB,EAAE,MAAM,gBAAgB,CAAC;AA8CvD,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AACvC,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AACrC,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAmB7C,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAE5D,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAE/H,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC"}
|
package/dist/postgrest.d.ts
CHANGED
|
@@ -43,6 +43,10 @@ export interface OrderOptions extends ReferencedTableOption {
|
|
|
43
43
|
ascending?: boolean;
|
|
44
44
|
nullsFirst?: boolean;
|
|
45
45
|
}
|
|
46
|
+
export interface PaginateOptions {
|
|
47
|
+
/** Rows per request. Capped server side by `api.rest.maxRows`. Default 1000. */
|
|
48
|
+
pageSize?: number;
|
|
49
|
+
}
|
|
46
50
|
export interface SelectOptions {
|
|
47
51
|
count?: PostgrestCount;
|
|
48
52
|
/** Send the request as HEAD: no rows come back, only the count. */
|
|
@@ -97,6 +101,8 @@ export declare function encodeLiteral(value: PostgrestPrimitive): string;
|
|
|
97
101
|
export declare class PostgrestQueryBuilder<Row extends object = Record<string, unknown>> implements PromiseLike<PostgrestResponse<Row[]>> {
|
|
98
102
|
private readonly http;
|
|
99
103
|
private readonly model;
|
|
104
|
+
/** supabase-js semantic parity, from `createClient(..., { compat: 'supabase' })`. */
|
|
105
|
+
private readonly compat;
|
|
100
106
|
private method;
|
|
101
107
|
private columns;
|
|
102
108
|
/**
|
|
@@ -120,7 +126,12 @@ export declare class PostgrestQueryBuilder<Row extends object = Record<string, u
|
|
|
120
126
|
private signal?;
|
|
121
127
|
private body?;
|
|
122
128
|
private rowMode;
|
|
123
|
-
|
|
129
|
+
private shouldThrow;
|
|
130
|
+
/** Set by `select()`, so a write can tell "rows asked for" from "rows always returned". */
|
|
131
|
+
private selectCalled;
|
|
132
|
+
constructor(http: HttpClient, model: string,
|
|
133
|
+
/** supabase-js semantic parity, from `createClient(..., { compat: 'supabase' })`. */
|
|
134
|
+
compat?: boolean);
|
|
124
135
|
/**
|
|
125
136
|
* Choose the columns, and optionally ask for a row count.
|
|
126
137
|
*
|
|
@@ -201,6 +212,37 @@ export declare class PostgrestQueryBuilder<Row extends object = Record<string, u
|
|
|
201
212
|
limit(count: number, options?: ReferencedTableOption): this;
|
|
202
213
|
/** Inclusive range -> offset/limit. `range(0, 9)` fetches 10 rows from offset 0. */
|
|
203
214
|
range(from: number, to: number, options?: ReferencedTableOption): this;
|
|
215
|
+
/**
|
|
216
|
+
* Every matching row, one page at a time.
|
|
217
|
+
*
|
|
218
|
+
* An unbounded `select()` stops at the server's `api.rest.maxRows` (1000 by
|
|
219
|
+
* default) and says nothing about it: the caller gets a full-looking array
|
|
220
|
+
* that is missing everything past the cap. This walks the result instead, so
|
|
221
|
+
* "give me all of them" is expressible without knowing the cap exists.
|
|
222
|
+
*
|
|
223
|
+
* ```ts
|
|
224
|
+
* for await (const row of client.from('events').select('*').stream()) { ... }
|
|
225
|
+
* ```
|
|
226
|
+
*
|
|
227
|
+
* The pages are separate requests, so rows inserted while the walk is running
|
|
228
|
+
* may be seen or missed depending on when they land. Order by a stable column
|
|
229
|
+
* if that matters.
|
|
230
|
+
*/
|
|
231
|
+
stream(options?: PaginateOptions): AsyncGenerator<Row, void, undefined>;
|
|
232
|
+
/**
|
|
233
|
+
* Like `stream()`, a page at a time rather than a row at a time, with the
|
|
234
|
+
* total from `Content-Range` when the server sent one.
|
|
235
|
+
*
|
|
236
|
+
* An error ends the walk by throwing, unlike awaiting the builder, which
|
|
237
|
+
* resolves `{ data, error }`. A `for await` loop has nowhere to put an error
|
|
238
|
+
* value, and silently ending the iteration early would look exactly like
|
|
239
|
+
* reaching the last page.
|
|
240
|
+
*/
|
|
241
|
+
paginate(options?: PaginateOptions): AsyncGenerator<{
|
|
242
|
+
rows: Row[];
|
|
243
|
+
from: number;
|
|
244
|
+
count: number | null;
|
|
245
|
+
}, void, undefined>;
|
|
204
246
|
/** Cancel the in-flight request when the signal aborts. */
|
|
205
247
|
abortSignal(signal: AbortSignal): this;
|
|
206
248
|
/**
|
|
@@ -208,6 +250,34 @@ export declare class PostgrestQueryBuilder<Row extends object = Record<string, u
|
|
|
208
250
|
* `Database` cannot express (a computed column, an embedded shape).
|
|
209
251
|
*/
|
|
210
252
|
returns<T extends object>(): PostgrestQueryBuilder<T>;
|
|
253
|
+
/** supabase-js's newer name for `returns()`. Also a compile-time cast only. */
|
|
254
|
+
overrideTypes<T extends object>(): PostgrestQueryBuilder<T>;
|
|
255
|
+
/**
|
|
256
|
+
* Reject the query instead of resolving `{ data: null, error }`.
|
|
257
|
+
*
|
|
258
|
+
* The `{ data, error }` envelope is the default in both SDKs because it makes
|
|
259
|
+
* a failure impossible to skip by accident. `throwOnError()` is the opt-out
|
|
260
|
+
* for code that would rather use try/catch, and ported Supabase code uses it
|
|
261
|
+
* widely enough that its absence is a `TypeError: … is not a function` on the
|
|
262
|
+
* first query.
|
|
263
|
+
*/
|
|
264
|
+
throwOnError(): this;
|
|
265
|
+
/**
|
|
266
|
+
* Fail the write if it would touch more than `count` rows.
|
|
267
|
+
*
|
|
268
|
+
* A guard against the missing-filter class of accident (`update()` with a
|
|
269
|
+
* typo'd `.eq()`), sent as `Prefer: max-affected`. A server that does not
|
|
270
|
+
* implement it ignores the preference, so treat this as a safety net rather
|
|
271
|
+
* than a guarantee, and keep the filter correct.
|
|
272
|
+
*/
|
|
273
|
+
maxAffected(count: number): this;
|
|
274
|
+
/**
|
|
275
|
+
* Roll the transaction back after running the query, so nothing is persisted.
|
|
276
|
+
* Useful for validating a write, or previewing what it would return.
|
|
277
|
+
*/
|
|
278
|
+
rollback(): this;
|
|
279
|
+
/** Ask for GeoJSON instead of rows. The result resolves to the parsed object. */
|
|
280
|
+
geojson(): PostgrestExplainBuilder;
|
|
211
281
|
/** Ask for `text/csv` instead of JSON. The result resolves to a string. */
|
|
212
282
|
csv(): PostgrestTextBuilder;
|
|
213
283
|
/** Ask the server for the query plan. Admin-only, and off by default. */
|
|
@@ -216,9 +286,26 @@ export declare class PostgrestQueryBuilder<Row extends object = Record<string, u
|
|
|
216
286
|
maybeSingle(): PostgrestSingleBuilder<Row>;
|
|
217
287
|
/** The URL path (with query string) this builder targets. Exposed for tests. */
|
|
218
288
|
toPath(): string;
|
|
289
|
+
/**
|
|
290
|
+
* The request this builder would send, as data.
|
|
291
|
+
*
|
|
292
|
+
* `client.transaction()` needs to describe several writes without issuing
|
|
293
|
+
* them, and the method and body are otherwise private. Exposed rather than
|
|
294
|
+
* reached into: a batch built from `(builder as any).method` would break the
|
|
295
|
+
* first time this class was refactored.
|
|
296
|
+
*/
|
|
297
|
+
toRequest(): {
|
|
298
|
+
method: string;
|
|
299
|
+
model: string;
|
|
300
|
+
query: Record<string, string[]>;
|
|
301
|
+
body: unknown;
|
|
302
|
+
};
|
|
219
303
|
/** The headers this builder sends. Exposed for tests alongside `toPath()`. */
|
|
220
304
|
toHeaders(): Record<string, string>;
|
|
221
305
|
private execute;
|
|
306
|
+
private isWrite;
|
|
307
|
+
/** Apply `single()` / `maybeSingle()` to a row list. The one place row mode is read. */
|
|
308
|
+
private finish;
|
|
222
309
|
then<TResult1 = PostgrestResponse<Row[]>, TResult2 = never>(onfulfilled?: ((value: PostgrestResponse<Row[]>) => TResult1 | PromiseLike<TResult1>) | null, onrejected?: ((reason: unknown) => TResult2 | PromiseLike<TResult2>) | null): PromiseLike<TResult1 | TResult2>;
|
|
223
310
|
}
|
|
224
311
|
/** Same builder, typed to resolve a single row (from `.single()` / `.maybeSingle()`). */
|
package/dist/postgrest.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-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