arkenv 1.0.0-alpha.2 → 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/README.md +20 -80
- package/dist/chunk-i8uDWG73.cjs +1 -0
- package/dist/index.cjs +375 -8
- package/dist/index.d.cts +1 -235
- package/package.json +27 -81
- package/dist/core-7-JO-N-w.d.cts +0 -82
- package/dist/core-7-JO-N-w.d.cts.map +0 -1
- package/dist/core-A65KioHX.mjs +0 -6
- package/dist/core-A65KioHX.mjs.map +0 -1
- package/dist/core-BaGd9k2K.d.mts +0 -76
- package/dist/core-BaGd9k2K.d.mts.map +0 -1
- package/dist/core-CA13n2Iu.cjs +0 -11
- package/dist/core.cjs +0 -8
- package/dist/core.d.cts +0 -9
- package/dist/core.d.mts +0 -2
- package/dist/core.mjs +0 -1
- package/dist/errors-C_uh86xh.mjs +0 -3
- package/dist/errors-C_uh86xh.mjs.map +0 -1
- package/dist/errors-Dn6WQ2pP.cjs +0 -8
- package/dist/index-Do-2CL1V.d.cts +0 -210
- package/dist/index-Do-2CL1V.d.cts.map +0 -1
- package/dist/index-NbQAnciD.d.mts +0 -204
- package/dist/index-NbQAnciD.d.mts.map +0 -1
- package/dist/index.d.cts.map +0 -1
- package/dist/index.d.mts +0 -229
- package/dist/index.d.mts.map +0 -1
- package/dist/index.mjs +0 -3
- package/dist/index.mjs.map +0 -1
- package/dist/standard.cjs +0 -8
- package/dist/standard.d.cts +0 -111
- package/dist/standard.d.cts.map +0 -1
- package/dist/standard.d.mts +0 -105
- package/dist/standard.d.mts.map +0 -1
- package/dist/standard.mjs +0 -3
- package/dist/standard.mjs.map +0 -1
package/dist/index.d.cts
CHANGED
|
@@ -1,235 +1 @@
|
|
|
1
|
-
|
|
2
|
-
import { a as Dict, n as SchemaShape, o as $, r as InferType, t as CompiledEnvSchema } from "./index-Do-2CL1V.cjs";
|
|
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
|
-
import * as _$arktype from "arktype";
|
|
6
|
-
import { distill, type as type$1 } from "arktype";
|
|
7
|
-
import * as _$arktype_internal_type_ts0 from "arktype/internal/type.ts";
|
|
8
|
-
|
|
9
|
-
//#region src/arkenv.d.ts
|
|
10
|
-
/**
|
|
11
|
-
* Declarative environment schema definition accepted by ArkEnv.
|
|
12
|
-
*
|
|
13
|
-
* Represents a declarative schema object mapping environment
|
|
14
|
-
* variable names to schema definitions (e.g. ArkType DSL strings
|
|
15
|
-
* or Standard Schema validators).
|
|
16
|
-
*
|
|
17
|
-
* This type is used to validate that a schema object is compatible with
|
|
18
|
-
* ArkEnv’s validator scope before being compiled or parsed.
|
|
19
|
-
*
|
|
20
|
-
* Most users will provide schemas in this form.
|
|
21
|
-
*
|
|
22
|
-
* @template def - The schema shape object
|
|
23
|
-
*/
|
|
24
|
-
type EnvSchema<def> = type$1.validate<def, $>;
|
|
25
|
-
/**
|
|
26
|
-
* Infer the validated and coerced environment object type from a schema.
|
|
27
|
-
* Supports declarative schema shapes, compiled ArkType schemas, and Standard Schema validators.
|
|
28
|
-
*
|
|
29
|
-
* @template T - The schema type
|
|
30
|
-
*/
|
|
31
|
-
type Infer<T> = T extends SchemaShape ? distill.Out<type$1.infer<T, $>> : InferType<T>;
|
|
32
|
-
/**
|
|
33
|
-
* The environment variables passed to `arkenv`.
|
|
34
|
-
* Uses `Dict<string>` to enforce
|
|
35
|
-
* compile-time safety: all input environment variables must be strings
|
|
36
|
-
* (or undefined), matching `process.env` semantics.
|
|
37
|
-
*/
|
|
38
|
-
type RuntimeEnvironment = Dict<string>;
|
|
39
|
-
/**
|
|
40
|
-
* Configuration options for `arkenv`
|
|
41
|
-
*/
|
|
42
|
-
type ArkEnvConfig = {
|
|
43
|
-
/**
|
|
44
|
-
* The environment variables to parse. Defaults to `process.env`
|
|
45
|
-
*/
|
|
46
|
-
env?: RuntimeEnvironment;
|
|
47
|
-
/**
|
|
48
|
-
* Whether to coerce environment variables to their defined types. Defaults to `true`
|
|
49
|
-
*/
|
|
50
|
-
coerce?: boolean;
|
|
51
|
-
/**
|
|
52
|
-
* Control how ArkEnv handles environment variables that are not defined in your schema.
|
|
53
|
-
*
|
|
54
|
-
* Defaults to `'delete'` to ensure your output object only contains
|
|
55
|
-
* keys you've explicitly declared. This differs from ArkType's standard behavior, which
|
|
56
|
-
* mirrors TypeScript by defaulting to `'ignore'`.
|
|
57
|
-
*
|
|
58
|
-
* - `delete` (ArkEnv default): Undeclared keys are allowed on input but stripped from the output.
|
|
59
|
-
* - `ignore` (ArkType default): Undeclared keys are allowed and preserved in the output.
|
|
60
|
-
* - `reject`: Undeclared keys will cause validation to fail.
|
|
61
|
-
*
|
|
62
|
-
* @default "delete"
|
|
63
|
-
* @see https://arktype.io/docs/configuration#onundeclaredkey
|
|
64
|
-
*/
|
|
65
|
-
onUndeclaredKey?: "ignore" | "delete" | "reject";
|
|
66
|
-
/**
|
|
67
|
-
* The format to use for array parsing when coercion is enabled.
|
|
68
|
-
*
|
|
69
|
-
* - `comma` (default): Strings are split by comma and trimmed.
|
|
70
|
-
* - `json`: Strings are parsed as JSON.
|
|
71
|
-
*
|
|
72
|
-
* @default "comma"
|
|
73
|
-
*/
|
|
74
|
-
arrayFormat?: "comma" | "json";
|
|
75
|
-
/**
|
|
76
|
-
* Whether to bypass secret redaction and print raw sensitive values during debugging.
|
|
77
|
-
* Defaults to checking `process.env.ARKENV_DEBUG_SECRETS === "true"` or `"1"`.
|
|
78
|
-
*/
|
|
79
|
-
debugSecrets?: boolean;
|
|
80
|
-
/**
|
|
81
|
-
* Whether to treat empty strings (`""`) as `undefined` before validation.
|
|
82
|
-
*
|
|
83
|
-
* When enabled, an environment variable set to an empty value (e.g. `PORT=`)
|
|
84
|
-
* will be treated as if it were missing, allowing defaults to apply and
|
|
85
|
-
* preventing validation errors for numeric or boolean types.
|
|
86
|
-
*
|
|
87
|
-
* @default false
|
|
88
|
-
*/
|
|
89
|
-
emptyAsUndefined?: boolean;
|
|
90
|
-
/**
|
|
91
|
-
* Whether to return a safe result object instead of throwing an error on validation failure.
|
|
92
|
-
*
|
|
93
|
-
* When enabled, the function returns an object with `{ success: true, data }` or `{ success: false, issues }`.
|
|
94
|
-
*
|
|
95
|
-
* @default false
|
|
96
|
-
*/
|
|
97
|
-
safe?: boolean;
|
|
98
|
-
};
|
|
99
|
-
/**
|
|
100
|
-
* Helper type to represent the output of parsing either an EnvSchema or CompiledEnvSchema.
|
|
101
|
-
*/
|
|
102
|
-
type ArkenvOutput<T extends SchemaShape, D> = distill.Out<type$1.infer<T, $>> | InferType<D>;
|
|
103
|
-
/**
|
|
104
|
-
* Utility to parse environment variables using ArkType or Standard Schema
|
|
105
|
-
*
|
|
106
|
-
* Naming convention: the main function is lowercase (`arkenv`) following the
|
|
107
|
-
* JavaScript convention for functions (e.g. `zod`, `joi`). Classes and types
|
|
108
|
-
* use PascalCase with the full product name (`ArkEnvError`, `SafeArkEnvResult`).
|
|
109
|
-
*
|
|
110
|
-
* @param def The schema definition
|
|
111
|
-
* @param config The evaluation configuration
|
|
112
|
-
* @returns The parsed environment variables, or a SafeArkEnvResult if `{ safe: true }` is configured
|
|
113
|
-
* @throws An {@link ArkEnvError | error} if the environment variables are invalid and `safe` is not enabled
|
|
114
|
-
*/
|
|
115
|
-
declare function arkenv<const T extends SchemaShape>(def: EnvSchema<T>, config?: ArkEnvConfig & {
|
|
116
|
-
safe?: false;
|
|
117
|
-
}): distill.Out<type$1.infer<T, $>>;
|
|
118
|
-
declare function arkenv<T extends CompiledEnvSchema>(def: T, config?: ArkEnvConfig & {
|
|
119
|
-
safe?: false;
|
|
120
|
-
}): InferType<T>;
|
|
121
|
-
declare function arkenv<const T extends SchemaShape, const D extends EnvSchema<T> | CompiledEnvSchema>(def: D, config?: ArkEnvConfig & {
|
|
122
|
-
safe?: false;
|
|
123
|
-
}): ArkenvOutput<T, D>;
|
|
124
|
-
declare function arkenv<const T extends SchemaShape>(def: EnvSchema<T>, config: ArkEnvConfig & {
|
|
125
|
-
safe: true;
|
|
126
|
-
}): SafeArkEnvResult<distill.Out<type$1.infer<T, $>>>;
|
|
127
|
-
declare function arkenv<T extends CompiledEnvSchema>(def: T, config: ArkEnvConfig & {
|
|
128
|
-
safe: true;
|
|
129
|
-
}): SafeArkEnvResult<InferType<T>>;
|
|
130
|
-
declare function arkenv<const T extends SchemaShape, const D extends EnvSchema<T> | CompiledEnvSchema>(def: D, config: ArkEnvConfig & {
|
|
131
|
-
safe: true;
|
|
132
|
-
}): SafeArkEnvResult<ArkenvOutput<T, D>>;
|
|
133
|
-
//#endregion
|
|
134
|
-
//#region src/schema.d.ts
|
|
135
|
-
/**
|
|
136
|
-
* Extract the keys from a schema definition dynamically.
|
|
137
|
-
* Supports plain objects, ArkType schemas, and Standard Schema validators.
|
|
138
|
-
*
|
|
139
|
-
* @param schema The schema definition to extract keys from
|
|
140
|
-
* @returns An array of extracted key names
|
|
141
|
-
* @internal
|
|
142
|
-
*/
|
|
143
|
-
declare function getSchemaKeys(schema: any): string[];
|
|
144
|
-
//#endregion
|
|
145
|
-
//#region src/index.d.ts
|
|
146
|
-
/**
|
|
147
|
-
* Like ArkType's `type`, but with ArkEnv's extra keywords, such as:
|
|
148
|
-
*
|
|
149
|
-
* - `string.host` – a hostname (e.g. `"localhost"`, `"127.0.0.1"`)
|
|
150
|
-
* - `number.port` – a port number (e.g. `8080`)
|
|
151
|
-
*
|
|
152
|
-
* See ArkType's docs for the full API:
|
|
153
|
-
* https://arktype.io/docs/type-api
|
|
154
|
-
*/
|
|
155
|
-
declare const type: _$arktype_internal_type_ts0.TypeParser<{
|
|
156
|
-
string: _$arktype.Submodule<{
|
|
157
|
-
trim: _$arktype.Submodule<_$arktype_internal_keywords_string_ts0.trim.$ & {
|
|
158
|
-
" arkInferred": (In: string) => _$arktype_internal_attributes_ts0.To<string>;
|
|
159
|
-
}>;
|
|
160
|
-
normalize: _$arktype.Submodule<_$arktype_internal_keywords_string_ts0.normalize.$ & {
|
|
161
|
-
" arkInferred": (In: string) => _$arktype_internal_attributes_ts0.To<string>;
|
|
162
|
-
}>;
|
|
163
|
-
root: string;
|
|
164
|
-
alpha: string;
|
|
165
|
-
alphanumeric: string;
|
|
166
|
-
hex: string;
|
|
167
|
-
base64: _$arktype.Submodule<{
|
|
168
|
-
root: string;
|
|
169
|
-
url: string;
|
|
170
|
-
} & {
|
|
171
|
-
" arkInferred": string;
|
|
172
|
-
}>;
|
|
173
|
-
capitalize: _$arktype.Submodule<_$arktype_internal_keywords_string_ts0.capitalize.$ & {
|
|
174
|
-
" arkInferred": (In: string) => _$arktype_internal_attributes_ts0.To<string>;
|
|
175
|
-
}>;
|
|
176
|
-
creditCard: string;
|
|
177
|
-
date: _$arktype.Submodule<_$arktype_internal_keywords_string_ts0.stringDate.$ & {
|
|
178
|
-
" arkInferred": string;
|
|
179
|
-
}>;
|
|
180
|
-
digits: string;
|
|
181
|
-
email: string;
|
|
182
|
-
integer: _$arktype.Submodule<_$arktype_internal_keywords_string_ts0.stringInteger.$ & {
|
|
183
|
-
" arkInferred": string;
|
|
184
|
-
}>;
|
|
185
|
-
ip: _$arktype.Submodule<_$arktype_internal_keywords_string_ts0.ip.$ & {
|
|
186
|
-
" arkInferred": string;
|
|
187
|
-
}>;
|
|
188
|
-
json: _$arktype.Submodule<_$arktype_internal_keywords_string_ts0.stringJson.$ & {
|
|
189
|
-
" arkInferred": string;
|
|
190
|
-
}>;
|
|
191
|
-
lower: _$arktype.Submodule<_$arktype_internal_keywords_string_ts0.lower.$ & {
|
|
192
|
-
" arkInferred": (In: string) => _$arktype_internal_attributes_ts0.To<string>;
|
|
193
|
-
}>;
|
|
194
|
-
numeric: _$arktype.Submodule<_$arktype_internal_keywords_string_ts0.stringNumeric.$ & {
|
|
195
|
-
" arkInferred": string;
|
|
196
|
-
}>;
|
|
197
|
-
regex: string;
|
|
198
|
-
semver: string;
|
|
199
|
-
upper: _$arktype.Submodule<{
|
|
200
|
-
root: (In: string) => _$arktype_internal_attributes_ts0.To<string>;
|
|
201
|
-
preformatted: string;
|
|
202
|
-
} & {
|
|
203
|
-
" arkInferred": (In: string) => _$arktype_internal_attributes_ts0.To<string>;
|
|
204
|
-
}>;
|
|
205
|
-
url: _$arktype.Submodule<_$arktype_internal_keywords_string_ts0.url.$ & {
|
|
206
|
-
" arkInferred": string;
|
|
207
|
-
}>;
|
|
208
|
-
uuid: _$arktype.Submodule<_$arktype_internal_keywords_string_ts0.uuid.$ & {
|
|
209
|
-
" arkInferred": string;
|
|
210
|
-
}>;
|
|
211
|
-
" arkInferred": string;
|
|
212
|
-
host: string;
|
|
213
|
-
}>;
|
|
214
|
-
number: _$arktype.Submodule<{
|
|
215
|
-
NaN: number;
|
|
216
|
-
Infinity: number;
|
|
217
|
-
root: number;
|
|
218
|
-
integer: number;
|
|
219
|
-
" arkInferred": number;
|
|
220
|
-
epoch: number;
|
|
221
|
-
safe: number;
|
|
222
|
-
NegativeInfinity: number;
|
|
223
|
-
port: number;
|
|
224
|
-
}>;
|
|
225
|
-
}>;
|
|
226
|
-
//#endregion
|
|
227
|
-
export { type ArkEnvConfig, type EnvSchema, type Infer, type SafeArkEnvResult, arkenv, arkenv as default, getSchemaKeys, type };
|
|
228
|
-
|
|
229
|
-
// CJS Interop Shim
|
|
230
|
-
if (module.exports && module.exports.default) {
|
|
231
|
-
Object.assign(module.exports.default, module.exports);
|
|
232
|
-
module.exports = module.exports.default;
|
|
233
|
-
}
|
|
234
|
-
|
|
235
|
-
//# 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.
|
|
5
|
-
"description": "
|
|
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
|
-
"
|
|
8
|
-
"types": "./dist/index.d.mts",
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
9
11
|
"exports": {
|
|
10
12
|
".": {
|
|
11
|
-
"types":
|
|
12
|
-
|
|
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
|
-
"
|
|
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
|
-
"
|
|
40
|
-
"
|
|
41
|
-
"
|
|
42
|
-
"
|
|
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.7 kB",
|
|
82
|
-
"import": "*",
|
|
83
|
-
"ignore": [
|
|
84
|
-
"arktype"
|
|
85
|
-
]
|
|
86
|
-
},
|
|
87
|
-
{
|
|
88
|
-
"name": "arkenv/standard",
|
|
89
|
-
"path": "dist/standard.mjs",
|
|
90
|
-
"limit": "3.5 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
|
-
"
|
|
103
|
-
"
|
|
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:
|
|
109
|
-
"
|
|
54
|
+
"test:run": "vitest run",
|
|
55
|
+
"typecheck": "tsc --noEmit"
|
|
110
56
|
}
|
|
111
57
|
}
|
package/dist/core-7-JO-N-w.d.cts
DELETED
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
//#region src/core.d.ts
|
|
2
|
-
/**
|
|
3
|
-
* Machine-readable classification codes for environment validation issues.
|
|
4
|
-
* Serves as the Source of Truth (SoT) for error categorization in ArkEnv.
|
|
5
|
-
*/
|
|
6
|
-
type EnvIssueCode = /** The environment variable is required but was not provided, and has no default value. */"MISSING_VARIABLE" /** The variable value failed a type assertion (e.g., expected a number or boolean but received a string). */ | "INVALID_TYPE" /** The variable value falls below the minimum allowed numeric limit or string/array length constraint. */ | "VALUE_TOO_SMALL" /** The variable value exceeds the maximum allowed numeric limit or string/array length constraint. */ | "VALUE_TOO_LARGE" /** The variable value did not match the specified regular expression (regex) pattern constraint. */ | "PATTERN_MISMATCH" /** The variable value is not in a valid format (e.g., failed email or UUID format validation). */ | "INVALID_FORMAT" /** An undeclared key was found in the environment, and the schema config is set to reject undeclared keys. */ | "UNDECLARED_KEY" /** The provided validation schema definition itself is malformed or invalid. */ | "INVALID_SCHEMA" /** A validation error was triggered by a custom validator function or inline pipe logic. */ | "CUSTOM";
|
|
7
|
-
/**
|
|
8
|
-
* Metadata associated with an environment validation issue.
|
|
9
|
-
*/
|
|
10
|
-
type EnvIssueMeta = {
|
|
11
|
-
/** The minimum expected boundary for numeric/string length constraints */min?: number; /** The maximum expected boundary for numeric/string length constraints */
|
|
12
|
-
max?: number; /** Additional validation pattern/specifier details */
|
|
13
|
-
validation?: string; /** Any custom constraint descriptions */
|
|
14
|
-
constraint?: string; /** Traversal error occurred during JSON-parsing of the environment variable */
|
|
15
|
-
traversalError?: string;
|
|
16
|
-
};
|
|
17
|
-
/**
|
|
18
|
-
* Normalized validation issue representing a failure on a specific environment variable.
|
|
19
|
-
*/
|
|
20
|
-
type EnvIssue = {
|
|
21
|
-
/** The dot-separated property path/name of the environment variable */path: string; /** The descriptive, user-friendly error message */
|
|
22
|
-
message: string; /** The normalized classification code for the issue */
|
|
23
|
-
code: EnvIssueCode; /** The expected type or value shape description */
|
|
24
|
-
expected?: string; /** The raw value received (redacted in string formatting if sensitive) */
|
|
25
|
-
received?: unknown; /** Additional validation metadata */
|
|
26
|
-
meta?: EnvIssueMeta;
|
|
27
|
-
};
|
|
28
|
-
/**
|
|
29
|
-
* Format a list of normalized environment issues into a single styled string.
|
|
30
|
-
*
|
|
31
|
-
* @param issues - The array of normalized issues to format
|
|
32
|
-
* @returns The formatted and styled error report string
|
|
33
|
-
*/
|
|
34
|
-
declare function formatIssues(issues: EnvIssue[]): string;
|
|
35
|
-
/**
|
|
36
|
-
* Error thrown when environment variable validation fails.
|
|
37
|
-
*
|
|
38
|
-
* This error extends the native `Error` class and provides formatted error messages
|
|
39
|
-
* that clearly indicate which environment variables are invalid and why.
|
|
40
|
-
*
|
|
41
|
-
* @example
|
|
42
|
-
* ```ts
|
|
43
|
-
* import arkenv from 'arkenv';
|
|
44
|
-
* import { ArkEnvError } from 'arkenv/core';
|
|
45
|
-
*
|
|
46
|
-
* try {
|
|
47
|
-
* const env = arkenv({
|
|
48
|
-
* PORT: 'number.port',
|
|
49
|
-
* HOST: 'string.host',
|
|
50
|
-
* });
|
|
51
|
-
* } catch (error) {
|
|
52
|
-
* if (error instanceof ArkEnvError) {
|
|
53
|
-
* console.error('Environment validation failed:', error.message);
|
|
54
|
-
* }
|
|
55
|
-
* }
|
|
56
|
-
* ```
|
|
57
|
-
*/
|
|
58
|
-
declare class ArkEnvError extends Error {
|
|
59
|
-
/** The list of normalized issues that caused the validation failure */
|
|
60
|
-
readonly issues: EnvIssue[];
|
|
61
|
-
constructor(issues: EnvIssue[], message?: string);
|
|
62
|
-
}
|
|
63
|
-
/**
|
|
64
|
-
* Result of a non-throwing arkenv parse operation.
|
|
65
|
-
*/
|
|
66
|
-
type SafeArkEnvResult<T> = {
|
|
67
|
-
success: true;
|
|
68
|
-
data: T;
|
|
69
|
-
} | {
|
|
70
|
-
success: false;
|
|
71
|
-
issues: readonly EnvIssue[];
|
|
72
|
-
};
|
|
73
|
-
//#endregion
|
|
74
|
-
export { SafeArkEnvResult as a, EnvIssueMeta as i, EnvIssue as n, formatIssues as o, EnvIssueCode as r, ArkEnvError as t };
|
|
75
|
-
|
|
76
|
-
// CJS Interop Shim
|
|
77
|
-
if (module.exports && module.exports.default) {
|
|
78
|
-
Object.assign(module.exports.default, module.exports);
|
|
79
|
-
module.exports = module.exports.default;
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
//# sourceMappingURL=core-7-JO-N-w.d.cts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"core-7-JO-N-w.d.cts","names":[],"sources":["../src/core.ts"],"mappings":";;AAOA;;;KAAY,YAAA,0tBAuCZ;;;;KAhBY,YAAA;EA4BX,0EA1BA,GAAA,WA0BmB;EAxBnB,GAAA,WAiCe;EA/Bf,UAAA;EAEA,UAAA,WA6B8C;EA3B9C,cAAA;AAAA;;;;KAMW,QAAA;EAsD0B,uEApDrC,IAAA,UAoDgC;EAlDhC,OAAA,UAoDiB;EAlDjB,IAAA,EAAM,YAAA,EAqDG;EAnDT,QAAA,WAoDC;EAlDD,QAAA,YAkDgE;EAhDhE,IAAA,GAAO,YAAA;AAAA;;;;;;;iBASQ,YAAA,CAAa,MAAA,EAAQ,QAAA;;;;;;;;;;;;;;;;;;;;;;;;cAiCxB,WAAA,SAAoB,KAAA;;WAEvB,MAAA,EAAQ,QAAA;cAGhB,MAAA,EAAQ,QAAA,IACR,OAAA;AAAA;;;;KAcU,gBAAA;EACP,OAAA;EAAe,IAAA,EAAM,CAAA;AAAA;EACrB,OAAA;EAAgB,MAAA,WAAiB,QAAA;AAAA"}
|
package/dist/core-A65KioHX.mjs
DELETED
|
@@ -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;function a(e){return 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`,this.issues=t}};Object.defineProperty(o,`name`,{value:`ArkEnvError`});export{a as n,i as r,o as t};
|
|
5
|
-
|
|
6
|
-
//# sourceMappingURL=core-A65KioHX.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"core-A65KioHX.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 * Machine-readable classification codes for environment validation issues.\n * Serves as the Source of Truth (SoT) for error categorization in ArkEnv.\n */\nexport type EnvIssueCode =\n\t/** The environment variable is required but was not provided, and has no default value. */\n\t| \"MISSING_VARIABLE\"\n\t/** The variable value failed a type assertion (e.g., expected a number or boolean but received a string). */\n\t| \"INVALID_TYPE\"\n\t/** The variable value falls below the minimum allowed numeric limit or string/array length constraint. */\n\t| \"VALUE_TOO_SMALL\"\n\t/** The variable value exceeds the maximum allowed numeric limit or string/array length constraint. */\n\t| \"VALUE_TOO_LARGE\"\n\t/** The variable value did not match the specified regular expression (regex) pattern constraint. */\n\t| \"PATTERN_MISMATCH\"\n\t/** The variable value is not in a valid format (e.g., failed email or UUID format validation). */\n\t| \"INVALID_FORMAT\"\n\t/** An undeclared key was found in the environment, and the schema config is set to reject undeclared keys. */\n\t| \"UNDECLARED_KEY\"\n\t/** The provided validation schema definition itself is malformed or invalid. */\n\t| \"INVALID_SCHEMA\"\n\t/** A validation error was triggered by a custom validator function or inline pipe logic. */\n\t| \"CUSTOM\";\n\n/**\n * Metadata associated with an environment validation issue.\n */\nexport type EnvIssueMeta = {\n\t/** The minimum expected boundary for numeric/string length constraints */\n\tmin?: number;\n\t/** The maximum expected boundary for numeric/string length constraints */\n\tmax?: number;\n\t/** Additional validation pattern/specifier details */\n\tvalidation?: string;\n\t/** Any custom constraint descriptions */\n\tconstraint?: string;\n\t/** Traversal error occurred during JSON-parsing of the environment variable */\n\ttraversalError?: string;\n};\n\n/**\n * Normalized validation issue representing a failure on a specific environment variable.\n */\nexport type EnvIssue = {\n\t/** The dot-separated property path/name of the environment variable */\n\tpath: string;\n\t/** The descriptive, user-friendly error message */\n\tmessage: string;\n\t/** The normalized classification code for the issue */\n\tcode: EnvIssueCode;\n\t/** The expected type or value shape description */\n\texpected?: string;\n\t/** The raw value received (redacted in string formatting if sensitive) */\n\treceived?: unknown;\n\t/** Additional validation metadata */\n\tmeta?: EnvIssueMeta;\n};\n\n/**\n * Format a list of normalized environment issues into a single styled string.\n *\n * @param issues - The array of normalized issues to format\n * @returns The formatted and styled error report string\n */\nexport function formatIssues(issues: EnvIssue[]): string {\n\treturn issues\n\t\t.map((issue) => {\n\t\t\tconst pathStr = styleText(\"yellow\", issue.path);\n\t\t\tconst messageStr = issue.message.trimStart();\n\t\t\treturn `${pathStr} ${messageStr}`;\n\t\t})\n\t\t.join(\"\\n\");\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\t/** The list of normalized issues that caused the validation failure */\n\treadonly issues: EnvIssue[];\n\n\tconstructor(\n\t\tissues: EnvIssue[],\n\t\tmessage = \"Errors found while validating environment variables\",\n\t) {\n\t\tconst formattedIssues = formatIssues(issues);\n\t\tsuper(`${styleText(\"red\", message)}\\n${indent(formattedIssues)}\\n`);\n\t\tthis.name = \"ArkEnvError\";\n\t\tthis.issues = issues;\n\t}\n}\n\nObject.defineProperty(ArkEnvError, \"name\", { value: \"ArkEnvError\" });\n\n/**\n * Result of a non-throwing arkenv parse operation.\n */\nexport type SafeArkEnvResult<T> =\n\t| { success: true; data: T }\n\t| { success: false; issues: readonly EnvIssue[] };\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,ECUR,SAAgB,EAAa,EAA4B,CACxD,OAAO,EACL,IAAK,GAGE,GAFS,EAAU,SAAU,EAAM,KAEzB,CAAC,GADC,EAAM,QAAQ,WACF,GAC9B,CACD,KAAK;EAAK,CA0Bb,IAAa,EAAb,cAAiC,KAAM,CAItC,YACC,EACA,EAAU,sDACT,CACD,IAAM,EAAkB,EAAa,EAAO,CAC5C,MAAM,GAAG,EAAU,MAAO,EAAQ,CAAC,IAAI,EAAO,EAAgB,CAAC,IAAI,CACnE,KAAK,KAAO,cACZ,KAAK,OAAS,IAIhB,OAAO,eAAe,EAAa,OAAQ,CAAE,MAAO,cAAe,CAAC"}
|
package/dist/core-BaGd9k2K.d.mts
DELETED
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
//#region src/core.d.ts
|
|
2
|
-
/**
|
|
3
|
-
* Machine-readable classification codes for environment validation issues.
|
|
4
|
-
* Serves as the Source of Truth (SoT) for error categorization in ArkEnv.
|
|
5
|
-
*/
|
|
6
|
-
type EnvIssueCode = /** The environment variable is required but was not provided, and has no default value. */"MISSING_VARIABLE" /** The variable value failed a type assertion (e.g., expected a number or boolean but received a string). */ | "INVALID_TYPE" /** The variable value falls below the minimum allowed numeric limit or string/array length constraint. */ | "VALUE_TOO_SMALL" /** The variable value exceeds the maximum allowed numeric limit or string/array length constraint. */ | "VALUE_TOO_LARGE" /** The variable value did not match the specified regular expression (regex) pattern constraint. */ | "PATTERN_MISMATCH" /** The variable value is not in a valid format (e.g., failed email or UUID format validation). */ | "INVALID_FORMAT" /** An undeclared key was found in the environment, and the schema config is set to reject undeclared keys. */ | "UNDECLARED_KEY" /** The provided validation schema definition itself is malformed or invalid. */ | "INVALID_SCHEMA" /** A validation error was triggered by a custom validator function or inline pipe logic. */ | "CUSTOM";
|
|
7
|
-
/**
|
|
8
|
-
* Metadata associated with an environment validation issue.
|
|
9
|
-
*/
|
|
10
|
-
type EnvIssueMeta = {
|
|
11
|
-
/** The minimum expected boundary for numeric/string length constraints */min?: number; /** The maximum expected boundary for numeric/string length constraints */
|
|
12
|
-
max?: number; /** Additional validation pattern/specifier details */
|
|
13
|
-
validation?: string; /** Any custom constraint descriptions */
|
|
14
|
-
constraint?: string; /** Traversal error occurred during JSON-parsing of the environment variable */
|
|
15
|
-
traversalError?: string;
|
|
16
|
-
};
|
|
17
|
-
/**
|
|
18
|
-
* Normalized validation issue representing a failure on a specific environment variable.
|
|
19
|
-
*/
|
|
20
|
-
type EnvIssue = {
|
|
21
|
-
/** The dot-separated property path/name of the environment variable */path: string; /** The descriptive, user-friendly error message */
|
|
22
|
-
message: string; /** The normalized classification code for the issue */
|
|
23
|
-
code: EnvIssueCode; /** The expected type or value shape description */
|
|
24
|
-
expected?: string; /** The raw value received (redacted in string formatting if sensitive) */
|
|
25
|
-
received?: unknown; /** Additional validation metadata */
|
|
26
|
-
meta?: EnvIssueMeta;
|
|
27
|
-
};
|
|
28
|
-
/**
|
|
29
|
-
* Format a list of normalized environment issues into a single styled string.
|
|
30
|
-
*
|
|
31
|
-
* @param issues - The array of normalized issues to format
|
|
32
|
-
* @returns The formatted and styled error report string
|
|
33
|
-
*/
|
|
34
|
-
declare function formatIssues(issues: EnvIssue[]): string;
|
|
35
|
-
/**
|
|
36
|
-
* Error thrown when environment variable validation fails.
|
|
37
|
-
*
|
|
38
|
-
* This error extends the native `Error` class and provides formatted error messages
|
|
39
|
-
* that clearly indicate which environment variables are invalid and why.
|
|
40
|
-
*
|
|
41
|
-
* @example
|
|
42
|
-
* ```ts
|
|
43
|
-
* import arkenv from 'arkenv';
|
|
44
|
-
* import { ArkEnvError } from 'arkenv/core';
|
|
45
|
-
*
|
|
46
|
-
* try {
|
|
47
|
-
* const env = arkenv({
|
|
48
|
-
* PORT: 'number.port',
|
|
49
|
-
* HOST: 'string.host',
|
|
50
|
-
* });
|
|
51
|
-
* } catch (error) {
|
|
52
|
-
* if (error instanceof ArkEnvError) {
|
|
53
|
-
* console.error('Environment validation failed:', error.message);
|
|
54
|
-
* }
|
|
55
|
-
* }
|
|
56
|
-
* ```
|
|
57
|
-
*/
|
|
58
|
-
declare class ArkEnvError extends Error {
|
|
59
|
-
/** The list of normalized issues that caused the validation failure */
|
|
60
|
-
readonly issues: EnvIssue[];
|
|
61
|
-
constructor(issues: EnvIssue[], message?: string);
|
|
62
|
-
}
|
|
63
|
-
/**
|
|
64
|
-
* Result of a non-throwing arkenv parse operation.
|
|
65
|
-
*/
|
|
66
|
-
type SafeArkEnvResult<T> = {
|
|
67
|
-
success: true;
|
|
68
|
-
data: T;
|
|
69
|
-
} | {
|
|
70
|
-
success: false;
|
|
71
|
-
issues: readonly EnvIssue[];
|
|
72
|
-
};
|
|
73
|
-
//#endregion
|
|
74
|
-
export { SafeArkEnvResult as a, EnvIssueMeta as i, EnvIssue as n, formatIssues as o, EnvIssueCode as r, ArkEnvError as t };
|
|
75
|
-
|
|
76
|
-
//# sourceMappingURL=core-BaGd9k2K.d.mts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"core-BaGd9k2K.d.mts","names":[],"sources":["../src/core.ts"],"mappings":";;AAOA;;;KAAY,YAAA,0tBAuCZ;;;;KAhBY,YAAA;EA4BX,0EA1BA,GAAA,WA0BmB;EAxBnB,GAAA,WAiCe;EA/Bf,UAAA;EAEA,UAAA,WA6B8C;EA3B9C,cAAA;AAAA;;;;KAMW,QAAA;EAsD0B,uEApDrC,IAAA,UAoDgC;EAlDhC,OAAA,UAoDiB;EAlDjB,IAAA,EAAM,YAAA,EAqDG;EAnDT,QAAA,WAoDC;EAlDD,QAAA,YAkDgE;EAhDhE,IAAA,GAAO,YAAA;AAAA;;;;;;;iBASQ,YAAA,CAAa,MAAA,EAAQ,QAAA;;;;;;;;;;;;;;;;;;;;;;;;cAiCxB,WAAA,SAAoB,KAAA;;WAEvB,MAAA,EAAQ,QAAA;cAGhB,MAAA,EAAQ,QAAA,IACR,OAAA;AAAA;;;;KAcU,gBAAA;EACP,OAAA;EAAe,IAAA,EAAM,CAAA;AAAA;EACrB,OAAA;EAAgB,MAAA,WAAiB,QAAA;AAAA"}
|
package/dist/core-CA13n2Iu.cjs
DELETED
|
@@ -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;function a(e){return 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`,this.issues=t}};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-CA13n2Iu.cjs`);exports.ArkEnvError=e.t,exports.formatIssues=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,9 +0,0 @@
|
|
|
1
|
-
import { a as SafeArkEnvResult, i as EnvIssueMeta, n as EnvIssue, o as formatIssues, r as EnvIssueCode, t as ArkEnvError } from "./core-7-JO-N-w.cjs";
|
|
2
|
-
export { ArkEnvError, EnvIssue, EnvIssueCode, EnvIssueMeta, SafeArkEnvResult, formatIssues };
|
|
3
|
-
|
|
4
|
-
// CJS Interop Shim
|
|
5
|
-
if (module.exports && module.exports.default) {
|
|
6
|
-
Object.assign(module.exports.default, module.exports);
|
|
7
|
-
module.exports = module.exports.default;
|
|
8
|
-
}
|
|
9
|
-
|
package/dist/core.d.mts
DELETED
package/dist/core.mjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{n as e,t}from"./core-A65KioHX.mjs";export{t as ArkEnvError,e as formatIssues};
|
package/dist/errors-C_uh86xh.mjs
DELETED
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import{r as e,t}from"./core-A65KioHX.mjs";const n=e=>{if(typeof e==`number`||typeof e!=`string`||!e.trim())return e;if(e.trim()===`NaN`)return NaN;let t=Number(e);return Number.isNaN(t)?e:t},r=e=>e===`true`?!0:e===`false`?!1:e,i=e=>{if(typeof e!=`string`)return e;let t=e.trim();if(t[0]!==`{`&&t[0]!==`[`)return e;try{return JSON.parse(t)}catch{return e}},a=e=>{if(e instanceof Date||typeof e!=`string`||!e.trim())return e;let t=new Date(e);return Number.isNaN(t.getTime())?e:t},o=e=>{let t={};for(let n in e){let r=e[n];r!==``&&(t[n]=r)}return t},s=(e,t=[])=>{let n=[];if(!e||typeof e!=`object`||Array.isArray(e))return n;let r=e;if(`const`in r){let e=typeof r.const;(e===`number`||e===`boolean`)&&n.push({path:[...t],type:`primitive`})}`enum`in r&&Array.isArray(r.enum)&&r.enum.some(e=>typeof e==`number`||typeof e==`boolean`)&&n.push({path:[...t],type:`primitive`});let i=r.type;if(i===`number`||i===`integer`||i===`boolean`)n.push({path:[...t],type:`primitive`});else if(i===`string`&&`format`in r&&(r.format===`date-time`||r.format===`date`))n.push({path:[...t],type:`date`});else if(i===`object`){if(r.properties&&Object.keys(r.properties).length>0){n.push({path:[...t],type:`object`});for(let e in r.properties)n.push(...s(r.properties[e],[...t,e]))}}else i===`array`&&(n.push({path:[...t],type:`array`}),r.items&&(Array.isArray(r.items)?r.items.forEach((e,r)=>{n.push(...s(e,[...t,String(r)]))}):n.push(...s(r.items,[...t,`*`]))));for(let e of[`anyOf`,`allOf`,`oneOf`])if(r[e]&&Array.isArray(r[e]))for(let i of r[e])n.push(...s(i,t));let a=new Set;return n.filter(e=>{let t=e.path.join(`/`)+`:`+e.type;return a.has(t)?!1:a.add(t)})},c=(e,t,o={})=>{let{arrayFormat:s=`comma`}=o,c=e=>{if(s===`json`)try{return JSON.parse(e)}catch{return e}return e.trim()?e.split(`,`).map(e=>e.trim()):[]},l=(e,t)=>{if(t===`array`&&typeof e==`string`)return c(e);if(t===`object`&&typeof e==`string`)return i(e);if(t===`date`&&typeof e==`string`)return a(e);if(t===`primitive`){if(Array.isArray(e))return e.map(e=>{if(typeof e!=`string`)return e;let t=n(e);return typeof t==`number`?t:r(e)});if(typeof e!=`string`)return e;let t=n(e);return typeof t==`number`?t:r(e)}return e};if(typeof e!=`object`||!e){let n=t.find(e=>e.path.length===0);return n?l(e,n.type):e}let u=[...t].sort((e,t)=>e.path.length-t.path.length),d=(e,t,n)=>{if(t.length===0)return n(e);let[r,...i]=t;if(r===`*`){if(Array.isArray(e)){let t=!1,r=e.map(e=>{let r=d(e,i,n);return r!==e&&(t=!0),r});return t?r:e}return e}if(!e||typeof e!=`object`)return e;if(Array.isArray(e)){let t=Number(r);if(!Number.isNaN(t)&&t>=0&&t<e.length){let r=d(e[t],i,n);if(r!==e[t]){let n=[...e];return n[t]=r,n}}return e}if(Object.hasOwn(e,r)){let t=d(e[r],i,n);if(t!==e[r])return{...e,[r]:t}}return e},f=e;for(let e of u)e.path.length>0&&(f=d(f,e.path,t=>l(t,e.type)));return f};function l(e,t,n,r){let i=t?o(e):e,a={...i},l=[];if(r){let e=r();l.push(...e.missingKeys||[]),e.hasSchema&&(a=c(a,s(e.schema),{arrayFormat:n}))}return{processedEnv:i,coercedEnv:a,missingKeys:l}}const u=/secret|(_|^)key(_|$)|token|(_|^)password(_|$)|(_|^)pass(_|$)|(_|^)auth(_|$)|jwt|cert|credential|database_url|db_url/i;function d(e){if(e!==void 0)return e;if(typeof process>`u`)return!1;let t=process.env.ARKENV_DEBUG_SECRETS;return t===`true`||t===`1`}function f(e){return u.test(e)&&!/public/i.test(e)}function p(e,t,n){let r=d(n?.debugSecrets);if(e===void 0)return`missing`;if(e===null)return`null`;if(!r&&f(t))return`[REDACTED]`;if(typeof e==`string`)return JSON.stringify(e);if(typeof e==`number`||typeof e==`boolean`||typeof e==`bigint`)return String(e);if(typeof e==`symbol`)return e.toString();if(typeof e==`function`)return`[Function]`;if(e&&typeof e==`object`)try{if(Array.isArray(e)){let r=e.slice(0,3).map(e=>p(e,t,n));return e.length>3&&r.push(`...(+${e.length-3} more)`),`[${r.join(`, `)}]`}let r=Object.keys(e),i=r.slice(0,3).map(r=>`${r}: ${p(e[r],t,n)}`);return r.length>3&&i.push(`...(+${r.length-3} more)`),`{ ${i.join(`, `)} }`}catch{return Object.prototype.toString.call(e)}return String(e)}const m={required:`MISSING_VARIABLE`,pattern:`PATTERN_MISMATCH`,min:`VALUE_TOO_SMALL`,minLength:`VALUE_TOO_SMALL`,max:`VALUE_TOO_LARGE`,maxLength:`VALUE_TOO_LARGE`,divisor:`INVALID_TYPE`,intersection:`INVALID_TYPE`,union:`INVALID_TYPE`,unit:`INVALID_TYPE`,proto:`INVALID_TYPE`,domain:`INVALID_TYPE`,exactLength:`INVALID_FORMAT`,before:`INVALID_FORMAT`,after:`INVALID_FORMAT`,predicate:`CUSTOM`};function h(e){return e in m?m[e]:`INVALID_FORMAT`}function g(e){let t=e.min??e.rule,n=e.max;return{...typeof t==`number`?{min:t}:{},...typeof n==`number`?{max:n}:{}}}const _={too_small:`VALUE_TOO_SMALL`,too_big:`VALUE_TOO_LARGE`,invalid_string:`INVALID_FORMAT`,invalid_date:`INVALID_FORMAT`,custom:`INVALID_FORMAT`};function v(e,t,n){let r=t.toLowerCase();return e===`invalid_type`&&(n===void 0||n===`undefined`)||r===`required`?`MISSING_VARIABLE`:e in _?_[e]:/regex|pattern|match/.test(r)?`PATTERN_MISMATCH`:`INVALID_TYPE`}function y(e){let t=e.minimum??e.min,n=e.maximum??e.max;return{...typeof t==`number`?{min:t}:{},...typeof n==`number`?{max:n}:{}}}function b(e){try{return{success:!0,data:e()}}catch(e){if(e instanceof t)return{success:!1,issues:e.issues};throw e}}function x(e,t,n,r,i,a){let o={path:e,message:t,code:n,meta:r??{}};return i&&(o.expected=i),a!==void 0&&(o.received=a),o}function S(t,n,r,i,a,o){if(n===`MISSING_VARIABLE`)return r?`must be ${r} (was missing)`:`is required`;if(t.includes(`(was `))return t;let s=`(was ${e(`cyan`,!d(o?.debugSecrets)&&f(a)?`[REDACTED]`:p(i,a,o))})`;return r&&!t.includes(`Expected`)?`must be ${r} ${s}`:`${t} ${s}`}function C(t,n,r){let i=t.match(/\(was (.*)\)/);if(!i?.[1])return t;let a=i[1],o=!d(r)&&f(n)?`[REDACTED]`:a;return o.includes(`\x1B[`)?t:t.replace(`(was ${a})`,`(was ${e(`cyan`,o)})`)}export{h as a,b as c,y as i,l,S as n,v as o,g as r,C as s,x as t};
|
|
2
|
-
|
|
3
|
-
//# sourceMappingURL=errors-C_uh86xh.mjs.map
|