@maverickcer/env-cap 0.7.4 → 0.7.5
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/ADOPTION.md +106 -124
- package/AGENTS.md +14 -13
- package/CHANGELOG.md +15 -0
- package/CODE_REVIEW.md +69 -173
- package/CONTRIBUTING.md +57 -74
- package/GUIDE.md +393 -872
- package/README.md +81 -76
- package/RELEASING.md +17 -15
- package/SECURITY.md +76 -227
- package/SUPPORT.md +21 -45
- package/VERSIONING.md +68 -105
- package/benchmarks/READING-BENCHMARKS.md +13 -7
- package/benchmarks/WRITING-BENCHMARKS.md +1 -1
- package/dist/.dts/_ipc/build-fs.d.ts +9 -14
- package/dist/.dts/_ipc/build-fs.d.ts.map +1 -1
- package/dist/.dts/_ipc/compiler-api.d.ts +6 -6
- package/dist/.dts/_ipc/display-path.d.ts.map +1 -1
- package/dist/.dts/_ipc/generated-banner.d.ts +8 -8
- package/dist/.dts/_ipc/glob.d.ts +6 -6
- package/dist/.dts/_ipc/no-node-fs.d.ts.map +1 -1
- package/dist/.dts/build/lifecycle-model.d.ts +8 -3
- package/dist/.dts/build/lifecycle-model.d.ts.map +1 -1
- package/dist/.dts/build/sarif.d.ts.map +1 -1
- package/dist/.dts/helpers/index.d.ts +1 -1
- package/dist/.dts/runtime/create.d.ts +3 -0
- package/dist/.dts/runtime/create.d.ts.map +1 -1
- package/dist/.dts/runtime/document.d.ts +7 -4
- package/dist/.dts/runtime/document.d.ts.map +1 -1
- package/dist/.dts/runtime/index.d.ts +11 -10
- package/dist/.dts/runtime/index.d.ts.map +1 -1
- package/dist/.dts/runtime/types.d.ts +16 -0
- package/dist/.dts/runtime/types.d.ts.map +1 -1
- package/dist/.dts/runtime/validate.d.ts +14 -1
- package/dist/.dts/runtime/validate.d.ts.map +1 -1
- package/dist/.dts7/_ipc/build-fs.d.ts +48 -0
- package/dist/.dts7/_ipc/build-fs.d.ts.map +1 -0
- package/dist/.dts7/_ipc/compiler-api.d.ts +17 -0
- package/dist/.dts7/_ipc/compiler-api.d.ts.map +1 -0
- package/dist/.dts7/_ipc/display-path.d.ts +27 -0
- package/dist/.dts7/_ipc/display-path.d.ts.map +1 -0
- package/dist/.dts7/_ipc/generated-banner.d.ts +58 -0
- package/dist/.dts7/_ipc/generated-banner.d.ts.map +1 -0
- package/dist/.dts7/_ipc/glob.d.ts +22 -0
- package/dist/.dts7/_ipc/glob.d.ts.map +1 -0
- package/dist/.dts7/_ipc/no-node-fs.d.ts +21 -0
- package/dist/.dts7/_ipc/no-node-fs.d.ts.map +1 -0
- package/dist/.dts7/_ipc/resolve-tsconfig-paths.d.ts +134 -0
- package/dist/.dts7/_ipc/resolve-tsconfig-paths.d.ts.map +1 -0
- package/dist/.dts7/_ipc/typescript.d.ts +20 -0
- package/dist/.dts7/_ipc/typescript.d.ts.map +1 -0
- package/dist/.dts7/build/assemble-project.d.ts +47 -0
- package/dist/.dts7/build/assemble-project.d.ts.map +1 -0
- package/dist/.dts7/build/change-model.d.ts +63 -0
- package/dist/.dts7/build/change-model.d.ts.map +1 -0
- package/dist/.dts7/build/check-artifacts.d.ts +48 -0
- package/dist/.dts7/build/check-artifacts.d.ts.map +1 -0
- package/dist/.dts7/build/citation-verification.d.ts +62 -0
- package/dist/.dts7/build/citation-verification.d.ts.map +1 -0
- package/dist/.dts7/build/compatibility.d.ts +83 -0
- package/dist/.dts7/build/compatibility.d.ts.map +1 -0
- package/dist/.dts7/build/compiler-api.d.ts +12 -0
- package/dist/.dts7/build/compiler-api.d.ts.map +1 -0
- package/dist/.dts7/build/contract-model.d.ts +93 -0
- package/dist/.dts7/build/contract-model.d.ts.map +1 -0
- package/dist/.dts7/build/deep-equal.d.ts +9 -0
- package/dist/.dts7/build/deep-equal.d.ts.map +1 -0
- package/dist/.dts7/build/deep-freeze.d.ts +20 -0
- package/dist/.dts7/build/deep-freeze.d.ts.map +1 -0
- package/dist/.dts7/build/dependency-graph.d.ts +170 -0
- package/dist/.dts7/build/dependency-graph.d.ts.map +1 -0
- package/dist/.dts7/build/dependency-model.d.ts +81 -0
- package/dist/.dts7/build/dependency-model.d.ts.map +1 -0
- package/dist/.dts7/build/discover.d.ts +41 -0
- package/dist/.dts7/build/discover.d.ts.map +1 -0
- package/dist/.dts7/build/display-path.d.ts +6 -0
- package/dist/.dts7/build/display-path.d.ts.map +1 -0
- package/dist/.dts7/build/docs.d.ts +176 -0
- package/dist/.dts7/build/docs.d.ts.map +1 -0
- package/dist/.dts7/build/env-example.d.ts +85 -0
- package/dist/.dts7/build/env-example.d.ts.map +1 -0
- package/dist/.dts7/build/errors.d.ts +78 -0
- package/dist/.dts7/build/errors.d.ts.map +1 -0
- package/dist/.dts7/build/evidence-cache.d.ts +74 -0
- package/dist/.dts7/build/evidence-cache.d.ts.map +1 -0
- package/dist/.dts7/build/evidence-model.d.ts +50 -0
- package/dist/.dts7/build/evidence-model.d.ts.map +1 -0
- package/dist/.dts7/build/evidence-reference.d.ts +67 -0
- package/dist/.dts7/build/evidence-reference.d.ts.map +1 -0
- package/dist/.dts7/build/evidence-snapshot.d.ts +148 -0
- package/dist/.dts7/build/evidence-snapshot.d.ts.map +1 -0
- package/dist/.dts7/build/exclusive-group.d.ts +19 -0
- package/dist/.dts7/build/exclusive-group.d.ts.map +1 -0
- package/dist/.dts7/build/finding-model.d.ts +80 -0
- package/dist/.dts7/build/finding-model.d.ts.map +1 -0
- package/dist/.dts7/build/generate-documentation.d.ts +176 -0
- package/dist/.dts7/build/generate-documentation.d.ts.map +1 -0
- package/dist/.dts7/build/generate-env-artifacts.d.ts +191 -0
- package/dist/.dts7/build/generate-env-artifacts.d.ts.map +1 -0
- package/dist/.dts7/build/generate-evidence.d.ts +77 -0
- package/dist/.dts7/build/generate-evidence.d.ts.map +1 -0
- package/dist/.dts7/build/generate-manifest.d.ts +101 -0
- package/dist/.dts7/build/generate-manifest.d.ts.map +1 -0
- package/dist/.dts7/build/generate-usage.d.ts +95 -0
- package/dist/.dts7/build/generate-usage.d.ts.map +1 -0
- package/dist/.dts7/build/generated-banner.d.ts +43 -0
- package/dist/.dts7/build/generated-banner.d.ts.map +1 -0
- package/dist/.dts7/build/glob.d.ts +6 -0
- package/dist/.dts7/build/glob.d.ts.map +1 -0
- package/dist/.dts7/build/governance-fields.d.ts +34 -0
- package/dist/.dts7/build/governance-fields.d.ts.map +1 -0
- package/dist/.dts7/build/humanize-key.d.ts +14 -0
- package/dist/.dts7/build/humanize-key.d.ts.map +1 -0
- package/dist/.dts7/build/index.d.ts +105 -0
- package/dist/.dts7/build/index.d.ts.map +1 -0
- package/dist/.dts7/build/lifecycle-model.d.ts +179 -0
- package/dist/.dts7/build/lifecycle-model.d.ts.map +1 -0
- package/dist/.dts7/build/link.d.ts +223 -0
- package/dist/.dts7/build/link.d.ts.map +1 -0
- package/dist/.dts7/build/literal-eval.d.ts +24 -0
- package/dist/.dts7/build/literal-eval.d.ts.map +1 -0
- package/dist/.dts7/build/live-expirations.d.ts +47 -0
- package/dist/.dts7/build/live-expirations.d.ts.map +1 -0
- package/dist/.dts7/build/manifest.d.ts +31 -0
- package/dist/.dts7/build/manifest.d.ts.map +1 -0
- package/dist/.dts7/build/map-utils.d.ts +8 -0
- package/dist/.dts7/build/map-utils.d.ts.map +1 -0
- package/dist/.dts7/build/merge-documentation.d.ts +35 -0
- package/dist/.dts7/build/merge-documentation.d.ts.map +1 -0
- package/dist/.dts7/build/ownership-model.d.ts +59 -0
- package/dist/.dts7/build/ownership-model.d.ts.map +1 -0
- package/dist/.dts7/build/parse.d.ts +207 -0
- package/dist/.dts7/build/parse.d.ts.map +1 -0
- package/dist/.dts7/build/reference-projections.d.ts +170 -0
- package/dist/.dts7/build/reference-projections.d.ts.map +1 -0
- package/dist/.dts7/build/resolution/resolve-import.d.ts +58 -0
- package/dist/.dts7/build/resolution/resolve-import.d.ts.map +1 -0
- package/dist/.dts7/build/resolution/resolve-package-schema.d.ts +83 -0
- package/dist/.dts7/build/resolution/resolve-package-schema.d.ts.map +1 -0
- package/dist/.dts7/build/resolution/resolve-tsconfig-paths.d.ts +18 -0
- package/dist/.dts7/build/resolution/resolve-tsconfig-paths.d.ts.map +1 -0
- package/dist/.dts7/build/resolution/resolve-within-root.d.ts +35 -0
- package/dist/.dts7/build/resolution/resolve-within-root.d.ts.map +1 -0
- package/dist/.dts7/build/sarif.d.ts +66 -0
- package/dist/.dts7/build/sarif.d.ts.map +1 -0
- package/dist/.dts7/build/scan-dependencies.d.ts +70 -0
- package/dist/.dts7/build/scan-dependencies.d.ts.map +1 -0
- package/dist/.dts7/build/sort-by-identity.d.ts +14 -0
- package/dist/.dts7/build/sort-by-identity.d.ts.map +1 -0
- package/dist/.dts7/build/source-position.d.ts +69 -0
- package/dist/.dts7/build/source-position.d.ts.map +1 -0
- package/dist/.dts7/build/tool-version.d.ts +8 -0
- package/dist/.dts7/build/tool-version.d.ts.map +1 -0
- package/dist/.dts7/build/types.d.ts +7 -0
- package/dist/.dts7/build/types.d.ts.map +1 -0
- package/dist/.dts7/build/typescript.d.ts +6 -0
- package/dist/.dts7/build/typescript.d.ts.map +1 -0
- package/dist/.dts7/build/usage-report.d.ts +124 -0
- package/dist/.dts7/build/usage-report.d.ts.map +1 -0
- package/dist/.dts7/cli/filesystem.d.ts +7 -0
- package/dist/.dts7/cli/filesystem.d.ts.map +1 -0
- package/dist/.dts7/eslint-plugin/glob.d.ts +7 -0
- package/dist/.dts7/eslint-plugin/glob.d.ts.map +1 -0
- package/dist/.dts7/eslint-plugin/index.d.ts +27 -0
- package/dist/.dts7/eslint-plugin/index.d.ts.map +1 -0
- package/dist/.dts7/eslint-plugin/no-node-fs.d.ts +15 -0
- package/dist/.dts7/eslint-plugin/no-node-fs.d.ts.map +1 -0
- package/dist/.dts7/eslint-plugin/no-raw-process-env.d.ts +23 -0
- package/dist/.dts7/eslint-plugin/no-raw-process-env.d.ts.map +1 -0
- package/dist/.dts7/evidence/define-projection.d.ts +52 -0
- package/dist/.dts7/evidence/define-projection.d.ts.map +1 -0
- package/dist/.dts7/evidence/index.d.ts +23 -0
- package/dist/.dts7/evidence/index.d.ts.map +1 -0
- package/dist/.dts7/helpers/index.d.ts +135 -0
- package/dist/.dts7/helpers/index.d.ts.map +1 -0
- package/dist/.dts7/helpers/processors.d.ts +32 -0
- package/dist/.dts7/helpers/processors.d.ts.map +1 -0
- package/dist/.dts7/helpers/validators.d.ts +68 -0
- package/dist/.dts7/helpers/validators.d.ts.map +1 -0
- package/dist/.dts7/node/index.d.ts +2 -0
- package/dist/.dts7/node/index.d.ts.map +1 -0
- package/dist/.dts7/runtime/cache.d.ts +17 -0
- package/dist/.dts7/runtime/cache.d.ts.map +1 -0
- package/dist/.dts7/runtime/create.d.ts +23 -0
- package/dist/.dts7/runtime/create.d.ts.map +1 -0
- package/dist/.dts7/runtime/document.d.ts +223 -0
- package/dist/.dts7/runtime/document.d.ts.map +1 -0
- package/dist/.dts7/runtime/errors.d.ts +55 -0
- package/dist/.dts7/runtime/errors.d.ts.map +1 -0
- package/dist/.dts7/runtime/index.d.ts +25 -0
- package/dist/.dts7/runtime/index.d.ts.map +1 -0
- package/dist/.dts7/runtime/registry.d.ts +12 -0
- package/dist/.dts7/runtime/registry.d.ts.map +1 -0
- package/dist/.dts7/runtime/reset.d.ts +8 -0
- package/dist/.dts7/runtime/reset.d.ts.map +1 -0
- package/dist/.dts7/runtime/types.d.ts +191 -0
- package/dist/.dts7/runtime/types.d.ts.map +1 -0
- package/dist/.dts7/runtime/validate.d.ts +27 -0
- package/dist/.dts7/runtime/validate.d.ts.map +1 -0
- package/dist/{build-6XFHJFQK.js → build-DNAYWD2B.js} +8 -5
- package/dist/build-DNAYWD2B.js.map +1 -0
- package/dist/build.cjs +7 -4
- package/dist/build.cjs.map +1 -1
- package/dist/build.js +7 -4
- package/dist/build.js.map +1 -1
- package/dist/build.ts7.d.cts +1 -0
- package/dist/build.ts7.d.ts +1 -0
- package/dist/{chunk-RL5KFVUT.js → chunk-HAGMVMN5.js} +2 -2
- package/dist/cli/index.js +3 -3
- package/dist/eslint-plugin/index.cjs.map +1 -1
- package/dist/eslint-plugin/index.js.map +1 -1
- package/dist/eslint-plugin/index.ts7.d.cts +1 -0
- package/dist/eslint-plugin/index.ts7.d.ts +1 -0
- package/dist/evidence.ts7.d.cts +1 -0
- package/dist/evidence.ts7.d.ts +1 -0
- package/dist/helpers.ts7.d.cts +1 -0
- package/dist/helpers.ts7.d.ts +1 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.ts7.d.cts +1 -0
- package/dist/index.ts7.d.ts +1 -0
- package/dist/node.ts7.d.cts +1 -0
- package/dist/node.ts7.d.ts +1 -0
- package/examples/README.md +46 -80
- package/package.json +27 -4
- package/schemas/env-cap-report.schema.json +1 -1
- package/skills/env-cap/SKILL.md +1 -1
- package/skills/env-cap/references/api.md +1 -1
- package/specs/architecture.md +2 -2
- package/specs/decisions/0001-runtime-documentation-separation.md +1 -1
- package/specs/decisions/0014-cross-package-schema-discovery.md +4 -1
- package/specs/decisions/0023-tsconfig-path-alias-resolution.md +4 -1
- package/specs/decisions/0049-typescript-7-scanner-uses-a-bundled-typescript-6.md +13 -8
- package/specs/generated-artifacts.md +14 -2
- package/dist/build-6XFHJFQK.js.map +0 -1
- /package/dist/{chunk-RL5KFVUT.js.map → chunk-HAGMVMN5.js.map} +0 -0
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Flags any `import`/`require`/dynamic `import()` of `node:fs` in library code, so a library surface acquires
|
|
3
|
+
* its filesystem capability from the caller instead of reaching for `node:fs` itself.
|
|
4
|
+
*
|
|
5
|
+
* @remarks
|
|
6
|
+
* Nothing is exempt by default. A package's own config allows its CLI folder (for example `src/cli/**`),
|
|
7
|
+
* which builds the `node:fs/promises` adapter, and a consuming project sets the `allow` option for its own CLI
|
|
8
|
+
* or script entry points. The rule itself lives in `../_ipc/no-node-fs.ts`, a managed copy of
|
|
9
|
+
* internal-package-contract's `runtime/no-node-fs.ts`; this supplies env-cap's documentation link and the decision
|
|
10
|
+
* record the message cites.
|
|
11
|
+
*/
|
|
12
|
+
export declare const noNodeFs: import("@typescript-eslint/utils/ts-eslint").RuleModule<"noNodeFs", [import("../_ipc/no-node-fs.js").RuleOptions], unknown, import("@typescript-eslint/utils/ts-eslint").RuleListener> & {
|
|
13
|
+
name: string;
|
|
14
|
+
};
|
|
15
|
+
//# sourceMappingURL=no-node-fs.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"no-node-fs.d.ts","sourceRoot":"","sources":["../../../src/eslint-plugin/no-node-fs.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;GAUG;AACH,eAAO,MAAM,QAAQ;;CAInB,CAAA"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export interface RuleOptions {
|
|
2
|
+
/** Glob-array of files this rule doesn't apply to, beyond the built-in
|
|
3
|
+
* env.schema.ts allowance below -- for a consuming project's own
|
|
4
|
+
* Node-only, build-time bootstrap code (see the README section this
|
|
5
|
+
* rule ships with for the canonical worked example: a live-expiration
|
|
6
|
+
* resolver authenticating to a secrets manager). Empty by default --
|
|
7
|
+
* MUST be populated explicitly by the consuming project; env-cap never
|
|
8
|
+
* guesses at what counts as "trusted bootstrap code." */
|
|
9
|
+
allow?: string[];
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Flags any direct `process.env.X`/`process.env["X"]` read in application code, so environment
|
|
13
|
+
* access always goes through a capability's own `createEnv()` contract instead.
|
|
14
|
+
*
|
|
15
|
+
* @remarks
|
|
16
|
+
* `env.schema.ts`/`env.schema.tsx` files are always exempt (that's where `createEnv()` itself
|
|
17
|
+
* reads `process.env`); the rule's `allow` option extends that exemption to a consuming
|
|
18
|
+
* project's own trusted bootstrap code.
|
|
19
|
+
*/
|
|
20
|
+
export declare const noRawProcessEnv: import("@typescript-eslint/utils/ts-eslint").RuleModule<"noRawProcessEnv", [RuleOptions], unknown, import("@typescript-eslint/utils/ts-eslint").RuleListener> & {
|
|
21
|
+
name: string;
|
|
22
|
+
};
|
|
23
|
+
//# sourceMappingURL=no-raw-process-env.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"no-raw-process-env.d.ts","sourceRoot":"","sources":["../../../src/eslint-plugin/no-raw-process-env.ts"],"names":[],"mappings":"AAWA,MAAM,WAAW,WAAW;IAC1B;;;;;;8DAM0D;IAC1D,KAAK,CAAC,EAAE,MAAM,EAAE,CAAA;CACjB;AAaD;;;;;;;;GAQG;AACH,eAAO,MAAM,eAAe;;CA4C1B,CAAA"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import type { EvidenceModel } from "../build/evidence-model.js";
|
|
2
|
+
/**
|
|
3
|
+
* A pure function from the full Evidence Model to one field of a
|
|
4
|
+
* projection's output shape. Must not mutate `evidence` -- the membrane
|
|
5
|
+
* `defineEvidenceProjection()` wraps it in enforces that at runtime, see
|
|
6
|
+
* `createTrackingProxy()` below -- and must not perform I/O; env-cap can
|
|
7
|
+
* enforce the read-only half of purity but not the "no side effects" half.
|
|
8
|
+
*/
|
|
9
|
+
export type EvidenceProjector<T> = (evidence: EvidenceModel) => T;
|
|
10
|
+
/** One independent, pure projector function per key of the projection's output shape `T`. */
|
|
11
|
+
export type EvidenceProjectionSchema<T extends Record<string, unknown>> = {
|
|
12
|
+
readonly [K in keyof T]: EvidenceProjector<T[K]>;
|
|
13
|
+
};
|
|
14
|
+
/** `project()`'s return shape: the computed output, plus which `EvidenceModel` field paths fed each output key. */
|
|
15
|
+
export interface EvidenceProjectionResult<T extends Record<string, unknown>> {
|
|
16
|
+
readonly value: T;
|
|
17
|
+
readonly sources: Readonly<Record<keyof T, readonly string[]>>;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* The function `defineEvidenceProjection()` returns. Callable directly for
|
|
21
|
+
* the common case (`projection(evidence)` -> `T`); `.project()` returns the
|
|
22
|
+
* same value alongside automatic provenance -- see ADR 0032.
|
|
23
|
+
*/
|
|
24
|
+
export interface EvidenceProjection<T extends Record<string, unknown>> {
|
|
25
|
+
(evidence: EvidenceModel): T;
|
|
26
|
+
/** Same computation as calling the projection directly, plus which `EvidenceModel` field paths fed each output key -- see {@link EvidenceProjectionResult}. */
|
|
27
|
+
project(evidence: EvidenceModel): EvidenceProjectionResult<T>;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Declares a projection: a named, pure transform from the immutable
|
|
31
|
+
* `EvidenceModel` to any consumer-defined output shape, built entirely from
|
|
32
|
+
* `schema`'s independent per-field projector functions -- see ADR 0031/0032.
|
|
33
|
+
*
|
|
34
|
+
* env-cap's own reference projections (`.env.example`, Environment
|
|
35
|
+
* Configuration Reference, Configuration Ownership, etc.) are built through
|
|
36
|
+
* this exact function, with no privileged internal path -- a consumer's own
|
|
37
|
+
* projection is a first-class citizen, not a lesser one.
|
|
38
|
+
*/
|
|
39
|
+
export declare function defineEvidenceProjection<T extends Record<string, unknown>>(schema: EvidenceProjectionSchema<T>): EvidenceProjection<T>;
|
|
40
|
+
/**
|
|
41
|
+
* The error every membrane write-trap below throws. A function, not a
|
|
42
|
+
* module-level `const` -- a `const` string's mutants are evaluated once at
|
|
43
|
+
* module load and can't be attributed to a covering test under Stryker's
|
|
44
|
+
* `perTest` coverage analysis (a documented false-Survivor, not a real
|
|
45
|
+
* gap); exported so a test can pin the exact message directly, the same way
|
|
46
|
+
* every membrane trap's own `.toThrow(...)` can't (a `TypeError` from a
|
|
47
|
+
* Proxy invariant violation is thrown either way a trap's body is mutated,
|
|
48
|
+
* so `.toThrow(TypeError)` alone doesn't distinguish "our message" from
|
|
49
|
+
* "the engine's own invariant-violation message").
|
|
50
|
+
*/
|
|
51
|
+
export declare function readOnlyMembraneError(): TypeError;
|
|
52
|
+
//# sourceMappingURL=define-projection.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"define-projection.d.ts","sourceRoot":"","sources":["../../../src/evidence/define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
|
|
3
|
+
*
|
|
4
|
+
* `defineEvidenceProjection()` is the extensibility mechanism the seven
|
|
5
|
+
* canonical fact models (ADR 0024) exist to serve. A projection is a named,
|
|
6
|
+
* pure transform from the immutable `EvidenceModel` -- assembled at build
|
|
7
|
+
* time by `generateEvidenceModel()`, `@maverickcer/env-cap/build` -- to any
|
|
8
|
+
* consumer-defined output shape, with automatic read-only enforcement and
|
|
9
|
+
* field-level provenance. See ADR 0031 (why a 5th entry point) and ADR 0032
|
|
10
|
+
* (the Proxy-based mechanism itself).
|
|
11
|
+
*
|
|
12
|
+
* This module is deliberately isomorphic: no `node:fs`, no `typescript`, no
|
|
13
|
+
* knowledge of how an `EvidenceModel` gets built -- it only imports that
|
|
14
|
+
* shape as a type (erased at compile time, mirroring `helpers`' one
|
|
15
|
+
* sanctioned cross-folder edge onto `runtime` -- see
|
|
16
|
+
* `specs/architecture.md`). A dashboard backend, an edge function, or a CI
|
|
17
|
+
* step can run a projection over a previously-generated,
|
|
18
|
+
* JSON-deserialized `EvidenceModel` with zero Node dependency.
|
|
19
|
+
*/
|
|
20
|
+
export type { EvidenceModel, EvidenceProvenance } from "../build/evidence-model.js";
|
|
21
|
+
export { defineEvidenceProjection } from "./define-projection.js";
|
|
22
|
+
export type { EvidenceProjection, EvidenceProjectionResult, EvidenceProjectionSchema, EvidenceProjector, } from "./define-projection.js";
|
|
23
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/evidence/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AACH,YAAY,EAAE,aAAa,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAA;AACnF,OAAO,EAAE,wBAAwB,EAAE,MAAM,wBAAwB,CAAA;AACjE,YAAY,EACV,kBAAkB,EAClB,wBAAwB,EACxB,wBAAwB,EACxB,iBAAiB,GAClB,MAAM,wBAAwB,CAAA"}
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Optional convenience helpers for common processor/validator patterns.
|
|
3
|
+
* Entirely separate from the core runtime -- `createEnv`/`validateEnv` have
|
|
4
|
+
* no knowledge of this module and work identically without it.
|
|
5
|
+
*
|
|
6
|
+
* Usage: `processors.toNumber()`, `validators.range(1, 65535)`.
|
|
7
|
+
*
|
|
8
|
+
* Deliberately built from explicit named imports assembled into plain object
|
|
9
|
+
* literals, not `export * as processors from "./processors.js"`. A bundler
|
|
10
|
+
* (tsup/esbuild) lowers that `export * as` form into a namespace-construction
|
|
11
|
+
* helper call it can't prove side-effect-free, which defeats tree-shaking in
|
|
12
|
+
* a *second*, downstream bundling pass (a consumer's own bundler bundling
|
|
13
|
+
* this already-bundled package): importing only `processors` would still
|
|
14
|
+
* ship all of `validators`' code. A plain object literal of already-imported
|
|
15
|
+
* bindings has no such call in the way, so `import { processors } from
|
|
16
|
+
* "@maverickcer/env-cap/helpers"` alone drops `validators` entirely.
|
|
17
|
+
*/
|
|
18
|
+
import { base64, parseJSON, split, toArray, toBigInt, toBoolean, toDate, toInteger, toLowerCase, toNumber, toRegExp, toString, toURL, toUpperCase, trim } from "./processors.js";
|
|
19
|
+
import { after, all, any, before, custom, email, endsWith, finite, future, includes, integer as integerValidator, length, matches, max, maxItems, maxLength, min, minItems, minLength, negative, not, oneOf, optional, past, positive, range, refine, required, safeInteger, unique, url as urlValidator, uuid, uuidVersion } from "./validators.js";
|
|
20
|
+
/**
|
|
21
|
+
* Convenience {@link runtime.Processor} implementations for common coercion
|
|
22
|
+
* patterns (e.g. `processors.toNumber()`).
|
|
23
|
+
*
|
|
24
|
+
* @remarks
|
|
25
|
+
* Naming matches `data-cap`'s `helpers.processors` -- but these
|
|
26
|
+
* throw with a formatted `Error` message on invalid input, where data-cap's
|
|
27
|
+
* silently return `undefined`. Do not assume the same failure mode when
|
|
28
|
+
* moving between packages.
|
|
29
|
+
*/
|
|
30
|
+
export declare const processors: {
|
|
31
|
+
/** Decodes a base64 string into a `Buffer`. */
|
|
32
|
+
base64: typeof base64;
|
|
33
|
+
/** Parses a JSON string; passes non-string values through unchanged. */
|
|
34
|
+
parseJSON: typeof parseJSON;
|
|
35
|
+
/** Splits a string on `separator` into a trimmed string array; returns `[]` for non-string input. */
|
|
36
|
+
split: typeof split;
|
|
37
|
+
/** Splits a delimited string (or passes through an array) into items, running each through `processors` in order. */
|
|
38
|
+
toArray: typeof toArray;
|
|
39
|
+
/** Coerces a value to a `bigint`. */
|
|
40
|
+
toBigInt: typeof toBigInt;
|
|
41
|
+
/** Coerces common boolean-like strings (`true`/`1`/`yes`/`on`, and their opposites) into a real boolean. */
|
|
42
|
+
toBoolean: typeof toBoolean;
|
|
43
|
+
/** Parses a value into a `Date`. */
|
|
44
|
+
toDate: typeof toDate;
|
|
45
|
+
/** Coerces a value to a number and requires it to be an integer. */
|
|
46
|
+
toInteger: typeof toInteger;
|
|
47
|
+
/** Lowercases a string (coercing nullish values to `""` first). */
|
|
48
|
+
toLowerCase: typeof toLowerCase;
|
|
49
|
+
/** Coerces a value to a number, rejecting empty/whitespace-only strings instead of silently resolving to `0`. */
|
|
50
|
+
toNumber: typeof toNumber;
|
|
51
|
+
/** Compiles a value into a `RegExp`. */
|
|
52
|
+
toRegExp: typeof toRegExp;
|
|
53
|
+
/** Coerces a value to a string, treating nullish values as `""`. */
|
|
54
|
+
toString: typeof toString;
|
|
55
|
+
/** Parses a value into a `URL`, treating nullish values as `""` first. */
|
|
56
|
+
toURL: typeof toURL;
|
|
57
|
+
/** Uppercases a string (coercing nullish values to `""` first). */
|
|
58
|
+
toUpperCase: typeof toUpperCase;
|
|
59
|
+
/** Trims surrounding whitespace from a string (coercing nullish values to `""` first). */
|
|
60
|
+
trim: typeof trim;
|
|
61
|
+
};
|
|
62
|
+
/** Convenience {@link runtime.Validator} implementations for common validation patterns (e.g. `validators.range(1, 65535)`). */
|
|
63
|
+
export declare const validators: {
|
|
64
|
+
/** Passes when the date value is strictly after `date`. */
|
|
65
|
+
after: typeof after;
|
|
66
|
+
/** Passes only when every wrapped validator passes; returns the first failing message. */
|
|
67
|
+
all: typeof all;
|
|
68
|
+
/** Passes when at least one wrapped validator passes. */
|
|
69
|
+
any: typeof any;
|
|
70
|
+
/** Passes when the date value is strictly before `date`. */
|
|
71
|
+
before: typeof before;
|
|
72
|
+
/** Identity wrapper for a hand-written `Validator<T>` -- no behavior change, just a fluent entry point alongside the other helpers. */
|
|
73
|
+
custom: typeof custom;
|
|
74
|
+
/** Passes for a plausibly-shaped email address (`local@domain`). */
|
|
75
|
+
email: typeof email;
|
|
76
|
+
/** Passes when the string ends with `suffix`. */
|
|
77
|
+
endsWith: typeof endsWith;
|
|
78
|
+
/** Alias for `oneOf` -- passes when the value is one of the `allowed` values. */
|
|
79
|
+
enum: typeof oneOf;
|
|
80
|
+
/** Passes when the number is finite (rejects `Infinity`/`-Infinity`/`NaN`). */
|
|
81
|
+
finite: typeof finite;
|
|
82
|
+
/** Passes when the date is strictly after the current time. */
|
|
83
|
+
future: typeof future;
|
|
84
|
+
/** Passes when the string contains `text` as a substring. */
|
|
85
|
+
includes: typeof includes;
|
|
86
|
+
/** Passes when the number is an integer. */
|
|
87
|
+
integer: typeof integerValidator;
|
|
88
|
+
/** Passes when the string's length is exactly `expected`. */
|
|
89
|
+
length: typeof length;
|
|
90
|
+
/** Passes when the string matches `pattern`; `message` overrides the default failure text. */
|
|
91
|
+
matches: typeof matches;
|
|
92
|
+
/** Passes when the number is less than or equal to `maximum`. */
|
|
93
|
+
max: typeof max;
|
|
94
|
+
/** Passes when the array has at most `maximum` items. */
|
|
95
|
+
maxItems: typeof maxItems;
|
|
96
|
+
/** Passes when the string's length is at most `length`. */
|
|
97
|
+
maxLength: typeof maxLength;
|
|
98
|
+
/** Passes when the number is greater than or equal to `minimum`. */
|
|
99
|
+
min: typeof min;
|
|
100
|
+
/** Passes when the array has at least `minimum` items. */
|
|
101
|
+
minItems: typeof minItems;
|
|
102
|
+
/** Passes when the string's length is at least `length`. */
|
|
103
|
+
minLength: typeof minLength;
|
|
104
|
+
/** Passes when the number is strictly negative. */
|
|
105
|
+
negative: typeof negative;
|
|
106
|
+
/** Inverts a validator: passes when the wrapped validator fails, and vice versa. */
|
|
107
|
+
not: typeof not;
|
|
108
|
+
/** Passes when the value is one of the `allowed` values. */
|
|
109
|
+
oneOf: typeof oneOf;
|
|
110
|
+
/** Passes when the value is undefined, otherwise delegates to the provided validator. */
|
|
111
|
+
optional: typeof optional;
|
|
112
|
+
/** Passes when the date is strictly before the current time. */
|
|
113
|
+
past: typeof past;
|
|
114
|
+
/** Passes when the number is strictly positive. */
|
|
115
|
+
positive: typeof positive;
|
|
116
|
+
/** Passes when the number is within `[minimum, maximum]` inclusive. */
|
|
117
|
+
range: typeof range;
|
|
118
|
+
/** Runs the wrapped validator but replaces its failure message with `message`. */
|
|
119
|
+
refine: typeof refine;
|
|
120
|
+
/** Alias for `matches` -- passes when the string matches `pattern`. */
|
|
121
|
+
regex: typeof matches;
|
|
122
|
+
/** Passes when the value is defined and, unless `allowEmptyString` is set, non-empty. */
|
|
123
|
+
required: typeof required;
|
|
124
|
+
/** Passes when the number is a safe integer (`Number.isSafeInteger`). */
|
|
125
|
+
safeInteger: typeof safeInteger;
|
|
126
|
+
/** Passes when every item in the array is unique. */
|
|
127
|
+
unique: typeof unique;
|
|
128
|
+
/** Passes when the string is a valid absolute URL. */
|
|
129
|
+
url: typeof urlValidator;
|
|
130
|
+
/** Passes when the string is a valid UUID of one of the given `versions` (default: any of 1-8). */
|
|
131
|
+
uuid: typeof uuid;
|
|
132
|
+
/** Shorthand for `uuid([version])` -- passes only for that exact UUID version. */
|
|
133
|
+
uuidVersion: typeof uuidVersion;
|
|
134
|
+
};
|
|
135
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/helpers/index.ts"],"names":[],"mappings":"AA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D,8FAA8F;;IAE9F,iEAAiE;;IAEjE,yDAAyD;;IAEzD,2DAA2D;;IAE3D,oEAAoE;;IAEpE,0DAA0D;;IAE1D,4DAA4D;;IAE5D,mDAAmD;;IAEnD,oFAAoF;;IAEpF,4DAA4D;;IAE5D,yFAAyF;;IAEzF,gEAAgE;;IAEhE,mDAAmD;;IAEnD,uEAAuE;;IAEvE,kFAAkF;;IAElF,uEAAuE;;IAEvE,yFAAyF;;IAEzF,yEAAyE;;IAEzE,qDAAqD;;IAErD,sDAAsD;;IAEtD,mGAAmG;;IAEnG,kFAAkF;;CAEnF,CAAA"}
|
|
@@ -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,CAS9C;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,CAc5C;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,CAK5C;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,CAStC"}
|
|
@@ -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;AAC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AE,MAAM,GAAG,SAAS,CAAC,MAAM,CAAC,CAIzE;AAED,kFAAkF;AAClF,wBAAgB,MAAM,CAAC,CAAC,EAAE,SAAS,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,CAoB9F;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,17 @@
|
|
|
1
|
+
import type { EnvValidationError } from "./errors.js";
|
|
2
|
+
import type { validateEnvResult } from "./types.js";
|
|
3
|
+
export interface CacheState {
|
|
4
|
+
/** ids of every contract validated as part of this initialization, so resetEnvCache() can clean up precisely. */
|
|
5
|
+
contractIds: Set<symbol>;
|
|
6
|
+
result?: validateEnvResult;
|
|
7
|
+
error?: EnvValidationError;
|
|
8
|
+
inFlight?: Promise<validateEnvResult>;
|
|
9
|
+
}
|
|
10
|
+
export declare function getState(): CacheState;
|
|
11
|
+
export declare function getContractValues(id: symbol): Readonly<Record<string, unknown>> | undefined;
|
|
12
|
+
export declare function setContractValues(id: symbol, values: Readonly<Record<string, unknown>>): void;
|
|
13
|
+
export declare function getContractError(id: symbol): EnvValidationError | undefined;
|
|
14
|
+
export declare function setContractError(id: symbol, error: EnvValidationError): void;
|
|
15
|
+
/** Clears cached state: the global status plus every contract validated as part of it. */
|
|
16
|
+
export declare function resetCache(): void;
|
|
17
|
+
//# 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,MAAM,WAAW,UAAU;IACzB,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,23 @@
|
|
|
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
|
+
* The contract redacts itself under `console.log`, `String()`, `JSON.stringify` and template
|
|
20
|
+
* interpolation. Spreading it or calling `Object.entries()` on it reads every value, so do not.
|
|
21
|
+
*/
|
|
22
|
+
export declare function createEnv<S extends EnvSchema>(schema: S, options?: CreateEnvOptions): EnvContract<S>;
|
|
23
|
+
//# 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;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,SAAS,CAAC,CAAC,SAAS,SAAS,EAC3C,MAAM,EAAE,CAAC,EACT,OAAO,GAAE,gBAAqB,GAC7B,WAAW,CAAC,CAAC,CAAC,CA4ChB"}
|