@protobase/cli 0.26.6 → 0.26.7
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/dist/package.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@protobase/cli",
|
|
3
|
-
"version": "0.26.
|
|
3
|
+
"version": "0.26.7",
|
|
4
4
|
"description": "The protobase command: scaffold, doctor, dev, build and serve a Protobase project.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|
|
@@ -35,11 +35,11 @@
|
|
|
35
35
|
"dependencies": {
|
|
36
36
|
"@hono/node-server": "^2.1.3",
|
|
37
37
|
"@hono/vite-dev-server": "^0.26.1",
|
|
38
|
-
"@protobase/layout": "0.26.
|
|
39
|
-
"@protobase/query": "0.26.
|
|
40
|
-
"@protobase/schema": "0.26.
|
|
41
|
-
"@protobase/server": "0.26.
|
|
42
|
-
"@protobase/ui": "0.26.
|
|
38
|
+
"@protobase/layout": "0.26.7",
|
|
39
|
+
"@protobase/query": "0.26.7",
|
|
40
|
+
"@protobase/schema": "0.26.7",
|
|
41
|
+
"@protobase/server": "0.26.7",
|
|
42
|
+
"@protobase/ui": "0.26.7",
|
|
43
43
|
"@react-email/render": "^2.1.0",
|
|
44
44
|
"@scalar/hono-api-reference": "^0.12.10",
|
|
45
45
|
"@tailwindcss/vite": "^4.3.3",
|
|
@@ -60,6 +60,7 @@ Reference:
|
|
|
60
60
|
- When defining views, columns, filters, charts, related records and actions → read [UI config](references/reference/ui-config.md)
|
|
61
61
|
- When asking how the packages fit together → read [Architecture](references/reference/architecture.md)
|
|
62
62
|
- When calling or changing the REST API, its filters, writes and errors → read [REST API](references/reference/api.md)
|
|
63
|
+
- When an app calls it with supabase-js, `from()` and `rpc()` under RLS → read [Supabase client API](references/reference/supabase-rest.md)
|
|
63
64
|
- When working with file fields and uploads → read [Files](references/reference/files.md)
|
|
64
65
|
- When reacting to changes of records → read [Events](references/reference/events.md)
|
|
65
66
|
- When delivering events to URLs → read [Webhooks](references/reference/webhooks.md)
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
<!-- Generated by scripts/protobase-skill.ts from website/src/content/docs/reference/supabase-rest.md: run `bun run docs:skill`, do not edit. -->
|
|
2
|
+
|
|
3
|
+
# Supabase client API
|
|
4
|
+
|
|
5
|
+
The PostgREST-compatible /rest/v1 that supabase-js's from() and rpc() call, under the tables' RLS policies.
|
|
6
|
+
|
|
7
|
+
An app with API keys also serves `/rest/v1`, the API that supabase-js's `from()` and `rpc()` call. An app moved from Supabase keeps its data calls: point the client at the app and give it the publishable key.
|
|
8
|
+
|
|
9
|
+
```ts
|
|
10
|
+
import { createClient } from '@supabase/supabase-js'
|
|
11
|
+
|
|
12
|
+
const supabase = createClient('https://my-app.example.com', 'sb_publishable_...')
|
|
13
|
+
const { data, error } = await supabase.from('todos').select('id, title').eq('done', false).order('id')
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
## Keys and roles
|
|
17
|
+
|
|
18
|
+
The keys are `options.apiKeys` of `createAdmin`, `{ publishable_key, secret_key }`, or else `PROTOBASE_PUBLISHABLE_KEY` and `PROTOBASE_SECRET_KEY`. Without either, or with `apiKeys: false`, the app serves no `/rest/v1`. Each request sends a key in the `apikey` header, and runs in one transaction as:
|
|
19
|
+
|
|
20
|
+
| The request sends | It runs as |
|
|
21
|
+
| --- | --- |
|
|
22
|
+
| the publishable key | `anon` |
|
|
23
|
+
| either key and a signed-in user's token | `authenticated` |
|
|
24
|
+
| the secret key | the app's own role, which owns the tables |
|
|
25
|
+
|
|
26
|
+
The transaction sets the role with `SET LOCAL ROLE` and the token's claims in `request.jwt.claims` and `request.jwt.claim.sub`, so Supabase's `auth.uid()`, `auth.role()` and `auth.jwt()` work, and the tables' RLS policies decide what the request may read and write. The `role` claim is the database role, as on Supabase. The database needs the `anon` and `authenticated` roles, and the app's role must be allowed to `SET ROLE` to them.
|
|
27
|
+
|
|
28
|
+
`/rest/v1` serves the tables the app declares as resources, in the `public` schema, under their table names. Any other table is `404`.
|
|
29
|
+
|
|
30
|
+
## What it understands
|
|
31
|
+
|
|
32
|
+
- Filters: `eq`, `neq`, `gt`, `gte`, `lt`, `lte`, `like`, `ilike`, `match`, `imatch`, `in`, `is`, `isdistinct`, `fts`, `plfts`, `phfts`, `wfts` with a language, `cs`, `cd`, `ov`, `sl`, `sr`, `nxr`, `nxl`, `adj`, `any` and `all` modifiers, `not.`, and `or`, `and`, `not.or` and `not.and` trees, on columns and JSON paths (`meta->>kind`).
|
|
33
|
+
- `select` with columns, aliases (`key:id`), casts (`priority::text`) and JSON paths.
|
|
34
|
+
- `order`, `limit`, `offset` and the `Range` header. A read returns at most 1000 rows, Supabase's default.
|
|
35
|
+
- `Prefer: count=exact|planned|estimated`, with the count in `Content-Range` and `206` for part of the rows.
|
|
36
|
+
- `Prefer: return=minimal|representation`, `resolution=merge-duplicates|ignore-duplicates`, `missing=default`, and `on_conflict` and `columns`.
|
|
37
|
+
- `.single()` and `.maybeSingle()`, through `Accept: application/vnd.pgrst.object+json`.
|
|
38
|
+
- `rpc/<function>` by POST and by GET, which runs read-only. A function returning rows takes `select`, filters, `order`, a range and a count.
|
|
39
|
+
|
|
40
|
+
Not yet: embedding other tables through foreign keys, CSV, other schemas, aggregates and `tx=rollback`.
|
|
41
|
+
|
|
42
|
+
## Scan guard
|
|
43
|
+
|
|
44
|
+
As on the [REST API](api.md#safety)), a filter or a sort reads only columns an index serves: a btree index for comparisons, `in`, `is` and sorts, a pg_trgm index for patterns and regular expressions, a GIN index for text search and `cs`, `cd` and `ov` (or GiST), and a GiST index for the range operators. A JSON path needs an index on that expression. Any other read is `400` with code `expensive-query` and the statement that adds the index as its `hint`. Functions are not judged.
|
|
45
|
+
|
|
46
|
+
## Errors
|
|
47
|
+
|
|
48
|
+
Errors come back as PostgREST sends them, `{ code, details, hint, message }`. A database error keeps its Postgres code, message, detail and hint, with PostgREST's status: an RLS refusal (`42501`) is `401` for `anon` and `403` for others, a duplicate (`23505`) `409`, a function that writes called by GET (`25006`) `405`. `.single()` on no or several rows is `406` `PGRST116`, an unknown table `404` `PGRST205`, an unknown function `404` `PGRST202`, and a missing or wrong key or token `401` `PGRST301`.
|