@motherbase/client 1.0.1 → 1.0.2
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 +155 -121
- package/dist/auth.d.ts +50 -45
- package/dist/auth.d.ts.map +1 -1
- package/dist/auth.js +96 -91
- package/dist/auth.js.map +1 -1
- package/dist/channel.d.ts +40 -0
- package/dist/channel.d.ts.map +1 -0
- package/dist/channel.js +74 -0
- package/dist/channel.js.map +1 -0
- package/dist/functions.d.ts +13 -0
- package/dist/functions.d.ts.map +1 -0
- package/dist/functions.js +21 -0
- package/dist/functions.js.map +1 -0
- package/dist/http.d.ts +27 -2
- package/dist/http.d.ts.map +1 -1
- package/dist/http.js +58 -5
- package/dist/http.js.map +1 -1
- package/dist/index.d.ts +52 -18
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +66 -20
- package/dist/index.js.map +1 -1
- package/dist/postgrest.d.ts +58 -0
- package/dist/postgrest.d.ts.map +1 -0
- package/dist/postgrest.js +165 -0
- package/dist/postgrest.js.map +1 -0
- package/dist/realtime.d.ts +63 -2
- package/dist/realtime.d.ts.map +1 -1
- package/dist/realtime.js +192 -9
- package/dist/realtime.js.map +1 -1
- package/dist/storage.d.ts +48 -22
- package/dist/storage.d.ts.map +1 -1
- package/dist/storage.js +89 -26
- package/dist/storage.js.map +1 -1
- package/dist/types.d.ts +44 -6
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +1 -1
- package/dist/types.js.map +1 -1
- package/package.json +1 -1
package/dist/storage.d.ts
CHANGED
|
@@ -1,29 +1,55 @@
|
|
|
1
1
|
import type { HttpClient } from './http.js';
|
|
2
|
-
import type { FileObject, FileVisibility } from './types.js';
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
import type { FileObject, FileVisibility, MotherbaseResponse, UploadInput } from './types.js';
|
|
3
|
+
export interface UploadOptions {
|
|
4
|
+
/** Object visibility. Defaults to the backend's default (private). */
|
|
5
5
|
visibility?: FileVisibility;
|
|
6
|
-
|
|
6
|
+
/** Passed through to the backend as the content type hint. */
|
|
7
|
+
contentType?: string;
|
|
8
|
+
upsert?: boolean;
|
|
7
9
|
}
|
|
8
|
-
interface
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
10
|
+
export interface UploadResult {
|
|
11
|
+
/** Stable object key. In this backend the key equals the created file id. */
|
|
12
|
+
path: string;
|
|
13
|
+
/** The created file's id (identical to `path`). */
|
|
14
|
+
id: string;
|
|
15
|
+
/** `bucket/id` convenience path. */
|
|
16
|
+
fullPath: string;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Supabase-compatible storage bucket handle. Maps onto the authenticated
|
|
20
|
+
* `/api/files` endpoints. NOTE: in this backend an object's identity is the
|
|
21
|
+
* server-issued file **id**, so the Supabase `path` argument to `download`,
|
|
22
|
+
* `remove`, `getPublicUrl` and `createSignedUrl` is the id returned by `upload`.
|
|
23
|
+
*/
|
|
24
|
+
export declare class StorageBucket {
|
|
25
|
+
private readonly http;
|
|
26
|
+
private readonly baseUrl;
|
|
27
|
+
private readonly bucket;
|
|
28
|
+
constructor(http: HttpClient, baseUrl: string, bucket: string);
|
|
29
|
+
upload(path: string, file: UploadInput, options?: UploadOptions): Promise<MotherbaseResponse<UploadResult>>;
|
|
30
|
+
download(path: string): Promise<MotherbaseResponse<Blob>>;
|
|
31
|
+
remove(paths: string[]): Promise<MotherbaseResponse<FileObject[]>>;
|
|
32
|
+
/**
|
|
33
|
+
* Not supported: the backend exposes no per-bucket object listing endpoint.
|
|
34
|
+
* Returns an error rather than throwing, for drop-in compatibility.
|
|
35
|
+
*/
|
|
36
|
+
list(_prefix?: string): Promise<MotherbaseResponse<FileObject[]>>;
|
|
37
|
+
/** Synchronous public URL (Supabase parity). Serves through the public bucket endpoint. */
|
|
38
|
+
getPublicUrl(path: string): {
|
|
39
|
+
data: {
|
|
40
|
+
publicUrl: string;
|
|
41
|
+
};
|
|
42
|
+
};
|
|
43
|
+
/** A (possibly signed) download URL for the object. */
|
|
44
|
+
createSignedUrl(path: string, _expiresIn?: number): Promise<MotherbaseResponse<{
|
|
45
|
+
signedUrl: string;
|
|
46
|
+
}>>;
|
|
13
47
|
}
|
|
14
|
-
|
|
48
|
+
/** Supabase-compatible storage client: `client.storage.from(bucket)`. */
|
|
49
|
+
export declare class StorageClient {
|
|
15
50
|
private readonly http;
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
/** Request a presigned PUT URL for direct-to-storage upload (S3 driver). */
|
|
20
|
-
presign(params: PresignParams): Promise<{
|
|
21
|
-
url: string;
|
|
22
|
-
[k: string]: unknown;
|
|
23
|
-
}>;
|
|
24
|
-
/** Get a (possibly signed) download URL for a stored file. */
|
|
25
|
-
getUrl(id: string): Promise<string>;
|
|
26
|
-
remove(id: string): Promise<unknown>;
|
|
51
|
+
private readonly baseUrl;
|
|
52
|
+
constructor(http: HttpClient, baseUrl: string);
|
|
53
|
+
from(bucket: string): StorageBucket;
|
|
27
54
|
}
|
|
28
|
-
export {};
|
|
29
55
|
//# sourceMappingURL=storage.d.ts.map
|
package/dist/storage.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"storage.d.ts","sourceRoot":"","sources":["../src/storage.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"storage.d.ts","sourceRoot":"","sources":["../src/storage.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAC5C,OAAO,KAAK,EAAE,UAAU,EAAE,cAAc,EAAE,kBAAkB,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAE9F,MAAM,WAAW,aAAa;IAC5B,sEAAsE;IACtE,UAAU,CAAC,EAAE,cAAc,CAAC;IAC5B,8DAA8D;IAC9D,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB;AAED,MAAM,WAAW,YAAY;IAC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AAO,EAAE,MAAM;IAE/E,IAAI,CAAC,MAAM,EAAE,MAAM,GAAG,aAAa;CAGpC"}
|
package/dist/storage.js
CHANGED
|
@@ -1,31 +1,94 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import { toError } from './http.js';
|
|
2
|
+
/**
|
|
3
|
+
* Supabase-compatible storage bucket handle. Maps onto the authenticated
|
|
4
|
+
* `/api/files` endpoints. NOTE: in this backend an object's identity is the
|
|
5
|
+
* server-issued file **id**, so the Supabase `path` argument to `download`,
|
|
6
|
+
* `remove`, `getPublicUrl` and `createSignedUrl` is the id returned by `upload`.
|
|
7
|
+
*/
|
|
8
|
+
export class StorageBucket {
|
|
9
|
+
constructor(http, baseUrl, bucket) {
|
|
3
10
|
this.http = http;
|
|
11
|
+
this.baseUrl = baseUrl;
|
|
12
|
+
this.bucket = bucket;
|
|
4
13
|
}
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
|
|
14
|
+
async upload(path, file, options = {}) {
|
|
15
|
+
try {
|
|
16
|
+
const form = new FormData();
|
|
17
|
+
if (typeof Blob !== 'undefined' && file instanceof Blob) {
|
|
18
|
+
form.append('file', file, path);
|
|
19
|
+
}
|
|
20
|
+
else {
|
|
21
|
+
form.append('file', file);
|
|
22
|
+
}
|
|
23
|
+
if (options.visibility)
|
|
24
|
+
form.append('visibility', options.visibility);
|
|
25
|
+
form.append('bucket', this.bucket);
|
|
26
|
+
const created = await this.http.request('/api/files/', { method: 'POST', form });
|
|
27
|
+
return {
|
|
28
|
+
data: { path: created.id, id: created.id, fullPath: `${this.bucket}/${created.id}` },
|
|
29
|
+
error: null,
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
catch (err) {
|
|
33
|
+
return { data: null, error: toError(err) };
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
async download(path) {
|
|
37
|
+
try {
|
|
38
|
+
const res = await this.http.requestRaw(`/api/files/${encodeURIComponent(path)}/raw`);
|
|
39
|
+
return { data: await res.blob(), error: null };
|
|
40
|
+
}
|
|
41
|
+
catch (err) {
|
|
42
|
+
return { data: null, error: toError(err) };
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
async remove(paths) {
|
|
46
|
+
try {
|
|
47
|
+
const removed = await Promise.all(paths.map(p => this.http.request(`/api/files/${encodeURIComponent(p)}`, { method: 'DELETE' })));
|
|
48
|
+
return { data: removed, error: null };
|
|
49
|
+
}
|
|
50
|
+
catch (err) {
|
|
51
|
+
return { data: null, error: toError(err) };
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Not supported: the backend exposes no per-bucket object listing endpoint.
|
|
56
|
+
* Returns an error rather than throwing, for drop-in compatibility.
|
|
57
|
+
*/
|
|
58
|
+
async list(_prefix) {
|
|
59
|
+
return {
|
|
60
|
+
data: null,
|
|
61
|
+
error: { message: 'storage.list is not supported by the Motherbase backend' },
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
/** Synchronous public URL (Supabase parity). Serves through the public bucket endpoint. */
|
|
65
|
+
getPublicUrl(path) {
|
|
66
|
+
const base = this.baseUrl.replace(/\/$/, '');
|
|
67
|
+
return {
|
|
68
|
+
data: {
|
|
69
|
+
publicUrl: `${base}/api/storage/${encodeURIComponent(this.bucket)}/files/${encodeURIComponent(path)}`,
|
|
70
|
+
},
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
/** A (possibly signed) download URL for the object. */
|
|
74
|
+
async createSignedUrl(path, _expiresIn) {
|
|
75
|
+
try {
|
|
76
|
+
const res = await this.http.request(`/api/files/${encodeURIComponent(path)}/url`);
|
|
77
|
+
return { data: { signedUrl: res.url }, error: null };
|
|
78
|
+
}
|
|
79
|
+
catch (err) {
|
|
80
|
+
return { data: null, error: toError(err) };
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
/** Supabase-compatible storage client: `client.storage.from(bucket)`. */
|
|
85
|
+
export class StorageClient {
|
|
86
|
+
constructor(http, baseUrl) {
|
|
87
|
+
this.http = http;
|
|
88
|
+
this.baseUrl = baseUrl;
|
|
89
|
+
}
|
|
90
|
+
from(bucket) {
|
|
91
|
+
return new StorageBucket(this.http, this.baseUrl, bucket);
|
|
29
92
|
}
|
|
30
93
|
}
|
|
31
94
|
//# sourceMappingURL=storage.js.map
|
package/dist/storage.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"storage.js","sourceRoot":"","sources":["../src/storage.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"storage.js","sourceRoot":"","sources":["../src/storage.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAqBpC;;;;;GAKG;AACH,MAAM,OAAO,aAAa;IACxB,YACmB,IAAgB,EAChB,OAAe,EACf,MAAc;QAFd,SAAI,GAAJ,IAAI,CAAY;QAChB,YAAO,GAAP,OAAO,CAAQ;QACf,WAAM,GAAN,MAAM,CAAQ;IAC9B,CAAC;IAEJ,KAAK,CAAC,MAAM,CACV,IAAY,EACZ,IAAiB,EACjB,UAAyB,EAAE;QAE3B,IAAI,CAAC;YACH,MAAM,IAAI,GAAG,IAAI,QAAQ,EAAE,CAAC;YAC5B,IAAI,OAAO,IAAI,KAAK,WAAW,IAAI,IAAI,YAAY,IAAI,EAAE,CAAC;gBACxD,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;YAClC,CAAC;iBAAM,CAAC;gBACN,IAAI,CAAC,MAAM,CAAC,MAAM,EA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E,CAAC;YACb,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC;QAC7C,CAAC;IACH,CAAC;CACF;AAED,yEAAyE;AACzE,MAAM,OAAO,aAAa;IACxB,YAA6B,IAAgB,EAAmB,OAAe;QAAlD,SAAI,GAAJ,IAAI,CAAY;QAAmB,YAAO,GAAP,OAAO,CAAQ;IAAG,CAAC;IAEnF,IAAI,CAAC,MAAc;QACjB,OAAO,IAAI,aAAa,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;IAC5D,CAAC;CACF"}
|
package/dist/types.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
/** Shared types for the Motherbase client SDK. */
|
|
2
|
-
/** The envelope
|
|
1
|
+
/** Shared types for the Motherbase client SDK (Supabase-js compatible surface). */
|
|
2
|
+
/** The envelope non-REST API endpoints (auth, storage, edge) wrap their payload in. */
|
|
3
3
|
export interface ApiEnvelope<T = unknown> {
|
|
4
4
|
status: 0 | 1;
|
|
5
5
|
message: string;
|
|
@@ -14,12 +14,17 @@ export interface User {
|
|
|
14
14
|
role?: string;
|
|
15
15
|
[key: string]: unknown;
|
|
16
16
|
}
|
|
17
|
-
/**
|
|
17
|
+
/**
|
|
18
|
+
* The bearer token issued by sign-up / sign-in. With Better Auth this is the
|
|
19
|
+
* session token; there is no separate refresh token (a session is valid until
|
|
20
|
+
* it expires, after which the user re-authenticates). `refreshToken` is kept
|
|
21
|
+
* optional for backwards source-compat and is unused.
|
|
22
|
+
*/
|
|
18
23
|
export interface Tokens {
|
|
19
24
|
accessToken: string;
|
|
20
|
-
refreshToken
|
|
25
|
+
refreshToken?: string;
|
|
21
26
|
}
|
|
22
|
-
/** The locally-held session:
|
|
27
|
+
/** The locally-held session: the bearer token plus the user it belongs to. */
|
|
23
28
|
export interface Session extends Tokens {
|
|
24
29
|
user: User;
|
|
25
30
|
}
|
|
@@ -34,7 +39,29 @@ export interface FileObject {
|
|
|
34
39
|
[key: string]: unknown;
|
|
35
40
|
}
|
|
36
41
|
export type FileVisibility = 'public' | 'private';
|
|
37
|
-
|
|
42
|
+
/** A file-ish value accepted by multipart uploads (browser File/Blob or RN asset). */
|
|
43
|
+
export type UploadInput = Blob | {
|
|
44
|
+
uri: string;
|
|
45
|
+
name?: string;
|
|
46
|
+
type?: string;
|
|
47
|
+
};
|
|
48
|
+
/**
|
|
49
|
+
* The uniform result envelope every data/auth/storage call resolves to.
|
|
50
|
+
* `error` is `null` on success; `data` is `null` on failure. Never throws for
|
|
51
|
+
* expected API errors — only for programmer misuse.
|
|
52
|
+
*/
|
|
53
|
+
export interface MotherbaseResponse<T> {
|
|
54
|
+
data: T | null;
|
|
55
|
+
error: MotherbaseError | null;
|
|
56
|
+
}
|
|
57
|
+
/** Supabase-shaped error object. */
|
|
58
|
+
export interface MotherbaseError {
|
|
59
|
+
message: string;
|
|
60
|
+
/** HTTP status code, when the failure came from an HTTP response. */
|
|
61
|
+
status?: number;
|
|
62
|
+
/** Backend/app error code, when present. */
|
|
63
|
+
code?: string;
|
|
64
|
+
}
|
|
38
65
|
/**
|
|
39
66
|
* Persists the session between runs. Implementations must be synchronous-or-async
|
|
40
67
|
* tolerant: every method may return a value or a promise of it.
|
|
@@ -50,7 +77,18 @@ export interface ClientOptions {
|
|
|
50
77
|
autoRefresh?: boolean;
|
|
51
78
|
/** Override the fetch implementation (for SSR or tests). */
|
|
52
79
|
fetch?: typeof fetch;
|
|
80
|
+
/** Extra headers merged into every request (e.g. a custom `apikey`). */
|
|
81
|
+
headers?: Record<string, string>;
|
|
82
|
+
/**
|
|
83
|
+
* Inject a socket.io factory for realtime (tests / custom transports).
|
|
84
|
+
* When omitted, `socket.io-client` is imported lazily at connect time.
|
|
85
|
+
*/
|
|
86
|
+
realtimeIoFactory?: (url: string, opts: Record<string, unknown>) => import('./realtime.js').SocketLike;
|
|
53
87
|
}
|
|
88
|
+
/** Supabase-compatible auth change events emitted by `onAuthStateChange`. */
|
|
89
|
+
export type AuthChangeEvent = 'SIGNED_IN' | 'SIGNED_OUT' | 'TOKEN_REFRESHED';
|
|
90
|
+
export type AuthChangeListener = (event: AuthChangeEvent, session: Session | null) => void;
|
|
91
|
+
/** Internal event names used by the session store. */
|
|
54
92
|
export type AuthEvent = 'signIn' | 'signOut' | 'tokenRefreshed';
|
|
55
93
|
export type AuthListener = (event: AuthEvent, session: Session | null) => void;
|
|
56
94
|
//# sourceMappingURL=types.d.ts.map
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,mFAAmF;AAEnF,uFAAuF;AACvF,MAAM,WAAW,WAAW,CAAC,CAAC,GAAG,OAAO;IACtC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,CAAC,CAAC;IACT,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACjC;AAED,6EAA6E;AAC7E,MAAM,WAAW,IAAI;IACnB,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB;AAED;;;;;GAKG;AACH,MAAM,WAAW,MAAM;IACrB,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED,8EAA8E;AAC9E,MAAM,WAAW,OAAQ,SAAQ,MAAM;IACrC,IAAI,EAAE,IAAI,CAAC;CACZ;AAED,0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,CAAC,EAAE,OAAO,KAAK,CAAC;IACrB,wEAAwE;IACxE,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACjC;;;OAGG;IACH,iBAAiB,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,OAAO,eAAe,EAAE,UAAU,CAAC;CACxG;AAED,6EAA6E;AAC7E,MAAM,MAAM,eAAe,GAAG,WAAW,GAAG,YAAY,GAAG,iBAAiB,CAAC;AAC7E,MAAM,MAAM,kBAAkB,GAAG,CAAC,KAAK,EAAE,eAAe,EAAE,OAAO,EAAE,OAAO,GAAG,IAAI,KAAK,IAAI,CAAC;AAE3F,sDAAsD;AACtD,MAAM,MAAM,SAAS,GAAG,QAAQ,GAAG,SAAS,GAAG,gBAAgB,CAAC;AAChE,MAAM,MAAM,YAAY,GAAG,CAAC,KAAK,EAAE,SAAS,EAAE,OAAO,EAAE,OAAO,GAAG,IAAI,KAAK,IAAI,CAAC"}
|
package/dist/types.js
CHANGED
package/dist/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,mFAAmF"}
|