@protobase/cli 0.30.0 → 0.30.1

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.
@@ -1,4 +1,4 @@
1
1
  //#region package.json
2
- var version = "0.30.0";
2
+ var version = "0.30.1";
3
3
  //#endregion
4
4
  export { version };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@protobase/cli",
3
- "version": "0.30.0",
3
+ "version": "0.30.1",
4
4
  "description": "The protobase command: scaffold, doctor, dev, build and serve a Protobase project.",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -36,11 +36,11 @@
36
36
  "@better-auth/core": "^1.7.7",
37
37
  "@hono/node-server": "^2.1.3",
38
38
  "@hono/vite-dev-server": "^0.26.1",
39
- "@protobase/layout": "0.30.0",
40
- "@protobase/query": "0.30.0",
41
- "@protobase/schema": "0.30.0",
42
- "@protobase/server": "0.30.0",
43
- "@protobase/ui": "0.30.0",
39
+ "@protobase/layout": "0.30.1",
40
+ "@protobase/query": "0.30.1",
41
+ "@protobase/schema": "0.30.1",
42
+ "@protobase/server": "0.30.1",
43
+ "@protobase/ui": "0.30.1",
44
44
  "@react-email/render": "^2.1.0",
45
45
  "@scalar/hono-api-reference": "^0.12.10",
46
46
  "@tailwindcss/vite": "^4.3.3",
@@ -62,6 +62,7 @@ Reference:
62
62
  - When asking how the packages fit together → read [Architecture](references/reference/architecture.md)
63
63
  - When calling or changing the REST API, its filters, writes and errors → read [REST API](references/reference/api.md)
64
64
  - When an app calls it with supabase-js, `from()` and `rpc()` under RLS → read [Supabase client API](references/reference/supabase-rest.md)
65
+ - When an app calls `storage` with supabase-js, under the storage policies → read [Supabase Storage API](references/reference/supabase-storage.md)
65
66
  - When working with file fields and uploads → read [Files](references/reference/files.md)
66
67
  - When reacting to changes of records → read [Events](references/reference/events.md)
67
68
  - When delivering events to URLs → read [Webhooks](references/reference/webhooks.md)
@@ -0,0 +1,54 @@
1
+ <!-- Generated by scripts/protobase-skill.ts from website/src/content/docs/reference/supabase-storage.md: run `bun run docs:skill`, do not edit. -->
2
+
3
+ # Supabase Storage API
4
+
5
+ The Storage-compatible /storage/v1 that supabase-js's storage calls, over the app's file provider, under the restored storage policies.
6
+
7
+ An app with API keys also serves `/storage/v1`, the API that supabase-js's `storage` calls. An app moved from Supabase keeps its uploads, downloads, public URLs and signed URLs: 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.storage.from('avatars').upload(`${userId}/avatar.png`, file)
14
+ ```
15
+
16
+ ## Where things are kept
17
+
18
+ The buckets and objects are the rows of `storage.buckets` and `storage.objects`, the schema that `protobase import supabase` restores with its policies. The bytes go to one of the app's [file providers](files.md)): `files.storage.provider` in `protobase.config.ts`, `private` by default, so a local folder or an S3-compatible bucket, with that provider's `max_bytes` and `max_files` quota. An object's bytes are kept at `storage/<SHA-256 of bucket and name>/<version>` in the provider. `files.storage.maxFileSize` caps every upload, `50 MB` by default, and a bucket's `file_size_limit` can only lower it. `files: { storage: false }` serves no `/storage/v1`.
19
+
20
+ ## Keys and roles
21
+
22
+ 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 `/storage/v1`. A request sends a key in the `apikey` header and runs as:
23
+
24
+ | The request sends | It runs as |
25
+ | --- | --- |
26
+ | the publishable key | `anon` |
27
+ | either key and a signed-in user's token | `authenticated` |
28
+ | the secret key | the app's own role, which owns the tables |
29
+
30
+ The role is set with `SET LOCAL ROLE` and the token's claims in `request.jwt.claims` and `request.jwt.claim.sub`, so Supabase's `auth.uid()` works in the policies. The database needs the `anon` and `authenticated` roles, and the app's role must be allowed to `SET ROLE` to them. Every read and write of `storage.objects` and `storage.buckets` runs as that role, with the token's claims set, so the restored policies decide, as on Supabase:
31
+
32
+ - an upload needs an `insert` policy, and one with `upsert` also `select` and `update`;
33
+ - a download, a signed URL, `info`, `list`, `copy`'s source and `move` need `select`, and `move` also `update`;
34
+ - `remove` and `empty` delete only what a `delete` policy allows;
35
+ - the bucket calls need policies on `storage.buckets`, which usually only the secret key gets past.
36
+
37
+ An upload is checked against the policies before its bytes are stored, then its row is written as the caller in one transaction. A refused upload stores nothing, and the bytes of a write that fails are deleted.
38
+
39
+ Public buckets are served at `/storage/v1/object/public/<bucket>/<name>` without a key. A signed URL serves one object to anyone until it expires; a signed upload URL takes one upload for two hours, written for the user who signed it.
40
+
41
+ ## What it serves
42
+
43
+ - `object/<bucket>/<name>`: upload (POST, with `x-upsert`), replace (PUT), download (GET, also `object/authenticated/...`), `exists` (HEAD) and delete.
44
+ - `object/public/...`, `object/sign/...` (one or many) and `object/upload/sign/...`.
45
+ - `object/list/<bucket>`, `object/move`, `object/copy` and `object/info/...`.
46
+ - `bucket`: list, get, create, update, empty and delete.
47
+
48
+ A download is sent with the type it was uploaded with, `nosniff` and a sandboxing Content-Security-Policy, so an uploaded page cannot run on the app's origin, and `?download` makes it an attachment.
49
+
50
+ Not yet: image transforms, resumable (TUS) uploads, the S3 protocol, object versioning and copying the bytes of an existing Supabase project.
51
+
52
+ ## Errors
53
+
54
+ Errors come back as Supabase Storage sends them: status `400` with `{ statusCode, error, message }`, where `statusCode` says what happened: `404` for an object or bucket that is not there or not visible, `403` for a refusal by policy, `409` for an object or bucket that exists, `413` for an object over the size limit, `415` for a type the bucket does not allow. A failure is `500`.