@protobase/cli 0.121.0 → 0.121.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.0";
2
+ var version = "0.121.1";
3
3
  //#endregion
4
4
  export { version };
@@ -8,7 +8,7 @@ const relationTargets = [
8
8
  const typesCompatible = (declared, base) => {
9
9
  if (declared === base) return true;
10
10
  if (declared === "relation") return relationTargets.includes(base);
11
- if (declared === "currency" || declared === "country" || declared === "file") return base === "text";
11
+ if (declared === "currency" || declared === "country" || declared === "mail_sender" || declared === "file") return base === "text";
12
12
  if (declared === "enum") return base === "text";
13
13
  if (declared === "text") return base === "enum";
14
14
  return false;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@protobase/cli",
3
- "version": "0.121.0",
3
+ "version": "0.121.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.0",
47
- "@protobase/layout": "0.121.0",
48
- "@protobase/query": "0.121.0",
49
- "@protobase/schema": "0.121.0",
50
- "@protobase/server": "0.121.0",
51
- "@protobase/ui": "0.121.0",
52
- "@protobase/workflows": "0.121.0",
46
+ "@protobase/config": "0.121.1",
47
+ "@protobase/layout": "0.121.1",
48
+ "@protobase/query": "0.121.1",
49
+ "@protobase/schema": "0.121.1",
50
+ "@protobase/server": "0.121.1",
51
+ "@protobase/ui": "0.121.1",
52
+ "@protobase/workflows": "0.121.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",
@@ -15,6 +15,7 @@ Mail the app sends, the PDF documents it makes, and forms for people without an
15
15
  - [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.
16
16
  - [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.
17
17
  - [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.
18
+ - [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.
18
19
  - [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.
19
20
  - [Bot check](../reference/forms.md#bot-check): Each submission passes a check in the browser, without a third-party service or a puzzle.
20
21
  - [Form rate limit](../reference/forms.md#rate-limit): Each client sends only a set number of submissions per minute.
@@ -93,6 +93,7 @@ Field and resource names are snake_case by convention, like the columns: they ar
93
93
  | `f.relation('resource')` | the key column(s) of another resource | its key | `.columns([...])` |
94
94
  | `f.currency()` | `text` | ISO 4217 code (`EUR`) | |
95
95
  | `f.country()` | `text` | ISO 3166-1 alpha-2 code (`NL`) | |
96
+ | `f.mailSender()` | `text` | a From address the saver may send from (`billing@shop.example`) | the form offers the saver's addresses as a dropdown; see [A From address on a record](email.md#a-from-address-on-a-record) |
96
97
  | `f.file()` | `text` | `{ uri, name, type, size, url }`; written with a ticket from `:upload` | `.accept([...])`, `.maxSize(size)`, `.public()`, `.storage(name)`, `.derive({...})`; see [Files](files.md) |
97
98
 
98
99
  A constraint a type does not support (`f.boolean().min(1)`) throws when the config loads. The builders are the members of [`f`](https://docs.protobase.net/api/schema/variables/f/).
@@ -402,6 +402,32 @@ export default defineFunction(async (request, { personalMail }) => {
402
402
  - <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>
403
403
  - <gap>An address cannot be shared with others who send mail because proving that the person owns the address is not implemented.</gap>
404
404
 
405
+ ### A From address on a record
406
+
407
+ :::caution[Beta]
408
+ A removal refused over records does not say which records hold the address; and since addresses cannot be shared yet, everyone else sees an address on a shared record as not available.
409
+ :::
410
+
411
+ A record can hold the address its mail goes out from, such as a client's or the seller's "Send from": declare the field with `f.mailSender()`, on a `text` column, and pass its value to `send({ from })`.
412
+
413
+ ```ts
414
+ send_from: f.mailSender().optional(),
415
+ ```
416
+
417
+ - **The form:** a dropdown of the signed-in person's addresses, their mailbox's own first, then those they entered, each as `Name <address>` when it has a name. The empty choice, **Sender's default address**, stores `null`: mail goes out from the default address of whoever sends it.
418
+ - **Saving:** a create or update may only set an address the saving person may send from, by the rule `send` uses; the address is stored as their sender spells it. Any other is refused with a `400` naming the field and the address. A visitor, and anyone on an app without personal mail, can set none.
419
+ - **An address no longer offered,** such as one another person entered, still shows, marked **not available**, with a link to the account page. Saving other fields, or giving the same address again, leaves it as it is.
420
+ - **Read views** show the address, with its name when it is one of the reader's.
421
+ - **Removing an address in use:** while a record that is not soft-deleted holds it in an `f.mailSender()` field, removing it on the account page, or disconnecting the mailbox whose own address it is (`POST /api/auth/unlink-account`), is refused with a `409` and changes nothing:
422
+
423
+ ```json
424
+ { "code": "MAIL_SENDER_IN_USE", "message": "billing@shop.example is still the From address of records in this app. Give them another From address first." }
425
+ ```
426
+
427
+ The refusal names no records, since they may be records the person cannot read, such as another organization's. It is in the language the request's `Accept-Language` asks for. The address is matched without regard to case, as sending matches it, so an index on the column's `lower()` serves it.
428
+ - <gap>A refused removal cannot name the records that hold the address because checking which of them the person may read is not implemented.</gap>
429
+ - <gap>A mail sender field cannot offer addresses shared with the person, nor refuse unsharing one a record holds, because sharing an address is not implemented.</gap>
430
+
405
431
  ## In a bundle
406
432
 
407
433
  A [bundle](cli.md#the-config-module) gets React and React Email's renderer from the serve runtime, as it gets `@protobase/server` and `@protobase/server/email`, so an email's component and the renderer share one React and hooks such as `useContext` work. React Email's other components are inlined, though `@protobase/server` uses them too: it loads them only to send its own mail, so the runtime does not supply them. Its `<Tailwind>` component needs `tailwindcss`, which the runtime does not supply, so a served config cannot use it: style with `style` props instead.