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