arkenv 1.0.0-alpha.1 → 1.0.0-alpha.3

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/dist/index.d.cts CHANGED
@@ -1,185 +1 @@
1
- import { a as Dict, n as SchemaShape, o as $, r as InferType, t as CompiledEnvSchema } from "./index-CzNfOanV.cjs";
2
- import * as _$arktype_internal_keywords_string_ts0 from "arktype/internal/keywords/string.ts";
3
- import * as _$arktype_internal_attributes_ts0 from "arktype/internal/attributes.ts";
4
- import * as _$arktype from "arktype";
5
- import { distill, type as type$1 } from "arktype";
6
- import * as _$arktype_internal_type_ts0 from "arktype/internal/type.ts";
7
-
8
- //#region src/arkenv.d.ts
9
- /**
10
- * Declarative environment schema definition accepted by ArkEnv.
11
- *
12
- * Represents a declarative schema object mapping environment
13
- * variable names to schema definitions (e.g. ArkType DSL strings
14
- * or Standard Schema validators).
15
- *
16
- * This type is used to validate that a schema object is compatible with
17
- * ArkEnv’s validator scope before being compiled or parsed.
18
- *
19
- * Most users will provide schemas in this form.
20
- *
21
- * @template def - The schema shape object
22
- */
23
- type EnvSchema<def> = type$1.validate<def, $>;
24
- /**
25
- * Infer the validated and coerced environment object type from a schema.
26
- * Supports declarative schema shapes, compiled ArkType schemas, and Standard Schema validators.
27
- *
28
- * @template T - The schema type
29
- */
30
- type Infer<T> = T extends SchemaShape ? distill.Out<type$1.infer<T, $>> : InferType<T>;
31
- type RuntimeEnvironment = Dict<string>;
32
- /**
33
- * Configuration options for `arkenv`
34
- */
35
- type ArkEnvConfig = {
36
- /**
37
- * The environment variables to parse. Defaults to `process.env`
38
- */
39
- env?: RuntimeEnvironment;
40
- /**
41
- * Whether to coerce environment variables to their defined types. Defaults to `true`
42
- */
43
- coerce?: boolean;
44
- /**
45
- * Control how ArkEnv handles environment variables that are not defined in your schema.
46
- *
47
- * Defaults to `'delete'` to ensure your output object only contains
48
- * keys you've explicitly declared. This differs from ArkType's standard behavior, which
49
- * mirrors TypeScript by defaulting to `'ignore'`.
50
- *
51
- * - `delete` (ArkEnv default): Undeclared keys are allowed on input but stripped from the output.
52
- * - `ignore` (ArkType default): Undeclared keys are allowed and preserved in the output.
53
- * - `reject`: Undeclared keys will cause validation to fail.
54
- *
55
- * @default "delete"
56
- * @see https://arktype.io/docs/configuration#onundeclaredkey
57
- */
58
- onUndeclaredKey?: "ignore" | "delete" | "reject";
59
- /**
60
- * The format to use for array parsing when coercion is enabled.
61
- *
62
- * - `comma` (default): Strings are split by comma and trimmed.
63
- * - `json`: Strings are parsed as JSON.
64
- *
65
- * @default "comma"
66
- */
67
- arrayFormat?: "comma" | "json";
68
- /**
69
- * Whether to treat empty strings (`""`) as `undefined` before validation.
70
- *
71
- * When enabled, an environment variable set to an empty value (e.g. `PORT=`)
72
- * will be treated as if it were missing, allowing defaults to apply and
73
- * preventing validation errors for numeric or boolean types.
74
- *
75
- * @default false
76
- */
77
- emptyAsUndefined?: boolean;
78
- };
79
- /**
80
- * TODO: `SchemaShape` is basically `Record<string, unknown>`.
81
- * If possible, find a better type than "const T extends Record<string, unknown>",
82
- * and be as close as possible to the type accepted by ArkType's `type`.
83
- */
84
- /**
85
- * Utility to parse environment variables using ArkType or Standard Schema
86
- * @param def - The schema definition
87
- * @param config - The evaluation configuration
88
- * @returns The parsed environment variables
89
- * @throws An {@link ArkEnvError | error} if the environment variables are invalid.
90
- */
91
- declare function arkenv<const T extends SchemaShape>(def: EnvSchema<T>, config?: ArkEnvConfig): distill.Out<type$1.infer<T, $>>;
92
- declare function arkenv<T extends CompiledEnvSchema>(def: T, config?: ArkEnvConfig): InferType<T>;
93
- declare function arkenv<const T extends SchemaShape>(def: EnvSchema<T> | CompiledEnvSchema, config?: ArkEnvConfig): distill.Out<type$1.infer<T, $>> | InferType<typeof def>;
94
- //#endregion
95
- //#region src/index.d.ts
96
- /**
97
- * Like ArkType's `type`, but with ArkEnv's extra keywords, such as:
98
- *
99
- * - `string.host` – a hostname (e.g. `"localhost"`, `"127.0.0.1"`)
100
- * - `number.port` – a port number (e.g. `8080`)
101
- *
102
- * See ArkType's docs for the full API:
103
- * https://arktype.io/docs/type-api
104
- */
105
- declare const type: _$arktype_internal_type_ts0.TypeParser<{
106
- string: _$arktype.Submodule<{
107
- trim: _$arktype.Submodule<_$arktype_internal_keywords_string_ts0.trim.$ & {
108
- " arkInferred": (In: string) => _$arktype_internal_attributes_ts0.To<string>;
109
- }>;
110
- normalize: _$arktype.Submodule<_$arktype_internal_keywords_string_ts0.normalize.$ & {
111
- " arkInferred": (In: string) => _$arktype_internal_attributes_ts0.To<string>;
112
- }>;
113
- root: string;
114
- alpha: string;
115
- alphanumeric: string;
116
- hex: string;
117
- base64: _$arktype.Submodule<{
118
- root: string;
119
- url: string;
120
- } & {
121
- " arkInferred": string;
122
- }>;
123
- capitalize: _$arktype.Submodule<_$arktype_internal_keywords_string_ts0.capitalize.$ & {
124
- " arkInferred": (In: string) => _$arktype_internal_attributes_ts0.To<string>;
125
- }>;
126
- creditCard: string;
127
- date: _$arktype.Submodule<_$arktype_internal_keywords_string_ts0.stringDate.$ & {
128
- " arkInferred": string;
129
- }>;
130
- digits: string;
131
- email: string;
132
- integer: _$arktype.Submodule<_$arktype_internal_keywords_string_ts0.stringInteger.$ & {
133
- " arkInferred": string;
134
- }>;
135
- ip: _$arktype.Submodule<_$arktype_internal_keywords_string_ts0.ip.$ & {
136
- " arkInferred": string;
137
- }>;
138
- json: _$arktype.Submodule<_$arktype_internal_keywords_string_ts0.stringJson.$ & {
139
- " arkInferred": string;
140
- }>;
141
- lower: _$arktype.Submodule<_$arktype_internal_keywords_string_ts0.lower.$ & {
142
- " arkInferred": (In: string) => _$arktype_internal_attributes_ts0.To<string>;
143
- }>;
144
- numeric: _$arktype.Submodule<_$arktype_internal_keywords_string_ts0.stringNumeric.$ & {
145
- " arkInferred": string;
146
- }>;
147
- regex: string;
148
- semver: string;
149
- upper: _$arktype.Submodule<{
150
- root: (In: string) => _$arktype_internal_attributes_ts0.To<string>;
151
- preformatted: string;
152
- } & {
153
- " arkInferred": (In: string) => _$arktype_internal_attributes_ts0.To<string>;
154
- }>;
155
- url: _$arktype.Submodule<_$arktype_internal_keywords_string_ts0.url.$ & {
156
- " arkInferred": string;
157
- }>;
158
- uuid: _$arktype.Submodule<_$arktype_internal_keywords_string_ts0.uuid.$ & {
159
- " arkInferred": string;
160
- }>;
161
- " arkInferred": string;
162
- host: string;
163
- }>;
164
- number: _$arktype.Submodule<{
165
- NaN: number;
166
- Infinity: number;
167
- root: number;
168
- integer: number;
169
- " arkInferred": number;
170
- epoch: number;
171
- safe: number;
172
- NegativeInfinity: number;
173
- port: number;
174
- }>;
175
- }>;
176
- //#endregion
177
- export { type ArkEnvConfig, type EnvSchema, type Infer, arkenv, arkenv as default, type };
178
-
179
- // CJS Interop Shim
180
- if (module.exports && module.exports.default) {
181
- Object.assign(module.exports.default, module.exports);
182
- module.exports = module.exports.default;
183
- }
184
-
185
- //# sourceMappingURL=index.d.cts.map
1
+ export { };
package/package.json CHANGED
@@ -1,47 +1,29 @@
1
1
  {
2
2
  "name": "arkenv",
3
3
  "type": "module",
4
- "version": "1.0.0-alpha.1",
5
- "description": "Typesafe environment variables parsing and validation with ArkType",
4
+ "version": "1.0.0-alpha.3",
5
+ "description": "Interactive CLI for scaffolding ArkEnv projects",
6
+ "bin": {
7
+ "arkenv": "./dist/index.cjs"
8
+ },
6
9
  "main": "./dist/index.cjs",
7
- "module": "./dist/index.mjs",
8
- "types": "./dist/index.d.mts",
10
+ "types": "./dist/index.d.ts",
9
11
  "exports": {
10
12
  ".": {
11
- "types": {
12
- "import": "./dist/index.d.mts",
13
- "require": "./dist/index.d.cts"
14
- },
15
- "import": "./dist/index.mjs",
13
+ "types": "./dist/index.d.ts",
14
+ "import": "./dist/index.js",
16
15
  "require": "./dist/index.cjs"
17
16
  },
18
- "./standard": {
19
- "types": {
20
- "import": "./dist/standard.d.mts",
21
- "require": "./dist/standard.d.cts"
22
- },
23
- "import": "./dist/standard.mjs",
24
- "require": "./dist/standard.cjs"
25
- },
26
- "./core": {
27
- "types": {
28
- "import": "./dist/core.d.mts",
29
- "require": "./dist/core.d.cts"
30
- },
31
- "import": "./dist/core.mjs",
32
- "require": "./dist/core.cjs"
33
- }
17
+ "./*": "./dist/*"
34
18
  },
35
19
  "files": [
36
20
  "dist"
37
21
  ],
38
22
  "keywords": [
39
- "pnpm",
40
- "arktype",
41
- "environment",
42
- "variables",
43
- "typesafe",
44
- "validation"
23
+ "arkenv",
24
+ "cli",
25
+ "scaffold",
26
+ "init"
45
27
  ],
46
28
  "license": "MIT",
47
29
  "homepage": "https://arkenv.js.org",
@@ -49,63 +31,27 @@
49
31
  "type": "git",
50
32
  "url": "git+https://github.com/yamcodes/arkenv.git"
51
33
  },
