@every-app/sdk 0.2.0 → 0.3.0-rc.10
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 +609 -3
- package/dist/cloudflare/catalogSettings.generated.d.ts +81 -0
- package/dist/cloudflare/catalogSettings.generated.d.ts.map +1 -0
- package/dist/cloudflare/catalogSettings.generated.js +174 -0
- package/dist/cloudflare/index.d.ts +23 -0
- package/dist/cloudflare/index.d.ts.map +1 -0
- package/dist/cloudflare/index.js +24 -0
- package/dist/cloudflare/sentinel.d.ts +127 -0
- package/dist/cloudflare/sentinel.d.ts.map +1 -0
- package/dist/cloudflare/sentinel.js +85 -0
- package/dist/cloudflare/worker.d.ts +805 -0
- package/dist/cloudflare/worker.d.ts.map +1 -0
- package/dist/cloudflare/worker.js +997 -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 +26 -0
- package/dist/dev/keypair.d.ts.map +1 -0
- package/dist/dev/keypair.js +62 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +5 -0
- package/dist/internal/aiDefault.d.ts +204 -0
- package/dist/internal/aiDefault.d.ts.map +1 -0
- package/dist/internal/aiDefault.js +334 -0
- package/dist/internal/aiProviders.d.ts +72 -0
- package/dist/internal/aiProviders.d.ts.map +1 -0
- package/dist/internal/aiProviders.js +233 -0
- package/dist/internal/appSettings.d.ts +315 -0
- package/dist/internal/appSettings.d.ts.map +1 -0
- package/dist/internal/appSettings.js +549 -0
- package/dist/internal/audit.d.ts +108 -0
- package/dist/internal/audit.d.ts.map +1 -0
- package/dist/internal/audit.js +235 -0
- package/dist/internal/capabilities.d.ts +3174 -0
- package/dist/internal/capabilities.d.ts.map +1 -0
- package/dist/internal/capabilities.js +1110 -0
- package/dist/internal/catalog/commerce.d.ts +394 -0
- package/dist/internal/catalog/commerce.d.ts.map +1 -0
- package/dist/internal/catalog/commerce.js +477 -0
- package/dist/internal/catalog/comms.d.ts +375 -0
- package/dist/internal/catalog/comms.d.ts.map +1 -0
- package/dist/internal/catalog/comms.js +520 -0
- package/dist/internal/catalog/index.d.ts +1973 -0
- package/dist/internal/catalog/index.d.ts.map +1 -0
- package/dist/internal/catalog/index.js +19 -0
- package/dist/internal/catalog/inference.d.ts +393 -0
- package/dist/internal/catalog/inference.d.ts.map +1 -0
- package/dist/internal/catalog/inference.js +460 -0
- package/dist/internal/catalog/infra.d.ts +423 -0
- package/dist/internal/catalog/infra.d.ts.map +1 -0
- package/dist/internal/catalog/infra.js +543 -0
- package/dist/internal/catalog/search.d.ts +400 -0
- package/dist/internal/catalog/search.d.ts.map +1 -0
- package/dist/internal/catalog/search.js +463 -0
- package/dist/internal/devProviders.d.ts +49 -0
- package/dist/internal/devProviders.d.ts.map +1 -0
- package/dist/internal/devProviders.js +80 -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 +193 -0
- package/dist/internal/events.d.ts.map +1 -0
- package/dist/internal/events.js +367 -0
- package/dist/internal/gatewaySettings.d.ts +83 -0
- package/dist/internal/gatewaySettings.d.ts.map +1 -0
- package/dist/internal/gatewaySettings.js +215 -0
- package/dist/internal/identity.d.ts +57 -5
- package/dist/internal/identity.d.ts.map +1 -1
- package/dist/internal/identity.js +99 -22
- package/dist/internal/index.d.ts +22 -1
- package/dist/internal/index.d.ts.map +1 -1
- package/dist/internal/index.js +22 -1
- package/dist/internal/members.d.ts +36 -0
- package/dist/internal/members.d.ts.map +1 -0
- package/dist/internal/members.js +7 -0
- package/dist/internal/oauthClient.d.ts +61 -0
- package/dist/internal/oauthClient.d.ts.map +1 -0
- package/dist/internal/oauthClient.js +133 -0
- package/dist/internal/oauthPresets.d.ts +33 -0
- package/dist/internal/oauthPresets.d.ts.map +1 -0
- package/dist/internal/oauthPresets.js +1064 -0
- package/dist/internal/oauthScopes.d.ts +172 -0
- package/dist/internal/oauthScopes.d.ts.map +1 -0
- package/dist/internal/oauthScopes.js +510 -0
- package/dist/internal/oauthSpec.d.ts +102 -0
- package/dist/internal/oauthSpec.d.ts.map +1 -0
- package/dist/internal/oauthSpec.js +789 -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 +150 -3
- package/dist/internal/protocol.d.ts.map +1 -1
- package/dist/internal/protocol.js +163 -2
- 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 +218 -0
- package/dist/internal/providerRegistry.d.ts.map +1 -0
- package/dist/internal/providerRegistry.js +432 -0
- package/dist/internal/providerSpec.d.ts +66 -0
- package/dist/internal/providerSpec.d.ts.map +1 -0
- package/dist/internal/providerSpec.js +1154 -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/signInProviders.d.ts +104 -0
- package/dist/internal/signInProviders.d.ts.map +1 -0
- package/dist/internal/signInProviders.js +245 -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/manifest.d.ts +238 -0
- package/dist/manifest.d.ts.map +1 -0
- package/dist/manifest.js +30 -0
- package/dist/server/ai.d.ts +111 -0
- package/dist/server/ai.d.ts.map +1 -0
- package/dist/server/ai.js +145 -0
- package/dist/server/aiBinding.d.ts +68 -0
- package/dist/server/aiBinding.d.ts.map +1 -0
- package/dist/server/aiBinding.js +294 -0
- package/dist/server/attribution.d.ts +43 -0
- package/dist/server/attribution.d.ts.map +1 -0
- package/dist/server/attribution.js +75 -0
- package/dist/server/authorizeUrl.d.ts +43 -0
- package/dist/server/authorizeUrl.d.ts.map +1 -0
- package/dist/server/authorizeUrl.js +106 -0
- package/dist/server/connectUrl.d.ts +21 -0
- package/dist/server/connectUrl.d.ts.map +1 -0
- package/dist/server/connectUrl.js +37 -0
- package/dist/server/context.d.ts +68 -0
- package/dist/server/context.d.ts.map +1 -0
- package/dist/server/context.js +117 -0
- package/dist/server/emailBinding.d.ts +72 -0
- package/dist/server/emailBinding.d.ts.map +1 -0
- package/dist/server/emailBinding.js +124 -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/env.d.ts +44 -0
- package/dist/server/env.d.ts.map +1 -0
- package/dist/server/env.js +1 -0
- package/dist/server/everyApp.d.ts +65 -19
- package/dist/server/everyApp.d.ts.map +1 -1
- package/dist/server/everyApp.js +195 -30
- package/dist/server/fromMcpTools.d.ts +89 -0
- package/dist/server/fromMcpTools.d.ts.map +1 -0
- package/dist/server/fromMcpTools.js +192 -0
- package/dist/server/gatewayFetch.d.ts +54 -14
- package/dist/server/gatewayFetch.d.ts.map +1 -1
- package/dist/server/gatewayFetch.js +201 -37
- package/dist/server/gatewayUrl.d.ts +13 -0
- package/dist/server/gatewayUrl.d.ts.map +1 -0
- package/dist/server/gatewayUrl.js +34 -0
- package/dist/server/index.d.ts +23 -3
- package/dist/server/index.d.ts.map +1 -1
- package/dist/server/index.js +19 -2
- package/dist/server/integrationFetch.d.ts +162 -0
- package/dist/server/integrationFetch.d.ts.map +1 -0
- package/dist/server/integrationFetch.js +688 -0
- package/dist/server/listMembers.d.ts +32 -0
- package/dist/server/listMembers.d.ts.map +1 -0
- package/dist/server/listMembers.js +71 -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/refusal.d.ts +55 -0
- package/dist/server/refusal.d.ts.map +1 -0
- package/dist/server/refusal.js +193 -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 +237 -0
- package/dist/tanstack-start/index.d.ts +9 -0
- package/dist/tanstack-start/index.d.ts.map +1 -0
- package/dist/tanstack-start/index.js +29 -0
- package/dist/testing/index.d.ts +93 -0
- package/dist/testing/index.d.ts.map +1 -0
- package/dist/testing/index.js +156 -0
- package/package.json +42 -8
- package/dist/server/mcp.d.ts +0 -66
- package/dist/server/mcp.d.ts.map +0 -1
- package/dist/server/mcp.js +0 -147
|
@@ -0,0 +1,805 @@
|
|
|
1
|
+
import { DEV_GATEWAY_KEYS } from "./catalogSettings.generated.js";
|
|
2
|
+
import { type AiGatewayValue } from "./sentinel.js";
|
|
3
|
+
export { helperWorkerName, workflowNameFor } from "./sentinel.js";
|
|
4
|
+
/** A Durable Object or Workflow class, and the helper Worker defining it. */
|
|
5
|
+
interface ClassResource {
|
|
6
|
+
readonly name: string;
|
|
7
|
+
readonly className: string;
|
|
8
|
+
/** A helper Worker (`workers`) that defines the class; the app's own when unset. */
|
|
9
|
+
readonly worker?: string;
|
|
10
|
+
}
|
|
11
|
+
/** A Hyperdrive config, and the helper Worker that alone binds it. */
|
|
12
|
+
interface HyperdriveResource {
|
|
13
|
+
readonly name: string;
|
|
14
|
+
/** A helper Worker (`workers`) that alone binds it; every Worker when unset. */
|
|
15
|
+
readonly worker?: string;
|
|
16
|
+
/** Whether Hyperdrive caches its reads (the deploy's concern; "off" by default). */
|
|
17
|
+
readonly caching?: "off" | "default";
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* How a queue's consumer takes its messages (`@cloudflare/config`'s
|
|
21
|
+
* `QueueConsumerTriggerOptions` but the name), and the helper Worker that
|
|
22
|
+
* consumes, when not the app's own.
|
|
23
|
+
*/
|
|
24
|
+
interface QueueConsumerSettings {
|
|
25
|
+
/** A helper Worker (`workers`) that consumes; the app's own when unset. */
|
|
26
|
+
readonly worker?: string;
|
|
27
|
+
readonly maxBatchSize?: number;
|
|
28
|
+
readonly maxBatchTimeout?: number;
|
|
29
|
+
readonly maxRetries?: number;
|
|
30
|
+
readonly maxConcurrency?: number | null;
|
|
31
|
+
readonly retryDelay?: number;
|
|
32
|
+
readonly visibilityTimeoutMs?: number;
|
|
33
|
+
/** Another of the manifest's queue bindings, which takes the messages that ran out of retries. */
|
|
34
|
+
readonly deadLetterQueue?: string;
|
|
35
|
+
}
|
|
36
|
+
/** A queue every Worker of the app produces to, and the Worker that consumes it. */
|
|
37
|
+
interface QueueResource {
|
|
38
|
+
readonly name: string;
|
|
39
|
+
/** `true`: the app's own Worker consumes; settings, maybe naming a helper Worker. */
|
|
40
|
+
readonly consumer?: true | QueueConsumerSettings;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* A Vectorize index: `dimensions` and `metric`, or a `preset` (the
|
|
44
|
+
* deploy's concern; the Worker only binds it by name).
|
|
45
|
+
*/
|
|
46
|
+
interface VectorizeResource {
|
|
47
|
+
readonly name: string;
|
|
48
|
+
readonly dimensions?: number;
|
|
49
|
+
readonly metric?: string;
|
|
50
|
+
readonly preset?: string;
|
|
51
|
+
}
|
|
52
|
+
/** An AI Gateway of the app's own, which every one of its Workers binds. */
|
|
53
|
+
interface AiGatewayResource {
|
|
54
|
+
readonly name: string;
|
|
55
|
+
/** Whether the gateway logs each request (the deploy's concern; on by default). */
|
|
56
|
+
readonly collectLogs?: boolean;
|
|
57
|
+
/** How long the gateway caches a response, in seconds (the deploy's concern; 0 by default). */
|
|
58
|
+
readonly cacheTtl?: number;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* A Cloudflare `send_email` binding and the addresses it may use: the
|
|
62
|
+
* senders, and one destination or a list of them (never both).
|
|
63
|
+
*/
|
|
64
|
+
interface SendEmailResource {
|
|
65
|
+
readonly name: string;
|
|
66
|
+
readonly allowedSenderAddresses?: readonly string[];
|
|
67
|
+
readonly destinationAddress?: string;
|
|
68
|
+
readonly allowedDestinationAddresses?: readonly string[];
|
|
69
|
+
}
|
|
70
|
+
/** An Analytics Engine dataset, by binding, and its name when not the default. */
|
|
71
|
+
interface AnalyticsEngineResource {
|
|
72
|
+
readonly name: string;
|
|
73
|
+
readonly dataset?: string;
|
|
74
|
+
}
|
|
75
|
+
/** Cloudflare's limits for one of the app's Workers. */
|
|
76
|
+
interface WorkerLimits {
|
|
77
|
+
readonly cpuMs?: number;
|
|
78
|
+
}
|
|
79
|
+
/** The fields of `everyapp.config.ts` the Worker definition is built from. */
|
|
80
|
+
export interface EveryAppWorkerManifest {
|
|
81
|
+
id: string;
|
|
82
|
+
compatibilityDate?: string;
|
|
83
|
+
resources?: {
|
|
84
|
+
d1?: readonly string[];
|
|
85
|
+
kv?: readonly string[];
|
|
86
|
+
/**
|
|
87
|
+
* R2 buckets every one of the app's Workers binds: `R2` named after the
|
|
88
|
+
* app's Worker, any other binding `<app worker>--<binding>`.
|
|
89
|
+
*/
|
|
90
|
+
r2?: readonly string[];
|
|
91
|
+
durableObjects?: readonly ClassResource[];
|
|
92
|
+
workflows?: readonly ClassResource[];
|
|
93
|
+
/** Hyperdrive configs, named `<app worker>--<binding>` by the deploy. */
|
|
94
|
+
hyperdrive?: readonly HyperdriveResource[];
|
|
95
|
+
/**
|
|
96
|
+
* Cloudflare Queues, named `<app worker>--<binding>`: every Worker of
|
|
97
|
+
* the app binds each one to produce, and the consumer's Worker gets
|
|
98
|
+
* its trigger.
|
|
99
|
+
*/
|
|
100
|
+
queues?: readonly QueueResource[];
|
|
101
|
+
/**
|
|
102
|
+
* Workers AI, by binding (`["AI"]`), which every one of the app's
|
|
103
|
+
* Workers binds: nothing to create, billed to the account. In
|
|
104
|
+
* development it reaches the account only once the app's Vite config
|
|
105
|
+
* turns `remoteBindings` on (see {@link AiBinding}).
|
|
106
|
+
*/
|
|
107
|
+
ai?: readonly string[];
|
|
108
|
+
/**
|
|
109
|
+
* Browser Rendering, by binding (`["BROWSER"]`), which every one of the
|
|
110
|
+
* app's Workers binds: nothing to create (Workers Paid). Local in
|
|
111
|
+
* development (see {@link BrowserBinding}).
|
|
112
|
+
*/
|
|
113
|
+
browser?: readonly string[];
|
|
114
|
+
/**
|
|
115
|
+
* Cloudflare Images, by binding (`["IMAGES"]`), which every one of the
|
|
116
|
+
* app's Workers binds: nothing to create. Local in development (see
|
|
117
|
+
* {@link ImagesBinding}).
|
|
118
|
+
*/
|
|
119
|
+
images?: readonly string[];
|
|
120
|
+
/**
|
|
121
|
+
* Vectorize indexes every one of the app's Workers binds, named
|
|
122
|
+
* `<app worker>--<binding>`. Cloudflare has no local Vectorize: in
|
|
123
|
+
* development each binding reaches the account's index (`dev.remote`),
|
|
124
|
+
* once the Vite plugin's `remoteBindings` is on and `cf auth login` ran.
|
|
125
|
+
*/
|
|
126
|
+
vectorize?: readonly VectorizeResource[];
|
|
127
|
+
/**
|
|
128
|
+
* AI Gateways of the app's own, each `<app worker>-<binding>` in the
|
|
129
|
+
* account, bound on every Worker as `{ id, accountId, url }`.
|
|
130
|
+
*/
|
|
131
|
+
aiGateway?: readonly AiGatewayResource[];
|
|
132
|
+
/**
|
|
133
|
+
* Cloudflare `send_email` bindings every one of the app's Workers
|
|
134
|
+
* gets, with their addresses; nothing is made in the account.
|
|
135
|
+
*/
|
|
136
|
+
sendEmail?: readonly SendEmailResource[];
|
|
137
|
+
/**
|
|
138
|
+
* Secrets Store secrets, by binding (`[{ name: "STRIPE_KEY" }]`), which
|
|
139
|
+
* every one of the app's Workers binds: each a secret in the account's
|
|
140
|
+
* store named `<app worker>--<binding>`, made by the deploy (see
|
|
141
|
+
* {@link SecretsStoreSecretBinding}).
|
|
142
|
+
*/
|
|
143
|
+
secretsStore?: readonly {
|
|
144
|
+
readonly name: string;
|
|
145
|
+
}[];
|
|
146
|
+
/**
|
|
147
|
+
* Analytics Engine datasets every one of the app's Workers writes to, by
|
|
148
|
+
* binding: `dataset` as written, else `<app worker>--<binding>`.
|
|
149
|
+
* Nothing to create; `writeDataPoint()` does nothing in development.
|
|
150
|
+
*/
|
|
151
|
+
analyticsEngine?: readonly AnalyticsEngineResource[];
|
|
152
|
+
};
|
|
153
|
+
/**
|
|
154
|
+
* Helper Workers deployed beside the app's Worker as
|
|
155
|
+
* `<app worker>--<name>`, built with {@link everyAppAuxiliaryWorker}.
|
|
156
|
+
* `binding` names the app Worker's service binding to one.
|
|
157
|
+
*/
|
|
158
|
+
workers?: readonly {
|
|
159
|
+
readonly name: string;
|
|
160
|
+
readonly binding?: string;
|
|
161
|
+
readonly limits?: WorkerLimits;
|
|
162
|
+
}[];
|
|
163
|
+
/**
|
|
164
|
+
* The database the app's code talks to, which its Workers read as
|
|
165
|
+
* DATABASE_PROVIDER; deployed Workers run near `region`.
|
|
166
|
+
*/
|
|
167
|
+
database?: {
|
|
168
|
+
readonly provider: "d1" | "postgres";
|
|
169
|
+
readonly region?: string;
|
|
170
|
+
};
|
|
171
|
+
/** Cloudflare's limits for the app's own Worker. */
|
|
172
|
+
limits?: WorkerLimits;
|
|
173
|
+
/**
|
|
174
|
+
* AI providers the app calls through the gateway (`createGatewayFetch()`):
|
|
175
|
+
* each by id, or as `{ id, optional, anyOf, why, docs }` (the manifest's
|
|
176
|
+
* settings model, `@every-app/sdk/internal` appSettings).
|
|
177
|
+
*/
|
|
178
|
+
providers?: ReadonlyArray<string | {
|
|
179
|
+
readonly id: string;
|
|
180
|
+
}>;
|
|
181
|
+
/** Capabilities the app calls through the gateway (`integrationFetch()`). */
|
|
182
|
+
capabilities?: {
|
|
183
|
+
readonly [id: string]: unknown;
|
|
184
|
+
};
|
|
185
|
+
/**
|
|
186
|
+
* The app's own secrets, e.g. an API key it calls out with. A deployed
|
|
187
|
+
* Worker gets them from `everyapp secret set <NAME>`, and later deploys
|
|
188
|
+
* keep them, so production builds don't declare them. In development each
|
|
189
|
+
* one that is set locally is declared, read as the Vite plugin reads
|
|
190
|
+
* secrets (`.dev.vars[.<mode>]` alone when present, otherwise the `.env`
|
|
191
|
+
* files and the environment), so the plugin passes it through. Type them
|
|
192
|
+
* as optional in `src/env.d.ts`.
|
|
193
|
+
*
|
|
194
|
+
* The keys of `providers` and `capabilities` need no listing: there's no
|
|
195
|
+
* gateway in development, so each one set locally under the gateway
|
|
196
|
+
* secret's name (OPENAI_API_KEY, DATAFORSEO_API_KEY, …) is declared for
|
|
197
|
+
* the SDK's direct fallback.
|
|
198
|
+
*
|
|
199
|
+
* Each by name, or as `{ name, optional, anyOf, why, docs }`: whether the
|
|
200
|
+
* app opens without it, and why it is needed.
|
|
201
|
+
*/
|
|
202
|
+
secrets?: ReadonlyArray<string | {
|
|
203
|
+
readonly name: string;
|
|
204
|
+
}>;
|
|
205
|
+
/**
|
|
206
|
+
* The app's plain settings: values that aren't secrets and differ per
|
|
207
|
+
* install (a PostHog host, a region), as `{ name, why, type, values,
|
|
208
|
+
* default, optional }`. A deployed Worker holds them like its secrets
|
|
209
|
+
* (`everyapp configure <app>` sets them; the deploy writes each
|
|
210
|
+
* default nobody has set), so production builds don't declare them. In
|
|
211
|
+
* development each one set locally (`.dev.vars`, `.env`, as for
|
|
212
|
+
* secrets) is declared as a secret, and one that isn't, but has a
|
|
213
|
+
* default, as text with its default.
|
|
214
|
+
*/
|
|
215
|
+
settings?: ReadonlyArray<{
|
|
216
|
+
readonly name: string;
|
|
217
|
+
readonly default?: string;
|
|
218
|
+
}>;
|
|
219
|
+
}
|
|
220
|
+
/** The context cf passes to a `defineConfig((ctx) => …)` factory. */
|
|
221
|
+
export interface EveryAppConfigContext {
|
|
222
|
+
mode: string | undefined;
|
|
223
|
+
isPreview?: boolean;
|
|
224
|
+
}
|
|
225
|
+
export interface EveryAppWorkerOptions<TManifest extends EveryAppWorkerManifest, TEntrypoint> {
|
|
226
|
+
/** The default export of `everyapp.config.ts`, declared `as const`. */
|
|
227
|
+
manifest: TManifest;
|
|
228
|
+
/** The Worker entry, usually a `cf-worker` namespace import of `src/entry.worker.ts`. */
|
|
229
|
+
entrypoint: TEntrypoint;
|
|
230
|
+
ctx: EveryAppConfigContext;
|
|
231
|
+
/** App root holding `.dev.vars` and `.env` files. Defaults to the working directory. */
|
|
232
|
+
root?: string;
|
|
233
|
+
/**
|
|
234
|
+
* Cron schedules (UTC) that run the Worker's `scheduled` handler, e.g.
|
|
235
|
+
* `"0 6 * * *"` (daily at 06:00). Deploys keep them; an app can't declare
|
|
236
|
+
* routes.
|
|
237
|
+
*/
|
|
238
|
+
crons?: readonly string[];
|
|
239
|
+
/**
|
|
240
|
+
* Compatibility flags beyond `nodejs_compat`, which every Every App Worker
|
|
241
|
+
* has, e.g. `["global_fetch_strictly_public"]` so the Worker's `fetch()`
|
|
242
|
+
* reaches only the public internet. Appended to `nodejs_compat`, without
|
|
243
|
+
* duplicates. The compatibility date is the manifest's.
|
|
244
|
+
*/
|
|
245
|
+
compatibilityFlags?: readonly string[];
|
|
246
|
+
}
|
|
247
|
+
export interface TextBinding {
|
|
248
|
+
type: "text";
|
|
249
|
+
value: string;
|
|
250
|
+
}
|
|
251
|
+
export interface SecretBinding {
|
|
252
|
+
type: "secret";
|
|
253
|
+
}
|
|
254
|
+
export interface D1Binding {
|
|
255
|
+
type: "d1";
|
|
256
|
+
name: string;
|
|
257
|
+
id?: string;
|
|
258
|
+
}
|
|
259
|
+
export interface KvBinding {
|
|
260
|
+
type: "kv";
|
|
261
|
+
id?: string;
|
|
262
|
+
}
|
|
263
|
+
export interface R2Binding {
|
|
264
|
+
type: "r2";
|
|
265
|
+
name: string;
|
|
266
|
+
}
|
|
267
|
+
export interface HyperdriveBinding {
|
|
268
|
+
type: "hyperdrive";
|
|
269
|
+
id: string;
|
|
270
|
+
dev?: {
|
|
271
|
+
connectionString?: string;
|
|
272
|
+
};
|
|
273
|
+
}
|
|
274
|
+
/** A producer binding to one of the app's queues. */
|
|
275
|
+
export interface QueueBinding {
|
|
276
|
+
type: "queue";
|
|
277
|
+
name: string;
|
|
278
|
+
}
|
|
279
|
+
/** A JSON value the Worker reads as it is: `env.<NAME>` is `value`. */
|
|
280
|
+
export interface JsonBinding<T = unknown> {
|
|
281
|
+
type: "json";
|
|
282
|
+
value: T;
|
|
283
|
+
}
|
|
284
|
+
/**
|
|
285
|
+
* An AI Gateway of the app's own (`resources.aiGateway`): its id, account
|
|
286
|
+
* and URL, which the Worker reads as `env.<NAME>.id` and `env.<NAME>.url`.
|
|
287
|
+
*/
|
|
288
|
+
export type AiGatewayBinding = JsonBinding<AiGatewayValue>;
|
|
289
|
+
/**
|
|
290
|
+
* Workers AI (`env.AI.run()`), which cf types as `Ai`. Deployed, it calls
|
|
291
|
+
* the account's Workers AI. Miniflare has none locally: in development the
|
|
292
|
+
* binding is marked remote, so it reaches the account once the app's Vite
|
|
293
|
+
* config sets `remoteBindings: true` (the starter sets it false) and
|
|
294
|
+
* `cf auth login` has run; until then every call throws `Binding AI needs
|
|
295
|
+
* to be run remotely`.
|
|
296
|
+
*/
|
|
297
|
+
export interface AiBinding {
|
|
298
|
+
type: "ai";
|
|
299
|
+
dev?: {
|
|
300
|
+
remote?: boolean;
|
|
301
|
+
};
|
|
302
|
+
}
|
|
303
|
+
/**
|
|
304
|
+
* Browser Rendering (`env.BROWSER`, for `@cloudflare/puppeteer` or
|
|
305
|
+
* `@cloudflare/playwright`), which cf types as `BrowserRun`. Deployed, it
|
|
306
|
+
* drives a headless Chrome on Cloudflare (Workers Paid). In development
|
|
307
|
+
* the same binding reaches Miniflare's local stand-in: the first session
|
|
308
|
+
* downloads a Chrome into the global `.wrangler` cache and starts it.
|
|
309
|
+
*/
|
|
310
|
+
export interface BrowserBinding {
|
|
311
|
+
type: "browser";
|
|
312
|
+
}
|
|
313
|
+
/**
|
|
314
|
+
* Cloudflare Images (`env.IMAGES.input(stream).transform(…).output(…)`,
|
|
315
|
+
* `env.IMAGES.info(stream)`), which cf types as the runtime's
|
|
316
|
+
* `ImagesBinding`. Deployed, it runs on Cloudflare and bills the account's
|
|
317
|
+
* Images transformations. In development Miniflare answers it locally with
|
|
318
|
+
* sharp, which ships with it.
|
|
319
|
+
*/
|
|
320
|
+
export interface ImagesBinding {
|
|
321
|
+
type: "images";
|
|
322
|
+
}
|
|
323
|
+
/**
|
|
324
|
+
* A Vectorize index, by name. `dev.remote` sends development calls to the
|
|
325
|
+
* account's index: Cloudflare has no local Vectorize.
|
|
326
|
+
*/
|
|
327
|
+
export interface VectorizeBinding {
|
|
328
|
+
type: "vectorize";
|
|
329
|
+
name: string;
|
|
330
|
+
dev?: {
|
|
331
|
+
remote?: boolean;
|
|
332
|
+
};
|
|
333
|
+
}
|
|
334
|
+
/**
|
|
335
|
+
* A `send_email` binding (cf's `SendEmailBindingOptions`): one destination,
|
|
336
|
+
* a list of them, or neither, and the senders it may use.
|
|
337
|
+
*/
|
|
338
|
+
type SendEmailDestination = {
|
|
339
|
+
destinationAddress: string;
|
|
340
|
+
allowedDestinationAddresses?: never;
|
|
341
|
+
} | {
|
|
342
|
+
destinationAddress?: never;
|
|
343
|
+
allowedDestinationAddresses: string[];
|
|
344
|
+
} | {
|
|
345
|
+
destinationAddress?: never;
|
|
346
|
+
allowedDestinationAddresses?: never;
|
|
347
|
+
};
|
|
348
|
+
export type SendEmailBinding = SendEmailDestination & {
|
|
349
|
+
type: "send-email";
|
|
350
|
+
allowedSenderAddresses?: string[];
|
|
351
|
+
};
|
|
352
|
+
/**
|
|
353
|
+
* A Secrets Store secret (`await env.STRIPE_KEY.get()`), which cf types as
|
|
354
|
+
* `SecretsStoreSecret`. Deployed, the secret the deploy made in the
|
|
355
|
+
* account's store; in development, the local store `local` that Miniflare
|
|
356
|
+
* keeps under `.cloudflare/state`, where `get()` throws `Secret "<name>"
|
|
357
|
+
* not found` until the secret is seeded there (`.dev.vars` doesn't reach
|
|
358
|
+
* this binding).
|
|
359
|
+
*/
|
|
360
|
+
export interface SecretsStoreSecretBinding {
|
|
361
|
+
type: "secrets-store-secret";
|
|
362
|
+
storeId: string;
|
|
363
|
+
secretName: string;
|
|
364
|
+
}
|
|
365
|
+
/**
|
|
366
|
+
* An Analytics Engine dataset (`env.EVENTS.writeDataPoint({ blobs,
|
|
367
|
+
* doubles, indexes })`), which cf types as `AnalyticsEngineDataset`.
|
|
368
|
+
* Deployed, the dataset exists once written to. In development Miniflare
|
|
369
|
+
* accepts every write and keeps none. cf's shape takes no `dev` options.
|
|
370
|
+
*/
|
|
371
|
+
export interface AnalyticsEngineDatasetBinding {
|
|
372
|
+
type: "analytics-engine-dataset";
|
|
373
|
+
name: string;
|
|
374
|
+
}
|
|
375
|
+
/**
|
|
376
|
+
* The app's own Worker, as the bindings of the Durable Objects it defines
|
|
377
|
+
* name it when its entrypoint is a `cf-worker` module import. cf reads each
|
|
378
|
+
* class from that module, so the `Env` it generates types the namespace
|
|
379
|
+
* with it (`DurableObjectNamespace<UserSyncDO>`) and RPC calls on a stub
|
|
380
|
+
* type-check, and it resolves the reference to the Worker's name.
|
|
381
|
+
*/
|
|
382
|
+
export interface EveryAppWorkerReference<TEntrypoint extends object> {
|
|
383
|
+
name: string;
|
|
384
|
+
compatibilityDate: string;
|
|
385
|
+
entrypoint: TEntrypoint;
|
|
386
|
+
}
|
|
387
|
+
/**
|
|
388
|
+
* A Durable Object binding. `worker` names the Worker defining the class:
|
|
389
|
+
* the app's own Worker by its definition (see
|
|
390
|
+
* {@link EveryAppWorkerReference}), or a Worker by name, which cf types as
|
|
391
|
+
* an untyped `DurableObjectNamespace`.
|
|
392
|
+
*/
|
|
393
|
+
export interface DurableObjectBinding<TWorker extends string | EveryAppWorkerReference<object> = string, TClassName extends string = string> {
|
|
394
|
+
type: "durable-object";
|
|
395
|
+
worker: TWorker;
|
|
396
|
+
exportName: TClassName;
|
|
397
|
+
}
|
|
398
|
+
export interface WorkflowBinding {
|
|
399
|
+
type: "workflow";
|
|
400
|
+
name: string;
|
|
401
|
+
worker: string;
|
|
402
|
+
exportName: string;
|
|
403
|
+
}
|
|
404
|
+
export interface GatewayBinding {
|
|
405
|
+
type: "worker";
|
|
406
|
+
worker: string;
|
|
407
|
+
exportName: string;
|
|
408
|
+
props: Record<string, string>;
|
|
409
|
+
}
|
|
410
|
+
/** The app's service binding to one of its helper Workers. */
|
|
411
|
+
export interface ServiceBinding {
|
|
412
|
+
type: "worker";
|
|
413
|
+
worker: string;
|
|
414
|
+
}
|
|
415
|
+
export interface VersionMetadataBinding {
|
|
416
|
+
type: "version-metadata";
|
|
417
|
+
}
|
|
418
|
+
/**
|
|
419
|
+
* A binding of any Worker these helpers build, each one `InputWorkerConfig`
|
|
420
|
+
* accepts, so a helper Worker's definition passes as the Vite plugin's
|
|
421
|
+
* `auxiliaryWorkers` config. A Durable Object binding names its Worker by
|
|
422
|
+
* name; only the app's own Worker names itself by definition (see
|
|
423
|
+
* {@link EveryAppWorkerReference}), in its typed `env`, which
|
|
424
|
+
* `defineConfig()` takes.
|
|
425
|
+
*/
|
|
426
|
+
export type EveryAppBinding = TextBinding | SecretBinding | D1Binding | KvBinding | R2Binding | HyperdriveBinding | QueueBinding | AiBinding | BrowserBinding | ImagesBinding | VectorizeBinding | AiGatewayBinding | JsonBinding<JsonValue> | SendEmailBinding | SecretsStoreSecretBinding | AnalyticsEngineDatasetBinding | DurableObjectBinding | WorkflowBinding | GatewayBinding | ServiceBinding | VersionMetadataBinding;
|
|
427
|
+
export interface DurableObjectExport {
|
|
428
|
+
type: "durable-object";
|
|
429
|
+
storage: "sqlite";
|
|
430
|
+
}
|
|
431
|
+
export interface WorkflowExport {
|
|
432
|
+
type: "workflow";
|
|
433
|
+
name: string;
|
|
434
|
+
}
|
|
435
|
+
type D1Names<M> = M extends {
|
|
436
|
+
resources: {
|
|
437
|
+
d1: readonly (infer B)[];
|
|
438
|
+
};
|
|
439
|
+
} ? B & string : never;
|
|
440
|
+
type KvNames<M> = M extends {
|
|
441
|
+
resources: {
|
|
442
|
+
kv: readonly (infer B)[];
|
|
443
|
+
};
|
|
444
|
+
} ? B & string : never;
|
|
445
|
+
type R2Names<M> = M extends {
|
|
446
|
+
resources: {
|
|
447
|
+
r2: readonly (infer B)[];
|
|
448
|
+
};
|
|
449
|
+
} ? B & string : never;
|
|
450
|
+
type AiNames<M> = M extends {
|
|
451
|
+
resources: {
|
|
452
|
+
ai: readonly (infer B)[];
|
|
453
|
+
};
|
|
454
|
+
} ? B & string : never;
|
|
455
|
+
type BrowserNames<M> = M extends {
|
|
456
|
+
resources: {
|
|
457
|
+
browser: readonly (infer B)[];
|
|
458
|
+
};
|
|
459
|
+
} ? B & string : never;
|
|
460
|
+
type ImagesNames<M> = M extends {
|
|
461
|
+
resources: {
|
|
462
|
+
images: readonly (infer B)[];
|
|
463
|
+
};
|
|
464
|
+
} ? B & string : never;
|
|
465
|
+
type VectorizeNames<M> = M extends {
|
|
466
|
+
resources: {
|
|
467
|
+
vectorize: readonly (infer V)[];
|
|
468
|
+
};
|
|
469
|
+
} ? V extends {
|
|
470
|
+
name: infer N extends string;
|
|
471
|
+
} ? N : never : never;
|
|
472
|
+
type AiGatewayNames<M> = M extends {
|
|
473
|
+
resources: {
|
|
474
|
+
aiGateway: readonly (infer G)[];
|
|
475
|
+
};
|
|
476
|
+
} ? G extends {
|
|
477
|
+
name: infer N extends string;
|
|
478
|
+
} ? N : never : never;
|
|
479
|
+
type AnalyticsEngineNames<M> = M extends {
|
|
480
|
+
resources: {
|
|
481
|
+
analyticsEngine: readonly (infer A)[];
|
|
482
|
+
};
|
|
483
|
+
} ? A extends {
|
|
484
|
+
name: infer N extends string;
|
|
485
|
+
} ? N : never : never;
|
|
486
|
+
type DurableObjects<M> = M extends {
|
|
487
|
+
resources: {
|
|
488
|
+
durableObjects: readonly (infer D)[];
|
|
489
|
+
};
|
|
490
|
+
} ? D : never;
|
|
491
|
+
type Workflows<M> = M extends {
|
|
492
|
+
resources: {
|
|
493
|
+
workflows: readonly (infer W)[];
|
|
494
|
+
};
|
|
495
|
+
} ? W : never;
|
|
496
|
+
type QueueNames<M> = M extends {
|
|
497
|
+
resources: {
|
|
498
|
+
queues: readonly (infer Q)[];
|
|
499
|
+
};
|
|
500
|
+
} ? Q extends {
|
|
501
|
+
name: infer N extends string;
|
|
502
|
+
} ? N : never : never;
|
|
503
|
+
type SendEmailNames<M> = M extends {
|
|
504
|
+
resources: {
|
|
505
|
+
sendEmail: readonly (infer S)[];
|
|
506
|
+
};
|
|
507
|
+
} ? S extends {
|
|
508
|
+
name: infer N extends string;
|
|
509
|
+
} ? N : never : never;
|
|
510
|
+
type SecretsStoreNames<M> = M extends {
|
|
511
|
+
resources: {
|
|
512
|
+
secretsStore: readonly (infer S)[];
|
|
513
|
+
};
|
|
514
|
+
} ? S extends {
|
|
515
|
+
name: infer N extends string;
|
|
516
|
+
} ? N : never : never;
|
|
517
|
+
type HelperWorkers<M> = M extends {
|
|
518
|
+
workers: readonly (infer H)[];
|
|
519
|
+
} ? H : never;
|
|
520
|
+
/** The Hyperdrive bindings the app's own Worker has: those no helper alone takes. */
|
|
521
|
+
type AppHyperdriveNames<M> = M extends {
|
|
522
|
+
resources: {
|
|
523
|
+
hyperdrive: readonly (infer H)[];
|
|
524
|
+
};
|
|
525
|
+
} ? H extends {
|
|
526
|
+
worker: string;
|
|
527
|
+
} ? never : H extends {
|
|
528
|
+
name: infer N extends string;
|
|
529
|
+
} ? N : never : never;
|
|
530
|
+
type DatabaseEnv<M> = M extends {
|
|
531
|
+
database: object;
|
|
532
|
+
} ? {
|
|
533
|
+
DATABASE_PROVIDER: TextBinding;
|
|
534
|
+
} : unknown;
|
|
535
|
+
type DevProviderKeys = typeof DEV_GATEWAY_KEYS.providers;
|
|
536
|
+
type DevCapabilityKeys = typeof DEV_GATEWAY_KEYS.capabilities;
|
|
537
|
+
/** The gateway keys a developer may set locally for the manifest's providers and capabilities. */
|
|
538
|
+
type DevGatewayKeys<M> = (M extends {
|
|
539
|
+
providers: readonly (infer P)[];
|
|
540
|
+
} ? P extends keyof DevProviderKeys ? DevProviderKeys[P][number] : never : never) | (M extends {
|
|
541
|
+
capabilities: infer C;
|
|
542
|
+
} ? keyof C extends infer K ? K extends keyof DevCapabilityKeys ? DevCapabilityKeys[K][number] : never : never : never);
|
|
543
|
+
/**
|
|
544
|
+
* A manifest Durable Object's binding: named after the app's own Worker by
|
|
545
|
+
* its definition when that Worker defines the class and its entrypoint is a
|
|
546
|
+
* module import, so cf types the namespace with the class; a helper
|
|
547
|
+
* Worker's class, or any class behind a path entrypoint, by name.
|
|
548
|
+
*/
|
|
549
|
+
type DurableObjectBindingFor<D, TEntrypoint> = D extends {
|
|
550
|
+
worker: string;
|
|
551
|
+
} ? DurableObjectBinding : TEntrypoint extends object ? D extends {
|
|
552
|
+
className: infer C extends string;
|
|
553
|
+
} ? DurableObjectBinding<EveryAppWorkerReference<TEntrypoint>, C> : DurableObjectBinding : DurableObjectBinding;
|
|
554
|
+
type ResourceEnv<M, TEntrypoint> = {
|
|
555
|
+
[B in D1Names<M>]: D1Binding;
|
|
556
|
+
} & {
|
|
557
|
+
[B in KvNames<M>]: KvBinding;
|
|
558
|
+
} & {
|
|
559
|
+
[B in R2Names<M>]: R2Binding;
|
|
560
|
+
} & {
|
|
561
|
+
[B in QueueNames<M>]: QueueBinding;
|
|
562
|
+
} & {
|
|
563
|
+
[B in AiNames<M>]: AiBinding;
|
|
564
|
+
} & {
|
|
565
|
+
[B in BrowserNames<M>]: BrowserBinding;
|
|
566
|
+
} & {
|
|
567
|
+
[B in ImagesNames<M>]: ImagesBinding;
|
|
568
|
+
} & {
|
|
569
|
+
[B in VectorizeNames<M>]: VectorizeBinding;
|
|
570
|
+
} & {
|
|
571
|
+
[B in AiGatewayNames<M>]: AiGatewayBinding;
|
|
572
|
+
} & {
|
|
573
|
+
[B in SendEmailNames<M>]: SendEmailBinding;
|
|
574
|
+
} & {
|
|
575
|
+
[B in SecretsStoreNames<M>]: SecretsStoreSecretBinding;
|
|
576
|
+
} & {
|
|
577
|
+
[B in AnalyticsEngineNames<M>]: AnalyticsEngineDatasetBinding;
|
|
578
|
+
} & {
|
|
579
|
+
[D in DurableObjects<M> as D extends {
|
|
580
|
+
name: infer N extends string;
|
|
581
|
+
} ? N : never]: DurableObjectBindingFor<D, TEntrypoint>;
|
|
582
|
+
} & {
|
|
583
|
+
[W in Workflows<M> as W extends {
|
|
584
|
+
name: infer N extends string;
|
|
585
|
+
} ? N : never]: WorkflowBinding;
|
|
586
|
+
} & {
|
|
587
|
+
[H in HelperWorkers<M> as H extends {
|
|
588
|
+
binding: infer B extends string;
|
|
589
|
+
} ? B : never]: ServiceBinding;
|
|
590
|
+
};
|
|
591
|
+
/** A JSON value, as cf's JSON bindings take one. */
|
|
592
|
+
type JsonValue = string | number | boolean | null | JsonValue[] | {
|
|
593
|
+
[key: string]: JsonValue;
|
|
594
|
+
};
|
|
595
|
+
/** `M` without `readonly`, as cf's JSON bindings take their value. */
|
|
596
|
+
type JsonValueOf<M> = M extends readonly (infer E)[] ? JsonValueOf<E>[] : M extends object ? {
|
|
597
|
+
-readonly [K in keyof M]: JsonValueOf<M[K]>;
|
|
598
|
+
} : M;
|
|
599
|
+
type SharedEnv<M> = {
|
|
600
|
+
EVERYAPP_APP_ID: TextBinding;
|
|
601
|
+
EVERYAPP_MANIFEST: JsonBinding<JsonValueOf<M>>;
|
|
602
|
+
CF_VERSION_METADATA: VersionMetadataBinding;
|
|
603
|
+
GATEWAY_URL: TextBinding | SecretBinding;
|
|
604
|
+
};
|
|
605
|
+
/**
|
|
606
|
+
* Hyperdrive in production; in development only where a local connection
|
|
607
|
+
* string is set, so `Env` marks each optional.
|
|
608
|
+
*/
|
|
609
|
+
type HyperdriveEnv<M> = {
|
|
610
|
+
[B in AppHyperdriveNames<M>]: HyperdriveBinding;
|
|
611
|
+
};
|
|
612
|
+
/** In dev, an app that lists `email` may get the installation's stand-in senders from .dev.vars. */
|
|
613
|
+
type DevEmailEnv<M> = M extends {
|
|
614
|
+
capabilities: {
|
|
615
|
+
email: unknown;
|
|
616
|
+
};
|
|
617
|
+
} ? {
|
|
618
|
+
EVERYAPP_EMAIL_SENDERS?: SecretBinding;
|
|
619
|
+
} : unknown;
|
|
620
|
+
/**
|
|
621
|
+
* Bindings in development: the well-known dev identity, as plain text, and
|
|
622
|
+
* the developer's own gateway keys (when set).
|
|
623
|
+
*/
|
|
624
|
+
export type EveryAppDevEnv<M, TEntrypoint = string> = ResourceEnv<M, TEntrypoint> & SharedEnv<M> & DatabaseEnv<M> & DevEmailEnv<M> & {
|
|
625
|
+
EVERYAPP_DEV: TextBinding;
|
|
626
|
+
EVERYAPP_DEV_CAPABILITIES: TextBinding;
|
|
627
|
+
/** The specs in `.everyapp/providers/*.json`, when the app has any: providers registered on a gateway, for integrationFetch()'s dev fallback. */
|
|
628
|
+
EVERYAPP_DEV_PROVIDERS?: TextBinding;
|
|
629
|
+
/** Under `everyapp dev --gateway` (linked dev): the gateway-lite's forwarder and the run's nonce, which the SDK's services call the real Gateway through. */
|
|
630
|
+
EVERYAPP_LINKED_DEV_URL?: TextBinding;
|
|
631
|
+
EVERYAPP_LINKED_DEV_NONCE?: TextBinding;
|
|
632
|
+
EVERYAPP_IDENTITY_PUBLIC_KEYS: TextBinding;
|
|
633
|
+
EVERYAPP_IDENTITY_ISSUER: TextBinding;
|
|
634
|
+
/** The stub dev gateway's organization (`dev-org`), so `withOrganization(env.EVERY_APP_ORG_ID, …)` works in development as deployed. */
|
|
635
|
+
EVERY_APP_ORG_ID: TextBinding;
|
|
636
|
+
} & {
|
|
637
|
+
[K in DevGatewayKeys<M>]: SecretBinding;
|
|
638
|
+
};
|
|
639
|
+
/** Bindings in production: the deployed identity and the gateway binding. */
|
|
640
|
+
export type EveryAppDeployEnv<M, TEntrypoint = string> = ResourceEnv<M, TEntrypoint> & SharedEnv<M> & DatabaseEnv<M> & HyperdriveEnv<M> & {
|
|
641
|
+
EVERYAPP_AUDIENCE: TextBinding;
|
|
642
|
+
EVERYAPP_IDENTITY_PUBLIC_KEYS: TextBinding;
|
|
643
|
+
EVERYAPP_IDENTITY_ISSUER: TextBinding;
|
|
644
|
+
EVERY_APP_GATEWAY: GatewayBinding;
|
|
645
|
+
/**
|
|
646
|
+
* The owning organization. The build always declares it; installing a
|
|
647
|
+
* shared app, which serves every organization, drops it.
|
|
648
|
+
*/
|
|
649
|
+
EVERY_APP_ORG_ID?: SecretBinding;
|
|
650
|
+
/**
|
|
651
|
+
* `1` on a shared app's Workers, added when it is installed: gateway
|
|
652
|
+
* calls say whom they are for.
|
|
653
|
+
*/
|
|
654
|
+
EVERYAPP_SHARED?: TextBinding;
|
|
655
|
+
};
|
|
656
|
+
/** The classes the app's own Worker defines: none a helper Worker does. */
|
|
657
|
+
export type EveryAppExports<M> = {
|
|
658
|
+
[E in DurableObjects<M> | Workflows<M> as E extends {
|
|
659
|
+
worker: string;
|
|
660
|
+
} ? never : E extends {
|
|
661
|
+
className: infer C extends string;
|
|
662
|
+
} ? C : never]: E extends Workflows<M> ? WorkflowExport : DurableObjectExport;
|
|
663
|
+
};
|
|
664
|
+
export interface EveryAppObservability {
|
|
665
|
+
enabled: boolean;
|
|
666
|
+
headSamplingRate: number;
|
|
667
|
+
redactQueryString: boolean;
|
|
668
|
+
logs: {
|
|
669
|
+
enabled: boolean;
|
|
670
|
+
invocationLogs: boolean;
|
|
671
|
+
persist: boolean;
|
|
672
|
+
headSamplingRate: number;
|
|
673
|
+
};
|
|
674
|
+
traces: {
|
|
675
|
+
enabled: boolean;
|
|
676
|
+
persist: boolean;
|
|
677
|
+
headSamplingRate: number;
|
|
678
|
+
};
|
|
679
|
+
issues: {
|
|
680
|
+
enabled: boolean;
|
|
681
|
+
};
|
|
682
|
+
}
|
|
683
|
+
/** Structural copy of cf's targeted placement: run near a cloud region. */
|
|
684
|
+
export interface EveryAppPlacement {
|
|
685
|
+
region: string;
|
|
686
|
+
}
|
|
687
|
+
/** Structural copy of cf's scheduled (cron) trigger. */
|
|
688
|
+
export interface ScheduledTrigger {
|
|
689
|
+
type: "scheduled";
|
|
690
|
+
schedule: string;
|
|
691
|
+
}
|
|
692
|
+
/**
|
|
693
|
+
* Structural copy of cf's queue consumer trigger: the Worker consumes the
|
|
694
|
+
* named queue (its `queue(batch, env)` handler), with these settings.
|
|
695
|
+
*/
|
|
696
|
+
export interface QueueConsumerTrigger {
|
|
697
|
+
type: "queue";
|
|
698
|
+
name: string;
|
|
699
|
+
deadLetterQueue?: string;
|
|
700
|
+
maxBatchSize?: number;
|
|
701
|
+
maxBatchTimeout?: number;
|
|
702
|
+
maxConcurrency?: number | null;
|
|
703
|
+
maxRetries?: number;
|
|
704
|
+
retryDelay?: number;
|
|
705
|
+
visibilityTimeoutMs?: number;
|
|
706
|
+
}
|
|
707
|
+
/** A trigger one of the app's Workers may have: its crons, the queues it consumes. */
|
|
708
|
+
export type EveryAppTrigger = ScheduledTrigger | QueueConsumerTrigger;
|
|
709
|
+
export interface EveryAppWorkerConfig<M, TEntrypoint> {
|
|
710
|
+
name: string;
|
|
711
|
+
entrypoint: TEntrypoint;
|
|
712
|
+
compatibilityDate: string;
|
|
713
|
+
compatibilityFlags: string[];
|
|
714
|
+
workersDev: false;
|
|
715
|
+
previewUrls: false;
|
|
716
|
+
/** The `crons` option's schedules and the queues it consumes; absent without any. */
|
|
717
|
+
triggers?: EveryAppTrigger[];
|
|
718
|
+
/** Near the manifest's `database.region`, once deployed. */
|
|
719
|
+
placement?: EveryAppPlacement;
|
|
720
|
+
/** The manifest's `limits`. */
|
|
721
|
+
limits?: {
|
|
722
|
+
cpuMs?: number;
|
|
723
|
+
};
|
|
724
|
+
observability: EveryAppObservability;
|
|
725
|
+
/** Either branch, so `Env` marks dev-only and deploy-only bindings optional. */
|
|
726
|
+
env: EveryAppDevEnv<M, TEntrypoint> | EveryAppDeployEnv<M, TEntrypoint>;
|
|
727
|
+
exports: EveryAppExports<M>;
|
|
728
|
+
}
|
|
729
|
+
/**
|
|
730
|
+
* Observability every Every App Worker ships with: logs (with invocation
|
|
731
|
+
* logs), sampled traces and Workers Issues, with query strings redacted so
|
|
732
|
+
* tokens and invitation ids in URLs stay out of logs.
|
|
733
|
+
*/
|
|
734
|
+
export declare const EVERYAPP_OBSERVABILITY: Readonly<EveryAppObservability>;
|
|
735
|
+
/**
|
|
736
|
+
* Build the Worker definition for an Every App app from its manifest.
|
|
737
|
+
*
|
|
738
|
+
* - `development` (cf dev) and no mode (cf API commands, `cf workers types`):
|
|
739
|
+
* EVERYAPP_DEV is on, the identity keys and issuer are the well-known dev
|
|
740
|
+
* ones (`@every-app/sdk/dev`) as plain text, so nothing needs writing to
|
|
741
|
+
* `.dev.vars`, and each D1 database gets a fixed local id (see
|
|
742
|
+
* {@link localD1Id}) that `cf d1 … --local` can address.
|
|
743
|
+
* - `production`: tenant-neutral. Everything install-specific (the Worker
|
|
744
|
+
* name, organization, gateway URL, identity keys, resource names and ids)
|
|
745
|
+
* is a placeholder from {@link sentinelDeployTarget}, which the installer
|
|
746
|
+
* rewrites (`everyapp deploy`, or a hosted gateway's deployer), so every
|
|
747
|
+
* build of an app is the same. Only with EVERYAPP_BUILD=1, which
|
|
748
|
+
* `everyapp deploy` sets: a bare `cf deploy` would upload the
|
|
749
|
+
* placeholders.
|
|
750
|
+
*/
|
|
751
|
+
export declare function everyAppWorker<const M extends EveryAppWorkerManifest, TEntrypoint extends string | object>(options: EveryAppWorkerOptions<M, TEntrypoint>): EveryAppWorkerConfig<M, TEntrypoint>;
|
|
752
|
+
export interface EveryAppAuxiliaryWorkerOptions<TManifest extends EveryAppWorkerManifest, TEntrypoint> extends EveryAppWorkerOptions<TManifest, TEntrypoint> {
|
|
753
|
+
/** The helper Worker's name in the manifest's `workers`. */
|
|
754
|
+
worker: string;
|
|
755
|
+
}
|
|
756
|
+
/** A helper Worker's definition, for the Vite plugin's `auxiliaryWorkers`. */
|
|
757
|
+
export interface EveryAppAuxiliaryWorkerConfig<TEntrypoint> {
|
|
758
|
+
name: string;
|
|
759
|
+
entrypoint: TEntrypoint;
|
|
760
|
+
compatibilityDate: string;
|
|
761
|
+
compatibilityFlags: string[];
|
|
762
|
+
workersDev: false;
|
|
763
|
+
previewUrls: false;
|
|
764
|
+
triggers?: EveryAppTrigger[];
|
|
765
|
+
placement?: EveryAppPlacement;
|
|
766
|
+
limits?: {
|
|
767
|
+
cpuMs?: number;
|
|
768
|
+
};
|
|
769
|
+
observability: EveryAppObservability;
|
|
770
|
+
env: Record<string, EveryAppBinding>;
|
|
771
|
+
exports: Record<string, DurableObjectExport | WorkflowExport>;
|
|
772
|
+
}
|
|
773
|
+
/**
|
|
774
|
+
* Build the definition of one of the app's helper Workers (the manifest's
|
|
775
|
+
* `workers`), e.g. one that runs a memory-hungry job away from the app's
|
|
776
|
+
* Worker. It is named `<app worker>--<worker>`, is private like the app, and
|
|
777
|
+
* binds the app's and Analytics Engine datasets, the classes it defines, and
|
|
778
|
+
* binds the app's D1 databases, KV namespaces, R2 buckets, Workers AI,
|
|
779
|
+
* Browser Rendering, Images, Vectorize indexes, AI Gateways, `send_email`
|
|
780
|
+
* bindings and Secrets Store secrets, the classes it defines, and
|
|
781
|
+
* the gateway (with the app's identity, for capabilities). Only the app's
|
|
782
|
+
* Worker reaches it. Pass it to the Vite plugin:
|
|
783
|
+
*
|
|
784
|
+
* cloudflare({
|
|
785
|
+
* auxiliaryWorkers: [
|
|
786
|
+
* { config: everyAppAuxiliaryWorker({ manifest, worker: "audit", entrypoint: "./src/audit.ts", ctx: { mode } }) },
|
|
787
|
+
* ],
|
|
788
|
+
* })
|
|
789
|
+
*/
|
|
790
|
+
export declare function everyAppAuxiliaryWorker<const M extends EveryAppWorkerManifest, TEntrypoint extends string | object>(options: EveryAppAuxiliaryWorkerOptions<M, TEntrypoint>): EveryAppAuxiliaryWorkerConfig<TEntrypoint>;
|
|
791
|
+
/**
|
|
792
|
+
* The local D1 database id for a binding: a 32-hex string, because
|
|
793
|
+
* `cf d1 … --local` rejects names. The everyapp CLI computes the same id to
|
|
794
|
+
* apply local migrations to the database `cf dev` serves.
|
|
795
|
+
*/
|
|
796
|
+
export declare function localD1Id(workerName: string, binding: string): string;
|
|
797
|
+
/**
|
|
798
|
+
* The sqlite file `cf dev` (and `cf d1 … --local`) keeps the local D1
|
|
799
|
+
* database `databaseId` in, under the app at `root`, for tools such as
|
|
800
|
+
* drizzle-kit studio: `.cloudflare/state/v3/d1/miniflare-D1DatabaseObject/
|
|
801
|
+
* <hash>.sqlite`. The database is a Durable Object named after its id, and
|
|
802
|
+
* the file after that object's id. `databaseId` is the {@link localD1Id}.
|
|
803
|
+
*/
|
|
804
|
+
export declare function localD1Path(root: string, databaseId: string): string;
|
|
805
|
+
//# sourceMappingURL=worker.d.ts.map
|