@fungi.computer/carrier 0.2.4 → 0.2.6
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/README.md +79 -38
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -1,50 +1,25 @@
|
|
|
1
1
|
# Carrier (`@fungi.computer/carrier`)
|
|
2
2
|
|
|
3
|
-
Carrier
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
Carrier
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
change, and Post delivers the event to the addressed object with retries, dead
|
|
15
|
-
letters and idempotent receipts.
|
|
3
|
+
Carrier sends email and passes messages between parts of your app reliably, and
|
|
4
|
+
records honestly what happened to each one.
|
|
5
|
+
|
|
6
|
+
```mermaid
|
|
7
|
+
flowchart LR
|
|
8
|
+
App[Your app] -->|send| Carrier
|
|
9
|
+
Carrier -->|commits to SQLite| Store[(Your storage)]
|
|
10
|
+
Carrier -->|tick| Provider[Email provider]
|
|
11
|
+
Carrier -->|Post| DO[Another Durable Object]
|
|
12
|
+
Provider -->|what it really said| Carrier
|
|
13
|
+
```
|
|
16
14
|
|
|
17
|
-
|
|
18
|
-
adapter wires Email to Durable Object SQLite, alarms and the Email Service
|
|
19
|
-
binding, so your application keeps no delivery state machine of its own.
|
|
15
|
+
## Quick start
|
|
20
16
|
|
|
21
|
-
|
|
17
|
+
Install it:
|
|
22
18
|
|
|
23
19
|
```sh
|
|
24
20
|
npm install @fungi.computer/carrier @fungi.computer/watchdog
|
|
25
21
|
```
|
|
26
22
|
|
|
27
|
-
The Node SQLite quick start imports Watchdog’s adapter directly.
|
|
28
|
-
|
|
29
|
-
Carrier is ESM-only. It depends on `@fungi.computer/watchdog`, `effect`, `pg`
|
|
30
|
-
and `@cloudflare/workers-types`, which npm installs for you. The portable Email
|
|
31
|
-
owner and SQLite Post run on any synchronous SQLite handle, such as Durable
|
|
32
|
-
Object storage or `node:sqlite` in Node 24. The D1 and PostgreSQL Post adapters
|
|
33
|
-
need a migrated database.
|
|
34
|
-
|
|
35
|
-
Entrypoints:
|
|
36
|
-
|
|
37
|
-
- `@fungi.computer/carrier` and `@fungi.computer/carrier/email`: the Email API,
|
|
38
|
-
`createCarrier` and its types.
|
|
39
|
-
- `@fungi.computer/carrier/cloudflare`: `createCloudflareCarrier` for a Durable
|
|
40
|
-
Object, and `cloudflareEmailTransport`.
|
|
41
|
-
- `@fungi.computer/carrier/inspection`: read-only operator inspection.
|
|
42
|
-
- `@fungi.computer/carrier/post`: Post over Durable Object SQLite.
|
|
43
|
-
- `@fungi.computer/carrier/post-d1` and `@fungi.computer/carrier/post-postgres`:
|
|
44
|
-
Post over shared D1 or PostgreSQL.
|
|
45
|
-
|
|
46
|
-
## Quick start
|
|
47
|
-
|
|
48
23
|
This sends one email through an in-memory `node:sqlite` store and a fake
|
|
49
24
|
transport. Swap the transport for a real provider and the store for your Durable
|
|
50
25
|
Object storage when you deploy.
|
|
@@ -92,6 +67,72 @@ from the Durable Object alarm.
|
|
|
92
67
|
|
|
93
68
|
In a Durable Object, `ctx.storage` is already the SQLite owner.
|
|
94
69
|
|
|
70
|
+
## Common tasks
|
|
71
|
+
|
|
72
|
+
### Send an email
|
|
73
|
+
|
|
74
|
+
`send()` stores it and `tick()` hands it to the provider. See the Quick start.
|
|
75
|
+
|
|
76
|
+
### Send an event between objects
|
|
77
|
+
|
|
78
|
+
Post sends inside your own transaction. See [Post](#post).
|
|
79
|
+
|
|
80
|
+
### Inspect what happened
|
|
81
|
+
|
|
82
|
+
See Operator inspection.
|
|
83
|
+
|
|
84
|
+
### Use another provider or database
|
|
85
|
+
|
|
86
|
+
See Another provider and
|
|
87
|
+
[Post transactions on D1 and PostgreSQL](#post-transactions-on-d1-and-postgresql).
|
|
88
|
+
|
|
89
|
+
## Reference
|
|
90
|
+
|
|
91
|
+
### Overview
|
|
92
|
+
|
|
93
|
+
Carrier delivers things durably and tells you the truth about what happened. It
|
|
94
|
+
has two parts.
|
|
95
|
+
|
|
96
|
+
**Email.** You call `send()` with an email and a stable ID. Carrier commits it
|
|
97
|
+
to SQLite, dispatches it through your provider, retries temporary refusals, and
|
|
98
|
+
records what the provider actually said. A receipt never claims more than the
|
|
99
|
+
evidence shows. If a response is lost, the email is `outcome_unknown`, and
|
|
100
|
+
Carrier does not guess and send it twice.
|
|
101
|
+
|
|
102
|
+
**Post.** Typed, ordered, point-to-point envelopes between named Cloudflare
|
|
103
|
+
Durable Objects. You call `send` inside the same transaction as your own state
|
|
104
|
+
change, and Post delivers the event to the addressed object with retries, dead
|
|
105
|
+
letters and idempotent receipts.
|
|
106
|
+
|
|
107
|
+
Both run on [Watchdog](../watchdog/README.md) for durable work. The Cloudflare
|
|
108
|
+
adapter wires Email to Durable Object SQLite, alarms and the Email Service
|
|
109
|
+
binding, so your application keeps no delivery state machine of its own.
|
|
110
|
+
|
|
111
|
+
## Install or set up
|
|
112
|
+
|
|
113
|
+
```sh
|
|
114
|
+
npm install @fungi.computer/carrier @fungi.computer/watchdog
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
The Node SQLite quick start imports Watchdog’s adapter directly.
|
|
118
|
+
|
|
119
|
+
Carrier is ESM-only. It depends on `@fungi.computer/watchdog`, `effect`, `pg`
|
|
120
|
+
and `@cloudflare/workers-types`, which npm installs for you. The portable Email
|
|
121
|
+
owner and SQLite Post run on any synchronous SQLite handle, such as Durable
|
|
122
|
+
Object storage or `node:sqlite` in Node 24. The D1 and PostgreSQL Post adapters
|
|
123
|
+
need a migrated database.
|
|
124
|
+
|
|
125
|
+
Entrypoints:
|
|
126
|
+
|
|
127
|
+
- `@fungi.computer/carrier` and `@fungi.computer/carrier/email`: the Email API,
|
|
128
|
+
`createCarrier` and its types.
|
|
129
|
+
- `@fungi.computer/carrier/cloudflare`: `createCloudflareCarrier` for a Durable
|
|
130
|
+
Object, and `cloudflareEmailTransport`.
|
|
131
|
+
- `@fungi.computer/carrier/inspection`: read-only operator inspection.
|
|
132
|
+
- `@fungi.computer/carrier/post`: Post over Durable Object SQLite.
|
|
133
|
+
- `@fungi.computer/carrier/post-d1` and `@fungi.computer/carrier/post-postgres`:
|
|
134
|
+
Post over shared D1 or PostgreSQL.
|
|
135
|
+
|
|
95
136
|
## Core concepts
|
|
96
137
|
|
|
97
138
|
**Emails and Messages.** One Email has shared content and an envelope: `from`,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fungi.computer/carrier",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.6",
|
|
4
4
|
"author": "Levi <levi@technomancy.dev>",
|
|
5
5
|
"description": "Durable email submission and recipient delivery tracking",
|
|
6
6
|
"type": "module",
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
"@cloudflare/workers-types": "5.20260828.1",
|
|
47
47
|
"@fungi.computer/almanac": "0.2.1",
|
|
48
48
|
"@fungi.computer/cairn": "0.1.0",
|
|
49
|
-
"@fungi.computer/watchdog": "0.1.
|
|
49
|
+
"@fungi.computer/watchdog": "0.1.5",
|
|
50
50
|
"effect": "4.0.2",
|
|
51
51
|
"pg": "8.23.0",
|
|
52
52
|
"@types/pg": "8.23.1"
|