@cloudflare/config 0.10.0 → 0.12.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 +234 -179
- package/dist/index.mjs +424 -19
- package/dist/{public-BwQqexwo.mjs → public-BYCVISMH.mjs} +31 -50
- package/dist/{public-DZgNmLyp.d.mts → public-CxIWEZqM.d.mts} +1509 -1384
- package/dist/public.d.mts +2 -2
- package/dist/public.mjs +2 -2
- package/package.json +3 -3
|
@@ -1,1682 +1,1807 @@
|
|
|
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/container-definition.d.ts
|
|
235
|
+
type ContainerConfigExport<T$1 extends ContainerConfig = ContainerConfig> = ConfigInput<T$1>;
|
|
236
|
+
type DistributiveOmit<T$1, K$1 extends PropertyKey> = T$1 extends unknown ? Omit<T$1, K$1> : never;
|
|
237
|
+
/**
|
|
238
|
+
* Authored Container config shape — {@link ContainerConfig} without the `type`
|
|
239
|
+
* discriminant, which `defineContainer` injects.
|
|
240
|
+
*/
|
|
241
|
+
type ContainerConfigInput = DistributiveOmit<ContainerConfig, "type">;
|
|
242
|
+
/** Declare a Container application. */
|
|
243
|
+
declare const defineContainer: <const TInput extends ConfigInput<ContainerConfigInput>>(config: TInput) => TInput extends ((ctx: ConfigContext) => infer TResult) ? (ctx: ConfigContext) => TResult extends Promise<infer TConfig extends {
|
|
244
|
+
[x: string]: unknown;
|
|
245
|
+
}> ? Promise<ConfigWithType<TConfig, "container">> : TResult extends {
|
|
246
|
+
[x: string]: unknown;
|
|
247
|
+
} ? ConfigWithType<TResult, "container"> : never : TInput extends Promise<infer TConfig extends {
|
|
248
|
+
[x: string]: unknown;
|
|
249
|
+
}> ? Promise<ConfigWithType<TConfig, "container">> : TInput extends {
|
|
250
|
+
[x: string]: unknown;
|
|
251
|
+
} ? ConfigWithType<TInput, "container"> : never;
|
|
252
|
+
//#endregion
|
|
253
|
+
//#region src/exports.d.ts
|
|
225
254
|
/**
|
|
226
|
-
*
|
|
227
|
-
*
|
|
255
|
+
* Storage backend for the Durable Object.
|
|
256
|
+
*
|
|
257
|
+
* Containers are only supported on the SQLite storage engine, so `container` is
|
|
258
|
+
* only offered alongside `storage: "sqlite"`.
|
|
228
259
|
*/
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
/**
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
}
|
|
260
|
+
type DurableObjectStorageOptions<TContainer extends ContainerConfigExport | undefined = ContainerConfigExport | undefined> = {
|
|
261
|
+
/**
|
|
262
|
+
* Selects the SQLite-backed storage engine (recommended for new
|
|
263
|
+
* classes).
|
|
264
|
+
*/
|
|
265
|
+
storage: "sqlite";
|
|
266
|
+
/**
|
|
267
|
+
* Attach a Container application to this Durable Object by config reference.
|
|
268
|
+
*/
|
|
269
|
+
container?: TContainer;
|
|
270
|
+
} | {
|
|
271
|
+
/** Selects the legacy key-value storage engine. */
|
|
272
|
+
storage: "legacy-kv";
|
|
273
|
+
};
|
|
240
274
|
/**
|
|
241
|
-
*
|
|
275
|
+
* Declares a provisioned Durable Object class exported from this Worker.
|
|
242
276
|
*
|
|
243
|
-
* For
|
|
277
|
+
* For more information about Durable Objects, see the documentation at
|
|
278
|
+
* https://developers.cloudflare.com/workers/learning/using-durable-objects
|
|
279
|
+
*
|
|
280
|
+
* For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#durable-objects
|
|
244
281
|
*/
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
}
|
|
282
|
+
type DurableObjectCreatedExportOptions<TContainer extends ContainerConfigExport | undefined = ContainerConfigExport | undefined> = {
|
|
283
|
+
state?: "created";
|
|
284
|
+
} & DurableObjectStorageOptions<TContainer>;
|
|
248
285
|
/**
|
|
249
|
-
*
|
|
286
|
+
* Retire a provisioned Durable Object namespace whose class has
|
|
287
|
+
* been removed from code.
|
|
250
288
|
*
|
|
251
|
-
*
|
|
289
|
+
* During deploy, the class must not be exported in the uploaded code, and no
|
|
290
|
+
* other Worker may hold a `durableObject` binding to the namespace.
|
|
252
291
|
*/
|
|
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;
|
|
268
|
-
}
|
|
269
|
-
/** Binding to Cloudflare Media Transformations. */
|
|
270
|
-
interface MediaBinding$1 extends MediaBindingOptions {
|
|
271
|
-
type: "media";
|
|
292
|
+
interface DurableObjectDeletedExportOptions {
|
|
293
|
+
state: "deleted";
|
|
272
294
|
}
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
295
|
+
/**
|
|
296
|
+
* Rename a provisioned Durable Object namespace's class. The
|
|
297
|
+
* `renamedTo` value must also appear as a live (`state: "created"`)
|
|
298
|
+
* `durableObject` entry in the same `exports` map.
|
|
299
|
+
*/
|
|
300
|
+
interface DurableObjectRenamedExportOptions {
|
|
301
|
+
state: "renamed";
|
|
302
|
+
/**
|
|
303
|
+
* The destination class name. Must be a valid JavaScript identifier and
|
|
304
|
+
* must appear as a live (`state: "created"`) `durableObject` entry in the
|
|
305
|
+
* same `exports` map.
|
|
306
|
+
*/
|
|
307
|
+
renamedTo: string;
|
|
278
308
|
}
|
|
279
309
|
/**
|
|
280
|
-
*
|
|
281
|
-
*
|
|
282
|
-
* For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#mtls-certificates
|
|
310
|
+
* Transfer ownership of a Durable Object namespace to another Worker in the same account.
|
|
311
|
+
* The target Worker must first deploy an `expectingTransfer` entry naming this Worker via `transferFrom`.
|
|
283
312
|
*/
|
|
284
|
-
interface
|
|
285
|
-
|
|
313
|
+
interface DurableObjectTransferredExportOptions {
|
|
314
|
+
state: "transferred";
|
|
315
|
+
/**
|
|
316
|
+
* The destination Worker. Must reference a Worker in the same account.
|
|
317
|
+
*/
|
|
318
|
+
transferredTo: string;
|
|
286
319
|
}
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
320
|
+
/**
|
|
321
|
+
* Prepare to receive cross-Worker Durable Object transfer.
|
|
322
|
+
* Once the source Worker's `transferred` export is deployed, this entry becomes a normal live `durable-object` export.
|
|
323
|
+
*/
|
|
324
|
+
type DurableObjectExpectingTransferExportOptions<TContainer extends ContainerConfigExport | undefined = ContainerConfigExport | undefined> = {
|
|
325
|
+
state: "expecting-transfer";
|
|
326
|
+
/**
|
|
327
|
+
* The source Worker for the two-phase cross-Worker transfer.
|
|
328
|
+
*/
|
|
329
|
+
transferFrom: string;
|
|
330
|
+
} & DurableObjectStorageOptions<TContainer>;
|
|
331
|
+
type DurableObjectCreatedExport<TContainer extends ContainerConfigExport | undefined = ContainerConfigExport | undefined> = DurableObjectCreatedExportOptions<TContainer> & {
|
|
332
|
+
type: "durable-object";
|
|
333
|
+
};
|
|
334
|
+
interface DurableObjectDeletedExport extends DurableObjectDeletedExportOptions {
|
|
335
|
+
type: "durable-object";
|
|
292
336
|
}
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
type: "pipeline";
|
|
337
|
+
interface DurableObjectRenamedExport extends DurableObjectRenamedExportOptions {
|
|
338
|
+
type: "durable-object";
|
|
296
339
|
}
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
/** @internal Carries type parameters for inference */
|
|
300
|
-
__typeParams: [TRecord];
|
|
340
|
+
interface DurableObjectTransferredExport extends DurableObjectTransferredExportOptions {
|
|
341
|
+
type: "durable-object";
|
|
301
342
|
}
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
343
|
+
type DurableObjectExpectingTransferExport<TContainer extends ContainerConfigExport | undefined = ContainerConfigExport | undefined> = DurableObjectExpectingTransferExportOptions<TContainer> & {
|
|
344
|
+
type: "durable-object";
|
|
345
|
+
};
|
|
346
|
+
type DurableObjectExportOptions = DurableObjectCreatedExportOptions | DurableObjectDeletedExportOptions | DurableObjectRenamedExportOptions | DurableObjectTransferredExportOptions | DurableObjectExpectingTransferExportOptions;
|
|
347
|
+
type DurableObjectExports = DurableObjectCreatedExport | DurableObjectDeletedExport | DurableObjectRenamedExport | DurableObjectTransferredExport | DurableObjectExpectingTransferExport;
|
|
348
|
+
interface WorkerEntrypointExportOptions {
|
|
349
|
+
cache?: {
|
|
350
|
+
/** Whether cache is enabled for this entrypoint. */
|
|
351
|
+
enabled: boolean;
|
|
352
|
+
};
|
|
309
353
|
}
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
*
|
|
313
|
-
* For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#queues
|
|
314
|
-
*/
|
|
315
|
-
interface QueueBinding extends QueueBindingOptions {
|
|
316
|
-
type: "queue";
|
|
354
|
+
interface WorkerEntrypointExport extends WorkerEntrypointExportOptions {
|
|
355
|
+
type: "worker";
|
|
317
356
|
}
|
|
318
357
|
/**
|
|
319
|
-
*
|
|
320
|
-
*
|
|
321
|
-
* For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#queues
|
|
358
|
+
* Configuration for named exports declared by the Worker. Each entry's
|
|
359
|
+
* key is the exported class name; the value configures the export.
|
|
322
360
|
*/
|
|
323
|
-
interface
|
|
324
|
-
/**
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
361
|
+
interface Exports {
|
|
362
|
+
/**
|
|
363
|
+
* Declares a Durable Object class defined by this Worker.
|
|
364
|
+
*
|
|
365
|
+
* For more information about Durable Objects, see the documentation at
|
|
366
|
+
* https://developers.cloudflare.com/workers/learning/using-durable-objects
|
|
367
|
+
*
|
|
368
|
+
* For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#durable-objects
|
|
369
|
+
*/
|
|
370
|
+
durableObject<TContainer extends ContainerConfigExport | undefined = undefined>(options: DurableObjectCreatedExportOptions<TContainer>): DurableObjectCreatedExport<TContainer>;
|
|
371
|
+
/**
|
|
372
|
+
* Retire a provisioned Durable Object namespace whose class has been removed from code.
|
|
373
|
+
*/
|
|
374
|
+
durableObject(options: DurableObjectDeletedExportOptions): DurableObjectDeletedExport;
|
|
375
|
+
/**
|
|
376
|
+
* Rename a provisioned Durable Object namespace's class.
|
|
377
|
+
*/
|
|
378
|
+
durableObject(options: DurableObjectRenamedExportOptions): DurableObjectRenamedExport;
|
|
379
|
+
/**
|
|
380
|
+
* Transfer ownership of a Durable Object namespace to another Worker in the same account.
|
|
381
|
+
*/
|
|
382
|
+
durableObject(options: DurableObjectTransferredExportOptions): DurableObjectTransferredExport;
|
|
383
|
+
/**
|
|
384
|
+
* Prepare to receive cross-Worker Durable Object transfer.
|
|
385
|
+
* The source Worker must follow up with a deployment containing a `transferred` export to commit the transfer.
|
|
386
|
+
*/
|
|
387
|
+
durableObject<TContainer extends ContainerConfigExport | undefined = undefined>(options: DurableObjectExpectingTransferExportOptions<TContainer>): DurableObjectExpectingTransferExport<TContainer>;
|
|
388
|
+
durableObject(options: DurableObjectExportOptions): DurableObjectExports;
|
|
389
|
+
/** Declares a WorkerEntrypoint export defined by this Worker. */
|
|
390
|
+
worker(options?: WorkerEntrypointExportOptions): WorkerEntrypointExport;
|
|
340
391
|
}
|
|
341
392
|
/**
|
|
342
|
-
*
|
|
393
|
+
* Exports builder for configuring Worker exports.
|
|
343
394
|
*
|
|
344
|
-
*
|
|
395
|
+
* @example
|
|
396
|
+
* ```typescript
|
|
397
|
+
* import { defineContainer, defineWorker, exports } from "@cloudflare/config";
|
|
398
|
+
*
|
|
399
|
+
* const myContainer = defineContainer({
|
|
400
|
+
* name: "my-container",
|
|
401
|
+
* image: { dockerfile: "./Dockerfile" },
|
|
402
|
+
* });
|
|
403
|
+
*
|
|
404
|
+
* export default defineWorker({
|
|
405
|
+
* exports: {
|
|
406
|
+
* MyDurableObject: exports.durableObject({ storage: "sqlite" }),
|
|
407
|
+
* MyContainerDO: exports.durableObject({ storage: "sqlite", container: myContainer }),
|
|
408
|
+
* OldClass: exports.durableObject({ state: "deleted" }),
|
|
409
|
+
* OldName: exports.durableObject({ state: "renamed", renamedTo: "NewName" }),
|
|
410
|
+
* Outgoing: exports.durableObject({ state: "transferred", transferredTo: "target-worker" }),
|
|
411
|
+
* Incoming: exports.durableObject({ state: "expecting-transfer", storage: "sqlite", transferFrom: "source-worker" }),
|
|
412
|
+
* },
|
|
413
|
+
* });
|
|
414
|
+
* ```
|
|
345
415
|
*/
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
interface
|
|
350
|
-
/**
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
interface RateLimitBinding extends RateLimitBindingOptions {
|
|
362
|
-
type: "rate-limit";
|
|
416
|
+
declare const exports: Exports;
|
|
417
|
+
//#endregion
|
|
418
|
+
//#region src/triggers.d.ts
|
|
419
|
+
interface FetchTriggerOptions {
|
|
420
|
+
/**
|
|
421
|
+
* A route that your Worker should be published to.
|
|
422
|
+
*
|
|
423
|
+
* For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#types-of-routes
|
|
424
|
+
*/
|
|
425
|
+
pattern: string;
|
|
426
|
+
/**
|
|
427
|
+
* The DNS zone the pattern is attached to. Required when the
|
|
428
|
+
* pattern is ambiguous.
|
|
429
|
+
*/
|
|
430
|
+
zone?: string;
|
|
363
431
|
}
|
|
364
432
|
/**
|
|
365
|
-
*
|
|
366
|
-
* the binding name.
|
|
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
|
|
433
|
+
* Fetch trigger — a route that your Worker should be published to.
|
|
371
434
|
*
|
|
372
|
-
* For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#
|
|
435
|
+
* For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#types-of-routes
|
|
373
436
|
*/
|
|
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;
|
|
437
|
+
interface FetchTrigger extends FetchTriggerOptions {
|
|
438
|
+
type: "fetch";
|
|
382
439
|
}
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
440
|
+
interface QueueConsumerTriggerOptions {
|
|
441
|
+
/** The name of the queue from which this consumer should consume. */
|
|
442
|
+
name: string;
|
|
443
|
+
/** The queue to send messages that failed to be consumed. */
|
|
444
|
+
deadLetterQueue?: string;
|
|
445
|
+
/** The maximum number of messages per batch. */
|
|
446
|
+
maxBatchSize?: number;
|
|
447
|
+
/** The maximum number of seconds to wait to fill a batch with messages. */
|
|
448
|
+
maxBatchTimeout?: number;
|
|
449
|
+
/**
|
|
450
|
+
* The maximum number of concurrent consumer Worker invocations.
|
|
451
|
+
* Leaving this unset will allow your consumer to scale to the
|
|
452
|
+
* maximum concurrency needed to keep up with the message backlog.
|
|
453
|
+
*/
|
|
454
|
+
maxConcurrency?: number | null;
|
|
455
|
+
/** The maximum number of retries for each message. */
|
|
456
|
+
maxRetries?: number;
|
|
457
|
+
/** The number of seconds to wait before retrying a message. */
|
|
458
|
+
retryDelay?: number;
|
|
459
|
+
/** The number of milliseconds to wait for pulled messages to become visible again. */
|
|
460
|
+
visibilityTimeoutMs?: number;
|
|
386
461
|
}
|
|
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
462
|
/**
|
|
406
|
-
*
|
|
463
|
+
* Queue consumer trigger — invokes this Worker when messages arrive on the
|
|
464
|
+
* named queue.
|
|
407
465
|
*
|
|
408
|
-
* For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#
|
|
466
|
+
* For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#queues
|
|
409
467
|
*/
|
|
410
|
-
|
|
411
|
-
type: "
|
|
412
|
-
};
|
|
413
|
-
interface StreamBindingOptions {
|
|
414
|
-
/** Options that only apply during local development. */
|
|
415
|
-
dev?: BindingDevOptions;
|
|
468
|
+
interface QueueConsumerTrigger extends QueueConsumerTriggerOptions {
|
|
469
|
+
type: "queue";
|
|
416
470
|
}
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
471
|
+
interface ScheduledTriggerOptions {
|
|
472
|
+
/**
|
|
473
|
+
* A "cron" definition to trigger a Worker's "scheduled" function.
|
|
474
|
+
*
|
|
475
|
+
* Lets you call Workers periodically, much like a cron job.
|
|
476
|
+
*
|
|
477
|
+
* More details here https://developers.cloudflare.com/workers/platform/cron-triggers
|
|
478
|
+
*/
|
|
479
|
+
schedule: string;
|
|
420
480
|
}
|
|
421
481
|
/**
|
|
422
|
-
*
|
|
423
|
-
* binding name.
|
|
482
|
+
* Scheduled (cron) trigger — invokes this Worker on the given schedules.
|
|
424
483
|
*
|
|
425
|
-
*
|
|
484
|
+
* More details here https://developers.cloudflare.com/workers/platform/cron-triggers
|
|
426
485
|
*/
|
|
427
|
-
interface
|
|
428
|
-
type: "
|
|
429
|
-
/** The string value made available to the Worker. */
|
|
430
|
-
value: T$1;
|
|
486
|
+
interface ScheduledTrigger extends ScheduledTriggerOptions {
|
|
487
|
+
type: "scheduled";
|
|
431
488
|
}
|
|
432
|
-
interface
|
|
433
|
-
/**
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
/** Plugin-specific options. */
|
|
441
|
-
options?: Record<string, unknown>;
|
|
442
|
-
};
|
|
443
|
-
[key: string]: unknown;
|
|
489
|
+
interface EmailTriggerOptions {
|
|
490
|
+
/**
|
|
491
|
+
* Inbound Email Routing addresses handled by this Worker.
|
|
492
|
+
*
|
|
493
|
+
* Each entry is a literal recipient address (e.g. `"support@example.com"`)
|
|
494
|
+
* or a `*@domain` catch-all (e.g. `"*@example.com"`).
|
|
495
|
+
*/
|
|
496
|
+
addresses: string[];
|
|
444
497
|
}
|
|
445
498
|
/**
|
|
446
|
-
*
|
|
447
|
-
*
|
|
448
|
-
* changes.
|
|
499
|
+
* Email trigger — invokes this Worker for the configured Email Routing
|
|
500
|
+
* addresses.
|
|
449
501
|
*/
|
|
450
|
-
interface
|
|
451
|
-
type:
|
|
502
|
+
interface EmailTrigger extends EmailTriggerOptions {
|
|
503
|
+
type: "email";
|
|
452
504
|
}
|
|
453
|
-
interface
|
|
454
|
-
/** The
|
|
455
|
-
|
|
456
|
-
/**
|
|
457
|
-
|
|
505
|
+
interface ConnectTriggerOptions {
|
|
506
|
+
/** The transport protocol to listen for. */
|
|
507
|
+
protocol: "tcp";
|
|
508
|
+
/** The port to listen on. */
|
|
509
|
+
port: number;
|
|
510
|
+
/** The address to bind to. Defaults to `127.0.0.1`. */
|
|
511
|
+
address?: string;
|
|
458
512
|
}
|
|
459
513
|
/**
|
|
460
|
-
*
|
|
461
|
-
*
|
|
462
|
-
*
|
|
514
|
+
* Connect trigger — invokes this Worker's `connect(socket, env, ctx)`
|
|
515
|
+
* handler for raw socket connections received on the configured
|
|
516
|
+
* protocol/port.
|
|
463
517
|
*/
|
|
464
|
-
interface
|
|
465
|
-
type: "
|
|
466
|
-
}
|
|
467
|
-
/** Binding to the Worker version's metadata. */
|
|
468
|
-
interface VersionMetadataBinding {
|
|
469
|
-
type: "version-metadata";
|
|
470
|
-
}
|
|
471
|
-
type VpcNetworkBindingOptions = {
|
|
472
|
-
/** The tunnel ID of the Cloudflare Tunnel to route traffic through. Mutually exclusive with `networkId`. */
|
|
473
|
-
tunnelId: string;
|
|
474
|
-
networkId?: never;
|
|
475
|
-
/** Options that only apply during local development. */
|
|
476
|
-
dev?: BindingDevOptions;
|
|
477
|
-
} | {
|
|
478
|
-
tunnelId?: never;
|
|
479
|
-
/** The network ID to route traffic through. Mutually exclusive with `tunnelId`. */
|
|
480
|
-
networkId: string;
|
|
481
|
-
/** Options that only apply during local development. */
|
|
482
|
-
dev?: BindingDevOptions;
|
|
483
|
-
};
|
|
484
|
-
/** Binding to a VPC network. */
|
|
485
|
-
type VpcNetworkBinding = VpcNetworkBindingOptions & {
|
|
486
|
-
type: "vpc-network";
|
|
487
|
-
};
|
|
488
|
-
interface VpcServiceBindingOptions {
|
|
489
|
-
/** The service ID of the VPC connectivity service. */
|
|
490
|
-
id: string;
|
|
491
|
-
/** Options that only apply during local development. */
|
|
492
|
-
dev?: BindingDevOptions;
|
|
493
|
-
}
|
|
494
|
-
/** Binding to a VPC service. */
|
|
495
|
-
interface VpcServiceBinding extends VpcServiceBindingOptions {
|
|
496
|
-
type: "vpc-service";
|
|
497
|
-
}
|
|
498
|
-
interface WebSearchBindingOptions {
|
|
499
|
-
/** Options that only apply during local development. */
|
|
500
|
-
dev?: BindingDevOptions;
|
|
518
|
+
interface ConnectTrigger extends ConnectTriggerOptions {
|
|
519
|
+
type: "connect";
|
|
501
520
|
}
|
|
502
521
|
/**
|
|
503
|
-
*
|
|
504
|
-
*
|
|
522
|
+
* Event triggers — fetch routes, queue consumers, cron schedules, Email
|
|
523
|
+
* Routing addresses, and raw sockets — that invoke this Worker.
|
|
524
|
+
* Construct entries with `triggers.fetch(...)`, `triggers.queue(...)`,
|
|
525
|
+
* `triggers.scheduled(...)`, `triggers.email(...)`, or `triggers.connect(...)`.
|
|
526
|
+
*
|
|
527
|
+
* For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#triggers
|
|
505
528
|
*/
|
|
506
|
-
interface
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
529
|
+
interface Triggers {
|
|
530
|
+
/**
|
|
531
|
+
* Fetch trigger — a route that your Worker should be published to.
|
|
532
|
+
*
|
|
533
|
+
* For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#types-of-routes
|
|
534
|
+
*/
|
|
535
|
+
fetch(options: FetchTriggerOptions): FetchTrigger;
|
|
536
|
+
/**
|
|
537
|
+
* Queue consumer trigger — invokes this Worker when messages arrive on the
|
|
538
|
+
* named queue.
|
|
539
|
+
*
|
|
540
|
+
* For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#queues
|
|
541
|
+
*/
|
|
542
|
+
queue(options: QueueConsumerTriggerOptions): QueueConsumerTrigger;
|
|
543
|
+
/**
|
|
544
|
+
* Scheduled (cron) trigger — invokes this Worker on the given schedules.
|
|
545
|
+
*
|
|
546
|
+
* More details here https://developers.cloudflare.com/workers/platform/cron-triggers
|
|
547
|
+
*/
|
|
548
|
+
scheduled(options: ScheduledTriggerOptions): ScheduledTrigger;
|
|
549
|
+
/**
|
|
550
|
+
* Email trigger — invokes this Worker for the configured Email Routing
|
|
551
|
+
* addresses.
|
|
552
|
+
*/
|
|
553
|
+
email(options: EmailTriggerOptions): EmailTrigger;
|
|
554
|
+
/**
|
|
555
|
+
* Connect trigger — invokes this Worker's `connect(socket, env, ctx)`
|
|
556
|
+
* handler for raw socket connections received on the configured
|
|
557
|
+
* protocol/port.
|
|
558
|
+
*/
|
|
559
|
+
connect(options: ConnectTriggerOptions): ConnectTrigger;
|
|
518
560
|
}
|
|
519
561
|
/**
|
|
520
|
-
*
|
|
521
|
-
* Worker; `exportName` selects a named `WorkerEntrypoint` export (defaults to
|
|
522
|
-
* the default export).
|
|
562
|
+
* Triggers builder for configuring event triggers.
|
|
523
563
|
*
|
|
524
|
-
*
|
|
564
|
+
* @example
|
|
565
|
+
* ```typescript
|
|
566
|
+
* import { defineWorker, triggers } from "@cloudflare/config";
|
|
567
|
+
*
|
|
568
|
+
* export default defineWorker({
|
|
569
|
+
* triggers: [
|
|
570
|
+
* triggers.fetch({ pattern: "example.com/*", zone: "example.com" }),
|
|
571
|
+
* triggers.queue({ name: "my-queue" }),
|
|
572
|
+
* triggers.scheduled({ schedule: "0 * * * *" }),
|
|
573
|
+
* triggers.scheduled({ schedule: "30 0 * * *" }),
|
|
574
|
+
* triggers.email({ addresses: ["support@example.com"] }),
|
|
575
|
+
* triggers.connect({ protocol: "tcp", port: 5432 }),
|
|
576
|
+
* ],
|
|
577
|
+
* });
|
|
578
|
+
* ```
|
|
525
579
|
*/
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
580
|
+
declare const triggers: Triggers;
|
|
581
|
+
//#endregion
|
|
582
|
+
//#region src/types.d.ts
|
|
529
583
|
/**
|
|
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
|
|
584
|
+
* Union of all binding definitions accepted in `env`.
|
|
535
585
|
*/
|
|
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
|
-
}
|
|
586
|
+
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;
|
|
552
587
|
/**
|
|
553
|
-
*
|
|
554
|
-
* the Workflow; `exportName` is the exported `WorkflowEntrypoint` class name.
|
|
588
|
+
* Union of all trigger definitions accepted in `triggers`.
|
|
555
589
|
*/
|
|
556
|
-
|
|
557
|
-
type: "workflow";
|
|
558
|
-
}
|
|
590
|
+
type Trigger = ConnectTrigger | EmailTrigger | FetchTrigger | QueueConsumerTrigger | ScheduledTrigger;
|
|
559
591
|
/**
|
|
560
|
-
*
|
|
561
|
-
*
|
|
592
|
+
* Union of all export definitions accepted in `exports`. Worker entries
|
|
593
|
+
* configure WorkerEntrypoint exports. Durable Object entries configure live
|
|
594
|
+
* classes and tombstone lifecycle operations.
|
|
562
595
|
*/
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
/**
|
|
567
|
-
|
|
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;
|
|
596
|
+
type Export = DurableObjectCreatedExport | DurableObjectDeletedExport | DurableObjectRenamedExport | DurableObjectTransferredExport | DurableObjectExpectingTransferExport | WorkerEntrypointExport;
|
|
597
|
+
/** An image source accepted in an authored Container configuration. */
|
|
598
|
+
type ContainerImage = {
|
|
599
|
+
/** The path to a Dockerfile. */
|
|
600
|
+
dockerfile: string;
|
|
575
601
|
/**
|
|
576
|
-
*
|
|
602
|
+
* Build context of the application.
|
|
577
603
|
*
|
|
578
|
-
*
|
|
579
|
-
*/
|
|
580
|
-
ai<TAiModelList extends AiModelListType = AiModels>(options?: AiBindingOptions): TypedAiBinding<TAiModelList>;
|
|
581
|
-
/**
|
|
582
|
-
* AI Search instance binding. Each binding is bound directly to a single
|
|
583
|
-
* pre-existing instance within the "default" namespace.
|
|
584
|
-
*/
|
|
585
|
-
aiSearch(options: AiSearchBindingOptions): AiSearchBinding;
|
|
586
|
-
/**
|
|
587
|
-
* AI Search namespace binding. Each binding is scoped to a namespace and
|
|
588
|
-
* allows dynamic instance CRUD within it.
|
|
604
|
+
* @default The directory containing `dockerfile`.
|
|
589
605
|
*/
|
|
590
|
-
|
|
606
|
+
buildContext?: string;
|
|
607
|
+
/** Image variables available to the image at build time only. */
|
|
608
|
+
buildVars?: Record<string, string>;
|
|
609
|
+
} | {
|
|
591
610
|
/**
|
|
592
|
-
*
|
|
611
|
+
* Reference to an existing image.
|
|
593
612
|
*
|
|
594
|
-
* For
|
|
595
|
-
|
|
596
|
-
analyticsEngineDataset(options?: AnalyticsEngineDatasetBindingOptions): AnalyticsEngineDatasetBinding;
|
|
597
|
-
/**
|
|
598
|
-
* Binding to an Artifacts instance. Artifacts provides git-compatible file
|
|
599
|
-
* storage on Cloudflare Workers.
|
|
613
|
+
* For supported registries, refer to
|
|
614
|
+
* https://developers.cloudflare.com/containers/guides/image-management/#use-pre-built-container-images
|
|
600
615
|
*/
|
|
601
|
-
|
|
616
|
+
reference: string;
|
|
617
|
+
};
|
|
618
|
+
/** Fields shared by all Container application configurations. */
|
|
619
|
+
interface BaseContainerConfig {
|
|
602
620
|
/**
|
|
603
|
-
*
|
|
621
|
+
* Discriminates this config as a Container config.
|
|
604
622
|
*
|
|
605
|
-
*
|
|
623
|
+
* Injected automatically by `defineContainer`; only needs to be written by
|
|
624
|
+
* hand when authoring a raw config object without the helper.
|
|
606
625
|
*/
|
|
607
|
-
|
|
626
|
+
type: "container";
|
|
608
627
|
/**
|
|
609
|
-
*
|
|
628
|
+
* Name of the application.
|
|
610
629
|
*
|
|
611
|
-
*
|
|
630
|
+
* This is also the identifier used to reference the Container from a Durable
|
|
631
|
+
* Object's `exports` entry via its `container` field.
|
|
612
632
|
*/
|
|
613
|
-
|
|
633
|
+
name: string;
|
|
634
|
+
/** Configures observability for Container instances. */
|
|
635
|
+
observability?: {
|
|
636
|
+
/** Whether observability is enabled. */
|
|
637
|
+
enabled?: boolean;
|
|
638
|
+
logs?: {
|
|
639
|
+
/** Whether log collection is enabled. */
|
|
640
|
+
enabled?: boolean;
|
|
641
|
+
};
|
|
642
|
+
} & ({
|
|
643
|
+
/** Percentage of Container instances targeted for observability. */
|
|
644
|
+
targetInstancePercentage?: number;
|
|
645
|
+
targetInstanceCount?: never;
|
|
646
|
+
} | {
|
|
647
|
+
targetInstancePercentage?: never;
|
|
648
|
+
/** Number of Container instances targeted for observability. */
|
|
649
|
+
targetInstanceCount?: number;
|
|
650
|
+
});
|
|
614
651
|
/**
|
|
615
|
-
*
|
|
652
|
+
* Passed through without client-side validation or transformation.
|
|
616
653
|
*
|
|
617
|
-
*
|
|
654
|
+
* @hidden
|
|
618
655
|
*/
|
|
619
|
-
|
|
656
|
+
unsafe?: Record<string, unknown>;
|
|
657
|
+
}
|
|
658
|
+
/** A Container application managed with a standard scheduling policy. */
|
|
659
|
+
interface StandardContainerConfig extends BaseContainerConfig {
|
|
660
|
+
/** The image to build or deploy. */
|
|
661
|
+
image: ContainerImage;
|
|
620
662
|
/**
|
|
621
|
-
*
|
|
663
|
+
* Maximum number of application instances.
|
|
622
664
|
*
|
|
623
|
-
*
|
|
665
|
+
* @default 20
|
|
624
666
|
*/
|
|
625
|
-
|
|
667
|
+
maxInstances?: number;
|
|
626
668
|
/**
|
|
627
|
-
*
|
|
628
|
-
*
|
|
669
|
+
* The instance type to be used for the Container.
|
|
670
|
+
* Select from one of the following named instance types:
|
|
629
671
|
*
|
|
630
|
-
*
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
672
|
+
* - lite: 1/16 vCPU, 256 MiB memory, and 2 GB disk
|
|
673
|
+
* - basic: 1/4 vCPU, 1 GiB memory, and 4 GB disk
|
|
674
|
+
* - standard-1: 1/2 vCPU, 4 GiB memory, and 8 GB disk
|
|
675
|
+
* - standard-2: 1 vCPU, 6 GiB memory, and 12 GB disk
|
|
676
|
+
* - standard-3: 2 vCPU, 8 GiB memory, and 16 GB disk
|
|
677
|
+
* - standard-4: 4 vCPU, 12 GiB memory, and 20 GB disk
|
|
678
|
+
*
|
|
679
|
+
* Customers on an enterprise plan have the additional option to set custom
|
|
680
|
+
* limits.
|
|
681
|
+
*
|
|
682
|
+
* @default "lite"
|
|
683
|
+
*/
|
|
684
|
+
instanceType?: "basic" | "lite" | "standard-1" | "standard-2" | "standard-3" | "standard-4" | {
|
|
685
|
+
/** @default 0.0625 (1/16 vCPU) */
|
|
686
|
+
vcpu?: number;
|
|
687
|
+
/** @default 256 MiB */
|
|
688
|
+
memoryMib?: number;
|
|
689
|
+
/** @default 2 GB */
|
|
690
|
+
diskMb?: number;
|
|
691
|
+
};
|
|
635
692
|
/**
|
|
636
|
-
*
|
|
693
|
+
* The scheduling policy of the application.
|
|
637
694
|
*
|
|
638
|
-
*
|
|
695
|
+
* @default "default"
|
|
639
696
|
*/
|
|
640
|
-
|
|
697
|
+
schedulingPolicy?: "default" | "regional";
|
|
698
|
+
ssh?: {
|
|
699
|
+
/**
|
|
700
|
+
* If enabled, users with write access to the Container application can
|
|
701
|
+
* connect to it over SSH.
|
|
702
|
+
*
|
|
703
|
+
* @default false
|
|
704
|
+
*/
|
|
705
|
+
enabled: boolean;
|
|
706
|
+
/**
|
|
707
|
+
* Port that the SSH service is running on.
|
|
708
|
+
*
|
|
709
|
+
* @default 22
|
|
710
|
+
*/
|
|
711
|
+
port?: number;
|
|
712
|
+
};
|
|
713
|
+
/** SSH public keys to put in the Container's authorized_keys file. */
|
|
714
|
+
authorizedKeys?: Array<{
|
|
715
|
+
name: string;
|
|
716
|
+
publicKey: string;
|
|
717
|
+
}>;
|
|
718
|
+
/** Scheduling constraints for Container placement. */
|
|
719
|
+
constraints?: {
|
|
720
|
+
/** Limit Container placement to specific geographic regions. */
|
|
721
|
+
regions?: Array<"ENAM" | "WNAM" | "EEUR" | "WEUR" | "APAC" | "SAM" | "ME" | "OC" | "AFR">;
|
|
722
|
+
/** Restrict Containers to compliance boundaries. */
|
|
723
|
+
jurisdiction?: "eu" | "fedramp";
|
|
724
|
+
};
|
|
725
|
+
rollout?: {
|
|
726
|
+
/**
|
|
727
|
+
* How a rollout should be created. It supports the following modes:
|
|
728
|
+
*
|
|
729
|
+
* - full-auto: The Container application will be rolled out fully
|
|
730
|
+
* automatically.
|
|
731
|
+
* - none: The Container application will not have a rollout or update.
|
|
732
|
+
* - full-manual: The Container application will be rolled out by manually
|
|
733
|
+
* progressing through the rollout steps.
|
|
734
|
+
*
|
|
735
|
+
* @default "full-auto"
|
|
736
|
+
* @hidden
|
|
737
|
+
*/
|
|
738
|
+
kind?: "full-auto" | "none" | "full-manual";
|
|
739
|
+
/**
|
|
740
|
+
* Configures what percentage of instances should be updated at each step of
|
|
741
|
+
* a rollout. You can specify this as a single number or an array of numbers.
|
|
742
|
+
*
|
|
743
|
+
* If this is a single number, each step will progress by that percentage.
|
|
744
|
+
* The options are 5, 10, 20, 25, 50, or 100.
|
|
745
|
+
*
|
|
746
|
+
* If this is an array, each step specifies the cumulative rollout progress.
|
|
747
|
+
* The final step must be 100.
|
|
748
|
+
*
|
|
749
|
+
* @default [10, 100]
|
|
750
|
+
*/
|
|
751
|
+
stepPercentage?: number | number[];
|
|
752
|
+
/**
|
|
753
|
+
* Configures the grace period, in seconds, for active instances before they
|
|
754
|
+
* are shut down during a rollout.
|
|
755
|
+
*
|
|
756
|
+
* @default 0
|
|
757
|
+
*/
|
|
758
|
+
activeGracePeriod?: number;
|
|
759
|
+
};
|
|
760
|
+
}
|
|
761
|
+
/** A Container application managed by a Durable Object. */
|
|
762
|
+
interface DurableObjectContainerConfig extends BaseContainerConfig {
|
|
763
|
+
schedulingPolicy: "durable-object";
|
|
764
|
+
/** Named images that the Durable Object can start. */
|
|
765
|
+
images?: Record<string, ContainerImage>;
|
|
766
|
+
}
|
|
767
|
+
/**
|
|
768
|
+
* Container application configuration. This is the input shape passed to
|
|
769
|
+
* `defineContainer` and is validated at runtime by `InputContainerSchema`.
|
|
770
|
+
*/
|
|
771
|
+
type ContainerConfig = DurableObjectContainerConfig | StandardContainerConfig;
|
|
772
|
+
/**
|
|
773
|
+
* Worker configuration. This is the input shape passed to
|
|
774
|
+
* [`defineWorker`](https://developers.cloudflare.com/workers/wrangler/configuration/).
|
|
775
|
+
*
|
|
776
|
+
* Fields are validated at runtime by `InputWorkerSchema` and normalised before
|
|
777
|
+
* being passed to downstream tooling.
|
|
778
|
+
*/
|
|
779
|
+
interface WorkerConfig {
|
|
641
780
|
/**
|
|
642
|
-
*
|
|
781
|
+
* Discriminates this config as a Worker config.
|
|
643
782
|
*
|
|
644
|
-
*
|
|
783
|
+
* Injected automatically by `defineWorker`; only needs to be written by
|
|
784
|
+
* hand when authoring a raw config object without the helper.
|
|
645
785
|
*/
|
|
646
|
-
|
|
786
|
+
type: "worker";
|
|
647
787
|
/**
|
|
648
|
-
*
|
|
649
|
-
* binding name.
|
|
788
|
+
* The name of your Worker.
|
|
650
789
|
*/
|
|
651
|
-
|
|
790
|
+
name: string;
|
|
652
791
|
/**
|
|
653
|
-
*
|
|
792
|
+
* A date in the form yyyy-mm-dd, which will be used to determine
|
|
793
|
+
* which version of the Workers runtime is used.
|
|
654
794
|
*
|
|
655
|
-
*
|
|
795
|
+
* More details at https://developers.cloudflare.com/workers/configuration/compatibility-dates
|
|
656
796
|
*/
|
|
657
|
-
|
|
658
|
-
/** Binding for forwarding logs to logfwdr. */
|
|
659
|
-
logfwdr(options: LogfwdrBindingOptions): LogfwdrBinding;
|
|
660
|
-
/** Binding to Cloudflare Media Transformations. */
|
|
661
|
-
media(options?: MediaBindingOptions): MediaBinding$1;
|
|
797
|
+
compatibilityDate: string;
|
|
662
798
|
/**
|
|
663
|
-
*
|
|
799
|
+
* A list of flags that enable features from upcoming features of
|
|
800
|
+
* the Workers runtime, usually used together with `compatibilityDate`.
|
|
664
801
|
*
|
|
665
|
-
*
|
|
802
|
+
* More details at https://developers.cloudflare.com/workers/configuration/compatibility-flags/
|
|
803
|
+
*
|
|
804
|
+
* @default []
|
|
666
805
|
*/
|
|
667
|
-
|
|
668
|
-
/** Binding to a Cloudflare Pipeline. */
|
|
669
|
-
pipeline<TRecord extends PipelineRecord = PipelineRecord>(options: PipelineBindingOptions): TypedPipelineBinding<TRecord>;
|
|
806
|
+
compatibilityFlags?: string[];
|
|
670
807
|
/**
|
|
671
|
-
*
|
|
808
|
+
* The entrypoint module that will be executed.
|
|
672
809
|
*
|
|
673
|
-
*
|
|
810
|
+
* May be either a path string (e.g. `"./src/index.ts"`) or a module
|
|
811
|
+
* namespace imported with the `cf-worker` import attribute.
|
|
812
|
+
*
|
|
813
|
+
* @example
|
|
814
|
+
* ```ts
|
|
815
|
+
* import * as entrypoint from "./src" with { type: "cf-worker" };
|
|
816
|
+
* export default defineWorker({ entrypoint });
|
|
817
|
+
* ```
|
|
674
818
|
*/
|
|
675
|
-
|
|
819
|
+
entrypoint?: string | WorkerModule;
|
|
676
820
|
/**
|
|
677
|
-
*
|
|
821
|
+
* Specify the directory of static assets to deploy/serve.
|
|
678
822
|
*
|
|
679
|
-
*
|
|
823
|
+
* More details at https://developers.cloudflare.com/workers/frameworks/
|
|
824
|
+
*
|
|
825
|
+
* For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#assets
|
|
680
826
|
*/
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
827
|
+
assets?: {
|
|
828
|
+
/** How to handle HTML requests. */
|
|
829
|
+
htmlHandling?: "auto-trailing-slash" | "drop-trailing-slash" | "force-trailing-slash" | "none";
|
|
830
|
+
/** How to handle requests that do not match an asset. */
|
|
831
|
+
notFoundHandling?: "single-page-application" | "404-page" | "none";
|
|
832
|
+
/**
|
|
833
|
+
* Matches will be routed to the User Worker, and matches to negative rules will go to the Asset Worker.
|
|
834
|
+
*
|
|
835
|
+
* Can also be `true`, indicating that every request should be routed to the User Worker.
|
|
836
|
+
*/
|
|
837
|
+
runWorkerFirst?: string[] | boolean;
|
|
838
|
+
};
|
|
684
839
|
/**
|
|
685
|
-
*
|
|
686
|
-
* the binding name.
|
|
687
|
-
*
|
|
688
|
-
* When defined, this binding:
|
|
689
|
-
* - Replaces .dev.vars/.env/process.env inference for type generation
|
|
690
|
-
* - Enables local dev validation with warnings for missing secrets
|
|
840
|
+
* Custom domains that your Worker should be published to.
|
|
691
841
|
*
|
|
692
|
-
* For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#
|
|
842
|
+
* For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#types-of-routes
|
|
693
843
|
*/
|
|
694
|
-
|
|
695
|
-
/** Binding to a Secrets Store secret. */
|
|
696
|
-
secretsStoreSecret(options: SecretsStoreSecretBindingOptions): SecretsStoreSecretBinding;
|
|
844
|
+
domains?: string[];
|
|
697
845
|
/**
|
|
698
|
-
*
|
|
846
|
+
* Event triggers — fetch routes, queue consumers, cron schedules, Email
|
|
847
|
+
* Routing addresses, and raw sockets — that invoke this Worker.
|
|
848
|
+
* Construct entries with `triggers.fetch(...)`, `triggers.queue(...)`,
|
|
849
|
+
* `triggers.scheduled(...)`, `triggers.email(...)`, or
|
|
850
|
+
* `triggers.connect(...)`.
|
|
699
851
|
*
|
|
700
|
-
* For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#
|
|
852
|
+
* For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#triggers
|
|
701
853
|
*/
|
|
702
|
-
|
|
703
|
-
/** Binding to Cloudflare Stream. */
|
|
704
|
-
stream(options?: StreamBindingOptions): StreamBinding$1;
|
|
854
|
+
triggers?: Trigger[];
|
|
705
855
|
/**
|
|
706
|
-
*
|
|
707
|
-
* binding name.
|
|
856
|
+
* A list of Tail Workers that are bound to this Worker.
|
|
708
857
|
*
|
|
709
|
-
*
|
|
858
|
+
* `@cloudflare/config` unifies regular and streaming tail consumers under
|
|
859
|
+
* a single field; pass `streaming: true` to forward streaming tail events.
|
|
860
|
+
*
|
|
861
|
+
* @default []
|
|
710
862
|
*/
|
|
711
|
-
|
|
863
|
+
tailConsumers?: Array<{
|
|
864
|
+
/** The name of the service tail events will be forwarded to. */
|
|
865
|
+
worker: string;
|
|
866
|
+
/** Whether to stream tail events in real time. */
|
|
867
|
+
streaming?: boolean;
|
|
868
|
+
}>;
|
|
712
869
|
/**
|
|
713
|
-
*
|
|
714
|
-
*
|
|
715
|
-
* For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#vectorize-indexes
|
|
870
|
+
* Specify the cache behavior of the Worker.
|
|
716
871
|
*/
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
vpcService(options: VpcServiceBindingOptions): VpcServiceBinding;
|
|
872
|
+
cache?: {
|
|
873
|
+
/** If cache is enabled for this Worker. */
|
|
874
|
+
enabled: boolean;
|
|
875
|
+
/** Whether cached assets may be reused across Worker versions. */
|
|
876
|
+
crossVersionCache?: boolean;
|
|
877
|
+
};
|
|
724
878
|
/**
|
|
725
|
-
*
|
|
726
|
-
*
|
|
879
|
+
* Specify how the Worker should be located to minimize round-trip time.
|
|
880
|
+
*
|
|
881
|
+
* More details: https://developers.cloudflare.com/workers/platform/smart-placement/
|
|
727
882
|
*/
|
|
728
|
-
|
|
883
|
+
placement?: {
|
|
884
|
+
mode: "off" | "smart";
|
|
885
|
+
hint?: string;
|
|
886
|
+
} | {
|
|
887
|
+
mode?: "targeted";
|
|
888
|
+
region: string;
|
|
889
|
+
} | {
|
|
890
|
+
mode?: "targeted";
|
|
891
|
+
host: string;
|
|
892
|
+
} | {
|
|
893
|
+
mode?: "targeted";
|
|
894
|
+
hostname: string;
|
|
895
|
+
};
|
|
729
896
|
/**
|
|
730
|
-
*
|
|
731
|
-
*
|
|
732
|
-
* the default export).
|
|
897
|
+
* Specify limits for runtime behavior.
|
|
898
|
+
* Only supported for the "standard" Usage Model.
|
|
733
899
|
*
|
|
734
|
-
* For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#
|
|
900
|
+
* For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#limits
|
|
735
901
|
*/
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
//#region src/triggers.d.ts
|
|
743
|
-
interface FetchTriggerOptions {
|
|
902
|
+
limits?: {
|
|
903
|
+
/** Maximum allowed CPU time for a Worker's invocation in milliseconds. */
|
|
904
|
+
cpuMs?: number;
|
|
905
|
+
/** Maximum allowed number of fetch requests that a Worker's invocation can execute. */
|
|
906
|
+
subrequests?: number;
|
|
907
|
+
};
|
|
744
908
|
/**
|
|
745
|
-
*
|
|
909
|
+
* Send Trace Events from this Worker to Workers Logpush.
|
|
746
910
|
*
|
|
747
|
-
*
|
|
911
|
+
* This will not configure a corresponding Logpush job automatically.
|
|
912
|
+
*
|
|
913
|
+
* For more information about Workers Logpush, see:
|
|
914
|
+
* https://blog.cloudflare.com/logpush-for-workers/
|
|
748
915
|
*/
|
|
749
|
-
|
|
916
|
+
logpush?: boolean;
|
|
750
917
|
/**
|
|
751
|
-
*
|
|
752
|
-
*
|
|
918
|
+
* Specify the observability behavior of the Worker.
|
|
919
|
+
*
|
|
920
|
+
* For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#observability
|
|
753
921
|
*/
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
922
|
+
observability?: {
|
|
923
|
+
/** If observability is enabled for this Worker. */
|
|
924
|
+
enabled?: boolean;
|
|
925
|
+
/** The sampling rate. */
|
|
926
|
+
headSamplingRate?: number;
|
|
927
|
+
/**
|
|
928
|
+
* Whether query strings are removed from request URLs in logs and traces.
|
|
929
|
+
*
|
|
930
|
+
* @default false
|
|
931
|
+
*/
|
|
932
|
+
redactQueryString?: boolean;
|
|
933
|
+
logs?: {
|
|
934
|
+
enabled?: boolean;
|
|
935
|
+
/** The sampling rate. */
|
|
936
|
+
headSamplingRate?: number;
|
|
937
|
+
/** Set to false to disable invocation logs. */
|
|
938
|
+
invocationLogs?: boolean;
|
|
939
|
+
/**
|
|
940
|
+
* If logs should be persisted to the Cloudflare observability platform where they can be queried in the dashboard.
|
|
941
|
+
*
|
|
942
|
+
* @default true
|
|
943
|
+
*/
|
|
944
|
+
persist?: boolean;
|
|
945
|
+
/**
|
|
946
|
+
* What destinations logs emitted from the Worker should be sent to.
|
|
947
|
+
*
|
|
948
|
+
* @default []
|
|
949
|
+
*/
|
|
950
|
+
destinations?: string[];
|
|
951
|
+
};
|
|
952
|
+
traces?: {
|
|
953
|
+
enabled?: boolean;
|
|
954
|
+
/** The sampling rate. */
|
|
955
|
+
headSamplingRate?: number;
|
|
956
|
+
/**
|
|
957
|
+
* If traces should be persisted to the Cloudflare observability platform where they can be queried in the dashboard.
|
|
958
|
+
*
|
|
959
|
+
* @default true
|
|
960
|
+
*/
|
|
961
|
+
persist?: boolean;
|
|
962
|
+
/**
|
|
963
|
+
* What destinations traces emitted from the Worker should be sent to.
|
|
964
|
+
*
|
|
965
|
+
* @default []
|
|
966
|
+
*/
|
|
967
|
+
destinations?: string[];
|
|
968
|
+
};
|
|
969
|
+
};
|
|
773
970
|
/**
|
|
774
|
-
*
|
|
775
|
-
*
|
|
776
|
-
*
|
|
971
|
+
* Whether we use `<name>.<subdomain>.workers.dev` to
|
|
972
|
+
* test and deploy your Worker.
|
|
973
|
+
*
|
|
974
|
+
* For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#workersdev
|
|
975
|
+
*
|
|
976
|
+
* @default true
|
|
777
977
|
*/
|
|
778
|
-
|
|
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;
|
|
785
|
-
}
|
|
786
|
-
/**
|
|
787
|
-
* Queue consumer trigger — invokes this Worker when messages arrive on the
|
|
788
|
-
* named queue.
|
|
789
|
-
*
|
|
790
|
-
* For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#queues
|
|
791
|
-
*/
|
|
792
|
-
interface QueueConsumerTrigger extends QueueConsumerTriggerOptions {
|
|
793
|
-
type: "queue";
|
|
794
|
-
}
|
|
795
|
-
interface ScheduledTriggerOptions {
|
|
978
|
+
workersDev?: boolean;
|
|
796
979
|
/**
|
|
797
|
-
*
|
|
980
|
+
* Whether we use `<version>-<name>.<subdomain>.workers.dev` to
|
|
981
|
+
* serve Preview URLs for your Worker.
|
|
798
982
|
*
|
|
799
|
-
*
|
|
983
|
+
* @default false
|
|
984
|
+
*/
|
|
985
|
+
previewUrls?: boolean;
|
|
986
|
+
/**
|
|
987
|
+
* Designates this Worker as an internal-only "first-party" Worker.
|
|
800
988
|
*
|
|
801
|
-
*
|
|
989
|
+
* @internal
|
|
802
990
|
*/
|
|
803
|
-
|
|
804
|
-
}
|
|
805
|
-
/**
|
|
806
|
-
* Scheduled (cron) trigger — invokes this Worker on the given schedules.
|
|
807
|
-
*
|
|
808
|
-
* More details here https://developers.cloudflare.com/workers/platform/cron-triggers
|
|
809
|
-
*/
|
|
810
|
-
interface ScheduledTrigger extends ScheduledTriggerOptions {
|
|
811
|
-
type: "scheduled";
|
|
812
|
-
}
|
|
813
|
-
interface EmailTriggerOptions {
|
|
991
|
+
firstPartyWorker?: boolean;
|
|
814
992
|
/**
|
|
815
|
-
*
|
|
993
|
+
* "Unsafe" tables for runtime features that aren't directly supported by
|
|
994
|
+
* this configuration. Values are forwarded verbatim in the Worker's
|
|
995
|
+
* upload metadata.
|
|
816
996
|
*
|
|
817
|
-
*
|
|
818
|
-
* or a `*@domain` catch-all (e.g. `"*@example.com"`).
|
|
997
|
+
* @default {}
|
|
819
998
|
*/
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
* handler for raw socket connections received on the configured
|
|
840
|
-
* protocol/port.
|
|
841
|
-
*/
|
|
842
|
-
interface ConnectTrigger extends ConnectTriggerOptions {
|
|
843
|
-
type: "connect";
|
|
844
|
-
}
|
|
845
|
-
/**
|
|
846
|
-
* Event triggers — fetch routes, queue consumers, cron schedules, Email
|
|
847
|
-
* Routing addresses, and raw sockets — that invoke this Worker.
|
|
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
|
|
852
|
-
*/
|
|
853
|
-
interface Triggers {
|
|
999
|
+
unsafe?: {
|
|
1000
|
+
/**
|
|
1001
|
+
* Arbitrary key/value pairs that will be included in the uploaded metadata. Values specified
|
|
1002
|
+
* here will always be applied to metadata last, so can add new or override existing fields.
|
|
1003
|
+
*/
|
|
1004
|
+
metadata?: Record<string, unknown>;
|
|
1005
|
+
/**
|
|
1006
|
+
* Used for internal capnp uploads for the Workers runtime.
|
|
1007
|
+
*/
|
|
1008
|
+
capnp?: {
|
|
1009
|
+
basePath: string;
|
|
1010
|
+
sourceSchemas: string[];
|
|
1011
|
+
compiledSchema?: never;
|
|
1012
|
+
} | {
|
|
1013
|
+
basePath?: never;
|
|
1014
|
+
sourceSchemas?: never;
|
|
1015
|
+
compiledSchema: string;
|
|
1016
|
+
};
|
|
1017
|
+
};
|
|
854
1018
|
/**
|
|
855
|
-
*
|
|
856
|
-
*
|
|
857
|
-
* For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#types-of-routes
|
|
1019
|
+
* Bindings exposed on the Worker's `env` object. Construct entries with
|
|
1020
|
+
* `bindings.kv(...)`, `bindings.r2(...)`, etc.
|
|
858
1021
|
*/
|
|
859
|
-
|
|
1022
|
+
env?: Record<string, Binding>;
|
|
860
1023
|
/**
|
|
861
|
-
*
|
|
862
|
-
*
|
|
1024
|
+
* Configuration for named exports declared by the Worker. Each entry's
|
|
1025
|
+
* key is the exported class name; the value configures the export.
|
|
863
1026
|
*
|
|
864
|
-
*
|
|
1027
|
+
* Only one export kind is currently supported:
|
|
1028
|
+
*
|
|
1029
|
+
* - Construct entries with `exports.durableObject(...)`.
|
|
1030
|
+
* - Declares Durable Object classes exported from this Worker.
|
|
1031
|
+
* For more information about Durable Objects, see the documentation at
|
|
1032
|
+
* https://developers.cloudflare.com/workers/learning/using-durable-objects.
|
|
1033
|
+
* For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#durable-objects.
|
|
865
1034
|
*/
|
|
866
|
-
|
|
1035
|
+
exports?: Record<string, Export>;
|
|
1036
|
+
}
|
|
1037
|
+
/**
|
|
1038
|
+
* Settings shared by the other exports.
|
|
1039
|
+
* Authored as a named `settings` export via
|
|
1040
|
+
* `defineSettings`.
|
|
1041
|
+
*/
|
|
1042
|
+
interface SettingsConfig {
|
|
867
1043
|
/**
|
|
868
|
-
*
|
|
1044
|
+
* Discriminates this config as a settings config.
|
|
869
1045
|
*
|
|
870
|
-
*
|
|
1046
|
+
* Injected automatically by `defineSettings`; only needs to be written by
|
|
1047
|
+
* hand when authoring a raw config object without the helper.
|
|
871
1048
|
*/
|
|
872
|
-
|
|
1049
|
+
type: "settings";
|
|
873
1050
|
/**
|
|
874
|
-
*
|
|
875
|
-
*
|
|
1051
|
+
* This is the ID of the account associated with your zone.
|
|
1052
|
+
* You might have more than one account, so make sure to use
|
|
1053
|
+
* the ID of the account associated with the zone/route you
|
|
1054
|
+
* provide, if you provide one. It can also be specified through
|
|
1055
|
+
* the CLOUDFLARE_ACCOUNT_ID environment variable.
|
|
876
1056
|
*/
|
|
877
|
-
|
|
1057
|
+
accountId?: string;
|
|
878
1058
|
/**
|
|
879
|
-
*
|
|
880
|
-
*
|
|
881
|
-
*
|
|
1059
|
+
* Specify the compliance region mode of the Worker.
|
|
1060
|
+
*
|
|
1061
|
+
* Although if the user does not specify a compliance region, the default is `public`,
|
|
1062
|
+
* it can be set to `undefined` in configuration to delegate to the CLOUDFLARE_COMPLIANCE_REGION environment variable.
|
|
882
1063
|
*/
|
|
883
|
-
|
|
1064
|
+
complianceRegion?: "public" | "fedramp-high";
|
|
884
1065
|
}
|
|
1066
|
+
//#endregion
|
|
1067
|
+
//#region src/worker-definition.d.ts
|
|
1068
|
+
type WorkerConfigExport<T$1 extends WorkerConfig = WorkerConfig> = ConfigInput<T$1>;
|
|
885
1069
|
/**
|
|
886
|
-
*
|
|
887
|
-
*
|
|
888
|
-
* @example
|
|
889
|
-
* ```typescript
|
|
890
|
-
* import { defineWorker, triggers } from "@cloudflare/config";
|
|
891
|
-
*
|
|
892
|
-
* export default defineWorker({
|
|
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
|
-
* ```
|
|
1070
|
+
* Authored Worker config shape — {@link WorkerConfig} without the `type`
|
|
1071
|
+
* discriminant, which `defineWorker` injects.
|
|
903
1072
|
*/
|
|
904
|
-
|
|
1073
|
+
type WorkerConfigInput = Omit<WorkerConfig, "type">;
|
|
1074
|
+
declare const defineWorker: <const TInput extends ConfigInput<WorkerConfigInput>>(config: TInput) => TInput extends ((ctx: ConfigContext) => infer TResult) ? (ctx: ConfigContext) => TResult extends Promise<infer TConfig extends {
|
|
1075
|
+
[x: string]: unknown;
|
|
1076
|
+
}> ? Promise<ConfigWithType<TConfig, "worker">> : TResult extends {
|
|
1077
|
+
[x: string]: unknown;
|
|
1078
|
+
} ? ConfigWithType<TResult, "worker"> : never : TInput extends Promise<infer TConfig extends {
|
|
1079
|
+
[x: string]: unknown;
|
|
1080
|
+
}> ? Promise<ConfigWithType<TConfig, "worker">> : TInput extends {
|
|
1081
|
+
[x: string]: unknown;
|
|
1082
|
+
} ? ConfigWithType<TInput, "worker"> : never;
|
|
905
1083
|
//#endregion
|
|
906
|
-
//#region src/
|
|
1084
|
+
//#region src/bindings.d.ts
|
|
1085
|
+
/** Options that control a binding during local development. */
|
|
1086
|
+
interface BindingDevOptions {
|
|
1087
|
+
/** Whether the binding should connect to the remote resource. */
|
|
1088
|
+
remote?: boolean;
|
|
1089
|
+
}
|
|
1090
|
+
interface AgentMemoryBindingOptions {
|
|
1091
|
+
/** The user-chosen namespace name. Must exist in Cloudflare at deploy time. */
|
|
1092
|
+
namespace: string;
|
|
1093
|
+
/** Options that only apply during local development. */
|
|
1094
|
+
dev?: BindingDevOptions;
|
|
1095
|
+
}
|
|
907
1096
|
/**
|
|
908
|
-
*
|
|
909
|
-
*
|
|
910
|
-
* Containers are only supported on the SQLite storage engine, so `container` is
|
|
911
|
-
* only offered alongside `storage: "sqlite"`.
|
|
1097
|
+
* Agent Memory namespace binding. Each binding is scoped to a namespace and
|
|
1098
|
+
* allows agents to persist and recall memory.
|
|
912
1099
|
*/
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
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
|
-
};
|
|
1100
|
+
interface AgentMemoryBinding extends AgentMemoryBindingOptions {
|
|
1101
|
+
type: "agent-memory";
|
|
1102
|
+
}
|
|
1103
|
+
interface AiBindingOptions {
|
|
1104
|
+
/** Options that only apply during local development. */
|
|
1105
|
+
dev?: BindingDevOptions;
|
|
1106
|
+
}
|
|
928
1107
|
/**
|
|
929
|
-
*
|
|
930
|
-
*
|
|
931
|
-
* For more information about Durable Objects, see the documentation at
|
|
932
|
-
* https://developers.cloudflare.com/workers/learning/using-durable-objects
|
|
1108
|
+
* Binding to the Workers AI project.
|
|
933
1109
|
*
|
|
934
|
-
* For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#
|
|
1110
|
+
* For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#workers-ai
|
|
935
1111
|
*/
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
}
|
|
1112
|
+
interface AiBinding extends AiBindingOptions {
|
|
1113
|
+
type: "ai";
|
|
1114
|
+
}
|
|
939
1115
|
/**
|
|
940
|
-
*
|
|
941
|
-
* been removed from code.
|
|
1116
|
+
* Binding to the Workers AI project.
|
|
942
1117
|
*
|
|
943
|
-
*
|
|
944
|
-
* other Worker may hold a `durableObject` binding to the namespace.
|
|
1118
|
+
* For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#workers-ai
|
|
945
1119
|
*/
|
|
946
|
-
interface
|
|
947
|
-
|
|
1120
|
+
interface TypedAiBinding<TAiModelList extends AiModelListType = AiModels> extends AiBinding {
|
|
1121
|
+
/** @internal Carries type parameters for inference */
|
|
1122
|
+
__typeParams: [TAiModelList];
|
|
1123
|
+
}
|
|
1124
|
+
interface AiSearchBindingOptions {
|
|
1125
|
+
/** The user-chosen instance name. Must exist in Cloudflare at deploy time. */
|
|
1126
|
+
name: string;
|
|
1127
|
+
/** Options that only apply during local development. */
|
|
1128
|
+
dev?: BindingDevOptions;
|
|
948
1129
|
}
|
|
949
1130
|
/**
|
|
950
|
-
*
|
|
951
|
-
*
|
|
952
|
-
* `durableObject` entry in the same `exports` map.
|
|
1131
|
+
* AI Search instance binding. Each binding is bound directly to a single
|
|
1132
|
+
* pre-existing instance within the "default" namespace.
|
|
953
1133
|
*/
|
|
954
|
-
interface
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
1134
|
+
interface AiSearchBinding extends AiSearchBindingOptions {
|
|
1135
|
+
type: "ai-search";
|
|
1136
|
+
}
|
|
1137
|
+
interface AiSearchNamespaceBindingOptions {
|
|
1138
|
+
/** The user-chosen namespace name. Must exist in Cloudflare at deploy time. */
|
|
1139
|
+
namespace: string;
|
|
1140
|
+
/** Options that only apply during local development. */
|
|
1141
|
+
dev?: BindingDevOptions;
|
|
962
1142
|
}
|
|
963
1143
|
/**
|
|
964
|
-
*
|
|
965
|
-
*
|
|
1144
|
+
* AI Search namespace binding. Each binding is scoped to a namespace and
|
|
1145
|
+
* allows dynamic instance CRUD within it.
|
|
966
1146
|
*/
|
|
967
|
-
interface
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
1147
|
+
interface AiSearchNamespaceBinding extends AiSearchNamespaceBindingOptions {
|
|
1148
|
+
type: "ai-search-namespace";
|
|
1149
|
+
}
|
|
1150
|
+
interface AnalyticsEngineDatasetBindingOptions {
|
|
1151
|
+
/** The name of this dataset to write to. */
|
|
1152
|
+
name?: string;
|
|
973
1153
|
}
|
|
974
1154
|
/**
|
|
975
|
-
*
|
|
976
|
-
*
|
|
1155
|
+
* Binding to an Analytics Engine dataset.
|
|
1156
|
+
*
|
|
1157
|
+
* For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#analytics-engine-datasets
|
|
977
1158
|
*/
|
|
978
|
-
|
|
979
|
-
|
|
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 {
|
|
989
|
-
type: "durable-object";
|
|
990
|
-
}
|
|
991
|
-
interface DurableObjectRenamedExport extends DurableObjectRenamedExportOptions {
|
|
992
|
-
type: "durable-object";
|
|
1159
|
+
interface AnalyticsEngineDatasetBinding extends AnalyticsEngineDatasetBindingOptions {
|
|
1160
|
+
type: "analytics-engine-dataset";
|
|
993
1161
|
}
|
|
994
|
-
interface
|
|
995
|
-
|
|
1162
|
+
interface ArtifactsBindingOptions {
|
|
1163
|
+
/** The namespace to use. */
|
|
1164
|
+
namespace: string;
|
|
1165
|
+
/** Options that only apply during local development. */
|
|
1166
|
+
dev?: BindingDevOptions;
|
|
996
1167
|
}
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
cache?: {
|
|
1004
|
-
/** Whether cache is enabled for this entrypoint. */
|
|
1005
|
-
enabled: boolean;
|
|
1006
|
-
};
|
|
1168
|
+
/**
|
|
1169
|
+
* Binding to an Artifacts instance. Artifacts provides git-compatible file
|
|
1170
|
+
* storage on Cloudflare Workers.
|
|
1171
|
+
*/
|
|
1172
|
+
interface ArtifactsBinding extends ArtifactsBindingOptions {
|
|
1173
|
+
type: "artifacts";
|
|
1007
1174
|
}
|
|
1008
|
-
|
|
1009
|
-
|
|
1175
|
+
/**
|
|
1176
|
+
* Binding to the Worker's static assets.
|
|
1177
|
+
*
|
|
1178
|
+
* For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#assets
|
|
1179
|
+
*/
|
|
1180
|
+
interface AssetsBinding {
|
|
1181
|
+
type: "assets";
|
|
1182
|
+
}
|
|
1183
|
+
interface BrowserBindingOptions {
|
|
1184
|
+
/** Options that only apply during local development. */
|
|
1185
|
+
dev?: BindingDevOptions;
|
|
1010
1186
|
}
|
|
1011
1187
|
/**
|
|
1012
|
-
*
|
|
1013
|
-
*
|
|
1188
|
+
* Binding to a headless browser usable from the Worker.
|
|
1189
|
+
*
|
|
1190
|
+
* For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#browser-rendering
|
|
1014
1191
|
*/
|
|
1015
|
-
interface
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
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;
|
|
1192
|
+
interface BrowserBinding extends BrowserBindingOptions {
|
|
1193
|
+
type: "browser";
|
|
1194
|
+
}
|
|
1195
|
+
interface D1BindingOptions {
|
|
1196
|
+
/** The UUID of this D1 database (not required). */
|
|
1197
|
+
id?: string;
|
|
1198
|
+
/** The name of this D1 database. */
|
|
1199
|
+
name?: string;
|
|
1200
|
+
/** Options that only apply during local development. */
|
|
1201
|
+
dev?: BindingDevOptions;
|
|
1045
1202
|
}
|
|
1046
1203
|
/**
|
|
1047
|
-
*
|
|
1204
|
+
* Binding to a D1 database.
|
|
1048
1205
|
*
|
|
1049
|
-
*
|
|
1050
|
-
|
|
1051
|
-
|
|
1206
|
+
* For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#d1-databases
|
|
1207
|
+
*/
|
|
1208
|
+
interface D1Binding extends D1BindingOptions {
|
|
1209
|
+
type: "d1";
|
|
1210
|
+
}
|
|
1211
|
+
interface DispatchNamespaceBindingOptions {
|
|
1212
|
+
/** The namespace to bind to. */
|
|
1213
|
+
namespace?: string;
|
|
1214
|
+
/** Details about the outbound Worker which will handle outbound requests from your namespace. */
|
|
1215
|
+
outbound?: {
|
|
1216
|
+
/** Name of the Worker handling the outbound requests. */
|
|
1217
|
+
worker: string;
|
|
1218
|
+
/** (Optional) List of parameter names, for sending context from your dispatch Worker to the outbound handler. */
|
|
1219
|
+
parameters?: string[];
|
|
1220
|
+
};
|
|
1221
|
+
/** Options that only apply during local development. */
|
|
1222
|
+
dev?: BindingDevOptions;
|
|
1223
|
+
}
|
|
1224
|
+
/**
|
|
1225
|
+
* Binding to a Workers for Platforms dispatch namespace.
|
|
1052
1226
|
*
|
|
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
|
-
* ```
|
|
1227
|
+
* For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#dispatch-namespace-bindings-workers-for-platforms
|
|
1064
1228
|
*/
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1229
|
+
interface DispatchNamespaceBinding extends DispatchNamespaceBindingOptions {
|
|
1230
|
+
type: "dispatch-namespace";
|
|
1231
|
+
}
|
|
1232
|
+
type WorkerReference = string | WorkerConfigExport;
|
|
1233
|
+
type ReferencedWorkerConfig<TWorker$1 extends WorkerReference> = TWorker$1 extends string ? never : UnwrapConfig<TWorker$1>;
|
|
1234
|
+
type DurableObjectExportName<TWorker$1 extends WorkerReference> = TWorker$1 extends string ? string : InferDurableNamespaces<ReferencedWorkerConfig<TWorker$1>>;
|
|
1235
|
+
type WorkerEntrypointExportName<TWorker$1 extends WorkerReference> = TWorker$1 extends string ? string : InferWorkerEntrypointExports<ReferencedWorkerConfig<TWorker$1>>;
|
|
1236
|
+
type WorkflowExportName<TWorker$1 extends WorkerReference> = TWorker$1 extends string ? string : InferExportsByType<ReferencedWorkerConfig<TWorker$1>, "workflow">;
|
|
1237
|
+
interface DurableObjectBindingOptions<TWorker$1 extends WorkerReference = WorkerReference, TExportName$1 extends DurableObjectExportName<TWorker$1> = DurableObjectExportName<TWorker$1>> {
|
|
1238
|
+
/** The name or config of the Worker that defines the Durable Object class. */
|
|
1239
|
+
worker: TWorker$1;
|
|
1240
|
+
/** The exported class name of the Durable Object. */
|
|
1241
|
+
exportName: TExportName$1;
|
|
1076
1242
|
}
|
|
1077
|
-
declare const DEFINITION: unique symbol;
|
|
1078
1243
|
/**
|
|
1079
|
-
*
|
|
1080
|
-
*
|
|
1244
|
+
* Binding to a Durable Object class. `worker` is the name or config of the
|
|
1245
|
+
* Worker that defines the class; `exportName` is the exported class name.
|
|
1246
|
+
*
|
|
1247
|
+
* For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#durable-objects
|
|
1081
1248
|
*/
|
|
1082
|
-
|
|
1249
|
+
interface DurableObjectBinding<TWorker$1 extends WorkerReference = WorkerReference, TExportName$1 extends DurableObjectExportName<TWorker$1> = DurableObjectExportName<TWorker$1>> extends DurableObjectBindingOptions<TWorker$1, TExportName$1> {
|
|
1250
|
+
type: "durable-object";
|
|
1251
|
+
}
|
|
1252
|
+
interface FlagshipBindingOptions {
|
|
1253
|
+
/** The Flagship app ID to bind to. */
|
|
1254
|
+
id?: string;
|
|
1255
|
+
/** Options that only apply during local development. */
|
|
1256
|
+
dev?: BindingDevOptions;
|
|
1257
|
+
}
|
|
1258
|
+
/** Binding to a Flagship feature-flag service. */
|
|
1259
|
+
interface FlagshipBinding extends FlagshipBindingOptions {
|
|
1260
|
+
type: "flagship";
|
|
1261
|
+
}
|
|
1262
|
+
interface HyperdriveBindingOptions {
|
|
1263
|
+
/** The ID of the Hyperdrive configuration. */
|
|
1264
|
+
id: string;
|
|
1265
|
+
/** Options that only apply during local development. */
|
|
1266
|
+
dev?: {
|
|
1267
|
+
/** The database connection string used during local development. */
|
|
1268
|
+
connectionString?: string;
|
|
1269
|
+
};
|
|
1270
|
+
}
|
|
1083
1271
|
/**
|
|
1084
|
-
*
|
|
1272
|
+
* Binding to a Hyperdrive configuration.
|
|
1085
1273
|
*
|
|
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`.
|
|
1274
|
+
* For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#hyperdrive
|
|
1090
1275
|
*/
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1276
|
+
interface HyperdriveBinding extends HyperdriveBindingOptions {
|
|
1277
|
+
type: "hyperdrive";
|
|
1278
|
+
}
|
|
1279
|
+
interface ImagesBindingOptions {
|
|
1280
|
+
/** Options that only apply during local development. */
|
|
1281
|
+
dev?: BindingDevOptions;
|
|
1282
|
+
}
|
|
1094
1283
|
/**
|
|
1095
|
-
*
|
|
1284
|
+
* Binding to Cloudflare Images.
|
|
1285
|
+
*
|
|
1286
|
+
* For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#images
|
|
1096
1287
|
*/
|
|
1097
|
-
|
|
1288
|
+
interface ImagesBinding$1 extends ImagesBindingOptions {
|
|
1289
|
+
type: "images";
|
|
1290
|
+
}
|
|
1098
1291
|
/**
|
|
1099
|
-
*
|
|
1292
|
+
* Inline JSON value made available to the Worker on `env` under the
|
|
1293
|
+
* binding name.
|
|
1100
1294
|
*/
|
|
1101
|
-
|
|
1295
|
+
interface JsonBinding<T$1 extends Json = Json> {
|
|
1296
|
+
type: "json";
|
|
1297
|
+
/** The JSON value made available to the Worker. */
|
|
1298
|
+
value: T$1;
|
|
1299
|
+
}
|
|
1300
|
+
interface KvBindingOptions {
|
|
1301
|
+
/** The ID of the KV namespace. */
|
|
1302
|
+
id?: string;
|
|
1303
|
+
/** Options that only apply during local development. */
|
|
1304
|
+
dev?: BindingDevOptions;
|
|
1305
|
+
}
|
|
1102
1306
|
/**
|
|
1103
|
-
*
|
|
1104
|
-
*
|
|
1105
|
-
*
|
|
1307
|
+
* Binding to a Workers KV namespace.
|
|
1308
|
+
*
|
|
1309
|
+
* For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#kv-namespaces
|
|
1106
1310
|
*/
|
|
1107
|
-
|
|
1311
|
+
interface KvBinding extends KvBindingOptions {
|
|
1312
|
+
type: "kv";
|
|
1313
|
+
}
|
|
1108
1314
|
/**
|
|
1109
|
-
*
|
|
1110
|
-
* [`defineWorker`](https://developers.cloudflare.com/workers/wrangler/configuration/).
|
|
1315
|
+
* Binding to a Workers KV namespace.
|
|
1111
1316
|
*
|
|
1112
|
-
*
|
|
1113
|
-
* being passed to downstream tooling.
|
|
1317
|
+
* For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#kv-namespaces
|
|
1114
1318
|
*/
|
|
1115
|
-
interface
|
|
1116
|
-
/**
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1319
|
+
interface TypedKvBinding<TKey extends string = string> extends KvBinding {
|
|
1320
|
+
/** @internal Carries type parameters for inference */
|
|
1321
|
+
__typeParams: [TKey];
|
|
1322
|
+
}
|
|
1323
|
+
interface LogfwdrBindingOptions {
|
|
1324
|
+
/** The destination for this logged message. */
|
|
1325
|
+
destination: string;
|
|
1326
|
+
}
|
|
1327
|
+
/** Binding for forwarding logs to logfwdr. */
|
|
1328
|
+
interface LogfwdrBinding extends LogfwdrBindingOptions {
|
|
1329
|
+
type: "logfwdr";
|
|
1330
|
+
}
|
|
1331
|
+
interface MediaBindingOptions {
|
|
1332
|
+
/** Options that only apply during local development. */
|
|
1333
|
+
dev?: BindingDevOptions;
|
|
1334
|
+
}
|
|
1335
|
+
/** Binding to Cloudflare Media Transformations. */
|
|
1336
|
+
interface MediaBinding$1 extends MediaBindingOptions {
|
|
1337
|
+
type: "media";
|
|
1338
|
+
}
|
|
1339
|
+
interface MtlsCertificateBindingOptions {
|
|
1340
|
+
/** The UUID of the uploaded mTLS certificate. */
|
|
1341
|
+
id: string;
|
|
1342
|
+
/** Options that only apply during local development. */
|
|
1343
|
+
dev?: BindingDevOptions;
|
|
1344
|
+
}
|
|
1345
|
+
/**
|
|
1346
|
+
* Binding to an uploaded mTLS certificate.
|
|
1347
|
+
*
|
|
1348
|
+
* For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#mtls-certificates
|
|
1349
|
+
*/
|
|
1350
|
+
interface MtlsCertificateBinding extends MtlsCertificateBindingOptions {
|
|
1351
|
+
type: "mtls-certificate";
|
|
1352
|
+
}
|
|
1353
|
+
interface PipelineBindingOptions {
|
|
1354
|
+
/** Name of the Pipeline to bind. */
|
|
1126
1355
|
name: string;
|
|
1356
|
+
/** Options that only apply during local development. */
|
|
1357
|
+
dev?: BindingDevOptions;
|
|
1358
|
+
}
|
|
1359
|
+
/** Binding to a Cloudflare Pipeline. */
|
|
1360
|
+
interface PipelineBinding extends PipelineBindingOptions {
|
|
1361
|
+
type: "pipeline";
|
|
1362
|
+
}
|
|
1363
|
+
/** Binding to a Cloudflare Pipeline. */
|
|
1364
|
+
interface TypedPipelineBinding<TRecord extends PipelineRecord = PipelineRecord> extends PipelineBinding {
|
|
1365
|
+
/** @internal Carries type parameters for inference */
|
|
1366
|
+
__typeParams: [TRecord];
|
|
1367
|
+
}
|
|
1368
|
+
interface QueueBindingOptions {
|
|
1369
|
+
/** The name of this Queue. */
|
|
1370
|
+
name?: string;
|
|
1371
|
+
/** The number of seconds to wait before delivering a message. */
|
|
1372
|
+
deliveryDelay?: number;
|
|
1373
|
+
/** Options that only apply during local development. */
|
|
1374
|
+
dev?: BindingDevOptions;
|
|
1375
|
+
}
|
|
1376
|
+
/**
|
|
1377
|
+
* Producer binding to a Cloudflare Queue.
|
|
1378
|
+
*
|
|
1379
|
+
* For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#queues
|
|
1380
|
+
*/
|
|
1381
|
+
interface QueueBinding extends QueueBindingOptions {
|
|
1382
|
+
type: "queue";
|
|
1383
|
+
}
|
|
1384
|
+
/**
|
|
1385
|
+
* Producer binding to a Cloudflare Queue.
|
|
1386
|
+
*
|
|
1387
|
+
* For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#queues
|
|
1388
|
+
*/
|
|
1389
|
+
interface TypedQueueBinding<TBody = unknown> extends QueueBinding {
|
|
1390
|
+
/** @internal Carries type parameters for inference */
|
|
1391
|
+
__typeParams: [TBody];
|
|
1392
|
+
}
|
|
1393
|
+
interface R2BindingOptions {
|
|
1394
|
+
/** The name of this R2 bucket at the edge. */
|
|
1395
|
+
name?: string;
|
|
1396
|
+
/** The jurisdiction that the bucket exists in. Default if not present. */
|
|
1397
|
+
jurisdiction?: string;
|
|
1398
|
+
/** Settings that only apply to local development. */
|
|
1399
|
+
dev?: BindingDevOptions & {
|
|
1400
|
+
/** EXPERIMENTAL: credentials for the local S3-compatible endpoint. */
|
|
1401
|
+
experimentalS3Credentials?: {
|
|
1402
|
+
accessKeyId: string;
|
|
1403
|
+
secretAccessKey: string;
|
|
1404
|
+
};
|
|
1405
|
+
};
|
|
1406
|
+
}
|
|
1407
|
+
/**
|
|
1408
|
+
* Binding to an R2 bucket.
|
|
1409
|
+
*
|
|
1410
|
+
* For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#r2-buckets
|
|
1411
|
+
*/
|
|
1412
|
+
interface R2Binding extends R2BindingOptions {
|
|
1413
|
+
type: "r2";
|
|
1414
|
+
}
|
|
1415
|
+
interface RateLimitBindingOptions {
|
|
1416
|
+
/** The namespace ID for this rate limiter. */
|
|
1417
|
+
namespace: string;
|
|
1418
|
+
/** Simple rate limiting configuration. */
|
|
1419
|
+
simple: {
|
|
1420
|
+
/** The maximum number of requests allowed in the time period. */
|
|
1421
|
+
limit: number;
|
|
1422
|
+
/** The time period in seconds (10 for ten seconds, 60 for one minute). */
|
|
1423
|
+
period: 10 | 60;
|
|
1424
|
+
};
|
|
1425
|
+
}
|
|
1426
|
+
/** Binding to a rate limiter. */
|
|
1427
|
+
interface RateLimitBinding extends RateLimitBindingOptions {
|
|
1428
|
+
type: "rate-limit";
|
|
1429
|
+
}
|
|
1430
|
+
/**
|
|
1431
|
+
* Declares a secret that is required by your Worker, exposed on `env` under
|
|
1432
|
+
* the binding name.
|
|
1433
|
+
*
|
|
1434
|
+
* When defined, this binding:
|
|
1435
|
+
* - Replaces .dev.vars/.env/process.env inference for type generation
|
|
1436
|
+
* - Enables local dev validation with warnings for missing secrets
|
|
1437
|
+
*
|
|
1438
|
+
* For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#secrets-configuration-property
|
|
1439
|
+
*/
|
|
1440
|
+
interface SecretBinding {
|
|
1441
|
+
type: "secret";
|
|
1442
|
+
}
|
|
1443
|
+
interface SecretsStoreSecretBindingOptions {
|
|
1444
|
+
/** ID of the secret store. */
|
|
1445
|
+
storeId: string;
|
|
1446
|
+
/** Name of the secret. */
|
|
1447
|
+
secretName: string;
|
|
1448
|
+
}
|
|
1449
|
+
/** Binding to a Secrets Store secret. */
|
|
1450
|
+
interface SecretsStoreSecretBinding extends SecretsStoreSecretBindingOptions {
|
|
1451
|
+
type: "secrets-store-secret";
|
|
1452
|
+
}
|
|
1453
|
+
type SendEmailDestinationOptions = {
|
|
1454
|
+
/** If this binding should be restricted to a specific verified address. */
|
|
1455
|
+
destinationAddress: string;
|
|
1456
|
+
allowedDestinationAddresses?: never;
|
|
1457
|
+
} | {
|
|
1458
|
+
destinationAddress?: never;
|
|
1459
|
+
/** If this binding should be restricted to a set of verified addresses. */
|
|
1460
|
+
allowedDestinationAddresses: string[];
|
|
1461
|
+
} | {
|
|
1462
|
+
destinationAddress?: never;
|
|
1463
|
+
allowedDestinationAddresses?: never;
|
|
1464
|
+
};
|
|
1465
|
+
type SendEmailBindingOptions = SendEmailDestinationOptions & {
|
|
1466
|
+
/** If this binding should be restricted to a set of sender addresses. */
|
|
1467
|
+
allowedSenderAddresses?: string[];
|
|
1468
|
+
/** Options that only apply during local development. */
|
|
1469
|
+
dev?: BindingDevOptions;
|
|
1470
|
+
};
|
|
1471
|
+
/**
|
|
1472
|
+
* Binding for sending email from inside the Worker.
|
|
1473
|
+
*
|
|
1474
|
+
* For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#email-bindings
|
|
1475
|
+
*/
|
|
1476
|
+
type SendEmailBinding = SendEmailBindingOptions & {
|
|
1477
|
+
type: "send-email";
|
|
1478
|
+
};
|
|
1479
|
+
interface StreamBindingOptions {
|
|
1480
|
+
/** Options that only apply during local development. */
|
|
1481
|
+
dev?: BindingDevOptions;
|
|
1482
|
+
}
|
|
1483
|
+
/** Binding to Cloudflare Stream. */
|
|
1484
|
+
interface StreamBinding$1 extends StreamBindingOptions {
|
|
1485
|
+
type: "stream";
|
|
1486
|
+
}
|
|
1487
|
+
/**
|
|
1488
|
+
* Inline string value made available to the Worker on `env` under the
|
|
1489
|
+
* binding name.
|
|
1490
|
+
*
|
|
1491
|
+
* For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#environment-variables
|
|
1492
|
+
*/
|
|
1493
|
+
interface TextBinding<T$1 extends string = string> {
|
|
1494
|
+
type: "text";
|
|
1495
|
+
/** The string value made available to the Worker. */
|
|
1496
|
+
value: T$1;
|
|
1497
|
+
}
|
|
1498
|
+
interface UnsafeBindingOptions {
|
|
1499
|
+
/** Local-dev plugin configuration for this unsafe binding. */
|
|
1500
|
+
dev?: {
|
|
1501
|
+
/** The plugin package that provides the binding's local-dev implementation. */
|
|
1502
|
+
plugin: {
|
|
1503
|
+
package: string;
|
|
1504
|
+
name: string;
|
|
1505
|
+
};
|
|
1506
|
+
/** Plugin-specific options. */
|
|
1507
|
+
options?: Record<string, unknown>;
|
|
1508
|
+
};
|
|
1509
|
+
[key: string]: unknown;
|
|
1510
|
+
}
|
|
1511
|
+
/**
|
|
1512
|
+
* Escape-hatch binding for runtime features that aren't directly supported
|
|
1513
|
+
* by this configuration. Included in the Worker's upload metadata without
|
|
1514
|
+
* changes.
|
|
1515
|
+
*/
|
|
1516
|
+
interface UnsafeBinding extends UnsafeBindingOptions {
|
|
1517
|
+
type: `unsafe:${string}`;
|
|
1518
|
+
}
|
|
1519
|
+
interface VectorizeBindingOptions {
|
|
1520
|
+
/** The name of the Vectorize index. */
|
|
1521
|
+
name: string;
|
|
1522
|
+
/** Options that only apply during local development. */
|
|
1523
|
+
dev?: BindingDevOptions;
|
|
1524
|
+
}
|
|
1525
|
+
/**
|
|
1526
|
+
* Binding to a Vectorize index.
|
|
1527
|
+
*
|
|
1528
|
+
* For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#vectorize-indexes
|
|
1529
|
+
*/
|
|
1530
|
+
interface VectorizeBinding extends VectorizeBindingOptions {
|
|
1531
|
+
type: "vectorize";
|
|
1532
|
+
}
|
|
1533
|
+
/** Binding to the Worker version's metadata. */
|
|
1534
|
+
interface VersionMetadataBinding {
|
|
1535
|
+
type: "version-metadata";
|
|
1536
|
+
}
|
|
1537
|
+
type VpcNetworkBindingOptions = {
|
|
1538
|
+
/** The tunnel ID of the Cloudflare Tunnel to route traffic through. Mutually exclusive with `networkId`. */
|
|
1539
|
+
tunnelId: string;
|
|
1540
|
+
networkId?: never;
|
|
1541
|
+
/** Options that only apply during local development. */
|
|
1542
|
+
dev?: BindingDevOptions;
|
|
1543
|
+
} | {
|
|
1544
|
+
tunnelId?: never;
|
|
1545
|
+
/** The network ID to route traffic through. Mutually exclusive with `tunnelId`. */
|
|
1546
|
+
networkId: string;
|
|
1547
|
+
/** Options that only apply during local development. */
|
|
1548
|
+
dev?: BindingDevOptions;
|
|
1549
|
+
};
|
|
1550
|
+
/** Binding to a VPC network. */
|
|
1551
|
+
type VpcNetworkBinding = VpcNetworkBindingOptions & {
|
|
1552
|
+
type: "vpc-network";
|
|
1553
|
+
};
|
|
1554
|
+
interface VpcServiceBindingOptions {
|
|
1555
|
+
/** The service ID of the VPC connectivity service. */
|
|
1556
|
+
id: string;
|
|
1557
|
+
/** Options that only apply during local development. */
|
|
1558
|
+
dev?: BindingDevOptions;
|
|
1559
|
+
}
|
|
1560
|
+
/** Binding to a VPC service. */
|
|
1561
|
+
interface VpcServiceBinding extends VpcServiceBindingOptions {
|
|
1562
|
+
type: "vpc-service";
|
|
1563
|
+
}
|
|
1564
|
+
interface WebSearchBindingOptions {
|
|
1565
|
+
/** Options that only apply during local development. */
|
|
1566
|
+
dev?: BindingDevOptions;
|
|
1567
|
+
}
|
|
1568
|
+
/**
|
|
1569
|
+
* Cloudflare Web Search binding. There is exactly one shared web corpus, so
|
|
1570
|
+
* the binding is zero-config — only the variable name is required.
|
|
1571
|
+
*/
|
|
1572
|
+
interface WebSearchBinding extends WebSearchBindingOptions {
|
|
1573
|
+
type: "web-search";
|
|
1574
|
+
}
|
|
1575
|
+
interface WorkerBindingOptions<TWorker$1 extends WorkerReference = WorkerReference, TExportName$1 extends WorkerEntrypointExportName<TWorker$1> | undefined = WorkerEntrypointExportName<TWorker$1> | undefined> {
|
|
1576
|
+
/** The name or config of the bound Worker. */
|
|
1577
|
+
worker: TWorker$1;
|
|
1578
|
+
/** The named export to bind to (defaults to the default export). */
|
|
1579
|
+
exportName?: TExportName$1;
|
|
1580
|
+
/** Optional properties that will be made available to the service via `ctx.props`. */
|
|
1581
|
+
props?: Record<string, unknown>;
|
|
1582
|
+
/** Options that only apply during local development. */
|
|
1583
|
+
dev?: BindingDevOptions;
|
|
1584
|
+
}
|
|
1585
|
+
/**
|
|
1586
|
+
* Service binding (Worker-to-Worker). `worker` is the name or config of the
|
|
1587
|
+
* bound Worker; `exportName` selects a named `WorkerEntrypoint` export
|
|
1588
|
+
* (defaults to the default export).
|
|
1589
|
+
*
|
|
1590
|
+
* For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#service-bindings
|
|
1591
|
+
*/
|
|
1592
|
+
interface WorkerBinding<TWorker$1 extends WorkerReference = WorkerReference, TExportName$1 extends WorkerEntrypointExportName<TWorker$1> | undefined = WorkerEntrypointExportName<TWorker$1> | undefined> extends WorkerBindingOptions<TWorker$1, TExportName$1> {
|
|
1593
|
+
type: "worker";
|
|
1594
|
+
}
|
|
1595
|
+
/** Binding to a Worker Loader. */
|
|
1596
|
+
interface WorkerLoaderBinding {
|
|
1597
|
+
type: "worker-loader";
|
|
1598
|
+
}
|
|
1599
|
+
interface WorkflowBindingOptions<TWorker$1 extends WorkerReference = WorkerReference, TExportName$1 extends WorkflowExportName<TWorker$1> = WorkflowExportName<TWorker$1>> {
|
|
1600
|
+
/** The name or config of the Worker that defines the Workflow. */
|
|
1601
|
+
worker: TWorker$1;
|
|
1602
|
+
/** The exported class name of the Workflow. */
|
|
1603
|
+
exportName: TExportName$1;
|
|
1604
|
+
}
|
|
1605
|
+
/**
|
|
1606
|
+
* Binding to a Workflow. `worker` is the name or config of the Worker that
|
|
1607
|
+
* defines the Workflow; `exportName` is the exported `WorkflowEntrypoint`
|
|
1608
|
+
* class name.
|
|
1609
|
+
*/
|
|
1610
|
+
interface WorkflowBinding<TWorker$1 extends WorkerReference = WorkerReference, TExportName$1 extends WorkflowExportName<TWorker$1> = WorkflowExportName<TWorker$1>> extends WorkflowBindingOptions<TWorker$1, TExportName$1> {
|
|
1611
|
+
type: "workflow";
|
|
1612
|
+
}
|
|
1613
|
+
interface Bindings {
|
|
1127
1614
|
/**
|
|
1128
|
-
*
|
|
1129
|
-
*
|
|
1130
|
-
*
|
|
1131
|
-
* More details at https://developers.cloudflare.com/workers/configuration/compatibility-dates
|
|
1132
|
-
*/
|
|
1133
|
-
compatibilityDate: string;
|
|
1134
|
-
/**
|
|
1135
|
-
* A list of flags that enable features from upcoming features of
|
|
1136
|
-
* the Workers runtime, usually used together with `compatibilityDate`.
|
|
1137
|
-
*
|
|
1138
|
-
* More details at https://developers.cloudflare.com/workers/configuration/compatibility-flags/
|
|
1139
|
-
*
|
|
1140
|
-
* @default []
|
|
1141
|
-
*/
|
|
1142
|
-
compatibilityFlags?: string[];
|
|
1143
|
-
/**
|
|
1144
|
-
* The entrypoint module that will be executed.
|
|
1145
|
-
*
|
|
1146
|
-
* May be either a path string (e.g. `"./src/index.ts"`) or a module
|
|
1147
|
-
* namespace imported with the `cf-worker` import attribute.
|
|
1148
|
-
*
|
|
1149
|
-
* @example
|
|
1150
|
-
* ```ts
|
|
1151
|
-
* import * as entrypoint from "./src" with { type: "cf-worker" };
|
|
1152
|
-
* export default defineWorker({ entrypoint });
|
|
1153
|
-
* ```
|
|
1615
|
+
* Agent Memory namespace binding. Each binding is scoped to a namespace and
|
|
1616
|
+
* allows agents to persist and recall memory.
|
|
1154
1617
|
*/
|
|
1155
|
-
|
|
1618
|
+
agentMemory(options: AgentMemoryBindingOptions): AgentMemoryBinding;
|
|
1156
1619
|
/**
|
|
1157
|
-
*
|
|
1158
|
-
*
|
|
1159
|
-
* More details at https://developers.cloudflare.com/workers/frameworks/
|
|
1620
|
+
* Binding to the Workers AI project.
|
|
1160
1621
|
*
|
|
1161
|
-
* For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#
|
|
1622
|
+
* For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#workers-ai
|
|
1162
1623
|
*/
|
|
1163
|
-
|
|
1164
|
-
/** How to handle HTML requests. */
|
|
1165
|
-
htmlHandling?: "auto-trailing-slash" | "drop-trailing-slash" | "force-trailing-slash" | "none";
|
|
1166
|
-
/** How to handle requests that do not match an asset. */
|
|
1167
|
-
notFoundHandling?: "single-page-application" | "404-page" | "none";
|
|
1168
|
-
/**
|
|
1169
|
-
* Matches will be routed to the User Worker, and matches to negative rules will go to the Asset Worker.
|
|
1170
|
-
*
|
|
1171
|
-
* Can also be `true`, indicating that every request should be routed to the User Worker.
|
|
1172
|
-
*/
|
|
1173
|
-
runWorkerFirst?: string[] | boolean;
|
|
1174
|
-
};
|
|
1624
|
+
ai<TAiModelList extends AiModelListType = AiModels>(options?: AiBindingOptions): TypedAiBinding<TAiModelList>;
|
|
1175
1625
|
/**
|
|
1176
|
-
*
|
|
1177
|
-
*
|
|
1178
|
-
* For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#types-of-routes
|
|
1626
|
+
* AI Search instance binding. Each binding is bound directly to a single
|
|
1627
|
+
* pre-existing instance within the "default" namespace.
|
|
1179
1628
|
*/
|
|
1180
|
-
|
|
1629
|
+
aiSearch(options: AiSearchBindingOptions): AiSearchBinding;
|
|
1181
1630
|
/**
|
|
1182
|
-
*
|
|
1183
|
-
*
|
|
1184
|
-
* Construct entries with `triggers.fetch(...)`, `triggers.queue(...)`,
|
|
1185
|
-
* `triggers.scheduled(...)`, `triggers.email(...)`, or
|
|
1186
|
-
* `triggers.connect(...)`.
|
|
1187
|
-
*
|
|
1188
|
-
* For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#triggers
|
|
1631
|
+
* AI Search namespace binding. Each binding is scoped to a namespace and
|
|
1632
|
+
* allows dynamic instance CRUD within it.
|
|
1189
1633
|
*/
|
|
1190
|
-
|
|
1634
|
+
aiSearchNamespace(options: AiSearchNamespaceBindingOptions): AiSearchNamespaceBinding;
|
|
1191
1635
|
/**
|
|
1192
|
-
*
|
|
1193
|
-
*
|
|
1194
|
-
* `@cloudflare/config` unifies regular and streaming tail consumers under
|
|
1195
|
-
* a single field; pass `streaming: true` to forward streaming tail events.
|
|
1636
|
+
* Binding to an Analytics Engine dataset.
|
|
1196
1637
|
*
|
|
1197
|
-
*
|
|
1638
|
+
* For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#analytics-engine-datasets
|
|
1198
1639
|
*/
|
|
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
|
-
}>;
|
|
1640
|
+
analyticsEngineDataset(options?: AnalyticsEngineDatasetBindingOptions): AnalyticsEngineDatasetBinding;
|
|
1205
1641
|
/**
|
|
1206
|
-
*
|
|
1642
|
+
* Binding to an Artifacts instance. Artifacts provides git-compatible file
|
|
1643
|
+
* storage on Cloudflare Workers.
|
|
1207
1644
|
*/
|
|
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
|
-
};
|
|
1645
|
+
artifacts(options: ArtifactsBindingOptions): ArtifactsBinding;
|
|
1214
1646
|
/**
|
|
1215
|
-
*
|
|
1647
|
+
* Binding to the Worker's static assets.
|
|
1216
1648
|
*
|
|
1217
|
-
*
|
|
1649
|
+
* For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#assets
|
|
1218
1650
|
*/
|
|
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
|
-
};
|
|
1651
|
+
assets(): AssetsBinding;
|
|
1232
1652
|
/**
|
|
1233
|
-
*
|
|
1234
|
-
* Only supported for the "standard" Usage Model.
|
|
1653
|
+
* Binding to a headless browser usable from the Worker.
|
|
1235
1654
|
*
|
|
1236
|
-
* For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#
|
|
1655
|
+
* For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#browser-rendering
|
|
1237
1656
|
*/
|
|
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
|
-
};
|
|
1657
|
+
browser(options?: BrowserBindingOptions): BrowserBinding;
|
|
1244
1658
|
/**
|
|
1245
|
-
*
|
|
1659
|
+
* Binding to a D1 database.
|
|
1246
1660
|
*
|
|
1247
|
-
*
|
|
1661
|
+
* For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#d1-databases
|
|
1662
|
+
*/
|
|
1663
|
+
d1(options?: D1BindingOptions): D1Binding;
|
|
1664
|
+
/**
|
|
1665
|
+
* Binding to a Workers for Platforms dispatch namespace.
|
|
1248
1666
|
*
|
|
1249
|
-
* For
|
|
1250
|
-
* https://blog.cloudflare.com/logpush-for-workers/
|
|
1667
|
+
* For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#dispatch-namespace-bindings-workers-for-platforms
|
|
1251
1668
|
*/
|
|
1252
|
-
|
|
1669
|
+
dispatchNamespace(options?: DispatchNamespaceBindingOptions): DispatchNamespaceBinding;
|
|
1253
1670
|
/**
|
|
1254
|
-
*
|
|
1671
|
+
* Binding to a Durable Object class. `worker` is the name or config of the
|
|
1672
|
+
* Worker that defines the class; `exportName` is the exported class name.
|
|
1255
1673
|
*
|
|
1256
|
-
* For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#
|
|
1674
|
+
* For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#durable-objects
|
|
1257
1675
|
*/
|
|
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
|
-
};
|
|
1676
|
+
durableObject<TWorker$1 extends WorkerReference, TExportName$1 extends DurableObjectExportName<TWorker$1>>(options: DurableObjectBindingOptions<TWorker$1, TExportName$1>): DurableObjectBinding<TWorker$1, TExportName$1>;
|
|
1677
|
+
/** Binding to a Flagship feature-flag service. */
|
|
1678
|
+
flagship(options?: FlagshipBindingOptions): FlagshipBinding;
|
|
1306
1679
|
/**
|
|
1307
|
-
*
|
|
1308
|
-
* test and deploy your Worker.
|
|
1680
|
+
* Binding to a Hyperdrive configuration.
|
|
1309
1681
|
*
|
|
1310
|
-
* For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#
|
|
1682
|
+
* For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#hyperdrive
|
|
1683
|
+
*/
|
|
1684
|
+
hyperdrive(options: HyperdriveBindingOptions): HyperdriveBinding;
|
|
1685
|
+
/**
|
|
1686
|
+
* Binding to Cloudflare Images.
|
|
1311
1687
|
*
|
|
1312
|
-
*
|
|
1688
|
+
* For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#images
|
|
1313
1689
|
*/
|
|
1314
|
-
|
|
1690
|
+
images(options?: ImagesBindingOptions): ImagesBinding$1;
|
|
1315
1691
|
/**
|
|
1316
|
-
*
|
|
1317
|
-
*
|
|
1692
|
+
* Inline JSON value made available to the Worker on `env` under the
|
|
1693
|
+
* binding name.
|
|
1694
|
+
*/
|
|
1695
|
+
json<T$1 extends Json>(value: T$1): JsonBinding<T$1>;
|
|
1696
|
+
/**
|
|
1697
|
+
* Binding to a Workers KV namespace.
|
|
1318
1698
|
*
|
|
1319
|
-
*
|
|
1699
|
+
* For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#kv-namespaces
|
|
1320
1700
|
*/
|
|
1321
|
-
|
|
1701
|
+
kv<TKey extends string = string>(options?: KvBindingOptions): TypedKvBinding<TKey>;
|
|
1702
|
+
/** Binding for forwarding logs to logfwdr. */
|
|
1703
|
+
logfwdr(options: LogfwdrBindingOptions): LogfwdrBinding;
|
|
1704
|
+
/** Binding to Cloudflare Media Transformations. */
|
|
1705
|
+
media(options?: MediaBindingOptions): MediaBinding$1;
|
|
1322
1706
|
/**
|
|
1323
|
-
*
|
|
1707
|
+
* Binding to an uploaded mTLS certificate.
|
|
1324
1708
|
*
|
|
1325
|
-
*
|
|
1709
|
+
* For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#mtls-certificates
|
|
1326
1710
|
*/
|
|
1327
|
-
|
|
1711
|
+
mtlsCertificate(options: MtlsCertificateBindingOptions): MtlsCertificateBinding;
|
|
1712
|
+
/** Binding to a Cloudflare Pipeline. */
|
|
1713
|
+
pipeline<TRecord extends PipelineRecord = PipelineRecord>(options: PipelineBindingOptions): TypedPipelineBinding<TRecord>;
|
|
1328
1714
|
/**
|
|
1329
|
-
*
|
|
1330
|
-
* this configuration. Values are forwarded verbatim in the Worker's
|
|
1331
|
-
* upload metadata.
|
|
1715
|
+
* Producer binding to a Cloudflare Queue.
|
|
1332
1716
|
*
|
|
1333
|
-
*
|
|
1717
|
+
* For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#queues
|
|
1334
1718
|
*/
|
|
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
|
-
};
|
|
1719
|
+
queue<TBody = unknown>(options?: QueueBindingOptions): TypedQueueBinding<TBody>;
|
|
1354
1720
|
/**
|
|
1355
|
-
*
|
|
1356
|
-
*
|
|
1721
|
+
* Binding to an R2 bucket.
|
|
1722
|
+
*
|
|
1723
|
+
* For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#r2-buckets
|
|
1357
1724
|
*/
|
|
1358
|
-
|
|
1725
|
+
r2(options?: R2BindingOptions): R2Binding;
|
|
1726
|
+
/** Binding to a rate limiter. */
|
|
1727
|
+
rateLimit(options: RateLimitBindingOptions): RateLimitBinding;
|
|
1359
1728
|
/**
|
|
1360
|
-
*
|
|
1361
|
-
*
|
|
1729
|
+
* Declares a secret that is required by your Worker, exposed on `env` under
|
|
1730
|
+
* the binding name.
|
|
1362
1731
|
*
|
|
1363
|
-
*
|
|
1732
|
+
* When defined, this binding:
|
|
1733
|
+
* - Replaces .dev.vars/.env/process.env inference for type generation
|
|
1734
|
+
* - Enables local dev validation with warnings for missing secrets
|
|
1364
1735
|
*
|
|
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.
|
|
1736
|
+
* For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#secrets-configuration-property
|
|
1370
1737
|
*/
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
* Settings shared by the other exports.
|
|
1375
|
-
* Authored as a named `settings` export via
|
|
1376
|
-
* `defineSettings`.
|
|
1377
|
-
*/
|
|
1378
|
-
interface SettingsConfig {
|
|
1738
|
+
secret(): SecretBinding;
|
|
1739
|
+
/** Binding to a Secrets Store secret. */
|
|
1740
|
+
secretsStoreSecret(options: SecretsStoreSecretBindingOptions): SecretsStoreSecretBinding;
|
|
1379
1741
|
/**
|
|
1380
|
-
*
|
|
1742
|
+
* Binding for sending email from inside the Worker.
|
|
1381
1743
|
*
|
|
1382
|
-
*
|
|
1383
|
-
* hand when authoring a raw config object without the helper.
|
|
1744
|
+
* For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#email-bindings
|
|
1384
1745
|
*/
|
|
1385
|
-
|
|
1746
|
+
sendEmail(options?: SendEmailBindingOptions): SendEmailBinding;
|
|
1747
|
+
/** Binding to Cloudflare Stream. */
|
|
1748
|
+
stream(options?: StreamBindingOptions): StreamBinding$1;
|
|
1386
1749
|
/**
|
|
1387
|
-
*
|
|
1388
|
-
*
|
|
1389
|
-
*
|
|
1390
|
-
*
|
|
1391
|
-
* the CLOUDFLARE_ACCOUNT_ID environment variable.
|
|
1750
|
+
* Inline string value made available to the Worker on `env` under the
|
|
1751
|
+
* binding name.
|
|
1752
|
+
*
|
|
1753
|
+
* For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#environment-variables
|
|
1392
1754
|
*/
|
|
1393
|
-
|
|
1755
|
+
text<T$1 extends string>(value: T$1): TextBinding<T$1>;
|
|
1394
1756
|
/**
|
|
1395
|
-
*
|
|
1757
|
+
* Binding to a Vectorize index.
|
|
1396
1758
|
*
|
|
1397
|
-
*
|
|
1398
|
-
* it can be set to `undefined` in configuration to delegate to the CLOUDFLARE_COMPLIANCE_REGION environment variable.
|
|
1759
|
+
* For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#vectorize-indexes
|
|
1399
1760
|
*/
|
|
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> {
|
|
1761
|
+
vectorize(options: VectorizeBindingOptions): VectorizeBinding;
|
|
1762
|
+
/** Binding to the Worker version's metadata. */
|
|
1763
|
+
versionMetadata(): VersionMetadataBinding;
|
|
1764
|
+
/** Binding to a VPC network. */
|
|
1765
|
+
vpcNetwork(options: VpcNetworkBindingOptions): VpcNetworkBinding;
|
|
1766
|
+
/** Binding to a VPC service. */
|
|
1767
|
+
vpcService(options: VpcServiceBindingOptions): VpcServiceBinding;
|
|
1418
1768
|
/**
|
|
1419
|
-
*
|
|
1420
|
-
*
|
|
1421
|
-
*
|
|
1422
|
-
* For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#durable-objects
|
|
1769
|
+
* Cloudflare Web Search binding. There is exactly one shared web corpus, so
|
|
1770
|
+
* the binding is zero-config — only the variable name is required.
|
|
1423
1771
|
*/
|
|
1424
|
-
|
|
1425
|
-
worker: TWorkerName;
|
|
1426
|
-
exportName: TExportName$1;
|
|
1427
|
-
}): TypedDurableObjectBinding<TConfig$1, TExportName$1>;
|
|
1772
|
+
webSearch(options?: WebSearchBindingOptions): WebSearchBinding;
|
|
1428
1773
|
/**
|
|
1429
|
-
* Service binding (Worker-to-Worker). `worker` is the name of the
|
|
1430
|
-
* Worker; `exportName` selects a named `WorkerEntrypoint` export
|
|
1431
|
-
* the default export).
|
|
1774
|
+
* Service binding (Worker-to-Worker). `worker` is the name or config of the
|
|
1775
|
+
* bound Worker; `exportName` selects a named `WorkerEntrypoint` export
|
|
1776
|
+
* (defaults to the default export).
|
|
1432
1777
|
*
|
|
1433
1778
|
* For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#service-bindings
|
|
1434
1779
|
*/
|
|
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;
|
|
1780
|
+
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>>;
|
|
1781
|
+
/** Binding to a Worker Loader. */
|
|
1782
|
+
workerLoader(): WorkerLoaderBinding;
|
|
1540
1783
|
}
|
|
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;
|
|
1784
|
+
declare const bindings: Bindings;
|
|
1660
1785
|
//#endregion
|
|
1661
1786
|
//#region src/settings-definition.d.ts
|
|
1787
|
+
type SettingsConfigExport<T$1 extends SettingsConfig = SettingsConfig> = ConfigInput<T$1>;
|
|
1662
1788
|
/**
|
|
1663
1789
|
* Authored settings config shape — {@link SettingsConfig} without the `type`
|
|
1664
1790
|
* discriminant, which `defineSettings` injects.
|
|
1665
1791
|
*/
|
|
1666
1792
|
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
1793
|
/**
|
|
1677
1794
|
* Declare shared settings.
|
|
1678
1795
|
* Authored as a named `settings` export.
|
|
1679
1796
|
*/
|
|
1680
|
-
declare
|
|
1797
|
+
declare const defineSettings: <const TInput extends ConfigInput<SettingsConfigInput>>(config: TInput) => TInput extends ((ctx: ConfigContext) => infer TResult) ? (ctx: ConfigContext) => TResult extends Promise<infer TConfig extends {
|
|
1798
|
+
[x: string]: unknown;
|
|
1799
|
+
}> ? Promise<ConfigWithType<TConfig, "settings">> : TResult extends {
|
|
1800
|
+
[x: string]: unknown;
|
|
1801
|
+
} ? ConfigWithType<TResult, "settings"> : never : TInput extends Promise<infer TConfig extends {
|
|
1802
|
+
[x: string]: unknown;
|
|
1803
|
+
}> ? Promise<ConfigWithType<TConfig, "settings">> : TInput extends {
|
|
1804
|
+
[x: string]: unknown;
|
|
1805
|
+
} ? ConfigWithType<TInput, "settings"> : never;
|
|
1681
1806
|
//#endregion
|
|
1682
|
-
export {
|
|
1807
|
+
export { SettingsConfig as $, SecretsStoreSecretBinding as A, VersionMetadataBinding as B, MediaBinding$1 as C, InferMainModule as Ct, 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, ContainerConfig as Q, UnsafeBinding as R, LogfwdrBinding as S, InferEnv as St, PipelineBinding as T, WebSearchBinding as U, VpcNetworkBinding as V, WorkerBinding as W, WorkerConfigInput as X, WorkerConfigExport as Y, defineWorker as Z, FlagshipBinding as _, ContainerConfigExport as _t, AiBinding as a, ScheduledTrigger as at, JsonBinding as b, ConfigContext as bt, AnalyticsEngineDatasetBinding as c, DurableObjectCreatedExport as ct, BindingDevOptions as d, DurableObjectRenamedExport as dt, WorkerConfig as et, Bindings as f, DurableObjectTransferredExport as ft, DurableObjectBinding as g, exports as gt, DispatchNamespaceBinding as h, WorkerEntrypointExportOptions as ht, AgentMemoryBinding as i, QueueConsumerTrigger as it, SendEmailBinding as j, SecretBinding as k, ArtifactsBinding as l, DurableObjectDeletedExport as lt, D1Binding as m, WorkerEntrypointExport as mt, SettingsConfigInput as n, EmailTrigger as nt, AiSearchBinding as o, Triggers as ot, BrowserBinding as p, Exports as pt, WorkflowBinding as q, defineSettings as r, FetchTrigger as rt, AiSearchNamespaceBinding as s, triggers as st, SettingsConfigExport as t, ConnectTrigger as tt, AssetsBinding as u, DurableObjectExpectingTransferExport as ut, HyperdriveBinding as v, ContainerConfigInput as vt, MtlsCertificateBinding as w, UnwrapConfig as wt, KvBinding as x, InferDurableNamespaces as xt, ImagesBinding$1 as y, defineContainer as yt, VectorizeBinding as z };
|