@protobase/cli 0.43.1 → 0.44.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/dist/cli/package.js +1 -1
- package/dist/project/long-connect.js +16 -0
- package/dist/project/pg-db.js +16 -8
- package/dist/project/pool-wait.js +20 -0
- package/dist/project/project-admin.js +1 -1
- package/dist/serve/env.js +2 -3
- package/package.json +6 -6
- package/skills/protobase/references/features/api-functions.md +1 -0
- package/skills/protobase/references/features/rest-api.md +1 -1
- package/skills/protobase/references/guides/api-functions.md +17 -0
- package/skills/protobase/references/guides/mobile-app.md +3 -3
- package/skills/protobase/references/reference/access.md +1 -1
- package/skills/protobase/references/reference/api.md +9 -7
- package/skills/protobase/references/reference/assistant.md +1 -1
- package/skills/protobase/references/reference/auth.md +15 -3
- package/skills/protobase/references/reference/cli.md +2 -2
- package/skills/protobase/references/reference/comments.md +1 -1
- package/skills/protobase/references/reference/data-config.md +8 -4
- package/skills/protobase/references/reference/events.md +1 -1
- package/skills/protobase/references/reference/files.md +4 -4
- package/skills/protobase/references/reference/jobs.md +1 -0
- package/skills/protobase/references/reference/layouts.md +1 -1
- package/skills/protobase/references/reference/mcp.md +1 -1
- package/skills/protobase/references/reference/supabase-realtime.md +2 -2
- package/skills/protobase/references/reference/supabase-rest.md +11 -1
- package/skills/protobase/references/reference/supabase-storage.md +6 -1
- package/skills/protobase/references/reference/ui-config.md +4 -4
- package/skills/supabase-move/references/deno.md +1 -1
package/dist/cli/package.js
CHANGED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
//#region src/project/long-connect.ts
|
|
2
|
+
const refusedAtLogin = (error) => error instanceof Error && error.code === "08P01";
|
|
3
|
+
/**
|
|
4
|
+
* The long-query pool's `connect`: a pooler that refuses the `statement_timeout` it logs in with is an error that says
|
|
5
|
+
* what the pooler lacks, rather than the protocol error it answers with.
|
|
6
|
+
*/
|
|
7
|
+
const connectLong = (pool) => async () => {
|
|
8
|
+
try {
|
|
9
|
+
return await pool.connect();
|
|
10
|
+
} catch (error) {
|
|
11
|
+
if (!refusedAtLogin(error)) throw error;
|
|
12
|
+
throw new Error("The database refused statement_timeout at login, which longQueries needs: a PgBouncer in front of it must list statement_timeout in track_extra_parameters", { cause: error });
|
|
13
|
+
}
|
|
14
|
+
};
|
|
15
|
+
//#endregion
|
|
16
|
+
export { connectLong };
|
package/dist/project/pg-db.js
CHANGED
|
@@ -1,14 +1,22 @@
|
|
|
1
1
|
import { gateBackgroundWork } from "./background-gate.js";
|
|
2
|
-
import {
|
|
2
|
+
import { connectLong } from "./long-connect.js";
|
|
3
|
+
import { connectOrBusy } from "./pool-wait.js";
|
|
4
|
+
import { appPool, longQueryPool, readDbConnections, wantsLongQueries } from "@protobase/server";
|
|
3
5
|
import { Kysely, PostgresDialect } from "kysely";
|
|
4
6
|
//#region src/project/pg-db.ts
|
|
5
|
-
const createPgDb = (pg, url, max =
|
|
6
|
-
const pool =
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
7
|
+
const createPgDb = (pg, url, max = readDbConnections(process.env)) => {
|
|
8
|
+
const pool = appPool(pg, url, max);
|
|
9
|
+
const long = longQueryPool(pg, url);
|
|
10
|
+
const shortConnect = connectOrBusy(pool);
|
|
11
|
+
const longConnect = connectLong(long);
|
|
12
|
+
const routed = {
|
|
13
|
+
options: pool.options,
|
|
14
|
+
connect: () => wantsLongQueries() ? longConnect() : shortConnect(),
|
|
15
|
+
end: async () => {
|
|
16
|
+
await Promise.all([pool.end(), long.end()]);
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
return new Kysely({ dialect: new PostgresDialect({ pool: gateBackgroundWork(routed, Math.max(1, max - 1)) }) });
|
|
12
20
|
};
|
|
13
21
|
//#endregion
|
|
14
22
|
export { createPgDb };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { ConnectionsBusy, poolWaitMs } from "@protobase/server";
|
|
2
|
+
//#region src/project/pool-wait.ts
|
|
3
|
+
/**
|
|
4
|
+
* The pool's `connect`, where a query that finds every connection in use and waits `poolWaitMs` for one (the pool's
|
|
5
|
+
* own `connectionTimeoutMillis`) fails with `ConnectionsBusy`, so a saturated app answers at once rather than queue
|
|
6
|
+
* requests behind slow ones. The pool tells its timeout by no code, so a failure counts as one when every connection
|
|
7
|
+
* was in use as the query asked; any other failure is the pool's own.
|
|
8
|
+
*/
|
|
9
|
+
const connectOrBusy = (pool) => async () => {
|
|
10
|
+
const max = pool.options.max ?? 10;
|
|
11
|
+
const full = pool.totalCount >= max && pool.idleCount === 0;
|
|
12
|
+
try {
|
|
13
|
+
return await pool.connect();
|
|
14
|
+
} catch (error) {
|
|
15
|
+
if (full && !pool.ending) throw new ConnectionsBusy(max, poolWaitMs, { cause: error });
|
|
16
|
+
throw error;
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
//#endregion
|
|
20
|
+
export { connectOrBusy };
|
|
@@ -4,7 +4,7 @@ import { configExports, createAdmin, jobDefinitions } from "@protobase/server";
|
|
|
4
4
|
* The admin API of a project over `db`, as `dev`, `serve` and `worker` build it: its config module's resources, views,
|
|
5
5
|
* pages and subscriptions, and the rest of its config; served from a bundle, the plugins it carries, their field
|
|
6
6
|
* types and which icons are the project's own (`protobase dev` passes the project's icons alone). `jobs` are the project's own and the delivery of its events and history. With a `reporter`, every error the API turns
|
|
7
|
-
* into a 500 goes to the error tracker too, besides the project's `onUnhandledError` or the console. With the host's
|
|
7
|
+
* into a 500, and every stopped query, goes to the error tracker too, besides the project's `onUnhandledError` or the console. With the host's
|
|
8
8
|
* `upgradeWebSocket`, it serves `/api/sb/realtime/v1` too.
|
|
9
9
|
*/
|
|
10
10
|
const projectAdmin = (project, config, db, ui, reporter, upgradeWebSocket) => {
|
package/dist/serve/env.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { readTrustedProxies } from "./client-address.js";
|
|
2
|
-
import { readSigningKey } from "@protobase/server";
|
|
2
|
+
import { readDbConnections, readSigningKey } from "@protobase/server";
|
|
3
3
|
//#region src/serve/env.ts
|
|
4
4
|
const defaultPort = 8787;
|
|
5
5
|
const readBoolean = (env, name, fallback) => {
|
|
@@ -14,8 +14,7 @@ const readServeEnv = (env) => {
|
|
|
14
14
|
const minutes = env.PROTOBASE_FILES_CLEANUP_MINUTES ? Number(env.PROTOBASE_FILES_CLEANUP_MINUTES) : 60;
|
|
15
15
|
if (!Number.isInteger(minutes) || minutes < 0) throw new Error(`PROTOBASE_FILES_CLEANUP_MINUTES must be a whole number of minutes, not "${env.PROTOBASE_FILES_CLEANUP_MINUTES}"`);
|
|
16
16
|
const mobileSigningKey = readSigningKey(env);
|
|
17
|
-
const connections = env.PROTOBASE_DB_CONNECTIONS ?
|
|
18
|
-
if (connections !== void 0 && (!Number.isInteger(connections) || connections < 1)) throw new Error(`PROTOBASE_DB_CONNECTIONS must be a whole number of connections, at least 1, not "${env.PROTOBASE_DB_CONNECTIONS}"`);
|
|
17
|
+
const connections = env.PROTOBASE_DB_CONNECTIONS ? readDbConnections(env) : void 0;
|
|
19
18
|
return {
|
|
20
19
|
port,
|
|
21
20
|
databaseUrl: env.DATABASE_URL || void 0,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@protobase/cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.44.0",
|
|
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.12",
|
|
37
37
|
"@hono/node-server": "^2.1.3",
|
|
38
38
|
"@hono/vite-dev-server": "^0.26.1",
|
|
39
|
-
"@protobase/layout": "0.
|
|
40
|
-
"@protobase/query": "0.
|
|
41
|
-
"@protobase/schema": "0.
|
|
42
|
-
"@protobase/server": "0.
|
|
43
|
-
"@protobase/ui": "0.
|
|
39
|
+
"@protobase/layout": "0.44.0",
|
|
40
|
+
"@protobase/query": "0.44.0",
|
|
41
|
+
"@protobase/schema": "0.44.0",
|
|
42
|
+
"@protobase/server": "0.44.0",
|
|
43
|
+
"@protobase/ui": "0.44.0",
|
|
44
44
|
"@react-email/render": "^2.1.0",
|
|
45
45
|
"@scalar/hono-api-reference": "^0.12.10",
|
|
46
46
|
"@tailwindcss/vite": "^4.3.3",
|
|
@@ -11,3 +11,4 @@ Endpoints of your own beside the REST API.
|
|
|
11
11
|
- [Public functions and webhooks](../guides/api-functions.md#public-functions-and-webhooks): A function can be open to anyone, with helpers that check webhook signatures.
|
|
12
12
|
- [WebSockets](../guides/api-functions.md#websockets): A function can accept a WebSocket, and the caller is checked again every minute.
|
|
13
13
|
- [Hono apps](../guides/api-functions.md#hono-apps): A function with several routes can be a Hono app.
|
|
14
|
+
- [Long queries](../guides/api-functions.md#long-queries): A function or job that does bulk work may run queries for up to 30 seconds, on a connection kept for it.
|
|
@@ -15,7 +15,7 @@ The API every resource gets, with filters, writes, errors and the typed client.
|
|
|
15
15
|
- [Batch writes](../reference/api.md#batch-writes): Up to 500 creates, updates, deletes and reorders across resources in one transaction.
|
|
16
16
|
- [Record permissions](../reference/api.md#record-permissions): Responses say which records and fields the caller may change.
|
|
17
17
|
- [Scan guard](../reference/api.md#safety): Reads that would scan a large table without an index are refused, with the index to create.
|
|
18
|
-
- [Statement timeouts](../reference/api.md#safety): Every request
|
|
18
|
+
- [Statement timeouts](../reference/api.md#safety): Every request's queries stop after 1 second by default, with an error that names the request, and reads run read-only.
|
|
19
19
|
- [Errors](../reference/api.md#errors): Every error is a problem document with a stable type and per-field details.
|
|
20
20
|
- [Audit events](../reference/api.md#audit-events): Reveals of sensitive values and organization changes are published as audit events.
|
|
21
21
|
- [Error reporting](../reference/api.md#error-reporting): Server and admin app errors go to a Sentry-compatible error tracker when a DSN is set.
|
|
@@ -390,9 +390,26 @@ defineFunction({ cors: { origin: 'https://workshop.pips-bikes.example' } }, app)
|
|
|
390
390
|
|
|
391
391
|
Preflight requests are answered before authentication, because a browser sends them without a token. Every response, including a `401` problem, carries the CORS headers. In a protected function, the `hono/cors` middleware inside a Hono app would never see the preflight, because authentication runs first.
|
|
392
392
|
|
|
393
|
+
## Long queries
|
|
394
|
+
|
|
395
|
+
A function's queries through `db` have the database's own statement timeout: on Protobase Cloud, 1 second, so a slow query fails where it runs instead of holding a connection that pages wait for. A function that does bulk work, such as an import, a report or a large delete, asks for longer:
|
|
396
|
+
|
|
397
|
+
```ts
|
|
398
|
+
export default defineFunction({ longQueries: true }, async (request, { db }) => {
|
|
399
|
+
await sql`delete from audit_log where at < now() - interval '1 year'`.execute(db)
|
|
400
|
+
return new Response(null, { status: 204 })
|
|
401
|
+
})
|
|
402
|
+
```
|
|
403
|
+
|
|
404
|
+
- **Up to 30 seconds** per query, the most any query of an app may run. Work longer than that belongs in steps, such as a [job](../reference/jobs.md) per batch, which takes `longQueries` too.
|
|
405
|
+
- **One connection kept for it.** Under `protobase dev` and `serve`, those queries run on a connection of their own, which asks for the longer timeout when it logs in, so long work never takes the connections pages need; a second long call waits for it. A PgBouncer of your own in front of the database must list `statement_timeout` in `track_extra_parameters` to pass that on; Protobase Cloud's does. With a `db` the project exports itself, the option changes nothing.
|
|
406
|
+
- **`records` keep the API's limit,** [`statementTimeoutMs`](../reference/api.md#safety).
|
|
407
|
+
- **A query past its limit** is stopped, and the call answers `504 statement-timeout` naming the call, its limit and the way out, such as `POST /api/functions/import ran a query longer than the database's statement timeout, so the database stopped it. Make the query faster, such as with an index or a narrower filter, or give it longQueries: true, whose queries may run up to 30 s.` It goes to `options.onUnhandledError` and the [error tracker](../reference/api.md#error-reporting).
|
|
408
|
+
|
|
393
409
|
## Errors
|
|
394
410
|
|
|
395
411
|
- **Problems:** throw an `HttpProblem` (or `badRequest`, `unauthorized`, `forbidden`, `notFound` from `@protobase/server`) to answer with an [RFC 9457 problem](../reference/api.md#errors). Hono's `HTTPException` works too.
|
|
412
|
+
- **A query the database stopped** is a `504 statement-timeout` that names the call; see [Long queries](#long-queries).
|
|
396
413
|
- **Everything else:** any other error, or a handler that returns something other than a `Response`, becomes a `500 internal-error` problem without its message. The error goes to `options.onUnhandledError`, which `protobase dev` and `serve` print.
|
|
397
414
|
|
|
398
415
|
## Functions moved from Supabase
|
|
@@ -7,7 +7,7 @@ Run a Protobase app on iOS and Android and build signed store releases from a mo
|
|
|
7
7
|
A Protobase app runs as an iOS or Android app with nothing more than a `mobile` section in its `protobase.config.ts`. `protobase mobile` wraps the app in [Capacitor](https://capacitorjs.com): the app's shell, its UI plugins, theme and favicon open from files on the device, and the app calls your server's API.
|
|
8
8
|
|
|
9
9
|
:::caution[Beta]
|
|
10
|
-
In the app, passkeys
|
|
10
|
+
<gap>In the app, passkeys do not work yet.</gap> <gap>In the app, sign-in with another provider does not work yet.</gap> <gap>"Forgot password?" is not offered in the app, as the emailed link cannot lead back into it.</gap>
|
|
11
11
|
:::
|
|
12
12
|
|
|
13
13
|
## 1. Install the tools
|
|
@@ -37,10 +37,10 @@ With a mobile section, the API answers the app's origins, `capacitor://localhost
|
|
|
37
37
|
|
|
38
38
|
Signing in works in the app as on the web, with nothing more to set up:
|
|
39
39
|
|
|
40
|
-
- Emailed codes, passwords and the second step of two-factor authentication work. Passkeys
|
|
40
|
+
- Emailed codes, passwords and the second step of two-factor authentication work. <gap>Passkeys do not work in the app yet.</gap> <gap>Sign-in with another provider does not work in the app yet.</gap>
|
|
41
41
|
- The app calls `/api/auth` through the device's native HTTP, naming its Capacitor origin. With a mobile section, sign-in trusts the Capacitor origin a request names, for that request only, without CORS.
|
|
42
42
|
- The session lives in the device's cookie store, so it survives reloads, updates and relaunches. On iOS, signing in or out within about a second of killing the app may be lost.
|
|
43
|
-
- "Forgot password?" is not offered in the app, as the emailed link cannot lead back into it
|
|
43
|
+
- <gap>"Forgot password?" is not offered in the app, as the emailed link cannot lead back into it.</gap>
|
|
44
44
|
- In the app, page script can reach the session cookie through Capacitor's native plugins, so keep untrusted script out of UI plugins.
|
|
45
45
|
- While you develop over plain `http://localhost` with a mobile section, a page served on `https://localhost` in the same browser can send sign-in requests that carry your dev session, as some browsers treat the two as the same site. Do not open untrusted pages on `https://localhost` while you develop.
|
|
46
46
|
|
|
@@ -160,7 +160,7 @@ export const operations = resource('operations')
|
|
|
160
160
|
|
|
161
161
|
- **Every write is checked.** Creating a record checks the parent it names; changing it, the parent it points at and the one it moves to; deleting and undeleting it, the parent it points at. So a record cannot be created under an allowed parent and then moved under another. It holds for `/api/v1` and its batches, and for everything that writes through them: forms, [API functions](../guides/api-functions.md) and the assistant.
|
|
162
162
|
- **The caller's own rules decide.** The parent is read as the caller would read it, with its tenant, row filters, soft delete and record-level rules; for `update`, also its update row filter and record-level update rule, given an empty input. A parent the caller cannot see, may not update, that is soft deleted or does not exist gets the same `403` as a refused create (`You may not create this operations record`), and nothing is written: the answer does not tell which VM ids exist.
|
|
163
|
-
- **One column, to a key of one field.**
|
|
163
|
+
- **One column, to a key of one field.** <gap>A relation of several columns cannot be a parent: the config does not load with one.</gap> The server does not start with a parent resource the app does not have. <gap>A resource whose key has several fields cannot be a parent: the server does not start with one.</gap>
|
|
164
164
|
- **A null relation checks nothing.** A relation set by a column default or a trigger is checked from the record as written.
|
|
165
165
|
- **`update` follows the parent's own parents**, so with VMs under `.parent((r) => r.folder_id, 'update')` an operation needs update on the VM's folder too. A write that would put a record under itself, or under a cycle already in the data, is refused. A `read` parent is not followed further.
|
|
166
166
|
- **Several parents** are each checked with their own access, also two of one resource, such as a transfer that reads its `source_vm_id` and updates its `target_vm_id`.
|
|
@@ -19,7 +19,7 @@ const admin = createAdmin({
|
|
|
19
19
|
authenticate, // required: no development mode; anonymous only with that role
|
|
20
20
|
auth, // optional: mounts login at /api/auth/*
|
|
21
21
|
functions, // optional: your own endpoints at /api/functions/<name>, see /guides/api-functions/
|
|
22
|
-
options: { statementTimeoutMs:
|
|
22
|
+
options: { statementTimeoutMs: 1_000, scanGuard: { mode: 'reject' } },
|
|
23
23
|
})
|
|
24
24
|
```
|
|
25
25
|
|
|
@@ -144,10 +144,11 @@ With [organizations](auth.md#organizations), someone with a global role switchin
|
|
|
144
144
|
Create, update and delete share one pipeline (`write-pipeline.ts`):
|
|
145
145
|
|
|
146
146
|
1. the caller is authenticated and, for tenant-scoped resources, has a tenant (`403` otherwise);
|
|
147
|
-
2. unknown fields, read-only fields and the tenant column in the body are refused, each value is validated by its field's zod schema (an empty string for a text field without `.optional()` counts as missing: `required`, or its default on a create), then the resource's `.validate()` rules run (`400` with `errors: [{ field, code, message }]`);
|
|
147
|
+
2. unknown fields, read-only fields and the tenant column in the body are refused, each value is validated by its field's zod schema (an empty string for a text field without `.optional()` counts as missing: `required`, or its default on a create), then the resource's `.validate()` rules run (`400` with `errors: [{ field, code, message }]`); what needs the network is checked before the transaction opens, such as the address of a [webhook subscription](webhooks.md)'s URL;
|
|
148
148
|
3. one transaction with `SET LOCAL statement_timeout`; the row is locked with `FOR UPDATE`; another tenant's key, or a soft-deleted row, is a `404`;
|
|
149
149
|
4. the access rule runs, then `If-Match` is compared with the ETag (`428` when missing on PATCH, `412` when stale);
|
|
150
|
-
5. the write, then `writeHooks` inside the same transaction (a hook that throws rolls the write back). Audit logging and the admin store plug in here.
|
|
150
|
+
5. the write, then `writeHooks` inside the same transaction (a hook that throws rolls the write back). Audit logging and the admin store plug in here. A hook does database work only, through the transaction it is given: while it waits on anything else, such as an HTTP call, the transaction stays open with the row locked, and on Protobase Cloud the database ends a transaction left idle for a second. Work that waits belongs in a [job](jobs.md) the hook enqueues;
|
|
151
|
+
6. once it commits, the files it took out of its rows are scheduled for deletion (see [Deleting files](files.md#deleting-files)), so the transaction never waits on the storage.
|
|
151
152
|
|
|
152
153
|
**ETag**: the `version` or `updated_at` column when the resource has a read-only one (bumped on every update, so no trigger is needed; the ETag keeps the column's full microsecond text), otherwise a hash of the exposed fields. It is computed from the row itself, so lists need no extra query.
|
|
153
154
|
|
|
@@ -193,7 +194,8 @@ The API sends no CORS headers until it has something to allow: other websites in
|
|
|
193
194
|
|
|
194
195
|
## Safety
|
|
195
196
|
|
|
196
|
-
- Every request runs in a transaction with `SET LOCAL statement_timeout` (`statementTimeoutMs`, default
|
|
197
|
+
- Every request runs in a transaction with `SET LOCAL statement_timeout` (`statementTimeoutMs`, default 1 s), so a slow query fails where it runs instead of holding a connection that other requests wait for. List, search, get, histogram, series, map and seek transactions are read-only. A query that runs longer is stopped: a `504` `statement-timeout` that names the request, its limit and the ways out, such as `GET /api/v1/orders ran a query longer than 1 s, so the database stopped it. Make the query faster, such as with an index or a narrower filter, or move the work into a function or job with longQueries: true, whose queries may run up to 30 s.` It goes to `options.onUnhandledError` and the [error tracker](#error-reporting) like a `500`. A read that needs longer has no way to opt out: give it an index, or move it into a [function](../guides/api-functions.md#long-queries) or [job](jobs.md) with `longQueries`.
|
|
198
|
+
- Under `protobase dev` and `serve`, a request waits at most 2 seconds for a free database connection. When every connection stays busy that long, it is a `503` `connections-busy` with `Retry-After: 1` that names the request, reported the same way, rather than a request that hangs behind slow ones.
|
|
197
199
|
- **Scan guard**: a list, `:search`, `:seek`, `:map` page, card photos, `:facets` and `:aggregate` read only columns an index serves, so they stay cheap however many rows match. The server reads each table's valid indexes from the catalog once, then checks every column the caller's filter, the role's row filter, the sort's first field and a facet's or an aggregate's grouped field read:
|
|
198
200
|
- Comparisons, `in`, null checks, sorts and facets need a btree index with the column as a key, every key before it pinned by the query: by `=` or `in` in the filter (outside `OR` and `NOT`), by the tenant or by soft delete. `(for_sale, status, published_at desc)` serves `for_sale = true AND status = "available"` sorted by `published_at desc`, but not `status` alone. `=` on text may use a pg_trgm index instead.
|
|
199
201
|
- Patterns (`name = "*port*"`), `regex()`, `similar()` and `search()` need a pg_trgm (GIN or GiST) index on each column they read, a `digitsEnd` search field one on its digits; JSON `field:value` needs a GIN index.
|
|
@@ -213,8 +215,8 @@ Every error is `application/problem+json` (RFC 9457) with `type` (`urn:protobase
|
|
|
213
215
|
| 404 | `not-found` |
|
|
214
216
|
| 409 | `conflict` |
|
|
215
217
|
| 412 / 428 | `precondition-failed` / `precondition-required` |
|
|
216
|
-
| 503 | `read-only`: the database refuses writes, as during a deploy's write freeze; send the write again after `Retry-After` |
|
|
217
|
-
| 504 | `statement-timeout
|
|
218
|
+
| 503 | `read-only`: the database refuses writes, as during a deploy's write freeze; send the write again after `Retry-After`. `connections-busy`: every database connection stayed busy for 2 seconds (see [Safety](#safety)) |
|
|
219
|
+
| 504 | `statement-timeout`: a query ran past its limit (see [Safety](#safety)) |
|
|
218
220
|
|
|
219
221
|
### Error reporting
|
|
220
222
|
|
|
@@ -226,7 +228,7 @@ export default defineConfig({
|
|
|
226
228
|
})
|
|
227
229
|
```
|
|
228
230
|
|
|
229
|
-
- **Server:** every `500` with the request it failed, under `dev`, `serve` and the runtime, besides `options.onUnhandledError` or the console. Under `serve`, the runtime and `worker`, an uncaught exception or unhandled rejection too, which then still ends the process with exit code 1.
|
|
231
|
+
- **Server:** every `500` with the request it failed, and every `504 statement-timeout` and `503 connections-busy` with the request it names, under `dev`, `serve` and the runtime, besides `options.onUnhandledError` or the console. Under `serve`, the runtime and `worker`, an uncaught exception or unhandled rejection too, which then still ends the process with exit code 1.
|
|
230
232
|
- **Admin app:** uncaught errors and the errors of components that fail to draw. `/api/meta` names the DSN to every signed-in caller, as a browser app always shows its own.
|
|
231
233
|
- Errors only, with no performance tracing. Before an event leaves, the values of authorization headers, cookies, passwords, tokens and other credentials, in fields and in URLs, are replaced by `[Filtered]`.
|
|
232
234
|
- `environment` names the deployment in the tracker; without it the tracker's default, `production`. `errorReporting: false` turns reporting off whatever the environment says. A DSN that is no `http(s)` URL with a key and a project id stops startup.
|
|
@@ -110,7 +110,7 @@ The tool and its component live apart, joined by the name, since the server conf
|
|
|
110
110
|
|
|
111
111
|
Each message carries the page the user is on, such as `/orders/42`, which the model reads with it.
|
|
112
112
|
|
|
113
|
-
There is one conversation per user, shared by their tabs
|
|
113
|
+
<gap>There is one conversation per user, shared by their tabs.</gap> The server keeps it as a file, `<chats>/<user>/chat.jsonl` (see `PROTOBASE_ASSISTANT_CHATS`), with the chat and everything the model read, so a restart keeps it and the app only ever sends the new message. The directory is made on the first message and must be writable: in a container, point it at a volume. With several instances, send each user's requests to the same one.
|
|
114
114
|
|
|
115
115
|
## Another backend
|
|
116
116
|
|
|
@@ -23,7 +23,7 @@ Users, sessions and signing keys stay apart from the application's tables. The E
|
|
|
23
23
|
createAuth({ database: { dialect: new PostgresDialect({ pool }), type: 'postgres', schemaName: 'auth', transaction: true }, ... })
|
|
24
24
|
```
|
|
25
25
|
|
|
26
|
-
Build that pool
|
|
26
|
+
Build that pool with `appPool(pg, process.env.DATABASE_URL)` (from `@protobase/server`), as the presets do: it is the app's one pool on that database, which `protobase dev` and `serve` share, so the store opens no connections beyond [`PROTOBASE_DB_CONNECTIONS`](cli.md#serve), and a database restart is printed instead of stopping the app. A pool of the app's own, such as `new pg.Pool(...)`, opens its connections beside the runtime's.
|
|
27
27
|
|
|
28
28
|
### Migrations
|
|
29
29
|
|
|
@@ -339,7 +339,12 @@ Instead of the metadata XML, `idp` takes the provider's entity ID, sign-in URL a
|
|
|
339
339
|
- **Sign-in links** work as for the other providers: `https://<app>/?sign-in=okta` starts it at once. A SAML provider links an account by signing in, so the Sign-in & security page does not offer to connect it.
|
|
340
340
|
- `GET /api/auth/status` lists the providers as `samlProviders: [{ id, name }]`. Like `socialProviders`, they have no row in the [sign-in policy](#sign-in-policy), and a required passkey or two-factor authentication still holds back the token until it is set up.
|
|
341
341
|
- **No migration:** the providers live in config, so the store gets no table for them.
|
|
342
|
-
- The plugin's defaults stay: the response must answer a request this app made, within 5 minutes of clock skew, once. Not supported yet:
|
|
342
|
+
- The plugin's defaults stay: the response must answer a request this app made, within 5 minutes of clock skew, once. Not supported yet:
|
|
343
|
+
- <gap>SAML sign-in does not support SCIM yet.</gap>
|
|
344
|
+
- <gap>SAML sign-in does not support single logout yet.</gap>
|
|
345
|
+
- <gap>SAML sign-in cannot be started at the provider yet.</gap>
|
|
346
|
+
- <gap>SAML providers cannot be kept per organization yet.</gap>
|
|
347
|
+
- <gap>SAML sign-in does not support signed or encrypted requests yet.</gap>
|
|
343
348
|
|
|
344
349
|
## Platform sign-in provider
|
|
345
350
|
|
|
@@ -493,7 +498,14 @@ An app moving from Supabase keeps its `supabase.auth` calls and its `@supabase/s
|
|
|
493
498
|
- The access token is ES256, valid for an hour, with Supabase's claims: `sub`, `role: authenticated`, `aud: authenticated`, `email`, `app_metadata`, `user_metadata`, `aal`, `session_id`, issued by `<baseURL>/api/sb/auth/v1`. Its keys are at `/api/sb/auth/v1/.well-known/jwks.json`. It is apart from the EdDSA token of [Tokens and roles](#tokens-and-roles): neither is accepted for the other.
|
|
494
499
|
- The refresh token is the Better Auth session's token. Each refresh gives the session a new one, so a refresh token works once, and signing out, a ban or a revoked session ends it.
|
|
495
500
|
- `email_confirmed_at` is the time the address was confirmed, in the user table's `email_confirmed_at` column. An account verified before that column existed has none.
|
|
496
|
-
- Not offered:
|
|
501
|
+
- Not offered:
|
|
502
|
+
- <gap>`/api/sb/auth/v1` does not offer MFA.</gap>
|
|
503
|
+
- <gap>`/api/sb/auth/v1` does not offer passkeys.</gap>
|
|
504
|
+
- <gap>`/api/sb/auth/v1` does not offer SSO.</gap>
|
|
505
|
+
- <gap>`/api/sb/auth/v1` does not offer phone sign-in.</gap>
|
|
506
|
+
- <gap>`/api/sb/auth/v1` does not offer anonymous sign-in.</gap>
|
|
507
|
+
- <gap>`/api/sb/auth/v1` does not offer the admin API.</gap>
|
|
508
|
+
- <gap>`/api/sb/auth/v1` does not offer changing the address.</gap>
|
|
497
509
|
|
|
498
510
|
## Tokens for scripts and curl
|
|
499
511
|
|
|
@@ -376,7 +376,7 @@ Serves the API of a bundle from `protobase build` and owns the process around it
|
|
|
376
376
|
| Variable | |
|
|
377
377
|
| --- | --- |
|
|
378
378
|
| `DATABASE_URL` | the API's pool (Kysely over `pg`, 10 connections); not needed when the config exports `db` |
|
|
379
|
-
| `PROTOBASE_DB_CONNECTIONS` | the connections that pool opens, such as the database's limit for the app; default 10. [API functions](../guides/api-functions.md) and [jobs](jobs.md) hold at most one less, so a long import leaves a connection to page and API requests |
|
|
379
|
+
| `PROTOBASE_DB_CONNECTIONS` | the connections that pool opens, such as the database's limit for the app; default 10. The app's own code shares them through [`appPool`](auth.md#admin-store), as the presets' Better Auth store does. [API functions](../guides/api-functions.md) and [jobs](jobs.md) hold at most one less, so a long import leaves a connection to page and API requests; those with [`longQueries`](../guides/api-functions.md#long-queries) take theirs from one more connection, kept for them. A query waits at most 2 seconds for a free connection, then fails with `503 connections-busy` ([Safety](api.md#safety)) |
|
|
380
380
|
| `PORT` | default 8787 |
|
|
381
381
|
| `REQUEST_LOG` | `true` logs every request; default `false` |
|
|
382
382
|
| `PROTOBASE_SMTP_URL` | the SMTP server for password-reset mail, emailed sign-in and two-factor codes and the app's own [email](email.md), credential included: `smtp://user:password@host:587` (STARTTLS when offered) or `smtps://...:465`; without it they are off ([Password reset](auth.md#password-reset), [Emailed sign-in codes](auth.md#emailed-sign-in-codes)) |
|
|
@@ -525,7 +525,7 @@ Turns a Supabase project's database into the project in the current directory, i
|
|
|
525
525
|
|
|
526
526
|
1. **The first run** takes the Supabase database's connection string, for its `postgres` role (the session pooler's or the direct one; the transaction pooler cannot hold the snapshot the dumps share). It fails unless the database has Supabase's `auth` and `storage` schemas and its `supabase_admin` role, and while `auth.users` has single sign-on (SAML) users, which Supabase opens only through their identity provider and Better Auth would find by email: merge or delete them in Supabase first. It notes the Supabase CLI's `supabase/config.toml`, `supabase/migrations/` and `supabase/functions/` when the checkout has them. It converts `supabase/functions` into the project's `functions/` (see [functions moved from Supabase](../guides/api-functions.md#functions-moved-from-supabase)): `Deno.serve(handler)` and std's `serve(handler)` become `export default defineFunction({ supabase: true }, { fetch: handler })`, an existing default export is wrapped the same way, so each function also answers at `/api/sb/functions/v1/<name>`, `npm:`, `jsr:` and esm.sh imports become bare imports of packages it adds to `package.json`, `Deno.env.get(name)` becomes `process.env[name]`, `EdgeRuntime.waitUntil` becomes `waitUntil` of `@protobase/server`, a function with `verify_jwt = false` in `config.toml` becomes public (`{ public: true, supabase: true }`), and `_shared` and the like are converted beside them. It stops before anything else when `functions/` already has one of their names. It dumps `auth`, `storage` and every schema the app made, schema and data apart, as of one snapshot, leaving out the platform's own migration tables, and writes the schemas as the project's next migration, `NNN_supabase_schema.sql`. It asks the project's database which of the app's extensions its role may create, by trying each in a transaction it rolls back: Postgres alone allows the trusted ones, Supabase's Postgres image all it allowlists, such as pg_net, pgmq and Vault. The migration creates those first, then, where pg_net is among them and the app has Database Webhooks, the `supabase_functions.http_request` function their triggers call, over pg_net; then the dump without what fails there, as comments: grants and default privileges for `dashboard_user`, `supabase_*`, `authenticator` and `postgres`, statements about the `public` schema, Realtime's publication, pgsodium's security labels, the views that decrypt with it and the triggers that encrypt with it, database webhooks without pg_net, functions in plv8, plls or plcoffee where the database has no such language, and a timescaledb hypertable's insert-blocking trigger. It then writes `NNN_supabase_users.sql`, the nullable columns Better Auth needs on `auth.users` (`name`, `email_verified`, `image`, `app_role`, `banned`, `ban_reason`, `ban_expires`) and GoTrue's `'authenticated'` as the default of `role` and `aud`. It points the app at `auth.users`: `auth/auth.ts` gets `...supabaseUsers` in its one `createAuth({` call, from the new `auth/supabase-users.ts` (the table, `role` in `app_role`, `raw_user_meta_data` as the metadata, bcrypt hashes and UUID ids; see [an existing users table](auth.md#an-existing-users-table)). It removes the migrations `protobase auth migration` or `protobase migration` wrote for Protobase's own user table, since `auth.users` replaces it, and stops before writing anything when `auth/auth.ts` is missing or calls `createAuth({` other than once, or when the project's database has a schema the dump creates already, such as the `auth` schema those migrations made. The project's database needs the roles `anon`, `authenticated` and `service_role` that the dump's grants and policies name; the command makes them when its role may, and otherwise stops, naming them. The data dump goes to `supabase-import/`, which it adds to `.gitignore`, since it holds every row and the users' password hashes. Where the project's database can create Vault, pgmq and pg_cron, `supabase-import/replay.sql` holds what a dump cannot carry: Vault's secrets with their values, read decrypted since only Supabase's key opens their ciphertext, pgmq's queues with their messages, since pgmq owns their tables, and pg_cron's jobs, which live in its own schema.
|
|
527
527
|
2. **Apply the migration** with the project's other migrations, such as `bun run db:migrate`.
|
|
528
|
-
3. **The second run**, without a connection string, loads the data in one transaction, with the app's triggers off so a sign-up trigger on `auth.users` does not run again for users who already have their rows, and fails the transaction unless every table holds the source's number of rows. In the same transaction it makes Vault's secrets and pgmq's queues again through `vault.create_secret`, `pgmq.create` and `pgmq.send`, each message with its headers and the time it becomes visible. Where the project's database has pg_cron, as Supabase's Postgres image does when it serves that database, it schedules pg_cron's jobs again there with `cron.schedule`, run by the importing role, an inactive one inactive. Elsewhere it writes each job of plain SQL as a [recurring job](jobs.md#recurring-jobs) of its own in `jobs/`, of the same name, schedule and `cron.timezone`, that runs its SQL as the app's database role, tried once each time as pg_cron did, exports it from `jobs/index.ts` and adds `jobs` to `protobase.config.ts` (or writes one); they run once [`migration`](#migration) has added the jobs schema. Recurring jobs wake an app that sleeps, so they run where a host stops an idle app too. A job that calls what the database lacks, such as pg_net's `net.http_*`, `cron` or Vault, an inactive one and a schedule recurring jobs do not take, such as `30 seconds` or `$`, stay in the report, as does a job of another database. It loads only into empty tables, deletes the data dump and the replay, runs [`scaffold`](#scaffold) on the imported tables of the app's schemas (not `auth` or `storage`), giving the tables of the `supabase_realtime` publication [`.live()`](live.md) so [`/api/sb/realtime/v1`](supabase-realtime.md) keeps sending their `postgres_changes` once [`migration`](#migration) has written their capture triggers, writes Better Auth's other tables next to `auth.users` as [`auth migration`](#auth-migration) does (`NNN_auth.sql`), then `NNN_supabase_accounts.sql`, and writes `supabase-import/report.md`: the rows loaded, the imported tables' size against the Starter plan's 500 MB, each sign-in provider's identities, what it made again, the tables it made live, and what needs a person: the pg_cron jobs it could not carry over, each with why, Realtime tables it made no resource of, Vault secrets by name and pgmq queues where the database has no such extension (and partitioned queues), the columns pgsodium encrypts, still holding Supabase's ciphertext, whose values to export decrypted in Supabase before declaring them [`.encrypted()`](data-config.md#encrypted-fields) and running [`encryption apply`](#encryption-apply), the extensions it cannot create, hypertables and plv8, plls or plcoffee functions to convert, triggers that call out over HTTP without pg_net, the converted Edge Functions with the packages to install and the code the conversion left (`deno.land/x` imports, Deno's file, KV and WebSocket APIs, `Supabase.ai`), and the indexes [`doctor`](#doctor) finds missing. `NNN_supabase_accounts.sql` fills the user columns from what Supabase Auth recorded and leaves them empty where it recorded nothing: the name from `raw_user_meta_data`'s `full_name` or `name`, the picture from its `avatar_url` or `picture`, `email_verified` from `email_confirmed_at`, and a ban from `banned_until`, which Better Auth lifts once it has passed. It gives each password of a confirmed address, as Supabase hashed it, a `credential` account (a user who never confirmed theirs signs in by code or resets the password, since GoTrue refused their password sign-in too), and each identity of a social provider an account under Better Auth's name for it (`azure` is `microsoft`, keyed on the `oid` claim; `linkedin_oidc` is `linkedin`, `slack_oidc` is `slack`, `x` is `twitter`), unless its user has an address they never confirmed, since GoTrue refused that sign-in too. Email, phone, anonymous and single sign-on identities
|
|
528
|
+
3. **The second run**, without a connection string, loads the data in one transaction, with the app's triggers off so a sign-up trigger on `auth.users` does not run again for users who already have their rows, and fails the transaction unless every table holds the source's number of rows. In the same transaction it makes Vault's secrets and pgmq's queues again through `vault.create_secret`, `pgmq.create` and `pgmq.send`, each message with its headers and the time it becomes visible. Where the project's database has pg_cron, as Supabase's Postgres image does when it serves that database, it schedules pg_cron's jobs again there with `cron.schedule`, run by the importing role, an inactive one inactive. Elsewhere it writes each job of plain SQL as a [recurring job](jobs.md#recurring-jobs) of its own in `jobs/`, of the same name, schedule and `cron.timezone`, that runs its SQL as the app's database role, tried once each time as pg_cron did, exports it from `jobs/index.ts` and adds `jobs` to `protobase.config.ts` (or writes one); they run once [`migration`](#migration) has added the jobs schema. Recurring jobs wake an app that sleeps, so they run where a host stops an idle app too. A job that calls what the database lacks, such as pg_net's `net.http_*`, `cron` or Vault, an inactive one and a schedule recurring jobs do not take, such as `30 seconds` or `$`, stay in the report, as does a job of another database. It loads only into empty tables, deletes the data dump and the replay, runs [`scaffold`](#scaffold) on the imported tables of the app's schemas (not `auth` or `storage`), giving the tables of the `supabase_realtime` publication [`.live()`](live.md) so [`/api/sb/realtime/v1`](supabase-realtime.md) keeps sending their `postgres_changes` once [`migration`](#migration) has written their capture triggers, writes Better Auth's other tables next to `auth.users` as [`auth migration`](#auth-migration) does (`NNN_auth.sql`), then `NNN_supabase_accounts.sql`, and writes `supabase-import/report.md`: the rows loaded, the imported tables' size against the Starter plan's 500 MB, each sign-in provider's identities, what it made again, the tables it made live, and what needs a person: the pg_cron jobs it could not carry over, each with why, Realtime tables it made no resource of, Vault secrets by name and pgmq queues where the database has no such extension (and partitioned queues), the columns pgsodium encrypts, still holding Supabase's ciphertext, whose values to export decrypted in Supabase before declaring them [`.encrypted()`](data-config.md#encrypted-fields) and running [`encryption apply`](#encryption-apply), the extensions it cannot create, hypertables and plv8, plls or plcoffee functions to convert, triggers that call out over HTTP without pg_net, the converted Edge Functions with the packages to install and the code the conversion left (`deno.land/x` imports, Deno's file, KV and WebSocket APIs, `Supabase.ai`), and the indexes [`doctor`](#doctor) finds missing. `NNN_supabase_accounts.sql` fills the user columns from what Supabase Auth recorded and leaves them empty where it recorded nothing: the name from `raw_user_meta_data`'s `full_name` or `name`, the picture from its `avatar_url` or `picture`, `email_verified` from `email_confirmed_at`, and a ban from `banned_until`, which Better Auth lifts once it has passed. It gives each password of a confirmed address, as Supabase hashed it, a `credential` account (a user who never confirmed theirs signs in by code or resets the password, since GoTrue refused their password sign-in too), and each identity of a social provider an account under Better Auth's name for it (`azure` is `microsoft`, keyed on the `oid` claim; `linkedin_oidc` is `linkedin`, `slack_oidc` is `slack`, `x` is `twitter`), unless its user has an address they never confirmed, since GoTrue refused that sign-in too. Email, phone, anonymous and single sign-on identities and sessions do not carry over. <gap>The import cannot carry over MFA factors because that is not implemented.</gap> <gap>The import cannot carry over passkeys because that is not implemented.</gap>
|
|
529
529
|
4. **Apply the migrations** again. Supabase's users then sign in with their own passwords, and with a social provider once it is in `createAuth`'s `socialProviders`; new users get a UUID in `auth.users`, so the app's triggers there run for them.
|
|
530
530
|
|
|
531
531
|
5. **Storage's files**: with `--storage-url https://<ref>.supabase.co` and the project's secret key in the variable `--storage-key-env` names, `SUPABASE_SERVICE_ROLE_KEY` by default, the second run, or any run after it, copies the bytes of every object in `storage.objects` from the Supabase project's Storage API into the app's [Storage file provider](supabase-storage.md#where-things-are-kept), where [`/api/sb/storage/v1`](supabase-storage.md) serves them, with the type and cache control the rows recorded. It streams each object, checks its byte count against the size Supabase recorded and its MD5 against the ETag where that is one, and deletes a copy that does not match. It first prints each bucket's size and stops when what is left to copy and what the provider holds exceed the provider's `max_bytes`, unless `--yes`. An object that fails does not stop the rest; the run then fails, listing them in `supabase-import/storage.md`, and a rerun copies only what the provider does not hold yet. The key goes only in the requests' headers, never in a file.
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
Comments on a resource's records by anyone who may read them, with @mentions that email the people named, shown on the record page and listed for admins.
|
|
6
6
|
|
|
7
|
-
A resource with [`.comments()`](https://docs.protobase.net/api/schema/interfaces/resourcebuilder/#comments) takes comments on its records: plain text, each with its author and time. Typing `@` in a comment mentions someone, who gets an email with a link to the record. Comments cannot be edited
|
|
7
|
+
A resource with [`.comments()`](https://docs.protobase.net/api/schema/interfaces/resourcebuilder/#comments) takes comments on its records: plain text, each with its author and time. Typing `@` in a comment mentions someone, who gets an email with a link to the record. <gap>Comments cannot be edited.</gap> <gap>Comments have no replies.</gap> <gap>Comments have no reactions.</gap>
|
|
8
8
|
|
|
9
9
|
```ts title="config/tickets.ts"
|
|
10
10
|
import { f, l, resource, view } from '@protobase/schema'
|
|
@@ -147,7 +147,11 @@ export const products = resource('products')
|
|
|
147
147
|
## Rollups and formulas
|
|
148
148
|
|
|
149
149
|
:::caution[Beta]
|
|
150
|
-
|
|
150
|
+
Not yet:
|
|
151
|
+
|
|
152
|
+
- <gap>A rollup over its own table is not supported yet.</gap>
|
|
153
|
+
- <gap>A rollup on a resource with a key of several columns is not supported yet.</gap>
|
|
154
|
+
- <gap>A rollup through a relation of several columns is not supported yet.</gap>
|
|
151
155
|
:::
|
|
152
156
|
|
|
153
157
|
A **rollup** is a value of the other records that point at a record, such as an order's total of its lines. A **formula** is a value computed from the record's own fields, such as a line's amount. Neither needs SQL: you declare the field, and [`protobase migration`](cli.md#migration) writes its column into the project's next migration (`NNN_computed.sql`). Both are real columns, kept by the database in the transaction that writes, so they are right for writes from psql or other services too, and they filter and sort like any column once they have an index.
|
|
@@ -194,7 +198,7 @@ export const orderLines = resource('order_lines')
|
|
|
194
198
|
| `avg` | The average of `field`. Empty without records. | `f.decimal()`, `.optional()` |
|
|
195
199
|
| `min`, `max` | The least or greatest value of `field`. Empty without records. | a number field, `.optional()` |
|
|
196
200
|
|
|
197
|
-
Empty values of `field` are left out, as in SQL. The migration adds the column, a function in the `rollups` schema and a trigger on `from`'s table that sets the value after every insert, delete and update of the columns it reads, and then sets every record's value once. A rollup over its own table
|
|
201
|
+
Empty values of `field` are left out, as in SQL. The migration adds the column, a function in the `rollups` schema and a trigger on `from`'s table that sets the value after every insert, delete and update of the columns it reads, and then sets every record's value once. <gap>A rollup over its own table is not supported yet.</gap> <gap>A rollup on a resource with a key of several columns is not supported yet.</gap> <gap>A rollup through a relation of several columns is not supported yet.</gap>
|
|
198
202
|
|
|
199
203
|
`.formula(expression)` is a Postgres generated column. The expression reads the record's number fields, and takes numbers, `+ - * /`, parentheses, `coalesce(a, b, ...)` and `round(x)` or `round(x, digits)`. It is computed exactly as decimals, so `7 / 2` is 3.5, and is stored as the field's type, so an integer field rounds the result. A formula that reads an optional field is `.optional()` too, unless `coalesce()` gives that field a value. A formula cannot read another formula. When the expression changes, the migration drops the column and adds it again, so an index on it must be created again in the same migration.
|
|
200
204
|
|
|
@@ -249,7 +253,7 @@ To rotate it on several instances:
|
|
|
249
253
|
|
|
250
254
|
**A lost key loses its values.** Nothing can decrypt them; `status` lists them as `unknown-key`, and writing a new value replaces one. `apply` refuses to run while a column holds values under none of its keys, so a wrong key in a local `.env` does not seal values the app cannot read; clear values whose key is lost (set them to `null` with SQL) to go on.
|
|
251
255
|
|
|
252
|
-
There is no command that decrypts a field
|
|
256
|
+
<gap>There is no command that decrypts a field.</gap> Keep `.encrypted()` on a field while its column holds encrypted values; `status` reports encrypted values in a field that is not encrypted.
|
|
253
257
|
|
|
254
258
|
### What a value is bound to
|
|
255
259
|
|
|
@@ -257,7 +261,7 @@ A value opens only where it was sealed: its table as `.table()` names it (with o
|
|
|
257
261
|
|
|
258
262
|
- Renaming the resource or the field in the config changes nothing.
|
|
259
263
|
- Renaming the table or the column, moving the table to another schema, or adding or changing the schema in `.table()` makes the field's values unreadable until `protobase encryption apply --rebind people --from-table <old table>` (or `--rebind people.iban --from-column <old column>`) runs. Run it at update time, like a migration; reveals fail until then.
|
|
260
|
-
- Changing a resource's declared key or tenant field makes its values unreadable
|
|
264
|
+
- Changing a resource's declared key or tenant field makes its values unreadable. <gap>No command rebinds encrypted values after a change of a resource's key or tenant field.</gap> Make such a change before encrypting.
|
|
261
265
|
- The record key must be unique in its table, as [`protobase doctor`](cli.md#doctor) checks, or at least within each tenant. A key changed in the database, by SQL, a trigger or a foreign key `on update cascade` (which `status` warns about), makes that row's values unreadable; the API refuses to change the key of a record with encrypted fields.
|
|
262
266
|
|
|
263
267
|
### Encrypting an existing column
|
|
@@ -65,7 +65,7 @@ The options combine with AND:
|
|
|
65
65
|
| `changed: [r.status]` | One of these fields changed. It works on sensitive fields too. |
|
|
66
66
|
| `match` | A function of the change that returns `true` for the event, for what a filter cannot say. |
|
|
67
67
|
|
|
68
|
-
Filters use the language of [access rules](access.md) and views, on any field, filterable or not. They are checked against the resource when the config loads, so a typo stops startup. A filter cannot use a sensitive field, since captured records never hold their values (use `changed`)
|
|
68
|
+
Filters use the language of [access rules](access.md) and views, on any field, filterable or not. They are checked against the resource when the config loads, so a typo stops startup. A filter cannot use a sensitive field, since captured records never hold their values (use `changed`). <gap>An event filter cannot use `search()`, `similar()` or a field of another resource.</gap>
|
|
69
69
|
|
|
70
70
|
`match` sees the change as the event does: `operation` (`create`, `update`, `delete` or `undelete`), `before` and `after` (the records by field name, without sensitive fields), `changed` (field names), `actor` (`{ id, roles }` for a write through the API, `null` otherwise), `source` (`api` or `database`), `tenant` and `transaction`.
|
|
71
71
|
|
|
@@ -128,7 +128,7 @@ await storeFile({ provider: 'public', path: 'images/test.png', body: bytes, env:
|
|
|
128
128
|
### S3-compatible buckets
|
|
129
129
|
|
|
130
130
|
:::caution[Beta]
|
|
131
|
-
S3-compatible buckets work only when the app runs on Bun
|
|
131
|
+
<gap>S3-compatible buckets work only when the app runs on Bun, as Node has no S3 client built in.</gap> On Node the first file operation fails.
|
|
132
132
|
:::
|
|
133
133
|
|
|
134
134
|
`s3Files` stores files in any bucket with the S3 API, such as Cloudflare R2, Scaleway Object Storage or AWS S3, under `prefix` when given, so one bucket can hold several providers or apps:
|
|
@@ -200,7 +200,7 @@ The decided type picks the stored extension, and downloads are served by that ex
|
|
|
200
200
|
| `fileType()` | the detected type, for a text field |
|
|
201
201
|
| `processor({ accepts?, run })` | your own: `run(file)` gets `{ name, type, size, head, read() }`, where `head` is the first 256 KB and `read()` streams the whole file |
|
|
202
202
|
|
|
203
|
-
Processors run once, on the upload route, after the file is stored. A processor whose `accepts` does not match the type leaves its field `null`, so a field that takes images and PDFs gets a width only for images. The values travel signed inside the ticket and are written with the file in the same transaction; replacing the file recomputes them and clearing it sets them to `null`. A value the field's own schema refuses is an error in the processor. Files stored before a processor was added keep their fields as they are
|
|
203
|
+
Processors run once, on the upload route, after the file is stored. A processor whose `accepts` does not match the type leaves its field `null`, so a field that takes images and PDFs gets a width only for images. The values travel signed inside the ticket and are written with the file in the same transaction; replacing the file recomputes them and clearing it sets them to `null`. A value the field's own schema refuses is an error in the processor. <gap>Files stored before a processor was added keep their fields as they are, as processors do not run on existing files.</gap>
|
|
204
204
|
|
|
205
205
|
## Image variants and placeholders
|
|
206
206
|
|
|
@@ -220,7 +220,7 @@ photo_placeholder: f.text().readOnly().optional(),
|
|
|
220
220
|
- **`.variants({ name: variant })`** stores resized copies beside the file, each at most `width` by `height` pixels (either may be left out) and never enlarged. `fit: 'inside'`, the default, keeps the whole image in that box; `'cover'` fills the box and crops the rest, and needs both sides. `format` is `webp`, `avif`, `jpeg` or `png`, and `quality` 1 to 100, the format's default when left out. Names are snake_case. A variant is stored at the file's path followed by its name and extension (`…/2992db9c-….jpg.card.webp`) with the same provider, served and deleted with the file. The admin app shows tables, forms and cards with the smallest variant large enough for them.
|
|
221
221
|
- **`{ original: variant }`**, as `.variants()`' second argument, stores that image instead of the upload, so the upload is not kept: `{ original: { width: 2560, format: 'webp' } }` stores at most 2560 pixels wide as WebP.
|
|
222
222
|
|
|
223
|
-
Variants and placeholders turn the image upright first, following its EXIF orientation, and carry no metadata. JPEG, PNG, WebP, AVIF, GIF and TIFF images are processed; any other file, HEIC and SVG included, is stored as it is, without variants, and its placeholder is `null`. Files uploaded before a field declared
|
|
223
|
+
Variants and placeholders turn the image upright first, following its EXIF orientation, and carry no metadata. JPEG, PNG, WebP, AVIF, GIF and TIFF images are processed; any other file, HEIC and SVG included, is stored as it is, without variants, and its placeholder is `null`. <gap>Files uploaded before a field declared variants keep none, as variants are not made for existing files.</gap>
|
|
224
224
|
|
|
225
225
|
sharp is a native package, so the config passes it in, and a [built bundle](cli.md#native-packages) carries it with its add-on for linux:
|
|
226
226
|
|
|
@@ -279,7 +279,7 @@ A trusted host is matched exactly: `images.example.com` does not trust `cdn.imag
|
|
|
279
279
|
|
|
280
280
|
Files are deleted by schedule, never in the write itself, so a restore of the database to an earlier moment still finds its files:
|
|
281
281
|
|
|
282
|
-
- A write that **replaces or clears** a file, or **deletes a row** (not a soft delete), schedules the delete of each file it took out of its row, with its variants. It is due after the provider's retention: `files.retention`, 1 day by default, or 0 for a public provider.
|
|
282
|
+
- A write that **replaces or clears** a file, or **deletes a row** (not a soft delete), schedules the delete of each file it took out of its row, with its variants, once it commits, so its transaction never waits on the storage. It is due after the provider's retention: `files.retention`, 1 day by default, or 0 for a public provider. When the storage refuses the entry, the write still stands, the file stays in storage, and the error goes to `options.onUnhandledError`.
|
|
283
283
|
- Every **upload** schedules one too, due an hour after its ticket expires, so a file nobody saved, or whose write rolled back, goes as well.
|
|
284
284
|
- Each scheduled delete is a small JSON object in the provider's own storage, in a `.cleanup/` folder, named after its due time and saying what to delete: `.cleanup/2026-10-12T03-00-00Z-<uuid>.json` holding `{ "provider": "private", "path": "1/2992db9c-….jpg", "due": "…" }`.
|
|
285
285
|
- A **cleanup run** handles the entries that are due. Right before deleting, it checks every file column of every resource for the file: one that a row holds again (a rolled-back write, a restore, a copied value) is kept, and its entry dropped. Two runs at once do no harm.
|
|
@@ -73,6 +73,7 @@ export default defineConfig({
|
|
|
73
73
|
| `retryDelay`, `maxRetryDelay` | The wait before the first retry, doubling with each one (with some jitter), and its ceiling; default `2s` and `1 hour`. Milliseconds or text such as `30 seconds`. |
|
|
74
74
|
| `timeout` | How long one try may run before it counts as failed; default `15 minutes`. |
|
|
75
75
|
| `concurrency` | Jobs of this name running at once in each worker process; default 1. |
|
|
76
|
+
| `longQueries` | Its queries through `db` may run up to 30 seconds instead of the database's own limit, for imports, backfills and large deletes; see [Long queries](../guides/api-functions.md#long-queries). A query stopped at its limit fails the try with an error that names the job. |
|
|
76
77
|
| `ordered` | Jobs run one at a time per group, in the order they were enqueued; see [Ordered groups](#ordered-groups). |
|
|
77
78
|
| `schedule`, `timezone` | Runs the job on a cron schedule, in a time zone (default `UTC`); see [Recurring jobs](#recurring-jobs). |
|
|
78
79
|
|
|
@@ -69,7 +69,7 @@ A `RecordCard` (its first match) and each card of a `CardRow` hold a **record**.
|
|
|
69
69
|
| `status`, `plan.name` | A field of the record around it, through relations. |
|
|
70
70
|
| `invoices.count` | How many `invoices` the user can see (an exact count from the list API). |
|
|
71
71
|
|
|
72
|
-
Comparisons, `AND`, `OR`, `NOT` and parentheses work
|
|
72
|
+
Comparisons, `AND`, `OR`, `NOT` and parentheses work. <gap>A condition cannot call functions such as `now()`, as they are not supported.</gap> A field that is missing or that the user cannot read makes the comparison false, and a `Show` that names a resource or field the user cannot see is left out of their page.
|
|
73
73
|
|
|
74
74
|
Record pages take the same conditions in the `when` of `l.section`, `l.related` and `l.sidebar`; see [Form and read view](ui-config.md#form-and-read-view).
|
|
75
75
|
|
|
@@ -92,7 +92,7 @@ A user with one of those roles creates, updates and deletes records over MCP wit
|
|
|
92
92
|
|
|
93
93
|
No role is exempt unless named. The roles are checked against the signed-in user, not against the client, and a user holding several is exempt when any of them is named. A name that is not one of the app's roles, or is `anonymous`, stops the server at startup. Naming a role a person signs in with lets any client that person allows write as them unasked.
|
|
94
94
|
|
|
95
|
-
A deleted record cannot be restored over MCP
|
|
95
|
+
<gap>A deleted record cannot be restored over MCP.</gap> There is no SQL that writes.
|
|
96
96
|
|
|
97
97
|
#### Batch writes
|
|
98
98
|
|
|
@@ -24,7 +24,7 @@ The server serves the socket when the host gives `createAdmin` its WebSocket upg
|
|
|
24
24
|
|
|
25
25
|
## Which tables
|
|
26
26
|
|
|
27
|
-
A channel may listen to the tables of the resources with [`.live()`](live.md), by `schema` (`*` for any), `table` (every live table of the schema when left out), `event` (`INSERT`, `UPDATE`, `DELETE` or `*`) and `filter`. A table that is not live is refused when the channel joins, with Supabase's message; [`import supabase`](cli.md#import-supabase) makes the tables of the project's `supabase_realtime` publication live. A filter is Supabase's: `column=operator.value`, with `eq`, `neq`, `lt`, `lte`, `gt`, `gte`, `in.(a,b)`, `like`, `ilike`, `match`, `imatch`, `is` and `isdistinct`, `not.` before the operator, and several conditions joined by commas, all of which must hold. Postgres compares each value as the column's type. `select`
|
|
27
|
+
A channel may listen to the tables of the resources with [`.live()`](live.md), by `schema` (`*` for any), `table` (every live table of the schema when left out), `event` (`INSERT`, `UPDATE`, `DELETE` or `*`) and `filter`. A table that is not live is refused when the channel joins, with Supabase's message; [`import supabase`](cli.md#import-supabase) makes the tables of the project's `supabase_realtime` publication live. A filter is Supabase's: `column=operator.value`, with `eq`, `neq`, `lt`, `lte`, `gt`, `gte`, `in.(a,b)`, `like`, `ilike`, `match`, `imatch`, `is` and `isdistinct`, `not.` before the operator, and several conditions joined by commas, all of which must hold. Postgres compares each value as the column's type. <gap>A channel cannot `select` columns because that is not supported yet.</gap> <gap>A channel cannot be private because private channels are not supported yet.</gap>
|
|
28
28
|
|
|
29
29
|
## Broadcast and presence
|
|
30
30
|
|
|
@@ -46,7 +46,7 @@ A broadcast reaches the topic's other channels, and the sender's own with `self`
|
|
|
46
46
|
|
|
47
47
|
Limits, near Supabase's Free plan, apply per socket and per topic. A socket sends at most 100 broadcast and presence messages a second, joins at most 100 times a second and holds at most 100 channels; on each channel it sends at most 5 presence updates in 30 seconds, also counted across a rejoin. A topic takes 100 broadcasts a second, whoever sends them, so one busy sender can use up a topic's budget. A topic is at most 255 bytes, and a tracked presence at most 10 000 bytes of JSON. A message over a limit gets an error reply and goes to no one, where Supabase would close the channel. A frame over 256 KiB closes the socket with 1009. It closes with 1008 when the client leaves more than 4 MiB unread, or sends more than 300 messages or 4 MiB while earlier ones wait, such as behind a token check.
|
|
48
48
|
|
|
49
|
-
Broadcasts and presence go between the channels of one serving process, which is how a cloud app runs;
|
|
49
|
+
Broadcasts and presence go between the channels of one serving process, which is how a cloud app runs; <gap>Several processes behind one address do not reach each other's channels, because broadcasts and presence are not shared between processes.</gap> <gap>Sending without a joined channel, which supabase-js does over `POST /api/sb/realtime/v1/api/broadcast`, is not supported.</gap>
|
|
50
50
|
|
|
51
51
|
## What a subscriber receives
|
|
52
52
|
|
|
@@ -38,7 +38,17 @@ The transaction sets the role with `SET LOCAL ROLE` and the token's claims in `r
|
|
|
38
38
|
- `.single()` and `.maybeSingle()`, through `Accept: application/vnd.pgrst.object+json`.
|
|
39
39
|
- `rpc/<function>` by POST and by GET, which runs read-only. A function returning rows takes `select`, filters, `order`, a range and a count.
|
|
40
40
|
|
|
41
|
-
Not yet:
|
|
41
|
+
Not yet:
|
|
42
|
+
|
|
43
|
+
- <gap>`/api/sb/rest/v1` does not support many-to-many embeds through a junction table yet.</gap>
|
|
44
|
+
- <gap>`/api/sb/rest/v1` does not support spreads (`...profiles(name)`) yet.</gap>
|
|
45
|
+
- <gap>`/api/sb/rest/v1` does not support computed relationships yet.</gap>
|
|
46
|
+
- <gap>`/api/sb/rest/v1` does not support embeds in a function's rows yet.</gap>
|
|
47
|
+
- <gap>`/api/sb/rest/v1` does not support ordering by an embedded column yet.</gap>
|
|
48
|
+
- <gap>`/api/sb/rest/v1` does not support CSV yet.</gap>
|
|
49
|
+
- <gap>`/api/sb/rest/v1` does not support schemas other than `public` yet.</gap>
|
|
50
|
+
- <gap>`/api/sb/rest/v1` does not support aggregates yet.</gap>
|
|
51
|
+
- <gap>`/api/sb/rest/v1` does not support `tx=rollback` yet.</gap>
|
|
42
52
|
|
|
43
53
|
## Scan guard
|
|
44
54
|
|
|
@@ -47,7 +47,12 @@ Public buckets are served at `/api/sb/storage/v1/object/public/<bucket>/<name>`
|
|
|
47
47
|
|
|
48
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
49
|
|
|
50
|
-
Not yet:
|
|
50
|
+
Not yet:
|
|
51
|
+
|
|
52
|
+
- <gap>`/api/sb/storage/v1` does not support image transforms yet.</gap>
|
|
53
|
+
- <gap>`/api/sb/storage/v1` does not support resumable (TUS) uploads yet.</gap>
|
|
54
|
+
- <gap>`/api/sb/storage/v1` does not support the S3 protocol yet.</gap>
|
|
55
|
+
- <gap>`/api/sb/storage/v1` does not support object versioning yet.</gap>
|
|
51
56
|
|
|
52
57
|
## Errors
|
|
53
58
|
|
|
@@ -69,7 +69,7 @@ Field hints:
|
|
|
69
69
|
| --- | --- |
|
|
70
70
|
| `.label(text)` | Instead of the name in words (`customer_id` would be "Customer" anyway). |
|
|
71
71
|
| `.help(text, { when? })` | A line under the field on the record page and in forms. `when: 'editing'` shows it only while the record is edited; see [Help while editing](#help-while-editing). |
|
|
72
|
-
| `.format(format)` | `badge` shows statuses as coloured badges, `code` sets identifiers in monospace, `percent` adds a % sign. On a text field, `email`, `phone` and `url` show the value as a link that writes to it (`mailto:`), calls it (`tel:`, its digits and a leading +) or opens it in a new tab (only an `http` or `https` address; anything else stays text), on the record page, in its sidebar and in the list's cells but the title's, which links to the record; forms edit it in an email, phone or web address input, which brings up the keyboard for it on a mobile screen and offers the browser's autofill. Another field type with one of them stops the server at startup. `relative` on a timestamp shows it as "5 minutes ago" or "in 2 hours" in lists and on the record page, with the exact time on hover; `absolute` and `compact` are accepted and carried in `/meta` for apps that render their own lists
|
|
72
|
+
| `.format(format)` | `badge` shows statuses as coloured badges, `code` sets identifiers in monospace, `percent` adds a % sign. On a text field, `email`, `phone` and `url` show the value as a link that writes to it (`mailto:`), calls it (`tel:`, its digits and a leading +) or opens it in a new tab (only an `http` or `https` address; anything else stays text), on the record page, in its sidebar and in the list's cells but the title's, which links to the record; forms edit it in an email, phone or web address input, which brings up the keyboard for it on a mobile screen and offers the browser's autofill. Another field type with one of them stops the server at startup. `relative` on a timestamp shows it as "5 minutes ago" or "in 2 hours" in lists and on the record page, with the exact time on hover; `absolute` and `compact` are accepted and carried in `/meta` for apps that render their own lists. <gap>The admin does not use the `absolute` and `compact` formats yet.</gap> |
|
|
73
73
|
| `.multiline()` | A text of several lines, such as a description: forms edit it in a box that grows with the text, so the page scrolls rather than the box, and the record page's sections, a page's field blocks and a card's subtitle keep its line breaks (a card shows the first three lines); the record's sidebar shows it on one line. On the record page and the create form it takes the whole width of its section. Only a text field takes it; the list's table shows the text on one line. |
|
|
74
74
|
| `.markdown()` | Markdown, such as a task's notes: forms edit its source in a box that grows with it, with a Write and Preview switch above it, and store it exactly as typed. The record page's sections and a page's field blocks show it rendered as GitHub does, line breaks kept; raw HTML shows as text, links and images keep only http(s), mailto, tel and relative addresses, and links open in a new tab. A card's subtitle shows its first three lines rendered, its links as text; the list's table, the record's sidebar and a card's other lines show its text on one line without the marks. On the record page and the create form it takes the whole width of its section. Only a text field takes it, and the renderer loads with the first markdown shown. |
|
|
75
75
|
| `.prefix(text)`, `.suffix(text)`, `.decimals(n)` | Money and measures: `€` and `2` show `€1,234.50`, `.suffix(' m²')` shows `120 m²`. They show wherever the number does: records, cards, table cells, forms and the range filter. |
|
|
@@ -333,7 +333,7 @@ Every widget takes `secondary: true` (e.g. `w.facets(r.agent, { secondary: true
|
|
|
333
333
|
|
|
334
334
|
### Charts (graphs): records per day or week, or per value, above a list
|
|
335
335
|
|
|
336
|
-
A list can show a graph of how many of its records fall on each day or week, such as a daily graph of new listings. `.chart((r) => ({ field, range, granularity }))` draws the list's records per day over a date or timestamp field as bars above the list, following its filters, headed by their total and how much the second half of the bars differs from the first. `range` is how far back it reaches: `7d`, `30d`, `90d`, `1y` or `all`. A **Day** and **Week** switch changes the bars, and **Week** shows the last 12 weeks whatever the range; `granularity: 'week'` opens it on weeks.
|
|
336
|
+
A list can show a graph of how many of its records fall on each day or week, such as a daily graph of new listings. `.chart((r) => ({ field, range, granularity }))` draws the list's records per day over a date or timestamp field as bars above the list, following its filters, headed by their total and how much the second half of the bars differs from the first. `range` is how far back it reaches: `7d`, `30d`, `90d`, `1y` or `all`. A **Day** and **Week** switch changes the bars, and **Week** shows the last 12 weeks whatever the range; `granularity: 'week'` opens it on weeks. <gap>`hour` and `month` are accepted and show days, as hourly and monthly bars are not built.</gap> Its bars do not filter the list.
|
|
337
337
|
|
|
338
338
|
It can show the list's records per value of a field instead, such as orders per status or revenue per customer: `.chart((r) => ({ groupBy: r.status, type: 'donut' }))`. `groupBy` is a filterable field that is no date, such as an enum, a boolean or a relation, with an index that serves it; `type` is `bar` (the default, the largest first) or `donut`; `sum: r.total` or `average: r.total` adds up a numeric field instead of counting (a donut takes no average); `limit` is how many values it shows, 10 by default. Each value links to the list filtered to it, and follows the list's filters, its own terms on `groupBy` included. A date, file or JSON `groupBy`, or a `sum` of a field that is no number, stops the server at startup, and a user who cannot read one of its fields sees no chart. A page shows the same with the [`Chart`](blocks.md#chart) block.
|
|
339
339
|
|
|
@@ -511,7 +511,7 @@ To tell users of new records, a job matches each new record against the saved fi
|
|
|
511
511
|
|
|
512
512
|
Every list has an **Export** button beside its title, and **Export N** beside **Delete N** for the rows selected in its table. Both open one dialog that asks for the format, Excel (`.xlsx`) or CSV; the rows, those the list finds with its filters, search and sort, or the selected ones; the columns, the list's own in its order to start with, then any field the user may read, each moved up or down; and the values, **As shown**, as the list shows them (enum value labels, the names of related records, dates and numbers formatted with the view's prefix, suffix and decimals), or **Raw values**, as the API stores them (keys, codes, ISO dates). It says how many rows that is before it starts: counted exactly up to 10,000, the planner's estimate above.
|
|
513
513
|
|
|
514
|
-
The rows come through the list API as the user may read them, page by page with its page tokens (`POST /{resource}:search`, 500 a page), so the [scan guard](api.md#safety), the role's row filter and its readable fields apply as on the list; a [sensitive field](data-config.md#sensitive-fields) is never offered. The selected rows are found again by their key
|
|
514
|
+
The rows come through the list API as the user may read them, page by page with its page tokens (`POST /{resource}:search`, 500 a page), so the [scan guard](api.md#safety), the role's row filter and its readable fields apply as on the list; a [sensitive field](data-config.md#sensitive-fields) is never offered. The selected rows are found again by their key. <gap>A resource with a composite key cannot export selected rows and offers only the list's rows.</gap> The browser builds the file in a Web Worker, the server only answering the pages it reads anyway, and writes it as it goes: to the file the user picks where the browser has the [File System Access API](https://developer.mozilla.org/docs/Web/API/File_System_API), as a download otherwise. A progress dialog counts the rows, and **Cancel** stops after the page being read and discards the file.
|
|
515
515
|
|
|
516
516
|
A workbook has one sheet named after the records, a bold header row of the columns' labels that stays in view, columns as wide as their header and the first page's values, and typed cells: numbers, dates and times with a number format (as shown, the list's format; raw, `yyyy-mm-dd`), booleans as TRUE and FALSE, and text. As shown, a time is on the viewer's clock, as the list shows it; raw, in UTC, as the API sends it; a 64-bit integer past 2^53 stays text so that no digit is lost, and a text is cut at Excel's 32,767 characters. A sheet holds at most 1,048,575 rows. A CSV file is UTF-8 with a byte order mark, so Excel reads it as such, quoted as RFC 4180 has it, with a text that starts with `=`, `+`, `-`, `@`, a tab or a carriage return written after an apostrophe, so that a spreadsheet does not run it as a formula. The file is named after the records and the day, as `Orders 2026-10-16.xlsx`.
|
|
517
517
|
|
|
@@ -763,7 +763,7 @@ d.map(
|
|
|
763
763
|
|
|
764
764
|
`radius`, `area` and `defaultRadius` need `approximate` or `exact`, and the server refuses to start when a field is of another type. A user who may not read the field that marks the positions sees them as exact.
|
|
765
765
|
|
|
766
|
-
A map does not edit the position
|
|
766
|
+
<gap>A map does not edit the position.</gap> List the fields in a section as well when users should change them. The [property portal example](https://github.com/PrototeamHQ/protobase/tree/main/examples/property-portal) shows a listing on a map, and its listings on one.
|
|
767
767
|
|
|
768
768
|
#### Map layers
|
|
769
769
|
|
|
@@ -18,7 +18,7 @@ What the conversion leaves in `functions/`, by the note the report gives, and wh
|
|
|
18
18
|
| `Deno.env.toObject` | `process.env`. |
|
|
19
19
|
| `Deno.cwd`, `Deno.args`, `Deno.exit` | `process.cwd()`; no arguments; throw an error instead of exiting. |
|
|
20
20
|
| `Deno.openKv` | A table, in a migration, in a schema named for what it keeps (`create table <schema>.<name> (key text[] primary key, value jsonb not null, expires_at timestamptz)`), read and written with the function's `db`. `expireIn` becomes `expires_at`, and readers skip expired rows. Deno KV's data does not come over: start empty, unless the user exports it. |
|
|
21
|
-
| `Deno.upgradeWebSocket` |
|
|
21
|
+
| `Deno.upgradeWebSocket` | `acceptWebSocket(events)` of the function's context, at `/api/functions/<name>` (see [WebSockets](../../protobase/references/guides/api-functions.md#websockets)), so point the client there. Or move the messages to Realtime broadcast on a channel, which supabase-js reaches at `/api/sb/realtime/v1` (see [Supabase Realtime](../../protobase/references/reference/supabase-realtime.md)), and change the client to it; when that does not fit, stop on it and tell the user. |
|
|
22
22
|
| `Deno.serve(...)` or `serve(...)`, `which Protobase does not run` | Make the file's default export `{ fetch: handler }` itself, once per function, in its `index.ts`. |
|
|
23
23
|
| `no Deno.serve or default export to serve` | Find the handler and default-export `{ fetch: handler }`. |
|
|
24
24
|
| `<dir> has no index.ts, so it was not imported` | Move its entry point to `index.ts` in `supabase/functions/<name>`, and convert it as the import did: rerun it in a scratch checkout, or apply this table by hand. |
|