@cloudflare/config 0.9.0 → 0.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -214,55 +214,31 @@ const exports = {
214
214
 
215
215
  //#endregion
216
216
  //#region src/definition.ts
217
- const DEFINITION = Symbol.for("@cloudflare/config:definition");
218
- /**
219
- * Unwrap an authored config from its value / promise / function shape, awaiting
220
- * the result. A function config is invoked with {@link ConfigContext}.
221
- */
222
- async function unwrap(config, ctx) {
223
- return typeof config === "function" ? await config(ctx) : await config;
224
- }
225
- /**
226
- * Resolve any `cloudflare.config.ts` export to its plain config value.
227
- *
228
- * A `define*` helper stores its authored config plus `type` under the
229
- * {@link DEFINITION} symbol; here we unwrap the config and stamp `type` back on.
230
- * Every other export — a raw object/promise/function — is unwrapped as-is and
231
- * already carries its own `type`. Discrimination happens afterwards via `type`.
232
- */
233
- async function resolveExportDefinition(def, ctx) {
234
- if (typeof def === "object" && def !== null && DEFINITION in def) {
235
- const { config, type } = def[DEFINITION];
217
+ /** Add a config type while preserving its value, promise, or function shape. */
218
+ function addConfigType(config, type) {
219
+ function addType(value) {
236
220
  return {
237
- ...await unwrap(config, ctx),
221
+ ...value,
238
222
  type
239
223
  };
240
224
  }
241
- return await unwrap(def, ctx);
225
+ if (typeof config === "function") return (ctx) => {
226
+ const result = config(ctx);
227
+ return result instanceof Promise ? result.then(addType) : addType(result);
228
+ };
229
+ return config instanceof Promise ? config.then(addType) : addType(config);
230
+ }
231
+ /** Create a type-safe config helper for a particular export type. */
232
+ function createConfigDefiner(type) {
233
+ function define(config) {
234
+ return addConfigType(config, type);
235
+ }
236
+ return define;
242
237
  }
243
238
 
244
239
  //#endregion
245
240
  //#region src/worker-definition.ts
246
- function defineWorker(config) {
247
- return {
248
- [DEFINITION]: {
249
- config,
250
- type: "worker"
251
- },
252
- durableObject(options) {
253
- return {
254
- type: "durable-object",
255
- ...options
256
- };
257
- },
258
- worker(options) {
259
- return {
260
- type: "worker",
261
- ...options
262
- };
263
- }
264
- };
265
- }
241
+ const defineWorker = createConfigDefiner("worker");
266
242
 
267
243
  //#endregion
268
244
  //#region src/settings-definition.ts
@@ -270,12 +246,7 @@ function defineWorker(config) {
270
246
  * Declare shared settings.
271
247
  * Authored as a named `settings` export.
272
248
  */
273
- function defineSettings(config) {
274
- return { [DEFINITION]: {
275
- config,
276
- type: "settings"
277
- } };
278
- }
249
+ const defineSettings = createConfigDefiner("settings");
279
250
 
280
251
  //#endregion
281
- export { triggers as a, exports as i, defineWorker as n, bindings as o, resolveExportDefinition as r, defineSettings as t };
252
+ export { bindings as a, triggers as i, defineWorker as n, exports as r, defineSettings as t };
package/dist/public.d.mts CHANGED
@@ -1,2 +1,2 @@
1
- import { $ as PipelineBinding, A as Triggers, B as Bindings, C as WorkerEntrypointExportOptions, Ct as WorkflowBinding, D as FetchTrigger, E as EmailTrigger, F as AiSearchNamespaceBinding, G as FlagshipBinding, H as D1Binding, I as AnalyticsEngineDatasetBinding, J as JsonBinding, K as HyperdriveBinding, L as ArtifactsBinding, M as AgentMemoryBinding, N as AiBinding, O as QueueConsumerTrigger, P as AiSearchBinding, Q as MtlsCertificateBinding, R as AssetsBinding, S as WorkerEntrypointExport, St as WorkerLoaderBinding, T as ConnectTrigger, U as DispatchNamespaceBinding, V as BrowserBinding, W as DurableObjectBinding, X as LogfwdrBinding, Y as KvBinding, Z as MediaBinding, _ as DurableObjectDeletedExport, _t as VersionMetadataBinding, a as InferEnv, at as SendEmailBinding, b as DurableObjectTransferredExport, bt as WebSearchBinding, c as TypedWorkerDefinition, ct as TypedAiBinding, d as defineWorker, dt as TypedPipelineBinding, et as QueueBinding, f as SettingsConfig, ft as TypedQueueBinding, g as DurableObjectCreatedExport, gt as VectorizeBinding, ht as UnsafeBinding, i as InferDurableNamespaces, it as SecretsStoreSecretBinding, j as triggers, k as ScheduledTrigger, l as WorkerConfigExport, lt as TypedDurableObjectBinding, m as ConfigContext, mt as TypedWorkflowBinding, n as SettingsDefinition, nt as RateLimitBinding, o as InferMainModule, ot as StreamBinding, p as WorkerConfig, pt as TypedWorkerBinding, q as ImagesBinding, r as defineSettings, rt as SecretBinding, s as UnwrapConfig, st as TextBinding, t as SettingsConfigInput, tt as R2Binding, u as WorkerConfigInput, ut as TypedKvBinding, v as DurableObjectExpectingTransferExport, vt as VpcNetworkBinding, w as exports, wt as bindings, x as Exports, xt as WorkerBinding, y as DurableObjectRenamedExport, yt as VpcServiceBinding, z as BindingDevOptions } from "./public-CN_InYwn.mjs";
2
- export { AgentMemoryBinding, AiBinding, AiSearchBinding, AiSearchNamespaceBinding, AnalyticsEngineDatasetBinding, ArtifactsBinding, AssetsBinding, BindingDevOptions, Bindings, BrowserBinding, ConfigContext, ConnectTrigger, D1Binding, DispatchNamespaceBinding, DurableObjectBinding, DurableObjectCreatedExport, DurableObjectDeletedExport, DurableObjectExpectingTransferExport, DurableObjectRenamedExport, DurableObjectTransferredExport, EmailTrigger, Exports, FetchTrigger, FlagshipBinding, HyperdriveBinding, ImagesBinding, InferDurableNamespaces, InferEnv, InferMainModule, JsonBinding, KvBinding, LogfwdrBinding, MediaBinding, MtlsCertificateBinding, PipelineBinding, QueueBinding, QueueConsumerTrigger, R2Binding, RateLimitBinding, ScheduledTrigger, SecretBinding, SecretsStoreSecretBinding, SendEmailBinding, SettingsConfig, SettingsConfigInput, SettingsDefinition, StreamBinding, TextBinding, Triggers, TypedAiBinding, TypedDurableObjectBinding, TypedKvBinding, TypedPipelineBinding, TypedQueueBinding, TypedWorkerBinding, TypedWorkerDefinition, TypedWorkflowBinding, UnsafeBinding, UnwrapConfig, VectorizeBinding, VersionMetadataBinding, VpcNetworkBinding, VpcServiceBinding, WebSearchBinding, WorkerBinding, WorkerConfig, WorkerConfigExport, WorkerConfigInput, WorkerEntrypointExport, WorkerEntrypointExportOptions, WorkerLoaderBinding, WorkflowBinding, bindings, defineSettings, defineWorker, exports, triggers };
1
+ import { $ as WorkerConfig, A as SecretsStoreSecretBinding, B as VersionMetadataBinding, C as MediaBinding, D as R2Binding, E as QueueBinding, F as TypedKvBinding, G as WorkerLoaderBinding, H as VpcServiceBinding, I as TypedPipelineBinding, J as bindings, K as WorkerReference, L as TypedQueueBinding, M as StreamBinding, N as TextBinding, O as RateLimitBinding, P as TypedAiBinding, Q as SettingsConfig, R as UnsafeBinding, S as LogfwdrBinding, T as PipelineBinding, U as WebSearchBinding, V as VpcNetworkBinding, W as WorkerBinding, X as WorkerConfigInput, Y as WorkerConfigExport, Z as defineWorker, _ as FlagshipBinding, _t as InferDurableNamespaces, a as AiBinding, at as Triggers, b as JsonBinding, bt as UnwrapConfig, c as AnalyticsEngineDatasetBinding, ct as DurableObjectDeletedExport, d as BindingDevOptions, dt as DurableObjectTransferredExport, et as ConnectTrigger, f as Bindings, ft as Exports, g as DurableObjectBinding, gt as ConfigContext, h as DispatchNamespaceBinding, ht as exports, i as AgentMemoryBinding, it as ScheduledTrigger, j as SendEmailBinding, k as SecretBinding, l as ArtifactsBinding, lt as DurableObjectExpectingTransferExport, m as D1Binding, mt as WorkerEntrypointExportOptions, n as SettingsConfigInput, nt as FetchTrigger, o as AiSearchBinding, ot as triggers, p as BrowserBinding, pt as WorkerEntrypointExport, q as WorkflowBinding, r as defineSettings, rt as QueueConsumerTrigger, s as AiSearchNamespaceBinding, st as DurableObjectCreatedExport, t as SettingsConfigExport, tt as EmailTrigger, u as AssetsBinding, ut as DurableObjectRenamedExport, v as HyperdriveBinding, vt as InferEnv, w as MtlsCertificateBinding, x as KvBinding, y as ImagesBinding, yt as InferMainModule, z as VectorizeBinding } from "./public-E85Be_2R.mjs";
2
+ export { AgentMemoryBinding, AiBinding, AiSearchBinding, AiSearchNamespaceBinding, AnalyticsEngineDatasetBinding, ArtifactsBinding, AssetsBinding, BindingDevOptions, Bindings, BrowserBinding, ConfigContext, ConnectTrigger, D1Binding, DispatchNamespaceBinding, DurableObjectBinding, DurableObjectCreatedExport, DurableObjectDeletedExport, DurableObjectExpectingTransferExport, DurableObjectRenamedExport, DurableObjectTransferredExport, EmailTrigger, Exports, FetchTrigger, FlagshipBinding, HyperdriveBinding, ImagesBinding, InferDurableNamespaces, InferEnv, InferMainModule, JsonBinding, KvBinding, LogfwdrBinding, MediaBinding, MtlsCertificateBinding, PipelineBinding, QueueBinding, QueueConsumerTrigger, R2Binding, RateLimitBinding, ScheduledTrigger, SecretBinding, SecretsStoreSecretBinding, SendEmailBinding, SettingsConfig, SettingsConfigExport, SettingsConfigInput, StreamBinding, TextBinding, Triggers, TypedAiBinding, TypedKvBinding, TypedPipelineBinding, TypedQueueBinding, UnsafeBinding, UnwrapConfig, VectorizeBinding, VersionMetadataBinding, VpcNetworkBinding, VpcServiceBinding, WebSearchBinding, WorkerBinding, WorkerConfig, WorkerConfigExport, WorkerConfigInput, WorkerEntrypointExport, WorkerEntrypointExportOptions, WorkerLoaderBinding, WorkerReference, WorkflowBinding, bindings, defineSettings, defineWorker, exports, triggers };
package/dist/public.mjs CHANGED
@@ -1,3 +1,3 @@
1
- import { a as triggers, i as exports, n as defineWorker, o as bindings, t as defineSettings } from "./public-BwQqexwo.mjs";
1
+ import { a as bindings, i as triggers, n as defineWorker, r as exports, t as defineSettings } from "./public-bN7EDGtD.mjs";
2
2
 
3
3
  export { bindings, defineSettings, defineWorker, exports, triggers };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cloudflare/config",
3
- "version": "0.9.0",
3
+ "version": "0.11.0",
4
4
  "description": "Definitions and utilities for configuring Cloudflare Workers and related products. This is not yet stable enough for external use — APIs may change without notice.",
5
5
  "homepage": "https://github.com/cloudflare/workers-sdk/tree/main/packages/config#readme",
6
6
  "bugs": {
@@ -31,13 +31,13 @@
31
31
  "zod": "4.4.3"
32
32
  },
33
33
  "devDependencies": {
34
- "@cloudflare/workers-types": "^5.20260828.1",
34
+ "@cloudflare/workers-types": "^5.20260908.1",
35
35
  "ts-dedent": "^2.2.0",
36
36
  "tsdown": "0.16.3",
37
37
  "typescript": "5.8.3",
38
38
  "vitest": "4.1.0",
39
39
  "@cloudflare/workers-tsconfig": "0.0.0",
40
- "@cloudflare/workers-utils": "0.34.0"
40
+ "@cloudflare/workers-utils": "0.37.0"
41
41
  },
42
42
  "workers-sdk": {
43
43
  "prerelease": true