@rebasepro/client 0.21.0 → 0.21.1-canary.g8c5a265

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.
Files changed (2) hide show
  1. package/README.md +21 -18
  2. package/package.json +4 -4
package/README.md CHANGED
@@ -9,8 +9,8 @@ pnpm add @rebasepro/client
9
9
  ```
10
10
 
11
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)`.
12
+ `import`. It needs Node `>=22.22.0` (its `engines` floor), where `require()`
13
+ of it resolves too: Node has supported `require(esm)` since 22.12.
14
14
 
15
15
  ## What This Package Does
16
16
 
@@ -20,7 +20,7 @@ ESM-only: `"type": "module"` with no CommonJS build, so it is loaded with
20
20
  - **Authentication** — email/password, Google, 10+ OAuth providers, session management, password reset
21
21
  - **Admin** — user CRUD for admins
22
22
  - **Storage** — file upload, download, delete, list
23
- - **Realtime** — WebSocket subscriptions for collection and snapshot changes
23
+ - **Realtime** — WebSocket subscriptions for collection and row changes
24
24
  - **Offline / local-first sync** (opt-in) — a local row database, writes that apply instantly offline and replay when the connection returns, and live queries
25
25
  - **Cron** — list, trigger, and manage cron jobs
26
26
  - **Custom functions** — invoke server-side Hono route functions
@@ -32,8 +32,8 @@ ESM-only: `"type": "module"` with no CommonJS build, so it is loaded with
32
32
 
33
33
  | Export | Description |
34
34
  |---|---|
35
- | `createRebaseClient<DB>(options)` | Create a `RebaseClient` instance. Generic `DB` parameter enables type-safe `client.data.*` access. |
36
- | `RebaseClient<DB>` | The client type — includes `auth`, `admin`, `cron`, `functions`, `storage`, `ws`, `data`, `call`, and token management methods. |
35
+ | `createRebaseClient<DB>(options)` | Create a client instance. Generic `DB` parameter enables type-safe `client.data.*` access. |
36
+ | `CreateRebaseClientResult<DB>` | The client type it returns (`RebaseClient<DB>` from `@rebasepro/types`, narrowed) — includes `auth`, `admin`, `cron`, `functions`, `storage`, `ws`, `data`, `call`, and token management methods. |
37
37
  | `CreateRebaseClientOptions` | Extends `RebaseClientConfig` with `auth`, `admin`, and `cron` sub-configs. |
38
38
 
39
39
  ### Config
@@ -56,19 +56,19 @@ ESM-only: `"type": "module"` with no CommonJS build, so it is loaded with
56
56
 
57
57
  | Method | Description |
58
58
  |---|---|
59
- | `find(params?)` | Query with pagination. Returns `FindResponse<M>` (`{ data, meta }`) |
60
- | `findById(id)` | Fetch a single snapshot. Returns `Snapshot<M> \| undefined` |
61
- | `create(data, id?)` | Create snapshot. Returns `Snapshot<M>` |
62
- | `update(id, data)` | Update snapshot. Returns `Snapshot<M>` |
63
- | `delete(id)` | Delete snapshot |
64
- | `count(params?)` | Count matching snapshots |
59
+ | `find(params?)` | Query with pagination. Returns `FindResult<M>` (`{ data, meta }`, flat rows) |
60
+ | `findById(id)` | Fetch a single row. Returns `M \| undefined` |
61
+ | `create(data, id?)` | Create a row. Returns `M` |
62
+ | `update(id, data)` | Update a row. Returns `M` |
63
+ | `delete(id)` | Delete a row |
64
+ | `count(params?)` | Count matching rows |
65
65
  | `where(col, op, val)` | Start a fluent query — returns `QueryBuilder` |
66
66
  | `orderBy(col, dir?)` | Order results — returns `QueryBuilder` |
67
67
  | `limit(n)` / `offset(n)` | Pagination — returns `QueryBuilder` |
68
68
  | `search(str)` | Full-text search — returns `QueryBuilder` |
