@cloudflare/vite-plugin 1.55.0 → 1.57.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/cf-vite.mjs +8 -2
- package/dist/experimental-config.d.mts +306 -323
- package/dist/experimental-config.d.mts.map +1 -1
- package/dist/experimental-config.mjs +66 -39
- package/dist/experimental-config.mjs.map +1 -1
- package/dist/index.mjs +1765 -831
- package/dist/index.mjs.map +1 -1
- package/dist/{package-Dj3pQSjo.mjs → package-CVgGbwca.mjs} +2 -2
- package/dist/{package-Dj3pQSjo.mjs.map → package-CVgGbwca.mjs.map} +1 -1
- package/package.json +14 -14
|
@@ -1,7 +1,174 @@
|
|
|
1
1
|
import { Pipeline, PipelineRecord } from "cloudflare:pipelines";
|
|
2
2
|
|
|
3
|
-
//#region ../config/dist/public-
|
|
3
|
+
//#region ../config/dist/public-fVh2BrM5.d.mts
|
|
4
4
|
|
|
5
|
+
//#region src/exports.d.ts
|
|
6
|
+
/**
|
|
7
|
+
* Storage backend for the Durable Object.
|
|
8
|
+
*
|
|
9
|
+
* Containers are only supported on the SQLite storage engine, so `container` is
|
|
10
|
+
* only offered alongside `storage: "sqlite"`.
|
|
11
|
+
*/
|
|
12
|
+
type DurableObjectStorageOptions<TContainer extends ContainerDefinition | undefined = ContainerDefinition | undefined> = {
|
|
13
|
+
/**
|
|
14
|
+
* Selects the SQLite-backed storage engine (recommended for new
|
|
15
|
+
* classes).
|
|
16
|
+
*/
|
|
17
|
+
storage: "sqlite";
|
|
18
|
+
/**
|
|
19
|
+
* Attach a Container application to this Durable Object by config reference.
|
|
20
|
+
*/
|
|
21
|
+
container?: TContainer;
|
|
22
|
+
} | {
|
|
23
|
+
/** Selects the legacy key-value storage engine. */
|
|
24
|
+
storage: "legacy-kv";
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
* Declares a provisioned Durable Object class exported from this Worker.
|
|
28
|
+
*
|
|
29
|
+
* For more information about Durable Objects, see the documentation at
|
|
30
|
+
* https://developers.cloudflare.com/workers/learning/using-durable-objects
|
|
31
|
+
*
|
|
32
|
+
* For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#durable-objects
|
|
33
|
+
*/
|
|
34
|
+
type DurableObjectCreatedExportOptions<TContainer extends ContainerDefinition | undefined = ContainerDefinition | undefined> = {
|
|
35
|
+
state?: "created";
|
|
36
|
+
} & DurableObjectStorageOptions<TContainer>;
|
|
37
|
+
/**
|
|
38
|
+
* Retire a provisioned Durable Object namespace whose class has
|
|
39
|
+
* been removed from code.
|
|
40
|
+
*
|
|
41
|
+
* During deploy, the class must not be exported in the uploaded code, and no
|
|
42
|
+
* other Worker may hold a `durableObject` binding to the namespace.
|
|
43
|
+
*/
|
|
44
|
+
interface DurableObjectDeletedExportOptions {
|
|
45
|
+
state: "deleted";
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Rename a provisioned Durable Object namespace's class. The
|
|
49
|
+
* `renamedTo` value must also appear as a live (`state: "created"`)
|
|
50
|
+
* `durableObject` entry in the same `exports` map.
|
|
51
|
+
*/
|
|
52
|
+
interface DurableObjectRenamedExportOptions {
|
|
53
|
+
state: "renamed";
|
|
54
|
+
/**
|
|
55
|
+
* The destination class name. Must be a valid JavaScript identifier and
|
|
56
|
+
* must appear as a live (`state: "created"`) `durableObject` entry in the
|
|
57
|
+
* same `exports` map.
|
|
58
|
+
*/
|
|
59
|
+
renamedTo: string;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Transfer ownership of a Durable Object namespace to another Worker in the same account.
|
|
63
|
+
* The target Worker must first deploy an `expectingTransfer` entry naming this Worker via `transferFrom`.
|
|
64
|
+
*/
|
|
65
|
+
interface DurableObjectTransferredExportOptions {
|
|
66
|
+
state: "transferred";
|
|
67
|
+
/**
|
|
68
|
+
* The destination Worker. Must reference a Worker in the same account.
|
|
69
|
+
*/
|
|
70
|
+
transferredTo: string;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Prepare to receive cross-Worker Durable Object transfer.
|
|
74
|
+
* Once the source Worker's `transferred` export is deployed, this entry becomes a normal live `durable-object` export.
|
|
75
|
+
*/
|
|
76
|
+
type DurableObjectExpectingTransferExportOptions<TContainer extends ContainerDefinition | undefined = ContainerDefinition | undefined> = {
|
|
77
|
+
state: "expecting-transfer";
|
|
78
|
+
/**
|
|
79
|
+
* The source Worker for the two-phase cross-Worker transfer.
|
|
80
|
+
*/
|
|
81
|
+
transferFrom: string;
|
|
82
|
+
} & DurableObjectStorageOptions<TContainer>;
|
|
83
|
+
type DurableObjectCreatedExport<TContainer extends ContainerDefinition | undefined = ContainerDefinition | undefined> = DurableObjectCreatedExportOptions<TContainer> & {
|
|
84
|
+
type: "durable-object";
|
|
85
|
+
};
|
|
86
|
+
interface DurableObjectDeletedExport extends DurableObjectDeletedExportOptions {
|
|
87
|
+
type: "durable-object";
|
|
88
|
+
}
|
|
89
|
+
interface DurableObjectRenamedExport extends DurableObjectRenamedExportOptions {
|
|
90
|
+
type: "durable-object";
|
|
91
|
+
}
|
|
92
|
+
interface DurableObjectTransferredExport extends DurableObjectTransferredExportOptions {
|
|
93
|
+
type: "durable-object";
|
|
94
|
+
}
|
|
95
|
+
type DurableObjectExpectingTransferExport<TContainer extends ContainerDefinition | undefined = ContainerDefinition | undefined> = DurableObjectExpectingTransferExportOptions<TContainer> & {
|
|
96
|
+
type: "durable-object";
|
|
97
|
+
};
|
|
98
|
+
type DurableObjectExportOptions = DurableObjectCreatedExportOptions | DurableObjectDeletedExportOptions | DurableObjectRenamedExportOptions | DurableObjectTransferredExportOptions | DurableObjectExpectingTransferExportOptions;
|
|
99
|
+
type DurableObjectExports = DurableObjectCreatedExport | DurableObjectDeletedExport | DurableObjectRenamedExport | DurableObjectTransferredExport | DurableObjectExpectingTransferExport;
|
|
100
|
+
interface WorkerEntrypointExportOptions {
|
|
101
|
+
cache?: {
|
|
102
|
+
/** Whether cache is enabled for this entrypoint. */
|
|
103
|
+
enabled: boolean;
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
interface WorkerEntrypointExport extends WorkerEntrypointExportOptions {
|
|
107
|
+
type: "worker";
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Configuration for named exports declared by the Worker. Each entry's
|
|
111
|
+
* key is the exported class name; the value configures the export.
|
|
112
|
+
*/
|
|
113
|
+
interface Exports {
|
|
114
|
+
/**
|
|
115
|
+
* Declares a Durable Object class defined by this Worker.
|
|
116
|
+
*
|
|
117
|
+
* For more information about Durable Objects, see the documentation at
|
|
118
|
+
* https://developers.cloudflare.com/workers/learning/using-durable-objects
|
|
119
|
+
*
|
|
120
|
+
* For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#durable-objects
|
|
121
|
+
*/
|
|
122
|
+
durableObject<TContainer extends ContainerDefinition | undefined = undefined>(options: DurableObjectCreatedExportOptions<TContainer>): DurableObjectCreatedExport<TContainer>;
|
|
123
|
+
/**
|
|
124
|
+
* Retire a provisioned Durable Object namespace whose class has been removed from code.
|
|
125
|
+
*/
|
|
126
|
+
durableObject(options: DurableObjectDeletedExportOptions): DurableObjectDeletedExport;
|
|
127
|
+
/**
|
|
128
|
+
* Rename a provisioned Durable Object namespace's class.
|
|
129
|
+
*/
|
|
130
|
+
durableObject(options: DurableObjectRenamedExportOptions): DurableObjectRenamedExport;
|
|
131
|
+
/**
|
|
132
|
+
* Transfer ownership of a Durable Object namespace to another Worker in the same account.
|
|
133
|
+
*/
|
|
134
|
+
durableObject(options: DurableObjectTransferredExportOptions): DurableObjectTransferredExport;
|
|
135
|
+
/**
|
|
136
|
+
* Prepare to receive cross-Worker Durable Object transfer.
|
|
137
|
+
* The source Worker must follow up with a deployment containing a `transferred` export to commit the transfer.
|
|
138
|
+
*/
|
|
139
|
+
durableObject<TContainer extends ContainerDefinition | undefined = undefined>(options: DurableObjectExpectingTransferExportOptions<TContainer>): DurableObjectExpectingTransferExport<TContainer>;
|
|
140
|
+
durableObject(options: DurableObjectExportOptions): DurableObjectExports;
|
|
141
|
+
/** Declares a WorkerEntrypoint export defined by this Worker. */
|
|
142
|
+
worker(options?: WorkerEntrypointExportOptions): WorkerEntrypointExport;
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* Exports builder for configuring Worker exports.
|
|
146
|
+
*
|
|
147
|
+
* @example
|
|
148
|
+
* ```typescript
|
|
149
|
+
* import { defineConfig, defineContainer, defineWorker, exports } from "@cloudflare/config";
|
|
150
|
+
*
|
|
151
|
+
* const myContainer = defineContainer({
|
|
152
|
+
* name: "my-container",
|
|
153
|
+
* image: { dockerfile: "./Dockerfile" },
|
|
154
|
+
* });
|
|
155
|
+
*
|
|
156
|
+
* const worker = defineWorker({
|
|
157
|
+
* exports: {
|
|
158
|
+
* MyDurableObject: exports.durableObject({ storage: "sqlite" }),
|
|
159
|
+
* MyContainerDO: exports.durableObject({ storage: "sqlite", container: myContainer }),
|
|
160
|
+
* OldClass: exports.durableObject({ state: "deleted" }),
|
|
161
|
+
* OldName: exports.durableObject({ state: "renamed", renamedTo: "NewName" }),
|
|
162
|
+
* Outgoing: exports.durableObject({ state: "transferred", transferredTo: "target-worker" }),
|
|
163
|
+
* Incoming: exports.durableObject({ state: "expecting-transfer", storage: "sqlite", transferFrom: "source-worker" }),
|
|
164
|
+
* },
|
|
165
|
+
* });
|
|
166
|
+
*
|
|
167
|
+
* export default defineConfig({ worker, containers: [myContainer] });
|
|
168
|
+
* ```
|
|
169
|
+
*/
|
|
170
|
+
declare const exports: Exports;
|
|
171
|
+
//#endregion
|
|
5
172
|
//#region src/inference.d.ts
|
|
6
173
|
/**
|
|
7
174
|
* The Worker's entry module, imported with the `{ type: "cf-worker" }` import attribute
|
|
@@ -133,7 +300,7 @@ type InferWorkerEntrypointExports<TUnwrappedConfig> = Exclude<keyof InferMainMod
|
|
|
133
300
|
* Unwrap function and promise types to get the underlying config.
|
|
134
301
|
* Use this to normalize a config before passing it to other inference utilities.
|
|
135
302
|
*/
|
|
136
|
-
type UnwrapConfig<TConfig
|
|
303
|
+
type UnwrapConfig<TConfig> = TConfig extends ((...args: any[]) => infer TReturn) ? UnwrapConfig<TReturn> : TConfig extends Promise<infer TCompletion> ? UnwrapConfig<TCompletion> : TConfig;
|
|
137
304
|
/**
|
|
138
305
|
* Infer the `Env` interface type from a Worker config.
|
|
139
306
|
*
|
|
@@ -203,218 +370,6 @@ type InferMainModule<TUnwrappedConfig> = TUnwrappedConfig extends {
|
|
|
203
370
|
entrypoint: infer TModule extends WorkerModule;
|
|
204
371
|
} ? TModule : DefaultModule;
|
|
205
372
|
//#endregion
|
|
206
|
-
//#region src/utils.d.ts
|
|
207
|
-
/**
|
|
208
|
-
* Represents any valid JSON value.
|
|
209
|
-
*/
|
|
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;
|
|
223
|
-
}
|
|
224
|
-
/**
|
|
225
|
-
* The authored config in any of its supported shapes: a plain value, a promise,
|
|
226
|
-
* or a function of {@link ConfigContext}.
|
|
227
|
-
*/
|
|
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
|
|
254
|
-
/**
|
|
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"`.
|
|
259
|
-
*/
|
|
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
|
-
};
|
|
274
|
-
/**
|
|
275
|
-
* Declares a provisioned Durable Object class exported from this Worker.
|
|
276
|
-
*
|
|
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
|
|
281
|
-
*/
|
|
282
|
-
type DurableObjectCreatedExportOptions<TContainer extends ContainerConfigExport | undefined = ContainerConfigExport | undefined> = {
|
|
283
|
-
state?: "created";
|
|
284
|
-
} & DurableObjectStorageOptions<TContainer>;
|
|
285
|
-
/**
|
|
286
|
-
* Retire a provisioned Durable Object namespace whose class has
|
|
287
|
-
* been removed from code.
|
|
288
|
-
*
|
|
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.
|
|
291
|
-
*/
|
|
292
|
-
interface DurableObjectDeletedExportOptions {
|
|
293
|
-
state: "deleted";
|
|
294
|
-
}
|
|
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;
|
|
308
|
-
}
|
|
309
|
-
/**
|
|
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`.
|
|
312
|
-
*/
|
|
313
|
-
interface DurableObjectTransferredExportOptions {
|
|
314
|
-
state: "transferred";
|
|
315
|
-
/**
|
|
316
|
-
* The destination Worker. Must reference a Worker in the same account.
|
|
317
|
-
*/
|
|
318
|
-
transferredTo: string;
|
|
319
|
-
}
|
|
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";
|
|
336
|
-
}
|
|
337
|
-
interface DurableObjectRenamedExport extends DurableObjectRenamedExportOptions {
|
|
338
|
-
type: "durable-object";
|
|
339
|
-
}
|
|
340
|
-
interface DurableObjectTransferredExport extends DurableObjectTransferredExportOptions {
|
|
341
|
-
type: "durable-object";
|
|
342
|
-
}
|
|
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
|
-
};
|
|
353
|
-
}
|
|
354
|
-
interface WorkerEntrypointExport extends WorkerEntrypointExportOptions {
|
|
355
|
-
type: "worker";
|
|
356
|
-
}
|
|
357
|
-
/**
|
|
358
|
-
* Configuration for named exports declared by the Worker. Each entry's
|
|
359
|
-
* key is the exported class name; the value configures the export.
|
|
360
|
-
*/
|
|
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;
|
|
391
|
-
}
|
|
392
|
-
/**
|
|
393
|
-
* Exports builder for configuring Worker exports.
|
|
394
|
-
*
|
|
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
|
-
* ```
|
|
415
|
-
*/
|
|
416
|
-
declare const exports: Exports;
|
|
417
|
-
//#endregion
|
|
418
373
|
//#region src/triggers.d.ts
|
|
419
374
|
interface FetchTriggerOptions {
|
|
420
375
|
/**
|
|
@@ -563,23 +518,47 @@ interface Triggers {
|
|
|
563
518
|
*
|
|
564
519
|
* @example
|
|
565
520
|
* ```typescript
|
|
566
|
-
* import {
|
|
521
|
+
* import { defineConfig, triggers } from "@cloudflare/config";
|
|
567
522
|
*
|
|
568
|
-
* export default
|
|
569
|
-
*
|
|
570
|
-
*
|
|
571
|
-
*
|
|
572
|
-
* triggers
|
|
573
|
-
*
|
|
574
|
-
*
|
|
575
|
-
*
|
|
576
|
-
*
|
|
523
|
+
* export default defineConfig({
|
|
524
|
+
* worker: {
|
|
525
|
+
* name: "my-worker",
|
|
526
|
+
* compatibilityDate: "2026-09-17",
|
|
527
|
+
* triggers: [
|
|
528
|
+
* triggers.fetch({ pattern: "example.com/*", zone: "example.com" }),
|
|
529
|
+
* triggers.queue({ name: "my-queue" }),
|
|
530
|
+
* triggers.scheduled({ schedule: "0 * * * *" }),
|
|
531
|
+
* triggers.scheduled({ schedule: "30 0 * * *" }),
|
|
532
|
+
* triggers.email({ addresses: ["support@example.com"] }),
|
|
533
|
+
* triggers.connect({ protocol: "tcp", port: 5432 }),
|
|
534
|
+
* ],
|
|
535
|
+
* },
|
|
577
536
|
* });
|
|
578
537
|
* ```
|
|
579
538
|
*/
|
|
580
539
|
declare const triggers: Triggers;
|
|
581
540
|
//#endregion
|
|
582
541
|
//#region src/types.d.ts
|
|
542
|
+
/** Account-level values shared by the resources in a configuration. */
|
|
543
|
+
interface Settings {
|
|
544
|
+
/**
|
|
545
|
+
* This is the ID of the account associated with your zone. It can also be
|
|
546
|
+
* specified through the `CLOUDFLARE_ACCOUNT_ID` environment variable.
|
|
547
|
+
*/
|
|
548
|
+
accountId?: string;
|
|
549
|
+
/**
|
|
550
|
+
* The compliance boundary in which commands should operate. When omitted,
|
|
551
|
+
* this can be supplied through `CLOUDFLARE_COMPLIANCE_REGION`.
|
|
552
|
+
*/
|
|
553
|
+
complianceRegion?: "public" | "fedramp-high";
|
|
554
|
+
}
|
|
555
|
+
/** The authored shape of `cloudflare.config.ts`'s default export. */
|
|
556
|
+
interface CloudflareConfig extends Settings {
|
|
557
|
+
/** The Worker defined by this configuration. */
|
|
558
|
+
worker?: ConfigInput<WorkerConfig>;
|
|
559
|
+
/** Container applications defined by this configuration. */
|
|
560
|
+
containers?: ConfigInput<ContainerConfig>[];
|
|
561
|
+
}
|
|
583
562
|
/**
|
|
584
563
|
* Union of all binding definitions accepted in `env`.
|
|
585
564
|
*/
|
|
@@ -615,15 +594,27 @@ type ContainerImage = {
|
|
|
615
594
|
*/
|
|
616
595
|
reference: string;
|
|
617
596
|
};
|
|
597
|
+
/** Application-wide observability settings shared by all Containers. */
|
|
598
|
+
interface ContainerObservabilityConfig {
|
|
599
|
+
/** Whether observability is enabled. */
|
|
600
|
+
enabled?: boolean;
|
|
601
|
+
logs?: {
|
|
602
|
+
/** Whether log collection is enabled. */
|
|
603
|
+
enabled?: boolean;
|
|
604
|
+
};
|
|
605
|
+
}
|
|
606
|
+
/** Observability settings for a standard Container application. */
|
|
607
|
+
type StandardContainerObservabilityConfig = ContainerObservabilityConfig & ({
|
|
608
|
+
/** Percentage of Container instances targeted for observability. */
|
|
609
|
+
targetInstancePercentage?: number;
|
|
610
|
+
targetInstanceCount?: never;
|
|
611
|
+
} | {
|
|
612
|
+
targetInstancePercentage?: never;
|
|
613
|
+
/** Number of Container instances targeted for observability. */
|
|
614
|
+
targetInstanceCount?: number;
|
|
615
|
+
});
|
|
618
616
|
/** Fields shared by all Container application configurations. */
|
|
619
617
|
interface BaseContainerConfig {
|
|
620
|
-
/**
|
|
621
|
-
* Discriminates this config as a Container config.
|
|
622
|
-
*
|
|
623
|
-
* Injected automatically by `defineContainer`; only needs to be written by
|
|
624
|
-
* hand when authoring a raw config object without the helper.
|
|
625
|
-
*/
|
|
626
|
-
type: "container";
|
|
627
618
|
/**
|
|
628
619
|
* Name of the application.
|
|
629
620
|
*
|
|
@@ -631,23 +622,6 @@ interface BaseContainerConfig {
|
|
|
631
622
|
* Object's `exports` entry via its `container` field.
|
|
632
623
|
*/
|
|
633
624
|
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
|
-
});
|
|
651
625
|
/**
|
|
652
626
|
* Passed through without client-side validation or transformation.
|
|
653
627
|
*
|
|
@@ -657,6 +631,8 @@ interface BaseContainerConfig {
|
|
|
657
631
|
}
|
|
658
632
|
/** A Container application managed with a standard scheduling policy. */
|
|
659
633
|
interface StandardContainerConfig extends BaseContainerConfig {
|
|
634
|
+
/** Configures observability and optional targeting for Container instances. */
|
|
635
|
+
observability?: StandardContainerObservabilityConfig;
|
|
660
636
|
/** The image to build or deploy. */
|
|
661
637
|
image: ContainerImage;
|
|
662
638
|
/**
|
|
@@ -761,29 +737,27 @@ interface StandardContainerConfig extends BaseContainerConfig {
|
|
|
761
737
|
/** A Container application managed by a Durable Object. */
|
|
762
738
|
interface DurableObjectContainerConfig extends BaseContainerConfig {
|
|
763
739
|
schedulingPolicy: "durable-object";
|
|
740
|
+
/**
|
|
741
|
+
* Configures application-wide observability. Instance targeting is not
|
|
742
|
+
* supported for Durable Object-managed Containers.
|
|
743
|
+
*/
|
|
744
|
+
observability?: ContainerObservabilityConfig;
|
|
764
745
|
/** Named images that the Durable Object can start. */
|
|
765
746
|
images?: Record<string, ContainerImage>;
|
|
766
747
|
}
|
|
767
748
|
/**
|
|
768
749
|
* Container application configuration. This is the input shape passed to
|
|
769
|
-
* `defineContainer` and
|
|
750
|
+
* `defineContainer` and parsed at runtime by `InputContainerSchema`.
|
|
770
751
|
*/
|
|
771
752
|
type ContainerConfig = DurableObjectContainerConfig | StandardContainerConfig;
|
|
772
753
|
/**
|
|
773
754
|
* Worker configuration. This is the input shape passed to
|
|
774
755
|
* [`defineWorker`](https://developers.cloudflare.com/workers/wrangler/configuration/).
|
|
775
756
|
*
|
|
776
|
-
* Fields are
|
|
757
|
+
* Fields are parsed and normalised at runtime by `InputWorkerSchema` before
|
|
777
758
|
* being passed to downstream tooling.
|
|
778
759
|
*/
|
|
779
760
|
interface WorkerConfig {
|
|
780
|
-
/**
|
|
781
|
-
* Discriminates this config as a Worker config.
|
|
782
|
-
*
|
|
783
|
-
* Injected automatically by `defineWorker`; only needs to be written by
|
|
784
|
-
* hand when authoring a raw config object without the helper.
|
|
785
|
-
*/
|
|
786
|
-
type: "worker";
|
|
787
761
|
/**
|
|
788
762
|
* The name of your Worker.
|
|
789
763
|
*/
|
|
@@ -812,8 +786,10 @@ interface WorkerConfig {
|
|
|
812
786
|
*
|
|
813
787
|
* @example
|
|
814
788
|
* ```ts
|
|
789
|
+
* import { defineConfig, defineWorker } from "@cloudflare/config";
|
|
815
790
|
* import * as entrypoint from "./src" with { type: "cf-worker" };
|
|
816
|
-
*
|
|
791
|
+
* const worker = defineWorker({ entrypoint });
|
|
792
|
+
* export default defineConfig({ worker });
|
|
817
793
|
* ```
|
|
818
794
|
*/
|
|
819
795
|
entrypoint?: string | WorkerModule;
|
|
@@ -1039,52 +1015,81 @@ interface WorkerConfig {
|
|
|
1039
1015
|
*/
|
|
1040
1016
|
exports?: Record<string, Export>;
|
|
1041
1017
|
}
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
interface SettingsConfig {
|
|
1048
|
-
/**
|
|
1049
|
-
* Discriminates this config as a settings config.
|
|
1050
|
-
*
|
|
1051
|
-
* Injected automatically by `defineSettings`; only needs to be written by
|
|
1052
|
-
* hand when authoring a raw config object without the helper.
|
|
1053
|
-
*/
|
|
1054
|
-
type: "settings";
|
|
1055
|
-
/**
|
|
1056
|
-
* This is the ID of the account associated with your zone.
|
|
1057
|
-
* You might have more than one account, so make sure to use
|
|
1058
|
-
* the ID of the account associated with the zone/route you
|
|
1059
|
-
* provide, if you provide one. It can also be specified through
|
|
1060
|
-
* the CLOUDFLARE_ACCOUNT_ID environment variable.
|
|
1061
|
-
*/
|
|
1062
|
-
accountId?: string;
|
|
1018
|
+
//#endregion
|
|
1019
|
+
//#region src/definition.d.ts
|
|
1020
|
+
interface ConfigContext {
|
|
1021
|
+
/** Whether the config is being evaluated for a Preview build. */
|
|
1022
|
+
isPreview: boolean;
|
|
1063
1023
|
/**
|
|
1064
|
-
*
|
|
1065
|
-
*
|
|
1066
|
-
*
|
|
1067
|
-
*
|
|
1024
|
+
* The mode the config is being evaluated in.
|
|
1025
|
+
* Set via the `--mode` CLI flag.
|
|
1026
|
+
* 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)).
|
|
1027
|
+
* In Wrangler the mode defaults to `undefined`.
|
|
1068
1028
|
*/
|
|
1069
|
-
|
|
1029
|
+
mode: string | undefined;
|
|
1070
1030
|
}
|
|
1031
|
+
/**
|
|
1032
|
+
* A configuration value, promise, or factory. Factories can be passed directly
|
|
1033
|
+
* for automatic resolution with the current context or called explicitly with
|
|
1034
|
+
* another context before they are used.
|
|
1035
|
+
*/
|
|
1036
|
+
type ConfigInput<T$1> = T$1 | Promise<T$1> | ((ctx: ConfigContext) => T$1 | Promise<T$1>);
|
|
1037
|
+
type ContainerDefinition<T$1 extends ContainerConfig = ContainerConfig> = ConfigInput<T$1>;
|
|
1038
|
+
type WorkerDefinition<T$1 extends WorkerConfig = WorkerConfig> = ConfigInput<T$1>;
|
|
1039
|
+
/** A Worker name, value, promise, or context-aware factory. */
|
|
1040
|
+
type WorkerReference = string | WorkerDefinition;
|
|
1041
|
+
/**
|
|
1042
|
+
* Used to define the default export in `cloudflare.config.ts`.
|
|
1043
|
+
*
|
|
1044
|
+
* @example
|
|
1045
|
+
* ```typescript
|
|
1046
|
+
* import { defineConfig } from "@cloudflare/config";
|
|
1047
|
+
*
|
|
1048
|
+
* export default defineConfig({
|
|
1049
|
+
* worker: {
|
|
1050
|
+
* name: "my-worker",
|
|
1051
|
+
* compatibilityDate: "2026-09-17",
|
|
1052
|
+
* },
|
|
1053
|
+
* });
|
|
1054
|
+
* ```
|
|
1055
|
+
*/
|
|
1056
|
+
declare const defineConfig: <const TInput extends ConfigInput<CloudflareConfig>>(config: TInput) => TInput;
|
|
1057
|
+
/**
|
|
1058
|
+
* Define a Container.
|
|
1059
|
+
*
|
|
1060
|
+
* @example
|
|
1061
|
+
* ```typescript
|
|
1062
|
+
* import { defineContainer } from "@cloudflare/config";
|
|
1063
|
+
*
|
|
1064
|
+
* const container = defineContainer({
|
|
1065
|
+
* name: "my-container",
|
|
1066
|
+
* image: { dockerfile: "./Dockerfile" },
|
|
1067
|
+
* });
|
|
1068
|
+
* ```
|
|
1069
|
+
*/
|
|
1070
|
+
declare const defineContainer: <const TInput extends ConfigInput<ContainerConfig>>(config: TInput) => TInput;
|
|
1071
|
+
/**
|
|
1072
|
+
* Define a Worker.
|
|
1073
|
+
*
|
|
1074
|
+
* @example
|
|
1075
|
+
* ```typescript
|
|
1076
|
+
* import { defineWorker } from "@cloudflare/config";
|
|
1077
|
+
*
|
|
1078
|
+
* const worker = defineWorker({
|
|
1079
|
+
* name: "my-worker",
|
|
1080
|
+
* compatibilityDate: "2026-09-17",
|
|
1081
|
+
* });
|
|
1082
|
+
* ```
|
|
1083
|
+
*/
|
|
1084
|
+
declare const defineWorker: <const TInput extends ConfigInput<WorkerConfig>>(config: TInput) => TInput;
|
|
1071
1085
|
//#endregion
|
|
1072
|
-
//#region src/
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
declare const defineWorker: <const TInput extends ConfigInput<WorkerConfigInput>>(config: TInput) => TInput extends ((ctx: ConfigContext) => infer TResult) ? (ctx: ConfigContext) => TResult extends Promise<infer TConfig extends {
|
|
1080
|
-
[x: string]: unknown;
|
|
1081
|
-
}> ? Promise<ConfigWithType<TConfig, "worker">> : TResult extends {
|
|
1082
|
-
[x: string]: unknown;
|
|
1083
|
-
} ? ConfigWithType<TResult, "worker"> : never : TInput extends Promise<infer TConfig extends {
|
|
1084
|
-
[x: string]: unknown;
|
|
1085
|
-
}> ? Promise<ConfigWithType<TConfig, "worker">> : TInput extends {
|
|
1086
|
-
[x: string]: unknown;
|
|
1087
|
-
} ? ConfigWithType<TInput, "worker"> : never;
|
|
1086
|
+
//#region src/utils.d.ts
|
|
1087
|
+
/**
|
|
1088
|
+
* Represents any valid JSON value.
|
|
1089
|
+
*/
|
|
1090
|
+
type Json = string | number | boolean | null | Json[] | {
|
|
1091
|
+
[key: string]: Json;
|
|
1092
|
+
};
|
|
1088
1093
|
//#endregion
|
|
1089
1094
|
//#region src/bindings.d.ts
|
|
1090
1095
|
/** Options that control a binding during local development. */
|
|
@@ -1234,7 +1239,6 @@ interface DispatchNamespaceBindingOptions {
|
|
|
1234
1239
|
interface DispatchNamespaceBinding extends DispatchNamespaceBindingOptions {
|
|
1235
1240
|
type: "dispatch-namespace";
|
|
1236
1241
|
}
|
|
1237
|
-
type WorkerReference = string | WorkerConfigExport;
|
|
1238
1242
|
type ReferencedWorkerConfig<TWorker$1 extends WorkerReference> = TWorker$1 extends string ? never : UnwrapConfig<TWorker$1>;
|
|
1239
1243
|
type DurableObjectExportName<TWorker$1 extends WorkerReference> = TWorker$1 extends string ? string : InferDurableNamespaces<ReferencedWorkerConfig<TWorker$1>>;
|
|
1240
1244
|
type WorkerEntrypointExportName<TWorker$1 extends WorkerReference> = TWorker$1 extends string ? string : InferWorkerEntrypointExports<ReferencedWorkerConfig<TWorker$1>>;
|
|
@@ -1772,27 +1776,6 @@ interface Bindings {
|
|
|
1772
1776
|
}
|
|
1773
1777
|
declare const bindings: Bindings;
|
|
1774
1778
|
//#endregion
|
|
1775
|
-
//#region src/settings-definition.d.ts
|
|
1776
|
-
type SettingsConfigExport<T$1 extends SettingsConfig = SettingsConfig> = ConfigInput<T$1>;
|
|
1777
|
-
/**
|
|
1778
|
-
* Authored settings config shape — {@link SettingsConfig} without the `type`
|
|
1779
|
-
* discriminant, which `defineSettings` injects.
|
|
1780
|
-
*/
|
|
1781
|
-
type SettingsConfigInput = Omit<SettingsConfig, "type">;
|
|
1782
|
-
/**
|
|
1783
|
-
* Declare shared settings.
|
|
1784
|
-
* Authored as a named `settings` export.
|
|
1785
|
-
*/
|
|
1786
|
-
declare const defineSettings: <const TInput extends ConfigInput<SettingsConfigInput>>(config: TInput) => TInput extends ((ctx: ConfigContext) => infer TResult) ? (ctx: ConfigContext) => TResult extends Promise<infer TConfig extends {
|
|
1787
|
-
[x: string]: unknown;
|
|
1788
|
-
}> ? Promise<ConfigWithType<TConfig, "settings">> : TResult extends {
|
|
1789
|
-
[x: string]: unknown;
|
|
1790
|
-
} ? ConfigWithType<TResult, "settings"> : never : TInput extends Promise<infer TConfig extends {
|
|
1791
|
-
[x: string]: unknown;
|
|
1792
|
-
}> ? Promise<ConfigWithType<TConfig, "settings">> : TInput extends {
|
|
1793
|
-
[x: string]: unknown;
|
|
1794
|
-
} ? ConfigWithType<TInput, "settings"> : never;
|
|
1795
|
-
//#endregion
|
|
1796
1779
|
//#endregion
|
|
1797
|
-
export { AgentMemoryBinding, AiBinding, AiSearchBinding, AiSearchNamespaceBinding, AnalyticsEngineDatasetBinding, ArtifactsBinding, AssetsBinding, BindingDevOptions, Bindings, BrowserBinding, ConfigContext, ConnectTrigger, ContainerConfig,
|
|
1780
|
+
export { AgentMemoryBinding, AiBinding, AiSearchBinding, AiSearchNamespaceBinding, AnalyticsEngineDatasetBinding, ArtifactsBinding, AssetsBinding, BindingDevOptions, Bindings, BrowserBinding, CloudflareConfig, ConfigContext, ConnectTrigger, ContainerConfig, ContainerDefinition, D1Binding, DispatchNamespaceBinding, DurableObjectBinding, DurableObjectCreatedExport, DurableObjectDeletedExport, DurableObjectExpectingTransferExport, DurableObjectRenamedExport, DurableObjectTransferredExport, EmailTrigger, Exports, FetchTrigger, FlagshipBinding, HyperdriveBinding, ImagesBinding$1 as ImagesBinding, InferDurableNamespaces, InferEnv, InferMainModule, JsonBinding, KvBinding, LogfwdrBinding, MediaBinding$1 as MediaBinding, MtlsCertificateBinding, PipelineBinding, QueueBinding, QueueConsumerTrigger, R2Binding, RateLimitBinding, ScheduledTrigger, SecretBinding, SecretsStoreSecretBinding, SendEmailBinding, Settings, StreamBinding$1 as StreamBinding, TextBinding, Triggers, TypedAiBinding, TypedKvBinding, TypedPipelineBinding, TypedQueueBinding, UnsafeBinding, UnwrapConfig, VectorizeBinding, VersionMetadataBinding, VpcNetworkBinding, VpcServiceBinding, WorkerBinding, WorkerConfig, WorkerDefinition, WorkerEntrypointExport, WorkerEntrypointExportOptions, WorkerLoaderBinding, WorkerReference, WorkflowBinding, bindings, defineConfig, defineContainer, defineWorker, exports, triggers };
|
|
1798
1781
|
//# sourceMappingURL=experimental-config.d.mts.map
|