@motherbase/client 1.4.0 → 1.5.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 +379 -284
- package/package.json +1 -1
- package/dist/admin.d.ts +0 -81
- package/dist/admin.d.ts.map +0 -1
- package/dist/admin.js +0 -85
- package/dist/admin.js.map +0 -1
- package/dist/auth.d.ts +0 -362
- package/dist/auth.d.ts.map +0 -1
- package/dist/auth.js +0 -721
- package/dist/auth.js.map +0 -1
- package/dist/channel.d.ts +0 -122
- package/dist/channel.d.ts.map +0 -1
- package/dist/channel.js +0 -213
- package/dist/channel.js.map +0 -1
- package/dist/compat.d.ts +0 -40
- package/dist/compat.d.ts.map +0 -1
- package/dist/compat.js +0 -98
- package/dist/compat.js.map +0 -1
- package/dist/cookie.d.ts +0 -68
- package/dist/cookie.d.ts.map +0 -1
- package/dist/cookie.js +0 -152
- package/dist/cookie.js.map +0 -1
- package/dist/database.d.ts +0 -188
- package/dist/database.d.ts.map +0 -1
- package/dist/database.js +0 -2
- package/dist/database.js.map +0 -1
- package/dist/devices.d.ts +0 -13
- package/dist/devices.d.ts.map +0 -1
- package/dist/devices.js +0 -13
- package/dist/devices.js.map +0 -1
- package/dist/edge.d.ts +0 -7
- package/dist/edge.d.ts.map +0 -1
- package/dist/edge.js +0 -13
- package/dist/edge.js.map +0 -1
- package/dist/functions.d.ts +0 -60
- package/dist/functions.d.ts.map +0 -1
- package/dist/functions.js +0 -75
- package/dist/functions.js.map +0 -1
- package/dist/http.d.ts +0 -123
- package/dist/http.d.ts.map +0 -1
- package/dist/http.js +0 -205
- package/dist/http.js.map +0 -1
- package/dist/index.d.ts +0 -185
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -331
- package/dist/index.js.map +0 -1
- package/dist/mfa.d.ts +0 -109
- package/dist/mfa.d.ts.map +0 -1
- package/dist/mfa.js +0 -134
- package/dist/mfa.js.map +0 -1
- package/dist/postgrest.d.ts +0 -326
- package/dist/postgrest.d.ts.map +0 -1
- package/dist/postgrest.js +0 -629
- package/dist/postgrest.js.map +0 -1
- package/dist/profile.d.ts +0 -16
- package/dist/profile.d.ts.map +0 -1
- package/dist/profile.js +0 -26
- package/dist/profile.js.map +0 -1
- package/dist/query.d.ts +0 -97
- package/dist/query.d.ts.map +0 -1
- package/dist/query.js +0 -94
- package/dist/query.js.map +0 -1
- package/dist/realtime.d.ts +0 -114
- package/dist/realtime.d.ts.map +0 -1
- package/dist/realtime.js +0 -372
- package/dist/realtime.js.map +0 -1
- package/dist/rest.d.ts +0 -50
- package/dist/rest.d.ts.map +0 -1
- package/dist/rest.js +0 -75
- package/dist/rest.js.map +0 -1
- package/dist/session.d.ts +0 -47
- package/dist/session.d.ts.map +0 -1
- package/dist/session.js +0 -136
- package/dist/session.js.map +0 -1
- package/dist/storage.d.ts +0 -239
- package/dist/storage.d.ts.map +0 -1
- package/dist/storage.js +0 -391
- package/dist/storage.js.map +0 -1
- package/dist/testing.d.ts +0 -38
- package/dist/testing.d.ts.map +0 -1
- package/dist/testing.js +0 -50
- package/dist/testing.js.map +0 -1
- package/dist/types.d.ts +0 -343
- package/dist/types.d.ts.map +0 -1
- package/dist/types.js +0 -2
- package/dist/types.js.map +0 -1
- package/dist/warn.d.ts +0 -4
- package/dist/warn.d.ts.map +0 -1
- package/dist/warn.js +0 -27
- package/dist/warn.js.map +0 -1
package/dist/profile.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"profile.d.ts","sourceRoot":"","sources":["../src/profile.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAC5C,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAEvC,sFAAsF;AACtF,MAAM,MAAM,WAAW,GAAG,IAAI,GAAG;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;AAW/E,qBAAa,WAAW;IACV,OAAO,CAAC,QAAQ,CAAC,IAAI;gBAAJ,IAAI,EAAE,UAAU;IAE7C,cAAc,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAI/C,WAAW,CAAC,IAAI,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC;IAM7C,aAAa,IAAI,OAAO,CAAC,OAAO,CAAC;CAGlC"}
|
package/dist/profile.js
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
function appendFile(form, field, file) {
|
|
2
|
-
if (typeof Blob !== 'undefined' && file instanceof Blob) {
|
|
3
|
-
form.append(field, file);
|
|
4
|
-
}
|
|
5
|
-
else {
|
|
6
|
-
// React Native style { uri, name, type }
|
|
7
|
-
form.append(field, file);
|
|
8
|
-
}
|
|
9
|
-
}
|
|
10
|
-
export class UsersModule {
|
|
11
|
-
constructor(http) {
|
|
12
|
-
this.http = http;
|
|
13
|
-
}
|
|
14
|
-
updateUsername(username) {
|
|
15
|
-
return this.http.request('/api/users/username', { method: 'PUT', body: { username } });
|
|
16
|
-
}
|
|
17
|
-
updateImage(file) {
|
|
18
|
-
const form = new FormData();
|
|
19
|
-
appendFile(form, 'image', file);
|
|
20
|
-
return this.http.request('/api/users/image', { method: 'PUT', form });
|
|
21
|
-
}
|
|
22
|
-
deleteAccount() {
|
|
23
|
-
return this.http.request('/api/users/', { method: 'DELETE' });
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
//# sourceMappingURL=profile.js.map
|
package/dist/profile.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"profile.js","sourceRoot":"","sources":["../src/profile.ts"],"names":[],"mappings":"AAMA,SAAS,UAAU,CAAC,IAAc,EAAE,KAAa,EAAE,IAAiB;IAClE,IAAI,OAAO,IAAI,KAAK,WAAW,IAAI,IAAI,YAAY,IAAI,EAAE,CAAC;QACxD,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;IAC3B,CAAC;SAAM,CAAC;QACN,yCAAyC;QACzC,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,IAAuB,CAAC,CAAC;IAC9C,CAAC;AACH,CAAC;AAED,MAAM,OAAO,WAAW;IACtB,YAA6B,IAAgB;QAAhB,SAAI,GAAJ,IAAI,CAAY;IAAG,CAAC;IAEjD,cAAc,CAAC,QAAgB;QAC7B,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,CAAO,qBAAqB,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE,QAAQ,EAAE,EAAE,CAAC,CAAC;IAC/F,CAAC;IAED,WAAW,CAAC,IAAiB;QAC3B,MAAM,IAAI,GAAG,IAAI,QAAQ,EAAE,CAAC;QAC5B,UAAU,CAAC,IAAI,EAAE,OAAO,EAAE,IAAI,CAAC,CAAC;QAChC,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,CAAO,kBAAkB,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;IAC9E,CAAC;IAED,aAAa;QACX,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,aAAa,EAAE,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC,CAAC;IAChE,CAAC;CACF"}
|
package/dist/query.d.ts
DELETED
|
@@ -1,97 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* React Query / SWR glue: cache keys and fetchers for Motherbase queries.
|
|
3
|
-
*
|
|
4
|
-
* Every app that reaches for a data-fetching library writes the same two
|
|
5
|
-
* things, badly: a key convention, and a fetcher that remembers to throw on
|
|
6
|
-
* `{ error }` instead of caching it as data. The second one is the bug. A
|
|
7
|
-
* fetcher that returns `{ data: null, error }` resolves successfully as far as
|
|
8
|
-
* React Query is concerned, so the error is cached, `isError` stays false, and
|
|
9
|
-
* the UI renders an empty list forever.
|
|
10
|
-
*
|
|
11
|
-
* No dependency on React Query here, and none needed: the returned objects are
|
|
12
|
-
* plain `{ queryKey, queryFn }`, which is what `useQuery` takes. The same
|
|
13
|
-
* objects work with SWR by passing `queryKey` as the key and `queryFn` as the
|
|
14
|
-
* fetcher.
|
|
15
|
-
*/
|
|
16
|
-
import type { MotherbaseClient } from './index.js';
|
|
17
|
-
import type { TypedQuery } from './database.js';
|
|
18
|
-
import type { PostgrestResponse } from './postgrest.js';
|
|
19
|
-
/**
|
|
20
|
-
* The builder handed to a `build` callback: the same object `client.from()`
|
|
21
|
-
* returns, narrowed to the row type the helper was called with. Typed rather
|
|
22
|
-
* than `any`, so `.eq('athor', …)` is a compile error inside the callback and
|
|
23
|
-
* the editor completes the column names.
|
|
24
|
-
*/
|
|
25
|
-
export type QueryBuilderFor<Row extends object> = TypedQuery<Row, Partial<Row>, Partial<Row>>;
|
|
26
|
-
/**
|
|
27
|
-
* Any client, whatever `Database` it was created with.
|
|
28
|
-
*
|
|
29
|
-
* ponytail: the generic arguments are erased here because `from()`'s relation
|
|
30
|
-
* names are literal types that differ per `Database`, so no single parameter
|
|
31
|
-
* type accepts them all. The erasure stops at this boundary: everything the
|
|
32
|
-
* helpers hand back to the caller is typed through `Row`.
|
|
33
|
-
*/
|
|
34
|
-
type AnyClient = MotherbaseClient<any, any, any>;
|
|
35
|
-
/**
|
|
36
|
-
* Cache keys, hierarchical so invalidation can be coarse.
|
|
37
|
-
*
|
|
38
|
-
* `['motherbase', 'table', 'posts']` is a prefix of every key below it, so
|
|
39
|
-
* `invalidateQueries({ queryKey: keys.table('posts') })` reaches every list and
|
|
40
|
-
* every row of that table, which is what you want after a write. Anything
|
|
41
|
-
* narrower leaves a stale list on screen next to a fresh row.
|
|
42
|
-
*/
|
|
43
|
-
export declare const keys: {
|
|
44
|
-
all: readonly ["motherbase"];
|
|
45
|
-
table: (table: string) => readonly ["motherbase", "table", string];
|
|
46
|
-
list: (table: string, filters?: unknown) => readonly ["motherbase", "table", string, "list"] | readonly ["motherbase", "table", string, "list", {} | null];
|
|
47
|
-
row: (table: string, id: unknown) => readonly ["motherbase", "table", string, "row", unknown];
|
|
48
|
-
};
|
|
49
|
-
export interface QueryOptions<T> {
|
|
50
|
-
queryKey: readonly unknown[];
|
|
51
|
-
queryFn: () => Promise<T>;
|
|
52
|
-
}
|
|
53
|
-
/**
|
|
54
|
-
* A list query.
|
|
55
|
-
*
|
|
56
|
-
* `build` receives the query builder so filters, ordering and column selection
|
|
57
|
-
* stay in the caller's hands; whatever it returns is awaited and unwrapped.
|
|
58
|
-
* Pass `filters` to make the key unique per filter set, or two different
|
|
59
|
-
* filtered lists of the same table will share one cache entry and overwrite
|
|
60
|
-
* each other.
|
|
61
|
-
*
|
|
62
|
-
* ```ts
|
|
63
|
-
* useQuery(listQuery(client, 'posts', {
|
|
64
|
-
* filters: { author },
|
|
65
|
-
* build: q => q.select('*').eq('author', author).order('created_at'),
|
|
66
|
-
* }))
|
|
67
|
-
* ```
|
|
68
|
-
*/
|
|
69
|
-
export declare function listQuery<Row extends object = Record<string, unknown>>(client: AnyClient, table: string, options?: {
|
|
70
|
-
filters?: unknown;
|
|
71
|
-
build?: (query: QueryBuilderFor<Row>) => PromiseLike<PostgrestResponse<Row[]>>;
|
|
72
|
-
}): QueryOptions<Row[]>;
|
|
73
|
-
/**
|
|
74
|
-
* One row by primary key (or by any unique column, through `column`).
|
|
75
|
-
*
|
|
76
|
-
* Resolves `null` rather than throwing when the row is not there: "not found"
|
|
77
|
-
* is an answer, and a cache library that receives it as an error retries it.
|
|
78
|
-
*/
|
|
79
|
-
export declare function rowQuery<Row extends object = Record<string, unknown>>(client: AnyClient, table: string, id: unknown, options?: {
|
|
80
|
-
column?: keyof Row & string;
|
|
81
|
-
columns?: string;
|
|
82
|
-
}): QueryOptions<Row | null>;
|
|
83
|
-
/**
|
|
84
|
-
* Every row, walked through `stream()` rather than capped at the server's
|
|
85
|
-
* `api.rest.maxRows`.
|
|
86
|
-
*
|
|
87
|
-
* Separate from `listQuery` on purpose: this issues one request per page, so it
|
|
88
|
-
* belongs to lists that are known to be small enough to hold in memory and
|
|
89
|
-
* large enough to exceed the cap. Anything unbounded wants real pagination.
|
|
90
|
-
*/
|
|
91
|
-
export declare function allRowsQuery<Row extends object = Record<string, unknown>>(client: AnyClient, table: string, options?: {
|
|
92
|
-
filters?: unknown;
|
|
93
|
-
pageSize?: number;
|
|
94
|
-
build?: (query: QueryBuilderFor<Row>) => QueryBuilderFor<Row>;
|
|
95
|
-
}): QueryOptions<Row[]>;
|
|
96
|
-
export {};
|
|
97
|
-
//# sourceMappingURL=query.d.ts.map
|
package/dist/query.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"query.d.ts","sourceRoot":"","sources":["../src/query.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AACnD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAExD;;;;;GAKG;AACH,MAAM,MAAM,eAAe,CAAC,GAAG,SAAS,MAAM,IAAI,UAAU,CAAC,GAAG,EAAE,OAAO,CAAC,GAAG,CAAC,EAAE,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC;AAE9F;;;;;;;GAOG;AACH,KAAK,SAAS,GAAG,gBAAgB,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC;AAOjD;;;;;;;GAOG;AACH,eAAO,MAAM,IAAI;;mBAEA,MAAM;kBACP,MAAM,YAAY,OAAO;iBAI1B,MAAM,MAAM,OAAO;CACjC,CAAC;AASF,MAAM,WAAW,YAAY,CAAC,CAAC;IAC7B,QAAQ,EAAE,SAAS,OAAO,EAAE,CAAC;IAC7B,OAAO,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,CAAC;CAC3B;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,SAAS,CAAC,GAAG,SAAS,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACpE,MAAM,EAAE,SAAS,EACjB,KAAK,EAAE,MAAM,EACb,OAAO,GAAE;IACP,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,KAAK,CAAC,EAAE,CAAC,KAAK,EAAE,eAAe,CAAC,GAAG,CAAC,KAAK,WAAW,CAAC,iBAAiB,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC;CAC3E,GACL,YAAY,CAAC,GAAG,EAAE,CAAC,CASrB;AAED;;;;;GAKG;AACH,wBAAgB,QAAQ,CAAC,GAAG,SAAS,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACnE,MAAM,EAAE,SAAS,EACjB,KAAK,EAAE,MAAM,EACb,EAAE,EAAE,OAAO,EACX,OAAO,GAAE;IAAE,MAAM,CAAC,EAAE,MAAM,GAAG,GAAG,MAAM,CAAC;IAAC,OAAO,CAAC,EAAE,MAAM,CAAA;CAAO,GAC9D,YAAY,CAAC,GAAG,GAAG,IAAI,CAAC,CAc1B;AAED;;;;;;;GAOG;AACH,wBAAgB,YAAY,CAAC,GAAG,SAAS,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACvE,MAAM,EAAE,SAAS,EACjB,KAAK,EAAE,MAAM,EACb,OAAO,GAAE;IACP,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,CAAC,KAAK,EAAE,eAAe,CAAC,GAAG,CAAC,KAAK,eAAe,CAAC,GAAG,CAAC,CAAC;CAC1D,GACL,YAAY,CAAC,GAAG,EAAE,CAAC,CAYrB"}
|
package/dist/query.js
DELETED
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
/** `from()` on an erased client, re-typed to the row the caller asked for. */
|
|
2
|
-
function queryFor(client, table) {
|
|
3
|
-
return client.from(table);
|
|
4
|
-
}
|
|
5
|
-
/**
|
|
6
|
-
* Cache keys, hierarchical so invalidation can be coarse.
|
|
7
|
-
*
|
|
8
|
-
* `['motherbase', 'table', 'posts']` is a prefix of every key below it, so
|
|
9
|
-
* `invalidateQueries({ queryKey: keys.table('posts') })` reaches every list and
|
|
10
|
-
* every row of that table, which is what you want after a write. Anything
|
|
11
|
-
* narrower leaves a stale list on screen next to a fresh row.
|
|
12
|
-
*/
|
|
13
|
-
export const keys = {
|
|
14
|
-
all: ['motherbase'],
|
|
15
|
-
table: (table) => ['motherbase', 'table', table],
|
|
16
|
-
list: (table, filters) => (filters === undefined
|
|
17
|
-
? ['motherbase', 'table', table, 'list']
|
|
18
|
-
: ['motherbase', 'table', table, 'list', filters]),
|
|
19
|
-
row: (table, id) => ['motherbase', 'table', table, 'row', id],
|
|
20
|
-
};
|
|
21
|
-
/** Unwrap a `{ data, error }` result the way a cache library needs: throw on error. */
|
|
22
|
-
async function unwrap(result) {
|
|
23
|
-
const { data, error } = await result;
|
|
24
|
-
if (error)
|
|
25
|
-
throw Object.assign(new Error(error.message), error);
|
|
26
|
-
return data;
|
|
27
|
-
}
|
|
28
|
-
/**
|
|
29
|
-
* A list query.
|
|
30
|
-
*
|
|
31
|
-
* `build` receives the query builder so filters, ordering and column selection
|
|
32
|
-
* stay in the caller's hands; whatever it returns is awaited and unwrapped.
|
|
33
|
-
* Pass `filters` to make the key unique per filter set, or two different
|
|
34
|
-
* filtered lists of the same table will share one cache entry and overwrite
|
|
35
|
-
* each other.
|
|
36
|
-
*
|
|
37
|
-
* ```ts
|
|
38
|
-
* useQuery(listQuery(client, 'posts', {
|
|
39
|
-
* filters: { author },
|
|
40
|
-
* build: q => q.select('*').eq('author', author).order('created_at'),
|
|
41
|
-
* }))
|
|
42
|
-
* ```
|
|
43
|
-
*/
|
|
44
|
-
export function listQuery(client, table, options = {}) {
|
|
45
|
-
const { filters, build } = options;
|
|
46
|
-
return {
|
|
47
|
-
queryKey: keys.list(table, filters),
|
|
48
|
-
queryFn: () => {
|
|
49
|
-
const base = queryFor(client, table);
|
|
50
|
-
return unwrap(build ? build(base) : base.select('*'));
|
|
51
|
-
},
|
|
52
|
-
};
|
|
53
|
-
}
|
|
54
|
-
/**
|
|
55
|
-
* One row by primary key (or by any unique column, through `column`).
|
|
56
|
-
*
|
|
57
|
-
* Resolves `null` rather than throwing when the row is not there: "not found"
|
|
58
|
-
* is an answer, and a cache library that receives it as an error retries it.
|
|
59
|
-
*/
|
|
60
|
-
export function rowQuery(client, table, id, options = {}) {
|
|
61
|
-
const { column = 'id', columns = '*' } = options;
|
|
62
|
-
return {
|
|
63
|
-
queryKey: keys.row(table, id),
|
|
64
|
-
queryFn: () => unwrap(queryFor(client, table)
|
|
65
|
-
// `columns` is a runtime string, so it cannot be checked against the
|
|
66
|
-
// row the way a literal passed to `.select()` is.
|
|
67
|
-
.select(columns)
|
|
68
|
-
.eq(column, id)
|
|
69
|
-
.maybeSingle()),
|
|
70
|
-
};
|
|
71
|
-
}
|
|
72
|
-
/**
|
|
73
|
-
* Every row, walked through `stream()` rather than capped at the server's
|
|
74
|
-
* `api.rest.maxRows`.
|
|
75
|
-
*
|
|
76
|
-
* Separate from `listQuery` on purpose: this issues one request per page, so it
|
|
77
|
-
* belongs to lists that are known to be small enough to hold in memory and
|
|
78
|
-
* large enough to exceed the cap. Anything unbounded wants real pagination.
|
|
79
|
-
*/
|
|
80
|
-
export function allRowsQuery(client, table, options = {}) {
|
|
81
|
-
const { filters, pageSize, build } = options;
|
|
82
|
-
return {
|
|
83
|
-
queryKey: [...keys.list(table, filters), 'all'],
|
|
84
|
-
queryFn: async () => {
|
|
85
|
-
const base = queryFor(client, table);
|
|
86
|
-
const query = build ? build(base) : base.select('*');
|
|
87
|
-
const rows = [];
|
|
88
|
-
for await (const row of query.stream({ pageSize }))
|
|
89
|
-
rows.push(row);
|
|
90
|
-
return rows;
|
|
91
|
-
},
|
|
92
|
-
};
|
|
93
|
-
}
|
|
94
|
-
//# sourceMappingURL=query.js.map
|
package/dist/query.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"query.js","sourceRoot":"","sources":["../src/query.ts"],"names":[],"mappings":"AAqCA,8EAA8E;AAC9E,SAAS,QAAQ,CAAqB,MAAiB,EAAE,KAAa;IACpE,OAAO,MAAM,CAAC,IAAI,CAAM,KAAc,CAAyB,CAAC;AAClE,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,IAAI,GAAG;IAClB,GAAG,EAAE,CAAC,YAAY,CAAU;IAC5B,KAAK,EAAE,CAAC,KAAa,EAAE,EAAE,CAAC,CAAC,YAAY,EAAE,OAAO,EAAE,KAAK,CAAU;IACjE,IAAI,EAAE,CAAC,KAAa,EAAE,OAAiB,EAAE,EAAE,CACzC,CAAC,OAAO,KAAK,SAAS;QACpB,CAAC,CAAE,CAAC,YAAY,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,CAAW;QACnD,CAAC,CAAE,CAAC,YAAY,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,CAAW,CAAC;IACjE,GAAG,EAAE,CAAC,KAAa,EAAE,EAAW,EAAE,EAAE,CAAC,CAAC,YAAY,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE,CAAU;CACxF,CAAC;AAEF,uFAAuF;AACvF,KAAK,UAAU,MAAM,CAAI,MAAyC;IAChE,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,MAAM,MAAM,CAAC;IACrC,IAAI,KAAK;QAAE,MAAM,MAAM,CAAC,MAAM,CAAC,IAAI,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC,EAAE,KAAK,CAAC,CAAC;IAChE,OAAO,IAAS,CAAC;AACnB,CAAC;AAOD;;;;;;;;;;;;;;;GAeG;AACH,MAAM,UAAU,SAAS,CACvB,MAAiB,EACjB,KAAa,EACb,UAGI,EAAE;IAEN,MAAM,EAAE,OAAO,EAAE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AE,KAAK,CAAC,CAAC;YAC1C,MAAM,KAAK,GAAG,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAE,IAAI,CAAC,MAAM,CAAC,GAAG,CAA0B,CAAC;YAC/E,MAAM,IAAI,GAAU,EAAE,CAAC;YACvB,IAAI,KAAK,EAAE,MAAM,GAAG,IAAI,KAAK,CAAC,MAAM,CAAC,EAAE,QAAQ,EAAE,CAAC;gBAAE,IAAI,CAAC,IAAI,CAAC,GAAU,CAAC,CAAC;YAC1E,OAAO,IAAI,CAAC;QACd,CAAC;KACF,CAAC;AACJ,CAAC"}
|
package/dist/realtime.d.ts
DELETED
|
@@ -1,114 +0,0 @@
|
|
|
1
|
-
import type { SessionStore } from './session.js';
|
|
2
|
-
import { type RealtimeJoinAck, type RealtimeJoinConfig, type RealtimeTopicEnvelope, type RealtimeTopicMessageType } from '@motherbase/contracts';
|
|
3
|
-
export type RealtimeStatus = 'idle' | 'connecting' | 'connected' | 'reconnecting' | 'polling' | 'disconnected' | 'error';
|
|
4
|
-
export type RealtimeStatusListener = (status: RealtimeStatus, detail?: unknown) => void;
|
|
5
|
-
export interface RealtimeConnectOptions {
|
|
6
|
-
timeoutMs?: number;
|
|
7
|
-
fallbackPolling?: boolean;
|
|
8
|
-
}
|
|
9
|
-
export interface RealtimeWatchOptions {
|
|
10
|
-
intervalMs?: number;
|
|
11
|
-
query?: string;
|
|
12
|
-
polling?: boolean;
|
|
13
|
-
}
|
|
14
|
-
/** Events received are pre-filtered by server-side REST policies for the current session. */
|
|
15
|
-
export type RealtimeWatchEvent<T> = {
|
|
16
|
-
type: 'created' | 'updated' | 'deleted';
|
|
17
|
-
source: 'socket';
|
|
18
|
-
payload: T;
|
|
19
|
-
} | {
|
|
20
|
-
type: 'snapshot';
|
|
21
|
-
source: 'polling';
|
|
22
|
-
rows: T[];
|
|
23
|
-
};
|
|
24
|
-
/** Minimal shape we rely on from socket.io-client's Socket. */
|
|
25
|
-
export interface SocketLike {
|
|
26
|
-
on(event: string, cb: (...args: unknown[]) => void): void;
|
|
27
|
-
off(event: string, cb?: (...args: unknown[]) => void): void;
|
|
28
|
-
emit(event: string, ...args: unknown[]): void;
|
|
29
|
-
disconnect(): void;
|
|
30
|
-
connected: boolean;
|
|
31
|
-
}
|
|
32
|
-
export type IoFactory = (url: string, opts: Record<string, unknown>) => SocketLike;
|
|
33
|
-
/** What RealtimeModule needs from a RealtimeChannel (avoids a circular import). */
|
|
34
|
-
export interface ChannelHandle {
|
|
35
|
-
_receive(envelope: RealtimeTopicEnvelope): void;
|
|
36
|
-
/** Called after a reconnect replayed (or failed to replay) this topic's join. */
|
|
37
|
-
_rejoined?(ok: boolean): void;
|
|
38
|
-
}
|
|
39
|
-
/**
|
|
40
|
-
* Lazy wrapper over socket.io-client. The dependency is optional: it is only
|
|
41
|
-
* imported when `connect()` is called, so apps that never use realtime do not
|
|
42
|
-
* need to install it.
|
|
43
|
-
*/
|
|
44
|
-
export declare class RealtimeModule {
|
|
45
|
-
private readonly baseUrl;
|
|
46
|
-
private readonly store;
|
|
47
|
-
private readonly fetchImpl;
|
|
48
|
-
/** Inject a socket factory (tests / custom transports). Falls back to socket.io-client. */
|
|
49
|
-
private readonly ioFactory?;
|
|
50
|
-
private socket;
|
|
51
|
-
private status;
|
|
52
|
-
private readonly statusListeners;
|
|
53
|
-
private readonly pollers;
|
|
54
|
-
private readonly tableSubscriptionRefs;
|
|
55
|
-
private pollerSeq;
|
|
56
|
-
private readonly channelsByTopic;
|
|
57
|
-
/** Topics joined on the current socket, replayed as-is after a reconnect. */
|
|
58
|
-
private readonly joinedTopics;
|
|
59
|
-
private topicRouterBound;
|
|
60
|
-
constructor(baseUrl: string, store: SessionStore, fetchImpl?: typeof fetch,
|
|
61
|
-
/** Inject a socket factory (tests / custom transports). Falls back to socket.io-client. */
|
|
62
|
-
ioFactory?: IoFactory | undefined);
|
|
63
|
-
/** True once a socket is connected. */
|
|
64
|
-
get connected(): boolean;
|
|
65
|
-
getStatus(): RealtimeStatus;
|
|
66
|
-
onStatusChange(listener: RealtimeStatusListener): () => void;
|
|
67
|
-
connect(options?: RealtimeConnectOptions): Promise<void>;
|
|
68
|
-
on(event: string, cb: (...args: unknown[]) => void): void;
|
|
69
|
-
off(event: string, cb?: (...args: unknown[]) => void): void;
|
|
70
|
-
emit(event: string, ...args: unknown[]): void;
|
|
71
|
-
/**
|
|
72
|
-
* @deprecated Legacy low-level table watcher. Prefer the Supabase-shaped
|
|
73
|
-
* `client.channel(topic).on('postgres_changes', { event, schema, table, filter }, cb)`.
|
|
74
|
-
* Kept for backwards compatibility; scheduled for removal.
|
|
75
|
-
*
|
|
76
|
-
* Subscribe to create/update/delete events for a model table.
|
|
77
|
-
*
|
|
78
|
-
* Events are filtered server-side: you will only receive events for rows
|
|
79
|
-
* your session is authorized to see (based on REST API SELECT policies).
|
|
80
|
-
* Anonymous sessions receive only public rows; authenticated sessions receive
|
|
81
|
-
* rows matching their access policies (e.g. owner-only rows they own).
|
|
82
|
-
*
|
|
83
|
-
* Falls back to polling the REST endpoint at subscribe time if the WebSocket
|
|
84
|
-
* is not yet connected (polling does not auto-start on later disconnects).
|
|
85
|
-
*/
|
|
86
|
-
watchTable<T>(model: string, cb: (event: RealtimeWatchEvent<T>) => void, options?: RealtimeWatchOptions): () => void;
|
|
87
|
-
disconnect(): void;
|
|
88
|
-
/** Register a channel so incoming rt:msg envelopes for its topic are routed to it. */
|
|
89
|
-
registerChannel(topic: string, channel: ChannelHandle): void;
|
|
90
|
-
unregisterChannel(topic: string): void;
|
|
91
|
-
/** Emit rt:join and resolve the server ack (or a timeout/error ack). */
|
|
92
|
-
joinTopic(topic: string, config: RealtimeJoinConfig, timeoutMs?: number): Promise<RealtimeJoinAck>;
|
|
93
|
-
leaveTopic(topic: string): void;
|
|
94
|
-
sendTopic(topic: string, type: RealtimeTopicMessageType, event: string, payload: unknown): void;
|
|
95
|
-
/** Emit an rt:msg and wait for the server ack (or resolve 'timed out'/'error'). */
|
|
96
|
-
sendTopicWithAck(topic: string, type: RealtimeTopicMessageType, event: string, payload: unknown, timeoutMs?: number): Promise<'ok' | 'timed out' | 'error'>;
|
|
97
|
-
private bindTopicRouter;
|
|
98
|
-
private retainTableSubscription;
|
|
99
|
-
private releaseTableSubscription;
|
|
100
|
-
private resubscribeTables;
|
|
101
|
-
/**
|
|
102
|
-
* Replay every joined topic on a fresh socket. The server keeps topic state on
|
|
103
|
-
* the socket, so without this a reconnected channel still reports SUBSCRIBED
|
|
104
|
-
* and receives nothing at all.
|
|
105
|
-
*/
|
|
106
|
-
private rejoinTopics;
|
|
107
|
-
private bindSocketStatus;
|
|
108
|
-
private waitForConnect;
|
|
109
|
-
private startPolling;
|
|
110
|
-
private stopPolling;
|
|
111
|
-
private fetchRows;
|
|
112
|
-
private setStatus;
|
|
113
|
-
}
|
|
114
|
-
//# sourceMappingURL=realtime.d.ts.map
|
package/dist/realtime.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"realtime.d.ts","sourceRoot":"","sources":["../src/realtime.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AACjD,OAAO,EAKL,KAAK,eAAe,EACpB,KAAK,kBAAkB,EACvB,KAAK,qBAAqB,EAC1B,KAAK,wBAAwB,EAC9B,MAAM,uBAAuB,CAAC;AAE/B,MAAM,MAAM,cAAc,GACtB,MAAM,GACN,YAAY,GACZ,WAAW,GACX,cAAc,GACd,SAAS,GACT,cAAc,GACd,OAAO,CAAC;AACZ,MAAM,MAAM,sBAAsB,GAAG,CAAC,MAAM,EAAE,cAAc,EAAE,MAAM,CAAC,EAAE,OAAO,KAAK,IAAI,CAAC;AAExF,MAAM,WAAW,sBAAsB;IACrC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,eAAe,CAAC,EAAE,OAAO,CAAC;CAC3B;AAED,MAAM,WAAW,oBAAoB;IACnC,UAAU,CAAC,EA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