envapt 8.0.0-next.3 → 8.1.0-next.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +26 -36
- 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/portable/engine/Envapter.mjs +1 -1
- package/dist/portable/engine/Envapter.mjs.map +1 -1
- package/dist/types/engine/Envapter.d.mts +18 -0
- package/package.json +11 -8
package/CHANGELOG.md
CHANGED
|
@@ -1,28 +1,27 @@
|
|
|
1
1
|
# envapt
|
|
2
2
|
|
|
3
|
-
## 8.
|
|
3
|
+
## 8.1.0-next.0
|
|
4
4
|
|
|
5
|
-
###
|
|
5
|
+
### Minor Changes
|
|
6
6
|
|
|
7
|
-
-
|
|
7
|
+
- 8d99963: Add `Envapter.has(key)`, a boolean presence check that mirrors `getRequired`'s missing semantics, true exactly when a required read of the same key finds a value. Templates resolve first, empty counts as missing, and whitespace-only counts as missing only under strict mode.
|
|
8
8
|
|
|
9
|
-
## 8.0.0
|
|
9
|
+
## 8.0.0
|
|
10
10
|
|
|
11
11
|
### Major Changes
|
|
12
12
|
|
|
13
|
-
-
|
|
14
|
-
|
|
15
|
-
### Minor Changes
|
|
13
|
+
- Add `getRequired(key, converter)` and `getRequiredAll(spec, casing?)` for typed required reads. `getRequired` takes the converter positionally, returns the non-undefined value, and throws `MissingEnvValue` on a missing, empty, or unconvertible value. `getRequiredAll` reads a group in one call and returns a typed record, throwing once listing every missing key. Its spec values can be tokens, `array()` tokens, or custom parser functions, and an optional `casing` (`'camelCase'`, `'PascalCase'`, or `'kebab-case'`) renames the record keys.
|
|
16
14
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
`Converters.Email` validates with the WHATWG `input[type=email]` pattern and returns the address unchanged. `Converters.Port` accepts an integer in the `0-65535` range, including `0` for ephemeral binding. Both fall back on invalid input, throw under `getRequired`, and compose inside `Converters.array`.
|
|
15
|
+
**BREAKING:** the `{ required: true }` options-bag form of `getUsing` and `getWith` is removed, use `getRequired` instead. The `@Envapt` decorator's `{ required: true }` option is unchanged.
|
|
20
16
|
|
|
21
|
-
|
|
17
|
+
- Return `undefined` for a missing read with no fallback across every reader, including the decorators and converter dispatch that returned `null` before. No-fallback decorator field types drop `| null`, so retype such fields to `| undefined`. `getWith` now runs its custom converter on a missing key with `raw` as `undefined`. An explicit `undefined` fallback counts as no fallback everywhere, so `Envapter.parse(key, schema, undefined)` throws `MissingEnvValue`.
|
|
18
|
+
- Move the engine's mutable state and read cache into a module that the `exports` map does not include. They are no longer fields on the class and have no import path, so outside code cannot read or write them through an `as`-cast or a subclass. Drop the internal `TimeUnit` type and `isStrict()` method from the public exports.
|
|
19
|
+
- **BREAKING:** Tighten the `Integer` and `Float` converters.
|
|
22
20
|
|
|
23
|
-
|
|
21
|
+
`Converters.Integer` parses with `Number` and requires `Number.isSafeInteger`, so trailing characters (`42abc`), non-integers (`3.9`), and values past 2^53 now fall back. `Converters.Float` parses with `Number`, so trailing characters (`3.14xyz`) now fall back. `Float` still accepts `Infinity`.
|
|
24
22
|
|
|
25
|
-
-
|
|
23
|
+
- Trim internal-only exports out of the public API surface, from 36 exported types down to a small core. Gone are the source shape interfaces, the decorator return types, the schema brands, the converter and inference machinery (including the `ConverterToken` and `EnvaptConverter` aliases), the `isArrayOf` guard, the `EnvKeyInput`/`ArrayOf`/`ArrayElement` helpers, and the redundant `InferSchemaInput`/`InferSchemaOutput` aliases. Type inference on the readers and decorators is unchanged, since these types are inferred at the call site or reproducible from the still-public `Source` and `StandardSchemaV1`. For a schema's output type, use your validator's own inference (`z.infer`, valibot's `InferOutput`, arktype's `.infer`) or `StandardSchemaV1.InferOutput`.
|
|
24
|
+
- Unify the rule for when an environment value counts as missing, and use it in every read path, with the global `strict` flag as its only knob.
|
|
26
25
|
|
|
27
26
|
A value is missing when it is unset or an empty string (always), and additionally when it is whitespace-only under `Envapter.strict = true`. This one rule now applies to ordered-key reads, `getRequired` / `getRequiredAll`, `Envapter.require`, the `@Envapt({ required: true })` decorator, environment detection, and `${VAR}` template resolution, so their behavior stays consistent.
|
|
28
27
|
|
|
@@ -34,39 +33,30 @@
|
|
|
34
33
|
|
|
35
34
|
Set `Envapter.strict = true` for the old whitespace-is-blank behavior.
|
|
36
35
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
- 60ba358: Under `Envapter.debug = 'verbose'`, log when a present value cannot be parsed by a built-in converter and the read falls back to its default. This surfaces a malformed value (for example a non-numeric `PORT`) that would otherwise fall back silently.
|
|
40
|
-
- 5be3e5c: Add `@see` links to the docs site on the public API TSDoc, so hovering a reader, converter, source, decorator, or error in an editor links to its documentation page.
|
|
41
|
-
|
|
42
|
-
## 8.0.0-next.0
|
|
43
|
-
|
|
44
|
-
### Major Changes
|
|
45
|
-
|
|
46
|
-
- f889a67: Add `getRequired(key, converter)` and `getRequiredAll(spec, casing?)` for typed required reads. `getRequired` takes the converter positionally, returns the non-undefined value, and throws `MissingEnvValue` on a missing or empty key. `getRequiredAll` reads a group in one call and returns a typed record, throwing once listing every missing key. Its spec values can be tokens, `array()` tokens, or custom parser functions, and an optional `casing` (`'camelCase'`, `'PascalCase'`, or `'kebab-case'`) renames the record keys.
|
|
47
|
-
|
|
48
|
-
**BREAKING:** the `{ required: true }` options-bag form of `getUsing` and `getWith` is removed, use `getRequired` instead. The `@Envapt` decorator's `{ required: true }` option is unchanged.
|
|
49
|
-
|
|
50
|
-
- 5e02661: Move the engine's mutable state and read cache into a module that the `exports` map does not include. They are no longer fields on the class and have no import path, so outside code cannot read or write them through an `as`-cast or a subclass. Drop the internal `TimeUnit` type and `isStrict()` method from the public exports.
|
|
51
|
-
- 651008e: **BREAKING:** Tighten the `Integer` and `Float` converters.
|
|
52
|
-
|
|
53
|
-
`Converters.Integer` parses with `Number` and requires `Number.isSafeInteger`, so trailing characters (`42abc`), non-integers (`3.9`), and values past 2^53 now fall back. `Converters.Float` parses with `Number`, so trailing characters (`3.14xyz`) now fall back. `Float` still accepts `Infinity`.
|
|
54
|
-
|
|
55
|
-
- d415d68: Trim internal-only types out of the public API surface, from 36 exported types down to 15. Gone are the source shape interfaces, the decorator return types, the schema brands, the converter/inference machinery, the `EnvKeyInput`/`ArrayOf`/`ArrayElement` helpers, and the redundant `InferSchemaInput`/`InferSchemaOutput` aliases. Type inference on the readers and decorators is unchanged, since these types are inferred at the call site or reproducible from the still-public `Source` and `StandardSchemaV1`. For a schema's output type, use your validator's own inference (`z.infer`, valibot's `InferOutput`, arktype's `.infer`) or `StandardSchemaV1.InferOutput`.
|
|
56
|
-
- d415d68: Collapse to one portable build and a single universal `envapt` import, and rename the source classes. Three breaking changes.
|
|
36
|
+
- Collapse to one portable build and a single universal `envapt` import, and rename the source classes. Three breaking changes.
|
|
57
37
|
|
|
58
38
|
1. The source classes drop the `Env` infix. `PortableSource` (was `ManualEnvSource` / `WorkerEnvSource`, which were the same class) is the one source for every runtime without a filesystem. `FileSource` (was `NodeEnvSource`) is the Node source. The `Source` type replaces `EnvSource`. The v7.1 deprecated aliases are removed.
|
|
59
39
|
2. `Envapter.fileApiMode` defaults to `'warn'`. On the portable build the file-only config APIs (`envPaths`, `baseDir`, `envFileOptions`, `configureProfiles`, `resetProfiles`) now warn once and no-op by default. Set `Envapter.fileApiMode = 'throw'` to restore the previous throwing behavior. An unconfigured read still throws `NoSourceBound` on first access.
|
|
60
40
|
3. The `envapt/workerd` and `envapt/browser` subpaths are removed. Import from `envapt` everywhere. The package exports route Workers, the browser, and the edge runtimes (workerd, edge-light, fastly, worker, browser, react-native) to the portable build, and Node, Bun, and Deno to the node build. The portable types now include the file APIs, so config shared between dev and deploy compiles on every runtime.
|
|
61
41
|
|
|
42
|
+
- A built-in converter fallback must now be a value the converter would accept. One of the correct type but an invalid value throws `FallbackConverterTypeMismatch`: an out-of-range `Port`, a `NaN` `Number` or `Float`, a non-safe-integer `Integer`, an `Invalid Date`, or an `Email` that is not a valid address. Pass a valid fallback or omit it.
|
|
43
|
+
|
|
62
44
|
### Minor Changes
|
|
63
45
|
|
|
64
|
-
-
|
|
46
|
+
- Add the `Email` and `Port` converters.
|
|
47
|
+
|
|
48
|
+
`Converters.Email` validates with the WHATWG `input[type=email]` pattern and returns the address unchanged. `Converters.Port` accepts an integer in the `0-65535` range, including `0` for ephemeral binding. Both fall back on invalid input, throw under `getRequired`, and compose inside `Converters.array`.
|
|
49
|
+
|
|
50
|
+
- Add `merge`, a source combinator that layers several sources with last-wins precedence. It keeps the `.env` cascade and file APIs on one filesystem-backed member, and throws `InvalidMergedSource` with no members or more than one file-backed member.
|
|
51
|
+
|
|
52
|
+
`useSource` and `merge` also accept a reader function `(key) => string | undefined` as a source, for a runtime that reads one key at a time and cannot list its keys. envapt calls the reader on a cache miss and caches the result.
|
|
65
53
|
|
|
66
54
|
### Patch Changes
|
|
67
55
|
|
|
68
|
-
-
|
|
69
|
-
-
|
|
56
|
+
- Under `Envapter.debug = 'verbose'`, log when a present value cannot be parsed by a built-in converter and the read falls back to its default. This surfaces a malformed value (for example a non-numeric `PORT`) that would otherwise fall back silently.
|
|
57
|
+
- Fix the read cache rebuilding on every access when a bound source and the `.env` cascade resolve to no keys. It now builds once per `useSource`, matching a non-empty source.
|
|
58
|
+
- Move the engine read-path into module functions under core/ so a consumer subclass can no longer reach or mutate the read cache. No public API change.
|
|
59
|
+
- Add `@see` links to the docs site on the public API TSDoc, so hovering a reader, converter, source, decorator, or error in an editor links to its documentation page.
|
|
70
60
|
|
|
71
61
|
## 7.1.0
|
|
72
62
|
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const e=require("../infra/Error.cjs");require("../core/Environment.cjs");const t=require("../core/engine.cjs"),n=require("../core/AdvancedMethods.cjs");var r=class r extends n.AdvancedMethods{static resolve(t,...n){let i=r.strict;return t.reduce((t,r,a)=>{let o=n[a];if(!o)return t+r;let s=super.get(o,``);if(i&&s.trim()===``)throw new e.EnvaptError(305,`Cannot resolve template variable "\${${o}}": value is missing or empty.`);return t+r+s},``)}resolve(e,...t){return r.resolve(e,...t)}static require(...r){let i=r.filter(e=>n.resolveRequired(t.resolveKeyInput(e),t.templateResolver).value===void 0);if(i.length>0)throw new e.EnvaptError(305,`Missing required environment variables: ${i.join(`, `)}.`)}require(...e){r.require(...e)}};exports.Envapter=r;
|
|
1
|
+
const e=require("../infra/Error.cjs");require("../core/Environment.cjs");const t=require("../core/engine.cjs"),n=require("../core/AdvancedMethods.cjs");var r=class r extends n.AdvancedMethods{static resolve(t,...n){let i=r.strict;return t.reduce((t,r,a)=>{let o=n[a];if(!o)return t+r;let s=super.get(o,``);if(i&&s.trim()===``)throw new e.EnvaptError(305,`Cannot resolve template variable "\${${o}}": value is missing or empty.`);return t+r+s},``)}resolve(e,...t){return r.resolve(e,...t)}static require(...r){let i=r.filter(e=>n.resolveRequired(t.resolveKeyInput(e),t.templateResolver).value===void 0);if(i.length>0)throw new e.EnvaptError(305,`Missing required environment variables: ${i.join(`, `)}.`)}require(...e){r.require(...e)}static has(r){try{return n.resolveRequired(t.resolveKeyInput(r),t.templateResolver).value!==void 0}catch(t){if(t instanceof e.EnvaptError&&t.code===305)return!1;throw t}}has(e){return r.has(e)}};exports.Envapter=r;
|
|
2
2
|
//# sourceMappingURL=Envapter.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Envapter.cjs","names":["AdvancedMethods","EnvaptError","resolveRequired","resolveKeyInput","templateResolver"],"sources":["../../../src/engine/Envapter.ts"],"sourcesContent":["import { AdvancedMethods } from '../core';\nimport { resolveRequired } from '../core/AdvancedMethods';\nimport { resolveKeyInput, templateResolver } from '../core/engine';\nimport { EnvaptError, EnvaptErrorCodes } from '../infra/Error';\n\nexport { Environment } from '../core';\n\n/**\n * Main configuration class for environment variable management.\n *\n * Provides both static and instance methods for retrieving typed environment variables\n * with support for template resolution, multiple .env files, and environment detection.\n *\n * Extend your own classes from this to define properties with \\@Envapt decorators and get access to environment-variable methods.\n *\n * @example\n * ```ts\n * // Static usage\n * const port = Envapter.getNumber('PORT', 3000);\n * const url = Envapter.get('API_URL', 'http://localhost');\n * const replica = Envapter.get(['READONLY_URL', 'DATABASE_URL'], 'sqlite://memory');\n *\n * // Instance usage\n * const env = new Envapter();\n * const dbUrl = env.get('DATABASE_URL', 'sqlite://memory');\n * const primaryHost = env.get(['PRIMARY_HOST', 'SECONDARY_HOST']);\n * ```\n *\n * @public\n */\nexport class Envapter extends AdvancedMethods {\n /**\n * Tagged template literal for resolving environment variables in template strings.\n *\n * @example\n * ```ts\n * // Given API_HOST=api.example.com and API_PORT=8080 in environment\n * const endpoint = Envapter.resolve`Connecting to ${'API_HOST'}:${'API_PORT'}`;\n * // Returns: \"Connecting to api.example.com:8080\"\n *\n * // Works with template variables in .env too:\n * // API_URL=https://${API_HOST}:${API_PORT}\n * const message = Envapter.resolve`Service endpoint: ${'API_URL'}`;\n * // Returns: \"Service endpoint: https://api.example.com:8080\"\n * ```\n * @see {@link https://envapt.materwelon.dev/docs/templates#the-resolve-tagged-template}\n */\n static resolve(strings: TemplateStringsArray, ...keys: string[]): string {\n const strict = Envapter.strict;\n return strings.reduce((result, string, i) => {\n const envKey = keys[i];\n if (!envKey) return result + string;\n const raw = super.get(envKey, '');\n if (strict && raw.trim() === '') {\n throw new EnvaptError(\n EnvaptErrorCodes.MissingEnvValue,\n `Cannot resolve template variable \"\\${${envKey}}\": value is missing or empty.`\n );\n }\n return result + string + raw;\n }, '');\n }\n\n /**\n * @see {@link Envapter.resolve}\n */\n resolve(strings: TemplateStringsArray, ...keys: string[]): string {\n return Envapter.resolve(strings, ...keys);\n }\n\n /**\n * Assert that one or more environment variables are present and non-empty after template\n * resolution. Throws `MissingEnvValue` listing every missing key. A whitespace-only value\n * counts as missing only under strict mode.\n *\n * For a typed required read in functional code, use `Envapter.getRequired(key, converter)`.\n *\n * @example\n * ```ts\n * Envapter.require('DATABASE_URL');\n * Envapter.require('DATABASE_URL', 'API_KEY', 'SENTRY_DSN');\n * ```\n */\n static require(...keys: [string, ...string[]]): void {\n const missing = keys.filter((k) => resolveRequired(resolveKeyInput(k), templateResolver).value === undefined);\n\n if (missing.length > 0) {\n throw new EnvaptError(\n EnvaptErrorCodes.MissingEnvValue,\n `Missing required environment variables: ${missing.join(', ')}.`\n );\n }\n }\n\n /**\n * @see {@link Envapter.require}\n */\n require(...keys: [string, ...string[]]): void {\n Envapter.require(...keys);\n }\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"Envapter.cjs","names":["AdvancedMethods","EnvaptError","resolveRequired","resolveKeyInput","templateResolver"],"sources":["../../../src/engine/Envapter.ts"],"sourcesContent":["import { AdvancedMethods } from '../core';\nimport { resolveRequired } from '../core/AdvancedMethods';\nimport { resolveKeyInput, templateResolver } from '../core/engine';\nimport { EnvaptError, EnvaptErrorCodes } from '../infra/Error';\n\nimport type { EnvKeyInput } from '../types';\n\nexport { Environment } from '../core';\n\n/**\n * Main configuration class for environment variable management.\n *\n * Provides both static and instance methods for retrieving typed environment variables\n * with support for template resolution, multiple .env files, and environment detection.\n *\n * Extend your own classes from this to define properties with \\@Envapt decorators and get access to environment-variable methods.\n *\n * @example\n * ```ts\n * // Static usage\n * const port = Envapter.getNumber('PORT', 3000);\n * const url = Envapter.get('API_URL', 'http://localhost');\n * const replica = Envapter.get(['READONLY_URL', 'DATABASE_URL'], 'sqlite://memory');\n *\n * // Instance usage\n * const env = new Envapter();\n * const dbUrl = env.get('DATABASE_URL', 'sqlite://memory');\n * const primaryHost = env.get(['PRIMARY_HOST', 'SECONDARY_HOST']);\n * ```\n *\n * @public\n */\nexport class Envapter extends AdvancedMethods {\n /**\n * Tagged template literal for resolving environment variables in template strings.\n *\n * @example\n * ```ts\n * // Given API_HOST=api.example.com and API_PORT=8080 in environment\n * const endpoint = Envapter.resolve`Connecting to ${'API_HOST'}:${'API_PORT'}`;\n * // Returns: \"Connecting to api.example.com:8080\"\n *\n * // Works with template variables in .env too:\n * // API_URL=https://${API_HOST}:${API_PORT}\n * const message = Envapter.resolve`Service endpoint: ${'API_URL'}`;\n * // Returns: \"Service endpoint: https://api.example.com:8080\"\n * ```\n * @see {@link https://envapt.materwelon.dev/docs/templates#the-resolve-tagged-template}\n */\n static resolve(strings: TemplateStringsArray, ...keys: string[]): string {\n const strict = Envapter.strict;\n return strings.reduce((result, string, i) => {\n const envKey = keys[i];\n if (!envKey) return result + string;\n const raw = super.get(envKey, '');\n if (strict && raw.trim() === '') {\n throw new EnvaptError(\n EnvaptErrorCodes.MissingEnvValue,\n `Cannot resolve template variable \"\\${${envKey}}\": value is missing or empty.`\n );\n }\n return result + string + raw;\n }, '');\n }\n\n /**\n * @see {@link Envapter.resolve}\n */\n resolve(strings: TemplateStringsArray, ...keys: string[]): string {\n return Envapter.resolve(strings, ...keys);\n }\n\n /**\n * Assert that one or more environment variables are present and non-empty after template\n * resolution. Throws `MissingEnvValue` listing every missing key. A whitespace-only value\n * counts as missing only under strict mode.\n *\n * For a typed required read in functional code, use `Envapter.getRequired(key, converter)`.\n *\n * @example\n * ```ts\n * Envapter.require('DATABASE_URL');\n * Envapter.require('DATABASE_URL', 'API_KEY', 'SENTRY_DSN');\n * ```\n */\n static require(...keys: [string, ...string[]]): void {\n const missing = keys.filter((k) => resolveRequired(resolveKeyInput(k), templateResolver).value === undefined);\n\n if (missing.length > 0) {\n throw new EnvaptError(\n EnvaptErrorCodes.MissingEnvValue,\n `Missing required environment variables: ${missing.join(', ')}.`\n );\n }\n }\n\n /**\n * @see {@link Envapter.require}\n */\n require(...keys: [string, ...string[]]): void {\n Envapter.require(...keys);\n }\n\n /**\n * Check whether `key` has a value, with the same missing semantics as `getRequired`.\n * Under strict mode an unresolvable template in an ordered key list ends the scan early\n * and counts as absent. Returns `true` exactly when a required read of the same key\n * finds a value.\n *\n * @example\n * ```ts\n * if (!Envapter.has('DATABASE_URL')) throw new MyStartupError('DATABASE_URL');\n * ```\n * @see {@link https://envapt.materwelon.dev/docs/envapter#fail-fast-on-missing-values}\n */\n static has(key: EnvKeyInput): boolean {\n try {\n return resolveRequired(resolveKeyInput(key), templateResolver).value !== undefined;\n } catch (error) {\n // under strict an unresolvable template throws MissingEnvValue, and that read counts as absent\n if (error instanceof EnvaptError && error.code === EnvaptErrorCodes.MissingEnvValue) return false;\n throw error;\n }\n }\n\n /**\n * @see {@link Envapter.has}\n */\n has(key: EnvKeyInput): boolean {\n return Envapter.has(key);\n }\n}\n"],"mappings":"wJAgCA,IAAa,EAAb,MAAa,UAAiBA,EAAAA,eAAgB,CAiB1C,OAAO,QAAQ,EAA+B,GAAG,EAAwB,CACrE,IAAM,EAAS,EAAS,OACxB,OAAO,EAAQ,QAAQ,EAAQ,EAAQ,IAAM,CACzC,IAAM,EAAS,EAAK,GACpB,GAAI,CAAC,EAAQ,OAAO,EAAS,EAC7B,IAAM,EAAM,MAAM,IAAI,EAAQ,EAAE,EAChC,GAAI,GAAU,EAAI,KAAK,IAAM,GACzB,MAAM,IAAIC,EAAAA,YAAAA,IAEN,wCAAwC,EAAO,+BACnD,EAEJ,OAAO,EAAS,EAAS,CAC7B,EAAG,EAAE,CACT,CAKA,QAAQ,EAA+B,GAAG,EAAwB,CAC9D,OAAO,EAAS,QAAQ,EAAS,GAAG,CAAI,CAC5C,CAeA,OAAO,QAAQ,GAAG,EAAmC,CACjD,IAAM,EAAU,EAAK,OAAQ,GAAMC,EAAAA,gBAAgBC,EAAAA,gBAAgB,CAAC,EAAGC,EAAAA,gBAAgB,CAAC,CAAC,QAAU,IAAA,EAAS,EAE5G,GAAI,EAAQ,OAAS,EACjB,MAAM,IAAIH,EAAAA,YAAAA,IAEN,2CAA2C,EAAQ,KAAK,IAAI,EAAE,EAClE,CAER,CAKA,QAAQ,GAAG,EAAmC,CAC1C,EAAS,QAAQ,GAAG,CAAI,CAC5B,CAcA,OAAO,IAAI,EAA2B,CAClC,GAAI,CACA,OAAOC,EAAAA,gBAAgBC,EAAAA,gBAAgB,CAAG,EAAGC,EAAAA,gBAAgB,CAAC,CAAC,QAAU,IAAA,EAC7E,OAAS,EAAO,CAEZ,GAAI,aAAiBH,EAAAA,aAAe,EAAM,OAAA,IAA2C,MAAO,GAC5F,MAAM,CACV,CACJ,CAKA,IAAI,EAA2B,CAC3B,OAAO,EAAS,IAAI,CAAG,CAC3B,CACJ"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{EnvaptError as e}from"../infra/Error.mjs";import"../core/Environment.mjs";import{resolveKeyInput as t,templateResolver as n}from"../core/engine.mjs";import{AdvancedMethods as r,resolveRequired as i}from"../core/AdvancedMethods.mjs";var a=class a extends r{static resolve(t,...n){let r=a.strict;return t.reduce((t,i,a)=>{let o=n[a];if(!o)return t+i;let s=super.get(o,``);if(r&&s.trim()===``)throw new e(305,`Cannot resolve template variable "\${${o}}": value is missing or empty.`);return t+i+s},``)}resolve(e,...t){return a.resolve(e,...t)}static require(...r){let a=r.filter(e=>i(t(e),n).value===void 0);if(a.length>0)throw new e(305,`Missing required environment variables: ${a.join(`, `)}.`)}require(...e){a.require(...e)}};export{a as Envapter};
|
|
1
|
+
import{EnvaptError as e}from"../infra/Error.mjs";import"../core/Environment.mjs";import{resolveKeyInput as t,templateResolver as n}from"../core/engine.mjs";import{AdvancedMethods as r,resolveRequired as i}from"../core/AdvancedMethods.mjs";var a=class a extends r{static resolve(t,...n){let r=a.strict;return t.reduce((t,i,a)=>{let o=n[a];if(!o)return t+i;let s=super.get(o,``);if(r&&s.trim()===``)throw new e(305,`Cannot resolve template variable "\${${o}}": value is missing or empty.`);return t+i+s},``)}resolve(e,...t){return a.resolve(e,...t)}static require(...r){let a=r.filter(e=>i(t(e),n).value===void 0);if(a.length>0)throw new e(305,`Missing required environment variables: ${a.join(`, `)}.`)}require(...e){a.require(...e)}static has(r){try{return i(t(r),n).value!==void 0}catch(t){if(t instanceof e&&t.code===305)return!1;throw t}}has(e){return a.has(e)}};export{a as Envapter};
|
|
2
2
|
//# sourceMappingURL=Envapter.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Envapter.mjs","names":[],"sources":["../../../src/engine/Envapter.ts"],"sourcesContent":["import { AdvancedMethods } from '../core';\nimport { resolveRequired } from '../core/AdvancedMethods';\nimport { resolveKeyInput, templateResolver } from '../core/engine';\nimport { EnvaptError, EnvaptErrorCodes } from '../infra/Error';\n\nexport { Environment } from '../core';\n\n/**\n * Main configuration class for environment variable management.\n *\n * Provides both static and instance methods for retrieving typed environment variables\n * with support for template resolution, multiple .env files, and environment detection.\n *\n * Extend your own classes from this to define properties with \\@Envapt decorators and get access to environment-variable methods.\n *\n * @example\n * ```ts\n * // Static usage\n * const port = Envapter.getNumber('PORT', 3000);\n * const url = Envapter.get('API_URL', 'http://localhost');\n * const replica = Envapter.get(['READONLY_URL', 'DATABASE_URL'], 'sqlite://memory');\n *\n * // Instance usage\n * const env = new Envapter();\n * const dbUrl = env.get('DATABASE_URL', 'sqlite://memory');\n * const primaryHost = env.get(['PRIMARY_HOST', 'SECONDARY_HOST']);\n * ```\n *\n * @public\n */\nexport class Envapter extends AdvancedMethods {\n /**\n * Tagged template literal for resolving environment variables in template strings.\n *\n * @example\n * ```ts\n * // Given API_HOST=api.example.com and API_PORT=8080 in environment\n * const endpoint = Envapter.resolve`Connecting to ${'API_HOST'}:${'API_PORT'}`;\n * // Returns: \"Connecting to api.example.com:8080\"\n *\n * // Works with template variables in .env too:\n * // API_URL=https://${API_HOST}:${API_PORT}\n * const message = Envapter.resolve`Service endpoint: ${'API_URL'}`;\n * // Returns: \"Service endpoint: https://api.example.com:8080\"\n * ```\n * @see {@link https://envapt.materwelon.dev/docs/templates#the-resolve-tagged-template}\n */\n static resolve(strings: TemplateStringsArray, ...keys: string[]): string {\n const strict = Envapter.strict;\n return strings.reduce((result, string, i) => {\n const envKey = keys[i];\n if (!envKey) return result + string;\n const raw = super.get(envKey, '');\n if (strict && raw.trim() === '') {\n throw new EnvaptError(\n EnvaptErrorCodes.MissingEnvValue,\n `Cannot resolve template variable \"\\${${envKey}}\": value is missing or empty.`\n );\n }\n return result + string + raw;\n }, '');\n }\n\n /**\n * @see {@link Envapter.resolve}\n */\n resolve(strings: TemplateStringsArray, ...keys: string[]): string {\n return Envapter.resolve(strings, ...keys);\n }\n\n /**\n * Assert that one or more environment variables are present and non-empty after template\n * resolution. Throws `MissingEnvValue` listing every missing key. A whitespace-only value\n * counts as missing only under strict mode.\n *\n * For a typed required read in functional code, use `Envapter.getRequired(key, converter)`.\n *\n * @example\n * ```ts\n * Envapter.require('DATABASE_URL');\n * Envapter.require('DATABASE_URL', 'API_KEY', 'SENTRY_DSN');\n * ```\n */\n static require(...keys: [string, ...string[]]): void {\n const missing = keys.filter((k) => resolveRequired(resolveKeyInput(k), templateResolver).value === undefined);\n\n if (missing.length > 0) {\n throw new EnvaptError(\n EnvaptErrorCodes.MissingEnvValue,\n `Missing required environment variables: ${missing.join(', ')}.`\n );\n }\n }\n\n /**\n * @see {@link Envapter.require}\n */\n require(...keys: [string, ...string[]]): void {\n Envapter.require(...keys);\n }\n}\n"],"mappings":"+
|
|
1
|
+
{"version":3,"file":"Envapter.mjs","names":[],"sources":["../../../src/engine/Envapter.ts"],"sourcesContent":["import { AdvancedMethods } from '../core';\nimport { resolveRequired } from '../core/AdvancedMethods';\nimport { resolveKeyInput, templateResolver } from '../core/engine';\nimport { EnvaptError, EnvaptErrorCodes } from '../infra/Error';\n\nimport type { EnvKeyInput } from '../types';\n\nexport { Environment } from '../core';\n\n/**\n * Main configuration class for environment variable management.\n *\n * Provides both static and instance methods for retrieving typed environment variables\n * with support for template resolution, multiple .env files, and environment detection.\n *\n * Extend your own classes from this to define properties with \\@Envapt decorators and get access to environment-variable methods.\n *\n * @example\n * ```ts\n * // Static usage\n * const port = Envapter.getNumber('PORT', 3000);\n * const url = Envapter.get('API_URL', 'http://localhost');\n * const replica = Envapter.get(['READONLY_URL', 'DATABASE_URL'], 'sqlite://memory');\n *\n * // Instance usage\n * const env = new Envapter();\n * const dbUrl = env.get('DATABASE_URL', 'sqlite://memory');\n * const primaryHost = env.get(['PRIMARY_HOST', 'SECONDARY_HOST']);\n * ```\n *\n * @public\n */\nexport class Envapter extends AdvancedMethods {\n /**\n * Tagged template literal for resolving environment variables in template strings.\n *\n * @example\n * ```ts\n * // Given API_HOST=api.example.com and API_PORT=8080 in environment\n * const endpoint = Envapter.resolve`Connecting to ${'API_HOST'}:${'API_PORT'}`;\n * // Returns: \"Connecting to api.example.com:8080\"\n *\n * // Works with template variables in .env too:\n * // API_URL=https://${API_HOST}:${API_PORT}\n * const message = Envapter.resolve`Service endpoint: ${'API_URL'}`;\n * // Returns: \"Service endpoint: https://api.example.com:8080\"\n * ```\n * @see {@link https://envapt.materwelon.dev/docs/templates#the-resolve-tagged-template}\n */\n static resolve(strings: TemplateStringsArray, ...keys: string[]): string {\n const strict = Envapter.strict;\n return strings.reduce((result, string, i) => {\n const envKey = keys[i];\n if (!envKey) return result + string;\n const raw = super.get(envKey, '');\n if (strict && raw.trim() === '') {\n throw new EnvaptError(\n EnvaptErrorCodes.MissingEnvValue,\n `Cannot resolve template variable \"\\${${envKey}}\": value is missing or empty.`\n );\n }\n return result + string + raw;\n }, '');\n }\n\n /**\n * @see {@link Envapter.resolve}\n */\n resolve(strings: TemplateStringsArray, ...keys: string[]): string {\n return Envapter.resolve(strings, ...keys);\n }\n\n /**\n * Assert that one or more environment variables are present and non-empty after template\n * resolution. Throws `MissingEnvValue` listing every missing key. A whitespace-only value\n * counts as missing only under strict mode.\n *\n * For a typed required read in functional code, use `Envapter.getRequired(key, converter)`.\n *\n * @example\n * ```ts\n * Envapter.require('DATABASE_URL');\n * Envapter.require('DATABASE_URL', 'API_KEY', 'SENTRY_DSN');\n * ```\n */\n static require(...keys: [string, ...string[]]): void {\n const missing = keys.filter((k) => resolveRequired(resolveKeyInput(k), templateResolver).value === undefined);\n\n if (missing.length > 0) {\n throw new EnvaptError(\n EnvaptErrorCodes.MissingEnvValue,\n `Missing required environment variables: ${missing.join(', ')}.`\n );\n }\n }\n\n /**\n * @see {@link Envapter.require}\n */\n require(...keys: [string, ...string[]]): void {\n Envapter.require(...keys);\n }\n\n /**\n * Check whether `key` has a value, with the same missing semantics as `getRequired`.\n * Under strict mode an unresolvable template in an ordered key list ends the scan early\n * and counts as absent. Returns `true` exactly when a required read of the same key\n * finds a value.\n *\n * @example\n * ```ts\n * if (!Envapter.has('DATABASE_URL')) throw new MyStartupError('DATABASE_URL');\n * ```\n * @see {@link https://envapt.materwelon.dev/docs/envapter#fail-fast-on-missing-values}\n */\n static has(key: EnvKeyInput): boolean {\n try {\n return resolveRequired(resolveKeyInput(key), templateResolver).value !== undefined;\n } catch (error) {\n // under strict an unresolvable template throws MissingEnvValue, and that read counts as absent\n if (error instanceof EnvaptError && error.code === EnvaptErrorCodes.MissingEnvValue) return false;\n throw error;\n }\n }\n\n /**\n * @see {@link Envapter.has}\n */\n has(key: EnvKeyInput): boolean {\n return Envapter.has(key);\n }\n}\n"],"mappings":"+OAgCA,IAAa,EAAb,MAAa,UAAiB,CAAgB,CAiB1C,OAAO,QAAQ,EAA+B,GAAG,EAAwB,CACrE,IAAM,EAAS,EAAS,OACxB,OAAO,EAAQ,QAAQ,EAAQ,EAAQ,IAAM,CACzC,IAAM,EAAS,EAAK,GACpB,GAAI,CAAC,EAAQ,OAAO,EAAS,EAC7B,IAAM,EAAM,MAAM,IAAI,EAAQ,EAAE,EAChC,GAAI,GAAU,EAAI,KAAK,IAAM,GACzB,MAAM,IAAI,EAAA,IAEN,wCAAwC,EAAO,+BACnD,EAEJ,OAAO,EAAS,EAAS,CAC7B,EAAG,EAAE,CACT,CAKA,QAAQ,EAA+B,GAAG,EAAwB,CAC9D,OAAO,EAAS,QAAQ,EAAS,GAAG,CAAI,CAC5C,CAeA,OAAO,QAAQ,GAAG,EAAmC,CACjD,IAAM,EAAU,EAAK,OAAQ,GAAM,EAAgB,EAAgB,CAAC,EAAG,CAAgB,CAAC,CAAC,QAAU,IAAA,EAAS,EAE5G,GAAI,EAAQ,OAAS,EACjB,MAAM,IAAI,EAAA,IAEN,2CAA2C,EAAQ,KAAK,IAAI,EAAE,EAClE,CAER,CAKA,QAAQ,GAAG,EAAmC,CAC1C,EAAS,QAAQ,GAAG,CAAI,CAC5B,CAcA,OAAO,IAAI,EAA2B,CAClC,GAAI,CACA,OAAO,EAAgB,EAAgB,CAAG,EAAG,CAAgB,CAAC,CAAC,QAAU,IAAA,EAC7E,OAAS,EAAO,CAEZ,GAAI,aAAiB,GAAe,EAAM,OAAA,IAA2C,MAAO,GAC5F,MAAM,CACV,CACJ,CAKA,IAAI,EAA2B,CAC3B,OAAO,EAAS,IAAI,CAAG,CAC3B,CACJ"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{EnvaptError as e}from"../infra/Error.mjs";import"../core/Environment.mjs";import{resolveKeyInput as t,templateResolver as n}from"../core/engine.mjs";import{AdvancedMethods as r,resolveRequired as i}from"../core/AdvancedMethods.mjs";var a=class a extends r{static resolve(t,...n){let r=a.strict;return t.reduce((t,i,a)=>{let o=n[a];if(!o)return t+i;let s=super.get(o,``);if(r&&s.trim()===``)throw new e(305,`Cannot resolve template variable "\${${o}}": value is missing or empty.`);return t+i+s},``)}resolve(e,...t){return a.resolve(e,...t)}static require(...r){let a=r.filter(e=>i(t(e),n).value===void 0);if(a.length>0)throw new e(305,`Missing required environment variables: ${a.join(`, `)}.`)}require(...e){a.require(...e)}};export{a as Envapter};
|
|
1
|
+
import{EnvaptError as e}from"../infra/Error.mjs";import"../core/Environment.mjs";import{resolveKeyInput as t,templateResolver as n}from"../core/engine.mjs";import{AdvancedMethods as r,resolveRequired as i}from"../core/AdvancedMethods.mjs";var a=class a extends r{static resolve(t,...n){let r=a.strict;return t.reduce((t,i,a)=>{let o=n[a];if(!o)return t+i;let s=super.get(o,``);if(r&&s.trim()===``)throw new e(305,`Cannot resolve template variable "\${${o}}": value is missing or empty.`);return t+i+s},``)}resolve(e,...t){return a.resolve(e,...t)}static require(...r){let a=r.filter(e=>i(t(e),n).value===void 0);if(a.length>0)throw new e(305,`Missing required environment variables: ${a.join(`, `)}.`)}require(...e){a.require(...e)}static has(r){try{return i(t(r),n).value!==void 0}catch(t){if(t instanceof e&&t.code===305)return!1;throw t}}has(e){return a.has(e)}};export{a as Envapter};
|
|
2
2
|
//# sourceMappingURL=Envapter.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Envapter.mjs","names":[],"sources":["../../../src/engine/Envapter.ts"],"sourcesContent":["import { AdvancedMethods } from '../core';\nimport { resolveRequired } from '../core/AdvancedMethods';\nimport { resolveKeyInput, templateResolver } from '../core/engine';\nimport { EnvaptError, EnvaptErrorCodes } from '../infra/Error';\n\nexport { Environment } from '../core';\n\n/**\n * Main configuration class for environment variable management.\n *\n * Provides both static and instance methods for retrieving typed environment variables\n * with support for template resolution, multiple .env files, and environment detection.\n *\n * Extend your own classes from this to define properties with \\@Envapt decorators and get access to environment-variable methods.\n *\n * @example\n * ```ts\n * // Static usage\n * const port = Envapter.getNumber('PORT', 3000);\n * const url = Envapter.get('API_URL', 'http://localhost');\n * const replica = Envapter.get(['READONLY_URL', 'DATABASE_URL'], 'sqlite://memory');\n *\n * // Instance usage\n * const env = new Envapter();\n * const dbUrl = env.get('DATABASE_URL', 'sqlite://memory');\n * const primaryHost = env.get(['PRIMARY_HOST', 'SECONDARY_HOST']);\n * ```\n *\n * @public\n */\nexport class Envapter extends AdvancedMethods {\n /**\n * Tagged template literal for resolving environment variables in template strings.\n *\n * @example\n * ```ts\n * // Given API_HOST=api.example.com and API_PORT=8080 in environment\n * const endpoint = Envapter.resolve`Connecting to ${'API_HOST'}:${'API_PORT'}`;\n * // Returns: \"Connecting to api.example.com:8080\"\n *\n * // Works with template variables in .env too:\n * // API_URL=https://${API_HOST}:${API_PORT}\n * const message = Envapter.resolve`Service endpoint: ${'API_URL'}`;\n * // Returns: \"Service endpoint: https://api.example.com:8080\"\n * ```\n * @see {@link https://envapt.materwelon.dev/docs/templates#the-resolve-tagged-template}\n */\n static resolve(strings: TemplateStringsArray, ...keys: string[]): string {\n const strict = Envapter.strict;\n return strings.reduce((result, string, i) => {\n const envKey = keys[i];\n if (!envKey) return result + string;\n const raw = super.get(envKey, '');\n if (strict && raw.trim() === '') {\n throw new EnvaptError(\n EnvaptErrorCodes.MissingEnvValue,\n `Cannot resolve template variable \"\\${${envKey}}\": value is missing or empty.`\n );\n }\n return result + string + raw;\n }, '');\n }\n\n /**\n * @see {@link Envapter.resolve}\n */\n resolve(strings: TemplateStringsArray, ...keys: string[]): string {\n return Envapter.resolve(strings, ...keys);\n }\n\n /**\n * Assert that one or more environment variables are present and non-empty after template\n * resolution. Throws `MissingEnvValue` listing every missing key. A whitespace-only value\n * counts as missing only under strict mode.\n *\n * For a typed required read in functional code, use `Envapter.getRequired(key, converter)`.\n *\n * @example\n * ```ts\n * Envapter.require('DATABASE_URL');\n * Envapter.require('DATABASE_URL', 'API_KEY', 'SENTRY_DSN');\n * ```\n */\n static require(...keys: [string, ...string[]]): void {\n const missing = keys.filter((k) => resolveRequired(resolveKeyInput(k), templateResolver).value === undefined);\n\n if (missing.length > 0) {\n throw new EnvaptError(\n EnvaptErrorCodes.MissingEnvValue,\n `Missing required environment variables: ${missing.join(', ')}.`\n );\n }\n }\n\n /**\n * @see {@link Envapter.require}\n */\n require(...keys: [string, ...string[]]): void {\n Envapter.require(...keys);\n }\n}\n"],"mappings":"+
|
|
1
|
+
{"version":3,"file":"Envapter.mjs","names":[],"sources":["../../../src/engine/Envapter.ts"],"sourcesContent":["import { AdvancedMethods } from '../core';\nimport { resolveRequired } from '../core/AdvancedMethods';\nimport { resolveKeyInput, templateResolver } from '../core/engine';\nimport { EnvaptError, EnvaptErrorCodes } from '../infra/Error';\n\nimport type { EnvKeyInput } from '../types';\n\nexport { Environment } from '../core';\n\n/**\n * Main configuration class for environment variable management.\n *\n * Provides both static and instance methods for retrieving typed environment variables\n * with support for template resolution, multiple .env files, and environment detection.\n *\n * Extend your own classes from this to define properties with \\@Envapt decorators and get access to environment-variable methods.\n *\n * @example\n * ```ts\n * // Static usage\n * const port = Envapter.getNumber('PORT', 3000);\n * const url = Envapter.get('API_URL', 'http://localhost');\n * const replica = Envapter.get(['READONLY_URL', 'DATABASE_URL'], 'sqlite://memory');\n *\n * // Instance usage\n * const env = new Envapter();\n * const dbUrl = env.get('DATABASE_URL', 'sqlite://memory');\n * const primaryHost = env.get(['PRIMARY_HOST', 'SECONDARY_HOST']);\n * ```\n *\n * @public\n */\nexport class Envapter extends AdvancedMethods {\n /**\n * Tagged template literal for resolving environment variables in template strings.\n *\n * @example\n * ```ts\n * // Given API_HOST=api.example.com and API_PORT=8080 in environment\n * const endpoint = Envapter.resolve`Connecting to ${'API_HOST'}:${'API_PORT'}`;\n * // Returns: \"Connecting to api.example.com:8080\"\n *\n * // Works with template variables in .env too:\n * // API_URL=https://${API_HOST}:${API_PORT}\n * const message = Envapter.resolve`Service endpoint: ${'API_URL'}`;\n * // Returns: \"Service endpoint: https://api.example.com:8080\"\n * ```\n * @see {@link https://envapt.materwelon.dev/docs/templates#the-resolve-tagged-template}\n */\n static resolve(strings: TemplateStringsArray, ...keys: string[]): string {\n const strict = Envapter.strict;\n return strings.reduce((result, string, i) => {\n const envKey = keys[i];\n if (!envKey) return result + string;\n const raw = super.get(envKey, '');\n if (strict && raw.trim() === '') {\n throw new EnvaptError(\n EnvaptErrorCodes.MissingEnvValue,\n `Cannot resolve template variable \"\\${${envKey}}\": value is missing or empty.`\n );\n }\n return result + string + raw;\n }, '');\n }\n\n /**\n * @see {@link Envapter.resolve}\n */\n resolve(strings: TemplateStringsArray, ...keys: string[]): string {\n return Envapter.resolve(strings, ...keys);\n }\n\n /**\n * Assert that one or more environment variables are present and non-empty after template\n * resolution. Throws `MissingEnvValue` listing every missing key. A whitespace-only value\n * counts as missing only under strict mode.\n *\n * For a typed required read in functional code, use `Envapter.getRequired(key, converter)`.\n *\n * @example\n * ```ts\n * Envapter.require('DATABASE_URL');\n * Envapter.require('DATABASE_URL', 'API_KEY', 'SENTRY_DSN');\n * ```\n */\n static require(...keys: [string, ...string[]]): void {\n const missing = keys.filter((k) => resolveRequired(resolveKeyInput(k), templateResolver).value === undefined);\n\n if (missing.length > 0) {\n throw new EnvaptError(\n EnvaptErrorCodes.MissingEnvValue,\n `Missing required environment variables: ${missing.join(', ')}.`\n );\n }\n }\n\n /**\n * @see {@link Envapter.require}\n */\n require(...keys: [string, ...string[]]): void {\n Envapter.require(...keys);\n }\n\n /**\n * Check whether `key` has a value, with the same missing semantics as `getRequired`.\n * Under strict mode an unresolvable template in an ordered key list ends the scan early\n * and counts as absent. Returns `true` exactly when a required read of the same key\n * finds a value.\n *\n * @example\n * ```ts\n * if (!Envapter.has('DATABASE_URL')) throw new MyStartupError('DATABASE_URL');\n * ```\n * @see {@link https://envapt.materwelon.dev/docs/envapter#fail-fast-on-missing-values}\n */\n static has(key: EnvKeyInput): boolean {\n try {\n return resolveRequired(resolveKeyInput(key), templateResolver).value !== undefined;\n } catch (error) {\n // under strict an unresolvable template throws MissingEnvValue, and that read counts as absent\n if (error instanceof EnvaptError && error.code === EnvaptErrorCodes.MissingEnvValue) return false;\n throw error;\n }\n }\n\n /**\n * @see {@link Envapter.has}\n */\n has(key: EnvKeyInput): boolean {\n return Envapter.has(key);\n }\n}\n"],"mappings":"+OAgCA,IAAa,EAAb,MAAa,UAAiB,CAAgB,CAiB1C,OAAO,QAAQ,EAA+B,GAAG,EAAwB,CACrE,IAAM,EAAS,EAAS,OACxB,OAAO,EAAQ,QAAQ,EAAQ,EAAQ,IAAM,CACzC,IAAM,EAAS,EAAK,GACpB,GAAI,CAAC,EAAQ,OAAO,EAAS,EAC7B,IAAM,EAAM,MAAM,IAAI,EAAQ,EAAE,EAChC,GAAI,GAAU,EAAI,KAAK,IAAM,GACzB,MAAM,IAAI,EAAA,IAEN,wCAAwC,EAAO,+BACnD,EAEJ,OAAO,EAAS,EAAS,CAC7B,EAAG,EAAE,CACT,CAKA,QAAQ,EAA+B,GAAG,EAAwB,CAC9D,OAAO,EAAS,QAAQ,EAAS,GAAG,CAAI,CAC5C,CAeA,OAAO,QAAQ,GAAG,EAAmC,CACjD,IAAM,EAAU,EAAK,OAAQ,GAAM,EAAgB,EAAgB,CAAC,EAAG,CAAgB,CAAC,CAAC,QAAU,IAAA,EAAS,EAE5G,GAAI,EAAQ,OAAS,EACjB,MAAM,IAAI,EAAA,IAEN,2CAA2C,EAAQ,KAAK,IAAI,EAAE,EAClE,CAER,CAKA,QAAQ,GAAG,EAAmC,CAC1C,EAAS,QAAQ,GAAG,CAAI,CAC5B,CAcA,OAAO,IAAI,EAA2B,CAClC,GAAI,CACA,OAAO,EAAgB,EAAgB,CAAG,EAAG,CAAgB,CAAC,CAAC,QAAU,IAAA,EAC7E,OAAS,EAAO,CAEZ,GAAI,aAAiB,GAAe,EAAM,OAAA,IAA2C,MAAO,GAC5F,MAAM,CACV,CACJ,CAKA,IAAI,EAA2B,CAC3B,OAAO,EAAS,IAAI,CAAG,CAC3B,CACJ"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Environment } from "../core/Environment.mjs";
|
|
2
|
+
import { EnvKeyInput } from "../types/Env.mjs";
|
|
2
3
|
import { AdvancedMethods } from "../core/AdvancedMethods.mjs";
|
|
3
4
|
|
|
4
5
|
//#region src/engine/Envapter.d.ts
|
|
@@ -65,6 +66,23 @@ declare class Envapter extends AdvancedMethods {
|
|
|
65
66
|
* @see {@link Envapter.require}
|
|
66
67
|
*/
|
|
67
68
|
require(...keys: [string, ...string[]]): void;
|
|
69
|
+
/**
|
|
70
|
+
* Check whether `key` has a value, with the same missing semantics as `getRequired`.
|
|
71
|
+
* Under strict mode an unresolvable template in an ordered key list ends the scan early
|
|
72
|
+
* and counts as absent. Returns `true` exactly when a required read of the same key
|
|
73
|
+
* finds a value.
|
|
74
|
+
*
|
|
75
|
+
* @example
|
|
76
|
+
* ```ts
|
|
77
|
+
* if (!Envapter.has('DATABASE_URL')) throw new MyStartupError('DATABASE_URL');
|
|
78
|
+
* ```
|
|
79
|
+
* @see {@link https://envapt.materwelon.dev/docs/envapter#fail-fast-on-missing-values}
|
|
80
|
+
*/
|
|
81
|
+
static has(key: EnvKeyInput): boolean;
|
|
82
|
+
/**
|
|
83
|
+
* @see {@link Envapter.has}
|
|
84
|
+
*/
|
|
85
|
+
has(key: EnvKeyInput): boolean;
|
|
68
86
|
}
|
|
69
87
|
//#endregion
|
|
70
88
|
export { Envapter };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "envapt",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "8.
|
|
4
|
+
"version": "8.1.0-next.0",
|
|
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": {
|
|
@@ -186,14 +186,15 @@
|
|
|
186
186
|
"provenance": true
|
|
187
187
|
},
|
|
188
188
|
"devDependencies": {
|
|
189
|
-
"@cloudflare/vitest-pool-workers": "0.
|
|
190
|
-
"@cloudflare/workers-types": "^
|
|
191
|
-
"@vitest/browser": "4.1.
|
|
192
|
-
"@vitest/browser-playwright": "4.1.
|
|
193
|
-
"arktype": "^2.2.
|
|
189
|
+
"@cloudflare/vitest-pool-workers": "0.18.0",
|
|
190
|
+
"@cloudflare/workers-types": "^5.20260706.1",
|
|
191
|
+
"@vitest/browser": "4.1.10",
|
|
192
|
+
"@vitest/browser-playwright": "4.1.10",
|
|
193
|
+
"arktype": "^2.2.2",
|
|
194
194
|
"esbuild": "^0.28.1",
|
|
195
|
-
"playwright": "1.61.
|
|
196
|
-
"
|
|
195
|
+
"playwright": "1.61.1",
|
|
196
|
+
"typescript7": "npm:typescript@7.0.2",
|
|
197
|
+
"valibot": "^1.4.2",
|
|
197
198
|
"zod": "4.4.3"
|
|
198
199
|
},
|
|
199
200
|
"scripts": {
|
|
@@ -219,7 +220,9 @@
|
|
|
219
220
|
"test:resolution-matrix": "node tests/resolution-matrix/run.mjs",
|
|
220
221
|
"test:cjs-validity": "node tests/cjs-validity/run.mjs",
|
|
221
222
|
"test:tsc-emit": "node tests/tsc-emit/run.mjs",
|
|
223
|
+
"test:tsc-emit:ts7": "ENVAPT_TSC_PACKAGE=typescript7 node tests/tsc-emit/run.mjs",
|
|
222
224
|
"test:stage3-emit": "node tests/stage3-emit/run.mjs",
|
|
225
|
+
"test:stage3-emit:ts7": "ENVAPT_TSC_PACKAGE=typescript7 node tests/stage3-emit/run.mjs",
|
|
223
226
|
"test:all": "node ../../scripts/test-all.mjs",
|
|
224
227
|
"coverage": "pnpm run test --coverage",
|
|
225
228
|
"cs": "changeset",
|