69
- | `include(...rels)` | Include related snapshots — returns `QueryBuilder` |
69
+ | `include(...rels)` | Include related rows — returns `QueryBuilder` |
70
70
  | `listen(params, onUpdate, onError?)` | Realtime subscription (requires WebSocket) |
71
- | `listenById(id, onUpdate, onError?)` | Realtime single-snapshot subscription |
71
+ | `listenById(id, onUpdate, onError?)` | Realtime single-row subscription |
72
72
  | `observe(params, onResult, onError?, options?)` | Live query — local-first when `offline` is on, otherwise fetch + `listen` |
73
73
  | `observeById(id, onResult, onError?, options?)` | Live query for a single row |
74
74
 
@@ -131,13 +131,16 @@ ESM-only: `"type": "module"` with no CommonJS build, so it is loaded with
131
131
  | `createCookieStorage(options?)` | Cookie-based auth storage adapter |
132
132
  | `createMemoryStorage()` | In-memory auth storage adapter |
133
133
  | `QueryBuilder` | Fluent query builder (also re-exported from `@rebasepro/common`) |
134
- | `Snapshot`, `FindResponse` | Re-exported from `@rebasepro/types` |
134
+ | `FindResult`, `FindParams`, `User`, … | Re-exported from `@rebasepro/types` |
135
135
 
136
136
  ## Quick Start
137
137
 
138
138
  ```ts
139
139
  import { createRebaseClient } from "@rebasepro/client";
140
140
 
141
+ // Without a type argument every row is `Record<string, unknown>`. Pass the
142
+ // `Database` type `rebase generate-sdk` writes — `createRebaseClient<Database>(…)`
143
+ // — and every row, filter and sort below is checked.
141
144
  const client = createRebaseClient({
142
145
  baseUrl: "http://localhost:3001",
143
146
  });
@@ -148,8 +151,8 @@ await client.auth.signInWithEmail("user@example.com", "password");
148
151
  // CRUD
149
152
  const { data: products } = await client.data.products.find({ limit: 10 });
150
153
  const product = await client.data.products.create({ name: "Camera", price: 299 });
151
- await client.data.products.update(product.id, { price: 249 });
152
- await client.data.products.delete(product.id);
154
+ await client.data.products.update(42, { price: 249 });
155
+ await client.data.products.delete(42);
153
156
 
154
157
  // Fluent queries
155
158
  const { data: expensive } = await client.data.products
@@ -171,6 +174,6 @@ const unsubscribe = client.data.products.listen(
171
174
  ## Related Packages
172
175
 
173
176
  - [`@rebasepro/common`](../common) — `QueryBuilder`, `buildRebaseData`, shared utilities
174
- - [`@rebasepro/types`](../types) — `Snapshot`, `FindResponse`, `CollectionAccessor`, etc.
177
+ - [`@rebasepro/types`](../types) — `Entity`, `FindResult`, `CollectionAccessor`, etc.
175
178
  - [`@rebasepro/utils`](../utils) — `toSnakeCase` and other helpers
176
- - [`@rebasepro/app`](../auth) — React hook adapter that wraps `client.auth` for CMS integration
179
+ - [`@rebasepro/app`](../app) — React hook adapter that wraps `client.auth` for CMS integration
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rebasepro/client",
3
- "version": "0.21.0",
3
+ "version": "0.21.1-canary.g8c5a265",
4
4
  "description": "HTTP SDK client for the Rebase custom backend",
5
5
  "keywords": [
6
6
  "rebase",
@@ -41,9 +41,9 @@
41
41
  "./package.json": "./package.json"
42
42
  },
43
43
  "dependencies": {
44
- "@rebasepro/common": "0.21.0",
45
- "@rebasepro/utils": "0.21.0",
46
- "@rebasepro/types": "0.21.0"
44
+ "@rebasepro/common": "0.21.1-canary.g8c5a265",
45
+ "@rebasepro/utils": "0.21.1-canary.g8c5a265",
46
+ "@rebasepro/types": "0.21.1-canary.g8c5a265"
47
47
  },
48
48
  "devDependencies": {
49
49
  "@jest/globals": "^30.4.1",