@protobase/cli 0.121.13 → 0.122.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.
@@ -1,4 +1,4 @@
1
1
  //#region package.json
2
- var version = "0.121.13";
2
+ var version = "0.122.0";
3
3
  //#endregion
4
4
  export { version };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@protobase/cli",
3
- "version": "0.121.13",
3
+ "version": "0.122.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.121.13",
47
- "@protobase/layout": "0.121.13",
48
- "@protobase/query": "0.121.13",
49
- "@protobase/schema": "0.121.13",
50
- "@protobase/server": "0.121.13",
51
- "@protobase/ui": "0.121.13",
52
- "@protobase/workflows": "0.121.13",
46
+ "@protobase/config": "0.122.0",
47
+ "@protobase/layout": "0.122.0",
48
+ "@protobase/query": "0.122.0",
49
+ "@protobase/schema": "0.122.0",
50
+ "@protobase/server": "0.122.0",
51
+ "@protobase/ui": "0.122.0",
52
+ "@protobase/workflows": "0.122.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",
@@ -279,9 +279,7 @@ export const orders = resource('orders')
279
279
  ## Time rollups
280
280
 
281
281
  :::caution[Beta]
282
- Not yet:
283
-
284
- - <gap>A time rollup cannot average an optional field because a count of its records with a value is not implemented.</gap>
282
+ A rollup cannot yet group by an optional field or roll up a source with some access rules, as the marked limits below say.
285
283
  :::
286
284
 
287
285
  A large events table, such as millions of meter readings, gets a **time rollup**: a table with one row per hour or day and per group, holding how many records fell in it and the sums and greatest values of their numbers. A chart over months then reads a few thousand rows instead of millions. You declare the rollup as a resource over the events resource, and [`protobase migration`](cli.md#migration) writes its table, indexes and refresh function into the project's next migration (`NNN_computed.sql`), with the rollup filled once. From then on the app keeps it up to date by itself, at most a minute behind. It is plain Postgres: no extension.
@@ -339,8 +337,9 @@ The rollup's records have these fields, all read-only:
339
337
  | `events` | How many records of the source fell in the bucket, as a bigint. |
340
338
  | `<field>_sum` | The sum of the field: a bigint for an integer, a decimal of ten more digits for a bigint or a decimal. Empty when every value was. |
341
339
  | `<field>_max` | The greatest value of the field, of its type. Empty when every value was. |
340
+ | `<field>_count` | How many records of the bucket have a value of the field, as a bigint, for every field in `measures`. |
342
341
 
343
- Records the source soft deleted are left out. The migration creates the table in the rollup's schema, with a unique index on `(bucket, by...)` and an index on `(group, bucket)` per group, so a list filtered on the bucket, on a group or on both passes the [scan guard](api.md#safety). It writes `rollups.<table>_refresh(from timestamptz)`, which recomputes every bucket from the one `from` falls in, in one statement: it upserts their counts and sums and deletes those left without records. When the rollup's declaration changes, the migration drops its table and creates and fills it again. The table and function of a rollup the config no longer has stay; a migration of your own drops them, in a deploy after the one that stops reading them.
342
+ Records the source soft deleted are left out. The migration creates the table in the rollup's schema, with a unique index on `(bucket, by...)` and an index on `(group, bucket)` per group, so a list filtered on the bucket, on a group or on both passes the [scan guard](api.md#safety). It writes `rollups.<table>_refresh(from timestamptz)`, which recomputes every bucket from the one `from` falls in, in one statement: it upserts their counts, sums and greatest values and deletes those left without records. When the rollup's declaration changes, the migration drops its table and creates and fills it again. The table and function of a rollup the config no longer has stay; a migration of your own drops them, in a deploy after the one that stops reading them.
344
343
 
345
344
  Only the database writes a rollup's rows: creates, updates and deletes are refused whatever its rules say, and it cannot have soft delete, a manual order, an author, a parent or `.openExisting()`. Its access is its own `.access()`: the source's rules do not reach it, so give it rules that let read only those who may see every record of a group. Its tenant is the source's, which is why `by` includes it. A field that is sensitive or has its own read rule, such as `.access({ read: roles.can('costs.read') })`, cannot be grouped by or measured, and one with its own read rule cannot be the rollup's `time`, since a bucket would show it to anyone who reads the rollup. The server does not start while the source has its own `read` or `list` rule in `.access()`, whatever the rule returns, or while a role reads only some of the source's records that a bucket mixes with others: `.own` or `.team` while `by` does not include the source's owner field, or a role's filter on fields outside `by`. <gap>A time rollup cannot group by an optional field because a bucket key with empty parts is not implemented.</gap> <gap>A time rollup cannot roll up a resource whose reads follow a parent because applying the parent's access to buckets is not implemented.</gap> <gap>A time rollup cannot roll up a resource with its own `read` or `list` access rule because declaring the fields such a rule filters on is not implemented.</gap>
346
345
 
@@ -360,7 +359,7 @@ A [`Chart`](blocks.md#chart), [`:aggregate`](api.md#routes) and `:series` read a
360
359
  | --- | --- |
361
360
  | The count | The count, or `sum=events` |
362
361
  | `sum=watts` | `sum=watts_sum` |
363
- | `average=watts` | `average=watts_sum`: the sum divided by the records it holds, not an average of hourly averages |
362
+ | `average=watts` | `average=watts_sum`: the sum divided by the records with a value, `watts_count`, not an average of hourly averages; empty when no record has one |
364
363
  | `maximum=watts` | `maximum=watts_max` |
365
364
 
366
365
  Any other measure, such as `average=watts_max` or `sum` of a `by` field, is refused with `400 invalid-option`, and so is what the buckets cannot tell apart:
@@ -368,7 +367,6 @@ Any other measure, such as `average=watts_max` or `sum` of a `by` field, is refu
368
367
  - A granularity finer than the bucket, such as `15_minutes` on an hourly rollup or `hour` on a daily one.
369
368
  - For an hourly rollup, a `time_zone` whose hours or days start inside a UTC hour over the range, such as `Asia/Kolkata`. Zones a whole number of hours off UTC, such as `Europe/Amsterdam`, give their own days, weeks and months.
370
369
  - For a daily rollup, any `time_zone` but `UTC`. A chart asks for the viewer's time zone, so a chart on a daily rollup answers only to viewers in UTC; chart an hourly rollup for the others.
371
- - An `average` of a field that is optional in the source, since `events` counts its records without a value too. Its sum and maximum work. <gap>A time rollup cannot average an optional field because a count of its records with a value is not implemented.</gap>
372
370
 
373
371
  A bucket counts when its start is inside the range, so a range that starts inside an hour or day counts from the next one. Facets and histograms of a rollup count its rows, as for any resource. This dashboard charts the example's readings over 90 days from the hourly rollup:
374
372