envapt 8.1.1 → 8.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +18 -15
- package/README.md +5 -6
- package/dist/node/config.cjs.map +1 -1
- package/dist/node/config.mjs.map +1 -1
- package/dist/node/converters/BuiltInConverters.cjs.map +1 -1
- package/dist/node/converters/BuiltInConverters.mjs.map +1 -1
- package/dist/node/converters/Converters.cjs.map +1 -1
- package/dist/node/converters/Converters.mjs.map +1 -1
- package/dist/node/converters/ListOfBuiltInConverters.cjs.map +1 -1
- package/dist/node/converters/ListOfBuiltInConverters.mjs.map +1 -1
- package/dist/node/converters/ValueConverter.cjs.map +1 -1
- package/dist/node/converters/ValueConverter.mjs.map +1 -1
- package/dist/node/core/AdvancedMethods.cjs.map +1 -1
- package/dist/node/core/AdvancedMethods.mjs.map +1 -1
- package/dist/node/core/EnvapterBase.cjs.map +1 -1
- package/dist/node/core/EnvapterBase.mjs.map +1 -1
- package/dist/node/core/EnvironmentMethods.cjs.map +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.map +1 -1
- package/dist/node/core/engine.mjs.map +1 -1
- package/dist/node/core/missing.cjs.map +1 -1
- package/dist/node/core/missing.mjs.map +1 -1
- package/dist/node/core/paths.cjs.map +1 -1
- package/dist/node/core/paths.mjs.map +1 -1
- package/dist/node/core/state.cjs.map +1 -1
- package/dist/node/core/state.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/modern/createAccessorDecorator.cjs.map +1 -1
- package/dist/node/decorators/modern/createAccessorDecorator.mjs.map +1 -1
- package/dist/node/decorators/resolveDecoratorValue.cjs.map +1 -1
- package/dist/node/decorators/resolveDecoratorValue.mjs.map +1 -1
- package/dist/node/engine/Envapter.cjs.map +1 -1
- package/dist/node/engine/Envapter.mjs.map +1 -1
- package/dist/node/engine/NodeEnvapter.cjs.map +1 -1
- package/dist/node/engine/NodeEnvapter.mjs.map +1 -1
- package/dist/node/engine/TemplateResolver.cjs.map +1 -1
- package/dist/node/engine/TemplateResolver.mjs.map +1 -1
- package/dist/node/engine/Validators.cjs.map +1 -1
- package/dist/node/engine/Validators.mjs.map +1 -1
- package/dist/node/infra/Debug.cjs.map +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/recase.cjs.map +1 -1
- package/dist/node/infra/recase.mjs.map +1 -1
- package/dist/node/infra/runtime.cjs.map +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/UnboundSource.cjs.map +1 -1
- package/dist/node/sources/UnboundSource.mjs.map +1 -1
- package/dist/node/sources/coerce.cjs.map +1 -1
- package/dist/node/sources/coerce.mjs.map +1 -1
- package/dist/node/sources/merge.cjs.map +1 -1
- package/dist/node/sources/merge.mjs.map +1 -1
- package/dist/portable/converters/BuiltInConverters.mjs.map +1 -1
- package/dist/portable/converters/Converters.mjs.map +1 -1
- package/dist/portable/converters/ListOfBuiltInConverters.mjs.map +1 -1
- package/dist/portable/converters/ValueConverter.mjs.map +1 -1
- package/dist/portable/core/AdvancedMethods.mjs.map +1 -1
- package/dist/portable/core/EnvapterBase.mjs.map +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.map +1 -1
- package/dist/portable/core/missing.mjs.map +1 -1
- package/dist/portable/core/paths.mjs.map +1 -1
- package/dist/portable/core/state.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/modern/createAccessorDecorator.mjs.map +1 -1
- package/dist/portable/decorators/resolveDecoratorValue.mjs.map +1 -1
- package/dist/portable/engine/Envapter.mjs.map +1 -1
- package/dist/portable/engine/PortableEnvapter.mjs.map +1 -1
- package/dist/portable/engine/TemplateResolver.mjs.map +1 -1
- package/dist/portable/engine/Validators.mjs.map +1 -1
- package/dist/portable/engine/fileApiStub.mjs.map +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/recase.mjs.map +1 -1
- package/dist/portable/infra/runtime.mjs.map +1 -1
- package/dist/portable/sources/PortableSource.mjs.map +1 -1
- package/dist/portable/sources/UnboundSource.mjs.map +1 -1
- package/dist/portable/sources/coerce.mjs.map +1 -1
- package/dist/portable/sources/merge.mjs.map +1 -1
- package/dist/types/converters/Converters.d.mts +4 -5
- package/dist/types/core/AdvancedMethods.d.mts +6 -12
- package/dist/types/core/EnvapterBase.d.mts +9 -12
- package/dist/types/core/Environment.d.mts +1 -2
- package/dist/types/core/EnvironmentMethods.d.mts +1 -6
- package/dist/types/core/PrimitiveMethods.d.mts +1 -5
- package/dist/types/decorators/legacy/Envapt.d.mts +17 -19
- package/dist/types/decorators/legacy/SugarDecorators.d.mts +12 -13
- package/dist/types/decorators/modern/Envapt.d.mts +17 -19
- package/dist/types/decorators/modern/SugarDecorators.d.mts +12 -13
- package/dist/types/engine/Envapter.d.mts +2 -2
- package/dist/types/engine/NodeEnvapter.d.mts +5 -6
- package/dist/types/engine/PortableEnvapter.d.mts +5 -7
- package/dist/types/infra/Debug.d.mts +3 -5
- package/dist/types/infra/Dotenv.d.mts +2 -4
- package/dist/types/infra/Error.d.mts +4 -5
- package/dist/types/infra/StandardSchema.d.mts +5 -7
- package/dist/types/sources/FileSource.d.mts +1 -2
- package/dist/types/sources/PortableSource.d.mts +7 -8
- package/dist/types/sources/merge.d.mts +1 -2
- package/dist/types/types/Conversion.d.mts +0 -4
- package/dist/types/types/Decorator.d.mts +2 -3
- package/dist/types/types/Options.d.mts +7 -7
- package/dist/types/types/Schema.d.mts +1 -1
- package/package.json +11 -13
|
@@ -2,8 +2,8 @@ import { Environment } from "../core/Environment.mjs";
|
|
|
2
2
|
import { EnvaptConverter } from "./Conversion.mjs";
|
|
3
3
|
//#region src/types/Options.d.ts
|
|
4
4
|
/**
|
|
5
|
-
* Options for the \@Envapt decorator (modern API). `required: true`
|
|
6
|
-
*
|
|
5
|
+
* Options for the \@Envapt decorator (modern API). `required: true` and `fallback` cannot be
|
|
6
|
+
* used together, and the `@Envapt` overloads reject the pair at compile time.
|
|
7
7
|
* @public
|
|
8
8
|
* @see {@link https://envapt.materwelon.dev/docs/decorators#declaring-decorated-fields}
|
|
9
9
|
*/
|
|
@@ -21,27 +21,27 @@ interface EnvaptOptions<TFallback = string> {
|
|
|
21
21
|
* @see {@link https://envapt.materwelon.dev/docs/environment#custom-profiles}
|
|
22
22
|
*/
|
|
23
23
|
interface EnvProfile {
|
|
24
|
-
/** One or more `.env` paths to load for this environment.
|
|
24
|
+
/** One or more `.env` paths to load for this environment. Earlier paths take precedence. */
|
|
25
25
|
paths: string | string[];
|
|
26
26
|
}
|
|
27
27
|
/**
|
|
28
28
|
* Configuration object for `Envapter.configureProfiles`. Maps each `Environment` to an optional
|
|
29
29
|
* profile override. Unspecified environments fall through to the default cascade behavior
|
|
30
|
-
* (`.env.${env}.local`, `.env
|
|
30
|
+
* (`.env.${env}.local`, `.env.${env}`, `.env.local`, `.env`).
|
|
31
31
|
* @public
|
|
32
32
|
* @see {@link https://envapt.materwelon.dev/docs/environment#custom-profiles}
|
|
33
33
|
*/
|
|
34
34
|
type ProfilesConfig = Partial<Record<Environment, EnvProfile>> & {
|
|
35
35
|
/**
|
|
36
36
|
* When `false`, disables the default dotenv-flow cascade entirely. Only the explicitly
|
|
37
|
-
* configured paths are loaded. Defaults to `true` (cascade still runs
|
|
38
|
-
*
|
|
37
|
+
* configured paths are loaded. Defaults to `true` (the cascade still runs and configured
|
|
38
|
+
* paths take higher precedence).
|
|
39
39
|
*/
|
|
40
40
|
useDefaults?: boolean;
|
|
41
41
|
};
|
|
42
42
|
/**
|
|
43
43
|
* How the portable build's filesystem-only config APIs behave when called. `'warn'` (the default)
|
|
44
|
-
* warns once and no-ops
|
|
44
|
+
* warns once and no-ops. `'throw'` throws `FileApiUnsupported`. The node build runs these APIs
|
|
45
45
|
* normally and is unaffected by this value.
|
|
46
46
|
* @public
|
|
47
47
|
* @see {@link https://envapt.materwelon.dev/docs/compatibility#binding-by-runtime}
|
|
@@ -7,5 +7,5 @@ type Err<Msg extends string> = Msg & {
|
|
|
7
7
|
type SchemaMustBeSync = Err<'Schema must be synchronous. envapt is boot-time config loading; async refinements (validate returning `Promise<Result>`) belong outside the env layer.'>;
|
|
8
8
|
type SchemaConstraint<Schema extends StandardSchemaV1> = ReturnType<Schema['~standard']['validate']> extends Promise<unknown> ? SchemaMustBeSync : Schema;
|
|
9
9
|
//#endregion
|
|
10
|
-
export type {
|
|
10
|
+
export type { SchemaConstraint };
|
|
11
11
|
//# sourceMappingURL=Schema.d.mts.map
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "envapt",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "8.
|
|
4
|
+
"version": "8.2.1",
|
|
5
5
|
"description": "Type-safe config for TypeScript. Read typed values from any source, process.env, .env files, Cloudflare Workers bindings, browser bundles, or any object you supply. Zero runtime dependencies, one API across Node, Bun, Deno, Workers, and the browser. TC39 accessor decorators (legacy decorators at envapt/legacy), converters, and Standard Schema (zod/valibot/arktype) validation.",
|
|
6
6
|
"types": "./dist/types/index.d.mts",
|
|
7
7
|
"exports": {
|
|
@@ -178,7 +178,7 @@
|
|
|
178
178
|
"license": "Apache-2.0",
|
|
179
179
|
"engines": {
|
|
180
180
|
"node": ">=20.0.0",
|
|
181
|
-
"bun": ">=1.3.
|
|
181
|
+
"bun": ">=1.3.11",
|
|
182
182
|
"deno": ">=2.5.0"
|
|
183
183
|
},
|
|
184
184
|
"publishConfig": {
|
|
@@ -186,16 +186,15 @@
|
|
|
186
186
|
"provenance": true
|
|
187
187
|
},
|
|
188
188
|
"devDependencies": {
|
|
189
|
-
"@cloudflare/vitest-pool-workers": "0.
|
|
190
|
-
"@cloudflare/workers-types": "^5.
|
|
191
|
-
"@vitest/browser": "4.1.
|
|
192
|
-
"
|
|
193
|
-
"
|
|
194
|
-
"
|
|
195
|
-
"playwright": "1.61.1",
|
|
189
|
+
"@cloudflare/vitest-pool-workers": "0.22.0",
|
|
190
|
+
"@cloudflare/workers-types": "^5.20260911.1",
|
|
191
|
+
"@vitest/browser-playwright": "4.1.11",
|
|
192
|
+
"arktype": "^2.2.3",
|
|
193
|
+
"esbuild": "^0.28.2",
|
|
194
|
+
"playwright": "1.63.0",
|
|
196
195
|
"typescript7": "npm:typescript@7.0.2",
|
|
197
|
-
"valibot": "^1.
|
|
198
|
-
"zod": "4.4
|
|
196
|
+
"valibot": "^1.5.0",
|
|
197
|
+
"zod": "4.6.4"
|
|
199
198
|
},
|
|
200
199
|
"scripts": {
|
|
201
200
|
"clean": "rm -rf dist",
|
|
@@ -208,7 +207,6 @@
|
|
|
208
207
|
"fmt:check": "prettier --check '{src,tests,scripts}/**/*.{ts,tsx,json,md}' --cache",
|
|
209
208
|
"fmt:all": "prettier --write .",
|
|
210
209
|
"tc": "tsc --noEmit",
|
|
211
|
-
"tsd": "tsd",
|
|
212
210
|
"test": "vitest run",
|
|
213
211
|
"test:watch": "vitest dev",
|
|
214
212
|
"test:integration": "node tests/integration/run.mjs",
|
|
@@ -231,5 +229,5 @@
|
|
|
231
229
|
"bump": "pnpm tsx ../../scripts/release/bump-jsr.ts",
|
|
232
230
|
"release": "pnpm run cs:publish"
|
|
233
231
|
},
|
|
234
|
-
"readme": "<img src=\"https://raw.githubusercontent.com/materwelonDhruv/envapt/main/.github/assets/logo.png\" width=\"120\" align=\"left\" alt=\"envapt logo\" />\n\n<h3>envapt</h3>\n\n<p>\n <strong>The apt way to read typed config.</strong><br/>\n Read config from any source as real typed values, with zero runtime dependencies.\n</p>\n\n<p>\n <a href=\"https://www.npmjs.com/package/envapt\"><img alt=\"npm\" src=\"https://img.shields.io/npm/v/envapt?logo=npm&logoColor=cb3838&label=%20&labelColor=103544&color=cb3838\"></a>\n <a href=\"https://www.npmjs.com/package/envapt\"><img alt=\"downloads\" src=\"https://img.shields.io/npm/dm/envapt?style=flat&color=f7f6e8&labelColor=103544&label=downloads\"></a>\n <a href=\"https://jsr.io/@materwelon/envapt\"><img alt=\"jsr\" src=\"https://jsr.io/badges/@materwelon/envapt\"></a>\n <img alt=\"CI\" src=\"https://img.shields.io/github/actions/workflow/status/materwelonDhruv/envapt/checks.yml?branch=main&label=tests&style=flat&logo=github&color=3fb950&labelColor=103544\">\n <a href=\"LICENSE\"><img alt=\"License\" src=\"https://img.shields.io/npm/l/envapt?style=flat&color=e97826&logo=apache&label=\"></a>\n</p>\n\n<br clear=\"left\"/>\n\nenvapt returns config as the type you asked for
|
|
232
|
+
"readme": "<img src=\"https://raw.githubusercontent.com/materwelonDhruv/envapt/main/.github/assets/logo.png\" width=\"120\" align=\"left\" alt=\"envapt logo\" />\n\n<h3>envapt</h3>\n\n<p>\n <strong>The apt way to read typed config.</strong><br/>\n Read config from any source as real typed values, with zero runtime dependencies.\n</p>\n\n<p>\n <a href=\"https://www.npmjs.com/package/envapt\"><img alt=\"npm\" src=\"https://img.shields.io/npm/v/envapt?logo=npm&logoColor=cb3838&label=%20&labelColor=103544&color=cb3838\"></a>\n <a href=\"https://www.npmjs.com/package/envapt\"><img alt=\"downloads\" src=\"https://img.shields.io/npm/dm/envapt?style=flat&color=f7f6e8&labelColor=103544&label=downloads\"></a>\n <a href=\"https://jsr.io/@materwelon/envapt\"><img alt=\"jsr\" src=\"https://jsr.io/badges/@materwelon/envapt\"></a>\n <img alt=\"CI\" src=\"https://img.shields.io/github/actions/workflow/status/materwelonDhruv/envapt/checks.yml?branch=main&label=tests&style=flat&logo=github&color=3fb950&labelColor=103544\">\n <a href=\"LICENSE\"><img alt=\"License\" src=\"https://img.shields.io/npm/l/envapt?style=flat&color=e97826&logo=apache&label=\"></a>\n</p>\n\n<br clear=\"left\"/>\n\nenvapt returns config as the type you asked for, with a fallback that removes `undefined` from the\nreturn type. It reads from whatever source you bind. On Node, Bun, and Deno that is `process.env`\nand your `.env` files, bound on import. On Cloudflare Workers, in the browser, or for a secrets\nobject you fetched at boot, you bind the source with `Envapter.useSource(...)`.\n\n```ts\nimport { Converters, Envapter } from 'envapt';\n\nconst { port, databaseUrl, cacheTtl, allowedOrigins } = Envapter.getRequiredAll(\n {\n PORT: Converters.Port, // number, checked against 0-65535\n DATABASE_URL: Converters.Url, // URL\n CACHE_TTL: Converters.Time, // \"15m\" parsed to 900000\n ALLOWED_ORIGINS: Converters.array() // string[]\n // ... and many more built-in converters\n },\n 'camelCase'\n);\n```\n\nCall that at startup and a missing value fails the boot, with one error naming every key that was\nmissing. Reads with a fallback (`Envapter.getNumber('WORKERS', 4)`) never throw.\n\n**[Read the docs →](https://envapt.materwelon.dev)**\n\n## What you get\n\n- **Typed values.** A fallback removes `undefined` from the return type. Built-in converters cover\n numbers, integers, floats, booleans, bigint, symbols, JSON, URLs, regular expressions, dates,\n durations, ports, emails, and arrays, or pass your own function or a Standard Schema validator\n (zod, valibot, arktype).\n- **Any source.** A source is any object with a `readVars()` method, so you can bind `process.env`, a\n Cloudflare Workers binding, a browser bundle, or a secrets payload you fetched from a store at boot.\n On Node, Bun, and Deno one binds on import.\n- **Zero runtime dependencies.** The reader, converters, and built-in `.env` parser are self-contained,\n so nothing is added to your dependency tree.\n- **Runs on Node, Bun, Deno, Cloudflare Workers, and the browser.** Node `>=20`, Bun `>=1.3.11`, Deno\n `>=2.5` (ESM and CJS). The portable build resolves through the package `exports`\n conditions.\n- **`.env` loading built in on Node.** The default Node source adds a per-environment file cascade,\n `${VAR}` templates, and strict / required checks. Off Node there is no filesystem, so you bind\n another source with `Envapter.useSource(...)` and read with the same typed API.\n\n## Install\n\n```sh\nnpm install envapt\npnpm add envapt\nyarn add envapt\nbun add envapt\ndeno add jsr:@materwelon/envapt\n```\n\n## Quick start\n\nRead values functionally with `Envapter`, or bind them to class fields with the `@Envapt` decorator.\nBoth share the same parsing, converters, and cache.\n\n### Functional\n\nRead a value from any call site, in JavaScript or TypeScript. No build step. On Node the source is\nbound for you. On Workers and in the browser, call `Envapter.useSource(...)` first.\n\n```ts\nimport { Converters, Envapter } from 'envapt';\n\nconst requestTimeout = Envapter.getUsing('REQUEST_TIMEOUT', Converters.Time, '30s'); // 30000\nconst maxRetries = Envapter.getNumber('MAX_RETRIES', 3);\nconst debug = Envapter.getBoolean('DEBUG', false);\n```\n\nOn Cloudflare Workers, `env` is importable at module scope, so bind it once in a config module, and in\nthe browser seed a `PortableSource` from the object your bundler injects.\n\n```ts\nimport { env } from 'cloudflare:workers';\nimport { Envapter, PortableSource } from 'envapt';\n\nEnvapter.useSource(new PortableSource(env));\n\nexport const apiToken = Envapter.get('API_TOKEN');\n```\n\n### Decorator\n\nBind a value to a class field with a TC39 accessor decorator. No `experimentalDecorators` flag, and it runs on Bun and Deno from `.ts` directly.\n\n```ts\nimport { Converters, Envapt, EnvTime } from 'envapt';\n\nclass Config {\n @Envapt('PORT', { converter: Converters.Port, fallback: 3000 })\n static accessor port: number;\n\n @EnvTime('CACHE_TTL', '15m')\n static accessor cacheTtl: number;\n}\n```\n\nThe legacy (experimentalDecorators) decorators are exported from `envapt/legacy`.\n\n## Agent skill\n\nInstall the envapt agent skill so AI coding tools use the correct API:\n\n```sh\nnpx skills add materwelonDhruv/envapt\n```\n\n---\n\n<p align=\"center\"><sub>Built by <a href=\"https://github.com/materwelondhruv\">@materwelonDhruv</a> · Apache 2.0</sub></p>\n"
|
|
235
233
|
}
|