@cloudflare/config 0.11.0 → 0.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { $ as
|
|
1
|
+
import { $ as SettingsConfig, A as SecretsStoreSecretBinding, B as VersionMetadataBinding, C as MediaBinding, Ct as InferMainModule, 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 ContainerConfig, R as UnsafeBinding, S as LogfwdrBinding, St as InferEnv, 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 ContainerConfigExport, a as AiBinding, at as ScheduledTrigger, b as JsonBinding, bt as ConfigContext, c as AnalyticsEngineDatasetBinding, ct as DurableObjectCreatedExport, d as BindingDevOptions, dt as DurableObjectRenamedExport, et as WorkerConfig, f as Bindings, ft as DurableObjectTransferredExport, g as DurableObjectBinding, gt as exports, h as DispatchNamespaceBinding, ht as WorkerEntrypointExportOptions, i as AgentMemoryBinding, it as QueueConsumerTrigger, j as SendEmailBinding, k as SecretBinding, l as ArtifactsBinding, lt as DurableObjectDeletedExport, m as D1Binding, mt as WorkerEntrypointExport, n as SettingsConfigInput, nt as EmailTrigger, o as AiSearchBinding, ot as Triggers, p as BrowserBinding, pt as Exports, q as WorkflowBinding, r as defineSettings, rt as FetchTrigger, s as AiSearchNamespaceBinding, st as triggers, t as SettingsConfigExport, tt as ConnectTrigger, u as AssetsBinding, ut as DurableObjectExpectingTransferExport, v as HyperdriveBinding, vt as ContainerConfigInput, w as MtlsCertificateBinding, wt as UnwrapConfig, x as KvBinding, xt as InferDurableNamespaces, y as ImagesBinding, yt as defineContainer, z as VectorizeBinding } from "./public-CxIWEZqM.mjs";
|
|
2
2
|
import * as z from "zod";
|
|
3
3
|
import { RawConfig } from "@cloudflare/workers-utils";
|
|
4
4
|
|
|
@@ -321,6 +321,215 @@ declare const BindingSchema: z.ZodType<BindingOutput, BindingInput>;
|
|
|
321
321
|
declare function validateSingletonBindings(env: Record<string, {
|
|
322
322
|
type: string;
|
|
323
323
|
}>, ctx: z.RefinementCtx): void;
|
|
324
|
+
/**
|
|
325
|
+
* Input Container schema — validates user-authored `cloudflare.config.ts`
|
|
326
|
+
* Container exports. Dockerfiles are built by the consuming build tool.
|
|
327
|
+
*/
|
|
328
|
+
declare const InputContainerSchema: z.ZodUnion<readonly [z.ZodObject<{
|
|
329
|
+
type: z.ZodLiteral<"container">;
|
|
330
|
+
name: z.ZodString;
|
|
331
|
+
observability: z.ZodOptional<z.ZodUnion<readonly [z.ZodObject<{
|
|
332
|
+
enabled: z.ZodOptional<z.ZodBoolean>;
|
|
333
|
+
logs: z.ZodOptional<z.ZodObject<{
|
|
334
|
+
enabled: z.ZodOptional<z.ZodBoolean>;
|
|
335
|
+
}, z.core.$strict>>;
|
|
336
|
+
targetInstancePercentage: z.ZodOptional<z.ZodNumber>;
|
|
337
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
338
|
+
enabled: z.ZodOptional<z.ZodBoolean>;
|
|
339
|
+
logs: z.ZodOptional<z.ZodObject<{
|
|
340
|
+
enabled: z.ZodOptional<z.ZodBoolean>;
|
|
341
|
+
}, z.core.$strict>>;
|
|
342
|
+
targetInstanceCount: z.ZodOptional<z.ZodNumber>;
|
|
343
|
+
}, z.core.$strict>]>>;
|
|
344
|
+
unsafe: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
345
|
+
maxInstances: z.ZodDefault<z.ZodNumber>;
|
|
346
|
+
instanceType: z.ZodOptional<z.ZodUnion<readonly [z.ZodEnum<{
|
|
347
|
+
basic: "basic";
|
|
348
|
+
lite: "lite";
|
|
349
|
+
"standard-1": "standard-1";
|
|
350
|
+
"standard-2": "standard-2";
|
|
351
|
+
"standard-3": "standard-3";
|
|
352
|
+
"standard-4": "standard-4";
|
|
353
|
+
}>, z.ZodObject<{
|
|
354
|
+
vcpu: z.ZodOptional<z.ZodNumber>;
|
|
355
|
+
memoryMib: z.ZodOptional<z.ZodNumber>;
|
|
356
|
+
diskMb: z.ZodOptional<z.ZodNumber>;
|
|
357
|
+
}, z.core.$strict>]>>;
|
|
358
|
+
schedulingPolicy: z.ZodOptional<z.ZodEnum<{
|
|
359
|
+
default: "default";
|
|
360
|
+
regional: "regional";
|
|
361
|
+
}>>;
|
|
362
|
+
ssh: z.ZodOptional<z.ZodObject<{
|
|
363
|
+
enabled: z.ZodBoolean;
|
|
364
|
+
port: z.ZodOptional<z.ZodNumber>;
|
|
365
|
+
}, z.core.$strict>>;
|
|
366
|
+
authorizedKeys: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
367
|
+
name: z.ZodString;
|
|
368
|
+
publicKey: z.ZodString;
|
|
369
|
+
}, z.core.$strict>>>;
|
|
370
|
+
constraints: z.ZodOptional<z.ZodObject<{
|
|
371
|
+
regions: z.ZodOptional<z.ZodArray<z.ZodEnum<{
|
|
372
|
+
ENAM: "ENAM";
|
|
373
|
+
WNAM: "WNAM";
|
|
374
|
+
EEUR: "EEUR";
|
|
375
|
+
WEUR: "WEUR";
|
|
376
|
+
APAC: "APAC";
|
|
377
|
+
SAM: "SAM";
|
|
378
|
+
ME: "ME";
|
|
379
|
+
OC: "OC";
|
|
380
|
+
AFR: "AFR";
|
|
381
|
+
}>>>;
|
|
382
|
+
jurisdiction: z.ZodOptional<z.ZodEnum<{
|
|
383
|
+
eu: "eu";
|
|
384
|
+
fedramp: "fedramp";
|
|
385
|
+
}>>;
|
|
386
|
+
}, z.core.$strict>>;
|
|
387
|
+
rollout: z.ZodOptional<z.ZodObject<{
|
|
388
|
+
kind: z.ZodOptional<z.ZodEnum<{
|
|
389
|
+
none: "none";
|
|
390
|
+
"full-auto": "full-auto";
|
|
391
|
+
"full-manual": "full-manual";
|
|
392
|
+
}>>;
|
|
393
|
+
stepPercentage: z.ZodOptional<z.ZodUnion<readonly [z.ZodNumber, z.ZodArray<z.ZodNumber>]>>;
|
|
394
|
+
activeGracePeriod: z.ZodOptional<z.ZodNumber>;
|
|
395
|
+
}, z.core.$strict>>;
|
|
396
|
+
image: z.ZodUnion<readonly [z.ZodObject<{
|
|
397
|
+
dockerfile: z.ZodString;
|
|
398
|
+
buildContext: z.ZodOptional<z.ZodString>;
|
|
399
|
+
buildVars: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
400
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
401
|
+
reference: z.ZodString;
|
|
402
|
+
}, z.core.$strict>]>;
|
|
403
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
404
|
+
type: z.ZodLiteral<"container">;
|
|
405
|
+
name: z.ZodString;
|
|
406
|
+
observability: z.ZodOptional<z.ZodUnion<readonly [z.ZodObject<{
|
|
407
|
+
enabled: z.ZodOptional<z.ZodBoolean>;
|
|
408
|
+
logs: z.ZodOptional<z.ZodObject<{
|
|
409
|
+
enabled: z.ZodOptional<z.ZodBoolean>;
|
|
410
|
+
}, z.core.$strict>>;
|
|
411
|
+
targetInstancePercentage: z.ZodOptional<z.ZodNumber>;
|
|
412
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
413
|
+
enabled: z.ZodOptional<z.ZodBoolean>;
|
|
414
|
+
logs: z.ZodOptional<z.ZodObject<{
|
|
415
|
+
enabled: z.ZodOptional<z.ZodBoolean>;
|
|
416
|
+
}, z.core.$strict>>;
|
|
417
|
+
targetInstanceCount: z.ZodOptional<z.ZodNumber>;
|
|
418
|
+
}, z.core.$strict>]>>;
|
|
419
|
+
unsafe: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
420
|
+
schedulingPolicy: z.ZodLiteral<"durable-object">;
|
|
421
|
+
images: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodObject<{
|
|
422
|
+
dockerfile: z.ZodString;
|
|
423
|
+
buildContext: z.ZodOptional<z.ZodString>;
|
|
424
|
+
buildVars: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
425
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
426
|
+
reference: z.ZodString;
|
|
427
|
+
}, z.core.$strict>]>>>;
|
|
428
|
+
}, z.core.$strict>]>;
|
|
429
|
+
type ParsedInputContainerConfig = z.output<typeof InputContainerSchema>;
|
|
430
|
+
/**
|
|
431
|
+
* Output Container schema — validates Container configs in the Build Output
|
|
432
|
+
* Specification, after any Dockerfile has been built into a local or remote
|
|
433
|
+
* image reference.
|
|
434
|
+
*/
|
|
435
|
+
declare const OutputContainerSchema: z.ZodUnion<readonly [z.ZodObject<{
|
|
436
|
+
type: z.ZodLiteral<"container">;
|
|
437
|
+
name: z.ZodString;
|
|
438
|
+
observability: z.ZodOptional<z.ZodUnion<readonly [z.ZodObject<{
|
|
439
|
+
enabled: z.ZodOptional<z.ZodBoolean>;
|
|
440
|
+
logs: z.ZodOptional<z.ZodObject<{
|
|
441
|
+
enabled: z.ZodOptional<z.ZodBoolean>;
|
|
442
|
+
}, z.core.$strict>>;
|
|
443
|
+
targetInstancePercentage: z.ZodOptional<z.ZodNumber>;
|
|
444
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
445
|
+
enabled: z.ZodOptional<z.ZodBoolean>;
|
|
446
|
+
logs: z.ZodOptional<z.ZodObject<{
|
|
447
|
+
enabled: z.ZodOptional<z.ZodBoolean>;
|
|
448
|
+
}, z.core.$strict>>;
|
|
449
|
+
targetInstanceCount: z.ZodOptional<z.ZodNumber>;
|
|
450
|
+
}, z.core.$strict>]>>;
|
|
451
|
+
unsafe: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
452
|
+
maxInstances: z.ZodDefault<z.ZodNumber>;
|
|
453
|
+
instanceType: z.ZodOptional<z.ZodUnion<readonly [z.ZodEnum<{
|
|
454
|
+
basic: "basic";
|
|
455
|
+
lite: "lite";
|
|
456
|
+
"standard-1": "standard-1";
|
|
457
|
+
"standard-2": "standard-2";
|
|
458
|
+
"standard-3": "standard-3";
|
|
459
|
+
"standard-4": "standard-4";
|
|
460
|
+
}>, z.ZodObject<{
|
|
461
|
+
vcpu: z.ZodOptional<z.ZodNumber>;
|
|
462
|
+
memoryMib: z.ZodOptional<z.ZodNumber>;
|
|
463
|
+
diskMb: z.ZodOptional<z.ZodNumber>;
|
|
464
|
+
}, z.core.$strict>]>>;
|
|
465
|
+
schedulingPolicy: z.ZodOptional<z.ZodEnum<{
|
|
466
|
+
default: "default";
|
|
467
|
+
regional: "regional";
|
|
468
|
+
}>>;
|
|
469
|
+
ssh: z.ZodOptional<z.ZodObject<{
|
|
470
|
+
enabled: z.ZodBoolean;
|
|
471
|
+
port: z.ZodOptional<z.ZodNumber>;
|
|
472
|
+
}, z.core.$strict>>;
|
|
473
|
+
authorizedKeys: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
474
|
+
name: z.ZodString;
|
|
475
|
+
publicKey: z.ZodString;
|
|
476
|
+
}, z.core.$strict>>>;
|
|
477
|
+
constraints: z.ZodOptional<z.ZodObject<{
|
|
478
|
+
regions: z.ZodOptional<z.ZodArray<z.ZodEnum<{
|
|
479
|
+
ENAM: "ENAM";
|
|
480
|
+
WNAM: "WNAM";
|
|
481
|
+
EEUR: "EEUR";
|
|
482
|
+
WEUR: "WEUR";
|
|
483
|
+
APAC: "APAC";
|
|
484
|
+
SAM: "SAM";
|
|
485
|
+
ME: "ME";
|
|
486
|
+
OC: "OC";
|
|
487
|
+
AFR: "AFR";
|
|
488
|
+
}>>>;
|
|
489
|
+
jurisdiction: z.ZodOptional<z.ZodEnum<{
|
|
490
|
+
eu: "eu";
|
|
491
|
+
fedramp: "fedramp";
|
|
492
|
+
}>>;
|
|
493
|
+
}, z.core.$strict>>;
|
|
494
|
+
rollout: z.ZodOptional<z.ZodObject<{
|
|
495
|
+
kind: z.ZodOptional<z.ZodEnum<{
|
|
496
|
+
none: "none";
|
|
497
|
+
"full-auto": "full-auto";
|
|
498
|
+
"full-manual": "full-manual";
|
|
499
|
+
}>>;
|
|
500
|
+
stepPercentage: z.ZodOptional<z.ZodUnion<readonly [z.ZodNumber, z.ZodArray<z.ZodNumber>]>>;
|
|
501
|
+
activeGracePeriod: z.ZodOptional<z.ZodNumber>;
|
|
502
|
+
}, z.core.$strict>>;
|
|
503
|
+
image: z.ZodUnion<readonly [z.ZodObject<{
|
|
504
|
+
reference: z.ZodString;
|
|
505
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
506
|
+
localReference: z.ZodString;
|
|
507
|
+
}, z.core.$strict>]>;
|
|
508
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
509
|
+
type: z.ZodLiteral<"container">;
|
|
510
|
+
name: z.ZodString;
|
|
511
|
+
observability: z.ZodOptional<z.ZodUnion<readonly [z.ZodObject<{
|
|
512
|
+
enabled: z.ZodOptional<z.ZodBoolean>;
|
|
513
|
+
logs: z.ZodOptional<z.ZodObject<{
|
|
514
|
+
enabled: z.ZodOptional<z.ZodBoolean>;
|
|
515
|
+
}, z.core.$strict>>;
|
|
516
|
+
targetInstancePercentage: z.ZodOptional<z.ZodNumber>;
|
|
517
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
518
|
+
enabled: z.ZodOptional<z.ZodBoolean>;
|
|
519
|
+
logs: z.ZodOptional<z.ZodObject<{
|
|
520
|
+
enabled: z.ZodOptional<z.ZodBoolean>;
|
|
521
|
+
}, z.core.$strict>>;
|
|
522
|
+
targetInstanceCount: z.ZodOptional<z.ZodNumber>;
|
|
523
|
+
}, z.core.$strict>]>>;
|
|
524
|
+
unsafe: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
525
|
+
schedulingPolicy: z.ZodLiteral<"durable-object">;
|
|
526
|
+
images: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodObject<{
|
|
527
|
+
reference: z.ZodString;
|
|
528
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
529
|
+
localReference: z.ZodString;
|
|
530
|
+
}, z.core.$strict>]>>>;
|
|
531
|
+
}, z.core.$strict>]>;
|
|
532
|
+
type ParsedOutputContainerConfig = z.output<typeof OutputContainerSchema>;
|
|
324
533
|
declare const DurableObjectCreatedExportSchema: z.ZodObject<{
|
|
325
534
|
type: z.ZodLiteral<"durable-object">;
|
|
326
535
|
state: z.ZodOptional<z.ZodLiteral<"created">>;
|
|
@@ -815,15 +1024,18 @@ declare function generateTypes({
|
|
|
815
1024
|
/**
|
|
816
1025
|
* Convert a parsed `@cloudflare/config` config into a Wrangler `RawConfig`.
|
|
817
1026
|
*
|
|
818
|
-
* The caller is responsible for unwrapping any function/promise
|
|
819
|
-
* the
|
|
1027
|
+
* The caller is responsible for unwrapping any function/promise wrappers and
|
|
1028
|
+
* validating the configs against their corresponding input schemas before
|
|
1029
|
+
* passing them in.
|
|
820
1030
|
*
|
|
821
1031
|
* @param workerConfig The parsed (post-validation) Worker config.
|
|
822
1032
|
* @param settingsConfig The optional parsed settings config, whose fields
|
|
823
1033
|
* are merged onto the result.
|
|
1034
|
+
* @param containerExports The parsed Container exports to include in the
|
|
1035
|
+
* result.
|
|
824
1036
|
* @returns The corresponding Wrangler `RawConfig`.
|
|
825
1037
|
*/
|
|
826
|
-
declare function convertToWranglerConfig(workerConfig: ParsedInputWorkerConfig, settingsConfig?: ParsedInputSettingsConfig): RawConfig;
|
|
1038
|
+
declare function convertToWranglerConfig(workerConfig: ParsedInputWorkerConfig, settingsConfig?: ParsedInputSettingsConfig, containerExports?: ParsedInputContainerConfig[]): RawConfig;
|
|
827
1039
|
//#endregion
|
|
828
1040
|
//#region src/load.d.ts
|
|
829
1041
|
/**
|
|
@@ -888,8 +1100,9 @@ declare function registerConfigHooks(): () => void;
|
|
|
888
1100
|
//#endregion
|
|
889
1101
|
//#region src/config-loader.d.ts
|
|
890
1102
|
type ParsedConfigExports = {
|
|
1103
|
+
default?: ParsedInputWorkerConfig;
|
|
891
1104
|
settings?: ParsedInputSettingsConfig;
|
|
892
|
-
} & Record<string, ParsedInputWorkerConfig>;
|
|
1105
|
+
} & Record<string, ParsedInputContainerConfig | ParsedInputWorkerConfig>;
|
|
893
1106
|
type ConfigParseResult = z.ZodSafeParseSuccess<ParsedConfigExports> | z.ZodSafeParseError<unknown>;
|
|
894
1107
|
interface LoadAndValidateConfigResult {
|
|
895
1108
|
/**
|
|
@@ -903,9 +1116,10 @@ interface LoadAndValidateConfigResult {
|
|
|
903
1116
|
/**
|
|
904
1117
|
* Resolve and validate loaded `cloudflare.config.ts` exports.
|
|
905
1118
|
*
|
|
906
|
-
* Config inputs are resolved once by identity. Top-level Worker
|
|
907
|
-
* also parsed once by identity
|
|
908
|
-
* enough to replace
|
|
1119
|
+
* Config inputs are resolved once by identity. Top-level Worker and Container
|
|
1120
|
+
* exports are also parsed once by identity. References are resolved only far
|
|
1121
|
+
* enough to replace them with resource names, then Container links are
|
|
1122
|
+
* validated across the exported resources.
|
|
909
1123
|
*/
|
|
910
1124
|
declare function resolveAndValidateConfigExports(exports: Record<string, unknown>, ctx: ConfigContext): Promise<ConfigParseResult>;
|
|
911
1125
|
/**
|
|
@@ -915,4 +1129,4 @@ declare function loadAndValidateConfig(configPath: string, ctx: ConfigContext, o
|
|
|
915
1129
|
include?: string[];
|
|
916
1130
|
}): Promise<LoadAndValidateConfigResult>;
|
|
917
1131
|
//#endregion
|
|
918
|
-
export { AgentMemoryBinding, AiBinding, AiSearchBinding, AiSearchNamespaceBinding, AnalyticsEngineDatasetBinding, AnalyticsEngineDatasetBindingSchema, ArtifactsBinding, AssetsBinding, AssetsSchema, BindingDevOptions, BindingSchema, Bindings, BrowserBinding, BrowserBindingSchema, ConfigContext, type ConfigParseResult, ConnectTrigger, D1Binding, D1BindingSchema, DispatchNamespaceBinding, DurableObjectBinding, DurableObjectCreatedExport, DurableObjectCreatedExportSchema, DurableObjectDeletedExport, DurableObjectDeletedExportSchema, DurableObjectExpectingTransferExport, DurableObjectExpectingTransferExportSchema, DurableObjectRenamedExport, DurableObjectRenamedExportSchema, DurableObjectTransferredExport, DurableObjectTransferredExportSchema, EmailTrigger, ExportSchema, Exports, FetchTrigger, FlagshipBinding, FlagshipBindingSchema, HyperdriveBinding, HyperdriveBindingSchema, ImagesBinding, InferDurableNamespaces, InferEnv, InferMainModule, InputSettingsSchema, InputWorkerSchema, JsonBinding, KVBindingSchema, KnownBindingSchema, KvBinding, type LoadAndValidateConfigResult, type LoadConfigResult, LogfwdrBinding, MediaBinding, type ModuleType, ModuleTypeSchema, MtlsCertificateBinding, OutputSettingsSchema, OutputWorkerSchema, type ParsedConfigExports, type ParsedInputSettingsConfig, type ParsedInputWorkerConfig, type ParsedOutputSettingsConfig, type ParsedOutputWorkerConfig, PipelineBinding, QueueBinding, QueueBindingSchema, QueueConsumerTrigger, R2Binding, R2BindingSchema, RateLimitBinding, ScheduledTrigger, SecretBinding, SecretsStoreSecretBinding, SendEmailBinding, SettingsConfig, SettingsConfigExport, SettingsConfigInput, StreamBinding, TailConsumerSchema, TextBinding, Triggers, TypedAiBinding, TypedKvBinding, TypedPipelineBinding, TypedQueueBinding, UnsafeBinding, UnsafeBindingSchema, UnwrapConfig, VectorizeBinding, VersionMetadataBinding, VpcNetworkBinding, VpcServiceBinding, WebSearchBinding, WorkerBinding, WorkerBindingSchema, WorkerConfig, WorkerConfigExport, WorkerConfigInput, WorkerEntrypointExport, WorkerEntrypointExportOptions, WorkerEntrypointExportSchema, WorkerLoaderBinding, WorkerReference, WorkflowBinding, bindings, convertToWranglerConfig, defineSettings, defineWorker, exports, generateTypes, loadAndValidateConfig, loadConfig, registerConfigHooks, resolveAndValidateConfigExports, triggers, validateSingletonBindings };
|
|
1132
|
+
export { AgentMemoryBinding, AiBinding, AiSearchBinding, AiSearchNamespaceBinding, AnalyticsEngineDatasetBinding, AnalyticsEngineDatasetBindingSchema, ArtifactsBinding, AssetsBinding, AssetsSchema, BindingDevOptions, BindingSchema, Bindings, BrowserBinding, BrowserBindingSchema, ConfigContext, type ConfigParseResult, ConnectTrigger, ContainerConfig, ContainerConfigExport, ContainerConfigInput, D1Binding, D1BindingSchema, DispatchNamespaceBinding, DurableObjectBinding, DurableObjectCreatedExport, DurableObjectCreatedExportSchema, DurableObjectDeletedExport, DurableObjectDeletedExportSchema, DurableObjectExpectingTransferExport, DurableObjectExpectingTransferExportSchema, DurableObjectRenamedExport, DurableObjectRenamedExportSchema, DurableObjectTransferredExport, DurableObjectTransferredExportSchema, EmailTrigger, ExportSchema, Exports, FetchTrigger, FlagshipBinding, FlagshipBindingSchema, HyperdriveBinding, HyperdriveBindingSchema, ImagesBinding, InferDurableNamespaces, InferEnv, InferMainModule, InputContainerSchema, InputSettingsSchema, InputWorkerSchema, JsonBinding, KVBindingSchema, KnownBindingSchema, KvBinding, type LoadAndValidateConfigResult, type LoadConfigResult, LogfwdrBinding, MediaBinding, type ModuleType, ModuleTypeSchema, MtlsCertificateBinding, OutputContainerSchema, OutputSettingsSchema, OutputWorkerSchema, type ParsedConfigExports, type ParsedInputContainerConfig, type ParsedInputSettingsConfig, type ParsedInputWorkerConfig, type ParsedOutputContainerConfig, type ParsedOutputSettingsConfig, type ParsedOutputWorkerConfig, PipelineBinding, QueueBinding, QueueBindingSchema, QueueConsumerTrigger, R2Binding, R2BindingSchema, RateLimitBinding, ScheduledTrigger, SecretBinding, SecretsStoreSecretBinding, SendEmailBinding, SettingsConfig, SettingsConfigExport, SettingsConfigInput, StreamBinding, TailConsumerSchema, TextBinding, Triggers, TypedAiBinding, TypedKvBinding, TypedPipelineBinding, TypedQueueBinding, UnsafeBinding, UnsafeBindingSchema, UnwrapConfig, VectorizeBinding, VersionMetadataBinding, VpcNetworkBinding, VpcServiceBinding, WebSearchBinding, WorkerBinding, WorkerBindingSchema, WorkerConfig, WorkerConfigExport, WorkerConfigInput, WorkerEntrypointExport, WorkerEntrypointExportOptions, WorkerEntrypointExportSchema, WorkerLoaderBinding, WorkerReference, WorkflowBinding, bindings, convertToWranglerConfig, defineContainer, defineSettings, defineWorker, exports, generateTypes, loadAndValidateConfig, loadConfig, registerConfigHooks, resolveAndValidateConfigExports, triggers, validateSingletonBindings };
|
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as
|
|
1
|
+
import { a as triggers, i as exports$1, n as defineWorker, o as bindings, r as defineContainer, t as defineSettings } from "./public-BYCVISMH.mjs";
|
|
2
2
|
import * as nodeModule from "node:module";
|
|
3
3
|
import * as z from "zod";
|
|
4
4
|
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
@@ -263,6 +263,136 @@ function validateSingletonBindings(env, ctx) {
|
|
|
263
263
|
});
|
|
264
264
|
}
|
|
265
265
|
const EnvSchema = z.record(z.string(), BindingSchema).superRefine(validateSingletonBindings).optional();
|
|
266
|
+
const ContainerImageDockerfileSchema = z.strictObject({
|
|
267
|
+
dockerfile: z.string().min(1),
|
|
268
|
+
buildContext: z.string().optional(),
|
|
269
|
+
buildVars: z.record(z.string(), z.string()).optional()
|
|
270
|
+
});
|
|
271
|
+
const ContainerImageReferenceSchema = z.strictObject({ reference: z.string().min(1) });
|
|
272
|
+
const ContainerImageLocalReferenceSchema = z.strictObject({ localReference: z.string().min(1) });
|
|
273
|
+
const InputContainerImageSchema = z.union([ContainerImageDockerfileSchema, ContainerImageReferenceSchema]);
|
|
274
|
+
const OutputContainerImageSchema = z.union([ContainerImageReferenceSchema, ContainerImageLocalReferenceSchema]);
|
|
275
|
+
const VALID_ROLLOUT_STEP_PERCENTAGES = new Set([
|
|
276
|
+
5,
|
|
277
|
+
10,
|
|
278
|
+
20,
|
|
279
|
+
25,
|
|
280
|
+
50,
|
|
281
|
+
100
|
|
282
|
+
]);
|
|
283
|
+
const ContainerRolloutStepPercentageSchema = z.union([z.number(), z.array(z.number())]).superRefine((stepPercentage, ctx) => {
|
|
284
|
+
if (typeof stepPercentage === "number") {
|
|
285
|
+
if (!VALID_ROLLOUT_STEP_PERCENTAGES.has(stepPercentage)) ctx.addIssue({
|
|
286
|
+
code: "custom",
|
|
287
|
+
message: "A rollout step percentage must be one of 5, 10, 20, 25, 50, or 100"
|
|
288
|
+
});
|
|
289
|
+
return;
|
|
290
|
+
}
|
|
291
|
+
if (stepPercentage.length === 0) {
|
|
292
|
+
ctx.addIssue({
|
|
293
|
+
code: "custom",
|
|
294
|
+
message: "A rollout must contain at least one step percentage"
|
|
295
|
+
});
|
|
296
|
+
return;
|
|
297
|
+
}
|
|
298
|
+
for (const [index, step] of stepPercentage.entries()) {
|
|
299
|
+
if (step < 10 || step > 100) ctx.addIssue({
|
|
300
|
+
code: "custom",
|
|
301
|
+
path: [index],
|
|
302
|
+
message: "Rollout step percentages must be between 10 and 100"
|
|
303
|
+
});
|
|
304
|
+
const previousStep = stepPercentage[index - 1];
|
|
305
|
+
if (previousStep !== void 0 && step < previousStep) ctx.addIssue({
|
|
306
|
+
code: "custom",
|
|
307
|
+
path: [index],
|
|
308
|
+
message: "Rollout step percentages must be in ascending order"
|
|
309
|
+
});
|
|
310
|
+
}
|
|
311
|
+
const lastIndex = stepPercentage.length - 1;
|
|
312
|
+
if (stepPercentage[lastIndex] !== 100) ctx.addIssue({
|
|
313
|
+
code: "custom",
|
|
314
|
+
path: [lastIndex],
|
|
315
|
+
message: "The final rollout step percentage must be 100"
|
|
316
|
+
});
|
|
317
|
+
});
|
|
318
|
+
function validateContainerRelationships(container, ctx) {
|
|
319
|
+
const stepPercentage = container.rollout?.stepPercentage;
|
|
320
|
+
if (Array.isArray(stepPercentage) && container.maxInstances !== void 0 && stepPercentage.length > container.maxInstances) ctx.addIssue({
|
|
321
|
+
code: "custom",
|
|
322
|
+
path: ["rollout", "stepPercentage"],
|
|
323
|
+
message: "A rollout cannot contain more steps than the maximum number of instances"
|
|
324
|
+
});
|
|
325
|
+
}
|
|
326
|
+
const ContainerObservabilityBaseSchema = z.strictObject({
|
|
327
|
+
enabled: z.boolean().optional(),
|
|
328
|
+
logs: z.strictObject({ enabled: z.boolean().optional() }).optional()
|
|
329
|
+
});
|
|
330
|
+
const ContainerObservabilitySchema = z.union([ContainerObservabilityBaseSchema.extend({ targetInstancePercentage: z.number().min(0).max(100).optional() }), ContainerObservabilityBaseSchema.extend({ targetInstanceCount: z.number().int().nonnegative().optional() })]);
|
|
331
|
+
const BaseContainerSchema = z.strictObject({
|
|
332
|
+
type: z.literal("container"),
|
|
333
|
+
name: z.string().min(1),
|
|
334
|
+
observability: ContainerObservabilitySchema.optional(),
|
|
335
|
+
unsafe: z.record(z.string(), z.unknown()).optional()
|
|
336
|
+
});
|
|
337
|
+
const StandardContainerBaseSchema = BaseContainerSchema.extend({
|
|
338
|
+
maxInstances: z.number().int().nonnegative().default(20),
|
|
339
|
+
instanceType: z.union([z.enum([
|
|
340
|
+
"basic",
|
|
341
|
+
"lite",
|
|
342
|
+
"standard-1",
|
|
343
|
+
"standard-2",
|
|
344
|
+
"standard-3",
|
|
345
|
+
"standard-4"
|
|
346
|
+
]), z.strictObject({
|
|
347
|
+
vcpu: z.number().min(.0625).optional(),
|
|
348
|
+
memoryMib: z.number().nonnegative().optional(),
|
|
349
|
+
diskMb: z.number().nonnegative().optional()
|
|
350
|
+
})]).optional(),
|
|
351
|
+
schedulingPolicy: z.enum(["default", "regional"]).optional(),
|
|
352
|
+
ssh: z.strictObject({
|
|
353
|
+
enabled: z.boolean(),
|
|
354
|
+
port: z.number().int().min(1).max(65535).optional()
|
|
355
|
+
}).optional(),
|
|
356
|
+
authorizedKeys: z.array(z.strictObject({
|
|
357
|
+
name: z.string(),
|
|
358
|
+
publicKey: z.string()
|
|
359
|
+
})).optional(),
|
|
360
|
+
constraints: z.strictObject({
|
|
361
|
+
regions: z.array(z.enum([
|
|
362
|
+
"ENAM",
|
|
363
|
+
"WNAM",
|
|
364
|
+
"EEUR",
|
|
365
|
+
"WEUR",
|
|
366
|
+
"APAC",
|
|
367
|
+
"SAM",
|
|
368
|
+
"ME",
|
|
369
|
+
"OC",
|
|
370
|
+
"AFR"
|
|
371
|
+
])).optional(),
|
|
372
|
+
jurisdiction: z.enum(["eu", "fedramp"]).optional()
|
|
373
|
+
}).optional(),
|
|
374
|
+
rollout: z.strictObject({
|
|
375
|
+
kind: z.enum([
|
|
376
|
+
"full-auto",
|
|
377
|
+
"none",
|
|
378
|
+
"full-manual"
|
|
379
|
+
]).optional(),
|
|
380
|
+
stepPercentage: ContainerRolloutStepPercentageSchema.optional(),
|
|
381
|
+
activeGracePeriod: z.number().nonnegative().optional()
|
|
382
|
+
}).optional()
|
|
383
|
+
});
|
|
384
|
+
const DurableObjectContainerBaseSchema = BaseContainerSchema.extend({ schedulingPolicy: z.literal("durable-object") });
|
|
385
|
+
/**
|
|
386
|
+
* Input Container schema — validates user-authored `cloudflare.config.ts`
|
|
387
|
+
* Container exports. Dockerfiles are built by the consuming build tool.
|
|
388
|
+
*/
|
|
389
|
+
const InputContainerSchema = z.union([StandardContainerBaseSchema.extend({ image: InputContainerImageSchema }).superRefine(validateContainerRelationships), DurableObjectContainerBaseSchema.extend({ images: z.record(z.string(), InputContainerImageSchema).optional() })]);
|
|
390
|
+
/**
|
|
391
|
+
* Output Container schema — validates Container configs in the Build Output
|
|
392
|
+
* Specification, after any Dockerfile has been built into a local or remote
|
|
393
|
+
* image reference.
|
|
394
|
+
*/
|
|
395
|
+
const OutputContainerSchema = z.union([StandardContainerBaseSchema.extend({ image: OutputContainerImageSchema }).superRefine(validateContainerRelationships), DurableObjectContainerBaseSchema.extend({ images: z.record(z.string(), OutputContainerImageSchema).optional() })]);
|
|
266
396
|
const DurableObjectCreatedExportSchema = z.strictObject({
|
|
267
397
|
type: z.literal("durable-object"),
|
|
268
398
|
state: z.literal("created").optional(),
|
|
@@ -441,8 +571,13 @@ const InputSettingsSchema = z.strictObject({
|
|
|
441
571
|
* Build Output Specification. Adds the `mode` the build was produced in.
|
|
442
572
|
*/
|
|
443
573
|
const OutputSettingsSchema = InputSettingsSchema.extend({ mode: z.string().optional() });
|
|
574
|
+
const DEFAULT_EXPORT_NAME = "default";
|
|
444
575
|
const SETTINGS_EXPORT_NAME = "settings";
|
|
445
|
-
const SUPPORTED_EXPORT_TYPES = new Set([
|
|
576
|
+
const SUPPORTED_EXPORT_TYPES = new Set([
|
|
577
|
+
"container",
|
|
578
|
+
"worker",
|
|
579
|
+
"settings"
|
|
580
|
+
]);
|
|
446
581
|
function invalidConfigExportMessage(exportName) {
|
|
447
582
|
return `The \`${exportName}\` export is not a supported export type. Move constants, helper functions, and other unsupported exports to a separate module.`;
|
|
448
583
|
}
|
|
@@ -459,6 +594,15 @@ const ConfigExportsTypeSchema = z.record(z.string(), z.unknown()).check((ctx) =>
|
|
|
459
594
|
});
|
|
460
595
|
continue;
|
|
461
596
|
}
|
|
597
|
+
if (key === DEFAULT_EXPORT_NAME && type !== "worker") {
|
|
598
|
+
ctx.issues.push({
|
|
599
|
+
code: "custom",
|
|
600
|
+
input: value,
|
|
601
|
+
path: [key],
|
|
602
|
+
message: `The \`${DEFAULT_EXPORT_NAME}\` export is reserved for a \`worker\` config; found a \`${type}\` config.`
|
|
603
|
+
});
|
|
604
|
+
continue;
|
|
605
|
+
}
|
|
462
606
|
const isSettingsName = key === SETTINGS_EXPORT_NAME;
|
|
463
607
|
const isSettingsType = type === "settings";
|
|
464
608
|
if (isSettingsType && !isSettingsName) ctx.issues.push({
|
|
@@ -656,18 +800,26 @@ __name(createFatalError, "createFatalError");
|
|
|
656
800
|
|
|
657
801
|
//#endregion
|
|
658
802
|
//#region src/convert.ts
|
|
803
|
+
const ROLLOUT_KIND_MAP = {
|
|
804
|
+
"full-auto": "full_auto",
|
|
805
|
+
"full-manual": "full_manual",
|
|
806
|
+
none: "none"
|
|
807
|
+
};
|
|
659
808
|
/**
|
|
660
809
|
* Convert a parsed `@cloudflare/config` config into a Wrangler `RawConfig`.
|
|
661
810
|
*
|
|
662
|
-
* The caller is responsible for unwrapping any function/promise
|
|
663
|
-
* the
|
|
811
|
+
* The caller is responsible for unwrapping any function/promise wrappers and
|
|
812
|
+
* validating the configs against their corresponding input schemas before
|
|
813
|
+
* passing them in.
|
|
664
814
|
*
|
|
665
815
|
* @param workerConfig The parsed (post-validation) Worker config.
|
|
666
816
|
* @param settingsConfig The optional parsed settings config, whose fields
|
|
667
817
|
* are merged onto the result.
|
|
818
|
+
* @param containerExports The parsed Container exports to include in the
|
|
819
|
+
* result.
|
|
668
820
|
* @returns The corresponding Wrangler `RawConfig`.
|
|
669
821
|
*/
|
|
670
|
-
function convertToWranglerConfig(workerConfig, settingsConfig) {
|
|
822
|
+
function convertToWranglerConfig(workerConfig, settingsConfig, containerExports = []) {
|
|
671
823
|
const result = {};
|
|
672
824
|
convertTopLevel(workerConfig, result);
|
|
673
825
|
convertBindingsAndAssets(workerConfig, result);
|
|
@@ -676,8 +828,50 @@ function convertToWranglerConfig(workerConfig, settingsConfig) {
|
|
|
676
828
|
convertTriggers(workerConfig, result);
|
|
677
829
|
convertTailConsumers(workerConfig, result);
|
|
678
830
|
if (settingsConfig !== void 0) convertSettings(settingsConfig, result);
|
|
831
|
+
if (containerExports.length > 0) result.containers = containerExports.map((container) => convertContainer(container));
|
|
679
832
|
return result;
|
|
680
833
|
}
|
|
834
|
+
function convertContainer(container) {
|
|
835
|
+
if (container.schedulingPolicy === "durable-object") throw new UserError("Durable Object-managed Containers are not currently supported by `convertToWranglerConfig()`.", { telemetryMessage: false });
|
|
836
|
+
const converted = { name: container.name };
|
|
837
|
+
if (container.observability !== void 0) converted.observability = convertContainerObservability(container.observability);
|
|
838
|
+
if (container.unsafe !== void 0) converted.unsafe = container.unsafe;
|
|
839
|
+
converted.image = "dockerfile" in container.image ? container.image.dockerfile : container.image.reference;
|
|
840
|
+
converted.max_instances = container.maxInstances;
|
|
841
|
+
if ("dockerfile" in container.image) {
|
|
842
|
+
if (container.image.buildContext !== void 0) converted.image_build_context = container.image.buildContext;
|
|
843
|
+
if (container.image.buildVars !== void 0) converted.image_vars = container.image.buildVars;
|
|
844
|
+
}
|
|
845
|
+
if (container.instanceType !== void 0) if (typeof container.instanceType === "string") converted.instance_type = container.instanceType;
|
|
846
|
+
else {
|
|
847
|
+
const instanceType = {};
|
|
848
|
+
if (container.instanceType.vcpu !== void 0) instanceType.vcpu = container.instanceType.vcpu;
|
|
849
|
+
if (container.instanceType.memoryMib !== void 0) instanceType.memory_mib = container.instanceType.memoryMib;
|
|
850
|
+
if (container.instanceType.diskMb !== void 0) instanceType.disk_mb = container.instanceType.diskMb;
|
|
851
|
+
converted.instance_type = instanceType;
|
|
852
|
+
}
|
|
853
|
+
if (container.schedulingPolicy !== void 0) converted.scheduling_policy = container.schedulingPolicy;
|
|
854
|
+
if (container.ssh !== void 0) converted.ssh = container.ssh;
|
|
855
|
+
if (container.authorizedKeys !== void 0) converted.authorized_keys = container.authorizedKeys.map(({ name, publicKey }) => ({
|
|
856
|
+
name,
|
|
857
|
+
public_key: publicKey
|
|
858
|
+
}));
|
|
859
|
+
if (container.constraints !== void 0) converted.constraints = container.constraints;
|
|
860
|
+
if (container.rollout !== void 0) {
|
|
861
|
+
if (container.rollout.kind !== void 0) converted.rollout_kind = ROLLOUT_KIND_MAP[container.rollout.kind];
|
|
862
|
+
if (container.rollout.stepPercentage !== void 0) converted.rollout_step_percentage = container.rollout.stepPercentage;
|
|
863
|
+
if (container.rollout.activeGracePeriod !== void 0) converted.rollout_active_grace_period = container.rollout.activeGracePeriod;
|
|
864
|
+
}
|
|
865
|
+
return converted;
|
|
866
|
+
}
|
|
867
|
+
function convertContainerObservability(observability) {
|
|
868
|
+
const converted = {};
|
|
869
|
+
if (observability.enabled !== void 0) converted.enabled = observability.enabled;
|
|
870
|
+
if (observability.logs !== void 0) converted.logs = observability.logs;
|
|
871
|
+
if ("targetInstancePercentage" in observability && observability.targetInstancePercentage !== void 0) converted.target_instance_percentage = observability.targetInstancePercentage;
|
|
872
|
+
if ("targetInstanceCount" in observability && observability.targetInstanceCount !== void 0) converted.target_instance_count = observability.targetInstanceCount;
|
|
873
|
+
return converted;
|
|
874
|
+
}
|
|
681
875
|
/**
|
|
682
876
|
* Merge a parsed settings config's fields (`account_id`, `compliance_region`)
|
|
683
877
|
* onto an existing Wrangler `RawConfig`.
|
|
@@ -1351,6 +1545,9 @@ function isRecord(value) {
|
|
|
1351
1545
|
function isConfigReference(value) {
|
|
1352
1546
|
return typeof value === "function" || isRecord(value);
|
|
1353
1547
|
}
|
|
1548
|
+
function normalizeConfigReference(reference, resolved, expectedType) {
|
|
1549
|
+
return isRecord(resolved) && resolved.type === expectedType && typeof resolved.name === "string" ? resolved.name : reference;
|
|
1550
|
+
}
|
|
1354
1551
|
function createDefinitionResolver(ctx) {
|
|
1355
1552
|
const resolvedDefinitions = /* @__PURE__ */ new Map();
|
|
1356
1553
|
return (input) => {
|
|
@@ -1371,7 +1568,7 @@ async function normalizeWorkerReferences(resolved, resolveDefinition) {
|
|
|
1371
1568
|
const target = await resolveDefinition(binding.worker);
|
|
1372
1569
|
env[bindingName] = {
|
|
1373
1570
|
...binding,
|
|
1374
|
-
worker:
|
|
1571
|
+
worker: normalizeConfigReference(binding.worker, target, "worker")
|
|
1375
1572
|
};
|
|
1376
1573
|
}
|
|
1377
1574
|
return {
|
|
@@ -1379,22 +1576,151 @@ async function normalizeWorkerReferences(resolved, resolveDefinition) {
|
|
|
1379
1576
|
env
|
|
1380
1577
|
};
|
|
1381
1578
|
}
|
|
1579
|
+
async function normalizeContainerReferences(resolved, resolveDefinition, resolvedExports) {
|
|
1580
|
+
const issues = [];
|
|
1581
|
+
if (!isRecord(resolved) || !isRecord(resolved.exports)) return {
|
|
1582
|
+
value: resolved,
|
|
1583
|
+
issues
|
|
1584
|
+
};
|
|
1585
|
+
const workerExports = { ...resolved.exports };
|
|
1586
|
+
for (const [exportName, workerExport] of Object.entries(workerExports)) {
|
|
1587
|
+
if (!isRecord(workerExport) || workerExport.type !== "durable-object" || workerExport.container === void 0) continue;
|
|
1588
|
+
const reference = workerExport.container;
|
|
1589
|
+
if (typeof reference === "string") {
|
|
1590
|
+
issues.push({
|
|
1591
|
+
code: "custom",
|
|
1592
|
+
input: reference,
|
|
1593
|
+
path: [
|
|
1594
|
+
"exports",
|
|
1595
|
+
exportName,
|
|
1596
|
+
"container"
|
|
1597
|
+
],
|
|
1598
|
+
message: "Container provided as a string. Reference an exported Container definition instead."
|
|
1599
|
+
});
|
|
1600
|
+
workerExports[exportName] = {
|
|
1601
|
+
...workerExport,
|
|
1602
|
+
container: void 0
|
|
1603
|
+
};
|
|
1604
|
+
continue;
|
|
1605
|
+
}
|
|
1606
|
+
const target = await resolveDefinition(reference);
|
|
1607
|
+
if (isRecord(target) && target.type === "container" && typeof target.name === "string" && !Object.values(resolvedExports).includes(target)) {
|
|
1608
|
+
issues.push({
|
|
1609
|
+
code: "custom",
|
|
1610
|
+
input: reference,
|
|
1611
|
+
path: [
|
|
1612
|
+
"exports",
|
|
1613
|
+
exportName,
|
|
1614
|
+
"container"
|
|
1615
|
+
],
|
|
1616
|
+
message: `The referenced Container "${target.name}" is not exported.`
|
|
1617
|
+
});
|
|
1618
|
+
workerExports[exportName] = {
|
|
1619
|
+
...workerExport,
|
|
1620
|
+
container: void 0
|
|
1621
|
+
};
|
|
1622
|
+
continue;
|
|
1623
|
+
}
|
|
1624
|
+
workerExports[exportName] = {
|
|
1625
|
+
...workerExport,
|
|
1626
|
+
container: normalizeConfigReference(reference, target, "container")
|
|
1627
|
+
};
|
|
1628
|
+
}
|
|
1629
|
+
return {
|
|
1630
|
+
value: {
|
|
1631
|
+
...resolved,
|
|
1632
|
+
exports: workerExports
|
|
1633
|
+
},
|
|
1634
|
+
issues
|
|
1635
|
+
};
|
|
1636
|
+
}
|
|
1637
|
+
async function normalizeConfigReferences(resolved, resolveDefinition, resolvedExports) {
|
|
1638
|
+
return normalizeContainerReferences(await normalizeWorkerReferences(resolved, resolveDefinition), resolveDefinition, resolvedExports);
|
|
1639
|
+
}
|
|
1382
1640
|
function prefixIssues(issues, prefix) {
|
|
1383
1641
|
return issues.map((issue) => ({
|
|
1384
1642
|
...issue,
|
|
1385
1643
|
path: [prefix, ...issue.path]
|
|
1386
1644
|
}));
|
|
1387
1645
|
}
|
|
1646
|
+
function validateUniqueResourceNames(configExports) {
|
|
1647
|
+
const issues = [];
|
|
1648
|
+
const exportNameByResourceName = {
|
|
1649
|
+
container: /* @__PURE__ */ new Map(),
|
|
1650
|
+
worker: /* @__PURE__ */ new Map()
|
|
1651
|
+
};
|
|
1652
|
+
for (const [exportName, config] of Object.entries(configExports)) {
|
|
1653
|
+
if (config.type !== "container" && config.type !== "worker") continue;
|
|
1654
|
+
const resourceType = config.type === "container" ? "Container" : "Worker";
|
|
1655
|
+
const exportNames = exportNameByResourceName[config.type];
|
|
1656
|
+
const previousExportName = exportNames.get(config.name);
|
|
1657
|
+
if (previousExportName !== void 0) {
|
|
1658
|
+
issues.push({
|
|
1659
|
+
code: "custom",
|
|
1660
|
+
input: config.name,
|
|
1661
|
+
path: [exportName, "name"],
|
|
1662
|
+
message: `The ${resourceType} name "${config.name}" is also used by the "${previousExportName}" export. ${resourceType} names must be unique.`
|
|
1663
|
+
});
|
|
1664
|
+
continue;
|
|
1665
|
+
}
|
|
1666
|
+
exportNames.set(config.name, exportName);
|
|
1667
|
+
}
|
|
1668
|
+
return issues;
|
|
1669
|
+
}
|
|
1670
|
+
function validateContainerExportLinks(configExports) {
|
|
1671
|
+
const issues = [];
|
|
1672
|
+
const containerNames = /* @__PURE__ */ new Set();
|
|
1673
|
+
for (const config of Object.values(configExports)) if (config.type === "container") containerNames.add(config.name);
|
|
1674
|
+
const firstReferenceByContainerName = /* @__PURE__ */ new Map();
|
|
1675
|
+
for (const [workerExportName, config] of Object.entries(configExports)) {
|
|
1676
|
+
if (config.type !== "worker") continue;
|
|
1677
|
+
for (const [durableObjectExportName, workerExport] of Object.entries(config.exports ?? {})) {
|
|
1678
|
+
if (workerExport.type !== "durable-object" || !("container" in workerExport) || workerExport.container === void 0) continue;
|
|
1679
|
+
const containerName = workerExport.container;
|
|
1680
|
+
const path = [
|
|
1681
|
+
workerExportName,
|
|
1682
|
+
"exports",
|
|
1683
|
+
durableObjectExportName,
|
|
1684
|
+
"container"
|
|
1685
|
+
];
|
|
1686
|
+
if (!containerNames.has(containerName)) {
|
|
1687
|
+
issues.push({
|
|
1688
|
+
code: "custom",
|
|
1689
|
+
input: containerName,
|
|
1690
|
+
path,
|
|
1691
|
+
message: `The Container "${containerName}" is not exported from this configuration.`
|
|
1692
|
+
});
|
|
1693
|
+
continue;
|
|
1694
|
+
}
|
|
1695
|
+
const firstReference = firstReferenceByContainerName.get(containerName);
|
|
1696
|
+
if (firstReference !== void 0) {
|
|
1697
|
+
issues.push({
|
|
1698
|
+
code: "custom",
|
|
1699
|
+
input: containerName,
|
|
1700
|
+
path,
|
|
1701
|
+
message: `The Container "${containerName}" is already referenced by "${firstReference.workerExportName}.exports.${firstReference.durableObjectExportName}". A Container can only be linked to one Durable Object.`
|
|
1702
|
+
});
|
|
1703
|
+
continue;
|
|
1704
|
+
}
|
|
1705
|
+
firstReferenceByContainerName.set(containerName, {
|
|
1706
|
+
workerExportName,
|
|
1707
|
+
durableObjectExportName
|
|
1708
|
+
});
|
|
1709
|
+
}
|
|
1710
|
+
}
|
|
1711
|
+
return issues;
|
|
1712
|
+
}
|
|
1388
1713
|
/**
|
|
1389
1714
|
* Resolve and validate loaded `cloudflare.config.ts` exports.
|
|
1390
1715
|
*
|
|
1391
|
-
* Config inputs are resolved once by identity. Top-level Worker
|
|
1392
|
-
* also parsed once by identity
|
|
1393
|
-
* enough to replace
|
|
1716
|
+
* Config inputs are resolved once by identity. Top-level Worker and Container
|
|
1717
|
+
* exports are also parsed once by identity. References are resolved only far
|
|
1718
|
+
* enough to replace them with resource names, then Container links are
|
|
1719
|
+
* validated across the exported resources.
|
|
1394
1720
|
*/
|
|
1395
1721
|
async function resolveAndValidateConfigExports(exports$2, ctx) {
|
|
1396
1722
|
const resolveDefinition = createDefinitionResolver(ctx);
|
|
1397
|
-
const
|
|
1723
|
+
const parsedResources = /* @__PURE__ */ new Map();
|
|
1398
1724
|
const resolvedExports = {};
|
|
1399
1725
|
for (const [name, input] of Object.entries(exports$2)) resolvedExports[name] = await resolveDefinition(input);
|
|
1400
1726
|
const typeResult = ConfigExportsTypeSchema.safeParse(resolvedExports);
|
|
@@ -1408,17 +1734,20 @@ async function resolveAndValidateConfigExports(exports$2, ctx) {
|
|
|
1408
1734
|
for (const [name, input] of Object.entries(exports$2)) {
|
|
1409
1735
|
const resolved = resolvedExports[name];
|
|
1410
1736
|
if (!isRecord(resolved)) continue;
|
|
1411
|
-
if (resolved.type
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1737
|
+
if (resolved.type !== "worker" && resolved.type !== "container") continue;
|
|
1738
|
+
let result = parsedResources.get(input);
|
|
1739
|
+
if (!result) {
|
|
1740
|
+
if (resolved.type === "worker") {
|
|
1741
|
+
const normalized = await normalizeConfigReferences(resolved, resolveDefinition, resolvedExports);
|
|
1742
|
+
issues.push(...prefixIssues(normalized.issues, name));
|
|
1743
|
+
result = InputWorkerSchema.safeParse(normalized.value);
|
|
1744
|
+
} else result = InputContainerSchema.safeParse(resolved);
|
|
1745
|
+
parsedResources.set(input, result);
|
|
1746
|
+
if (!result.success) issues.push(...prefixIssues(result.error.issues, name));
|
|
1420
1747
|
}
|
|
1748
|
+
if (result.success) data[name] = result.data;
|
|
1421
1749
|
}
|
|
1750
|
+
issues.push(...validateUniqueResourceNames(data), ...validateContainerExportLinks(data));
|
|
1422
1751
|
return issues.length > 0 ? {
|
|
1423
1752
|
success: false,
|
|
1424
1753
|
error: new z.ZodError(issues)
|
|
@@ -1439,4 +1768,4 @@ async function loadAndValidateConfig(configPath, ctx, options) {
|
|
|
1439
1768
|
}
|
|
1440
1769
|
|
|
1441
1770
|
//#endregion
|
|
1442
|
-
export { AnalyticsEngineDatasetBindingSchema, AssetsSchema, BindingSchema, BrowserBindingSchema, D1BindingSchema, DurableObjectCreatedExportSchema, DurableObjectDeletedExportSchema, DurableObjectExpectingTransferExportSchema, DurableObjectRenamedExportSchema, DurableObjectTransferredExportSchema, ExportSchema, FlagshipBindingSchema, HyperdriveBindingSchema, InputSettingsSchema, InputWorkerSchema, KVBindingSchema, KnownBindingSchema, ModuleTypeSchema, OutputSettingsSchema, OutputWorkerSchema, QueueBindingSchema, R2BindingSchema, TailConsumerSchema, UnsafeBindingSchema, WorkerBindingSchema, WorkerEntrypointExportSchema, bindings, convertToWranglerConfig, defineSettings, defineWorker, exports$1 as exports, generateTypes, loadAndValidateConfig, loadConfig, registerConfigHooks, resolveAndValidateConfigExports, triggers, validateSingletonBindings };
|
|
1771
|
+
export { AnalyticsEngineDatasetBindingSchema, AssetsSchema, BindingSchema, BrowserBindingSchema, D1BindingSchema, DurableObjectCreatedExportSchema, DurableObjectDeletedExportSchema, DurableObjectExpectingTransferExportSchema, DurableObjectRenamedExportSchema, DurableObjectTransferredExportSchema, ExportSchema, FlagshipBindingSchema, HyperdriveBindingSchema, InputContainerSchema, InputSettingsSchema, InputWorkerSchema, KVBindingSchema, KnownBindingSchema, ModuleTypeSchema, OutputContainerSchema, OutputSettingsSchema, OutputWorkerSchema, QueueBindingSchema, R2BindingSchema, TailConsumerSchema, UnsafeBindingSchema, WorkerBindingSchema, WorkerEntrypointExportSchema, bindings, convertToWranglerConfig, defineContainer, defineSettings, defineWorker, exports$1 as exports, generateTypes, loadAndValidateConfig, loadConfig, registerConfigHooks, resolveAndValidateConfigExports, triggers, validateSingletonBindings };
|
|
@@ -193,12 +193,17 @@ function worker(options = {}) {
|
|
|
193
193
|
*
|
|
194
194
|
* @example
|
|
195
195
|
* ```typescript
|
|
196
|
-
* import { defineWorker, exports } from "@cloudflare/config";
|
|
196
|
+
* import { defineContainer, defineWorker, exports } from "@cloudflare/config";
|
|
197
|
+
*
|
|
198
|
+
* const myContainer = defineContainer({
|
|
199
|
+
* name: "my-container",
|
|
200
|
+
* image: { dockerfile: "./Dockerfile" },
|
|
201
|
+
* });
|
|
197
202
|
*
|
|
198
203
|
* export default defineWorker({
|
|
199
204
|
* exports: {
|
|
200
205
|
* MyDurableObject: exports.durableObject({ storage: "sqlite" }),
|
|
201
|
-
* MyContainerDO: exports.durableObject({ storage: "sqlite", container:
|
|
206
|
+
* MyContainerDO: exports.durableObject({ storage: "sqlite", container: myContainer }),
|
|
202
207
|
* OldClass: exports.durableObject({ state: "deleted" }),
|
|
203
208
|
* OldName: exports.durableObject({ state: "renamed", renamedTo: "NewName" }),
|
|
204
209
|
* Outgoing: exports.durableObject({ state: "transferred", transferredTo: "target-worker" }),
|
|
@@ -236,6 +241,11 @@ function createConfigDefiner(type) {
|
|
|
236
241
|
return define;
|
|
237
242
|
}
|
|
238
243
|
|
|
244
|
+
//#endregion
|
|
245
|
+
//#region src/container-definition.ts
|
|
246
|
+
/** Declare a Container application. */
|
|
247
|
+
const defineContainer = createConfigDefiner("container");
|
|
248
|
+
|
|
239
249
|
//#endregion
|
|
240
250
|
//#region src/worker-definition.ts
|
|
241
251
|
const defineWorker = createConfigDefiner("worker");
|
|
@@ -249,4 +259,4 @@ const defineWorker = createConfigDefiner("worker");
|
|
|
249
259
|
const defineSettings = createConfigDefiner("settings");
|
|
250
260
|
|
|
251
261
|
//#endregion
|
|
252
|
-
export {
|
|
262
|
+
export { triggers as a, exports as i, defineWorker as n, bindings as o, defineContainer as r, defineSettings as t };
|
|
@@ -231,6 +231,25 @@ type ConfigWithType<T$1 extends ConfigObject, TType extends string> = T$1 & {
|
|
|
231
231
|
type: TType;
|
|
232
232
|
};
|
|
233
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
|
|
234
253
|
//#region src/exports.d.ts
|
|
235
254
|
/**
|
|
236
255
|
* Storage backend for the Durable Object.
|
|
@@ -238,17 +257,16 @@ type ConfigWithType<T$1 extends ConfigObject, TType extends string> = T$1 & {
|
|
|
238
257
|
* Containers are only supported on the SQLite storage engine, so `container` is
|
|
239
258
|
* only offered alongside `storage: "sqlite"`.
|
|
240
259
|
*/
|
|
241
|
-
type DurableObjectStorageOptions = {
|
|
260
|
+
type DurableObjectStorageOptions<TContainer extends ContainerConfigExport | undefined = ContainerConfigExport | undefined> = {
|
|
242
261
|
/**
|
|
243
262
|
* Selects the SQLite-backed storage engine (recommended for new
|
|
244
263
|
* classes).
|
|
245
264
|
*/
|
|
246
265
|
storage: "sqlite";
|
|
247
266
|
/**
|
|
248
|
-
* Attach a
|
|
249
|
-
* name must match an entry in the top level `containers` array.
|
|
267
|
+
* Attach a Container application to this Durable Object by config reference.
|
|
250
268
|
*/
|
|
251
|
-
container?:
|
|
269
|
+
container?: TContainer;
|
|
252
270
|
} | {
|
|
253
271
|
/** Selects the legacy key-value storage engine. */
|
|
254
272
|
storage: "legacy-kv";
|
|
@@ -261,9 +279,9 @@ type DurableObjectStorageOptions = {
|
|
|
261
279
|
*
|
|
262
280
|
* For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#durable-objects
|
|
263
281
|
*/
|
|
264
|
-
type DurableObjectCreatedExportOptions = {
|
|
282
|
+
type DurableObjectCreatedExportOptions<TContainer extends ContainerConfigExport | undefined = ContainerConfigExport | undefined> = {
|
|
265
283
|
state?: "created";
|
|
266
|
-
} & DurableObjectStorageOptions
|
|
284
|
+
} & DurableObjectStorageOptions<TContainer>;
|
|
267
285
|
/**
|
|
268
286
|
* Retire a provisioned Durable Object namespace whose class has
|
|
269
287
|
* been removed from code.
|
|
@@ -303,14 +321,14 @@ interface DurableObjectTransferredExportOptions {
|
|
|
303
321
|
* Prepare to receive cross-Worker Durable Object transfer.
|
|
304
322
|
* Once the source Worker's `transferred` export is deployed, this entry becomes a normal live `durable-object` export.
|
|
305
323
|
*/
|
|
306
|
-
type DurableObjectExpectingTransferExportOptions = {
|
|
324
|
+
type DurableObjectExpectingTransferExportOptions<TContainer extends ContainerConfigExport | undefined = ContainerConfigExport | undefined> = {
|
|
307
325
|
state: "expecting-transfer";
|
|
308
326
|
/**
|
|
309
327
|
* The source Worker for the two-phase cross-Worker transfer.
|
|
310
328
|
*/
|
|
311
329
|
transferFrom: string;
|
|
312
|
-
} & DurableObjectStorageOptions
|
|
313
|
-
type DurableObjectCreatedExport = DurableObjectCreatedExportOptions & {
|
|
330
|
+
} & DurableObjectStorageOptions<TContainer>;
|
|
331
|
+
type DurableObjectCreatedExport<TContainer extends ContainerConfigExport | undefined = ContainerConfigExport | undefined> = DurableObjectCreatedExportOptions<TContainer> & {
|
|
314
332
|
type: "durable-object";
|
|
315
333
|
};
|
|
316
334
|
interface DurableObjectDeletedExport extends DurableObjectDeletedExportOptions {
|
|
@@ -322,7 +340,7 @@ interface DurableObjectRenamedExport extends DurableObjectRenamedExportOptions {
|
|
|
322
340
|
interface DurableObjectTransferredExport extends DurableObjectTransferredExportOptions {
|
|
323
341
|
type: "durable-object";
|
|
324
342
|
}
|
|
325
|
-
type DurableObjectExpectingTransferExport = DurableObjectExpectingTransferExportOptions & {
|
|
343
|
+
type DurableObjectExpectingTransferExport<TContainer extends ContainerConfigExport | undefined = ContainerConfigExport | undefined> = DurableObjectExpectingTransferExportOptions<TContainer> & {
|
|
326
344
|
type: "durable-object";
|
|
327
345
|
};
|
|
328
346
|
type DurableObjectExportOptions = DurableObjectCreatedExportOptions | DurableObjectDeletedExportOptions | DurableObjectRenamedExportOptions | DurableObjectTransferredExportOptions | DurableObjectExpectingTransferExportOptions;
|
|
@@ -349,7 +367,7 @@ interface Exports {
|
|
|
349
367
|
*
|
|
350
368
|
* For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#durable-objects
|
|
351
369
|
*/
|
|
352
|
-
durableObject(options: DurableObjectCreatedExportOptions): DurableObjectCreatedExport
|
|
370
|
+
durableObject<TContainer extends ContainerConfigExport | undefined = undefined>(options: DurableObjectCreatedExportOptions<TContainer>): DurableObjectCreatedExport<TContainer>;
|
|
353
371
|
/**
|
|
354
372
|
* Retire a provisioned Durable Object namespace whose class has been removed from code.
|
|
355
373
|
*/
|
|
@@ -366,7 +384,7 @@ interface Exports {
|
|
|
366
384
|
* Prepare to receive cross-Worker Durable Object transfer.
|
|
367
385
|
* The source Worker must follow up with a deployment containing a `transferred` export to commit the transfer.
|
|
368
386
|
*/
|
|
369
|
-
durableObject(options: DurableObjectExpectingTransferExportOptions): DurableObjectExpectingTransferExport
|
|
387
|
+
durableObject<TContainer extends ContainerConfigExport | undefined = undefined>(options: DurableObjectExpectingTransferExportOptions<TContainer>): DurableObjectExpectingTransferExport<TContainer>;
|
|
370
388
|
durableObject(options: DurableObjectExportOptions): DurableObjectExports;
|
|
371
389
|
/** Declares a WorkerEntrypoint export defined by this Worker. */
|
|
372
390
|
worker(options?: WorkerEntrypointExportOptions): WorkerEntrypointExport;
|
|
@@ -376,12 +394,17 @@ interface Exports {
|
|
|
376
394
|
*
|
|
377
395
|
* @example
|
|
378
396
|
* ```typescript
|
|
379
|
-
* import { defineWorker, exports } from "@cloudflare/config";
|
|
397
|
+
* import { defineContainer, defineWorker, exports } from "@cloudflare/config";
|
|
398
|
+
*
|
|
399
|
+
* const myContainer = defineContainer({
|
|
400
|
+
* name: "my-container",
|
|
401
|
+
* image: { dockerfile: "./Dockerfile" },
|
|
402
|
+
* });
|
|
380
403
|
*
|
|
381
404
|
* export default defineWorker({
|
|
382
405
|
* exports: {
|
|
383
406
|
* MyDurableObject: exports.durableObject({ storage: "sqlite" }),
|
|
384
|
-
* MyContainerDO: exports.durableObject({ storage: "sqlite", container:
|
|
407
|
+
* MyContainerDO: exports.durableObject({ storage: "sqlite", container: myContainer }),
|
|
385
408
|
* OldClass: exports.durableObject({ state: "deleted" }),
|
|
386
409
|
* OldName: exports.durableObject({ state: "renamed", renamedTo: "NewName" }),
|
|
387
410
|
* Outgoing: exports.durableObject({ state: "transferred", transferredTo: "target-worker" }),
|
|
@@ -571,6 +594,181 @@ type Trigger = ConnectTrigger | EmailTrigger | FetchTrigger | QueueConsumerTrigg
|
|
|
571
594
|
* classes and tombstone lifecycle operations.
|
|
572
595
|
*/
|
|
573
596
|
type Export = DurableObjectCreatedExport | DurableObjectDeletedExport | DurableObjectRenamedExport | DurableObjectTransferredExport | DurableObjectExpectingTransferExport | WorkerEntrypointExport;
|
|
597
|
+
/** An image source accepted in an authored Container configuration. */
|
|
598
|
+
type ContainerImage = {
|
|
599
|
+
/** The path to a Dockerfile. */
|
|
600
|
+
dockerfile: string;
|
|
601
|
+
/**
|
|
602
|
+
* Build context of the application.
|
|
603
|
+
*
|
|
604
|
+
* @default The directory containing `dockerfile`.
|
|
605
|
+
*/
|
|
606
|
+
buildContext?: string;
|
|
607
|
+
/** Image variables available to the image at build time only. */
|
|
608
|
+
buildVars?: Record<string, string>;
|
|
609
|
+
} | {
|
|
610
|
+
/**
|
|
611
|
+
* Reference to an existing image.
|
|
612
|
+
*
|
|
613
|
+
* For supported registries, refer to
|
|
614
|
+
* https://developers.cloudflare.com/containers/guides/image-management/#use-pre-built-container-images
|
|
615
|
+
*/
|
|
616
|
+
reference: string;
|
|
617
|
+
};
|
|
618
|
+
/** Fields shared by all Container application configurations. */
|
|
619
|
+
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
|
+
/**
|
|
628
|
+
* Name of the application.
|
|
629
|
+
*
|
|
630
|
+
* This is also the identifier used to reference the Container from a Durable
|
|
631
|
+
* Object's `exports` entry via its `container` field.
|
|
632
|
+
*/
|
|
633
|
+
name: string;
|
|
634
|
+
/** Configures observability for Container instances. */
|
|
635
|
+
observability?: {
|
|
636
|
+
/** Whether observability is enabled. */
|
|
637
|
+
enabled?: boolean;
|
|
638
|
+
logs?: {
|
|
639
|
+
/** Whether log collection is enabled. */
|
|
640
|
+
enabled?: boolean;
|
|
641
|
+
};
|
|
642
|
+
} & ({
|
|
643
|
+
/** Percentage of Container instances targeted for observability. */
|
|
644
|
+
targetInstancePercentage?: number;
|
|
645
|
+
targetInstanceCount?: never;
|
|
646
|
+
} | {
|
|
647
|
+
targetInstancePercentage?: never;
|
|
648
|
+
/** Number of Container instances targeted for observability. */
|
|
649
|
+
targetInstanceCount?: number;
|
|
650
|
+
});
|
|
651
|
+
/**
|
|
652
|
+
* Passed through without client-side validation or transformation.
|
|
653
|
+
*
|
|
654
|
+
* @hidden
|
|
655
|
+
*/
|
|
656
|
+
unsafe?: Record<string, unknown>;
|
|
657
|
+
}
|
|
658
|
+
/** A Container application managed with a standard scheduling policy. */
|
|
659
|
+
interface StandardContainerConfig extends BaseContainerConfig {
|
|
660
|
+
/** The image to build or deploy. */
|
|
661
|
+
image: ContainerImage;
|
|
662
|
+
/**
|
|
663
|
+
* Maximum number of application instances.
|
|
664
|
+
*
|
|
665
|
+
* @default 20
|
|
666
|
+
*/
|
|
667
|
+
maxInstances?: number;
|
|
668
|
+
/**
|
|
669
|
+
* The instance type to be used for the Container.
|
|
670
|
+
* Select from one of the following named instance types:
|
|
671
|
+
*
|
|
672
|
+
* - lite: 1/16 vCPU, 256 MiB memory, and 2 GB disk
|
|
673
|
+
* - basic: 1/4 vCPU, 1 GiB memory, and 4 GB disk
|
|
674
|
+
* - standard-1: 1/2 vCPU, 4 GiB memory, and 8 GB disk
|
|
675
|
+
* - standard-2: 1 vCPU, 6 GiB memory, and 12 GB disk
|
|
676
|
+
* - standard-3: 2 vCPU, 8 GiB memory, and 16 GB disk
|
|
677
|
+
* - standard-4: 4 vCPU, 12 GiB memory, and 20 GB disk
|
|
678
|
+
*
|
|
679
|
+
* Customers on an enterprise plan have the additional option to set custom
|
|
680
|
+
* limits.
|
|
681
|
+
*
|
|
682
|
+
* @default "lite"
|
|
683
|
+
*/
|
|
684
|
+
instanceType?: "basic" | "lite" | "standard-1" | "standard-2" | "standard-3" | "standard-4" | {
|
|
685
|
+
/** @default 0.0625 (1/16 vCPU) */
|
|
686
|
+
vcpu?: number;
|
|
687
|
+
/** @default 256 MiB */
|
|
688
|
+
memoryMib?: number;
|
|
689
|
+
/** @default 2 GB */
|
|
690
|
+
diskMb?: number;
|
|
691
|
+
};
|
|
692
|
+
/**
|
|
693
|
+
* The scheduling policy of the application.
|
|
694
|
+
*
|
|
695
|
+
* @default "default"
|
|
696
|
+
*/
|
|
697
|
+
schedulingPolicy?: "default" | "regional";
|
|
698
|
+
ssh?: {
|
|
699
|
+
/**
|
|
700
|
+
* If enabled, users with write access to the Container application can
|
|
701
|
+
* connect to it over SSH.
|
|
702
|
+
*
|
|
703
|
+
* @default false
|
|
704
|
+
*/
|
|
705
|
+
enabled: boolean;
|
|
706
|
+
/**
|
|
707
|
+
* Port that the SSH service is running on.
|
|
708
|
+
*
|
|
709
|
+
* @default 22
|
|
710
|
+
*/
|
|
711
|
+
port?: number;
|
|
712
|
+
};
|
|
713
|
+
/** SSH public keys to put in the Container's authorized_keys file. */
|
|
714
|
+
authorizedKeys?: Array<{
|
|
715
|
+
name: string;
|
|
716
|
+
publicKey: string;
|
|
717
|
+
}>;
|
|
718
|
+
/** Scheduling constraints for Container placement. */
|
|
719
|
+
constraints?: {
|
|
720
|
+
/** Limit Container placement to specific geographic regions. */
|
|
721
|
+
regions?: Array<"ENAM" | "WNAM" | "EEUR" | "WEUR" | "APAC" | "SAM" | "ME" | "OC" | "AFR">;
|
|
722
|
+
/** Restrict Containers to compliance boundaries. */
|
|
723
|
+
jurisdiction?: "eu" | "fedramp";
|
|
724
|
+
};
|
|
725
|
+
rollout?: {
|
|
726
|
+
/**
|
|
727
|
+
* How a rollout should be created. It supports the following modes:
|
|
728
|
+
*
|
|
729
|
+
* - full-auto: The Container application will be rolled out fully
|
|
730
|
+
* automatically.
|
|
731
|
+
* - none: The Container application will not have a rollout or update.
|
|
732
|
+
* - full-manual: The Container application will be rolled out by manually
|
|
733
|
+
* progressing through the rollout steps.
|
|
734
|
+
*
|
|
735
|
+
* @default "full-auto"
|
|
736
|
+
* @hidden
|
|
737
|
+
*/
|
|
738
|
+
kind?: "full-auto" | "none" | "full-manual";
|
|
739
|
+
/**
|
|
740
|
+
* Configures what percentage of instances should be updated at each step of
|
|
741
|
+
* a rollout. You can specify this as a single number or an array of numbers.
|
|
742
|
+
*
|
|
743
|
+
* If this is a single number, each step will progress by that percentage.
|
|
744
|
+
* The options are 5, 10, 20, 25, 50, or 100.
|
|
745
|
+
*
|
|
746
|
+
* If this is an array, each step specifies the cumulative rollout progress.
|
|
747
|
+
* The final step must be 100.
|
|
748
|
+
*
|
|
749
|
+
* @default [10, 100]
|
|
750
|
+
*/
|
|
751
|
+
stepPercentage?: number | number[];
|
|
752
|
+
/**
|
|
753
|
+
* Configures the grace period, in seconds, for active instances before they
|
|
754
|
+
* are shut down during a rollout.
|
|
755
|
+
*
|
|
756
|
+
* @default 0
|
|
757
|
+
*/
|
|
758
|
+
activeGracePeriod?: number;
|
|
759
|
+
};
|
|
760
|
+
}
|
|
761
|
+
/** A Container application managed by a Durable Object. */
|
|
762
|
+
interface DurableObjectContainerConfig extends BaseContainerConfig {
|
|
763
|
+
schedulingPolicy: "durable-object";
|
|
764
|
+
/** Named images that the Durable Object can start. */
|
|
765
|
+
images?: Record<string, ContainerImage>;
|
|
766
|
+
}
|
|
767
|
+
/**
|
|
768
|
+
* Container application configuration. This is the input shape passed to
|
|
769
|
+
* `defineContainer` and is validated at runtime by `InputContainerSchema`.
|
|
770
|
+
*/
|
|
771
|
+
type ContainerConfig = DurableObjectContainerConfig | StandardContainerConfig;
|
|
574
772
|
/**
|
|
575
773
|
* Worker configuration. This is the input shape passed to
|
|
576
774
|
* [`defineWorker`](https://developers.cloudflare.com/workers/wrangler/configuration/).
|
|
@@ -1606,4 +1804,4 @@ declare const defineSettings: <const TInput extends ConfigInput<SettingsConfigIn
|
|
|
1606
1804
|
[x: string]: unknown;
|
|
1607
1805
|
} ? ConfigWithType<TInput, "settings"> : never;
|
|
1608
1806
|
//#endregion
|
|
1609
|
-
export {
|
|
1807
|
+
export { SettingsConfig as $, SecretsStoreSecretBinding as A, VersionMetadataBinding as B, MediaBinding$1 as C, InferMainModule as Ct, R2Binding as D, QueueBinding as E, TypedKvBinding as F, WorkerLoaderBinding as G, VpcServiceBinding as H, TypedPipelineBinding as I, bindings as J, WorkerReference as K, TypedQueueBinding as L, StreamBinding$1 as M, TextBinding as N, RateLimitBinding as O, TypedAiBinding as P, ContainerConfig as Q, UnsafeBinding as R, LogfwdrBinding as S, InferEnv as St, PipelineBinding as T, WebSearchBinding as U, VpcNetworkBinding as V, WorkerBinding as W, WorkerConfigInput as X, WorkerConfigExport as Y, defineWorker as Z, FlagshipBinding as _, ContainerConfigExport as _t, AiBinding as a, ScheduledTrigger as at, JsonBinding as b, ConfigContext as bt, AnalyticsEngineDatasetBinding as c, DurableObjectCreatedExport as ct, BindingDevOptions as d, DurableObjectRenamedExport as dt, WorkerConfig as et, Bindings as f, DurableObjectTransferredExport as ft, DurableObjectBinding as g, exports as gt, DispatchNamespaceBinding as h, WorkerEntrypointExportOptions as ht, AgentMemoryBinding as i, QueueConsumerTrigger as it, SendEmailBinding as j, SecretBinding as k, ArtifactsBinding as l, DurableObjectDeletedExport as lt, D1Binding as m, WorkerEntrypointExport as mt, SettingsConfigInput as n, EmailTrigger as nt, AiSearchBinding as o, Triggers as ot, BrowserBinding as p, Exports as pt, WorkflowBinding as q, defineSettings as r, FetchTrigger as rt, AiSearchNamespaceBinding as s, triggers as st, SettingsConfigExport as t, ConnectTrigger as tt, AssetsBinding as u, DurableObjectExpectingTransferExport as ut, HyperdriveBinding as v, ContainerConfigInput as vt, MtlsCertificateBinding as w, UnwrapConfig as wt, KvBinding as x, InferDurableNamespaces as xt, ImagesBinding$1 as y, defineContainer as yt, VectorizeBinding as z };
|
package/dist/public.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { $ as
|
|
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 };
|
|
1
|
+
import { $ as SettingsConfig, A as SecretsStoreSecretBinding, B as VersionMetadataBinding, C as MediaBinding, Ct as InferMainModule, 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 ContainerConfig, R as UnsafeBinding, S as LogfwdrBinding, St as InferEnv, 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 ContainerConfigExport, a as AiBinding, at as ScheduledTrigger, b as JsonBinding, bt as ConfigContext, c as AnalyticsEngineDatasetBinding, ct as DurableObjectCreatedExport, d as BindingDevOptions, dt as DurableObjectRenamedExport, et as WorkerConfig, f as Bindings, ft as DurableObjectTransferredExport, g as DurableObjectBinding, gt as exports, h as DispatchNamespaceBinding, ht as WorkerEntrypointExportOptions, i as AgentMemoryBinding, it as QueueConsumerTrigger, j as SendEmailBinding, k as SecretBinding, l as ArtifactsBinding, lt as DurableObjectDeletedExport, m as D1Binding, mt as WorkerEntrypointExport, n as SettingsConfigInput, nt as EmailTrigger, o as AiSearchBinding, ot as Triggers, p as BrowserBinding, pt as Exports, q as WorkflowBinding, r as defineSettings, rt as FetchTrigger, s as AiSearchNamespaceBinding, st as triggers, t as SettingsConfigExport, tt as ConnectTrigger, u as AssetsBinding, ut as DurableObjectExpectingTransferExport, v as HyperdriveBinding, vt as ContainerConfigInput, w as MtlsCertificateBinding, wt as UnwrapConfig, x as KvBinding, xt as InferDurableNamespaces, y as ImagesBinding, yt as defineContainer, z as VectorizeBinding } from "./public-CxIWEZqM.mjs";
|
|
2
|
+
export { AgentMemoryBinding, AiBinding, AiSearchBinding, AiSearchNamespaceBinding, AnalyticsEngineDatasetBinding, ArtifactsBinding, AssetsBinding, BindingDevOptions, Bindings, BrowserBinding, ConfigContext, ConnectTrigger, ContainerConfig, ContainerConfigExport, ContainerConfigInput, 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, defineContainer, defineSettings, defineWorker, exports, triggers };
|
package/dist/public.mjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { a as
|
|
1
|
+
import { a as triggers, i as exports, n as defineWorker, o as bindings, r as defineContainer, t as defineSettings } from "./public-BYCVISMH.mjs";
|
|
2
2
|
|
|
3
|
-
export { bindings, defineSettings, defineWorker, exports, triggers };
|
|
3
|
+
export { bindings, defineContainer, defineSettings, defineWorker, exports, triggers };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cloudflare/config",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.12.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.
|
|
34
|
+
"@cloudflare/workers-types": "^5.20260911.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.
|
|
40
|
+
"@cloudflare/workers-utils": "0.38.1"
|
|
41
41
|
},
|
|
42
42
|
"workers-sdk": {
|
|
43
43
|
"prerelease": true
|