@protobase/cli 0.108.0 → 0.109.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/doctor/index-issues.js +14 -3
- package/dist/doctor/run.js +5 -2
- package/package.json +8 -8
- package/skills/protobase/references/reference/cli.md +6 -0
- package/skills/protobase/references/reference/files.md +1 -1
- package/skills/protobase/references/reference/supabase-storage.md +2 -0
package/dist/cli/package.js
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import { uncoveredColumns } from "@protobase/query";
|
|
1
|
+
import { uncoveredColumns, uncoveredFileColumns } from "@protobase/query";
|
|
2
2
|
//#region src/doctor/index-issues.ts
|
|
3
3
|
const kinds = {
|
|
4
4
|
btree: "index",
|
|
5
5
|
trigram: "pg_trgm index",
|
|
6
6
|
digits: "pg_trgm index",
|
|
7
|
-
gin: "GIN index"
|
|
7
|
+
gin: "GIN index",
|
|
8
|
+
file: "index"
|
|
8
9
|
};
|
|
9
10
|
const served = (column) => column.need === "digits" ? `the digits of "${column.column}"` : `the column "${column.column}"`;
|
|
10
11
|
/**
|
|
@@ -32,5 +33,15 @@ const indexIssues = (model, table, shapes) => {
|
|
|
32
33
|
suggestion: `${column.suggestion};`
|
|
33
34
|
}));
|
|
34
35
|
};
|
|
36
|
+
/**
|
|
37
|
+
* The file columns of `model` the file cleanup reads every row of before it deletes a file, as no index looks a file up
|
|
38
|
+
* there: a warning each, since the API refuses nothing for it.
|
|
39
|
+
*/
|
|
40
|
+
const fileIndexIssues = (model, table) => uncoveredFileColumns(model, table).map((column) => ({
|
|
41
|
+
severity: "warning",
|
|
42
|
+
resource: model.name,
|
|
43
|
+
message: `no index looks up the files of "${column.column}", so each file cleanup reads every row of the table to check that none holds a file it deletes`,
|
|
44
|
+
suggestion: `${column.suggestion};`
|
|
45
|
+
}));
|
|
35
46
|
//#endregion
|
|
36
|
-
export { indexIssues };
|
|
47
|
+
export { fileIndexIssues, indexIssues };
|
package/dist/doctor/run.js
CHANGED
|
@@ -7,7 +7,7 @@ import { loadDataConfig } from "../project/load-data-config.js";
|
|
|
7
7
|
import { readOnlyDb } from "../db/read-only-db.js";
|
|
8
8
|
import { builtInIndexIssues, builtInModels } from "./built-in-models.js";
|
|
9
9
|
import { checkResource } from "./check.js";
|
|
10
|
-
import { indexIssues } from "./index-issues.js";
|
|
10
|
+
import { fileIndexIssues, indexIssues } from "./index-issues.js";
|
|
11
11
|
import { unplannedBlocks } from "./page-shapes.js";
|
|
12
12
|
import { readShapes } from "./read-shapes.js";
|
|
13
13
|
import { relationIssues } from "./relation-issues.js";
|
|
@@ -44,7 +44,10 @@ const runDoctor = async (options, out) => {
|
|
|
44
44
|
views: [...builtIn.views, ...config.views],
|
|
45
45
|
pages: config.pages
|
|
46
46
|
});
|
|
47
|
-
const indexes = await Promise.all(models.map(async (model) =>
|
|
47
|
+
const indexes = await Promise.all(models.map(async (model) => {
|
|
48
|
+
const table = await tableIndexes(db, model);
|
|
49
|
+
return [...indexIssues(model, table, shapes), ...fileIndexIssues(model, table)];
|
|
50
|
+
})).then((found) => found.map((issues, i) => i < builtIn.models.length ? builtInIndexIssues(issues) : issues)).finally(() => db.destroy());
|
|
48
51
|
const issues = [...userTables.issues, ...models.flatMap((model, i) => [
|
|
49
52
|
...checkResource(model, tables),
|
|
50
53
|
...relationIssues(model, models),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@protobase/cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.109.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": {
|
|
@@ -43,13 +43,13 @@
|
|
|
43
43
|
"dependencies": {
|
|
44
44
|
"@better-auth/core": "^1.7.12",
|
|
45
45
|
"@hono/node-server": "^2.1.3",
|
|
46
|
-
"@protobase/config": "0.
|
|
47
|
-
"@protobase/layout": "0.
|
|
48
|
-
"@protobase/query": "0.
|
|
49
|
-
"@protobase/schema": "0.
|
|
50
|
-
"@protobase/server": "0.
|
|
51
|
-
"@protobase/ui": "0.
|
|
52
|
-
"@protobase/workflows": "0.
|
|
46
|
+
"@protobase/config": "0.109.0",
|
|
47
|
+
"@protobase/layout": "0.109.0",
|
|
48
|
+
"@protobase/query": "0.109.0",
|
|
49
|
+
"@protobase/schema": "0.109.0",
|
|
50
|
+
"@protobase/server": "0.109.0",
|
|
51
|
+
"@protobase/ui": "0.109.0",
|
|
52
|
+
"@protobase/workflows": "0.109.0",
|
|
53
53
|
"@react-email/render": "^2.1.0",
|
|
54
54
|
"@scalar/hono-api-reference": "^0.12.10",
|
|
55
55
|
"@sentry/vite-plugin": "^11.10.0",
|
|
@@ -128,6 +128,12 @@ Imports `config/index.ts` and the views of `config/*/ui.ts`, as the config modul
|
|
|
128
128
|
GET /seller?order_by=name asc (the seller list's order)
|
|
129
129
|
fix: mark "name" .sortable() in data.ts, or sort the list by a sortable field
|
|
130
130
|
```
|
|
131
|
+
- warning: a file field whose column no index looks files up in, so each [file cleanup](files.md#deleting-files) reads every row of the table before it deletes a file. The fix is an index on the file without its query part, which a partial index cannot be, as soft-deleted rows still hold their files:
|
|
132
|
+
|
|
133
|
+
```
|
|
134
|
+
warning photos: no index looks up the files of "photo", so each file cleanup reads every row of the table to check that none holds a file it deletes
|
|
135
|
+
fix: create index on "photos" ((split_part("photo", '?', 1)));
|
|
136
|
+
```
|
|
131
137
|
- warning: enum values differ
|
|
132
138
|
|
|
133
139
|
Doctor also lists, as a note it does not count, each custom component of a page that declares no [reads](custom-components.md#reads), since it reads outside the page's plan.
|
|
@@ -392,7 +392,7 @@ Files are deleted by schedule, never in the write itself, so a restore of the da
|
|
|
392
392
|
- 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 the default export of `hooks/error.ts`.
|
|
393
393
|
- 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.
|
|
394
394
|
- 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": "…" }`.
|
|
395
|
-
- 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.
|
|
395
|
+
- 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. It looks the files up by `split_part(column, '?', 1)`, the file without its query part, which an index on that expression serves; [`protobase doctor`](cli.md#doctor) warns of each file column without one and writes it.
|
|
396
396
|
|
|
397
397
|
A run happens:
|
|
398
398
|
|
|
@@ -49,6 +49,8 @@ Public buckets are served at `/api/sb/storage/v1/object/public/<bucket>/<name>`
|
|
|
49
49
|
- `object/list/<bucket>`, `object/move`, `object/copy` and `object/info/...`.
|
|
50
50
|
- `bucket`: list, get, create, update, empty and delete.
|
|
51
51
|
|
|
52
|
+
A list walks the folder's level entry by entry on the storage schema's `(bucket_id, name collate "C")` index: a folder below it costs one read however many objects it holds, so the top of a big bucket lists as fast as any folder.
|
|
53
|
+
|
|
52
54
|
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.
|
|
53
55
|
|
|
54
56
|
Not yet:
|