@cloudflare/workers-utils 0.48.0 → 0.50.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 +2 -0
- package/dist/browser.mjs +1 -1
- package/dist/{chunk-CAPCWVOB.mjs → chunk-XEBMRQST.mjs} +148 -96
- package/dist/{compliance-NXalJMKU.d.mts → compliance-CAnqGKXC.d.mts} +3 -0
- package/dist/compliance.d.mts +1 -1
- package/dist/index.d.mts +2 -2
- package/dist/index.mjs +13 -7
- package/dist/local-env.d.mts +18 -1
- package/dist/local-env.mjs +76 -10
- package/dist/metafile-esm.json +1 -1
- package/dist/test-helpers/index.d.mts +1 -1
- package/dist/zod-format.mjs +1 -1
- package/package.json +6 -6
|
@@ -443,6 +443,7 @@ interface CfVpcNetwork {
|
|
|
443
443
|
interface CfAnalyticsEngineDataset {
|
|
444
444
|
binding: string;
|
|
445
445
|
dataset?: string;
|
|
446
|
+
remote?: boolean;
|
|
446
447
|
}
|
|
447
448
|
interface CfDispatchNamespace {
|
|
448
449
|
binding: string;
|
|
@@ -2731,6 +2732,8 @@ interface EnvironmentNonInheritable {
|
|
|
2731
2732
|
binding: string;
|
|
2732
2733
|
/** The name of this dataset to write to. */
|
|
2733
2734
|
dataset?: string;
|
|
2735
|
+
/** Whether the dataset should be remote or not in local development */
|
|
2736
|
+
remote?: boolean;
|
|
2734
2737
|
}[];
|
|
2735
2738
|
/**
|
|
2736
2739
|
* A browser that will be usable from the Worker.
|
package/dist/compliance.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { s as COMPLIANCE_REGION_CONFIG_PUBLIC, t as COMPLIANCE_REGION_CONFIG_UNKNOWN, h as ComplianceConfig, bQ as getCloudflareApiBaseUrl, bS as getCloudflareComplianceRegion, bT as getCloudflareContainerRegistry, bY as getComplianceRegionSubdomain } from './compliance-
|
|
1
|
+
export { s as COMPLIANCE_REGION_CONFIG_PUBLIC, t as COMPLIANCE_REGION_CONFIG_UNKNOWN, h as ComplianceConfig, bQ as getCloudflareApiBaseUrl, bS as getCloudflareComplianceRegion, bT as getCloudflareContainerRegistry, bY as getComplianceRegionSubdomain } from './compliance-CAnqGKXC.mjs';
|
|
2
2
|
import 'node:url';
|
|
3
3
|
import 'undici';
|
|
4
4
|
import '@cloudflare/workers-shared';
|
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { C as ComputedFields, B as Binding, R as RawConfig, b as Config, E as Exports, D as DurableObjectExport, W as WorkerEntrypointExport, c as WorkflowExport, d as ContainerApp, e as WorkerMetadataBinding, T as TailConsumer, f as WorkerMetadata, g as CfTailConsumer, L as Logger, A as ApiCredentials, h as ComplianceConfig, i as Route } from './compliance-
|
|
2
|
-
export { j as ARTIFACTS_EVENT_TYPES, k as Access, l as ArtifactsEventTrigger, m as ArtifactsEventType, n as AssetConfigMetadata, o as Assets, p as AssetsOptions, q as AsyncHook, r as BinaryFile, s as COMPLIANCE_REGION_CONFIG_PUBLIC, t as COMPLIANCE_REGION_CONFIG_UNKNOWN, u as CacheOptions, v as CfAIBinding, w as CfAISearch, x as CfAISearchNamespace, y as CfAccount, z as CfAgentMemory, F as CfAnalyticsEngineDataset, G as CfAnalyticsSQLBinding, H as CfArtifacts, I as CfAssetsBinding, J as CfBrowserBinding, K as CfCapnp, M as CfD1Database, N as CfDataBlobBindings, O as CfDevPluginCfg, P as CfDispatchNamespace, Q as CfDurableObject, S as CfDurableObjectMigrations, U as CfExports, V as CfFlagship, X as CfHelloWorld, Y as CfHyperdrive, Z as CfImagesBinding, _ as CfK2Binding, $ as CfKvNamespace, a0 as CfLogfwdr, a1 as CfLogfwdrBinding, a2 as CfMTlsCertificate, a3 as CfMediaBinding, a4 as CfModule, a5 as CfModuleType, a6 as CfPipeline, a7 as CfPlacement, a8 as CfQueue, a9 as CfR2Bucket, aa as CfRateLimit, ab as CfScriptFormat, ac as CfSecretsStoreSecrets, ad as CfSendEmailBindings, ae as CfService, af as CfStreamBinding, ag as CfTextBlobBindings, ah as CfUnsafe, ai as CfUnsafeBinding, aj as CfUserLimits, ak as CfVars, al as CfVectorize, am as CfVersionMetadataBinding, an as CfVpcNetwork, ao as CfVpcService, ap as CfWasmModuleBindings, aq as CfWorkerContext, ar as CfWorkerInit, as as CfWorkerLoader, at as CfWorkerSourceMap, au as CfWorkflow, av as CloudchamberConfig, aw as ConfigFields, ax as ConfigModuleRuleType, ay as ConfiguredExport, az as ConnectHandler, aA as ContainerEngine, aB as ContainerObservability, aC as CustomDomainRoute, aD as DispatchNamespaceOutbound, aE as DockerConfiguration, aF as DurableObjectBindings, aG as DurableObjectCodeUpdateStrategy, aH as DurableObjectContainerImage, aI as DurableObjectExportStorage, aJ as DurableObjectMigration, aK as DurableObjectsConfig, aL as ENVIRONMENT_TAG_PREFIX, aM as Entry, aN as Environment, aO as EnvironmentNonInheritable, aP as ExportsReconciliationEntryBase, aQ as ExportsReconciliationErrorDetail, aR as ExportsReconciliationInfo, aS as ExportsReconciliationRename, aT as ExportsReconciliationResult, aU as ExportsReconciliationTransfer, aV as ExportsReconciliationTransferPending, aW as ExportsReconciliationWarning, aX as FetchKVGetValueFetcher, aY as FetchListResultFetcher, aZ as FetchPagedListResultFetcher, a_ as FetchResult, a$ as FetchResultFetcher, b0 as File, b1 as Hook, b2 as HookValues, b3 as INHERIT_SYMBOL, b4 as JSON_CONFIG_FORMATS, b5 as Json, b6 as LOGGER_LEVELS, b7 as LegacyAssetPaths, b8 as LocalS3Credentials, b9 as LogLevel, ba as LoggerLevel, bb as NodeJSCompatMode, bc as Observability, bd as PATH_TO_DEPLOY_CONFIG, be as PreviewsConfig, bf as RawDevConfig, bg as RawDurableObjectsConfig, bh as RawEnvironment, a as RedirectedRawConfig, bi as Rule, bj as SERVICE_TAG_PREFIX, bk as ServiceFetch, bl as ServiceMetadataRes, bm as StartDevWorkerInput, bn as StreamingTailConsumer, bo as TcpConnectHandler, bp as Trigger, bq as UdpConnectHandler, br as UserLimits, bs as ValidatedAssetsOptions, bt as WORKFLOW_JURISDICTIONS, bu as WorkflowBinding, bv as WorkflowJurisdiction, bw as ZoneIdRoute, bx as ZoneNameRoute, by as addAuthorizationHeader, bz as defaultWranglerConfig, bA as extractAccountTag, bB as extractWAFBlockRayId, bC as fetchInternalBase, bD as fetchKVGetValueBase, bE as fetchListResultBase, bF as fetchResultBase, bG as getBrowserRenderingHeadfulFromEnv, bH as getBuildConditionsFromEnv, bI as getBuildPlatformFromEnv, bJ as getC3CommandFromEnv, bK as getCIGeneratePreviewAlias, bL as getCIMatchTag, bM as getCIOverrideName, bN as getCIOverrideNetworkModeHost, bO as getCfFetchEnabledFromEnv, bP as getCfFetchPathFromEnv, bQ as getCloudflareApiBaseUrl, bR as getCloudflareApiEnvironmentFromEnv, bS as getCloudflareComplianceRegion, bT as getCloudflareContainerRegistry, bU as getCloudflareEnv, bV as getCloudflareIncludeProcessEnvFromEnv, bW as getCloudflareLoadDevVarsFromDotEnv, bX as getCloudflaredPathFromEnv, bY as getComplianceRegionSubdomain, bZ as getD1ExtraLocationChoices, b_ as getDisableConfigWatching, b$ as getLocalExplorerEnabledFromEnv, c0 as getLocalObservabilityEnabledFromEnv, c1 as getNoSkillsUpdatePromptsFromEnv, c2 as getOpenNextDeployFromEnv, c3 as getOutputFileDirectoryFromEnv, c4 as getOutputFilePathFromEnv, c5 as getRegistryPath, c6 as getSanitizeLogs, c7 as getSubdomainMixedStateCheckDisabled, c8 as getTraceHeader, c9 as getWorkersCIBranchName, ca as getWranglerCacheDirFromEnv, cb as getWranglerHideBanner, cc as getWranglerSendErrorReportsFromEnv, cd as getWranglerSendMetricsFromEnv, ce as hasCursor, cf as hasMorePages, cg as isDoNotTrackEnabled, ch as isWAFBlockResponse, ci as maybeAddTraceHeader, cj as parseRetryAfterMs, ck as parseRetryAfterValue, cl as performApiFetchBase, cm as renderError, cn as throwFetchError, co as truncate } from './compliance-
|
|
1
|
+
import { C as ComputedFields, B as Binding, R as RawConfig, b as Config, E as Exports, D as DurableObjectExport, W as WorkerEntrypointExport, c as WorkflowExport, d as ContainerApp, e as WorkerMetadataBinding, T as TailConsumer, f as WorkerMetadata, g as CfTailConsumer, L as Logger, A as ApiCredentials, h as ComplianceConfig, i as Route } from './compliance-CAnqGKXC.mjs';
|
|
2
|
+
export { j as ARTIFACTS_EVENT_TYPES, k as Access, l as ArtifactsEventTrigger, m as ArtifactsEventType, n as AssetConfigMetadata, o as Assets, p as AssetsOptions, q as AsyncHook, r as BinaryFile, s as COMPLIANCE_REGION_CONFIG_PUBLIC, t as COMPLIANCE_REGION_CONFIG_UNKNOWN, u as CacheOptions, v as CfAIBinding, w as CfAISearch, x as CfAISearchNamespace, y as CfAccount, z as CfAgentMemory, F as CfAnalyticsEngineDataset, G as CfAnalyticsSQLBinding, H as CfArtifacts, I as CfAssetsBinding, J as CfBrowserBinding, K as CfCapnp, M as CfD1Database, N as CfDataBlobBindings, O as CfDevPluginCfg, P as CfDispatchNamespace, Q as CfDurableObject, S as CfDurableObjectMigrations, U as CfExports, V as CfFlagship, X as CfHelloWorld, Y as CfHyperdrive, Z as CfImagesBinding, _ as CfK2Binding, $ as CfKvNamespace, a0 as CfLogfwdr, a1 as CfLogfwdrBinding, a2 as CfMTlsCertificate, a3 as CfMediaBinding, a4 as CfModule, a5 as CfModuleType, a6 as CfPipeline, a7 as CfPlacement, a8 as CfQueue, a9 as CfR2Bucket, aa as CfRateLimit, ab as CfScriptFormat, ac as CfSecretsStoreSecrets, ad as CfSendEmailBindings, ae as CfService, af as CfStreamBinding, ag as CfTextBlobBindings, ah as CfUnsafe, ai as CfUnsafeBinding, aj as CfUserLimits, ak as CfVars, al as CfVectorize, am as CfVersionMetadataBinding, an as CfVpcNetwork, ao as CfVpcService, ap as CfWasmModuleBindings, aq as CfWorkerContext, ar as CfWorkerInit, as as CfWorkerLoader, at as CfWorkerSourceMap, au as CfWorkflow, av as CloudchamberConfig, aw as ConfigFields, ax as ConfigModuleRuleType, ay as ConfiguredExport, az as ConnectHandler, aA as ContainerEngine, aB as ContainerObservability, aC as CustomDomainRoute, aD as DispatchNamespaceOutbound, aE as DockerConfiguration, aF as DurableObjectBindings, aG as DurableObjectCodeUpdateStrategy, aH as DurableObjectContainerImage, aI as DurableObjectExportStorage, aJ as DurableObjectMigration, aK as DurableObjectsConfig, aL as ENVIRONMENT_TAG_PREFIX, aM as Entry, aN as Environment, aO as EnvironmentNonInheritable, aP as ExportsReconciliationEntryBase, aQ as ExportsReconciliationErrorDetail, aR as ExportsReconciliationInfo, aS as ExportsReconciliationRename, aT as ExportsReconciliationResult, aU as ExportsReconciliationTransfer, aV as ExportsReconciliationTransferPending, aW as ExportsReconciliationWarning, aX as FetchKVGetValueFetcher, aY as FetchListResultFetcher, aZ as FetchPagedListResultFetcher, a_ as FetchResult, a$ as FetchResultFetcher, b0 as File, b1 as Hook, b2 as HookValues, b3 as INHERIT_SYMBOL, b4 as JSON_CONFIG_FORMATS, b5 as Json, b6 as LOGGER_LEVELS, b7 as LegacyAssetPaths, b8 as LocalS3Credentials, b9 as LogLevel, ba as LoggerLevel, bb as NodeJSCompatMode, bc as Observability, bd as PATH_TO_DEPLOY_CONFIG, be as PreviewsConfig, bf as RawDevConfig, bg as RawDurableObjectsConfig, bh as RawEnvironment, a as RedirectedRawConfig, bi as Rule, bj as SERVICE_TAG_PREFIX, bk as ServiceFetch, bl as ServiceMetadataRes, bm as StartDevWorkerInput, bn as StreamingTailConsumer, bo as TcpConnectHandler, bp as Trigger, bq as UdpConnectHandler, br as UserLimits, bs as ValidatedAssetsOptions, bt as WORKFLOW_JURISDICTIONS, bu as WorkflowBinding, bv as WorkflowJurisdiction, bw as ZoneIdRoute, bx as ZoneNameRoute, by as addAuthorizationHeader, bz as defaultWranglerConfig, bA as extractAccountTag, bB as extractWAFBlockRayId, bC as fetchInternalBase, bD as fetchKVGetValueBase, bE as fetchListResultBase, bF as fetchResultBase, bG as getBrowserRenderingHeadfulFromEnv, bH as getBuildConditionsFromEnv, bI as getBuildPlatformFromEnv, bJ as getC3CommandFromEnv, bK as getCIGeneratePreviewAlias, bL as getCIMatchTag, bM as getCIOverrideName, bN as getCIOverrideNetworkModeHost, bO as getCfFetchEnabledFromEnv, bP as getCfFetchPathFromEnv, bQ as getCloudflareApiBaseUrl, bR as getCloudflareApiEnvironmentFromEnv, bS as getCloudflareComplianceRegion, bT as getCloudflareContainerRegistry, bU as getCloudflareEnv, bV as getCloudflareIncludeProcessEnvFromEnv, bW as getCloudflareLoadDevVarsFromDotEnv, bX as getCloudflaredPathFromEnv, bY as getComplianceRegionSubdomain, bZ as getD1ExtraLocationChoices, b_ as getDisableConfigWatching, b$ as getLocalExplorerEnabledFromEnv, c0 as getLocalObservabilityEnabledFromEnv, c1 as getNoSkillsUpdatePromptsFromEnv, c2 as getOpenNextDeployFromEnv, c3 as getOutputFileDirectoryFromEnv, c4 as getOutputFilePathFromEnv, c5 as getRegistryPath, c6 as getSanitizeLogs, c7 as getSubdomainMixedStateCheckDisabled, c8 as getTraceHeader, c9 as getWorkersCIBranchName, ca as getWranglerCacheDirFromEnv, cb as getWranglerHideBanner, cc as getWranglerSendErrorReportsFromEnv, cd as getWranglerSendMetricsFromEnv, ce as hasCursor, cf as hasMorePages, cg as isDoNotTrackEnabled, ch as isWAFBlockResponse, ci as maybeAddTraceHeader, cj as parseRetryAfterMs, ck as parseRetryAfterValue, cl as performApiFetchBase, cm as renderError, cn as throwFetchError, co as truncate } from './compliance-CAnqGKXC.mjs';
|
|
3
3
|
import * as jsoncParser from 'jsonc-parser';
|
|
4
4
|
import { UserError, TelemetryMessage } from './errors.mjs';
|
|
5
5
|
export { CommandLineArgsError, DeprecationError, FatalError, JsonFriendlyFatalError, MissingConfigError, createFatalError } from './errors.mjs';
|
package/dist/index.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { createRequire } from 'node:module';
|
|
2
2
|
export { MetricsRegistry } from './chunk-6G6FCMPX.mjs';
|
|
3
|
-
import { external_exports } from './chunk-
|
|
4
|
-
export { formatZodError } from './chunk-
|
|
3
|
+
import { external_exports } from './chunk-XEBMRQST.mjs';
|
|
4
|
+
export { formatZodError } from './chunk-XEBMRQST.mjs';
|
|
5
5
|
import { isRedirectedRawConfig, configFileName, formatConfigSnippet, partitionExports, getDurableObjectExports, getContainerNameToClassNameMap, parsePackageJSON, readFileSync, ParseError, parseJSON, APIError, isLiveDurableObjectExport, dir, parseTOML, modify, applyEdits, format, stringify, parseJSONC } from './chunk-2HLTAS5V.mjs';
|
|
6
6
|
export { APIError, ENVIRONMENT_TAG_PREFIX, INHERIT_SYMBOL, JSON_CONFIG_FORMATS, PATH_TO_DEPLOY_CONFIG, ParseError, SERVICE_TAG_PREFIX, configFileName, configFormat, experimental_readRawConfig, findWranglerConfig, formatConfigSnippet, getContainerDurableObjectClassNames, getContainerNameToClassNameMap, getDurableObjectClassNameToUseSQLiteMap, getDurableObjectContainerApps, getDurableObjectExports, getResolvedDurableObjectContainerApps, hasDurableObjectExports, indexLocation, isDurableObjectContainerApp, isLiveDurableObjectExport, isRedirectedConfig, parseByteSize, parseHumanDuration, parseJSON, parseJSONC, parseNonHyphenedUuid, parsePackageJSON, parseTOML, partitionExports, readFileSync, readFileSyncToBuffer, resolveContainerClassName, resolveWranglerConfigPath, searchLocation, validateDurableObjectContainerApplications } from './chunk-2HLTAS5V.mjs';
|
|
7
7
|
export { NODEJS_COMPAT_DEFAULT_ON_DATE, NODEJS_COMPAT_V2_SWITCH_OVER_DATE, getTodaysCompatDate, isCompatDate, isNodejsCompatDefaultOn, resolveNodejsCompat, stripRedundantNodejsCompatFlags } from './chunk-2Q77CKVU.mjs';
|
|
@@ -6382,8 +6382,12 @@ var validateAnalyticsEngineBinding = /* @__PURE__ */ __name((diagnostics, field,
|
|
|
6382
6382
|
}
|
|
6383
6383
|
validateAdditionalProperties(diagnostics, field, Object.keys(value), [
|
|
6384
6384
|
"binding",
|
|
6385
|
-
"dataset"
|
|
6385
|
+
"dataset",
|
|
6386
|
+
"remote"
|
|
6386
6387
|
]);
|
|
6388
|
+
if (!isRemoteValid(value, field, diagnostics)) {
|
|
6389
|
+
isValid = false;
|
|
6390
|
+
}
|
|
6387
6391
|
return isValid;
|
|
6388
6392
|
}, "validateAnalyticsEngineBinding");
|
|
6389
6393
|
var validateWorkerNamespaceBinding = /* @__PURE__ */ __name((diagnostics, field, value) => {
|
|
@@ -8441,7 +8445,6 @@ var BINDING_LOCAL_SUPPORT = {
|
|
|
8441
8445
|
unsafe_hello_world: "local-only",
|
|
8442
8446
|
durable_object_namespace: "local-only",
|
|
8443
8447
|
fetcher: "local-only",
|
|
8444
|
-
analytics_engine: "local-only",
|
|
8445
8448
|
secrets_store_secret: "local-only",
|
|
8446
8449
|
ratelimit: "local-only",
|
|
8447
8450
|
worker_loader: "local-only",
|
|
@@ -8459,6 +8462,7 @@ var BINDING_LOCAL_SUPPORT = {
|
|
|
8459
8462
|
// TODO: Miniflare currently ignores `remote: true` on queues, tracked in #13727.
|
|
8460
8463
|
queue: "local-and-remote",
|
|
8461
8464
|
flagship: "local-and-remote",
|
|
8465
|
+
analytics_engine: "local-and-remote",
|
|
8462
8466
|
vectorize: "remote",
|
|
8463
8467
|
mtls_certificate: "remote",
|
|
8464
8468
|
dispatch_namespace: "remote",
|
|
@@ -9166,7 +9170,7 @@ function mapWorkerMetadataBindings(bindings) {
|
|
|
9166
9170
|
__name(mapWorkerMetadataBindings, "mapWorkerMetadataBindings");
|
|
9167
9171
|
|
|
9168
9172
|
// src/default-compat-date.ts
|
|
9169
|
-
var DEFAULT_COMPAT_DATE = "2026-10-
|
|
9173
|
+
var DEFAULT_COMPAT_DATE = "2026-10-23";
|
|
9170
9174
|
|
|
9171
9175
|
// src/construct-wrangler-config.ts
|
|
9172
9176
|
function constructWranglerConfig(config) {
|
|
@@ -10012,12 +10016,14 @@ function printBindings(bindings, options) {
|
|
|
10012
10016
|
}
|
|
10013
10017
|
if (analytics_engine_datasets.length > 0) {
|
|
10014
10018
|
output.push(
|
|
10015
|
-
...analytics_engine_datasets.map(({ binding, dataset }) => {
|
|
10019
|
+
...analytics_engine_datasets.map(({ binding, dataset, remote }) => {
|
|
10016
10020
|
return {
|
|
10017
10021
|
name: binding,
|
|
10018
10022
|
type: getBindingTypeFriendlyName("analytics_engine"),
|
|
10019
10023
|
value: dataset ?? binding,
|
|
10020
|
-
mode: getMode({
|
|
10024
|
+
mode: getMode({
|
|
10025
|
+
isSimulatedLocally: context.remoteBindingsDisabled || !remote
|
|
10026
|
+
})
|
|
10021
10027
|
};
|
|
10022
10028
|
})
|
|
10023
10029
|
);
|
package/dist/local-env.d.mts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
declare function caseInsensitiveEnv(): Record<string, string>;
|
|
2
|
+
|
|
1
3
|
type LocalEnvValueSource = {
|
|
2
4
|
type: "file";
|
|
3
5
|
path: string;
|
|
@@ -8,6 +10,21 @@ interface LoadedEnv {
|
|
|
8
10
|
values: Record<string, string>;
|
|
9
11
|
sources: Record<string, LocalEnvValueSource>;
|
|
10
12
|
}
|
|
13
|
+
/**
|
|
14
|
+
* Parses dotenv contents and expands variable references without changing the
|
|
15
|
+
* supplied process environment or adding its unrelated keys to the result.
|
|
16
|
+
*
|
|
17
|
+
* Process values override file values, including explicitly empty strings. On
|
|
18
|
+
* Windows, process keys are matched case-insensitively. References can use
|
|
19
|
+
* process values and earlier file values; unresolved references become empty
|
|
20
|
+
* strings. Escape a dollar sign with `\$` to keep it literal.
|
|
21
|
+
*
|
|
22
|
+
* @param contents The dotenv contents to parse and expand.
|
|
23
|
+
* @param processEnv The process values used for expansion and overrides.
|
|
24
|
+
* Defaults to `process.env`.
|
|
25
|
+
* @returns Expanded values for the keys declared in the dotenv contents.
|
|
26
|
+
*/
|
|
27
|
+
declare function parseAndExpandDotEnv(contents: string, processEnv?: NodeJS.ProcessEnv): Record<string, string>;
|
|
11
28
|
/**
|
|
12
29
|
* Returns the local `.env` candidates in increasing precedence order.
|
|
13
30
|
*
|
|
@@ -51,4 +68,4 @@ declare function loadEnv(envDir: string | false, mode?: string): Promise<LoadedE
|
|
|
51
68
|
*/
|
|
52
69
|
declare function loadDevVars(envDir: string | false, mode?: string): Promise<Record<string, string> | undefined>;
|
|
53
70
|
|
|
54
|
-
export { type LoadedEnv, type LocalEnvValueSource, getDevVarsCandidatePaths, getEnvPaths, loadDevVars, loadEnv };
|
|
71
|
+
export { type LoadedEnv, type LocalEnvValueSource, caseInsensitiveEnv, getDevVarsCandidatePaths, getEnvPaths, loadDevVars, loadEnv, parseAndExpandDotEnv };
|
package/dist/local-env.mjs
CHANGED
|
@@ -82,6 +82,71 @@ var require_main = __commonJS({
|
|
|
82
82
|
|
|
83
83
|
// src/local-env.ts
|
|
84
84
|
var import_dotenv_expand = __toESM(require_main());
|
|
85
|
+
|
|
86
|
+
// src/case-insensitive-env.ts
|
|
87
|
+
function caseInsensitiveEnv() {
|
|
88
|
+
const tracked = /* @__PURE__ */ new Map();
|
|
89
|
+
const targetObj = {};
|
|
90
|
+
const canonical = /* @__PURE__ */ __name((property) => typeof property === "string" ? property.toLowerCase() : property, "canonical");
|
|
91
|
+
return new Proxy(targetObj, {
|
|
92
|
+
get(target, property, receiver) {
|
|
93
|
+
const actualProperty = tracked.get(canonical(property));
|
|
94
|
+
return actualProperty !== void 0 ? Reflect.get(target, actualProperty, receiver) : void 0;
|
|
95
|
+
},
|
|
96
|
+
set(target, property, value, receiver) {
|
|
97
|
+
const key = canonical(property);
|
|
98
|
+
const previous = tracked.get(key);
|
|
99
|
+
if (previous !== void 0 && previous !== property) {
|
|
100
|
+
Reflect.deleteProperty(target, previous);
|
|
101
|
+
}
|
|
102
|
+
tracked.set(key, property);
|
|
103
|
+
return Reflect.set(target, property, value, receiver);
|
|
104
|
+
},
|
|
105
|
+
has(target, property) {
|
|
106
|
+
const actualProperty = tracked.get(canonical(property));
|
|
107
|
+
return actualProperty !== void 0 ? Reflect.has(target, actualProperty) : false;
|
|
108
|
+
},
|
|
109
|
+
getOwnPropertyDescriptor(target, property) {
|
|
110
|
+
const actualProperty = tracked.get(canonical(property));
|
|
111
|
+
return actualProperty !== void 0 ? Reflect.getOwnPropertyDescriptor(target, actualProperty) : void 0;
|
|
112
|
+
},
|
|
113
|
+
defineProperty(target, property, descriptor) {
|
|
114
|
+
const key = canonical(property);
|
|
115
|
+
const previous = tracked.get(key);
|
|
116
|
+
if (previous !== void 0 && previous !== property) {
|
|
117
|
+
Reflect.deleteProperty(target, previous);
|
|
118
|
+
}
|
|
119
|
+
tracked.set(key, property);
|
|
120
|
+
return Reflect.defineProperty(target, property, descriptor);
|
|
121
|
+
},
|
|
122
|
+
deleteProperty(target, property) {
|
|
123
|
+
const key = canonical(property);
|
|
124
|
+
const actualProperty = tracked.get(key);
|
|
125
|
+
tracked.delete(key);
|
|
126
|
+
return actualProperty !== void 0 ? Reflect.deleteProperty(target, actualProperty) : Reflect.deleteProperty(target, property);
|
|
127
|
+
}
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
__name(caseInsensitiveEnv, "caseInsensitiveEnv");
|
|
131
|
+
|
|
132
|
+
// src/local-env.ts
|
|
133
|
+
function parseAndExpandDotEnv(contents, processEnv = process.env) {
|
|
134
|
+
return expandParsedDotEnv(parse(contents), processEnv);
|
|
135
|
+
}
|
|
136
|
+
__name(parseAndExpandDotEnv, "parseAndExpandDotEnv");
|
|
137
|
+
function expandParsedDotEnv(parsed, processEnv) {
|
|
138
|
+
const expanded = { ...parsed };
|
|
139
|
+
const expandedKeys = Object.keys(expanded);
|
|
140
|
+
const processEnvOverrides = copyProcessEnv(processEnv);
|
|
141
|
+
(0, import_dotenv_expand.expand)({ parsed: expanded, processEnv: copyProcessEnv(processEnv) });
|
|
142
|
+
for (const key of expandedKeys) {
|
|
143
|
+
if (Object.hasOwn(processEnvOverrides, key)) {
|
|
144
|
+
expanded[key] = processEnvOverrides[key];
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
return expanded;
|
|
148
|
+
}
|
|
149
|
+
__name(expandParsedDotEnv, "expandParsedDotEnv");
|
|
85
150
|
function getEnvPaths(envDir, mode) {
|
|
86
151
|
if (envDir === false) {
|
|
87
152
|
return [];
|
|
@@ -123,9 +188,8 @@ async function loadEnv(envDir, mode) {
|
|
|
123
188
|
parsedSources[key] = { type: "file", path: loaded.path };
|
|
124
189
|
}
|
|
125
190
|
}
|
|
126
|
-
const processEnv = copyProcessEnv();
|
|
127
|
-
|
|
128
|
-
const values = { ...parsed };
|
|
191
|
+
const processEnv = copyProcessEnv(process.env);
|
|
192
|
+
const values = expandParsedDotEnv(parsed, processEnv);
|
|
129
193
|
const sources = { ...parsedSources };
|
|
130
194
|
for (const [key, value] of Object.entries(processEnv)) {
|
|
131
195
|
values[key] = value;
|
|
@@ -167,13 +231,15 @@ function isMissingFileError(error) {
|
|
|
167
231
|
return error instanceof Error && "code" in error && (error.code === "ENOENT" || error.code === "ENOTDIR");
|
|
168
232
|
}
|
|
169
233
|
__name(isMissingFileError, "isMissingFileError");
|
|
170
|
-
function copyProcessEnv() {
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
234
|
+
function copyProcessEnv(processEnv) {
|
|
235
|
+
const copied = process.platform === "win32" ? caseInsensitiveEnv() : {};
|
|
236
|
+
for (const [key, value] of Object.entries(processEnv)) {
|
|
237
|
+
if (value !== void 0) {
|
|
238
|
+
copied[key] = value;
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
return copied;
|
|
176
242
|
}
|
|
177
243
|
__name(copyProcessEnv, "copyProcessEnv");
|
|
178
244
|
|
|
179
|
-
export { getDevVarsCandidatePaths, getEnvPaths, loadDevVars, loadEnv };
|
|
245
|
+
export { caseInsensitiveEnv, getDevVarsCandidatePaths, getEnvPaths, loadDevVars, loadEnv, parseAndExpandDotEnv };
|