envapt 8.0.0-next.0 → 8.0.0-next.2
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 +33 -0
- package/dist/node/converters/BuiltInConverters.cjs +1 -1
- package/dist/node/converters/BuiltInConverters.cjs.map +1 -1
- package/dist/node/converters/BuiltInConverters.mjs +1 -1
- package/dist/node/converters/BuiltInConverters.mjs.map +1 -1
- package/dist/node/converters/Converters.cjs +1 -1
- package/dist/node/converters/Converters.cjs.map +1 -1
- package/dist/node/converters/Converters.mjs +1 -1
- package/dist/node/converters/Converters.mjs.map +1 -1
- package/dist/node/converters/ListOfBuiltInConverters.cjs +1 -1
- package/dist/node/converters/ListOfBuiltInConverters.cjs.map +1 -1
- package/dist/node/converters/ListOfBuiltInConverters.mjs +1 -1
- package/dist/node/converters/ListOfBuiltInConverters.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/BuiltInConverters.mjs +1 -1
- package/dist/portable/converters/BuiltInConverters.mjs.map +1 -1
- package/dist/portable/converters/Converters.mjs +1 -1
- package/dist/portable/converters/Converters.mjs.map +1 -1
- package/dist/portable/converters/ListOfBuiltInConverters.mjs +1 -1
- package/dist/portable/converters/ListOfBuiltInConverters.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 +7 -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 +5 -5
- package/dist/types/types/Options.d.mts +4 -0
- package/dist/types/types/Source.d.mts +3 -0
- package/package.json +1 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{EnvaptError as e}from"../infra/Error.mjs";function
|
|
1
|
+
import{EnvaptError as e}from"../infra/Error.mjs";import{normalizeSource as t}from"./normalizeSource.mjs";function n(...n){if(n.length===0)throw new e(308,`merge requires at least one source.`);let r=n.map(t),i=r.filter(e=>e.supportsFiles===!0);if(i.length>1)throw new e(308,`merge accepts at most one filesystem-backed source, so the .env cascade and file APIs route to a single member.`);let a=()=>{let e={};for(let t of r)Object.assign(e,t.readVars());return e},o=r.filter(e=>typeof e.readVar==`function`),s=o.length===0?void 0:e=>{for(let t=o.length-1;t>=0;t--){let n=o[t]?.readVar(e);if(n!==void 0)return n}},c=i[0];if(!c){let e={readVars:a};return s&&(e.readVar=s),e}let l={readVars:a,supportsFiles:!0,readFile:(e,t)=>c.readFile(e,t),resolvePath:(e,t)=>c.resolvePath(e,t),normalizeBaseDir:e=>c.normalizeBaseDir(e),writeVars:e=>c.writeVars(e)};return s&&(l.readVar=s),l}export{n as merge};
|
|
2
2
|
//# sourceMappingURL=merge.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"merge.mjs","names":[],"sources":["../../../src/sources/merge.ts"],"sourcesContent":["import { EnvaptError, EnvaptErrorCodes } from '../infra/Error';\n\nimport type { FileCapableSource, Source } from '../types';\n\n/**\n * Compose several sources into one, read last-wins. A later member's value overrides an
|
|
1
|
+
{"version":3,"file":"merge.mjs","names":[],"sources":["../../../src/sources/merge.ts"],"sourcesContent":["import { normalizeSource } from './normalizeSource';\nimport { EnvaptError, EnvaptErrorCodes } from '../infra/Error';\n\nimport type { BareSource, FileCapableSource, Source } from '../types';\n\n/**\n * Compose several sources into one, read last-wins. A later member's `readVars()` value overrides an\n * earlier member's for the same key. A member may be a `(key) => string | undefined` reader for a\n * source that reads one key at a time, and it fills a key missing from every snapshot. Bind the result\n * with `Envapter.useSource`. Throws {@link EnvaptErrorCodes.InvalidMergedSource} with no members or with\n * more than one file-backed member.\n * @public\n * @see {@link https://envapt.materwelon.dev/docs/sources#combining-sources}\n */\nexport function merge(...members: (Source | ((key: string) => string | undefined))[]): Source {\n if (members.length === 0) {\n throw new EnvaptError(EnvaptErrorCodes.InvalidMergedSource, 'merge requires at least one source.');\n }\n\n const sources = members.map(normalizeSource);\n\n const fileMembers = sources.filter((m): m is FileCapableSource => m.supportsFiles === true);\n if (fileMembers.length > 1) {\n throw new EnvaptError(\n EnvaptErrorCodes.InvalidMergedSource,\n 'merge accepts at most one filesystem-backed source, so the .env cascade and file APIs route to a single member.'\n );\n }\n\n const readVars = (): Record<string, string> => {\n const merged: Record<string, string> = {};\n for (const m of sources) Object.assign(merged, m.readVars());\n return merged;\n };\n\n const readers = sources.filter(\n (m): m is Source & { readVar: (key: string) => string | undefined } => typeof m.readVar === 'function'\n );\n const readVar =\n readers.length === 0\n ? undefined\n : (key: string): string | undefined => {\n // last reader that answers wins, so scan from the end and return the first defined value\n for (let i = readers.length - 1; i >= 0; i--) {\n const found = readers[i]?.readVar(key);\n if (found !== undefined) return found;\n }\n return undefined;\n };\n\n const fileMember = fileMembers[0];\n if (!fileMember) {\n const bare: BareSource = { readVars };\n if (readVar) bare.readVar = readVar;\n return bare;\n }\n\n const fileCapable: FileCapableSource = {\n readVars,\n supportsFiles: true,\n readFile: (path, encoding) => fileMember.readFile(path, encoding),\n resolvePath: (baseDir, candidate) => fileMember.resolvePath(baseDir, candidate),\n normalizeBaseDir: (value) => fileMember.normalizeBaseDir(value),\n writeVars: (vars) => fileMember.writeVars(vars)\n };\n if (readVar) fileCapable.readVar = readVar;\n return fileCapable;\n}\n"],"mappings":"yGAcA,SAAgB,EAAM,GAAG,EAAqE,CAC1F,GAAI,EAAQ,SAAW,EACnB,MAAM,IAAI,EAAA,IAAkD,qCAAqC,EAGrG,IAAM,EAAU,EAAQ,IAAI,CAAe,EAErC,EAAc,EAAQ,OAAQ,GAA8B,EAAE,gBAAkB,EAAI,EAC1F,GAAI,EAAY,OAAS,EACrB,MAAM,IAAI,EAAA,IAEN,iHACJ,EAGJ,IAAM,MAAyC,CAC3C,IAAM,EAAiC,CAAC,EACxC,IAAK,IAAM,KAAK,EAAS,OAAO,OAAO,EAAQ,EAAE,SAAS,CAAC,EAC3D,OAAO,CACX,EAEM,EAAU,EAAQ,OACnB,GAAsE,OAAO,EAAE,SAAY,UAChG,EACM,EACF,EAAQ,SAAW,EACb,IAAA,GACC,GAAoC,CAEjC,IAAK,IAAI,EAAI,EAAQ,OAAS,EAAG,GAAK,EAAG,IAAK,CAC1C,IAAM,EAAQ,EAAQ,EAAE,EAAE,QAAQ,CAAG,EACrC,GAAI,IAAU,IAAA,GAAW,OAAO,CACpC,CAEJ,EAEJ,EAAa,EAAY,GAC/B,GAAI,CAAC,EAAY,CACb,IAAM,EAAmB,CAAE,UAAS,EAEpC,OADI,IAAS,EAAK,QAAU,GACrB,CACX,CAEA,IAAM,EAAiC,CACnC,WACA,cAAe,GACf,UAAW,EAAM,IAAa,EAAW,SAAS,EAAM,CAAQ,EAChE,aAAc,EAAS,IAAc,EAAW,YAAY,EAAS,CAAS,EAC9E,iBAAmB,GAAU,EAAW,iBAAiB,CAAK,EAC9D,UAAY,GAAS,EAAW,UAAU,CAAI,CAClD,EAEA,OADI,IAAS,EAAY,QAAU,GAC5B,CACX"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"normalizeSource.mjs","names":[],"sources":["../../../src/sources/normalizeSource.ts"],"sourcesContent":["import type { Source } from '../types';\n\nexport function normalizeSource(source: Source | ((key: string) => string | undefined)): Source {\n return typeof source === 'function' ? { supportsFiles: false, readVars: () => ({}), readVar: source } : source;\n}\n"],"mappings":"AAEA,SAAgB,EAAgB,EAAgE,CAC5F,OAAO,OAAO,GAAW,WAAa,CAAE,cAAe,GAAO,cAAiB,CAAC,GAAI,QAAS,CAAO,EAAI,CAC5G"}
|
|
@@ -12,16 +12,15 @@ declare const SCALAR: {
|
|
|
12
12
|
readonly Regexp: "regexp";
|
|
13
13
|
readonly Date: "date";
|
|
14
14
|
readonly Time: "time";
|
|
15
|
+
readonly Port: "port";
|
|
16
|
+
readonly Email: "email";
|
|
15
17
|
};
|
|
16
|
-
/**
|
|
17
|
-
* String tokens for every built-in scalar converter.
|
|
18
|
-
* @public
|
|
19
|
-
*/
|
|
20
18
|
type ConverterToken = (typeof SCALAR)[keyof typeof SCALAR];
|
|
21
19
|
/**
|
|
22
20
|
* Custom element converter for use inside {@link Converters.array}. Receives the trimmed,
|
|
23
21
|
* non-empty raw string for one array slot and returns the parsed value.
|
|
24
22
|
* @public
|
|
23
|
+
* @see {@link https://envapt.materwelon.dev/docs/converters#custom-converters}
|
|
25
24
|
*/
|
|
26
25
|
type CustomElementConverter<TReturn = unknown> = (raw: string) => TReturn;
|
|
27
26
|
type ArrayElement = Exclude<ConverterToken, 'json' | 'regexp'> | CustomElementConverter;
|
|
@@ -30,11 +29,6 @@ interface ArrayOf<TElement extends ArrayElement = ArrayElement> {
|
|
|
30
29
|
readonly of: TElement;
|
|
31
30
|
readonly delimiter: string;
|
|
32
31
|
}
|
|
33
|
-
/**
|
|
34
|
-
* Runtime type guard for tokens produced by {@link Converters.array}.
|
|
35
|
-
* @internal
|
|
36
|
-
*/
|
|
37
|
-
declare function isArrayOf(value: unknown): value is ArrayOf;
|
|
38
32
|
type ArrayScalarElement = Exclude<ConverterToken, 'json' | 'regexp'>;
|
|
39
33
|
declare function buildArrayConverter<TReturn>(opts: {
|
|
40
34
|
of: CustomElementConverter<TReturn>;
|
|
@@ -61,6 +55,7 @@ declare function buildArrayConverter(opts?: {
|
|
|
61
55
|
* ```
|
|
62
56
|
*
|
|
63
57
|
* @public
|
|
58
|
+
* @see {@link https://envapt.materwelon.dev/docs/converters#built-in-tokens}
|
|
64
59
|
*/
|
|
65
60
|
declare const Converters: {
|
|
66
61
|
readonly array: typeof buildArrayConverter;
|
|
@@ -76,7 +71,9 @@ declare const Converters: {
|
|
|
76
71
|
readonly Regexp: "regexp";
|
|
77
72
|
readonly Date: "date";
|
|
78
73
|
readonly Time: "time";
|
|
74
|
+
readonly Port: "port";
|
|
75
|
+
readonly Email: "email";
|
|
79
76
|
};
|
|
80
77
|
//#endregion
|
|
81
|
-
export { ArrayOf, ConverterToken, Converters, CustomElementConverter
|
|
78
|
+
export { ArrayOf, ConverterToken, Converters, CustomElementConverter };
|
|
82
79
|
//# sourceMappingURL=Converters.d.mts.map
|
|
@@ -18,6 +18,8 @@ declare class AdvancedMethods extends PrimitiveMethods {
|
|
|
18
18
|
* Supports both scalar tokens (e.g. `Converters.Number`) and `ArrayOf<...>` tokens
|
|
19
19
|
* produced by `Converters.array(...)`. The key can be a single name or an ordered list.
|
|
20
20
|
* The first defined value wins.
|
|
21
|
+
* @see {@link https://envapt.materwelon.dev/docs/envapter#converters}
|
|
22
|
+
* @see {@link https://envapt.materwelon.dev/docs/converters#custom-converters}
|
|
21
23
|
*/
|
|
22
24
|
static getUsing<TFallback extends TimeFallback | undefined = undefined>(key: EnvKeyInput, converter: 'time', fallback?: TFallback): ConditionalReturn<number, TFallback>;
|
|
23
25
|
static getUsing<TConverter extends BuiltInConverter | ArrayOf, TFallback = undefined>(key: EnvKeyInput, converter: TConverter, fallback?: TFallback): AdvancedConverterReturn<TConverter, TFallback>;
|
|
@@ -31,6 +33,8 @@ declare class AdvancedMethods extends PrimitiveMethods {
|
|
|
31
33
|
/**
|
|
32
34
|
* Get an environment variable using a custom converter function.
|
|
33
35
|
* Accepts a single key or an ordered list for automatic fallback.
|
|
36
|
+
* @see {@link https://envapt.materwelon.dev/docs/envapter#converters}
|
|
37
|
+
* @see {@link https://envapt.materwelon.dev/docs/converters#custom-converters}
|
|
34
38
|
*/
|
|
35
39
|
static getWith<TReturnType, TFallback extends TReturnType | undefined = undefined>(key: EnvKeyInput, converter: ConverterFunction<TReturnType>, fallback?: TFallback): ConditionalReturn<TReturnType, TFallback>;
|
|
36
40
|
/**
|
|
@@ -41,6 +45,8 @@ declare class AdvancedMethods extends PrimitiveMethods {
|
|
|
41
45
|
* Read a required environment variable and convert it, throwing `MissingEnvValue` when the value
|
|
42
46
|
* is missing or empty. Returns the non-undefined converter output. Accepts a built-in or `ArrayOf`
|
|
43
47
|
* token, or a custom parser function. The key can be a single name or an ordered list.
|
|
48
|
+
* @see {@link https://envapt.materwelon.dev/docs/envapter#fail-fast-on-missing-values}
|
|
49
|
+
* @see {@link https://envapt.materwelon.dev/docs/converters#require-a-converted-value}
|
|
44
50
|
*/
|
|
45
51
|
static getRequired<TConverter extends BuiltInConverter | ArrayOf>(key: EnvKeyInput, converter: TConverter): InferConverterReturnType<TConverter>;
|
|
46
52
|
static getRequired<TReturnType>(key: EnvKeyInput, converter: ConverterFunction<TReturnType, string>): TReturnType;
|
|
@@ -56,6 +62,8 @@ declare class AdvancedMethods extends PrimitiveMethods {
|
|
|
56
62
|
* `MissingEnvValue` listing them all. Pass a `casing` (`'camelCase'`, `'PascalCase'`, or
|
|
57
63
|
* `'kebab-case'`) to rename the record keys, splitting on underscores, which assumes the
|
|
58
64
|
* conventional SCREAMING_SNAKE env-var names. With no casing the keys stay as-is.
|
|
65
|
+
* @see {@link https://envapt.materwelon.dev/docs/envapter#fail-fast-on-missing-values}
|
|
66
|
+
* @see {@link https://envapt.materwelon.dev/docs/converters#require-a-converted-value}
|
|
59
67
|
*/
|
|
60
68
|
static getRequiredAll<Spec extends RequiredSpec, Casing extends KeyCasing | undefined = undefined>(spec: Spec, casing?: Casing): { [K in keyof Spec as RecaseKey<K & string, Casing>]: InferSpecField<Spec[K]> };
|
|
61
69
|
/**
|
|
@@ -76,6 +84,7 @@ declare class AdvancedMethods extends PrimitiveMethods {
|
|
|
76
84
|
* import { z } from 'zod';
|
|
77
85
|
* const port = Envapter.parse('PORT', z.coerce.number().min(1024).max(65535), 3000);
|
|
78
86
|
* ```
|
|
87
|
+
* @see {@link https://envapt.materwelon.dev/docs/standard-schema#any-conformant-validator-or-none}
|
|
79
88
|
*/
|
|
80
89
|
static parse<Schema extends StandardSchemaV1>(key: EnvKeyInput, schema: SchemaConstraint<Schema>, fallback?: InferSchemaOutput<Schema>): InferSchemaOutput<Schema>;
|
|
81
90
|
/**
|
|
@@ -9,6 +9,7 @@ declare abstract class EnvapterBase {
|
|
|
9
9
|
/**
|
|
10
10
|
* Enable or disable strict mode. Default `false`. Setting refreshes the cache so
|
|
11
11
|
* previously-cached converted values get re-evaluated under the new rule.
|
|
12
|
+
* @see {@link https://envapt.materwelon.dev/docs/strict-mode#what-strict-mode-changes}
|
|
12
13
|
*/
|
|
13
14
|
static set strict(value: boolean);
|
|
14
15
|
static get strict(): boolean;
|
|
@@ -16,6 +17,7 @@ declare abstract class EnvapterBase {
|
|
|
16
17
|
* Set the debug log level. Defaults to `silent`. When unset, reads `ENVAPT_DEBUG` from the
|
|
17
18
|
* bound source on first access. The setter overrides any env-var value. Output goes to stderr
|
|
18
19
|
* on Node (the console elsewhere), prefixed with `[envapt]`.
|
|
20
|
+
* @see {@link https://envapt.materwelon.dev/docs/configuration#debug-logging}
|
|
19
21
|
*/
|
|
20
22
|
static set debug(level: DebugLevel);
|
|
21
23
|
static get debug(): DebugLevel;
|
|
@@ -29,6 +31,7 @@ declare abstract class EnvapterBase {
|
|
|
29
31
|
* Flipping `false → true` mirrors the existing tracked delta immediately (no cache
|
|
30
32
|
* refresh). Flipping `true → false` is one-way: previously mirrored keys remain in
|
|
31
33
|
* `process.env` until the process exits.
|
|
34
|
+
* @see {@link https://envapt.materwelon.dev/docs/configuration#mirroring-to-processenv}
|
|
32
35
|
*/
|
|
33
36
|
static set syncProcessEnv(value: boolean);
|
|
34
37
|
static get syncProcessEnv(): boolean;
|
|
@@ -37,6 +40,7 @@ declare abstract class EnvapterBase {
|
|
|
37
40
|
* `envFileOptions`, `configureProfiles`, `resetProfiles`). `'warn'` (the default) warns once and
|
|
38
41
|
* no-ops, `'throw'` throws {@link EnvaptError} `FileApiUnsupported`. The node build runs these
|
|
39
42
|
* APIs normally and this value has no effect there.
|
|
43
|
+
* @see {@link https://envapt.materwelon.dev/docs/compatibility#binding-by-runtime}
|
|
40
44
|
*/
|
|
41
45
|
static set fileApiMode(mode: FileApiMode);
|
|
42
46
|
static get fileApiMode(): FileApiMode;
|
|
@@ -44,16 +48,20 @@ declare abstract class EnvapterBase {
|
|
|
44
48
|
* Eagerly load the `.env` cascade now instead of lazily on the first read. Idempotent: a no-op
|
|
45
49
|
* once the cache is built. Useful before mirroring to `process.env` (see {@link syncProcessEnv}),
|
|
46
50
|
* which is what the `envapt/config` side-effect entry does.
|
|
51
|
+
* @see {@link https://envapt.materwelon.dev/docs/configuration#which-files-load}
|
|
47
52
|
*/
|
|
48
53
|
static load(): void;
|
|
49
54
|
/**
|
|
50
55
|
* Bind the environment {@link Source}. On Node the entry binds {@link FileSource} for you
|
|
51
56
|
* (a `process.env` snapshot plus the `.env` cascade). On the browser or Workers, pass a
|
|
52
|
-
* `PortableSource` (or any `Source`) before reading.
|
|
57
|
+
* `PortableSource` (or any `Source`) before reading. Pass a `(key) => string | undefined` reader for
|
|
58
|
+
* a source that reads one key at a time and cannot list its keys. Clears and rebuilds the cache.
|
|
59
|
+
* @see {@link https://envapt.materwelon.dev/docs/sources#the-providers}
|
|
53
60
|
*/
|
|
54
|
-
static useSource(source: Source): void;
|
|
61
|
+
static useSource(source: Source | ((key: string) => string | undefined)): void;
|
|
55
62
|
/**
|
|
56
63
|
* Read an environment variable as its raw string, skipping parsing and conversion.
|
|
64
|
+
* @see {@link https://envapt.materwelon.dev/docs/envapter#raw-values}
|
|
57
65
|
*/
|
|
58
66
|
getRaw(key: EnvKeyInput): string | undefined;
|
|
59
67
|
}
|
|
@@ -2,13 +2,14 @@
|
|
|
2
2
|
/**
|
|
3
3
|
* Environment types supported by Envapter
|
|
4
4
|
*
|
|
5
|
-
* The following keys are checked in order until the first with a non-
|
|
5
|
+
* The following keys are checked in order until the first with a present (non-missing) value, defaulting to development if none are set:
|
|
6
6
|
* - `ENVIRONMENT`
|
|
7
7
|
* - `ENV`
|
|
8
8
|
* - `NODE_ENV`
|
|
9
9
|
* - `MODE`
|
|
10
10
|
*
|
|
11
11
|
* @public
|
|
12
|
+
* @see {@link https://envapt.materwelon.dev/docs/environment#detecting-the-environment}
|
|
12
13
|
*/
|
|
13
14
|
declare enum Environment {
|
|
14
15
|
/** The default when no environment variable names a known environment. */
|
|
@@ -9,10 +9,12 @@ import { EnvapterBase } from "./EnvapterBase.mjs";
|
|
|
9
9
|
declare class EnvironmentMethods extends EnvapterBase {
|
|
10
10
|
/**
|
|
11
11
|
* Get the current application environment
|
|
12
|
+
* @see {@link https://envapt.materwelon.dev/docs/environment#detecting-the-environment}
|
|
12
13
|
*/
|
|
13
14
|
static get environment(): Environment;
|
|
14
15
|
/**
|
|
15
16
|
* Set the application environment. Accepts either Environment enum or string value.
|
|
17
|
+
* @see {@link https://envapt.materwelon.dev/docs/environment#detecting-the-environment}
|
|
16
18
|
*/
|
|
17
19
|
static set environment(env: string | Environment);
|
|
18
20
|
/**
|
|
@@ -25,6 +27,7 @@ declare class EnvironmentMethods extends EnvapterBase {
|
|
|
25
27
|
set environment(env: string | Environment);
|
|
26
28
|
/**
|
|
27
29
|
* Check if the current environment is production
|
|
30
|
+
* @see {@link https://envapt.materwelon.dev/docs/environment#branching-on-the-environment}
|
|
28
31
|
*/
|
|
29
32
|
static get isProduction(): boolean;
|
|
30
33
|
/**
|
|
@@ -33,6 +36,7 @@ declare class EnvironmentMethods extends EnvapterBase {
|
|
|
33
36
|
get isProduction(): boolean;
|
|
34
37
|
/**
|
|
35
38
|
* Check if the current environment is staging
|
|
39
|
+
* @see {@link https://envapt.materwelon.dev/docs/environment#branching-on-the-environment}
|
|
36
40
|
*/
|
|
37
41
|
static get isStaging(): boolean;
|
|
38
42
|
/**
|
|
@@ -41,6 +45,7 @@ declare class EnvironmentMethods extends EnvapterBase {
|
|
|
41
45
|
get isStaging(): boolean;
|
|
42
46
|
/**
|
|
43
47
|
* Check if the current environment is development
|
|
48
|
+
* @see {@link https://envapt.materwelon.dev/docs/environment#branching-on-the-environment}
|
|
44
49
|
*/
|
|
45
50
|
static get isDevelopment(): boolean;
|
|
46
51
|
/**
|
|
@@ -49,6 +54,7 @@ declare class EnvironmentMethods extends EnvapterBase {
|
|
|
49
54
|
get isDevelopment(): boolean;
|
|
50
55
|
/**
|
|
51
56
|
* Check if the current environment is test
|
|
57
|
+
* @see {@link https://envapt.materwelon.dev/docs/environment#branching-on-the-environment}
|
|
52
58
|
*/
|
|
53
59
|
static get isTest(): boolean;
|
|
54
60
|
/**
|
|
@@ -11,6 +11,7 @@ declare class PrimitiveMethods extends EnvironmentMethods {
|
|
|
11
11
|
* Get a string environment variable with optional fallback.
|
|
12
12
|
* Supports template variable resolution using `${VAR}` syntax.
|
|
13
13
|
* Accepts a single key or an ordered array of keys (first match wins).
|
|
14
|
+
* @see {@link https://envapt.materwelon.dev/docs/envapter#primitives}
|
|
14
15
|
*/
|
|
15
16
|
static get<Default extends string | undefined = undefined>(key: EnvKeyInput, def?: Default): ConditionalReturn<string, Default>;
|
|
16
17
|
/**
|
|
@@ -21,6 +22,7 @@ declare class PrimitiveMethods extends EnvironmentMethods {
|
|
|
21
22
|
* Get a number environment variable with optional fallback.
|
|
22
23
|
* Automatically converts string values to numbers.
|
|
23
24
|
* Accepts a single key or an ordered array of keys (first match wins).
|
|
25
|
+
* @see {@link https://envapt.materwelon.dev/docs/envapter#primitives}
|
|
24
26
|
*/
|
|
25
27
|
static getNumber<Default extends number | undefined = undefined>(key: EnvKeyInput, def?: Default): ConditionalReturn<number, Default>;
|
|
26
28
|
/**
|
|
@@ -31,6 +33,7 @@ declare class PrimitiveMethods extends EnvironmentMethods {
|
|
|
31
33
|
* Get a boolean environment variable with optional fallback.
|
|
32
34
|
* Recognizes: `1`, `yes`, `true`, `on` as **true**; `0`, `no`, `false`, `off` as **false** (case-insensitive).
|
|
33
35
|
* Accepts a single key or an ordered array of keys (first match wins).
|
|
36
|
+
* @see {@link https://envapt.materwelon.dev/docs/envapter#primitives}
|
|
34
37
|
*/
|
|
35
38
|
static getBoolean<Default extends boolean | undefined = undefined>(key: EnvKeyInput, def?: Default): ConditionalReturn<boolean, Default>;
|
|
36
39
|
/**
|
|
@@ -41,6 +44,7 @@ declare class PrimitiveMethods extends EnvironmentMethods {
|
|
|
41
44
|
* Get a bigint environment variable with optional fallback.
|
|
42
45
|
* Automatically converts string values to bigint.
|
|
43
46
|
* Accepts a single key or an ordered array of keys (first match wins).
|
|
47
|
+
* @see {@link https://envapt.materwelon.dev/docs/envapter#primitives}
|
|
44
48
|
*/
|
|
45
49
|
static getBigInt<Default extends bigint | undefined = undefined>(key: EnvKeyInput, def?: Default): ConditionalReturn<bigint, Default>;
|
|
46
50
|
/**
|
|
@@ -51,6 +55,7 @@ declare class PrimitiveMethods extends EnvironmentMethods {
|
|
|
51
55
|
* Get a symbol environment variable with optional fallback.
|
|
52
56
|
* Creates a symbol from the string value.
|
|
53
57
|
* Accepts a single key or an ordered array of keys (first match wins).
|
|
58
|
+
* @see {@link https://envapt.materwelon.dev/docs/envapter#primitives}
|
|
54
59
|
*/
|
|
55
60
|
static getSymbol<Default extends symbol | undefined = undefined>(key: EnvKeyInput, def?: Default): ConditionalReturn<symbol, Default>;
|
|
56
61
|
/**
|
|
@@ -6,18 +6,21 @@ import { EnvaptFieldDecorator } from "../../types/Decorator.mjs";
|
|
|
6
6
|
/**
|
|
7
7
|
* Shorthand for `@Envapt(key, { converter: Converters.Boolean, fallback })`.
|
|
8
8
|
* @public
|
|
9
|
+
* @see {@link https://envapt.materwelon.dev/docs/decorators#shorthand-decorators}
|
|
9
10
|
*/
|
|
10
11
|
declare function EnvBool(key: EnvKeyInput, fallback: boolean): EnvaptFieldDecorator<boolean>;
|
|
11
12
|
declare function EnvBool(key: EnvKeyInput): EnvaptFieldDecorator<boolean | null>;
|
|
12
13
|
/**
|
|
13
14
|
* Shorthand for `@Envapt(key, { converter: Converters.Number, fallback })`.
|
|
14
15
|
* @public
|
|
16
|
+
* @see {@link https://envapt.materwelon.dev/docs/decorators#shorthand-decorators}
|
|
15
17
|
*/
|
|
16
18
|
declare function EnvNum(key: EnvKeyInput, fallback: number): EnvaptFieldDecorator<number>;
|
|
17
19
|
declare function EnvNum(key: EnvKeyInput): EnvaptFieldDecorator<number | null>;
|
|
18
20
|
/**
|
|
19
21
|
* Shorthand for `@Envapt(key, { converter: Converters.String, fallback })`.
|
|
20
22
|
* @public
|
|
23
|
+
* @see {@link https://envapt.materwelon.dev/docs/decorators#shorthand-decorators}
|
|
21
24
|
*/
|
|
22
25
|
declare function EnvStr(key: EnvKeyInput, fallback: string): EnvaptFieldDecorator<string>;
|
|
23
26
|
declare function EnvStr(key: EnvKeyInput): EnvaptFieldDecorator<string | null>;
|
|
@@ -25,6 +28,7 @@ declare function EnvStr(key: EnvKeyInput): EnvaptFieldDecorator<string | null>;
|
|
|
25
28
|
* Shorthand for `@Envapt(key, { converter: Converters.Time, fallback })`. The fallback is a
|
|
26
29
|
* millisecond number or a time string (`'15m'`), and the resolved value is always milliseconds.
|
|
27
30
|
* @public
|
|
31
|
+
* @see {@link https://envapt.materwelon.dev/docs/decorators#shorthand-decorators}
|
|
28
32
|
*/
|
|
29
33
|
declare function EnvTime(key: EnvKeyInput, fallback: TimeFallback): EnvaptFieldDecorator<number>;
|
|
30
34
|
declare function EnvTime(key: EnvKeyInput): EnvaptFieldDecorator<number | null>;
|
|
@@ -32,6 +36,7 @@ declare function EnvTime(key: EnvKeyInput): EnvaptFieldDecorator<number | null>;
|
|
|
32
36
|
* Shorthand for `@Envapt(key, { converter: Converters.Url, fallback })`. The fallback is a `URL`
|
|
33
37
|
* instance, not a URL string.
|
|
34
38
|
* @public
|
|
39
|
+
* @see {@link https://envapt.materwelon.dev/docs/decorators#shorthand-decorators}
|
|
35
40
|
*/
|
|
36
41
|
declare function EnvUrl(key: EnvKeyInput, fallback: URL): EnvaptFieldDecorator<URL>;
|
|
37
42
|
declare function EnvUrl(key: EnvKeyInput): EnvaptFieldDecorator<URL | null>;
|
|
@@ -6,18 +6,21 @@ import { EnvaptAccessorDecorator } from "../../types/Decorator.mjs";
|
|
|
6
6
|
/**
|
|
7
7
|
* Shorthand for `@Envapt(key, { converter: Converters.Boolean, fallback })`.
|
|
8
8
|
* @public
|
|
9
|
+
* @see {@link https://envapt.materwelon.dev/docs/decorators#shorthand-decorators}
|
|
9
10
|
*/
|
|
10
11
|
declare function EnvBool(key: EnvKeyInput, fallback: boolean): EnvaptAccessorDecorator<boolean>;
|
|
11
12
|
declare function EnvBool(key: EnvKeyInput): EnvaptAccessorDecorator<boolean | null>;
|
|
12
13
|
/**
|
|
13
14
|
* Shorthand for `@Envapt(key, { converter: Converters.Number, fallback })`.
|
|
14
15
|
* @public
|
|
16
|
+
* @see {@link https://envapt.materwelon.dev/docs/decorators#shorthand-decorators}
|
|
15
17
|
*/
|
|
16
18
|
declare function EnvNum(key: EnvKeyInput, fallback: number): EnvaptAccessorDecorator<number>;
|
|
17
19
|
declare function EnvNum(key: EnvKeyInput): EnvaptAccessorDecorator<number | null>;
|
|
18
20
|
/**
|
|
19
21
|
* Shorthand for `@Envapt(key, { converter: Converters.String, fallback })`.
|
|
20
22
|
* @public
|
|
23
|
+
* @see {@link https://envapt.materwelon.dev/docs/decorators#shorthand-decorators}
|
|
21
24
|
*/
|
|
22
25
|
declare function EnvStr(key: EnvKeyInput, fallback: string): EnvaptAccessorDecorator<string>;
|
|
23
26
|
declare function EnvStr(key: EnvKeyInput): EnvaptAccessorDecorator<string | null>;
|
|
@@ -25,6 +28,7 @@ declare function EnvStr(key: EnvKeyInput): EnvaptAccessorDecorator<string | null
|
|
|
25
28
|
* Shorthand for `@Envapt(key, { converter: Converters.Time, fallback })`. The fallback is a
|
|
26
29
|
* millisecond number or a time string (`'15m'`), and the resolved value is always milliseconds.
|
|
27
30
|
* @public
|
|
31
|
+
* @see {@link https://envapt.materwelon.dev/docs/decorators#shorthand-decorators}
|
|
28
32
|
*/
|
|
29
33
|
declare function EnvTime(key: EnvKeyInput, fallback: TimeFallback): EnvaptAccessorDecorator<number>;
|
|
30
34
|
declare function EnvTime(key: EnvKeyInput): EnvaptAccessorDecorator<number | null>;
|
|
@@ -32,6 +36,7 @@ declare function EnvTime(key: EnvKeyInput): EnvaptAccessorDecorator<number | nul
|
|
|
32
36
|
* Shorthand for `@Envapt(key, { converter: Converters.Url, fallback })`. The fallback is a `URL`
|
|
33
37
|
* instance, not a URL string.
|
|
34
38
|
* @public
|
|
39
|
+
* @see {@link https://envapt.materwelon.dev/docs/decorators#shorthand-decorators}
|
|
35
40
|
*/
|
|
36
41
|
declare function EnvUrl(key: EnvKeyInput, fallback: URL): EnvaptAccessorDecorator<URL>;
|
|
37
42
|
declare function EnvUrl(key: EnvKeyInput): EnvaptAccessorDecorator<URL | null>;
|
|
@@ -40,6 +40,7 @@ declare class Envapter extends AdvancedMethods {
|
|
|
40
40
|
* const message = Envapter.resolve`Service endpoint: ${'API_URL'}`;
|
|
41
41
|
* // Returns: "Service endpoint: https://api.example.com:8080"
|
|
42
42
|
* ```
|
|
43
|
+
* @see {@link https://envapt.materwelon.dev/docs/templates#the-resolve-tagged-template}
|
|
43
44
|
*/
|
|
44
45
|
static resolve(strings: TemplateStringsArray, ...keys: string[]): string;
|
|
45
46
|
/**
|
|
@@ -47,8 +48,9 @@ declare class Envapter extends AdvancedMethods {
|
|
|
47
48
|
*/
|
|
48
49
|
resolve(strings: TemplateStringsArray, ...keys: string[]): string;
|
|
49
50
|
/**
|
|
50
|
-
* Assert that one or more environment variables are present and non-empty
|
|
51
|
-
*
|
|
51
|
+
* Assert that one or more environment variables are present and non-empty after template
|
|
52
|
+
* resolution. Throws `MissingEnvValue` listing every missing key. A whitespace-only value
|
|
53
|
+
* counts as missing only under strict mode.
|
|
52
54
|
*
|
|
53
55
|
* For a typed required read in functional code, use `Envapter.getRequired(key, converter)`.
|
|
54
56
|
*
|
|
@@ -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 {
|
|
@@ -42,6 +39,8 @@ interface ConverterMap {
|
|
|
42
39
|
regexp: RegExp;
|
|
43
40
|
date: Date;
|
|
44
41
|
time: number;
|
|
42
|
+
port: number;
|
|
43
|
+
email: string;
|
|
45
44
|
}
|
|
46
45
|
type BuiltInConverterReturnType<ConverterKey extends BuiltInConverter> = ConverterMap[ConverterKey];
|
|
47
46
|
/**
|
|
@@ -52,6 +51,7 @@ type TimeUnit = 'ms' | 's' | 'm' | 'h' | 'd' | 'w';
|
|
|
52
51
|
/**
|
|
53
52
|
* Fallback type for time duration conversions
|
|
54
53
|
* @public
|
|
54
|
+
* @see {@link https://envapt.materwelon.dev/docs/converters#time-and-durations}
|
|
55
55
|
*/
|
|
56
56
|
type TimeFallback = number | `${number}${TimeUnit}`;
|
|
57
57
|
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
|