@vinext/cloudflare 0.2.1 → 1.0.0-beta.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.
@@ -1,4 +1,5 @@
1
1
  //#region src/cache/kv-data-adapter.d.ts
2
+ declare const DEFAULT_KV_DATA_CACHE_BINDING = "VINEXT_KV_CACHE";
2
3
  /** Options accepted by {@link kvDataAdapter}, forwarded to the runtime factory. */
3
4
  type KvDataAdapterOptions = {
4
5
  /** KV namespace binding name on the Worker `env`. @default "VINEXT_KV_CACHE" */binding?: string; /** Namespace prefix for cache keys (isolates multiple apps in one namespace). */
@@ -24,4 +25,4 @@ declare function kvDataAdapter(options?: KvDataAdapterOptions): {
24
25
  options: KvDataAdapterOptions | undefined;
25
26
  };
26
27
  //#endregion
27
- export { KvDataAdapterOptions, kvDataAdapter };
28
+ export { DEFAULT_KV_DATA_CACHE_BINDING, KvDataAdapterOptions, kvDataAdapter };
@@ -1,5 +1,6 @@
1
1
  import { fileURLToPath } from "node:url";
2
2
  //#region src/cache/kv-data-adapter.ts
3
+ const DEFAULT_KV_DATA_CACHE_BINDING = "VINEXT_KV_CACHE";
3
4
  /**
4
5
  * Cloudflare KV data cache.
5
6
  *
@@ -21,4 +22,4 @@ function kvDataAdapter(options) {
21
22
  };
22
23
  }
23
24
  //#endregion
24
- export { kvDataAdapter };
25
+ export { DEFAULT_KV_DATA_CACHE_BINDING, kvDataAdapter };
@@ -0,0 +1,37 @@
1
+ import { PrerenderManifest, PrerenderedPathSelectionOptions } from "vinext/internal/server/prerender-manifest";
2
+
3
+ //#region src/cdn-warm.d.ts
4
+ type CdnWarmOptions = {
5
+ targetUrl: string;
6
+ paths: readonly string[];
7
+ headers?: HeadersInit;
8
+ concurrency?: number;
9
+ timeoutMs?: number;
10
+ retries?: number;
11
+ strict?: boolean;
12
+ fetchImpl?: typeof fetch;
13
+ };
14
+ declare const DEFAULT_CDN_WARM_TIMEOUT_MS = 5000;
15
+ type PrerenderCdnWarmOptions = Omit<CdnWarmOptions, "paths"> & {
16
+ root: string;
17
+ includeFallbackShells?: boolean;
18
+ };
19
+ type CdnWarmResult = {
20
+ total: number;
21
+ warmed: number;
22
+ failed: number;
23
+ failures: Array<{
24
+ path: string;
25
+ error: string;
26
+ }>;
27
+ };
28
+ declare function readPrerenderWarmPaths(root: string, options?: {
29
+ includeFallbackShells?: boolean;
30
+ strict?: boolean;
31
+ }): string[];
32
+ declare function getWarmPathsFromPrerenderManifest(manifest: PrerenderManifest, options?: PrerenderedPathSelectionOptions): string[];
33
+ declare function buildWarmupUrl(targetUrl: string, pathname: string): URL;
34
+ declare function warmCdnCache(options: CdnWarmOptions): Promise<CdnWarmResult>;
35
+ declare function warmCdnCacheFromPrerender(options: PrerenderCdnWarmOptions): Promise<CdnWarmResult>;
36
+ //#endregion
37
+ export { CdnWarmOptions, CdnWarmResult, DEFAULT_CDN_WARM_TIMEOUT_MS, PrerenderCdnWarmOptions, buildWarmupUrl, getWarmPathsFromPrerenderManifest, readPrerenderWarmPaths, warmCdnCache, warmCdnCacheFromPrerender };
@@ -0,0 +1,183 @@
1
+ import path from "node:path";
2
+ import fs from "node:fs";
3
+ import { PRERENDER_PATHS_MANIFEST } from "vinext/internal/build/prerender-paths";
4
+ import { getPrerenderedConcretePaths, readPrerenderManifest } from "vinext/internal/server/prerender-manifest";
5
+ //#region src/cdn-warm.ts
6
+ const DEFAULT_CDN_WARM_TIMEOUT_MS = 5e3;
7
+ function readBuiltBuildId(root) {
8
+ try {
9
+ const buildId = fs.readFileSync(path.join(root, "dist", "server", "BUILD_ID"), "utf-8").trim();
10
+ return buildId.length > 0 ? buildId : null;
11
+ } catch (error) {
12
+ if (error && typeof error === "object" && "code" in error && error.code === "ENOENT") return null;
13
+ throw error;
14
+ }
15
+ }
16
+ function readPrerenderPathManifest(manifestPath) {
17
+ if (!fs.existsSync(manifestPath)) return null;
18
+ try {
19
+ const parsed = JSON.parse(fs.readFileSync(manifestPath, "utf-8"));
20
+ if (!parsed || typeof parsed !== "object") return null;
21
+ const manifest = parsed;
22
+ if (!Array.isArray(manifest.paths)) return null;
23
+ return manifest;
24
+ } catch (error) {
25
+ console.warn(`[vinext] Failed to read prerender path manifest at ${manifestPath}:`, error);
26
+ return null;
27
+ }
28
+ }
29
+ function readPrerenderPathWarmPaths(root, options) {
30
+ const manifest = readPrerenderPathManifest(path.join(root, "dist", "server", PRERENDER_PATHS_MANIFEST));
31
+ if (!manifest) return null;
32
+ const builtBuildId = readBuiltBuildId(root);
33
+ if (!manifest.buildId || !builtBuildId || manifest.buildId !== builtBuildId) {
34
+ const message = "[vinext] CDN warmup skipped: prerender path manifest buildId does not match dist/server/BUILD_ID.";
35
+ if (options?.strict) throw new Error(message);
36
+ console.warn(message);
37
+ return [];
38
+ }
39
+ return manifest.paths.filter((pathname) => pathname.startsWith("/"));
40
+ }
41
+ function readPrerenderWarmPaths(root, options) {
42
+ const shouldPreferPrerenderManifest = options?.includeFallbackShells === true;
43
+ if (!shouldPreferPrerenderManifest) {
44
+ const pathManifestPaths = readPrerenderPathWarmPaths(root, options);
45
+ if (pathManifestPaths !== null) return pathManifestPaths;
46
+ }
47
+ const manifest = readPrerenderManifest(path.join(root, "dist", "server", "vinext-prerender.json"));
48
+ if (!manifest) {
49
+ if (shouldPreferPrerenderManifest) {
50
+ const pathManifestPaths = readPrerenderPathWarmPaths(root, options);
51
+ if (pathManifestPaths !== null) {
52
+ console.warn("[vinext] CDN warmup fallback shells requested, but prerender manifest not found; warming build-discovered paths only.");
53
+ return pathManifestPaths;
54
+ }
55
+ }
56
+ const message = "[vinext] CDN warmup skipped: prerender manifest not found.";
57
+ if (options?.strict) throw new Error(message);
58
+ return [];
59
+ }
60
+ const builtBuildId = readBuiltBuildId(root);
61
+ if (!manifest.buildId || !builtBuildId || manifest.buildId !== builtBuildId) {
62
+ const message = "[vinext] CDN warmup skipped: prerender manifest buildId does not match dist/server/BUILD_ID.";
63
+ if (options?.strict) throw new Error(message);
64
+ console.warn(message);
65
+ return [];
66
+ }
67
+ return getPrerenderedConcretePaths(manifest, options);
68
+ }
69
+ function getWarmPathsFromPrerenderManifest(manifest, options) {
70
+ return getPrerenderedConcretePaths(manifest, options);
71
+ }
72
+ function normalizeWarmPath(pathname) {
73
+ return pathname.startsWith("/") ? pathname : `/${pathname}`;
74
+ }
75
+ function buildWarmupUrl(targetUrl, pathname) {
76
+ return new URL(normalizeWarmPath(pathname), targetUrl.endsWith("/") ? targetUrl : `${targetUrl}/`);
77
+ }
78
+ function isRetryableStatus(status) {
79
+ return status === 408 || status === 429 || status >= 500;
80
+ }
81
+ async function fetchWithTimeout(fetchImpl, url, timeoutMs, headers) {
82
+ const controller = new AbortController();
83
+ const timer = setTimeout(() => controller.abort(), timeoutMs);
84
+ const requestHeaders = new Headers(headers);
85
+ requestHeaders.set("User-Agent", "vinext-cloudflare-cdn-warm");
86
+ try {
87
+ return await fetchImpl(url, {
88
+ method: "GET",
89
+ redirect: "follow",
90
+ headers: requestHeaders,
91
+ signal: controller.signal
92
+ });
93
+ } finally {
94
+ clearTimeout(timer);
95
+ }
96
+ }
97
+ async function warmOnePath(pathname, options) {
98
+ const url = buildWarmupUrl(options.targetUrl, pathname);
99
+ let lastError = "unknown error";
100
+ for (let attempt = 0; attempt <= options.retries; attempt++) try {
101
+ const response = await fetchWithTimeout(options.fetchImpl, url, options.timeoutMs, options.headers);
102
+ await response.arrayBuffer();
103
+ if (response.status < 400) return {
104
+ path: pathname,
105
+ ok: true
106
+ };
107
+ lastError = `HTTP ${response.status}`;
108
+ if (!isRetryableStatus(response.status)) break;
109
+ } catch (error) {
110
+ if (error instanceof DOMException && error.name === "AbortError") lastError = `timed out after ${options.timeoutMs}ms`;
111
+ else lastError = error instanceof Error ? error.message : String(error);
112
+ }
113
+ return {
114
+ path: pathname,
115
+ ok: false,
116
+ error: lastError
117
+ };
118
+ }
119
+ async function runWithConcurrency(items, concurrency, fn) {
120
+ const results = Array.from({ length: items.length });
121
+ let nextIndex = 0;
122
+ async function worker() {
123
+ while (nextIndex < items.length) {
124
+ const index = nextIndex++;
125
+ results[index] = await fn(items[index]);
126
+ }
127
+ }
128
+ if (items.length === 0) return results;
129
+ const workers = Array.from({ length: Math.min(concurrency, items.length) }, () => worker());
130
+ await Promise.all(workers);
131
+ return results;
132
+ }
133
+ async function warmCdnCache(options) {
134
+ const paths = options.paths;
135
+ const concurrency = Math.max(1, options.concurrency ?? 10);
136
+ const timeoutMs = Math.max(1, options.timeoutMs ?? 5e3);
137
+ const retries = Math.max(0, options.retries ?? 1);
138
+ const fetchImpl = options.fetchImpl ?? fetch;
139
+ if (paths.length === 0) return {
140
+ total: 0,
141
+ warmed: 0,
142
+ failed: 0,
143
+ failures: []
144
+ };
145
+ console.log(`\n Warming CDN cache for ${paths.length} build-discovered path(s)...`);
146
+ const results = await runWithConcurrency(paths, concurrency, (pathname) => warmOnePath(pathname, {
147
+ targetUrl: options.targetUrl,
148
+ timeoutMs,
149
+ retries,
150
+ fetchImpl,
151
+ headers: options.headers
152
+ }));
153
+ const failures = results.filter((result) => !result.ok).map(({ path, error }) => ({
154
+ path,
155
+ error
156
+ }));
157
+ const warmed = results.length - failures.length;
158
+ console.log(` CDN warmup: ${warmed}/${paths.length} path(s) warmed.`);
159
+ if (failures.length > 0) {
160
+ for (const failure of failures.slice(0, 5)) console.warn(` CDN warmup failed for ${failure.path}: ${failure.error}`);
161
+ if (failures.length > 5) console.warn(` CDN warmup: ${failures.length - 5} additional failure(s) omitted.`);
162
+ }
163
+ const result = {
164
+ total: paths.length,
165
+ warmed,
166
+ failed: failures.length,
167
+ failures
168
+ };
169
+ if (options.strict && failures.length > 0) throw new Error(`CDN warmup failed for ${failures.length}/${paths.length} path(s). First failure: ${failures[0].path}: ${failures[0].error}`);
170
+ return result;
171
+ }
172
+ async function warmCdnCacheFromPrerender(options) {
173
+ const paths = readPrerenderWarmPaths(options.root, {
174
+ includeFallbackShells: options.includeFallbackShells,
175
+ strict: options.strict
176
+ });
177
+ return warmCdnCache({
178
+ ...options,
179
+ paths
180
+ });
181
+ }
182
+ //#endregion
183
+ export { DEFAULT_CDN_WARM_TIMEOUT_MS, buildWarmupUrl, getWarmPathsFromPrerenderManifest, readPrerenderWarmPaths, warmCdnCache, warmCdnCacheFromPrerender };
package/dist/cli.js CHANGED
@@ -43,6 +43,12 @@ async function deployCommand() {
43
43
  name: parsed.name,
44
44
  prerenderAll: parsed.prerenderAll,
45
45
  prerenderConcurrency: parsed.prerenderConcurrency,
46
+ warmCdnCache: parsed.warmCdnCache,
47
+ warmCdnConcurrency: parsed.warmCdnConcurrency,
48
+ warmCdnTimeout: parsed.warmCdnTimeout,
49
+ warmCdnRetries: parsed.warmCdnRetries,
50
+ warmCdnStrict: parsed.warmCdnStrict,
51
+ warmCdnIncludeFallbacks: parsed.warmCdnIncludeFallbacks,
46
52
  experimentalTPR: parsed.experimentalTPR,
47
53
  tprCoverage: parsed.tprCoverage,
48
54
  tprLimit: parsed.tprLimit,
@@ -60,7 +66,7 @@ if (command === "--help" || command === "-h" || !command) {
60
66
  switch (command) {
61
67
  case "deploy":
62
68
  deployCommand().catch((error) => {
63
- console.error(error);
69
+ console.error(error instanceof Error ? error.message : String(error));
64
70
  process.exit(1);
65
71
  });
66
72
  break;
@@ -1,3 +1,5 @@
1
+ import { VinextCacheConfig } from "vinext/internal/cache-adapters";
2
+
1
3
  //#region src/deploy-config.d.ts
2
4
  /**
3
5
  * Check whether an existing vite.config file already imports and uses the
@@ -17,6 +19,12 @@ declare function viteConfigHasCloudflarePlugin(root: string): boolean;
17
19
  * blocked on a false negative.
18
20
  */
19
21
  declare function viteConfigHasCacheAdapter(root: string): boolean;
22
+ type ResolvedKvDataAdapterConfig = {
23
+ binding: string;
24
+ appPrefix?: string;
25
+ ttlSeconds?: number;
26
+ };
27
+ declare function resolveKvDataAdapterConfig(cache: VinextCacheConfig | null | undefined): ResolvedKvDataAdapterConfig | null;
20
28
  declare function viteConfigHasImageAdapter(root: string): boolean;
21
29
  /**
22
30
  * Detect whether an existing user-authored Worker entry wires up a cache
@@ -44,4 +52,4 @@ declare function formatMissingCacheAdapterError(options: {
44
52
  }): string;
45
53
  declare function formatImageOptimizationHint(): string;
46
54
  //#endregion
47
- export { formatImageOptimizationHint, formatMissingCacheAdapterError, viteConfigHasCacheAdapter, viteConfigHasCloudflarePlugin, viteConfigHasImageAdapter, workerEntryHasCacheHandler };
55
+ export { ResolvedKvDataAdapterConfig, formatImageOptimizationHint, formatMissingCacheAdapterError, resolveKvDataAdapterConfig, viteConfigHasCacheAdapter, viteConfigHasCloudflarePlugin, viteConfigHasImageAdapter, workerEntryHasCacheHandler };
@@ -1,5 +1,6 @@
1
- import fs from "node:fs";
1
+ import { DEFAULT_KV_DATA_CACHE_BINDING } from "./cache/kv-data-adapter.js";
2
2
  import path from "node:path";
3
+ import fs from "node:fs";
3
4
  import { findViteConfigPath } from "vinext/internal/utils/project";
4
5
  //#region src/deploy-config.ts
5
6
  function escapeRegExp(value) {
@@ -86,6 +87,24 @@ function viteConfigHasCacheAdapter(root) {
86
87
  if (!block) return false;
87
88
  return cacheFieldAssigned(block, "cdn") || cacheFieldAssigned(block, "data");
88
89
  }
90
+ function isCloudflareKvDataAdapterPath(adapter) {
91
+ const normalized = adapter.replace(/\\/g, "/");
92
+ return normalized === "@vinext/cloudflare/cache/kv-data-adapter.runtime" || normalized === "@vinext/cloudflare/cache/kv-data-adapter.runtime.js" || normalized.endsWith("/cache/kv-data-adapter.runtime.js");
93
+ }
94
+ function readPositiveNumberOption(options, field) {
95
+ const value = options?.[field];
96
+ return typeof value === "number" && Number.isFinite(value) && value > 0 ? value : void 0;
97
+ }
98
+ function resolveKvDataAdapterConfig(cache) {
99
+ const data = cache?.data;
100
+ if (!data?.adapter || !isCloudflareKvDataAdapterPath(data.adapter)) return null;
101
+ const options = data.options;
102
+ return {
103
+ binding: typeof options?.binding === "string" && options.binding.length > 0 ? options.binding : DEFAULT_KV_DATA_CACHE_BINDING,
104
+ ...typeof options?.appPrefix === "string" && options.appPrefix.length > 0 ? { appPrefix: options.appPrefix } : {},
105
+ ...readPositiveNumberOption(options, "ttlSeconds") !== void 0 ? { ttlSeconds: readPositiveNumberOption(options, "ttlSeconds") } : {}
106
+ };
107
+ }
89
108
  function viteConfigHasImageAdapter(root) {
90
109
  const configPath = findViteConfigPath(root);
91
110
  if (!configPath) return true;
@@ -147,4 +166,4 @@ function formatImageOptimizationHint() {
147
166
  return " [vinext] next/image is served unoptimized. To enable edge image\n optimization via Cloudflare Images, run:\n\n vinext init --platform=cloudflare --image-optimization=cloudflare-images\n\n This adds the imagesOptimizer() option to your Vite config and the matching\n IMAGES binding to your Wrangler config without replacing existing settings.";
148
167
  }
149
168
  //#endregion
150
- export { formatImageOptimizationHint, formatMissingCacheAdapterError, viteConfigHasCacheAdapter, viteConfigHasCloudflarePlugin, viteConfigHasImageAdapter, workerEntryHasCacheHandler };
169
+ export { formatImageOptimizationHint, formatMissingCacheAdapterError, resolveKvDataAdapterConfig, viteConfigHasCacheAdapter, viteConfigHasCloudflarePlugin, viteConfigHasImageAdapter, workerEntryHasCacheHandler };
@@ -15,12 +15,23 @@ function formatDeployHelp() {
15
15
  --preview Deploy to preview environment (same as --env preview)
16
16
  --env <name> Deploy using wrangler env.<name>
17
17
  --name <name> Custom Worker name (default: from package.json)
18
+ --config <path> Wrangler config path (default: wrangler.jsonc/json/toml)
18
19
  --skip-build Skip the build step (use existing dist/)
19
20
  --dry-run Validate setup without building or deploying
20
21
  --prerender-all Pre-render discovered routes after building (future
21
22
  releases will auto-populate the remote cache)
22
23
  --prerender-concurrency <count>
23
24
  Maximum number of routes to pre-render in parallel
25
+ --experimental-warm-cdn-cache
26
+ Upload a Worker version, warm build-discovered paths
27
+ through the production URL, then promote it (experimental)
28
+ --warm-cdn-concurrency <count>
29
+ Maximum number of CDN warmup requests in parallel
30
+ --warm-cdn-timeout <ms> Per-request CDN warmup timeout (default: 5000)
31
+ --warm-cdn-retries <n> Retries for transient CDN warmup failures (default: 1)
32
+ --warm-cdn-strict Fail deploy when any CDN warmup request fails
33
+ --warm-cdn-include-fallbacks
34
+ Also warm PPR fallback-shell placeholder paths
24
35
  -h, --help Show this help
25
36
 
26
37
  Experimental:
@@ -35,14 +46,19 @@ function formatDeployHelp() {
35
46
  a custom domain (zone analytics are unavailable on *.workers.dev) and the
36
47
  CLOUDFLARE_API_TOKEN environment variable with Zone.Analytics read permission.
37
48
 
49
+ CDN warmup requests populate the edge cache only in the Cloudflare data centers
50
+ reached by the warmup run; they do not globally prefill every edge location.
51
+
38
52
  Examples:
39
53
  npx @vinext/cloudflare deploy Build and deploy to production
40
54
  vpx @vinext/cloudflare deploy Build and deploy with Vite+
41
55
  vp exec vinext-cloudflare deploy Run the locally installed Vite+ bin
42
56
  vinext-cloudflare deploy --preview Deploy to a preview URL
43
57
  vinext-cloudflare deploy --env staging Deploy using wrangler env.staging
58
+ vinext-cloudflare deploy --config dist/server/wrangler.json Deploy using a generated Wrangler config
44
59
  vinext-cloudflare deploy --dry-run Validate setup without building or deploying
45
60
  vinext-cloudflare deploy --name my-app Deploy with a custom Worker name
61
+ vinext-cloudflare deploy --experimental-warm-cdn-cache Warm build-discovered paths during version deploy (experimental)
46
62
  vinext-cloudflare deploy --experimental-tpr Enable TPR during deploy
47
63
  vinext-cloudflare deploy --experimental-tpr --tpr-coverage 95 Cover 95% of traffic
48
64
  vinext-cloudflare deploy --experimental-tpr --tpr-limit 500 Cap at 500 pages
package/dist/deploy.d.ts CHANGED
@@ -1,15 +1,25 @@
1
- import { execFileSync } from "node:child_process";
1
+ import { parseWranglerConfig } from "./tpr.js";
2
+ import { WranglerDeploymentStatus, WranglerVersionTraffic } from "./version-deploy.js";
3
+ import { KVBulkPair } from "./prerender-kv-populate.js";
4
+ import { spawn } from "node:child_process";
2
5
 
3
6
  //#region src/deploy.d.ts
4
7
  type DeployOptions = {
5
8
  /** Project root directory */root: string; /** Deploy to preview environment (default: production) */
6
9
  preview?: boolean; /** Wrangler environment name from wrangler.jsonc env.<name> */
7
10
  env?: string; /** Custom project name for the Worker */
8
- name?: string; /** Skip the build step (assume already built) */
11
+ name?: string; /** Wrangler config path, relative to root unless absolute */
12
+ config?: string; /** Skip the build step (assume already built) */
9
13
  skipBuild?: boolean; /** Dry run — validate setup but don't build or deploy */
10
14
  dryRun?: boolean; /** Pre-render all discovered routes into the dist output after building */
11
15
  prerenderAll?: boolean; /** Maximum number of routes to prerender in parallel */
12
- prerenderConcurrency?: number; /** Enable experimental TPR (Traffic-aware Pre-Rendering) */
16
+ prerenderConcurrency?: number; /** Warm Cloudflare's CDN cache by requesting build-discovered paths for the uploaded version */
17
+ warmCdnCache?: boolean; /** Maximum number of CDN warmup requests to issue in parallel */
18
+ warmCdnConcurrency?: number; /** Per-request CDN warmup timeout in milliseconds */
19
+ warmCdnTimeout?: number; /** Number of CDN warmup retries for transient failures */
20
+ warmCdnRetries?: number; /** Fail deployment if any CDN warmup request fails */
21
+ warmCdnStrict?: boolean; /** Include PPR fallback-shell placeholder paths during CDN warmup */
22
+ warmCdnIncludeFallbacks?: boolean; /** Enable experimental TPR (Traffic-aware Pre-Rendering) */
13
23
  experimentalTPR?: boolean; /** TPR: traffic coverage percentage target (0–100, default: 90) */
14
24
  tprCoverage?: number; /** TPR: hard cap on number of pages to pre-render (default: 1000) */
15
25
  tprLimit?: number; /** TPR: analytics lookback window in hours (default: 24) */
@@ -20,10 +30,17 @@ declare function parseDeployArgs(args: string[]): {
20
30
  preview: boolean;
21
31
  env: string | undefined;
22
32
  name: string | undefined;
33
+ config: string | undefined;
23
34
  skipBuild: boolean;
24
35
  dryRun: boolean;
25
36
  prerenderAll: boolean;
26
37
  prerenderConcurrency: number | undefined;
38
+ warmCdnCache: boolean;
39
+ warmCdnConcurrency: number | undefined;
40
+ warmCdnTimeout: number | undefined;
41
+ warmCdnRetries: number | undefined;
42
+ warmCdnStrict: boolean;
43
+ warmCdnIncludeFallbacks: boolean;
27
44
  experimentalTPR: boolean;
28
45
  tprCoverage: number | undefined;
29
46
  tprLimit: number | undefined;
@@ -46,8 +63,17 @@ type WranglerDeployArgs = {
46
63
  args: string[];
47
64
  env: string | undefined;
48
65
  };
66
+ type WranglerKVBulkPutArgs = {
67
+ args: string[];
68
+ env: string | undefined;
69
+ };
49
70
  declare function validateWranglerEnvName(env: string): string;
50
- declare function buildWranglerDeployArgs(options: Pick<DeployOptions, "preview" | "env">): WranglerDeployArgs;
71
+ declare function buildWranglerDeployArgs(options: Pick<DeployOptions, "preview" | "env" | "name" | "config">): WranglerDeployArgs;
72
+ declare function buildWranglerKVBulkPutArgs(options: {
73
+ binding: string;
74
+ env?: string;
75
+ filePath: string;
76
+ }): WranglerKVBulkPutArgs;
51
77
  /**
52
78
  * Resolve Wrangler's JavaScript CLI entrypoint in node_modules.
53
79
  *
@@ -59,12 +85,25 @@ declare function buildNodeCliInvocation(scriptPath: string, args: string[], node
59
85
  file: string;
60
86
  args: string[];
61
87
  };
62
- declare function buildWranglerInvocation(root: string, options: Pick<DeployOptions, "preview" | "env">, nodeExecutable?: string): {
88
+ declare function buildWranglerInvocation(root: string, options: Pick<DeployOptions, "preview" | "env" | "name" | "config">, nodeExecutable?: string): {
63
89
  file: string;
64
90
  args: string[];
65
91
  env: string | undefined;
66
92
  };
67
- declare function runWranglerDeploy(root: string, options: Pick<DeployOptions, "preview" | "env">, execute?: typeof execFileSync): string;
93
+ declare function runWranglerKVBulkPut(root: string, options: {
94
+ binding: string;
95
+ env?: string;
96
+ pairs: KVBulkPair[];
97
+ tempDir?: string;
98
+ }, execute?: typeof spawn, nodeExecutable?: string): Promise<void>;
99
+ declare function runWranglerDeploy(root: string, options: Pick<DeployOptions, "preview" | "env" | "name" | "config">, execute?: typeof spawn): Promise<string>;
100
+ declare function deployWithCdnWarmup(root: string, paths: readonly string[], options: Pick<DeployOptions, "preview" | "env" | "name" | "config" | "warmCdnConcurrency" | "warmCdnTimeout" | "warmCdnRetries" | "warmCdnStrict">): Promise<string>;
101
+ declare function resolveCdnWarmupTargetUrl(root: string, deployedUrl: string | null): string | null;
102
+ declare function resolveCdnWarmupTargetUrl(root: string, deployedUrl: string | null, options: Pick<DeployOptions, "preview" | "env" | "config">): string | null;
103
+ declare function getZeroPercentStagingTraffic(deployment: WranglerDeploymentStatus | null, versionId: string): WranglerVersionTraffic[] | null;
104
+ type ParsedWranglerConfig = NonNullable<ReturnType<typeof parseWranglerConfig>>;
105
+ declare function resolveWorkerNameForVersionOverride(config: ParsedWranglerConfig | null, options: Pick<DeployOptions, "preview" | "env" | "name">): string | undefined;
106
+ declare function buildVersionOverrideHeaders(workerName: string | undefined, versionId: string): HeadersInit | undefined;
68
107
  declare function deploy(options: DeployOptions): Promise<void>;
69
108
  //#endregion
70
- export { DeployOptions, buildNodeCliInvocation, buildWranglerDeployArgs, buildWranglerInvocation, deploy, parseDeployArgs, resolveWranglerBin, runWranglerDeploy, validateWranglerEnvName, withCloudflareEnv };
109
+ export { DeployOptions, buildNodeCliInvocation, buildVersionOverrideHeaders, buildWranglerDeployArgs, buildWranglerInvocation, buildWranglerKVBulkPutArgs, deploy, deployWithCdnWarmup, getZeroPercentStagingTraffic, parseDeployArgs, resolveCdnWarmupTargetUrl, resolveWorkerNameForVersionOverride, resolveWranglerBin, runWranglerDeploy, runWranglerKVBulkPut, validateWranglerEnvName, withCloudflareEnv };