@every-app/sdk 0.1.14 → 0.3.0-rc.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.
- package/README.md +608 -2
- package/dist/cloudflare/index.d.ts +21 -1
- package/dist/cloudflare/index.d.ts.map +1 -1
- package/dist/cloudflare/index.js +21 -1
- package/dist/cloudflare/sentinel.d.ts +69 -0
- package/dist/cloudflare/sentinel.d.ts.map +1 -0
- package/dist/cloudflare/sentinel.js +50 -0
- package/dist/cloudflare/worker.d.ts +511 -0
- package/dist/cloudflare/worker.d.ts.map +1 -0
- package/dist/cloudflare/worker.js +738 -0
- package/dist/dev/index.d.ts +8 -0
- package/dist/dev/index.d.ts.map +1 -0
- package/dist/dev/index.js +7 -0
- package/dist/dev/keypair.d.ts +24 -0
- package/dist/dev/keypair.d.ts.map +1 -0
- package/dist/dev/keypair.js +60 -0
- package/dist/internal/aiProviders.d.ts +67 -0
- package/dist/internal/aiProviders.d.ts.map +1 -0
- package/dist/internal/aiProviders.js +220 -0
- package/dist/internal/appSettings.d.ts +237 -0
- package/dist/internal/appSettings.d.ts.map +1 -0
- package/dist/internal/appSettings.js +374 -0
- package/dist/internal/capabilities.d.ts +1344 -0
- package/dist/internal/capabilities.d.ts.map +1 -0
- package/dist/internal/capabilities.js +1521 -0
- package/dist/internal/devProviders.d.ts +49 -0
- package/dist/internal/devProviders.d.ts.map +1 -0
- package/dist/internal/devProviders.js +62 -0
- package/dist/internal/email.d.ts +280 -0
- package/dist/internal/email.d.ts.map +1 -0
- package/dist/internal/email.js +613 -0
- package/dist/internal/events.d.ts +182 -0
- package/dist/internal/events.d.ts.map +1 -0
- package/dist/internal/events.js +324 -0
- package/dist/internal/gatewaySettings.d.ts +82 -0
- package/dist/internal/gatewaySettings.d.ts.map +1 -0
- package/dist/internal/gatewaySettings.js +209 -0
- package/dist/internal/identity.d.ts +88 -0
- package/dist/internal/identity.d.ts.map +1 -0
- package/dist/internal/identity.js +231 -0
- package/dist/internal/index.d.ts +19 -0
- package/dist/internal/index.d.ts.map +1 -0
- package/dist/internal/index.js +18 -0
- package/dist/internal/members.d.ts +35 -0
- package/dist/internal/members.d.ts.map +1 -0
- package/dist/internal/members.js +7 -0
- package/dist/internal/oauthClient.d.ts +63 -0
- package/dist/internal/oauthClient.d.ts.map +1 -0
- package/dist/internal/oauthClient.js +194 -0
- package/dist/internal/oauthScopes.d.ts +117 -0
- package/dist/internal/oauthScopes.d.ts.map +1 -0
- package/dist/internal/oauthScopes.js +416 -0
- package/dist/internal/organizationName.d.ts +18 -0
- package/dist/internal/organizationName.d.ts.map +1 -0
- package/dist/internal/organizationName.js +24 -0
- package/dist/internal/protocol.d.ts +195 -0
- package/dist/internal/protocol.d.ts.map +1 -0
- package/dist/internal/protocol.js +250 -0
- package/dist/internal/providerApps.d.ts +75 -0
- package/dist/internal/providerApps.d.ts.map +1 -0
- package/dist/internal/providerApps.js +59 -0
- package/dist/internal/providerRegistry.d.ts +147 -0
- package/dist/internal/providerRegistry.d.ts.map +1 -0
- package/dist/internal/providerRegistry.js +262 -0
- package/dist/internal/providerSpec.d.ts +55 -0
- package/dist/internal/providerSpec.d.ts.map +1 -0
- package/dist/internal/providerSpec.js +746 -0
- package/dist/internal/remoteMcp.d.ts +188 -0
- package/dist/internal/remoteMcp.d.ts.map +1 -0
- package/dist/internal/remoteMcp.js +543 -0
- package/dist/internal/tools.d.ts +115 -0
- package/dist/internal/tools.d.ts.map +1 -0
- package/dist/internal/tools.js +80 -0
- package/dist/server/attribution.d.ts +39 -0
- package/dist/server/attribution.d.ts.map +1 -0
- package/dist/server/attribution.js +67 -0
- package/dist/server/authorizeUrl.d.ts +43 -0
- package/dist/server/authorizeUrl.d.ts.map +1 -0
- package/dist/server/authorizeUrl.js +110 -0
- package/dist/server/emit.d.ts +63 -0
- package/dist/server/emit.d.ts.map +1 -0
- package/dist/server/emit.js +101 -0
- package/dist/server/everyApp.d.ts +81 -0
- package/dist/server/everyApp.d.ts.map +1 -0
- package/dist/server/everyApp.js +185 -0
- package/dist/server/gatewayFetch.d.ts +37 -0
- package/dist/server/gatewayFetch.d.ts.map +1 -0
- package/dist/server/gatewayFetch.js +115 -0
- package/dist/server/index.d.ts +18 -0
- package/dist/server/index.d.ts.map +1 -0
- package/dist/server/index.js +15 -0
- package/dist/server/integrationFetch.d.ts +131 -0
- package/dist/server/integrationFetch.d.ts.map +1 -0
- package/dist/server/integrationFetch.js +526 -0
- package/dist/server/listMembers.d.ts +32 -0
- package/dist/server/listMembers.d.ts.map +1 -0
- package/dist/server/listMembers.js +74 -0
- package/dist/server/nodeServer.d.ts +48 -0
- package/dist/server/nodeServer.d.ts.map +1 -0
- package/dist/server/nodeServer.js +45 -0
- package/dist/server/sendEmail.d.ts +39 -0
- package/dist/server/sendEmail.d.ts.map +1 -0
- package/dist/server/sendEmail.js +114 -0
- package/dist/server/tools.d.ts +184 -0
- package/dist/server/tools.d.ts.map +1 -0
- package/dist/server/tools.js +347 -0
- package/dist/server/toolsEndpoint.d.ts +32 -0
- package/dist/server/toolsEndpoint.d.ts.map +1 -0
- package/dist/server/toolsEndpoint.js +231 -0
- package/package.json +21 -31
- package/dist/cloudflare/getLocalD1Url.d.ts +0 -2
- package/dist/cloudflare/getLocalD1Url.d.ts.map +0 -1
- package/dist/cloudflare/getLocalD1Url.js +0 -40
- package/dist/cloudflare/lazyInit.d.ts +0 -22
- package/dist/cloudflare/lazyInit.d.ts.map +0 -1
- package/dist/cloudflare/lazyInit.js +0 -65
- package/dist/cloudflare/server/gateway.d.ts +0 -29
- package/dist/cloudflare/server/gateway.d.ts.map +0 -1
- package/dist/cloudflare/server/gateway.js +0 -69
- package/dist/cloudflare/server/index.d.ts +0 -3
- package/dist/cloudflare/server/index.d.ts.map +0 -1
- package/dist/cloudflare/server/index.js +0 -2
- package/dist/core/authenticatedFetch.d.ts +0 -9
- package/dist/core/authenticatedFetch.d.ts.map +0 -1
- package/dist/core/authenticatedFetch.js +0 -31
- package/dist/core/index.d.ts +0 -4
- package/dist/core/index.d.ts.map +0 -1
- package/dist/core/index.js +0 -2
- package/dist/core/sessionManager.d.ts +0 -58
- package/dist/core/sessionManager.d.ts.map +0 -1
- package/dist/core/sessionManager.js +0 -357
- package/dist/shared/bypassGatewayLocalOnly.d.ts +0 -15
- package/dist/shared/bypassGatewayLocalOnly.d.ts.map +0 -1
- package/dist/shared/bypassGatewayLocalOnly.js +0 -45
- package/dist/shared/parseMessagePayload.d.ts +0 -3
- package/dist/shared/parseMessagePayload.d.ts.map +0 -1
- package/dist/shared/parseMessagePayload.js +0 -18
- package/dist/tanstack/EmbeddedAppProvider.d.ts +0 -30
- package/dist/tanstack/EmbeddedAppProvider.d.ts.map +0 -1
- package/dist/tanstack/EmbeddedAppProvider.js +0 -57
- package/dist/tanstack/GatewayRequiredError.d.ts +0 -20
- package/dist/tanstack/GatewayRequiredError.d.ts.map +0 -1
- package/dist/tanstack/GatewayRequiredError.js +0 -91
- package/dist/tanstack/_internal/useEveryAppSession.d.ts +0 -18
- package/dist/tanstack/_internal/useEveryAppSession.d.ts.map +0 -1
- package/dist/tanstack/_internal/useEveryAppSession.js +0 -47
- package/dist/tanstack/index.d.ts +0 -4
- package/dist/tanstack/index.d.ts.map +0 -1
- package/dist/tanstack/index.js +0 -3
- package/dist/tanstack/server/authConfig.d.ts +0 -3
- package/dist/tanstack/server/authConfig.d.ts.map +0 -1
- package/dist/tanstack/server/authConfig.js +0 -13
- package/dist/tanstack/server/authenticateRequest.d.ts +0 -31
- package/dist/tanstack/server/authenticateRequest.d.ts.map +0 -1
- package/dist/tanstack/server/authenticateRequest.js +0 -154
- package/dist/tanstack/server/index.d.ts +0 -4
- package/dist/tanstack/server/index.d.ts.map +0 -1
- package/dist/tanstack/server/index.js +0 -2
- package/dist/tanstack/server/types.d.ts +0 -5
- package/dist/tanstack/server/types.d.ts.map +0 -1
- package/dist/tanstack/server/types.js +0 -1
- package/dist/tanstack/useEveryAppRouter.d.ts +0 -7
- package/dist/tanstack/useEveryAppRouter.d.ts.map +0 -1
- package/dist/tanstack/useEveryAppRouter.js +0 -66
- package/dist/tanstack/useSessionTokenClientMiddleware.d.ts +0 -2
- package/dist/tanstack/useSessionTokenClientMiddleware.d.ts.map +0 -1
- package/dist/tanstack/useSessionTokenClientMiddleware.js +0 -29
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A provider registered on a gateway, in local development
|
|
3
|
+
* (docs/design/2026-10-provider-registry.md, section 4). There is no
|
|
4
|
+
* gateway to ask in `everyapp dev`, so the spec comes from the app's
|
|
5
|
+
* directory: `everyapp provider add` (run in an app directory) and
|
|
6
|
+
* `everyapp provider show <id> --save` write it to
|
|
7
|
+
* `.everyapp/providers/<id>.json`, `everyAppWorker()` reads every such
|
|
8
|
+
* file when it builds the dev Worker and hands them over as one text
|
|
9
|
+
* binding, {@link DEV_PROVIDERS_ENV}, and `integrationFetch()`'s local
|
|
10
|
+
* fallback resolves an id outside the catalog from it, with the
|
|
11
|
+
* developer's own key from `.dev.vars` under the spec's setting names.
|
|
12
|
+
*
|
|
13
|
+
* The binding is JSON: `[{ "file": ".everyapp/providers/stripe.json",
|
|
14
|
+
* "spec": <the file's JSON, or its text when it isn't JSON> }]`. Each spec
|
|
15
|
+
* is parsed here, with the same parser `provider add` uses; one that
|
|
16
|
+
* doesn't parse is ignored until an app asks for its id, which then gets
|
|
17
|
+
* a ConfigurationError naming the file.
|
|
18
|
+
*/
|
|
19
|
+
import type { ApiKeyCapability } from "./capabilities.js";
|
|
20
|
+
/** The dev Worker's binding holding the specs (a copy is in ../cloudflare/worker.ts, kept in step by a test). */
|
|
21
|
+
export declare const DEV_PROVIDERS_ENV = "EVERYAPP_DEV_PROVIDERS";
|
|
22
|
+
/** Where the specs live in an app, relative to its directory. */
|
|
23
|
+
export declare const DEV_PROVIDERS_DIR = ".everyapp/providers";
|
|
24
|
+
/** One file as the binding carries it. */
|
|
25
|
+
export interface DevProviderFile {
|
|
26
|
+
/** Relative to the app: `.everyapp/providers/stripe.json`. */
|
|
27
|
+
file: string;
|
|
28
|
+
/** The file's JSON, or its text when it isn't JSON. */
|
|
29
|
+
spec: unknown;
|
|
30
|
+
}
|
|
31
|
+
/** The file `everyapp dev` reads a registered provider's spec from. */
|
|
32
|
+
export declare function devProviderFile(id: string): string;
|
|
33
|
+
/** A registered provider resolved for local development, or why it can't be. */
|
|
34
|
+
export type DevProviderLookup = {
|
|
35
|
+
found: true;
|
|
36
|
+
capability: ApiKeyCapability;
|
|
37
|
+
file: string;
|
|
38
|
+
} | {
|
|
39
|
+
found: false;
|
|
40
|
+
problem: string;
|
|
41
|
+
};
|
|
42
|
+
/**
|
|
43
|
+
* `id`'s spec from the dev Worker's {@link DEV_PROVIDERS_ENV}: a file whose
|
|
44
|
+
* spec says that id, or whose name is `<id>.json`. A file that matches but
|
|
45
|
+
* doesn't parse (or names another id) is the problem; no file is too,
|
|
46
|
+
* naming the command that writes one.
|
|
47
|
+
*/
|
|
48
|
+
export declare function resolveDevProvider(values: Readonly<Record<string, unknown>>, id: string): DevProviderLookup;
|
|
49
|
+
//# sourceMappingURL=devProviders.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"devProviders.d.ts","sourceRoot":"","sources":["../../src/internal/devProviders.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AACH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAG1D,iHAAiH;AACjH,eAAO,MAAM,iBAAiB,2BAA2B,CAAC;AAE1D,iEAAiE;AACjE,eAAO,MAAM,iBAAiB,wBAAwB,CAAC;AAEvD,0CAA0C;AAC1C,MAAM,WAAW,eAAe;IAC9B,8DAA8D;IAC9D,IAAI,EAAE,MAAM,CAAC;IACb,uDAAuD;IACvD,IAAI,EAAE,OAAO,CAAC;CACf;AAED,uEAAuE;AACvE,wBAAgB,eAAe,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM,CAElD;AAED,gFAAgF;AAChF,MAAM,MAAM,iBAAiB,GACzB;IAAE,KAAK,EAAE,IAAI,CAAC;IAAC,UAAU,EAAE,gBAAgB,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GAC3D;IAAE,KAAK,EAAE,KAAK,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAAC;AAuBtC;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAChC,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,EACzC,EAAE,EAAE,MAAM,GACT,iBAAiB,CA+BnB"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { describeSpecProblems, parseProviderSpec } from "./providerSpec.js";
|
|
2
|
+
/** The dev Worker's binding holding the specs (a copy is in ../cloudflare/worker.ts, kept in step by a test). */
|
|
3
|
+
export const DEV_PROVIDERS_ENV = "EVERYAPP_DEV_PROVIDERS";
|
|
4
|
+
/** Where the specs live in an app, relative to its directory. */
|
|
5
|
+
export const DEV_PROVIDERS_DIR = ".everyapp/providers";
|
|
6
|
+
/** The file `everyapp dev` reads a registered provider's spec from. */
|
|
7
|
+
export function devProviderFile(id) {
|
|
8
|
+
return `${DEV_PROVIDERS_DIR}/${id}.json`;
|
|
9
|
+
}
|
|
10
|
+
function isRecord(value) {
|
|
11
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
12
|
+
}
|
|
13
|
+
/** The files the binding carries; none when it is absent or not of its shape. */
|
|
14
|
+
function devProviderFiles(value) {
|
|
15
|
+
if (typeof value !== "string")
|
|
16
|
+
return [];
|
|
17
|
+
let parsed;
|
|
18
|
+
try {
|
|
19
|
+
parsed = JSON.parse(value);
|
|
20
|
+
}
|
|
21
|
+
catch {
|
|
22
|
+
return [];
|
|
23
|
+
}
|
|
24
|
+
if (!Array.isArray(parsed))
|
|
25
|
+
return [];
|
|
26
|
+
return parsed.flatMap((entry) => isRecord(entry) && typeof entry["file"] === "string"
|
|
27
|
+
? [{ file: entry["file"], spec: entry["spec"] }]
|
|
28
|
+
: []);
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* `id`'s spec from the dev Worker's {@link DEV_PROVIDERS_ENV}: a file whose
|
|
32
|
+
* spec says that id, or whose name is `<id>.json`. A file that matches but
|
|
33
|
+
* doesn't parse (or names another id) is the problem; no file is too,
|
|
34
|
+
* naming the command that writes one.
|
|
35
|
+
*/
|
|
36
|
+
export function resolveDevProvider(values, id) {
|
|
37
|
+
const files = devProviderFiles(values[DEV_PROVIDERS_ENV]);
|
|
38
|
+
const matching = files.filter((entry) => (isRecord(entry.spec) && entry.spec["id"] === id) ||
|
|
39
|
+
entry.file.split("/").at(-1) === `${id}.json`);
|
|
40
|
+
let problem = null;
|
|
41
|
+
for (const entry of matching) {
|
|
42
|
+
const parsed = parseProviderSpec(typeof entry.spec === "string" ? null : entry.spec);
|
|
43
|
+
if (!parsed.ok) {
|
|
44
|
+
problem ??=
|
|
45
|
+
typeof entry.spec === "string"
|
|
46
|
+
? `${entry.file} isn't JSON`
|
|
47
|
+
: `${entry.file} isn't a provider spec: ${describeSpecProblems(parsed.problems)}`;
|
|
48
|
+
continue;
|
|
49
|
+
}
|
|
50
|
+
if (parsed.id !== id) {
|
|
51
|
+
problem ??= `${entry.file} is ${parsed.id}'s spec, not ${id}'s`;
|
|
52
|
+
continue;
|
|
53
|
+
}
|
|
54
|
+
return { found: true, capability: parsed.capability, file: entry.file };
|
|
55
|
+
}
|
|
56
|
+
return {
|
|
57
|
+
found: false,
|
|
58
|
+
problem: problem
|
|
59
|
+
? `${problem}. Write it again with everyapp provider show ${id} --save in the app's directory, then start everyapp dev again.`
|
|
60
|
+
: `"${id}" isn't in the built-in provider catalog, and no ${devProviderFile(id)} describes it. A provider registered on the gateway (everyapp provider add) is reached through the EVERY_APP_GATEWAY binding; for everyapp dev, run everyapp provider show ${id} --save in the app's directory, then start everyapp dev again.`,
|
|
61
|
+
};
|
|
62
|
+
}
|
|
@@ -0,0 +1,280 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The `email` capability's wire contract (docs/capabilities.md "Gateway
|
|
3
|
+
* services"): what an app sends to `POST /api/integrations/email/send`,
|
|
4
|
+
* how the request is checked, which senders and inbound addresses an
|
|
5
|
+
* installation may hold (`everyapp email set`), which provider a gateway
|
|
6
|
+
* sends with (Cloudflare Email Sending or Resend), and how the provider's
|
|
7
|
+
* answers map onto the gateway's refusals.
|
|
8
|
+
*
|
|
9
|
+
* The gateway enforces these, the CLI's `email set` checks the lists with
|
|
10
|
+
* the same validator, and the SDK's local-dev fallback applies the same
|
|
11
|
+
* checks and the same REST body, so a refusal in `everyapp dev` is the one
|
|
12
|
+
* production gives. Pure functions only: no env, no I/O.
|
|
13
|
+
*/
|
|
14
|
+
/** An address with an optional display name. */
|
|
15
|
+
export interface EmailAddressInput {
|
|
16
|
+
address: string;
|
|
17
|
+
name?: string;
|
|
18
|
+
}
|
|
19
|
+
/** A file attached to the message, its bytes base64-encoded. */
|
|
20
|
+
export interface EmailAttachmentInput {
|
|
21
|
+
filename: string;
|
|
22
|
+
/** The MIME type, e.g. `application/pdf`. */
|
|
23
|
+
contentType: string;
|
|
24
|
+
/** The file's bytes, base64. */
|
|
25
|
+
content: string;
|
|
26
|
+
/** `inline` embeds it in the HTML body, referenced as `cid:<contentId>`. */
|
|
27
|
+
disposition?: "attachment" | "inline";
|
|
28
|
+
/** Required for an inline attachment. */
|
|
29
|
+
contentId?: string;
|
|
30
|
+
}
|
|
31
|
+
/** What an app asks the gateway to send. */
|
|
32
|
+
export interface SendEmailMessage {
|
|
33
|
+
/** At least one; with `cc` and `bcc`, at most 50 recipients. */
|
|
34
|
+
to: string | string[];
|
|
35
|
+
cc?: string | string[];
|
|
36
|
+
bcc?: string | string[];
|
|
37
|
+
/** At most 998 characters, on one line. */
|
|
38
|
+
subject: string;
|
|
39
|
+
/** At least one of `text` and `html`. */
|
|
40
|
+
text?: string;
|
|
41
|
+
html?: string;
|
|
42
|
+
/**
|
|
43
|
+
* Absent: the gateway's own sender (EMAIL_FROM). Present: it must match
|
|
44
|
+
* one of the installation's senders (`everyapp email set --sender`).
|
|
45
|
+
*/
|
|
46
|
+
from?: string | EmailAddressInput;
|
|
47
|
+
replyTo?: string | EmailAddressInput;
|
|
48
|
+
/** e.g. `In-Reply-To`, `References`, `X-…`: at most 20, values on one line. */
|
|
49
|
+
headers?: Record<string, string>;
|
|
50
|
+
attachments?: EmailAttachmentInput[];
|
|
51
|
+
}
|
|
52
|
+
/** An attachment that passed {@link parseSendEmailMessage}. */
|
|
53
|
+
export interface CheckedEmailAttachment {
|
|
54
|
+
filename: string;
|
|
55
|
+
contentType: string;
|
|
56
|
+
content: string;
|
|
57
|
+
disposition: "attachment" | "inline";
|
|
58
|
+
contentId?: string;
|
|
59
|
+
}
|
|
60
|
+
/** A message that passed {@link parseSendEmailMessage}: lists, trimmed. */
|
|
61
|
+
export interface CheckedEmailMessage {
|
|
62
|
+
to: string[];
|
|
63
|
+
cc: string[];
|
|
64
|
+
bcc: string[];
|
|
65
|
+
subject: string;
|
|
66
|
+
text?: string;
|
|
67
|
+
html?: string;
|
|
68
|
+
from?: EmailAddressInput;
|
|
69
|
+
replyTo?: EmailAddressInput;
|
|
70
|
+
headers?: Record<string, string>;
|
|
71
|
+
attachments?: CheckedEmailAttachment[];
|
|
72
|
+
}
|
|
73
|
+
/** What a send answers. `logged`: local dev only, nothing was sent. */
|
|
74
|
+
export interface SendEmailResult {
|
|
75
|
+
messageId?: string;
|
|
76
|
+
status: "delivered" | "queued" | "logged";
|
|
77
|
+
}
|
|
78
|
+
/** `GET /api/integrations/email`: whether the app can send, and as whom. */
|
|
79
|
+
export interface EmailCapabilityStatus {
|
|
80
|
+
capability: "email";
|
|
81
|
+
/** The app's manifest lists `email`. */
|
|
82
|
+
requested: boolean;
|
|
83
|
+
/** The gateway has a sender and a transport. */
|
|
84
|
+
configured: boolean;
|
|
85
|
+
/** Sends would go through. */
|
|
86
|
+
ready: boolean;
|
|
87
|
+
/** The From a message without `from` gets; null unless ready. */
|
|
88
|
+
sender: {
|
|
89
|
+
address: string;
|
|
90
|
+
name: string;
|
|
91
|
+
} | null;
|
|
92
|
+
/**
|
|
93
|
+
* The `from` patterns the gateway accepts from this app: its
|
|
94
|
+
* installation's; empty for none, and on a hosted gateway.
|
|
95
|
+
*/
|
|
96
|
+
senders: string[];
|
|
97
|
+
/**
|
|
98
|
+
* The provider mail goes out with; null unless configured. In local dev,
|
|
99
|
+
* the one the gateway would pick from `.dev.vars` (only Cloudflare's REST
|
|
100
|
+
* API really sends from dev; otherwise sends are printed).
|
|
101
|
+
*/
|
|
102
|
+
provider: EmailProviderId | null;
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* The providers a gateway sends mail with, in the order it prefers them
|
|
106
|
+
* (docs/runbooks/email-sending-setup.md, "Choosing a provider"). One serves
|
|
107
|
+
* the whole gateway: its own mail and every app's.
|
|
108
|
+
*/
|
|
109
|
+
export declare const EMAIL_PROVIDER_IDS: readonly ["cloudflare", "resend"];
|
|
110
|
+
export type EmailProviderId = (typeof EMAIL_PROVIDER_IDS)[number];
|
|
111
|
+
/** Each provider's name, as messages give it. */
|
|
112
|
+
export declare const EMAIL_PROVIDER_LABELS: Readonly<Record<EmailProviderId, string>>;
|
|
113
|
+
/**
|
|
114
|
+
* How far a provider is set up: by settings the operator gave it (Email
|
|
115
|
+
* Sending's REST pair, RESEND_API_KEY), only by a binding every gateway
|
|
116
|
+
* Worker declares (Cloudflare's EMAIL), or not at all.
|
|
117
|
+
*/
|
|
118
|
+
export type EmailProviderSetup = "settings" | "binding" | null;
|
|
119
|
+
/** The provider {@link chooseEmailProvider} picked, or why there is none. */
|
|
120
|
+
export type EmailProviderChoice = {
|
|
121
|
+
ok: true;
|
|
122
|
+
provider: EmailProviderId;
|
|
123
|
+
} | {
|
|
124
|
+
ok: false;
|
|
125
|
+
error: "unknown_provider";
|
|
126
|
+
requested: string;
|
|
127
|
+
} | {
|
|
128
|
+
ok: false;
|
|
129
|
+
error: "not_configured";
|
|
130
|
+
requested: EmailProviderId | null;
|
|
131
|
+
};
|
|
132
|
+
/**
|
|
133
|
+
* Which provider sends. EMAIL_PROVIDER (trimmed, any case), when set, names
|
|
134
|
+
* it, and it must be set up. Without it: the first provider, in
|
|
135
|
+
* {@link EMAIL_PROVIDER_IDS} order, the operator gave settings to, else one
|
|
136
|
+
* a binding alone sets up. The EMAIL binding is declared on every gateway
|
|
137
|
+
* Worker, so it can't be what makes Cloudflare win over a RESEND_API_KEY
|
|
138
|
+
* the operator set.
|
|
139
|
+
*/
|
|
140
|
+
export declare function chooseEmailProvider(emailProvider: unknown, setup: (provider: EmailProviderId) => EmailProviderSetup): EmailProviderChoice;
|
|
141
|
+
/** Cloudflare Email Sending's limits the gateway checks before sending, and the lists an installation keeps on the gateway. */
|
|
142
|
+
export declare const EMAIL_LIMITS: {
|
|
143
|
+
/** The request body, read with a counting stream. */
|
|
144
|
+
readonly bodyBytes: number;
|
|
145
|
+
readonly recipients: 50;
|
|
146
|
+
readonly subjectChars: 998;
|
|
147
|
+
readonly headers: 20;
|
|
148
|
+
readonly headerValueBytes: 2048;
|
|
149
|
+
readonly headerNameBytes: 100;
|
|
150
|
+
readonly headersTotalBytes: number;
|
|
151
|
+
readonly attachments: 32;
|
|
152
|
+
/** Sender patterns an installation may hold (`everyapp email set --sender`). */
|
|
153
|
+
readonly senders: 20;
|
|
154
|
+
/** Inbound addresses an installation may hold (Email Routing allows 200 rules a domain). */
|
|
155
|
+
readonly inbound: 50;
|
|
156
|
+
/** Email Routing's limit on a rule's address (its matcher's value). */
|
|
157
|
+
readonly inboundAddressChars: 90;
|
|
158
|
+
};
|
|
159
|
+
/**
|
|
160
|
+
* A sender: `*@<domain>` (any address on exactly that domain) or
|
|
161
|
+
* `<local>@<domain>`, in lowercase. Set per installed app with
|
|
162
|
+
* `everyapp email set --sender`; the gateway reads them from its registry.
|
|
163
|
+
*/
|
|
164
|
+
export declare const EMAIL_SENDER_PATTERN: RegExp;
|
|
165
|
+
/**
|
|
166
|
+
* An inbound address Email Routing delivers to the app's Worker: `*@<domain>`,
|
|
167
|
+
* the catch-all of a zone's apex, or one address, in lowercase. The CLI finds
|
|
168
|
+
* the zone; a catch-all on a subdomain is refused there.
|
|
169
|
+
*/
|
|
170
|
+
export declare const EMAIL_INBOUND_PATTERN: RegExp;
|
|
171
|
+
/** The command that sets an installation's senders and inbound addresses, for messages. */
|
|
172
|
+
export declare const EMAIL_SET_COMMAND = "everyapp email set";
|
|
173
|
+
/** An installed app's email configuration, as the gateway's `apps` row holds it (`[]` for a null column). */
|
|
174
|
+
export interface AppEmailConfig {
|
|
175
|
+
/** The `from` patterns the gateway accepts from the app; empty: the gateway's sender only. */
|
|
176
|
+
senders: string[];
|
|
177
|
+
/** The addresses Email Routing delivers to the app's Worker; empty: none. */
|
|
178
|
+
inbound: string[];
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* Why `values` can't be an installation's senders or inbound addresses
|
|
182
|
+
* (`everyapp email set`), one sentence each; empty when they can. The
|
|
183
|
+
* rules the manifest's `capabilities.email.senders` and `email.inbound`
|
|
184
|
+
* had: the patterns above, no duplicates, at most EMAIL_LIMITS.senders or
|
|
185
|
+
* EMAIL_LIMITS.inbound entries, an inbound address at most
|
|
186
|
+
* EMAIL_LIMITS.inboundAddressChars long.
|
|
187
|
+
*/
|
|
188
|
+
export declare function emailListProblems(kind: "senders" | "inbound", values: readonly string[]): string[];
|
|
189
|
+
/** A list as the row stores it: JSON, or null for none. */
|
|
190
|
+
export declare function storedEmailList(values: readonly string[]): string | null;
|
|
191
|
+
/**
|
|
192
|
+
* The 403 `email_sender_not_allowed` sentence. `where` says what sets the
|
|
193
|
+
* senders: the gateway's registry row, or `.dev.vars` in local dev.
|
|
194
|
+
*/
|
|
195
|
+
export declare function emailSenderRefusal(address: string, where: "gateway" | "dev"): string;
|
|
196
|
+
export type ParsedEmailMessage = {
|
|
197
|
+
ok: true;
|
|
198
|
+
message: CheckedEmailMessage;
|
|
199
|
+
} | {
|
|
200
|
+
ok: false;
|
|
201
|
+
problem: string;
|
|
202
|
+
};
|
|
203
|
+
/**
|
|
204
|
+
* Check a send request's JSON body against what Email Sending takes, so an
|
|
205
|
+
* app hears "bcc has 51 recipients" from the gateway rather than a bare
|
|
206
|
+
* provider error. Unknown fields are refused (a `reply_to` typo would
|
|
207
|
+
* otherwise vanish).
|
|
208
|
+
*/
|
|
209
|
+
export declare function parseSendEmailMessage(input: unknown): ParsedEmailMessage;
|
|
210
|
+
/**
|
|
211
|
+
* Whether `address` may be a message's From under `patterns` (the
|
|
212
|
+
* installation's senders, `apps.email_senders`): `*@example.com` takes any
|
|
213
|
+
* address on exactly example.com (not its subdomains), anything else that
|
|
214
|
+
* address alone. Case never matters.
|
|
215
|
+
*/
|
|
216
|
+
export declare function senderAllowed(address: string, patterns: readonly string[]): boolean;
|
|
217
|
+
/** The domain of an address, lowercased. */
|
|
218
|
+
export declare function emailDomain(address: string): string;
|
|
219
|
+
/** The distinct recipients of a message, lowercased: what budgets count. */
|
|
220
|
+
export declare function distinctRecipients(message: Pick<CheckedEmailMessage, "to" | "cc" | "bcc">): string[];
|
|
221
|
+
/** A gateway refusal: status, `x-everyapp-error` code, message. */
|
|
222
|
+
export interface EmailRefusal {
|
|
223
|
+
status: number;
|
|
224
|
+
code: string;
|
|
225
|
+
message: string;
|
|
226
|
+
}
|
|
227
|
+
/**
|
|
228
|
+
* The refusal for an error the provider answered with, by its code:
|
|
229
|
+
* Cloudflare's binding `E_*` or REST numeric one, or the `E_*` code the
|
|
230
|
+
* gateway's Resend provider maps Resend's errors onto. `senderDomain` is
|
|
231
|
+
* the From's domain, for the step that verifies it with `provider`.
|
|
232
|
+
*/
|
|
233
|
+
export declare function emailProviderRefusal(providerCode: string | undefined, senderDomain: string, provider?: EmailProviderId): EmailRefusal;
|
|
234
|
+
/** The URL of Email Sending's REST `send` for an account. */
|
|
235
|
+
export declare function emailRestUrl(accountId: string): string;
|
|
236
|
+
/** A message as Email Sending's REST `send` takes it (snake_case fields). */
|
|
237
|
+
export declare function emailRestBody(message: Omit<CheckedEmailMessage, "from"> & {
|
|
238
|
+
from: EmailAddressInput;
|
|
239
|
+
}): Record<string, unknown>;
|
|
240
|
+
/**
|
|
241
|
+
* Read Email Sending's REST answer: the message id and whether delivery is
|
|
242
|
+
* queued, or the provider's error code. A message whose every recipient
|
|
243
|
+
* bounced permanently failed; one that reached some of them did not.
|
|
244
|
+
*/
|
|
245
|
+
export declare function readEmailRestResponse(httpStatus: number, body: unknown): {
|
|
246
|
+
ok: true;
|
|
247
|
+
messageId?: string;
|
|
248
|
+
status: "delivered" | "queued";
|
|
249
|
+
} | {
|
|
250
|
+
ok: false;
|
|
251
|
+
providerCode?: string;
|
|
252
|
+
message: string;
|
|
253
|
+
};
|
|
254
|
+
/**
|
|
255
|
+
* The sender EMAIL_FROM and EMAIL_FROM_NAME configure: EMAIL_FROM is an
|
|
256
|
+
* address, or `Name <address>` with the name in it. Null unless both an
|
|
257
|
+
* address and a name are set.
|
|
258
|
+
*/
|
|
259
|
+
export declare function parseEmailSender(from: string | undefined, name: string | undefined): {
|
|
260
|
+
address: string;
|
|
261
|
+
name: string;
|
|
262
|
+
} | null;
|
|
263
|
+
/**
|
|
264
|
+
* The binding an app's Workers get in local dev when `.dev.vars` sets it
|
|
265
|
+
* (`everyAppWorker()` declares it like the other dev keys): the senders a
|
|
266
|
+
* gateway would hold for this installation, a comma- or whitespace-
|
|
267
|
+
* separated list or a JSON array. Deployed, the gateway reads them from the
|
|
268
|
+
* app's registry row (`apps.email_senders`, `everyapp email set --sender`).
|
|
269
|
+
*/
|
|
270
|
+
export declare const EMAIL_SENDERS_ENV = "EVERYAPP_EMAIL_SENDERS";
|
|
271
|
+
/**
|
|
272
|
+
* A list of addresses or patterns: an `apps` row's `email_senders` or
|
|
273
|
+
* `email_inbound` (JSON), or {@link EMAIL_SENDERS_ENV} (JSON, or separated
|
|
274
|
+
* by commas or whitespace). None when unset, or when JSON that isn't an
|
|
275
|
+
* array; other text is read as a comma or whitespace list, so a word no
|
|
276
|
+
* address matches allows no sender. Only `everyapp email set` writes the
|
|
277
|
+
* columns, as JSON; the admin page reads them as JSON only.
|
|
278
|
+
*/
|
|
279
|
+
export declare function parseEmailList(value: unknown): string[];
|
|
280
|
+
//# sourceMappingURL=email.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"email.d.ts","sourceRoot":"","sources":["../../src/internal/email.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,gDAAgD;AAChD,MAAM,WAAW,iBAAiB;IAChC,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,gEAAgE;AAChE,MAAM,WAAW,oBAAoB;IACnC,QAAQ,EAAE,MAAM,CAAC;IACjB,6CAA6C;IAC7C,WAAW,EAAE,MAAM,CAAC;IACpB,gCAAgC;IAChC,OAAO,EAAE,MAAM,CAAC;IAChB,4EAA4E;IAC5E,WAAW,CAAC,EAAE,YAAY,GAAG,QAAQ,CAAC;IACtC,yCAAyC;IACzC,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,4CAA4C;AAC5C,MAAM,WAAW,gBAAgB;IAC/B,gEAAgE;IAChE,EAAE,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IACtB,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IACvB,GAAG,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IACxB,2CAA2C;IAC3C,OAAO,EAAE,MAAM,CAAC;IAChB,yCAAyC;IACzC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd;;;OAGG;IACH,IAAI,CAAC,EAAE,MAAM,GAAG,iBAAiB,CAAC;IAClC,OAAO,CAAC,EAAE,MAAM,GAAG,iBAAiB,CAAC;IACrC,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