@maverickcer/env-cap 0.5.2 → 0.6.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/README.md +11 -5
- package/dist/.dts/build/assemble-project.d.ts +1 -1
- package/dist/.dts/build/assemble-project.d.ts.map +1 -1
- package/dist/.dts/build/change-model.d.ts.map +1 -1
- package/dist/.dts/build/check-artifacts.d.ts.map +1 -1
- package/dist/.dts/build/citation-verification.d.ts.map +1 -1
- package/dist/.dts/build/compatibility.d.ts.map +1 -1
- package/dist/.dts/build/compiler-api.d.ts +15 -0
- package/dist/.dts/build/compiler-api.d.ts.map +1 -0
- package/dist/.dts/build/dependency-graph.d.ts +3 -1
- package/dist/.dts/build/dependency-graph.d.ts.map +1 -1
- package/dist/.dts/build/dependency-model.d.ts.map +1 -1
- package/dist/.dts/build/discover.d.ts.map +1 -1
- package/dist/.dts/build/docs.d.ts +1 -1
- package/dist/.dts/build/docs.d.ts.map +1 -1
- package/dist/.dts/build/env-example.d.ts.map +1 -1
- package/dist/.dts/build/evidence-cache.d.ts +1 -1
- package/dist/.dts/build/evidence-cache.d.ts.map +1 -1
- package/dist/.dts/build/evidence-model.d.ts +2 -2
- package/dist/.dts/build/evidence-snapshot.d.ts +25 -0
- package/dist/.dts/build/evidence-snapshot.d.ts.map +1 -1
- package/dist/.dts/build/finding-model.d.ts +1 -1
- package/dist/.dts/build/finding-model.d.ts.map +1 -1
- package/dist/.dts/build/generate-documentation.d.ts.map +1 -1
- package/dist/.dts/build/generate-env-artifacts.d.ts +23 -8
- package/dist/.dts/build/generate-env-artifacts.d.ts.map +1 -1
- package/dist/.dts/build/generate-evidence.d.ts.map +1 -1
- package/dist/.dts/build/generate-manifest.d.ts +1 -1
- package/dist/.dts/build/generate-manifest.d.ts.map +1 -1
- package/dist/.dts/build/generate-usage.d.ts +3 -3
- package/dist/.dts/build/generate-usage.d.ts.map +1 -1
- package/dist/.dts/build/generated-banner.d.ts +15 -3
- package/dist/.dts/build/generated-banner.d.ts.map +1 -1
- package/dist/.dts/build/glob.d.ts.map +1 -1
- package/dist/.dts/build/index.d.ts +2 -2
- package/dist/.dts/build/lifecycle-model.d.ts.map +1 -1
- package/dist/.dts/build/link.d.ts.map +1 -1
- package/dist/.dts/build/literal-eval.d.ts +4 -3
- package/dist/.dts/build/literal-eval.d.ts.map +1 -1
- package/dist/.dts/build/live-expirations.d.ts.map +1 -1
- package/dist/.dts/build/manifest.d.ts.map +1 -1
- package/dist/.dts/build/parse.d.ts +12 -12
- package/dist/.dts/build/parse.d.ts.map +1 -1
- package/dist/.dts/build/reference-projections.d.ts +17 -3
- package/dist/.dts/build/reference-projections.d.ts.map +1 -1
- package/dist/.dts/build/resolution/resolve-import.d.ts +5 -0
- package/dist/.dts/build/resolution/resolve-import.d.ts.map +1 -1
- package/dist/.dts/build/resolution/resolve-package-schema.d.ts +1 -1
- package/dist/.dts/build/resolution/resolve-package-schema.d.ts.map +1 -1
- package/dist/.dts/build/resolution/resolve-tsconfig-paths.d.ts +20 -2
- package/dist/.dts/build/resolution/resolve-tsconfig-paths.d.ts.map +1 -1
- package/dist/.dts/build/sarif.d.ts.map +1 -1
- package/dist/.dts/build/scan-dependencies.d.ts +23 -0
- package/dist/.dts/build/scan-dependencies.d.ts.map +1 -1
- package/dist/.dts/build/types.d.ts +1 -1
- package/dist/.dts/build/typescript.d.ts +20 -0
- package/dist/.dts/build/typescript.d.ts.map +1 -0
- package/dist/.dts/build/usage-report.d.ts.map +1 -1
- package/dist/.dts/cli/filesystem.d.ts +4 -0
- package/dist/.dts/cli/filesystem.d.ts.map +1 -1
- package/dist/.dts/eslint-plugin/glob.d.ts.map +1 -1
- package/dist/.dts/eslint-plugin/index.d.ts +2 -2
- package/dist/.dts/eslint-plugin/no-node-fs.d.ts.map +1 -1
- package/dist/.dts/eslint-plugin/no-raw-process-env.d.ts.map +1 -1
- package/dist/.dts/evidence/index.d.ts +2 -2
- package/dist/.dts/helpers/index.d.ts +2 -2
- package/dist/.dts/helpers/processors.d.ts.map +1 -1
- package/dist/.dts/helpers/validators.d.ts.map +1 -1
- package/dist/.dts/runtime/cache.d.ts +0 -3
- package/dist/.dts/runtime/cache.d.ts.map +1 -1
- package/dist/.dts/runtime/create.d.ts.map +1 -1
- package/dist/.dts/runtime/document.d.ts.map +1 -1
- package/dist/.dts/runtime/index.d.ts +2 -2
- package/dist/.dts/runtime/registry.d.ts.map +1 -1
- package/dist/.dts/runtime/validate.d.ts.map +1 -1
- package/dist/{build-FPFNFLDI.js → build-H4KFV44Z.js} +501 -599
- package/dist/build-H4KFV44Z.js.map +1 -0
- package/dist/build.cjs +516 -607
- package/dist/build.cjs.map +1 -1
- package/dist/build.js +513 -605
- package/dist/build.js.map +1 -1
- package/dist/{chunk-HBSIU37C.js → chunk-7GVPOHDU.js} +2 -2
- package/dist/chunk-7GVPOHDU.js.map +1 -0
- package/dist/cli/index.js +35 -41
- package/dist/cli/index.js.map +1 -1
- package/dist/eslint-plugin/index.cjs +15 -576
- package/dist/eslint-plugin/index.cjs.map +1 -1
- package/dist/eslint-plugin/index.js +15 -576
- package/dist/eslint-plugin/index.js.map +1 -1
- package/dist/evidence.cjs.map +1 -1
- package/dist/evidence.js.map +1 -1
- package/dist/helpers.cjs +4 -9
- package/dist/helpers.cjs.map +1 -1
- package/dist/helpers.js +4 -9
- package/dist/helpers.js.map +1 -1
- package/dist/index.cjs +11 -25
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +11 -25
- package/dist/index.js.map +1 -1
- package/dist/node.cjs +10 -8
- package/dist/node.cjs.map +1 -1
- package/dist/node.js +10 -8
- package/dist/node.js.map +1 -1
- package/node_modules/@typescript/old/LICENSE.txt +55 -0
- package/node_modules/@typescript/old/README.md +50 -0
- package/node_modules/@typescript/old/SECURITY.md +39 -0
- package/node_modules/@typescript/old/ThirdPartyNoticeText.txt +193 -0
- package/node_modules/@typescript/old/bin/tsc +2 -0
- package/node_modules/@typescript/old/bin/tsserver +2 -0
- package/node_modules/@typescript/old/lib/_tsc.js +134465 -0
- package/node_modules/@typescript/old/lib/_tsserver.js +659 -0
- package/node_modules/@typescript/old/lib/_typingsInstaller.js +222 -0
- package/node_modules/@typescript/old/lib/cs/diagnosticMessages.generated.json +2129 -0
- package/node_modules/@typescript/old/lib/de/diagnosticMessages.generated.json +2125 -0
- package/node_modules/@typescript/old/lib/es/diagnosticMessages.generated.json +2129 -0
- package/node_modules/@typescript/old/lib/fr/diagnosticMessages.generated.json +2129 -0
- package/node_modules/@typescript/old/lib/it/diagnosticMessages.generated.json +2125 -0
- package/node_modules/@typescript/old/lib/ja/diagnosticMessages.generated.json +2129 -0
- package/node_modules/@typescript/old/lib/ko/diagnosticMessages.generated.json +2129 -0
- package/node_modules/@typescript/old/lib/lib.d.ts +20 -0
- package/node_modules/@typescript/old/lib/lib.decorators.d.ts +382 -0
- package/node_modules/@typescript/old/lib/lib.decorators.legacy.d.ts +20 -0
- package/node_modules/@typescript/old/lib/lib.dom.asynciterable.d.ts +18 -0
- package/node_modules/@typescript/old/lib/lib.dom.d.ts +45125 -0
- package/node_modules/@typescript/old/lib/lib.dom.iterable.d.ts +18 -0
- package/node_modules/@typescript/old/lib/lib.es2015.collection.d.ts +150 -0
- package/node_modules/@typescript/old/lib/lib.es2015.core.d.ts +595 -0
- package/node_modules/@typescript/old/lib/lib.es2015.d.ts +26 -0
- package/node_modules/@typescript/old/lib/lib.es2015.generator.d.ts +75 -0
- package/node_modules/@typescript/old/lib/lib.es2015.iterable.d.ts +603 -0
- package/node_modules/@typescript/old/lib/lib.es2015.promise.d.ts +79 -0
- package/node_modules/@typescript/old/lib/lib.es2015.proxy.d.ts +126 -0
- package/node_modules/@typescript/old/lib/lib.es2015.reflect.d.ts +142 -0
- package/node_modules/@typescript/old/lib/lib.es2015.symbol.d.ts +44 -0
- package/node_modules/@typescript/old/lib/lib.es2015.symbol.wellknown.d.ts +324 -0
- package/node_modules/@typescript/old/lib/lib.es2016.array.include.d.ts +114 -0
- package/node_modules/@typescript/old/lib/lib.es2016.d.ts +19 -0
- package/node_modules/@typescript/old/lib/lib.es2016.full.d.ts +21 -0
- package/node_modules/@typescript/old/lib/lib.es2016.intl.d.ts +29 -0
- package/node_modules/@typescript/old/lib/lib.es2017.arraybuffer.d.ts +19 -0
- package/node_modules/@typescript/old/lib/lib.es2017.d.ts +24 -0
- package/node_modules/@typescript/old/lib/lib.es2017.date.d.ts +29 -0
- package/node_modules/@typescript/old/lib/lib.es2017.full.d.ts +21 -0
- package/node_modules/@typescript/old/lib/lib.es2017.intl.d.ts +42 -0
- package/node_modules/@typescript/old/lib/lib.es2017.object.d.ts +47 -0
- package/node_modules/@typescript/old/lib/lib.es2017.sharedmemory.d.ts +133 -0
- package/node_modules/@typescript/old/lib/lib.es2017.string.d.ts +43 -0
- package/node_modules/@typescript/old/lib/lib.es2017.typedarrays.d.ts +51 -0
- package/node_modules/@typescript/old/lib/lib.es2018.asyncgenerator.d.ts +75 -0
- package/node_modules/@typescript/old/lib/lib.es2018.asynciterable.d.ts +51 -0
- package/node_modules/@typescript/old/lib/lib.es2018.d.ts +22 -0
- package/node_modules/@typescript/old/lib/lib.es2018.full.d.ts +22 -0
- package/node_modules/@typescript/old/lib/lib.es2018.intl.d.ts +81 -0
- package/node_modules/@typescript/old/lib/lib.es2018.promise.d.ts +28 -0
- package/node_modules/@typescript/old/lib/lib.es2018.regexp.d.ts +35 -0
- package/node_modules/@typescript/old/lib/lib.es2019.array.d.ts +77 -0
- package/node_modules/@typescript/old/lib/lib.es2019.d.ts +22 -0
- package/node_modules/@typescript/old/lib/lib.es2019.full.d.ts +22 -0
- package/node_modules/@typescript/old/lib/lib.es2019.intl.d.ts +21 -0
- package/node_modules/@typescript/old/lib/lib.es2019.object.d.ts +31 -0
- package/node_modules/@typescript/old/lib/lib.es2019.string.d.ts +35 -0
- package/node_modules/@typescript/old/lib/lib.es2019.symbol.d.ts +22 -0
- package/node_modules/@typescript/old/lib/lib.es2020.bigint.d.ts +763 -0
- package/node_modules/@typescript/old/lib/lib.es2020.d.ts +25 -0
- package/node_modules/@typescript/old/lib/lib.es2020.date.d.ts +40 -0
- package/node_modules/@typescript/old/lib/lib.es2020.full.d.ts +22 -0
- package/node_modules/@typescript/old/lib/lib.es2020.intl.d.ts +472 -0
- package/node_modules/@typescript/old/lib/lib.es2020.number.d.ts +26 -0
- package/node_modules/@typescript/old/lib/lib.es2020.promise.d.ts +45 -0
- package/node_modules/@typescript/old/lib/lib.es2020.sharedmemory.d.ts +97 -0
- package/node_modules/@typescript/old/lib/lib.es2020.string.d.ts +42 -0
- package/node_modules/@typescript/old/lib/lib.es2020.symbol.wellknown.d.ts +39 -0
- package/node_modules/@typescript/old/lib/lib.es2021.d.ts +21 -0
- package/node_modules/@typescript/old/lib/lib.es2021.full.d.ts +22 -0
- package/node_modules/@typescript/old/lib/lib.es2021.intl.d.ts +164 -0
- package/node_modules/@typescript/old/lib/lib.es2021.promise.d.ts +46 -0
- package/node_modules/@typescript/old/lib/lib.es2021.string.d.ts +31 -0
- package/node_modules/@typescript/old/lib/lib.es2021.weakref.d.ts +76 -0
- package/node_modules/@typescript/old/lib/lib.es2022.array.d.ts +119 -0
- package/node_modules/@typescript/old/lib/lib.es2022.d.ts +23 -0
- package/node_modules/@typescript/old/lib/lib.es2022.error.d.ts +73 -0
- package/node_modules/@typescript/old/lib/lib.es2022.full.d.ts +22 -0
- package/node_modules/@typescript/old/lib/lib.es2022.intl.d.ts +143 -0
- package/node_modules/@typescript/old/lib/lib.es2022.object.d.ts +24 -0
- package/node_modules/@typescript/old/lib/lib.es2022.regexp.d.ts +37 -0
- package/node_modules/@typescript/old/lib/lib.es2022.string.d.ts +23 -0
- package/node_modules/@typescript/old/lib/lib.es2023.array.d.ts +922 -0
- package/node_modules/@typescript/old/lib/lib.es2023.collection.d.ts +19 -0
- package/node_modules/@typescript/old/lib/lib.es2023.d.ts +20 -0
- package/node_modules/@typescript/old/lib/lib.es2023.full.d.ts +22 -0
- package/node_modules/@typescript/old/lib/lib.es2023.intl.d.ts +62 -0
- package/node_modules/@typescript/old/lib/lib.es2024.arraybuffer.d.ts +63 -0
- package/node_modules/@typescript/old/lib/lib.es2024.collection.d.ts +27 -0
- package/node_modules/@typescript/old/lib/lib.es2024.d.ts +24 -0
- package/node_modules/@typescript/old/lib/lib.es2024.full.d.ts +22 -0
- package/node_modules/@typescript/old/lib/lib.es2024.object.d.ts +27 -0
- package/node_modules/@typescript/old/lib/lib.es2024.promise.d.ts +33 -0
- package/node_modules/@typescript/old/lib/lib.es2024.regexp.d.ts +23 -0
- package/node_modules/@typescript/old/lib/lib.es2024.sharedmemory.d.ts +66 -0
- package/node_modules/@typescript/old/lib/lib.es2024.string.d.ts +27 -0
- package/node_modules/@typescript/old/lib/lib.es2025.collection.d.ts +94 -0
- package/node_modules/@typescript/old/lib/lib.es2025.d.ts +23 -0
- package/node_modules/@typescript/old/lib/lib.es2025.float16.d.ts +443 -0
- package/node_modules/@typescript/old/lib/lib.es2025.full.d.ts +22 -0
- package/node_modules/@typescript/old/lib/lib.es2025.intl.d.ts +200 -0
- package/node_modules/@typescript/old/lib/lib.es2025.iterator.d.ts +146 -0
- package/node_modules/@typescript/old/lib/lib.es2025.promise.d.ts +32 -0
- package/node_modules/@typescript/old/lib/lib.es2025.regexp.d.ts +30 -0
- package/node_modules/@typescript/old/lib/lib.es5.d.ts +4599 -0
- package/node_modules/@typescript/old/lib/lib.es6.d.ts +21 -0
- package/node_modules/@typescript/old/lib/lib.esnext.array.d.ts +33 -0
- package/node_modules/@typescript/old/lib/lib.esnext.collection.d.ts +47 -0
- package/node_modules/@typescript/old/lib/lib.esnext.d.ts +27 -0
- package/node_modules/@typescript/old/lib/lib.esnext.date.d.ts +21 -0
- package/node_modules/@typescript/old/lib/lib.esnext.decorators.d.ts +26 -0
- package/node_modules/@typescript/old/lib/lib.esnext.disposable.d.ts +191 -0
- package/node_modules/@typescript/old/lib/lib.esnext.error.d.ts +22 -0
- package/node_modules/@typescript/old/lib/lib.esnext.full.d.ts +22 -0
- package/node_modules/@typescript/old/lib/lib.esnext.intl.d.ts +107 -0
- package/node_modules/@typescript/old/lib/lib.esnext.sharedmemory.d.ts +23 -0
- package/node_modules/@typescript/old/lib/lib.esnext.temporal.d.ts +485 -0
- package/node_modules/@typescript/old/lib/lib.esnext.typedarrays.d.ts +90 -0
- package/node_modules/@typescript/old/lib/lib.scripthost.d.ts +320 -0
- package/node_modules/@typescript/old/lib/lib.webworker.asynciterable.d.ts +18 -0
- package/node_modules/@typescript/old/lib/lib.webworker.d.ts +15606 -0
- package/node_modules/@typescript/old/lib/lib.webworker.importscripts.d.ts +21 -0
- package/node_modules/@typescript/old/lib/lib.webworker.iterable.d.ts +18 -0
- package/node_modules/@typescript/old/lib/pl/diagnosticMessages.generated.json +2129 -0
- package/node_modules/@typescript/old/lib/pt-br/diagnosticMessages.generated.json +2129 -0
- package/node_modules/@typescript/old/lib/ru/diagnosticMessages.generated.json +2125 -0
- package/node_modules/@typescript/old/lib/tr/diagnosticMessages.generated.json +2129 -0
- package/node_modules/@typescript/old/lib/tsc.js +8 -0
- package/node_modules/@typescript/old/lib/tsserver.js +8 -0
- package/node_modules/@typescript/old/lib/tsserverlibrary.d.ts +17 -0
- package/node_modules/@typescript/old/lib/tsserverlibrary.js +21 -0
- package/node_modules/@typescript/old/lib/typesMap.json +497 -0
- package/node_modules/@typescript/old/lib/typescript.d.ts +11448 -0
- package/node_modules/@typescript/old/lib/typescript.js +201039 -0
- package/node_modules/@typescript/old/lib/typingsInstaller.js +8 -0
- package/node_modules/@typescript/old/lib/watchGuard.js +53 -0
- package/node_modules/@typescript/old/lib/zh-cn/diagnosticMessages.generated.json +2129 -0
- package/node_modules/@typescript/old/lib/zh-tw/diagnosticMessages.generated.json +2125 -0
- package/node_modules/@typescript/old/package.json +118 -0
- package/node_modules/@typescript/typescript6/LICENSE.txt +55 -0
- package/node_modules/@typescript/typescript6/README.md +9 -0
- package/node_modules/@typescript/typescript6/bin/tsc6 +2 -0
- package/node_modules/@typescript/typescript6/lib/tsc.js +1 -0
- package/node_modules/@typescript/typescript6/lib/tsserverlibrary.d.ts +2 -0
- package/node_modules/@typescript/typescript6/lib/tsserverlibrary.js +1 -0
- package/node_modules/@typescript/typescript6/lib/typescript.d.ts +2 -0
- package/node_modules/@typescript/typescript6/lib/typescript.js +1 -0
- package/node_modules/@typescript/typescript6/package.json +39 -0
- package/package.json +35 -15
- package/schemas/env-cap-report.schema.json +1 -1
- package/dist/build-FPFNFLDI.js.map +0 -1
- package/dist/chunk-HBSIU37C.js.map +0 -1
package/dist/index.cjs
CHANGED
|
@@ -5,7 +5,7 @@ var state = createState();
|
|
|
5
5
|
var contractValues = /* @__PURE__ */ new Map();
|
|
6
6
|
var contractErrors = /* @__PURE__ */ new Map();
|
|
7
7
|
function createState() {
|
|
8
|
-
return {
|
|
8
|
+
return { contractIds: /* @__PURE__ */ new Set() };
|
|
9
9
|
}
|
|
10
10
|
function getState() {
|
|
11
11
|
return state;
|
|
@@ -89,9 +89,8 @@ function getContractInternals(contract) {
|
|
|
89
89
|
return internals;
|
|
90
90
|
}
|
|
91
91
|
function isEnvContract(value) {
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
return internalsByContract.has(value);
|
|
92
|
+
const key = value;
|
|
93
|
+
return typeof value === "object" && internalsByContract.has(key);
|
|
95
94
|
}
|
|
96
95
|
|
|
97
96
|
// src/runtime/create.ts
|
|
@@ -103,13 +102,6 @@ function createEnv(schema, options = {}) {
|
|
|
103
102
|
for (const key of Object.keys(schema)) {
|
|
104
103
|
Object.defineProperty(contract, key, {
|
|
105
104
|
enumerable: true,
|
|
106
|
-
// Redundant with `Object.freeze(contract)` below (runs after every
|
|
107
|
-
// `defineProperty` call in this function, and forces `configurable:
|
|
108
|
-
// false` on every own property regardless of what was set here) --
|
|
109
|
-
// kept only as the conventional default for a getter no one should
|
|
110
|
-
// reconfigure, not because anything could observe the difference.
|
|
111
|
-
// Stryker disable next-line BooleanLiteral
|
|
112
|
-
configurable: false,
|
|
113
105
|
get() {
|
|
114
106
|
const error = getContractError(internals.id);
|
|
115
107
|
if (error) throw error;
|
|
@@ -139,7 +131,7 @@ function createEnv(schema, options = {}) {
|
|
|
139
131
|
}
|
|
140
132
|
|
|
141
133
|
// src/runtime/document.ts
|
|
142
|
-
function documentEnv(
|
|
134
|
+
function documentEnv() {
|
|
143
135
|
}
|
|
144
136
|
|
|
145
137
|
// src/runtime/reset.ts
|
|
@@ -150,16 +142,15 @@ function resetEnvCache() {
|
|
|
150
142
|
// src/runtime/validate.ts
|
|
151
143
|
async function validateEnv(options) {
|
|
152
144
|
const state2 = getState();
|
|
153
|
-
if (state2.
|
|
145
|
+
if (state2.result) {
|
|
154
146
|
return state2.result;
|
|
155
147
|
}
|
|
156
|
-
if (state2.
|
|
148
|
+
if (state2.error) {
|
|
157
149
|
throw state2.error;
|
|
158
150
|
}
|
|
159
151
|
if (state2.inFlight) {
|
|
160
152
|
return state2.inFlight;
|
|
161
153
|
}
|
|
162
|
-
state2.status = "validating";
|
|
163
154
|
const run = runValidation(options, state2);
|
|
164
155
|
state2.inFlight = run;
|
|
165
156
|
try {
|
|
@@ -175,18 +166,15 @@ async function runValidation(options, state2) {
|
|
|
175
166
|
const failures = [];
|
|
176
167
|
let variableCount = 0;
|
|
177
168
|
const activeContexts = options.activeContexts?.length ? new Set(options.activeContexts) : void 0;
|
|
178
|
-
const resolved =
|
|
179
|
-
for (const contract of options.manifest) {
|
|
169
|
+
const resolved = options.manifest.map((contract) => {
|
|
180
170
|
const internals = getContractInternals(contract);
|
|
181
171
|
const values = {};
|
|
182
|
-
for (const key of Object.
|
|
183
|
-
const definition = internals.schema[key];
|
|
184
|
-
if (definition === void 0) continue;
|
|
172
|
+
for (const [key, definition] of Object.entries(internals.schema)) {
|
|
185
173
|
if (!matchesContext(definition.context, activeContexts)) continue;
|
|
186
174
|
variableCount += 1;
|
|
187
175
|
const raw = options.values[key];
|
|
188
176
|
let working = raw;
|
|
189
|
-
if (working === void 0
|
|
177
|
+
if (working === void 0) {
|
|
190
178
|
working = typeof definition.default === "function" ? definition.default() : definition.default;
|
|
191
179
|
}
|
|
192
180
|
let processed = working;
|
|
@@ -224,15 +212,14 @@ async function runValidation(options, state2) {
|
|
|
224
212
|
}
|
|
225
213
|
values[key] = processed;
|
|
226
214
|
}
|
|
227
|
-
resolved.push({ id: internals.id, values });
|
|
228
215
|
state2.contractIds.add(internals.id);
|
|
229
|
-
|
|
216
|
+
return { id: internals.id, values };
|
|
217
|
+
});
|
|
230
218
|
if (failures.length > 0) {
|
|
231
219
|
const error = new EnvValidationError(failures);
|
|
232
220
|
for (const { id } of resolved) {
|
|
233
221
|
setContractError(id, error);
|
|
234
222
|
}
|
|
235
|
-
state2.status = "failed";
|
|
236
223
|
state2.error = error;
|
|
237
224
|
throw error;
|
|
238
225
|
}
|
|
@@ -243,7 +230,6 @@ async function runValidation(options, state2) {
|
|
|
243
230
|
contractCount: options.manifest.length,
|
|
244
231
|
variableCount
|
|
245
232
|
};
|
|
246
|
-
state2.status = "ready";
|
|
247
233
|
state2.result = result;
|
|
248
234
|
return result;
|
|
249
235
|
}
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/runtime/cache.ts","../src/runtime/errors.ts","../src/runtime/registry.ts","../src/runtime/create.ts","../src/runtime/document.ts","../src/runtime/reset.ts","../src/runtime/validate.ts"],"names":["state"],"mappings":";;;AAyBA,IAAI,QAAoB,WAAA,EAAY;AACpC,IAAM,cAAA,uBAAqB,GAAA,EAA+C;AAC1E,IAAM,cAAA,uBAAqB,GAAA,EAAgC;AAE3D,SAAS,WAAA,GAA0B;AACjC,EAAA,OAAO,EAAE,MAAA,EAAQ,eAAA,EAAiB,WAAA,kBAAa,IAAI,KAAI,EAAE;AAC3D;AAEO,SAAS,QAAA,GAAuB;AACrC,EAAA,OAAO,KAAA;AACT;AAEO,SAAS,kBAAkB,EAAA,EAA2D;AAC3F,EAAA,OAAO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nimport type { validateEnvResult } from \"./types.js\"\n\ntype CacheStatus = \"uninitialized\" | \"validating\" | \"ready\" | \"failed\"\n\nexport interface CacheState {\n status: CacheStatus\n /** ids of every contract validated as part of this initialization, so resetEnvCache() can clean up precisely. */\n contractIds: Set<symbol>\n result?: validateEnvResult\n error?: EnvValidationError\n inFlight?: Promise<validateEnvResult>\n}\n\n/**\n * All shared state lives here -- nothing is exported except the accessor\n * functions below, and every write goes through them. Values are frozen\n * before they ever reach `contractValues`, so once set, a contract's\n * resolved record cannot be mutated in place.\n *\n * There is a single global state, not one per \"runtime\": a process validates\n * its environment once, at startup. Server and client contexts never share a\n * process (server code and a browser bundle are two separate processes), so\n * there's nothing to key a second state by.\n */\nlet state: CacheState = createState()\nconst contractValues = new Map<symbol, Readonly<Record<string, unknown>>>()\nconst contractErrors = new Map<symbol, EnvValidationError>()\n\nfunction createState(): CacheState {\n return { status: \"uninitialized\", contractIds: new Set() }\n}\n\nexport function getState(): CacheState {\n return state\n}\n\nexport function getContractValues(id: symbol): Readonly<Record<string, unknown>> | undefined {\n return contractValues.get(id)\n}\n\nexport function setContractValues(id: symbol, values: Readonly<Record<string, unknown>>): void {\n contractValues.set(id, values)\n}\n\nexport function getContractError(id: symbol): EnvValidationError | undefined {\n return contractErrors.get(id)\n}\n\nexport function setContractError(id: symbol, error: EnvValidationError): void {\n contractErrors.set(id, error)\n}\n\n/** Clears cached state: the global status plus every contract validated as part of it. */\nexport function resetCache(): void {\n for (const id of state.contractIds) {\n contractValues.delete(id)\n contractErrors.delete(id)\n }\n state = createState()\n}\n","/**\n * Every error type here is constructed only from: the variable name, the\n * declaring contract's name, the failure kind, and a message string that the\n * *developer's own* processor/validator produced. Raw or processed environment\n * values are never read into an error -- see the Security section in the README.\n *\n * Documentation (description, owner, etc.) never appears here, even when a\n * {@link documentEnv} call exists for this variable -- `documentEnv` is\n * build-time-only and its data is never retained anywhere {@link validateEnv}\n * could read it back out. This is a deliberate consequence of keeping the\n * runtime minimal, not an oversight.\n */\n\n/** One variable's processing or validation failure, as recorded by {@link validateEnv}. */\nexport interface VariableFailure {\n /** The schema key that failed. */\n readonly variable: string\n /** The declaring contract's `name` (see {@link CreateEnvOptions}). */\n readonly contractName: string\n /** `import.meta.url` (or similar) passed to `createEnv`'s `source` option, if any. Falls back to `contractName` when absent. */\n readonly source: string | undefined\n /** Which stage produced the failure. */\n readonly kind: \"processor\" | \"validator\"\n /** The error message from the developer's own processor/validator, or the thrown error's message. */\n readonly message: string\n}\n\nfunction formatFailure(failure: VariableFailure): string {\n const heading = failure.kind === \"processor\" ? \"Processor failed:\" : \"Validation failed:\"\n const lines = [\n failure.variable,\n \"-\".repeat(Math.max(failure.variable.length, 3)),\n heading,\n failure.message,\n ]\n\n lines.push(\"\", \"Source:\", failure.source ?? failure.contractName)\n\n return lines.join(\"\\n\")\n}\n\nfunction formatReport(failures: readonly VariableFailure[]): string {\n const count = failures.length\n const noun = count === 1 ? \"configuration error\" : \"configuration errors\"\n const header = `Environment validation failed.\\n\\n${count} ${noun} found:`\n const blocks = failures.map(formatFailure)\n return [header, ...blocks].join(\"\\n\\n\")\n}\n\n/**\n * Thrown by {@link validateEnv} when one or more variables fail processing or\n * validation. Aggregates every failure across every contract in the batch --\n * the caller sees the whole picture in one error, not one-at-a-time.\n *\n * @remarks\n * `code` is a stable, Stable-tier discriminant for programmatic handling --\n * prefer it over `.name`/`instanceof` when a message-independent switch is needed.\n */\nexport class EnvValidationError extends Error {\n /** Stable discriminant for programmatic handling; always `\"ENV_VALIDATION_FAILED\"`. */\n readonly code = \"ENV_VALIDATION_FAILED\"\n /** Every variable failure across every contract in the batch. */\n readonly failures: readonly VariableFailure[]\n\n constructor(failures: readonly VariableFailure[]) {\n super(formatReport(failures))\n this.name = \"EnvValidationError\"\n this.failures = failures\n Error.captureStackTrace?.(this, EnvValidationError)\n }\n}\n\n/**\n * Thrown when a contract's value is accessed via property access before\n * {@link validateEnv} has completed successfully for it.\n *\n * @remarks\n * `code` is a stable, Stable-tier discriminant for programmatic handling --\n * prefer it over `.name`/`instanceof` when a message-independent switch is needed.\n */\nexport class EnvNotReadyError extends Error {\n /** Stable discriminant for programmatic handling; always `\"ENV_NOT_READY\"`. */\n readonly code = \"ENV_NOT_READY\"\n\n constructor(contractName: string, key: string) {\n const target = `\"${contractName}\".${key}`\n super(\n `Environment contract ${target} has not been validated yet. ` +\n \"Call validateEnv() during application startup before accessing environment values.\",\n )\n this.name = \"EnvNotReadyError\"\n Error.captureStackTrace?.(this, EnvNotReadyError)\n }\n}\n","import type { ContractInternals } from \"./types.js\"\n\n/**\n * Private map from a contract object (returned by `createEnv`) to its internal\n * identity/schema. Not exported from the package -- this is the only place\n * that ever associates a contract with its schema, so `validateEnv()`\n * cannot accidentally read across contracts.\n */\nconst internalsByContract = new WeakMap<object, ContractInternals>()\n\n/** Associates a contract object with its internal identity/schema. Called once, by `createEnv`. */\nexport function registerContract(contract: object, internals: ContractInternals): void {\n internalsByContract.set(contract, internals)\n}\n\n/**\n * Looks up a contract's internal identity/schema.\n *\n * @throws {TypeError} If `contract` wasn't returned by `createEnv` (and so was never registered).\n */\nexport function getContractInternals(contract: object): ContractInternals {\n const internals = internalsByContract.get(contract)\n if (!internals) {\n throw new TypeError(\n \"env-cap: this value was not created by createEnv(). \" +\n \"validateEnv() and resetEnvCache() only accept contracts returned from createEnv().\",\n )\n }\n return internals\n}\n\n/** Type guard: `true` when `value` was created by `createEnv` (i.e. is a registered contract). */\nexport function isEnvContract(value: unknown): value is object {\n if (typeof value !== \"object\") return false\n // Split onto its own line (rather than one `&&`-chained expression) so\n // this one check's disable directive can't also silence the still-real,\n // still-tested `typeof` check above. Runtime-redundant on its own --\n // hand-verified: `WeakMap.prototype.has(null)` is spec-guaranteed to\n // return `false` (never throws for a non-object key), so `.has(value)`\n // alone already does the right thing for `null`, the one value where\n // `typeof value === \"object\"` is true but `value` isn't really an object.\n // Kept as a real check anyway because TS needs SOME `null` exclusion here\n // to accept `value` as an `object` below (`typeof value === \"object\"`\n // alone narrows to `object | null`, TS's one special case for `typeof`) --\n // tried a cast/assertion instead (`value as object` / `value!`) and hit an\n // unresolvable conflict in this repo's eslint config: `src/**` bans `!`\n // (`no-non-null-assertion`) while the sibling `non-nullable-type-\n // assertion-style` rule then demands `!` over `as` for a null-only cast.\n // Stryker disable next-line ConditionalExpression\n if (value === null) return false\n return internalsByContract.has(value)\n}\n","import { getContractError, getContractValues } from \"./cache.js\"\nimport { EnvNotReadyError } from \"./errors.js\"\nimport { registerContract } from \"./registry.js\"\nimport type { ContractInternals, CreateEnvOptions, EnvContract, EnvSchema } from \"./types.js\"\n\nlet anonymousCount = 0\n\n/**\n * Declares a feature's environment contract. Colocate this call with the\n * feature that consumes the variables (e.g. `features/payments/env.schema.ts`).\n *\n * @remarks\n * `createEnv` is runtime-only: `processor`/`validator`/`default` are the\n * whole vocabulary, because they're the only fields {@link validateEnv} actually\n * reads. Documentation -- description, ownership, lifecycle, category, and\n * everything else that only exists to generate docs -- lives in a separate\n * {@link documentEnv} call (see `document.ts`), which is entirely optional and\n * never required for this to work.\n *\n * @returns An {@link EnvContract} exposing one read-only getter per key -- there is no\n * global env object, only per-feature contracts like `paymentsEnv.STRIPE_KEY`. Accessing a\n * key throws until {@link validateEnv} has run successfully for the runtime this contract\n * was passed to.\n */\nexport function createEnv<S extends EnvSchema>(\n schema: S,\n options: CreateEnvOptions = {},\n): EnvContract<S> {\n const name = options.name ?? `anonymous-contract-${++anonymousCount}`\n const internals: ContractInternals<S> = { id: Symbol(name), name, source: options.source, schema }\n\n const contract: Record<string, unknown> = {}\n\n for (const key of Object.keys(schema)) {\n Object.defineProperty(contract, key, {\n enumerable: true,\n // Redundant with `Object.freeze(contract)` below (runs after every\n // `defineProperty` call in this function, and forces `configurable:\n // false` on every own property regardless of what was set here) --\n // kept only as the conventional default for a getter no one should\n // reconfigure, not because anything could observe the difference.\n // Stryker disable next-line BooleanLiteral\n configurable: false,\n get(): unknown {\n const error = getContractError(internals.id)\n if (error) throw error\n const values = getContractValues(internals.id)\n // Checking key presence, not just `values` presence, matters once\n // validation contexts exist: a variable whose context didn't match\n // this run's activeContexts is never written into `values` (see\n // validate.ts), so it must throw exactly like an unvalidated\n // contract, not silently resolve to `undefined`.\n if (!values || !Object.prototype.hasOwnProperty.call(values, key)) {\n throw new EnvNotReadyError(name, key)\n }\n return values[key]\n },\n })\n }\n\n // Redact the whole-object view so accidental console.log/JSON.stringify of a\n // contract never prints secret values. Individual keys remain fully readable.\n Object.defineProperty(contract, Symbol.for(\"nodejs.util.inspect.custom\"), {\n enumerable: false,\n value: () => `EnvContract(\"${name}\") { ${Object.keys(schema).length} variable(s) }`,\n })\n Object.defineProperty(contract, \"toString\", {\n enumerable: false,\n value: () => `EnvContract(\"${name}\")`,\n })\n Object.defineProperty(contract, \"toJSON\", {\n enumerable: false,\n value: () => `[EnvContract:${name}]`,\n })\n\n Object.freeze(contract)\n registerContract(contract, internals)\n return contract as EnvContract<S>\n}\n","import type { EnvSchema } from \"./types.js\"\n\n/**\n * Developer-supplied evidence assertions for one variable -- categorically\n * different from every field on {@link VariableDocs}: those are\n * declared-and-never-verified, while `dynamicAccess` is re-checked against\n * reality on every run (fresh / stale / missing). Kept structurally separate,\n * in `VariableDocs.evidence` rather than folded in alongside `description`/\n * `owner`/..., specifically so that different epistemic status is visible in\n * the shape itself and not only in a doc comment. See ADR 0037.\n */\nexport interface VariableEvidenceDocs {\n /**\n * Citation(s) of where this variable is actually read dynamically --\n * somewhere env-cap's own static AST scan can't see (a shell script, a\n * Docker entrypoint, a sibling service). Each entry is a\n * `\"<relative-path>:<line>:<column>\"` citation.\n *\n * @remarks\n * A developer's re-acknowledgment that access happens, never a claim\n * env-cap itself observed anything -- tracked as its own independent fact\n * and never folded into the AST-derived `VariableAccessStatus`. Re-verified\n * every run: a citation whose file no longer exists, or whose content has\n * visibly changed since it was last acknowledged, is flagged rather than\n * trusted forever.\n */\n dynamicAccess?: readonly string[]\n}\n\n/**\n * Per-variable documentation. Every field is optional and unconstrained on\n * purpose -- there is no required shape, so documenting a variable never\n * fights the type checker, and you can add a field the generator doesn't\n * know about yet without it being rejected.\n */\nexport interface VariableDocs {\n /** Human-readable explanation of what this variable is and what it controls. */\n description?: string\n /** Who owns this variable (a team, a handle, whatever your org uses). Overrides the contract's own `owner` for this key. */\n owner?: string\n /**\n * How sensitive this variable's value is. Overrides the contract's own `sensitivity` for this\n * key.\n *\n * @remarks\n * Deliberately an open `string`, not a closed union: an org's own sensitivity vocabulary is its\n * own, and a level env-cap doesn't recognize is always honored, never dropped. The generator\n * still reports a `NONSTANDARD_SENSITIVITY_LEVEL` finding (severity `info`, never blocking) for\n * anything outside `secret`/`credential`/`pii`/`config`, so vocabulary drift stays visible\n * without being enforced.\n */\n sensitivity?: string\n /** ISO date string (e.g. \"2026-06-01\") -- when this variable's current value stops being valid (a key rotation deadline, a sunset date, etc.). */\n expiresAt?: string\n /** How to get a new value before/when it expires (e.g. \"Rotate in the Stripe dashboard, then redeploy.\"). */\n refreshInstructions?: string\n /**\n * The kind of authenticator/secret this variable holds (e.g. \"api-key\", \"oauth-client-secret\",\n * \"database-password\", \"tls-certificate\") -- feeds the NIST SP 800-53 IA-5 rotation-compliance\n * report's \"authenticator type\" column (IA-5's main statement requires an organization-defined\n * rotation period \"by authenticator type,\" so this is what a generator groups/labels by).\n *\n * @remarks\n * Deliberately an open `string`, not a closed union -- same \"open vocabulary\" pattern as\n * {@link sensitivity}: an org's own authenticator taxonomy is its own, and IA-5 itself never\n * names a fixed set of types either.\n */\n authenticatorType?: string\n /**\n * How often this variable's value must be rotated, in organization-defined terms (e.g. \"90\n * days\", \"P90D\", \"6 months\") -- IA-5's own \"organization-defined time period\" per authenticator\n * type (the time-based half of IA-5's two-trigger rotation model). Paired with\n * {@link lastRotatedAt} so a generator can compute whether rotation is actually current, rather\n * than only recording that a period was declared; see `lifecycle-model.ts`'s\n * `computeRotationStatus()` for exactly how the two combine with {@link expiresAt}.\n */\n rotationPeriod?: string\n /**\n * ISO date string -- the last time this variable's value was actually rotated. Paired with\n * {@link rotationPeriod} to compute rotation compliance. Independent of {@link expiresAt}, which\n * states when the *current* value stops being valid, not when it was last changed -- a value can\n * be freshly rotated and still have a near-term `expiresAt` (a short-lived token), or long overdue\n * for rotation while its `expiresAt` (if any) is still comfortably in the future.\n */\n lastRotatedAt?: string\n /**\n * IA-5's event-based rotation triggers that apply to this variable (e.g. \"suspected compromise\",\n * \"personnel change\", \"system update\") -- the event-based half of IA-5's two-trigger rotation\n * model. Structured and additive alongside the existing free-text {@link refreshInstructions}\n * rather than replacing it: this is a list a generator can render as its own column,\n * `refreshInstructions` stays prose (\"how to actually rotate it\"). Presence-only -- env-cap has\n * no way to observe whether a listed event actually occurred, so declaring this never by itself\n * changes a computed rotation-compliance status (see `lifecycle-model.ts`); it only makes the\n * event-based trigger's existence visible in generated output.\n */\n rotationTriggerEvents?: readonly string[]\n /**\n * Explicit, actionable instructions for obtaining this variable's value the *first* time --\n * where `refreshInstructions` is \"how to rotate it once you already have one,\" this is \"how to\n * get one at all\" (e.g. \"Create a restricted API key in the Stripe dashboard under Developers ->\n * API keys, scoped to read/write Charges.\"). A named field specifically so this can render as\n * its own labeled line in generated docs, rather than requiring a `metadata.setup`-style\n * convention with no dedicated rendering or type checking.\n */\n setupInstructions?: string\n /** Documentation-level assertion that this variable must be set. Independent of how (or whether) a validator actually enforces it. */\n required?: boolean\n /** Marks this variable as being phased out. Independent of `expiresAt` (a rotation/sunset date) and of the contract-level `active` switch (on/off, not a phase-out signal). */\n deprecated?: boolean\n /** Why this variable is deprecated, and/or what to use instead. Only meaningful alongside `deprecated: true`. */\n deprecatedReason?: string\n /** ISO date string -- by when a deprecated variable must be removed. Only meaningful alongside `deprecated: true`. */\n removeBy?: string\n /** The previous environment variable name this one replaces, if this declaration is the result of a rename. Lets the Change Model correlate a remove+add pair into a single rename entry instead of two unrelated changes. */\n renamedFrom?: string\n /** Why this variable's value is collected/used -- a framework-agnostic fact (pairs with `legalBasis`; a specific citation like a GDPR article belongs in `metadata` instead). Overrides the contract's own `purpose` for this key. */\n purpose?: string\n /** The legal basis this variable's collection/use relies on -- framework-agnostic (e.g. \"user consent,\" \"contractual necessity\"), never a specific statute name. Overrides the contract's own `legalBasis` for this key. */\n legalBasis?: string\n /** Descriptive retention policy (e.g. \"delete after 90 days\"). A policy statement, not a computed value -- unlike `expiresAt`, nothing parses or evaluates this. Overrides the contract's own `retention` for this key. */\n retention?: string\n /** Where this variable's value is/must be stored (a region, or a permitted set of regions). Overrides the contract's own `dataResidency` for this key. */\n dataResidency?: string | string[]\n /** Documentation-level assertion that this variable's handling must be auditable. Overrides the contract's own `auditRequired` for this key. */\n auditRequired?: boolean\n /**\n * Developer-supplied evidence assertions for this variable -- verified over\n * time, unlike every other field above, which is declared and never\n * verified. Kept structurally separate for exactly that reason; see\n * {@link VariableEvidenceDocs}.\n */\n evidence?: VariableEvidenceDocs\n /**\n * Structured, unsupported-key documentation -- any primitive or object value, for anything that\n * doesn't warrant its own named field. A previously-supported top-level key belongs in a named\n * field above instead of here once one exists for it.\n */\n metadata?: Record<string, unknown>\n}\n\n/**\n * Contract-level documentation, plus everything {@link documentEnv}'s options used to carry that\n * only the generator ever read.\n *\n * @remarks\n * Generic over `S`, the exact schema type {@link documentEnv} infers from its `schema` argument --\n * this is what makes `variables` below a closed, checked map (a typo'd or renamed key is a\n * compile error, not a silent no-op) rather than an open `Record<string, VariableDocs>` any string\n * would satisfy. `S` defaults to the widest possible schema so this type is still nameable on its\n * own (e.g. in a helper function's own parameter type) without narrowing to one specific contract.\n */\nexport interface ContractDocs<S extends EnvSchema = EnvSchema> {\n /** Overrides the auto-generated label used in generated docs. Purely cosmetic. Wins over `createEnv()`'s own `name` option, which in turn wins over the exported binding name. */\n name?: string\n /** Groups this contract under a heading in the generated docs' feature catalog. */\n category?: string\n /** The generator throws if two *active* contracts declare the same `exclusiveGroup` -- use it to mark interchangeable features (e.g. two database backends) as mutually exclusive. */\n exclusiveGroup?: string\n /** When `false`, this contract is excluded from the generated manifest, docs' required section, and exclusiveGroup checks -- it still appears, marked disabled, in the feature catalog. Defaults to `true`. */\n active?: boolean\n /** Default owner for every variable in this contract that doesn't set its own `owner`. */\n owner?: string\n /** Default sensitivity for every variable in this contract that doesn't set its own `sensitivity` -- see {@link VariableDocs.sensitivity} for why this is an open `string`. */\n sensitivity?: string\n /** Whole-contract/feature sunset date, ISO date string. */\n expiresAt?: string\n /** Marks this whole contract/feature as being phased out. Independent of `active` (on/off, not a phase-out signal). */\n deprecated?: boolean\n /** Why this contract is deprecated, and/or what to use instead. Only meaningful alongside `deprecated: true`. */\n deprecatedReason?: string\n /** Default reason this contract's variables' values are collected/used -- see {@link VariableDocs.purpose}. */\n purpose?: string\n /** Default legal basis for this contract's variables -- see {@link VariableDocs.legalBasis}. */\n legalBasis?: string\n /** Default retention policy for this contract's variables -- see {@link VariableDocs.retention}. */\n retention?: string\n /** Default data residency for this contract's variables -- see {@link VariableDocs.dataResidency}. */\n dataResidency?: string | string[]\n /** Default audit-required assertion for this contract's variables -- see {@link VariableDocs.auditRequired}. */\n auditRequired?: boolean\n /** Arbitrary contract-level documentation (e.g. `runbook`), rendered alongside this feature -- see {@link VariableDocs.metadata}. */\n metadata?: Record<string, unknown>\n /**\n * Per-variable documentation, keyed by variable name -- keys are checked against `S`'s own keys\n * at compile time, so documenting a variable that was renamed or removed from `schema` (or a\n * plain typo) is a type error here, not a silently-ignored entry the generator would otherwise\n * have to report as \"stale\" after the fact. A schema key absent from `variables` entirely is\n * still valid (not every variable needs documentation) and is reported as undocumented by the\n * generator, exactly as before.\n */\n variables?: { readonly [K in keyof S]?: VariableDocs }\n}\n\n/**\n * Documents a schema for the generator: explains values, assigns ownership,\n * and describes lifecycle, feeding the generated docs artifact and\n * `.env.example`. Pass it the *same* schema object given to {@link createEnv}, so\n * the generator can statically link the two and verify every variable is\n * documented -- and so TypeScript can check `docs.variables`' keys against\n * `schema`'s own keys, the same object identity doing double duty for both\n * the generator's static link and the type checker's.\n *\n * @remarks\n * A no-op at runtime by design -- nothing passed here is retained anywhere,\n * and this can never throw, no matter how malformed `schema`/`docs` are.\n * Calling it is entirely optional: {@link createEnv} works identically whether or\n * not a matching `documentEnv` call exists. The real \"is everything\n * documented?\" check, and every artifact this data drives (the docs\n * artifact's ownership matrix, dependency graph, lifecycle report, and\n * security review; `.env.example`'s comments), runs entirely inside\n * {@link build.generateEnvManifest}'s static analysis -- this function's only job at\n * runtime is to exist as a safe, harmless marker the AST parser can find,\n * and to give you type-checked argument shapes while writing it.\n *\n * `S` is inferred from `schema`, never written out by hand -- pass the\n * schema object literal (or a `const`-inferred reference to it) directly for\n * the strongest inference; an explicitly-widened `schema: EnvSchema`\n * annotation loses the per-key literal type and falls back to accepting any\n * string key in `docs.variables`, same as before this generic existed.\n */\n// Deliberately a true no-op (see the doc comment above): `documentEnv` has no\n// runtime behavior at all, only a compile-time keyed-shape check and a\n// static-analysis-visible call site -- its body being empty is observably\n// identical to explicitly discarding both arguments, so there is nothing a\n// test could assert to distinguish the two. (A `next-line` disable placed\n// inside the parameter list, right before the closing paren, does not\n// reliably attach as the block's own leading comment -- hence this unscoped\n// disable/restore pair instead; see data-cap's `core/document.ts` for the\n// same pattern and the Stryker directive-attachment mechanics behind it.)\n// Stryker disable BlockStatement\nexport function documentEnv<S extends EnvSchema>(schema: S, docs: ContractDocs<S>): void {\n // Intentionally inert -- see the module doc comment above. Do not add\n // logic here; anything this function does happens at runtime, in every\n // process that imports the schema file, which is exactly what this split\n // exists to avoid. The `void`s below only satisfy `noUnusedParameters` --\n // a bare `schema`/`docs` expression statement trips `no-unused-expressions`\n // instead, and renaming these public parameters to `_schema`/`_docs` would\n // leak into every consumer's editor hover.\n // eslint-disable-next-line @typescript-eslint/no-meaningless-void-operator\n void schema\n // eslint-disable-next-line @typescript-eslint/no-meaningless-void-operator\n void docs\n}\n// Stryker restore BlockStatement\n","import { resetCache } from \"./cache.js\"\n\n/**\n * Clears cached validation state. Intended for tests and dev tooling (e.g.\n * `beforeEach(() => resetEnvCache())` in a test suite that re-validates with\n * different fixture values per test) -- production applications validate\n * once at startup and should not normally call this.\n */\nexport function resetEnvCache(): void {\n resetCache()\n}\n","import { getState, setContractError, setContractValues } from \"./cache.js\"\nimport type { CacheState } from \"./cache.js\"\nimport { EnvValidationError } from \"./errors.js\"\nimport type { VariableFailure } from \"./errors.js\"\nimport { getContractInternals } from \"./registry.js\"\nimport type { validateEnvOptions, validateEnvResult } from \"./types.js\"\n\n/**\n * Validates every variable in every contract in `options.manifest` against\n * `options.values`, then caches the results.\n *\n * @remarks\n * Idempotent: the first successful (or failed) call is authoritative for the life of the\n * process -- later calls return (or re-throw) that same outcome without re-running any\n * processor or validator. Concurrent in-flight calls share one underlying run.\n *\n * @throws {EnvValidationError} If any variable fails processing or validation.\n */\nexport async function validateEnv(options: validateEnvOptions): Promise<validateEnvResult> {\n const state = getState()\n\n // `result`/`error` are only ever set together with their matching\n // `status` (`runValidation()` below sets `state.status = \"ready\"` and\n // `state.result` in the same statement pair, likewise \"failed\"/`error`),\n // and `resetCache()` always replaces the whole `state` object rather than\n // resetting fields individually -- so checking `status` alone already\n // implies `result`/`error` is set. Load-bearing for TypeScript's own\n // narrowing of `state.result`/`state.error` from `T | undefined` to `T`\n // for the `return`/`throw` below, though -- hand-verified by removing\n // each `&&` clause entirely and running the full `vitest run`: all 1236\n // tests still pass.\n // Stryker disable next-line ConditionalExpression, LogicalOperator\n if (state.status === \"ready\" && state.result) {\n return state.result\n }\n // Stryker disable next-line ConditionalExpression, LogicalOperator\n if (state.status === \"failed\" && state.error) {\n throw state.error\n }\n if (state.inFlight) {\n return state.inFlight\n }\n\n // Genuinely unobservable via any real (all-synchronous, per `Processor`/\n // `Validator`'s own types) caller: `runValidation()` below has no\n // internal `await`, so its entire body -- including overwriting\n // `state.status` to \"ready\" or \"failed\" -- runs to completion\n // synchronously as part of evaluating the very next line, before control\n // ever returns to anything that could observe \"validating\". Kept as an\n // honest, self-documenting state-machine value (and to keep `CacheStatus`\n // meaningful if a future version ever awaits inside `runValidation()`).\n // Hand-verified: replacing the string with \"\" and running the full\n // `vitest run` leaves all 1236 tests passing.\n // Stryker disable next-line StringLiteral\n state.status = \"validating\"\n const run = runValidation(options, state)\n state.inFlight = run\n try {\n return await run\n } finally {\n // Not `= undefined`: `inFlight` is genuinely optional (absent between\n // runs), and exactOptionalPropertyTypes distinguishes \"key absent\" from\n // \"key present holding undefined\" -- delete is the operation that\n // actually means the former.\n delete state.inFlight\n }\n}\n\n/**\n * Whether a variable participates in a validation run: unset `context`\n * always participates; otherwise it participates only when `activeContexts`\n * contains that exact string (no prefix matching, no wildcards, no\n * hierarchy -- see ADR 0022's Formal Invariants).\n */\nfunction matchesContext(\n variableContext: string | undefined,\n activeContexts: ReadonlySet<string> | undefined,\n): boolean {\n return variableContext === undefined || (activeContexts?.has(variableContext) ?? false)\n}\n\n// `async` is load-bearing here despite no internal `await`: `validateEnv()`\n// assigns this call's return value directly to `state.inFlight` so\n// concurrent callers can share one in-flight run (see its own doc comment).\n// That only works if this genuinely returns a Promise -- a synchronous\n// function returning/throwing a plain value would change both the\n// concurrent-sharing behavior and the timing of a thrown validation error.\n// eslint-disable-next-line @typescript-eslint/require-await\nasync function runValidation(\n options: validateEnvOptions,\n state: CacheState,\n): Promise<validateEnvResult> {\n const failures: VariableFailure[] = []\n let variableCount = 0\n\n // Allocated only when contexts are actually in play, so the (overwhelmingly\n // common, and every pre-existing) zero-context path does no extra work.\n const activeContexts = options.activeContexts?.length\n ? new Set(options.activeContexts)\n : undefined\n\n // A poisoned seed element here would be an accumulator only ever `.push()`ed\n // to (never filtered), reaching the two per-entry loops below\n // (`setContractError`/`setContractValues`) destructured as `{id: undefined,\n // values: undefined}` -- `setContractValues(undefined, Object.freeze(undefined))`\n // neither throws nor collides with any real contract's own symbol-keyed\n // entry, so it's unobservable via any real `createEnv()`/`validateEnv()`\n // consumer. Hand-verified: seeding this with a phantom entry and running\n // the full `vitest run` leaves all 1236 tests passing.\n // Stryker disable next-line ArrayDeclaration\n const resolved: { id: symbol; values: Record<string, unknown> }[] = []\n\n for (const contract of options.manifest) {\n const internals = getContractInternals(contract)\n const values: Record<string, unknown> = {}\n\n for (const key of Object.keys(internals.schema)) {\n const definition = internals.schema[key]\n // `key` was just enumerated from `Object.keys(internals.schema)`, so\n // this is always a real entry -- noUncheckedIndexedAccess can't\n // express that invariant from an object index signature, only that\n // indexing is *generally* unsafe. A real guard (not a non-null\n // assertion, forbidden in src/) satisfies the type checker without\n // hiding the possibility. Hand-verified: mutating this condition away\n // and running the real suite passes unchanged.\n // Stryker disable next-line ConditionalExpression\n if (definition === undefined) continue\n\n // A variable whose context isn't active is skipped entirely -- no\n // default/processor/validator runs, it's never counted as validated,\n // and it stays out of `values`, so `create.ts`'s getter finds it\n // absent and throws EnvNotReadyError exactly as if this run had\n // never happened for it. See ADR 0022.\n if (!matchesContext(definition.context, activeContexts)) continue\n\n variableCount += 1\n\n const raw = options.values[key]\n\n let working: unknown = raw\n // Bypassing the `!== undefined` clause only matters when `working ===\n // undefined` AND `definition.default` genuinely is `undefined` --\n // `typeof undefined === \"function\"` is false, so `working` is\n // assigned `definition.default` (`undefined`) either way: applying \"no\n // default\" when there wasn't one is identical to not applying it.\n // Hand-verified: replacing the whole clause with `true` and running\n // the full `vitest run` leaves all 1236 tests passing.\n // Stryker disable next-line ConditionalExpression\n if (working === undefined && definition.default !== undefined) {\n working =\n typeof definition.default === \"function\"\n ? (definition.default as () => unknown)()\n : definition.default\n }\n\n let processed: unknown = working\n if (definition.processor) {\n try {\n processed = definition.processor(working)\n } catch (cause) {\n failures.push({\n variable: key,\n contractName: internals.name,\n source: internals.source,\n kind: \"processor\",\n message: toMessage(cause),\n })\n continue\n }\n }\n\n if (definition.validator) {\n let outcome: true | string\n try {\n outcome = definition.validator(processed, options.values)\n } catch (cause) {\n outcome = toMessage(cause)\n }\n if (outcome !== true) {\n failures.push({\n variable: key,\n contractName: internals.name,\n source: internals.source,\n kind: \"validator\",\n message: outcome,\n })\n continue\n }\n }\n\n values[key] = processed\n }\n\n resolved.push({ id: internals.id, values })\n state.contractIds.add(internals.id)\n }\n\n if (failures.length > 0) {\n const error = new EnvValidationError(failures)\n for (const { id } of resolved) {\n setContractError(id, error)\n }\n state.status = \"failed\"\n state.error = error\n throw error\n }\n\n for (const { id, values } of resolved) {\n setContractValues(id, Object.freeze(values))\n }\n\n const result: validateEnvResult = {\n contractCount: options.manifest.length,\n variableCount,\n }\n state.status = \"ready\"\n state.result = result\n return result\n}\n\nfunction toMessage(cause: unknown): string {\n return cause instanceof Error ? cause.message : String(cause)\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/runtime/cache.ts","../src/runtime/errors.ts","../src/runtime/registry.ts","../src/runtime/create.ts","../src/runtime/document.ts","../src/runtime/reset.ts","../src/runtime/validate.ts"],"names":["state"],"mappings":";;;AAsBA,IAAI,QAAoB,WAAA,EAAY;AACpC,IAAM,cAAA,uBAAqB,GAAA,EAA+C;AAC1E,IAAM,cAAA,uBAAqB,GAAA,EAAgC;AAE3D,SAAS,WAAA,GAA0B;AACjC,EAAA,OAAO,EAAE,WAAA,kBAAa,IAAI,GAAA,EAAI,EAAE;AAClC;AAEO,SAAS,QAAA,GAAuB;AACrC,EAAA,OAAO,KAAA;AACT;AAEO,SAAS,kBAAkB,EAAA,EAA2D;AAC3F,EAAA,OAAO,cAAA,CAAe,IAAI,EAAE,CAAA;AAC9B;AAEO,SAAS,iBAAA,CAAkB,IAAY,MAAA,EAAiD;AAC7F,EAAA,cAAA,CAAe,GAAA,CAAI,IAAI,MAAM,CAAA;AAC/B;AAEO,SAAS,iBAAiB,EAAA,EAA4C;AAC3E,EAAA,OAAO,cAAA,CAAe,IAAI,EAAE,CAAA;AAC9B;AAEO,SAAS,gBAAA,CAAiB,IAAY,KAAA,EAAiC;AAC5E,EAAA,cAAA,CAAe,GAAA,CAAI,IAAI,KAAK,CAAA;AAC9B;AAGO,SAAS,UAAA,GAAmB;AACjC,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AAA,CAAO,MAAM,CAAC,CAAA;AAAA,EAC7C;AAEA,EAAA,MAAM,MAAA,GAA4B;AAAA,IAChC,aAAA,EAAe,QAAQ,QAAA,CAAS,MAAA;AAAA,IAChC;AAAA,GACF;AACA,EAAAA,OAAM,MAAA,GAAS,MAAA;AACf,EAAA,OAAO,MAAA;AACT;AAEA,SAAS,UAAU,KAAA,EAAwB;AACzC,EAAA,OAAO,KAAA,YAAiB,KAAA,GAAQ,KAAA,CAAM,OAAA,GAAU,OAAO,KAAK,CAAA;AAC9D","file":"index.cjs"}
|
package/dist/index.js
CHANGED
|
@@ -3,7 +3,7 @@ var state = createState();
|
|
|
3
3
|
var contractValues = /* @__PURE__ */ new Map();
|
|
4
4
|
var contractErrors = /* @__PURE__ */ new Map();
|
|
5
5
|
function createState() {
|
|
6
|
-
return {
|
|
6
|
+
return { contractIds: /* @__PURE__ */ new Set() };
|
|
7
7
|
}
|
|
8
8
|
function getState() {
|
|
9
9
|
return state;
|
|
@@ -87,9 +87,8 @@ function getContractInternals(contract) {
|
|
|
87
87
|
return internals;
|
|
88
88
|
}
|
|
89
89
|
function isEnvContract(value) {
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
return internalsByContract.has(value);
|
|
90
|
+
const key = value;
|
|
91
|
+
return typeof value === "object" && internalsByContract.has(key);
|
|
93
92
|
}
|
|
94
93
|
|
|
95
94
|
// src/runtime/create.ts
|
|
@@ -101,13 +100,6 @@ function createEnv(schema, options = {}) {
|
|
|
101
100
|
for (const key of Object.keys(schema)) {
|
|
102
101
|
Object.defineProperty(contract, key, {
|
|
103
102
|
enumerable: true,
|
|
104
|
-
// Redundant with `Object.freeze(contract)` below (runs after every
|
|
105
|
-
// `defineProperty` call in this function, and forces `configurable:
|
|
106
|
-
// false` on every own property regardless of what was set here) --
|
|
107
|
-
// kept only as the conventional default for a getter no one should
|
|
108
|
-
// reconfigure, not because anything could observe the difference.
|
|
109
|
-
// Stryker disable next-line BooleanLiteral
|
|
110
|
-
configurable: false,
|
|
111
103
|
get() {
|
|
112
104
|
const error = getContractError(internals.id);
|
|
113
105
|
if (error) throw error;
|
|
@@ -137,7 +129,7 @@ function createEnv(schema, options = {}) {
|
|
|
137
129
|
}
|
|
138
130
|
|
|
139
131
|
// src/runtime/document.ts
|
|
140
|
-
function documentEnv(
|
|
132
|
+
function documentEnv() {
|
|
141
133
|
}
|
|
142
134
|
|
|
143
135
|
// src/runtime/reset.ts
|
|
@@ -148,16 +140,15 @@ function resetEnvCache() {
|
|
|
148
140
|
// src/runtime/validate.ts
|
|
149
141
|
async function validateEnv(options) {
|
|
150
142
|
const state2 = getState();
|
|
151
|
-
if (state2.
|
|
143
|
+
if (state2.result) {
|
|
152
144
|
return state2.result;
|
|
153
145
|
}
|
|
154
|
-
if (state2.
|
|
146
|
+
if (state2.error) {
|
|
155
147
|
throw state2.error;
|
|
156
148
|
}
|
|
157
149
|
if (state2.inFlight) {
|
|
158
150
|
return state2.inFlight;
|
|
159
151
|
}
|
|
160
|
-
state2.status = "validating";
|
|
161
152
|
const run = runValidation(options, state2);
|
|
162
153
|
state2.inFlight = run;
|
|
163
154
|
try {
|
|
@@ -173,18 +164,15 @@ async function runValidation(options, state2) {
|
|
|
173
164
|
const failures = [];
|
|
174
165
|
let variableCount = 0;
|
|
175
166
|
const activeContexts = options.activeContexts?.length ? new Set(options.activeContexts) : void 0;
|
|
176
|
-
const resolved =
|
|
177
|
-
for (const contract of options.manifest) {
|
|
167
|
+
const resolved = options.manifest.map((contract) => {
|
|
178
168
|
const internals = getContractInternals(contract);
|
|
179
169
|
const values = {};
|
|
180
|
-
for (const key of Object.
|
|
181
|
-
const definition = internals.schema[key];
|
|
182
|
-
if (definition === void 0) continue;
|
|
170
|
+
for (const [key, definition] of Object.entries(internals.schema)) {
|
|
183
171
|
if (!matchesContext(definition.context, activeContexts)) continue;
|
|
184
172
|
variableCount += 1;
|
|
185
173
|
const raw = options.values[key];
|
|
186
174
|
let working = raw;
|
|
187
|
-
if (working === void 0
|
|
175
|
+
if (working === void 0) {
|
|
188
176
|
working = typeof definition.default === "function" ? definition.default() : definition.default;
|
|
189
177
|
}
|
|
190
178
|
let processed = working;
|
|
@@ -222,15 +210,14 @@ async function runValidation(options, state2) {
|
|
|
222
210
|
}
|
|
223
211
|
values[key] = processed;
|
|
224
212
|
}
|
|
225
|
-
resolved.push({ id: internals.id, values });
|
|
226
213
|
state2.contractIds.add(internals.id);
|
|
227
|
-
|
|
214
|
+
return { id: internals.id, values };
|
|
215
|
+
});
|
|
228
216
|
if (failures.length > 0) {
|
|
229
217
|
const error = new EnvValidationError(failures);
|
|
230
218
|
for (const { id } of resolved) {
|
|
231
219
|
setContractError(id, error);
|
|
232
220
|
}
|
|
233
|
-
state2.status = "failed";
|
|
234
221
|
state2.error = error;
|
|
235
222
|
throw error;
|
|
236
223
|
}
|
|
@@ -241,7 +228,6 @@ async function runValidation(options, state2) {
|
|
|
241
228
|
contractCount: options.manifest.length,
|
|
242
229
|
variableCount
|
|
243
230
|
};
|
|
244
|
-
state2.status = "ready";
|
|
245
231
|
state2.result = result;
|
|
246
232
|
return result;
|
|
247
233
|
}
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/runtime/cache.ts","../src/runtime/errors.ts","../src/runtime/registry.ts","../src/runtime/create.ts","../src/runtime/document.ts","../src/runtime/reset.ts","../src/runtime/validate.ts"],"names":["state"],"mappings":";AAyBA,IAAI,QAAoB,WAAA,EAAY;AACpC,IAAM,cAAA,uBAAqB,GAAA,EAA+C;AAC1E,IAAM,cAAA,uBAAqB,GAAA,EAAgC;AAE3D,SAAS,WAAA,GAA0B;AACjC,EAAA,OAAO,EAAE,MAAA,EAAQ,eAAA,EAAiB,WAAA,kBAAa,IAAI,KAAI,EAAE;AAC3D;AAEO,SAAS,QAAA,GAAuB;AACrC,EAAA,OAAO,KAAA;AACT;AAEO,SAAS,kBAAkB,EAAA,EAA2D;AAC3F,EAAA,OAAO,cAAA,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nvResult } from \"./types.js\"\n\ntype CacheStatus = \"uninitialized\" | \"validating\" | \"ready\" | \"failed\"\n\nexport interface CacheState {\n status: CacheStatus\n /** ids of every contract validated as part of this initialization, so resetEnvCache() can clean up precisely. */\n contractIds: Set<symbol>\n result?: validateEnvResult\n error?: EnvValidationError\n inFlight?: Promise<validateEnvResult>\n}\n\n/**\n * All shared state lives here -- nothing is exported except the accessor\n * functions below, and every write goes through them. Values are frozen\n * before they ever reach `contractValues`, so once set, a contract's\n * resolved record cannot be mutated in place.\n *\n * There is a single global state, not one per \"runtime\": a process validates\n * its environment once, at startup. Server and client contexts never share a\n * process (server code and a browser bundle are two separate processes), so\n * there's nothing to key a second state by.\n */\nlet state: CacheState = createState()\nconst contractValues = new Map<symbol, Readonly<Record<string, unknown>>>()\nconst contractErrors = new Map<symbol, EnvValidationError>()\n\nfunction createState(): CacheState {\n return { status: \"uninitialized\", contractIds: new Set() }\n}\n\nexport function getState(): CacheState {\n return state\n}\n\nexport function getContractValues(id: symbol): Readonly<Record<string, unknown>> | undefined {\n return contractValues.get(id)\n}\n\nexport function setContractValues(id: symbol, values: Readonly<Record<string, unknown>>): void {\n contractValues.set(id, values)\n}\n\nexport function getContractError(id: symbol): EnvValidationError | undefined {\n return contractErrors.get(id)\n}\n\nexport function setContractError(id: symbol, error: EnvValidationError): void {\n contractErrors.set(id, error)\n}\n\n/** Clears cached state: the global status plus every contract validated as part of it. */\nexport function resetCache(): void {\n for (const id of state.contractIds) {\n contractValues.delete(id)\n contractErrors.delete(id)\n }\n state = createState()\n}\n","/**\n * Every error type here is constructed only from: the variable name, the\n * declaring contract's name, the failure kind, and a message string that the\n * *developer's own* processor/validator produced. Raw or processed environment\n * values are never read into an error -- see the Security section in the README.\n *\n * Documentation (description, owner, etc.) never appears here, even when a\n * {@link documentEnv} call exists for this variable -- `documentEnv` is\n * build-time-only and its data is never retained anywhere {@link validateEnv}\n * could read it back out. This is a deliberate consequence of keeping the\n * runtime minimal, not an oversight.\n */\n\n/** One variable's processing or validation failure, as recorded by {@link validateEnv}. */\nexport interface VariableFailure {\n /** The schema key that failed. */\n readonly variable: string\n /** The declaring contract's `name` (see {@link CreateEnvOptions}). */\n readonly contractName: string\n /** `import.meta.url` (or similar) passed to `createEnv`'s `source` option, if any. Falls back to `contractName` when absent. */\n readonly source: string | undefined\n /** Which stage produced the failure. */\n readonly kind: \"processor\" | \"validator\"\n /** The error message from the developer's own processor/validator, or the thrown error's message. */\n readonly message: string\n}\n\nfunction formatFailure(failure: VariableFailure): string {\n const heading = failure.kind === \"processor\" ? \"Processor failed:\" : \"Validation failed:\"\n const lines = [\n failure.variable,\n \"-\".repeat(Math.max(failure.variable.length, 3)),\n heading,\n failure.message,\n ]\n\n lines.push(\"\", \"Source:\", failure.source ?? failure.contractName)\n\n return lines.join(\"\\n\")\n}\n\nfunction formatReport(failures: readonly VariableFailure[]): string {\n const count = failures.length\n const noun = count === 1 ? \"configuration error\" : \"configuration errors\"\n const header = `Environment validation failed.\\n\\n${count} ${noun} found:`\n const blocks = failures.map(formatFailure)\n return [header, ...blocks].join(\"\\n\\n\")\n}\n\n/**\n * Thrown by {@link validateEnv} when one or more variables fail processing or\n * validation. Aggregates every failure across every contract in the batch --\n * the caller sees the whole picture in one error, not one-at-a-time.\n *\n * @remarks\n * `code` is a stable, Stable-tier discriminant for programmatic handling --\n * prefer it over `.name`/`instanceof` when a message-independent switch is needed.\n */\nexport class EnvValidationError extends Error {\n /** Stable discriminant for programmatic handling; always `\"ENV_VALIDATION_FAILED\"`. */\n readonly code = \"ENV_VALIDATION_FAILED\"\n /** Every variable failure across every contract in the batch. */\n readonly failures: readonly VariableFailure[]\n\n constructor(failures: readonly VariableFailure[]) {\n super(formatReport(failures))\n this.name = \"EnvValidationError\"\n this.failures = failures\n Error.captureStackTrace?.(this, EnvValidationError)\n }\n}\n\n/**\n * Thrown when a contract's value is accessed via property access before\n * {@link validateEnv} has completed successfully for it.\n *\n * @remarks\n * `code` is a stable, Stable-tier discriminant for programmatic handling --\n * prefer it over `.name`/`instanceof` when a message-independent switch is needed.\n */\nexport class EnvNotReadyError extends Error {\n /** Stable discriminant for programmatic handling; always `\"ENV_NOT_READY\"`. */\n readonly code = \"ENV_NOT_READY\"\n\n constructor(contractName: string, key: string) {\n const target = `\"${contractName}\".${key}`\n super(\n `Environment contract ${target} has not been validated yet. ` +\n \"Call validateEnv() during application startup before accessing environment values.\",\n )\n this.name = \"EnvNotReadyError\"\n Error.captureStackTrace?.(this, EnvNotReadyError)\n }\n}\n","import type { ContractInternals } from \"./types.js\"\n\n/**\n * Private map from a contract object (returned by `createEnv`) to its internal\n * identity/schema. Not exported from the package -- this is the only place\n * that ever associates a contract with its schema, so `validateEnv()`\n * cannot accidentally read across contracts.\n */\nconst internalsByContract = new WeakMap<object, ContractInternals>()\n\n/** Associates a contract object with its internal identity/schema. Called once, by `createEnv`. */\nexport function registerContract(contract: object, internals: ContractInternals): void {\n internalsByContract.set(contract, internals)\n}\n\n/**\n * Looks up a contract's internal identity/schema.\n *\n * @throws {TypeError} If `contract` wasn't returned by `createEnv` (and so was never registered).\n */\nexport function getContractInternals(contract: object): ContractInternals {\n const internals = internalsByContract.get(contract)\n if (!internals) {\n throw new TypeError(\n \"env-cap: this value was not created by createEnv(). \" +\n \"validateEnv() and resetEnvCache() only accept contracts returned from createEnv().\",\n )\n }\n return internals\n}\n\n/** Type guard: `true` when `value` was created by `createEnv` (i.e. is a registered contract). */\nexport function isEnvContract(value: unknown): value is object {\n if (typeof value !== \"object\") return false\n // Split onto its own line (rather than one `&&`-chained expression) so\n // this one check's disable directive can't also silence the still-real,\n // still-tested `typeof` check above. Runtime-redundant on its own --\n // hand-verified: `WeakMap.prototype.has(null)` is spec-guaranteed to\n // return `false` (never throws for a non-object key), so `.has(value)`\n // alone already does the right thing for `null`, the one value where\n // `typeof value === \"object\"` is true but `value` isn't really an object.\n // Kept as a real check anyway because TS needs SOME `null` exclusion here\n // to accept `value` as an `object` below (`typeof value === \"object\"`\n // alone narrows to `object | null`, TS's one special case for `typeof`) --\n // tried a cast/assertion instead (`value as object` / `value!`) and hit an\n // unresolvable conflict in this repo's eslint config: `src/**` bans `!`\n // (`no-non-null-assertion`) while the sibling `non-nullable-type-\n // assertion-style` rule then demands `!` over `as` for a null-only cast.\n // Stryker disable next-line ConditionalExpression\n if (value === null) return false\n return internalsByContract.has(value)\n}\n","import { getContractError, getContractValues } from \"./cache.js\"\nimport { EnvNotReadyError } from \"./errors.js\"\nimport { registerContract } from \"./registry.js\"\nimport type { ContractInternals, CreateEnvOptions, EnvContract, EnvSchema } from \"./types.js\"\n\nlet anonymousCount = 0\n\n/**\n * Declares a feature's environment contract. Colocate this call with the\n * feature that consumes the variables (e.g. `features/payments/env.schema.ts`).\n *\n * @remarks\n * `createEnv` is runtime-only: `processor`/`validator`/`default` are the\n * whole vocabulary, because they're the only fields {@link validateEnv} actually\n * reads. Documentation -- description, ownership, lifecycle, category, and\n * everything else that only exists to generate docs -- lives in a separate\n * {@link documentEnv} call (see `document.ts`), which is entirely optional and\n * never required for this to work.\n *\n * @returns An {@link EnvContract} exposing one read-only getter per key -- there is no\n * global env object, only per-feature contracts like `paymentsEnv.STRIPE_KEY`. Accessing a\n * key throws until {@link validateEnv} has run successfully for the runtime this contract\n * was passed to.\n */\nexport function createEnv<S extends EnvSchema>(\n schema: S,\n options: CreateEnvOptions = {},\n): EnvContract<S> {\n const name = options.name ?? `anonymous-contract-${++anonymousCount}`\n const internals: ContractInternals<S> = { id: Symbol(name), name, source: options.source, schema }\n\n const contract: Record<string, unknown> = {}\n\n for (const key of Object.keys(schema)) {\n Object.defineProperty(contract, key, {\n enumerable: true,\n // Redundant with `Object.freeze(contract)` below (runs after every\n // `defineProperty` call in this function, and forces `configurable:\n // false` on every own property regardless of what was set here) --\n // kept only as the conventional default for a getter no one should\n // reconfigure, not because anything could observe the difference.\n // Stryker disable next-line BooleanLiteral\n configurable: false,\n get(): unknown {\n const error = getContractError(internals.id)\n if (error) throw error\n const values = getContractValues(internals.id)\n // Checking key presence, not just `values` presence, matters once\n // validation contexts exist: a variable whose context didn't match\n // this run's activeContexts is never written into `values` (see\n // validate.ts), so it must throw exactly like an unvalidated\n // contract, not silently resolve to `undefined`.\n if (!values || !Object.prototype.hasOwnProperty.call(values, key)) {\n throw new EnvNotReadyError(name, key)\n }\n return values[key]\n },\n })\n }\n\n // Redact the whole-object view so accidental console.log/JSON.stringify of a\n // contract never prints secret values. Individual keys remain fully readable.\n Object.defineProperty(contract, Symbol.for(\"nodejs.util.inspect.custom\"), {\n enumerable: false,\n value: () => `EnvContract(\"${name}\") { ${Object.keys(schema).length} variable(s) }`,\n })\n Object.defineProperty(contract, \"toString\", {\n enumerable: false,\n value: () => `EnvContract(\"${name}\")`,\n })\n Object.defineProperty(contract, \"toJSON\", {\n enumerable: false,\n value: () => `[EnvContract:${name}]`,\n })\n\n Object.freeze(contract)\n registerContract(contract, internals)\n return contract as EnvContract<S>\n}\n","import type { EnvSchema } from \"./types.js\"\n\n/**\n * Developer-supplied evidence assertions for one variable -- categorically\n * different from every field on {@link VariableDocs}: those are\n * declared-and-never-verified, while `dynamicAccess` is re-checked against\n * reality on every run (fresh / stale / missing). Kept structurally separate,\n * in `VariableDocs.evidence` rather than folded in alongside `description`/\n * `owner`/..., specifically so that different epistemic status is visible in\n * the shape itself and not only in a doc comment. See ADR 0037.\n */\nexport interface VariableEvidenceDocs {\n /**\n * Citation(s) of where this variable is actually read dynamically --\n * somewhere env-cap's own static AST scan can't see (a shell script, a\n * Docker entrypoint, a sibling service). Each entry is a\n * `\"<relative-path>:<line>:<column>\"` citation.\n *\n * @remarks\n * A developer's re-acknowledgment that access happens, never a claim\n * env-cap itself observed anything -- tracked as its own independent fact\n * and never folded into the AST-derived `VariableAccessStatus`. Re-verified\n * every run: a citation whose file no longer exists, or whose content has\n * visibly changed since it was last acknowledged, is flagged rather than\n * trusted forever.\n */\n dynamicAccess?: readonly string[]\n}\n\n/**\n * Per-variable documentation. Every field is optional and unconstrained on\n * purpose -- there is no required shape, so documenting a variable never\n * fights the type checker, and you can add a field the generator doesn't\n * know about yet without it being rejected.\n */\nexport interface VariableDocs {\n /** Human-readable explanation of what this variable is and what it controls. */\n description?: string\n /** Who owns this variable (a team, a handle, whatever your org uses). Overrides the contract's own `owner` for this key. */\n owner?: string\n /**\n * How sensitive this variable's value is. Overrides the contract's own `sensitivity` for this\n * key.\n *\n * @remarks\n * Deliberately an open `string`, not a closed union: an org's own sensitivity vocabulary is its\n * own, and a level env-cap doesn't recognize is always honored, never dropped. The generator\n * still reports a `NONSTANDARD_SENSITIVITY_LEVEL` finding (severity `info`, never blocking) for\n * anything outside `secret`/`credential`/`pii`/`config`, so vocabulary drift stays visible\n * without being enforced.\n */\n sensitivity?: string\n /** ISO date string (e.g. \"2026-06-01\") -- when this variable's current value stops being valid (a key rotation deadline, a sunset date, etc.). */\n expiresAt?: string\n /** How to get a new value before/when it expires (e.g. \"Rotate in the Stripe dashboard, then redeploy.\"). */\n refreshInstructions?: string\n /**\n * The kind of authenticator/secret this variable holds (e.g. \"api-key\", \"oauth-client-secret\",\n * \"database-password\", \"tls-certificate\") -- feeds the NIST SP 800-53 IA-5 rotation-compliance\n * report's \"authenticator type\" column (IA-5's main statement requires an organization-defined\n * rotation period \"by authenticator type,\" so this is what a generator groups/labels by).\n *\n * @remarks\n * Deliberately an open `string`, not a closed union -- same \"open vocabulary\" pattern as\n * {@link sensitivity}: an org's own authenticator taxonomy is its own, and IA-5 itself never\n * names a fixed set of types either.\n */\n authenticatorType?: string\n /**\n * How often this variable's value must be rotated, in organization-defined terms (e.g. \"90\n * days\", \"P90D\", \"6 months\") -- IA-5's own \"organization-defined time period\" per authenticator\n * type (the time-based half of IA-5's two-trigger rotation model). Paired with\n * {@link lastRotatedAt} so a generator can compute whether rotation is actually current, rather\n * than only recording that a period was declared; see `lifecycle-model.ts`'s\n * `computeRotationStatus()` for exactly how the two combine with {@link expiresAt}.\n */\n rotationPeriod?: string\n /**\n * ISO date string -- the last time this variable's value was actually rotated. Paired with\n * {@link rotationPeriod} to compute rotation compliance. Independent of {@link expiresAt}, which\n * states when the *current* value stops being valid, not when it was last changed -- a value can\n * be freshly rotated and still have a near-term `expiresAt` (a short-lived token), or long overdue\n * for rotation while its `expiresAt` (if any) is still comfortably in the future.\n */\n lastRotatedAt?: string\n /**\n * IA-5's event-based rotation triggers that apply to this variable (e.g. \"suspected compromise\",\n * \"personnel change\", \"system update\") -- the event-based half of IA-5's two-trigger rotation\n * model. Structured and additive alongside the existing free-text {@link refreshInstructions}\n * rather than replacing it: this is a list a generator can render as its own column,\n * `refreshInstructions` stays prose (\"how to actually rotate it\"). Presence-only -- env-cap has\n * no way to observe whether a listed event actually occurred, so declaring this never by itself\n * changes a computed rotation-compliance status (see `lifecycle-model.ts`); it only makes the\n * event-based trigger's existence visible in generated output.\n */\n rotationTriggerEvents?: readonly string[]\n /**\n * Explicit, actionable instructions for obtaining this variable's value the *first* time --\n * where `refreshInstructions` is \"how to rotate it once you already have one,\" this is \"how to\n * get one at all\" (e.g. \"Create a restricted API key in the Stripe dashboard under Developers ->\n * API keys, scoped to read/write Charges.\"). A named field specifically so this can render as\n * its own labeled line in generated docs, rather than requiring a `metadata.setup`-style\n * convention with no dedicated rendering or type checking.\n */\n setupInstructions?: string\n /** Documentation-level assertion that this variable must be set. Independent of how (or whether) a validator actually enforces it. */\n required?: boolean\n /** Marks this variable as being phased out. Independent of `expiresAt` (a rotation/sunset date) and of the contract-level `active` switch (on/off, not a phase-out signal). */\n deprecated?: boolean\n /** Why this variable is deprecated, and/or what to use instead. Only meaningful alongside `deprecated: true`. */\n deprecatedReason?: string\n /** ISO date string -- by when a deprecated variable must be removed. Only meaningful alongside `deprecated: true`. */\n removeBy?: string\n /** The previous environment variable name this one replaces, if this declaration is the result of a rename. Lets the Change Model correlate a remove+add pair into a single rename entry instead of two unrelated changes. */\n renamedFrom?: string\n /** Why this variable's value is collected/used -- a framework-agnostic fact (pairs with `legalBasis`; a specific citation like a GDPR article belongs in `metadata` instead). Overrides the contract's own `purpose` for this key. */\n purpose?: string\n /** The legal basis this variable's collection/use relies on -- framework-agnostic (e.g. \"user consent,\" \"contractual necessity\"), never a specific statute name. Overrides the contract's own `legalBasis` for this key. */\n legalBasis?: string\n /** Descriptive retention policy (e.g. \"delete after 90 days\"). A policy statement, not a computed value -- unlike `expiresAt`, nothing parses or evaluates this. Overrides the contract's own `retention` for this key. */\n retention?: string\n /** Where this variable's value is/must be stored (a region, or a permitted set of regions). Overrides the contract's own `dataResidency` for this key. */\n dataResidency?: string | string[]\n /** Documentation-level assertion that this variable's handling must be auditable. Overrides the contract's own `auditRequired` for this key. */\n auditRequired?: boolean\n /**\n * Developer-supplied evidence assertions for this variable -- verified over\n * time, unlike every other field above, which is declared and never\n * verified. Kept structurally separate for exactly that reason; see\n * {@link VariableEvidenceDocs}.\n */\n evidence?: VariableEvidenceDocs\n /**\n * Structured, unsupported-key documentation -- any primitive or object value, for anything that\n * doesn't warrant its own named field. A previously-supported top-level key belongs in a named\n * field above instead of here once one exists for it.\n */\n metadata?: Record<string, unknown>\n}\n\n/**\n * Contract-level documentation, plus everything {@link documentEnv}'s options used to carry that\n * only the generator ever read.\n *\n * @remarks\n * Generic over `S`, the exact schema type {@link documentEnv} infers from its `schema` argument --\n * this is what makes `variables` below a closed, checked map (a typo'd or renamed key is a\n * compile error, not a silent no-op) rather than an open `Record<string, VariableDocs>` any string\n * would satisfy. `S` defaults to the widest possible schema so this type is still nameable on its\n * own (e.g. in a helper function's own parameter type) without narrowing to one specific contract.\n */\nexport interface ContractDocs<S extends EnvSchema = EnvSchema> {\n /** Overrides the auto-generated label used in generated docs. Purely cosmetic. Wins over `createEnv()`'s own `name` option, which in turn wins over the exported binding name. */\n name?: string\n /** Groups this contract under a heading in the generated docs' feature catalog. */\n category?: string\n /** The generator throws if two *active* contracts declare the same `exclusiveGroup` -- use it to mark interchangeable features (e.g. two database backends) as mutually exclusive. */\n exclusiveGroup?: string\n /** When `false`, this contract is excluded from the generated manifest, docs' required section, and exclusiveGroup checks -- it still appears, marked disabled, in the feature catalog. Defaults to `true`. */\n active?: boolean\n /** Default owner for every variable in this contract that doesn't set its own `owner`. */\n owner?: string\n /** Default sensitivity for every variable in this contract that doesn't set its own `sensitivity` -- see {@link VariableDocs.sensitivity} for why this is an open `string`. */\n sensitivity?: string\n /** Whole-contract/feature sunset date, ISO date string. */\n expiresAt?: string\n /** Marks this whole contract/feature as being phased out. Independent of `active` (on/off, not a phase-out signal). */\n deprecated?: boolean\n /** Why this contract is deprecated, and/or what to use instead. Only meaningful alongside `deprecated: true`. */\n deprecatedReason?: string\n /** Default reason this contract's variables' values are collected/used -- see {@link VariableDocs.purpose}. */\n purpose?: string\n /** Default legal basis for this contract's variables -- see {@link VariableDocs.legalBasis}. */\n legalBasis?: string\n /** Default retention policy for this contract's variables -- see {@link VariableDocs.retention}. */\n retention?: string\n /** Default data residency for this contract's variables -- see {@link VariableDocs.dataResidency}. */\n dataResidency?: string | string[]\n /** Default audit-required assertion for this contract's variables -- see {@link VariableDocs.auditRequired}. */\n auditRequired?: boolean\n /** Arbitrary contract-level documentation (e.g. `runbook`), rendered alongside this feature -- see {@link VariableDocs.metadata}. */\n metadata?: Record<string, unknown>\n /**\n * Per-variable documentation, keyed by variable name -- keys are checked against `S`'s own keys\n * at compile time, so documenting a variable that was renamed or removed from `schema` (or a\n * plain typo) is a type error here, not a silently-ignored entry the generator would otherwise\n * have to report as \"stale\" after the fact. A schema key absent from `variables` entirely is\n * still valid (not every variable needs documentation) and is reported as undocumented by the\n * generator, exactly as before.\n */\n variables?: { readonly [K in keyof S]?: VariableDocs }\n}\n\n/**\n * Documents a schema for the generator: explains values, assigns ownership,\n * and describes lifecycle, feeding the generated docs artifact and\n * `.env.example`. Pass it the *same* schema object given to {@link createEnv}, so\n * the generator can statically link the two and verify every variable is\n * documented -- and so TypeScript can check `docs.variables`' keys against\n * `schema`'s own keys, the same object identity doing double duty for both\n * the generator's static link and the type checker's.\n *\n * @remarks\n * A no-op at runtime by design -- nothing passed here is retained anywhere,\n * and this can never throw, no matter how malformed `schema`/`docs` are.\n * Calling it is entirely optional: {@link createEnv} works identically whether or\n * not a matching `documentEnv` call exists. The real \"is everything\n * documented?\" check, and every artifact this data drives (the docs\n * artifact's ownership matrix, dependency graph, lifecycle report, and\n * security review; `.env.example`'s comments), runs entirely inside\n * {@link build.generateEnvManifest}'s static analysis -- this function's only job at\n * runtime is to exist as a safe, harmless marker the AST parser can find,\n * and to give you type-checked argument shapes while writing it.\n *\n * `S` is inferred from `schema`, never written out by hand -- pass the\n * schema object literal (or a `const`-inferred reference to it) directly for\n * the strongest inference; an explicitly-widened `schema: EnvSchema`\n * annotation loses the per-key literal type and falls back to accepting any\n * string key in `docs.variables`, same as before this generic existed.\n */\n// Deliberately a true no-op (see the doc comment above): `documentEnv` has no\n// runtime behavior at all, only a compile-time keyed-shape check and a\n// static-analysis-visible call site -- its body being empty is observably\n// identical to explicitly discarding both arguments, so there is nothing a\n// test could assert to distinguish the two. (A `next-line` disable placed\n// inside the parameter list, right before the closing paren, does not\n// reliably attach as the block's own leading comment -- hence this unscoped\n// disable/restore pair instead; see data-cap's `core/document.ts` for the\n// same pattern and the Stryker directive-attachment mechanics behind it.)\n// Stryker disable BlockStatement\nexport function documentEnv<S extends EnvSchema>(schema: S, docs: ContractDocs<S>): void {\n // Intentionally inert -- see the module doc comment above. Do not add\n // logic here; anything this function does happens at runtime, in every\n // process that imports the schema file, which is exactly what this split\n // exists to avoid. The `void`s below only satisfy `noUnusedParameters` --\n // a bare `schema`/`docs` expression statement trips `no-unused-expressions`\n // instead, and renaming these public parameters to `_schema`/`_docs` would\n // leak into every consumer's editor hover.\n // eslint-disable-next-line @typescript-eslint/no-meaningless-void-operator\n void schema\n // eslint-disable-next-line @typescript-eslint/no-meaningless-void-operator\n void docs\n}\n// Stryker restore BlockStatement\n","import { resetCache } from \"./cache.js\"\n\n/**\n * Clears cached validation state. Intended for tests and dev tooling (e.g.\n * `beforeEach(() => resetEnvCache())` in a test suite that re-validates with\n * different fixture values per test) -- production applications validate\n * once at startup and should not normally call this.\n */\nexport function resetEnvCache(): void {\n resetCache()\n}\n","import { getState, setContractError, setContractValues } from \"./cache.js\"\nimport type { CacheState } from \"./cache.js\"\nimport { EnvValidationError } from \"./errors.js\"\nimport type { VariableFailure } from \"./errors.js\"\nimport { getContractInternals } from \"./registry.js\"\nimport type { validateEnvOptions, validateEnvResult } from \"./types.js\"\n\n/**\n * Validates every variable in every contract in `options.manifest` against\n * `options.values`, then caches the results.\n *\n * @remarks\n * Idempotent: the first successful (or failed) call is authoritative for the life of the\n * process -- later calls return (or re-throw) that same outcome without re-running any\n * processor or validator. Concurrent in-flight calls share one underlying run.\n *\n * @throws {EnvValidationError} If any variable fails processing or validation.\n */\nexport async function validateEnv(options: validateEnvOptions): Promise<validateEnvResult> {\n const state = getState()\n\n // `result`/`error` are only ever set together with their matching\n // `status` (`runValidation()` below sets `state.status = \"ready\"` and\n // `state.result` in the same statement pair, likewise \"failed\"/`error`),\n // and `resetCache()` always replaces the whole `state` object rather than\n // resetting fields individually -- so checking `status` alone already\n // implies `result`/`error` is set. Load-bearing for TypeScript's own\n // narrowing of `state.result`/`state.error` from `T | undefined` to `T`\n // for the `return`/`throw` below, though -- hand-verified by removing\n // each `&&` clause entirely and running the full `vitest run`: all 1236\n // tests still pass.\n // Stryker disable next-line ConditionalExpression, LogicalOperator\n if (state.status === \"ready\" && state.result) {\n return state.result\n }\n // Stryker disable next-line ConditionalExpression, LogicalOperator\n if (state.status === \"failed\" && state.error) {\n throw state.error\n }\n if (state.inFlight) {\n return state.inFlight\n }\n\n // Genuinely unobservable via any real (all-synchronous, per `Processor`/\n // `Validator`'s own types) caller: `runValidation()` below has no\n // internal `await`, so its entire body -- including overwriting\n // `state.status` to \"ready\" or \"failed\" -- runs to completion\n // synchronously as part of evaluating the very next line, before control\n // ever returns to anything that could observe \"validating\". Kept as an\n // honest, self-documenting state-machine value (and to keep `CacheStatus`\n // meaningful if a future version ever awaits inside `runValidation()`).\n // Hand-verified: replacing the string with \"\" and running the full\n // `vitest run` leaves all 1236 tests passing.\n // Stryker disable next-line StringLiteral\n state.status = \"validating\"\n const run = runValidation(options, state)\n state.inFlight = run\n try {\n return await run\n } finally {\n // Not `= undefined`: `inFlight` is genuinely optional (absent between\n // runs), and exactOptionalPropertyTypes distinguishes \"key absent\" from\n // \"key present holding undefined\" -- delete is the operation that\n // actually means the former.\n delete state.inFlight\n }\n}\n\n/**\n * Whether a variable participates in a validation run: unset `context`\n * always participates; otherwise it participates only when `activeContexts`\n * contains that exact string (no prefix matching, no wildcards, no\n * hierarchy -- see ADR 0022's Formal Invariants).\n */\nfunction matchesContext(\n variableContext: string | undefined,\n activeContexts: ReadonlySet<string> | undefined,\n): boolean {\n return variableContext === undefined || (activeContexts?.has(variableContext) ?? false)\n}\n\n// `async` is load-bearing here despite no internal `await`: `validateEnv()`\n// assigns this call's return value directly to `state.inFlight` so\n// concurrent callers can share one in-flight run (see its own doc comment).\n// That only works if this genuinely returns a Promise -- a synchronous\n// function returning/throwing a plain value would change both the\n// concurrent-sharing behavior and the timing of a thrown validation error.\n// eslint-disable-next-line @typescript-eslint/require-await\nasync function runValidation(\n options: validateEnvOptions,\n state: CacheState,\n): Promise<validateEnvResult> {\n const failures: VariableFailure[] = []\n let variableCount = 0\n\n // Allocated only when contexts are actually in play, so the (overwhelmingly\n // common, and every pre-existing) zero-context path does no extra work.\n const activeContexts = options.activeContexts?.length\n ? new Set(options.activeContexts)\n : undefined\n\n // A poisoned seed element here would be an accumulator only ever `.push()`ed\n // to (never filtered), reaching the two per-entry loops below\n // (`setContractError`/`setContractValues`) destructured as `{id: undefined,\n // values: undefined}` -- `setContractValues(undefined, Object.freeze(undefined))`\n // neither throws nor collides with any real contract's own symbol-keyed\n // entry, so it's unobservable via any real `createEnv()`/`validateEnv()`\n // consumer. Hand-verified: seeding this with a phantom entry and running\n // the full `vitest run` leaves all 1236 tests passing.\n // Stryker disable next-line ArrayDeclaration\n const resolved: { id: symbol; values: Record<string, unknown> }[] = []\n\n for (const contract of options.manifest) {\n const internals = getContractInternals(contract)\n const values: Record<string, unknown> = {}\n\n for (const key of Object.keys(internals.schema)) {\n const definition = internals.schema[key]\n // `key` was just enumerated from `Object.keys(internals.schema)`, so\n // this is always a real entry -- noUncheckedIndexedAccess can't\n // express that invariant from an object index signature, only that\n // indexing is *generally* unsafe. A real guard (not a non-null\n // assertion, forbidden in src/) satisfies the type checker without\n // hiding the possibility. Hand-verified: mutating this condition away\n // and running the real suite passes unchanged.\n // Stryker disable next-line ConditionalExpression\n if (definition === undefined) continue\n\n // A variable whose context isn't active is skipped entirely -- no\n // default/processor/validator runs, it's never counted as validated,\n // and it stays out of `values`, so `create.ts`'s getter finds it\n // absent and throws EnvNotReadyError exactly as if this run had\n // never happened for it. See ADR 0022.\n if (!matchesContext(definition.context, activeContexts)) continue\n\n variableCount += 1\n\n const raw = options.values[key]\n\n let working: unknown = raw\n // Bypassing the `!== undefined` clause only matters when `working ===\n // undefined` AND `definition.default` genuinely is `undefined` --\n // `typeof undefined === \"function\"` is false, so `working` is\n // assigned `definition.default` (`undefined`) either way: applying \"no\n // default\" when there wasn't one is identical to not applying it.\n // Hand-verified: replacing the whole clause with `true` and running\n // the full `vitest run` leaves all 1236 tests passing.\n // Stryker disable next-line ConditionalExpression\n if (working === undefined && definition.default !== undefined) {\n working =\n typeof definition.default === \"function\"\n ? (definition.default as () => unknown)()\n : definition.default\n }\n\n let processed: unknown = working\n if (definition.processor) {\n try {\n processed = definition.processor(working)\n } catch (cause) {\n failures.push({\n variable: key,\n contractName: internals.name,\n source: internals.source,\n kind: \"processor\",\n message: toMessage(cause),\n })\n continue\n }\n }\n\n if (definition.validator) {\n let outcome: true | string\n try {\n outcome = definition.validator(processed, options.values)\n } catch (cause) {\n outcome = toMessage(cause)\n }\n if (outcome !== true) {\n failures.push({\n variable: key,\n contractName: internals.name,\n source: internals.source,\n kind: \"validator\",\n message: outcome,\n })\n continue\n }\n }\n\n values[key] = processed\n }\n\n resolved.push({ id: internals.id, values })\n state.contractIds.add(internals.id)\n }\n\n if (failures.length > 0) {\n const error = new EnvValidationError(failures)\n for (const { id } of resolved) {\n setContractError(id, error)\n }\n state.status = \"failed\"\n state.error = error\n throw error\n }\n\n for (const { id, values } of resolved) {\n setContractValues(id, Object.freeze(values))\n }\n\n const result: validateEnvResult = {\n contractCount: options.manifest.length,\n variableCount,\n }\n state.status = \"ready\"\n state.result = result\n return result\n}\n\nfunction toMessage(cause: unknown): string {\n return cause instanceof Error ? cause.message : String(cause)\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/runtime/cache.ts","../src/runtime/errors.ts","../src/runtime/registry.ts","../src/runtime/create.ts","../src/runtime/document.ts","../src/runtime/reset.ts","../src/runtime/validate.ts"],"names":["state"],"mappings":";AAsBA,IAAI,QAAoB,WAAA,EAAY;AACpC,IAAM,cAAA,uBAAqB,GAAA,EAA+C;AAC1E,IAAM,cAAA,uBAAqB,GAAA,EAAgC;AAE3D,SAAS,WAAA,GAA0B;AACjC,EAAA,OAAO,EAAE,WAAA,kBAAa,IAAI,GAAA,EAAI,EAAE;AAClC;AAEO,SAAS,QAAA,GAAuB;AACrC,EAAA,OAAO,KAAA;AACT;AAEO,SAAS,kBAAkB,EAAA,EAA2D;AAC3F,EAAA,OAAO,cAAA,CAAe,IAAI,EAAE,CAAA;AAC9B;AAEO,SAAS,iBAAA,CAAkB,IAAY,MAAA,EAAiD;AAC7F,EAAA,cAAA,CAAe,GAAA,CAAI,IAAI,MAAM,CAAA;AAC/B;AAEO,SAAS,iBAAiB,EAAA,EAA4C;AAC3E,EAAA,OAAO,cAAA,CAAe,IAAI,EAAE,CAAA;AAC9B;AAEO,SAAS,gBAAA,CAAiB,IAAY,KAAA,EAAiC;AAC5E,EAAA,cAAA,CAAe,GAAA,CAAI,IAAI,KAAK,CAAA;AAC9B;AAGO,SAAS,UAAA,GAAmB;AACjC,EAAA,KAAA,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AAM,CAAC,CAAA;AAAA,EAC7C;AAEA,EAAA,MAAM,MAAA,GAA4B;AAAA,IAChC,aAAA,EAAe,QAAQ,QAAA,CAAS,MAAA;AAAA,IAChC;AAAA,GACF;AACA,EAAAA,OAAM,MAAA,GAAS,MAAA;AACf,EAAA,OAAO,MAAA;AACT;AAEA,SAAS,UAAU,KAAA,EAAwB;AACzC,EAAA,OAAO,KAAA,YAAiB,KAAA,GAAQ,KAAA,CAAM,OAAA,GAAU,OAAO,KAAK,CAAA;AAC9D","file":"index.js"}
|
package/dist/node.cjs
CHANGED
|
@@ -25,14 +25,16 @@ function stat(path) {
|
|
|
25
25
|
function realpath(path) {
|
|
26
26
|
return fs__default.default.realpath(path);
|
|
27
27
|
}
|
|
28
|
-
var nodeBuildFileSystem = {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
28
|
+
var nodeBuildFileSystem = new class {
|
|
29
|
+
constructor() {
|
|
30
|
+
this.readFile = readFile;
|
|
31
|
+
this.writeFile = writeFile;
|
|
32
|
+
this.mkdir = mkdir;
|
|
33
|
+
this.readdir = readdir;
|
|
34
|
+
this.stat = stat;
|
|
35
|
+
this.realpath = realpath;
|
|
36
|
+
}
|
|
37
|
+
}();
|
|
36
38
|
|
|
37
39
|
exports.nodeBuildFileSystem = nodeBuildFileSystem;
|
|
38
40
|
//# sourceMappingURL=node.cjs.map
|
package/dist/node.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/cli/filesystem.ts"],"names":["fs"],"mappings":";;;;;;;;;AA0BA,SAAS,QAAA,CAAS,MAAc,QAAA,EAAmC;AACjE,EAAA,OAAOA,mBAAA,CAAG,QAAA,CAAS,IAAA,EAAM,QAAQ,CAAA;AACnC;AAEA,SAAS,SAAA,CAAU,IAAA,EAAc,IAAA,EAAc,QAAA,EAAiC;AAC9E,EAAA,OAAOA,mBAAA,CAAG,SA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B;AAMO,IAAM,mBAAA,GAAuC,IAAK,MAAiC;AAAA,EAAjC,WAAA,GAAA;AACvD,IAAA,IAAA,CAAS,QAAA,GAAW,QAAA;AACpB,IAAA,IAAA,CAAS,SAAA,GAAY,SAAA;AACrB,IAAA,IAAA,CAAS,KAAA,GAAQ,KAAA;AACjB,IAAA,IAAA,CAAS,OAAA,GAAU,OAAA;AACnB,IAAA,IAAA,CAAS,IAAA,GAAO,IAAA;AAChB,IAAA,IAAA,CAAS,QAAA,GAAW,QAAA;AAAA,EAAA;AACtB,CAAA","file":"node.cjs"}
|
package/dist/node.js
CHANGED
|
@@ -19,14 +19,16 @@ function stat(path) {
|
|
|
19
19
|
function realpath(path) {
|
|
20
20
|
return fs.realpath(path);
|
|
21
21
|
}
|
|
22
|
-
var nodeBuildFileSystem = {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
22
|
+
var nodeBuildFileSystem = new class {
|
|
23
|
+
constructor() {
|
|
24
|
+
this.readFile = readFile;
|
|
25
|
+
this.writeFile = writeFile;
|
|
26
|
+
this.mkdir = mkdir;
|
|
27
|
+
this.readdir = readdir;
|
|
28
|
+
this.stat = stat;
|
|
29
|
+
this.realpath = realpath;
|
|
30
|
+
}
|
|
31
|
+
}();
|
|
30
32
|
|
|
31
33
|
export { nodeBuildFileSystem };
|
|
32
34
|
//# sourceMappingURL=node.js.map
|
package/dist/node.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/cli/filesystem.ts"],"names":[],"mappings":";;;AA0BA,SAAS,QAAA,CAAS,MAAc,QAAA,EAAmC;AACjE,EAAA,OAAO,EAAA,CAAG,QAAA,CAAS,IAAA,EAAM,QAAQ,CAAA;AACnC;AAEA,SAAS,SAAA,CAAU,IAAA,EAAc,IAAA,EAAc,QAAA,EAAiC;AAC9E,EAAA,OAAO,EAAA,CAAG,SAAA,CAAU,IAAA,EA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