@cloudflare/config 0.15.0 → 0.16.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 +309 -87
- package/dist/index.mjs +133 -226
- package/dist/{public-Dyr8BJqf.mjs → public-BMg6-Hxh.mjs} +65 -47
- package/dist/{public-CFsFemEv.d.mts → public-fVh2BrM5.d.mts} +280 -307
- package/dist/public.d.mts +2 -2
- package/dist/public.mjs +2 -2
- package/package.json +3 -3
|
@@ -1,7 +1,174 @@
|
|
|
1
1
|
import { Pipeline, PipelineRecord } from "cloudflare:pipelines";
|
|
2
2
|
|
|
3
|
-
//#region src/
|
|
3
|
+
//#region src/exports.d.ts
|
|
4
4
|
|
|
5
|
+
/**
|
|
6
|
+
* Storage backend for the Durable Object.
|
|
7
|
+
*
|
|
8
|
+
* Containers are only supported on the SQLite storage engine, so `container` is
|
|
9
|
+
* only offered alongside `storage: "sqlite"`.
|
|
10
|
+
*/
|
|
11
|
+
type DurableObjectStorageOptions<TContainer extends ContainerDefinition | undefined = ContainerDefinition | undefined> = {
|
|
12
|
+
/**
|
|
13
|
+
* Selects the SQLite-backed storage engine (recommended for new
|
|
14
|
+
* classes).
|
|
15
|
+
*/
|
|
16
|
+
storage: "sqlite";
|
|
17
|
+
/**
|
|
18
|
+
* Attach a Container application to this Durable Object by config reference.
|
|
19
|
+
*/
|
|
20
|
+
container?: TContainer;
|
|
21
|
+
} | {
|
|
22
|
+
/** Selects the legacy key-value storage engine. */
|
|
23
|
+
storage: "legacy-kv";
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* Declares a provisioned Durable Object class exported from this Worker.
|
|
27
|
+
*
|
|
28
|
+
* For more information about Durable Objects, see the documentation at
|
|
29
|
+
* https://developers.cloudflare.com/workers/learning/using-durable-objects
|
|
30
|
+
*
|
|
31
|
+
* For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#durable-objects
|
|
32
|
+
*/
|
|
33
|
+
type DurableObjectCreatedExportOptions<TContainer extends ContainerDefinition | undefined = ContainerDefinition | undefined> = {
|
|
34
|
+
state?: "created";
|
|
35
|
+
} & DurableObjectStorageOptions<TContainer>;
|
|
36
|
+
/**
|
|
37
|
+
* Retire a provisioned Durable Object namespace whose class has
|
|
38
|
+
* been removed from code.
|
|
39
|
+
*
|
|
40
|
+
* During deploy, the class must not be exported in the uploaded code, and no
|
|
41
|
+
* other Worker may hold a `durableObject` binding to the namespace.
|
|
42
|
+
*/
|
|
43
|
+
interface DurableObjectDeletedExportOptions {
|
|
44
|
+
state: "deleted";
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Rename a provisioned Durable Object namespace's class. The
|
|
48
|
+
* `renamedTo` value must also appear as a live (`state: "created"`)
|
|
49
|
+
* `durableObject` entry in the same `exports` map.
|
|
50
|
+
*/
|
|
51
|
+
interface DurableObjectRenamedExportOptions {
|
|
52
|
+
state: "renamed";
|
|
53
|
+
/**
|
|
54
|
+
* The destination class name. Must be a valid JavaScript identifier and
|
|
55
|
+
* must appear as a live (`state: "created"`) `durableObject` entry in the
|
|
56
|
+
* same `exports` map.
|
|
57
|
+
*/
|
|
58
|
+
renamedTo: string;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Transfer ownership of a Durable Object namespace to another Worker in the same account.
|
|
62
|
+
* The target Worker must first deploy an `expectingTransfer` entry naming this Worker via `transferFrom`.
|
|
63
|
+
*/
|
|
64
|
+
interface DurableObjectTransferredExportOptions {
|
|
65
|
+
state: "transferred";
|
|
66
|
+
/**
|
|
67
|
+
* The destination Worker. Must reference a Worker in the same account.
|
|
68
|
+
*/
|
|
69
|
+
transferredTo: string;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Prepare to receive cross-Worker Durable Object transfer.
|
|
73
|
+
* Once the source Worker's `transferred` export is deployed, this entry becomes a normal live `durable-object` export.
|
|
74
|
+
*/
|
|
75
|
+
type DurableObjectExpectingTransferExportOptions<TContainer extends ContainerDefinition | undefined = ContainerDefinition | undefined> = {
|
|
76
|
+
state: "expecting-transfer";
|
|
77
|
+
/**
|
|
78
|
+
* The source Worker for the two-phase cross-Worker transfer.
|
|
79
|
+
*/
|
|
80
|
+
transferFrom: string;
|
|
81
|
+
} & DurableObjectStorageOptions<TContainer>;
|
|
82
|
+
type DurableObjectCreatedExport<TContainer extends ContainerDefinition | undefined = ContainerDefinition | undefined> = DurableObjectCreatedExportOptions<TContainer> & {
|
|
83
|
+
type: "durable-object";
|
|
84
|
+
};
|
|
85
|
+
interface DurableObjectDeletedExport extends DurableObjectDeletedExportOptions {
|
|
86
|
+
type: "durable-object";
|
|
87
|
+
}
|
|
88
|
+
interface DurableObjectRenamedExport extends DurableObjectRenamedExportOptions {
|
|
89
|
+
type: "durable-object";
|
|
90
|
+
}
|
|
91
|
+
interface DurableObjectTransferredExport extends DurableObjectTransferredExportOptions {
|
|
92
|
+
type: "durable-object";
|
|
93
|
+
}
|
|
94
|
+
type DurableObjectExpectingTransferExport<TContainer extends ContainerDefinition | undefined = ContainerDefinition | undefined> = DurableObjectExpectingTransferExportOptions<TContainer> & {
|
|
95
|
+
type: "durable-object";
|
|
96
|
+
};
|
|
97
|
+
type DurableObjectExportOptions = DurableObjectCreatedExportOptions | DurableObjectDeletedExportOptions | DurableObjectRenamedExportOptions | DurableObjectTransferredExportOptions | DurableObjectExpectingTransferExportOptions;
|
|
98
|
+
type DurableObjectExports = DurableObjectCreatedExport | DurableObjectDeletedExport | DurableObjectRenamedExport | DurableObjectTransferredExport | DurableObjectExpectingTransferExport;
|
|
99
|
+
interface WorkerEntrypointExportOptions {
|
|
100
|
+
cache?: {
|
|
101
|
+
/** Whether cache is enabled for this entrypoint. */
|
|
102
|
+
enabled: boolean;
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
interface WorkerEntrypointExport extends WorkerEntrypointExportOptions {
|
|
106
|
+
type: "worker";
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Configuration for named exports declared by the Worker. Each entry's
|
|
110
|
+
* key is the exported class name; the value configures the export.
|
|
111
|
+
*/
|
|
112
|
+
interface Exports {
|
|
113
|
+
/**
|
|
114
|
+
* Declares a Durable Object class defined by this Worker.
|
|
115
|
+
*
|
|
116
|
+
* For more information about Durable Objects, see the documentation at
|
|
117
|
+
* https://developers.cloudflare.com/workers/learning/using-durable-objects
|
|
118
|
+
*
|
|
119
|
+
* For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#durable-objects
|
|
120
|
+
*/
|
|
121
|
+
durableObject<TContainer extends ContainerDefinition | undefined = undefined>(options: DurableObjectCreatedExportOptions<TContainer>): DurableObjectCreatedExport<TContainer>;
|
|
122
|
+
/**
|
|
123
|
+
* Retire a provisioned Durable Object namespace whose class has been removed from code.
|
|
124
|
+
*/
|
|
125
|
+
durableObject(options: DurableObjectDeletedExportOptions): DurableObjectDeletedExport;
|
|
126
|
+
/**
|
|
127
|
+
* Rename a provisioned Durable Object namespace's class.
|
|
128
|
+
*/
|
|
129
|
+
durableObject(options: DurableObjectRenamedExportOptions): DurableObjectRenamedExport;
|
|
130
|
+
/**
|
|
131
|
+
* Transfer ownership of a Durable Object namespace to another Worker in the same account.
|
|
132
|
+
*/
|
|
133
|
+
durableObject(options: DurableObjectTransferredExportOptions): DurableObjectTransferredExport;
|
|
134
|
+
/**
|
|
135
|
+
* Prepare to receive cross-Worker Durable Object transfer.
|
|
136
|
+
* The source Worker must follow up with a deployment containing a `transferred` export to commit the transfer.
|
|
137
|
+
*/
|
|
138
|
+
durableObject<TContainer extends ContainerDefinition | undefined = undefined>(options: DurableObjectExpectingTransferExportOptions<TContainer>): DurableObjectExpectingTransferExport<TContainer>;
|
|
139
|
+
durableObject(options: DurableObjectExportOptions): DurableObjectExports;
|
|
140
|
+
/** Declares a WorkerEntrypoint export defined by this Worker. */
|
|
141
|
+
worker(options?: WorkerEntrypointExportOptions): WorkerEntrypointExport;
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* Exports builder for configuring Worker exports.
|
|
145
|
+
*
|
|
146
|
+
* @example
|
|
147
|
+
* ```typescript
|
|
148
|
+
* import { defineConfig, defineContainer, defineWorker, exports } from "@cloudflare/config";
|
|
149
|
+
*
|
|
150
|
+
* const myContainer = defineContainer({
|
|
151
|
+
* name: "my-container",
|
|
152
|
+
* image: { dockerfile: "./Dockerfile" },
|
|
153
|
+
* });
|
|
154
|
+
*
|
|
155
|
+
* const worker = defineWorker({
|
|
156
|
+
* exports: {
|
|
157
|
+
* MyDurableObject: exports.durableObject({ storage: "sqlite" }),
|
|
158
|
+
* MyContainerDO: exports.durableObject({ storage: "sqlite", container: myContainer }),
|
|
159
|
+
* OldClass: exports.durableObject({ state: "deleted" }),
|
|
160
|
+
* OldName: exports.durableObject({ state: "renamed", renamedTo: "NewName" }),
|
|
161
|
+
* Outgoing: exports.durableObject({ state: "transferred", transferredTo: "target-worker" }),
|
|
162
|
+
* Incoming: exports.durableObject({ state: "expecting-transfer", storage: "sqlite", transferFrom: "source-worker" }),
|
|
163
|
+
* },
|
|
164
|
+
* });
|
|
165
|
+
*
|
|
166
|
+
* export default defineConfig({ worker, containers: [myContainer] });
|
|
167
|
+
* ```
|
|
168
|
+
*/
|
|
169
|
+
declare const exports: Exports;
|
|
170
|
+
//#endregion
|
|
171
|
+
//#region src/inference.d.ts
|
|
5
172
|
/**
|
|
6
173
|
* The Worker's entry module, imported with the `{ type: "cf-worker" }` import attribute
|
|
7
174
|
* @example
|
|
@@ -132,7 +299,7 @@ type InferWorkerEntrypointExports<TUnwrappedConfig> = Exclude<keyof InferMainMod
|
|
|
132
299
|
* Unwrap function and promise types to get the underlying config.
|
|
133
300
|
* Use this to normalize a config before passing it to other inference utilities.
|
|
134
301
|
*/
|
|
135
|
-
type UnwrapConfig<TConfig
|
|
302
|
+
type UnwrapConfig<TConfig> = TConfig extends ((...args: any[]) => infer TReturn) ? UnwrapConfig<TReturn> : TConfig extends Promise<infer TCompletion> ? UnwrapConfig<TCompletion> : TConfig;
|
|
136
303
|
/**
|
|
137
304
|
* Infer the `Env` interface type from a Worker config.
|
|
138
305
|
*
|
|
@@ -202,219 +369,6 @@ type InferMainModule<TUnwrappedConfig> = TUnwrappedConfig extends {
|
|
|
202
369
|
entrypoint: infer TModule extends WorkerModule;
|
|
203
370
|
} ? TModule : DefaultModule;
|
|
204
371
|
//#endregion
|
|
205
|
-
//#region src/utils.d.ts
|
|
206
|
-
/**
|
|
207
|
-
* Represents any valid JSON value.
|
|
208
|
-
*/
|
|
209
|
-
type Json = string | number | boolean | null | Json[] | {
|
|
210
|
-
[key: string]: Json;
|
|
211
|
-
};
|
|
212
|
-
//#endregion
|
|
213
|
-
//#region src/definition.d.ts
|
|
214
|
-
interface ConfigContext {
|
|
215
|
-
isPreview: boolean;
|
|
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
372
|
//#region src/triggers.d.ts
|
|
419
373
|
interface FetchTriggerOptions {
|
|
420
374
|
/**
|
|
@@ -563,23 +517,47 @@ interface Triggers {
|
|
|
563
517
|
*
|
|
564
518
|
* @example
|
|
565
519
|
* ```typescript
|
|
566
|
-
* import {
|
|
520
|
+
* import { defineConfig, triggers } from "@cloudflare/config";
|
|
567
521
|
*
|
|
568
|
-
* export default
|
|
569
|
-
*
|
|
570
|
-
*
|
|
571
|
-
*
|
|
572
|
-
* triggers
|
|
573
|
-
*
|
|
574
|
-
*
|
|
575
|
-
*
|
|
576
|
-
*
|
|
522
|
+
* export default defineConfig({
|
|
523
|
+
* worker: {
|
|
524
|
+
* name: "my-worker",
|
|
525
|
+
* compatibilityDate: "2026-09-17",
|
|
526
|
+
* triggers: [
|
|
527
|
+
* triggers.fetch({ pattern: "example.com/*", zone: "example.com" }),
|
|
528
|
+
* triggers.queue({ name: "my-queue" }),
|
|
529
|
+
* triggers.scheduled({ schedule: "0 * * * *" }),
|
|
530
|
+
* triggers.scheduled({ schedule: "30 0 * * *" }),
|
|
531
|
+
* triggers.email({ addresses: ["support@example.com"] }),
|
|
532
|
+
* triggers.connect({ protocol: "tcp", port: 5432 }),
|
|
533
|
+
* ],
|
|
534
|
+
* },
|
|
577
535
|
* });
|
|
578
536
|
* ```
|
|
579
537
|
*/
|
|
580
538
|
declare const triggers: Triggers;
|
|
581
539
|
//#endregion
|
|
582
540
|
//#region src/types.d.ts
|
|
541
|
+
/** Account-level values shared by the resources in a configuration. */
|
|
542
|
+
interface Settings {
|
|
543
|
+
/**
|
|
544
|
+
* This is the ID of the account associated with your zone. It can also be
|
|
545
|
+
* specified through the `CLOUDFLARE_ACCOUNT_ID` environment variable.
|
|
546
|
+
*/
|
|
547
|
+
accountId?: string;
|
|
548
|
+
/**
|
|
549
|
+
* The compliance boundary in which commands should operate. When omitted,
|
|
550
|
+
* this can be supplied through `CLOUDFLARE_COMPLIANCE_REGION`.
|
|
551
|
+
*/
|
|
552
|
+
complianceRegion?: "public" | "fedramp-high";
|
|
553
|
+
}
|
|
554
|
+
/** The authored shape of `cloudflare.config.ts`'s default export. */
|
|
555
|
+
interface CloudflareConfig extends Settings {
|
|
556
|
+
/** The Worker defined by this configuration. */
|
|
557
|
+
worker?: ConfigInput<WorkerConfig>;
|
|
558
|
+
/** Container applications defined by this configuration. */
|
|
559
|
+
containers?: ConfigInput<ContainerConfig>[];
|
|
560
|
+
}
|
|
583
561
|
/**
|
|
584
562
|
* Union of all binding definitions accepted in `env`.
|
|
585
563
|
*/
|
|
@@ -636,13 +614,6 @@ type StandardContainerObservabilityConfig = ContainerObservabilityConfig & ({
|
|
|
636
614
|
});
|
|
637
615
|
/** Fields shared by all Container application configurations. */
|
|
638
616
|
interface BaseContainerConfig {
|
|
639
|
-
/**
|
|
640
|
-
* Discriminates this config as a Container config.
|
|
641
|
-
*
|
|
642
|
-
* Injected automatically by `defineContainer`; only needs to be written by
|
|
643
|
-
* hand when authoring a raw config object without the helper.
|
|
644
|
-
*/
|
|
645
|
-
type: "container";
|
|
646
617
|
/**
|
|
647
618
|
* Name of the application.
|
|
648
619
|
*
|
|
@@ -775,24 +746,17 @@ interface DurableObjectContainerConfig extends BaseContainerConfig {
|
|
|
775
746
|
}
|
|
776
747
|
/**
|
|
777
748
|
* Container application configuration. This is the input shape passed to
|
|
778
|
-
* `defineContainer` and
|
|
749
|
+
* `defineContainer` and parsed at runtime by `InputContainerSchema`.
|
|
779
750
|
*/
|
|
780
751
|
type ContainerConfig = DurableObjectContainerConfig | StandardContainerConfig;
|
|
781
752
|
/**
|
|
782
753
|
* Worker configuration. This is the input shape passed to
|
|
783
754
|
* [`defineWorker`](https://developers.cloudflare.com/workers/wrangler/configuration/).
|
|
784
755
|
*
|
|
785
|
-
* Fields are
|
|
756
|
+
* Fields are parsed and normalised at runtime by `InputWorkerSchema` before
|
|
786
757
|
* being passed to downstream tooling.
|
|
787
758
|
*/
|
|
788
759
|
interface WorkerConfig {
|
|
789
|
-
/**
|
|
790
|
-
* Discriminates this config as a Worker config.
|
|
791
|
-
*
|
|
792
|
-
* Injected automatically by `defineWorker`; only needs to be written by
|
|
793
|
-
* hand when authoring a raw config object without the helper.
|
|
794
|
-
*/
|
|
795
|
-
type: "worker";
|
|
796
760
|
/**
|
|
797
761
|
* The name of your Worker.
|
|
798
762
|
*/
|
|
@@ -821,8 +785,10 @@ interface WorkerConfig {
|
|
|
821
785
|
*
|
|
822
786
|
* @example
|
|
823
787
|
* ```ts
|
|
788
|
+
* import { defineConfig, defineWorker } from "@cloudflare/config";
|
|
824
789
|
* import * as entrypoint from "./src" with { type: "cf-worker" };
|
|
825
|
-
*
|
|
790
|
+
* const worker = defineWorker({ entrypoint });
|
|
791
|
+
* export default defineConfig({ worker });
|
|
826
792
|
* ```
|
|
827
793
|
*/
|
|
828
794
|
entrypoint?: string | WorkerModule;
|
|
@@ -1048,52 +1014,81 @@ interface WorkerConfig {
|
|
|
1048
1014
|
*/
|
|
1049
1015
|
exports?: Record<string, Export>;
|
|
1050
1016
|
}
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
interface SettingsConfig {
|
|
1057
|
-
/**
|
|
1058
|
-
* Discriminates this config as a settings config.
|
|
1059
|
-
*
|
|
1060
|
-
* Injected automatically by `defineSettings`; only needs to be written by
|
|
1061
|
-
* hand when authoring a raw config object without the helper.
|
|
1062
|
-
*/
|
|
1063
|
-
type: "settings";
|
|
1064
|
-
/**
|
|
1065
|
-
* This is the ID of the account associated with your zone.
|
|
1066
|
-
* You might have more than one account, so make sure to use
|
|
1067
|
-
* the ID of the account associated with the zone/route you
|
|
1068
|
-
* provide, if you provide one. It can also be specified through
|
|
1069
|
-
* the CLOUDFLARE_ACCOUNT_ID environment variable.
|
|
1070
|
-
*/
|
|
1071
|
-
accountId?: string;
|
|
1017
|
+
//#endregion
|
|
1018
|
+
//#region src/definition.d.ts
|
|
1019
|
+
interface ConfigContext {
|
|
1020
|
+
/** Whether the config is being evaluated for a Preview build. */
|
|
1021
|
+
isPreview: boolean;
|
|
1072
1022
|
/**
|
|
1073
|
-
*
|
|
1074
|
-
*
|
|
1075
|
-
*
|
|
1076
|
-
*
|
|
1023
|
+
* The mode the config is being evaluated in.
|
|
1024
|
+
* Set via the `--mode` CLI flag.
|
|
1025
|
+
* 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)).
|
|
1026
|
+
* In Wrangler the mode defaults to `undefined`.
|
|
1077
1027
|
*/
|
|
1078
|
-
|
|
1028
|
+
mode: string | undefined;
|
|
1079
1029
|
}
|
|
1030
|
+
/**
|
|
1031
|
+
* A configuration value, promise, or factory. Factories can be passed directly
|
|
1032
|
+
* for automatic resolution with the current context or called explicitly with
|
|
1033
|
+
* another context before they are used.
|
|
1034
|
+
*/
|
|
1035
|
+
type ConfigInput<T$1> = T$1 | Promise<T$1> | ((ctx: ConfigContext) => T$1 | Promise<T$1>);
|
|
1036
|
+
type ContainerDefinition<T$1 extends ContainerConfig = ContainerConfig> = ConfigInput<T$1>;
|
|
1037
|
+
type WorkerDefinition<T$1 extends WorkerConfig = WorkerConfig> = ConfigInput<T$1>;
|
|
1038
|
+
/** A Worker name, value, promise, or context-aware factory. */
|
|
1039
|
+
type WorkerReference = string | WorkerDefinition;
|
|
1040
|
+
/**
|
|
1041
|
+
* Used to define the default export in `cloudflare.config.ts`.
|
|
1042
|
+
*
|
|
1043
|
+
* @example
|
|
1044
|
+
* ```typescript
|
|
1045
|
+
* import { defineConfig } from "@cloudflare/config";
|
|
1046
|
+
*
|
|
1047
|
+
* export default defineConfig({
|
|
1048
|
+
* worker: {
|
|
1049
|
+
* name: "my-worker",
|
|
1050
|
+
* compatibilityDate: "2026-09-17",
|
|
1051
|
+
* },
|
|
1052
|
+
* });
|
|
1053
|
+
* ```
|
|
1054
|
+
*/
|
|
1055
|
+
declare const defineConfig: <const TInput extends ConfigInput<CloudflareConfig>>(config: TInput) => TInput;
|
|
1056
|
+
/**
|
|
1057
|
+
* Define a Container.
|
|
1058
|
+
*
|
|
1059
|
+
* @example
|
|
1060
|
+
* ```typescript
|
|
1061
|
+
* import { defineContainer } from "@cloudflare/config";
|
|
1062
|
+
*
|
|
1063
|
+
* const container = defineContainer({
|
|
1064
|
+
* name: "my-container",
|
|
1065
|
+
* image: { dockerfile: "./Dockerfile" },
|
|
1066
|
+
* });
|
|
1067
|
+
* ```
|
|
1068
|
+
*/
|
|
1069
|
+
declare const defineContainer: <const TInput extends ConfigInput<ContainerConfig>>(config: TInput) => TInput;
|
|
1070
|
+
/**
|
|
1071
|
+
* Define a Worker.
|
|
1072
|
+
*
|
|
1073
|
+
* @example
|
|
1074
|
+
* ```typescript
|
|
1075
|
+
* import { defineWorker } from "@cloudflare/config";
|
|
1076
|
+
*
|
|
1077
|
+
* const worker = defineWorker({
|
|
1078
|
+
* name: "my-worker",
|
|
1079
|
+
* compatibilityDate: "2026-09-17",
|
|
1080
|
+
* });
|
|
1081
|
+
* ```
|
|
1082
|
+
*/
|
|
1083
|
+
declare const defineWorker: <const TInput extends ConfigInput<WorkerConfig>>(config: TInput) => TInput;
|
|
1080
1084
|
//#endregion
|
|
1081
|
-
//#region src/
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
declare const defineWorker: <const TInput extends ConfigInput<WorkerConfigInput>>(config: TInput) => TInput extends ((ctx: ConfigContext) => infer TResult) ? (ctx: ConfigContext) => TResult extends Promise<infer TConfig extends {
|
|
1089
|
-
[x: string]: unknown;
|
|
1090
|
-
}> ? Promise<ConfigWithType<TConfig, "worker">> : TResult extends {
|
|
1091
|
-
[x: string]: unknown;
|
|
1092
|
-
} ? ConfigWithType<TResult, "worker"> : never : TInput extends Promise<infer TConfig extends {
|
|
1093
|
-
[x: string]: unknown;
|
|
1094
|
-
}> ? Promise<ConfigWithType<TConfig, "worker">> : TInput extends {
|
|
1095
|
-
[x: string]: unknown;
|
|
1096
|
-
} ? ConfigWithType<TInput, "worker"> : never;
|
|
1085
|
+
//#region src/utils.d.ts
|
|
1086
|
+
/**
|
|
1087
|
+
* Represents any valid JSON value.
|
|
1088
|
+
*/
|
|
1089
|
+
type Json = string | number | boolean | null | Json[] | {
|
|
1090
|
+
[key: string]: Json;
|
|
1091
|
+
};
|
|
1097
1092
|
//#endregion
|
|
1098
1093
|
//#region src/bindings.d.ts
|
|
1099
1094
|
/** Options that control a binding during local development. */
|
|
@@ -1243,7 +1238,6 @@ interface DispatchNamespaceBindingOptions {
|
|
|
1243
1238
|
interface DispatchNamespaceBinding extends DispatchNamespaceBindingOptions {
|
|
1244
1239
|
type: "dispatch-namespace";
|
|
1245
1240
|
}
|
|
1246
|
-
type WorkerReference = string | WorkerConfigExport;
|
|
1247
1241
|
type ReferencedWorkerConfig<TWorker$1 extends WorkerReference> = TWorker$1 extends string ? never : UnwrapConfig<TWorker$1>;
|
|
1248
1242
|
type DurableObjectExportName<TWorker$1 extends WorkerReference> = TWorker$1 extends string ? string : InferDurableNamespaces<ReferencedWorkerConfig<TWorker$1>>;
|
|
1249
1243
|
type WorkerEntrypointExportName<TWorker$1 extends WorkerReference> = TWorker$1 extends string ? string : InferWorkerEntrypointExports<ReferencedWorkerConfig<TWorker$1>>;
|
|
@@ -1781,25 +1775,4 @@ interface Bindings {
|
|
|
1781
1775
|
}
|
|
1782
1776
|
declare const bindings: Bindings;
|
|
1783
1777
|
//#endregion
|
|
1784
|
-
|
|
1785
|
-
type SettingsConfigExport<T$1 extends SettingsConfig = SettingsConfig> = ConfigInput<T$1>;
|
|
1786
|
-
/**
|
|
1787
|
-
* Authored settings config shape — {@link SettingsConfig} without the `type`
|
|
1788
|
-
* discriminant, which `defineSettings` injects.
|
|
1789
|
-
*/
|
|
1790
|
-
type SettingsConfigInput = Omit<SettingsConfig, "type">;
|
|
1791
|
-
/**
|
|
1792
|
-
* Declare shared settings.
|
|
1793
|
-
* Authored as a named `settings` export.
|
|
1794
|
-
*/
|
|
1795
|
-
declare const defineSettings: <const TInput extends ConfigInput<SettingsConfigInput>>(config: TInput) => TInput extends ((ctx: ConfigContext) => infer TResult) ? (ctx: ConfigContext) => TResult extends Promise<infer TConfig extends {
|
|
1796
|
-
[x: string]: unknown;
|
|
1797
|
-
}> ? Promise<ConfigWithType<TConfig, "settings">> : TResult extends {
|
|
1798
|
-
[x: string]: unknown;
|
|
1799
|
-
} ? ConfigWithType<TResult, "settings"> : never : TInput extends Promise<infer TConfig extends {
|
|
1800
|
-
[x: string]: unknown;
|
|
1801
|
-
}> ? Promise<ConfigWithType<TConfig, "settings">> : TInput extends {
|
|
1802
|
-
[x: string]: unknown;
|
|
1803
|
-
} ? ConfigWithType<TInput, "settings"> : never;
|
|
1804
|
-
//#endregion
|
|
1805
|
-
export { WorkerConfig as $, SecretsStoreSecretBinding as A, VersionMetadataBinding as B, MediaBinding$1 as C, UnwrapConfig as Ct, R2Binding as D, QueueBinding as E, TypedKvBinding as F, WorkerReference as G, VpcServiceBinding as H, TypedPipelineBinding as I, WorkerConfigExport as J, WorkflowBinding as K, TypedQueueBinding as L, StreamBinding$1 as M, TextBinding as N, RateLimitBinding as O, TypedAiBinding as P, SettingsConfig as Q, UnsafeBinding as R, LogfwdrBinding as S, InferMainModule as St, PipelineBinding as T, WorkerBinding as U, VpcNetworkBinding as V, WorkerLoaderBinding as W, defineWorker as X, WorkerConfigInput as Y, ContainerConfig as Z, FlagshipBinding as _, ContainerConfigInput as _t, AiBinding as a, Triggers as at, JsonBinding as b, InferDurableNamespaces as bt, AnalyticsEngineDatasetBinding as c, DurableObjectDeletedExport as ct, BindingDevOptions as d, DurableObjectTransferredExport as dt, ConnectTrigger as et, Bindings as f, Exports as ft, DurableObjectBinding as g, ContainerConfigExport as gt, DispatchNamespaceBinding as h, exports as ht, AgentMemoryBinding as i, ScheduledTrigger as it, SendEmailBinding as j, SecretBinding as k, ArtifactsBinding as l, DurableObjectExpectingTransferExport as lt, D1Binding as m, WorkerEntrypointExportOptions as mt, SettingsConfigInput as n, FetchTrigger as nt, AiSearchBinding as o, triggers as ot, BrowserBinding as p, WorkerEntrypointExport as pt, bindings as q, defineSettings as r, QueueConsumerTrigger as rt, AiSearchNamespaceBinding as s, DurableObjectCreatedExport as st, SettingsConfigExport as t, EmailTrigger as tt, AssetsBinding as u, DurableObjectRenamedExport as ut, HyperdriveBinding as v, defineContainer as vt, MtlsCertificateBinding as w, KvBinding as x, InferEnv as xt, ImagesBinding$1 as y, ConfigContext as yt, VectorizeBinding as z };
|
|
1778
|
+
export { Settings as $, TextBinding as A, WorkerBinding as B, QueueBinding as C, SecretsStoreSecretBinding as D, SecretBinding as E, UnsafeBinding as F, ContainerDefinition as G, WorkflowBinding as H, VectorizeBinding as I, defineConfig as J, WorkerDefinition as K, VersionMetadataBinding as L, TypedKvBinding as M, TypedPipelineBinding as N, SendEmailBinding as O, TypedQueueBinding as P, ContainerConfig as Q, VpcNetworkBinding as R, PipelineBinding as S, RateLimitBinding as T, bindings as U, WorkerLoaderBinding as V, ConfigContext as W, defineWorker as X, defineContainer as Y, CloudflareConfig as Z, JsonBinding as _, Exports as _t, AnalyticsEngineDatasetBinding as a, ScheduledTrigger as at, MediaBinding$1 as b, exports as bt, BindingDevOptions as c, InferDurableNamespaces as ct, D1Binding as d, UnwrapConfig as dt, WorkerConfig as et, DispatchNamespaceBinding as f, DurableObjectCreatedExport as ft, ImagesBinding$1 as g, DurableObjectTransferredExport as gt, HyperdriveBinding as h, DurableObjectRenamedExport as ht, AiSearchNamespaceBinding as i, QueueConsumerTrigger as it, TypedAiBinding as j, StreamBinding$1 as k, Bindings as l, InferEnv as lt, FlagshipBinding as m, DurableObjectExpectingTransferExport as mt, AiBinding as n, EmailTrigger as nt, ArtifactsBinding as o, Triggers as ot, DurableObjectBinding as p, DurableObjectDeletedExport as pt, WorkerReference as q, AiSearchBinding as r, FetchTrigger as rt, AssetsBinding as s, triggers as st, AgentMemoryBinding as t, ConnectTrigger as tt, BrowserBinding as u, InferMainModule as ut, KvBinding as v, WorkerEntrypointExport as vt, R2Binding as w, MtlsCertificateBinding as x, LogfwdrBinding as y, WorkerEntrypointExportOptions as yt, VpcServiceBinding as z };
|