@maverickcer/env-cap 0.2.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/LICENSE +21 -0
- package/README.md +279 -0
- package/dist/.dts/build/assemble-project.d.ts +47 -0
- package/dist/.dts/build/assemble-project.d.ts.map +1 -0
- package/dist/.dts/build/change-model.d.ts +62 -0
- package/dist/.dts/build/change-model.d.ts.map +1 -0
- package/dist/.dts/build/check-artifacts.d.ts +48 -0
- package/dist/.dts/build/check-artifacts.d.ts.map +1 -0
- package/dist/.dts/build/citation-verification.d.ts +62 -0
- package/dist/.dts/build/citation-verification.d.ts.map +1 -0
- package/dist/.dts/build/compatibility.d.ts +76 -0
- package/dist/.dts/build/compatibility.d.ts.map +1 -0
- package/dist/.dts/build/contract-model.d.ts +92 -0
- package/dist/.dts/build/contract-model.d.ts.map +1 -0
- package/dist/.dts/build/deep-equal.d.ts +9 -0
- package/dist/.dts/build/deep-equal.d.ts.map +1 -0
- package/dist/.dts/build/deep-freeze.d.ts +20 -0
- package/dist/.dts/build/deep-freeze.d.ts.map +1 -0
- package/dist/.dts/build/dependency-graph.d.ts +168 -0
- package/dist/.dts/build/dependency-graph.d.ts.map +1 -0
- package/dist/.dts/build/dependency-model.d.ts +79 -0
- package/dist/.dts/build/dependency-model.d.ts.map +1 -0
- package/dist/.dts/build/discover.d.ts +25 -0
- package/dist/.dts/build/discover.d.ts.map +1 -0
- package/dist/.dts/build/display-path.d.ts +24 -0
- package/dist/.dts/build/display-path.d.ts.map +1 -0
- package/dist/.dts/build/docs.d.ts +176 -0
- package/dist/.dts/build/docs.d.ts.map +1 -0
- package/dist/.dts/build/env-example.d.ts +85 -0
- package/dist/.dts/build/env-example.d.ts.map +1 -0
- package/dist/.dts/build/errors.d.ts +78 -0
- package/dist/.dts/build/errors.d.ts.map +1 -0
- package/dist/.dts/build/evidence-cache.d.ts +74 -0
- package/dist/.dts/build/evidence-cache.d.ts.map +1 -0
- package/dist/.dts/build/evidence-model.d.ts +50 -0
- package/dist/.dts/build/evidence-model.d.ts.map +1 -0
- package/dist/.dts/build/evidence-reference.d.ts +67 -0
- package/dist/.dts/build/evidence-reference.d.ts.map +1 -0
- package/dist/.dts/build/evidence-snapshot.d.ts +123 -0
- package/dist/.dts/build/evidence-snapshot.d.ts.map +1 -0
- package/dist/.dts/build/exclusive-group.d.ts +19 -0
- package/dist/.dts/build/exclusive-group.d.ts.map +1 -0
- package/dist/.dts/build/finding-model.d.ts +79 -0
- package/dist/.dts/build/finding-model.d.ts.map +1 -0
- package/dist/.dts/build/generate-documentation.d.ts +176 -0
- package/dist/.dts/build/generate-documentation.d.ts.map +1 -0
- package/dist/.dts/build/generate-env-artifacts.d.ts +176 -0
- package/dist/.dts/build/generate-env-artifacts.d.ts.map +1 -0
- package/dist/.dts/build/generate-evidence.d.ts +77 -0
- package/dist/.dts/build/generate-evidence.d.ts.map +1 -0
- package/dist/.dts/build/generate-manifest.d.ts +101 -0
- package/dist/.dts/build/generate-manifest.d.ts.map +1 -0
- package/dist/.dts/build/generate-usage.d.ts +95 -0
- package/dist/.dts/build/generate-usage.d.ts.map +1 -0
- package/dist/.dts/build/generated-banner.d.ts +52 -0
- package/dist/.dts/build/generated-banner.d.ts.map +1 -0
- package/dist/.dts/build/glob.d.ts +18 -0
- package/dist/.dts/build/glob.d.ts.map +1 -0
- package/dist/.dts/build/governance-fields.d.ts +34 -0
- package/dist/.dts/build/governance-fields.d.ts.map +1 -0
- package/dist/.dts/build/humanize-key.d.ts +14 -0
- package/dist/.dts/build/humanize-key.d.ts.map +1 -0
- package/dist/.dts/build/index.d.ts +107 -0
- package/dist/.dts/build/index.d.ts.map +1 -0
- package/dist/.dts/build/lifecycle-model.d.ts +64 -0
- package/dist/.dts/build/lifecycle-model.d.ts.map +1 -0
- package/dist/.dts/build/link.d.ts +215 -0
- package/dist/.dts/build/link.d.ts.map +1 -0
- package/dist/.dts/build/literal-eval.d.ts +23 -0
- package/dist/.dts/build/literal-eval.d.ts.map +1 -0
- package/dist/.dts/build/live-expirations.d.ts +47 -0
- package/dist/.dts/build/live-expirations.d.ts.map +1 -0
- package/dist/.dts/build/manifest-snapshot.d.ts +229 -0
- package/dist/.dts/build/manifest-snapshot.d.ts.map +1 -0
- package/dist/.dts/build/manifest.d.ts +31 -0
- package/dist/.dts/build/manifest.d.ts.map +1 -0
- package/dist/.dts/build/map-utils.d.ts +8 -0
- package/dist/.dts/build/map-utils.d.ts.map +1 -0
- package/dist/.dts/build/ownership-model.d.ts +57 -0
- package/dist/.dts/build/ownership-model.d.ts.map +1 -0
- package/dist/.dts/build/parse.d.ts +199 -0
- package/dist/.dts/build/parse.d.ts.map +1 -0
- package/dist/.dts/build/reference-projections.d.ts +156 -0
- package/dist/.dts/build/reference-projections.d.ts.map +1 -0
- package/dist/.dts/build/resolution/resolve-import.d.ts +53 -0
- package/dist/.dts/build/resolution/resolve-import.d.ts.map +1 -0
- package/dist/.dts/build/resolution/resolve-package-schema.d.ts +83 -0
- package/dist/.dts/build/resolution/resolve-package-schema.d.ts.map +1 -0
- package/dist/.dts/build/resolution/resolve-tsconfig-paths.d.ts +101 -0
- package/dist/.dts/build/resolution/resolve-tsconfig-paths.d.ts.map +1 -0
- package/dist/.dts/build/resolution/resolve-within-root.d.ts +35 -0
- package/dist/.dts/build/resolution/resolve-within-root.d.ts.map +1 -0
- package/dist/.dts/build/resolve-import.d.ts +50 -0
- package/dist/.dts/build/resolve-import.d.ts.map +1 -0
- package/dist/.dts/build/resolve-package-schema.d.ts +99 -0
- package/dist/.dts/build/resolve-package-schema.d.ts.map +1 -0
- package/dist/.dts/build/resolve-tsconfig-paths.d.ts +100 -0
- package/dist/.dts/build/resolve-tsconfig-paths.d.ts.map +1 -0
- package/dist/.dts/build/resolve-within-root.d.ts +35 -0
- package/dist/.dts/build/resolve-within-root.d.ts.map +1 -0
- package/dist/.dts/build/sarif.d.ts +66 -0
- package/dist/.dts/build/sarif.d.ts.map +1 -0
- package/dist/.dts/build/scan-dependencies.d.ts +47 -0
- package/dist/.dts/build/scan-dependencies.d.ts.map +1 -0
- package/dist/.dts/build/sort-by-identity.d.ts +14 -0
- package/dist/.dts/build/sort-by-identity.d.ts.map +1 -0
- package/dist/.dts/build/source-position.d.ts +69 -0
- package/dist/.dts/build/source-position.d.ts.map +1 -0
- package/dist/.dts/build/tool-version.d.ts +8 -0
- package/dist/.dts/build/tool-version.d.ts.map +1 -0
- package/dist/.dts/build/types.d.ts +53 -0
- package/dist/.dts/build/types.d.ts.map +1 -0
- package/dist/.dts/build/usage-report.d.ts +124 -0
- package/dist/.dts/build/usage-report.d.ts.map +1 -0
- package/dist/.dts/cli/filesystem.d.ts +3 -0
- package/dist/.dts/cli/filesystem.d.ts.map +1 -0
- package/dist/.dts/eslint-plugin/glob.d.ts +18 -0
- package/dist/.dts/eslint-plugin/glob.d.ts.map +1 -0
- package/dist/.dts/eslint-plugin/index.d.ts +27 -0
- package/dist/.dts/eslint-plugin/index.d.ts.map +1 -0
- package/dist/.dts/eslint-plugin/no-node-fs.d.ts +25 -0
- package/dist/.dts/eslint-plugin/no-node-fs.d.ts.map +1 -0
- package/dist/.dts/eslint-plugin/no-raw-process-env.d.ts +23 -0
- package/dist/.dts/eslint-plugin/no-raw-process-env.d.ts.map +1 -0
- package/dist/.dts/evidence/define-projection.d.ts +51 -0
- package/dist/.dts/evidence/define-projection.d.ts.map +1 -0
- package/dist/.dts/evidence/index.d.ts +23 -0
- package/dist/.dts/evidence/index.d.ts.map +1 -0
- package/dist/.dts/helpers/index.d.ts +135 -0
- package/dist/.dts/helpers/index.d.ts.map +1 -0
- package/dist/.dts/helpers/processors.d.ts +32 -0
- package/dist/.dts/helpers/processors.d.ts.map +1 -0
- package/dist/.dts/helpers/validators.d.ts +68 -0
- package/dist/.dts/helpers/validators.d.ts.map +1 -0
- package/dist/.dts/node/index.d.ts +2 -0
- package/dist/.dts/node/index.d.ts.map +1 -0
- package/dist/.dts/runtime/cache.d.ts +20 -0
- package/dist/.dts/runtime/cache.d.ts.map +1 -0
- package/dist/.dts/runtime/create.d.ts +20 -0
- package/dist/.dts/runtime/create.d.ts.map +1 -0
- package/dist/.dts/runtime/document.d.ts +181 -0
- package/dist/.dts/runtime/document.d.ts.map +1 -0
- package/dist/.dts/runtime/errors.d.ts +55 -0
- package/dist/.dts/runtime/errors.d.ts.map +1 -0
- package/dist/.dts/runtime/index.d.ts +24 -0
- package/dist/.dts/runtime/index.d.ts.map +1 -0
- package/dist/.dts/runtime/registry.d.ts +12 -0
- package/dist/.dts/runtime/registry.d.ts.map +1 -0
- package/dist/.dts/runtime/reset.d.ts +8 -0
- package/dist/.dts/runtime/reset.d.ts.map +1 -0
- package/dist/.dts/runtime/types.d.ts +175 -0
- package/dist/.dts/runtime/types.d.ts.map +1 -0
- package/dist/.dts/runtime/validate.d.ts +14 -0
- package/dist/.dts/runtime/validate.d.ts.map +1 -0
- package/dist/build.cjs +83 -0
- package/dist/build.cjs.map +1 -0
- package/dist/build.d.cts +1 -0
- package/dist/build.d.ts +1 -0
- package/dist/build.js +19 -0
- package/dist/build.js.map +1 -0
- package/dist/cli/index.js +134 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/eslint-plugin/index.cjs +12 -0
- package/dist/eslint-plugin/index.cjs.map +1 -0
- package/dist/eslint-plugin/index.d.cts +1 -0
- package/dist/eslint-plugin/index.d.ts +1 -0
- package/dist/eslint-plugin/index.js +5 -0
- package/dist/eslint-plugin/index.js.map +1 -0
- package/dist/evidence.cjs +7 -0
- package/dist/evidence.cjs.map +1 -0
- package/dist/evidence.d.cts +1 -0
- package/dist/evidence.d.ts +1 -0
- package/dist/evidence.js +5 -0
- package/dist/evidence.js.map +1 -0
- package/dist/helpers.cjs +8 -0
- package/dist/helpers.cjs.map +1 -0
- package/dist/helpers.d.cts +1 -0
- package/dist/helpers.d.ts +1 -0
- package/dist/helpers.js +5 -0
- package/dist/helpers.js.map +1 -0
- package/dist/index.cjs +15 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +7 -0
- package/dist/index.js.map +1 -0
- package/dist/node.cjs +13 -0
- package/dist/node.cjs.map +1 -0
- package/dist/node.d.cts +1 -0
- package/dist/node.d.ts +1 -0
- package/dist/node.js +7 -0
- package/dist/node.js.map +1 -0
- package/package.json +183 -0
- package/schemas/contract-model.schema.json +321 -0
- package/schemas/env-cap-report.schema.json +2369 -0
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { Processor } from "../runtime/index.js";
|
|
2
|
+
/** Splits a delimited string (or passes through an array) into items, running each through `processors` in order. */
|
|
3
|
+
export declare function toArray<T>(separator?: string | RegExp, processors?: Processor<unknown>[]): Processor<T[]>;
|
|
4
|
+
/** Decodes a base64 string into a `Buffer`. */
|
|
5
|
+
export declare function base64(): Processor<Buffer>;
|
|
6
|
+
/** Coerces a value to a `bigint`. */
|
|
7
|
+
export declare function toBigInt(): Processor<bigint>;
|
|
8
|
+
/** Coerces common boolean-like strings (`true`/`1`/`yes`/`on`, and their opposites) into a real boolean. */
|
|
9
|
+
export declare function toBoolean(): Processor<boolean>;
|
|
10
|
+
/** Parses a value into a `Date`. */
|
|
11
|
+
export declare function toDate(): Processor<Date>;
|
|
12
|
+
/** Coerces a value to a number and requires it to be an integer. */
|
|
13
|
+
export declare function toInteger(): Processor<number>;
|
|
14
|
+
/** Parses a JSON string; passes non-string values through unchanged. */
|
|
15
|
+
export declare function parseJSON<T = unknown>(): Processor<T>;
|
|
16
|
+
/** Lowercases a string (coercing nullish values to `""` first). */
|
|
17
|
+
export declare function toLowerCase(): Processor<string>;
|
|
18
|
+
/** Coerces a value to a number, rejecting empty/whitespace-only strings instead of silently resolving to `0`. */
|
|
19
|
+
export declare function toNumber(): Processor<number>;
|
|
20
|
+
/** Compiles a value into a `RegExp`. */
|
|
21
|
+
export declare function toRegExp(): Processor<RegExp>;
|
|
22
|
+
/** Splits a string on `separator` into a trimmed string array; returns `[]` for non-string input. */
|
|
23
|
+
export declare function split(separator?: string): Processor<string[]>;
|
|
24
|
+
/** Coerces a value to a string, treating nullish values as `""`. */
|
|
25
|
+
export declare function toString(): Processor<string>;
|
|
26
|
+
/** Trims surrounding whitespace from a string (coercing nullish values to `""` first). */
|
|
27
|
+
export declare function trim(): Processor<string>;
|
|
28
|
+
/** Uppercases a string (coercing nullish values to `""` first). */
|
|
29
|
+
export declare function toUpperCase(): Processor<string>;
|
|
30
|
+
/** Parses a value into a `URL`, treating nullish values as `""` first. */
|
|
31
|
+
export declare function toURL(): Processor<URL>;
|
|
32
|
+
//# sourceMappingURL=processors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"processors.d.ts","sourceRoot":"","sources":["../../../src/helpers/processors.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAA;AAepD,qHAAqH;AACrH,wBAAgB,OAAO,CAAC,CAAC,EACvB,SAAS,GAAE,MAAM,GAAG,MAAY,EAChC,UAAU,GAAE,SAAS,CAAC,OAAO,CAAC,EAAO,GACpC,SAAS,CAAC,CAAC,EAAE,CAAC,CAYhB;AAED,+CAA+C;AAC/C,wBAAgB,MAAM,IAAI,SAAS,CAAC,MAAM,CAAC,CAQ1C;AAED,qCAAqC;AACrC,wBAAgB,QAAQ,IAAI,SAAS,CAAC,MAAM,CAAC,CAQ5C;AAED,4GAA4G;AAC5G,wBAAgB,SAAS,IAAI,SAAS,CAAC,OAAO,CAAC,CAiB9C;AAED,oCAAoC;AACpC,wBAAgB,MAAM,IAAI,SAAS,CAAC,IAAI,CAAC,CAUxC;AAED,oEAAoE;AACpE,wBAAgB,SAAS,IAAI,SAAS,CAAC,MAAM,CAAC,CAU7C;AAED,wEAAwE;AACxE,wBAAgB,SAAS,CAAC,CAAC,GAAG,OAAO,KAAK,SAAS,CAAC,CAAC,CAAC,CAcrD;AAED,mEAAmE;AACnE,wBAAgB,WAAW,IAAI,SAAS,CAAC,MAAM,CAAC,CAE/C;AAED,iHAAiH;AACjH,wBAAgB,QAAQ,IAAI,SAAS,CAAC,MAAM,CAAC,CAqB5C;AAED,wCAAwC;AACxC,wBAAgB,QAAQ,IAAI,SAAS,CAAC,MAAM,CAAC,CAQ5C;AAED,qGAAqG;AACrG,wBAAgB,KAAK,CAAC,SAAS,SAAM,GAAG,SAAS,CAAC,MAAM,EAAE,CAAC,CAM1D;AAED,oEAAoE;AACpE,wBAAgB,QAAQ,IAAI,SAAS,CAAC,MAAM,CAAC,CAU5C;AAED,0FAA0F;AAC1F,wBAAgB,IAAI,IAAI,SAAS,CAAC,MAAM,CAAC,CAExC;AAED,mEAAmE;AACnE,wBAAgB,WAAW,IAAI,SAAS,CAAC,MAAM,CAAC,CAE/C;AAED,0EAA0E;AAC1E,wBAAgB,KAAK,IAAI,SAAS,CAAC,GAAG,CAAC,CAetC"}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import type { Validator } from "../runtime/index.js";
|
|
2
|
+
/** Passes when the date value is strictly after `date`. */
|
|
3
|
+
export declare function after(date: Date): Validator<Date>;
|
|
4
|
+
/** Passes only when every wrapped validator passes; returns the first failing message. */
|
|
5
|
+
export declare function all<T>(...validators: Validator<T>[]): Validator<T>;
|
|
6
|
+
/** Passes when at least one wrapped validator passes. */
|
|
7
|
+
export declare function any<T>(...validators: Validator<T>[]): Validator<T>;
|
|
8
|
+
/** Passes when the date value is strictly before `date`. */
|
|
9
|
+
export declare function before(date: Date): Validator<Date>;
|
|
10
|
+
/** Identity wrapper for a hand-written `Validator<T>` -- no behavior change, just a fluent entry point alongside the other helpers. */
|
|
11
|
+
export declare function custom<T>(validator: Validator<T>): Validator<T>;
|
|
12
|
+
/** Passes for a plausibly-shaped email address (`local@domain`). */
|
|
13
|
+
export declare function email(): Validator<string>;
|
|
14
|
+
/** Passes when the string ends with `suffix`. */
|
|
15
|
+
export declare function endsWith(suffix: string): Validator<string>;
|
|
16
|
+
/** Passes when the number is finite (rejects `Infinity`/`-Infinity`/`NaN`). */
|
|
17
|
+
export declare function finite(): Validator<number>;
|
|
18
|
+
/** Passes when the date is strictly after the current time. */
|
|
19
|
+
export declare function future(): Validator<Date>;
|
|
20
|
+
/** Passes when the string contains `text` as a substring. */
|
|
21
|
+
export declare function includes(text: string): Validator<string>;
|
|
22
|
+
/** Passes when the number is an integer. */
|
|
23
|
+
export declare function integer(): Validator<number>;
|
|
24
|
+
/** Passes when the string's length is exactly `expected`. */
|
|
25
|
+
export declare function length(expected: number): Validator<string>;
|
|
26
|
+
/** Passes when the string matches `pattern`; `message` overrides the default failure text. */
|
|
27
|
+
export declare function matches(pattern: RegExp, message?: string): Validator<string>;
|
|
28
|
+
/** Passes when the number is less than or equal to `maximum`. */
|
|
29
|
+
export declare function max(maximum: number): Validator<number>;
|
|
30
|
+
/** Passes when the array has at most `maximum` items. */
|
|
31
|
+
export declare function maxItems<T>(maximum: number): Validator<T[]>;
|
|
32
|
+
/** Passes when the string's length is at most `length`. */
|
|
33
|
+
export declare function maxLength(length: number): Validator<string>;
|
|
34
|
+
/** Passes when the number is greater than or equal to `minimum`. */
|
|
35
|
+
export declare function min(minimum: number): Validator<number>;
|
|
36
|
+
/** Passes when the array has at least `minimum` items. */
|
|
37
|
+
export declare function minItems<T>(minimum: number): Validator<T[]>;
|
|
38
|
+
/** Passes when the string's length is at least `length`. */
|
|
39
|
+
export declare function minLength(length: number): Validator<string>;
|
|
40
|
+
/** Passes when the number is strictly negative. */
|
|
41
|
+
export declare function negative(): Validator<number>;
|
|
42
|
+
/** Inverts a validator: passes when the wrapped validator fails, and vice versa. */
|
|
43
|
+
export declare function not<T>(validator: Validator<T>): Validator<T>;
|
|
44
|
+
/** Passes when the value is one of the `allowed` values. */
|
|
45
|
+
export declare function oneOf<T>(allowed: readonly T[]): Validator<T>;
|
|
46
|
+
/** Passes when the value is undefined, otherwise delegates to the provided validator. */
|
|
47
|
+
export declare function optional<T>(validator: Validator<T>): Validator<T | undefined>;
|
|
48
|
+
/** Passes when the date is strictly before the current time. */
|
|
49
|
+
export declare function past(): Validator<Date>;
|
|
50
|
+
/** Passes when the number is strictly positive. */
|
|
51
|
+
export declare function positive(): Validator<number>;
|
|
52
|
+
/** Passes when the number is within `[minimum, maximum]` inclusive. */
|
|
53
|
+
export declare function range(minimum: number, maximum: number): Validator<number>;
|
|
54
|
+
/** Runs the wrapped validator but replaces its failure message with `message`. */
|
|
55
|
+
export declare function refine<T>(validator: Validator<T>, message: string): Validator<T>;
|
|
56
|
+
/** Passes when the value is defined and, unless `allowEmptyString` is set, non-empty. */
|
|
57
|
+
export declare function required(allowEmptyString?: boolean): Validator<unknown>;
|
|
58
|
+
/** Passes when the number is a safe integer (`Number.isSafeInteger`). */
|
|
59
|
+
export declare function safeInteger(): Validator<number>;
|
|
60
|
+
/** Passes when every item in the array is unique. */
|
|
61
|
+
export declare function unique<T>(): Validator<T[]>;
|
|
62
|
+
/** Passes when the string is a valid absolute URL. */
|
|
63
|
+
export declare function url(): Validator<string>;
|
|
64
|
+
/** Passes when the string is a valid UUID of one of the given `versions` (default: any of 1-8). */
|
|
65
|
+
export declare function uuid(versions?: readonly number[]): Validator<string>;
|
|
66
|
+
/** Shorthand for `uuid([version])` -- passes only for that exact UUID version. */
|
|
67
|
+
export declare function uuidVersion(number: number): Validator<string>;
|
|
68
|
+
//# sourceMappingURL=validators.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validators.d.ts","sourceRoot":"","sources":["../../../src/helpers/validators.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAA;AAEpD,2DAA2D;AAC3D,wBAAgB,KAAK,CAAC,IAAI,EAAE,IAAI,GAAG,SAAS,CAAC,IAAI,CAAC,CAEjD;AAED,0FAA0F;AAC1F,wBAAgB,GAAG,CAAC,CAAC,EAAE,GAAG,UAAU,EAAE,SAAS,CAAC,CAAC,CAAC,EAAE,GAAG,SAAS,CAA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AAS,EAAE,SAAS,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC,CAAC,CAEhF;AAED,yFAAyF;AACzF,wBAAgB,QAAQ,CAAC,gBAAgB,UAAQ,GAAG,SAAS,CAAC,OAAO,CAAC,CAYrE;AAED,yEAAyE;AACzE,wBAAgB,WAAW,IAAI,SAAS,CAAC,MAAM,CAAC,CAE/C;AAED,qDAAqD;AACrD,wBAAgB,MAAM,CAAC,CAAC,KAAK,SAAS,CAAC,CAAC,EAAE,CAAC,CAG1C;AAED,sDAAsD;AACtD,wBAAgB,GAAG,IAAI,SAAS,CAAC,MAAM,CAAC,CASvC;AAED,mGAAmG;AACnG,wBAAgB,IAAI,CAAC,QAAQ,GAAE,SAAS,MAAM,EAA6B,GAAG,SAAS,CAAC,MAAM,CAAC,CAmB9F;AAED,kFAAkF;AAClF,wBAAgB,WAAW,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,MAAM,CAAC,CAE7D"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/node/index.ts"],"names":[],"mappings":"AAoBA,OAAO,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAA"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { EnvValidationError } from "./errors.js";
|
|
2
|
+
import type { validateEnvResult } from "./types.js";
|
|
3
|
+
type CacheStatus = "uninitialized" | "validating" | "ready" | "failed";
|
|
4
|
+
export interface CacheState {
|
|
5
|
+
status: CacheStatus;
|
|
6
|
+
/** ids of every contract validated as part of this initialization, so resetEnvCache() can clean up precisely. */
|
|
7
|
+
contractIds: Set<symbol>;
|
|
8
|
+
result?: validateEnvResult;
|
|
9
|
+
error?: EnvValidationError;
|
|
10
|
+
inFlight?: Promise<validateEnvResult>;
|
|
11
|
+
}
|
|
12
|
+
export declare function getState(): CacheState;
|
|
13
|
+
export declare function getContractValues(id: symbol): Readonly<Record<string, unknown>> | undefined;
|
|
14
|
+
export declare function setContractValues(id: symbol, values: Readonly<Record<string, unknown>>): void;
|
|
15
|
+
export declare function getContractError(id: symbol): EnvValidationError | undefined;
|
|
16
|
+
export declare function setContractError(id: symbol, error: EnvValidationError): void;
|
|
17
|
+
/** Clears cached state: the global status plus every contract validated as part of it. */
|
|
18
|
+
export declare function resetCache(): void;
|
|
19
|
+
export {};
|
|
20
|
+
//# sourceMappingURL=cache.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cache.d.ts","sourceRoot":"","sources":["../../../src/runtime/cache.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAA;AACrD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAA;AAEnD,KAAK,WAAW,GAAG,eAAe,GAAG,YAAY,GAAG,OAAO,GAAG,QAAQ,CAAA;AAEtE,MAAM,WAAW,UAAU;IACzB,MAAM,EAAE,WAAW,CAAA;IACnB,iHAAiH;IACjH,WAAW,EAAE,GAAG,CAAC,MAAM,CAAC,CAAA;IACxB,MAAM,CAAC,EAAE,iBAAiB,CAAA;IAC1B,KAAK,CAAC,EAAE,kBAAkB,CAAA;IAC1B,QAAQ,CAAC,EAAE,OAAO,CAAC,iBAAiB,CAAC,CAAA;CACtC;AAqBD,wBAAgB,QAAQ,IAAI,UAAU,CAErC;AAED,wBAAgB,iBAAiB,CAAC,EAAE,EAAE,MAAM,GAAG,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,GAAG,SAAS,CAE3F;AAED,wBAAgB,iBAAiB,CAAC,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,GAAG,IAAI,CAE7F;AAED,wBAAgB,gBAAgB,CAAC,EAAE,EAAE,MAAM,GAAG,kBAAkB,GAAG,SAAS,CAE3E;AAED,wBAAgB,gBAAgB,CAAC,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,kBAAkB,GAAG,IAAI,CAE5E;AAED,0FAA0F;AAC1F,wBAAgB,UAAU,IAAI,IAAI,CAMjC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { CreateEnvOptions, EnvContract, EnvSchema } from "./types.js";
|
|
2
|
+
/**
|
|
3
|
+
* Declares a feature's environment contract. Colocate this call with the
|
|
4
|
+
* feature that consumes the variables (e.g. `features/payments/env.schema.ts`).
|
|
5
|
+
*
|
|
6
|
+
* @remarks
|
|
7
|
+
* `createEnv` is runtime-only: `processor`/`validator`/`default` are the
|
|
8
|
+
* whole vocabulary, because they're the only fields {@link validateEnv} actually
|
|
9
|
+
* reads. Documentation -- description, ownership, lifecycle, category, and
|
|
10
|
+
* everything else that only exists to generate docs -- lives in a separate
|
|
11
|
+
* {@link documentEnv} call (see `document.ts`), which is entirely optional and
|
|
12
|
+
* never required for this to work.
|
|
13
|
+
*
|
|
14
|
+
* @returns An {@link EnvContract} exposing one read-only getter per key -- there is no
|
|
15
|
+
* global env object, only per-feature contracts like `paymentsEnv.STRIPE_KEY`. Accessing a
|
|
16
|
+
* key throws until {@link validateEnv} has run successfully for the runtime this contract
|
|
17
|
+
* was passed to.
|
|
18
|
+
*/
|
|
19
|
+
export declare function createEnv<S extends EnvSchema>(schema: S, options?: CreateEnvOptions): EnvContract<S>;
|
|
20
|
+
//# sourceMappingURL=create.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create.d.ts","sourceRoot":"","sources":["../../../src/runtime/create.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAqB,gBAAgB,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,YAAY,CAAA;AAI7F;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,SAAS,CAAC,CAAC,SAAS,SAAS,EAC3C,MAAM,EAAE,CAAC,EACT,OAAO,GAAE,gBAAqB,GAC7B,WAAW,CAAC,CAAC,CAAC,CAmDhB"}
|
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
import type { EnvSchema } from "./types.js";
|
|
2
|
+
/**
|
|
3
|
+
* Developer-supplied evidence assertions for one variable -- categorically
|
|
4
|
+
* different from every field on {@link VariableDocs}: those are
|
|
5
|
+
* declared-and-never-verified, while `dynamicAccess` is re-checked against
|
|
6
|
+
* reality on every run (fresh / stale / missing). Kept structurally separate,
|
|
7
|
+
* in `VariableDocs.evidence` rather than folded in alongside `description`/
|
|
8
|
+
* `owner`/..., specifically so that different epistemic status is visible in
|
|
9
|
+
* the shape itself and not only in a doc comment. See ADR 0037.
|
|
10
|
+
*/
|
|
11
|
+
interface VariableEvidenceDocs {
|
|
12
|
+
/**
|
|
13
|
+
* Citation(s) of where this variable is actually read dynamically --
|
|
14
|
+
* somewhere env-cap's own static AST scan can't see (a shell script, a
|
|
15
|
+
* Docker entrypoint, a sibling service). Each entry is a
|
|
16
|
+
* `"<relative-path>:<line>:<column>"` citation.
|
|
17
|
+
*
|
|
18
|
+
* @remarks
|
|
19
|
+
* A developer's re-acknowledgment that access happens, never a claim
|
|
20
|
+
* env-cap itself observed anything -- tracked as its own independent fact
|
|
21
|
+
* and never folded into the AST-derived `VariableAccessStatus`. Re-verified
|
|
22
|
+
* every run: a citation whose file no longer exists, or whose content has
|
|
23
|
+
* visibly changed since it was last acknowledged, is flagged rather than
|
|
24
|
+
* trusted forever.
|
|
25
|
+
*/
|
|
26
|
+
dynamicAccess?: readonly string[];
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Per-variable documentation. Every field is optional and unconstrained on
|
|
30
|
+
* purpose -- there is no required shape, so documenting a variable never
|
|
31
|
+
* fights the type checker, and you can add a field the generator doesn't
|
|
32
|
+
* know about yet without it being rejected.
|
|
33
|
+
*/
|
|
34
|
+
export interface VariableDocs {
|
|
35
|
+
/** Human-readable explanation of what this variable is and what it controls. */
|
|
36
|
+
description?: string;
|
|
37
|
+
/** Who owns this variable (a team, a handle, whatever your org uses). Overrides the contract's own `owner` for this key. */
|
|
38
|
+
owner?: string;
|
|
39
|
+
/**
|
|
40
|
+
* How sensitive this variable's value is. Overrides the contract's own `sensitivity` for this
|
|
41
|
+
* key.
|
|
42
|
+
*
|
|
43
|
+
* @remarks
|
|
44
|
+
* Deliberately an open `string`, not a closed union: an org's own sensitivity vocabulary is its
|
|
45
|
+
* own, and a level env-cap doesn't recognize is always honored, never dropped. The generator
|
|
46
|
+
* still reports a `NONSTANDARD_SENSITIVITY_LEVEL` finding (severity `info`, never blocking) for
|
|
47
|
+
* anything outside `secret`/`credential`/`pii`/`config`, so vocabulary drift stays visible
|
|
48
|
+
* without being enforced.
|
|
49
|
+
*/
|
|
50
|
+
sensitivity?: string;
|
|
51
|
+
/** 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.). */
|
|
52
|
+
expiresAt?: string;
|
|
53
|
+
/** How to get a new value before/when it expires (e.g. "Rotate in the Stripe dashboard, then redeploy."). */
|
|
54
|
+
refreshInstructions?: string;
|
|
55
|
+
/**
|
|
56
|
+
* Explicit, actionable instructions for obtaining this variable's value the *first* time --
|
|
57
|
+
* where `refreshInstructions` is "how to rotate it once you already have one," this is "how to
|
|
58
|
+
* get one at all" (e.g. "Create a restricted API key in the Stripe dashboard under Developers ->
|
|
59
|
+
* API keys, scoped to read/write Charges."). A named field specifically so this can render as
|
|
60
|
+
* its own labeled line in generated docs, rather than requiring a `metadata.setup`-style
|
|
61
|
+
* convention with no dedicated rendering or type checking.
|
|
62
|
+
*/
|
|
63
|
+
setupInstructions?: string;
|
|
64
|
+
/** Documentation-level assertion that this variable must be set. Independent of how (or whether) a validator actually enforces it. */
|
|
65
|
+
required?: boolean;
|
|
66
|
+
/** 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). */
|
|
67
|
+
deprecated?: boolean;
|
|
68
|
+
/** Why this variable is deprecated, and/or what to use instead. Only meaningful alongside `deprecated: true`. */
|
|
69
|
+
deprecatedReason?: string;
|
|
70
|
+
/** ISO date string -- by when a deprecated variable must be removed. Only meaningful alongside `deprecated: true`. */
|
|
71
|
+
removeBy?: string;
|
|
72
|
+
/** 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. */
|
|
73
|
+
renamedFrom?: string;
|
|
74
|
+
/** 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. */
|
|
75
|
+
purpose?: string;
|
|
76
|
+
/** 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. */
|
|
77
|
+
legalBasis?: string;
|
|
78
|
+
/** 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. */
|
|
79
|
+
retention?: string;
|
|
80
|
+
/** 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. */
|
|
81
|
+
dataResidency?: string | string[];
|
|
82
|
+
/** Documentation-level assertion that this variable's handling must be auditable. Overrides the contract's own `auditRequired` for this key. */
|
|
83
|
+
auditRequired?: boolean;
|
|
84
|
+
/**
|
|
85
|
+
* Developer-supplied evidence assertions for this variable -- verified over
|
|
86
|
+
* time, unlike every other field above, which is declared and never
|
|
87
|
+
* verified. Kept structurally separate for exactly that reason; see
|
|
88
|
+
* {@link VariableEvidenceDocs}.
|
|
89
|
+
*/
|
|
90
|
+
evidence?: VariableEvidenceDocs;
|
|
91
|
+
/**
|
|
92
|
+
* Structured, unsupported-key documentation -- any primitive or object value, for anything that
|
|
93
|
+
* doesn't warrant its own named field. A previously-supported top-level key belongs in a named
|
|
94
|
+
* field above instead of here once one exists for it.
|
|
95
|
+
*/
|
|
96
|
+
metadata?: Record<string, unknown>;
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Contract-level documentation, plus everything {@link documentEnv}'s options used to carry that
|
|
100
|
+
* only the generator ever read.
|
|
101
|
+
*
|
|
102
|
+
* @remarks
|
|
103
|
+
* Generic over `S`, the exact schema type {@link documentEnv} infers from its `schema` argument --
|
|
104
|
+
* this is what makes `variables` below a closed, checked map (a typo'd or renamed key is a
|
|
105
|
+
* compile error, not a silent no-op) rather than an open `Record<string, VariableDocs>` any string
|
|
106
|
+
* would satisfy. `S` defaults to the widest possible schema so this type is still nameable on its
|
|
107
|
+
* own (e.g. in a helper function's own parameter type) without narrowing to one specific contract.
|
|
108
|
+
*/
|
|
109
|
+
export interface ContractDocs<S extends EnvSchema = EnvSchema> {
|
|
110
|
+
/** 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. */
|
|
111
|
+
name?: string;
|
|
112
|
+
/** Groups this contract under a heading in the generated docs' feature catalog. */
|
|
113
|
+
category?: string;
|
|
114
|
+
/** 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. */
|
|
115
|
+
exclusiveGroup?: string;
|
|
116
|
+
/** 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`. */
|
|
117
|
+
active?: boolean;
|
|
118
|
+
/** Default owner for every variable in this contract that doesn't set its own `owner`. */
|
|
119
|
+
owner?: string;
|
|
120
|
+
/** 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`. */
|
|
121
|
+
sensitivity?: string;
|
|
122
|
+
/** Whole-contract/feature sunset date, ISO date string. */
|
|
123
|
+
expiresAt?: string;
|
|
124
|
+
/** Marks this whole contract/feature as being phased out. Independent of `active` (on/off, not a phase-out signal). */
|
|
125
|
+
deprecated?: boolean;
|
|
126
|
+
/** Why this contract is deprecated, and/or what to use instead. Only meaningful alongside `deprecated: true`. */
|
|
127
|
+
deprecatedReason?: string;
|
|
128
|
+
/** Default reason this contract's variables' values are collected/used -- see {@link VariableDocs.purpose}. */
|
|
129
|
+
purpose?: string;
|
|
130
|
+
/** Default legal basis for this contract's variables -- see {@link VariableDocs.legalBasis}. */
|
|
131
|
+
legalBasis?: string;
|
|
132
|
+
/** Default retention policy for this contract's variables -- see {@link VariableDocs.retention}. */
|
|
133
|
+
retention?: string;
|
|
134
|
+
/** Default data residency for this contract's variables -- see {@link VariableDocs.dataResidency}. */
|
|
135
|
+
dataResidency?: string | string[];
|
|
136
|
+
/** Default audit-required assertion for this contract's variables -- see {@link VariableDocs.auditRequired}. */
|
|
137
|
+
auditRequired?: boolean;
|
|
138
|
+
/** Arbitrary contract-level documentation (e.g. `runbook`), rendered alongside this feature -- see {@link VariableDocs.metadata}. */
|
|
139
|
+
metadata?: Record<string, unknown>;
|
|
140
|
+
/**
|
|
141
|
+
* Per-variable documentation, keyed by variable name -- keys are checked against `S`'s own keys
|
|
142
|
+
* at compile time, so documenting a variable that was renamed or removed from `schema` (or a
|
|
143
|
+
* plain typo) is a type error here, not a silently-ignored entry the generator would otherwise
|
|
144
|
+
* have to report as "stale" after the fact. A schema key absent from `variables` entirely is
|
|
145
|
+
* still valid (not every variable needs documentation) and is reported as undocumented by the
|
|
146
|
+
* generator, exactly as before.
|
|
147
|
+
*/
|
|
148
|
+
variables?: {
|
|
149
|
+
readonly [K in keyof S]?: VariableDocs;
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* Documents a schema for the generator: explains values, assigns ownership,
|
|
154
|
+
* and describes lifecycle, feeding the generated docs artifact and
|
|
155
|
+
* `.env.example`. Pass it the *same* schema object given to {@link createEnv}, so
|
|
156
|
+
* the generator can statically link the two and verify every variable is
|
|
157
|
+
* documented -- and so TypeScript can check `docs.variables`' keys against
|
|
158
|
+
* `schema`'s own keys, the same object identity doing double duty for both
|
|
159
|
+
* the generator's static link and the type checker's.
|
|
160
|
+
*
|
|
161
|
+
* @remarks
|
|
162
|
+
* A no-op at runtime by design -- nothing passed here is retained anywhere,
|
|
163
|
+
* and this can never throw, no matter how malformed `schema`/`docs` are.
|
|
164
|
+
* Calling it is entirely optional: {@link createEnv} works identically whether or
|
|
165
|
+
* not a matching `documentEnv` call exists. The real "is everything
|
|
166
|
+
* documented?" check, and every artifact this data drives (the docs
|
|
167
|
+
* artifact's ownership matrix, dependency graph, lifecycle report, and
|
|
168
|
+
* security review; `.env.example`'s comments), runs entirely inside
|
|
169
|
+
* {@link build.generateEnvManifest}'s static analysis -- this function's only job at
|
|
170
|
+
* runtime is to exist as a safe, harmless marker the AST parser can find,
|
|
171
|
+
* and to give you type-checked argument shapes while writing it.
|
|
172
|
+
*
|
|
173
|
+
* `S` is inferred from `schema`, never written out by hand -- pass the
|
|
174
|
+
* schema object literal (or a `const`-inferred reference to it) directly for
|
|
175
|
+
* the strongest inference; an explicitly-widened `schema: EnvSchema`
|
|
176
|
+
* annotation loses the per-key literal type and falls back to accepting any
|
|
177
|
+
* string key in `docs.variables`, same as before this generic existed.
|
|
178
|
+
*/
|
|
179
|
+
export declare function documentEnv<S extends EnvSchema>(schema: S, docs: ContractDocs<S>): void;
|
|
180
|
+
export {};
|
|
181
|
+
//# sourceMappingURL=document.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"document.d.ts","sourceRoot":"","sources":["../../../src/runtime/document.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAA;AAE3C;;;;;;;;GAQG;AACH,UAAU,oBAAoB;IAC5B;;;;;;;;;;;;;OAaG;IACH,aAAa,CAAC,EAAE,SAAS,MAAM,EAAE,CAAA;CAClC;AAED;;;;;GAKG;AACH,MAAM,WAAW,YAAY;IAC3B,gFAAgF;IAChF,WAAW,CAAC,EAAE,MAAM,CA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OAAO,CAAA;IAChB,0FAA0F;IAC1F,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,+KAA+K;IAC/K,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,2DAA2D;IAC3D,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,uHAAuH;IACvH,UAAU,CAAC,EAAE,OAAO,CAAA;IACpB,iHAAiH;IACjH,gBAAgB,CAAC,EAAE,MAAM,CAAA;IACzB,+GAA+G;IAC/G,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,gGAAgG;IAChG,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,oGAAoG;IACpG,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,sGAAsG;IACtG,aAAa,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAA;IACjC,gHAAgH;IAChH,aAAa,CAAC,EAAE,OAAO,CAAA;IACvB,qIAAqI;IACrI,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IAClC;;;;;;;OAOG;IACH,SAAS,CAAC,EAAE;QAAE,QAAQ,EAAE,CAAC,IAAI,MAAM,CAAC,CAAC,CAAC,EAAE,YAAY;KAAE,CAAA;CACvD;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAWH,wBAAgB,WAAW,CAAC,CAAC,SAAS,SAAS,EAAE,MAAM,EAAE,CAAC,EAAE,IAAI,EAAE,YAAY,CAAC,CAAC,CAAC,GAAG,IAAI,CAYvF"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Every error type here is constructed only from: the variable name, the
|
|
3
|
+
* declaring contract's name, the failure kind, and a message string that the
|
|
4
|
+
* *developer's own* processor/validator produced. Raw or processed environment
|
|
5
|
+
* values are never read into an error -- see the Security section in the README.
|
|
6
|
+
*
|
|
7
|
+
* Documentation (description, owner, etc.) never appears here, even when a
|
|
8
|
+
* {@link documentEnv} call exists for this variable -- `documentEnv` is
|
|
9
|
+
* build-time-only and its data is never retained anywhere {@link validateEnv}
|
|
10
|
+
* could read it back out. This is a deliberate consequence of keeping the
|
|
11
|
+
* runtime minimal, not an oversight.
|
|
12
|
+
*/
|
|
13
|
+
/** One variable's processing or validation failure, as recorded by {@link validateEnv}. */
|
|
14
|
+
export interface VariableFailure {
|
|
15
|
+
/** The schema key that failed. */
|
|
16
|
+
readonly variable: string;
|
|
17
|
+
/** The declaring contract's `name` (see {@link CreateEnvOptions}). */
|
|
18
|
+
readonly contractName: string;
|
|
19
|
+
/** `import.meta.url` (or similar) passed to `createEnv`'s `source` option, if any. Falls back to `contractName` when absent. */
|
|
20
|
+
readonly source: string | undefined;
|
|
21
|
+
/** Which stage produced the failure. */
|
|
22
|
+
readonly kind: "processor" | "validator";
|
|
23
|
+
/** The error message from the developer's own processor/validator, or the thrown error's message. */
|
|
24
|
+
readonly message: string;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Thrown by {@link validateEnv} when one or more variables fail processing or
|
|
28
|
+
* validation. Aggregates every failure across every contract in the batch --
|
|
29
|
+
* the caller sees the whole picture in one error, not one-at-a-time.
|
|
30
|
+
*
|
|
31
|
+
* @remarks
|
|
32
|
+
* `code` is a stable, Stable-tier discriminant for programmatic handling --
|
|
33
|
+
* prefer it over `.name`/`instanceof` when a message-independent switch is needed.
|
|
34
|
+
*/
|
|
35
|
+
export declare class EnvValidationError extends Error {
|
|
36
|
+
/** Stable discriminant for programmatic handling; always `"ENV_VALIDATION_FAILED"`. */
|
|
37
|
+
readonly code = "ENV_VALIDATION_FAILED";
|
|
38
|
+
/** Every variable failure across every contract in the batch. */
|
|
39
|
+
readonly failures: readonly VariableFailure[];
|
|
40
|
+
constructor(failures: readonly VariableFailure[]);
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Thrown when a contract's value is accessed via property access before
|
|
44
|
+
* {@link validateEnv} has completed successfully for it.
|
|
45
|
+
*
|
|
46
|
+
* @remarks
|
|
47
|
+
* `code` is a stable, Stable-tier discriminant for programmatic handling --
|
|
48
|
+
* prefer it over `.name`/`instanceof` when a message-independent switch is needed.
|
|
49
|
+
*/
|
|
50
|
+
export declare class EnvNotReadyError extends Error {
|
|
51
|
+
/** Stable discriminant for programmatic handling; always `"ENV_NOT_READY"`. */
|
|
52
|
+
readonly code = "ENV_NOT_READY";
|
|
53
|
+
constructor(contractName: string, key: string);
|
|
54
|
+
}
|
|
55
|
+
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../../src/runtime/errors.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,2FAA2F;AAC3F,MAAM,WAAW,eAAe;IAC9B,kCAAkC;IAClC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAA;IACzB,sEAAsE;IACtE,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAA;IAC7B,gIAAgI;IAChI,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAA;IACnC,wCAAwC;IACxC,QAAQ,CAAC,IAAI,EAAE,WAAW,GAAG,WAAW,CAAA;IACxC,qGAAqG;IACrG,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;CACzB;AAwBD;;;;;;;;GAQG;AACH,qBAAa,kBAAmB,SAAQ,KAAK;IAC3C,uFAAuF;IACvF,QAAQ,CAAC,IAAI,2BAA0B;IACvC,iEAAiE;IACjE,QAAQ,CAAC,QAAQ,EAAE,SAAS,eAAe,EAAE,CAAA;gBAEjC,QAAQ,EAAE,SAAS,eAAe,EAAE;CAMjD;AAED;;;;;;;GAOG;AACH,qBAAa,gBAAiB,SAAQ,KAAK;IACzC,+EAA+E;IAC/E,QAAQ,CAAC,IAAI,mBAAkB;gBAEnB,YAAY,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM;CAS9C"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* env-cap runtime entry point.
|
|
3
|
+
*
|
|
4
|
+
* Zero dependencies, isomorphic (no `fs`, no `process` other than the values
|
|
5
|
+
* the developer passes in). Handles processing, validation, caching, and
|
|
6
|
+
* typed access only -- discovery and manifest generation live in
|
|
7
|
+
* `env-cap/build` and are never imported from here.
|
|
8
|
+
*
|
|
9
|
+
* `documentEnv` is exported from here, not `env-cap/build`, even though
|
|
10
|
+
* it exists purely for documentation: it's meant to be called inline in the
|
|
11
|
+
* same schema file as `createEnv`, which is ordinary runtime code that may
|
|
12
|
+
* end up in any bundle (including a browser one). It must be exactly as
|
|
13
|
+
* cheap and safe to import as `createEnv` -- see `document.ts`.
|
|
14
|
+
*/
|
|
15
|
+
export type { CreateEnvOptions, DefaultValue, EnvContract, EnvDefinition, EnvSchema, InferEnvValue, Processor, RawEnv, validateEnvOptions, validateEnvResult, Validator, } from "./types.js";
|
|
16
|
+
export { createEnv } from "./create.js";
|
|
17
|
+
export { documentEnv } from "./document.js";
|
|
18
|
+
export type { ContractDocs, VariableDocs } from "./document.js";
|
|
19
|
+
export { EnvNotReadyError, EnvValidationError } from "./errors.js";
|
|
20
|
+
export type { VariableFailure } from "./errors.js";
|
|
21
|
+
export { isEnvContract } from "./registry.js";
|
|
22
|
+
export { resetEnvCache } from "./reset.js";
|
|
23
|
+
export { validateEnv } from "./validate.js";
|
|
24
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/runtime/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,YAAY,EACV,gBAAgB,EAChB,YAAY,EACZ,WAAW,EACX,aAAa,EACb,SAAS,EACT,aAAa,EACb,SAAS,EACT,MAAM,EACN,kBAAkB,EAClB,iBAAiB,EACjB,SAAS,GACV,MAAM,YAAY,CAAA;AAEnB,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AACvC,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA;AAC3C,YAAY,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,eAAe,CAAA;AAC/D,OAAO,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAA;AAClE,YAAY,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AAClD,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAA;AAC7C,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAA;AAC1C,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { ContractInternals } from "./types.js";
|
|
2
|
+
/** Associates a contract object with its internal identity/schema. Called once, by `createEnv`. */
|
|
3
|
+
export declare function registerContract(contract: object, internals: ContractInternals): void;
|
|
4
|
+
/**
|
|
5
|
+
* Looks up a contract's internal identity/schema.
|
|
6
|
+
*
|
|
7
|
+
* @throws {TypeError} If `contract` wasn't returned by `createEnv` (and so was never registered).
|
|
8
|
+
*/
|
|
9
|
+
export declare function getContractInternals(contract: object): ContractInternals;
|
|
10
|
+
/** Type guard: `true` when `value` was created by `createEnv` (i.e. is a registered contract). */
|
|
11
|
+
export declare function isEnvContract(value: unknown): value is object;
|
|
12
|
+
//# sourceMappingURL=registry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../../src/runtime/registry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAA;AAUnD,mGAAmG;AACnG,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,iBAAiB,GAAG,IAAI,CAErF;AAED;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,QAAQ,EAAE,MAAM,GAAG,iBAAiB,CASxE;AAED,kGAAkG;AAClG,wBAAgB,aAAa,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,MAAM,CAmB7D"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Clears cached validation state. Intended for tests and dev tooling (e.g.
|
|
3
|
+
* `beforeEach(() => resetEnvCache())` in a test suite that re-validates with
|
|
4
|
+
* different fixture values per test) -- production applications validate
|
|
5
|
+
* once at startup and should not normally call this.
|
|
6
|
+
*/
|
|
7
|
+
export declare function resetEnvCache(): void;
|
|
8
|
+
//# sourceMappingURL=reset.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reset.d.ts","sourceRoot":"","sources":["../../../src/runtime/reset.ts"],"names":[],"mappings":"AAEA;;;;;GAKG;AACH,wBAAgB,aAAa,IAAI,IAAI,CAEpC"}
|