@cloudflare/workers-utils 0.22.0 → 0.23.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/browser.d.mts +6 -3
- package/dist/browser.mjs +1 -2
- package/dist/{chunk-AKFE3ND4.mjs → chunk-J6D57QVQ.mjs} +4 -42
- package/dist/{chunk-GMTGAG26.mjs → chunk-ULVYGN52.mjs} +8 -2
- package/dist/{config-CXobNAeT.d.mts → config-BT23LDfr.d.mts} +28 -4
- package/dist/index.d.mts +115 -7
- package/dist/index.mjs +461 -21
- package/dist/metafile-esm.json +1 -1
- package/dist/test-helpers/index.d.mts +1 -1
- package/dist/test-helpers/index.mjs +1 -2
- package/package.json +8 -8
- package/dist/chunk-OZQVB3L3.mjs +0 -8
package/dist/browser.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { T as TailConsumer, az as WorkerMetadata, R as RawConfig } from './config-
|
|
1
|
+
import { T as TailConsumer, az as WorkerMetadata, R as RawConfig } from './config-BT23LDfr.mjs';
|
|
2
2
|
import { AssetConfig } from '@cloudflare/workers-shared';
|
|
3
3
|
import { Cloudflare } from 'cloudflare';
|
|
4
4
|
|
|
@@ -34,9 +34,12 @@ interface APIWorkerConfig {
|
|
|
34
34
|
};
|
|
35
35
|
}
|
|
36
36
|
/**
|
|
37
|
-
* Given
|
|
37
|
+
* Given information about a Worker,
|
|
38
38
|
* construct a Wrangler config file for the application.
|
|
39
|
+
*
|
|
40
|
+
* @param config - The Worker configuration sourced from the Cloudflare API
|
|
41
|
+
* @returns A Wrangler-compatible raw config object
|
|
39
42
|
*/
|
|
40
|
-
declare function constructWranglerConfig(
|
|
43
|
+
declare function constructWranglerConfig(config: APIWorkerConfig): RawConfig;
|
|
41
44
|
|
|
42
45
|
export { constructWranglerConfig };
|
package/dist/browser.mjs
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { ENVIRONMENT_TAG_PREFIX, SERVICE_TAG_PREFIX } from './chunk-OZQVB3L3.mjs';
|
|
2
1
|
import { __name } from './chunk-DCOBXSFB.mjs';
|
|
3
2
|
import assert from 'node:assert';
|
|
4
3
|
|
|
@@ -38,8 +37,7 @@ function mapWorkerMetadataBindings(bindings) {
|
|
|
38
37
|
{
|
|
39
38
|
configObj.vars = {
|
|
40
39
|
...configObj.vars ?? {},
|
|
41
|
-
name: binding.
|
|
42
|
-
json: binding.json
|
|
40
|
+
[binding.name]: binding.json
|
|
43
41
|
};
|
|
44
42
|
}
|
|
45
43
|
break;
|
|
@@ -300,9 +298,9 @@ function mapWorkerMetadataBindings(bindings) {
|
|
|
300
298
|
}
|
|
301
299
|
];
|
|
302
300
|
break;
|
|
303
|
-
case "
|
|
301
|
+
case "websearch":
|
|
304
302
|
{
|
|
305
|
-
configObj.
|
|
303
|
+
configObj.websearch = {
|
|
306
304
|
binding: binding.name
|
|
307
305
|
};
|
|
308
306
|
}
|
|
@@ -437,7 +435,7 @@ function mapWorkerMetadataBindings(bindings) {
|
|
|
437
435
|
__name(mapWorkerMetadataBindings, "mapWorkerMetadataBindings");
|
|
438
436
|
|
|
439
437
|
// src/construct-wrangler-config.ts
|
|
440
|
-
function
|
|
438
|
+
function constructWranglerConfig(config) {
|
|
441
439
|
const mappedBindings = mapWorkerMetadataBindings(config.bindings);
|
|
442
440
|
const durableObjectClassNames = config.bindings.filter(
|
|
443
441
|
(binding) => binding.type === "durable_object_namespace" && binding.script_name === config.name
|
|
@@ -485,42 +483,6 @@ function convertWorkerToWranglerConfig(config) {
|
|
|
485
483
|
...mappedBindings
|
|
486
484
|
};
|
|
487
485
|
}
|
|
488
|
-
__name(convertWorkerToWranglerConfig, "convertWorkerToWranglerConfig");
|
|
489
|
-
function constructWranglerConfig(workerOrWorkers) {
|
|
490
|
-
let workers;
|
|
491
|
-
if (Array.isArray(workerOrWorkers)) {
|
|
492
|
-
workers = workerOrWorkers;
|
|
493
|
-
} else {
|
|
494
|
-
workers = [workerOrWorkers];
|
|
495
|
-
}
|
|
496
|
-
const topLevelEnv = workers.find(
|
|
497
|
-
(w) => !w.tags?.some((t) => t.startsWith(ENVIRONMENT_TAG_PREFIX))
|
|
498
|
-
);
|
|
499
|
-
const workerName = topLevelEnv?.name ?? workers[0].name;
|
|
500
|
-
const entrypoint = topLevelEnv?.entrypoint ?? workers[0].entrypoint;
|
|
501
|
-
let combinedConfig;
|
|
502
|
-
if (topLevelEnv) {
|
|
503
|
-
combinedConfig = convertWorkerToWranglerConfig(topLevelEnv);
|
|
504
|
-
} else {
|
|
505
|
-
combinedConfig = {
|
|
506
|
-
name: workerName,
|
|
507
|
-
main: entrypoint
|
|
508
|
-
};
|
|
509
|
-
}
|
|
510
|
-
for (const env of workers) {
|
|
511
|
-
const serviceTag = env.tags?.find(
|
|
512
|
-
(t) => t === `${SERVICE_TAG_PREFIX}${workerName}`
|
|
513
|
-
);
|
|
514
|
-
const envTag = env.tags?.find((t) => t.startsWith(ENVIRONMENT_TAG_PREFIX));
|
|
515
|
-
if (serviceTag !== `${SERVICE_TAG_PREFIX}${workerName}` || envTag === void 0) {
|
|
516
|
-
continue;
|
|
517
|
-
}
|
|
518
|
-
const [_, envName] = envTag.split("=");
|
|
519
|
-
combinedConfig.env ??= {};
|
|
520
|
-
combinedConfig.env[envName] = convertWorkerToWranglerConfig(env);
|
|
521
|
-
}
|
|
522
|
-
return combinedConfig;
|
|
523
|
-
}
|
|
524
486
|
__name(constructWranglerConfig, "constructWranglerConfig");
|
|
525
487
|
|
|
526
488
|
export { assertNever, constructWranglerConfig, getTodaysCompatDate, isCompatDate, mapWorkerMetadataBindings };
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { PATH_TO_DEPLOY_CONFIG } from './chunk-OZQVB3L3.mjs';
|
|
2
1
|
import { __name } from './chunk-DCOBXSFB.mjs';
|
|
3
2
|
import fs, { readFileSync as readFileSync$1, statSync, existsSync } from 'node:fs';
|
|
4
3
|
import path, { resolve, isAbsolute, dirname, join } from 'node:path';
|
|
@@ -2652,6 +2651,13 @@ function removeBOMAndValidate(buffer, file2) {
|
|
|
2652
2651
|
return content;
|
|
2653
2652
|
}
|
|
2654
2653
|
__name(removeBOMAndValidate, "removeBOMAndValidate");
|
|
2654
|
+
|
|
2655
|
+
// src/constants.ts
|
|
2656
|
+
var INHERIT_SYMBOL = Symbol.for("inherit_binding");
|
|
2657
|
+
var SERVICE_TAG_PREFIX = "cf:service=";
|
|
2658
|
+
var ENVIRONMENT_TAG_PREFIX = "cf:environment=";
|
|
2659
|
+
var PATH_TO_DEPLOY_CONFIG = ".wrangler/deploy/config.json";
|
|
2660
|
+
var JSON_CONFIG_FORMATS = ["json", "jsonc"];
|
|
2655
2661
|
function absolute(input, root) {
|
|
2656
2662
|
return isAbsolute(input) ? input : resolve(root || ".", input);
|
|
2657
2663
|
}
|
|
@@ -3179,4 +3185,4 @@ smol-toml/dist/index.js:
|
|
|
3179
3185
|
*)
|
|
3180
3186
|
*/
|
|
3181
3187
|
|
|
3182
|
-
export { APIError, CommandLineArgsError, DeprecationError, FatalError, JsonFriendlyFatalError, MissingConfigError, ParseError, UserError, applyEdits, configFileName, configFormat, createFatalError, dedent, dist_default, experimental_readRawConfig, findWranglerConfig, format2 as format, formatConfigSnippet, indexLocation, isDirectory, isRedirectedConfig, isRedirectedRawConfig, modify, parseByteSize, parseHumanDuration, parseJSON, parseJSONC, parseNonHyphenedUuid, parsePackageJSON, parseTOML, readFileSync, readFileSyncToBuffer, removeDir, removeDirSync, resolveWranglerConfigPath, searchLocation };
|
|
3188
|
+
export { APIError, CommandLineArgsError, DeprecationError, ENVIRONMENT_TAG_PREFIX, FatalError, INHERIT_SYMBOL, JSON_CONFIG_FORMATS, JsonFriendlyFatalError, MissingConfigError, PATH_TO_DEPLOY_CONFIG, ParseError, SERVICE_TAG_PREFIX, UserError, applyEdits, configFileName, configFormat, createFatalError, dedent, dist_default, experimental_readRawConfig, findWranglerConfig, format2 as format, formatConfigSnippet, indexLocation, isDirectory, isRedirectedConfig, isRedirectedRawConfig, modify, parseByteSize, parseHumanDuration, parseJSON, parseJSONC, parseNonHyphenedUuid, parsePackageJSON, parseTOML, readFileSync, readFileSyncToBuffer, removeDir, removeDirSync, resolveWranglerConfigPath, searchLocation };
|
|
@@ -198,6 +198,7 @@ interface CfD1Database {
|
|
|
198
198
|
database_internal_env?: string;
|
|
199
199
|
migrations_table?: string;
|
|
200
200
|
migrations_dir?: string;
|
|
201
|
+
migrations_pattern?: string;
|
|
201
202
|
remote?: boolean;
|
|
202
203
|
raw?: boolean;
|
|
203
204
|
}
|
|
@@ -526,7 +527,7 @@ type WorkerMetadataBinding = {
|
|
|
526
527
|
name: string;
|
|
527
528
|
instance_name: string;
|
|
528
529
|
} | {
|
|
529
|
-
type: "
|
|
530
|
+
type: "websearch";
|
|
530
531
|
name: string;
|
|
531
532
|
} | {
|
|
532
533
|
type: "agent_memory";
|
|
@@ -858,7 +859,7 @@ type Binding = {
|
|
|
858
859
|
} & BindingOmit<CfAISearchNamespace>) | ({
|
|
859
860
|
type: "ai_search";
|
|
860
861
|
} & BindingOmit<CfAISearch>) | ({
|
|
861
|
-
type: "
|
|
862
|
+
type: "websearch";
|
|
862
863
|
} & BindingOmit<CfWebSearch>) | ({
|
|
863
864
|
type: "agent_memory";
|
|
864
865
|
} & BindingOmit<CfAgentMemory>) | ({
|
|
@@ -927,6 +928,14 @@ type Entry = {
|
|
|
927
928
|
exports: string[];
|
|
928
929
|
};
|
|
929
930
|
|
|
931
|
+
/**
|
|
932
|
+
* Wrangler configuration types. The JSDoc on these fields is also the source
|
|
933
|
+
* of truth for the equivalent fields in `@cloudflare/config`
|
|
934
|
+
* (`packages/config/src/types.ts` — `UserConfig` — and the binding option
|
|
935
|
+
* interfaces in `packages/config/src/config.ts`). When editing prose here,
|
|
936
|
+
* mirror the changes there.
|
|
937
|
+
*/
|
|
938
|
+
|
|
930
939
|
/**
|
|
931
940
|
* The `Environment` interface declares all the configuration fields that
|
|
932
941
|
* can be specified for an environment.
|
|
@@ -1814,6 +1823,21 @@ interface EnvironmentNonInheritable {
|
|
|
1814
1823
|
migrations_table?: string;
|
|
1815
1824
|
/** The path to the directory of migrations for this D1 database (defaults to './migrations'). */
|
|
1816
1825
|
migrations_dir?: string;
|
|
1826
|
+
/**
|
|
1827
|
+
* A glob pattern (relative to the Wrangler config file) used to discover
|
|
1828
|
+
* migration files for this D1 database. Defaults to `${migrations_dir}/*.sql`
|
|
1829
|
+
* if not specified.
|
|
1830
|
+
*
|
|
1831
|
+
* Use this to opt in to nested layouts such as `migrations/*\/migration.sql`
|
|
1832
|
+
* (as produced by some ORMs).
|
|
1833
|
+
*
|
|
1834
|
+
* When `migrations_pattern` is set, `migrations_dir` must also be set, and
|
|
1835
|
+
* `migrations_pattern` must start with `${migrations_dir}/`. This keeps the
|
|
1836
|
+
* relationship between the two settings explicit and lets Wrangler record
|
|
1837
|
+
* each migration's name in the migrations table as a path relative to
|
|
1838
|
+
* `migrations_dir`.
|
|
1839
|
+
*/
|
|
1840
|
+
migrations_pattern?: string;
|
|
1817
1841
|
/** Internal use only. */
|
|
1818
1842
|
database_internal_env?: string;
|
|
1819
1843
|
/** Whether the D1 database should be remote or not in local development */
|
|
@@ -1902,7 +1926,7 @@ interface EnvironmentNonInheritable {
|
|
|
1902
1926
|
* @default {}
|
|
1903
1927
|
* @nonInheritable
|
|
1904
1928
|
*/
|
|
1905
|
-
|
|
1929
|
+
websearch: {
|
|
1906
1930
|
/** The binding name used to refer to Web Search in the Worker. */
|
|
1907
1931
|
binding: string;
|
|
1908
1932
|
/** Whether the Web Search binding should be remote or not in local development */
|
|
@@ -2699,4 +2723,4 @@ interface EnvironmentMap {
|
|
|
2699
2723
|
}
|
|
2700
2724
|
declare const defaultWranglerConfig: Config;
|
|
2701
2725
|
|
|
2702
|
-
export { type CfVectorize as $, type Assets as A, type Binding as B, type ComputedFields as C, type DurableObjectMigration as D, type Environment as E, type CfWasmModuleBindings as F, type CfTextBlobBindings as G, type CfBrowserBinding as H, type CfAIBinding as I, type CfImagesBinding as J, type CfMediaBinding as K, type CfStreamBinding as L, type CfVersionMetadataBinding as M, type CfDataBlobBindings as N, type Observability as O, type PreviewsConfig as P, type CfDurableObject as Q, type RawConfig as R, type StreamingTailConsumer as S, type TailConsumer as T, type UserLimits as U, type CfWorkflow as V, type WorkerMetadataBinding as W, type CfQueue as X, type CfR2Bucket as Y, type ZoneIdRoute as Z, type CfD1Database as _, type RedirectedRawConfig as a, type CfAISearchNamespace as a0, type CfAISearch as a1, type CfWebSearch as a2, type CfAgentMemory as a3, type CfSecretsStoreSecrets as a4, type CfArtifacts as a5, type CfHelloWorld as a6, type CfFlagship as a7, type CfWorkerLoader as a8, type CfRateLimit as a9, type ServiceMetadataRes as aA, type ServiceFetch as aB, type File as aC, type BinaryFile as aD, type Trigger as aE, type Entry as aF, INHERIT_SYMBOL as aG, SERVICE_TAG_PREFIX as aH, ENVIRONMENT_TAG_PREFIX as aI, PATH_TO_DEPLOY_CONFIG as aJ, JSON_CONFIG_FORMATS as aK, type CfHyperdrive as aa, type CfService as ab, type CfVpcService as ac, type CfVpcNetwork as ad, type CfAnalyticsEngineDataset as ae, type CfDispatchNamespace as af, type CfMTlsCertificate as ag, type CfLogfwdr as ah, type CfLogfwdrBinding as ai, type CfAssetsBinding as aj, type CfPipeline as ak, type CfUnsafeBinding as al, type CfCapnp as am, type CfUnsafe as an, type CfDurableObjectMigrations as ao, type CfPlacement as ap, type CfTailConsumer as aq, type CfUserLimits as ar, type CfWorkerInit as as, type CfWorkerContext as at, type CfWorkerSourceMap as au, type Json as av, type AssetConfigMetadata as aw, type AssetsOptions as ax, type LegacyAssetPaths as ay, type WorkerMetadata as az, type Config as b, type
|
|
2726
|
+
export { type CfVectorize as $, type Assets as A, type Binding as B, type ComputedFields as C, type DurableObjectMigration as D, type Environment as E, type CfWasmModuleBindings as F, type CfTextBlobBindings as G, type CfBrowserBinding as H, type CfAIBinding as I, type CfImagesBinding as J, type CfMediaBinding as K, type CfStreamBinding as L, type CfVersionMetadataBinding as M, type CfDataBlobBindings as N, type Observability as O, type PreviewsConfig as P, type CfDurableObject as Q, type RawConfig as R, type StreamingTailConsumer as S, type TailConsumer as T, type UserLimits as U, type CfWorkflow as V, type WorkerMetadataBinding as W, type CfQueue as X, type CfR2Bucket as Y, type ZoneIdRoute as Z, type CfD1Database as _, type RedirectedRawConfig as a, type CfAISearchNamespace as a0, type CfAISearch as a1, type CfWebSearch as a2, type CfAgentMemory as a3, type CfSecretsStoreSecrets as a4, type CfArtifacts as a5, type CfHelloWorld as a6, type CfFlagship as a7, type CfWorkerLoader as a8, type CfRateLimit as a9, type ServiceMetadataRes as aA, type ServiceFetch as aB, type File as aC, type BinaryFile as aD, type Trigger as aE, type Entry as aF, INHERIT_SYMBOL as aG, SERVICE_TAG_PREFIX as aH, ENVIRONMENT_TAG_PREFIX as aI, PATH_TO_DEPLOY_CONFIG as aJ, JSON_CONFIG_FORMATS as aK, type CfHyperdrive as aa, type CfService as ab, type CfVpcService as ac, type CfVpcNetwork as ad, type CfAnalyticsEngineDataset as ae, type CfDispatchNamespace as af, type CfMTlsCertificate as ag, type CfLogfwdr as ah, type CfLogfwdrBinding as ai, type CfAssetsBinding as aj, type CfPipeline as ak, type CfUnsafeBinding as al, type CfCapnp as am, type CfUnsafe as an, type CfDurableObjectMigrations as ao, type CfPlacement as ap, type CfTailConsumer as aq, type CfUserLimits as ar, type CfWorkerInit as as, type CfWorkerContext as at, type CfWorkerSourceMap as au, type Json as av, type AssetConfigMetadata as aw, type AssetsOptions as ax, type LegacyAssetPaths as ay, type WorkerMetadata as az, type Config as b, type Route as c, type RawDevConfig as d, type ConfigFields as e, type RawEnvironment as f, defaultWranglerConfig as g, type ZoneNameRoute as h, type CustomDomainRoute as i, type CloudchamberConfig as j, type ContainerApp as k, type DurableObjectBindings as l, type WorkflowBinding as m, type EnvironmentNonInheritable as n, type Rule as o, type ConfigModuleRuleType as p, type DispatchNamespaceOutbound as q, type CacheOptions as r, type DockerConfiguration as s, type ContainerEngine as t, type CfScriptFormat as u, type CfModuleType as v, type CfModule as w, type CfVars as x, type CfKvNamespace as y, type CfSendEmailBindings as z };
|
package/dist/index.d.mts
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
import { C as ComputedFields, B as Binding, R as RawConfig, b as Config, W as WorkerMetadataBinding } from './config-
|
|
2
|
-
export { aw as AssetConfigMetadata, A as Assets, ax as AssetsOptions, aD as BinaryFile, r as CacheOptions, I as CfAIBinding, a1 as CfAISearch, a0 as CfAISearchNamespace, a3 as CfAgentMemory, ae as CfAnalyticsEngineDataset, a5 as CfArtifacts, aj as CfAssetsBinding, H as CfBrowserBinding, am as CfCapnp, _ as CfD1Database, N as CfDataBlobBindings, af as CfDispatchNamespace, Q as CfDurableObject, ao as CfDurableObjectMigrations, a7 as CfFlagship, a6 as CfHelloWorld, aa as CfHyperdrive, J as CfImagesBinding, y as CfKvNamespace, ah as CfLogfwdr, ai as CfLogfwdrBinding, ag as CfMTlsCertificate, K as CfMediaBinding, w as CfModule, v as CfModuleType, ak as CfPipeline, ap as CfPlacement, X as CfQueue, Y as CfR2Bucket, a9 as CfRateLimit, u as CfScriptFormat, a4 as CfSecretsStoreSecrets, z as CfSendEmailBindings, ab as CfService, L as CfStreamBinding, aq as CfTailConsumer, G as CfTextBlobBindings, an as CfUnsafe, al as CfUnsafeBinding, ar as CfUserLimits, x as CfVars, $ as CfVectorize, M as CfVersionMetadataBinding, ad as CfVpcNetwork, ac as CfVpcService, F as CfWasmModuleBindings, a2 as CfWebSearch, at as CfWorkerContext, as as CfWorkerInit, a8 as CfWorkerLoader, au as CfWorkerSourceMap, V as CfWorkflow, j as CloudchamberConfig,
|
|
1
|
+
import { C as ComputedFields, B as Binding, R as RawConfig, b as Config, W as WorkerMetadataBinding, c as Route } from './config-BT23LDfr.mjs';
|
|
2
|
+
export { aw as AssetConfigMetadata, A as Assets, ax as AssetsOptions, aD as BinaryFile, r as CacheOptions, I as CfAIBinding, a1 as CfAISearch, a0 as CfAISearchNamespace, a3 as CfAgentMemory, ae as CfAnalyticsEngineDataset, a5 as CfArtifacts, aj as CfAssetsBinding, H as CfBrowserBinding, am as CfCapnp, _ as CfD1Database, N as CfDataBlobBindings, af as CfDispatchNamespace, Q as CfDurableObject, ao as CfDurableObjectMigrations, a7 as CfFlagship, a6 as CfHelloWorld, aa as CfHyperdrive, J as CfImagesBinding, y as CfKvNamespace, ah as CfLogfwdr, ai as CfLogfwdrBinding, ag as CfMTlsCertificate, K as CfMediaBinding, w as CfModule, v as CfModuleType, ak as CfPipeline, ap as CfPlacement, X as CfQueue, Y as CfR2Bucket, a9 as CfRateLimit, u as CfScriptFormat, a4 as CfSecretsStoreSecrets, z as CfSendEmailBindings, ab as CfService, L as CfStreamBinding, aq as CfTailConsumer, G as CfTextBlobBindings, an as CfUnsafe, al as CfUnsafeBinding, ar as CfUserLimits, x as CfVars, $ as CfVectorize, M as CfVersionMetadataBinding, ad as CfVpcNetwork, ac as CfVpcService, F as CfWasmModuleBindings, a2 as CfWebSearch, at as CfWorkerContext, as as CfWorkerInit, a8 as CfWorkerLoader, au as CfWorkerSourceMap, V as CfWorkflow, j as CloudchamberConfig, e as ConfigFields, p as ConfigModuleRuleType, k as ContainerApp, t as ContainerEngine, i as CustomDomainRoute, q as DispatchNamespaceOutbound, s as DockerConfiguration, l as DurableObjectBindings, D as DurableObjectMigration, aI as ENVIRONMENT_TAG_PREFIX, aF as Entry, E as Environment, n as EnvironmentNonInheritable, aC as File, aG as INHERIT_SYMBOL, aK as JSON_CONFIG_FORMATS, av as Json, ay as LegacyAssetPaths, O as Observability, aJ as PATH_TO_DEPLOY_CONFIG, P as PreviewsConfig, d as RawDevConfig, f as RawEnvironment, a as RedirectedRawConfig, o as Rule, aH as SERVICE_TAG_PREFIX, aB as ServiceFetch, aA as ServiceMetadataRes, S as StreamingTailConsumer, T as TailConsumer, aE as Trigger, U as UserLimits, az as WorkerMetadata, m as WorkflowBinding, Z as ZoneIdRoute, h as ZoneNameRoute, g as defaultWranglerConfig } from './config-BT23LDfr.mjs';
|
|
3
3
|
import * as jsoncParser from 'jsonc-parser';
|
|
4
4
|
export { constructWranglerConfig } from './browser.mjs';
|
|
5
5
|
export { Counter, MetricsRegistry } from './prometheus-metrics.mjs';
|
|
6
6
|
import { ChildProcess } from 'node:child_process';
|
|
7
|
+
import { URLSearchParams } from 'node:url';
|
|
8
|
+
import { RequestInit, Response, Headers } from 'undici';
|
|
7
9
|
import '@cloudflare/workers-shared';
|
|
8
10
|
import 'cloudflare';
|
|
9
11
|
|
|
@@ -90,7 +92,7 @@ declare const bucketFormatMessage = "Bucket names must begin and end with an alp
|
|
|
90
92
|
* Config field names for bindings (e.g., "kv_namespaces", "d1_databases").
|
|
91
93
|
* These are the keys used in Wrangler's config file
|
|
92
94
|
*/
|
|
93
|
-
type ConfigBindingFieldName = "data_blobs" | "durable_objects" | "kv_namespaces" | "send_email" | "queues" | "d1_databases" | "vectorize" | "ai_search_namespaces" | "ai_search" | "
|
|
95
|
+
type ConfigBindingFieldName = "data_blobs" | "durable_objects" | "kv_namespaces" | "send_email" | "queues" | "d1_databases" | "vectorize" | "ai_search_namespaces" | "ai_search" | "websearch" | "agent_memory" | "hyperdrive" | "r2_buckets" | "logfwdr" | "services" | "analytics_engine_datasets" | "text_blobs" | "browser" | "ai" | "images" | "stream" | "media" | "version_metadata" | "unsafe" | "vars" | "wasm_modules" | "dispatch_namespaces" | "mtls_certificates" | "workflows" | "pipelines" | "secrets_store_secrets" | "artifacts" | "ratelimits" | "assets" | "unsafe_hello_world" | "flagship" | "worker_loaders" | "vpc_services" | "vpc_networks";
|
|
94
96
|
/**
|
|
95
97
|
* @deprecated new code should use getBindingTypeFriendlyName() instead
|
|
96
98
|
*/
|
|
@@ -894,7 +896,7 @@ declare function getWranglerTmpDir(projectRoot: string | undefined, prefix: stri
|
|
|
894
896
|
* the latest version and download URL, matching cloudflared's own update mechanism.
|
|
895
897
|
*/
|
|
896
898
|
|
|
897
|
-
interface Logger {
|
|
899
|
+
interface Logger$1 {
|
|
898
900
|
log: typeof console.log;
|
|
899
901
|
warn: typeof console.warn;
|
|
900
902
|
debug: typeof console.debug;
|
|
@@ -907,7 +909,7 @@ declare function spawnCloudflared(args: string[], options?: {
|
|
|
907
909
|
env?: Record<string, string>;
|
|
908
910
|
skipVersionCheck?: boolean;
|
|
909
911
|
confirmDownload?: (message: string) => Promise<boolean>;
|
|
910
|
-
logger?: Logger;
|
|
912
|
+
logger?: Logger$1;
|
|
911
913
|
}): Promise<ChildProcess>;
|
|
912
914
|
|
|
913
915
|
interface QuickTunnelResult {
|
|
@@ -931,7 +933,7 @@ interface TunnelOptions {
|
|
|
931
933
|
expiryMs?: number;
|
|
932
934
|
reminderIntervalMs?: number;
|
|
933
935
|
extendHint?: string;
|
|
934
|
-
logger?: Logger;
|
|
936
|
+
logger?: Logger$1;
|
|
935
937
|
}
|
|
936
938
|
/**
|
|
937
939
|
* Start a Cloudflare Quick Tunnel for a local dev origin.
|
|
@@ -943,6 +945,75 @@ interface TunnelOptions {
|
|
|
943
945
|
*/
|
|
944
946
|
declare function startTunnel(options: TunnelOptions): Tunnel;
|
|
945
947
|
|
|
948
|
+
interface FetchError {
|
|
949
|
+
code: number;
|
|
950
|
+
documentation_url?: string;
|
|
951
|
+
message: string;
|
|
952
|
+
error_chain?: FetchError[];
|
|
953
|
+
}
|
|
954
|
+
|
|
955
|
+
type Logger = {
|
|
956
|
+
debug: (...args: unknown[]) => void;
|
|
957
|
+
debugWithSanitization: (label: string, ...args: unknown[]) => void;
|
|
958
|
+
log: (...args: unknown[]) => void;
|
|
959
|
+
info: (...args: unknown[]) => void;
|
|
960
|
+
warn: (...args: unknown[]) => void;
|
|
961
|
+
error: (...args: unknown[]) => void;
|
|
962
|
+
};
|
|
963
|
+
|
|
964
|
+
type ApiCredentials = {
|
|
965
|
+
apiToken: string;
|
|
966
|
+
} | {
|
|
967
|
+
authKey: string;
|
|
968
|
+
authEmail: string;
|
|
969
|
+
};
|
|
970
|
+
interface FetchResult<ResponseType = unknown> {
|
|
971
|
+
success: boolean;
|
|
972
|
+
result: ResponseType;
|
|
973
|
+
errors: FetchError[];
|
|
974
|
+
messages?: (string | {
|
|
975
|
+
code?: number;
|
|
976
|
+
message: string;
|
|
977
|
+
})[];
|
|
978
|
+
result_info?: unknown;
|
|
979
|
+
}
|
|
980
|
+
type FetchResultFetcher = <ResponseType>(complianceConfig: ComplianceConfig, resource: string, init?: RequestInit, queryParams?: URLSearchParams, abortSignal?: AbortSignal) => Promise<ResponseType>;
|
|
981
|
+
type FetchListResultFetcher = <ResponseType>(complianceConfig: ComplianceConfig, resource: string, init?: RequestInit, queryParams?: URLSearchParams) => Promise<ResponseType[]>;
|
|
982
|
+
/**
|
|
983
|
+
*
|
|
984
|
+
* Note this requires its caller to handle credentials
|
|
985
|
+
* (need to call requireLoggedIn and requireApiToken)
|
|
986
|
+
*/
|
|
987
|
+
declare function performApiFetchBase(complianceConfig: ComplianceConfig, resource: string, init: RequestInit | undefined, userAgent: string, logger: Logger, queryParams?: URLSearchParams, abortSignal?: AbortSignal, credentials?: ApiCredentials): Promise<Response>;
|
|
988
|
+
declare function fetchInternalBase<ResponseType>(complianceConfig: ComplianceConfig, resource: string, init: RequestInit | undefined, userAgent: string, logger: Logger, queryParams?: URLSearchParams, abortSignal?: AbortSignal, credentials?: ApiCredentials): Promise<{
|
|
989
|
+
response: ResponseType;
|
|
990
|
+
status: number;
|
|
991
|
+
}>;
|
|
992
|
+
declare function fetchResultBase<ResponseType>(complianceConfig: ComplianceConfig, resource: string, init: RequestInit | undefined, userAgent: string, logger: Logger, queryParams?: URLSearchParams, abortSignal?: AbortSignal, credentials?: ApiCredentials): Promise<ResponseType>;
|
|
993
|
+
declare function fetchListResultBase<ResponseType>(complianceConfig: ComplianceConfig, resource: string, init: RequestInit | undefined, userAgent: string, logger: Logger, queryParams?: URLSearchParams, credentials?: ApiCredentials): Promise<ResponseType[]>;
|
|
994
|
+
declare function truncate(text: string, maxLength: number): string;
|
|
995
|
+
declare function isWAFBlockResponse(headers: Headers): boolean;
|
|
996
|
+
declare function extractWAFBlockRayId(headers: Headers): string | undefined;
|
|
997
|
+
declare function extractAccountTag(resource: string): string | undefined;
|
|
998
|
+
interface PageResultInfo {
|
|
999
|
+
page: number;
|
|
1000
|
+
per_page: number;
|
|
1001
|
+
count: number;
|
|
1002
|
+
total_count: number;
|
|
1003
|
+
}
|
|
1004
|
+
declare function hasMorePages(result_info: unknown): result_info is PageResultInfo;
|
|
1005
|
+
declare function renderError(err: FetchError | {
|
|
1006
|
+
code?: number;
|
|
1007
|
+
message?: string;
|
|
1008
|
+
documentation_url?: string;
|
|
1009
|
+
}, level?: number): string;
|
|
1010
|
+
declare function addAuthorizationHeader(headers: Headers, auth: ApiCredentials, overrideExisting?: boolean): void;
|
|
1011
|
+
declare function throwFetchError(resource: string, response: FetchResult<unknown>, status: number): never;
|
|
1012
|
+
declare function hasCursor(result_info: unknown): result_info is {
|
|
1013
|
+
cursor: string;
|
|
1014
|
+
};
|
|
1015
|
+
declare function maybeAddTraceHeader(headers: Headers): void;
|
|
1016
|
+
|
|
946
1017
|
type NpmVersionCheckResult = {
|
|
947
1018
|
status: "up-to-date";
|
|
948
1019
|
} | {
|
|
@@ -967,4 +1038,41 @@ type NpmVersionCheckResult = {
|
|
|
967
1038
|
*/
|
|
968
1039
|
declare function fetchLatestNpmVersion(name: string, version: string): Promise<NpmVersionCheckResult>;
|
|
969
1040
|
|
|
970
|
-
|
|
1041
|
+
declare function retryOnAPIFailure<T>(action: () => T | Promise<T>, logger: Logger, backoff?: number, attempts?: number, abortSignal?: AbortSignal): Promise<T>;
|
|
1042
|
+
|
|
1043
|
+
declare function formatTime(duration: number): string;
|
|
1044
|
+
|
|
1045
|
+
/**
|
|
1046
|
+
* Get the hostname on which to run a Worker.
|
|
1047
|
+
*
|
|
1048
|
+
* The most accurate place is usually
|
|
1049
|
+
* `route.pattern`, as that includes any subdomains. For example:
|
|
1050
|
+
* ```js
|
|
1051
|
+
* {
|
|
1052
|
+
* pattern: foo.example.com
|
|
1053
|
+
* zone_name: example.com
|
|
1054
|
+
* }
|
|
1055
|
+
* ```
|
|
1056
|
+
* However, in the case of patterns that _can't_ be parsed as a hostname
|
|
1057
|
+
* (primarily the pattern `*/ declare function getHostFromRoute(route: Route): string | undefined;
|
|
1058
|
+
/**
|
|
1059
|
+
* Best-effort derivation of the Cloudflare zone name that owns a given route,
|
|
1060
|
+
* for use as the `CF-Worker` header value on outbound subrequests in local
|
|
1061
|
+
* development (see https://developers.cloudflare.com/fundamentals/reference/http-headers/#cf-worker).
|
|
1062
|
+
*
|
|
1063
|
+
* In production, `CF-Worker` is set to the zone name — for a route
|
|
1064
|
+
* `foo.example.com/*` on zone `example.com`, the header is `example.com`.
|
|
1065
|
+
* When the user has explicitly told us the zone name in their route config
|
|
1066
|
+
* (`zone_name`), use it. Otherwise, fall back to {@link getHostFromRoute},
|
|
1067
|
+
* which returns the route pattern's hostname — this is the closest local
|
|
1068
|
+
* approximation without performing an API lookup, and matches the behaviour
|
|
1069
|
+
* users see when their route's hostname is already the apex (e.g.
|
|
1070
|
+
* `example.com/*`).
|
|
1071
|
+
*/
|
|
1072
|
+
declare function getZoneFromRoute(route: Route): string | undefined;
|
|
1073
|
+
/**
|
|
1074
|
+
* Given something that resembles a URL, try to extract a host from it.
|
|
1075
|
+
*/
|
|
1076
|
+
declare function getHostFromUrl(urlLike: string): string | undefined;
|
|
1077
|
+
|
|
1078
|
+
export { APIError, type ApiCredentials, Binding, type BindingLocalSupport, COMPLIANCE_REGION_CONFIG_PUBLIC, COMPLIANCE_REGION_CONFIG_UNKNOWN, CommandLineArgsError, type CompatDate, type ComplianceConfig, Config, type ConfigBindingFieldName, type ConfigBindingOptions, DeprecationError, Diagnostics, type EphemeralDirectory, FatalError, type FetchListResultFetcher, type FetchResult, type FetchResultFetcher, JsonFriendlyFatalError, type Location, type Logger, type Message, MissingConfigError, type NormalizeAndValidateConfigArgs, type NpmVersionCheckResult, type PackageJSON, ParseError, type ParseFile, PatchConfigError, RawConfig, type ResolveConfigPathOptions, Route, type TelemetryMessage, type Tunnel, type TunnelOptions, UserError, WorkerMetadataBinding, addAuthorizationHeader, assertNever, bucketFormatMessage, configFileName, configFormat, createFatalError, experimental_patchConfig, experimental_readRawConfig, extractAccountTag, extractWAFBlockRayId, fetchInternalBase, fetchLatestNpmVersion, fetchListResultBase, fetchResultBase, findWranglerConfig, formatConfigSnippet, formatTime, friendlyBindingNames, getBindingLocalSupport, getBindingTypeFriendlyName, getBooleanEnvironmentVariableFactory, getBrowserRenderingHeadfulFromEnv, getBuildConditionsFromEnv, getBuildPlatformFromEnv, getC3CommandFromEnv, getCIGeneratePreviewAlias, getCIMatchTag, getCIOverrideName, getCIOverrideNetworkModeHost, getCfFetchEnabledFromEnv, getCfFetchPathFromEnv, getCloudflareApiBaseUrl, getCloudflareApiEnvironmentFromEnv, getCloudflareComplianceRegion, getCloudflareEnv, getCloudflareIncludeProcessEnvFromEnv, getCloudflareLoadDevVarsFromDotEnv, getCloudflaredPathFromEnv, getComplianceRegionSubdomain, getD1ExtraLocationChoices, getDisableConfigWatching, getDockerPath, getEnvironmentVariableFactory, getGlobalWranglerConfigPath, getHostFromRoute, getHostFromUrl, getLocalExplorerEnabledFromEnv, getOpenNextDeployFromEnv, getOutputFileDirectoryFromEnv, getOutputFilePathFromEnv, getRegistryPath, getSanitizeLogs, getSubdomainMixedStateCheckDisabled, getTodaysCompatDate, getTraceHeader, getWorkersCIBranchName, getWranglerCacheDirFromEnv, getWranglerHiddenDirPath, getWranglerHideBanner, getWranglerSendErrorReportsFromEnv, getWranglerSendMetricsFromEnv, getWranglerTmpDir, getZoneFromRoute, hasCursor, hasMorePages, hasProperty, indexLocation, isCompatDate, isDirectory, isDockerfile, isOptionalProperty, isPagesConfig, isRedirectedConfig, isRequiredProperty, isValidR2BucketName, isWAFBlockResponse, mapWorkerMetadataBindings, maybeAddTraceHeader, normalizeAndValidateConfig, parseByteSize, parseHumanDuration, parseJSON, parseJSONC, parseNonHyphenedUuid, parsePackageJSON, parseTOML, performApiFetchBase, readFileSync, readFileSyncToBuffer, removeDir, removeDirSync, renderError, resolveWranglerConfigPath, retryOnAPIFailure, searchLocation, spawnCloudflared, startTunnel, sweepStaleWranglerTmpDirs, throwFetchError, truncate, validatePagesConfig };
|