@cloudflare/workers-utils 0.33.1 → 0.35.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 +1 -1
- package/dist/browser.mjs +1 -1
- package/dist/chunk-3IYLA2JH.mjs +73 -0
- package/dist/{chunk-IV7UMGT2.mjs → chunk-6VP24PQU.mjs} +1 -1
- package/dist/chunk-7AX24RFK.mjs +265 -0
- package/dist/chunk-C6O4ION7.mjs +42 -0
- package/dist/chunk-MCNIGVAF.mjs +45 -0
- package/dist/{chunk-QFKPUV4H.mjs → chunk-V6JSHOVJ.mjs} +16 -115
- package/dist/chunk-WO2IAW6M.mjs +62 -0
- package/dist/chunk-XUGGRRBO.mjs +178 -0
- package/dist/compatibility-date.d.mts +80 -0
- package/dist/compatibility-date.mjs +2 -0
- package/dist/{config-CRUFg2tu.d.mts → compliance-j3-tqeao.d.mts} +64 -17
- package/dist/compliance.d.mts +4 -0
- package/dist/compliance.mjs +7 -0
- package/dist/docker-path.d.mts +8 -0
- package/dist/docker-path.mjs +3 -0
- package/dist/errors.d.mts +55 -0
- package/dist/errors.mjs +2 -0
- package/dist/index.d.mts +238 -145
- package/dist/index.mjs +1656 -703
- package/dist/metafile-esm.json +1 -1
- package/dist/open-PBXRGS4R.mjs +3 -3
- package/dist/test-helpers/index.d.mts +6 -2
- package/dist/test-helpers/index.mjs +39 -2
- package/dist/zod-format.d.mts +6 -0
- package/dist/zod-format.mjs +2 -0
- package/package.json +24 -3
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { __name } from './chunk-Q72B4Q5Z.mjs';
|
|
2
|
+
|
|
3
|
+
// src/errors.ts
|
|
4
|
+
var UserError = class extends Error {
|
|
5
|
+
static {
|
|
6
|
+
__name(this, "UserError");
|
|
7
|
+
}
|
|
8
|
+
telemetryMessage;
|
|
9
|
+
constructor(message, options) {
|
|
10
|
+
super(message, options);
|
|
11
|
+
Object.setPrototypeOf(this, new.target.prototype);
|
|
12
|
+
this.telemetryMessage = typeof options?.telemetryMessage === "string" ? options.telemetryMessage : options?.telemetryMessage ? message : void 0;
|
|
13
|
+
}
|
|
14
|
+
};
|
|
15
|
+
var DeprecationError = class extends UserError {
|
|
16
|
+
static {
|
|
17
|
+
__name(this, "DeprecationError");
|
|
18
|
+
}
|
|
19
|
+
constructor(message, options) {
|
|
20
|
+
super(`Deprecation:
|
|
21
|
+
${message}`, options);
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
var FatalError = class extends UserError {
|
|
25
|
+
static {
|
|
26
|
+
__name(this, "FatalError");
|
|
27
|
+
}
|
|
28
|
+
code;
|
|
29
|
+
constructor(message, options) {
|
|
30
|
+
super(message, options);
|
|
31
|
+
this.code = options.code;
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
var CommandLineArgsError = class extends UserError {
|
|
35
|
+
static {
|
|
36
|
+
__name(this, "CommandLineArgsError");
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
var JsonFriendlyFatalError = class extends FatalError {
|
|
40
|
+
static {
|
|
41
|
+
__name(this, "JsonFriendlyFatalError");
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
var MissingConfigError = class extends Error {
|
|
45
|
+
static {
|
|
46
|
+
__name(this, "MissingConfigError");
|
|
47
|
+
}
|
|
48
|
+
telemetryMessage;
|
|
49
|
+
constructor(key) {
|
|
50
|
+
super(`Missing config value for ${key}`);
|
|
51
|
+
this.telemetryMessage = `Missing config value for ${key}`;
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
function createFatalError(message, isJson, options) {
|
|
55
|
+
if (isJson) {
|
|
56
|
+
return new JsonFriendlyFatalError(JSON.stringify(message), options);
|
|
57
|
+
}
|
|
58
|
+
return new FatalError(`${message}`, options);
|
|
59
|
+
}
|
|
60
|
+
__name(createFatalError, "createFatalError");
|
|
61
|
+
|
|
62
|
+
export { CommandLineArgsError, DeprecationError, FatalError, JsonFriendlyFatalError, MissingConfigError, UserError, createFatalError };
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
import { dedent } from './chunk-MCNIGVAF.mjs';
|
|
2
|
+
import { getEnvironmentVariableFactory, getBooleanEnvironmentVariableFactory } from './chunk-3IYLA2JH.mjs';
|
|
3
|
+
import { UserError } from './chunk-WO2IAW6M.mjs';
|
|
4
|
+
import { getGlobalConfigPath } from './chunk-34VZWBGB.mjs';
|
|
5
|
+
import { __name } from './chunk-Q72B4Q5Z.mjs';
|
|
6
|
+
import path from 'node:path';
|
|
7
|
+
|
|
8
|
+
var getC3CommandFromEnv = getEnvironmentVariableFactory({
|
|
9
|
+
variableName: "WRANGLER_C3_COMMAND",
|
|
10
|
+
defaultValue: /* @__PURE__ */ __name(() => "create cloudflare", "defaultValue")
|
|
11
|
+
});
|
|
12
|
+
var getDoNotTrackFromEnv = getEnvironmentVariableFactory({
|
|
13
|
+
variableName: "DO_NOT_TRACK"
|
|
14
|
+
});
|
|
15
|
+
function isDoNotTrackEnabled() {
|
|
16
|
+
const value = getDoNotTrackFromEnv()?.toLowerCase();
|
|
17
|
+
return value === "1" || value === "true";
|
|
18
|
+
}
|
|
19
|
+
__name(isDoNotTrackEnabled, "isDoNotTrackEnabled");
|
|
20
|
+
var getWranglerSendMetricsVariableFromEnv = getBooleanEnvironmentVariableFactory({
|
|
21
|
+
variableName: "WRANGLER_SEND_METRICS"
|
|
22
|
+
});
|
|
23
|
+
function getWranglerSendMetricsFromEnv() {
|
|
24
|
+
if (isDoNotTrackEnabled()) {
|
|
25
|
+
return false;
|
|
26
|
+
}
|
|
27
|
+
return getWranglerSendMetricsVariableFromEnv();
|
|
28
|
+
}
|
|
29
|
+
__name(getWranglerSendMetricsFromEnv, "getWranglerSendMetricsFromEnv");
|
|
30
|
+
var getNoSkillsUpdatePromptsFromEnv = getBooleanEnvironmentVariableFactory({
|
|
31
|
+
variableName: "WRANGLER_NO_SKILLS_UPDATE_PROMPTS"
|
|
32
|
+
});
|
|
33
|
+
var getWranglerSendErrorReportsFromEnv = getBooleanEnvironmentVariableFactory({
|
|
34
|
+
variableName: "WRANGLER_SEND_ERROR_REPORTS",
|
|
35
|
+
defaultValue: false
|
|
36
|
+
});
|
|
37
|
+
var getCloudflareApiEnvironmentFromEnv = getEnvironmentVariableFactory(
|
|
38
|
+
{
|
|
39
|
+
variableName: "WRANGLER_API_ENVIRONMENT",
|
|
40
|
+
defaultValue: /* @__PURE__ */ __name(() => "production", "defaultValue"),
|
|
41
|
+
choices: ["production", "staging"]
|
|
42
|
+
}
|
|
43
|
+
);
|
|
44
|
+
var COMPLIANCE_REGION_CONFIG_PUBLIC = {
|
|
45
|
+
compliance_region: "public"
|
|
46
|
+
};
|
|
47
|
+
var COMPLIANCE_REGION_CONFIG_UNKNOWN = {
|
|
48
|
+
compliance_region: void 0
|
|
49
|
+
};
|
|
50
|
+
var getCloudflareComplianceRegionFromEnv = getEnvironmentVariableFactory({
|
|
51
|
+
variableName: "CLOUDFLARE_COMPLIANCE_REGION",
|
|
52
|
+
choices: ["public", "fedramp_high"]
|
|
53
|
+
});
|
|
54
|
+
var getCloudflareComplianceRegion = /* @__PURE__ */ __name((complianceConfig) => {
|
|
55
|
+
const complianceRegionFromEnv = getCloudflareComplianceRegionFromEnv();
|
|
56
|
+
if (complianceRegionFromEnv !== void 0 && complianceConfig?.compliance_region !== void 0 && complianceRegionFromEnv !== complianceConfig.compliance_region) {
|
|
57
|
+
throw new UserError(
|
|
58
|
+
dedent`
|
|
59
|
+
The compliance region has been set to different values in two places:
|
|
60
|
+
- \`CLOUDFLARE_COMPLIANCE_REGION\` environment variable: \`${complianceRegionFromEnv}\`
|
|
61
|
+
- \`compliance_region\` configuration property: \`${complianceConfig.compliance_region}\`
|
|
62
|
+
`,
|
|
63
|
+
{ telemetryMessage: false }
|
|
64
|
+
);
|
|
65
|
+
}
|
|
66
|
+
return complianceRegionFromEnv || complianceConfig?.compliance_region || "public";
|
|
67
|
+
}, "getCloudflareComplianceRegion");
|
|
68
|
+
var getCloudflareApiBaseUrlFromEnv = getEnvironmentVariableFactory({
|
|
69
|
+
variableName: "CLOUDFLARE_API_BASE_URL",
|
|
70
|
+
deprecatedName: "CF_API_BASE_URL"
|
|
71
|
+
});
|
|
72
|
+
var getCloudflareApiBaseUrl = /* @__PURE__ */ __name((complianceConfig) => getCloudflareApiBaseUrlFromEnv() ?? `https://api${getComplianceRegionSubdomain(complianceConfig)}${getStagingSubdomain()}.cloudflare.com/client/v4`, "getCloudflareApiBaseUrl");
|
|
73
|
+
function getComplianceRegionSubdomain(complianceConfig) {
|
|
74
|
+
return getCloudflareComplianceRegion(complianceConfig) === "fedramp_high" ? ".fed" : "";
|
|
75
|
+
}
|
|
76
|
+
__name(getComplianceRegionSubdomain, "getComplianceRegionSubdomain");
|
|
77
|
+
function getStagingSubdomain() {
|
|
78
|
+
return getCloudflareApiEnvironmentFromEnv() === "staging" ? ".staging" : "";
|
|
79
|
+
}
|
|
80
|
+
__name(getStagingSubdomain, "getStagingSubdomain");
|
|
81
|
+
var getSanitizeLogs = getBooleanEnvironmentVariableFactory({
|
|
82
|
+
variableName: "WRANGLER_LOG_SANITIZE",
|
|
83
|
+
defaultValue: true
|
|
84
|
+
});
|
|
85
|
+
var getOutputFileDirectoryFromEnv = getEnvironmentVariableFactory({
|
|
86
|
+
variableName: "WRANGLER_OUTPUT_FILE_DIRECTORY"
|
|
87
|
+
});
|
|
88
|
+
var getOutputFilePathFromEnv = getEnvironmentVariableFactory({
|
|
89
|
+
variableName: "WRANGLER_OUTPUT_FILE_PATH"
|
|
90
|
+
});
|
|
91
|
+
var getCIMatchTag = getEnvironmentVariableFactory({
|
|
92
|
+
variableName: "WRANGLER_CI_MATCH_TAG"
|
|
93
|
+
});
|
|
94
|
+
var getCIOverrideName = getEnvironmentVariableFactory({
|
|
95
|
+
variableName: "WRANGLER_CI_OVERRIDE_NAME"
|
|
96
|
+
});
|
|
97
|
+
var getCIOverrideNetworkModeHost = getEnvironmentVariableFactory({
|
|
98
|
+
variableName: "WRANGLER_CI_OVERRIDE_NETWORK_MODE_HOST"
|
|
99
|
+
});
|
|
100
|
+
var getCIGeneratePreviewAlias = getEnvironmentVariableFactory({
|
|
101
|
+
variableName: "WRANGLER_CI_GENERATE_PREVIEW_ALIAS",
|
|
102
|
+
defaultValue: /* @__PURE__ */ __name(() => "false", "defaultValue"),
|
|
103
|
+
choices: ["true", "false"]
|
|
104
|
+
});
|
|
105
|
+
var getWorkersCIBranchName = getEnvironmentVariableFactory({
|
|
106
|
+
variableName: "WORKERS_CI_BRANCH"
|
|
107
|
+
});
|
|
108
|
+
var getBuildConditionsFromEnv = getEnvironmentVariableFactory({
|
|
109
|
+
variableName: "WRANGLER_BUILD_CONDITIONS"
|
|
110
|
+
});
|
|
111
|
+
var getBuildPlatformFromEnv = getEnvironmentVariableFactory({
|
|
112
|
+
variableName: "WRANGLER_BUILD_PLATFORM"
|
|
113
|
+
});
|
|
114
|
+
var getRegistryPath = getEnvironmentVariableFactory({
|
|
115
|
+
variableName: "WRANGLER_REGISTRY_PATH",
|
|
116
|
+
defaultValue() {
|
|
117
|
+
return path.join(getGlobalConfigPath(), "registry");
|
|
118
|
+
}
|
|
119
|
+
});
|
|
120
|
+
var getD1ExtraLocationChoices = getEnvironmentVariableFactory({
|
|
121
|
+
variableName: "WRANGLER_D1_EXTRA_LOCATION_CHOICES"
|
|
122
|
+
});
|
|
123
|
+
var getSubdomainMixedStateCheckDisabled = getBooleanEnvironmentVariableFactory({
|
|
124
|
+
variableName: "WRANGLER_DISABLE_SUBDOMAIN_MIXED_STATE_CHECK",
|
|
125
|
+
defaultValue: false
|
|
126
|
+
});
|
|
127
|
+
var getCloudflareLoadDevVarsFromDotEnv = getBooleanEnvironmentVariableFactory({
|
|
128
|
+
variableName: "CLOUDFLARE_LOAD_DEV_VARS_FROM_DOT_ENV",
|
|
129
|
+
defaultValue: true
|
|
130
|
+
});
|
|
131
|
+
var getCloudflareIncludeProcessEnvFromEnv = getBooleanEnvironmentVariableFactory({
|
|
132
|
+
variableName: "CLOUDFLARE_INCLUDE_PROCESS_ENV",
|
|
133
|
+
defaultValue: false
|
|
134
|
+
});
|
|
135
|
+
var getTraceHeader = getEnvironmentVariableFactory({
|
|
136
|
+
variableName: "WRANGLER_TRACE_ID"
|
|
137
|
+
});
|
|
138
|
+
var getDisableConfigWatching = getBooleanEnvironmentVariableFactory({
|
|
139
|
+
variableName: "WRANGLER_CI_DISABLE_CONFIG_WATCHING",
|
|
140
|
+
defaultValue: false
|
|
141
|
+
});
|
|
142
|
+
var getWranglerHideBanner = getBooleanEnvironmentVariableFactory({
|
|
143
|
+
variableName: "WRANGLER_HIDE_BANNER",
|
|
144
|
+
defaultValue: false
|
|
145
|
+
});
|
|
146
|
+
var getCloudflareEnv = getEnvironmentVariableFactory({
|
|
147
|
+
variableName: "CLOUDFLARE_ENV"
|
|
148
|
+
});
|
|
149
|
+
var getOpenNextDeployFromEnv = getEnvironmentVariableFactory({
|
|
150
|
+
variableName: "OPEN_NEXT_DEPLOY"
|
|
151
|
+
});
|
|
152
|
+
var getLocalExplorerEnabledFromEnv = getBooleanEnvironmentVariableFactory({
|
|
153
|
+
variableName: "X_LOCAL_EXPLORER",
|
|
154
|
+
defaultValue: true
|
|
155
|
+
});
|
|
156
|
+
var getLocalObservabilityEnabledFromEnv = getBooleanEnvironmentVariableFactory({
|
|
157
|
+
variableName: "X_LOCAL_OBSERVABILITY",
|
|
158
|
+
defaultValue: true
|
|
159
|
+
});
|
|
160
|
+
var getBrowserRenderingHeadfulFromEnv = getBooleanEnvironmentVariableFactory({
|
|
161
|
+
variableName: "X_BROWSER_HEADFUL",
|
|
162
|
+
defaultValue: false
|
|
163
|
+
});
|
|
164
|
+
var getCfFetchEnabledFromEnv = getBooleanEnvironmentVariableFactory({
|
|
165
|
+
variableName: "CLOUDFLARE_CF_FETCH_ENABLED",
|
|
166
|
+
defaultValue: true
|
|
167
|
+
});
|
|
168
|
+
var getCfFetchPathFromEnv = getEnvironmentVariableFactory({
|
|
169
|
+
variableName: "CLOUDFLARE_CF_FETCH_PATH"
|
|
170
|
+
});
|
|
171
|
+
var getWranglerCacheDirFromEnv = getEnvironmentVariableFactory({
|
|
172
|
+
variableName: "WRANGLER_CACHE_DIR"
|
|
173
|
+
});
|
|
174
|
+
var getCloudflaredPathFromEnv = getEnvironmentVariableFactory({
|
|
175
|
+
variableName: "CLOUDFLARED_PATH"
|
|
176
|
+
});
|
|
177
|
+
|
|
178
|
+
export { COMPLIANCE_REGION_CONFIG_PUBLIC, COMPLIANCE_REGION_CONFIG_UNKNOWN, getBrowserRenderingHeadfulFromEnv, getBuildConditionsFromEnv, getBuildPlatformFromEnv, getC3CommandFromEnv, getCIGeneratePreviewAlias, getCIMatchTag, getCIOverrideName, getCIOverrideNetworkModeHost, getCfFetchEnabledFromEnv, getCfFetchPathFromEnv, getCloudflareApiBaseUrl, getCloudflareApiEnvironmentFromEnv, getCloudflareComplianceRegion, getCloudflareEnv, getCloudflareIncludeProcessEnvFromEnv, getCloudflareLoadDevVarsFromDotEnv, getCloudflaredPathFromEnv, getComplianceRegionSubdomain, getD1ExtraLocationChoices, getDisableConfigWatching, getLocalExplorerEnabledFromEnv, getLocalObservabilityEnabledFromEnv, getNoSkillsUpdatePromptsFromEnv, getOpenNextDeployFromEnv, getOutputFileDirectoryFromEnv, getOutputFilePathFromEnv, getRegistryPath, getSanitizeLogs, getSubdomainMixedStateCheckDisabled, getTraceHeader, getWorkersCIBranchName, getWranglerCacheDirFromEnv, getWranglerHideBanner, getWranglerSendErrorReportsFromEnv, getWranglerSendMetricsFromEnv, isDoNotTrackEnabled };
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
type YYYY = `${number}${number}${number}${number}`;
|
|
2
|
+
type MM = `${number}${number}`;
|
|
3
|
+
type DD = `${number}${number}`;
|
|
4
|
+
/**
|
|
5
|
+
* Represents a valid compatibility date, a string such as `2025-09-27`
|
|
6
|
+
*/
|
|
7
|
+
type CompatDate = `${YYYY}-${MM}-${DD}`;
|
|
8
|
+
/**
|
|
9
|
+
* Discern whether a string represents a compatibility date (`YYYY-MM-DD`)
|
|
10
|
+
*
|
|
11
|
+
* @param str The target string
|
|
12
|
+
* @returns true if the string represents a compatibility date, false otherwise
|
|
13
|
+
*/
|
|
14
|
+
declare function isCompatDate(str: string): str is CompatDate;
|
|
15
|
+
/**
|
|
16
|
+
* Returns today's date as a compatibility date string (`YYYY-MM-DD`).
|
|
17
|
+
*/
|
|
18
|
+
declare function getTodaysCompatDate(): CompatDate;
|
|
19
|
+
/**
|
|
20
|
+
* The compatibility date on which the `nodejs_compat` and `nodejs_compat_v2`
|
|
21
|
+
* compatibility flags became enabled by default in workerd.
|
|
22
|
+
*
|
|
23
|
+
* From this date onwards, specifying either flag explicitly is a validation
|
|
24
|
+
* error ("The compatibility flag nodejs_compat became the default as of
|
|
25
|
+
* 2026-08-04 so does not need to be specified anymore"), so tooling must not
|
|
26
|
+
* add them to configurations using such a compatibility date.
|
|
27
|
+
*
|
|
28
|
+
* @see https://github.com/cloudflare/workerd/blob/main/src/workerd/io/compatibility-date.capnp
|
|
29
|
+
*/
|
|
30
|
+
declare const NODEJS_COMPAT_DEFAULT_ON_DATE = "2026-08-04";
|
|
31
|
+
/**
|
|
32
|
+
* Whether workerd enables Node.js compatibility by default for the given
|
|
33
|
+
* compatibility date, i.e. without the `nodejs_compat` flag being specified.
|
|
34
|
+
*
|
|
35
|
+
* @param compatibilityDate The compatibility date to check
|
|
36
|
+
* @returns true if the date is on or after {@link NODEJS_COMPAT_DEFAULT_ON_DATE}
|
|
37
|
+
*/
|
|
38
|
+
declare function isNodejsCompatDefaultOn(compatibilityDate: string | undefined): boolean;
|
|
39
|
+
/**
|
|
40
|
+
* The compatibility date on which `nodejs_compat` started implying
|
|
41
|
+
* `nodejs_compat_v2`.
|
|
42
|
+
*/
|
|
43
|
+
declare const NODEJS_COMPAT_V2_SWITCH_OVER_DATE = "2024-09-23";
|
|
44
|
+
/**
|
|
45
|
+
* Resolves whether workerd will enable the `nodejs_compat` and
|
|
46
|
+
* `nodejs_compat_v2` features, mirroring how workerd itself resolves them from
|
|
47
|
+
* the compatibility date and flags:
|
|
48
|
+
* - Both are enabled by default from {@link NODEJS_COMPAT_DEFAULT_ON_DATE}
|
|
49
|
+
* onwards, and each must be turned off separately from that date, with
|
|
50
|
+
* `no_nodejs_compat` and `no_nodejs_compat_v2` respectively.
|
|
51
|
+
* - Before that date, `nodejs_compat` implies `nodejs_compat_v2` from
|
|
52
|
+
* {@link NODEJS_COMPAT_V2_SWITCH_OVER_DATE} onwards.
|
|
53
|
+
*
|
|
54
|
+
* @param compatibilityDate The compatibility date
|
|
55
|
+
* @param compatibilityFlags The compatibility flags
|
|
56
|
+
*/
|
|
57
|
+
declare function resolveNodejsCompat(compatibilityDate: string, compatibilityFlags: string[]): {
|
|
58
|
+
isNodejsCompatEnabled: boolean;
|
|
59
|
+
isNodejsCompatV2Enabled: boolean;
|
|
60
|
+
};
|
|
61
|
+
/**
|
|
62
|
+
* Removes the `nodejs_compat` and `nodejs_compat_v2` flags from a list of
|
|
63
|
+
* compatibility flags when the compatibility date already enables them.
|
|
64
|
+
*
|
|
65
|
+
* workerd rejects a compatibility flag that its compatibility date enables by
|
|
66
|
+
* default, so from {@link NODEJS_COMPAT_DEFAULT_ON_DATE} onwards specifying
|
|
67
|
+
* either flag stops a Worker from starting up. Removing them is a no-op for
|
|
68
|
+
* such a date, so tooling can accept the redundant flags rather than failing.
|
|
69
|
+
*
|
|
70
|
+
* A flag is kept when its matching opt-out is specified too, since workerd
|
|
71
|
+
* reports those as contradictory and the enable flag wins there - dropping it
|
|
72
|
+
* would silently switch Node.js compatibility off instead.
|
|
73
|
+
*
|
|
74
|
+
* @param compatibilityDate The compatibility date
|
|
75
|
+
* @param compatibilityFlags The compatibility flags
|
|
76
|
+
* @returns The flags, without the ones the date makes redundant
|
|
77
|
+
*/
|
|
78
|
+
declare function stripRedundantNodejsCompatFlags(compatibilityDate: string | undefined, compatibilityFlags: string[]): string[];
|
|
79
|
+
|
|
80
|
+
export { type CompatDate, NODEJS_COMPAT_DEFAULT_ON_DATE, NODEJS_COMPAT_V2_SWITCH_OVER_DATE, getTodaysCompatDate, isCompatDate, isNodejsCompatDefaultOn, resolveNodejsCompat, stripRedundantNodejsCompatFlags };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { URLSearchParams } from 'node:url';
|
|
2
|
-
import { RequestInit, Response as Response$1,
|
|
2
|
+
import { RequestInit, Headers, Response as Response$1, MockAgent } from 'undici';
|
|
3
3
|
import { RouterConfig, AssetConfig } from '@cloudflare/workers-shared';
|
|
4
4
|
|
|
5
5
|
interface FetchError {
|
|
@@ -179,12 +179,7 @@ declare const getRegistryPath: () => string;
|
|
|
179
179
|
* External accounts cannot access testing environments, so should not set this variable.
|
|
180
180
|
*/
|
|
181
181
|
declare const getD1ExtraLocationChoices: () => string | undefined;
|
|
182
|
-
|
|
183
|
-
* `WRANGLER_DOCKER_BIN` specifies the path to a docker binary.
|
|
184
|
-
*
|
|
185
|
-
* By default it's `docker`.
|
|
186
|
-
*/
|
|
187
|
-
declare const getDockerPath: () => string;
|
|
182
|
+
|
|
188
183
|
declare const getSubdomainMixedStateCheckDisabled: () => boolean;
|
|
189
184
|
/**
|
|
190
185
|
/**
|
|
@@ -471,12 +466,16 @@ interface CfKvNamespace {
|
|
|
471
466
|
type CfSendEmailBindings = {
|
|
472
467
|
name: string;
|
|
473
468
|
remote?: boolean;
|
|
469
|
+
allowed_sender_addresses?: string[];
|
|
474
470
|
} & ({
|
|
475
|
-
destination_address
|
|
471
|
+
destination_address: string;
|
|
472
|
+
allowed_destination_addresses?: never;
|
|
476
473
|
} | {
|
|
477
|
-
|
|
474
|
+
destination_address?: never;
|
|
475
|
+
allowed_destination_addresses: string[];
|
|
478
476
|
} | {
|
|
479
|
-
|
|
477
|
+
destination_address?: never;
|
|
478
|
+
allowed_destination_addresses?: never;
|
|
480
479
|
});
|
|
481
480
|
/**
|
|
482
481
|
* A binding to a wasm module (in service-worker format)
|
|
@@ -555,11 +554,13 @@ interface CfWorkflow {
|
|
|
555
554
|
class_name: string;
|
|
556
555
|
binding: string;
|
|
557
556
|
script_name?: string;
|
|
558
|
-
remote?: boolean;
|
|
559
557
|
raw?: boolean;
|
|
560
558
|
limits?: {
|
|
561
559
|
steps?: number;
|
|
562
560
|
};
|
|
561
|
+
concurrency?: {
|
|
562
|
+
limit?: number;
|
|
563
|
+
};
|
|
563
564
|
schedules?: string | string[];
|
|
564
565
|
}
|
|
565
566
|
interface CfQueue {
|
|
@@ -1291,9 +1292,15 @@ type Trigger = {
|
|
|
1291
1292
|
cron: string;
|
|
1292
1293
|
} | ({
|
|
1293
1294
|
type: "queue-consumer";
|
|
1294
|
-
} & Omit<QueueConsumer, "type">)
|
|
1295
|
-
type
|
|
1296
|
-
|
|
1295
|
+
} & Omit<QueueConsumer, "type">) | {
|
|
1296
|
+
type: "connect";
|
|
1297
|
+
protocol: "tcp";
|
|
1298
|
+
port: number;
|
|
1299
|
+
address?: string;
|
|
1300
|
+
};
|
|
1301
|
+
type DistributiveOmit<T, K extends PropertyKey> = T extends unknown ? Omit<T, K> : never;
|
|
1302
|
+
type BindingOmit<T> = DistributiveOmit<T, "binding">;
|
|
1303
|
+
type NameOmit<T> = DistributiveOmit<T, "name">;
|
|
1297
1304
|
type Binding = {
|
|
1298
1305
|
type: "plain_text";
|
|
1299
1306
|
value: string;
|
|
@@ -2366,15 +2373,29 @@ type WorkflowBinding = {
|
|
|
2366
2373
|
class_name: string;
|
|
2367
2374
|
/** The script where the Workflow is defined (if it's external to this Worker) */
|
|
2368
2375
|
script_name?: string;
|
|
2369
|
-
/** Whether the Workflow should be remote or not in local development */
|
|
2370
|
-
remote?: boolean;
|
|
2371
2376
|
/** Optional limits for the Workflow */
|
|
2372
2377
|
limits?: {
|
|
2373
2378
|
/** Maximum number of steps a Workflow instance can execute */
|
|
2374
2379
|
steps?: number;
|
|
2375
2380
|
};
|
|
2381
|
+
/** Optional concurrency configuration for the Workflow */
|
|
2382
|
+
concurrency?: {
|
|
2383
|
+
/** Maximum number of Workflow instances that can run concurrently */
|
|
2384
|
+
limit?: number;
|
|
2385
|
+
};
|
|
2376
2386
|
/** Optional cron schedule(s) for automatically triggering workflow instances */
|
|
2377
2387
|
schedules?: string | string[];
|
|
2388
|
+
/**
|
|
2389
|
+
* Optional default retention for instances of this Workflow, applied when an instance does not
|
|
2390
|
+
* set its own retention. Accepts milliseconds or a duration string such as `"3 days"`, and is
|
|
2391
|
+
* validated by the Workflows API at deploy time.
|
|
2392
|
+
*/
|
|
2393
|
+
default_retention?: {
|
|
2394
|
+
/** How long to retain instances that completed successfully or were terminated */
|
|
2395
|
+
success_retention?: number | string;
|
|
2396
|
+
/** How long to retain errored instances */
|
|
2397
|
+
error_retention?: number | string;
|
|
2398
|
+
};
|
|
2378
2399
|
};
|
|
2379
2400
|
/**
|
|
2380
2401
|
* The `EnvironmentNonInheritable` interface declares all the configuration fields for an environment
|
|
@@ -2565,6 +2586,26 @@ interface EnvironmentNonInheritable {
|
|
|
2565
2586
|
retry_delay?: number;
|
|
2566
2587
|
}[];
|
|
2567
2588
|
};
|
|
2589
|
+
/**
|
|
2590
|
+
* Specifies raw sockets that this Worker should listen on.
|
|
2591
|
+
* Each entry opens a listening socket on the
|
|
2592
|
+
* given port that delivers incoming connections directly to the Worker's
|
|
2593
|
+
* `connect(socket, env, ctx)` handler.
|
|
2594
|
+
*
|
|
2595
|
+
* NOTE: This field is not automatically inherited from the top level environment,
|
|
2596
|
+
* and so must be specified in every named environment.
|
|
2597
|
+
*
|
|
2598
|
+
* @default []
|
|
2599
|
+
* @nonInheritable
|
|
2600
|
+
*/
|
|
2601
|
+
connect: {
|
|
2602
|
+
/** The transport protocol to listen for. */
|
|
2603
|
+
protocol: "tcp";
|
|
2604
|
+
/** The port to listen on. */
|
|
2605
|
+
port: number;
|
|
2606
|
+
/** The address to bind to. Defaults to `127.0.0.1`. */
|
|
2607
|
+
address?: string;
|
|
2608
|
+
}[];
|
|
2568
2609
|
/**
|
|
2569
2610
|
* Specifies R2 buckets that are bound to this Worker environment.
|
|
2570
2611
|
*
|
|
@@ -3210,6 +3251,12 @@ interface Observability {
|
|
|
3210
3251
|
enabled?: boolean;
|
|
3211
3252
|
/** The sampling rate */
|
|
3212
3253
|
head_sampling_rate?: number;
|
|
3254
|
+
/**
|
|
3255
|
+
* Whether query strings are removed from request URLs in logs and traces.
|
|
3256
|
+
*
|
|
3257
|
+
* @default false
|
|
3258
|
+
*/
|
|
3259
|
+
redact_query_string?: boolean;
|
|
3213
3260
|
logs?: {
|
|
3214
3261
|
enabled?: boolean;
|
|
3215
3262
|
/** The sampling rate */
|
|
@@ -3566,4 +3613,4 @@ interface EnvironmentMap {
|
|
|
3566
3613
|
}
|
|
3567
3614
|
declare const defaultWranglerConfig: Config;
|
|
3568
3615
|
|
|
3569
|
-
export { type
|
|
3616
|
+
export { type CfModuleType as $, ARTIFACTS_EVENT_TYPES as A, type Binding as B, type ComputedFields as C, type DurableObjectExport as D, type Exports as E, type CfBrowserBinding as F, type CfCapnp as G, type CfD1Database as H, type CfDataBlobBindings as I, type CfDevPluginCfg as J, type CfDispatchNamespace as K, type Logger as L, type CfDurableObject as M, type CfDurableObjectMigrations as N, type CfExports as O, type CfFlagship as P, type CfHelloWorld as Q, type RawConfig as R, type CfHyperdrive as S, type CfImagesBinding as T, type CfKvNamespace as U, type CfLogfwdr as V, type WorkerEntrypointExport as W, type CfLogfwdrBinding as X, type CfMTlsCertificate as Y, type CfMediaBinding as Z, type CfModule as _, type RedirectedRawConfig as a, type LocalS3Credentials as a$, type CfPipeline as a0, type CfPlacement as a1, type CfQueue as a2, type CfR2Bucket as a3, type CfRateLimit as a4, type CfScriptFormat as a5, type CfSecretsStoreSecrets as a6, type CfSendEmailBindings as a7, type CfService as a8, type CfStreamBinding as a9, type DurableObjectExportStorage as aA, type DurableObjectMigration as aB, ENVIRONMENT_TAG_PREFIX as aC, type Entry as aD, type Environment as aE, type EnvironmentNonInheritable as aF, type ExportsReconciliationEntryBase as aG, type ExportsReconciliationErrorDetail as aH, type ExportsReconciliationInfo as aI, type ExportsReconciliationRename as aJ, type ExportsReconciliationResult as aK, type ExportsReconciliationTransfer as aL, type ExportsReconciliationTransferPending as aM, type ExportsReconciliationWarning as aN, type FetchKVGetValueFetcher as aO, type FetchListResultFetcher as aP, type FetchPagedListResultFetcher as aQ, type FetchResult as aR, type FetchResultFetcher as aS, type File as aT, type Hook as aU, type HookValues as aV, INHERIT_SYMBOL as aW, JSON_CONFIG_FORMATS as aX, type Json as aY, LOGGER_LEVELS as aZ, type LegacyAssetPaths as a_, type CfTextBlobBindings as aa, type CfUnsafe as ab, type CfUnsafeBinding as ac, type CfUserLimits as ad, type CfVars as ae, type CfVectorize as af, type CfVersionMetadataBinding as ag, type CfVpcNetwork as ah, type CfVpcService as ai, type CfWasmModuleBindings as aj, type CfWebSearch as ak, type CfWorkerContext as al, type CfWorkerInit as am, type CfWorkerLoader as an, type CfWorkerSourceMap as ao, type CfWorkflow as ap, type CloudchamberConfig as aq, type ComplianceConfig as ar, type ConfigFields as as, type ConfigModuleRuleType as at, type ConfiguredExport as au, type ContainerEngine as av, type CustomDomainRoute as aw, type DispatchNamespaceOutbound as ax, type DockerConfiguration as ay, type DurableObjectBindings as az, type Config as b, getWranglerSendErrorReportsFromEnv as b$, type LogLevel as b0, type LoggerLevel as b1, type NodeJSCompatMode as b2, type Observability as b3, PATH_TO_DEPLOY_CONFIG as b4, type PreviewsConfig as b5, type RawDevConfig as b6, type RawEnvironment as b7, type Rule as b8, SERVICE_TAG_PREFIX as b9, getCIOverrideName as bA, getCIOverrideNetworkModeHost as bB, getCfFetchEnabledFromEnv as bC, getCfFetchPathFromEnv as bD, getCloudflareApiBaseUrl as bE, getCloudflareApiEnvironmentFromEnv as bF, getCloudflareComplianceRegion as bG, getCloudflareEnv as bH, getCloudflareIncludeProcessEnvFromEnv as bI, getCloudflareLoadDevVarsFromDotEnv as bJ, getCloudflaredPathFromEnv as bK, getComplianceRegionSubdomain as bL, getD1ExtraLocationChoices as bM, getDisableConfigWatching as bN, getLocalExplorerEnabledFromEnv as bO, getLocalObservabilityEnabledFromEnv as bP, getNoSkillsUpdatePromptsFromEnv as bQ, getOpenNextDeployFromEnv as bR, getOutputFileDirectoryFromEnv as bS, getOutputFilePathFromEnv as bT, getRegistryPath as bU, getSanitizeLogs as bV, getSubdomainMixedStateCheckDisabled as bW, getTraceHeader as bX, getWorkersCIBranchName as bY, getWranglerCacheDirFromEnv as bZ, getWranglerHideBanner as b_, type ServiceFetch as ba, type ServiceMetadataRes as bb, type StartDevWorkerInput as bc, type StreamingTailConsumer as bd, type TailConsumer as be, type Trigger as bf, type UserLimits as bg, type ValidatedAssetsOptions as bh, type WorkerMetadata as bi, type WorkflowBinding as bj, type ZoneIdRoute as bk, type ZoneNameRoute as bl, addAuthorizationHeader as bm, defaultWranglerConfig as bn, extractAccountTag as bo, extractWAFBlockRayId as bp, fetchInternalBase as bq, fetchKVGetValueBase as br, fetchListResultBase as bs, fetchResultBase as bt, getBrowserRenderingHeadfulFromEnv as bu, getBuildConditionsFromEnv as bv, getBuildPlatformFromEnv as bw, getC3CommandFromEnv as bx, getCIGeneratePreviewAlias as by, getCIMatchTag as bz, type ContainerApp as c, getWranglerSendMetricsFromEnv as c0, hasCursor as c1, hasMorePages as c2, isDoNotTrackEnabled as c3, isWAFBlockResponse as c4, maybeAddTraceHeader as c5, parseRetryAfterMs as c6, parseRetryAfterValue as c7, performApiFetchBase as c8, renderError as c9, throwFetchError as ca, truncate as cb, type WorkerMetadataBinding as d, type CfTailConsumer as e, type Route as f, type Access as g, type ApiCredentials as h, type ArtifactsEventTrigger as i, type ArtifactsEventType as j, type AssetConfigMetadata as k, type Assets as l, type AssetsOptions as m, type AsyncHook as n, type BinaryFile as o, COMPLIANCE_REGION_CONFIG_PUBLIC as p, COMPLIANCE_REGION_CONFIG_UNKNOWN as q, type CacheOptions as r, type CfAIBinding as s, type CfAISearch as t, type CfAISearchNamespace as u, type CfAccount as v, type CfAgentMemory as w, type CfAnalyticsEngineDataset as x, type CfArtifacts as y, type CfAssetsBinding as z };
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { p as COMPLIANCE_REGION_CONFIG_PUBLIC, q as COMPLIANCE_REGION_CONFIG_UNKNOWN, ar as ComplianceConfig, bE as getCloudflareApiBaseUrl, bG as getCloudflareComplianceRegion, bL as getComplianceRegionSubdomain } from './compliance-j3-tqeao.mjs';
|
|
2
|
+
import 'node:url';
|
|
3
|
+
import 'undici';
|
|
4
|
+
import '@cloudflare/workers-shared';
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { COMPLIANCE_REGION_CONFIG_PUBLIC, COMPLIANCE_REGION_CONFIG_UNKNOWN, getCloudflareApiBaseUrl, getCloudflareComplianceRegion, getComplianceRegionSubdomain } from './chunk-XUGGRRBO.mjs';
|
|
2
|
+
import './chunk-MCNIGVAF.mjs';
|
|
3
|
+
import './chunk-3IYLA2JH.mjs';
|
|
4
|
+
import './chunk-WO2IAW6M.mjs';
|
|
5
|
+
import './chunk-34VZWBGB.mjs';
|
|
6
|
+
import './chunk-53IMCORZ.mjs';
|
|
7
|
+
import './chunk-Q72B4Q5Z.mjs';
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This is used to provide telemetry with a sanitised error
|
|
3
|
+
* message that could not have any user-identifying information.
|
|
4
|
+
* Set to `true` to duplicate `message`.
|
|
5
|
+
* */
|
|
6
|
+
type TelemetryMessage = {
|
|
7
|
+
telemetryMessage: string | boolean;
|
|
8
|
+
};
|
|
9
|
+
type UserErrorOptions = ErrorOptions & TelemetryMessage;
|
|
10
|
+
type FatalErrorOptions = UserErrorOptions & {
|
|
11
|
+
code?: number;
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* Base class for errors where the user has done something wrong. These are not
|
|
15
|
+
* reported to Sentry. API errors are intentionally *not* `UserError`s, and are
|
|
16
|
+
* reported to Sentry. This will help us understand which API errors need better
|
|
17
|
+
* messaging.
|
|
18
|
+
*/
|
|
19
|
+
declare class UserError extends Error {
|
|
20
|
+
telemetryMessage: string | undefined;
|
|
21
|
+
constructor(message: string, options: UserErrorOptions);
|
|
22
|
+
}
|
|
23
|
+
declare class DeprecationError extends UserError {
|
|
24
|
+
constructor(message: string, options: TelemetryMessage);
|
|
25
|
+
}
|
|
26
|
+
declare class FatalError extends UserError {
|
|
27
|
+
readonly code: number | undefined;
|
|
28
|
+
constructor(message: string, options: FatalErrorOptions);
|
|
29
|
+
}
|
|
30
|
+
declare class CommandLineArgsError extends UserError {
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* JsonFriendlyFatalError is used to output JSON when wrangler crashes, useful for --json mode.
|
|
34
|
+
*
|
|
35
|
+
* To use, pass stringify'd json into the constructor like so:
|
|
36
|
+
* ```js
|
|
37
|
+
* throw new JsonFriendlyFatalError(JSON.stringify({ error: messageToDisplay }), {
|
|
38
|
+
* telemetryMessage: false,
|
|
39
|
+
* });
|
|
40
|
+
* ```
|
|
41
|
+
*/
|
|
42
|
+
declare class JsonFriendlyFatalError extends FatalError {
|
|
43
|
+
}
|
|
44
|
+
declare class MissingConfigError extends Error {
|
|
45
|
+
telemetryMessage: string | undefined;
|
|
46
|
+
constructor(key: string);
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Create either a FatalError or JsonFriendlyFatalError depending upon `isJson` parameter.
|
|
50
|
+
*
|
|
51
|
+
* If `isJson` is true, then the `message` is JSON stringified.
|
|
52
|
+
*/
|
|
53
|
+
declare function createFatalError(message: unknown, isJson: boolean, options: FatalErrorOptions): Error;
|
|
54
|
+
|
|
55
|
+
export { CommandLineArgsError, DeprecationError, FatalError, JsonFriendlyFatalError, MissingConfigError, type TelemetryMessage, UserError, createFatalError };
|
package/dist/errors.mjs
ADDED