52
- "bugs": "https://github.com/yamcodes/arkenv/labels/arkenv",
34
+ "bugs": "https://github.com/yamcodes/arkenv/labels/arkenv-cli",
53
35
  "author": "Yam Borodetsky <yam@yam.codes>",
36
+ "dependencies": {
37
+ "@clack/prompts": "^1.3.0",
38
+ "dedent": "^1.7.2",
39
+ "jsonc-parser": "^3.3.1",
40
+ "magicast": "^0.5.2",
41
+ "picocolors": "^1.1.1",
42
+ "radashi": "^12.9.1"
43
+ },
54
44
  "devDependencies": {
55
- "@ark/attest": "0.56.0",
56
- "@size-limit/esbuild-why": "12.1.0",
57
- "@size-limit/preset-small-lib": "12.1.0",
58
45
  "@types/node": "24.12.2",
59
- "arktype": "2.2.0",
60
- "rimraf": "6.1.3",
61
- "size-limit": "12.1.0",
62
46
  "tsdown": "0.21.10",
63
- "typescript": "6.0.3",
64
- "vitest": "4.1.5",
65
- "zod": "4.4.1",
66
- "@repo/scope": "0.1.3",
67
- "@repo/types": "0.1.0"
68
- },
69
- "peerDependencies": {
70
- "arktype": "^2.1.22"
47
+ "typescript": "6.0.3"
71
48
  },
