@cloudflare/vite-plugin 1.54.5 → 1.54.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/experimental-config.d.mts +1309 -1383
- package/dist/experimental-config.d.mts.map +1 -1
- package/dist/experimental-config.mjs +22 -26
- package/dist/experimental-config.mjs.map +1 -1
- package/dist/index.mjs +749 -547
- package/dist/index.mjs.map +1 -1
- package/dist/{open-PBXRGS4R-HMkvHv1N.mjs → open-PBXRGS4R-DFtj97wF.mjs} +3 -3
- package/dist/{open-PBXRGS4R-HMkvHv1N.mjs.map → open-PBXRGS4R-DFtj97wF.mjs.map} +1 -1
- package/dist/{package-BUBRX7k4.mjs → package-CsWrn9PH.mjs} +2 -2
- package/dist/{package-BUBRX7k4.mjs.map → package-CsWrn9PH.mjs.map} +1 -1
- package/package.json +12 -12
|
@@ -1,1686 +1,1612 @@
|
|
|
1
1
|
import { Pipeline, PipelineRecord } from "cloudflare:pipelines";
|
|
2
2
|
|
|
3
|
-
//#region ../config/dist/public-
|
|
3
|
+
//#region ../config/dist/public-E85Be_2R.d.mts
|
|
4
4
|
|
|
5
|
-
//#region src/
|
|
5
|
+
//#region src/inference.d.ts
|
|
6
6
|
/**
|
|
7
|
-
*
|
|
7
|
+
* The Worker's entry module, imported with the `{ type: "cf-worker" }` import attribute
|
|
8
|
+
* @example
|
|
9
|
+
* ```ts
|
|
10
|
+
* import * as entrypoint from "./src" with { type: "cf-worker" };
|
|
11
|
+
* ```
|
|
8
12
|
*/
|
|
9
|
-
type
|
|
10
|
-
[key: string]: Json;
|
|
11
|
-
};
|
|
12
|
-
//#endregion
|
|
13
|
-
//#region src/bindings.d.ts
|
|
14
|
-
/** Options that control a binding during local development. */
|
|
15
|
-
interface BindingDevOptions {
|
|
16
|
-
/** Whether the binding should connect to the remote resource. */
|
|
17
|
-
remote?: boolean;
|
|
18
|
-
}
|
|
19
|
-
interface AgentMemoryBindingOptions {
|
|
20
|
-
/** The user-chosen namespace name. Must exist in Cloudflare at deploy time. */
|
|
21
|
-
namespace: string;
|
|
22
|
-
/** Options that only apply during local development. */
|
|
23
|
-
dev?: BindingDevOptions;
|
|
24
|
-
}
|
|
13
|
+
type WorkerModule = Record<string, any>;
|
|
25
14
|
/**
|
|
26
|
-
*
|
|
27
|
-
*
|
|
15
|
+
* Default module type representing an unknown Worker's exports.
|
|
16
|
+
* - default export can be `ExportedHandler` or a `WorkerEntrypoint` class constructor
|
|
17
|
+
* - named exports can be `WorkerEntrypoint`, `DurableObject`, or `WorkflowEntrypoint` class constructors
|
|
28
18
|
*/
|
|
29
|
-
interface
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
interface AiBindingOptions {
|
|
33
|
-
/** Options that only apply during local development. */
|
|
34
|
-
dev?: BindingDevOptions;
|
|
19
|
+
interface DefaultModule {
|
|
20
|
+
default?: ExportedHandler | Constructor<Rpc.WorkerEntrypointBranded>;
|
|
21
|
+
[key: string]: ExportedHandler | Constructor<Rpc.WorkerEntrypointBranded> | Constructor<Rpc.DurableObjectBranded> | Constructor<Rpc.WorkflowEntrypointBranded> | undefined;
|
|
35
22
|
}
|
|
36
23
|
/**
|
|
37
|
-
*
|
|
38
|
-
*
|
|
39
|
-
* For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#workers-ai
|
|
24
|
+
* Represents a class constructor that creates instances of TInstance.
|
|
40
25
|
*/
|
|
41
|
-
|
|
42
|
-
type: "ai";
|
|
43
|
-
}
|
|
26
|
+
type Constructor<TInstance> = new (...args: any[]) => TInstance;
|
|
44
27
|
/**
|
|
45
|
-
*
|
|
46
|
-
*
|
|
47
|
-
* For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#workers-ai
|
|
28
|
+
* Extracts the instance type from a class constructor if it extends `TInstance`.
|
|
48
29
|
*/
|
|
49
|
-
|
|
50
|
-
/** @internal Carries type parameters for inference */
|
|
51
|
-
__typeParams: [TAiModelList];
|
|
52
|
-
}
|
|
53
|
-
interface AiSearchBindingOptions {
|
|
54
|
-
/** The user-chosen instance name. Must exist in Cloudflare at deploy time. */
|
|
55
|
-
name: string;
|
|
56
|
-
/** Options that only apply during local development. */
|
|
57
|
-
dev?: BindingDevOptions;
|
|
58
|
-
}
|
|
30
|
+
type ExtractInstance<T$1, TInstance> = T$1 extends Constructor<TInstance> ? InstanceType<T$1> : never;
|
|
59
31
|
/**
|
|
60
|
-
*
|
|
61
|
-
*
|
|
32
|
+
* Mapping from binding type literals to Cloudflare runtime types.
|
|
33
|
+
*
|
|
34
|
+
* Entries fall into two groups:
|
|
35
|
+
* - Parameterized bindings (ai, json, kv, pipeline, queue, text) refine their
|
|
36
|
+
* runtime type from the binding instance via nominal matches against the
|
|
37
|
+
* `Typed*Binding` / `JsonBinding` / `TextBinding` interfaces from
|
|
38
|
+
* `./bindings`. When `TBinding` does not match, the entry falls back to the
|
|
39
|
+
* unparameterized runtime type.
|
|
40
|
+
* - Non-parameterized bindings map their type literal directly to a runtime
|
|
41
|
+
* type and ignore `TBinding`.
|
|
42
|
+
*
|
|
43
|
+
* IMPORTANT: The right-hand-side identifiers in this map (e.g. `KVNamespace`,
|
|
44
|
+
* `ImagesBinding`, `Fetcher`) must resolve to the ambient runtime types from
|
|
45
|
+
* `@cloudflare/workers-types`, not to local config interfaces. Several local
|
|
46
|
+
* binding interfaces in `./bindings.ts` (`ImagesBinding`, `MediaBinding`,
|
|
47
|
+
* `StreamBinding`) share names with ambient globals — importing those local
|
|
48
|
+
* types into this file silently shadows the globals and breaks `InferEnv`.
|
|
49
|
+
* Only import the `Typed*Binding`, `JsonBinding`, and `TextBinding` interfaces
|
|
50
|
+
* from `./bindings` (their names do not collide with ambient globals); never
|
|
51
|
+
* widen the import to a wildcard or to the plain `*Binding` interfaces.
|
|
62
52
|
*/
|
|
63
|
-
interface
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
53
|
+
interface BindingTypeMap<TBinding> {
|
|
54
|
+
ai: TBinding extends TypedAiBinding<infer T> ? Ai<T> : Ai;
|
|
55
|
+
json: TBinding extends JsonBinding<infer T> ? T : never;
|
|
56
|
+
kv: TBinding extends TypedKvBinding<infer T> ? KVNamespace<T> : KVNamespace;
|
|
57
|
+
pipeline: TBinding extends TypedPipelineBinding<infer T> ? Pipeline<T> : Pipeline;
|
|
58
|
+
queue: TBinding extends TypedQueueBinding<infer T> ? Queue<T> : Queue;
|
|
59
|
+
text: TBinding extends TextBinding<infer T> ? T : never;
|
|
60
|
+
"agent-memory": AgentMemoryNamespace;
|
|
61
|
+
"ai-search": AiSearchInstance;
|
|
62
|
+
"ai-search-namespace": AiSearchNamespace;
|
|
63
|
+
"analytics-engine-dataset": AnalyticsEngineDataset;
|
|
64
|
+
artifacts: Artifacts;
|
|
65
|
+
assets: Fetcher;
|
|
66
|
+
browser: BrowserRun;
|
|
67
|
+
d1: D1Database;
|
|
68
|
+
"dispatch-namespace": DispatchNamespace;
|
|
69
|
+
"durable-object": DurableObjectNamespace;
|
|
70
|
+
flagship: Flagship;
|
|
71
|
+
hyperdrive: Hyperdrive;
|
|
72
|
+
images: ImagesBinding;
|
|
73
|
+
logfwdr: any;
|
|
74
|
+
media: MediaBinding;
|
|
75
|
+
"mtls-certificate": Fetcher;
|
|
76
|
+
"rate-limit": RateLimit;
|
|
77
|
+
r2: R2Bucket;
|
|
78
|
+
secret: string;
|
|
79
|
+
"secrets-store-secret": SecretsStoreSecret;
|
|
80
|
+
"send-email": SendEmail;
|
|
81
|
+
stream: StreamBinding;
|
|
82
|
+
vectorize: VectorizeIndex;
|
|
83
|
+
"version-metadata": WorkerVersionMetadata;
|
|
84
|
+
"vpc-service": Fetcher;
|
|
85
|
+
"vpc-network": Fetcher;
|
|
86
|
+
"web-search": WebSearch;
|
|
87
|
+
worker: Fetcher;
|
|
88
|
+
"worker-loader": WorkerLoader;
|
|
89
|
+
workflow: Workflow;
|
|
71
90
|
}
|
|
91
|
+
type SelectedWorkerExportName<TBinding> = TBinding extends {
|
|
92
|
+
exportName?: infer TExportName;
|
|
93
|
+
} ? TExportName extends string ? TExportName : "default" : "default";
|
|
94
|
+
type InferBindingType<TBinding> = TBinding extends {
|
|
95
|
+
type: "worker";
|
|
96
|
+
worker: infer TWorker extends WorkerReference;
|
|
97
|
+
} ? TWorker extends string ? Fetcher : InferMainModule<UnwrapConfig<TWorker>> extends infer TModule extends WorkerModule ? SelectedWorkerExportName<TBinding> extends infer TExportName ? TExportName extends keyof TModule ? TModule[TExportName] extends Constructor<any> ? Fetcher<ExtractInstance<TModule[TExportName], Rpc.WorkerEntrypointBranded>> : Fetcher : never : never : never : TBinding extends {
|
|
98
|
+
type: "durable-object";
|
|
99
|
+
worker: infer TWorker extends WorkerReference;
|
|
100
|
+
exportName: infer TExportName extends string;
|
|
101
|
+
} ? TWorker extends string ? DurableObjectNamespace : InferMainModule<UnwrapConfig<TWorker>> extends infer TModule extends WorkerModule ? TExportName extends keyof TModule ? DurableObjectNamespace<ExtractInstance<TModule[TExportName], Rpc.DurableObjectBranded>> : never : never : TBinding extends {
|
|
102
|
+
type: "workflow";
|
|
103
|
+
worker: infer TWorker extends WorkerReference;
|
|
104
|
+
exportName: infer TExportName extends string;
|
|
105
|
+
} ? TWorker extends string ? Workflow : InferMainModule<UnwrapConfig<TWorker>> extends infer TModule extends WorkerModule ? TExportName extends keyof TModule ? ExtractInstance<TModule[TExportName], Rpc.WorkflowEntrypointBranded> extends infer TWorkflow ? TWorkflow extends {
|
|
106
|
+
run(event: {
|
|
107
|
+
payload: infer P;
|
|
108
|
+
}, step: any): any;
|
|
109
|
+
} ? Workflow<P> : Workflow : Workflow : never : never : TBinding extends {
|
|
110
|
+
type: `unsafe:${string}`;
|
|
111
|
+
} ? any : TBinding extends {
|
|
112
|
+
type: infer K extends keyof BindingTypeMap<TBinding>;
|
|
113
|
+
} ? BindingTypeMap<TBinding>[K] : never;
|
|
72
114
|
/**
|
|
73
|
-
*
|
|
74
|
-
*
|
|
115
|
+
* Infer export names from a config's exports, optionally filtered by type.
|
|
116
|
+
* When TExportType is `string` (default), returns all export names.
|
|
117
|
+
* When TExportType is a specific literal like `"durable-object"` or `"workflow"`,
|
|
118
|
+
* returns only exports of that type.
|
|
75
119
|
*/
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
}
|
|
120
|
+
type InferExportsByType<TUnwrappedConfig, TExportType extends string = string> = TUnwrappedConfig extends {
|
|
121
|
+
exports: infer TExports extends Record<string, {
|
|
122
|
+
type: string;
|
|
123
|
+
}>;
|
|
124
|
+
} ? { [K in keyof TExports]: TExports[K] extends {
|
|
125
|
+
type: TExportType;
|
|
126
|
+
} ? K & string : never }[keyof TExports] : never;
|
|
83
127
|
/**
|
|
84
|
-
*
|
|
85
|
-
*
|
|
86
|
-
*
|
|
128
|
+
* Infer `WorkerEntrypoint` export names from a config.
|
|
129
|
+
* Returns named module exports that are not declared as type `"durable-object"` or `"workflow"` in `exports`.
|
|
130
|
+
* Excludes `"default"` since `exportName` should only be provided for named exports.
|
|
87
131
|
*/
|
|
88
|
-
|
|
89
|
-
type: "analytics-engine-dataset";
|
|
90
|
-
}
|
|
91
|
-
interface ArtifactsBindingOptions {
|
|
92
|
-
/** The namespace to use. */
|
|
93
|
-
namespace: string;
|
|
94
|
-
/** Options that only apply during local development. */
|
|
95
|
-
dev?: BindingDevOptions;
|
|
96
|
-
}
|
|
132
|
+
type InferWorkerEntrypointExports<TUnwrappedConfig> = Exclude<keyof InferMainModule<TUnwrappedConfig> & string, "default" | InferExportsByType<TUnwrappedConfig, "durable-object" | "workflow">>;
|
|
97
133
|
/**
|
|
98
|
-
*
|
|
99
|
-
*
|
|
134
|
+
* Unwrap function and promise types to get the underlying config.
|
|
135
|
+
* Use this to normalize a config before passing it to other inference utilities.
|
|
100
136
|
*/
|
|
101
|
-
|
|
102
|
-
type: "artifacts";
|
|
103
|
-
}
|
|
137
|
+
type UnwrapConfig<TConfig$1> = TConfig$1 extends ((...args: any[]) => infer TReturn) ? UnwrapConfig<TReturn> : TConfig$1 extends Promise<infer TCompletion> ? UnwrapConfig<TCompletion> : TConfig$1;
|
|
104
138
|
/**
|
|
105
|
-
*
|
|
139
|
+
* Infer the `Env` interface type from a Worker config.
|
|
106
140
|
*
|
|
107
|
-
*
|
|
108
|
-
|
|
109
|
-
interface AssetsBinding {
|
|
110
|
-
type: "assets";
|
|
111
|
-
}
|
|
112
|
-
interface BrowserBindingOptions {
|
|
113
|
-
/** Options that only apply during local development. */
|
|
114
|
-
dev?: BindingDevOptions;
|
|
115
|
-
}
|
|
116
|
-
/**
|
|
117
|
-
* Binding to a headless browser usable from the Worker.
|
|
141
|
+
* Transforms a config object's `env` bindings into their
|
|
142
|
+
* corresponding Cloudflare runtime types.
|
|
118
143
|
*
|
|
119
|
-
*
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
}
|
|
124
|
-
interface D1BindingOptions {
|
|
125
|
-
/** The UUID of this D1 database (not required). */
|
|
126
|
-
id?: string;
|
|
127
|
-
/** The name of this D1 database. */
|
|
128
|
-
name?: string;
|
|
129
|
-
/** Options that only apply during local development. */
|
|
130
|
-
dev?: BindingDevOptions;
|
|
131
|
-
}
|
|
132
|
-
/**
|
|
133
|
-
* Binding to a D1 database.
|
|
144
|
+
* @example
|
|
145
|
+
* ```typescript
|
|
146
|
+
* import { defineWorker, bindings } from "@cloudflare/config";
|
|
147
|
+
* import type { InferEnv, UnwrapConfig } from "@cloudflare/config";
|
|
134
148
|
*
|
|
135
|
-
*
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
/** The namespace to bind to. */
|
|
142
|
-
namespace?: string;
|
|
143
|
-
/** Details about the outbound Worker which will handle outbound requests from your namespace. */
|
|
144
|
-
outbound?: {
|
|
145
|
-
/** Name of the Worker handling the outbound requests. */
|
|
146
|
-
worker: string;
|
|
147
|
-
/** (Optional) List of parameter names, for sending context from your dispatch Worker to the outbound handler. */
|
|
148
|
-
parameters?: string[];
|
|
149
|
-
};
|
|
150
|
-
/** Options that only apply during local development. */
|
|
151
|
-
dev?: BindingDevOptions;
|
|
152
|
-
}
|
|
153
|
-
/**
|
|
154
|
-
* Binding to a Workers for Platforms dispatch namespace.
|
|
149
|
+
* const config = defineWorker({
|
|
150
|
+
* env: {
|
|
151
|
+
* MY_JSON: bindings.json({ id: string }),
|
|
152
|
+
* MY_KV: bindings.kv(),
|
|
153
|
+
* },
|
|
154
|
+
* });
|
|
155
155
|
*
|
|
156
|
-
*
|
|
156
|
+
* type WorkerConfig = UnwrapConfig<typeof config>;
|
|
157
|
+
* // Inferred as: { MY_JSON: { id: string }; MY_KV: KVNamespace }
|
|
158
|
+
* export type Env = InferEnv<WorkerConfig>;
|
|
159
|
+
* ```
|
|
157
160
|
*/
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
}
|
|
161
|
-
interface DurableObjectBindingOptions {
|
|
162
|
-
/** The name of the Worker that defines the Durable Object class. */
|
|
163
|
-
worker: string;
|
|
164
|
-
/** The exported class name of the Durable Object. */
|
|
165
|
-
exportName: string;
|
|
166
|
-
}
|
|
161
|
+
type InferEnv<TUnwrappedConfig> = TUnwrappedConfig extends {
|
|
162
|
+
env: infer TEnv extends Record<string, any>;
|
|
163
|
+
} ? { [K in keyof TEnv]: InferBindingType<TEnv[K]> } : never;
|
|
167
164
|
/**
|
|
168
|
-
*
|
|
169
|
-
*
|
|
170
|
-
*
|
|
171
|
-
*
|
|
172
|
-
|
|
173
|
-
|
|
165
|
+
* Infer the Durable Object namespace names from a Worker config's exports.
|
|
166
|
+
* Returns a union of export names that declare a *live* Durable Object —
|
|
167
|
+
* `type: "durable-object"` with `state` either omitted, `"created"`, or
|
|
168
|
+
* `"expecting-transfer"`. Tombstone entries (`deleted`, `renamed`,
|
|
169
|
+
* `transferred`) are excluded because they retire the namespace and a
|
|
170
|
+
* binding to a tombstoned class would fail at deploy time.
|
|
171
|
+
*
|
|
172
|
+
* @example
|
|
173
|
+
* ```typescript
|
|
174
|
+
* import { defineWorker } from "@cloudflare/config";
|
|
175
|
+
* import type { InferDurableNamespaces, UnwrapConfig } from "@cloudflare/config";
|
|
176
|
+
*
|
|
177
|
+
* const config = defineWorker({
|
|
178
|
+
* exports: {
|
|
179
|
+
* MyDurableObject: { type: "durable-object", storage: "sqlite" },
|
|
180
|
+
* OldGone: { type: "durable-object", state: "deleted" },
|
|
181
|
+
* },
|
|
182
|
+
* });
|
|
183
|
+
*
|
|
184
|
+
* type WorkerConfig = UnwrapConfig<typeof config>;
|
|
185
|
+
* // Inferred as: "MyDurableObject" (the deleted tombstone is excluded)
|
|
186
|
+
* type DurableNamespaces = InferDurableNamespaces<WorkerConfig>;
|
|
187
|
+
* ```
|
|
188
|
+
*/
|
|
189
|
+
type InferDurableNamespaces<TUnwrappedConfig> = TUnwrappedConfig extends {
|
|
190
|
+
exports: infer TExports extends Record<string, {
|
|
191
|
+
type: string;
|
|
192
|
+
}>;
|
|
193
|
+
} ? { [K in keyof TExports]: TExports[K] extends {
|
|
174
194
|
type: "durable-object";
|
|
175
|
-
}
|
|
195
|
+
} ? TExports[K] extends {
|
|
196
|
+
state: "deleted" | "renamed" | "transferred";
|
|
197
|
+
} ? never : K & string : never }[keyof TExports] : never;
|
|
176
198
|
/**
|
|
177
|
-
*
|
|
178
|
-
*
|
|
179
|
-
*
|
|
180
|
-
* For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#durable-objects
|
|
199
|
+
* Infer the main module type from a Worker config's entrypoint.
|
|
200
|
+
* If entrypoint is a module namespace object, returns that type.
|
|
201
|
+
* If entrypoint is a `string` or not present, returns `DefaultModule` as a fallback.
|
|
181
202
|
*/
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
}
|
|
188
|
-
interface FlagshipBindingOptions {
|
|
189
|
-
/** The Flagship app ID to bind to. */
|
|
190
|
-
id?: string;
|
|
191
|
-
/** Options that only apply during local development. */
|
|
192
|
-
dev?: BindingDevOptions;
|
|
193
|
-
}
|
|
194
|
-
/** Binding to a Flagship feature-flag service. */
|
|
195
|
-
interface FlagshipBinding extends FlagshipBindingOptions {
|
|
196
|
-
type: "flagship";
|
|
197
|
-
}
|
|
198
|
-
interface HyperdriveBindingOptions {
|
|
199
|
-
/** The ID of the Hyperdrive configuration. */
|
|
200
|
-
id: string;
|
|
201
|
-
/** Options that only apply during local development. */
|
|
202
|
-
dev?: {
|
|
203
|
-
/** The database connection string used during local development. */
|
|
204
|
-
connectionString?: string;
|
|
205
|
-
};
|
|
206
|
-
}
|
|
203
|
+
type InferMainModule<TUnwrappedConfig> = TUnwrappedConfig extends {
|
|
204
|
+
entrypoint: infer TModule extends WorkerModule;
|
|
205
|
+
} ? TModule : DefaultModule;
|
|
206
|
+
//#endregion
|
|
207
|
+
//#region src/utils.d.ts
|
|
207
208
|
/**
|
|
208
|
-
*
|
|
209
|
-
*
|
|
210
|
-
* For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#hyperdrive
|
|
209
|
+
* Represents any valid JSON value.
|
|
211
210
|
*/
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
211
|
+
type Json = string | number | boolean | null | Json[] | {
|
|
212
|
+
[key: string]: Json;
|
|
213
|
+
};
|
|
214
|
+
//#endregion
|
|
215
|
+
//#region src/definition.d.ts
|
|
216
|
+
interface ConfigContext {
|
|
217
|
+
/**
|
|
218
|
+
* The mode the config is being evaluated in.
|
|
219
|
+
* Set via the `--mode` CLI flag.
|
|
220
|
+
* In Vite the mode defaults to `development` in `vite dev` and `production` in `vite build` ([more info](https://vite.dev/guide/env-and-mode.html#modes)).
|
|
221
|
+
* In Wrangler the mode defaults to `undefined`.
|
|
222
|
+
*/
|
|
223
|
+
mode: string | undefined;
|
|
218
224
|
}
|
|
219
225
|
/**
|
|
220
|
-
*
|
|
221
|
-
*
|
|
222
|
-
* For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#images
|
|
226
|
+
* The authored config in any of its supported shapes: a plain value, a promise,
|
|
227
|
+
* or a function of {@link ConfigContext}.
|
|
223
228
|
*/
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
229
|
+
type ConfigInput<T$1> = T$1 | Promise<T$1> | ((ctx: ConfigContext) => T$1 | Promise<T$1>);
|
|
230
|
+
type ConfigObject = Record<string, unknown>;
|
|
231
|
+
type ConfigWithType<T$1 extends ConfigObject, TType extends string> = T$1 & {
|
|
232
|
+
type: TType;
|
|
233
|
+
};
|
|
234
|
+
//#endregion
|
|
235
|
+
//#region src/exports.d.ts
|
|
227
236
|
/**
|
|
228
|
-
*
|
|
229
|
-
*
|
|
237
|
+
* Storage backend for the Durable Object.
|
|
238
|
+
*
|
|
239
|
+
* Containers are only supported on the SQLite storage engine, so `container` is
|
|
240
|
+
* only offered alongside `storage: "sqlite"`.
|
|
230
241
|
*/
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
/**
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
+
type DurableObjectStorageOptions = {
|
|
243
|
+
/**
|
|
244
|
+
* Selects the SQLite-backed storage engine (recommended for new
|
|
245
|
+
* classes).
|
|
246
|
+
*/
|
|
247
|
+
storage: "sqlite";
|
|
248
|
+
/**
|
|
249
|
+
* Attach a container to this Durable Object, by container name. The
|
|
250
|
+
* name must match an entry in the top level `containers` array.
|
|
251
|
+
*/
|
|
252
|
+
container?: string;
|
|
253
|
+
} | {
|
|
254
|
+
/** Selects the legacy key-value storage engine. */
|
|
255
|
+
storage: "legacy-kv";
|
|
256
|
+
};
|
|
242
257
|
/**
|
|
243
|
-
*
|
|
258
|
+
* Declares a provisioned Durable Object class exported from this Worker.
|
|
244
259
|
*
|
|
245
|
-
* For
|
|
260
|
+
* For more information about Durable Objects, see the documentation at
|
|
261
|
+
* https://developers.cloudflare.com/workers/learning/using-durable-objects
|
|
262
|
+
*
|
|
263
|
+
* For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#durable-objects
|
|
246
264
|
*/
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
}
|
|
265
|
+
type DurableObjectCreatedExportOptions = {
|
|
266
|
+
state?: "created";
|
|
267
|
+
} & DurableObjectStorageOptions;
|
|
250
268
|
/**
|
|
251
|
-
*
|
|
269
|
+
* Retire a provisioned Durable Object namespace whose class has
|
|
270
|
+
* been removed from code.
|
|
252
271
|
*
|
|
253
|
-
*
|
|
272
|
+
* During deploy, the class must not be exported in the uploaded code, and no
|
|
273
|
+
* other Worker may hold a `durableObject` binding to the namespace.
|
|
254
274
|
*/
|
|
255
|
-
interface
|
|
256
|
-
|
|
257
|
-
__typeParams: [TKey];
|
|
258
|
-
}
|
|
259
|
-
interface LogfwdrBindingOptions {
|
|
260
|
-
/** The destination for this logged message. */
|
|
261
|
-
destination: string;
|
|
262
|
-
}
|
|
263
|
-
/** Binding for forwarding logs to logfwdr. */
|
|
264
|
-
interface LogfwdrBinding extends LogfwdrBindingOptions {
|
|
265
|
-
type: "logfwdr";
|
|
266
|
-
}
|
|
267
|
-
interface MediaBindingOptions {
|
|
268
|
-
/** Options that only apply during local development. */
|
|
269
|
-
dev?: BindingDevOptions;
|
|
275
|
+
interface DurableObjectDeletedExportOptions {
|
|
276
|
+
state: "deleted";
|
|
270
277
|
}
|
|
271
|
-
/**
|
|
272
|
-
|
|
273
|
-
|
|
278
|
+
/**
|
|
279
|
+
* Rename a provisioned Durable Object namespace's class. The
|
|
280
|
+
* `renamedTo` value must also appear as a live (`state: "created"`)
|
|
281
|
+
* `durableObject` entry in the same `exports` map.
|
|
282
|
+
*/
|
|
283
|
+
interface DurableObjectRenamedExportOptions {
|
|
284
|
+
state: "renamed";
|
|
285
|
+
/**
|
|
286
|
+
* The destination class name. Must be a valid JavaScript identifier and
|
|
287
|
+
* must appear as a live (`state: "created"`) `durableObject` entry in the
|
|
288
|
+
* same `exports` map.
|
|
289
|
+
*/
|
|
290
|
+
renamedTo: string;
|
|
274
291
|
}
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
292
|
+
/**
|
|
293
|
+
* Transfer ownership of a Durable Object namespace to another Worker in the same account.
|
|
294
|
+
* The target Worker must first deploy an `expectingTransfer` entry naming this Worker via `transferFrom`.
|
|
295
|
+
*/
|
|
296
|
+
interface DurableObjectTransferredExportOptions {
|
|
297
|
+
state: "transferred";
|
|
298
|
+
/**
|
|
299
|
+
* The destination Worker. Must reference a Worker in the same account.
|
|
300
|
+
*/
|
|
301
|
+
transferredTo: string;
|
|
280
302
|
}
|
|
281
303
|
/**
|
|
282
|
-
*
|
|
283
|
-
*
|
|
284
|
-
* For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#mtls-certificates
|
|
304
|
+
* Prepare to receive cross-Worker Durable Object transfer.
|
|
305
|
+
* Once the source Worker's `transferred` export is deployed, this entry becomes a normal live `durable-object` export.
|
|
285
306
|
*/
|
|
286
|
-
|
|
287
|
-
|
|
307
|
+
type DurableObjectExpectingTransferExportOptions = {
|
|
308
|
+
state: "expecting-transfer";
|
|
309
|
+
/**
|
|
310
|
+
* The source Worker for the two-phase cross-Worker transfer.
|
|
311
|
+
*/
|
|
312
|
+
transferFrom: string;
|
|
313
|
+
} & DurableObjectStorageOptions;
|
|
314
|
+
type DurableObjectCreatedExport = DurableObjectCreatedExportOptions & {
|
|
315
|
+
type: "durable-object";
|
|
316
|
+
};
|
|
317
|
+
interface DurableObjectDeletedExport extends DurableObjectDeletedExportOptions {
|
|
318
|
+
type: "durable-object";
|
|
288
319
|
}
|
|
289
|
-
interface
|
|
290
|
-
|
|
291
|
-
name: string;
|
|
292
|
-
/** Options that only apply during local development. */
|
|
293
|
-
dev?: BindingDevOptions;
|
|
320
|
+
interface DurableObjectRenamedExport extends DurableObjectRenamedExportOptions {
|
|
321
|
+
type: "durable-object";
|
|
294
322
|
}
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
type: "pipeline";
|
|
323
|
+
interface DurableObjectTransferredExport extends DurableObjectTransferredExportOptions {
|
|
324
|
+
type: "durable-object";
|
|
298
325
|
}
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
326
|
+
type DurableObjectExpectingTransferExport = DurableObjectExpectingTransferExportOptions & {
|
|
327
|
+
type: "durable-object";
|
|
328
|
+
};
|
|
329
|
+
type DurableObjectExportOptions = DurableObjectCreatedExportOptions | DurableObjectDeletedExportOptions | DurableObjectRenamedExportOptions | DurableObjectTransferredExportOptions | DurableObjectExpectingTransferExportOptions;
|
|
330
|
+
type DurableObjectExports = DurableObjectCreatedExport | DurableObjectDeletedExport | DurableObjectRenamedExport | DurableObjectTransferredExport | DurableObjectExpectingTransferExport;
|
|
331
|
+
interface WorkerEntrypointExportOptions {
|
|
332
|
+
cache?: {
|
|
333
|
+
/** Whether cache is enabled for this entrypoint. */
|
|
334
|
+
enabled: boolean;
|
|
335
|
+
};
|
|
303
336
|
}
|
|
304
|
-
interface
|
|
305
|
-
|
|
306
|
-
name?: string;
|
|
307
|
-
/** The number of seconds to wait before delivering a message. */
|
|
308
|
-
deliveryDelay?: number;
|
|
309
|
-
/** Options that only apply during local development. */
|
|
310
|
-
dev?: BindingDevOptions;
|
|
337
|
+
interface WorkerEntrypointExport extends WorkerEntrypointExportOptions {
|
|
338
|
+
type: "worker";
|
|
311
339
|
}
|
|
312
340
|
/**
|
|
313
|
-
*
|
|
314
|
-
*
|
|
315
|
-
* For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#queues
|
|
341
|
+
* Configuration for named exports declared by the Worker. Each entry's
|
|
342
|
+
* key is the exported class name; the value configures the export.
|
|
316
343
|
*/
|
|
317
|
-
interface
|
|
318
|
-
|
|
344
|
+
interface Exports {
|
|
345
|
+
/**
|
|
346
|
+
* Declares a Durable Object class defined by this Worker.
|
|
347
|
+
*
|
|
348
|
+
* For more information about Durable Objects, see the documentation at
|
|
349
|
+
* https://developers.cloudflare.com/workers/learning/using-durable-objects
|
|
350
|
+
*
|
|
351
|
+
* For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#durable-objects
|
|
352
|
+
*/
|
|
353
|
+
durableObject(options: DurableObjectCreatedExportOptions): DurableObjectCreatedExport;
|
|
354
|
+
/**
|
|
355
|
+
* Retire a provisioned Durable Object namespace whose class has been removed from code.
|
|
356
|
+
*/
|
|
357
|
+
durableObject(options: DurableObjectDeletedExportOptions): DurableObjectDeletedExport;
|
|
358
|
+
/**
|
|
359
|
+
* Rename a provisioned Durable Object namespace's class.
|
|
360
|
+
*/
|
|
361
|
+
durableObject(options: DurableObjectRenamedExportOptions): DurableObjectRenamedExport;
|
|
362
|
+
/**
|
|
363
|
+
* Transfer ownership of a Durable Object namespace to another Worker in the same account.
|
|
364
|
+
*/
|
|
365
|
+
durableObject(options: DurableObjectTransferredExportOptions): DurableObjectTransferredExport;
|
|
366
|
+
/**
|
|
367
|
+
* Prepare to receive cross-Worker Durable Object transfer.
|
|
368
|
+
* The source Worker must follow up with a deployment containing a `transferred` export to commit the transfer.
|
|
369
|
+
*/
|
|
370
|
+
durableObject(options: DurableObjectExpectingTransferExportOptions): DurableObjectExpectingTransferExport;
|
|
371
|
+
durableObject(options: DurableObjectExportOptions): DurableObjectExports;
|
|
372
|
+
/** Declares a WorkerEntrypoint export defined by this Worker. */
|
|
373
|
+
worker(options?: WorkerEntrypointExportOptions): WorkerEntrypointExport;
|
|
319
374
|
}
|
|
320
375
|
/**
|
|
321
|
-
*
|
|
376
|
+
* Exports builder for configuring Worker exports.
|
|
322
377
|
*
|
|
323
|
-
*
|
|
378
|
+
* @example
|
|
379
|
+
* ```typescript
|
|
380
|
+
* import { defineWorker, exports } from "@cloudflare/config";
|
|
381
|
+
*
|
|
382
|
+
* export default defineWorker({
|
|
383
|
+
* exports: {
|
|
384
|
+
* MyDurableObject: exports.durableObject({ storage: "sqlite" }),
|
|
385
|
+
* MyContainerDO: exports.durableObject({ storage: "sqlite", container: "my-container" }),
|
|
386
|
+
* OldClass: exports.durableObject({ state: "deleted" }),
|
|
387
|
+
* OldName: exports.durableObject({ state: "renamed", renamedTo: "NewName" }),
|
|
388
|
+
* Outgoing: exports.durableObject({ state: "transferred", transferredTo: "target-worker" }),
|
|
389
|
+
* Incoming: exports.durableObject({ state: "expecting-transfer", storage: "sqlite", transferFrom: "source-worker" }),
|
|
390
|
+
* },
|
|
391
|
+
* });
|
|
392
|
+
* ```
|
|
324
393
|
*/
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
};
|
|
341
|
-
};
|
|
394
|
+
declare const exports: Exports;
|
|
395
|
+
//#endregion
|
|
396
|
+
//#region src/triggers.d.ts
|
|
397
|
+
interface FetchTriggerOptions {
|
|
398
|
+
/**
|
|
399
|
+
* A route that your Worker should be published to.
|
|
400
|
+
*
|
|
401
|
+
* For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#types-of-routes
|
|
402
|
+
*/
|
|
403
|
+
pattern: string;
|
|
404
|
+
/**
|
|
405
|
+
* The DNS zone the pattern is attached to. Required when the
|
|
406
|
+
* pattern is ambiguous.
|
|
407
|
+
*/
|
|
408
|
+
zone?: string;
|
|
342
409
|
}
|
|
343
410
|
/**
|
|
344
|
-
*
|
|
411
|
+
* Fetch trigger — a route that your Worker should be published to.
|
|
345
412
|
*
|
|
346
|
-
* For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#
|
|
413
|
+
* For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#types-of-routes
|
|
347
414
|
*/
|
|
348
|
-
interface
|
|
349
|
-
type: "
|
|
350
|
-
}
|
|
351
|
-
interface RateLimitBindingOptions {
|
|
352
|
-
/** The namespace ID for this rate limiter. */
|
|
353
|
-
namespace: string;
|
|
354
|
-
/** Simple rate limiting configuration. */
|
|
355
|
-
simple: {
|
|
356
|
-
/** The maximum number of requests allowed in the time period. */
|
|
357
|
-
limit: number;
|
|
358
|
-
/** The time period in seconds (10 for ten seconds, 60 for one minute). */
|
|
359
|
-
period: 10 | 60;
|
|
360
|
-
};
|
|
415
|
+
interface FetchTrigger extends FetchTriggerOptions {
|
|
416
|
+
type: "fetch";
|
|
361
417
|
}
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
418
|
+
interface QueueConsumerTriggerOptions {
|
|
419
|
+
/** The name of the queue from which this consumer should consume. */
|
|
420
|
+
name: string;
|
|
421
|
+
/** The queue to send messages that failed to be consumed. */
|
|
422
|
+
deadLetterQueue?: string;
|
|
423
|
+
/** The maximum number of messages per batch. */
|
|
424
|
+
maxBatchSize?: number;
|
|
425
|
+
/** The maximum number of seconds to wait to fill a batch with messages. */
|
|
426
|
+
maxBatchTimeout?: number;
|
|
427
|
+
/**
|
|
428
|
+
* The maximum number of concurrent consumer Worker invocations.
|
|
429
|
+
* Leaving this unset will allow your consumer to scale to the
|
|
430
|
+
* maximum concurrency needed to keep up with the message backlog.
|
|
431
|
+
*/
|
|
432
|
+
maxConcurrency?: number | null;
|
|
433
|
+
/** The maximum number of retries for each message. */
|
|
434
|
+
maxRetries?: number;
|
|
435
|
+
/** The number of seconds to wait before retrying a message. */
|
|
436
|
+
retryDelay?: number;
|
|
437
|
+
/** The number of milliseconds to wait for pulled messages to become visible again. */
|
|
438
|
+
visibilityTimeoutMs?: number;
|
|
365
439
|
}
|
|
366
440
|
/**
|
|
367
|
-
*
|
|
368
|
-
*
|
|
369
|
-
*
|
|
370
|
-
* When defined, this binding:
|
|
371
|
-
* - Replaces .dev.vars/.env/process.env inference for type generation
|
|
372
|
-
* - Enables local dev validation with warnings for missing secrets
|
|
441
|
+
* Queue consumer trigger — invokes this Worker when messages arrive on the
|
|
442
|
+
* named queue.
|
|
373
443
|
*
|
|
374
|
-
* For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#
|
|
444
|
+
* For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#queues
|
|
375
445
|
*/
|
|
376
|
-
interface
|
|
377
|
-
type: "
|
|
378
|
-
}
|
|
379
|
-
interface SecretsStoreSecretBindingOptions {
|
|
380
|
-
/** ID of the secret store. */
|
|
381
|
-
storeId: string;
|
|
382
|
-
/** Name of the secret. */
|
|
383
|
-
secretName: string;
|
|
446
|
+
interface QueueConsumerTrigger extends QueueConsumerTriggerOptions {
|
|
447
|
+
type: "queue";
|
|
384
448
|
}
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
449
|
+
interface ScheduledTriggerOptions {
|
|
450
|
+
/**
|
|
451
|
+
* A "cron" definition to trigger a Worker's "scheduled" function.
|
|
452
|
+
*
|
|
453
|
+
* Lets you call Workers periodically, much like a cron job.
|
|
454
|
+
*
|
|
455
|
+
* More details here https://developers.cloudflare.com/workers/platform/cron-triggers
|
|
456
|
+
*/
|
|
457
|
+
schedule: string;
|
|
388
458
|
}
|
|
389
|
-
type SendEmailDestinationOptions = {
|
|
390
|
-
/** If this binding should be restricted to a specific verified address. */
|
|
391
|
-
destinationAddress: string;
|
|
392
|
-
allowedDestinationAddresses?: never;
|
|
393
|
-
} | {
|
|
394
|
-
destinationAddress?: never;
|
|
395
|
-
/** If this binding should be restricted to a set of verified addresses. */
|
|
396
|
-
allowedDestinationAddresses: string[];
|
|
397
|
-
} | {
|
|
398
|
-
destinationAddress?: never;
|
|
399
|
-
allowedDestinationAddresses?: never;
|
|
400
|
-
};
|
|
401
|
-
type SendEmailBindingOptions = SendEmailDestinationOptions & {
|
|
402
|
-
/** If this binding should be restricted to a set of sender addresses. */
|
|
403
|
-
allowedSenderAddresses?: string[];
|
|
404
|
-
/** Options that only apply during local development. */
|
|
405
|
-
dev?: BindingDevOptions;
|
|
406
|
-
};
|
|
407
459
|
/**
|
|
408
|
-
*
|
|
460
|
+
* Scheduled (cron) trigger — invokes this Worker on the given schedules.
|
|
409
461
|
*
|
|
410
|
-
*
|
|
462
|
+
* More details here https://developers.cloudflare.com/workers/platform/cron-triggers
|
|
411
463
|
*/
|
|
412
|
-
|
|
413
|
-
type: "
|
|
414
|
-
};
|
|
415
|
-
interface StreamBindingOptions {
|
|
416
|
-
/** Options that only apply during local development. */
|
|
417
|
-
dev?: BindingDevOptions;
|
|
464
|
+
interface ScheduledTrigger extends ScheduledTriggerOptions {
|
|
465
|
+
type: "scheduled";
|
|
418
466
|
}
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
467
|
+
interface EmailTriggerOptions {
|
|
468
|
+
/**
|
|
469
|
+
* Inbound Email Routing addresses handled by this Worker.
|
|
470
|
+
*
|
|
471
|
+
* Each entry is a literal recipient address (e.g. `"support@example.com"`)
|
|
472
|
+
* or a `*@domain` catch-all (e.g. `"*@example.com"`).
|
|
473
|
+
*/
|
|
474
|
+
addresses: string[];
|
|
422
475
|
}
|
|
423
476
|
/**
|
|
424
|
-
*
|
|
425
|
-
*
|
|
426
|
-
*
|
|
427
|
-
* For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#environment-variables
|
|
477
|
+
* Email trigger — invokes this Worker for the configured Email Routing
|
|
478
|
+
* addresses.
|
|
428
479
|
*/
|
|
429
|
-
interface
|
|
430
|
-
type: "
|
|
431
|
-
/** The string value made available to the Worker. */
|
|
432
|
-
value: T$1;
|
|
480
|
+
interface EmailTrigger extends EmailTriggerOptions {
|
|
481
|
+
type: "email";
|
|
433
482
|
}
|
|
434
|
-
interface
|
|
435
|
-
/**
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
};
|
|
442
|
-
/** Plugin-specific options. */
|
|
443
|
-
options?: Record<string, unknown>;
|
|
444
|
-
};
|
|
445
|
-
[key: string]: unknown;
|
|
483
|
+
interface ConnectTriggerOptions {
|
|
484
|
+
/** The transport protocol to listen for. */
|
|
485
|
+
protocol: "tcp";
|
|
486
|
+
/** The port to listen on. */
|
|
487
|
+
port: number;
|
|
488
|
+
/** The address to bind to. Defaults to `127.0.0.1`. */
|
|
489
|
+
address?: string;
|
|
446
490
|
}
|
|
447
491
|
/**
|
|
448
|
-
*
|
|
449
|
-
*
|
|
450
|
-
*
|
|
492
|
+
* Connect trigger — invokes this Worker's `connect(socket, env, ctx)`
|
|
493
|
+
* handler for raw socket connections received on the configured
|
|
494
|
+
* protocol/port.
|
|
451
495
|
*/
|
|
452
|
-
interface
|
|
453
|
-
type:
|
|
454
|
-
}
|
|
455
|
-
interface VectorizeBindingOptions {
|
|
456
|
-
/** The name of the Vectorize index. */
|
|
457
|
-
name: string;
|
|
458
|
-
/** Options that only apply during local development. */
|
|
459
|
-
dev?: BindingDevOptions;
|
|
496
|
+
interface ConnectTrigger extends ConnectTriggerOptions {
|
|
497
|
+
type: "connect";
|
|
460
498
|
}
|
|
461
499
|
/**
|
|
462
|
-
*
|
|
500
|
+
* Event triggers — fetch routes, queue consumers, cron schedules, Email
|
|
501
|
+
* Routing addresses, and raw sockets — that invoke this Worker.
|
|
502
|
+
* Construct entries with `triggers.fetch(...)`, `triggers.queue(...)`,
|
|
503
|
+
* `triggers.scheduled(...)`, `triggers.email(...)`, or `triggers.connect(...)`.
|
|
463
504
|
*
|
|
464
|
-
* For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#
|
|
505
|
+
* For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#triggers
|
|
465
506
|
*/
|
|
466
|
-
interface
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
/**
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
/**
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
interface VpcServiceBinding extends VpcServiceBindingOptions {
|
|
498
|
-
type: "vpc-service";
|
|
499
|
-
}
|
|
500
|
-
interface WebSearchBindingOptions {
|
|
501
|
-
/** Options that only apply during local development. */
|
|
502
|
-
dev?: BindingDevOptions;
|
|
507
|
+
interface Triggers {
|
|
508
|
+
/**
|
|
509
|
+
* Fetch trigger — a route that your Worker should be published to.
|
|
510
|
+
*
|
|
511
|
+
* For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#types-of-routes
|
|
512
|
+
*/
|
|
513
|
+
fetch(options: FetchTriggerOptions): FetchTrigger;
|
|
514
|
+
/**
|
|
515
|
+
* Queue consumer trigger — invokes this Worker when messages arrive on the
|
|
516
|
+
* named queue.
|
|
517
|
+
*
|
|
518
|
+
* For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#queues
|
|
519
|
+
*/
|
|
520
|
+
queue(options: QueueConsumerTriggerOptions): QueueConsumerTrigger;
|
|
521
|
+
/**
|
|
522
|
+
* Scheduled (cron) trigger — invokes this Worker on the given schedules.
|
|
523
|
+
*
|
|
524
|
+
* More details here https://developers.cloudflare.com/workers/platform/cron-triggers
|
|
525
|
+
*/
|
|
526
|
+
scheduled(options: ScheduledTriggerOptions): ScheduledTrigger;
|
|
527
|
+
/**
|
|
528
|
+
* Email trigger — invokes this Worker for the configured Email Routing
|
|
529
|
+
* addresses.
|
|
530
|
+
*/
|
|
531
|
+
email(options: EmailTriggerOptions): EmailTrigger;
|
|
532
|
+
/**
|
|
533
|
+
* Connect trigger — invokes this Worker's `connect(socket, env, ctx)`
|
|
534
|
+
* handler for raw socket connections received on the configured
|
|
535
|
+
* protocol/port.
|
|
536
|
+
*/
|
|
537
|
+
connect(options: ConnectTriggerOptions): ConnectTrigger;
|
|
503
538
|
}
|
|
504
539
|
/**
|
|
505
|
-
*
|
|
506
|
-
*
|
|
540
|
+
* Triggers builder for configuring event triggers.
|
|
541
|
+
*
|
|
542
|
+
* @example
|
|
543
|
+
* ```typescript
|
|
544
|
+
* import { defineWorker, triggers } from "@cloudflare/config";
|
|
545
|
+
*
|
|
546
|
+
* export default defineWorker({
|
|
547
|
+
* triggers: [
|
|
548
|
+
* triggers.fetch({ pattern: "example.com/*", zone: "example.com" }),
|
|
549
|
+
* triggers.queue({ name: "my-queue" }),
|
|
550
|
+
* triggers.scheduled({ schedule: "0 * * * *" }),
|
|
551
|
+
* triggers.scheduled({ schedule: "30 0 * * *" }),
|
|
552
|
+
* triggers.email({ addresses: ["support@example.com"] }),
|
|
553
|
+
* triggers.connect({ protocol: "tcp", port: 5432 }),
|
|
554
|
+
* ],
|
|
555
|
+
* });
|
|
556
|
+
* ```
|
|
507
557
|
*/
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
interface WorkerBindingOptions {
|
|
512
|
-
/** The name of the bound Worker. */
|
|
513
|
-
worker: string;
|
|
514
|
-
/** The named export to bind to (defaults to the default export). */
|
|
515
|
-
exportName?: string;
|
|
516
|
-
/** Optional properties that will be made available to the service via `ctx.props`. */
|
|
517
|
-
props?: Record<string, unknown>;
|
|
518
|
-
/** Options that only apply during local development. */
|
|
519
|
-
dev?: BindingDevOptions;
|
|
520
|
-
}
|
|
558
|
+
declare const triggers: Triggers;
|
|
559
|
+
//#endregion
|
|
560
|
+
//#region src/types.d.ts
|
|
521
561
|
/**
|
|
522
|
-
*
|
|
523
|
-
* Worker; `exportName` selects a named `WorkerEntrypoint` export (defaults to
|
|
524
|
-
* the default export).
|
|
525
|
-
*
|
|
526
|
-
* For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#service-bindings
|
|
562
|
+
* Union of all binding definitions accepted in `env`.
|
|
527
563
|
*/
|
|
528
|
-
|
|
529
|
-
type: "worker";
|
|
530
|
-
}
|
|
564
|
+
type Binding = AgentMemoryBinding | AiBinding | AiSearchBinding | AiSearchNamespaceBinding | AnalyticsEngineDatasetBinding | ArtifactsBinding | AssetsBinding | BrowserBinding | D1Binding | DispatchNamespaceBinding | DurableObjectBinding | FlagshipBinding | HyperdriveBinding | ImagesBinding$1 | JsonBinding | KvBinding | LogfwdrBinding | MediaBinding$1 | MtlsCertificateBinding | PipelineBinding | QueueBinding | R2Binding | RateLimitBinding | SecretBinding | SecretsStoreSecretBinding | SendEmailBinding | StreamBinding$1 | TextBinding | UnsafeBinding | VectorizeBinding | VersionMetadataBinding | VpcNetworkBinding | VpcServiceBinding | WebSearchBinding | WorkerBinding | WorkerLoaderBinding;
|
|
531
565
|
/**
|
|
532
|
-
*
|
|
533
|
-
* Worker; `exportName` selects a named `WorkerEntrypoint` export (defaults to
|
|
534
|
-
* the default export).
|
|
535
|
-
*
|
|
536
|
-
* For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#service-bindings
|
|
566
|
+
* Union of all trigger definitions accepted in `triggers`.
|
|
537
567
|
*/
|
|
538
|
-
|
|
539
|
-
worker: string;
|
|
540
|
-
exportName: TExportName$1;
|
|
541
|
-
/** @internal Carries the config type for inference */
|
|
542
|
-
__config: TConfig$1;
|
|
543
|
-
}
|
|
544
|
-
/** Binding to a Worker Loader. */
|
|
545
|
-
interface WorkerLoaderBinding {
|
|
546
|
-
type: "worker-loader";
|
|
547
|
-
}
|
|
548
|
-
interface WorkflowBindingOptions {
|
|
549
|
-
/** The name of the Worker that defines the Workflow. */
|
|
550
|
-
worker: string;
|
|
551
|
-
/** The exported class name of the Workflow. */
|
|
552
|
-
exportName: string;
|
|
553
|
-
}
|
|
568
|
+
type Trigger = ConnectTrigger | EmailTrigger | FetchTrigger | QueueConsumerTrigger | ScheduledTrigger;
|
|
554
569
|
/**
|
|
555
|
-
*
|
|
556
|
-
*
|
|
570
|
+
* Union of all export definitions accepted in `exports`. Worker entries
|
|
571
|
+
* configure WorkerEntrypoint exports. Durable Object entries configure live
|
|
572
|
+
* classes and tombstone lifecycle operations.
|
|
557
573
|
*/
|
|
558
|
-
|
|
559
|
-
type: "workflow";
|
|
560
|
-
}
|
|
574
|
+
type Export = DurableObjectCreatedExport | DurableObjectDeletedExport | DurableObjectRenamedExport | DurableObjectTransferredExport | DurableObjectExpectingTransferExport | WorkerEntrypointExport;
|
|
561
575
|
/**
|
|
562
|
-
*
|
|
563
|
-
*
|
|
576
|
+
* Worker configuration. This is the input shape passed to
|
|
577
|
+
* [`defineWorker`](https://developers.cloudflare.com/workers/wrangler/configuration/).
|
|
578
|
+
*
|
|
579
|
+
* Fields are validated at runtime by `InputWorkerSchema` and normalised before
|
|
580
|
+
* being passed to downstream tooling.
|
|
564
581
|
*/
|
|
565
|
-
interface
|
|
566
|
-
worker: string;
|
|
567
|
-
exportName: TExportName$1;
|
|
568
|
-
/** @internal Carries the config type for inference */
|
|
569
|
-
__config: TConfig$1;
|
|
570
|
-
}
|
|
571
|
-
interface Bindings {
|
|
572
|
-
/**
|
|
573
|
-
* Agent Memory namespace binding. Each binding is scoped to a namespace and
|
|
574
|
-
* allows agents to persist and recall memory.
|
|
575
|
-
*/
|
|
576
|
-
agentMemory(options: AgentMemoryBindingOptions): AgentMemoryBinding;
|
|
582
|
+
interface WorkerConfig {
|
|
577
583
|
/**
|
|
578
|
-
*
|
|
584
|
+
* Discriminates this config as a Worker config.
|
|
579
585
|
*
|
|
580
|
-
*
|
|
586
|
+
* Injected automatically by `defineWorker`; only needs to be written by
|
|
587
|
+
* hand when authoring a raw config object without the helper.
|
|
581
588
|
*/
|
|
582
|
-
|
|
589
|
+
type: "worker";
|
|
583
590
|
/**
|
|
584
|
-
*
|
|
585
|
-
* pre-existing instance within the "default" namespace.
|
|
591
|
+
* The name of your Worker.
|
|
586
592
|
*/
|
|
587
|
-
|
|
593
|
+
name: string;
|
|
588
594
|
/**
|
|
589
|
-
*
|
|
590
|
-
*
|
|
595
|
+
* A date in the form yyyy-mm-dd, which will be used to determine
|
|
596
|
+
* which version of the Workers runtime is used.
|
|
597
|
+
*
|
|
598
|
+
* More details at https://developers.cloudflare.com/workers/configuration/compatibility-dates
|
|
591
599
|
*/
|
|
592
|
-
|
|
600
|
+
compatibilityDate: string;
|
|
593
601
|
/**
|
|
594
|
-
*
|
|
602
|
+
* A list of flags that enable features from upcoming features of
|
|
603
|
+
* the Workers runtime, usually used together with `compatibilityDate`.
|
|
595
604
|
*
|
|
596
|
-
*
|
|
605
|
+
* More details at https://developers.cloudflare.com/workers/configuration/compatibility-flags/
|
|
606
|
+
*
|
|
607
|
+
* @default []
|
|
597
608
|
*/
|
|
598
|
-
|
|
609
|
+
compatibilityFlags?: string[];
|
|
599
610
|
/**
|
|
600
|
-
*
|
|
601
|
-
*
|
|
611
|
+
* The entrypoint module that will be executed.
|
|
612
|
+
*
|
|
613
|
+
* May be either a path string (e.g. `"./src/index.ts"`) or a module
|
|
614
|
+
* namespace imported with the `cf-worker` import attribute.
|
|
615
|
+
*
|
|
616
|
+
* @example
|
|
617
|
+
* ```ts
|
|
618
|
+
* import * as entrypoint from "./src" with { type: "cf-worker" };
|
|
619
|
+
* export default defineWorker({ entrypoint });
|
|
620
|
+
* ```
|
|
602
621
|
*/
|
|
603
|
-
|
|
622
|
+
entrypoint?: string | WorkerModule;
|
|
604
623
|
/**
|
|
605
|
-
*
|
|
624
|
+
* Specify the directory of static assets to deploy/serve.
|
|
625
|
+
*
|
|
626
|
+
* More details at https://developers.cloudflare.com/workers/frameworks/
|
|
606
627
|
*
|
|
607
628
|
* For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#assets
|
|
608
629
|
*/
|
|
609
|
-
assets
|
|
630
|
+
assets?: {
|
|
631
|
+
/** How to handle HTML requests. */
|
|
632
|
+
htmlHandling?: "auto-trailing-slash" | "drop-trailing-slash" | "force-trailing-slash" | "none";
|
|
633
|
+
/** How to handle requests that do not match an asset. */
|
|
634
|
+
notFoundHandling?: "single-page-application" | "404-page" | "none";
|
|
635
|
+
/**
|
|
636
|
+
* Matches will be routed to the User Worker, and matches to negative rules will go to the Asset Worker.
|
|
637
|
+
*
|
|
638
|
+
* Can also be `true`, indicating that every request should be routed to the User Worker.
|
|
639
|
+
*/
|
|
640
|
+
runWorkerFirst?: string[] | boolean;
|
|
641
|
+
};
|
|
610
642
|
/**
|
|
611
|
-
*
|
|
643
|
+
* Custom domains that your Worker should be published to.
|
|
612
644
|
*
|
|
613
|
-
* For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#
|
|
645
|
+
* For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#types-of-routes
|
|
614
646
|
*/
|
|
615
|
-
|
|
647
|
+
domains?: string[];
|
|
616
648
|
/**
|
|
617
|
-
*
|
|
649
|
+
* Event triggers — fetch routes, queue consumers, cron schedules, Email
|
|
650
|
+
* Routing addresses, and raw sockets — that invoke this Worker.
|
|
651
|
+
* Construct entries with `triggers.fetch(...)`, `triggers.queue(...)`,
|
|
652
|
+
* `triggers.scheduled(...)`, `triggers.email(...)`, or
|
|
653
|
+
* `triggers.connect(...)`.
|
|
618
654
|
*
|
|
619
|
-
* For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#
|
|
655
|
+
* For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#triggers
|
|
620
656
|
*/
|
|
621
|
-
|
|
657
|
+
triggers?: Trigger[];
|
|
622
658
|
/**
|
|
623
|
-
*
|
|
659
|
+
* A list of Tail Workers that are bound to this Worker.
|
|
624
660
|
*
|
|
625
|
-
*
|
|
661
|
+
* `@cloudflare/config` unifies regular and streaming tail consumers under
|
|
662
|
+
* a single field; pass `streaming: true` to forward streaming tail events.
|
|
663
|
+
*
|
|
664
|
+
* @default []
|
|
626
665
|
*/
|
|
627
|
-
|
|
666
|
+
tailConsumers?: Array<{
|
|
667
|
+
/** The name of the service tail events will be forwarded to. */
|
|
668
|
+
worker: string;
|
|
669
|
+
/** Whether to stream tail events in real time. */
|
|
670
|
+
streaming?: boolean;
|
|
671
|
+
}>;
|
|
628
672
|
/**
|
|
629
|
-
*
|
|
630
|
-
* that defines the class; `exportName` is the exported class name.
|
|
631
|
-
*
|
|
632
|
-
* For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#durable-objects
|
|
673
|
+
* Specify the cache behavior of the Worker.
|
|
633
674
|
*/
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
675
|
+
cache?: {
|
|
676
|
+
/** If cache is enabled for this Worker. */
|
|
677
|
+
enabled: boolean;
|
|
678
|
+
/** Whether cached assets may be reused across Worker versions. */
|
|
679
|
+
crossVersionCache?: boolean;
|
|
680
|
+
};
|
|
637
681
|
/**
|
|
638
|
-
*
|
|
682
|
+
* Specify how the Worker should be located to minimize round-trip time.
|
|
639
683
|
*
|
|
640
|
-
*
|
|
684
|
+
* More details: https://developers.cloudflare.com/workers/platform/smart-placement/
|
|
641
685
|
*/
|
|
642
|
-
|
|
686
|
+
placement?: {
|
|
687
|
+
mode: "off" | "smart";
|
|
688
|
+
hint?: string;
|
|
689
|
+
} | {
|
|
690
|
+
mode?: "targeted";
|
|
691
|
+
region: string;
|
|
692
|
+
} | {
|
|
693
|
+
mode?: "targeted";
|
|
694
|
+
host: string;
|
|
695
|
+
} | {
|
|
696
|
+
mode?: "targeted";
|
|
697
|
+
hostname: string;
|
|
698
|
+
};
|
|
643
699
|
/**
|
|
644
|
-
*
|
|
700
|
+
* Specify limits for runtime behavior.
|
|
701
|
+
* Only supported for the "standard" Usage Model.
|
|
645
702
|
*
|
|
646
|
-
* For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#
|
|
703
|
+
* For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#limits
|
|
647
704
|
*/
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
/**
|
|
655
|
-
* Binding to a Workers KV namespace.
|
|
656
|
-
*
|
|
657
|
-
* For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#kv-namespaces
|
|
658
|
-
*/
|
|
659
|
-
kv<TKey extends string = string>(options?: KvBindingOptions): TypedKvBinding<TKey>;
|
|
660
|
-
/** Binding for forwarding logs to logfwdr. */
|
|
661
|
-
logfwdr(options: LogfwdrBindingOptions): LogfwdrBinding;
|
|
662
|
-
/** Binding to Cloudflare Media Transformations. */
|
|
663
|
-
media(options?: MediaBindingOptions): MediaBinding$1;
|
|
705
|
+
limits?: {
|
|
706
|
+
/** Maximum allowed CPU time for a Worker's invocation in milliseconds. */
|
|
707
|
+
cpuMs?: number;
|
|
708
|
+
/** Maximum allowed number of fetch requests that a Worker's invocation can execute. */
|
|
709
|
+
subrequests?: number;
|
|
710
|
+
};
|
|
664
711
|
/**
|
|
665
|
-
*
|
|
712
|
+
* Send Trace Events from this Worker to Workers Logpush.
|
|
666
713
|
*
|
|
667
|
-
*
|
|
668
|
-
*/
|
|
669
|
-
mtlsCertificate(options: MtlsCertificateBindingOptions): MtlsCertificateBinding;
|
|
670
|
-
/** Binding to a Cloudflare Pipeline. */
|
|
671
|
-
pipeline<TRecord extends PipelineRecord = PipelineRecord>(options: PipelineBindingOptions): TypedPipelineBinding<TRecord>;
|
|
672
|
-
/**
|
|
673
|
-
* Producer binding to a Cloudflare Queue.
|
|
714
|
+
* This will not configure a corresponding Logpush job automatically.
|
|
674
715
|
*
|
|
675
|
-
* For
|
|
716
|
+
* For more information about Workers Logpush, see:
|
|
717
|
+
* https://blog.cloudflare.com/logpush-for-workers/
|
|
676
718
|
*/
|
|
677
|
-
|
|
719
|
+
logpush?: boolean;
|
|
678
720
|
/**
|
|
679
|
-
*
|
|
721
|
+
* Specify the observability behavior of the Worker.
|
|
680
722
|
*
|
|
681
|
-
* For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#
|
|
723
|
+
* For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#observability
|
|
682
724
|
*/
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
725
|
+
observability?: {
|
|
726
|
+
/** If observability is enabled for this Worker. */
|
|
727
|
+
enabled?: boolean;
|
|
728
|
+
/** The sampling rate. */
|
|
729
|
+
headSamplingRate?: number;
|
|
730
|
+
/**
|
|
731
|
+
* Whether query strings are removed from request URLs in logs and traces.
|
|
732
|
+
*
|
|
733
|
+
* @default false
|
|
734
|
+
*/
|
|
735
|
+
redactQueryString?: boolean;
|
|
736
|
+
logs?: {
|
|
737
|
+
enabled?: boolean;
|
|
738
|
+
/** The sampling rate. */
|
|
739
|
+
headSamplingRate?: number;
|
|
740
|
+
/** Set to false to disable invocation logs. */
|
|
741
|
+
invocationLogs?: boolean;
|
|
742
|
+
/**
|
|
743
|
+
* If logs should be persisted to the Cloudflare observability platform where they can be queried in the dashboard.
|
|
744
|
+
*
|
|
745
|
+
* @default true
|
|
746
|
+
*/
|
|
747
|
+
persist?: boolean;
|
|
748
|
+
/**
|
|
749
|
+
* What destinations logs emitted from the Worker should be sent to.
|
|
750
|
+
*
|
|
751
|
+
* @default []
|
|
752
|
+
*/
|
|
753
|
+
destinations?: string[];
|
|
754
|
+
};
|
|
755
|
+
traces?: {
|
|
756
|
+
enabled?: boolean;
|
|
757
|
+
/** The sampling rate. */
|
|
758
|
+
headSamplingRate?: number;
|
|
759
|
+
/**
|
|
760
|
+
* If traces should be persisted to the Cloudflare observability platform where they can be queried in the dashboard.
|
|
761
|
+
*
|
|
762
|
+
* @default true
|
|
763
|
+
*/
|
|
764
|
+
persist?: boolean;
|
|
765
|
+
/**
|
|
766
|
+
* What destinations traces emitted from the Worker should be sent to.
|
|
767
|
+
*
|
|
768
|
+
* @default []
|
|
769
|
+
*/
|
|
770
|
+
destinations?: string[];
|
|
771
|
+
};
|
|
772
|
+
};
|
|
686
773
|
/**
|
|
687
|
-
*
|
|
688
|
-
*
|
|
774
|
+
* Whether we use `<name>.<subdomain>.workers.dev` to
|
|
775
|
+
* test and deploy your Worker.
|
|
689
776
|
*
|
|
690
|
-
*
|
|
691
|
-
* - Replaces .dev.vars/.env/process.env inference for type generation
|
|
692
|
-
* - Enables local dev validation with warnings for missing secrets
|
|
777
|
+
* For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#workersdev
|
|
693
778
|
*
|
|
694
|
-
*
|
|
779
|
+
* @default true
|
|
695
780
|
*/
|
|
696
|
-
|
|
697
|
-
/** Binding to a Secrets Store secret. */
|
|
698
|
-
secretsStoreSecret(options: SecretsStoreSecretBindingOptions): SecretsStoreSecretBinding;
|
|
781
|
+
workersDev?: boolean;
|
|
699
782
|
/**
|
|
700
|
-
*
|
|
783
|
+
* Whether we use `<version>-<name>.<subdomain>.workers.dev` to
|
|
784
|
+
* serve Preview URLs for your Worker.
|
|
701
785
|
*
|
|
702
|
-
*
|
|
786
|
+
* @default false
|
|
703
787
|
*/
|
|
704
|
-
|
|
705
|
-
/** Binding to Cloudflare Stream. */
|
|
706
|
-
stream(options?: StreamBindingOptions): StreamBinding$1;
|
|
788
|
+
previewUrls?: boolean;
|
|
707
789
|
/**
|
|
708
|
-
*
|
|
709
|
-
* binding name.
|
|
790
|
+
* Designates this Worker as an internal-only "first-party" Worker.
|
|
710
791
|
*
|
|
711
|
-
*
|
|
792
|
+
* @internal
|
|
712
793
|
*/
|
|
713
|
-
|
|
794
|
+
firstPartyWorker?: boolean;
|
|
714
795
|
/**
|
|
715
|
-
*
|
|
796
|
+
* "Unsafe" tables for runtime features that aren't directly supported by
|
|
797
|
+
* this configuration. Values are forwarded verbatim in the Worker's
|
|
798
|
+
* upload metadata.
|
|
716
799
|
*
|
|
717
|
-
*
|
|
800
|
+
* @default {}
|
|
718
801
|
*/
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
802
|
+
unsafe?: {
|
|
803
|
+
/**
|
|
804
|
+
* Arbitrary key/value pairs that will be included in the uploaded metadata. Values specified
|
|
805
|
+
* here will always be applied to metadata last, so can add new or override existing fields.
|
|
806
|
+
*/
|
|
807
|
+
metadata?: Record<string, unknown>;
|
|
808
|
+
/**
|
|
809
|
+
* Used for internal capnp uploads for the Workers runtime.
|
|
810
|
+
*/
|
|
811
|
+
capnp?: {
|
|
812
|
+
basePath: string;
|
|
813
|
+
sourceSchemas: string[];
|
|
814
|
+
compiledSchema?: never;
|
|
815
|
+
} | {
|
|
816
|
+
basePath?: never;
|
|
817
|
+
sourceSchemas?: never;
|
|
818
|
+
compiledSchema: string;
|
|
819
|
+
};
|
|
820
|
+
};
|
|
726
821
|
/**
|
|
727
|
-
*
|
|
728
|
-
*
|
|
822
|
+
* Bindings exposed on the Worker's `env` object. Construct entries with
|
|
823
|
+
* `bindings.kv(...)`, `bindings.r2(...)`, etc.
|
|
729
824
|
*/
|
|
730
|
-
|
|
825
|
+
env?: Record<string, Binding>;
|
|
731
826
|
/**
|
|
732
|
-
*
|
|
733
|
-
*
|
|
734
|
-
* the default export).
|
|
827
|
+
* Configuration for named exports declared by the Worker. Each entry's
|
|
828
|
+
* key is the exported class name; the value configures the export.
|
|
735
829
|
*
|
|
736
|
-
*
|
|
830
|
+
* Only one export kind is currently supported:
|
|
831
|
+
*
|
|
832
|
+
* - Construct entries with `exports.durableObject(...)`.
|
|
833
|
+
* - Declares Durable Object classes exported from this Worker.
|
|
834
|
+
* For more information about Durable Objects, see the documentation at
|
|
835
|
+
* https://developers.cloudflare.com/workers/learning/using-durable-objects.
|
|
836
|
+
* For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#durable-objects.
|
|
737
837
|
*/
|
|
738
|
-
|
|
739
|
-
/** Binding to a Worker Loader. */
|
|
740
|
-
workerLoader(): WorkerLoaderBinding;
|
|
838
|
+
exports?: Record<string, Export>;
|
|
741
839
|
}
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
840
|
+
/**
|
|
841
|
+
* Settings shared by the other exports.
|
|
842
|
+
* Authored as a named `settings` export via
|
|
843
|
+
* `defineSettings`.
|
|
844
|
+
*/
|
|
845
|
+
interface SettingsConfig {
|
|
746
846
|
/**
|
|
747
|
-
*
|
|
847
|
+
* Discriminates this config as a settings config.
|
|
748
848
|
*
|
|
749
|
-
*
|
|
849
|
+
* Injected automatically by `defineSettings`; only needs to be written by
|
|
850
|
+
* hand when authoring a raw config object without the helper.
|
|
750
851
|
*/
|
|
751
|
-
|
|
852
|
+
type: "settings";
|
|
752
853
|
/**
|
|
753
|
-
*
|
|
754
|
-
*
|
|
854
|
+
* This is the ID of the account associated with your zone.
|
|
855
|
+
* You might have more than one account, so make sure to use
|
|
856
|
+
* the ID of the account associated with the zone/route you
|
|
857
|
+
* provide, if you provide one. It can also be specified through
|
|
858
|
+
* the CLOUDFLARE_ACCOUNT_ID environment variable.
|
|
755
859
|
*/
|
|
756
|
-
|
|
860
|
+
accountId?: string;
|
|
861
|
+
/**
|
|
862
|
+
* Specify the compliance region mode of the Worker.
|
|
863
|
+
*
|
|
864
|
+
* Although if the user does not specify a compliance region, the default is `public`,
|
|
865
|
+
* it can be set to `undefined` in configuration to delegate to the CLOUDFLARE_COMPLIANCE_REGION environment variable.
|
|
866
|
+
*/
|
|
867
|
+
complianceRegion?: "public" | "fedramp-high";
|
|
757
868
|
}
|
|
869
|
+
//#endregion
|
|
870
|
+
//#region src/worker-definition.d.ts
|
|
871
|
+
type WorkerConfigExport<T$1 extends WorkerConfig = WorkerConfig> = ConfigInput<T$1>;
|
|
758
872
|
/**
|
|
759
|
-
*
|
|
760
|
-
*
|
|
761
|
-
* For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#types-of-routes
|
|
873
|
+
* Authored Worker config shape — {@link WorkerConfig} without the `type`
|
|
874
|
+
* discriminant, which `defineWorker` injects.
|
|
762
875
|
*/
|
|
763
|
-
|
|
764
|
-
|
|
876
|
+
type WorkerConfigInput = Omit<WorkerConfig, "type">;
|
|
877
|
+
declare const defineWorker: <const TInput extends ConfigInput<WorkerConfigInput>>(config: TInput) => TInput extends ((ctx: ConfigContext) => infer TResult) ? (ctx: ConfigContext) => TResult extends Promise<infer TConfig extends {
|
|
878
|
+
[x: string]: unknown;
|
|
879
|
+
}> ? Promise<ConfigWithType<TConfig, "worker">> : TResult extends {
|
|
880
|
+
[x: string]: unknown;
|
|
881
|
+
} ? ConfigWithType<TResult, "worker"> : never : TInput extends Promise<infer TConfig extends {
|
|
882
|
+
[x: string]: unknown;
|
|
883
|
+
}> ? Promise<ConfigWithType<TConfig, "worker">> : TInput extends {
|
|
884
|
+
[x: string]: unknown;
|
|
885
|
+
} ? ConfigWithType<TInput, "worker"> : never;
|
|
886
|
+
//#endregion
|
|
887
|
+
//#region src/bindings.d.ts
|
|
888
|
+
/** Options that control a binding during local development. */
|
|
889
|
+
interface BindingDevOptions {
|
|
890
|
+
/** Whether the binding should connect to the remote resource. */
|
|
891
|
+
remote?: boolean;
|
|
765
892
|
}
|
|
766
|
-
interface
|
|
767
|
-
/** The
|
|
768
|
-
|
|
769
|
-
/**
|
|
770
|
-
|
|
771
|
-
/** The maximum number of messages per batch. */
|
|
772
|
-
maxBatchSize?: number;
|
|
773
|
-
/** The maximum number of seconds to wait to fill a batch with messages. */
|
|
774
|
-
maxBatchTimeout?: number;
|
|
775
|
-
/**
|
|
776
|
-
* The maximum number of concurrent consumer Worker invocations.
|
|
777
|
-
* Leaving this unset will allow your consumer to scale to the
|
|
778
|
-
* maximum concurrency needed to keep up with the message backlog.
|
|
779
|
-
*/
|
|
780
|
-
maxConcurrency?: number | null;
|
|
781
|
-
/** The maximum number of retries for each message. */
|
|
782
|
-
maxRetries?: number;
|
|
783
|
-
/** The number of seconds to wait before retrying a message. */
|
|
784
|
-
retryDelay?: number;
|
|
785
|
-
/** The number of milliseconds to wait for pulled messages to become visible again. */
|
|
786
|
-
visibilityTimeoutMs?: number;
|
|
893
|
+
interface AgentMemoryBindingOptions {
|
|
894
|
+
/** The user-chosen namespace name. Must exist in Cloudflare at deploy time. */
|
|
895
|
+
namespace: string;
|
|
896
|
+
/** Options that only apply during local development. */
|
|
897
|
+
dev?: BindingDevOptions;
|
|
787
898
|
}
|
|
788
899
|
/**
|
|
789
|
-
*
|
|
790
|
-
*
|
|
791
|
-
*
|
|
792
|
-
* For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#queues
|
|
900
|
+
* Agent Memory namespace binding. Each binding is scoped to a namespace and
|
|
901
|
+
* allows agents to persist and recall memory.
|
|
793
902
|
*/
|
|
794
|
-
interface
|
|
795
|
-
type: "
|
|
903
|
+
interface AgentMemoryBinding extends AgentMemoryBindingOptions {
|
|
904
|
+
type: "agent-memory";
|
|
796
905
|
}
|
|
797
|
-
interface
|
|
798
|
-
/**
|
|
799
|
-
|
|
800
|
-
*
|
|
801
|
-
* Lets you call Workers periodically, much like a cron job.
|
|
802
|
-
*
|
|
803
|
-
* More details here https://developers.cloudflare.com/workers/platform/cron-triggers
|
|
804
|
-
*/
|
|
805
|
-
schedule: string;
|
|
906
|
+
interface AiBindingOptions {
|
|
907
|
+
/** Options that only apply during local development. */
|
|
908
|
+
dev?: BindingDevOptions;
|
|
806
909
|
}
|
|
807
910
|
/**
|
|
808
|
-
*
|
|
911
|
+
* Binding to the Workers AI project.
|
|
809
912
|
*
|
|
810
|
-
*
|
|
913
|
+
* For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#workers-ai
|
|
811
914
|
*/
|
|
812
|
-
interface
|
|
813
|
-
type: "
|
|
814
|
-
}
|
|
815
|
-
interface EmailTriggerOptions {
|
|
816
|
-
/**
|
|
817
|
-
* Inbound Email Routing addresses handled by this Worker.
|
|
818
|
-
*
|
|
819
|
-
* Each entry is a literal recipient address (e.g. `"support@example.com"`)
|
|
820
|
-
* or a `*@domain` catch-all (e.g. `"*@example.com"`).
|
|
821
|
-
*/
|
|
822
|
-
addresses: string[];
|
|
915
|
+
interface AiBinding extends AiBindingOptions {
|
|
916
|
+
type: "ai";
|
|
823
917
|
}
|
|
824
918
|
/**
|
|
825
|
-
*
|
|
826
|
-
*
|
|
919
|
+
* Binding to the Workers AI project.
|
|
920
|
+
*
|
|
921
|
+
* For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#workers-ai
|
|
827
922
|
*/
|
|
828
|
-
interface
|
|
829
|
-
type
|
|
923
|
+
interface TypedAiBinding<TAiModelList extends AiModelListType = AiModels> extends AiBinding {
|
|
924
|
+
/** @internal Carries type parameters for inference */
|
|
925
|
+
__typeParams: [TAiModelList];
|
|
830
926
|
}
|
|
831
|
-
interface
|
|
832
|
-
/** The
|
|
833
|
-
|
|
834
|
-
/**
|
|
835
|
-
|
|
836
|
-
/** The address to bind to. Defaults to `127.0.0.1`. */
|
|
837
|
-
address?: string;
|
|
927
|
+
interface AiSearchBindingOptions {
|
|
928
|
+
/** The user-chosen instance name. Must exist in Cloudflare at deploy time. */
|
|
929
|
+
name: string;
|
|
930
|
+
/** Options that only apply during local development. */
|
|
931
|
+
dev?: BindingDevOptions;
|
|
838
932
|
}
|
|
839
933
|
/**
|
|
840
|
-
*
|
|
841
|
-
*
|
|
842
|
-
* protocol/port.
|
|
934
|
+
* AI Search instance binding. Each binding is bound directly to a single
|
|
935
|
+
* pre-existing instance within the "default" namespace.
|
|
843
936
|
*/
|
|
844
|
-
interface
|
|
845
|
-
type: "
|
|
937
|
+
interface AiSearchBinding extends AiSearchBindingOptions {
|
|
938
|
+
type: "ai-search";
|
|
939
|
+
}
|
|
940
|
+
interface AiSearchNamespaceBindingOptions {
|
|
941
|
+
/** The user-chosen namespace name. Must exist in Cloudflare at deploy time. */
|
|
942
|
+
namespace: string;
|
|
943
|
+
/** Options that only apply during local development. */
|
|
944
|
+
dev?: BindingDevOptions;
|
|
846
945
|
}
|
|
847
946
|
/**
|
|
848
|
-
*
|
|
849
|
-
*
|
|
850
|
-
* Construct entries with `triggers.fetch(...)`, `triggers.queue(...)`,
|
|
851
|
-
* `triggers.scheduled(...)`, `triggers.email(...)`, or `triggers.connect(...)`.
|
|
852
|
-
*
|
|
853
|
-
* For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#triggers
|
|
947
|
+
* AI Search namespace binding. Each binding is scoped to a namespace and
|
|
948
|
+
* allows dynamic instance CRUD within it.
|
|
854
949
|
*/
|
|
855
|
-
interface
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
fetch(options: FetchTriggerOptions): FetchTrigger;
|
|
862
|
-
/**
|
|
863
|
-
* Queue consumer trigger — invokes this Worker when messages arrive on the
|
|
864
|
-
* named queue.
|
|
865
|
-
*
|
|
866
|
-
* For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#queues
|
|
867
|
-
*/
|
|
868
|
-
queue(options: QueueConsumerTriggerOptions): QueueConsumerTrigger;
|
|
869
|
-
/**
|
|
870
|
-
* Scheduled (cron) trigger — invokes this Worker on the given schedules.
|
|
871
|
-
*
|
|
872
|
-
* More details here https://developers.cloudflare.com/workers/platform/cron-triggers
|
|
873
|
-
*/
|
|
874
|
-
scheduled(options: ScheduledTriggerOptions): ScheduledTrigger;
|
|
875
|
-
/**
|
|
876
|
-
* Email trigger — invokes this Worker for the configured Email Routing
|
|
877
|
-
* addresses.
|
|
878
|
-
*/
|
|
879
|
-
email(options: EmailTriggerOptions): EmailTrigger;
|
|
880
|
-
/**
|
|
881
|
-
* Connect trigger — invokes this Worker's `connect(socket, env, ctx)`
|
|
882
|
-
* handler for raw socket connections received on the configured
|
|
883
|
-
* protocol/port.
|
|
884
|
-
*/
|
|
885
|
-
connect(options: ConnectTriggerOptions): ConnectTrigger;
|
|
950
|
+
interface AiSearchNamespaceBinding extends AiSearchNamespaceBindingOptions {
|
|
951
|
+
type: "ai-search-namespace";
|
|
952
|
+
}
|
|
953
|
+
interface AnalyticsEngineDatasetBindingOptions {
|
|
954
|
+
/** The name of this dataset to write to. */
|
|
955
|
+
name?: string;
|
|
886
956
|
}
|
|
887
957
|
/**
|
|
888
|
-
*
|
|
889
|
-
*
|
|
890
|
-
* @example
|
|
891
|
-
* ```typescript
|
|
892
|
-
* import { defineWorker, triggers } from "@cloudflare/config";
|
|
958
|
+
* Binding to an Analytics Engine dataset.
|
|
893
959
|
*
|
|
894
|
-
*
|
|
895
|
-
* triggers: [
|
|
896
|
-
* triggers.fetch({ pattern: "example.com/*", zone: "example.com" }),
|
|
897
|
-
* triggers.queue({ name: "my-queue" }),
|
|
898
|
-
* triggers.scheduled({ schedule: "0 * * * *" }),
|
|
899
|
-
* triggers.scheduled({ schedule: "30 0 * * *" }),
|
|
900
|
-
* triggers.email({ addresses: ["support@example.com"] }),
|
|
901
|
-
* triggers.connect({ protocol: "tcp", port: 5432 }),
|
|
902
|
-
* ],
|
|
903
|
-
* });
|
|
904
|
-
* ```
|
|
960
|
+
* For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#analytics-engine-datasets
|
|
905
961
|
*/
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
962
|
+
interface AnalyticsEngineDatasetBinding extends AnalyticsEngineDatasetBindingOptions {
|
|
963
|
+
type: "analytics-engine-dataset";
|
|
964
|
+
}
|
|
965
|
+
interface ArtifactsBindingOptions {
|
|
966
|
+
/** The namespace to use. */
|
|
967
|
+
namespace: string;
|
|
968
|
+
/** Options that only apply during local development. */
|
|
969
|
+
dev?: BindingDevOptions;
|
|
970
|
+
}
|
|
909
971
|
/**
|
|
910
|
-
*
|
|
911
|
-
*
|
|
912
|
-
* Containers are only supported on the SQLite storage engine, so `container` is
|
|
913
|
-
* only offered alongside `storage: "sqlite"`.
|
|
972
|
+
* Binding to an Artifacts instance. Artifacts provides git-compatible file
|
|
973
|
+
* storage on Cloudflare Workers.
|
|
914
974
|
*/
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
* classes).
|
|
919
|
-
*/
|
|
920
|
-
storage: "sqlite";
|
|
921
|
-
/**
|
|
922
|
-
* Attach a container to this Durable Object, by container name. The
|
|
923
|
-
* name must match an entry in the top level `containers` array.
|
|
924
|
-
*/
|
|
925
|
-
container?: string;
|
|
926
|
-
} | {
|
|
927
|
-
/** Selects the legacy key-value storage engine. */
|
|
928
|
-
storage: "legacy-kv";
|
|
929
|
-
};
|
|
975
|
+
interface ArtifactsBinding extends ArtifactsBindingOptions {
|
|
976
|
+
type: "artifacts";
|
|
977
|
+
}
|
|
930
978
|
/**
|
|
931
|
-
*
|
|
932
|
-
*
|
|
933
|
-
* For more information about Durable Objects, see the documentation at
|
|
934
|
-
* https://developers.cloudflare.com/workers/learning/using-durable-objects
|
|
979
|
+
* Binding to the Worker's static assets.
|
|
935
980
|
*
|
|
936
|
-
* For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#
|
|
981
|
+
* For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#assets
|
|
937
982
|
*/
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
}
|
|
983
|
+
interface AssetsBinding {
|
|
984
|
+
type: "assets";
|
|
985
|
+
}
|
|
986
|
+
interface BrowserBindingOptions {
|
|
987
|
+
/** Options that only apply during local development. */
|
|
988
|
+
dev?: BindingDevOptions;
|
|
989
|
+
}
|
|
941
990
|
/**
|
|
942
|
-
*
|
|
943
|
-
* been removed from code.
|
|
991
|
+
* Binding to a headless browser usable from the Worker.
|
|
944
992
|
*
|
|
945
|
-
*
|
|
946
|
-
* other Worker may hold a `durableObject` binding to the namespace.
|
|
993
|
+
* For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#browser-rendering
|
|
947
994
|
*/
|
|
948
|
-
interface
|
|
949
|
-
|
|
995
|
+
interface BrowserBinding extends BrowserBindingOptions {
|
|
996
|
+
type: "browser";
|
|
997
|
+
}
|
|
998
|
+
interface D1BindingOptions {
|
|
999
|
+
/** The UUID of this D1 database (not required). */
|
|
1000
|
+
id?: string;
|
|
1001
|
+
/** The name of this D1 database. */
|
|
1002
|
+
name?: string;
|
|
1003
|
+
/** Options that only apply during local development. */
|
|
1004
|
+
dev?: BindingDevOptions;
|
|
950
1005
|
}
|
|
951
1006
|
/**
|
|
952
|
-
*
|
|
953
|
-
*
|
|
954
|
-
*
|
|
1007
|
+
* Binding to a D1 database.
|
|
1008
|
+
*
|
|
1009
|
+
* For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#d1-databases
|
|
955
1010
|
*/
|
|
956
|
-
interface
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
1011
|
+
interface D1Binding extends D1BindingOptions {
|
|
1012
|
+
type: "d1";
|
|
1013
|
+
}
|
|
1014
|
+
interface DispatchNamespaceBindingOptions {
|
|
1015
|
+
/** The namespace to bind to. */
|
|
1016
|
+
namespace?: string;
|
|
1017
|
+
/** Details about the outbound Worker which will handle outbound requests from your namespace. */
|
|
1018
|
+
outbound?: {
|
|
1019
|
+
/** Name of the Worker handling the outbound requests. */
|
|
1020
|
+
worker: string;
|
|
1021
|
+
/** (Optional) List of parameter names, for sending context from your dispatch Worker to the outbound handler. */
|
|
1022
|
+
parameters?: string[];
|
|
1023
|
+
};
|
|
1024
|
+
/** Options that only apply during local development. */
|
|
1025
|
+
dev?: BindingDevOptions;
|
|
964
1026
|
}
|
|
965
1027
|
/**
|
|
966
|
-
*
|
|
967
|
-
*
|
|
1028
|
+
* Binding to a Workers for Platforms dispatch namespace.
|
|
1029
|
+
*
|
|
1030
|
+
* For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#dispatch-namespace-bindings-workers-for-platforms
|
|
968
1031
|
*/
|
|
969
|
-
interface
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
1032
|
+
interface DispatchNamespaceBinding extends DispatchNamespaceBindingOptions {
|
|
1033
|
+
type: "dispatch-namespace";
|
|
1034
|
+
}
|
|
1035
|
+
type WorkerReference = string | WorkerConfigExport;
|
|
1036
|
+
type ReferencedWorkerConfig<TWorker$1 extends WorkerReference> = TWorker$1 extends string ? never : UnwrapConfig<TWorker$1>;
|
|
1037
|
+
type DurableObjectExportName<TWorker$1 extends WorkerReference> = TWorker$1 extends string ? string : InferDurableNamespaces<ReferencedWorkerConfig<TWorker$1>>;
|
|
1038
|
+
type WorkerEntrypointExportName<TWorker$1 extends WorkerReference> = TWorker$1 extends string ? string : InferWorkerEntrypointExports<ReferencedWorkerConfig<TWorker$1>>;
|
|
1039
|
+
type WorkflowExportName<TWorker$1 extends WorkerReference> = TWorker$1 extends string ? string : InferExportsByType<ReferencedWorkerConfig<TWorker$1>, "workflow">;
|
|
1040
|
+
interface DurableObjectBindingOptions<TWorker$1 extends WorkerReference = WorkerReference, TExportName$1 extends DurableObjectExportName<TWorker$1> = DurableObjectExportName<TWorker$1>> {
|
|
1041
|
+
/** The name or config of the Worker that defines the Durable Object class. */
|
|
1042
|
+
worker: TWorker$1;
|
|
1043
|
+
/** The exported class name of the Durable Object. */
|
|
1044
|
+
exportName: TExportName$1;
|
|
975
1045
|
}
|
|
976
1046
|
/**
|
|
977
|
-
*
|
|
978
|
-
*
|
|
1047
|
+
* Binding to a Durable Object class. `worker` is the name or config of the
|
|
1048
|
+
* Worker that defines the class; `exportName` is the exported class name.
|
|
1049
|
+
*
|
|
1050
|
+
* For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#durable-objects
|
|
979
1051
|
*/
|
|
980
|
-
|
|
981
|
-
state: "expecting-transfer";
|
|
982
|
-
/**
|
|
983
|
-
* The source Worker for the two-phase cross-Worker transfer.
|
|
984
|
-
*/
|
|
985
|
-
transferFrom: string;
|
|
986
|
-
} & DurableObjectStorageOptions;
|
|
987
|
-
type DurableObjectCreatedExport = DurableObjectCreatedExportOptions & {
|
|
988
|
-
type: "durable-object";
|
|
989
|
-
};
|
|
990
|
-
interface DurableObjectDeletedExport extends DurableObjectDeletedExportOptions {
|
|
1052
|
+
interface DurableObjectBinding<TWorker$1 extends WorkerReference = WorkerReference, TExportName$1 extends DurableObjectExportName<TWorker$1> = DurableObjectExportName<TWorker$1>> extends DurableObjectBindingOptions<TWorker$1, TExportName$1> {
|
|
991
1053
|
type: "durable-object";
|
|
992
1054
|
}
|
|
993
|
-
interface
|
|
994
|
-
|
|
1055
|
+
interface FlagshipBindingOptions {
|
|
1056
|
+
/** The Flagship app ID to bind to. */
|
|
1057
|
+
id?: string;
|
|
1058
|
+
/** Options that only apply during local development. */
|
|
1059
|
+
dev?: BindingDevOptions;
|
|
995
1060
|
}
|
|
996
|
-
|
|
997
|
-
|
|
1061
|
+
/** Binding to a Flagship feature-flag service. */
|
|
1062
|
+
interface FlagshipBinding extends FlagshipBindingOptions {
|
|
1063
|
+
type: "flagship";
|
|
998
1064
|
}
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
/** Whether cache is enabled for this entrypoint. */
|
|
1007
|
-
enabled: boolean;
|
|
1065
|
+
interface HyperdriveBindingOptions {
|
|
1066
|
+
/** The ID of the Hyperdrive configuration. */
|
|
1067
|
+
id: string;
|
|
1068
|
+
/** Options that only apply during local development. */
|
|
1069
|
+
dev?: {
|
|
1070
|
+
/** The database connection string used during local development. */
|
|
1071
|
+
connectionString?: string;
|
|
1008
1072
|
};
|
|
1009
1073
|
}
|
|
1010
|
-
interface WorkerEntrypointExport extends WorkerEntrypointExportOptions {
|
|
1011
|
-
type: "worker";
|
|
1012
|
-
}
|
|
1013
1074
|
/**
|
|
1014
|
-
*
|
|
1015
|
-
*
|
|
1075
|
+
* Binding to a Hyperdrive configuration.
|
|
1076
|
+
*
|
|
1077
|
+
* For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#hyperdrive
|
|
1016
1078
|
*/
|
|
1017
|
-
interface
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
*
|
|
1024
|
-
* For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#durable-objects
|
|
1025
|
-
*/
|
|
1026
|
-
durableObject(options: DurableObjectCreatedExportOptions): DurableObjectCreatedExport;
|
|
1027
|
-
/**
|
|
1028
|
-
* Retire a provisioned Durable Object namespace whose class has been removed from code.
|
|
1029
|
-
*/
|
|
1030
|
-
durableObject(options: DurableObjectDeletedExportOptions): DurableObjectDeletedExport;
|
|
1031
|
-
/**
|
|
1032
|
-
* Rename a provisioned Durable Object namespace's class.
|
|
1033
|
-
*/
|
|
1034
|
-
durableObject(options: DurableObjectRenamedExportOptions): DurableObjectRenamedExport;
|
|
1035
|
-
/**
|
|
1036
|
-
* Transfer ownership of a Durable Object namespace to another Worker in the same account.
|
|
1037
|
-
*/
|
|
1038
|
-
durableObject(options: DurableObjectTransferredExportOptions): DurableObjectTransferredExport;
|
|
1039
|
-
/**
|
|
1040
|
-
* Prepare to receive cross-Worker Durable Object transfer.
|
|
1041
|
-
* The source Worker must follow up with a deployment containing a `transferred` export to commit the transfer.
|
|
1042
|
-
*/
|
|
1043
|
-
durableObject(options: DurableObjectExpectingTransferExportOptions): DurableObjectExpectingTransferExport;
|
|
1044
|
-
durableObject(options: DurableObjectExportOptions): DurableObjectExports;
|
|
1045
|
-
/** Declares a WorkerEntrypoint export defined by this Worker. */
|
|
1046
|
-
worker(options?: WorkerEntrypointExportOptions): WorkerEntrypointExport;
|
|
1079
|
+
interface HyperdriveBinding extends HyperdriveBindingOptions {
|
|
1080
|
+
type: "hyperdrive";
|
|
1081
|
+
}
|
|
1082
|
+
interface ImagesBindingOptions {
|
|
1083
|
+
/** Options that only apply during local development. */
|
|
1084
|
+
dev?: BindingDevOptions;
|
|
1047
1085
|
}
|
|
1048
1086
|
/**
|
|
1049
|
-
*
|
|
1050
|
-
*
|
|
1051
|
-
* @example
|
|
1052
|
-
* ```typescript
|
|
1053
|
-
* import { defineWorker, exports } from "@cloudflare/config";
|
|
1087
|
+
* Binding to Cloudflare Images.
|
|
1054
1088
|
*
|
|
1055
|
-
*
|
|
1056
|
-
* exports: {
|
|
1057
|
-
* MyDurableObject: exports.durableObject({ storage: "sqlite" }),
|
|
1058
|
-
* MyContainerDO: exports.durableObject({ storage: "sqlite", container: "my-container" }),
|
|
1059
|
-
* OldClass: exports.durableObject({ state: "deleted" }),
|
|
1060
|
-
* OldName: exports.durableObject({ state: "renamed", renamedTo: "NewName" }),
|
|
1061
|
-
* Outgoing: exports.durableObject({ state: "transferred", transferredTo: "target-worker" }),
|
|
1062
|
-
* Incoming: exports.durableObject({ state: "expecting-transfer", storage: "sqlite", transferFrom: "source-worker" }),
|
|
1063
|
-
* },
|
|
1064
|
-
* });
|
|
1065
|
-
* ```
|
|
1089
|
+
* For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#images
|
|
1066
1090
|
*/
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
//#region src/definition.d.ts
|
|
1070
|
-
interface ConfigContext {
|
|
1071
|
-
/**
|
|
1072
|
-
* The mode the config is being evaluated in.
|
|
1073
|
-
* Set via the `--mode` CLI flag.
|
|
1074
|
-
* In Vite the mode defaults to `development` in `vite dev` and `production` in `vite build` ([more info](https://vite.dev/guide/env-and-mode.html#modes)).
|
|
1075
|
-
* In Wrangler the mode defaults to `undefined`.
|
|
1076
|
-
*/
|
|
1077
|
-
mode: string | undefined;
|
|
1091
|
+
interface ImagesBinding$1 extends ImagesBindingOptions {
|
|
1092
|
+
type: "images";
|
|
1078
1093
|
}
|
|
1079
|
-
declare const DEFINITION: unique symbol;
|
|
1080
1094
|
/**
|
|
1081
|
-
*
|
|
1082
|
-
*
|
|
1095
|
+
* Inline JSON value made available to the Worker on `env` under the
|
|
1096
|
+
* binding name.
|
|
1083
1097
|
*/
|
|
1084
|
-
|
|
1098
|
+
interface JsonBinding<T$1 extends Json = Json> {
|
|
1099
|
+
type: "json";
|
|
1100
|
+
/** The JSON value made available to the Worker. */
|
|
1101
|
+
value: T$1;
|
|
1102
|
+
}
|
|
1103
|
+
interface KvBindingOptions {
|
|
1104
|
+
/** The ID of the KV namespace. */
|
|
1105
|
+
id?: string;
|
|
1106
|
+
/** Options that only apply during local development. */
|
|
1107
|
+
dev?: BindingDevOptions;
|
|
1108
|
+
}
|
|
1085
1109
|
/**
|
|
1086
|
-
*
|
|
1110
|
+
* Binding to a Workers KV namespace.
|
|
1087
1111
|
*
|
|
1088
|
-
*
|
|
1089
|
-
* {@link DEFINITION} symbol; here we unwrap the config and stamp `type` back on.
|
|
1090
|
-
* Every other export — a raw object/promise/function — is unwrapped as-is and
|
|
1091
|
-
* already carries its own `type`. Discrimination happens afterwards via `type`.
|
|
1112
|
+
* For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#kv-namespaces
|
|
1092
1113
|
*/
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1114
|
+
interface KvBinding extends KvBindingOptions {
|
|
1115
|
+
type: "kv";
|
|
1116
|
+
}
|
|
1096
1117
|
/**
|
|
1097
|
-
*
|
|
1118
|
+
* Binding to a Workers KV namespace.
|
|
1119
|
+
*
|
|
1120
|
+
* For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#kv-namespaces
|
|
1098
1121
|
*/
|
|
1099
|
-
|
|
1122
|
+
interface TypedKvBinding<TKey extends string = string> extends KvBinding {
|
|
1123
|
+
/** @internal Carries type parameters for inference */
|
|
1124
|
+
__typeParams: [TKey];
|
|
1125
|
+
}
|
|
1126
|
+
interface LogfwdrBindingOptions {
|
|
1127
|
+
/** The destination for this logged message. */
|
|
1128
|
+
destination: string;
|
|
1129
|
+
}
|
|
1130
|
+
/** Binding for forwarding logs to logfwdr. */
|
|
1131
|
+
interface LogfwdrBinding extends LogfwdrBindingOptions {
|
|
1132
|
+
type: "logfwdr";
|
|
1133
|
+
}
|
|
1134
|
+
interface MediaBindingOptions {
|
|
1135
|
+
/** Options that only apply during local development. */
|
|
1136
|
+
dev?: BindingDevOptions;
|
|
1137
|
+
}
|
|
1138
|
+
/** Binding to Cloudflare Media Transformations. */
|
|
1139
|
+
interface MediaBinding$1 extends MediaBindingOptions {
|
|
1140
|
+
type: "media";
|
|
1141
|
+
}
|
|
1142
|
+
interface MtlsCertificateBindingOptions {
|
|
1143
|
+
/** The UUID of the uploaded mTLS certificate. */
|
|
1144
|
+
id: string;
|
|
1145
|
+
/** Options that only apply during local development. */
|
|
1146
|
+
dev?: BindingDevOptions;
|
|
1147
|
+
}
|
|
1100
1148
|
/**
|
|
1101
|
-
*
|
|
1149
|
+
* Binding to an uploaded mTLS certificate.
|
|
1150
|
+
*
|
|
1151
|
+
* For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#mtls-certificates
|
|
1102
1152
|
*/
|
|
1103
|
-
|
|
1153
|
+
interface MtlsCertificateBinding extends MtlsCertificateBindingOptions {
|
|
1154
|
+
type: "mtls-certificate";
|
|
1155
|
+
}
|
|
1156
|
+
interface PipelineBindingOptions {
|
|
1157
|
+
/** Name of the Pipeline to bind. */
|
|
1158
|
+
name: string;
|
|
1159
|
+
/** Options that only apply during local development. */
|
|
1160
|
+
dev?: BindingDevOptions;
|
|
1161
|
+
}
|
|
1162
|
+
/** Binding to a Cloudflare Pipeline. */
|
|
1163
|
+
interface PipelineBinding extends PipelineBindingOptions {
|
|
1164
|
+
type: "pipeline";
|
|
1165
|
+
}
|
|
1166
|
+
/** Binding to a Cloudflare Pipeline. */
|
|
1167
|
+
interface TypedPipelineBinding<TRecord extends PipelineRecord = PipelineRecord> extends PipelineBinding {
|
|
1168
|
+
/** @internal Carries type parameters for inference */
|
|
1169
|
+
__typeParams: [TRecord];
|
|
1170
|
+
}
|
|
1171
|
+
interface QueueBindingOptions {
|
|
1172
|
+
/** The name of this Queue. */
|
|
1173
|
+
name?: string;
|
|
1174
|
+
/** The number of seconds to wait before delivering a message. */
|
|
1175
|
+
deliveryDelay?: number;
|
|
1176
|
+
/** Options that only apply during local development. */
|
|
1177
|
+
dev?: BindingDevOptions;
|
|
1178
|
+
}
|
|
1104
1179
|
/**
|
|
1105
|
-
*
|
|
1106
|
-
*
|
|
1107
|
-
*
|
|
1180
|
+
* Producer binding to a Cloudflare Queue.
|
|
1181
|
+
*
|
|
1182
|
+
* For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#queues
|
|
1108
1183
|
*/
|
|
1109
|
-
|
|
1184
|
+
interface QueueBinding extends QueueBindingOptions {
|
|
1185
|
+
type: "queue";
|
|
1186
|
+
}
|
|
1110
1187
|
/**
|
|
1111
|
-
*
|
|
1112
|
-
* [`defineWorker`](https://developers.cloudflare.com/workers/wrangler/configuration/).
|
|
1188
|
+
* Producer binding to a Cloudflare Queue.
|
|
1113
1189
|
*
|
|
1114
|
-
*
|
|
1115
|
-
* being passed to downstream tooling.
|
|
1190
|
+
* For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#queues
|
|
1116
1191
|
*/
|
|
1117
|
-
interface
|
|
1118
|
-
/**
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
* More details at https://developers.cloudflare.com/workers/configuration/compatibility-dates
|
|
1134
|
-
*/
|
|
1135
|
-
compatibilityDate: string;
|
|
1136
|
-
/**
|
|
1137
|
-
* A list of flags that enable features from upcoming features of
|
|
1138
|
-
* the Workers runtime, usually used together with `compatibilityDate`.
|
|
1139
|
-
*
|
|
1140
|
-
* More details at https://developers.cloudflare.com/workers/configuration/compatibility-flags/
|
|
1141
|
-
*
|
|
1142
|
-
* @default []
|
|
1143
|
-
*/
|
|
1144
|
-
compatibilityFlags?: string[];
|
|
1145
|
-
/**
|
|
1146
|
-
* The entrypoint module that will be executed.
|
|
1147
|
-
*
|
|
1148
|
-
* May be either a path string (e.g. `"./src/index.ts"`) or a module
|
|
1149
|
-
* namespace imported with the `cf-worker` import attribute.
|
|
1150
|
-
*
|
|
1151
|
-
* @example
|
|
1152
|
-
* ```ts
|
|
1153
|
-
* import * as entrypoint from "./src" with { type: "cf-worker" };
|
|
1154
|
-
* export default defineWorker({ entrypoint });
|
|
1155
|
-
* ```
|
|
1156
|
-
*/
|
|
1157
|
-
entrypoint?: string | WorkerModule;
|
|
1158
|
-
/**
|
|
1159
|
-
* Specify the directory of static assets to deploy/serve.
|
|
1160
|
-
*
|
|
1161
|
-
* More details at https://developers.cloudflare.com/workers/frameworks/
|
|
1162
|
-
*
|
|
1163
|
-
* For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#assets
|
|
1164
|
-
*/
|
|
1165
|
-
assets?: {
|
|
1166
|
-
/** How to handle HTML requests. */
|
|
1167
|
-
htmlHandling?: "auto-trailing-slash" | "drop-trailing-slash" | "force-trailing-slash" | "none";
|
|
1168
|
-
/** How to handle requests that do not match an asset. */
|
|
1169
|
-
notFoundHandling?: "single-page-application" | "404-page" | "none";
|
|
1170
|
-
/**
|
|
1171
|
-
* Matches will be routed to the User Worker, and matches to negative rules will go to the Asset Worker.
|
|
1172
|
-
*
|
|
1173
|
-
* Can also be `true`, indicating that every request should be routed to the User Worker.
|
|
1174
|
-
*/
|
|
1175
|
-
runWorkerFirst?: string[] | boolean;
|
|
1192
|
+
interface TypedQueueBinding<TBody = unknown> extends QueueBinding {
|
|
1193
|
+
/** @internal Carries type parameters for inference */
|
|
1194
|
+
__typeParams: [TBody];
|
|
1195
|
+
}
|
|
1196
|
+
interface R2BindingOptions {
|
|
1197
|
+
/** The name of this R2 bucket at the edge. */
|
|
1198
|
+
name?: string;
|
|
1199
|
+
/** The jurisdiction that the bucket exists in. Default if not present. */
|
|
1200
|
+
jurisdiction?: string;
|
|
1201
|
+
/** Settings that only apply to local development. */
|
|
1202
|
+
dev?: BindingDevOptions & {
|
|
1203
|
+
/** EXPERIMENTAL: credentials for the local S3-compatible endpoint. */
|
|
1204
|
+
experimentalS3Credentials?: {
|
|
1205
|
+
accessKeyId: string;
|
|
1206
|
+
secretAccessKey: string;
|
|
1207
|
+
};
|
|
1176
1208
|
};
|
|
1209
|
+
}
|
|
1210
|
+
/**
|
|
1211
|
+
* Binding to an R2 bucket.
|
|
1212
|
+
*
|
|
1213
|
+
* For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#r2-buckets
|
|
1214
|
+
*/
|
|
1215
|
+
interface R2Binding extends R2BindingOptions {
|
|
1216
|
+
type: "r2";
|
|
1217
|
+
}
|
|
1218
|
+
interface RateLimitBindingOptions {
|
|
1219
|
+
/** The namespace ID for this rate limiter. */
|
|
1220
|
+
namespace: string;
|
|
1221
|
+
/** Simple rate limiting configuration. */
|
|
1222
|
+
simple: {
|
|
1223
|
+
/** The maximum number of requests allowed in the time period. */
|
|
1224
|
+
limit: number;
|
|
1225
|
+
/** The time period in seconds (10 for ten seconds, 60 for one minute). */
|
|
1226
|
+
period: 10 | 60;
|
|
1227
|
+
};
|
|
1228
|
+
}
|
|
1229
|
+
/** Binding to a rate limiter. */
|
|
1230
|
+
interface RateLimitBinding extends RateLimitBindingOptions {
|
|
1231
|
+
type: "rate-limit";
|
|
1232
|
+
}
|
|
1233
|
+
/**
|
|
1234
|
+
* Declares a secret that is required by your Worker, exposed on `env` under
|
|
1235
|
+
* the binding name.
|
|
1236
|
+
*
|
|
1237
|
+
* When defined, this binding:
|
|
1238
|
+
* - Replaces .dev.vars/.env/process.env inference for type generation
|
|
1239
|
+
* - Enables local dev validation with warnings for missing secrets
|
|
1240
|
+
*
|
|
1241
|
+
* For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#secrets-configuration-property
|
|
1242
|
+
*/
|
|
1243
|
+
interface SecretBinding {
|
|
1244
|
+
type: "secret";
|
|
1245
|
+
}
|
|
1246
|
+
interface SecretsStoreSecretBindingOptions {
|
|
1247
|
+
/** ID of the secret store. */
|
|
1248
|
+
storeId: string;
|
|
1249
|
+
/** Name of the secret. */
|
|
1250
|
+
secretName: string;
|
|
1251
|
+
}
|
|
1252
|
+
/** Binding to a Secrets Store secret. */
|
|
1253
|
+
interface SecretsStoreSecretBinding extends SecretsStoreSecretBindingOptions {
|
|
1254
|
+
type: "secrets-store-secret";
|
|
1255
|
+
}
|
|
1256
|
+
type SendEmailDestinationOptions = {
|
|
1257
|
+
/** If this binding should be restricted to a specific verified address. */
|
|
1258
|
+
destinationAddress: string;
|
|
1259
|
+
allowedDestinationAddresses?: never;
|
|
1260
|
+
} | {
|
|
1261
|
+
destinationAddress?: never;
|
|
1262
|
+
/** If this binding should be restricted to a set of verified addresses. */
|
|
1263
|
+
allowedDestinationAddresses: string[];
|
|
1264
|
+
} | {
|
|
1265
|
+
destinationAddress?: never;
|
|
1266
|
+
allowedDestinationAddresses?: never;
|
|
1267
|
+
};
|
|
1268
|
+
type SendEmailBindingOptions = SendEmailDestinationOptions & {
|
|
1269
|
+
/** If this binding should be restricted to a set of sender addresses. */
|
|
1270
|
+
allowedSenderAddresses?: string[];
|
|
1271
|
+
/** Options that only apply during local development. */
|
|
1272
|
+
dev?: BindingDevOptions;
|
|
1273
|
+
};
|
|
1274
|
+
/**
|
|
1275
|
+
* Binding for sending email from inside the Worker.
|
|
1276
|
+
*
|
|
1277
|
+
* For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#email-bindings
|
|
1278
|
+
*/
|
|
1279
|
+
type SendEmailBinding = SendEmailBindingOptions & {
|
|
1280
|
+
type: "send-email";
|
|
1281
|
+
};
|
|
1282
|
+
interface StreamBindingOptions {
|
|
1283
|
+
/** Options that only apply during local development. */
|
|
1284
|
+
dev?: BindingDevOptions;
|
|
1285
|
+
}
|
|
1286
|
+
/** Binding to Cloudflare Stream. */
|
|
1287
|
+
interface StreamBinding$1 extends StreamBindingOptions {
|
|
1288
|
+
type: "stream";
|
|
1289
|
+
}
|
|
1290
|
+
/**
|
|
1291
|
+
* Inline string value made available to the Worker on `env` under the
|
|
1292
|
+
* binding name.
|
|
1293
|
+
*
|
|
1294
|
+
* For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#environment-variables
|
|
1295
|
+
*/
|
|
1296
|
+
interface TextBinding<T$1 extends string = string> {
|
|
1297
|
+
type: "text";
|
|
1298
|
+
/** The string value made available to the Worker. */
|
|
1299
|
+
value: T$1;
|
|
1300
|
+
}
|
|
1301
|
+
interface UnsafeBindingOptions {
|
|
1302
|
+
/** Local-dev plugin configuration for this unsafe binding. */
|
|
1303
|
+
dev?: {
|
|
1304
|
+
/** The plugin package that provides the binding's local-dev implementation. */
|
|
1305
|
+
plugin: {
|
|
1306
|
+
package: string;
|
|
1307
|
+
name: string;
|
|
1308
|
+
};
|
|
1309
|
+
/** Plugin-specific options. */
|
|
1310
|
+
options?: Record<string, unknown>;
|
|
1311
|
+
};
|
|
1312
|
+
[key: string]: unknown;
|
|
1313
|
+
}
|
|
1314
|
+
/**
|
|
1315
|
+
* Escape-hatch binding for runtime features that aren't directly supported
|
|
1316
|
+
* by this configuration. Included in the Worker's upload metadata without
|
|
1317
|
+
* changes.
|
|
1318
|
+
*/
|
|
1319
|
+
interface UnsafeBinding extends UnsafeBindingOptions {
|
|
1320
|
+
type: `unsafe:${string}`;
|
|
1321
|
+
}
|
|
1322
|
+
interface VectorizeBindingOptions {
|
|
1323
|
+
/** The name of the Vectorize index. */
|
|
1324
|
+
name: string;
|
|
1325
|
+
/** Options that only apply during local development. */
|
|
1326
|
+
dev?: BindingDevOptions;
|
|
1327
|
+
}
|
|
1328
|
+
/**
|
|
1329
|
+
* Binding to a Vectorize index.
|
|
1330
|
+
*
|
|
1331
|
+
* For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#vectorize-indexes
|
|
1332
|
+
*/
|
|
1333
|
+
interface VectorizeBinding extends VectorizeBindingOptions {
|
|
1334
|
+
type: "vectorize";
|
|
1335
|
+
}
|
|
1336
|
+
/** Binding to the Worker version's metadata. */
|
|
1337
|
+
interface VersionMetadataBinding {
|
|
1338
|
+
type: "version-metadata";
|
|
1339
|
+
}
|
|
1340
|
+
type VpcNetworkBindingOptions = {
|
|
1341
|
+
/** The tunnel ID of the Cloudflare Tunnel to route traffic through. Mutually exclusive with `networkId`. */
|
|
1342
|
+
tunnelId: string;
|
|
1343
|
+
networkId?: never;
|
|
1344
|
+
/** Options that only apply during local development. */
|
|
1345
|
+
dev?: BindingDevOptions;
|
|
1346
|
+
} | {
|
|
1347
|
+
tunnelId?: never;
|
|
1348
|
+
/** The network ID to route traffic through. Mutually exclusive with `tunnelId`. */
|
|
1349
|
+
networkId: string;
|
|
1350
|
+
/** Options that only apply during local development. */
|
|
1351
|
+
dev?: BindingDevOptions;
|
|
1352
|
+
};
|
|
1353
|
+
/** Binding to a VPC network. */
|
|
1354
|
+
type VpcNetworkBinding = VpcNetworkBindingOptions & {
|
|
1355
|
+
type: "vpc-network";
|
|
1356
|
+
};
|
|
1357
|
+
interface VpcServiceBindingOptions {
|
|
1358
|
+
/** The service ID of the VPC connectivity service. */
|
|
1359
|
+
id: string;
|
|
1360
|
+
/** Options that only apply during local development. */
|
|
1361
|
+
dev?: BindingDevOptions;
|
|
1362
|
+
}
|
|
1363
|
+
/** Binding to a VPC service. */
|
|
1364
|
+
interface VpcServiceBinding extends VpcServiceBindingOptions {
|
|
1365
|
+
type: "vpc-service";
|
|
1366
|
+
}
|
|
1367
|
+
interface WebSearchBindingOptions {
|
|
1368
|
+
/** Options that only apply during local development. */
|
|
1369
|
+
dev?: BindingDevOptions;
|
|
1370
|
+
}
|
|
1371
|
+
/**
|
|
1372
|
+
* Cloudflare Web Search binding. There is exactly one shared web corpus, so
|
|
1373
|
+
* the binding is zero-config — only the variable name is required.
|
|
1374
|
+
*/
|
|
1375
|
+
interface WebSearchBinding extends WebSearchBindingOptions {
|
|
1376
|
+
type: "web-search";
|
|
1377
|
+
}
|
|
1378
|
+
interface WorkerBindingOptions<TWorker$1 extends WorkerReference = WorkerReference, TExportName$1 extends WorkerEntrypointExportName<TWorker$1> | undefined = WorkerEntrypointExportName<TWorker$1> | undefined> {
|
|
1379
|
+
/** The name or config of the bound Worker. */
|
|
1380
|
+
worker: TWorker$1;
|
|
1381
|
+
/** The named export to bind to (defaults to the default export). */
|
|
1382
|
+
exportName?: TExportName$1;
|
|
1383
|
+
/** Optional properties that will be made available to the service via `ctx.props`. */
|
|
1384
|
+
props?: Record<string, unknown>;
|
|
1385
|
+
/** Options that only apply during local development. */
|
|
1386
|
+
dev?: BindingDevOptions;
|
|
1387
|
+
}
|
|
1388
|
+
/**
|
|
1389
|
+
* Service binding (Worker-to-Worker). `worker` is the name or config of the
|
|
1390
|
+
* bound Worker; `exportName` selects a named `WorkerEntrypoint` export
|
|
1391
|
+
* (defaults to the default export).
|
|
1392
|
+
*
|
|
1393
|
+
* For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#service-bindings
|
|
1394
|
+
*/
|
|
1395
|
+
interface WorkerBinding<TWorker$1 extends WorkerReference = WorkerReference, TExportName$1 extends WorkerEntrypointExportName<TWorker$1> | undefined = WorkerEntrypointExportName<TWorker$1> | undefined> extends WorkerBindingOptions<TWorker$1, TExportName$1> {
|
|
1396
|
+
type: "worker";
|
|
1397
|
+
}
|
|
1398
|
+
/** Binding to a Worker Loader. */
|
|
1399
|
+
interface WorkerLoaderBinding {
|
|
1400
|
+
type: "worker-loader";
|
|
1401
|
+
}
|
|
1402
|
+
interface WorkflowBindingOptions<TWorker$1 extends WorkerReference = WorkerReference, TExportName$1 extends WorkflowExportName<TWorker$1> = WorkflowExportName<TWorker$1>> {
|
|
1403
|
+
/** The name or config of the Worker that defines the Workflow. */
|
|
1404
|
+
worker: TWorker$1;
|
|
1405
|
+
/** The exported class name of the Workflow. */
|
|
1406
|
+
exportName: TExportName$1;
|
|
1407
|
+
}
|
|
1408
|
+
/**
|
|
1409
|
+
* Binding to a Workflow. `worker` is the name or config of the Worker that
|
|
1410
|
+
* defines the Workflow; `exportName` is the exported `WorkflowEntrypoint`
|
|
1411
|
+
* class name.
|
|
1412
|
+
*/
|
|
1413
|
+
interface WorkflowBinding<TWorker$1 extends WorkerReference = WorkerReference, TExportName$1 extends WorkflowExportName<TWorker$1> = WorkflowExportName<TWorker$1>> extends WorkflowBindingOptions<TWorker$1, TExportName$1> {
|
|
1414
|
+
type: "workflow";
|
|
1415
|
+
}
|
|
1416
|
+
interface Bindings {
|
|
1177
1417
|
/**
|
|
1178
|
-
*
|
|
1179
|
-
*
|
|
1180
|
-
* For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#types-of-routes
|
|
1418
|
+
* Agent Memory namespace binding. Each binding is scoped to a namespace and
|
|
1419
|
+
* allows agents to persist and recall memory.
|
|
1181
1420
|
*/
|
|
1182
|
-
|
|
1421
|
+
agentMemory(options: AgentMemoryBindingOptions): AgentMemoryBinding;
|
|
1183
1422
|
/**
|
|
1184
|
-
*
|
|
1185
|
-
* Routing addresses, and raw sockets — that invoke this Worker.
|
|
1186
|
-
* Construct entries with `triggers.fetch(...)`, `triggers.queue(...)`,
|
|
1187
|
-
* `triggers.scheduled(...)`, `triggers.email(...)`, or
|
|
1188
|
-
* `triggers.connect(...)`.
|
|
1423
|
+
* Binding to the Workers AI project.
|
|
1189
1424
|
*
|
|
1190
|
-
* For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#
|
|
1425
|
+
* For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#workers-ai
|
|
1191
1426
|
*/
|
|
1192
|
-
|
|
1427
|
+
ai<TAiModelList extends AiModelListType = AiModels>(options?: AiBindingOptions): TypedAiBinding<TAiModelList>;
|
|
1193
1428
|
/**
|
|
1194
|
-
*
|
|
1195
|
-
*
|
|
1196
|
-
|
|
1197
|
-
|
|
1429
|
+
* AI Search instance binding. Each binding is bound directly to a single
|
|
1430
|
+
* pre-existing instance within the "default" namespace.
|
|
1431
|
+
*/
|
|
1432
|
+
aiSearch(options: AiSearchBindingOptions): AiSearchBinding;
|
|
1433
|
+
/**
|
|
1434
|
+
* AI Search namespace binding. Each binding is scoped to a namespace and
|
|
1435
|
+
* allows dynamic instance CRUD within it.
|
|
1436
|
+
*/
|
|
1437
|
+
aiSearchNamespace(options: AiSearchNamespaceBindingOptions): AiSearchNamespaceBinding;
|
|
1438
|
+
/**
|
|
1439
|
+
* Binding to an Analytics Engine dataset.
|
|
1198
1440
|
*
|
|
1199
|
-
*
|
|
1441
|
+
* For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#analytics-engine-datasets
|
|
1200
1442
|
*/
|
|
1201
|
-
|
|
1202
|
-
/** The name of the service tail events will be forwarded to. */
|
|
1203
|
-
worker: string;
|
|
1204
|
-
/** Whether to stream tail events in real time. */
|
|
1205
|
-
streaming?: boolean;
|
|
1206
|
-
}>;
|
|
1443
|
+
analyticsEngineDataset(options?: AnalyticsEngineDatasetBindingOptions): AnalyticsEngineDatasetBinding;
|
|
1207
1444
|
/**
|
|
1208
|
-
*
|
|
1445
|
+
* Binding to an Artifacts instance. Artifacts provides git-compatible file
|
|
1446
|
+
* storage on Cloudflare Workers.
|
|
1209
1447
|
*/
|
|
1210
|
-
|
|
1211
|
-
/** If cache is enabled for this Worker. */
|
|
1212
|
-
enabled: boolean;
|
|
1213
|
-
/** Whether cached assets may be reused across Worker versions. */
|
|
1214
|
-
crossVersionCache?: boolean;
|
|
1215
|
-
};
|
|
1448
|
+
artifacts(options: ArtifactsBindingOptions): ArtifactsBinding;
|
|
1216
1449
|
/**
|
|
1217
|
-
*
|
|
1450
|
+
* Binding to the Worker's static assets.
|
|
1218
1451
|
*
|
|
1219
|
-
*
|
|
1452
|
+
* For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#assets
|
|
1220
1453
|
*/
|
|
1221
|
-
|
|
1222
|
-
mode: "off" | "smart";
|
|
1223
|
-
hint?: string;
|
|
1224
|
-
} | {
|
|
1225
|
-
mode?: "targeted";
|
|
1226
|
-
region: string;
|
|
1227
|
-
} | {
|
|
1228
|
-
mode?: "targeted";
|
|
1229
|
-
host: string;
|
|
1230
|
-
} | {
|
|
1231
|
-
mode?: "targeted";
|
|
1232
|
-
hostname: string;
|
|
1233
|
-
};
|
|
1454
|
+
assets(): AssetsBinding;
|
|
1234
1455
|
/**
|
|
1235
|
-
*
|
|
1236
|
-
* Only supported for the "standard" Usage Model.
|
|
1456
|
+
* Binding to a headless browser usable from the Worker.
|
|
1237
1457
|
*
|
|
1238
|
-
* For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#
|
|
1458
|
+
* For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#browser-rendering
|
|
1239
1459
|
*/
|
|
1240
|
-
|
|
1241
|
-
/** Maximum allowed CPU time for a Worker's invocation in milliseconds. */
|
|
1242
|
-
cpuMs?: number;
|
|
1243
|
-
/** Maximum allowed number of fetch requests that a Worker's invocation can execute. */
|
|
1244
|
-
subrequests?: number;
|
|
1245
|
-
};
|
|
1460
|
+
browser(options?: BrowserBindingOptions): BrowserBinding;
|
|
1246
1461
|
/**
|
|
1247
|
-
*
|
|
1462
|
+
* Binding to a D1 database.
|
|
1248
1463
|
*
|
|
1249
|
-
*
|
|
1464
|
+
* For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#d1-databases
|
|
1465
|
+
*/
|
|
1466
|
+
d1(options?: D1BindingOptions): D1Binding;
|
|
1467
|
+
/**
|
|
1468
|
+
* Binding to a Workers for Platforms dispatch namespace.
|
|
1250
1469
|
*
|
|
1251
|
-
* For
|
|
1252
|
-
* https://blog.cloudflare.com/logpush-for-workers/
|
|
1470
|
+
* For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#dispatch-namespace-bindings-workers-for-platforms
|
|
1253
1471
|
*/
|
|
1254
|
-
|
|
1472
|
+
dispatchNamespace(options?: DispatchNamespaceBindingOptions): DispatchNamespaceBinding;
|
|
1255
1473
|
/**
|
|
1256
|
-
*
|
|
1474
|
+
* Binding to a Durable Object class. `worker` is the name or config of the
|
|
1475
|
+
* Worker that defines the class; `exportName` is the exported class name.
|
|
1257
1476
|
*
|
|
1258
|
-
* For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#
|
|
1477
|
+
* For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#durable-objects
|
|
1259
1478
|
*/
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
/** The sampling rate. */
|
|
1264
|
-
headSamplingRate?: number;
|
|
1265
|
-
/**
|
|
1266
|
-
* Whether query strings are removed from request URLs in logs and traces.
|
|
1267
|
-
*
|
|
1268
|
-
* @default false
|
|
1269
|
-
*/
|
|
1270
|
-
redactQueryString?: boolean;
|
|
1271
|
-
logs?: {
|
|
1272
|
-
enabled?: boolean;
|
|
1273
|
-
/** The sampling rate. */
|
|
1274
|
-
headSamplingRate?: number;
|
|
1275
|
-
/** Set to false to disable invocation logs. */
|
|
1276
|
-
invocationLogs?: boolean;
|
|
1277
|
-
/**
|
|
1278
|
-
* If logs should be persisted to the Cloudflare observability platform where they can be queried in the dashboard.
|
|
1279
|
-
*
|
|
1280
|
-
* @default true
|
|
1281
|
-
*/
|
|
1282
|
-
persist?: boolean;
|
|
1283
|
-
/**
|
|
1284
|
-
* What destinations logs emitted from the Worker should be sent to.
|
|
1285
|
-
*
|
|
1286
|
-
* @default []
|
|
1287
|
-
*/
|
|
1288
|
-
destinations?: string[];
|
|
1289
|
-
};
|
|
1290
|
-
traces?: {
|
|
1291
|
-
enabled?: boolean;
|
|
1292
|
-
/** The sampling rate. */
|
|
1293
|
-
headSamplingRate?: number;
|
|
1294
|
-
/**
|
|
1295
|
-
* If traces should be persisted to the Cloudflare observability platform where they can be queried in the dashboard.
|
|
1296
|
-
*
|
|
1297
|
-
* @default true
|
|
1298
|
-
*/
|
|
1299
|
-
persist?: boolean;
|
|
1300
|
-
/**
|
|
1301
|
-
* What destinations traces emitted from the Worker should be sent to.
|
|
1302
|
-
*
|
|
1303
|
-
* @default []
|
|
1304
|
-
*/
|
|
1305
|
-
destinations?: string[];
|
|
1306
|
-
};
|
|
1307
|
-
};
|
|
1479
|
+
durableObject<TWorker$1 extends WorkerReference, TExportName$1 extends DurableObjectExportName<TWorker$1>>(options: DurableObjectBindingOptions<TWorker$1, TExportName$1>): DurableObjectBinding<TWorker$1, TExportName$1>;
|
|
1480
|
+
/** Binding to a Flagship feature-flag service. */
|
|
1481
|
+
flagship(options?: FlagshipBindingOptions): FlagshipBinding;
|
|
1308
1482
|
/**
|
|
1309
|
-
*
|
|
1310
|
-
* test and deploy your Worker.
|
|
1483
|
+
* Binding to a Hyperdrive configuration.
|
|
1311
1484
|
*
|
|
1312
|
-
* For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#
|
|
1485
|
+
* For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#hyperdrive
|
|
1486
|
+
*/
|
|
1487
|
+
hyperdrive(options: HyperdriveBindingOptions): HyperdriveBinding;
|
|
1488
|
+
/**
|
|
1489
|
+
* Binding to Cloudflare Images.
|
|
1313
1490
|
*
|
|
1314
|
-
*
|
|
1491
|
+
* For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#images
|
|
1315
1492
|
*/
|
|
1316
|
-
|
|
1493
|
+
images(options?: ImagesBindingOptions): ImagesBinding$1;
|
|
1317
1494
|
/**
|
|
1318
|
-
*
|
|
1319
|
-
*
|
|
1495
|
+
* Inline JSON value made available to the Worker on `env` under the
|
|
1496
|
+
* binding name.
|
|
1497
|
+
*/
|
|
1498
|
+
json<T$1 extends Json>(value: T$1): JsonBinding<T$1>;
|
|
1499
|
+
/**
|
|
1500
|
+
* Binding to a Workers KV namespace.
|
|
1320
1501
|
*
|
|
1321
|
-
*
|
|
1502
|
+
* For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#kv-namespaces
|
|
1322
1503
|
*/
|
|
1323
|
-
|
|
1504
|
+
kv<TKey extends string = string>(options?: KvBindingOptions): TypedKvBinding<TKey>;
|
|
1505
|
+
/** Binding for forwarding logs to logfwdr. */
|
|
1506
|
+
logfwdr(options: LogfwdrBindingOptions): LogfwdrBinding;
|
|
1507
|
+
/** Binding to Cloudflare Media Transformations. */
|
|
1508
|
+
media(options?: MediaBindingOptions): MediaBinding$1;
|
|
1324
1509
|
/**
|
|
1325
|
-
*
|
|
1510
|
+
* Binding to an uploaded mTLS certificate.
|
|
1326
1511
|
*
|
|
1327
|
-
*
|
|
1512
|
+
* For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#mtls-certificates
|
|
1328
1513
|
*/
|
|
1329
|
-
|
|
1514
|
+
mtlsCertificate(options: MtlsCertificateBindingOptions): MtlsCertificateBinding;
|
|
1515
|
+
/** Binding to a Cloudflare Pipeline. */
|
|
1516
|
+
pipeline<TRecord extends PipelineRecord = PipelineRecord>(options: PipelineBindingOptions): TypedPipelineBinding<TRecord>;
|
|
1330
1517
|
/**
|
|
1331
|
-
*
|
|
1332
|
-
* this configuration. Values are forwarded verbatim in the Worker's
|
|
1333
|
-
* upload metadata.
|
|
1518
|
+
* Producer binding to a Cloudflare Queue.
|
|
1334
1519
|
*
|
|
1335
|
-
*
|
|
1520
|
+
* For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#queues
|
|
1336
1521
|
*/
|
|
1337
|
-
|
|
1338
|
-
/**
|
|
1339
|
-
* Arbitrary key/value pairs that will be included in the uploaded metadata. Values specified
|
|
1340
|
-
* here will always be applied to metadata last, so can add new or override existing fields.
|
|
1341
|
-
*/
|
|
1342
|
-
metadata?: Record<string, unknown>;
|
|
1343
|
-
/**
|
|
1344
|
-
* Used for internal capnp uploads for the Workers runtime.
|
|
1345
|
-
*/
|
|
1346
|
-
capnp?: {
|
|
1347
|
-
basePath: string;
|
|
1348
|
-
sourceSchemas: string[];
|
|
1349
|
-
compiledSchema?: never;
|
|
1350
|
-
} | {
|
|
1351
|
-
basePath?: never;
|
|
1352
|
-
sourceSchemas?: never;
|
|
1353
|
-
compiledSchema: string;
|
|
1354
|
-
};
|
|
1355
|
-
};
|
|
1522
|
+
queue<TBody = unknown>(options?: QueueBindingOptions): TypedQueueBinding<TBody>;
|
|
1356
1523
|
/**
|
|
1357
|
-
*
|
|
1358
|
-
*
|
|
1524
|
+
* Binding to an R2 bucket.
|
|
1525
|
+
*
|
|
1526
|
+
* For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#r2-buckets
|
|
1359
1527
|
*/
|
|
1360
|
-
|
|
1528
|
+
r2(options?: R2BindingOptions): R2Binding;
|
|
1529
|
+
/** Binding to a rate limiter. */
|
|
1530
|
+
rateLimit(options: RateLimitBindingOptions): RateLimitBinding;
|
|
1361
1531
|
/**
|
|
1362
|
-
*
|
|
1363
|
-
*
|
|
1532
|
+
* Declares a secret that is required by your Worker, exposed on `env` under
|
|
1533
|
+
* the binding name.
|
|
1364
1534
|
*
|
|
1365
|
-
*
|
|
1535
|
+
* When defined, this binding:
|
|
1536
|
+
* - Replaces .dev.vars/.env/process.env inference for type generation
|
|
1537
|
+
* - Enables local dev validation with warnings for missing secrets
|
|
1366
1538
|
*
|
|
1367
|
-
*
|
|
1368
|
-
* - Declares Durable Object classes exported from this Worker.
|
|
1369
|
-
* For more information about Durable Objects, see the documentation at
|
|
1370
|
-
* https://developers.cloudflare.com/workers/learning/using-durable-objects.
|
|
1371
|
-
* For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#durable-objects.
|
|
1539
|
+
* For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#secrets-configuration-property
|
|
1372
1540
|
*/
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
* Settings shared by the other exports.
|
|
1377
|
-
* Authored as a named `settings` export via
|
|
1378
|
-
* `defineSettings`.
|
|
1379
|
-
*/
|
|
1380
|
-
interface SettingsConfig {
|
|
1541
|
+
secret(): SecretBinding;
|
|
1542
|
+
/** Binding to a Secrets Store secret. */
|
|
1543
|
+
secretsStoreSecret(options: SecretsStoreSecretBindingOptions): SecretsStoreSecretBinding;
|
|
1381
1544
|
/**
|
|
1382
|
-
*
|
|
1545
|
+
* Binding for sending email from inside the Worker.
|
|
1383
1546
|
*
|
|
1384
|
-
*
|
|
1385
|
-
* hand when authoring a raw config object without the helper.
|
|
1547
|
+
* For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#email-bindings
|
|
1386
1548
|
*/
|
|
1387
|
-
|
|
1549
|
+
sendEmail(options?: SendEmailBindingOptions): SendEmailBinding;
|
|
1550
|
+
/** Binding to Cloudflare Stream. */
|
|
1551
|
+
stream(options?: StreamBindingOptions): StreamBinding$1;
|
|
1388
1552
|
/**
|
|
1389
|
-
*
|
|
1390
|
-
*
|
|
1391
|
-
*
|
|
1392
|
-
*
|
|
1393
|
-
* the CLOUDFLARE_ACCOUNT_ID environment variable.
|
|
1553
|
+
* Inline string value made available to the Worker on `env` under the
|
|
1554
|
+
* binding name.
|
|
1555
|
+
*
|
|
1556
|
+
* For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#environment-variables
|
|
1394
1557
|
*/
|
|
1395
|
-
|
|
1558
|
+
text<T$1 extends string>(value: T$1): TextBinding<T$1>;
|
|
1396
1559
|
/**
|
|
1397
|
-
*
|
|
1560
|
+
* Binding to a Vectorize index.
|
|
1398
1561
|
*
|
|
1399
|
-
*
|
|
1400
|
-
* it can be set to `undefined` in configuration to delegate to the CLOUDFLARE_COMPLIANCE_REGION environment variable.
|
|
1562
|
+
* For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#vectorize-indexes
|
|
1401
1563
|
*/
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
*/
|
|
1410
|
-
interface WorkerDefinition<TConfig$1 extends WorkerConfig = WorkerConfig> extends Pick<Bindings, "durableObject" | "worker"> {
|
|
1411
|
-
[DEFINITION]: {
|
|
1412
|
-
config: ConfigInput<Omit<TConfig$1, "type">>;
|
|
1413
|
-
type: "worker";
|
|
1414
|
-
};
|
|
1415
|
-
}
|
|
1416
|
-
/**
|
|
1417
|
-
* Worker definition with typed cross-worker binding helpers.
|
|
1418
|
-
*/
|
|
1419
|
-
interface TypedWorkerDefinition<TConfig$1 extends WorkerConfig, TWorkerName extends string = InferWorkerName<TConfig$1>> extends WorkerDefinition<TConfig$1> {
|
|
1564
|
+
vectorize(options: VectorizeBindingOptions): VectorizeBinding;
|
|
1565
|
+
/** Binding to the Worker version's metadata. */
|
|
1566
|
+
versionMetadata(): VersionMetadataBinding;
|
|
1567
|
+
/** Binding to a VPC network. */
|
|
1568
|
+
vpcNetwork(options: VpcNetworkBindingOptions): VpcNetworkBinding;
|
|
1569
|
+
/** Binding to a VPC service. */
|
|
1570
|
+
vpcService(options: VpcServiceBindingOptions): VpcServiceBinding;
|
|
1420
1571
|
/**
|
|
1421
|
-
*
|
|
1422
|
-
*
|
|
1423
|
-
*
|
|
1424
|
-
* For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#durable-objects
|
|
1572
|
+
* Cloudflare Web Search binding. There is exactly one shared web corpus, so
|
|
1573
|
+
* the binding is zero-config — only the variable name is required.
|
|
1425
1574
|
*/
|
|
1426
|
-
|
|
1427
|
-
worker: TWorkerName;
|
|
1428
|
-
exportName: TExportName$1;
|
|
1429
|
-
}): TypedDurableObjectBinding<TConfig$1, TExportName$1>;
|
|
1575
|
+
webSearch(options?: WebSearchBindingOptions): WebSearchBinding;
|
|
1430
1576
|
/**
|
|
1431
|
-
* Service binding (Worker-to-Worker). `worker` is the name of the
|
|
1432
|
-
* Worker; `exportName` selects a named `WorkerEntrypoint` export
|
|
1433
|
-
* the default export).
|
|
1577
|
+
* Service binding (Worker-to-Worker). `worker` is the name or config of the
|
|
1578
|
+
* bound Worker; `exportName` selects a named `WorkerEntrypoint` export
|
|
1579
|
+
* (defaults to the default export).
|
|
1434
1580
|
*
|
|
1435
1581
|
* For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#service-bindings
|
|
1436
1582
|
*/
|
|
1437
|
-
worker<TExportName$1 extends
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
props?: Record<string, unknown>;
|
|
1441
|
-
dev?: BindingDevOptions;
|
|
1442
|
-
}): TypedWorkerBinding<TConfig$1, TExportName$1 extends string ? TExportName$1 : "default">;
|
|
1443
|
-
}
|
|
1444
|
-
type WorkerConfigExport<T$1 extends WorkerConfig = WorkerConfig> = ConfigInput<T$1>;
|
|
1445
|
-
/**
|
|
1446
|
-
* Authored Worker config shape — {@link WorkerConfig} without the `type`
|
|
1447
|
-
* discriminant, which `defineWorker` injects.
|
|
1448
|
-
*/
|
|
1449
|
-
type WorkerConfigInput = Omit<WorkerConfig, "type">;
|
|
1450
|
-
declare function defineWorker<const T$1 extends WorkerConfigInput>(config: (ctx: ConfigContext) => (WorkerConfigInput & T$1) | Promise<WorkerConfigInput & T$1>): TypedWorkerDefinition<T$1 & {
|
|
1451
|
-
type: "worker";
|
|
1452
|
-
}>;
|
|
1453
|
-
declare function defineWorker<const T$1 extends WorkerConfigInput>(config: (WorkerConfigInput & T$1) | Promise<WorkerConfigInput & T$1>): TypedWorkerDefinition<T$1 & {
|
|
1454
|
-
type: "worker";
|
|
1455
|
-
}>;
|
|
1456
|
-
//#endregion
|
|
1457
|
-
//#region src/inference.d.ts
|
|
1458
|
-
/**
|
|
1459
|
-
* The Worker's entry module, imported with the `{ type: "cf-worker" }` import attribute
|
|
1460
|
-
* @example
|
|
1461
|
-
* ```ts
|
|
1462
|
-
* import * as entrypoint from "./src" with { type: "cf-worker" };
|
|
1463
|
-
* ```
|
|
1464
|
-
*/
|
|
1465
|
-
type WorkerModule = Record<string, any>;
|
|
1466
|
-
/**
|
|
1467
|
-
* Default module type representing an unknown Worker's exports.
|
|
1468
|
-
* - default export can be `ExportedHandler` or a `WorkerEntrypoint` class constructor
|
|
1469
|
-
* - named exports can be `WorkerEntrypoint`, `DurableObject`, or `WorkflowEntrypoint` class constructors
|
|
1470
|
-
*/
|
|
1471
|
-
interface DefaultModule {
|
|
1472
|
-
default?: ExportedHandler | Constructor<Rpc.WorkerEntrypointBranded>;
|
|
1473
|
-
[key: string]: ExportedHandler | Constructor<Rpc.WorkerEntrypointBranded> | Constructor<Rpc.DurableObjectBranded> | Constructor<Rpc.WorkflowEntrypointBranded> | undefined;
|
|
1474
|
-
}
|
|
1475
|
-
/**
|
|
1476
|
-
* Represents a class constructor that creates instances of TInstance.
|
|
1477
|
-
*/
|
|
1478
|
-
type Constructor<TInstance> = new (...args: any[]) => TInstance;
|
|
1479
|
-
/**
|
|
1480
|
-
* Extracts the instance type from a class constructor if it extends `TInstance`.
|
|
1481
|
-
*/
|
|
1482
|
-
type ExtractInstance<T$1, TInstance> = T$1 extends Constructor<TInstance> ? InstanceType<T$1> : never;
|
|
1483
|
-
/**
|
|
1484
|
-
* Mapping from binding type literals to Cloudflare runtime types.
|
|
1485
|
-
*
|
|
1486
|
-
* Entries fall into two groups:
|
|
1487
|
-
* - Parameterized bindings (ai, json, kv, pipeline, queue, text) refine their
|
|
1488
|
-
* runtime type from the binding instance via nominal matches against the
|
|
1489
|
-
* `Typed*Binding` / `JsonBinding` / `TextBinding` interfaces from
|
|
1490
|
-
* `./bindings`. When `TBinding` does not match, the entry falls back to the
|
|
1491
|
-
* unparameterized runtime type.
|
|
1492
|
-
* - Non-parameterized bindings map their type literal directly to a runtime
|
|
1493
|
-
* type and ignore `TBinding`.
|
|
1494
|
-
*
|
|
1495
|
-
* IMPORTANT: The right-hand-side identifiers in this map (e.g. `KVNamespace`,
|
|
1496
|
-
* `ImagesBinding`, `Fetcher`) must resolve to the ambient runtime types from
|
|
1497
|
-
* `@cloudflare/workers-types`, not to local config interfaces. Several local
|
|
1498
|
-
* binding interfaces in `./bindings.ts` (`ImagesBinding`, `MediaBinding`,
|
|
1499
|
-
* `StreamBinding`) share names with ambient globals — importing those local
|
|
1500
|
-
* types into this file silently shadows the globals and breaks `InferEnv`.
|
|
1501
|
-
* Only import the `Typed*Binding`, `JsonBinding`, and `TextBinding` interfaces
|
|
1502
|
-
* from `./bindings` (their names do not collide with ambient globals); never
|
|
1503
|
-
* widen the import to a wildcard or to the plain `*Binding` interfaces.
|
|
1504
|
-
*/
|
|
1505
|
-
interface BindingTypeMap<TBinding> {
|
|
1506
|
-
ai: TBinding extends TypedAiBinding<infer T> ? Ai<T> : Ai;
|
|
1507
|
-
json: TBinding extends JsonBinding<infer T> ? T : never;
|
|
1508
|
-
kv: TBinding extends TypedKvBinding<infer T> ? KVNamespace<T> : KVNamespace;
|
|
1509
|
-
pipeline: TBinding extends TypedPipelineBinding<infer T> ? Pipeline<T> : Pipeline;
|
|
1510
|
-
queue: TBinding extends TypedQueueBinding<infer T> ? Queue<T> : Queue;
|
|
1511
|
-
text: TBinding extends TextBinding<infer T> ? T : never;
|
|
1512
|
-
"agent-memory": AgentMemoryNamespace;
|
|
1513
|
-
"ai-search": AiSearchInstance;
|
|
1514
|
-
"ai-search-namespace": AiSearchNamespace;
|
|
1515
|
-
"analytics-engine-dataset": AnalyticsEngineDataset;
|
|
1516
|
-
artifacts: Artifacts;
|
|
1517
|
-
assets: Fetcher;
|
|
1518
|
-
browser: BrowserRun;
|
|
1519
|
-
d1: D1Database;
|
|
1520
|
-
"dispatch-namespace": DispatchNamespace;
|
|
1521
|
-
"durable-object": DurableObjectNamespace;
|
|
1522
|
-
flagship: Flagship;
|
|
1523
|
-
hyperdrive: Hyperdrive;
|
|
1524
|
-
images: ImagesBinding;
|
|
1525
|
-
logfwdr: any;
|
|
1526
|
-
media: MediaBinding;
|
|
1527
|
-
"mtls-certificate": Fetcher;
|
|
1528
|
-
"rate-limit": RateLimit;
|
|
1529
|
-
r2: R2Bucket;
|
|
1530
|
-
secret: string;
|
|
1531
|
-
"secrets-store-secret": SecretsStoreSecret;
|
|
1532
|
-
"send-email": SendEmail;
|
|
1533
|
-
stream: StreamBinding;
|
|
1534
|
-
vectorize: VectorizeIndex;
|
|
1535
|
-
"version-metadata": WorkerVersionMetadata;
|
|
1536
|
-
"vpc-service": Fetcher;
|
|
1537
|
-
"vpc-network": Fetcher;
|
|
1538
|
-
"web-search": WebSearch;
|
|
1539
|
-
worker: Fetcher;
|
|
1540
|
-
"worker-loader": WorkerLoader;
|
|
1541
|
-
workflow: Workflow;
|
|
1583
|
+
worker<TWorker$1 extends WorkerReference, TExportName$1 extends WorkerEntrypointExportName<TWorker$1> | undefined = undefined>(options: WorkerBindingOptions<TWorker$1, TExportName$1>): WorkerBinding<TWorker$1, NoInfer<TExportName$1>>;
|
|
1584
|
+
/** Binding to a Worker Loader. */
|
|
1585
|
+
workerLoader(): WorkerLoaderBinding;
|
|
1542
1586
|
}
|
|
1543
|
-
|
|
1544
|
-
run(event: {
|
|
1545
|
-
payload: infer P;
|
|
1546
|
-
}, step: any): any;
|
|
1547
|
-
} ? Workflow<P> : Workflow : Workflow : never : never : TBinding extends {
|
|
1548
|
-
type: `unsafe:${string}`;
|
|
1549
|
-
} ? any : TBinding extends {
|
|
1550
|
-
type: infer K extends keyof BindingTypeMap<TBinding>;
|
|
1551
|
-
} ? BindingTypeMap<TBinding>[K] : never;
|
|
1552
|
-
/**
|
|
1553
|
-
* Infer the Worker name from a config.
|
|
1554
|
-
*
|
|
1555
|
-
* @example
|
|
1556
|
-
* ```typescript
|
|
1557
|
-
* import { defineWorker } from "@cloudflare/config";
|
|
1558
|
-
* import type { InferDurableNamespaces, UnwrapConfig } from "@cloudflare/config";
|
|
1559
|
-
*
|
|
1560
|
-
* const config = defineWorker({ name: "my-worker", ... });
|
|
1561
|
-
*
|
|
1562
|
-
* type WorkerConfig = UnwrapConfig<typeof config>;
|
|
1563
|
-
* // Inferred as: "my-worker"
|
|
1564
|
-
* type Name = InferWorkerName<WorkerConfig>;
|
|
1565
|
-
* ```
|
|
1566
|
-
*/
|
|
1567
|
-
type InferWorkerName<TUnwrappedConfig$1> = TUnwrappedConfig$1 extends {
|
|
1568
|
-
name: infer TName extends string;
|
|
1569
|
-
} ? TName : never;
|
|
1570
|
-
/**
|
|
1571
|
-
* Infer export names from a config's exports, optionally filtered by type.
|
|
1572
|
-
* When TExportType is `string` (default), returns all export names.
|
|
1573
|
-
* When TExportType is a specific literal like `"durable-object"` or `"workflow"`,
|
|
1574
|
-
* returns only exports of that type.
|
|
1575
|
-
*/
|
|
1576
|
-
type InferExportsByType<TUnwrappedConfig$1, TExportType extends string = string> = TUnwrappedConfig$1 extends {
|
|
1577
|
-
exports: infer TExports extends Record<string, {
|
|
1578
|
-
type: string;
|
|
1579
|
-
}>;
|
|
1580
|
-
} ? { [K in keyof TExports]: TExports[K] extends {
|
|
1581
|
-
type: TExportType;
|
|
1582
|
-
} ? K & string : never }[keyof TExports] : never;
|
|
1583
|
-
/**
|
|
1584
|
-
* Infer `WorkerEntrypoint` export names from a config.
|
|
1585
|
-
* Returns named module exports that are not declared as type `"durable-object"` or `"workflow"` in `exports`.
|
|
1586
|
-
* Excludes `"default"` since `exportName` should only be provided for named exports.
|
|
1587
|
-
*/
|
|
1588
|
-
type InferWorkerEntrypointExports<TUnwrappedConfig$1> = Exclude<keyof InferMainModule<TUnwrappedConfig$1> & string, "default" | InferExportsByType<TUnwrappedConfig$1, "durable-object" | "workflow">>;
|
|
1589
|
-
/**
|
|
1590
|
-
* Unwrap function and promise types to get the underlying config.
|
|
1591
|
-
* Use this to normalize a config before passing it to other inference utilities.
|
|
1592
|
-
*/
|
|
1593
|
-
type UnwrapConfig<TConfig$1> = TConfig$1 extends WorkerDefinition<infer TUnwrappedConfig> ? TUnwrappedConfig : TConfig$1 extends WorkerConfigExport<infer TUnwrappedConfig> ? TUnwrappedConfig : never;
|
|
1594
|
-
/**
|
|
1595
|
-
* Infer the `Env` interface type from a Worker config.
|
|
1596
|
-
*
|
|
1597
|
-
* Transforms a config object's `env` bindings into their
|
|
1598
|
-
* corresponding Cloudflare runtime types.
|
|
1599
|
-
*
|
|
1600
|
-
* @example
|
|
1601
|
-
* ```typescript
|
|
1602
|
-
* import { defineWorker, bindings } from "@cloudflare/config";
|
|
1603
|
-
* import type { InferEnv, UnwrapConfig } from "@cloudflare/config";
|
|
1604
|
-
*
|
|
1605
|
-
* const config = defineWorker({
|
|
1606
|
-
* env: {
|
|
1607
|
-
* MY_JSON: bindings.json({ id: string }),
|
|
1608
|
-
* MY_KV: bindings.kv(),
|
|
1609
|
-
* },
|
|
1610
|
-
* });
|
|
1611
|
-
*
|
|
1612
|
-
* type WorkerConfig = UnwrapConfig<typeof config>;
|
|
1613
|
-
* // Inferred as: { MY_JSON: { id: string }; MY_KV: KVNamespace }
|
|
1614
|
-
* export type Env = InferEnv<WorkerConfig>;
|
|
1615
|
-
* ```
|
|
1616
|
-
*/
|
|
1617
|
-
type InferEnv<TUnwrappedConfig$1> = TUnwrappedConfig$1 extends {
|
|
1618
|
-
env: infer TEnv extends Record<string, any>;
|
|
1619
|
-
} ? { [K in keyof TEnv]: InferBindingType<TEnv[K]> } : never;
|
|
1620
|
-
/**
|
|
1621
|
-
* Infer the Durable Object namespace names from a Worker config's exports.
|
|
1622
|
-
* Returns a union of export names that declare a *live* Durable Object —
|
|
1623
|
-
* `type: "durable-object"` with `state` either omitted, `"created"`, or
|
|
1624
|
-
* `"expecting-transfer"`. Tombstone entries (`deleted`, `renamed`,
|
|
1625
|
-
* `transferred`) are excluded because they retire the namespace and a
|
|
1626
|
-
* binding to a tombstoned class would fail at deploy time.
|
|
1627
|
-
*
|
|
1628
|
-
* @example
|
|
1629
|
-
* ```typescript
|
|
1630
|
-
* import { defineWorker } from "@cloudflare/config";
|
|
1631
|
-
* import type { InferDurableNamespaces, UnwrapConfig } from "@cloudflare/config";
|
|
1632
|
-
*
|
|
1633
|
-
* const config = defineWorker({
|
|
1634
|
-
* exports: {
|
|
1635
|
-
* MyDurableObject: { type: "durable-object", storage: "sqlite" },
|
|
1636
|
-
* OldGone: { type: "durable-object", state: "deleted" },
|
|
1637
|
-
* },
|
|
1638
|
-
* });
|
|
1639
|
-
*
|
|
1640
|
-
* type WorkerConfig = UnwrapConfig<typeof config>;
|
|
1641
|
-
* // Inferred as: "MyDurableObject" (the deleted tombstone is excluded)
|
|
1642
|
-
* type DurableNamespaces = InferDurableNamespaces<WorkerConfig>;
|
|
1643
|
-
* ```
|
|
1644
|
-
*/
|
|
1645
|
-
type InferDurableNamespaces<TUnwrappedConfig$1> = TUnwrappedConfig$1 extends {
|
|
1646
|
-
exports: infer TExports extends Record<string, {
|
|
1647
|
-
type: string;
|
|
1648
|
-
}>;
|
|
1649
|
-
} ? { [K in keyof TExports]: TExports[K] extends {
|
|
1650
|
-
type: "durable-object";
|
|
1651
|
-
} ? TExports[K] extends {
|
|
1652
|
-
state: "deleted" | "renamed" | "transferred";
|
|
1653
|
-
} ? never : K & string : never }[keyof TExports] : never;
|
|
1654
|
-
/**
|
|
1655
|
-
* Infer the main module type from a Worker config's entrypoint.
|
|
1656
|
-
* If entrypoint is a module namespace object, returns that type.
|
|
1657
|
-
* If entrypoint is a `string` or not present, returns `DefaultModule` as a fallback.
|
|
1658
|
-
*/
|
|
1659
|
-
type InferMainModule<TUnwrappedConfig$1> = TUnwrappedConfig$1 extends {
|
|
1660
|
-
entrypoint: infer TModule extends WorkerModule;
|
|
1661
|
-
} ? TModule : DefaultModule;
|
|
1587
|
+
declare const bindings: Bindings;
|
|
1662
1588
|
//#endregion
|
|
1663
1589
|
//#region src/settings-definition.d.ts
|
|
1590
|
+
type SettingsConfigExport<T$1 extends SettingsConfig = SettingsConfig> = ConfigInput<T$1>;
|
|
1664
1591
|
/**
|
|
1665
1592
|
* Authored settings config shape — {@link SettingsConfig} without the `type`
|
|
1666
1593
|
* discriminant, which `defineSettings` injects.
|
|
1667
1594
|
*/
|
|
1668
1595
|
type SettingsConfigInput = Omit<SettingsConfig, "type">;
|
|
1669
|
-
/**
|
|
1670
|
-
* A settings definition created by {@link defineSettings}.
|
|
1671
|
-
*/
|
|
1672
|
-
interface SettingsDefinition {
|
|
1673
|
-
[DEFINITION]: {
|
|
1674
|
-
config: ConfigInput<SettingsConfigInput>;
|
|
1675
|
-
type: "settings";
|
|
1676
|
-
};
|
|
1677
|
-
}
|
|
1678
1596
|
/**
|
|
1679
1597
|
* Declare shared settings.
|
|
1680
1598
|
* Authored as a named `settings` export.
|
|
1681
1599
|
*/
|
|
1682
|
-
declare
|
|
1600
|
+
declare const defineSettings: <const TInput extends ConfigInput<SettingsConfigInput>>(config: TInput) => TInput extends ((ctx: ConfigContext) => infer TResult) ? (ctx: ConfigContext) => TResult extends Promise<infer TConfig extends {
|
|
1601
|
+
[x: string]: unknown;
|
|
1602
|
+
}> ? Promise<ConfigWithType<TConfig, "settings">> : TResult extends {
|
|
1603
|
+
[x: string]: unknown;
|
|
1604
|
+
} ? ConfigWithType<TResult, "settings"> : never : TInput extends Promise<infer TConfig extends {
|
|
1605
|
+
[x: string]: unknown;
|
|
1606
|
+
}> ? Promise<ConfigWithType<TConfig, "settings">> : TInput extends {
|
|
1607
|
+
[x: string]: unknown;
|
|
1608
|
+
} ? ConfigWithType<TInput, "settings"> : never;
|
|
1683
1609
|
//#endregion
|
|
1684
1610
|
//#endregion
|
|
1685
|
-
export { AgentMemoryBinding, AiBinding, AiSearchBinding, AiSearchNamespaceBinding, AnalyticsEngineDatasetBinding, ArtifactsBinding, AssetsBinding, BindingDevOptions, Bindings, BrowserBinding, ConfigContext, ConnectTrigger, D1Binding, DispatchNamespaceBinding, DurableObjectBinding, DurableObjectCreatedExport, DurableObjectDeletedExport, DurableObjectExpectingTransferExport, DurableObjectRenamedExport, DurableObjectTransferredExport, EmailTrigger, Exports, FetchTrigger, FlagshipBinding, HyperdriveBinding, ImagesBinding$1 as ImagesBinding, InferDurableNamespaces, InferEnv, InferMainModule, JsonBinding, KvBinding, LogfwdrBinding, MediaBinding$1 as MediaBinding, MtlsCertificateBinding, PipelineBinding, QueueBinding, QueueConsumerTrigger, R2Binding, RateLimitBinding, ScheduledTrigger, SecretBinding, SecretsStoreSecretBinding, SendEmailBinding, SettingsConfig,
|
|
1611
|
+
export { AgentMemoryBinding, AiBinding, AiSearchBinding, AiSearchNamespaceBinding, AnalyticsEngineDatasetBinding, ArtifactsBinding, AssetsBinding, BindingDevOptions, Bindings, BrowserBinding, ConfigContext, ConnectTrigger, D1Binding, DispatchNamespaceBinding, DurableObjectBinding, DurableObjectCreatedExport, DurableObjectDeletedExport, DurableObjectExpectingTransferExport, DurableObjectRenamedExport, DurableObjectTransferredExport, EmailTrigger, Exports, FetchTrigger, FlagshipBinding, HyperdriveBinding, ImagesBinding$1 as ImagesBinding, InferDurableNamespaces, InferEnv, InferMainModule, JsonBinding, KvBinding, LogfwdrBinding, MediaBinding$1 as MediaBinding, MtlsCertificateBinding, PipelineBinding, QueueBinding, QueueConsumerTrigger, R2Binding, RateLimitBinding, ScheduledTrigger, SecretBinding, SecretsStoreSecretBinding, SendEmailBinding, SettingsConfig, SettingsConfigExport, SettingsConfigInput, StreamBinding$1 as StreamBinding, TextBinding, Triggers, TypedAiBinding, TypedKvBinding, TypedPipelineBinding, TypedQueueBinding, UnsafeBinding, UnwrapConfig, VectorizeBinding, VersionMetadataBinding, VpcNetworkBinding, VpcServiceBinding, WebSearchBinding, WorkerBinding, WorkerConfig, WorkerConfigExport, WorkerConfigInput, WorkerEntrypointExport, WorkerEntrypointExportOptions, WorkerLoaderBinding, WorkerReference, WorkflowBinding, bindings, defineSettings, defineWorker, exports, triggers };
|
|
1686
1612
|
//# sourceMappingURL=experimental-config.d.mts.map
|