envapt 8.0.0-next.0 → 8.0.0-next.1
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/CHANGELOG.md +21 -0
- package/dist/node/converters/Converters.cjs.map +1 -1
- package/dist/node/converters/Converters.mjs.map +1 -1
- package/dist/node/converters/ValueConverter.cjs +1 -1
- package/dist/node/converters/ValueConverter.cjs.map +1 -1
- package/dist/node/converters/ValueConverter.mjs +1 -1
- package/dist/node/converters/ValueConverter.mjs.map +1 -1
- package/dist/node/core/AdvancedMethods.cjs +1 -1
- package/dist/node/core/AdvancedMethods.cjs.map +1 -1
- package/dist/node/core/AdvancedMethods.mjs +1 -1
- package/dist/node/core/AdvancedMethods.mjs.map +1 -1
- package/dist/node/core/EnvapterBase.cjs +1 -1
- package/dist/node/core/EnvapterBase.cjs.map +1 -1
- package/dist/node/core/EnvapterBase.mjs +1 -1
- package/dist/node/core/EnvapterBase.mjs.map +1 -1
- package/dist/node/core/Environment.cjs +1 -1
- package/dist/node/core/Environment.cjs.map +1 -1
- package/dist/node/core/Environment.mjs +1 -1
- package/dist/node/core/Environment.mjs.map +1 -1
- package/dist/node/core/EnvironmentMethods.cjs +1 -1
- package/dist/node/core/EnvironmentMethods.cjs.map +1 -1
- package/dist/node/core/EnvironmentMethods.mjs +1 -1
- package/dist/node/core/EnvironmentMethods.mjs.map +1 -1
- package/dist/node/core/PrimitiveMethods.cjs.map +1 -1
- package/dist/node/core/PrimitiveMethods.mjs.map +1 -1
- package/dist/node/core/engine.cjs +1 -1
- package/dist/node/core/engine.cjs.map +1 -1
- package/dist/node/core/engine.mjs +1 -1
- package/dist/node/core/engine.mjs.map +1 -1
- package/dist/node/core/missing.cjs +2 -0
- package/dist/node/core/missing.cjs.map +1 -0
- package/dist/node/core/missing.mjs +2 -0
- package/dist/node/core/missing.mjs.map +1 -0
- package/dist/node/core/paths.cjs +1 -1
- package/dist/node/core/paths.cjs.map +1 -1
- package/dist/node/core/paths.mjs +1 -1
- package/dist/node/core/paths.mjs.map +1 -1
- package/dist/node/decorators/legacy/Envapt.cjs.map +1 -1
- package/dist/node/decorators/legacy/Envapt.mjs.map +1 -1
- package/dist/node/decorators/legacy/SugarDecorators.cjs.map +1 -1
- package/dist/node/decorators/legacy/SugarDecorators.mjs.map +1 -1
- package/dist/node/decorators/modern/Envapt.cjs.map +1 -1
- package/dist/node/decorators/modern/Envapt.mjs.map +1 -1
- package/dist/node/decorators/modern/SugarDecorators.cjs.map +1 -1
- package/dist/node/decorators/modern/SugarDecorators.mjs.map +1 -1
- package/dist/node/decorators/resolveDecoratorValue.cjs +1 -1
- package/dist/node/decorators/resolveDecoratorValue.cjs.map +1 -1
- package/dist/node/decorators/resolveDecoratorValue.mjs +1 -1
- package/dist/node/decorators/resolveDecoratorValue.mjs.map +1 -1
- package/dist/node/engine/Envapter.cjs +1 -1
- package/dist/node/engine/Envapter.cjs.map +1 -1
- package/dist/node/engine/Envapter.mjs +1 -1
- package/dist/node/engine/Envapter.mjs.map +1 -1
- package/dist/node/engine/NodeEnvapter.cjs +1 -1
- package/dist/node/engine/NodeEnvapter.cjs.map +1 -1
- package/dist/node/engine/NodeEnvapter.mjs +1 -1
- package/dist/node/engine/NodeEnvapter.mjs.map +1 -1
- package/dist/node/engine/TemplateResolver.cjs +1 -1
- package/dist/node/engine/TemplateResolver.cjs.map +1 -1
- package/dist/node/engine/TemplateResolver.mjs +1 -1
- package/dist/node/engine/TemplateResolver.mjs.map +1 -1
- package/dist/node/engine/Validators.cjs +1 -1
- package/dist/node/engine/Validators.mjs +1 -1
- package/dist/node/index.cjs +1 -1
- package/dist/node/index.mjs +1 -1
- package/dist/node/infra/Debug.cjs +1 -1
- package/dist/node/infra/Debug.cjs.map +1 -1
- package/dist/node/infra/Debug.mjs +1 -1
- package/dist/node/infra/Debug.mjs.map +1 -1
- package/dist/node/infra/Dotenv.cjs.map +1 -1
- package/dist/node/infra/Dotenv.mjs.map +1 -1
- package/dist/node/infra/Error.cjs.map +1 -1
- package/dist/node/infra/Error.mjs.map +1 -1
- package/dist/node/infra/runtime.cjs +1 -1
- package/dist/node/infra/runtime.cjs.map +1 -1
- package/dist/node/infra/runtime.mjs +1 -1
- package/dist/node/infra/runtime.mjs.map +1 -1
- package/dist/node/sources/FileSource.cjs.map +1 -1
- package/dist/node/sources/FileSource.mjs.map +1 -1
- package/dist/node/sources/PortableSource.cjs.map +1 -1
- package/dist/node/sources/PortableSource.mjs.map +1 -1
- package/dist/node/sources/merge.cjs +1 -1
- package/dist/node/sources/merge.cjs.map +1 -1
- package/dist/node/sources/merge.mjs +1 -1
- package/dist/node/sources/merge.mjs.map +1 -1
- package/dist/node/sources/normalizeSource.cjs +2 -0
- package/dist/node/sources/normalizeSource.cjs.map +1 -0
- package/dist/node/sources/normalizeSource.mjs +2 -0
- package/dist/node/sources/normalizeSource.mjs.map +1 -0
- package/dist/portable/converters/Converters.mjs.map +1 -1
- package/dist/portable/converters/ValueConverter.mjs +1 -1
- package/dist/portable/converters/ValueConverter.mjs.map +1 -1
- package/dist/portable/core/AdvancedMethods.mjs +1 -1
- package/dist/portable/core/AdvancedMethods.mjs.map +1 -1
- package/dist/portable/core/EnvapterBase.mjs +1 -1
- package/dist/portable/core/EnvapterBase.mjs.map +1 -1
- package/dist/portable/core/Environment.mjs +1 -1
- package/dist/portable/core/Environment.mjs.map +1 -1
- package/dist/portable/core/EnvironmentMethods.mjs +1 -1
- package/dist/portable/core/EnvironmentMethods.mjs.map +1 -1
- package/dist/portable/core/PrimitiveMethods.mjs.map +1 -1
- package/dist/portable/core/engine.mjs +1 -1
- package/dist/portable/core/engine.mjs.map +1 -1
- package/dist/portable/core/missing.mjs +2 -0
- package/dist/portable/core/missing.mjs.map +1 -0
- package/dist/portable/core/paths.mjs +1 -1
- package/dist/portable/core/paths.mjs.map +1 -1
- package/dist/portable/decorators/legacy/Envapt.mjs.map +1 -1
- package/dist/portable/decorators/legacy/SugarDecorators.mjs.map +1 -1
- package/dist/portable/decorators/modern/Envapt.mjs.map +1 -1
- package/dist/portable/decorators/modern/SugarDecorators.mjs.map +1 -1
- package/dist/portable/decorators/resolveDecoratorValue.mjs +1 -1
- package/dist/portable/decorators/resolveDecoratorValue.mjs.map +1 -1
- package/dist/portable/engine/Envapter.mjs +1 -1
- package/dist/portable/engine/Envapter.mjs.map +1 -1
- package/dist/portable/engine/TemplateResolver.mjs +1 -1
- package/dist/portable/engine/TemplateResolver.mjs.map +1 -1
- package/dist/portable/engine/Validators.mjs +1 -1
- package/dist/portable/index.mjs +1 -1
- package/dist/portable/infra/Debug.mjs +1 -1
- package/dist/portable/infra/Debug.mjs.map +1 -1
- package/dist/portable/infra/Dotenv.mjs.map +1 -1
- package/dist/portable/infra/Error.mjs.map +1 -1
- package/dist/portable/infra/runtime.mjs +1 -1
- package/dist/portable/infra/runtime.mjs.map +1 -1
- package/dist/portable/sources/PortableSource.mjs.map +1 -1
- package/dist/portable/sources/merge.mjs +1 -1
- package/dist/portable/sources/merge.mjs.map +1 -1
- package/dist/portable/sources/normalizeSource.mjs +2 -0
- package/dist/portable/sources/normalizeSource.mjs.map +1 -0
- package/dist/types/converters/Converters.d.mts +3 -10
- package/dist/types/core/AdvancedMethods.d.mts +9 -0
- package/dist/types/core/EnvapterBase.d.mts +10 -2
- package/dist/types/core/Environment.d.mts +2 -1
- package/dist/types/core/EnvironmentMethods.d.mts +6 -0
- package/dist/types/core/PrimitiveMethods.d.mts +5 -0
- package/dist/types/decorators/legacy/SugarDecorators.d.mts +5 -0
- package/dist/types/decorators/modern/SugarDecorators.d.mts +5 -0
- package/dist/types/engine/Envapter.d.mts +4 -2
- package/dist/types/engine/NodeEnvapter.d.mts +14 -2
- package/dist/types/index.d.mts +3 -3
- package/dist/types/index.portable.d.mts +3 -3
- package/dist/types/infra/Debug.d.mts +1 -0
- package/dist/types/infra/Dotenv.d.mts +1 -0
- package/dist/types/infra/Error.d.mts +2 -0
- package/dist/types/infra/StandardSchema.d.mts +1 -0
- package/dist/types/sources/FileSource.d.mts +1 -0
- package/dist/types/sources/PortableSource.d.mts +1 -0
- package/dist/types/sources/merge.d.mts +7 -4
- package/dist/types/types/Conversion.d.mts +3 -5
- package/dist/types/types/Options.d.mts +4 -0
- package/dist/types/types/Source.d.mts +3 -0
- package/package.json +1 -1
|
@@ -17,10 +17,12 @@ declare class NodeEnvapter extends Envapter {
|
|
|
17
17
|
*
|
|
18
18
|
* When set, this takes absolute precedence. The dotenv-flow auto-cascade and any
|
|
19
19
|
* `Envapter.configureProfiles` configuration are ignored.
|
|
20
|
+
* @see {@link https://envapt.materwelon.dev/docs/configuration#which-files-load}
|
|
20
21
|
*/
|
|
21
22
|
static set envPaths(paths: string[] | string);
|
|
22
23
|
/**
|
|
23
24
|
* Get currently configured .env file paths
|
|
25
|
+
* @see {@link https://envapt.materwelon.dev/docs/configuration#which-files-load}
|
|
24
26
|
*/
|
|
25
27
|
static get envPaths(): string[];
|
|
26
28
|
/**
|
|
@@ -32,14 +34,22 @@ declare class NodeEnvapter extends Envapter {
|
|
|
32
34
|
*
|
|
33
35
|
* Set this before `envPaths` so relative `envPaths` validate against the right directory.
|
|
34
36
|
* Unset (`undefined`) restores `process.cwd()` resolution.
|
|
37
|
+
* @see {@link https://envapt.materwelon.dev/docs/configuration#reading-from-a-fixed-directory}
|
|
35
38
|
*/
|
|
36
39
|
static set baseDir(value: string | URL | undefined);
|
|
37
|
-
/**
|
|
40
|
+
/**
|
|
41
|
+
* The configured base directory, or `undefined` when relative paths resolve against the working directory.
|
|
42
|
+
* @see {@link https://envapt.materwelon.dev/docs/configuration#reading-from-a-fixed-directory}
|
|
43
|
+
*/
|
|
38
44
|
static get baseDir(): string | undefined;
|
|
39
|
-
/**
|
|
45
|
+
/**
|
|
46
|
+
* Set the env file loader options (`encoding`, `override`). Refreshes the cache.
|
|
47
|
+
* @see {@link https://envapt.materwelon.dev/docs/configuration#which-files-load}
|
|
48
|
+
*/
|
|
40
49
|
static set envFileOptions(config: EnvFileOptions);
|
|
41
50
|
/**
|
|
42
51
|
* Get current env file loader options
|
|
52
|
+
* @see {@link https://envapt.materwelon.dev/docs/configuration#which-files-load}
|
|
43
53
|
*/
|
|
44
54
|
static get envFileOptions(): EnvFileOptions;
|
|
45
55
|
/**
|
|
@@ -58,12 +68,14 @@ declare class NodeEnvapter extends Envapter {
|
|
|
58
68
|
* [Environment.Production]: { paths: ['config/prod.env', 'secrets/prod.env'] }
|
|
59
69
|
* });
|
|
60
70
|
* ```
|
|
71
|
+
* @see {@link https://envapt.materwelon.dev/docs/environment#custom-profiles}
|
|
61
72
|
*/
|
|
62
73
|
static configureProfiles(config: ProfilesConfig): void;
|
|
63
74
|
/**
|
|
64
75
|
* Reset all path-resolution configuration to defaults: clears any prior
|
|
65
76
|
* `Envapter.configureProfiles` call AND any explicit `Envapter.envPaths` assignment.
|
|
66
77
|
* Returns the resolver to the pure dotenv-flow cascade.
|
|
78
|
+
* @see {@link https://envapt.materwelon.dev/docs/environment#custom-profiles}
|
|
67
79
|
*/
|
|
68
80
|
static resetProfiles(): void;
|
|
69
81
|
}
|
package/dist/types/index.d.mts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Environment } from "./core/Environment.mjs";
|
|
2
2
|
import { DebugLevel } from "./infra/Debug.mjs";
|
|
3
|
-
import {
|
|
4
|
-
import { ConverterFunction,
|
|
3
|
+
import { Converters, CustomElementConverter } from "./converters/Converters.mjs";
|
|
4
|
+
import { ConverterFunction, JsonValue, TimeFallback } from "./types/Conversion.mjs";
|
|
5
5
|
import { StandardSchemaV1 } from "./infra/StandardSchema.mjs";
|
|
6
6
|
import { EnvProfile, EnvaptOptions, FileApiMode, ProfilesConfig } from "./types/Options.mjs";
|
|
7
7
|
import { Source } from "./types/Source.mjs";
|
|
@@ -13,4 +13,4 @@ import { Envapt } from "./decorators/modern/Envapt.mjs";
|
|
|
13
13
|
import { EnvBool, EnvNum, EnvStr, EnvTime, EnvUrl } from "./decorators/modern/SugarDecorators.mjs";
|
|
14
14
|
import { NodeEnvapter } from "./engine/NodeEnvapter.mjs";
|
|
15
15
|
import { FileSource } from "./sources/FileSource.mjs";
|
|
16
|
-
export { type ConverterFunction,
|
|
16
|
+
export { type ConverterFunction, Converters, type CustomElementConverter, type DebugLevel, EnvBool, type EnvFileOptions, EnvNum, type EnvProfile, EnvStr, EnvTime, EnvUrl, Envapt, EnvaptError, EnvaptErrorCodes, type EnvaptOptions, NodeEnvapter as Envapter, Environment, type FileApiMode, FileSource, type JsonValue, PortableSource, type ProfilesConfig, type Source, type StandardSchemaV1, type TimeFallback, merge };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Environment } from "./core/Environment.mjs";
|
|
2
2
|
import { DebugLevel } from "./infra/Debug.mjs";
|
|
3
|
-
import {
|
|
4
|
-
import { ConverterFunction,
|
|
3
|
+
import { Converters, CustomElementConverter } from "./converters/Converters.mjs";
|
|
4
|
+
import { ConverterFunction, JsonValue, TimeFallback } from "./types/Conversion.mjs";
|
|
5
5
|
import { StandardSchemaV1 } from "./infra/StandardSchema.mjs";
|
|
6
6
|
import { EnvProfile, EnvaptOptions, FileApiMode, ProfilesConfig } from "./types/Options.mjs";
|
|
7
7
|
import { Source } from "./types/Source.mjs";
|
|
@@ -12,4 +12,4 @@ import { EnvaptError, EnvaptErrorCodes } from "./infra/Error.mjs";
|
|
|
12
12
|
import { Envapt } from "./decorators/modern/Envapt.mjs";
|
|
13
13
|
import { EnvBool, EnvNum, EnvStr, EnvTime, EnvUrl } from "./decorators/modern/SugarDecorators.mjs";
|
|
14
14
|
import { PortableEnvapter } from "./engine/PortableEnvapter.mjs";
|
|
15
|
-
export { type ConverterFunction,
|
|
15
|
+
export { type ConverterFunction, Converters, type CustomElementConverter, type DebugLevel, EnvBool, type EnvFileOptions, EnvNum, type EnvProfile, EnvStr, EnvTime, EnvUrl, Envapt, EnvaptError, EnvaptErrorCodes, type EnvaptOptions, PortableEnvapter as Envapter, Environment, type FileApiMode, type JsonValue, PortableSource, type ProfilesConfig, type Source, type StandardSchemaV1, type TimeFallback, merge };
|
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
* (whether it returns a fallback or `undefined`). `verbose` adds every loaded file,
|
|
7
7
|
* per-file key count, per-key load lines, and effective-paths / cache-rebuild notices.
|
|
8
8
|
* @public
|
|
9
|
+
* @see {@link https://envapt.materwelon.dev/docs/configuration#debug-logging}
|
|
9
10
|
*/
|
|
10
11
|
type DebugLevel = 'silent' | 'warn' | 'verbose';
|
|
11
12
|
//#endregion
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
* For debug output, use `Envapter.debug` (or the `ENVAPT_DEBUG` env var).
|
|
6
6
|
*
|
|
7
7
|
* @public
|
|
8
|
+
* @see {@link https://envapt.materwelon.dev/docs/configuration#which-files-load}
|
|
8
9
|
*/
|
|
9
10
|
interface EnvFileOptions {
|
|
10
11
|
/** Encoding for reading .env files. Defaults to 'utf8'. */
|
|
@@ -4,6 +4,7 @@ import { StandardSchemaV1 } from "./StandardSchema.mjs";
|
|
|
4
4
|
/**
|
|
5
5
|
* Numeric codes carried by {@link EnvaptError.code}, grouped by fallback (1xx), converter (2xx),
|
|
6
6
|
* and configuration (3xx) failures.
|
|
7
|
+
* @see {@link https://envapt.materwelon.dev/docs/errors#codes}
|
|
7
8
|
*/
|
|
8
9
|
declare enum EnvaptErrorCodes {
|
|
9
10
|
/** Thrown when an invalid fallback value is provided */
|
|
@@ -62,6 +63,7 @@ interface EnvaptErrorOptions {
|
|
|
62
63
|
* ```ts
|
|
63
64
|
* throw new EnvaptError(EnvaptErrorCodes.InvalidFallback, "Invalid fallback value provided for environment variable.");
|
|
64
65
|
* ```
|
|
66
|
+
* @see {@link https://envapt.materwelon.dev/docs/errors#the-error-shape}
|
|
65
67
|
*/
|
|
66
68
|
declare class EnvaptError extends Error {
|
|
67
69
|
/** The {@link EnvaptErrorCodes} value identifying what failed. */
|
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
* `SchemaMustBeSync` brand in `Types.ts`) and at runtime by the Parser dispatch.
|
|
10
10
|
*
|
|
11
11
|
* @public
|
|
12
|
+
* @see {@link https://envapt.materwelon.dev/docs/standard-schema#any-conformant-validator-or-none}
|
|
12
13
|
*/
|
|
13
14
|
interface StandardSchemaV1<Input = unknown, Output = Input> {
|
|
14
15
|
/** The Standard Schema entry point holding the validator and the inferred input/output types. */
|
|
@@ -6,6 +6,7 @@ import { FileCapableSource } from "../types/Source.mjs";
|
|
|
6
6
|
* `supportsFiles` is `true`, so the engine also layers the `.env` cascade on top, resolves
|
|
7
7
|
* `baseDir`, and can mirror loaded keys back to `process.env`.
|
|
8
8
|
* @public
|
|
9
|
+
* @see {@link https://envapt.materwelon.dev/docs/sources#the-providers}
|
|
9
10
|
*/
|
|
10
11
|
declare class FileSource implements FileCapableSource {
|
|
11
12
|
/** Always `true`. The engine layers the `.env` cascade and `baseDir` on top of `process.env`. */
|
|
@@ -9,6 +9,7 @@ import { BareSource } from "../types/Source.mjs";
|
|
|
9
9
|
* still apply, which means they must be JSON-serializable. Without a filesystem the `.env` cascade and
|
|
10
10
|
* file APIs do not apply.
|
|
11
11
|
* @public
|
|
12
|
+
* @see {@link https://envapt.materwelon.dev/docs/sources#the-providers}
|
|
12
13
|
*/
|
|
13
14
|
declare class PortableSource implements BareSource {
|
|
14
15
|
/** Always `false`. With no filesystem, the `.env` cascade and file APIs do not apply. */
|
|
@@ -2,12 +2,15 @@ import { Source } from "../types/Source.mjs";
|
|
|
2
2
|
|
|
3
3
|
//#region src/sources/merge.d.ts
|
|
4
4
|
/**
|
|
5
|
-
* Compose several sources into one, read last-wins. A later member's value overrides an
|
|
6
|
-
* member's
|
|
7
|
-
*
|
|
5
|
+
* Compose several sources into one, read last-wins. A later member's `readVars()` value overrides an
|
|
6
|
+
* earlier member's for the same key. A member may be a `(key) => string | undefined` reader for a
|
|
7
|
+
* source that reads one key at a time, and it fills a key missing from every snapshot. Bind the result
|
|
8
|
+
* with `Envapter.useSource`. Throws {@link EnvaptErrorCodes.InvalidMergedSource} with no members or with
|
|
9
|
+
* more than one file-backed member.
|
|
8
10
|
* @public
|
|
11
|
+
* @see {@link https://envapt.materwelon.dev/docs/sources#combining-sources}
|
|
9
12
|
*/
|
|
10
|
-
declare function merge(...members: Source[]): Source;
|
|
13
|
+
declare function merge(...members: (Source | ((key: string) => string | undefined))[]): Source;
|
|
11
14
|
//#endregion
|
|
12
15
|
export { merge };
|
|
13
16
|
//# sourceMappingURL=merge.d.mts.map
|
|
@@ -11,13 +11,9 @@ type BaseInput = string | undefined;
|
|
|
11
11
|
* @param fallback - Fallback value when parsing is skipped
|
|
12
12
|
* @returns Parsed value of type `TFallback`
|
|
13
13
|
* @public
|
|
14
|
+
* @see {@link https://envapt.materwelon.dev/docs/converters#custom-converters}
|
|
14
15
|
*/
|
|
15
16
|
type ConverterFunction<TFallback = unknown, TRaw extends BaseInput = BaseInput> = (raw: TRaw, fallback?: TFallback) => TFallback;
|
|
16
|
-
/**
|
|
17
|
-
* Environment variable converter: a primitive constructor, a built-in scalar token, an `ArrayOf<...>`
|
|
18
|
-
* produced by {@link Converters.array}, or a custom parser function.
|
|
19
|
-
* @public
|
|
20
|
-
*/
|
|
21
17
|
type EnvaptConverter<TFallback> = PrimitiveConstructor | BuiltInConverter | ArrayOf | ConverterFunction<TFallback>;
|
|
22
18
|
type JsonPrimitive = string | number | boolean | null;
|
|
23
19
|
type JsonArray = JsonValue[];
|
|
@@ -27,6 +23,7 @@ interface JsonObject {
|
|
|
27
23
|
/**
|
|
28
24
|
* JSON value types for custom converters
|
|
29
25
|
* @public
|
|
26
|
+
* @see {@link https://envapt.materwelon.dev/docs/converters#json}
|
|
30
27
|
*/
|
|
31
28
|
type JsonValue = JsonPrimitive | JsonArray | JsonObject;
|
|
32
29
|
interface ConverterMap {
|
|
@@ -52,6 +49,7 @@ type TimeUnit = 'ms' | 's' | 'm' | 'h' | 'd' | 'w';
|
|
|
52
49
|
/**
|
|
53
50
|
* Fallback type for time duration conversions
|
|
54
51
|
* @public
|
|
52
|
+
* @see {@link https://envapt.materwelon.dev/docs/converters#time-and-durations}
|
|
55
53
|
*/
|
|
56
54
|
type TimeFallback = number | `${number}${TimeUnit}`;
|
|
57
55
|
type ConditionalReturn<ReturnType, TFallback> = TFallback extends undefined ? ReturnType | undefined : ReturnType;
|
|
@@ -6,6 +6,7 @@ import { EnvaptConverter } from "./Conversion.mjs";
|
|
|
6
6
|
* Options for the \@Envapt decorator (modern API). `required: true` is mutually exclusive
|
|
7
7
|
* with `fallback`; see the per-converter overloads in `Envapt.ts` for the type-level mutex.
|
|
8
8
|
* @public
|
|
9
|
+
* @see {@link https://envapt.materwelon.dev/docs/decorators#declaring-decorated-fields}
|
|
9
10
|
*/
|
|
10
11
|
interface EnvaptOptions<TFallback = string> {
|
|
11
12
|
/** Value returned when the variable is missing or empty. Mutually exclusive with `required: true`. */
|
|
@@ -18,6 +19,7 @@ interface EnvaptOptions<TFallback = string> {
|
|
|
18
19
|
/**
|
|
19
20
|
* Per-environment profile entry passed to `Envapter.configureProfiles`.
|
|
20
21
|
* @public
|
|
22
|
+
* @see {@link https://envapt.materwelon.dev/docs/environment#custom-profiles}
|
|
21
23
|
*/
|
|
22
24
|
interface EnvProfile {
|
|
23
25
|
/** One or more `.env` paths to load for this environment. Order matters: earlier paths take precedence. */
|
|
@@ -28,6 +30,7 @@ interface EnvProfile {
|
|
|
28
30
|
* profile override. Unspecified environments fall through to the default cascade behavior
|
|
29
31
|
* (`.env.${env}.local`, `.env.local`, `.env.${env}`, `.env`).
|
|
30
32
|
* @public
|
|
33
|
+
* @see {@link https://envapt.materwelon.dev/docs/environment#custom-profiles}
|
|
31
34
|
*/
|
|
32
35
|
type ProfilesConfig = Partial<Record<Environment, EnvProfile>> & {
|
|
33
36
|
/**
|
|
@@ -42,6 +45,7 @@ type ProfilesConfig = Partial<Record<Environment, EnvProfile>> & {
|
|
|
42
45
|
* warns once and no-ops, `'throw'` throws `FileApiUnsupported`. The node build runs these APIs
|
|
43
46
|
* normally and is unaffected by this value.
|
|
44
47
|
* @public
|
|
48
|
+
* @see {@link https://envapt.materwelon.dev/docs/compatibility#binding-by-runtime}
|
|
45
49
|
*/
|
|
46
50
|
type FileApiMode = 'warn' | 'throw';
|
|
47
51
|
//#endregion
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
interface BareSource {
|
|
3
3
|
readVars(): Record<string, string>;
|
|
4
4
|
readonly supportsFiles?: false;
|
|
5
|
+
readVar?(key: string): string | undefined;
|
|
5
6
|
}
|
|
6
7
|
interface FileCapableSource {
|
|
7
8
|
readVars(): Record<string, string>;
|
|
@@ -10,6 +11,7 @@ interface FileCapableSource {
|
|
|
10
11
|
resolvePath(baseDir: string, candidate: string): string;
|
|
11
12
|
normalizeBaseDir(value: string | URL): string;
|
|
12
13
|
writeVars(vars: Record<string, string>): void;
|
|
14
|
+
readVar?(key: string): string | undefined;
|
|
13
15
|
}
|
|
14
16
|
/**
|
|
15
17
|
* A pluggable source of environment variables. The default {@link FileSource} reads `process.env` plus
|
|
@@ -17,6 +19,7 @@ interface FileCapableSource {
|
|
|
17
19
|
* environment (an injected object on the browser, the Cloudflare `env` binding on Workers). Bind one
|
|
18
20
|
* with `Envapter.useSource`.
|
|
19
21
|
* @public
|
|
22
|
+
* @see {@link https://envapt.materwelon.dev/docs/sources#any-object-can-be-a-source}
|
|
20
23
|
*/
|
|
21
24
|
type Source = BareSource | FileCapableSource;
|
|
22
25
|
//#endregion
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "envapt",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "8.0.0-next.
|
|
4
|
+
"version": "8.0.0-next.1",
|
|
5
5
|
"description": "Type-safe config for TypeScript. Read typed values from any source, process.env, .env files, Cloudflare Workers bindings, browser bundles, or any object you supply. Zero runtime dependencies, one API across Node, Bun, Deno, Workers, and the browser. TC39 accessor decorators (legacy decorators at envapt/legacy), converters, and Standard Schema (zod/valibot/arktype) validation.",
|
|
6
6
|
"types": "./dist/types/index.d.mts",
|
|
7
7
|
"exports": {
|