72
- "peerDependenciesMeta": {
73
- "arktype": {
74
- "optional": true
75
- }
76
- },
77
- "size-limit": [
78
- {
79
- "name": "arkenv",
80
- "path": "dist/index.mjs",
81
- "limit": "2 kB",
82
- "import": "*",
83
- "ignore": [
84
- "arktype"
85
- ]
86
- },
87
- {
88
- "name": "arkenv/standard",
89
- "path": "dist/standard.mjs",
90
- "limit": "2.3 kB",
91
- "import": "*"
92
- },
93
- {
94
- "name": "arkenv/core",
95
- "path": "dist/core.mjs",
96
- "limit": "500 B",
97
- "import": "*"
98
- }
99
- ],
100
49
  "scripts": {
101
50
  "build": "tsdown",
102
- "size": "size-limit --json > .size-limit.json",
103
- "test:once": "vitest run",
104
- "test:dist": "vitest run test/dist.test.ts",
105
- "typecheck": "tsc --noEmit",
106
- "clean": "rimraf dist node_modules",
51
+ "start": "node ./dist/index.cjs init",
52
+ "dev": "tsdown --watch",
107
53
  "test": "vitest",
108
- "test:types": "vitest run --typecheck.only",
109
- "fix": "pnpm -w run fix"
54
+ "test:run": "vitest run",
55
+ "typecheck": "tsc --noEmit"
110
56
  }
111
57
  }
