@fungi.computer/carrier 0.0.0-stage → 0.1.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/LICENSE +21 -0
- package/README.md +468 -2
- package/dist/cloudflare.d.ts +32 -0
- package/dist/cloudflare.js +80 -0
- package/dist/email.d.ts +2 -0
- package/dist/email.js +2 -0
- package/dist/index.d.ts +21 -0
- package/dist/index.js +28 -0
- package/dist/inspection.d.ts +108 -0
- package/dist/inspection.js +188 -0
- package/dist/internal/cloudflare-send.d.ts +9 -0
- package/dist/internal/cloudflare-send.js +79 -0
- package/dist/internal/contracts.d.ts +94 -0
- package/dist/internal/contracts.js +7 -0
- package/dist/internal/owner.d.ts +24 -0
- package/dist/internal/owner.js +419 -0
- package/dist/internal/policy.d.ts +25 -0
- package/dist/internal/policy.js +18 -0
- package/dist/internal/post-contract.d.ts +27 -0
- package/dist/internal/post-contract.js +22 -0
- package/dist/internal/post-execution.d.ts +45 -0
- package/dist/internal/post-execution.js +73 -0
- package/dist/internal/post-sql.d.ts +51 -0
- package/dist/internal/post-sql.js +259 -0
- package/dist/internal/receipt-schema.d.ts +3 -0
- package/dist/internal/receipt-schema.js +12 -0
- package/dist/post-d1.d.ts +36 -0
- package/dist/post-d1.js +55 -0
- package/dist/post-outbox.d.ts +52 -0
- package/dist/post-outbox.js +152 -0
- package/dist/post-postgres.d.ts +25 -0
- package/dist/post-postgres.js +79 -0
- package/dist/post.d.ts +189 -0
- package/dist/post.js +437 -0
- package/dist/testing.d.ts +16 -0
- package/dist/testing.js +20 -0
- package/docs/api/README.md +20 -0
- package/docs/api/cloudflare.md +100 -0
- package/docs/api/email.md +87 -0
- package/docs/api/index.md +343 -0
- package/docs/api/inspection.md +281 -0
- package/docs/api/post-d1.md +184 -0
- package/docs/api/post-postgres.md +108 -0
- package/docs/api/post.md +599 -0
- package/docs/api/testing.md +46 -0
- package/package.json +95 -3
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
<!-- Generated by Botanical API docs (TypeDoc + typedoc-plugin-markdown). Do not edit. -->
|
|
2
|
+
|
|
3
|
+
[**@fungi.computer/carrier**](README.md)
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
[@fungi.computer/carrier](README.md) / post-d1
|
|
8
|
+
|
|
9
|
+
# post-d1
|
|
10
|
+
|
|
11
|
+
## Type Aliases
|
|
12
|
+
|
|
13
|
+
### SqlPostOptions
|
|
14
|
+
|
|
15
|
+
```ts
|
|
16
|
+
type SqlPostOptions<R> = Readonly<{
|
|
17
|
+
routes: R;
|
|
18
|
+
failureDetail?: (cause) => string;
|
|
19
|
+
retry?: Readonly<{
|
|
20
|
+
maxAttempts: number;
|
|
21
|
+
baseDelayMs: number;
|
|
22
|
+
maxDelayMs: number;
|
|
23
|
+
}>;
|
|
24
|
+
now: () => number;
|
|
25
|
+
scheduleWake: (at) => Promise<void>;
|
|
26
|
+
}>;
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
SQL native Carrier runtime configuration; route decisions remain in Post.
|
|
30
|
+
|
|
31
|
+
#### Type Parameters
|
|
32
|
+
|
|
33
|
+
| Type Parameter |
|
|
34
|
+
| ------------------------------------------------------------------------------------ |
|
|
35
|
+
| `R` _extends_ `Record`\<`string`, [`PostRegistryRoute`](post.md#postregistryroute)\> |
|
|
36
|
+
|
|
37
|
+
---
|
|
38
|
+
|
|
39
|
+
### SqlPostRuntime
|
|
40
|
+
|
|
41
|
+
```ts
|
|
42
|
+
type SqlPostRuntime = Readonly<{
|
|
43
|
+
execute: (
|
|
44
|
+
job,
|
|
45
|
+
signal?,
|
|
46
|
+
) => Promise<
|
|
47
|
+
Readonly<{
|
|
48
|
+
kind: "completed";
|
|
49
|
+
}>
|
|
50
|
+
>;
|
|
51
|
+
enqueueDue: (limit?, afterKey?) => Promise<string | undefined>;
|
|
52
|
+
read: (key) => Promise<PostRow | undefined>;
|
|
53
|
+
}>;
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
Async inspection and Watchdog executor shared by D1 and PostgreSQL.
|
|
57
|
+
|
|
58
|
+
---
|
|
59
|
+
|
|
60
|
+
### D1PostSource
|
|
61
|
+
|
|
62
|
+
```ts
|
|
63
|
+
type D1PostSource = Readonly<{
|
|
64
|
+
text: string;
|
|
65
|
+
values: readonly (string | number | null)[];
|
|
66
|
+
}>;
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
Trusted SELECT yielding post_key, envelope_json, queue_name, next_attempt_at and
|
|
70
|
+
job_id.
|
|
71
|
+
|
|
72
|
+
---
|
|
73
|
+
|
|
74
|
+
### D1Post
|
|
75
|
+
|
|
76
|
+
```ts
|
|
77
|
+
type D1Post = SqlPostRuntime &
|
|
78
|
+
Readonly<{
|
|
79
|
+
send: (envelope) => readonly D1PreparedStatement[];
|
|
80
|
+
sendFromSelect: (source) => readonly D1PreparedStatement[];
|
|
81
|
+
}>;
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
Post admission statements; callers commit them with the originating D1 fact.
|
|
85
|
+
|
|
86
|
+
---
|
|
87
|
+
|
|
88
|
+
### D1PostErasureStatement
|
|
89
|
+
|
|
90
|
+
```ts
|
|
91
|
+
type D1PostErasureStatement = Readonly<{
|
|
92
|
+
text: string;
|
|
93
|
+
values: readonly (string | number | null)[];
|
|
94
|
+
}>;
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
Native erasure statement; its values remain bound by the caller's D1 driver.
|
|
98
|
+
|
|
99
|
+
## Variables
|
|
100
|
+
|
|
101
|
+
### postD1Schema
|
|
102
|
+
|
|
103
|
+
```ts
|
|
104
|
+
const postD1Schema: readonly string[];
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
Carrier-owned D1 schema, applied by the deployment migration owner.
|
|
108
|
+
|
|
109
|
+
## Functions
|
|
110
|
+
|
|
111
|
+
### createD1Post()
|
|
112
|
+
|
|
113
|
+
```ts
|
|
114
|
+
function createD1Post<R>(options): D1Post;
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
Bind the Post registry to native D1 batch admission and the shared delivery
|
|
118
|
+
engine.
|
|
119
|
+
|
|
120
|
+
#### Type Parameters
|
|
121
|
+
|
|
122
|
+
| Type Parameter |
|
|
123
|
+
| --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
124
|
+
| `R` _extends_ `Record`\<`string`, `Readonly`\<\{ `addressKind`: `string`; `address`: `Codec`\<`unknown`, `unknown`\>; `event`: `Codec`\<`unknown`, `unknown`\>; `encodeEnvelope`: (`envelope`) => `object`; `parseDelivery`: (`envelope`) => `object`; `prepareEnvelope?`: (`envelope`, `signal`) => `Promise`\<\{ `key`: `string`; `kind`: `string`; `address`: `unknown`; `event`: `unknown`; \}\>; `recordDelivered?`: (`envelope`) => `void`; `nameOf`: (`envelope`) => `string`; `namespace`: `Readonly`\<\{ `getByName`: (`name`) => `Readonly`\<\{ `deliver`: (`envelope`) => `Promise`\<[`PostDeliveryResult`](post.md#postdeliveryresult)\>; \}\>; \}\>; `recordCursor?`: (`envelope`, `cursor`) => `void`; `recordRefused?`: (`envelope`) => `void`; \}\>\> |
|
|
125
|
+
|
|
126
|
+
#### Parameters
|
|
127
|
+
|
|
128
|
+
| Parameter | Type |
|
|
129
|
+
| --------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
130
|
+
| `options` | `Readonly`\<\{ `routes`: `R`; `failureDetail?`: (`cause`) => `string`; `retry?`: `Readonly`\<\{ `maxAttempts`: `number`; `baseDelayMs`: `number`; `maxDelayMs`: `number`; \}\>; `now`: () => `number`; `scheduleWake`: (`at`) => `Promise`\<`void`\>; \}\> & `Readonly`\<\{ `database`: `D1Database`; `watchdog`: `D1Watchdog`; \}\> |
|
|
131
|
+
|
|
132
|
+
#### Returns
|
|
133
|
+
|
|
134
|
+
[`D1Post`](#d1post)
|
|
135
|
+
|
|
136
|
+
---
|
|
137
|
+
|
|
138
|
+
### prepareD1PostAdmission()
|
|
139
|
+
|
|
140
|
+
```ts
|
|
141
|
+
function prepareD1PostAdmission(
|
|
142
|
+
database,
|
|
143
|
+
source,
|
|
144
|
+
): readonly D1PreparedStatement[];
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
Prepare conditional envelopes and their jobs inside the producer's D1 batch.
|
|
148
|
+
|
|
149
|
+
#### Parameters
|
|
150
|
+
|
|
151
|
+
| Parameter | Type |
|
|
152
|
+
| ---------- | ------------------------------- |
|
|
153
|
+
| `database` | `D1Database` |
|
|
154
|
+
| `source` | [`D1PostSource`](#d1postsource) |
|
|
155
|
+
|
|
156
|
+
#### Returns
|
|
157
|
+
|
|
158
|
+
readonly `D1PreparedStatement`[]
|
|
159
|
+
|
|
160
|
+
---
|
|
161
|
+
|
|
162
|
+
### purgeD1Post()
|
|
163
|
+
|
|
164
|
+
```ts
|
|
165
|
+
function purgeD1Post(source): readonly Readonly<{
|
|
166
|
+
text: string;
|
|
167
|
+
values: readonly (string | number | null)[];
|
|
168
|
+
}>[];
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
Remove selected recipient queues, including every envelope and attempt,
|
|
172
|
+
atomically. The trusted SELECT yields queue_name from producer/envelope facts,
|
|
173
|
+
not job state.
|
|
174
|
+
|
|
175
|
+
#### Parameters
|
|
176
|
+
|
|
177
|
+
| Parameter | Type |
|
|
178
|
+
| --------- | --------------------------------------------------- |
|
|
179
|
+
| `source` | [`D1PostErasureStatement`](#d1posterasurestatement) |
|
|
180
|
+
|
|
181
|
+
#### Returns
|
|
182
|
+
|
|
183
|
+
readonly `Readonly`\<\{ `text`: `string`; `values`: readonly (`string` \|
|
|
184
|
+
`number` \| `null`)[]; \}\>[]
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
<!-- Generated by Botanical API docs (TypeDoc + typedoc-plugin-markdown). Do not edit. -->
|
|
2
|
+
|
|
3
|
+
[**@fungi.computer/carrier**](README.md)
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
[@fungi.computer/carrier](README.md) / post-postgres
|
|
8
|
+
|
|
9
|
+
# post-postgres
|
|
10
|
+
|
|
11
|
+
## Type Aliases
|
|
12
|
+
|
|
13
|
+
### PostgresPost
|
|
14
|
+
|
|
15
|
+
```ts
|
|
16
|
+
type PostgresPost = SqlPostRuntime &
|
|
17
|
+
Readonly<{
|
|
18
|
+
send: (client, envelope) => Promise<void>;
|
|
19
|
+
}>;
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
Post on PostgreSQL; the producer retains ownership of BEGIN and COMMIT.
|
|
23
|
+
|
|
24
|
+
---
|
|
25
|
+
|
|
26
|
+
### PostgresPostErasureStatement
|
|
27
|
+
|
|
28
|
+
```ts
|
|
29
|
+
type PostgresPostErasureStatement = Readonly<{
|
|
30
|
+
text: string;
|
|
31
|
+
values: readonly (string | number | null)[];
|
|
32
|
+
}>;
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
Parameterized native erasure; the producer controls BEGIN and COMMIT.
|
|
36
|
+
|
|
37
|
+
## Variables
|
|
38
|
+
|
|
39
|
+
### postPostgresSchema
|
|
40
|
+
|
|
41
|
+
```ts
|
|
42
|
+
const postPostgresSchema: readonly string[];
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
Carrier-owned PostgreSQL schema, applied by the deployment migration owner.
|
|
46
|
+
|
|
47
|
+
## Functions
|
|
48
|
+
|
|
49
|
+
### createPostgresPost()
|
|
50
|
+
|
|
51
|
+
```ts
|
|
52
|
+
function createPostgresPost<R>(options): PostgresPost;
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
Bind the Post registry to a PostgreSQL owner and the shared delivery engine.
|
|
56
|
+
|
|
57
|
+
#### Type Parameters
|
|
58
|
+
|
|
59
|
+
| Type Parameter |
|
|
60
|
+
| --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
61
|
+
| `R` _extends_ `Record`\<`string`, `Readonly`\<\{ `addressKind`: `string`; `address`: `Codec`\<`unknown`, `unknown`\>; `event`: `Codec`\<`unknown`, `unknown`\>; `encodeEnvelope`: (`envelope`) => `object`; `parseDelivery`: (`envelope`) => `object`; `prepareEnvelope?`: (`envelope`, `signal`) => `Promise`\<\{ `key`: `string`; `kind`: `string`; `address`: `unknown`; `event`: `unknown`; \}\>; `recordDelivered?`: (`envelope`) => `void`; `nameOf`: (`envelope`) => `string`; `namespace`: `Readonly`\<\{ `getByName`: (`name`) => `Readonly`\<\{ `deliver`: (`envelope`) => `Promise`\<[`PostDeliveryResult`](post.md#postdeliveryresult)\>; \}\>; \}\>; `recordCursor?`: (`envelope`, `cursor`) => `void`; `recordRefused?`: (`envelope`) => `void`; \}\>\> |
|
|
62
|
+
|
|
63
|
+
#### Parameters
|
|
64
|
+
|
|
65
|
+
| Parameter | Type |
|
|
66
|
+
| --------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
67
|
+
| `options` | `Readonly`\<\{ `routes`: `R`; `failureDetail?`: (`cause`) => `string`; `retry?`: `Readonly`\<\{ `maxAttempts`: `number`; `baseDelayMs`: `number`; `maxDelayMs`: `number`; \}\>; `now`: () => `number`; `scheduleWake`: (`at`) => `Promise`\<`void`\>; \}\> & `Readonly`\<\{ `database`: `Pick`\<`Pool`, `"query"` \| `"connect"`\>; `watchdog`: `PostgresWatchdog`; \}\> |
|
|
68
|
+
|
|
69
|
+
#### Returns
|
|
70
|
+
|
|
71
|
+
[`PostgresPost`](#postgrespost)
|
|
72
|
+
|
|
73
|
+
---
|
|
74
|
+
|
|
75
|
+
### purgePostgresPost()
|
|
76
|
+
|
|
77
|
+
```ts
|
|
78
|
+
function purgePostgresPost(source): readonly Readonly<{
|
|
79
|
+
text: string;
|
|
80
|
+
values: readonly (string | number | null)[];
|
|
81
|
+
}>[];
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
Purge selected recipient queues, including all envelopes and attempts. The
|
|
85
|
+
trusted SELECT yields queue_name from producer/envelope facts, not job state.
|
|
86
|
+
|
|
87
|
+
#### Parameters
|
|
88
|
+
|
|
89
|
+
| Parameter | Type |
|
|
90
|
+
| --------- | --------------------------------------------------------------- |
|
|
91
|
+
| `source` | [`PostgresPostErasureStatement`](#postgresposterasurestatement) |
|
|
92
|
+
|
|
93
|
+
#### Returns
|
|
94
|
+
|
|
95
|
+
readonly `Readonly`\<\{ `text`: `string`; `values`: readonly (`string` \|
|
|
96
|
+
`number` \| `null`)[]; \}\>[]
|
|
97
|
+
|
|
98
|
+
## References
|
|
99
|
+
|
|
100
|
+
### SqlPostOptions
|
|
101
|
+
|
|
102
|
+
Re-exports [SqlPostOptions](post-d1.md#sqlpostoptions)
|
|
103
|
+
|
|
104
|
+
---
|
|
105
|
+
|
|
106
|
+
### SqlPostRuntime
|
|
107
|
+
|
|
108
|
+
Re-exports [SqlPostRuntime](post-d1.md#sqlpostruntime)
|