@protobase/cli 0.121.13 → 0.122.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
1
  //#region package.json
2
- var version = "0.121.13";
2
+ var version = "0.122.1";
3
3
  //#endregion
4
4
  export { version };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@protobase/cli",
3
- "version": "0.121.13",
3
+ "version": "0.122.1",
4
4
  "description": "The protobase command: scaffold, doctor, dev, build and serve a Protobase project.",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -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.1",
47
+ "@protobase/layout": "0.122.1",
48
+ "@protobase/query": "0.122.1",
49
+ "@protobase/schema": "0.122.1",
50
+ "@protobase/server": "0.122.1",
51
+ "@protobase/ui": "0.122.1",
52
+ "@protobase/workflows": "0.122.1",
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",
@@ -16,6 +16,7 @@ Mail the app sends, the PDF documents it makes, and forms for people without an
16
16
  - [PDF documents](../reference/pdf.md#documents): PDF files such as invoices and quotes are React components with typed data, rendered from jobs, hooks or functions and attached to mail as they are.
17
17
  - [Mail from your own mailbox](../reference/email.md#from-someones-own-mailbox) (beta): People link their Gmail on the account page, and the app's functions send mail from it; an action offers to connect the mailbox right there when the link is missing or expired.
18
18
  - [From addresses](../reference/email.md#from-addresses): People enter their mailbox's other send-as addresses once on the account page, each with a display name and a signature of its own, and the app sends from the one it names or their default.
19
+ - [Checking a From address](../reference/email.md#checking-a-from-address) (coming soon): The app sends one test message from a send-as address through the person's Gmail and shows on the account page the From it arrived with. That catches Gmail sending from the person's own address, with no error, when a send-as address is not set up or verified. Works only on apps hosted on Protobase Cloud; self-hosted apps show the address as unchecked.
19
20
  - [A From address on a record](../reference/email.md#a-from-address-on-a-record) (beta): A field such as a client's "Send from" is a dropdown of the person's addresses, and an address a record holds cannot be removed.
20
21
  - [Public forms](../reference/forms.md#what-the-visitor-sees): A form at its own address lets people without an account create a record, such as a contact request.
21
22
  - [Bot check](../reference/forms.md#bot-check): Each submission passes a check in the browser, without a third-party service or a puzzle.
@@ -481,6 +481,7 @@ Serves the API of a bundle from `protobase build` and owns the process around it
481
481
  | `PROTOBASE_FIRST_ADMIN_URL` | the hosting platform's page where the app's first user is added, such as its console's; while the app has no users, the sign-in page links there in place of the `protobase users create` command ([the first admin](auth.md#first-run)) |
482
482
  | `PROTOBASE_RUNS_ON_NOTE` | `true` ends the sign-in page on the [Runs on Protobase note](app-identity.md#runs-on-protobase-note), for a hosting platform; default `false`, and any value but `true` or `false` stops startup |
483
483
  | `PROTOBASE_RUNTIME_URL` | the endpoint behind the top bar's [runtime update button](versioning.md#runtime-updates), such as a hosting platform's; without it there is no button |
484
+ | `PROTOBASE_MAIL_CHECK_URL` | the hosting platform's service that [checks a From address](email.md#checking-a-from-address), signed with a key derived from `PROTOBASE_SECRET`; without it the account page says addresses cannot be checked |
484
485
  | `PROTOBASE_SENTRY_DSN` | the DSN of a Sentry-compatible error tracker the app's server and admin app send their errors to, after the config's `errorReporting` ([Error reporting](api.md#error-reporting)); without it nothing is sent |
485
486
  | `PROTOBASE_MAP_STYLE_URL` | the URL of the MapLibre style the record page's [maps](ui-config.md#maps) are drawn with, after the config's `maps`; without it there are no maps |
486
487
  | `PROTOBASE_SOURCES` | other Protobase APIs whose resources the app draws as its own, a JSON list of `{ "url", "label", "resources", "roles"? }` after the config's `remoteResources` ([Remote resources](remote-resources.md#declaring-a-source)) |
@@ -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
 
@@ -432,9 +432,24 @@ export default defineFunction(async (request, { personalMail }) => {
432
432
 
433
433
  - **The mailbox's own address** is the one its provider's ID token names; Google gives it with the `email` scope sign-in asks for.
434
434
  - **The account page's calls:** `GET /api/auth/account/mail-senders` lists the person's addresses with their mailbox's own `address`; `POST .../mail-senders/add { address, name?, signature? }`, `POST .../mail-senders/update { id, name?, signature?, isDefault? }` (`name: null` drops the name, `signature: null` drops its own) and `POST .../mail-senders/remove { id }` change them. Each acts on the signed-in person's own addresses only.
435
- - <gap>An entered address cannot be checked to work before mail goes out from it because the test mail through the mailbox is not implemented.</gap>
436
435
  - <gap>An address cannot be shared with others who send mail because proving that the person owns the address is not implemented.</gap>
437
436
 
437
+ ### Checking a From address
438
+
439
+ :::note[Coming soon]
440
+ The app's side is built; the hosting platform's service that receives the test messages is not live yet.
441
+ :::
442
+
443
+ Gmail sends from the account's own address, without an error, when a From address is not one of its verified send-as addresses. So the account page checks an address by sending one test message from it through the person's mailbox, to a one-time address of a mail check service, and showing the From it arrived with:
444
+
445
+ - **When:** adding an address checks it at once; its dialog, under **Edit**, checks it again with **Check address**, and after a result with **Check again**.
446
+ - **Waiting:** the dialog asks every 3 seconds whether the message arrived, for up to 2 minutes, then says it did not arrive in time. Closing the dialog stops asking.
447
+ - **The result:** a From equal to the address, without regard to case, confirms it; any other shows the address the mailbox used instead, with how to set the address up in Gmail. The message also shows in the person's Sent folder.
448
+ - **The service:** the hosting platform names it in `PROTOBASE_MAIL_CHECK_URL`, a URL the app treats as opaque. The app makes two signed JSON `POST`s under it: `/alias-checks` answers `{ token, address }`, a one-time address and its token, and `/alias-checks/result { token }` answers `{ received: false }`, or `{ received: true, from }` with the address in the message's From header. Each carries [Standard Webhooks](https://www.standardwebhooks.com) headers under a key derived from `PROTOBASE_SECRET` by HKDF (`mailCheckSecret` and `mailCheckHeaders` of `@protobase/server`), which the service checks with `verifyStandardWebhook`. `PROTOBASE_MAIL_CHECK_URL` without `PROTOBASE_SECRET` stops startup.
449
+ - **Unchecked:** without the service, the dialog says the app cannot check From addresses, and how to check one by hand.
450
+ - **The account page's calls:** `GET /api/auth/account/mail-senders` says `checks: true` where the app can check; `POST .../mail-senders/check { id }` sends the test message and answers `{ status: 'waiting', check }`, or `{ status: 'unchecked' }`; `POST .../mail-senders/check-result { id, check }` answers `waiting`, `confirmed` or `mismatch` with `from`. Each acts on the signed-in person's own addresses only, and staff signed in as them cannot send a check.
451
+ - <gap>Self-hosted apps cannot check a From address because no mail check service that receives the test messages is implemented outside Protobase Cloud.</gap>
452
+
438
453
  ### A From address on a record
439
454
 
440
455
  :::caution[Beta]