@@ -1,6 +0,0 @@
1
- const e=(e,t=2,{dontDetectNewlines:n=!1}={})=>n?`${` `.repeat(t)}${e}`:e.split(`
2
- `).map(e=>`${` `.repeat(t)}${e}`).join(`
3
- `),t={red:`\x1B[31m`,yellow:`\x1B[33m`,cyan:`\x1B[36m`,reset:`\x1B[0m`},n=()=>typeof process<`u`&&process.versions!=null&&process.versions.node!=null,r=()=>!!(!n()||process.env.NO_COLOR!==void 0||process.env.CI!==void 0||process.stdout&&!process.stdout.isTTY),i=(e,i)=>n()&&!r()?`${t[e]}${i}${t.reset}`:i,a=e=>e.map(e=>`${i(`yellow`,e.path)} ${e.message.trimStart()}`).join(`
4
- `);var o=class extends Error{constructor(t,n=`Errors found while validating environment variables`){let r=a(t);super(`${i(`red`,n)}\n${e(r)}\n`),this.name=`ArkEnvError`}};Object.defineProperty(o,`name`,{value:`ArkEnvError`});export{a as n,i as r,o as t};
5
-
6
- //# sourceMappingURL=core-B0IkKRzg.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"core-B0IkKRzg.mjs","names":[],"sources":["../src/utils/indent.ts","../src/utils/style-text.ts","../src/core.ts"],"sourcesContent":["/**\n * Options for the `indent` function\n */\ntype IndentOptions = {\n\t/**\n\t * Whether to detect newlines and indent each line individually, defaults to false (indenting the whole string)\n\t */\n\tdontDetectNewlines?: boolean;\n};\n\n/**\n * Indent a string by a given amount\n * @param str - The string to indent\n * @param amt - The amount to indent by, defaults to 2\n * @param options - {@link IndentOptions}\n * @returns The indented string\n */\nexport const indent = (\n\tstr: string,\n\tamt = 2,\n\t{ dontDetectNewlines = false }: IndentOptions = {},\n) => {\n\tconst detectNewlines = !dontDetectNewlines;\n\tif (detectNewlines) {\n\t\treturn str\n\t\t\t.split(\"\\n\")\n\t\t\t.map((line) => `${\" \".repeat(amt)}${line}`)\n\t\t\t.join(\"\\n\");\n\t}\n\n\treturn `${\" \".repeat(amt)}${str}`;\n};\n","/**\n * Cross-platform text styling utility\n * Uses ANSI colors in Node environments, plain text in browsers\n * Respects NO_COLOR, CI environment variables, and TTY detection\n */\n\n// ANSI color codes for Node environments\nconst colors = {\n\tred: \"\\x1b[31m\",\n\tyellow: \"\\x1b[33m\",\n\tcyan: \"\\x1b[36m\",\n\treset: \"\\x1b[0m\",\n} as const;\n\n/**\n * Check if we're in a Node environment (not browser)\n * Checked dynamically to allow for testing with mocked globals\n */\nconst isNode = (): boolean =>\n\ttypeof process !== \"undefined\" &&\n\tprocess.versions != null &&\n\tprocess.versions.node != null;\n\n/**\n * Check if colors should be disabled based on environment\n * Respects NO_COLOR, CI environment variables, and TTY detection\n */\nconst shouldDisableColors = (): boolean => {\n\tif (!isNode()) return true;\n\n\t// Respect NO_COLOR environment variable (https://no-color.org/)\n\tif (process.env.NO_COLOR !== undefined) return true;\n\n\t// Disable colors in CI environments by default\n\tif (process.env.CI !== undefined) return true;\n\n\t// Disable colors if not writing to a TTY\n\tif (process.stdout && !process.stdout.isTTY) return true;\n\n\treturn false;\n};\n\n/**\n * Style text with color. Uses ANSI codes in Node, plain text in browsers.\n * @param color - The color to apply\n * @param text - The text to style\n * @returns Styled text in Node (if colors enabled), plain text otherwise\n */\nexport const styleText = (\n\tcolor: \"red\" | \"yellow\" | \"cyan\",\n\ttext: string,\n): string => {\n\t// Use ANSI colors only in Node environments with colors enabled\n\tif (isNode() && !shouldDisableColors()) {\n\t\treturn `${colors[color]}${text}${colors.reset}`;\n\t}\n\t// Fall back to plain text in browsers or when colors are disabled\n\treturn text;\n};\n","import { indent } from \"./utils/indent\";\nimport { styleText } from \"./utils/style-text\";\n\n/**\n * A single validation issue produced during environment variable parsing.\n * Used by {@link ArkEnvError} to report which key failed and why.\n */\nexport type ValidationIssue = {\n\tpath: string;\n\tmessage: string;\n};\n\nexport const formatInternalErrors = (errors: ValidationIssue[]): string =>\n\terrors\n\t\t.map(\n\t\t\t(error) =>\n\t\t\t\t`${styleText(\"yellow\", error.path)} ${error.message.trimStart()}`,\n\t\t)\n\t\t.join(\"\\n\");\n\n/**\n * Error thrown when environment variable validation fails.\n *\n * This error extends the native `Error` class and provides formatted error messages\n * that clearly indicate which environment variables are invalid and why.\n *\n * @example\n * ```ts\n * import arkenv from 'arkenv';\n * import { ArkEnvError } from 'arkenv/core';\n *\n * try {\n * const env = arkenv({\n * PORT: 'number.port',\n * HOST: 'string.host',\n * });\n * } catch (error) {\n * if (error instanceof ArkEnvError) {\n * console.error('Environment validation failed:', error.message);\n * }\n * }\n * ```\n */\nexport class ArkEnvError extends Error {\n\tconstructor(\n\t\terrors: ValidationIssue[],\n\t\tmessage = \"Errors found while validating environment variables\",\n\t) {\n\t\tconst formattedErrors = formatInternalErrors(errors);\n\t\tsuper(`${styleText(\"red\", message)}\\n${indent(formattedErrors)}\\n`);\n\t\tthis.name = \"ArkEnvError\";\n\t}\n}\n\nObject.defineProperty(ArkEnvError, \"name\", { value: \"ArkEnvError\" });\n"],"mappings":"AAiBA,MAAa,GACZ,EACA,EAAM,EACN,CAAE,qBAAqB,IAAyB,EAAE,GAE1B,EAQjB,GAAG,IAAI,OAAO,EAAI,GAAG,IANpB,EACL,MAAM;EAAK,CACX,IAAK,GAAS,GAAG,IAAI,OAAO,EAAI,GAAG,IAAO,CAC1C,KAAK;EAAK,CCpBR,EAAS,CACd,IAAK,WACL,OAAQ,WACR,KAAM,WACN,MAAO,UACP,CAMK,MACL,OAAO,QAAY,KACnB,QAAQ,UAAY,MACpB,QAAQ,SAAS,MAAQ,KAMpB,MAUL,GATI,CAAC,GAAQ,EAGT,QAAQ,IAAI,WAAa,IAAA,IAGzB,QAAQ,IAAI,KAAO,IAAA,IAGnB,QAAQ,QAAU,CAAC,QAAQ,OAAO,OAW1B,GACZ,EACA,IAGI,GAAQ,EAAI,CAAC,GAAqB,CAC9B,GAAG,EAAO,KAAS,IAAO,EAAO,QAGlC,EC7CK,EAAwB,GACpC,EACE,IACC,GACA,GAAG,EAAU,SAAU,EAAM,KAAK,CAAC,GAAG,EAAM,QAAQ,WAAW,GAChE,CACA,KAAK;EAAK,CAyBb,IAAa,EAAb,cAAiC,KAAM,CACtC,YACC,EACA,EAAU,sDACT,CACD,IAAM,EAAkB,EAAqB,EAAO,CACpD,MAAM,GAAG,EAAU,MAAO,EAAQ,CAAC,IAAI,EAAO,EAAgB,CAAC,IAAI,CACnE,KAAK,KAAO,gBAId,OAAO,eAAe,EAAa,OAAQ,CAAE,MAAO,cAAe,CAAC"}
@@ -1,11 +0,0 @@
1
- const e=(e,t=2,{dontDetectNewlines:n=!1}={})=>n?`${` `.repeat(t)}${e}`:e.split(`
2
- `).map(e=>`${` `.repeat(t)}${e}`).join(`
3
- `),t={red:`\x1B[31m`,yellow:`\x1B[33m`,cyan:`\x1B[36m`,reset:`\x1B[0m`},n=()=>typeof process<`u`&&process.versions!=null&&process.versions.node!=null,r=()=>!!(!n()||process.env.NO_COLOR!==void 0||process.env.CI!==void 0||process.stdout&&!process.stdout.isTTY),i=(e,i)=>n()&&!r()?`${t[e]}${i}${t.reset}`:i,a=e=>e.map(e=>`${i(`yellow`,e.path)} ${e.message.trimStart()}`).join(`
4
- `);var o=class extends Error{constructor(t,n=`Errors found while validating environment variables`){let r=a(t);super(`${i(`red`,n)}\n${e(r)}\n`),this.name=`ArkEnvError`}};Object.defineProperty(o,`name`,{value:`ArkEnvError`}),Object.defineProperty(exports,`n`,{enumerable:!0,get:function(){return a}}),Object.defineProperty(exports,`r`,{enumerable:!0,get:function(){return i}}),Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return o}});
5
-
6
- // CJS Interop Shim
7
- if (module.exports && module.exports.default) {
8
- Object.assign(module.exports.default, module.exports);
9
- module.exports = module.exports.default;
10
- }
11
-
package/dist/core.cjs DELETED
@@ -1,8 +0,0 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./core-BftJnV8f.cjs`);exports.ArkEnvError=e.t,exports.formatInternalErrors=e.n;
2
-
3
- // CJS Interop Shim
4
- if (module.exports && module.exports.default) {
5
- Object.assign(module.exports.default, module.exports);
6
- module.exports = module.exports.default;
7
- }
8
-
package/dist/core.d.cts DELETED
@@ -1,46 +0,0 @@
1
- //#region src/core.d.ts
2
- /**
3
- * A single validation issue produced during environment variable parsing.
4
- * Used by {@link ArkEnvError} to report which key failed and why.
5
- */
6
- type ValidationIssue = {
7
- path: string;
8
- message: string;
9
- };
10
- declare const formatInternalErrors: (errors: ValidationIssue[]) => string;
11
- /**
12
- * Error thrown when environment variable validation fails.
13
- *
14
- * This error extends the native `Error` class and provides formatted error messages
15
- * that clearly indicate which environment variables are invalid and why.
16
- *
17
- * @example
18
- * ```ts
19
- * import arkenv from 'arkenv';
20
- * import { ArkEnvError } from 'arkenv/core';
21
- *
22
- * try {
23
- * const env = arkenv({
24
- * PORT: 'number.port',
25
- * HOST: 'string.host',
26
- * });
27
- * } catch (error) {
28
- * if (error instanceof ArkEnvError) {
29
- * console.error('Environment validation failed:', error.message);
30
- * }
31
- * }
32
- * ```
33
- */
34
- declare class ArkEnvError extends Error {
35
- constructor(errors: ValidationIssue[], message?: string);
36
- }
37
- //#endregion
38
- export { ArkEnvError, ValidationIssue, formatInternalErrors };
39
-
40
- // CJS Interop Shim
41
- if (module.exports && module.exports.default) {
42
- Object.assign(module.exports.default, module.exports);
43
- module.exports = module.exports.default;
44
- }
45
-
46
- //# sourceMappingURL=core.d.cts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"core.d.cts","names":[],"sources":["../src/core.ts"],"mappings":";;AAOA;;;KAAY,eAAA;EACX,IAAA;EACA,OAAA;AAAA;AAAA,cAGY,oBAAA,GAAwB,MAAA,EAAQ,eAAA;;;AA+B7C;;;;;;;;;;;;;;;;;;;;;cAAa,WAAA,SAAoB,KAAA;cAE/B,MAAA,EAAQ,eAAA,IACR,OAAA;AAAA"}
package/dist/core.d.mts DELETED
@@ -1,40 +0,0 @@
1
- //#region src/core.d.ts
2
- /**
3
- * A single validation issue produced during environment variable parsing.
4
- * Used by {@link ArkEnvError} to report which key failed and why.
5
- */
6
- type ValidationIssue = {
7
- path: string;
8
- message: string;
9
- };
10
- declare const formatInternalErrors: (errors: ValidationIssue[]) => string;
11
- /**
12
- * Error thrown when environment variable validation fails.
13
- *
14
- * This error extends the native `Error` class and provides formatted error messages
15
- * that clearly indicate which environment variables are invalid and why.
16
- *
17
- * @example
18
- * ```ts
19
- * import arkenv from 'arkenv';
20
- * import { ArkEnvError } from 'arkenv/core';
21
- *
22
- * try {
23
- * const env = arkenv({
24
- * PORT: 'number.port',
25
- * HOST: 'string.host',
26
- * });
27
- * } catch (error) {
28
- * if (error instanceof ArkEnvError) {
29
- * console.error('Environment validation failed:', error.message);
30
- * }
31
- * }
32
- * ```
33
- */
34
- declare class ArkEnvError extends Error {
35
- constructor(errors: ValidationIssue[], message?: string);
36
- }
37
- //#endregion
38
- export { ArkEnvError, ValidationIssue, formatInternalErrors };
39
-
40
- //# sourceMappingURL=core.d.mts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"core.d.mts","names":[],"sources":["../src/core.ts"],"mappings":";;AAOA;;;KAAY,eAAA;EACX,IAAA;EACA,OAAA;AAAA;AAAA,cAGY,oBAAA,GAAwB,MAAA,EAAQ,eAAA;;;AA+B7C;;;;;;;;;;;;;;;;;;;;;cAAa,WAAA,SAAoB,KAAA;cAE/B,MAAA,EAAQ,eAAA,IACR,OAAA;AAAA"}
package/dist/core.mjs DELETED
@@ -1 +0,0 @@
1
- import{n as e,t}from"./core-B0IkKRzg.mjs";export{t as ArkEnvError,e as formatInternalErrors};
@@ -1,204 +0,0 @@
1
- import * as _$arktype from "arktype";
2
- import { Type, type } from "arktype";
3
- import * as _$arktype_internal_keywords_string_ts0 from "arktype/internal/keywords/string.ts";
4
- import * as _$arktype_internal_attributes_ts0 from "arktype/internal/attributes.ts";
5
-
6
- //#region ../internal/scope/dist/index.d.ts
7
- //#region src/root.d.ts
8
- /**
9
- * The root scope for the ArkEnv library,
10
- * containing extensions to the ArkType scopes with ArkEnv-specific types
11
- * like `string.host` and `number.port`.
12
- */
13
- declare const $: _$arktype.Scope<{
14
- string: _$arktype.Submodule<{
15
- trim: _$arktype.Submodule<_$arktype_internal_keywords_string_ts0.trim.$ & {
16
- " arkInferred": (In: string) => _$arktype_internal_attributes_ts0.To<string>;
17
- }>;
18
- normalize: _$arktype.Submodule<_$arktype_internal_keywords_string_ts0.normalize.$ & {
19
- " arkInferred": (In: string) => _$arktype_internal_attributes_ts0.To<string>;
20
- }>;
21
- root: string;
22
- alpha: string;
23
- alphanumeric: string;
24
- hex: string;
25
- base64: _$arktype.Submodule<{
26
- root: string;
27
- url: string;
28
- } & {
29
- " arkInferred": string;
30
- }>;
31
- capitalize: _$arktype.Submodule<_$arktype_internal_keywords_string_ts0.capitalize.$ & {
32
- " arkInferred": (In: string) => _$arktype_internal_attributes_ts0.To<string>;
33
- }>;
34
- creditCard: string;
35
- date: _$arktype.Submodule<_$arktype_internal_keywords_string_ts0.stringDate.$ & {
36
- " arkInferred": string;
37
- }>;
38
- digits: string;
39
- email: string;
40
- integer: _$arktype.Submodule<_$arktype_internal_keywords_string_ts0.stringInteger.$ & {
41
- " arkInferred": string;
42
- }>;
43
- ip: _$arktype.Submodule<_$arktype_internal_keywords_string_ts0.ip.$ & {
44
- " arkInferred": string;
45
- }>;
46
- json: _$arktype.Submodule<_$arktype_internal_keywords_string_ts0.stringJson.$ & {
47
- " arkInferred": string;
48
- }>;
49
- lower: _$arktype.Submodule<_$arktype_internal_keywords_string_ts0.lower.$ & {
50
- " arkInferred": (In: string) => _$arktype_internal_attributes_ts0.To<string>;
51
- }>;
52
- numeric: _$arktype.Submodule<_$arktype_internal_keywords_string_ts0.stringNumeric.$ & {
53
- " arkInferred": string;
54
- }>;
55
- regex: string;
56
- semver: string;
57
- upper: _$arktype.Submodule<{
58
- root: (In: string) => _$arktype_internal_attributes_ts0.To<string>;
59
- preformatted: string;
60
- } & {
61
- " arkInferred": (In: string) => _$arktype_internal_attributes_ts0.To<string>;
62
- }>;
63
- url: _$arktype.Submodule<_$arktype_internal_keywords_string_ts0.url.$ & {
64
- " arkInferred": string;
65
- }>;
66
- uuid: _$arktype.Submodule<_$arktype_internal_keywords_string_ts0.uuid.$ & {
67
- " arkInferred": string;
68
- }>;
69
- " arkInferred": string;
70
- host: string;
71
- }>;
72
- number: _$arktype.Submodule<{
73
- NaN: number;
74
- Infinity: number;
75
- root: number;
76
- integer: number;
77
- " arkInferred": number;
78
- epoch: number;
79
- safe: number;
80
- NegativeInfinity: number;
81
- port: number;
82
- }>;
83
- }>;
84
- type $ = (typeof $)["t"]; //#endregion
85
- //#endregion
86
- //#region ../internal/types/dist/helpers.d.ts
87
- type Dict<T> = Record<string, T | undefined>;
88
- //#endregion
89
- //#region ../internal/types/dist/standard-schema.d.ts
90
- /**
91
- * @see https://github.com/standard-schema/standard-schema/tree/3130ce43fdd848d9ab49dbb0458d04f18459961c/packages/spec
92
- *
93
- * Copied from standard-schema (MIT License)
94
- * Copyright (c) 2024 Colin McDannell
95
- */
96
- /** The Standard Typed interface. This is a base type extended by other specs. */
97
- interface StandardTypedV1<Input = unknown, Output = Input> {
98
- /** The Standard properties. */
99
- readonly "~standard": StandardTypedV1.Props<Input, Output>;
100
- }
101
- declare namespace StandardTypedV1 {
102
- /** The Standard Typed properties interface. */
103
- interface Props<Input = unknown, Output = Input> {
104
- /** The version number of the standard. */
105
- readonly version: 1;
106
- /** The vendor name of the schema library. */
107
- readonly vendor: string;
108
- /** Inferred types associated with the schema. */
109
- readonly types?: Types<Input, Output> | undefined;
110
- }
111
- /** The Standard Typed types interface. */
112
- interface Types<Input = unknown, Output = Input> {
113
- /** The input type of the schema. */
114
- readonly input: Input;
115
- /** The output type of the schema. */
116
- readonly output: Output;
117
- }
118
- /** Infers the input type of a Standard Typed. */
119
- type InferInput<Schema extends StandardTypedV1> = NonNullable<Schema["~standard"]["types"]>["input"];
120
- /** Infers the output type of a Standard Typed. */
121
- type InferOutput<Schema extends StandardTypedV1> = NonNullable<Schema["~standard"]["types"]>["output"];
122
- }
123
- /** The Standard Schema interface. */
124
- interface StandardSchemaV1<Input = unknown, Output = Input> {
125
- /** The Standard Schema properties. */
126
- readonly "~standard": StandardSchemaV1.Props<Input, Output>;
127
- }
128
- declare namespace StandardSchemaV1 {
129
- /** The Standard Schema properties interface. */
130
- interface Props<Input = unknown, Output = Input> extends StandardTypedV1.Props<Input, Output> {
131
- /** Validates unknown input values. */
132
- readonly validate: (value: unknown, options?: StandardSchemaV1.Options | undefined) => Result<Output> | Promise<Result<Output>>;
133
- }
134
- /** The result interface of the validate function. */
135
- type Result<Output> = SuccessResult<Output> | FailureResult;
136
- /** The result interface if validation succeeds. */
137
- interface SuccessResult<Output> {
138
- /** The typed output value. */
139
- readonly value: Output;
140
- /** A falsy value for `issues` indicates success. */
141
- readonly issues?: undefined;
142
- }
143
- interface Options {
144
- /** Explicit support for additional vendor-specific parameters, if needed. */
145
- readonly libraryOptions?: Record<string, unknown> | undefined;
146
- }
147
- /** The result interface if validation fails. */
148
- interface FailureResult {
149
- /** The issues of failed validation. */
150
- readonly issues: ReadonlyArray<Issue>;
151
- }
152
- /** The issue interface of the failure output. */
153
- interface Issue {
154
- /** The error message of the issue. */
155
- readonly message: string;
156
- /** The path of the issue, if any. */
157
- readonly path?: ReadonlyArray<PropertyKey | PathSegment> | undefined;
158
- }
159
- /** The path segment interface of the issue. */
160
- interface PathSegment {
161
- /** The key representing a path segment. */
162
- readonly key: PropertyKey;
163
- }
164
- /** The Standard types interface. */
165
- interface Types<Input = unknown, Output = Input> extends StandardTypedV1.Types<Input, Output> {}
166
- /** Infers the input type of a Standard. */
167
- type InferInput<Schema extends StandardTypedV1> = StandardTypedV1.InferInput<Schema>;
168
- /** Infers the output type of a Standard. */
169
- type InferOutput<Schema extends StandardTypedV1> = StandardTypedV1.InferOutput<Schema>;
170
- }
171
- //#endregion
172
- //#region ../internal/types/dist/infer-type.d.ts
173
- /**
174
- * Extract the inferred type from a schema definition.
175
- * Supports both ArkType type definitions and Standard Schema 1.0 validators.
176
- *
177
- * For Standard Schema validators (e.g., Zod, Valibot), extracts the output type.
178
- * For ArkType definitions, checks the call signature or type properties.
179
- *
180
- * @template T - The schema definition to infer from
181
- */
182
- type InferType<T> = T extends StandardSchemaV1<infer _Input, infer Output> ? Output : T extends ((value: Record<string, string | undefined>) => infer R) ? R extends type.errors ? never : R : T extends {
183
- t: infer U;
184
- } ? U : T extends type.Any<infer U, infer _Scope> ? U : never;
185
- //#endregion
186
- //#region ../internal/types/dist/schema.d.ts
187
- type SchemaShape = Record<string, unknown>;
188
- /**
189
- * @internal
190
- *
191
- * Compiled ArkType schema accepted by ArkEnv.
192
- * Produced by `arktype.type(...)` or `scope(...)`.
193
- *
194
- * Represents an already-constructed ArkType `Type` instance that
195
- * defines the full environment schema.
196
- *
197
- * This form bypasses schema validation and is intended for advanced
198
- * or programmatic use cases where schemas are constructed dynamically.
199
- */
200
- type CompiledEnvSchema = Type<SchemaShape, $>;
201
- //#endregion
202
- export { Dict as a, StandardSchemaV1 as i, SchemaShape as n, $ as o, InferType as r, CompiledEnvSchema as t };
203
-
204
- //# sourceMappingURL=index-Br22fqkz.d.mts.map