@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
|
@@ -133,17 +133,21 @@ const bindings = {
|
|
|
133
133
|
*
|
|
134
134
|
* @example
|
|
135
135
|
* ```typescript
|
|
136
|
-
* import {
|
|
136
|
+
* import { defineConfig, triggers } from "@cloudflare/config";
|
|
137
137
|
*
|
|
138
|
-
* export default
|
|
139
|
-
*
|
|
140
|
-
*
|
|
141
|
-
*
|
|
142
|
-
* triggers
|
|
143
|
-
*
|
|
144
|
-
*
|
|
145
|
-
*
|
|
146
|
-
*
|
|
138
|
+
* export default defineConfig({
|
|
139
|
+
* worker: {
|
|
140
|
+
* name: "my-worker",
|
|
141
|
+
* compatibilityDate: "2026-09-17",
|
|
142
|
+
* triggers: [
|
|
143
|
+
* triggers.fetch({ pattern: "example.com/*", zone: "example.com" }),
|
|
144
|
+
* triggers.queue({ name: "my-queue" }),
|
|
145
|
+
* triggers.scheduled({ schedule: "0 * * * *" }),
|
|
146
|
+
* triggers.scheduled({ schedule: "30 0 * * *" }),
|
|
147
|
+
* triggers.email({ addresses: ["support@example.com"] }),
|
|
148
|
+
* triggers.connect({ protocol: "tcp", port: 5432 }),
|
|
149
|
+
* ],
|
|
150
|
+
* },
|
|
147
151
|
* });
|
|
148
152
|
* ```
|
|
149
153
|
*/
|
|
@@ -189,14 +193,14 @@ function worker(options = {}) {
|
|
|
189
193
|
*
|
|
190
194
|
* @example
|
|
191
195
|
* ```typescript
|
|
192
|
-
* import { defineContainer, defineWorker, exports } from "@cloudflare/config";
|
|
196
|
+
* import { defineConfig, defineContainer, defineWorker, exports } from "@cloudflare/config";
|
|
193
197
|
*
|
|
194
198
|
* const myContainer = defineContainer({
|
|
195
199
|
* name: "my-container",
|
|
196
200
|
* image: { dockerfile: "./Dockerfile" },
|
|
197
201
|
* });
|
|
198
202
|
*
|
|
199
|
-
*
|
|
203
|
+
* const worker = defineWorker({
|
|
200
204
|
* exports: {
|
|
201
205
|
* MyDurableObject: exports.durableObject({ storage: "sqlite" }),
|
|
202
206
|
* MyContainerDO: exports.durableObject({ storage: "sqlite", container: myContainer }),
|
|
@@ -206,6 +210,8 @@ function worker(options = {}) {
|
|
|
206
210
|
* Incoming: exports.durableObject({ state: "expecting-transfer", storage: "sqlite", transferFrom: "source-worker" }),
|
|
207
211
|
* },
|
|
208
212
|
* });
|
|
213
|
+
*
|
|
214
|
+
* export default defineConfig({ worker, containers: [myContainer] });
|
|
209
215
|
* ```
|
|
210
216
|
*/
|
|
211
217
|
const exports = {
|
|
@@ -215,44 +221,56 @@ const exports = {
|
|
|
215
221
|
|
|
216
222
|
//#endregion
|
|
217
223
|
//#region src/definition.ts
|
|
218
|
-
/**
|
|
219
|
-
function
|
|
220
|
-
function
|
|
221
|
-
return
|
|
222
|
-
...value,
|
|
223
|
-
type
|
|
224
|
-
};
|
|
225
|
-
}
|
|
226
|
-
if (typeof config === "function") return (ctx) => {
|
|
227
|
-
const result = config(ctx);
|
|
228
|
-
return result instanceof Promise ? result.then(addType) : addType(result);
|
|
224
|
+
/** Create a type-safe identity helper for a configuration value or factory. */
|
|
225
|
+
function createConfigDefiner() {
|
|
226
|
+
return function define(config) {
|
|
227
|
+
return config;
|
|
229
228
|
};
|
|
230
|
-
return config instanceof Promise ? config.then(addType) : addType(config);
|
|
231
|
-
}
|
|
232
|
-
/** Create a type-safe config helper for a particular export type. */
|
|
233
|
-
function createConfigDefiner(type) {
|
|
234
|
-
function define(config) {
|
|
235
|
-
return addConfigType(config, type);
|
|
236
|
-
}
|
|
237
|
-
return define;
|
|
238
229
|
}
|
|
239
|
-
|
|
240
|
-
//#endregion
|
|
241
|
-
//#region src/container-definition.ts
|
|
242
|
-
/** Declare a Container application. */
|
|
243
|
-
const defineContainer = createConfigDefiner("container");
|
|
244
|
-
|
|
245
|
-
//#endregion
|
|
246
|
-
//#region src/worker-definition.ts
|
|
247
|
-
const defineWorker = createConfigDefiner("worker");
|
|
248
|
-
|
|
249
|
-
//#endregion
|
|
250
|
-
//#region src/settings-definition.ts
|
|
251
230
|
/**
|
|
252
|
-
*
|
|
253
|
-
*
|
|
231
|
+
* Used to define the default export in `cloudflare.config.ts`.
|
|
232
|
+
*
|
|
233
|
+
* @example
|
|
234
|
+
* ```typescript
|
|
235
|
+
* import { defineConfig } from "@cloudflare/config";
|
|
236
|
+
*
|
|
237
|
+
* export default defineConfig({
|
|
238
|
+
* worker: {
|
|
239
|
+
* name: "my-worker",
|
|
240
|
+
* compatibilityDate: "2026-09-17",
|
|
241
|
+
* },
|
|
242
|
+
* });
|
|
243
|
+
* ```
|
|
244
|
+
*/
|
|
245
|
+
const defineConfig = createConfigDefiner();
|
|
246
|
+
/**
|
|
247
|
+
* Define a Container.
|
|
248
|
+
*
|
|
249
|
+
* @example
|
|
250
|
+
* ```typescript
|
|
251
|
+
* import { defineContainer } from "@cloudflare/config";
|
|
252
|
+
*
|
|
253
|
+
* const container = defineContainer({
|
|
254
|
+
* name: "my-container",
|
|
255
|
+
* image: { dockerfile: "./Dockerfile" },
|
|
256
|
+
* });
|
|
257
|
+
* ```
|
|
258
|
+
*/
|
|
259
|
+
const defineContainer = createConfigDefiner();
|
|
260
|
+
/**
|
|
261
|
+
* Define a Worker.
|
|
262
|
+
*
|
|
263
|
+
* @example
|
|
264
|
+
* ```typescript
|
|
265
|
+
* import { defineWorker } from "@cloudflare/config";
|
|
266
|
+
*
|
|
267
|
+
* const worker = defineWorker({
|
|
268
|
+
* name: "my-worker",
|
|
269
|
+
* compatibilityDate: "2026-09-17",
|
|
270
|
+
* });
|
|
271
|
+
* ```
|
|
254
272
|
*/
|
|
255
|
-
const
|
|
273
|
+
const defineWorker = createConfigDefiner();
|
|
256
274
|
|
|
257
275
|
//#endregion
|
|
258
|
-
export { triggers as a, exports as i,
|
|
276
|
+
export { triggers as a, exports as i, defineContainer as n, bindings as o, defineWorker as r, defineConfig as t };
|