arkenv 0.9.0 → 0.9.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/arktype/index.cjs +8 -1
- package/dist/arktype/index.d.cts +32 -2
- package/dist/arktype/index.d.cts.map +1 -1
- package/dist/arktype/{index.d.ts → index.d.mts} +27 -3
- package/dist/arktype/index.d.mts.map +1 -0
- package/dist/arktype/index.mjs +3 -0
- package/dist/arktype/index.mjs.map +1 -0
- package/dist/{create-env-Dk1I0Ftq.d.ts → create-env-BDbKkDKm.d.mts} +124 -9
- package/dist/create-env-BDbKkDKm.d.mts.map +1 -0
- package/dist/{create-env-gH1q_Fv8.d.cts → create-env-D7N4rUVE.d.cts} +130 -9
- package/dist/create-env-D7N4rUVE.d.cts.map +1 -0
- package/dist/{errors-D_Q1KGgZ.js → errors-Bi-pULbt.mjs} +2 -1
- package/dist/errors-Bi-pULbt.mjs.map +1 -0
- package/dist/{errors-DM9X9ICI.cjs → errors-BtUS5QYF.cjs} +8 -1
- package/dist/index.cjs +8 -1
- package/dist/index.d.cts +32 -3
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +45 -0
- package/dist/index.d.mts.map +1 -0
- package/dist/index.mjs +3 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +18 -12
- package/dist/arktype/index.d.ts.map +0 -1
- package/dist/arktype/index.js +0 -2
- package/dist/arktype/index.js.map +0 -1
- package/dist/create-env-Dk1I0Ftq.d.ts.map +0 -1
- package/dist/create-env-gH1q_Fv8.d.cts.map +0 -1
- package/dist/errors-D_Q1KGgZ.js.map +0 -1
- package/dist/index.d.ts +0 -22
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -2
- package/dist/index.js.map +0 -1
package/README.md
CHANGED
|
@@ -109,7 +109,7 @@ bun add arkenv arktype
|
|
|
109
109
|
|
|
110
110
|
:rocket: **Let's get started!** Read the [2-minute setup guide](https://arkenv.js.org/docs/quickstart) or [start with an example](https://arkenv.js.org/docs/examples).
|
|
111
111
|
|
|
112
|
-
> Improve your DX with _syntax highlighting_ in [VS Code](https://arkenv.js.org/docs/integrations/vscode), [Cursor, Antigravity](https://arkenv.js.org/docs/integrations/open-vsx), and [JetBrains IDEs](https://arkenv.js.org/docs/integrations/jetbrains).
|
|
112
|
+
> Improve your DX with _syntax highlighting_ in [VS Code](https://arkenv.js.org/docs/arkenv/integrations/api/vscode), [Cursor, Antigravity](https://arkenv.js.org/docs/arkenv/integrations/api/open-vsx), and [JetBrains IDEs](https://arkenv.js.org/docs/arkenv/integrations/api/jetbrains).
|
|
113
113
|
|
|
114
114
|
## Requirements
|
|
115
115
|
|
package/dist/arktype/index.cjs
CHANGED
|
@@ -1 +1,8 @@
|
|
|
1
|
-
const e=require(`../errors-
|
|
1
|
+
const e=require(`../errors-BtUS5QYF.cjs`);let t=require(`arktype`);const n=(0,t.type)(`0 <= number.integer <= 65535`),r=(0,t.type)(`string.ip | 'localhost'`),i=(0,t.scope)({string:t.type.module({...t.type.keywords.string,host:r}),number:t.type.module({...t.type.keywords.number,port:n})}),a=e=>{if(typeof e==`number`||typeof e!=`string`)return e;let t=e.trim();if(t===``)return e;if(t===`NaN`)return NaN;let n=Number(t);return Number.isNaN(n)?e:n},o=e=>e===`true`?!0:e===`false`?!1:e,s=e=>{if(typeof e!=`string`)return e;let t=e.trim();if(!t.startsWith(`{`)&&!t.startsWith(`[`))return e;try{return JSON.parse(t)}catch{return e}},c=`*`,l=(e,t=[])=>{let n=[];if(typeof e==`boolean`)return n;if(`const`in e&&(typeof e.const==`number`||typeof e.const==`boolean`)&&n.push({path:[...t],type:`primitive`}),`enum`in e&&e.enum&&e.enum.some(e=>typeof e==`number`||typeof e==`boolean`)&&n.push({path:[...t],type:`primitive`}),`type`in e)if(e.type===`number`||e.type===`integer`)n.push({path:[...t],type:`primitive`});else if(e.type===`boolean`)n.push({path:[...t],type:`primitive`});else if(e.type===`object`){if(`properties`in e&&e.properties&&Object.keys(e.properties).length>0&&n.push({path:[...t],type:`object`}),`properties`in e&&e.properties)for(let[r,i]of Object.entries(e.properties))n.push(...l(i,[...t,r]))}else e.type===`array`&&(n.push({path:[...t],type:`array`}),`items`in e&&e.items&&(Array.isArray(e.items)?e.items.forEach((e,r)=>{n.push(...l(e,[...t,`${r}`]))}):n.push(...l(e.items,[...t,`*`]))));if(`anyOf`in e&&e.anyOf)for(let r of e.anyOf)n.push(...l(r,t));if(`allOf`in e&&e.allOf)for(let r of e.allOf)n.push(...l(r,t));if(`oneOf`in e&&e.oneOf)for(let r of e.oneOf)n.push(...l(r,t));let r=new Set;return n.filter(e=>{let t=JSON.stringify(e.path)+e.type;return r.has(t)?!1:(r.add(t),!0)})},u=(e,t,n={})=>{let{arrayFormat:r=`comma`}=n,i=e=>{if(r===`json`)try{return JSON.parse(e)}catch{return e}return e.trim()?e.split(`,`).map(e=>e.trim()):[]};if(typeof e!=`object`||!e){if(t.some(e=>e.path.length===0)){let n=t.find(e=>e.path.length===0);if(n?.type===`object`&&typeof e==`string`)return s(e);if(n?.type===`array`&&typeof e==`string`)return i(e);let r=a(e);return typeof r==`number`?r:o(e)}return e}let c=[...t].sort((e,t)=>e.path.length-t.path.length),l=(e,t,n)=>{if(!e||typeof e!=`object`||t.length===0)return;if(t.length===1){let r=t[0];if(r===`*`){if(Array.isArray(e))for(let t=0;t<e.length;t++){let r=e[t];if(n===`primitive`){let n=a(r);typeof n==`number`?e[t]=n:e[t]=o(r)}else n===`object`&&(e[t]=s(r))}return}let c=e;if(Object.prototype.hasOwnProperty.call(c,r)){let e=c[r];if(n===`array`&&typeof e==`string`){c[r]=i(e);return}if(n===`object`&&typeof e==`string`){c[r]=s(e);return}if(Array.isArray(e)){if(n===`primitive`)for(let t=0;t<e.length;t++){let n=e[t],r=a(n);typeof r==`number`?e[t]=r:e[t]=o(n)}}else if(n===`primitive`){let t=a(e);typeof t==`number`?c[r]=t:c[r]=o(e)}}return}let[r,...c]=t;if(r===`*`){if(Array.isArray(e))for(let t of e)l(t,c,n);return}l(e[r],c,n)};for(let t of c)l(e,t.path,t.type);return e};function d(e,t,n){let r=l(t.in.toJsonSchema({fallback:e=>e.base}));return r.length===0?t:e(`unknown`).pipe(e=>u(e,r,n)).pipe(t)}const f=i.type;function p(n,r){let{env:a=process.env,coerce:o=!0,onUndeclaredKey:s=`delete`,arrayFormat:c=`comma`}=r,l=(typeof n==`function`&&`assert`in n?n:i.type.raw(n)).onUndeclaredKey(s),u=l;o&&(u=d(i.type,l,{arrayFormat:c}));let f=u(a);if(f instanceof t.ArkErrors)throw new e.t(f);return f}exports.parse=p,exports.type=f;
|
|
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/arktype/index.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { i as SchemaShape, n as EnvSchema, t as ArkEnvConfig } from "../create-env-
|
|
1
|
+
import { i as SchemaShape, n as EnvSchema, t as ArkEnvConfig } from "../create-env-D7N4rUVE.cjs";
|
|
2
2
|
import * as arktype_internal_keywords_string_ts0 from "arktype/internal/keywords/string.ts";
|
|
3
3
|
import * as arktype_internal_attributes_ts0 from "arktype/internal/attributes.ts";
|
|
4
4
|
import * as arktype0 from "arktype";
|
|
@@ -6,8 +6,15 @@ import { distill } from "arktype";
|
|
|
6
6
|
import * as arktype_internal_type_ts0 from "arktype/internal/type.ts";
|
|
7
7
|
|
|
8
8
|
//#region src/arktype/index.d.ts
|
|
9
|
+
|
|
9
10
|
/**
|
|
10
|
-
*
|
|
11
|
+
* Like ArkType’s `type`, but with ArkEnv’s extra keywords, such as:
|
|
12
|
+
*
|
|
13
|
+
* - `string.host` – a hostname (e.g. `"localhost"`, `"127.0.0.1"`)
|
|
14
|
+
* - `number.port` – a port number (e.g. `8080`)
|
|
15
|
+
*
|
|
16
|
+
* See ArkType’s docs for the full API:
|
|
17
|
+
* https://arktype.io/docs/type-api
|
|
11
18
|
*/
|
|
12
19
|
declare const type: arktype_internal_type_ts0.TypeParser<{
|
|
13
20
|
string: arktype0.Submodule<{
|
|
@@ -80,7 +87,30 @@ declare const type: arktype_internal_type_ts0.TypeParser<{
|
|
|
80
87
|
port: number;
|
|
81
88
|
}>;
|
|
82
89
|
}>;
|
|
90
|
+
/**
|
|
91
|
+
* Parse and validate environment variables using ArkEnv’s schema rules.
|
|
92
|
+
*
|
|
93
|
+
* This applies:
|
|
94
|
+
* - schema validation
|
|
95
|
+
* - optional coercion (strings → numbers, booleans, arrays)
|
|
96
|
+
* - undeclared key handling
|
|
97
|
+
*
|
|
98
|
+
* On success, returns the validated environment object.
|
|
99
|
+
* On failure, throws an {@link ArkEnvError}.
|
|
100
|
+
*
|
|
101
|
+
* This is a low-level utility used internally by ArkEnv.
|
|
102
|
+
* Most users should prefer the default `arkenv()` export.
|
|
103
|
+
*
|
|
104
|
+
* @internal
|
|
105
|
+
*/
|
|
83
106
|
declare function parse<const T extends SchemaShape>(def: EnvSchema<T>, config: ArkEnvConfig): any;
|
|
84
107
|
//#endregion
|
|
85
108
|
export { type distill, parse, type };
|
|
109
|
+
|
|
110
|
+
// CJS Interop Shim
|
|
111
|
+
if (module.exports && module.exports.default) {
|
|
112
|
+
Object.assign(module.exports.default, module.exports);
|
|
113
|
+
module.exports = module.exports.default;
|
|
114
|
+
}
|
|
115
|
+
|
|
86
116
|
//# sourceMappingURL=index.d.cts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.cts","names":[],"sources":["../../src/arktype/index.ts"],"sourcesContent":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.cts","names":[],"sources":["../../src/arktype/index.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;;;;;;;;;cA4Ba,gCAAI;;;;;;;;;;;;;;;;;;;sBAAA,CAAA,EAAA,EAAA,MAAA,EAAA,qCAAA,CAAA,MAAA,CAAA;IAAA,CAAA,CAAA;IAkBD,UAAK,EAAA,MAAA;IAAiB,IAAA,oBAAA,qDAAA;MACtB,cAAA,EAAA,MAAA;IAAV,CAAA,CAAA;IACG,MAAA,EAAA,MAAA;IAAY,KAAA,EAAA,MAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAFL,sBAAsB,kBAChC,UAAU,YACP"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { i as SchemaShape, n as EnvSchema, t as ArkEnvConfig } from "../create-env-
|
|
1
|
+
import { i as SchemaShape, n as EnvSchema, t as ArkEnvConfig } from "../create-env-BDbKkDKm.mjs";
|
|
2
2
|
import * as arktype0 from "arktype";
|
|
3
3
|
import { distill } from "arktype";
|
|
4
4
|
import * as arktype_internal_keywords_string_ts0 from "arktype/internal/keywords/string.ts";
|
|
@@ -6,8 +6,15 @@ import * as arktype_internal_attributes_ts0 from "arktype/internal/attributes.ts
|
|
|
6
6
|
import * as arktype_internal_type_ts0 from "arktype/internal/type.ts";
|
|
7
7
|
|
|
8
8
|
//#region src/arktype/index.d.ts
|
|
9
|
+
|
|
9
10
|
/**
|
|
10
|
-
*
|
|
11
|
+
* Like ArkType’s `type`, but with ArkEnv’s extra keywords, such as:
|
|
12
|
+
*
|
|
13
|
+
* - `string.host` – a hostname (e.g. `"localhost"`, `"127.0.0.1"`)
|
|
14
|
+
* - `number.port` – a port number (e.g. `8080`)
|
|
15
|
+
*
|
|
16
|
+
* See ArkType’s docs for the full API:
|
|
17
|
+
* https://arktype.io/docs/type-api
|
|
11
18
|
*/
|
|
12
19
|
declare const type: arktype_internal_type_ts0.TypeParser<{
|
|
13
20
|
string: arktype0.Submodule<{
|
|
@@ -80,7 +87,24 @@ declare const type: arktype_internal_type_ts0.TypeParser<{
|
|
|
80
87
|
port: number;
|
|
81
88
|
}>;
|
|
82
89
|
}>;
|
|
90
|
+
/**
|
|
91
|
+
* Parse and validate environment variables using ArkEnv’s schema rules.
|
|
92
|
+
*
|
|
93
|
+
* This applies:
|
|
94
|
+
* - schema validation
|
|
95
|
+
* - optional coercion (strings → numbers, booleans, arrays)
|
|
96
|
+
* - undeclared key handling
|
|
97
|
+
*
|
|
98
|
+
* On success, returns the validated environment object.
|
|
99
|
+
* On failure, throws an {@link ArkEnvError}.
|
|
100
|
+
*
|
|
101
|
+
* This is a low-level utility used internally by ArkEnv.
|
|
102
|
+
* Most users should prefer the default `arkenv()` export.
|
|
103
|
+
*
|
|
104
|
+
* @internal
|
|
105
|
+
*/
|
|
83
106
|
declare function parse<const T extends SchemaShape>(def: EnvSchema<T>, config: ArkEnvConfig): any;
|
|
84
107
|
//#endregion
|
|
85
108
|
export { type distill, parse, type };
|
|
86
|
-
|
|
109
|
+
|
|
110
|
+
//# sourceMappingURL=index.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../../src/arktype/index.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;;;;;;;;;cA4Ba,gCAAI;;;;;;;;;;;;;;;;;;;sBAAA,CAAA,EAAA,EAAA,MAAA,EAAA,qCAAA,CAAA,MAAA,CAAA;IAAA,CAAA,CAAA;IAkBD,UAAK,EAAA,MAAA;IAAiB,IAAA,oBAAA,qDAAA;MACtB,cAAA,EAAA,MAAA;IAAV,CAAA,CAAA;IACG,MAAA,EAAA,MAAA;IAAY,KAAA,EAAA,MAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAFL,sBAAsB,kBAChC,UAAU,YACP"}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import{t as e}from"../errors-Bi-pULbt.mjs";import{ArkErrors as t,scope as n,type as r}from"arktype";const i=r(`0 <= number.integer <= 65535`),a=r(`string.ip | 'localhost'`),o=n({string:r.module({...r.keywords.string,host:a}),number:r.module({...r.keywords.number,port:i})}),s=e=>{if(typeof e==`number`||typeof e!=`string`)return e;let t=e.trim();if(t===``)return e;if(t===`NaN`)return NaN;let n=Number(t);return Number.isNaN(n)?e:n},c=e=>e===`true`?!0:e===`false`?!1:e,l=e=>{if(typeof e!=`string`)return e;let t=e.trim();if(!t.startsWith(`{`)&&!t.startsWith(`[`))return e;try{return JSON.parse(t)}catch{return e}},u=(e,t=[])=>{let n=[];if(typeof e==`boolean`)return n;if(`const`in e&&(typeof e.const==`number`||typeof e.const==`boolean`)&&n.push({path:[...t],type:`primitive`}),`enum`in e&&e.enum&&e.enum.some(e=>typeof e==`number`||typeof e==`boolean`)&&n.push({path:[...t],type:`primitive`}),`type`in e)if(e.type===`number`||e.type===`integer`)n.push({path:[...t],type:`primitive`});else if(e.type===`boolean`)n.push({path:[...t],type:`primitive`});else if(e.type===`object`){if(`properties`in e&&e.properties&&Object.keys(e.properties).length>0&&n.push({path:[...t],type:`object`}),`properties`in e&&e.properties)for(let[r,i]of Object.entries(e.properties))n.push(...u(i,[...t,r]))}else e.type===`array`&&(n.push({path:[...t],type:`array`}),`items`in e&&e.items&&(Array.isArray(e.items)?e.items.forEach((e,r)=>{n.push(...u(e,[...t,`${r}`]))}):n.push(...u(e.items,[...t,`*`]))));if(`anyOf`in e&&e.anyOf)for(let r of e.anyOf)n.push(...u(r,t));if(`allOf`in e&&e.allOf)for(let r of e.allOf)n.push(...u(r,t));if(`oneOf`in e&&e.oneOf)for(let r of e.oneOf)n.push(...u(r,t));let r=new Set;return n.filter(e=>{let t=JSON.stringify(e.path)+e.type;return r.has(t)?!1:(r.add(t),!0)})},d=(e,t,n={})=>{let{arrayFormat:r=`comma`}=n,i=e=>{if(r===`json`)try{return JSON.parse(e)}catch{return e}return e.trim()?e.split(`,`).map(e=>e.trim()):[]};if(typeof e!=`object`||!e){if(t.some(e=>e.path.length===0)){let n=t.find(e=>e.path.length===0);if(n?.type===`object`&&typeof e==`string`)return l(e);if(n?.type===`array`&&typeof e==`string`)return i(e);let r=s(e);return typeof r==`number`?r:c(e)}return e}let a=[...t].sort((e,t)=>e.path.length-t.path.length),o=(e,t,n)=>{if(!e||typeof e!=`object`||t.length===0)return;if(t.length===1){let r=t[0];if(r===`*`){if(Array.isArray(e))for(let t=0;t<e.length;t++){let r=e[t];if(n===`primitive`){let n=s(r);typeof n==`number`?e[t]=n:e[t]=c(r)}else n===`object`&&(e[t]=l(r))}return}let a=e;if(Object.prototype.hasOwnProperty.call(a,r)){let e=a[r];if(n===`array`&&typeof e==`string`){a[r]=i(e);return}if(n===`object`&&typeof e==`string`){a[r]=l(e);return}if(Array.isArray(e)){if(n===`primitive`)for(let t=0;t<e.length;t++){let n=e[t],r=s(n);typeof r==`number`?e[t]=r:e[t]=c(n)}}else if(n===`primitive`){let t=s(e);typeof t==`number`?a[r]=t:a[r]=c(e)}}return}let[r,...a]=t;if(r===`*`){if(Array.isArray(e))for(let t of e)o(t,a,n);return}o(e[r],a,n)};for(let t of a)o(e,t.path,t.type);return e};function f(e,t,n){let r=u(t.in.toJsonSchema({fallback:e=>e.base}));return r.length===0?t:e(`unknown`).pipe(e=>d(e,r,n)).pipe(t)}const p=o.type;function m(n,r){let{env:i=process.env,coerce:a=!0,onUndeclaredKey:s=`delete`,arrayFormat:c=`comma`}=r,l=(typeof n==`function`&&`assert`in n?n:o.type.raw(n)).onUndeclaredKey(s),u=l;a&&(u=f(o.type,l,{arrayFormat:c}));let d=u(i);if(d instanceof t)throw new e(d);return d}export{m as parse,p as type};
|
|
2
|
+
|
|
3
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.mjs","names":["t","e","n","results: CoercionTarget[]","i","type","$"],"sources":["../../../internal/scope/dist/index.js","../../src/arktype/coercion/morphs.ts","../../src/arktype/coercion/coerce.ts","../../src/arktype/index.ts"],"sourcesContent":["import{scope as e,type as t}from\"arktype\";const n=t(`0 <= number.integer <= 65535`),r=t(`string.ip | 'localhost'`),i=e({string:t.module({...t.keywords.string,host:r}),number:t.module({...t.keywords.number,port:n})});export{i as $};\n//# sourceMappingURL=index.js.map","/**\n * Attempt to coerce a value to a number.\n *\n * If the input is already a number, returns it unchanged.\n * If the input is a string that can be parsed as a number, returns the parsed number.\n * Otherwise, returns the original value unchanged.\n *\n * @internal\n * @param s - The value to coerce\n * @returns The coerced number or the original value\n */\nexport const coerceNumber = (s: unknown) => {\n\tif (typeof s === \"number\") return s;\n\tif (typeof s !== \"string\") return s;\n\tconst trimmed = s.trim();\n\tif (trimmed === \"\") return s;\n\tif (trimmed === \"NaN\") return Number.NaN;\n\tconst n = Number(trimmed);\n\treturn Number.isNaN(n) ? s : n;\n};\n\n/**\n * Attempt to coerce a value to a boolean.\n *\n * Convert the strings \"true\" and \"false\" to their boolean equivalents.\n * All other values are returned unchanged.\n *\n * @internal\n * @param s - The value to coerce\n * @returns The coerced boolean or the original value\n */\nexport const coerceBoolean = (s: unknown) => {\n\tif (s === \"true\") return true;\n\tif (s === \"false\") return false;\n\treturn s;\n};\n\n/**\n * Attempt to parse a value as JSON.\n *\n * If the input is a string that starts with `{` or `[` and can be parsed as JSON,\n * returns the parsed object or array. Otherwise, returns the original value unchanged.\n *\n * @internal\n * @param s - The value to parse\n * @returns The parsed JSON or the original value\n */\nexport const coerceJson = (s: unknown) => {\n\tif (typeof s !== \"string\") return s;\n\tconst trimmed = s.trim();\n\tif (!trimmed.startsWith(\"{\") && !trimmed.startsWith(\"[\")) return s;\n\ttry {\n\t\treturn JSON.parse(trimmed);\n\t} catch {\n\t\treturn s;\n\t}\n};\n","import type { BaseType, JsonSchema } from \"arktype\";\nimport { ArkEnvError } from \"../../errors.ts\";\nimport { coerceBoolean, coerceJson, coerceNumber } from \"./morphs.ts\";\n\n/**\n * A marker used in the coercion path to indicate that the target\n * is the *elements* of an array, rather than the array property itself.\n */\nconst ARRAY_ITEM_MARKER = \"*\";\n\n/**\n * @internal\n * Information about a path in the schema that requires coercion.\n */\ntype CoercionTarget = {\n\tpath: string[];\n\ttype: \"primitive\" | \"array\" | \"object\";\n};\n\n/**\n * Options for coercion behavior.\n */\nexport type CoerceOptions = {\n\t/**\n\t * format to use for array parsing\n\t * @default \"comma\"\n\t */\n\tarrayFormat?: \"comma\" | \"json\";\n};\n\n/**\n * Recursively find all paths in a JSON Schema that require coercion.\n * We prioritize \"number\", \"integer\", \"boolean\", \"array\", and \"object\" types.\n */\nconst findCoercionPaths = (\n\tnode: JsonSchema,\n\tpath: string[] = [],\n): CoercionTarget[] => {\n\tconst results: CoercionTarget[] = [];\n\n\tif (typeof node === \"boolean\") {\n\t\treturn results;\n\t}\n\n\tif (\"const\" in node) {\n\t\tif (typeof node.const === \"number\" || typeof node.const === \"boolean\") {\n\t\t\tresults.push({ path: [...path], type: \"primitive\" });\n\t\t}\n\t}\n\n\tif (\"enum\" in node && node.enum) {\n\t\tif (\n\t\t\tnode.enum.some((v) => typeof v === \"number\" || typeof v === \"boolean\")\n\t\t) {\n\t\t\tresults.push({ path: [...path], type: \"primitive\" });\n\t\t}\n\t}\n\n\tif (\"type\" in node) {\n\t\tif (node.type === \"number\" || node.type === \"integer\") {\n\t\t\tresults.push({ path: [...path], type: \"primitive\" });\n\t\t} else if (node.type === \"boolean\") {\n\t\t\tresults.push({ path: [...path], type: \"primitive\" });\n\t\t} else if (node.type === \"object\") {\n\t\t\t// Check if this object has properties defined\n\t\t\t// If it does, we want to coerce the whole object from a JSON string\n\t\t\t// But we also want to recursively check nested properties\n\t\t\tconst hasProperties =\n\t\t\t\t\"properties\" in node &&\n\t\t\t\tnode.properties &&\n\t\t\t\tObject.keys(node.properties).length > 0;\n\n\t\t\tif (hasProperties) {\n\t\t\t\t// Mark this path as needing object coercion (JSON parsing)\n\t\t\t\tresults.push({ path: [...path], type: \"object\" });\n\t\t\t}\n\n\t\t\t// Also recursively check nested properties for their own coercions\n\t\t\tif (\"properties\" in node && node.properties) {\n\t\t\t\tfor (const [key, prop] of Object.entries(node.properties)) {\n\t\t\t\t\tresults.push(\n\t\t\t\t\t\t...findCoercionPaths(prop as JsonSchema, [...path, key]),\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\t\t} else if (node.type === \"array\") {\n\t\t\t// Mark the array itself as a target for splitting strings\n\t\t\tresults.push({ path: [...path], type: \"array\" });\n\n\t\t\tif (\"items\" in node && node.items) {\n\t\t\t\tif (Array.isArray(node.items)) {\n\t\t\t\t\t// Tuple traversal\n\t\t\t\t\tnode.items.forEach((item, index) => {\n\t\t\t\t\t\tresults.push(\n\t\t\t\t\t\t\t...findCoercionPaths(item as JsonSchema, [...path, `${index}`]),\n\t\t\t\t\t\t);\n\t\t\t\t\t});\n\t\t\t\t} else {\n\t\t\t\t\t// List traversal\n\t\t\t\t\tresults.push(\n\t\t\t\t\t\t...findCoercionPaths(node.items as JsonSchema, [\n\t\t\t\t\t\t\t...path,\n\t\t\t\t\t\t\tARRAY_ITEM_MARKER,\n\t\t\t\t\t\t]),\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tif (\"anyOf\" in node && node.anyOf) {\n\t\tfor (const branch of node.anyOf) {\n\t\t\tresults.push(...findCoercionPaths(branch as JsonSchema, path));\n\t\t}\n\t}\n\n\tif (\"allOf\" in node && node.allOf) {\n\t\tfor (const branch of node.allOf) {\n\t\t\tresults.push(...findCoercionPaths(branch as JsonSchema, path));\n\t\t}\n\t}\n\n\tif (\"oneOf\" in node && node.oneOf) {\n\t\tfor (const branch of node.oneOf) {\n\t\t\tresults.push(...findCoercionPaths(branch as JsonSchema, path));\n\t\t}\n\t}\n\n\t// Deduplicate by path and type combination\n\tconst seen = new Set<string>();\n\treturn results.filter((t) => {\n\t\tconst key = JSON.stringify(t.path) + t.type;\n\t\tif (seen.has(key)) return false;\n\t\tseen.add(key);\n\t\treturn true;\n\t});\n};\n\n/**\n * Apply coercion to a data object based on identified paths.\n */\nconst applyCoercion = (\n\tdata: unknown,\n\ttargets: CoercionTarget[],\n\toptions: CoerceOptions = {},\n) => {\n\tconst { arrayFormat = \"comma\" } = options;\n\n\t// Helper to split string to array\n\tconst splitString = (val: string) => {\n\t\tif (arrayFormat === \"json\") {\n\t\t\ttry {\n\t\t\t\treturn JSON.parse(val);\n\t\t\t} catch {\n\t\t\t\treturn val;\n\t\t\t}\n\t\t}\n\n\t\tif (!val.trim()) return [];\n\t\treturn val.split(\",\").map((s) => s.trim());\n\t};\n\n\tif (typeof data !== \"object\" || data === null) {\n\t\t// If root data needs coercion\n\t\tif (targets.some((t) => t.path.length === 0)) {\n\t\t\tconst rootTarget = targets.find((t) => t.path.length === 0);\n\n\t\t\tif (rootTarget?.type === \"object\" && typeof data === \"string\") {\n\t\t\t\treturn coerceJson(data);\n\t\t\t}\n\n\t\t\tif (rootTarget?.type === \"array\" && typeof data === \"string\") {\n\t\t\t\treturn splitString(data);\n\t\t\t}\n\n\t\t\tconst asNumber = coerceNumber(data);\n\t\t\tif (typeof asNumber === \"number\") {\n\t\t\t\treturn asNumber;\n\t\t\t}\n\t\t\treturn coerceBoolean(data);\n\t\t}\n\t\treturn data;\n\t}\n\n\t// Sort targets by path length to ensure parent objects/arrays are coerced before their children\n\tconst sortedTargets = [...targets].sort(\n\t\t(a, b) => a.path.length - b.path.length,\n\t);\n\n\tconst walk = (\n\t\tcurrent: unknown,\n\t\ttargetPath: string[],\n\t\ttype: \"primitive\" | \"array\" | \"object\",\n\t) => {\n\t\tif (!current || typeof current !== \"object\") return;\n\n\t\tif (targetPath.length === 0) {\n\t\t\treturn;\n\t\t}\n\n\t\t// If we've reached the last key, apply coercion\n\t\tif (targetPath.length === 1) {\n\t\t\tconst lastKey = targetPath[0];\n\n\t\t\tif (lastKey === ARRAY_ITEM_MARKER) {\n\t\t\t\tif (Array.isArray(current)) {\n\t\t\t\t\tfor (let i = 0; i < current.length; i++) {\n\t\t\t\t\t\tconst original = current[i];\n\t\t\t\t\t\tif (type === \"primitive\") {\n\t\t\t\t\t\t\tconst asNumber = coerceNumber(original);\n\t\t\t\t\t\t\tif (typeof asNumber === \"number\") {\n\t\t\t\t\t\t\t\tcurrent[i] = asNumber;\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tcurrent[i] = coerceBoolean(original);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} else if (type === \"object\") {\n\t\t\t\t\t\t\tcurrent[i] = coerceJson(original);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst record = current as Record<string, unknown>;\n\t\t\t// biome-ignore lint/suspicious/noPrototypeBuiltins: ES2020 compatibility\n\t\t\tif (Object.prototype.hasOwnProperty.call(record, lastKey)) {\n\t\t\t\tconst original = record[lastKey];\n\n\t\t\t\tif (type === \"array\" && typeof original === \"string\") {\n\t\t\t\t\trecord[lastKey] = splitString(original);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tif (type === \"object\" && typeof original === \"string\") {\n\t\t\t\t\trecord[lastKey] = coerceJson(original);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tif (Array.isArray(original)) {\n\t\t\t\t\tif (type === \"primitive\") {\n\t\t\t\t\t\tfor (let i = 0; i < original.length; i++) {\n\t\t\t\t\t\t\tconst item = original[i];\n\t\t\t\t\t\t\tconst asNumber = coerceNumber(item);\n\t\t\t\t\t\t\tif (typeof asNumber === \"number\") {\n\t\t\t\t\t\t\t\toriginal[i] = asNumber;\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\toriginal[i] = coerceBoolean(item);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tif (type === \"primitive\") {\n\t\t\t\t\t\tconst asNumber = coerceNumber(original);\n\t\t\t\t\t\t// If numeric parsing didn't produce a number, try boolean coercion\n\t\t\t\t\t\tif (typeof asNumber === \"number\") {\n\t\t\t\t\t\t\trecord[lastKey] = asNumber;\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\trecord[lastKey] = coerceBoolean(original);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\n\t\t// Recurse down\n\t\tconst [nextKey, ...rest] = targetPath;\n\n\t\tif (nextKey === ARRAY_ITEM_MARKER) {\n\t\t\tif (Array.isArray(current)) {\n\t\t\t\tfor (const item of current) {\n\t\t\t\t\twalk(item, rest, type);\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\n\t\tconst record = current as Record<string, unknown>;\n\t\twalk(record[nextKey], rest, type);\n\t};\n\n\tfor (const target of sortedTargets) {\n\t\twalk(data, target.path, target.type);\n\t}\n\n\treturn data;\n};\n\n/**\n * Create a coercing wrapper around an ArkType schema using JSON Schema introspection.\n * Pre-process input data to coerce string values to numbers/booleans at identified paths\n * before validation.\n */\nexport function coerce<t, $ = {}>(\n\tat: any,\n\tschema: BaseType<t, $>,\n\toptions?: CoerceOptions,\n): BaseType<t, $> {\n\t// Use a fallback to handle unjsonifiable parts of the schema (like predicates)\n\t// by preserving the base schema. This ensures that even if part of the schema\n\t// cannot be fully represented in JSON Schema, we can still perform coercion\n\t// for the parts that can.\n\tconst json = schema.in.toJsonSchema({\n\t\tfallback: (ctx) => (ctx as any).base,\n\t});\n\tconst targets = findCoercionPaths(json as any);\n\n\tif (targets.length === 0) {\n\t\treturn schema;\n\t}\n\n\t/*\n\t * We use `type(\"unknown\")` to start the pipeline, which initializes a default scope.\n\t * Integrating the original `schema` with its custom scope `$` into this pipeline\n\t * creates a scope mismatch in TypeScript ({} vs $).\n\t * We cast to `BaseType<t, $>` to assert the final contract is maintained.\n\t */\n\treturn at(\"unknown\")\n\t\t.pipe((data: unknown) => applyCoercion(data, targets, options))\n\t\t.pipe(schema) as BaseType<t, $>;\n}\n","import { $ } from \"@repo/scope\";\nimport type { SchemaShape } from \"@repo/types\";\nimport type { distill } from \"arktype\";\nimport { ArkErrors } from \"arktype\";\nimport type { ArkEnvConfig, EnvSchema } from \"../create-env.ts\";\nimport { ArkEnvError } from \"../errors.ts\";\nimport { coerce } from \"./coercion/coerce.ts\";\n\n/**\n * Re-export of ArkType’s `distill` utilities.\n *\n * Exposed for internal use cases and type-level integrations.\n * ArkEnv does not add behavior or guarantees beyond what ArkType provides.\n *\n * @internal\n * @see https://github.com/arktypeio/arktype\n */\nexport type { distill };\n\n/**\n * Like ArkType’s `type`, but with ArkEnv’s extra keywords, such as:\n *\n * - `string.host` – a hostname (e.g. `\"localhost\"`, `\"127.0.0.1\"`)\n * - `number.port` – a port number (e.g. `8080`)\n *\n * See ArkType’s docs for the full API:\n * https://arktype.io/docs/type-api\n */\nexport const type = $.type;\n\n/**\n * Parse and validate environment variables using ArkEnv’s schema rules.\n *\n * This applies:\n * - schema validation\n * - optional coercion (strings → numbers, booleans, arrays)\n * - undeclared key handling\n *\n * On success, returns the validated environment object.\n * On failure, throws an {@link ArkEnvError}.\n *\n * This is a low-level utility used internally by ArkEnv.\n * Most users should prefer the default `arkenv()` export.\n *\n * @internal\n */\nexport function parse<const T extends SchemaShape>(\n\tdef: EnvSchema<T>,\n\tconfig: ArkEnvConfig,\n) {\n\tconst {\n\t\tenv = process.env,\n\t\tcoerce: shouldCoerce = true,\n\t\tonUndeclaredKey = \"delete\",\n\t\tarrayFormat = \"comma\",\n\t} = config;\n\n\t// If def is a type definition (has assert method), use it directly\n\t// Otherwise, use raw() to convert the schema definition\n\tconst isCompiledType = typeof def === \"function\" && \"assert\" in def;\n\tconst schema = (isCompiledType ? def : $.type.raw(def)) as any;\n\n\t// Apply the `onUndeclaredKey` option\n\tconst schemaWithKeys = schema.onUndeclaredKey(onUndeclaredKey);\n\n\t// Apply coercion transformation to allow strings to be parsed as numbers/booleans\n\tlet finalSchema = schemaWithKeys;\n\tif (shouldCoerce) {\n\t\tfinalSchema = coerce($.type, schemaWithKeys, { arrayFormat });\n\t}\n\n\t// Validate the environment variables\n\tconst validatedEnv = finalSchema(env);\n\n\t// In ArkType 2.x, calling a type as a function returns the validated data or ArkErrors\n\tif (validatedEnv instanceof ArkErrors) {\n\t\tthrow new ArkEnvError(validatedEnv);\n\t}\n\n\treturn validatedEnv;\n}\n"],"mappings":"oGAA0C,MAAM,EAAEA,EAAE,+BAA+B,CAAC,EAAEA,EAAE,0BAA0B,CAAC,EAAEC,EAAE,CAAC,OAAOD,EAAE,OAAO,CAAC,GAAGA,EAAE,SAAS,OAAO,KAAK,EAAE,CAAC,CAAC,OAAOA,EAAE,OAAO,CAAC,GAAGA,EAAE,SAAS,OAAO,KAAK,EAAE,CAAC,CAAC,CAAC,CCW1M,EAAgB,GAAe,CAE3C,GADI,OAAO,GAAM,UACb,OAAO,GAAM,SAAU,OAAO,EAClC,IAAM,EAAU,EAAE,MAAM,CACxB,GAAI,IAAY,GAAI,OAAO,EAC3B,GAAI,IAAY,MAAO,MAAO,KAC9B,IAAME,EAAI,OAAO,EAAQ,CACzB,OAAO,OAAO,MAAMA,EAAE,CAAG,EAAIA,GAajB,EAAiB,GACzB,IAAM,OAAe,GACrB,IAAM,QAAgB,GACnB,EAaK,EAAc,GAAe,CACzC,GAAI,OAAO,GAAM,SAAU,OAAO,EAClC,IAAM,EAAU,EAAE,MAAM,CACxB,GAAI,CAAC,EAAQ,WAAW,IAAI,EAAI,CAAC,EAAQ,WAAW,IAAI,CAAE,OAAO,EACjE,GAAI,CACH,OAAO,KAAK,MAAM,EAAQ,MACnB,CACP,OAAO,ICpBH,GACL,EACA,EAAiB,EAAE,GACG,CACtB,IAAMC,EAA4B,EAAE,CAEpC,GAAI,OAAO,GAAS,UACnB,OAAO,EAiBR,GAdI,UAAW,IACV,OAAO,EAAK,OAAU,UAAY,OAAO,EAAK,OAAU,YAC3D,EAAQ,KAAK,CAAE,KAAM,CAAC,GAAG,EAAK,CAAE,KAAM,YAAa,CAAC,CAIlD,SAAU,GAAQ,EAAK,MAEzB,EAAK,KAAK,KAAM,GAAM,OAAO,G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AAW,GAAS,EAAY,KAChC,CAAC,CAC4C,CAY9C,OAVI,EAAQ,SAAW,EACf,EASD,EAAG,UAAU,CAClB,KAAM,GAAkB,EAAc,EAAM,EAAS,EAAQ,CAAC,CAC9D,KAAK,EAAO,CCnSf,MAAa,EAAOC,EAAE,KAkBtB,SAAgB,EACf,EACA,EACC,CACD,GAAM,CACL,MAAM,QAAQ,IACd,OAAQ,EAAe,GACvB,kBAAkB,SAClB,cAAc,SACX,EAQE,GAJiB,OAAO,GAAQ,YAAc,WAAY,EAC/B,EAAMA,EAAE,KAAK,IAAI,EAAI,EAGxB,gBAAgB,EAAgB,CAG1D,EAAc,EACd,IACH,EAAc,EAAOA,EAAE,KAAM,EAAgB,CAAE,cAAa,CAAC,EAI9D,IAAM,EAAe,EAAY,EAAI,CAGrC,GAAI,aAAwB,EAC3B,MAAM,IAAI,EAAY,EAAa,CAGpC,OAAO"}
|
|
@@ -6,14 +6,100 @@ import * as arktype_internal_attributes_ts0 from "arktype/internal/attributes.ts
|
|
|
6
6
|
//#region ../internal/types/dist/helpers.d.ts
|
|
7
7
|
type Dict<T> = Record<string, T | undefined>;
|
|
8
8
|
//#endregion
|
|
9
|
+
//#region ../internal/types/dist/standard-schema.d.ts
|
|
10
|
+
/**
|
|
11
|
+
* @see https://github.com/standard-schema/standard-schema/tree/3130ce43fdd848d9ab49dbb0458d04f18459961c/packages/spec
|
|
12
|
+
*
|
|
13
|
+
* Copied from standard-schema (MIT License)
|
|
14
|
+
* Copyright (c) 2024 Colin McDannell
|
|
15
|
+
*/
|
|
16
|
+
/** The Standard Typed interface. This is a base type extended by other specs. */
|
|
17
|
+
interface StandardTypedV1<Input = unknown, Output = Input> {
|
|
18
|
+
/** The Standard properties. */
|
|
19
|
+
readonly "~standard": StandardTypedV1.Props<Input, Output>;
|
|
20
|
+
}
|
|
21
|
+
declare namespace StandardTypedV1 {
|
|
22
|
+
/** The Standard Typed properties interface. */
|
|
23
|
+
interface Props<Input = unknown, Output = Input> {
|
|
24
|
+
/** The version number of the standard. */
|
|
25
|
+
readonly version: 1;
|
|
26
|
+
/** The vendor name of the schema library. */
|
|
27
|
+
readonly vendor: string;
|
|
28
|
+
/** Inferred types associated with the schema. */
|
|
29
|
+
readonly types?: Types<Input, Output> | undefined;
|
|
30
|
+
}
|
|
31
|
+
/** The Standard Typed types interface. */
|
|
32
|
+
interface Types<Input = unknown, Output = Input> {
|
|
33
|
+
/** The input type of the schema. */
|
|
34
|
+
readonly input: Input;
|
|
35
|
+
/** The output type of the schema. */
|
|
36
|
+
readonly output: Output;
|
|
37
|
+
}
|
|
38
|
+
/** Infers the input type of a Standard Typed. */
|
|
39
|
+
type InferInput<Schema extends StandardTypedV1> = NonNullable<Schema["~standard"]["types"]>["input"];
|
|
40
|
+
/** Infers the output type of a Standard Typed. */
|
|
41
|
+
type InferOutput<Schema extends StandardTypedV1> = NonNullable<Schema["~standard"]["types"]>["output"];
|
|
42
|
+
}
|
|
43
|
+
/** The Standard Schema interface. */
|
|
44
|
+
interface StandardSchemaV1<Input = unknown, Output = Input> {
|
|
45
|
+
/** The Standard Schema properties. */
|
|
46
|
+
readonly "~standard": StandardSchemaV1.Props<Input, Output>;
|
|
47
|
+
}
|
|
48
|
+
declare namespace StandardSchemaV1 {
|
|
49
|
+
/** The Standard Schema properties interface. */
|
|
50
|
+
interface Props<Input = unknown, Output = Input> extends StandardTypedV1.Props<Input, Output> {
|
|
51
|
+
/** Validates unknown input values. */
|
|
52
|
+
readonly validate: (value: unknown, options?: StandardSchemaV1.Options | undefined) => Result<Output> | Promise<Result<Output>>;
|
|
53
|
+
}
|
|
54
|
+
/** The result interface of the validate function. */
|
|
55
|
+
type Result<Output> = SuccessResult<Output> | FailureResult;
|
|
56
|
+
/** The result interface if validation succeeds. */
|
|
57
|
+
interface SuccessResult<Output> {
|
|
58
|
+
/** The typed output value. */
|
|
59
|
+
readonly value: Output;
|
|
60
|
+
/** A falsy value for `issues` indicates success. */
|
|
61
|
+
readonly issues?: undefined;
|
|
62
|
+
}
|
|
63
|
+
interface Options {
|
|
64
|
+
/** Explicit support for additional vendor-specific parameters, if needed. */
|
|
65
|
+
readonly libraryOptions?: Record<string, unknown> | undefined;
|
|
66
|
+
}
|
|
67
|
+
/** The result interface if validation fails. */
|
|
68
|
+
interface FailureResult {
|
|
69
|
+
/** The issues of failed validation. */
|
|
70
|
+
readonly issues: ReadonlyArray<Issue>;
|
|
71
|
+
}
|
|
72
|
+
/** The issue interface of the failure output. */
|
|
73
|
+
interface Issue {
|
|
74
|
+
/** The error message of the issue. */
|
|
75
|
+
readonly message: string;
|
|
76
|
+
/** The path of the issue, if any. */
|
|
77
|
+
readonly path?: ReadonlyArray<PropertyKey | PathSegment> | undefined;
|
|
78
|
+
}
|
|
79
|
+
/** The path segment interface of the issue. */
|
|
80
|
+
interface PathSegment {
|
|
81
|
+
/** The key representing a path segment. */
|
|
82
|
+
readonly key: PropertyKey;
|
|
83
|
+
}
|
|
84
|
+
/** The Standard types interface. */
|
|
85
|
+
interface Types<Input = unknown, Output = Input> extends StandardTypedV1.Types<Input, Output> {}
|
|
86
|
+
/** Infers the input type of a Standard. */
|
|
87
|
+
type InferInput<Schema extends StandardTypedV1> = StandardTypedV1.InferInput<Schema>;
|
|
88
|
+
/** Infers the output type of a Standard. */
|
|
89
|
+
type InferOutput<Schema extends StandardTypedV1> = StandardTypedV1.InferOutput<Schema>;
|
|
90
|
+
}
|
|
91
|
+
//#endregion
|
|
9
92
|
//#region ../internal/types/dist/infer-type.d.ts
|
|
10
93
|
/**
|
|
11
|
-
* Extract the inferred type from
|
|
12
|
-
*
|
|
94
|
+
* Extract the inferred type from a schema definition.
|
|
95
|
+
* Supports both ArkType type definitions and Standard Schema 1.0 validators.
|
|
96
|
+
*
|
|
97
|
+
* For Standard Schema validators (e.g., Zod, Valibot), extracts the output type.
|
|
98
|
+
* For ArkType definitions, checks the call signature or type properties.
|
|
13
99
|
*
|
|
14
|
-
* @template T - The
|
|
100
|
+
* @template T - The schema definition to infer from
|
|
15
101
|
*/
|
|
16
|
-
type InferType<T> = T extends ((value: Record<string, string | undefined>) => infer R) ? R extends type.errors ? never : R : T extends {
|
|
102
|
+
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 {
|
|
17
103
|
t: infer U;
|
|
18
104
|
} ? U : T extends type.Any<infer U, infer _Scope> ? U : never;
|
|
19
105
|
//#endregion
|
|
@@ -100,10 +186,36 @@ type $ = (typeof $)["t"];
|
|
|
100
186
|
//#endregion
|
|
101
187
|
//#region ../internal/types/dist/schema.d.ts
|
|
102
188
|
type SchemaShape = Record<string, unknown>;
|
|
103
|
-
|
|
189
|
+
/**
|
|
190
|
+
* @internal
|
|
191
|
+
*
|
|
192
|
+
* Compiled ArkType schema accepted by ArkEnv.
|
|
193
|
+
* Produced by `arktype.type(...)` or `scope(...)`.
|
|
194
|
+
*
|
|
195
|
+
* Represents an already-constructed ArkType `Type` instance that
|
|
196
|
+
* defines the full environment schema.
|
|
197
|
+
*
|
|
198
|
+
* This form bypasses schema validation and is intended for advanced
|
|
199
|
+
* or programmatic use cases where schemas are constructed dynamically.
|
|
200
|
+
*/
|
|
201
|
+
type CompiledEnvSchema = Type<SchemaShape, $>;
|
|
104
202
|
//#endregion
|
|
105
203
|
//#region src/create-env.d.ts
|
|
106
|
-
|
|
204
|
+
/**
|
|
205
|
+
* Declarative environment schema definition accepted by ArkEnv.
|
|
206
|
+
*
|
|
207
|
+
* Represents a declarative schema object mapping environment
|
|
208
|
+
* variable names to schema definitions (e.g. ArkType DSL strings
|
|
209
|
+
* or Standard Schema validators).
|
|
210
|
+
*
|
|
211
|
+
* This type is used to validate that a schema object is compatible with
|
|
212
|
+
* ArkEnv’s validator scope before being compiled or parsed.
|
|
213
|
+
*
|
|
214
|
+
* Most users will provide schemas in this form.
|
|
215
|
+
*
|
|
216
|
+
* @template def - The schema shape object
|
|
217
|
+
*/
|
|
218
|
+
type EnvSchema<def> = type.validate<def, $>;
|
|
107
219
|
type RuntimeEnvironment = Dict<string>;
|
|
108
220
|
/**
|
|
109
221
|
* Configuration options for `createEnv`
|
|
@@ -163,9 +275,12 @@ type ArkEnvConfig = {
|
|
|
163
275
|
* @returns The parsed environment variables
|
|
164
276
|
* @throws An {@link ArkEnvError | error} if the environment variables are invalid.
|
|
165
277
|
*/
|
|
278
|
+
declare function createEnv<const T extends Record<string, StandardSchemaV1>>(def: T, config: ArkEnvConfig & {
|
|
279
|
+
validator: "standard";
|
|
280
|
+
}): { [K in keyof T]: StandardSchemaV1.InferOutput<T[K]> };
|
|
166
281
|
declare function createEnv<const T extends SchemaShape>(def: EnvSchema<T>, config?: ArkEnvConfig): distill.Out<type.infer<T, $>>;
|
|
167
|
-
declare function createEnv<T extends
|
|
168
|
-
declare function createEnv<const T extends SchemaShape>(def: EnvSchema<T> | EnvSchemaWithType, config?: ArkEnvConfig): distill.Out<type.infer<T, $>> | InferType<typeof def>;
|
|
282
|
+
declare function createEnv<T extends CompiledEnvSchema>(def: T, config?: ArkEnvConfig): InferType<T>;
|
|
169
283
|
//#endregion
|
|
170
284
|
export { SchemaShape as i, EnvSchema as n, createEnv as r, ArkEnvConfig as t };
|
|
171
|
-
|
|
285
|
+
|
|
286
|
+
//# sourceMappingURL=create-env-BDbKkDKm.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-env-BDbKkDKm.d.mts","names":["Dict","T","Record","StandardTypedV1","Input","Output","Props","Schema","Types","NonNullable","StandardSchemaV1","Options","Result","Promise","SuccessResult","FailureResult","Record","Issue","ReadonlyArray","PropertyKey","PathSegment","InferInput","InferOutput","StandardJSONSchemaV1","Converter","Target","type","StandardSchemaV1","InferType","T","Record","errors","Any","arktype0","arktype_internal_keywords_string_ts0","arktype_internal_attributes_ts0","$","trim","To","Submodule","normalize","capitalize","stringDate","stringInteger","ip","stringJson","lower","stringNumeric","url","uuid","Scope","$","Type","SchemaShape","Record","CompiledEnvSchema"],"sources":["../../internal/types/dist/helpers.d.ts","../../internal/types/dist/standard-schema.d.ts","../../internal/types/dist/infer-type.d.ts","../../internal/scope/dist/index.d.ts","../../internal/types/dist/schema.d.ts","../src/create-env.ts"],"sourcesContent":["export type Dict<T> = Record<string, T | undefined>;\n//# sourceMappingURL=helpers.d.ts.map","/**\n * @see https://github.com/standard-schema/standard-schema/tree/3130ce43fdd848d9ab49dbb0458d04f18459961c/packages/spec\n *\n * Copied from standard-schema (MIT License)\n * Copyright (c) 2024 Colin McDannell\n */\n/** The Standard Typed interface. This is a base type extended by other specs. */\nexport interface StandardTypedV1<Input = unknown, Output = Input> {\n /** The Standard properties. */\n readonly \"~standard\": StandardTypedV1.Props<Input, Output>;\n}\nexport declare namespace StandardTypedV1 {\n /** The Standard Typed properties interface. */\n interface Props<Input = unknown, Output = Input> {\n /** The version number of the standard. */\n readonly version: 1;\n /** The vendor name of the schema library. */\n readonly vendor: string;\n /** Inferred types associated with the schema. */\n readonly types?: Types<Input, Output> | undefined;\n }\n /** The Standard Typed types interface. */\n interface Types<Input = unknown, Output = Input> {\n /** The input type of the schema. */\n readonly input: Input;\n /** The output type of the schema. */\n readonly output: Output;\n }\n /** Infers the input type of a Standard Typed. */\n type InferInput<Schema extends StandardTypedV1> = NonNullable<Schema[\"~standard\"][\"types\"]>[\"input\"];\n /** Infers the output type of a Standard Typed. */\n type InferOutput<Schema extends StandardTypedV1> = NonNullable<Schema[\"~standard\"][\"types\"]>[\"output\"];\n}\n/** The Standard Schema interface. */\nexport interface StandardSchemaV1<Input = unknown, Output = Input> {\n /** The Standard Schema properties. */\n readonly \"~standard\": StandardSchemaV1.Props<Input, Output>;\n}\nexport declare namespace StandardSchemaV1 {\n /** The Standard Schema properties interface. */\n interface Props<Input = unknown, Output = Input> extends StandardTypedV1.Props<Input, Output> {\n /** Validates unknown input values. */\n readonly validate: (value: unknown, options?: StandardSchemaV1.Options | undefined) => Result<Output> | Promise<Result<Output>>;\n }\n /** The result interface of the validate function. */\n type Result<Output> = SuccessResult<Output> | FailureResult;\n /** The result interface if validation succeeds. */\n interface SuccessResult<Output> {\n /** The typed output value. */\n readonly value: Output;\n /** A falsy value for `issues` indicates success. */\n readonly issues?: undefined;\n }\n interface Options {\n /** Explicit support for additional vendor-specific parameters, if needed. */\n readonly libraryOptions?: Record<string, unknown> | undefined;\n }\n /** The result interface if validation fails. */\n interface FailureResult {\n /** The issues of failed validation. */\n readonly issues: ReadonlyArray<Issue>;\n }\n /** The issue interface of the failure output. */\n interface Issue {\n /** The error message of the issue. */\n readonly message: string;\n /** The path of the issue, if any. */\n readonly path?: ReadonlyArray<PropertyKey | PathSegment> | undefined;\n }\n /** The path segment interface of the issue. */\n interface PathSegment {\n /** The key representing a path segment. */\n readonly key: PropertyKey;\n }\n /** The Standard types interface. */\n interface Types<Input = unknown, Output = Input> extends StandardTypedV1.Types<Input, Output> {\n }\n /** Infers the input type of a Standard. */\n type InferInput<Schema extends StandardTypedV1> = StandardTypedV1.InferInput<Schema>;\n /** Infers the output type of a Standard. */\n type InferOutput<Schema extends StandardTypedV1> = StandardTypedV1.InferOutput<Schema>;\n}\n/** The Standard JSON Schema interface. */\nexport interface StandardJSONSchemaV1<Input = unknown, Output = Input> {\n /** The Standard JSON Schema properties. */\n readonly \"~standard\": StandardJSONSchemaV1.Props<Input, Output>;\n}\nexport declare namespace StandardJSONSchemaV1 {\n /** The Standard JSON Schema properties interface. */\n interface Props<Input = unknown, Output = Input> extends StandardTypedV1.Props<Input, Output> {\n /** Methods for generating the input/output JSON Schema. */\n readonly jsonSchema: StandardJSONSchemaV1.Converter;\n }\n /** The Standard JSON Schema converter interface. */\n interface Converter {\n /** Converts the input type to JSON Schema. May throw if conversion is not supported. */\n readonly input: (options: StandardJSONSchemaV1.Options) => Record<string, unknown>;\n /** Converts the output type to JSON Schema. May throw if conversion is not supported. */\n readonly output: (options: StandardJSONSchemaV1.Options) => Record<string, unknown>;\n }\n /**\n * The target version of the generated JSON Schema.\n *\n * It is *strongly recommended* that implementers support `\"draft-2020-12\"` and `\"draft-07\"`, as they are both in wide use. All other targets can be implemented on a best-effort basis. Libraries should throw if they don't support a specified target.\n *\n * The `\"openapi-3.0\"` target is intended as a standardized specifier for OpenAPI 3.0 which is a superset of JSON Schema `\"draft-04\"`.\n */\n type Target = \"draft-2020-12\" | \"draft-07\" | \"openapi-3.0\" | ({} & string);\n /** The options for the input/output methods. */\n interface Options {\n /** Specifies the target version of the generated JSON Schema. Support for all versions is on a best-effort basis. If a given version is not supported, the library should throw. */\n readonly target: Target;\n /** Explicit support for additional vendor-specific parameters, if needed. */\n readonly libraryOptions?: Record<string, unknown> | undefined;\n }\n /** The Standard types interface. */\n interface Types<Input = unknown, Output = Input> extends StandardTypedV1.Types<Input, Output> {\n }\n /** Infers the input type of a Standard. */\n type InferInput<Schema extends StandardTypedV1> = StandardTypedV1.InferInput<Schema>;\n /** Infers the output type of a Standard. */\n type InferOutput<Schema extends StandardTypedV1> = StandardTypedV1.InferOutput<Schema>;\n}\n//# sourceMappingURL=standard-schema.d.ts.map","import type { type } from \"arktype\";\nimport type { StandardSchemaV1 } from \"./standard-schema\";\n/**\n * Extract the inferred type from a schema definition.\n * Supports both ArkType type definitions and Standard Schema 1.0 validators.\n *\n * For Standard Schema validators (e.g., Zod, Valibot), extracts the output type.\n * For ArkType definitions, checks the call signature or type properties.\n *\n * @template T - The schema definition to infer from\n */\nexport 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 {\n t: infer U;\n} ? U : T extends type.Any<infer U, infer _Scope> ? U : never;\n//# sourceMappingURL=infer-type.d.ts.map","import * as arktype0 from \"arktype\";\nimport * as arktype_internal_keywords_string_ts0 from \"arktype/internal/keywords/string.ts\";\nimport * as arktype_internal_attributes_ts0 from \"arktype/internal/attributes.ts\";\n\n//#region src/root.d.ts\n/**\n * The root scope for the ArkEnv library,\n * containing extensions to the ArkType scopes with ArkEnv-specific types\n * like `string.host` and `number.port`.\n */\ndeclare const $: arktype0.Scope<{\n string: arktype0.Submodule<{\n trim: arktype0.Submodule<arktype_internal_keywords_string_ts0.trim.$ & {\n \" arkInferred\": (In: string) => arktype_internal_attributes_ts0.To<string>;\n }>;\n normalize: arktype0.Submodule<arktype_internal_keywords_string_ts0.normalize.$ & {\n \" arkInferred\": (In: string) => arktype_internal_attributes_ts0.To<string>;\n }>;\n root: string;\n alpha: string;\n alphanumeric: string;\n hex: string;\n base64: arktype0.Submodule<{\n root: string;\n url: string;\n } & {\n \" arkInferred\": string;\n }>;\n capitalize: arktype0.Submodule<arktype_internal_keywords_string_ts0.capitalize.$ & {\n \" arkInferred\": (In: string) => arktype_internal_attributes_ts0.To<string>;\n }>;\n creditCard: string;\n date: arktype0.Submodule<arktype_internal_keywords_string_ts0.stringDate.$ & {\n \" arkInferred\": string;\n }>;\n digits: string;\n email: string;\n integer: arktype0.Submodule<arktype_internal_keywords_string_ts0.stringInteger.$ & {\n \" arkInferred\": string;\n }>;\n ip: arktype0.Submodule<arktype_internal_keywords_string_ts0.ip.$ & {\n \" arkInferred\": string;\n }>;\n json: arktype0.Submodule<arktype_internal_keywords_string_ts0.stringJson.$ & {\n \" arkInferred\": string;\n }>;\n lower: arktype0.Submodule<arktype_internal_keywords_string_ts0.lower.$ & {\n \" arkInferred\": (In: string) => arktype_internal_attributes_ts0.To<string>;\n }>;\n numeric: arktype0.Submodule<arktype_internal_keywords_string_ts0.stringNumeric.$ & {\n \" arkInferred\": string;\n }>;\n regex: string;\n semver: string;\n upper: arktype0.Submodule<{\n root: (In: string) => arktype_internal_attributes_ts0.To<string>;\n preformatted: string;\n } & {\n \" arkInferred\": (In: string) => arktype_internal_attributes_ts0.To<string>;\n }>;\n url: arktype0.Submodule<arktype_internal_keywords_string_ts0.url.$ & {\n \" arkInferred\": string;\n }>;\n uuid: arktype0.Submodule<arktype_internal_keywords_string_ts0.uuid.$ & {\n \" arkInferred\": string;\n }>;\n \" arkInferred\": string;\n host: string;\n }>;\n number: arktype0.Submodule<{\n NaN: number;\n Infinity: number;\n root: number;\n integer: number;\n \" arkInferred\": number;\n epoch: number;\n safe: number;\n NegativeInfinity: number;\n port: number;\n }>;\n}>;\ntype $ = (typeof $)[\"t\"];\n//#endregion\nexport { $ };\n//# sourceMappingURL=index.d.ts.map","import type { $ } from \"@repo/scope\";\nimport type { Type } from \"arktype\";\nexport type SchemaShape = Record<string, unknown>;\n/**\n * @internal\n *\n * Compiled ArkType schema accepted by ArkEnv.\n * Produced by `arktype.type(...)` or `scope(...)`.\n *\n * Represents an already-constructed ArkType `Type` instance that\n * defines the full environment schema.\n *\n * This form bypasses schema validation and is intended for advanced\n * or programmatic use cases where schemas are constructed dynamically.\n */\nexport type CompiledEnvSchema = Type<SchemaShape, $>;\n//# sourceMappingURL=schema.d.ts.map"],"mappings":";;;;;;KAAYA,UAAUE,eAAeD;;;;;;;;;AAArC;UCOiBE,0CAA0CC;;wBAEjCD,eAAAA,CAAgBG,MAAMF,OAAOC;AAFvD;AAA2DD,kBAIlCD,eAAAA,CAJkCC;EAEXA;EAAOC,UAAAA,KAAAA,CAAAA,QAAAA,OAAAA,EAAAA,SAITD,KAJSC,CAAAA,CAAAA;IAA7BF;IAAqB,SAAA,OAAA,EAAA,CAAA;IAEtBA;IAEqBC,SAAAA,MAAAA,EAAAA,MAAAA;IAMfA;IAAOC,SAAAA,KAAAA,CAAAA,EAAbG,KAAaH,CAAPD,KAAOC,EAAAA,MAAAA,CAAAA,GAAAA,SAAAA;EAAbG;EAGqBJ;EAEtBA,UAAAA,KAAAA,CAAAA,QAAAA,OAAAA,EAAAA,SAFsBA,KAEtBA,CAAAA,CAAAA;IAECC;IAGUF,SAAAA,KAAAA,EALXC,KAKWD;IAA+BI;IAAZE,SAAAA,MAAAA,EAH7BJ,MAG6BI;EAElBN;EAA+BI;EAAZE,KAAAA,UAAAA,CAAAA,eAFpBN,eAEoBM,CAAAA,GAFDA,WAECA,C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9B,YACI,eACP,UAAU"}
|
|
@@ -6,14 +6,100 @@ import { Type, distill, type } from "arktype";
|
|
|
6
6
|
//#region ../internal/types/dist/helpers.d.ts
|
|
7
7
|
type Dict<T> = Record<string, T | undefined>;
|
|
8
8
|
//#endregion
|
|
9
|
+
//#region ../internal/types/dist/standard-schema.d.ts
|
|
10
|
+
/**
|
|
11
|
+
* @see https://github.com/standard-schema/standard-schema/tree/3130ce43fdd848d9ab49dbb0458d04f18459961c/packages/spec
|
|
12
|
+
*
|
|
13
|
+
* Copied from standard-schema (MIT License)
|
|
14
|
+
* Copyright (c) 2024 Colin McDannell
|
|
15
|
+
*/
|
|
16
|
+
/** The Standard Typed interface. This is a base type extended by other specs. */
|
|
17
|
+
interface StandardTypedV1<Input = unknown, Output = Input> {
|
|
18
|
+
/** The Standard properties. */
|
|
19
|
+
readonly "~standard": StandardTypedV1.Props<Input, Output>;
|
|
20
|
+
}
|
|
21
|
+
declare namespace StandardTypedV1 {
|
|
22
|
+
/** The Standard Typed properties interface. */
|
|
23
|
+
interface Props<Input = unknown, Output = Input> {
|
|
24
|
+
/** The version number of the standard. */
|
|
25
|
+
readonly version: 1;
|
|
26
|
+
/** The vendor name of the schema library. */
|
|
27
|
+
readonly vendor: string;
|
|
28
|
+
/** Inferred types associated with the schema. */
|
|
29
|
+
readonly types?: Types<Input, Output> | undefined;
|
|
30
|
+
}
|
|
31
|
+
/** The Standard Typed types interface. */
|
|
32
|
+
interface Types<Input = unknown, Output = Input> {
|
|
33
|
+
/** The input type of the schema. */
|
|
34
|
+
readonly input: Input;
|
|
35
|
+
/** The output type of the schema. */
|
|
36
|
+
readonly output: Output;
|
|
37
|
+
}
|
|
38
|
+
/** Infers the input type of a Standard Typed. */
|
|
39
|
+
type InferInput<Schema extends StandardTypedV1> = NonNullable<Schema["~standard"]["types"]>["input"];
|
|
40
|
+
/** Infers the output type of a Standard Typed. */
|
|
41
|
+
type InferOutput<Schema extends StandardTypedV1> = NonNullable<Schema["~standard"]["types"]>["output"];
|
|
42
|
+
}
|
|
43
|
+
/** The Standard Schema interface. */
|
|
44
|
+
interface StandardSchemaV1<Input = unknown, Output = Input> {
|
|
45
|
+
/** The Standard Schema properties. */
|
|
46
|
+
readonly "~standard": StandardSchemaV1.Props<Input, Output>;
|
|
47
|
+
}
|
|
48
|
+
declare namespace StandardSchemaV1 {
|
|
49
|
+
/** The Standard Schema properties interface. */
|
|
50
|
+
interface Props<Input = unknown, Output = Input> extends StandardTypedV1.Props<Input, Output> {
|
|
51
|
+
/** Validates unknown input values. */
|
|
52
|
+
readonly validate: (value: unknown, options?: StandardSchemaV1.Options | undefined) => Result<Output> | Promise<Result<Output>>;
|
|
53
|
+
}
|
|
54
|
+
/** The result interface of the validate function. */
|
|
55
|
+
type Result<Output> = SuccessResult<Output> | FailureResult;
|
|
56
|
+
/** The result interface if validation succeeds. */
|
|
57
|
+
interface SuccessResult<Output> {
|
|
58
|
+
/** The typed output value. */
|
|
59
|
+
readonly value: Output;
|
|
60
|
+
/** A falsy value for `issues` indicates success. */
|
|
61
|
+
readonly issues?: undefined;
|
|
62
|
+
}
|
|
63
|
+
interface Options {
|
|
64
|
+
/** Explicit support for additional vendor-specific parameters, if needed. */
|
|
65
|
+
readonly libraryOptions?: Record<string, unknown> | undefined;
|
|
66
|
+
}
|
|
67
|
+
/** The result interface if validation fails. */
|
|
68
|
+
interface FailureResult {
|
|
69
|
+
/** The issues of failed validation. */
|
|
70
|
+
readonly issues: ReadonlyArray<Issue>;
|
|
71
|
+
}
|
|
72
|
+
/** The issue interface of the failure output. */
|
|
73
|
+
interface Issue {
|
|
74
|
+
/** The error message of the issue. */
|
|
75
|
+
readonly message: string;
|
|
76
|
+
/** The path of the issue, if any. */
|
|
77
|
+
readonly path?: ReadonlyArray<PropertyKey | PathSegment> | undefined;
|
|
78
|
+
}
|
|
79
|
+
/** The path segment interface of the issue. */
|
|
80
|
+
interface PathSegment {
|
|
81
|
+
/** The key representing a path segment. */
|
|
82
|
+
readonly key: PropertyKey;
|
|
83
|
+
}
|
|
84
|
+
/** The Standard types interface. */
|
|
85
|
+
interface Types<Input = unknown, Output = Input> extends StandardTypedV1.Types<Input, Output> {}
|
|
86
|
+
/** Infers the input type of a Standard. */
|
|
87
|
+
type InferInput<Schema extends StandardTypedV1> = StandardTypedV1.InferInput<Schema>;
|
|
88
|
+
/** Infers the output type of a Standard. */
|
|
89
|
+
type InferOutput<Schema extends StandardTypedV1> = StandardTypedV1.InferOutput<Schema>;
|
|
90
|
+
}
|
|
91
|
+
//#endregion
|
|
9
92
|
//#region ../internal/types/dist/infer-type.d.ts
|
|
10
93
|
/**
|
|
11
|
-
* Extract the inferred type from
|
|
12
|
-
*
|
|
94
|
+
* Extract the inferred type from a schema definition.
|
|
95
|
+
* Supports both ArkType type definitions and Standard Schema 1.0 validators.
|
|
96
|
+
*
|
|
97
|
+
* For Standard Schema validators (e.g., Zod, Valibot), extracts the output type.
|
|
98
|
+
* For ArkType definitions, checks the call signature or type properties.
|
|
13
99
|
*
|
|
14
|
-
* @template T - The
|
|
100
|
+
* @template T - The schema definition to infer from
|
|
15
101
|
*/
|
|
16
|
-
type InferType<T> = T extends ((value: Record<string, string | undefined>) => infer R) ? R extends type.errors ? never : R : T extends {
|
|
102
|
+
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 {
|
|
17
103
|
t: infer U;
|
|
18
104
|
} ? U : T extends type.Any<infer U, infer _Scope> ? U : never;
|
|
19
105
|
//#endregion
|
|
@@ -100,10 +186,36 @@ type $ = (typeof $)["t"];
|
|
|
100
186
|
//#endregion
|
|
101
187
|
//#region ../internal/types/dist/schema.d.ts
|
|
102
188
|
type SchemaShape = Record<string, unknown>;
|
|
103
|
-
|
|
189
|
+
/**
|
|
190
|
+
* @internal
|
|
191
|
+
*
|
|
192
|
+
* Compiled ArkType schema accepted by ArkEnv.
|
|
193
|
+
* Produced by `arktype.type(...)` or `scope(...)`.
|
|
194
|
+
*
|
|
195
|
+
* Represents an already-constructed ArkType `Type` instance that
|
|
196
|
+
* defines the full environment schema.
|
|
197
|
+
*
|
|
198
|
+
* This form bypasses schema validation and is intended for advanced
|
|
199
|
+
* or programmatic use cases where schemas are constructed dynamically.
|
|
200
|
+
*/
|
|
201
|
+
type CompiledEnvSchema = Type<SchemaShape, $>;
|
|
104
202
|
//#endregion
|
|
105
203
|
//#region src/create-env.d.ts
|
|
106
|
-
|
|
204
|
+
/**
|
|
205
|
+
* Declarative environment schema definition accepted by ArkEnv.
|
|
206
|
+
*
|
|
207
|
+
* Represents a declarative schema object mapping environment
|
|
208
|
+
* variable names to schema definitions (e.g. ArkType DSL strings
|
|
209
|
+
* or Standard Schema validators).
|
|
210
|
+
*
|
|
211
|
+
* This type is used to validate that a schema object is compatible with
|
|
212
|
+
* ArkEnv’s validator scope before being compiled or parsed.
|
|
213
|
+
*
|
|
214
|
+
* Most users will provide schemas in this form.
|
|
215
|
+
*
|
|
216
|
+
* @template def - The schema shape object
|
|
217
|
+
*/
|
|
218
|
+
type EnvSchema<def> = type.validate<def, $>;
|
|
107
219
|
type RuntimeEnvironment = Dict<string>;
|
|
108
220
|
/**
|
|
109
221
|
* Configuration options for `createEnv`
|
|
@@ -163,9 +275,18 @@ type ArkEnvConfig = {
|
|
|
163
275
|
* @returns The parsed environment variables
|
|
164
276
|
* @throws An {@link ArkEnvError | error} if the environment variables are invalid.
|
|
165
277
|
*/
|
|
278
|
+
declare function createEnv<const T extends Record<string, StandardSchemaV1>>(def: T, config: ArkEnvConfig & {
|
|
279
|
+
validator: "standard";
|
|
280
|
+
}): { [K in keyof T]: StandardSchemaV1.InferOutput<T[K]> };
|
|
166
281
|
declare function createEnv<const T extends SchemaShape>(def: EnvSchema<T>, config?: ArkEnvConfig): distill.Out<type.infer<T, $>>;
|
|
167
|
-
declare function createEnv<T extends
|
|
168
|
-
declare function createEnv<const T extends SchemaShape>(def: EnvSchema<T> | EnvSchemaWithType, config?: ArkEnvConfig): distill.Out<type.infer<T, $>> | InferType<typeof def>;
|
|
282
|
+
declare function createEnv<T extends CompiledEnvSchema>(def: T, config?: ArkEnvConfig): InferType<T>;
|
|
169
283
|
//#endregion
|
|
170
284
|
export { SchemaShape as i, EnvSchema as n, createEnv as r, ArkEnvConfig as t };
|
|
171
|
-
|
|
285
|
+
|
|
286
|
+
// CJS Interop Shim
|
|
287
|
+
if (module.exports && module.exports.default) {
|
|
288
|
+
Object.assign(module.exports.default, module.exports);
|
|
289
|
+
module.exports = module.exports.default;
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
//# sourceMappingURL=create-env-D7N4rUVE.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-env-D7N4rUVE.d.cts","names":["Dict","T","Record","StandardTypedV1","Input","Output","Props","Schema","Types","NonNullable","StandardSchemaV1","Options","Result","Promise","SuccessResult","FailureResult","Record","Issue","ReadonlyArray","PropertyKey","PathSegment","InferInput","InferOutput","StandardJSONSchemaV1","Converter","Target","type","StandardSchemaV1","InferType","T","Record","errors","Any","arktype0","arktype_internal_keywords_string_ts0","arktype_internal_attributes_ts0","$","trim","To","Submodule","normalize","capitalize","stringDate","stringInteger","ip","stringJson","lower","stringNumeric","url","uuid","Scope","$","Type","SchemaShape","Record","CompiledEnvSchema"],"sources":["../../internal/types/dist/helpers.d.ts","../../internal/types/dist/standard-schema.d.ts","../../internal/types/dist/infer-type.d.ts","../../internal/scope/dist/index.d.ts","../../internal/types/dist/schema.d.ts","../src/create-env.ts"],"sourcesContent":["export type Dict<T> = Record<string, T | undefined>;\n//# sourceMappingURL=helpers.d.ts.map","/**\n * @see https://github.com/standard-schema/standard-schema/tree/3130ce43fdd848d9ab49dbb0458d04f18459961c/packages/spec\n *\n * Copied from standard-schema (MIT License)\n * Copyright (c) 2024 Colin McDannell\n */\n/** The Standard Typed interface. This is a base type extended by other specs. */\nexport interface StandardTypedV1<Input = unknown, Output = Input> {\n /** The Standard properties. */\n readonly \"~standard\": StandardTypedV1.Props<Input, Output>;\n}\nexport declare namespace StandardTypedV1 {\n /** The Standard Typed properties interface. */\n interface Props<Input = unknown, Output = Input> {\n /** The version number of the standard. */\n readonly version: 1;\n /** The vendor name of the schema library. */\n readonly vendor: string;\n /** Inferred types associated with the schema. */\n readonly types?: Types<Input, Output> | undefined;\n }\n /** The Standard Typed types interface. */\n interface Types<Input = unknown, Output = Input> {\n /** The input type of the schema. */\n readonly input: Input;\n /** The output type of the schema. */\n readonly output: Output;\n }\n /** Infers the input type of a Standard Typed. */\n type InferInput<Schema extends StandardTypedV1> = NonNullable<Schema[\"~standard\"][\"types\"]>[\"input\"];\n /** Infers the output type of a Standard Typed. */\n type InferOutput<Schema extends StandardTypedV1> = NonNullable<Schema[\"~standard\"][\"types\"]>[\"output\"];\n}\n/** The Standard Schema interface. */\nexport interface StandardSchemaV1<Input = unknown, Output = Input> {\n /** The Standard Schema properties. */\n readonly \"~standard\": StandardSchemaV1.Props<Input, Output>;\n}\nexport declare namespace StandardSchemaV1 {\n /** The Standard Schema properties interface. */\n interface Props<Input = unknown, Output = Input> extends StandardTypedV1.Props<Input, Output> {\n /** Validates unknown input values. */\n readonly validate: (value: unknown, options?: StandardSchemaV1.Options | undefined) => Result<Output> | Promise<Result<Output>>;\n }\n /** The result interface of the validate function. */\n type Result<Output> = SuccessResult<Output> | FailureResult;\n /** The result interface if validation succeeds. */\n interface SuccessResult<Output> {\n /** The typed output value. */\n readonly value: Output;\n /** A falsy value for `issues` indicates success. */\n readonly issues?: undefined;\n }\n interface Options {\n /** Explicit support for additional vendor-specific parameters, if needed. */\n readonly libraryOptions?: Record<string, unknown> | undefined;\n }\n /** The result interface if validation fails. */\n interface FailureResult {\n /** The issues of failed validation. */\n readonly issues: ReadonlyArray<Issue>;\n }\n /** The issue interface of the failure output. */\n interface Issue {\n /** The error message of the issue. */\n readonly message: string;\n /** The path of the issue, if any. */\n readonly path?: ReadonlyArray<PropertyKey | PathSegment> | undefined;\n }\n /** The path segment interface of the issue. */\n interface PathSegment {\n /** The key representing a path segment. */\n readonly key: PropertyKey;\n }\n /** The Standard types interface. */\n interface Types<Input = unknown, Output = Input> extends StandardTypedV1.Types<Input, Output> {\n }\n /** Infers the input type of a Standard. */\n type InferInput<Schema extends StandardTypedV1> = StandardTypedV1.InferInput<Schema>;\n /** Infers the output type of a Standard. */\n type InferOutput<Schema extends StandardTypedV1> = StandardTypedV1.InferOutput<Schema>;\n}\n/** The Standard JSON Schema interface. */\nexport interface StandardJSONSchemaV1<Input = unknown, Output = Input> {\n /** The Standard JSON Schema properties. */\n readonly \"~standard\": StandardJSONSchemaV1.Props<Input, Output>;\n}\nexport declare namespace StandardJSONSchemaV1 {\n /** The Standard JSON Schema properties interface. */\n interface Props<Input = unknown, Output = Input> extends StandardTypedV1.Props<Input, Output> {\n /** Methods for generating the input/output JSON Schema. */\n readonly jsonSchema: StandardJSONSchemaV1.Converter;\n }\n /** The Standard JSON Schema converter interface. */\n interface Converter {\n /** Converts the input type to JSON Schema. May throw if conversion is not supported. */\n readonly input: (options: StandardJSONSchemaV1.Options) => Record<string, unknown>;\n /** Converts the output type to JSON Schema. May throw if conversion is not supported. */\n readonly output: (options: StandardJSONSchemaV1.Options) => Record<string, unknown>;\n }\n /**\n * The target version of the generated JSON Schema.\n *\n * It is *strongly recommended* that implementers support `\"draft-2020-12\"` and `\"draft-07\"`, as they are both in wide use. All other targets can be implemented on a best-effort basis. Libraries should throw if they don't support a specified target.\n *\n * The `\"openapi-3.0\"` target is intended as a standardized specifier for OpenAPI 3.0 which is a superset of JSON Schema `\"draft-04\"`.\n */\n type Target = \"draft-2020-12\" | \"draft-07\" | \"openapi-3.0\" | ({} & string);\n /** The options for the input/output methods. */\n interface Options {\n /** Specifies the target version of the generated JSON Schema. Support for all versions is on a best-effort basis. If a given version is not supported, the library should throw. */\n readonly target: Target;\n /** Explicit support for additional vendor-specific parameters, if needed. */\n readonly libraryOptions?: Record<string, unknown> | undefined;\n }\n /** The Standard types interface. */\n interface Types<Input = unknown, Output = Input> extends StandardTypedV1.Types<Input, Output> {\n }\n /** Infers the input type of a Standard. */\n type InferInput<Schema extends StandardTypedV1> = StandardTypedV1.InferInput<Schema>;\n /** Infers the output type of a Standard. */\n type InferOutput<Schema extends StandardTypedV1> = StandardTypedV1.InferOutput<Schema>;\n}\n//# sourceMappingURL=standard-schema.d.ts.map","import type { type } from \"arktype\";\nimport type { StandardSchemaV1 } from \"./standard-schema\";\n/**\n * Extract the inferred type from a schema definition.\n * Supports both ArkType type definitions and Standard Schema 1.0 validators.\n *\n * For Standard Schema validators (e.g., Zod, Valibot), extracts the output type.\n * For ArkType definitions, checks the call signature or type properties.\n *\n * @template T - The schema definition to infer from\n */\nexport 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 {\n t: infer U;\n} ? U : T extends type.Any<infer U, infer _Scope> ? U : never;\n//# sourceMappingURL=infer-type.d.ts.map","import * as arktype0 from \"arktype\";\nimport * as arktype_internal_keywords_string_ts0 from \"arktype/internal/keywords/string.ts\";\nimport * as arktype_internal_attributes_ts0 from \"arktype/internal/attributes.ts\";\n\n//#region src/root.d.ts\n/**\n * The root scope for the ArkEnv library,\n * containing extensions to the ArkType scopes with ArkEnv-specific types\n * like `string.host` and `number.port`.\n */\ndeclare const $: arktype0.Scope<{\n string: arktype0.Submodule<{\n trim: arktype0.Submodule<arktype_internal_keywords_string_ts0.trim.$ & {\n \" arkInferred\": (In: string) => arktype_internal_attributes_ts0.To<string>;\n }>;\n normalize: arktype0.Submodule<arktype_internal_keywords_string_ts0.normalize.$ & {\n \" arkInferred\": (In: string) => arktype_internal_attributes_ts0.To<string>;\n }>;\n root: string;\n alpha: string;\n alphanumeric: string;\n hex: string;\n base64: arktype0.Submodule<{\n root: string;\n url: string;\n } & {\n \" arkInferred\": string;\n }>;\n capitalize: arktype0.Submodule<arktype_internal_keywords_string_ts0.capitalize.$ & {\n \" arkInferred\": (In: string) => arktype_internal_attributes_ts0.To<string>;\n }>;\n creditCard: string;\n date: arktype0.Submodule<arktype_internal_keywords_string_ts0.stringDate.$ & {\n \" arkInferred\": string;\n }>;\n digits: string;\n email: string;\n integer: arktype0.Submodule<arktype_internal_keywords_string_ts0.stringInteger.$ & {\n \" arkInferred\": string;\n }>;\n ip: arktype0.Submodule<arktype_internal_keywords_string_ts0.ip.$ & {\n \" arkInferred\": string;\n }>;\n json: arktype0.Submodule<arktype_internal_keywords_string_ts0.stringJson.$ & {\n \" arkInferred\": string;\n }>;\n lower: arktype0.Submodule<arktype_internal_keywords_string_ts0.lower.$ & {\n \" arkInferred\": (In: string) => arktype_internal_attributes_ts0.To<string>;\n }>;\n numeric: arktype0.Submodule<arktype_internal_keywords_string_ts0.stringNumeric.$ & {\n \" arkInferred\": string;\n }>;\n regex: string;\n semver: string;\n upper: arktype0.Submodule<{\n root: (In: string) => arktype_internal_attributes_ts0.To<string>;\n preformatted: string;\n } & {\n \" arkInferred\": (In: string) => arktype_internal_attributes_ts0.To<string>;\n }>;\n url: arktype0.Submodule<arktype_internal_keywords_string_ts0.url.$ & {\n \" arkInferred\": string;\n }>;\n uuid: arktype0.Submodule<arktype_internal_keywords_string_ts0.uuid.$ & {\n \" arkInferred\": string;\n }>;\n \" arkInferred\": string;\n host: string;\n }>;\n number: arktype0.Submodule<{\n NaN: number;\n Infinity: number;\n root: number;\n integer: number;\n \" arkInferred\": number;\n epoch: number;\n safe: number;\n NegativeInfinity: number;\n port: number;\n }>;\n}>;\ntype $ = (typeof $)[\"t\"];\n//#endregion\nexport { $ };\n//# sourceMappingURL=index.d.ts.map","import type { $ } from \"@repo/scope\";\nimport type { Type } from \"arktype\";\nexport type SchemaShape = Record<string, unknown>;\n/**\n * @internal\n *\n * Compiled ArkType schema accepted by ArkEnv.\n * Produced by `arktype.type(...)` or `scope(...)`.\n *\n * Represents an already-constructed ArkType `Type` instance that\n * defines the full environment schema.\n *\n * This form bypasses schema validation and is intended for advanced\n * or programmatic use cases where schemas are constructed dynamically.\n */\nexport type CompiledEnvSchema = Type<SchemaShape, $>;\n//# sourceMappingURL=schema.d.ts.map"],"mappings":";;;;;;KAAYA,UAAUE,eAAeD;;;;;;;;;AAArC;UCOiBE,0CAA0CC;;wBAEjCD,eAAAA,CAAgBG,MAAMF,OAAOC;AAFvD;AAA2DD,kBAIlCD,eAAAA,CAJkCC;EAEXA;EAAOC,UAAAA,KAAAA,CAAAA,QAAAA,OAAAA,EAAAA,SAITD,KAJSC,CAAAA,CAAAA;IAA7BF;IAAqB,SAAA,OAAA,EAAA,CAAA;IAEtBA;IAEqBC,SAAAA,MAAAA,EAAAA,MAAAA;IAMfA;IAAOC,SAAAA,KAAAA,CAAAA,EAAbG,KAAaH,CAAPD,KAAOC,EAAAA,MAAAA,CAAAA,GAAAA,SAAAA;EAAbG;EAGqBJ;EAEtBA,UAAAA,KAAAA,CAAAA,QAAAA,OAAAA,EAAAA,SAFsBA,KAEtBA,CAAAA,CAAAA;IAECC;IAGUF,SAAAA,KAAAA,EALXC,KAKWD;IAA+BI;IAAZE,SAAAA,MAAAA,EAH7BJ,MAG6BI;EAElBN;EAA+BI;EAAZE,KAAAA,UAAAA,CAAAA,eAFpBN,eAEoBM,CAAAA,GAFDA,WAECA,CAFWF,MAEXE,CAAAA,WAAAA,CAAAA,CAAAA,OAAAA,CAAAA,CAAAA,CAAAA,OAAAA,CAAAA;EAAW;EAGjDC,KAAAA,WAAAA,CAAAA,eAHmBP,eAGH,CAAA,GAHsBM,WAGtB,CAHkCF,MAGlC,CAAA,WAAA,CAAA,CAAA,OAAA,CAAA,CAAA,CAAA,QAAA,CAAA;;;AAEuBF,UAFvCK,gBAEuCL,CAAAA,QAAAA,OAAAA,EAAAA,SAFID,KAEJC,CAAAA,CAAAA;EAA9BK;EAAsB,SAAA,WAAA,EAAtBA,gBAAAA,CAAiBJ,KAAK,CAACF,KAAD,EAAQC,MAAR,CAAA;AAE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AAA,EAAAA,QAAAA,GAAAA,QAAAA,GAAAA,QAAAA;EAARC;;;;;;;;EAkBvFK,WAAAA,CAAAA,EAAAA,OAAAA,GAAAA,MAAAA;EAOaC;;;;;;;;EAWHhB,SAAAA,CAAAA,EAAAA,SAAAA,GAAAA,UAAAA;CAA8CI;;;;;;;;;ACnEjF;;;;AAA+GuB,iBGgF/F,SHhF+FA,CAAAA,gBGgFrE,MHhFqEA,CAAAA,MAAAA,EGgFtD,gBHhFsDA,CAAAA,CAAAA,CAAAA,GAAAA,EGiFzG,CHjFyGA,EAAAA,MAAAA,EGkFtG,YHlFsGA,GAAAA;EAA2DJ,SAAKK,EAAAA,UAAAA;CAAqBF,CAAAA,EAAAA,QAE5LA,MGiFS,CHjFTA,GGiFa,gBAAA,CAAiB,WHjF9BA,CGiF0C,CHjF1CA,CGiF4C,CHjF5CA,CAAAA,CAAAA,EAAUH;AAAQ,iBGkFV,SHlFU,CAAA,gBGkFgB,WHlFhB,CAAA,CAAA,GAAA,EGmFpB,SHnFoB,CGmFV,CHnFU,CAAA,EAAA,MAAA,CAAA,EGoFhB,YHpFgB,CAAA,EGqFvB,OAAA,CAAQ,GHrFe,CGqFX,IAAA,CAAG,KHrFQ,CGqFF,CHrFE,EGqFC,CHrFD,CAAA,CAAA;iBGsFV,oBAAoB,wBAC9B,YACI,eACP,UAAU"}
|
|
@@ -3,4 +3,5 @@ const e=(e,t=2,{dontDetectNewlines:n=!1}={})=>n?`${` `.repeat(t)}${e}`:e.split(`
|
|
|
3
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=>typeof e==`object`&&!!e&&`byPath`in e,o=e=>Object.entries(e.byPath).map(([e,t])=>{let n=t.message,r=e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`),a=RegExp(`^\\s*[:.-]?\\s*${r}\\s*[:.-]?\\s*`,`i`);n=a.test(n)?n.replace(a,t=>`${i(`yellow`,e)}${t.toLowerCase().replace(e.toLowerCase(),``)}`):`${i(`yellow`,e)} ${n}`;let o=n.match(/\(was (.*)\)/);if(o?.[1]){let e=o[1];if(!e.includes(`\x1B[`)){let t=i(`cyan`,e);n=n.replace(`(was ${e})`,`(was ${t})`)}}return n}).join(`
|
|
4
4
|
`),s=e=>e.map(e=>`${i(`yellow`,e.path)} ${e.message.trimStart()}`).join(`
|
|
5
5
|
`);var c=class extends Error{constructor(t,n=`Errors found while validating environment variables`){let r=a(t)?o(t):s(t);super(`${i(`red`,n)}\n${e(r)}\n`),this.name=`ArkEnvError`}};Object.defineProperty(c,`name`,{value:`ArkEnvError`});export{c as t};
|
|
6
|
-
|
|
6
|
+
|
|
7
|
+
//# sourceMappingURL=errors-Bi-pULbt.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors-Bi-pULbt.mjs","names":[],"sources":["../src/utils/indent.ts","../src/utils/style-text.ts","../src/errors.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 type { ArkErrors } from \"arktype\";\nimport { indent } from \"./utils/indent.ts\";\nimport { styleText } from \"./utils/style-text.ts\";\n\nexport type InternalValidationError = {\n\tpath: string;\n\tmessage: string;\n};\n\n/**\n * Check if the provided object is ArkType errors\n */\nconst isArkErrors = (errors: unknown): errors is ArkErrors => {\n\treturn (\n\t\terrors !== null &&\n\t\ttypeof errors === \"object\" &&\n\t\t\"byPath\" in (errors as Record<string, unknown>)\n\t);\n};\n\n/**\n * Format the errors returned by ArkType to be more readable\n * @param errors - The errors returned by ArkType\n * @returns A string of the formatted errors\n */\nexport const formatArkErrors = (errors: ArkErrors): string => {\n\treturn Object.entries(errors.byPath)\n\t\t.map(([path, error]) => {\n\t\t\tlet message = error.message;\n\n\t\t\tconst escapedPath = path.replace(/[.*+?^${}()|[\\]\\\\]/g, \"\\\\$&\");\n\t\t\tconst pathRegex = new RegExp(\n\t\t\t\t`^\\\\s*[:.-]?\\\\s*${escapedPath}\\\\s*[:.-]?\\\\s*`,\n\t\t\t\t\"i\",\n\t\t\t);\n\n\t\t\tif (pathRegex.test(message)) {\n\t\t\t\t// Style the existing path prefix\n\t\t\t\tmessage = message.replace(pathRegex, (match) => {\n\t\t\t\t\treturn `${styleText(\"yellow\", path)}${match.toLowerCase().replace(path.toLowerCase(), \"\")}`;\n\t\t\t\t});\n\t\t\t} else {\n\t\t\t\t// Prepend styled path\n\t\t\t\tmessage = `${styleText(\"yellow\", path)} ${message}`;\n\t\t\t}\n\n\t\t\t// Style (was ...)\n\t\t\tconst valueMatch = message.match(/\\(was (.*)\\)/);\n\t\t\tif (valueMatch?.[1]) {\n\t\t\t\tconst value = valueMatch[1];\n\t\t\t\tif (!value.includes(\"\\x1b[\")) {\n\t\t\t\t\tconst styledValue = styleText(\"cyan\", value);\n\t\t\t\t\tmessage = message.replace(`(was ${value})`, `(was ${styledValue})`);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn message;\n\t\t})\n\t\t.join(\"\\n\");\n};\n\nexport const formatInternalErrors = (\n\terrors: InternalValidationError[],\n): 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 { createEnv, ArkEnvError } from 'arkenv';\n *\n * try {\n * const env = createEnv({\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: ArkErrors | InternalValidationError[],\n\t\tmessage = \"Errors found while validating environment variables\",\n\t) {\n\t\t// ArkType errors subclass Array, so we must check for ArkErrors specifically first\n\t\tconst formattedErrors = isArkErrors(errors)\n\t\t\t? formatArkErrors(errors)\n\t\t\t: formatInternalErrors(errors as InternalValidationError[]);\n\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,EC7CF,EAAe,GAGnB,OAAO,GAAW,YADlB,GAEA,WAAa,EASF,EAAmB,GACxB,OAAO,QAAQ,EAAO,OAAO,CAClC,KAAK,CAAC,EAAM,KAAW,CACvB,IAAI,EAAU,EAAM,QAEd,EAAc,EAAK,QAAQ,sBAAuB,OAAO,CACzD,EAAgB,OACrB,kBAAkB,EAAY,gBAC9B,IACA,CAED,AAOC,EAPG,EAAU,KAAK,EAAQ,CAEhB,EAAQ,QAAQ,EAAY,GAC9B,GAAG,EAAU,SAAU,EAAK,GAAG,EAAM,aAAa,CAAC,QAAQ,EAAK,aAAa,CAAE,GAAG,GACxF,CAGQ,GAAG,EAAU,SAAU,EAAK,CAAC,GAAG,IAI3C,IAAM,EAAa,EAAQ,MAAM,eAAe,CAChD,GAAI,IAAa,GAAI,CACpB,IAAM,EAAQ,EAAW,GACzB,GAAI,CAAC,EAAM,SAAS,QAAQ,CAAE,CAC7B,IAAM,EAAc,EAAU,OAAQ,EAAM,CAC5C,EAAU,EAAQ,QAAQ,QAAQ,EAAM,GAAI,QAAQ,EAAY,GAAG,EAIrE,OAAO,GACN,CACD,KAAK;EAAK,CAGA,EACZ,GAEA,EACE,IACC,GACA,GAAG,EAAU,SAAU,EAAM,KAAK,CAAC,GAAG,EAAM,QAAQ,WAAW,GAChE,CACA,KAAK;EAAK,CAwBb,IAAa,EAAb,cAAiC,KAAM,CACtC,YACC,EACA,EAAU,sDACT,CAED,IAAM,EAAkB,EAAY,EAAO,CACxC,EAAgB,EAAO,CACvB,EAAqB,EAAoC,CAE5D,MAAM,GAAG,EAAU,MAAO,EAAQ,CAAC,IAAI,EAAO,EAAgB,CAAC,IAAI,CACnE,KAAK,KAAO,gBAId,OAAO,eAAe,EAAa,OAAQ,CAAE,MAAO,cAAe,CAAC"}
|
|
@@ -2,4 +2,11 @@ const e=(e,t=2,{dontDetectNewlines:n=!1}={})=>n?`${` `.repeat(t)}${e}`:e.split(`
|
|
|
2
2
|
`).map(e=>`${` `.repeat(t)}${e}`).join(`
|
|
3
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=>typeof e==`object`&&!!e&&`byPath`in e,o=e=>Object.entries(e.byPath).map(([e,t])=>{let n=t.message,r=e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`),a=RegExp(`^\\s*[:.-]?\\s*${r}\\s*[:.-]?\\s*`,`i`);n=a.test(n)?n.replace(a,t=>`${i(`yellow`,e)}${t.toLowerCase().replace(e.toLowerCase(),``)}`):`${i(`yellow`,e)} ${n}`;let o=n.match(/\(was (.*)\)/);if(o?.[1]){let e=o[1];if(!e.includes(`\x1B[`)){let t=i(`cyan`,e);n=n.replace(`(was ${e})`,`(was ${t})`)}}return n}).join(`
|
|
4
4
|
`),s=e=>e.map(e=>`${i(`yellow`,e.path)} ${e.message.trimStart()}`).join(`
|
|
5
|
-
`);var c=class extends Error{constructor(t,n=`Errors found while validating environment variables`){let r=a(t)?o(t):s(t);super(`${i(`red`,n)}\n${e(r)}\n`),this.name=`ArkEnvError`}};Object.defineProperty(c,`name`,{value:`ArkEnvError`}),Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return c}});
|
|
5
|
+
`);var c=class extends Error{constructor(t,n=`Errors found while validating environment variables`){let r=a(t)?o(t):s(t);super(`${i(`red`,n)}\n${e(r)}\n`),this.name=`ArkEnvError`}};Object.defineProperty(c,`name`,{value:`ArkEnvError`}),Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return c}});
|
|
6
|
+
|
|
7
|
+
// CJS Interop Shim
|
|
8
|
+
if (module.exports && module.exports.default) {
|
|
9
|
+
Object.assign(module.exports.default, module.exports);
|
|
10
|
+
module.exports = module.exports.default;
|
|
11
|
+
}
|
|
12
|
+
|
package/dist/index.cjs
CHANGED
|
@@ -1 +1,8 @@
|
|
|
1
|
-
Object.defineProperty(exports,`__esModule`,{value:!0});const e=require(`./errors-
|
|
1
|
+
Object.defineProperty(exports,`__esModule`,{value:!0});const e=require(`./errors-BtUS5QYF.cjs`);let t=require(`node:module`);function n(t,n){let{env:r=process.env,onUndeclaredKey:i=`delete`}=n,a={},o=[],s=new Set(Object.keys(r));for(let e in t){let n=t[e],i=r[e];if(!n||typeof n!=`object`||!(`~standard`in n))throw Error(`Invalid schema for key "${e}": expected a Standard Schema 1.0 validator (e.g. Zod, Valibot) in "standard" mode.`);let c=n[`~standard`].validate(i);if(c instanceof Promise)throw Error(`Async validation is not supported for key "${e}". ArkEnv is synchronous.`);if(c.issues)for(let t of c.issues)o.push({path:e,message:t.message});else a[e]=c.value;s.delete(e)}if(i!==`delete`)for(let e of s)i===`reject`?o.push({path:e,message:`Undeclared key`}):i===`ignore`&&(a[e]=r[e]);if(o.length>0)throw new e.t(o);return a}function r(e){return typeof e==`object`&&!!e&&`message`in e&&typeof e.message==`string`}function i(){let e=(()=>{try{let e={};if(e?.url)return(0,t.createRequire)(e.url)}catch{}try{let e=typeof module<`u`?module:void 0;if(e?.require)return e.require.bind(e)}catch{}try{return(0,t.createRequire)(`${process.cwd()}/index.js`)}catch{}})();if(!e)throw Error(`ArkEnv was unable to load the ArkType validator because neither 'createRequire' nor 'require' are available in this environment.`);let n=[`arkenv/arktype`,`./arktype.cjs`,`../arktype.cjs`,`./arktype/index.cjs`,`../arktype/index.cjs`,`./arktype`,`../arktype`,`./arktype/index.ts`,`../arktype/index.ts`],i;for(let t of n)try{return e(t)}catch(e){if(i=e,r(e)&&e.code===`MODULE_NOT_FOUND`){let n=e.message||``;if((n.includes(`'arktype'`)||n.includes(`"arktype"`)||n.includes(`Cannot find module 'arktype'`))&&!n.includes(t))break}}let a=r(i)?i.message:``;throw r(i)&&i.code===`MODULE_NOT_FOUND`&&(a.includes(`'arktype'`)||a.includes(`"arktype"`)||a.includes(`Cannot find module 'arktype'`))&&!a.includes(`./arktype`)&&!a.includes(`../arktype`)?Error(`The 'arktype' package is required when using the default validator mode. Please install it (npm install arktype) or set 'validator: "standard"' in your config if you only intend to use Standard Schema validators (like Zod or Valibot).`):i}function a(t,r={}){if((r.validator??`arktype`)===`standard`){if(!t||typeof t!=`object`||Array.isArray(t))throw new e.t([{path:``,message:`Invalid schema: expected an object mapping in "standard" mode.`}]);for(let n in t){let r=t[n];if(typeof r==`string`)throw new e.t([{path:n,message:`ArkType DSL strings are not supported in "standard" mode. Use a Standard Schema validator (e.g., Zod, Valibot) or set validator: "arktype".`}]);if(!r||typeof r!=`object`||!(`~standard`in r))throw new e.t([{path:n,message:`Invalid validator: expected a Standard Schema 1.0 validator (must have "~standard" property). ArkType validators are not supported in "standard" mode. Use validator: "arktype" for ArkType schemas.`}])}return n(t,r)}let{parse:a}=i();return a(t,r)}const o=a;var s=o;exports.ArkEnvError=e.t,exports.createEnv=a,exports.default=s;
|
|
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/index.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as EnvSchema, r as createEnv } from "./create-env-
|
|
1
|
+
import { n as EnvSchema, r as createEnv, t as ArkEnvConfig } from "./create-env-D7N4rUVE.cjs";
|
|
2
2
|
import { ArkErrors } from "arktype";
|
|
3
3
|
|
|
4
4
|
//#region src/errors.d.ts
|
|
@@ -6,17 +6,46 @@ type InternalValidationError = {
|
|
|
6
6
|
path: string;
|
|
7
7
|
message: string;
|
|
8
8
|
};
|
|
9
|
+
/**
|
|
10
|
+
* Error thrown when environment variable validation fails.
|
|
11
|
+
*
|
|
12
|
+
* This error extends the native `Error` class and provides formatted error messages
|
|
13
|
+
* that clearly indicate which environment variables are invalid and why.
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```ts
|
|
17
|
+
* import { createEnv, ArkEnvError } from 'arkenv';
|
|
18
|
+
*
|
|
19
|
+
* try {
|
|
20
|
+
* const env = createEnv({
|
|
21
|
+
* PORT: 'number.port',
|
|
22
|
+
* HOST: 'string.host',
|
|
23
|
+
* });
|
|
24
|
+
* } catch (error) {
|
|
25
|
+
* if (error instanceof ArkEnvError) {
|
|
26
|
+
* console.error('Environment validation failed:', error.message);
|
|
27
|
+
* }
|
|
28
|
+
* }
|
|
29
|
+
* ```
|
|
30
|
+
*/
|
|
9
31
|
declare class ArkEnvError extends Error {
|
|
10
32
|
constructor(errors: ArkErrors | InternalValidationError[], message?: string);
|
|
11
33
|
}
|
|
12
34
|
//#endregion
|
|
13
35
|
//#region src/index.d.ts
|
|
14
36
|
/**
|
|
15
|
-
*
|
|
37
|
+
* ArkEnv's main export, an alias for {@link createEnv}
|
|
16
38
|
*
|
|
17
39
|
* {@link https://arkenv.js.org | ArkEnv} is a typesafe environment variables validator from editor to runtime.
|
|
18
40
|
*/
|
|
19
41
|
declare const arkenv: typeof createEnv;
|
|
20
42
|
//#endregion
|
|
21
|
-
export { ArkEnvError, type EnvSchema, createEnv, arkenv as default };
|
|
43
|
+
export { type ArkEnvConfig, ArkEnvError, type EnvSchema, createEnv, arkenv as default };
|
|
44
|
+
|
|
45
|
+
// CJS Interop Shim
|
|
46
|
+
if (module.exports && module.exports.default) {
|
|
47
|
+
Object.assign(module.exports.default, module.exports);
|
|
48
|
+
module.exports = module.exports.default;
|
|
49
|
+
}
|
|
50
|
+
|
|
22
51
|
//# sourceMappingURL=index.d.cts.map
|
package/dist/index.d.cts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.cts","names":[],"sources":["../src/errors.ts","../src/index.ts"],"sourcesContent":[],"mappings":";;;;KAIY,uBAAA;;;AAAZ,CAAA
|
|
1
|
+
{"version":3,"file":"index.d.cts","names":[],"sources":["../src/errors.ts","../src/index.ts"],"sourcesContent":[],"mappings":";;;;KAIY,uBAAA;;;AAAZ,CAAA;;ACA0C;;;;;;;;;;;;;;;;;;;;;cDyF7B,WAAA,SAAoB,KAAA;sBAEvB,YAAY;;;;AA3FtB;AAyFA;;;;cClFM,MDkFgC,EAAA,OClF1B,SDkF0B"}
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { n as EnvSchema, r as createEnv, t as ArkEnvConfig } from "./create-env-BDbKkDKm.mjs";
|
|
2
|
+
import { ArkErrors } from "arktype";
|
|
3
|
+
|
|
4
|
+
//#region src/errors.d.ts
|
|
5
|
+
type InternalValidationError = {
|
|
6
|
+
path: string;
|
|
7
|
+
message: string;
|
|
8
|
+
};
|
|
9
|
+
/**
|
|
10
|
+
* Error thrown when environment variable validation fails.
|
|
11
|
+
*
|
|
12
|
+
* This error extends the native `Error` class and provides formatted error messages
|
|
13
|
+
* that clearly indicate which environment variables are invalid and why.
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```ts
|
|
17
|
+
* import { createEnv, ArkEnvError } from 'arkenv';
|
|
18
|
+
*
|
|
19
|
+
* try {
|
|
20
|
+
* const env = createEnv({
|
|
21
|
+
* PORT: 'number.port',
|
|
22
|
+
* HOST: 'string.host',
|
|
23
|
+
* });
|
|
24
|
+
* } catch (error) {
|
|
25
|
+
* if (error instanceof ArkEnvError) {
|
|
26
|
+
* console.error('Environment validation failed:', error.message);
|
|
27
|
+
* }
|
|
28
|
+
* }
|
|
29
|
+
* ```
|
|
30
|
+
*/
|
|
31
|
+
declare class ArkEnvError extends Error {
|
|
32
|
+
constructor(errors: ArkErrors | InternalValidationError[], message?: string);
|
|
33
|
+
}
|
|
34
|
+
//#endregion
|
|
35
|
+
//#region src/index.d.ts
|
|
36
|
+
/**
|
|
37
|
+
* ArkEnv's main export, an alias for {@link createEnv}
|
|
38
|
+
*
|
|
39
|
+
* {@link https://arkenv.js.org | ArkEnv} is a typesafe environment variables validator from editor to runtime.
|
|
40
|
+
*/
|
|
41
|
+
declare const arkenv: typeof createEnv;
|
|
42
|
+
//#endregion
|
|
43
|
+
export { type ArkEnvConfig, ArkEnvError, type EnvSchema, createEnv, arkenv as default };
|
|
44
|
+
|
|
45
|
+
//# sourceMappingURL=index.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/errors.ts","../src/index.ts"],"sourcesContent":[],"mappings":";;;;KAIY,uBAAA;;;AAAZ,CAAA;;ACA0C;;;;;;;;;;;;;;;;;;;;;cDyF7B,WAAA,SAAoB,KAAA;sBAEvB,YAAY;;;;AA3FtB;AAyFA;;;;cClFM,MDkFgC,EAAA,OClF1B,SDkF0B"}
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import{t as e}from"./errors-Bi-pULbt.mjs";import{createRequire as t}from"node:module";function n(t,n){let{env:r=process.env,onUndeclaredKey:i=`delete`}=n,a={},o=[],s=new Set(Object.keys(r));for(let e in t){let n=t[e],i=r[e];if(!n||typeof n!=`object`||!(`~standard`in n))throw Error(`Invalid schema for key "${e}": expected a Standard Schema 1.0 validator (e.g. Zod, Valibot) in "standard" mode.`);let c=n[`~standard`].validate(i);if(c instanceof Promise)throw Error(`Async validation is not supported for key "${e}". ArkEnv is synchronous.`);if(c.issues)for(let t of c.issues)o.push({path:e,message:t.message});else a[e]=c.value;s.delete(e)}if(i!==`delete`)for(let e of s)i===`reject`?o.push({path:e,message:`Undeclared key`}):i===`ignore`&&(a[e]=r[e]);if(o.length>0)throw new e(o);return a}function r(e){return typeof e==`object`&&!!e&&`message`in e&&typeof e.message==`string`}function i(){let e=(()=>{try{let e=import.meta;if(e?.url)return t(e.url)}catch{}try{let e=typeof module<`u`?module:void 0;if(e?.require)return e.require.bind(e)}catch{}try{return t(`${process.cwd()}/index.js`)}catch{}})();if(!e)throw Error(`ArkEnv was unable to load the ArkType validator because neither 'createRequire' nor 'require' are available in this environment.`);let n=[`arkenv/arktype`,`./arktype.cjs`,`../arktype.cjs`,`./arktype/index.cjs`,`../arktype/index.cjs`,`./arktype`,`../arktype`,`./arktype/index.ts`,`../arktype/index.ts`],i;for(let t of n)try{return e(t)}catch(e){if(i=e,r(e)&&e.code===`MODULE_NOT_FOUND`){let n=e.message||``;if((n.includes(`'arktype'`)||n.includes(`"arktype"`)||n.includes(`Cannot find module 'arktype'`))&&!n.includes(t))break}}let a=r(i)?i.message:``;throw r(i)&&i.code===`MODULE_NOT_FOUND`&&(a.includes(`'arktype'`)||a.includes(`"arktype"`)||a.includes(`Cannot find module 'arktype'`))&&!a.includes(`./arktype`)&&!a.includes(`../arktype`)?Error(`The 'arktype' package is required when using the default validator mode. Please install it (npm install arktype) or set 'validator: "standard"' in your config if you only intend to use Standard Schema validators (like Zod or Valibot).`):i}function a(t,r={}){if((r.validator??`arktype`)===`standard`){if(!t||typeof t!=`object`||Array.isArray(t))throw new e([{path:``,message:`Invalid schema: expected an object mapping in "standard" mode.`}]);for(let n in t){let r=t[n];if(typeof r==`string`)throw new e([{path:n,message:`ArkType DSL strings are not supported in "standard" mode. Use a Standard Schema validator (e.g., Zod, Valibot) or set validator: "arktype".`}]);if(!r||typeof r!=`object`||!(`~standard`in r))throw new e([{path:n,message:`Invalid validator: expected a Standard Schema 1.0 validator (must have "~standard" property). ArkType validators are not supported in "standard" mode. Use validator: "arktype" for ArkType schemas.`}])}return n(t,r)}let{parse:a}=i();return a(t,r)}var o=a;export{e as ArkEnvError,a as createEnv,o as default};
|
|
2
|
+
|
|
3
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.mjs","names":["output: Record<string, unknown>","errors: InternalValidationError[]","lastError: unknown","msg"],"sources":["../src/parse-standard.ts","../src/utils/load-arktype.ts","../src/create-env.ts","../src/index.ts"],"sourcesContent":["import type { StandardSchemaV1 } from \"@repo/types\";\nimport type { ArkEnvConfig } from \"./create-env.ts\";\nimport { ArkEnvError, type InternalValidationError } from \"./errors.ts\";\n\n/**\n * Standard Schema 1.0 parser dispatcher.\n * This helper implements parsing for the 'validator: \"standard\"' mode.\n */\nexport function parseStandard(\n\tdef: Record<string, unknown>,\n\tconfig: ArkEnvConfig,\n) {\n\tconst { env = process.env, onUndeclaredKey = \"delete\" } = config;\n\tconst output: Record<string, unknown> = {};\n\tconst errors: InternalValidationError[] = [];\n\tconst envKeys = new Set(Object.keys(env));\n\n\t// 1. Validate declared keys\n\tfor (const key in def) {\n\t\tconst validator = def[key];\n\t\tconst value = env[key];\n\n\t\t// Check if it's a Standard Schema validator\n\t\tif (\n\t\t\t!validator ||\n\t\t\ttypeof validator !== \"object\" ||\n\t\t\t!(\"~standard\" in validator)\n\t\t) {\n\t\t\tthrow new Error(\n\t\t\t\t`Invalid schema for key \"${key}\": expected a Standard Schema 1.0 validator (e.g. Zod, Valibot) in \"standard\" mode.`,\n\t\t\t);\n\t\t}\n\n\t\tconst result = (validator as StandardSchemaV1)[\"~standard\"].validate(value);\n\n\t\tif (result instanceof Promise) {\n\t\t\tthrow new Error(\n\t\t\t\t`Async validation is not supported for key \"${key}\". ArkEnv is synchronous.`,\n\t\t\t);\n\t\t}\n\n\t\tif (result.issues) {\n\t\t\tfor (const issue of result.issues) {\n\t\t\t\terrors.push({\n\t\t\t\t\tpath: key,\n\t\t\t\t\tmessage: issue.message,\n\t\t\t\t});\n\t\t\t}\n\t\t} else {\n\t\t\toutput[key] = result.value;\n\t\t}\n\n\t\tenvKeys.delete(key);\n\t}\n\n\t// 2. Handle undeclared keys\n\tif (onUndeclaredKey !== \"delete\") {\n\t\tfor (const key of envKeys) {\n\t\t\tif (onUndeclaredKey === \"reject\") {\n\t\t\t\terrors.push({\n\t\t\t\t\tpath: key,\n\t\t\t\t\tmessage: \"Undeclared key\",\n\t\t\t\t});\n\t\t\t} else if (onUndeclaredKey === \"ignore\") {\n\t\t\t\toutput[key] = env[key];\n\t\t\t}\n\t\t}\n\t}\n\n\tif (errors.length > 0) {\n\t\tthrow new ArkEnvError(errors);\n\t}\n\n\treturn output;\n}\n","import { createRequire } from \"node:module\";\n\n/**\n * An object that looks like an Error, containing at least a message and optionally a code.\n */\ntype ErrorLike = {\n\tmessage: string;\n\tcode?: string;\n};\n\nfunction isErrorLike(error: unknown): error is ErrorLike {\n\treturn (\n\t\ttypeof error === \"object\" &&\n\t\terror !== null &&\n\t\t\"message\" in error &&\n\t\ttypeof (error as Record<string, unknown>).message === \"string\"\n\t);\n}\n\n/**\n * Dynamically loads the ArkType validator module.\n * Provides a clear error message if the 'arktype' peer dependency is missing.\n */\nexport function loadArkTypeValidator() {\n\tconst _require = (() => {\n\t\ttry {\n\t\t\t// 1. ESM: Try to use import.meta.url\n\t\t\t// biome-ignore lint/suspicious/noExplicitAny: import.meta is not fully typed\n\t\t\tconst meta = import.meta as any;\n\t\t\tif (meta?.url) {\n\t\t\t\treturn createRequire(meta.url);\n\t\t\t}\n\t\t} catch {\n\t\t\t// ignore\n\t\t}\n\n\t\ttry {\n\t\t\t// 2. CommonJS: Use module.require if available\n\t\t\t// This is safer than eval and respects the local module scope.\n\t\t\t// biome-ignore lint/suspicious/noExplicitAny: module is a global in CJS\n\t\t\tconst m = typeof module !== \"undefined\" ? (module as any) : undefined;\n\t\t\tif (m?.require) {\n\t\t\t\treturn m.require.bind(m);\n\t\t\t}\n\t\t} catch {\n\t\t\t// ignore\n\t\t}\n\n\t\ttry {\n\t\t\t// 3. Generic Node: Try to use createRequire with the current directory\n\t\t\t// This works in both ESM and CJS if node:module is available.\n\t\t\treturn createRequire(`${process.cwd()}/index.js`);\n\t\t} catch {\n\t\t\t// ignore\n\t\t}\n\n\t\treturn undefined;\n\t})();\n\n\tif (!_require) {\n\t\tthrow new Error(\n\t\t\t\"ArkEnv was unable to load the ArkType validator because neither 'createRequire' \" +\n\t\t\t\t\"nor 'require' are available in this environment.\",\n\t\t);\n\t}\n\n\t// We try multiple paths to support both source execution (src/utils/load-arktype.ts)\n\t// and bundled execution (dist/index.js or dist/index.cjs where this is inlined).\n\tconst searchPaths = [\n\t\t\"arkenv/arktype\",\n\t\t\"./arktype.cjs\",\n\t\t\"../arktype.cjs\",\n\t\t\"./arktype/index.cjs\",\n\t\t\"../arktype/index.cjs\",\n\t\t\"./arktype\",\n\t\t\"../arktype\",\n\t\t\"./arktype/index.ts\",\n\t\t\"../arktype/index.ts\",\n\t];\n\n\tlet lastError: unknown;\n\n\tfor (const path of searchPaths) {\n\t\ttry {\n\t\t\treturn _require(path);\n\t\t} catch (e) {\n\t\t\tlastError = e;\n\n\t\t\tif (isErrorLike(e) && e.code === \"MODULE_NOT_FOUND\") {\n\t\t\t\tconst msg = e.message || \"\";\n\t\t\t\t// Nested failure: The error is about 'arktype' (the package) but we were trying to load a relative path.\n\t\t\t\tconst isNestedArkTypeFailure =\n\t\t\t\t\t(msg.includes(\"'arktype'\") ||\n\t\t\t\t\t\tmsg.includes('\"arktype\"') ||\n\t\t\t\t\t\tmsg.includes(\"Cannot find module 'arktype'\")) &&\n\t\t\t\t\t!msg.includes(path);\n\n\t\t\t\tif (isNestedArkTypeFailure) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t// If we reach here, either we searched all paths and none worked,\n\t// or we broke early because of a missing peer dependency.\n\tconst msg = isErrorLike(lastError) ? lastError.message : \"\";\n\t// Simpler heuristic: if the code is MODULE_NOT_FOUND and the message contains 'arktype'\n\t// but doesn't look like a relative path error for the current try.\n\tconst isMissingArkType =\n\t\tisErrorLike(lastError) &&\n\t\tlastError.code === \"MODULE_NOT_FOUND\" &&\n\t\t(msg.includes(\"'arktype'\") ||\n\t\t\tmsg.includes('\"arktype\"') ||\n\t\t\tmsg.includes(\"Cannot find module 'arktype'\")) &&\n\t\t!msg.includes(\"./arktype\") &&\n\t\t!msg.includes(\"../arktype\");\n\n\tif (isMissingArkType) {\n\t\tthrow new Error(\n\t\t\t\"The 'arktype' package is required when using the default validator mode. \" +\n\t\t\t\t\"Please install it (npm install arktype) or set 'validator: \\\"standard\\\"' in your config \" +\n\t\t\t\t\"if you only intend to use Standard Schema validators (like Zod or Valibot).\",\n\t\t);\n\t}\n\n\t// If it's some other error (like a syntax error in the validator), propagate it\n\tthrow lastError;\n}\n","import type { $ } from \"@repo/scope\";\nimport type {\n\tCompiledEnvSchema,\n\tDict,\n\tInferType,\n\tSchemaShape,\n\tStandardSchemaV1,\n} from \"@repo/types\";\nimport type { type as at, distill } from \"arktype\";\nimport { ArkEnvError } from \"./errors.ts\";\nimport { parseStandard } from \"./parse-standard.ts\";\nimport { loadArkTypeValidator } from \"./utils/load-arktype.ts\";\n\n/**\n * Declarative environment schema definition accepted by ArkEnv.\n *\n * Represents a declarative schema object mapping environment\n * variable names to schema definitions (e.g. ArkType DSL strings\n * or Standard Schema validators).\n *\n * This type is used to validate that a schema object is compatible with\n * ArkEnv’s validator scope before being compiled or parsed.\n *\n * Most users will provide schemas in this form.\n *\n * @template def - The schema shape object\n */\nexport type EnvSchema<def> = at.validate<def, $>;\ntype RuntimeEnvironment = Dict<string>;\n\n/**\n * Configuration options for `createEnv`\n */\nexport type ArkEnvConfig = {\n\t/**\n\t * The environment variables to parse. Defaults to `process.env`\n\t */\n\tenv?: RuntimeEnvironment;\n\t/**\n\t * Whether to coerce environment variables to their defined types. Defaults to `true`\n\t */\n\tcoerce?: boolean;\n\t/**\n\t * Control how ArkEnv handles environment variables that are not defined in your schema.\n\t *\n\t * Defaults to `'delete'` to ensure your output object only contains\n\t * keys you've explicitly declared. This differs from ArkType's standard behavior, which\n\t * mirrors TypeScript by defaulting to `'ignore'`.\n\t *\n\t * - `delete` (ArkEnv default): Undeclared keys are allowed on input but stripped from the output.\n\t * - `ignore` (ArkType default): Undeclared keys are allowed and preserved in the output.\n\t * - `reject`: Undeclared keys will cause validation to fail.\n\t *\n\t * @default \"delete\"\n\t * @see https://arktype.io/docs/configuration#onundeclaredkey\n\t */\n\tonUndeclaredKey?: \"ignore\" | \"delete\" | \"reject\";\n\n\t/**\n\t * The format to use for array parsing when coercion is enabled.\n\t *\n\t * - `comma` (default): Strings are split by comma and trimmed.\n\t * - `json`: Strings are parsed as JSON.\n\t *\n\t * @default \"comma\"\n\t */\n\tarrayFormat?: \"comma\" | \"json\";\n\t/**\n\t * Choose the validator engine to use.\n\t *\n\t * - `arktype` (default): Uses ArkType for all validation and coercion.\n\t * - `standard`: Uses Standard Schema 1.0 directly for validation. Coercion is not supported in this mode.\n\t *\n\t * @default \"arktype\"\n\t */\n\tvalidator?: \"arktype\" | \"standard\";\n};\n\n/**\n * TODO: `SchemaShape` is basically `Record<string, unknown>`.\n * If possible, find a better type than \"const T extends Record<string, unknown>\",\n * and be as close as possible to the type accepted by ArkType's `type`.\n */\n\n/**\n * Utility to parse environment variables using ArkType or Standard Schema\n * @param def - The schema definition\n * @param config - The evaluation configuration\n * @returns The parsed environment variables\n * @throws An {@link ArkEnvError | error} if the environment variables are invalid.\n */\nexport function createEnv<const T extends Record<string, StandardSchemaV1>>(\n\tdef: T,\n\tconfig: ArkEnvConfig & { validator: \"standard\" },\n): { [K in keyof T]: StandardSchemaV1.InferOutput<T[K]> };\nexport function createEnv<const T extends SchemaShape>(\n\tdef: EnvSchema<T>,\n\tconfig?: ArkEnvConfig,\n): distill.Out<at.infer<T, $>>;\nexport function createEnv<T extends CompiledEnvSchema>(\n\tdef: T,\n\tconfig?: ArkEnvConfig,\n): InferType<T>;\nexport function createEnv<const T extends SchemaShape>(\n\tdef: EnvSchema<T> | CompiledEnvSchema,\n\tconfig: ArkEnvConfig = {},\n): distill.Out<at.infer<T, $>> | InferType<typeof def> {\n\tconst mode = config.validator ?? \"arktype\";\n\n\tif (mode === \"standard\") {\n\t\t// Runtime guard: reject ArkType values in standard mode\n\t\tif (!def || typeof def !== \"object\" || Array.isArray(def)) {\n\t\t\tthrow new ArkEnvError([\n\t\t\t\t{\n\t\t\t\t\tpath: \"\",\n\t\t\t\t\tmessage:\n\t\t\t\t\t\t'Invalid schema: expected an object mapping in \"standard\" mode.',\n\t\t\t\t},\n\t\t\t]);\n\t\t}\n\n\t\t// Check each entry to ensure it's a Standard Schema validator\n\t\tfor (const key in def) {\n\t\t\tconst validator = (def as Record<string, unknown>)[key];\n\n\t\t\t// Reject strings (ArkType DSL)\n\t\t\tif (typeof validator === \"string\") {\n\t\t\t\tthrow new ArkEnvError([\n\t\t\t\t\t{\n\t\t\t\t\t\tpath: key,\n\t\t\t\t\t\tmessage:\n\t\t\t\t\t\t\t'ArkType DSL strings are not supported in \"standard\" mode. Use a Standard Schema validator (e.g., Zod, Valibot) or set validator: \"arktype\".',\n\t\t\t\t\t},\n\t\t\t\t]);\n\t\t\t}\n\n\t\t\t// Reject non-objects or objects without ~standard property (likely ArkType)\n\t\t\tif (\n\t\t\t\t!validator ||\n\t\t\t\ttypeof validator !== \"object\" ||\n\t\t\t\t!(\"~standard\" in validator)\n\t\t\t) {\n\t\t\t\tthrow new ArkEnvError([\n\t\t\t\t\t{\n\t\t\t\t\t\tpath: key,\n\t\t\t\t\t\tmessage:\n\t\t\t\t\t\t\t'Invalid validator: expected a Standard Schema 1.0 validator (must have \"~standard\" property). ArkType validators are not supported in \"standard\" mode. Use validator: \"arktype\" for ArkType schemas.',\n\t\t\t\t\t},\n\t\t\t\t]);\n\t\t\t}\n\t\t}\n\n\t\treturn parseStandard(def as Record<string, unknown>, config);\n\t}\n\n\tconst validator = loadArkTypeValidator();\n\tconst { parse } = validator;\n\n\treturn parse(def, config);\n}\n","import { createEnv } from \"./create-env.ts\";\n\nexport { createEnv };\nexport type { ArkEnvConfig, EnvSchema } from \"./create-env.ts\";\nexport { ArkEnvError } from \"./errors.ts\";\n\n/**\n * ArkEnv's main export, an alias for {@link createEnv}\n *\n * {@link https://arkenv.js.org | ArkEnv} is a typesafe environment variables validator from editor to runtime.\n */\nconst arkenv = createEnv;\nexport default arkenv;\n"],"mappings":"sFAQA,SAAgB,EACf,EACA,EACC,CACD,GAAM,CAAE,MAAM,QAAQ,IAAK,kBAAkB,UAAa,EACpDA,EAAkC,EAAE,CACpCC,EAAoC,EAAE,CACtC,EAAU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
4
|
-
"version": "0.9.
|
|
5
|
-
"main": "./dist/index.cjs",
|
|
6
|
-
"module": "./dist/index.js",
|
|
7
|
-
"types": "./dist/index.d.ts",
|
|
4
|
+
"version": "0.9.2",
|
|
8
5
|
"description": "Typesafe environment variables parsing and validation with ArkType",
|
|
6
|
+
"main": "./dist/index.cjs",
|
|
7
|
+
"module": "./dist/index.mjs",
|
|
8
|
+
"types": "./dist/index.d.mts",
|
|
9
9
|
"exports": {
|
|
10
10
|
".": {
|
|
11
|
-
"types":
|
|
12
|
-
|
|
11
|
+
"types": {
|
|
12
|
+
"import": "./dist/index.d.mts",
|
|
13
|
+
"require": "./dist/index.d.cts"
|
|
14
|
+
},
|
|
15
|
+
"import": "./dist/index.mjs",
|
|
13
16
|
"require": "./dist/index.cjs"
|
|
14
17
|
},
|
|
15
18
|
"./arktype": {
|
|
16
|
-
"types":
|
|
17
|
-
|
|
19
|
+
"types": {
|
|
20
|
+
"import": "./dist/arktype/index.d.mts",
|
|
21
|
+
"require": "./dist/arktype/index.d.cts"
|
|
22
|
+
},
|
|
23
|
+
"import": "./dist/arktype/index.mjs",
|
|
18
24
|
"require": "./dist/arktype/index.cjs"
|
|
19
25
|
}
|
|
20
26
|
},
|
|
@@ -40,15 +46,15 @@
|
|
|
40
46
|
"devDependencies": {
|
|
41
47
|
"@size-limit/esbuild-why": "12.0.0",
|
|
42
48
|
"@size-limit/preset-small-lib": "12.0.0",
|
|
43
|
-
"@types/node": "24.10.
|
|
49
|
+
"@types/node": "24.10.9",
|
|
44
50
|
"arktype": "2.1.29",
|
|
45
51
|
"rimraf": "6.1.2",
|
|
46
52
|
"size-limit": "12.0.0",
|
|
47
53
|
"tsdown": "0.18.4",
|
|
48
54
|
"typescript": "5.9.3",
|
|
49
55
|
"vitest": "4.0.17",
|
|
50
|
-
"@repo/
|
|
51
|
-
"@repo/
|
|
56
|
+
"@repo/types": "0.1.0",
|
|
57
|
+
"@repo/scope": "0.1.3"
|
|
52
58
|
},
|
|
53
59
|
"peerDependencies": {
|
|
54
60
|
"arktype": "^2.1.22"
|
|
@@ -60,7 +66,7 @@
|
|
|
60
66
|
},
|
|
61
67
|
"size-limit": [
|
|
62
68
|
{
|
|
63
|
-
"path": "dist/index.
|
|
69
|
+
"path": "dist/index.mjs",
|
|
64
70
|
"limit": "3 kB",
|
|
65
71
|
"import": "*",
|
|
66
72
|
"ignore": [
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[],"sources":["../../src/arktype/index.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;;cAaa,gCAAI;EAAJ,MAAA,oBAAa,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;sBAAT,MAAA;IAAA,CAAA,CAAA;IAED,KAAK,oBAAA,gDAAA;MAAiB,cAAA,EAAA,CAAA,EAAA,EAAA,MAAA,EAAA,qCAAA,CAAA,MAAA,CAAA;IACtB,CAAA,CAAA;IAAV,OAAA,oBAAA,wDAAA;MACG,cAAA,EAAA,MAAA;IAAY,CAAA,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAFL,sBAAsB,kBAChC,UAAU,YACP"}
|
package/dist/arktype/index.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{t as e}from"../errors-D_Q1KGgZ.js";import{ArkErrors as t,scope as n,type as r}from"arktype";const i=r(`0 <= number.integer <= 65535`),a=r(`string.ip | 'localhost'`),o=n({string:r.module({...r.keywords.string,host:a}),number:r.module({...r.keywords.number,port:i})}),s=e=>{if(typeof e==`number`||typeof e!=`string`)return e;let t=e.trim();if(t===``)return e;if(t===`NaN`)return NaN;let n=Number(t);return Number.isNaN(n)?e:n},c=e=>e===`true`?!0:e===`false`?!1:e,l=e=>{if(typeof e!=`string`)return e;let t=e.trim();if(!t.startsWith(`{`)&&!t.startsWith(`[`))return e;try{return JSON.parse(t)}catch{return e}},u=(e,t=[])=>{let n=[];if(typeof e==`boolean`)return n;if(`const`in e&&(typeof e.const==`number`||typeof e.const==`boolean`)&&n.push({path:[...t],type:`primitive`}),`enum`in e&&e.enum&&e.enum.some(e=>typeof e==`number`||typeof e==`boolean`)&&n.push({path:[...t],type:`primitive`}),`type`in e)if(e.type===`number`||e.type===`integer`)n.push({path:[...t],type:`primitive`});else if(e.type===`boolean`)n.push({path:[...t],type:`primitive`});else if(e.type===`object`){if(`properties`in e&&e.properties&&Object.keys(e.properties).length>0&&n.push({path:[...t],type:`object`}),`properties`in e&&e.properties)for(let[r,i]of Object.entries(e.properties))n.push(...u(i,[...t,r]))}else e.type===`array`&&(n.push({path:[...t],type:`array`}),`items`in e&&e.items&&(Array.isArray(e.items)?e.items.forEach((e,r)=>{n.push(...u(e,[...t,`${r}`]))}):n.push(...u(e.items,[...t,`*`]))));if(`anyOf`in e&&e.anyOf)for(let r of e.anyOf)n.push(...u(r,t));if(`allOf`in e&&e.allOf)for(let r of e.allOf)n.push(...u(r,t));if(`oneOf`in e&&e.oneOf)for(let r of e.oneOf)n.push(...u(r,t));let r=new Set;return n.filter(e=>{let t=JSON.stringify(e.path)+e.type;return r.has(t)?!1:(r.add(t),!0)})},d=(e,t,n={})=>{let{arrayFormat:r=`comma`}=n,i=e=>{if(r===`json`)try{return JSON.parse(e)}catch{return e}return e.trim()?e.split(`,`).map(e=>e.trim()):[]};if(typeof e!=`object`||!e){if(t.some(e=>e.path.length===0)){let n=t.find(e=>e.path.length===0);if(n?.type===`object`&&typeof e==`string`)return l(e);if(n?.type===`array`&&typeof e==`string`)return i(e);let r=s(e);return typeof r==`number`?r:c(e)}return e}let a=[...t].sort((e,t)=>e.path.length-t.path.length),o=(e,t,n)=>{if(!e||typeof e!=`object`||t.length===0)return;if(t.length===1){let r=t[0];if(r===`*`){if(Array.isArray(e))for(let t=0;t<e.length;t++){let r=e[t];if(n===`primitive`){let n=s(r);typeof n==`number`?e[t]=n:e[t]=c(r)}else n===`object`&&(e[t]=l(r))}return}let a=e;if(Object.prototype.hasOwnProperty.call(a,r)){let e=a[r];if(n===`array`&&typeof e==`string`){a[r]=i(e);return}if(n===`object`&&typeof e==`string`){a[r]=l(e);return}if(Array.isArray(e)){if(n===`primitive`)for(let t=0;t<e.length;t++){let n=e[t],r=s(n);typeof r==`number`?e[t]=r:e[t]=c(n)}}else if(n===`primitive`){let t=s(e);typeof t==`number`?a[r]=t:a[r]=c(e)}}return}let[r,...a]=t;if(r===`*`){if(Array.isArray(e))for(let t of e)o(t,a,n);return}o(e[r],a,n)};for(let t of a)o(e,t.path,t.type);return e};function f(e,t,n){let r=u(t.in.toJsonSchema({fallback:e=>e.base}));return r.length===0?t:e(`unknown`).pipe(e=>d(e,r,n)).pipe(t)}const p=o.type;function m(n,r){let{env:i=process.env,coerce:a=!0,onUndeclaredKey:s=`delete`,arrayFormat:c=`comma`}=r,l=(typeof n==`function`&&`assert`in n?n:o.type.raw(n)).onUndeclaredKey(s),u=l;a&&(u=f(o.type,l,{arrayFormat:c}));let d=u(i);if(d instanceof t)throw new e(d);return d}export{m as parse,p as type};
|
|
2
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["t","e","n","results: CoercionTarget[]","i","type","$"],"sources":["../../../internal/scope/dist/index.js","../../src/arktype/coercion/morphs.ts","../../src/arktype/coercion/coerce.ts","../../src/arktype/index.ts"],"sourcesContent":["import{scope as e,type as t}from\"arktype\";const n=t(`0 <= number.integer <= 65535`),r=t(`string.ip | 'localhost'`),i=e({string:t.module({...t.keywords.string,host:r}),number:t.module({...t.keywords.number,port:n})});export{i as $};\n//# sourceMappingURL=index.js.map","/**\n * Attempt to coerce a value to a number.\n *\n * If the input is already a number, returns it unchanged.\n * If the input is a string that can be parsed as a number, returns the parsed number.\n * Otherwise, returns the original value unchanged.\n *\n * @internal\n * @param s - The value to coerce\n * @returns The coerced number or the original value\n */\nexport const coerceNumber = (s: unknown) => {\n\tif (typeof s === \"number\") return s;\n\tif (typeof s !== \"string\") return s;\n\tconst trimmed = s.trim();\n\tif (trimmed === \"\") return s;\n\tif (trimmed === \"NaN\") return Number.NaN;\n\tconst n = Number(trimmed);\n\treturn Number.isNaN(n) ? s : n;\n};\n\n/**\n * Attempt to coerce a value to a boolean.\n *\n * Convert the strings \"true\" and \"false\" to their boolean equivalents.\n * All other values are returned unchanged.\n *\n * @internal\n * @param s - The value to coerce\n * @returns The coerced boolean or the original value\n */\nexport const coerceBoolean = (s: unknown) => {\n\tif (s === \"true\") return true;\n\tif (s === \"false\") return false;\n\treturn s;\n};\n\n/**\n * Attempt to parse a value as JSON.\n *\n * If the input is a string that starts with `{` or `[` and can be parsed as JSON,\n * returns the parsed object or array. Otherwise, returns the original value unchanged.\n *\n * @internal\n * @param s - The value to parse\n * @returns The parsed JSON or the original value\n */\nexport const coerceJson = (s: unknown) => {\n\tif (typeof s !== \"string\") return s;\n\tconst trimmed = s.trim();\n\tif (!trimmed.startsWith(\"{\") && !trimmed.startsWith(\"[\")) return s;\n\ttry {\n\t\treturn JSON.parse(trimmed);\n\t} catch {\n\t\treturn s;\n\t}\n};\n","import type { BaseType, JsonSchema } from \"arktype\";\nimport { ArkEnvError } from \"../../errors.ts\";\nimport { coerceBoolean, coerceJson, coerceNumber } from \"./morphs.ts\";\n\n/**\n * A marker used in the coercion path to indicate that the target\n * is the *elements* of an array, rather than the array property itself.\n */\nconst ARRAY_ITEM_MARKER = \"*\";\n\n/**\n * @internal\n * Information about a path in the schema that requires coercion.\n */\ntype CoercionTarget = {\n\tpath: string[];\n\ttype: \"primitive\" | \"array\" | \"object\";\n};\n\n/**\n * Options for coercion behavior.\n */\nexport type CoerceOptions = {\n\t/**\n\t * format to use for array parsing\n\t * @default \"comma\"\n\t */\n\tarrayFormat?: \"comma\" | \"json\";\n};\n\n/**\n * Recursively find all paths in a JSON Schema that require coercion.\n * We prioritize \"number\", \"integer\", \"boolean\", \"array\", and \"object\" types.\n */\nconst findCoercionPaths = (\n\tnode: JsonSchema,\n\tpath: string[] = [],\n): CoercionTarget[] => {\n\tconst results: CoercionTarget[] = [];\n\n\tif (typeof node === \"boolean\") {\n\t\treturn results;\n\t}\n\n\tif (\"const\" in node) {\n\t\tif (typeof node.const === \"number\" || typeof node.const === \"boolean\") {\n\t\t\tresults.push({ path: [...path], type: \"primitive\" });\n\t\t}\n\t}\n\n\tif (\"enum\" in node && node.enum) {\n\t\tif (\n\t\t\tnode.enum.some((v) => typeof v === \"number\" || typeof v === \"boolean\")\n\t\t) {\n\t\t\tresults.push({ path: [...path], type: \"primitive\" });\n\t\t}\n\t}\n\n\tif (\"type\" in node) {\n\t\tif (node.type === \"number\" || node.type === \"integer\") {\n\t\t\tresults.push({ path: [...path], type: \"primitive\" });\n\t\t} else if (node.type === \"boolean\") {\n\t\t\tresults.push({ path: [...path], type: \"primitive\" });\n\t\t} else if (node.type === \"object\") {\n\t\t\t// Check if this object has properties defined\n\t\t\t// If it does, we want to coerce the whole object from a JSON string\n\t\t\t// But we also want to recursively check nested properties\n\t\t\tconst hasProperties =\n\t\t\t\t\"properties\" in node &&\n\t\t\t\tnode.properties &&\n\t\t\t\tObject.keys(node.properties).length > 0;\n\n\t\t\tif (hasProperties) {\n\t\t\t\t// Mark this path as needing object coercion (JSON parsing)\n\t\t\t\tresults.push({ path: [...path], type: \"object\" });\n\t\t\t}\n\n\t\t\t// Also recursively check nested properties for their own coercions\n\t\t\tif (\"properties\" in node && node.properties) {\n\t\t\t\tfor (const [key, prop] of Object.entries(node.properties)) {\n\t\t\t\t\tresults.push(\n\t\t\t\t\t\t...findCoercionPaths(prop as JsonSchema, [...path, key]),\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\t\t} else if (node.type === \"array\") {\n\t\t\t// Mark the array itself as a target for splitting strings\n\t\t\tresults.push({ path: [...path], type: \"array\" });\n\n\t\t\tif (\"items\" in node && node.items) {\n\t\t\t\tif (Array.isArray(node.items)) {\n\t\t\t\t\t// Tuple traversal\n\t\t\t\t\tnode.items.forEach((item, index) => {\n\t\t\t\t\t\tresults.push(\n\t\t\t\t\t\t\t...findCoercionPaths(item as JsonSchema, [...path, `${index}`]),\n\t\t\t\t\t\t);\n\t\t\t\t\t});\n\t\t\t\t} else {\n\t\t\t\t\t// List traversal\n\t\t\t\t\tresults.push(\n\t\t\t\t\t\t...findCoercionPaths(node.items as JsonSchema, [\n\t\t\t\t\t\t\t...path,\n\t\t\t\t\t\t\tARRAY_ITEM_MARKER,\n\t\t\t\t\t\t]),\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tif (\"anyOf\" in node && node.anyOf) {\n\t\tfor (const branch of node.anyOf) {\n\t\t\tresults.push(...findCoercionPaths(branch as JsonSchema, path));\n\t\t}\n\t}\n\n\tif (\"allOf\" in node && node.allOf) {\n\t\tfor (const branch of node.allOf) {\n\t\t\tresults.push(...findCoercionPaths(branch as JsonSchema, path));\n\t\t}\n\t}\n\n\tif (\"oneOf\" in node && node.oneOf) {\n\t\tfor (const branch of node.oneOf) {\n\t\t\tresults.push(...findCoercionPaths(branch as JsonSchema, path));\n\t\t}\n\t}\n\n\t// Deduplicate by path and type combination\n\tconst seen = new Set<string>();\n\treturn results.filter((t) => {\n\t\tconst key = JSON.stringify(t.path) + t.type;\n\t\tif (seen.has(key)) return false;\n\t\tseen.add(key);\n\t\treturn true;\n\t});\n};\n\n/**\n * Apply coercion to a data object based on identified paths.\n */\nconst applyCoercion = (\n\tdata: unknown,\n\ttargets: CoercionTarget[],\n\toptions: CoerceOptions = {},\n) => {\n\tconst { arrayFormat = \"comma\" } = options;\n\n\t// Helper to split string to array\n\tconst splitString = (val: string) => {\n\t\tif (arrayFormat === \"json\") {\n\t\t\ttry {\n\t\t\t\treturn JSON.parse(val);\n\t\t\t} catch {\n\t\t\t\treturn val;\n\t\t\t}\n\t\t}\n\n\t\tif (!val.trim()) return [];\n\t\treturn val.split(\",\").map((s) => s.trim());\n\t};\n\n\tif (typeof data !== \"object\" || data === null) {\n\t\t// If root data needs coercion\n\t\tif (targets.some((t) => t.path.length === 0)) {\n\t\t\tconst rootTarget = targets.find((t) => t.path.length === 0);\n\n\t\t\tif (rootTarget?.type === \"object\" && typeof data === \"string\") {\n\t\t\t\treturn coerceJson(data);\n\t\t\t}\n\n\t\t\tif (rootTarget?.type === \"array\" && typeof data === \"string\") {\n\t\t\t\treturn splitString(data);\n\t\t\t}\n\n\t\t\tconst asNumber = coerceNumber(data);\n\t\t\tif (typeof asNumber === \"number\") {\n\t\t\t\treturn asNumber;\n\t\t\t}\n\t\t\treturn coerceBoolean(data);\n\t\t}\n\t\treturn data;\n\t}\n\n\t// Sort targets by path length to ensure parent objects/arrays are coerced before their children\n\tconst sortedTargets = [...targets].sort(\n\t\t(a, b) => a.path.length - b.path.length,\n\t);\n\n\tconst walk = (\n\t\tcurrent: unknown,\n\t\ttargetPath: string[],\n\t\ttype: \"primitive\" | \"array\" | \"object\",\n\t) => {\n\t\tif (!current || typeof current !== \"object\") return;\n\n\t\tif (targetPath.length === 0) {\n\t\t\treturn;\n\t\t}\n\n\t\t// If we've reached the last key, apply coercion\n\t\tif (targetPath.length === 1) {\n\t\t\tconst lastKey = targetPath[0];\n\n\t\t\tif (lastKey === ARRAY_ITEM_MARKER) {\n\t\t\t\tif (Array.isArray(current)) {\n\t\t\t\t\tfor (let i = 0; i < current.length; i++) {\n\t\t\t\t\t\tconst original = current[i];\n\t\t\t\t\t\tif (type === \"primitive\") {\n\t\t\t\t\t\t\tconst asNumber = coerceNumber(original);\n\t\t\t\t\t\t\tif (typeof asNumber === \"number\") {\n\t\t\t\t\t\t\t\tcurrent[i] = asNumber;\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tcurrent[i] = coerceBoolean(original);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} else if (type === \"object\") {\n\t\t\t\t\t\t\tcurrent[i] = coerceJson(original);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst record = current as Record<string, unknown>;\n\t\t\t// biome-ignore lint/suspicious/noPrototypeBuiltins: ES2020 compatibility\n\t\t\tif (Object.prototype.hasOwnProperty.call(record, lastKey)) {\n\t\t\t\tconst original = record[lastKey];\n\n\t\t\t\tif (type === \"array\" && typeof original === \"string\") {\n\t\t\t\t\trecord[lastKey] = splitString(original);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tif (type === \"object\" && typeof original === \"string\") {\n\t\t\t\t\trecord[lastKey] = coerceJson(original);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tif (Array.isArray(original)) {\n\t\t\t\t\tif (type === \"primitive\") {\n\t\t\t\t\t\tfor (let i = 0; i < original.length; i++) {\n\t\t\t\t\t\t\tconst item = original[i];\n\t\t\t\t\t\t\tconst asNumber = coerceNumber(item);\n\t\t\t\t\t\t\tif (typeof asNumber === \"number\") {\n\t\t\t\t\t\t\t\toriginal[i] = asNumber;\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\toriginal[i] = coerceBoolean(item);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tif (type === \"primitive\") {\n\t\t\t\t\t\tconst asNumber = coerceNumber(original);\n\t\t\t\t\t\t// If numeric parsing didn't produce a number, try boolean coercion\n\t\t\t\t\t\tif (typeof asNumber === \"number\") {\n\t\t\t\t\t\t\trecord[lastKey] = asNumber;\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\trecord[lastKey] = coerceBoolean(original);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\n\t\t// Recurse down\n\t\tconst [nextKey, ...rest] = targetPath;\n\n\t\tif (nextKey === ARRAY_ITEM_MARKER) {\n\t\t\tif (Array.isArray(current)) {\n\t\t\t\tfor (const item of current) {\n\t\t\t\t\twalk(item, rest, type);\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\n\t\tconst record = current as Record<string, unknown>;\n\t\twalk(record[nextKey], rest, type);\n\t};\n\n\tfor (const target of sortedTargets) {\n\t\twalk(data, target.path, target.type);\n\t}\n\n\treturn data;\n};\n\n/**\n * Create a coercing wrapper around an ArkType schema using JSON Schema introspection.\n * Pre-process input data to coerce string values to numbers/booleans at identified paths\n * before validation.\n */\nexport function coerce<t, $ = {}>(\n\tat: any,\n\tschema: BaseType<t, $>,\n\toptions?: CoerceOptions,\n): BaseType<t, $> {\n\t// Use a fallback to handle unjsonifiable parts of the schema (like predicates)\n\t// by preserving the base schema. This ensures that even if part of the schema\n\t// cannot be fully represented in JSON Schema, we can still perform coercion\n\t// for the parts that can.\n\tconst json = schema.in.toJsonSchema({\n\t\tfallback: (ctx) => (ctx as any).base,\n\t});\n\tconst targets = findCoercionPaths(json as any);\n\n\tif (targets.length === 0) {\n\t\treturn schema;\n\t}\n\n\t/*\n\t * We use `type(\"unknown\")` to start the pipeline, which initializes a default scope.\n\t * Integrating the original `schema` with its custom scope `$` into this pipeline\n\t * creates a scope mismatch in TypeScript ({} vs $).\n\t * We cast to `BaseType<t, $>` to assert the final contract is maintained.\n\t */\n\treturn at(\"unknown\")\n\t\t.pipe((data: unknown) => applyCoercion(data, targets, options))\n\t\t.pipe(schema) as BaseType<t, $>;\n}\n","import { $ } from \"@repo/scope\";\nimport type { SchemaShape } from \"@repo/types\";\nimport type { distill } from \"arktype\";\nimport { ArkErrors } from \"arktype\";\nimport type { ArkEnvConfig, EnvSchema } from \"../create-env.ts\";\nimport { ArkEnvError } from \"../errors.ts\";\nimport { coerce } from \"./coercion/coerce.ts\";\n\nexport type { distill };\n\n/**\n * Re-export the ArkType `type` function from the scoped root.\n */\nexport const type = $.type;\n\nexport function parse<const T extends SchemaShape>(\n\tdef: EnvSchema<T>,\n\tconfig: ArkEnvConfig,\n) {\n\tconst {\n\t\tenv = process.env,\n\t\tcoerce: shouldCoerce = true,\n\t\tonUndeclaredKey = \"delete\",\n\t\tarrayFormat = \"comma\",\n\t} = config;\n\n\t// If def is a type definition (has assert method), use it directly\n\t// Otherwise, use raw() to convert the schema definition\n\tconst isCompiledType = typeof def === \"function\" && \"assert\" in def;\n\tconst schema = (isCompiledType ? def : $.type.raw(def)) as any;\n\n\t// Apply the `onUndeclaredKey` option\n\tconst schemaWithKeys = schema.onUndeclaredKey(onUndeclaredKey);\n\n\t// Apply coercion transformation to allow strings to be parsed as numbers/booleans\n\tlet finalSchema = schemaWithKeys;\n\tif (shouldCoerce) {\n\t\tfinalSchema = coerce($.type, schemaWithKeys, { arrayFormat });\n\t}\n\n\t// Validate the environment variables\n\tconst validatedEnv = finalSchema(env);\n\n\t// In ArkType 2.x, calling a type as a function returns the validated data or ArkErrors\n\tif (validatedEnv instanceof ArkErrors) {\n\t\tthrow new ArkEnvError(validatedEnv);\n\t}\n\n\treturn validatedEnv;\n}\n"],"mappings":"mGAA0C,MAAM,EAAEA,EAAE,+BAA+B,CAAC,EAAEA,EAAE,0BAA0B,CAAC,EAAEC,EAAE,CAAC,OAAOD,EAAE,OAAO,CAAC,GAAGA,EAAE,SAAS,OAAO,KAAK,EAAE,CAAC,CAAC,OAAOA,EAAE,OAAO,CAAC,GAAGA,EAAE,SAAS,OAAO,KAAK,EAAE,CAAC,CAAC,CAAC,CCW1M,EAAgB,GAAe,CAE3C,GADI,OAAO,GAAM,UACb,OAAO,GAAM,SAAU,OAAO,EAClC,IAAM,EAAU,EAAE,MAAM,CACxB,GAAI,IAAY,GAAI,OAAO,EAC3B,GAAI,IAAY,MAAO,MAAO,KAC9B,IAAME,EAAI,OAAO,EAAQ,CACzB,OAAO,OAAO,MAAMA,EAAE,CAAG,EAAIA,GAajB,EAAiB,GACzB,IAAM,OAAe,GACrB,IAAM,QAAgB,GACnB,EAaK,EAAc,GAAe,CACzC,GAAI,OAAO,GAAM,SAAU,OAAO,EAClC,IAAM,EAAU,EAAE,MAAM,CACxB,GAAI,CAAC,EAAQ,WA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Aa,SACvB,EAAO,GAAW,EAElB,EAAO,GAAW,EAAc,EAAS,EAK7C,OAID,GAAM,CAAC,EAAS,GAAG,GAAQ,EAE3B,GAAI,IAAY,IAAmB,CAClC,GAAI,MAAM,QAAQ,EAAQ,CACzB,IAAK,IAAM,KAAQ,EAClB,EAAK,EAAM,EAAMA,EAAK,CAGxB,OAID,EADe,EACH,GAAU,EAAMA,EAAK,EAGlC,IAAK,IAAM,KAAU,EACpB,EAAK,EAAM,EAAO,KAAM,EAAO,KAAK,CAGrC,OAAO,GAQR,SAAgB,EACf,EACA,EACA,EACiB,CAQjB,IAAM,EAAU,EAHH,EAAO,GAAG,aAAa,CACnC,SAAW,GAAS,EAAY,KAChC,CAAC,CAC4C,CAY9C,OAVI,EAAQ,SAAW,EACf,EASD,EAAG,UAAU,CAClB,KAAM,GAAkB,EAAc,EAAM,EAAS,EAAQ,CAAC,CAC9D,KAAK,EAAO,CClTf,MAAa,EAAOC,EAAE,KAEtB,SAAgB,EACf,EACA,EACC,CACD,GAAM,CACL,MAAM,QAAQ,IACd,OAAQ,EAAe,GACvB,kBAAkB,SAClB,cAAc,SACX,EAQE,GAJiB,OAAO,GAAQ,YAAc,WAAY,EAC/B,EAAMA,EAAE,KAAK,IAAI,EAAI,EAGxB,gBAAgB,EAAgB,CAG1D,EAAc,EACd,IACH,EAAc,EAAOA,EAAE,KAAM,EAAgB,CAAE,cAAa,CAAC,EAI9D,IAAM,EAAe,EAAY,EAAI,CAGrC,GAAI,aAAwB,EAC3B,MAAM,IAAI,EAAY,EAAa,CAGpC,OAAO"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"create-env-Dk1I0Ftq.d.ts","names":["Dict","T","Record","type","InferType","T","Record","errors","Any","arktype0","arktype_internal_keywords_string_ts0","arktype_internal_attributes_ts0","$","trim","To","Submodule","normalize","capitalize","stringDate","stringInteger","ip","stringJson","lower","stringNumeric","url","uuid","Scope","$","Type","SchemaShape","Record","EnvSchemaWithType"],"sources":["../../internal/types/dist/helpers.d.ts","../../internal/types/dist/infer-type.d.ts","../../internal/scope/dist/index.d.ts","../../internal/types/dist/schema.d.ts","../src/create-env.ts"],"sourcesContent":["export type Dict<T> = Record<string, T | undefined>;\n//# sourceMappingURL=helpers.d.ts.map","import type { type } from \"arktype\";\n/**\n * Extract the inferred type from an ArkType type definition by checking its call signature.\n * When a type definition is called, it returns either the validated value or type.errors.\n *\n * @template T - The ArkType type definition to infer from\n */\nexport type InferType<T> = T extends (value: Record<string, string | undefined>) => infer R ? R extends type.errors ? never : R : T extends {\n t: infer U;\n} ? U : T extends type.Any<infer U, infer _Scope> ? U : never;\n//# sourceMappingURL=infer-type.d.ts.map","import * as arktype0 from \"arktype\";\nimport * as arktype_internal_keywords_string_ts0 from \"arktype/internal/keywords/string.ts\";\nimport * as arktype_internal_attributes_ts0 from \"arktype/internal/attributes.ts\";\n\n//#region src/root.d.ts\n/**\n * The root scope for the ArkEnv library,\n * containing extensions to the ArkType scopes with ArkEnv-specific types\n * like `string.host` and `number.port`.\n */\ndeclare const $: arktype0.Scope<{\n string: arktype0.Submodule<{\n trim: arktype0.Submodule<arktype_internal_keywords_string_ts0.trim.$ & {\n \" arkInferred\": (In: string) => arktype_internal_attributes_ts0.To<string>;\n }>;\n normalize: arktype0.Submodule<arktype_internal_keywords_string_ts0.normalize.$ & {\n \" arkInferred\": (In: string) => arktype_internal_attributes_ts0.To<string>;\n }>;\n root: string;\n alpha: string;\n alphanumeric: string;\n hex: string;\n base64: arktype0.Submodule<{\n root: string;\n url: string;\n } & {\n \" arkInferred\": string;\n }>;\n capitalize: arktype0.Submodule<arktype_internal_keywords_string_ts0.capitalize.$ & {\n \" arkInferred\": (In: string) => arktype_internal_attributes_ts0.To<string>;\n }>;\n creditCard: string;\n date: arktype0.Submodule<arktype_internal_keywords_string_ts0.stringDate.$ & {\n \" arkInferred\": string;\n }>;\n digits: string;\n email: string;\n integer: arktype0.Submodule<arktype_internal_keywords_string_ts0.stringInteger.$ & {\n \" arkInferred\": string;\n }>;\n ip: arktype0.Submodule<arktype_internal_keywords_string_ts0.ip.$ & {\n \" arkInferred\": string;\n }>;\n json: arktype0.Submodule<arktype_internal_keywords_string_ts0.stringJson.$ & {\n \" arkInferred\": string;\n }>;\n lower: arktype0.Submodule<arktype_internal_keywords_string_ts0.lower.$ & {\n \" arkInferred\": (In: string) => arktype_internal_attributes_ts0.To<string>;\n }>;\n numeric: arktype0.Submodule<arktype_internal_keywords_string_ts0.stringNumeric.$ & {\n \" arkInferred\": string;\n }>;\n regex: string;\n semver: string;\n upper: arktype0.Submodule<{\n root: (In: string) => arktype_internal_attributes_ts0.To<string>;\n preformatted: string;\n } & {\n \" arkInferred\": (In: string) => arktype_internal_attributes_ts0.To<string>;\n }>;\n url: arktype0.Submodule<arktype_internal_keywords_string_ts0.url.$ & {\n \" arkInferred\": string;\n }>;\n uuid: arktype0.Submodule<arktype_internal_keywords_string_ts0.uuid.$ & {\n \" arkInferred\": string;\n }>;\n \" arkInferred\": string;\n host: string;\n }>;\n number: arktype0.Submodule<{\n NaN: number;\n Infinity: number;\n root: number;\n integer: number;\n \" arkInferred\": number;\n epoch: number;\n safe: number;\n NegativeInfinity: number;\n port: number;\n }>;\n}>;\ntype $ = (typeof $)[\"t\"];\n//#endregion\nexport { $ };\n//# sourceMappingURL=index.d.ts.map","import type { $ } from \"@repo/scope\";\nimport type { Type } from \"arktype\";\nexport type SchemaShape = Record<string, unknown>;\nexport type EnvSchemaWithType = Type<SchemaShape, $>;\n//# sourceMappingURL=schema.d.ts.map"],"mappings":";;;;;;KAAYA,UAAUE,eAAeD;;;;;;;;AAArC;KCOYG,eAAeC,mBAAkBC,4DAA2DH,IAAAA,CAAKI,qBAAqBF;;QAE1HA,UAAUF,IAAAA,CAAKK;;;;;ADTvB;;;;ACOA,cCGcI,CDHFR,ECGKK,QAAAA,CAASiB,KDHL,CAAA;EAAMrB,MAAAA,ECIjBI,QAAAA,CAASM,SDJQV,CAAAA;IAAkBC,I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BC6EhB,SD7EgBA,CAAAA,UC6EI,iBD7EJA,CAAAA,CAAAA,GAAAA,EC8E1B,CD9E0BA,EAAAA,MAAAA,CAAAA,EC+EtB,YD/EsBA,CAAAA,ECgF7B,SDhF6BA,CCgFnB,CDhFmBA,CAAAA;AAAI,iBCiFpB,SDjFoB,CAAA,gBCiFM,WDjFN,CAAA,CAAA,GAAA,ECkF9B,SDlF8B,CCkFpB,CDlFoB,CAAA,GCkFf,iBDlFe,EAAA,MAAA,CAAA,ECmF1B,YDnF0B,CAAA,ECoFjC,OAAA,CAAQ,GDpFyB,CCoFrB,IAAA,CAAG,KDpFkB,CCoFZ,CDpFY,ECoFT,CDpFS,CAAA,CAAA,GCoFH,SDpFG,CAAA,OCoFc,GDpFd,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"create-env-gH1q_Fv8.d.cts","names":["Dict","T","Record","type","InferType","T","Record","errors","Any","arktype0","arktype_internal_keywords_string_ts0","arktype_internal_attributes_ts0","$","trim","To","Submodule","normalize","capitalize","stringDate","stringInteger","ip","stringJson","lower","stringNumeric","url","uuid","Scope","$","Type","SchemaShape","Record","EnvSchemaWithType"],"sources":["../../internal/types/dist/helpers.d.ts","../../internal/types/dist/infer-type.d.ts","../../internal/scope/dist/index.d.ts","../../internal/types/dist/schema.d.ts","../src/create-env.ts"],"sourcesContent":["export type Dict<T> = Record<string, T | undefined>;\n//# sourceMappingURL=helpers.d.ts.map","import type { type } from \"arktype\";\n/**\n * Extract the inferred type from an ArkType type definition by checking its call signature.\n * When a type definition is called, it returns either the validated value or type.errors.\n *\n * @template T - The ArkType type definition to infer from\n */\nexport type InferType<T> = T extends (value: Record<string, string | undefined>) => infer R ? R extends type.errors ? never : R : T extends {\n t: infer U;\n} ? U : T extends type.Any<infer U, infer _Scope> ? U : never;\n//# sourceMappingURL=infer-type.d.ts.map","import * as arktype0 from \"arktype\";\nimport * as arktype_internal_keywords_string_ts0 from \"arktype/internal/keywords/string.ts\";\nimport * as arktype_internal_attributes_ts0 from \"arktype/internal/attributes.ts\";\n\n//#region src/root.d.ts\n/**\n * The root scope for the ArkEnv library,\n * containing extensions to the ArkType scopes with ArkEnv-specific types\n * like `string.host` and `number.port`.\n */\ndeclare const $: arktype0.Scope<{\n string: arktype0.Submodule<{\n trim: arktype0.Submodule<arktype_internal_keywords_string_ts0.trim.$ & {\n \" arkInferred\": (In: string) => arktype_internal_attributes_ts0.To<string>;\n }>;\n normalize: arktype0.Submodule<arktype_internal_keywords_string_ts0.normalize.$ & {\n \" arkInferred\": (In: string) => arktype_internal_attributes_ts0.To<string>;\n }>;\n root: string;\n alpha: string;\n alphanumeric: string;\n hex: string;\n base64: arktype0.Submodule<{\n root: string;\n url: string;\n } & {\n \" arkInferred\": string;\n }>;\n capitalize: arktype0.Submodule<arktype_internal_keywords_string_ts0.capitalize.$ & {\n \" arkInferred\": (In: string) => arktype_internal_attributes_ts0.To<string>;\n }>;\n creditCard: string;\n date: arktype0.Submodule<arktype_internal_keywords_string_ts0.stringDate.$ & {\n \" arkInferred\": string;\n }>;\n digits: string;\n email: string;\n integer: arktype0.Submodule<arktype_internal_keywords_string_ts0.stringInteger.$ & {\n \" arkInferred\": string;\n }>;\n ip: arktype0.Submodule<arktype_internal_keywords_string_ts0.ip.$ & {\n \" arkInferred\": string;\n }>;\n json: arktype0.Submodule<arktype_internal_keywords_string_ts0.stringJson.$ & {\n \" arkInferred\": string;\n }>;\n lower: arktype0.Submodule<arktype_internal_keywords_string_ts0.lower.$ & {\n \" arkInferred\": (In: string) => arktype_internal_attributes_ts0.To<string>;\n }>;\n numeric: arktype0.Submodule<arktype_internal_keywords_string_ts0.stringNumeric.$ & {\n \" arkInferred\": string;\n }>;\n regex: string;\n semver: string;\n upper: arktype0.Submodule<{\n root: (In: string) => arktype_internal_attributes_ts0.To<string>;\n preformatted: string;\n } & {\n \" arkInferred\": (In: string) => arktype_internal_attributes_ts0.To<string>;\n }>;\n url: arktype0.Submodule<arktype_internal_keywords_string_ts0.url.$ & {\n \" arkInferred\": string;\n }>;\n uuid: arktype0.Submodule<arktype_internal_keywords_string_ts0.uuid.$ & {\n \" arkInferred\": string;\n }>;\n \" arkInferred\": string;\n host: string;\n }>;\n number: arktype0.Submodule<{\n NaN: number;\n Infinity: number;\n root: number;\n integer: number;\n \" arkInferred\": number;\n epoch: number;\n safe: number;\n NegativeInfinity: number;\n port: number;\n }>;\n}>;\ntype $ = (typeof $)[\"t\"];\n//#endregion\nexport { $ };\n//# sourceMappingURL=index.d.ts.map","import type { $ } from \"@repo/scope\";\nimport type { Type } from \"arktype\";\nexport type SchemaShape = Record<string, unknown>;\nexport type EnvSchemaWithType = Type<SchemaShape, $>;\n//# sourceMappingURL=schema.d.ts.map"],"mappings":";;;;;;KAAYA,UAAUE,eAAeD;;;;;;;;AAArC;KCOYG,eAAeC,mBAAkBC,4DAA2DH,IAAAA,CAAKI,qBAAqBF;;QAE1HA,UAAUF,IAAAA,CAAKK;;;;;ADTvB;;;;ACOA,cCGcI,CDHFR,ECGKK,QAAAA,CAASiB,KDHL,CAAA;EAAMrB,MAAAA,ECIjBI,QAAAA,CAASM,SDJQV,CAAAA;IAAkBC,IAAAA,ECKnCG,QAAAA,CAASM,SDL0BT,CCKhBI,oCAAAA,CAAqCG,IAAAA,CAAKD,CDL1BN,GAAAA;MAAgEC,cAAAA,EAAAA,CAAAA,EAAAA,EAAAA,MAAAA,EAAAA,GCMvEI,+BAAAA,CAAgCG,EDNuCP,CAAAA,MAAAA,CAAAA;IAAqBF,CAAAA,CAAAA;IAE1HA,SAAAA,ECMOI,QAAAA,CAASM,SDNhBV,CCM0BK,oCAAAA,CAAqCM,SAAAA,CAAUJ,CDNzEP,GAAAA;MAAeG,cAAAA,EAAAA,CAAAA,EAAAA,EAAAA,MAAAA,EAAAA,GCOeG,+BAAAA,CAAgCG,EDP/CN,CAAAA,MAAAA,CAAAA;IAAG,CAAA,CAAA;;;;ICCZI,GAAAA,EAsEZ,MAAA;IApE2BF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
|
|
1
|
-
{"version":3,"file":"errors-D_Q1KGgZ.js","names":[],"sources":["../src/utils/indent.ts","../src/utils/style-text.ts","../src/errors.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 type { ArkErrors } from \"arktype\";\nimport { indent } from \"./utils/indent.ts\";\nimport { styleText } from \"./utils/style-text.ts\";\n\nexport type InternalValidationError = {\n\tpath: string;\n\tmessage: string;\n};\n\n/**\n * Check if the provided object is ArkType errors\n */\nconst isArkErrors = (errors: unknown): errors is ArkErrors => {\n\treturn (\n\t\terrors !== null &&\n\t\ttypeof errors === \"object\" &&\n\t\t\"byPath\" in (errors as Record<string, unknown>)\n\t);\n};\n\n/**\n * Format the errors returned by ArkType to be more readable\n * @param errors - The errors returned by ArkType\n * @returns A string of the formatted errors\n */\nexport const formatArkErrors = (errors: ArkErrors): string => {\n\treturn Object.entries(errors.byPath)\n\t\t.map(([path, error]) => {\n\t\t\tlet message = error.message;\n\n\t\t\tconst escapedPath = path.replace(/[.*+?^${}()|[\\]\\\\]/g, \"\\\\$&\");\n\t\t\tconst pathRegex = new RegExp(\n\t\t\t\t`^\\\\s*[:.-]?\\\\s*${escapedPath}\\\\s*[:.-]?\\\\s*`,\n\t\t\t\t\"i\",\n\t\t\t);\n\n\t\t\tif (pathRegex.test(message)) {\n\t\t\t\t// Style the existing path prefix\n\t\t\t\tmessage = message.replace(pathRegex, (match) => {\n\t\t\t\t\treturn `${styleText(\"yellow\", path)}${match.toLowerCase().replace(path.toLowerCase(), \"\")}`;\n\t\t\t\t});\n\t\t\t} else {\n\t\t\t\t// Prepend styled path\n\t\t\t\tmessage = `${styleText(\"yellow\", path)} ${message}`;\n\t\t\t}\n\n\t\t\t// Style (was ...)\n\t\t\tconst valueMatch = message.match(/\\(was (.*)\\)/);\n\t\t\tif (valueMatch?.[1]) {\n\t\t\t\tconst value = valueMatch[1];\n\t\t\t\tif (!value.includes(\"\\x1b[\")) {\n\t\t\t\t\tconst styledValue = styleText(\"cyan\", value);\n\t\t\t\t\tmessage = message.replace(`(was ${value})`, `(was ${styledValue})`);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn message;\n\t\t})\n\t\t.join(\"\\n\");\n};\n\nexport const formatInternalErrors = (\n\terrors: InternalValidationError[],\n): 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\nexport class ArkEnvError extends Error {\n\tconstructor(\n\t\terrors: ArkErrors | InternalValidationError[],\n\t\tmessage = \"Errors found while validating environment variables\",\n\t) {\n\t\t// ArkType errors subclass Array, so we must check for ArkErrors specifically first\n\t\tconst formattedErrors = isArkErrors(errors)\n\t\t\t? formatArkErrors(errors)\n\t\t\t: formatInternalErrors(errors as InternalValidationError[]);\n\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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AAO,eAAe,EAAa,OAAQ,CAAE,MAAO,cAAe,CAAC"}
|
package/dist/index.d.ts
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { n as EnvSchema, r as createEnv } from "./create-env-Dk1I0Ftq.js";
|
|
2
|
-
import { ArkErrors } from "arktype";
|
|
3
|
-
|
|
4
|
-
//#region src/errors.d.ts
|
|
5
|
-
type InternalValidationError = {
|
|
6
|
-
path: string;
|
|
7
|
-
message: string;
|
|
8
|
-
};
|
|
9
|
-
declare class ArkEnvError extends Error {
|
|
10
|
-
constructor(errors: ArkErrors | InternalValidationError[], message?: string);
|
|
11
|
-
}
|
|
12
|
-
//#endregion
|
|
13
|
-
//#region src/index.d.ts
|
|
14
|
-
/**
|
|
15
|
-
* `arkenv`'s main export, an alias for {@link createEnv}
|
|
16
|
-
*
|
|
17
|
-
* {@link https://arkenv.js.org | ArkEnv} is a typesafe environment variables validator from editor to runtime.
|
|
18
|
-
*/
|
|
19
|
-
declare const arkenv: typeof createEnv;
|
|
20
|
-
//#endregion
|
|
21
|
-
export { ArkEnvError, type EnvSchema, createEnv, arkenv as default };
|
|
22
|
-
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/errors.ts","../src/index.ts"],"sourcesContent":[],"mappings":";;;;KAIY,uBAAA;;;AAAZ,CAAA;cAmEa,WAAA,SAAoB,KAAA;EC5D3B,WAAkB,CAAA,MAAA,ED8Dd,SC9DE,GD8DU,uBC9DE,EAAA,EAAA,OAAA,CAAA,EAAA,MAAA;;;;ADPxB;AAmEA;;;;cC5DM,MD4DgC,EAAA,OC5D1B,SD4D0B"}
|
package/dist/index.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{t as e}from"./errors-D_Q1KGgZ.js";import{createRequire as t}from"node:module";function n(t,n){let{env:r=process.env,onUndeclaredKey:i=`delete`}=n,a={},o=[],s=new Set(Object.keys(r));for(let e in t){let n=t[e],i=r[e];if(!n||typeof n!=`object`||!(`~standard`in n))throw Error(`Invalid schema for key "${e}": expected a Standard Schema 1.0 validator (e.g. Zod, Valibot) in "standard" mode.`);let c=n[`~standard`].validate(i);if(c instanceof Promise)throw Error(`Async validation is not supported for key "${e}". ArkEnv is synchronous.`);if(c.issues)for(let t of c.issues)o.push({path:e,message:t.message});else a[e]=c.value;s.delete(e)}if(i!==`delete`)for(let e of s)i===`reject`?o.push({path:e,message:`Undeclared key`}):i===`ignore`&&(a[e]=r[e]);if(o.length>0)throw new e(o);return a}function r(){let e=t(import.meta.url),n=[`./arktype.cjs`,`../arktype.cjs`,`./arktype/index.cjs`,`../arktype/index.cjs`,`./arktype`,`../arktype`,`./arktype/index.ts`,`../arktype/index.ts`],r;for(let t of n)try{return e(t)}catch(e){if(r=e,e.code===`MODULE_NOT_FOUND`){let n=e.message||``;if((n.includes(`'arktype'`)||n.includes(`"arktype"`)||n.includes(`Cannot find module 'arktype'`))&&!n.includes(t))break}}let i=r?.message||``;throw r?.code===`MODULE_NOT_FOUND`&&(i.includes(`'arktype'`)||i.includes(`"arktype"`)||i.includes(`Cannot find module 'arktype'`))&&!i.includes(`./arktype`)&&!i.includes(`../arktype`)?Error(`The 'arktype' package is required when using the default validator mode. Please install it (npm install arktype) or set 'validator: "standard"' in your config if you only intend to use Standard Schema validators (like Zod or Valibot).`):r}function i(t,i={}){if((i.validator??`arktype`)===`standard`){if(!t||typeof t!=`object`||Array.isArray(t))throw new e([{path:``,message:`Invalid schema: expected an object mapping in "standard" mode.`}]);for(let n in t){let r=t[n];if(typeof r==`string`)throw new e([{path:n,message:`ArkType DSL strings are not supported in "standard" mode. Use a Standard Schema validator (e.g., Zod, Valibot) or set validator: "arktype".`}]);if(!r||typeof r!=`object`||!(`~standard`in r))throw new e([{path:n,message:`Invalid validator: expected a Standard Schema 1.0 validator (must have "~standard" property). ArkType validators are not supported in "standard" mode. Use validator: "arktype" for ArkType schemas.`}])}return n(t,i)}let{parse:a}=r();return a(t,i)}var a=i;export{e as ArkEnvError,i as createEnv,a as default};
|
|
2
|
-
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["output: Record<string, unknown>","errors: InternalValidationError[]","lastError: any","e: any","msg"],"sources":["../src/parse-standard.ts","../src/utils/load-arktype.ts","../src/create-env.ts","../src/index.ts"],"sourcesContent":["import type { StandardSchemaV1 } from \"@repo/types\";\nimport type { ArkEnvConfig } from \"./create-env.ts\";\nimport { ArkEnvError, type InternalValidationError } from \"./errors.ts\";\n\n/**\n * Standard Schema 1.0 parser dispatcher.\n * This helper implements parsing for the 'validator: \"standard\"' mode.\n */\nexport function parseStandard(\n\tdef: Record<string, unknown>,\n\tconfig: ArkEnvConfig,\n) {\n\tconst { env = process.env, onUndeclaredKey = \"delete\" } = config;\n\tconst output: Record<string, unknown> = {};\n\tconst errors: InternalValidationError[] = [];\n\tconst envKeys = new Set(Object.keys(env));\n\n\t// 1. Validate declared keys\n\tfor (const key in def) {\n\t\tconst validator = def[key];\n\t\tconst value = env[key];\n\n\t\t// Check if it's a Standard Schema validator\n\t\tif (\n\t\t\t!validator ||\n\t\t\ttypeof validator !== \"object\" ||\n\t\t\t!(\"~standard\" in validator)\n\t\t) {\n\t\t\tthrow new Error(\n\t\t\t\t`Invalid schema for key \"${key}\": expected a Standard Schema 1.0 validator (e.g. Zod, Valibot) in \"standard\" mode.`,\n\t\t\t);\n\t\t}\n\n\t\tconst result = (validator as StandardSchemaV1)[\"~standard\"].validate(value);\n\n\t\tif (result instanceof Promise) {\n\t\t\tthrow new Error(\n\t\t\t\t`Async validation is not supported for key \"${key}\". ArkEnv is synchronous.`,\n\t\t\t);\n\t\t}\n\n\t\tif (result.issues) {\n\t\t\tfor (const issue of result.issues) {\n\t\t\t\terrors.push({\n\t\t\t\t\tpath: key,\n\t\t\t\t\tmessage: issue.message,\n\t\t\t\t});\n\t\t\t}\n\t\t} else {\n\t\t\toutput[key] = result.value;\n\t\t}\n\n\t\tenvKeys.delete(key);\n\t}\n\n\t// 2. Handle undeclared keys\n\tif (onUndeclaredKey !== \"delete\") {\n\t\tfor (const key of envKeys) {\n\t\t\tif (onUndeclaredKey === \"reject\") {\n\t\t\t\terrors.push({\n\t\t\t\t\tpath: key,\n\t\t\t\t\tmessage: \"Undeclared key\",\n\t\t\t\t});\n\t\t\t} else if (onUndeclaredKey === \"ignore\") {\n\t\t\t\toutput[key] = env[key];\n\t\t\t}\n\t\t}\n\t}\n\n\tif (errors.length > 0) {\n\t\tthrow new ArkEnvError(errors);\n\t}\n\n\treturn output;\n}\n","import { createRequire } from \"node:module\";\n\n/**\n * Dynamically loads the ArkType validator module.\n * Provides a clear error message if the 'arktype' peer dependency is missing.\n */\nexport function loadArkTypeValidator() {\n\tconst require = createRequire(import.meta.url);\n\n\t// We try multiple paths to support both source execution (src/utils/load-arktype.ts)\n\t// and bundled execution (dist/index.js or dist/index.cjs where this is inlined).\n\tconst searchPaths = [\n\t\t\"./arktype.cjs\",\n\t\t\"../arktype.cjs\",\n\t\t\"./arktype/index.cjs\",\n\t\t\"../arktype/index.cjs\",\n\t\t\"./arktype\",\n\t\t\"../arktype\",\n\t\t\"./arktype/index.ts\",\n\t\t\"../arktype/index.ts\",\n\t];\n\n\tlet lastError: any;\n\n\tfor (const path of searchPaths) {\n\t\ttry {\n\t\t\treturn require(path);\n\t\t} catch (e: any) {\n\t\t\tlastError = e;\n\n\t\t\t// Check if this error is specifically about the 'arktype' package being missing.\n\t\t\t// If require(path) failed because of a missing 'arktype' dependency INSIDE the path,\n\t\t\t// the error code will be MODULE_NOT_FOUND, but the message will not mention our path.\n\t\t\tif (e.code === \"MODULE_NOT_FOUND\") {\n\t\t\t\tconst msg = e.message || \"\";\n\t\t\t\t// Nested failure: The error is about 'arktype' (the package) but we were trying to load a relative path.\n\t\t\t\tconst isNestedArkTypeFailure =\n\t\t\t\t\t(msg.includes(\"'arktype'\") ||\n\t\t\t\t\t\tmsg.includes('\"arktype\"') ||\n\t\t\t\t\t\tmsg.includes(\"Cannot find module 'arktype'\")) &&\n\t\t\t\t\t!msg.includes(path);\n\n\t\t\t\tif (isNestedArkTypeFailure) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t// If we reach here, either we searched all paths and none worked,\n\t// or we broke early because of a missing peer dependency.\n\tconst msg = lastError?.message || \"\";\n\t// Simpler heuristic: if the code is MODULE_NOT_FOUND and the message contains 'arktype'\n\t// but doesn't look like a relative path error for the current try.\n\tconst isMissingArkType =\n\t\tlastError?.code === \"MODULE_NOT_FOUND\" &&\n\t\t(msg.includes(\"'arktype'\") ||\n\t\t\tmsg.includes('\"arktype\"') ||\n\t\t\tmsg.includes(\"Cannot find module 'arktype'\")) &&\n\t\t!msg.includes(\"./arktype\") &&\n\t\t!msg.includes(\"../arktype\");\n\n\tif (isMissingArkType) {\n\t\tthrow new Error(\n\t\t\t\"The 'arktype' package is required when using the default validator mode. \" +\n\t\t\t\t\"Please install it (npm install arktype) or set 'validator: \\\"standard\\\"' in your config \" +\n\t\t\t\t\"if you only intend to use Standard Schema validators (like Zod or Valibot).\",\n\t\t);\n\t}\n\n\t// If it's some other error (like a syntax error in the validator), propagate it\n\tthrow lastError;\n}\n","import type { $ } from \"@repo/scope\";\nimport type {\n\tDict,\n\tEnvSchemaWithType,\n\tInferType,\n\tSchemaShape,\n} from \"@repo/types\";\nimport type { type as at, distill } from \"arktype\";\nimport { ArkEnvError } from \"./errors.ts\";\nimport { parseStandard } from \"./parse-standard.ts\";\nimport { loadArkTypeValidator } from \"./utils/load-arktype.ts\";\n\nexport type EnvSchema<def> = at.validate<def, $>;\ntype RuntimeEnvironment = Dict<string>;\n\n/**\n * Configuration options for `createEnv`\n */\nexport type ArkEnvConfig = {\n\t/**\n\t * The environment variables to parse. Defaults to `process.env`\n\t */\n\tenv?: RuntimeEnvironment;\n\t/**\n\t * Whether to coerce environment variables to their defined types. Defaults to `true`\n\t */\n\tcoerce?: boolean;\n\t/**\n\t * Control how ArkEnv handles environment variables that are not defined in your schema.\n\t *\n\t * Defaults to `'delete'` to ensure your output object only contains\n\t * keys you've explicitly declared. This differs from ArkType's standard behavior, which\n\t * mirrors TypeScript by defaulting to `'ignore'`.\n\t *\n\t * - `delete` (ArkEnv default): Undeclared keys are allowed on input but stripped from the output.\n\t * - `ignore` (ArkType default): Undeclared keys are allowed and preserved in the output.\n\t * - `reject`: Undeclared keys will cause validation to fail.\n\t *\n\t * @default \"delete\"\n\t * @see https://arktype.io/docs/configuration#onundeclaredkey\n\t */\n\tonUndeclaredKey?: \"ignore\" | \"delete\" | \"reject\";\n\n\t/**\n\t * The format to use for array parsing when coercion is enabled.\n\t *\n\t * - `comma` (default): Strings are split by comma and trimmed.\n\t * - `json`: Strings are parsed as JSON.\n\t *\n\t * @default \"comma\"\n\t */\n\tarrayFormat?: \"comma\" | \"json\";\n\t/**\n\t * Choose the validator engine to use.\n\t *\n\t * - `arktype` (default): Uses ArkType for all validation and coercion.\n\t * - `standard`: Uses Standard Schema 1.0 directly for validation. Coercion is not supported in this mode.\n\t *\n\t * @default \"arktype\"\n\t */\n\tvalidator?: \"arktype\" | \"standard\";\n};\n\n/**\n * TODO: `SchemaShape` is basically `Record<string, unknown>`.\n * If possible, find a better type than \"const T extends Record<string, unknown>\",\n * and be as close as possible to the type accepted by ArkType's `type`.\n */\n\n/**\n * Utility to parse environment variables using ArkType or Standard Schema\n * @param def - The schema definition\n * @param config - The evaluation configuration\n * @returns The parsed environment variables\n * @throws An {@link ArkEnvError | error} if the environment variables are invalid.\n */\nexport function createEnv<const T extends SchemaShape>(\n\tdef: EnvSchema<T>,\n\tconfig?: ArkEnvConfig,\n): distill.Out<at.infer<T, $>>;\nexport function createEnv<T extends EnvSchemaWithType>(\n\tdef: T,\n\tconfig?: ArkEnvConfig,\n): InferType<T>;\nexport function createEnv<const T extends SchemaShape>(\n\tdef: EnvSchema<T> | EnvSchemaWithType,\n\tconfig?: ArkEnvConfig,\n): distill.Out<at.infer<T, $>> | InferType<typeof def>;\nexport function createEnv<const T extends SchemaShape>(\n\tdef: EnvSchema<T> | EnvSchemaWithType,\n\tconfig: ArkEnvConfig = {},\n): distill.Out<at.infer<T, $>> | InferType<typeof def> {\n\tconst mode = config.validator ?? \"arktype\";\n\n\tif (mode === \"standard\") {\n\t\t// Runtime guard: reject ArkType values in standard mode\n\t\tif (!def || typeof def !== \"object\" || Array.isArray(def)) {\n\t\t\tthrow new ArkEnvError([\n\t\t\t\t{\n\t\t\t\t\tpath: \"\",\n\t\t\t\t\tmessage:\n\t\t\t\t\t\t'Invalid schema: expected an object mapping in \"standard\" mode.',\n\t\t\t\t},\n\t\t\t]);\n\t\t}\n\n\t\t// Check each entry to ensure it's a Standard Schema validator\n\t\tfor (const key in def) {\n\t\t\tconst validator = (def as Record<string, unknown>)[key];\n\n\t\t\t// Reject strings (ArkType DSL)\n\t\t\tif (typeof validator === \"string\") {\n\t\t\t\tthrow new ArkEnvError([\n\t\t\t\t\t{\n\t\t\t\t\t\tpath: key,\n\t\t\t\t\t\tmessage:\n\t\t\t\t\t\t\t'ArkType DSL strings are not supported in \"standard\" mode. Use a Standard Schema validator (e.g., Zod, Valibot) or set validator: \"arktype\".',\n\t\t\t\t\t},\n\t\t\t\t]);\n\t\t\t}\n\n\t\t\t// Reject non-objects or objects without ~standard property (likely ArkType)\n\t\t\tif (\n\t\t\t\t!validator ||\n\t\t\t\ttypeof validator !== \"object\" ||\n\t\t\t\t!(\"~standard\" in validator)\n\t\t\t) {\n\t\t\t\tthrow new ArkEnvError([\n\t\t\t\t\t{\n\t\t\t\t\t\tpath: key,\n\t\t\t\t\t\tmessage:\n\t\t\t\t\t\t\t'Invalid validator: expected a Standard Schema 1.0 validator (must have \"~standard\" property). ArkType validators are not supported in \"standard\" mode. Use validator: \"arktype\" for ArkType schemas.',\n\t\t\t\t\t},\n\t\t\t\t]);\n\t\t\t}\n\t\t}\n\n\t\treturn parseStandard(\n\t\t\tdef as Record<string, unknown>,\n\t\t\tconfig,\n\t\t) as unknown as distill.Out<at.infer<T, $>>;\n\t}\n\n\tconst validator = loadArkTypeValidator();\n\tconst { parse } = validator;\n\n\treturn parse(def as any, config) as any;\n}\n","import { createEnv } from \"./create-env.ts\";\n\nexport { createEnv };\nexport type { EnvSchema } from \"./create-env.ts\";\nexport { ArkEnvError } from \"./errors.ts\";\n\n/**\n * `arkenv`'s main export, an alias for {@link createEnv}\n *\n * {@link https://arkenv.js.org | ArkEnv} is a typesafe environment variables validator from editor to runtime.\n */\nconst arkenv = createEnv;\nexport default arkenv;\n"],"mappings":"qFAQA,SAAgB,EACf,EACA,EACC,CACD,GAAM,CAAE,MAAM,QAAQ,IAAK,kBAAkB,UAAa,EACpDA,EAAkC,EAAE,CACpCC,EAAoC,EAAE,CACtC,EAAU,IAAI,IAAI,OAAO,KAAK,EAAI,CAAC,CAGzC,IAAK,IAAM,KAAO,EAAK,CACtB,IAAM,EAAY,EAAI,GAChB,EAAQ,EAAI,GAGlB,GACC,CAAC,GACD,OAAO,GAAc,UACrB,EAAE,cAAe,GAEjB,MAAU,MACT,2BAA2B,EAAI,qFAC/B,CAGF,IAAM,EAAU,EAA+B,aAAa,SAAS,EAAM,CAE3E,GAAI,aAAkB,QACrB,MAAU,MACT,8CAA8C,EAAI,2BAClD,CAGF,GAAI,EAAO,OACV,IAAK,IAAM,KAAS,EAAO,OAC1B,EAAO,KAAK,CACX,KAAM,EACN,QAAS,EAAM,QACf,CAAC,MAGH,EAAO,GAAO,EAAO,MAGtB,EAAQ,OAAO,EAAI,CAIpB,GAAI,IAAoB,aAClB,IAAM,KAAO,EACb,IAAoB,SACvB,EAAO,KAAK,CACX,KAAM,EACN,QAAS,iBACT,CAAC,CACQ,IAAoB,WAC9B,EAAO,GAAO,EAAI,IAKrB,GAAI,EAAO,OAAS,EACnB,MAAM,IAAI,EAAY,EAAO,CAG9B,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