@protobase/cli 0.88.2 → 0.89.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
CHANGED
package/dist/migration/parts.js
CHANGED
|
@@ -31,11 +31,11 @@ const migrationParts = (project) => {
|
|
|
31
31
|
title: "The role the assistant's read-only queries run as, which reads only the resources' tables",
|
|
32
32
|
sql: () => queryRunnerMigration(project.db, project.models, project.authTables)
|
|
33
33
|
}] : [],
|
|
34
|
-
|
|
34
|
+
{
|
|
35
35
|
name: "derived",
|
|
36
36
|
title: "The state of the resources' derived values and what they read",
|
|
37
37
|
sql: () => derivedMigration(project.db, project.models)
|
|
38
|
-
}
|
|
38
|
+
},
|
|
39
39
|
...comments ? [{
|
|
40
40
|
name: "comments",
|
|
41
41
|
title: "The comments table of the resources with comments",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@protobase/cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.89.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.89.0",
|
|
47
|
+
"@protobase/layout": "0.89.0",
|
|
48
|
+
"@protobase/query": "0.89.0",
|
|
49
|
+
"@protobase/schema": "0.89.0",
|
|
50
|
+
"@protobase/server": "0.89.0",
|
|
51
|
+
"@protobase/ui": "0.89.0",
|
|
52
|
+
"@protobase/workflows": "0.89.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",
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
A TypeScript function's result kept current by itself, recomputed when what it read changes or when a time rule flips.
|
|
6
6
|
|
|
7
7
|
:::caution[Experimental]
|
|
8
|
-
Derived values may change in any release. They cannot fill a list of rows in another resource yet, cannot see the reads inside a database function or view they call, show `recalculating` rather than `stale` after a failed run, and their status cannot be read through the REST API; [Limits](#limits) has the detail.
|
|
8
|
+
Derived values may change in any release. They cannot fill a list of rows in another resource yet, cannot see the reads inside a database function or view they call, show `recalculating` rather than `stale` after a failed run, keep what an earlier version of their function computed until a record changes, keep their last result, or none before a first one, while what they read changes during every run, and their status cannot be read through the REST API; [Limits](#limits) has the detail.
|
|
9
9
|
:::
|
|
10
10
|
|
|
11
11
|
A **derived value** is worked out from other records for each record of a resource, such as a verdict on an objective from its tasks. You write a small TypeScript function that reads records and the clock; Protobase records what it read, computes it again when a change touches that or when a time check flips, and stores the result. No timer is involved, and a value that did not change is not written. It works on any Postgres, with no extension.
|
|
@@ -52,7 +52,7 @@ The function gets the record's key as its URL has it, and returns the value as J
|
|
|
52
52
|
|
|
53
53
|
| | |
|
|
54
54
|
| --- | --- |
|
|
55
|
-
| `db` | The app's database. Each query sent through it is analysed, raw SQL included
|
|
55
|
+
| `db` | The app's database, in a read-only transaction, so a write throws before it happens, and so does opening a transaction of its own. Each query sent through it is analysed, raw SQL included. |
|
|
56
56
|
| `clock` | The time; see [The clock](#the-clock). |
|
|
57
57
|
| `depends(resource, where?)` | Names a dependency itself: every record of the resource, or those whose fields hold these values, such as `depends('tasks', { status: ['open', 'late'] })`. |
|
|
58
58
|
| `signal` | Aborted when the run times out or the worker shuts down. |
|
|
@@ -61,7 +61,7 @@ The function gets the record's key as its URL has it, and returns the value as J
|
|
|
61
61
|
|
|
62
62
|
Each query the function sends is parsed with Postgres's own parser, however it was built. For each table it reads, Protobase keeps the query's conditions on that table: comparisons of its columns with constants and parameters, `IN`, `= ANY`, `BETWEEN` and null tests, joined with `AND`, `OR` and `NOT`, with the conditions of inner joins, and of an outer join's `ON` for its optional side. The condition is the dependency, so a new row that comes to match is caught as well as a row that leaves it. A part it cannot work out, such as a function call or a column of another table, counts as matching every row: a query it cannot read at all reads the whole table. Nested queries, `WITH` queries and both sides of a `UNION` count too. An update counts only when it changes a column the query used.
|
|
63
63
|
|
|
64
|
-
A table that is no resource of `reads` or the record's own stops the run with an error naming it: add its resource to `reads`,
|
|
64
|
+
A table that is no resource of `reads` or the record's own stops the run with an error naming it: add its resource to `reads`. `depends()` takes only those resources too; with `track: false`, the dependencies it names are the only ones, for a function whose queries say less than it knows.
|
|
65
65
|
|
|
66
66
|
## The clock
|
|
67
67
|
|
|
@@ -77,9 +77,11 @@ Each check that has not flipped yet records the moment it will; the value is com
|
|
|
77
77
|
|
|
78
78
|
- **A new record** is computed once it is created, and a value declared for records that exist already computes each of them once, from the migration that adds it.
|
|
79
79
|
- **A change** that touches a recorded read, through the API or not, marks the value stale in the dispatch of [captured changes](events.md#how-changes-are-captured), and its run waits a second, so a burst of changes runs it once.
|
|
80
|
-
- **A change that lands while the function runs**
|
|
80
|
+
- **A change that lands while the function runs** and touches one of the reads that run made drops its result, and the value is computed again after the same second's wait; a change to what it did not read leaves the result kept.
|
|
81
|
+
- **Two runs of one record at once**, such as a change's and a time check's: only the one that started last keeps its result.
|
|
81
82
|
- **The value is written only when it differs**, so an unchanged value raises no event, live update or notification.
|
|
82
83
|
- A deleted record's value is dropped.
|
|
84
|
+
- A value no longer declared loses its state at the next migration, so declaring it again computes every record again.
|
|
83
85
|
|
|
84
86
|
Runs are `derived.compute` jobs, four at a time per worker, retried like any [job](jobs.md) when the function throws.
|
|
85
87
|
|
|
@@ -91,6 +93,7 @@ Runs are `derived.compute` jobs, four at a time per worker, retried like any [jo
|
|
|
91
93
|
| --- | --- |
|
|
92
94
|
| `derived.values` | A row per record and value: `status` (`current`, `stale` or `recalculating`), `value` as JSON, `computed_at`, and `flips_at`, the clock's next flip. |
|
|
93
95
|
| `derived.reads` | What each record's value read: the resource, the condition, and the fields it used. |
|
|
96
|
+
| `derived.pending` | The changes that landed while a record's run was under way, weighed against that run's reads when it ends. |
|
|
94
97
|
| `derived.declared` | The values whose records the migrations have computed once. |
|
|
95
98
|
|
|
96
99
|
## Limits
|
|
@@ -98,6 +101,8 @@ Runs are `derived.compute` jobs, four at a time per worker, retried like any [jo
|
|
|
98
101
|
- <gap>A derived value cannot fill a list of rows in another resource, such as one row per item that needs attention, because syncing a set of rows is not implemented.</gap>
|
|
99
102
|
- <gap>A derived value cannot see the reads inside a database function or view it calls, because reading their definitions is not implemented.</gap> Name them with `depends()`.
|
|
100
103
|
- <gap>A derived value whose function threw cannot show `stale` until its retry runs, because marking a failed run is not implemented; it shows `recalculating` meanwhile.</gap>
|
|
104
|
+
- <gap>A derived value cannot recompute the records it holds when its function changes, because tracking the function's code is not implemented; each record takes the new function at its next change or clock flip.</gap>
|
|
105
|
+
- <gap>A derived value cannot keep a result while a change touching what it read lands during every run, because bounding how often a run yields is not implemented; it keeps its last value meanwhile, and a record never computed has none.</gap>
|
|
101
106
|
- <gap>A derived value's status cannot be read through the REST API, because serving `derived.values` as a resource is not implemented.</gap>
|
|
102
107
|
|
|
103
108
|
## Reusing the detection
|