@rebasepro/client 0.17.3-canary.gdd23447 → 0.18.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 +4 -0
- package/dist/auth.d.ts +80 -0
- package/dist/functions.d.ts +6 -1
- package/dist/index.d.ts +8 -0
- package/dist/index.es.js +471 -94
- package/dist/index.es.js.map +1 -1
- package/dist/offline-connectivity.d.ts +12 -1
- package/dist/offline.d.ts +23 -1
- package/dist/query-contract.types.d.ts +30 -0
- package/dist/realtime-channel.d.ts +29 -1
- package/dist/sdk_query_builder.d.ts +21 -2
- package/dist/transport.d.ts +24 -0
- package/package.json +28 -15
- package/src/admin.ts +0 -90
- package/src/anonymous-client-guard.test.ts +0 -190
- package/src/api-keys.ts +0 -87
- package/src/auth-listener-errors.test.ts +0 -57
- package/src/auth-refresh-overflow.test.ts +0 -89
- package/src/auth.ts +0 -982
- package/src/backups.ts +0 -40
- package/src/client-close.test.ts +0 -80
- package/src/collection-listen-meta.test.ts +0 -105
- package/src/collection-observe.test.ts +0 -138
- package/src/collection.test.ts +0 -293
- package/src/collection.ts +0 -525
- package/src/cron.test.ts +0 -164
- package/src/cron.ts +0 -62
- package/src/data-proxy.test.ts +0 -183
- package/src/errors.ts +0 -9
- package/src/functions.ts +0 -82
- package/src/index.ts +0 -639
- package/src/like-pattern-redos.test.ts +0 -61
- package/src/offline-codec.ts +0 -79
- package/src/offline-connectivity.test.ts +0 -191
- package/src/offline-connectivity.ts +0 -255
- package/src/offline-idb-store.test.ts +0 -340
- package/src/offline-integration.test.ts +0 -180
- package/src/offline-query.test.ts +0 -431
- package/src/offline-query.ts +0 -529
- package/src/offline-store.ts +0 -357
- package/src/offline-sync-engine.test.ts +0 -857
- package/src/offline.test.ts +0 -897
- package/src/offline.ts +0 -1928
- package/src/query-contract.types.ts +0 -206
- package/src/query_builder.ts +0 -1
- package/src/realtime-channel.test.ts +0 -542
- package/src/realtime-channel.ts +0 -539
- package/src/realtime-concurrent-subscribe.test.ts +0 -102
- package/src/realtime-error-surfacing.test.ts +0 -105
- package/src/realtime-optout.test.ts +0 -279
- package/src/realtime-row-identity.test.ts +0 -254
- package/src/realtime-subscription-key.test.ts +0 -92
- package/src/reviver.ts +0 -39
- package/src/sdk_query_builder.ts +0 -206
- package/src/storage-key-encoding.test.ts +0 -65
- package/src/storage-registry.ts +0 -102
- package/src/storage.ts +0 -253
- package/src/transport-baseurl.test.ts +0 -101
- package/src/transport.ts +0 -505
- package/src/vector-search-listen.test.ts +0 -42
- package/src/vector-search-query.test.ts +0 -55
- package/src/websocket-url.test.ts +0 -97
- package/src/websocket.ts +0 -1837
package/README.md
CHANGED
|
@@ -8,6 +8,10 @@ HTTP SDK client for the Rebase backend — typed CRUD, auth, storage, realtime W
|
|
|
8
8
|
pnpm add @rebasepro/client
|
|
9
9
|
```
|
|
10
10
|
|
|
11
|
+
ESM-only: `"type": "module"` with no CommonJS build, so it is loaded with
|
|
12
|
+
`import`. `require()` of it resolves only on Node 22.12+, which supports
|
|
13
|
+
`require(esm)`.
|
|
14
|
+
|
|
11
15
|
## What This Package Does
|
|
12
16
|
|
|
13
17
|
`@rebasepro/client` is the primary SDK for interacting with a Rebase backend from any JavaScript/TypeScript environment (browser, Node.js, edge). It creates a single client instance that provides:
|
package/dist/auth.d.ts
CHANGED
|
@@ -123,6 +123,86 @@ export declare function createAuth(transport: Transport, options?: CreateAuthOpt
|
|
|
123
123
|
accessToken: string;
|
|
124
124
|
refreshToken: string;
|
|
125
125
|
}>;
|
|
126
|
+
signInAnonymously: () => Promise<{
|
|
127
|
+
user: User;
|
|
128
|
+
accessToken: string;
|
|
129
|
+
refreshToken: string;
|
|
130
|
+
}>;
|
|
131
|
+
linkAnonymous: (email: string, password: string) => Promise<{
|
|
132
|
+
user: User;
|
|
133
|
+
accessToken: string;
|
|
134
|
+
refreshToken: string;
|
|
135
|
+
}>;
|
|
136
|
+
mfa: {
|
|
137
|
+
/**
|
|
138
|
+
* Start enrolling a TOTP factor.
|
|
139
|
+
*
|
|
140
|
+
* Returns the secret and an `otpauth://` URI to render as a QR code,
|
|
141
|
+
* plus ten single-use recovery codes. **Show the recovery codes once
|
|
142
|
+
* and never again** — only their hashes are stored.
|
|
143
|
+
*
|
|
144
|
+
* The factor is not usable until `verify` confirms the user's
|
|
145
|
+
* authenticator produced a correct code from it.
|
|
146
|
+
*/
|
|
147
|
+
enroll(options?: {
|
|
148
|
+
friendlyName?: string;
|
|
149
|
+
issuer?: string;
|
|
150
|
+
}): Promise<{
|
|
151
|
+
factor: {
|
|
152
|
+
id: string;
|
|
153
|
+
factorType: string;
|
|
154
|
+
friendlyName?: string;
|
|
155
|
+
};
|
|
156
|
+
totp: {
|
|
157
|
+
secret: string;
|
|
158
|
+
uri: string;
|
|
159
|
+
qrUri: string;
|
|
160
|
+
};
|
|
161
|
+
recoveryCodes: string[];
|
|
162
|
+
}>;
|
|
163
|
+
/** Confirm an enrolment with a code from the authenticator app. */
|
|
164
|
+
verify(factorId: string, code: string): Promise<{
|
|
165
|
+
success: boolean;
|
|
166
|
+
factor: {
|
|
167
|
+
id: string;
|
|
168
|
+
verified: boolean;
|
|
169
|
+
};
|
|
170
|
+
}>;
|
|
171
|
+
/** The factors on this account, verified or not. */
|
|
172
|
+
listFactors(): Promise<{
|
|
173
|
+
id: string;
|
|
174
|
+
factorType: string;
|
|
175
|
+
friendlyName?: string;
|
|
176
|
+
verified: boolean;
|
|
177
|
+
createdAt: string;
|
|
178
|
+
}[]>;
|
|
179
|
+
/**
|
|
180
|
+
* Remove a factor. Requires an `aal2` session — one that has already
|
|
181
|
+
* answered a challenge — so a stolen `aal1` token cannot turn MFA off.
|
|
182
|
+
*/
|
|
183
|
+
unenroll(factorId: string): Promise<{
|
|
184
|
+
success: boolean;
|
|
185
|
+
message: string;
|
|
186
|
+
}>;
|
|
187
|
+
/** Open a challenge against a verified factor. Expires in five minutes. */
|
|
188
|
+
challenge(factorId: string): Promise<{
|
|
189
|
+
challengeId: string;
|
|
190
|
+
factorId: string;
|
|
191
|
+
expiresAt: string;
|
|
192
|
+
}>;
|
|
193
|
+
/**
|
|
194
|
+
* Answer a challenge with a TOTP code or a recovery code.
|
|
195
|
+
*
|
|
196
|
+
* This is where an MFA-enrolled account's real session is minted, at
|
|
197
|
+
* `aal2` — so the returned tokens replace the ones the sign-in handed
|
|
198
|
+
* back, and this client adopts them.
|
|
199
|
+
*/
|
|
200
|
+
verifyChallenge(challengeId: string, code: string): Promise<{
|
|
201
|
+
user: User;
|
|
202
|
+
accessToken: string;
|
|
203
|
+
refreshToken: string;
|
|
204
|
+
}>;
|
|
205
|
+
};
|
|
126
206
|
signOut: () => Promise<void>;
|
|
127
207
|
stopAutoRefresh: () => void;
|
|
128
208
|
refreshSession: () => Promise<RebaseSession>;
|
package/dist/functions.d.ts
CHANGED
|
@@ -19,9 +19,14 @@ export interface FunctionsClient {
|
|
|
19
19
|
/**
|
|
20
20
|
* Invoke a custom backend function by name.
|
|
21
21
|
*
|
|
22
|
+
* **The method is `POST` unless you say otherwise.** A function whose only
|
|
23
|
+
* route is `app.get("/")` therefore answers 404 to a bare `invoke(name)` —
|
|
24
|
+
* pass `{ method: "GET" }`, or write the route as `app.post`.
|
|
25
|
+
*
|
|
22
26
|
* @typeParam T - Expected shape of the response payload.
|
|
23
27
|
* @param name - Function name (the filename without extension, e.g. `"extract-job"`).
|
|
24
|
-
*
|
|
28
|
+
* One path segment: a sub-path goes in `options.path`.
|
|
29
|
+
* @param payload - Optional JSON-serialisable body. Dropped for `GET`.
|
|
25
30
|
* @param options - Optional overrides (HTTP method, sub-path, extra headers).
|
|
26
31
|
* @returns The parsed JSON response from the function.
|
|
27
32
|
*/
|
package/dist/index.d.ts
CHANGED
|
@@ -136,6 +136,14 @@ export type CreateRebaseClientResult<DB = Record<string, unknown>> = Omit<Rebase
|
|
|
136
136
|
storageRegistry: StorageSourceRegistry;
|
|
137
137
|
createStorageSource: (storageId: string) => StorageSource;
|
|
138
138
|
fetchStorageSources: () => Promise<StorageSourceDefinition[]>;
|
|
139
|
+
/**
|
|
140
|
+
* POST to an arbitrary endpoint on this backend, returning its body
|
|
141
|
+
* verbatim.
|
|
142
|
+
*
|
|
143
|
+
* The shorthand for {@link FunctionsClient.invoke} — `call("functions/x",
|
|
144
|
+
* p)` is `functions.invoke("x", p)` — and it unwraps exactly as little.
|
|
145
|
+
* Neither reaches into the response for a `data` key.
|
|
146
|
+
*/
|
|
139
147
|
call: <T = unknown>(endpoint: string, payload?: unknown) => Promise<T>;
|
|
140
148
|
collection: <M extends Record<string, unknown> = Record<string, unknown>>(slug: string) => CollectionClient<M>;
|
|
141
149
|
data: TypedDataLayer<DB>;
|