@lunora/mail 1.0.0-alpha.1 → 1.0.0-alpha.2
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/__assets__/package-og.svg +1 -1
- package/dist/inbound/index.d.mts +9 -23
- package/dist/inbound/index.d.ts +9 -23
- package/dist/inbound/index.mjs +1 -1
- package/dist/index.d.mts +8 -1
- package/dist/index.d.ts +8 -1
- package/dist/index.mjs +3 -3
- package/dist/packem_shared/{createCaptureSink-CNhqLMZ1.mjs → createCaptureSink-DeihS4LH.mjs} +7 -5
- package/dist/packem_shared/{createInboundEmailHandler-Cd8dyzB7.mjs → createInboundEmailHandler-D0uCOrU-.mjs} +4 -1
- package/dist/packem_shared/{createMailer-CMVVTp0F.mjs → createMailer-oEKPAd4J.mjs} +1 -1
- package/dist/packem_shared/shard-CJ-TvmfT.mjs +13 -0
- package/dist/packem_shared/shard.d-CL2Lmliv.d.mts +39 -0
- package/dist/packem_shared/shard.d-CL2Lmliv.d.ts +39 -0
- package/package.json +1 -1
- /package/dist/packem_shared/{toQueuedPayload-BEKOdaxU.mjs → consumeQueuedSend-BEKOdaxU.mjs} +0 -0
package/dist/inbound/index.d.mts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { D as DurableObjectJurisdiction, S as ShardNamespaceLike } from "../packem_shared/shard.d-CL2Lmliv.mjs";
|
|
2
|
+
export type { a as ShardStubLike } from "../packem_shared/shard.d-CL2Lmliv.mjs";
|
|
1
3
|
/** A raw RFC 822 message as accepted by the parser. */
|
|
2
4
|
type RawInboundEmail = ArrayBuffer | ReadableStream<Uint8Array> | string | Uint8Array;
|
|
3
5
|
/** One parsed attachment. `content` is preserved as the parser decoded it. */
|
|
@@ -68,28 +70,6 @@ interface InboundEmail {
|
|
|
68
70
|
*/
|
|
69
71
|
declare const parseInboundEmail: (raw: RawInboundEmail) => Promise<InboundEmail>;
|
|
70
72
|
/**
|
|
71
|
-
* Structural projections of the `SHARD` Durable Object namespace + one shard
|
|
72
|
-
* stub, shared by the inbound dispatcher. Mirrors the shapes the outbound dev
|
|
73
|
-
* capture sink uses (`packages/mail/src/from-env.ts`) so inbound dispatch routes
|
|
74
|
-
* a parsed message into a Lunora function over the exact same admin-RPC-over-shard
|
|
75
|
-
* path — without importing any Cloudflare types into `@lunora/mail`.
|
|
76
|
-
*/
|
|
77
|
-
/** Structural projection of one shard stub — only `fetch` returning something with `.json()`. */
|
|
78
|
-
interface ShardStubLike {
|
|
79
|
-
fetch: (input: string, init?: {
|
|
80
|
-
body?: string;
|
|
81
|
-
headers?: Record<string, string>;
|
|
82
|
-
method?: string;
|
|
83
|
-
}) => Promise<{
|
|
84
|
-
json: () => Promise<unknown>;
|
|
85
|
-
}>;
|
|
86
|
-
}
|
|
87
|
-
/** Structural projection of the `SHARD` Durable Object namespace. */
|
|
88
|
-
interface ShardNamespaceLike {
|
|
89
|
-
get: (id: unknown) => ShardStubLike;
|
|
90
|
-
idFromName: (name: string) => unknown;
|
|
91
|
-
}
|
|
92
|
-
/**
|
|
93
73
|
* Structural projection of Cloudflare's `ForwardableEmailMessage` (verified
|
|
94
74
|
* against `@cloudflare/workers-types`' `ForwardableEmailMessage`). Only the
|
|
95
75
|
* members the handler touches are modelled, so the host can pass the real
|
|
@@ -181,6 +161,12 @@ interface DispatchToLunoraFunctionOptions<TEnv = Record<string, unknown>> {
|
|
|
181
161
|
/** `functionPath` of the target mutation/action (e.g. `"inbound:onEmail"`). */
|
|
182
162
|
functionPath: string;
|
|
183
163
|
/**
|
|
164
|
+
* Pin inbound dispatch to a Cloudflare data-residency jurisdiction. Pass the
|
|
165
|
+
* same value as the worker's `jurisdiction` so inbound mail routes to the
|
|
166
|
+
* jurisdiction-pinned shard. Omit for the un-pinned global namespace.
|
|
167
|
+
*/
|
|
168
|
+
jurisdiction?: DurableObjectJurisdiction;
|
|
169
|
+
/**
|
|
184
170
|
* Map the parsed message into the function's args. Defaults to passing the
|
|
185
171
|
* whole {@link InboundEmail} with binary attachment `content` base64-encoded
|
|
186
172
|
* (see {@link toJsonSafeEmail}) so it survives the JSON-serialised RPC body.
|
|
@@ -204,4 +190,4 @@ interface DispatchToLunoraFunctionOptions<TEnv = Record<string, unknown>> {
|
|
|
204
190
|
* making any trust decision in the target function.
|
|
205
191
|
*/
|
|
206
192
|
declare const dispatchToLunoraFunction: <TEnv extends Record<string, unknown> = Record<string, unknown>>(options: DispatchToLunoraFunctionOptions<TEnv>) => InboundDispatch<TEnv>;
|
|
207
|
-
export { type DispatchToLunoraFunctionOptions, type ForwardableEmailMessageLike, type InboundAttachment, type InboundAuthentication, type InboundDispatch, type InboundDispatchContext, type InboundEmail, type InboundEmailHandler, type InboundEmailHandlerOptions, type InboundVerify, type RawInboundEmail, type RpcEnvelope, type ShardNamespaceLike,
|
|
193
|
+
export { type DispatchToLunoraFunctionOptions, type ForwardableEmailMessageLike, type InboundAttachment, type InboundAuthentication, type InboundDispatch, type InboundDispatchContext, type InboundEmail, type InboundEmailHandler, type InboundEmailHandlerOptions, type InboundVerify, type RawInboundEmail, type RpcEnvelope, type ShardNamespaceLike, createInboundEmailHandler, dispatchToLunoraFunction, parseInboundEmail };
|
package/dist/inbound/index.d.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { D as DurableObjectJurisdiction, S as ShardNamespaceLike } from "../packem_shared/shard.d-CL2Lmliv.js";
|
|
2
|
+
export type { a as ShardStubLike } from "../packem_shared/shard.d-CL2Lmliv.js";
|
|
1
3
|
/** A raw RFC 822 message as accepted by the parser. */
|
|
2
4
|
type RawInboundEmail = ArrayBuffer | ReadableStream<Uint8Array> | string | Uint8Array;
|
|
3
5
|
/** One parsed attachment. `content` is preserved as the parser decoded it. */
|
|
@@ -68,28 +70,6 @@ interface InboundEmail {
|
|
|
68
70
|
*/
|
|
69
71
|
declare const parseInboundEmail: (raw: RawInboundEmail) => Promise<InboundEmail>;
|
|
70
72
|
/**
|
|
71
|
-
* Structural projections of the `SHARD` Durable Object namespace + one shard
|
|
72
|
-
* stub, shared by the inbound dispatcher. Mirrors the shapes the outbound dev
|
|
73
|
-
* capture sink uses (`packages/mail/src/from-env.ts`) so inbound dispatch routes
|
|
74
|
-
* a parsed message into a Lunora function over the exact same admin-RPC-over-shard
|
|
75
|
-
* path — without importing any Cloudflare types into `@lunora/mail`.
|
|
76
|
-
*/
|
|
77
|
-
/** Structural projection of one shard stub — only `fetch` returning something with `.json()`. */
|
|
78
|
-
interface ShardStubLike {
|
|
79
|
-
fetch: (input: string, init?: {
|
|
80
|
-
body?: string;
|
|
81
|
-
headers?: Record<string, string>;
|
|
82
|
-
method?: string;
|
|
83
|
-
}) => Promise<{
|
|
84
|
-
json: () => Promise<unknown>;
|
|
85
|
-
}>;
|
|
86
|
-
}
|
|
87
|
-
/** Structural projection of the `SHARD` Durable Object namespace. */
|
|
88
|
-
interface ShardNamespaceLike {
|
|
89
|
-
get: (id: unknown) => ShardStubLike;
|
|
90
|
-
idFromName: (name: string) => unknown;
|
|
91
|
-
}
|
|
92
|
-
/**
|
|
93
73
|
* Structural projection of Cloudflare's `ForwardableEmailMessage` (verified
|
|
94
74
|
* against `@cloudflare/workers-types`' `ForwardableEmailMessage`). Only the
|
|
95
75
|
* members the handler touches are modelled, so the host can pass the real
|
|
@@ -181,6 +161,12 @@ interface DispatchToLunoraFunctionOptions<TEnv = Record<string, unknown>> {
|
|
|
181
161
|
/** `functionPath` of the target mutation/action (e.g. `"inbound:onEmail"`). */
|
|
182
162
|
functionPath: string;
|
|
183
163
|
/**
|
|
164
|
+
* Pin inbound dispatch to a Cloudflare data-residency jurisdiction. Pass the
|
|
165
|
+
* same value as the worker's `jurisdiction` so inbound mail routes to the
|
|
166
|
+
* jurisdiction-pinned shard. Omit for the un-pinned global namespace.
|
|
167
|
+
*/
|
|
168
|
+
jurisdiction?: DurableObjectJurisdiction;
|
|
169
|
+
/**
|
|
184
170
|
* Map the parsed message into the function's args. Defaults to passing the
|
|
185
171
|
* whole {@link InboundEmail} with binary attachment `content` base64-encoded
|
|
186
172
|
* (see {@link toJsonSafeEmail}) so it survives the JSON-serialised RPC body.
|
|
@@ -204,4 +190,4 @@ interface DispatchToLunoraFunctionOptions<TEnv = Record<string, unknown>> {
|
|
|
204
190
|
* making any trust decision in the target function.
|
|
205
191
|
*/
|
|
206
192
|
declare const dispatchToLunoraFunction: <TEnv extends Record<string, unknown> = Record<string, unknown>>(options: DispatchToLunoraFunctionOptions<TEnv>) => InboundDispatch<TEnv>;
|
|
207
|
-
export { type DispatchToLunoraFunctionOptions, type ForwardableEmailMessageLike, type InboundAttachment, type InboundAuthentication, type InboundDispatch, type InboundDispatchContext, type InboundEmail, type InboundEmailHandler, type InboundEmailHandlerOptions, type InboundVerify, type RawInboundEmail, type RpcEnvelope, type ShardNamespaceLike,
|
|
193
|
+
export { type DispatchToLunoraFunctionOptions, type ForwardableEmailMessageLike, type InboundAttachment, type InboundAuthentication, type InboundDispatch, type InboundDispatchContext, type InboundEmail, type InboundEmailHandler, type InboundEmailHandlerOptions, type InboundVerify, type RawInboundEmail, type RpcEnvelope, type ShardNamespaceLike, createInboundEmailHandler, dispatchToLunoraFunction, parseInboundEmail };
|
package/dist/inbound/index.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { createInboundEmailHandler, dispatchToLunoraFunction } from '../packem_shared/createInboundEmailHandler-
|
|
1
|
+
export { createInboundEmailHandler, dispatchToLunoraFunction } from '../packem_shared/createInboundEmailHandler-D0uCOrU-.mjs';
|
|
2
2
|
export { parseInboundEmail } from '../packem_shared/parseInboundEmail-Bw9u_1oc.mjs';
|
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { M as MailTransport, L as LunoraMailOptions, a as Mailer, b as MailboxSink, S as SendOptions } from "./packem_shared/capture-transport.d-ChnhdPO2.mjs";
|
|
2
2
|
export { type C as CapturedMail, type Q as QueueLike, type c as SendPayload, d as createCaptureTransport } from "./packem_shared/capture-transport.d-ChnhdPO2.mjs";
|
|
3
|
+
import { D as DurableObjectJurisdiction } from "./packem_shared/shard.d-CL2Lmliv.mjs";
|
|
3
4
|
import { ReactElement } from 'react';
|
|
4
5
|
/**
|
|
5
6
|
* Sends a raw RFC 822 message through a Worker's Email send binding. The Workers
|
|
@@ -40,6 +41,12 @@ type MailEnv = Record<string, unknown>;
|
|
|
40
41
|
interface FromEnvOptions {
|
|
41
42
|
/** RFC 822 send callback bound to the Worker's `send_email` binding (Cloudflare default transport). */
|
|
42
43
|
cloudflareSend?: CloudflareSend;
|
|
44
|
+
/**
|
|
45
|
+
* Pin the captured-mail inbox shard to a Cloudflare data-residency
|
|
46
|
+
* jurisdiction. Pass the same value as the worker's `jurisdiction` so the
|
|
47
|
+
* dev inbox co-resides with app data. Omit for the un-pinned global namespace.
|
|
48
|
+
*/
|
|
49
|
+
jurisdiction?: DurableObjectJurisdiction;
|
|
43
50
|
/** Shard the captured-mail inbox lives on; override if your worker sets a custom `defaultShardKey`. */
|
|
44
51
|
rootShard?: string;
|
|
45
52
|
}
|
|
@@ -58,7 +65,7 @@ declare const shouldCaptureMail: (env: MailEnv) => boolean;
|
|
|
58
65
|
* the `SHARD` binding or `LUNORA_ADMIN_TOKEN` it returns a sentinel id so a send
|
|
59
66
|
* never fails for lack of somewhere to record.
|
|
60
67
|
*/
|
|
61
|
-
declare const createCaptureSink: (env: MailEnv, rootShard?: string) => MailboxSink;
|
|
68
|
+
declare const createCaptureSink: (env: MailEnv, rootShard?: string, jurisdiction?: DurableObjectJurisdiction) => MailboxSink;
|
|
62
69
|
/**
|
|
63
70
|
* Build a {@link Mailer} from a Worker `env`. In a dev environment every send is
|
|
64
71
|
* captured into the studio's Mail inbox; otherwise it delivers via the supplied
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { M as MailTransport, L as LunoraMailOptions, a as Mailer, b as MailboxSink, S as SendOptions } from "./packem_shared/capture-transport.d-ChnhdPO2.js";
|
|
2
2
|
export { type C as CapturedMail, type Q as QueueLike, type c as SendPayload, d as createCaptureTransport } from "./packem_shared/capture-transport.d-ChnhdPO2.js";
|
|
3
|
+
import { D as DurableObjectJurisdiction } from "./packem_shared/shard.d-CL2Lmliv.js";
|
|
3
4
|
import { ReactElement } from 'react';
|
|
4
5
|
/**
|
|
5
6
|
* Sends a raw RFC 822 message through a Worker's Email send binding. The Workers
|
|
@@ -40,6 +41,12 @@ type MailEnv = Record<string, unknown>;
|
|
|
40
41
|
interface FromEnvOptions {
|
|
41
42
|
/** RFC 822 send callback bound to the Worker's `send_email` binding (Cloudflare default transport). */
|
|
42
43
|
cloudflareSend?: CloudflareSend;
|
|
44
|
+
/**
|
|
45
|
+
* Pin the captured-mail inbox shard to a Cloudflare data-residency
|
|
46
|
+
* jurisdiction. Pass the same value as the worker's `jurisdiction` so the
|
|
47
|
+
* dev inbox co-resides with app data. Omit for the un-pinned global namespace.
|
|
48
|
+
*/
|
|
49
|
+
jurisdiction?: DurableObjectJurisdiction;
|
|
43
50
|
/** Shard the captured-mail inbox lives on; override if your worker sets a custom `defaultShardKey`. */
|
|
44
51
|
rootShard?: string;
|
|
45
52
|
}
|
|
@@ -58,7 +65,7 @@ declare const shouldCaptureMail: (env: MailEnv) => boolean;
|
|
|
58
65
|
* the `SHARD` binding or `LUNORA_ADMIN_TOKEN` it returns a sentinel id so a send
|
|
59
66
|
* never fails for lack of somewhere to record.
|
|
60
67
|
*/
|
|
61
|
-
declare const createCaptureSink: (env: MailEnv, rootShard?: string) => MailboxSink;
|
|
68
|
+
declare const createCaptureSink: (env: MailEnv, rootShard?: string, jurisdiction?: DurableObjectJurisdiction) => MailboxSink;
|
|
62
69
|
/**
|
|
63
70
|
* Build a {@link Mailer} from a Worker `env`. In a dev environment every send is
|
|
64
71
|
* captured into the studio's Mail inbox; otherwise it delivers via the supplied
|
package/dist/index.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { createCaptureTransport } from './packem_shared/createCaptureTransport-Crz_8822.mjs';
|
|
2
2
|
export { createCloudflareTransport } from './packem_shared/createCloudflareTransport-yHOVEsZv.mjs';
|
|
3
|
-
export { default as createMailer } from './packem_shared/createMailer-
|
|
4
|
-
export { createCaptureSink, createMailerFromEnv, shouldCaptureMail } from './packem_shared/createCaptureSink-
|
|
5
|
-
export { consumeQueuedSend, toQueuedPayload } from './packem_shared/
|
|
3
|
+
export { default as createMailer } from './packem_shared/createMailer-oEKPAd4J.mjs';
|
|
4
|
+
export { createCaptureSink, createMailerFromEnv, shouldCaptureMail } from './packem_shared/createCaptureSink-DeihS4LH.mjs';
|
|
5
|
+
export { consumeQueuedSend, toQueuedPayload } from './packem_shared/consumeQueuedSend-BEKOdaxU.mjs';
|
|
6
6
|
export { default as renderEmail } from './packem_shared/renderEmail-hyS1bpVP.mjs';
|
|
7
7
|
export { default as createResendTransport } from './packem_shared/createResendTransport-oNIorpzv.mjs';
|
package/dist/packem_shared/{createCaptureSink-CNhqLMZ1.mjs → createCaptureSink-DeihS4LH.mjs}
RENAMED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { createCaptureTransport } from './createCaptureTransport-Crz_8822.mjs';
|
|
2
|
-
import createMailer from './createMailer-
|
|
2
|
+
import createMailer from './createMailer-oEKPAd4J.mjs';
|
|
3
|
+
import { a as applyJurisdiction } from './shard-CJ-TvmfT.mjs';
|
|
3
4
|
|
|
4
5
|
const RECORD_MAIL_OP = "__lunora_admin__:recordMail";
|
|
5
6
|
const DEFAULT_ROOT_SHARD = "__root__";
|
|
@@ -22,14 +23,15 @@ const shouldCaptureMail = (env) => {
|
|
|
22
23
|
return typeof value === "string" && DEV_ENVIRONMENT_PATTERN.test(value);
|
|
23
24
|
});
|
|
24
25
|
};
|
|
25
|
-
const createCaptureSink = (env, rootShard = DEFAULT_ROOT_SHARD) => {
|
|
26
|
+
const createCaptureSink = (env, rootShard = DEFAULT_ROOT_SHARD, jurisdiction) => {
|
|
26
27
|
return {
|
|
27
28
|
record: async (mail) => {
|
|
28
|
-
const
|
|
29
|
+
const binding = env["SHARD"];
|
|
29
30
|
const adminToken = typeof env["LUNORA_ADMIN_TOKEN"] === "string" ? env["LUNORA_ADMIN_TOKEN"] : void 0;
|
|
30
|
-
if (
|
|
31
|
+
if (binding === void 0 || adminToken === void 0) {
|
|
31
32
|
return { id: "uncaptured" };
|
|
32
33
|
}
|
|
34
|
+
const namespace = applyJurisdiction(binding, jurisdiction);
|
|
33
35
|
const stub = namespace.get(namespace.idFromName(rootShard));
|
|
34
36
|
const response = await stub.fetch("https://shard.internal/rpc", {
|
|
35
37
|
body: JSON.stringify({ args: mail, functionPath: RECORD_MAIL_OP }),
|
|
@@ -44,7 +46,7 @@ const createCaptureSink = (env, rootShard = DEFAULT_ROOT_SHARD) => {
|
|
|
44
46
|
const createMailerFromEnv = (env, options = {}) => {
|
|
45
47
|
const from = requireStringEnv(env, "MAIL_FROM");
|
|
46
48
|
if (shouldCaptureMail(env)) {
|
|
47
|
-
return createMailer({ from, transport: createCaptureTransport(createCaptureSink(env, options.rootShard)) });
|
|
49
|
+
return createMailer({ from, transport: createCaptureTransport(createCaptureSink(env, options.rootShard, options.jurisdiction)) });
|
|
48
50
|
}
|
|
49
51
|
if (options.cloudflareSend) {
|
|
50
52
|
return createMailer({ cloudflareSend: options.cloudflareSend, from });
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { a as applyJurisdiction } from './shard-CJ-TvmfT.mjs';
|
|
2
|
+
|
|
1
3
|
const GENERIC_REJECT_REASON = "message could not be processed";
|
|
2
4
|
const rejectOnError = (error, context) => {
|
|
3
5
|
console.error("@lunora/mail/inbound: dropping message —", error);
|
|
@@ -58,7 +60,8 @@ const dispatchToLunoraFunction = (options) => {
|
|
|
58
60
|
functionPath: options.functionPath,
|
|
59
61
|
shardKey
|
|
60
62
|
};
|
|
61
|
-
const
|
|
63
|
+
const namespace = applyJurisdiction(options.shard, options.jurisdiction);
|
|
64
|
+
const stub = namespace.get(namespace.idFromName(shardKey));
|
|
62
65
|
const response = await stub.fetch("https://shard.internal/rpc", {
|
|
63
66
|
body: JSON.stringify(envelope),
|
|
64
67
|
headers: { authorization: `Bearer ${adminToken}`, "content-type": "application/json" },
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { a as assertSafeHeaderValue, b as assertSafeAddresses } from './address-fkXxLKza.mjs';
|
|
2
2
|
import { isCaptureTransport } from './createCaptureTransport-Crz_8822.mjs';
|
|
3
3
|
import { createCloudflareTransport } from './createCloudflareTransport-yHOVEsZv.mjs';
|
|
4
|
-
import { toQueuedPayload } from './
|
|
4
|
+
import { toQueuedPayload } from './consumeQueuedSend-BEKOdaxU.mjs';
|
|
5
5
|
import renderEmail from './renderEmail-hyS1bpVP.mjs';
|
|
6
6
|
import createResendTransport from './createResendTransport-oNIorpzv.mjs';
|
|
7
7
|
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
const applyJurisdiction = (namespace, jurisdiction) => {
|
|
2
|
+
if (jurisdiction === void 0) {
|
|
3
|
+
return namespace;
|
|
4
|
+
}
|
|
5
|
+
if (typeof namespace.jurisdiction !== "function") {
|
|
6
|
+
throw new TypeError(
|
|
7
|
+
`@lunora/mail: Durable Object namespace does not support jurisdiction("${jurisdiction}") — update @cloudflare/workers-types or remove the jurisdiction option`
|
|
8
|
+
);
|
|
9
|
+
}
|
|
10
|
+
return namespace.jurisdiction(jurisdiction);
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export { applyJurisdiction as a };
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Structural projections of the `SHARD` Durable Object namespace + one shard
|
|
3
|
+
* stub, shared by the inbound dispatcher. Mirrors the shapes the outbound dev
|
|
4
|
+
* capture sink uses (`packages/mail/src/from-env.ts`) so inbound dispatch routes
|
|
5
|
+
* a parsed message into a Lunora function over the exact same admin-RPC-over-shard
|
|
6
|
+
* path — without importing any Cloudflare types into `@lunora/mail`.
|
|
7
|
+
*/
|
|
8
|
+
/** Structural projection of one shard stub — only `fetch` returning something with `.json()`. */
|
|
9
|
+
interface ShardStubLike {
|
|
10
|
+
fetch: (input: string, init?: {
|
|
11
|
+
body?: string;
|
|
12
|
+
headers?: Record<string, string>;
|
|
13
|
+
method?: string;
|
|
14
|
+
}) => Promise<{
|
|
15
|
+
json: () => Promise<unknown>;
|
|
16
|
+
}>;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Cloudflare Durable Object data-residency jurisdiction. Widening union —
|
|
20
|
+
* Cloudflare adds values over time.
|
|
21
|
+
* @see https://developers.cloudflare.com/durable-objects/reference/data-location/
|
|
22
|
+
*/
|
|
23
|
+
type DurableObjectJurisdiction = "eu" | "fedramp" | "us";
|
|
24
|
+
/** Structural projection of the `SHARD` Durable Object namespace. */
|
|
25
|
+
interface ShardNamespaceLike {
|
|
26
|
+
get: (id: unknown) => ShardStubLike;
|
|
27
|
+
idFromName: (name: string) => unknown;
|
|
28
|
+
/**
|
|
29
|
+
* Derive a jurisdiction-restricted subnamespace. Optional because older
|
|
30
|
+
* workers-types releases (and test doubles) may not expose it.
|
|
31
|
+
*/
|
|
32
|
+
jurisdiction?: (jurisdiction: DurableObjectJurisdiction) => ShardNamespaceLike;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Return a jurisdiction-restricted view of `namespace`, or `namespace`
|
|
36
|
+
* unchanged when no jurisdiction is configured. Fail-closed when the binding
|
|
37
|
+
* lacks `.jurisdiction()` so a residency constraint is never silently dropped.
|
|
38
|
+
*/
|
|
39
|
+
export { DurableObjectJurisdiction as D, ShardNamespaceLike as S, ShardStubLike as a };
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Structural projections of the `SHARD` Durable Object namespace + one shard
|
|
3
|
+
* stub, shared by the inbound dispatcher. Mirrors the shapes the outbound dev
|
|
4
|
+
* capture sink uses (`packages/mail/src/from-env.ts`) so inbound dispatch routes
|
|
5
|
+
* a parsed message into a Lunora function over the exact same admin-RPC-over-shard
|
|
6
|
+
* path — without importing any Cloudflare types into `@lunora/mail`.
|
|
7
|
+
*/
|
|
8
|
+
/** Structural projection of one shard stub — only `fetch` returning something with `.json()`. */
|
|
9
|
+
interface ShardStubLike {
|
|
10
|
+
fetch: (input: string, init?: {
|
|
11
|
+
body?: string;
|
|
12
|
+
headers?: Record<string, string>;
|
|
13
|
+
method?: string;
|
|
14
|
+
}) => Promise<{
|
|
15
|
+
json: () => Promise<unknown>;
|
|
16
|
+
}>;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Cloudflare Durable Object data-residency jurisdiction. Widening union —
|
|
20
|
+
* Cloudflare adds values over time.
|
|
21
|
+
* @see https://developers.cloudflare.com/durable-objects/reference/data-location/
|
|
22
|
+
*/
|
|
23
|
+
type DurableObjectJurisdiction = "eu" | "fedramp" | "us";
|
|
24
|
+
/** Structural projection of the `SHARD` Durable Object namespace. */
|
|
25
|
+
interface ShardNamespaceLike {
|
|
26
|
+
get: (id: unknown) => ShardStubLike;
|
|
27
|
+
idFromName: (name: string) => unknown;
|
|
28
|
+
/**
|
|
29
|
+
* Derive a jurisdiction-restricted subnamespace. Optional because older
|
|
30
|
+
* workers-types releases (and test doubles) may not expose it.
|
|
31
|
+
*/
|
|
32
|
+
jurisdiction?: (jurisdiction: DurableObjectJurisdiction) => ShardNamespaceLike;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Return a jurisdiction-restricted view of `namespace`, or `namespace`
|
|
36
|
+
* unchanged when no jurisdiction is configured. Fail-closed when the binding
|
|
37
|
+
* lacks `.jurisdiction()` so a residency constraint is never silently dropped.
|
|
38
|
+
*/
|
|
39
|
+
export { DurableObjectJurisdiction as D, ShardNamespaceLike as S, ShardStubLike as a };
|
package/package.json
CHANGED
|
File without changes
|