arkenv 0.12.1 → 0.12.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 CHANGED
@@ -3,7 +3,7 @@
3
3
  <h1 align="center">ArkEnv</h1>
4
4
  <div align="center">
5
5
  <p align="center">
6
- Environment variable validation from editor to runtime<br/> for <a href="https://nextjs.org/">Next.js</a>, <a href="https://nodejs.org/">Node.js</a>, <a href="https://vite.dev/">Vite</a>, and <a href="https://bun.com/">Bun</a>
6
+ Environment variable validation from editor to runtime<br/> for <a href="https://nextjs.org/">Next.js</a>, <a href="https://nuxt.com/">Nuxt</a>, <a href="https://nodejs.org/">Node.js</a>, <a href="https://vite.dev/">Vite</a>, and <a href="https://bun.com/">Bun</a>
7
7
  </p>
8
8
  <a href="https://github.com/yamcodes/arkenv/actions/workflows/test.yml?query=branch%3Amain"><img alt="Test Status" src="https://github.com/yamcodes/arkenv/actions/workflows/tests-badge.yml/badge.svg?branch=main"></a>
9
9
  <a href="https://bundlephobia.com/package/arkenv"><img alt="npm bundle size" src="https://img.shields.io/bundlephobia/minzip/arkenv"></a>
@@ -179,7 +179,7 @@ declare namespace StandardSchemaV1 {
179
179
  *
180
180
  * @template T - The schema definition to infer from
181
181
  */
182
- type InferType<T> = T extends StandardSchemaV1<infer _Input, infer Output> ? Output : T extends ((value: Record<string, string | undefined>) => infer R) ? R extends type.errors ? never : R : T extends {
182
+ type InferType<T> = T extends StandardSchemaV1<infer _Input, infer Output> ? Output : T extends ((value: Dict<string>) => infer R) ? R extends type.errors ? never : R : T extends {
183
183
  t: infer U;
184
184
  } ? U : T extends type.Any<infer U, infer _Scope> ? U : never;
185
185
  //#endregion
@@ -207,4 +207,4 @@ if (module.exports && module.exports.default) {
207
207
  module.exports = module.exports.default;
208
208
  }
209
209
 
210
- //# sourceMappingURL=index-CzNfOanV.d.cts.map
210
+ //# sourceMappingURL=index-BspEVkBJ.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index-BspEVkBJ.d.cts","names":["_$arktype","_$arktype_internal_keywords_string_ts0","_$arktype_internal_attributes_ts0","$","trim","To","Submodule","normalize","capitalize","stringDate","stringInteger","ip","stringJson","lower","stringNumeric","url","uuid","Scope","string","In","root","alpha","alphanumeric","hex","base64","creditCard","date","digits","email","integer","json","numeric","regex","semver","upper","preformatted","host","number","NaN","Infinity","epoch","safe","NegativeInfinity","port","Dict","T","Record","StandardTypedV1","Input","Output","Props","Schema","Types","NonNullable","version","vendor","types","input","output","InferInput","InferOutput","StandardSchemaV1","Options","Result","Promise","SuccessResult","FailureResult","Record","Issue","ReadonlyArray","PropertyKey","PathSegment","validate","value","options","issues","libraryOptions","message","path","key","StandardJSONSchemaV1","Converter","Target","jsonSchema","target","type","Dict","StandardSchemaV1","InferType","T","errors","Any","_Input","Output","value","R","t","U","_Scope","$","Type","SchemaShape","Record","CompiledEnvSchema"],"sources":["../../internal/scope/dist/index.d.ts","../../internal/types/dist/helpers.d.ts","../../internal/types/dist/standard-schema.d.ts","../../internal/types/dist/infer-type.d.ts","../../internal/types/dist/schema.d.ts"],"mappings":";;;;;;;;AAEoF;;;;cAQtEG,CAAAA,EAAGH,SAAAA,CAAUiB,KAAAA;EACzBC,MAAAA,EAAQlB,SAAAA,CAAUM,SAAAA;IAChBF,IAAAA,EAAMJ,SAAAA,CAAUM,SAAAA,CAAUL,sCAAAA,CAAuCG,IAAAA,CAAKD,CAAAA;MACpE,cAAA,GAAiBgB,EAAAA,aAAejB,iCAAAA,CAAkCG,EAAAA;IAAAA;IAEpEE,SAAAA,EAAWP,SAAAA,CAAUM,SAAAA,CAAUL,sCAAAA,CAAuCM,SAAAA,CAAUJ,CAAAA;MAC9E,cAAA,GAAiBgB,EAAAA,aAAejB,iCAAAA,CAAkCG,EAAAA;IAAAA;IAEpEe,IAAAA;IACAC,KAAAA;IACAC,YAAAA;IACAC,GAAAA;IACAC,MAAAA,EAAQxB,SAAAA,CAAUM,SAAAA;MAChBc,IAAA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A,gBAA2Bb,eAAAA,IAAmBA,eAAAA,CAAgBa,WAAAA,CAAYT,MAAAA;AAAAA;;;;;;AF9EC;;;;;;KGUxEqC,SAAAA,MAAeC,CAAAA,SAAUF,gBAAAA,+BAA+CM,MAAAA,GAASJ,CAAAA,WAAWK,KAAAA,EAAOR,IAAAA,wBAA2BS,CAAAA,SAAUV,IAAAA,CAAKK,MAAAA,WAAiBK,CAAAA,GAAIN,CAAAA;EAC1KO,CAAAA;AAAAA,IACAC,CAAAA,GAAIR,CAAAA,SAAUJ,IAAAA,CAAKM,GAAAA,0BAA6BM,CAAAA;;;KCZxCI,WAAAA,GAAcC,MAAAA;;;;AJA0D;;;;;;;;;KIaxEC,iBAAAA,GAAoBH,IAAAA,CAAKC,WAAAA,EAAaF,CAAAA"}
@@ -179,7 +179,7 @@ declare namespace StandardSchemaV1 {
179
179
  *
180
180
  * @template T - The schema definition to infer from
181
181
  */
182
- type InferType<T> = T extends StandardSchemaV1<infer _Input, infer Output> ? Output : T extends ((value: Record<string, string | undefined>) => infer R) ? R extends type.errors ? never : R : T extends {
182
+ type InferType<T> = T extends StandardSchemaV1<infer _Input, infer Output> ? Output : T extends ((value: Dict<string>) => infer R) ? R extends type.errors ? never : R : T extends {
183
183
  t: infer U;
184
184
  } ? U : T extends type.Any<infer U, infer _Scope> ? U : never;
185
185
  //#endregion
@@ -201,4 +201,4 @@ type CompiledEnvSchema = Type<SchemaShape, $>;
201
201
  //#endregion
202
202
  export { Dict as a, StandardSchemaV1 as i, SchemaShape as n, $ as o, InferType as r, CompiledEnvSchema as t };
203
203
 
204
- //# sourceMappingURL=index-Br22fqkz.d.mts.map
204
+ //# sourceMappingURL=index-BuKcfSYK.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index-BuKcfSYK.d.mts","names":["_$arktype","_$arktype_internal_keywords_string_ts0","_$arktype_internal_attributes_ts0","$","trim","To","Submodule","normalize","capitalize","stringDate","stringInteger","ip","stringJson","lower","stringNumeric","url","uuid","Scope","string","In","root","alpha","alphanumeric","hex","base64","creditCard","date","digits","email","integer","json","numeric","regex","semver","upper","preformatted","host","number","NaN","Infinity","epoch","safe","NegativeInfinity","port","Dict","T","Record","StandardTypedV1","Input","Output","Props","Schema","Types","NonNullable","version","vendor","types","input","output","InferInput","InferOutput","StandardSchemaV1","Options","Result","Promise","SuccessResult","FailureResult","Record","Issue","ReadonlyArray","PropertyKey","PathSegment","validate","value","options","issues","libraryOptions","message","path","key","StandardJSONSchemaV1","Converter","Target","jsonSchema","target","type","Dict","StandardSchemaV1","InferType","T","errors","Any","_Input","Output","value","R","t","U","_Scope","$","Type","SchemaShape","Record","CompiledEnvSchema"],"sources":["../../internal/scope/dist/index.d.ts","../../internal/types/dist/helpers.d.ts","../../internal/types/dist/standard-schema.d.ts","../../internal/types/dist/infer-type.d.ts","../../internal/types/dist/schema.d.ts"],"mappings":";;;;;;;;AAEoF;;;;cAQtEG,CAAAA,EAAGH,SAAAA,CAAUiB,KAAAA;EACzBC,MAAAA,EAAQlB,SAAAA,CAAUM,SAAAA;IAChBF,IAAAA,EAAMJ,SAAAA,CAAUM,SAAAA,CAAUL,sCAAAA,CAAuCG,IAAAA,CAAKD,CAAAA;MACpE,cAAA,GAAiBgB,EAAAA,aAAejB,iCAAAA,CAAkCG,EAAAA;IAAAA;IAEpEE,SAAAA,EAAWP,SAAAA,CAAUM,SAAAA,CAAUL,sCAAAA,CAAuCM,SAAAA,CAAUJ,CAAAA;MAC9E,cAAA,GAAiBgB,EAAAA,aAAejB,iCAAAA,CAAkCG,EAAAA;IAAAA;IAEpEe,IAAAA;IACAC,KAAAA;IACAC,YAAAA;IACAC,GAAAA;IACAC,MAAAA,EAAQxB,SAAAA,CAAUM,SAAAA;MAChBc,IAAAA;MACAL,GAAAA;IAAAA;MAEA,cAAA;IAAA;IAEFP,UAAAA,EAAYR,SAAAA,CAAUM,SAAAA,CAAUL,sCAAAA,CAAuCO,UAAAA,CAAWL,CAAAA;MAChF,cAAA,GAAiB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,MAAAA,GAASJ,CAAAA,WAAWK,KAAAA,EAAOR,IAAAA,wBAA2BS,CAAAA,SAAUV,IAAAA,CAAKK,MAAAA,WAAiBK,CAAAA,GAAIN,CAAAA;EAC1KO,CAAAA;AAAAA,IACAC,CAAAA,GAAIR,CAAAA,SAAUJ,IAAAA,CAAKM,GAAAA,0BAA6BM,CAAAA;;;KCZxCI,WAAAA,GAAcC,MAAAA;;;;AJA0D;;;;;;;;;KIaxEC,iBAAAA,GAAoBH,IAAAA,CAAKC,WAAAA,EAAaF,CAAAA"}
package/dist/index.cjs CHANGED
@@ -1,4 +1,4 @@
1
- Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});const e=require(`./shared-BW9_Fgr8.cjs`),t=require(`./core-BftJnV8f.cjs`);let n=require(`arktype`);const r=(0,n.type)(`0 <= number.integer <= 65535`),i=(0,n.type)(`string.ip | 'localhost'`),a=(0,n.scope)({string:n.type.module({...n.type.keywords.string,host:i}),number:n.type.module({...n.type.keywords.number,port:r})});function o(t,n,r){let i=e.n(n.in.toJsonSchema({fallback:e=>e.base}));return i.length===0?n:t(`unknown`).pipe(t=>e.t(t,i,r)).pipe(n)}function s(e){return Object.entries(e.byPath).map(([e,n])=>{let r=n.message,i=r.trimStart();if(i.length>0&&`:.-`.includes(i[0])&&(i=i.slice(1).trimStart()),i.toLowerCase().startsWith(e.toLowerCase())){let t=i.slice(e.length).trimStart();t.length>0&&`:.-`.includes(t[0])&&(t=t.slice(1)),r=t.trimStart()}let a=r.match(/\(was (.*)\)/);if(a?.[1]){let e=a[1];e.includes(`\x1B[`)||(r=r.replace(`(was ${e})`,`(was ${t.r(`cyan`,e)})`))}return{path:e,message:r}})}function c(r,i){let{env:c=process.env,coerce:l=!0,onUndeclaredKey:u=`delete`,arrayFormat:d=`comma`,emptyAsUndefined:f=!1}=i,p=(typeof r==`function`&&`assert`in r?r:a.type.raw(r)).onUndeclaredKey(u),m=p;l&&(m=o(a.type,p,{arrayFormat:d}));let h=f?e.r(c):c,g=m(h);if(g instanceof n.ArkErrors)throw new t.t(s(g));return g}function l(e,t={}){return c(e,t)}const u=a.type,d=l;exports.createEnv=l,exports.default=d,exports.type=u;
1
+ Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});const e=require(`./shared-ClquMPfF.cjs`),t=require(`./core-BftJnV8f.cjs`);let n=require(`arktype`);const r=(0,n.type)(`0 <= number.integer <= 65535`),i=(0,n.type)(`string.ip | 'localhost'`),a=(0,n.scope)({string:n.type.module({...n.type.keywords.string,host:i}),number:n.type.module({...n.type.keywords.number,port:r})});function o(t,n,r){let i=e.n(n.in.toJsonSchema({fallback:e=>e.base}));return i.length===0?n:t(`unknown`).pipe(t=>e.t(t,i,r)).pipe(n)}function s(e){return Object.entries(e.byPath).map(([e,n])=>{let r=n.message,i=r.trimStart();if(i.length>0&&`:.-`.includes(i[0])&&(i=i.slice(1).trimStart()),i.toLowerCase().startsWith(e.toLowerCase())){let t=i.slice(e.length).trimStart();t.length>0&&`:.-`.includes(t[0])&&(t=t.slice(1)),r=t.trimStart()}let a=r.match(/\(was (.*)\)/);if(a?.[1]){let e=a[1];e.includes(`\x1B[`)||(r=r.replace(`(was ${e})`,`(was ${t.r(`cyan`,e)})`))}return{path:e,message:r}})}function c(r,i){let{env:c=process.env,coerce:l=!0,onUndeclaredKey:u=`delete`,arrayFormat:d=`comma`,emptyAsUndefined:f=!1}=i,p=(typeof r==`function`&&`assert`in r?r:a.type.raw(r)).onUndeclaredKey(u),m=p;l&&(m=o(a.type,p,{arrayFormat:d}));let h=f?e.r(c):c,g=m(h);if(g instanceof n.ArkErrors)throw new t.t(s(g));return g}function l(e,t={}){return c(e,t)}function u(e){if(!e||typeof e!=`object`&&typeof e!=`function`)return[];if(e.json&&typeof e.json==`object`&&e.json.domain===`object`){let t=[];if(Array.isArray(e.json.required))for(let n of e.json.required)n&&typeof n==`object`&&`key`in n&&t.push(n.key);if(Array.isArray(e.json.optional))for(let n of e.json.optional)n&&typeof n==`object`&&`key`in n&&t.push(n.key);return t}let t=e[`~standard`],n=typeof t?.jsonSchema?.input==`function`&&t.jsonSchema.input||typeof e.jsonSchema?.input==`function`&&e.jsonSchema.input;if(n)try{let e=n({target:`draft-07`});if(e&&typeof e==`object`&&e.properties)return Object.keys(e.properties)}catch{}if(typeof e.toJSONSchema==`function`)try{let t=e.toJSONSchema();if(t&&typeof t==`object`&&t.properties)return Object.keys(t.properties)}catch{}if(typeof e.toStandardJSONSchema?.v1==`function`)try{let t=e.toStandardJSONSchema.v1();if(t&&typeof t==`object`&&t.properties)return Object.keys(t.properties)}catch{}return Object.keys(e)}const d=a.type,f=l;exports.createEnv=l,exports.default=f,exports.getSchemaKeys=u,exports.type=d;
2
2
 
3
3
  // CJS Interop Shim
4
4
  if (module.exports && module.exports.default) {
package/dist/index.d.cts CHANGED
@@ -1,4 +1,4 @@
1
- import { a as Dict, n as SchemaShape, o as $, r as InferType, t as CompiledEnvSchema } from "./index-CzNfOanV.cjs";
1
+ import { a as Dict, n as SchemaShape, o as $, r as InferType, t as CompiledEnvSchema } from "./index-BspEVkBJ.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 _$arktype from "arktype";
@@ -28,6 +28,12 @@ type EnvSchema<def> = type$1.validate<def, $>;
28
28
  * @template T - The schema type
29
29
  */
30
30
  type Infer<T> = T extends SchemaShape ? distill.Out<type$1.infer<T, $>> : InferType<T>;
31
+ /**
32
+ * The environment variables passed to `createEnv`.
33
+ * Uses `Dict<string>` to enforce
34
+ * compile-time safety: all input environment variables must be strings
35
+ * (or undefined), matching `process.env` semantics.
36
+ */
31
37
  type RuntimeEnvironment = Dict<string>;
32
38
  /**
33
39
  * Configuration options for `createEnv`
@@ -92,6 +98,17 @@ declare function createEnv<const T extends SchemaShape>(def: EnvSchema<T>, confi
92
98
  declare function createEnv<T extends CompiledEnvSchema>(def: T, config?: ArkEnvConfig): InferType<T>;
93
99
  declare function createEnv<const T extends SchemaShape>(def: EnvSchema<T> | CompiledEnvSchema, config?: ArkEnvConfig): distill.Out<type$1.infer<T, $>> | InferType<typeof def>;
94
100
  //#endregion
101
+ //#region src/schema.d.ts
102
+ /**
103
+ * Extract the keys from a schema definition dynamically.
104
+ * Supports plain objects, ArkType schemas, and Standard Schema validators.
105
+ *
106
+ * @param schema The schema definition to extract keys from
107
+ * @returns An array of extracted key names
108
+ * @internal
109
+ */
110
+ declare function getSchemaKeys(schema: any): string[];
111
+ //#endregion
95
112
  //#region src/index.d.ts
96
113
  /**
97
114
  * Like ArkType's `type`, but with ArkEnv's extra keywords, such as:
@@ -180,7 +197,7 @@ declare const type: _$arktype_internal_type_ts0.TypeParser<{
180
197
  */
181
198
  declare const arkenv: typeof createEnv;
182
199
  //#endregion
183
- export { type ArkEnvConfig, type EnvSchema, type Infer, createEnv, arkenv as default, type };
200
+ export { type ArkEnvConfig, type EnvSchema, type Infer, createEnv, arkenv as default, getSchemaKeys, type };
184
201
 
185
202
  // CJS Interop Shim
186
203
  if (module.exports && module.exports.default) {
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.cts","names":[],"sources":["../src/create-env.ts","../src/index.ts"],"mappings":";;;;;;;;;;;;;AAyBA;;;;;;;;;KAAY,SAAA,QAAiB,MAAA,CAAG,QAAA,CAAS,GAAA,EAAK,CAAA;;;;;;AAQ9C;KAAY,KAAA,MAAW,CAAA,SAAU,WAAA,GAC9B,OAAA,CAAQ,GAAA,CAAI,MAAA,CAAG,KAAA,CAAM,CAAA,EAAG,CAAA,KACxB,SAAA,CAAU,CAAA;AAAA,KAER,kBAAA,GAAqB,IAAA;;;;KAKd,YAAA;EARG;;;EAYd,GAAA,GAAM,kBAAA;EAXK;;;EAeX,MAAA;EAjBgC;;;;;;;;;;;AAEjB;;;EA8Bf,eAAA;EA5B6B;AAK9B;;;;;;;EAiCC,WAAA;E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xB,gBAAA;AAAA;;;;;;;;;;;;;iBAgBe,SAAA,iBAA0B,WAAA,CAAA,CACzC,GAAA,EAAK,SAAA,CAAU,CAAA,GACf,MAAA,GAAS,YAAA,GACP,OAAA,CAAQ,GAAA,CAAI,MAAA,CAAG,KAAA,CAAM,CAAA,EAAG,CAAA;AAAA,iBACX,SAAA,WAAoB,iBAAA,CAAA,CACnC,GAAA,EAAK,CAAA,EACL,MAAA,GAAS,YAAA,GACP,SAAA,CAAU,CAAA;AAAA,iBACG,SAAA,iBAA0B,WAAA,CAAA,CACzC,GAAA,EAAK,SAAA,CAAU,CAAA,IAAK,iBAAA,EACpB,MAAA,GAAS,YAAA,GACP,OAAA,CAAQ,GAAA,CAAI,MAAA,CAAG,KAAA,CAAM,CAAA,EAAG,CAAA,KAAM,SAAA,QAAiB,GAAA;;;;;;;;;;;iBC7GlC,aAAA,CAAc,MAAA;;;;;;;;ADe9B;;;;cEVa,IAAA,8BAAI,UAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAQX,MAAA,SAAM,SAAA"}
package/dist/index.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { a as Dict, n as SchemaShape, o as $, r as InferType, t as CompiledEnvSchema } from "./index-Br22fqkz.mjs";
1
+ import { a as Dict, n as SchemaShape, o as $, r as InferType, t as CompiledEnvSchema } from "./index-BuKcfSYK.mjs";
2
2
  import * as _$arktype from "arktype";
3
3
  import { distill, type as type$1 } from "arktype";
4
4
  import * as _$arktype_internal_keywords_string_ts0 from "arktype/internal/keywords/string.ts";
@@ -28,6 +28,12 @@ type EnvSchema<def> = type$1.validate<def, $>;
28
28
  * @template T - The schema type
29
29
  */
30
30
  type Infer<T> = T extends SchemaShape ? distill.Out<type$1.infer<T, $>> : InferType<T>;
31
+ /**
32
+ * The environment variables passed to `createEnv`.
33
+ * Uses `Dict<string>` to enforce
34
+ * compile-time safety: all input environment variables must be strings
35
+ * (or undefined), matching `process.env` semantics.
36
+ */
31
37
  type RuntimeEnvironment = Dict<string>;
32
38
  /**
33
39
  * Configuration options for `createEnv`
@@ -92,6 +98,17 @@ declare function createEnv<const T extends SchemaShape>(def: EnvSchema<T>, confi
92
98
  declare function createEnv<T extends CompiledEnvSchema>(def: T, config?: ArkEnvConfig): InferType<T>;
93
99
  declare function createEnv<const T extends SchemaShape>(def: EnvSchema<T> | CompiledEnvSchema, config?: ArkEnvConfig): distill.Out<type$1.infer<T, $>> | InferType<typeof def>;
94
100
  //#endregion
101
+ //#region src/schema.d.ts
102
+ /**
103
+ * Extract the keys from a schema definition dynamically.
104
+ * Supports plain objects, ArkType schemas, and Standard Schema validators.
105
+ *
106
+ * @param schema The schema definition to extract keys from
107
+ * @returns An array of extracted key names
108
+ * @internal
109
+ */
110
+ declare function getSchemaKeys(schema: any): string[];
111
+ //#endregion
95
112
  //#region src/index.d.ts
96
113
  /**
97
114
  * Like ArkType's `type`, but with ArkEnv's extra keywords, such as:
@@ -180,6 +197,6 @@ declare const type: _$arktype_internal_type_ts0.TypeParser<{
180
197
  */
181
198
  declare const arkenv: typeof createEnv;
182
199
  //#endregion
183
- export { type ArkEnvConfig, type EnvSchema, type Infer, createEnv, arkenv as default, type };
200
+ export { type ArkEnvConfig, type EnvSchema, type Infer, createEnv, arkenv as default, getSchemaKeys, type };
184
201
 
185
202
  //# sourceMappingURL=index.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.mts","names":[],"sources":["../src/create-env.ts","../src/index.ts"],"mappings":";;;;;;;;;;;;;AAyBA;;;;;;;;;KAAY,SAAA,QAAiB,MAAA,CAAG,QAAA,CAAS,GAAA,EAAK,CAAA;;;;;;AAQ9C;KAAY,KAAA,MAAW,CAAA,SAAU,WAAA,GAC9B,OAAA,CAAQ,GAAA,CAAI,MAAA,CAAG,KAAA,CAAM,CAAA,EAAG,CAAA,KACxB,SAAA,CAAU,CAAA;AAAA,KAER,kBAAA,GAAqB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;;;EAmBjB,GAAA,GAAM,kBAAA;EAlBI;;;EAsBV,MAAA;EAtB0B;;;;;AACX;;;;;AAahB;;;;EAuBC,eAAA;EAnBM;;;;;;;AAwDP;EA3BC,WAAA;EA2BwB;;;;;;;;;EAhBxB,gBAAA;AAAA;;;;;;;;;;;;;iBAgBe,SAAA,iBAA0B,WAAA,CAAA,CACzC,GAAA,EAAK,SAAA,CAAU,CAAA,GACf,MAAA,GAAS,YAAA,GACP,OAAA,CAAQ,GAAA,CAAI,MAAA,CAAG,KAAA,CAAM,CAAA,EAAG,CAAA;AAAA,iBACX,SAAA,WAAoB,iBAAA,CAAA,CACnC,GAAA,EAAK,CAAA,EACL,MAAA,GAAS,YAAA,GACP,SAAA,CAAU,CAAA;AAAA,iBACG,SAAA,iBAA0B,WAAA,CAAA,CACzC,GAAA,EAAK,SAAA,CAAU,CAAA,IAAK,iBAAA,EACpB,MAAA,GAAS,YAAA,GACP,OAAA,CAAQ,GAAA,CAAI,MAAA,CAAG,KAAA,CAAM,CAAA,EAAG,CAAA,KAAM,SAAA,QAAiB,GAAA;;;;;;;;;;;iBC7GlC,aAAA,CAAc,MAAA;;;;;;;;ADe9B;;;;cEVa,IAAA,8BAAI,UAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAQX,MAAA,SAAM,SAAA"}
package/dist/index.mjs CHANGED
@@ -1,3 +1,3 @@
1
- import{n as e,r as t,t as n}from"./shared-CTq6rhd_.mjs";import{r,t as i}from"./core-B0IkKRzg.mjs";import{ArkErrors as a,scope as o,type as s}from"arktype";const c=s(`0 <= number.integer <= 65535`),l=s(`string.ip | 'localhost'`),u=o({string:s.module({...s.keywords.string,host:l}),number:s.module({...s.keywords.number,port:c})});function d(t,r,i){let a=e(r.in.toJsonSchema({fallback:e=>e.base}));return a.length===0?r:t(`unknown`).pipe(e=>n(e,a,i)).pipe(r)}function f(e){return Object.entries(e.byPath).map(([e,t])=>{let n=t.message,i=n.trimStart();if(i.length>0&&`:.-`.includes(i[0])&&(i=i.slice(1).trimStart()),i.toLowerCase().startsWith(e.toLowerCase())){let t=i.slice(e.length).trimStart();t.length>0&&`:.-`.includes(t[0])&&(t=t.slice(1)),n=t.trimStart()}let a=n.match(/\(was (.*)\)/);if(a?.[1]){let e=a[1];e.includes(`\x1B[`)||(n=n.replace(`(was ${e})`,`(was ${r(`cyan`,e)})`))}return{path:e,message:n}})}function p(e,n){let{env:r=process.env,coerce:o=!0,onUndeclaredKey:s=`delete`,arrayFormat:c=`comma`,emptyAsUndefined:l=!1}=n,p=(typeof e==`function`&&`assert`in e?e:u.type.raw(e)).onUndeclaredKey(s),m=p;o&&(m=d(u.type,p,{arrayFormat:c}));let h=l?t(r):r,g=m(h);if(g instanceof a)throw new i(f(g));return g}function m(e,t={}){return p(e,t)}const h=u.type,g=m;export{m as createEnv,g as default,h as type};
1
+ import{n as e,r as t,t as n}from"./shared-BzftEfkT.mjs";import{r,t as i}from"./core-B0IkKRzg.mjs";import{ArkErrors as a,scope as o,type as s}from"arktype";const c=s(`0 <= number.integer <= 65535`),l=s(`string.ip | 'localhost'`),u=o({string:s.module({...s.keywords.string,host:l}),number:s.module({...s.keywords.number,port:c})});function d(t,r,i){let a=e(r.in.toJsonSchema({fallback:e=>e.base}));return a.length===0?r:t(`unknown`).pipe(e=>n(e,a,i)).pipe(r)}function f(e){return Object.entries(e.byPath).map(([e,t])=>{let n=t.message,i=n.trimStart();if(i.length>0&&`:.-`.includes(i[0])&&(i=i.slice(1).trimStart()),i.toLowerCase().startsWith(e.toLowerCase())){let t=i.slice(e.length).trimStart();t.length>0&&`:.-`.includes(t[0])&&(t=t.slice(1)),n=t.trimStart()}let a=n.match(/\(was (.*)\)/);if(a?.[1]){let e=a[1];e.includes(`\x1B[`)||(n=n.replace(`(was ${e})`,`(was ${r(`cyan`,e)})`))}return{path:e,message:n}})}function p(e,n){let{env:r=process.env,coerce:o=!0,onUndeclaredKey:s=`delete`,arrayFormat:c=`comma`,emptyAsUndefined:l=!1}=n,p=(typeof e==`function`&&`assert`in e?e:u.type.raw(e)).onUndeclaredKey(s),m=p;o&&(m=d(u.type,p,{arrayFormat:c}));let h=l?t(r):r,g=m(h);if(g instanceof a)throw new i(f(g));return g}function m(e,t={}){return p(e,t)}function h(e){if(!e||typeof e!=`object`&&typeof e!=`function`)return[];if(e.json&&typeof e.json==`object`&&e.json.domain===`object`){let t=[];if(Array.isArray(e.json.required))for(let n of e.json.required)n&&typeof n==`object`&&`key`in n&&t.push(n.key);if(Array.isArray(e.json.optional))for(let n of e.json.optional)n&&typeof n==`object`&&`key`in n&&t.push(n.key);return t}let t=e[`~standard`],n=typeof t?.jsonSchema?.input==`function`&&t.jsonSchema.input||typeof e.jsonSchema?.input==`function`&&e.jsonSchema.input;if(n)try{let e=n({target:`draft-07`});if(e&&typeof e==`object`&&e.properties)return Object.keys(e.properties)}catch{}if(typeof e.toJSONSchema==`function`)try{let t=e.toJSONSchema();if(t&&typeof t==`object`&&t.properties)return Object.keys(t.properties)}catch{}if(typeof e.toStandardJSONSchema?.v1==`function`)try{let t=e.toStandardJSONSchema.v1();if(t&&typeof t==`object`&&t.properties)return Object.keys(t.properties)}catch{}return Object.keys(e)}const g=u.type,_=m;export{m as createEnv,_ as default,h as getSchemaKeys,g as type};
2
2
 
3
3
  //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","names":["t","e","$","$"],"sources":["../../internal/scope/dist/index.js","../src/arktype/coercion/coerce.ts","../src/arktype/index.ts","../src/create-env.ts","../src/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","import type { BaseType } from \"arktype\";\nimport {\n\tapplyCoercion,\n\ttype CoerceOptions,\n\tfindCoercionPaths,\n} from \"@/coercion/shared\";\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 { stripEmptyStrings } from \"@/coercion/shared\";\nimport { ArkEnvError, type ValidationIssue } from \"@/core\";\nimport type { ArkEnvConfig, EnvSchema } from \"@/create-env\";\nimport { styleText } from \"@/utils/style-text\";\nimport { coerce } from \"./coercion/coerce\";\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 * Converts ArkType's `ArkErrors` (keyed by path) into a flat `ValidationIssue[]`\n * suitable for `ArkEnvError`. Strips leading path references from messages to\n * avoid duplication when `formatInternalErrors` prepends the styled path, and\n * applies cyan styling to inline \"(was …)\" values.\n *\n * @internal\n */\nfunction arkErrorsToIssues(errors: ArkErrors): ValidationIssue[] {\n\treturn Object.entries(errors.byPath).map(([path, error]) => {\n\t\tlet message = error.message;\n\n\t\t// Strip leading path reference if ArkType included it in the message\n\t\tlet trimmed = message.trimStart();\n\t\tif (trimmed.length > 0 && \":.-\".includes(trimmed[0])) {\n\t\t\ttrimmed = trimmed.slice(1).trimStart();\n\t\t}\n\t\tif (trimmed.toLowerCase().startsWith(path.toLowerCase())) {\n\t\t\tlet rest = trimmed.slice(path.length).trimStart();\n\t\t\tif (rest.length > 0 && \":.-\".includes(rest[0])) {\n\t\t\t\trest = rest.slice(1);\n\t\t\t}\n\t\t\tmessage = rest.trimStart();\n\t\t}\n\n\t\t// Style (was ...) inline values\n\t\tconst valueMatch = message.match(/\\(was (.*)\\)/);\n\t\tif (valueMatch?.[1]) {\n\t\t\tconst value = valueMatch[1];\n\t\t\tif (!value.includes(\"\\x1b[\")) {\n\t\t\t\tmessage = message.replace(\n\t\t\t\t\t`(was ${value})`,\n\t\t\t\t\t`(was ${styleText(\"cyan\", value)})`,\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\n\t\treturn { path, message };\n\t});\n}\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\temptyAsUndefined = false,\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// Optionally treat empty strings as undefined\n\tconst processedEnv = emptyAsUndefined\n\t\t? stripEmptyStrings(env as Record<string, string | undefined>)\n\t\t: env;\n\n\t// Validate the environment variables\n\tconst validatedEnv = finalSchema(processedEnv);\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(arkErrorsToIssues(validatedEnv));\n\t}\n\n\treturn validatedEnv;\n}\n","import type { $ } from \"@repo/scope\";\nimport type {\n\tCompiledEnvSchema,\n\tDict,\n\tInferType,\n\tSchemaShape,\n} from \"@repo/types\";\nimport type { type as at, distill } from \"arktype\";\nimport { parse } from \"./arktype\";\nimport type { ArkEnvError } from \"./core\";\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, $>;\n\n/**\n * Infer the validated and coerced environment object type from a schema.\n * Supports declarative schema shapes, compiled ArkType schemas, and Standard Schema validators.\n *\n * @template T - The schema type\n */\nexport type Infer<T> = T extends SchemaShape\n\t? distill.Out<at.infer<T, $>>\n\t: InferType<T>;\n\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\n\t/**\n\t * Whether to treat empty strings (`\"\"`) as `undefined` before validation.\n\t *\n\t * When enabled, an environment variable set to an empty value (e.g. `PORT=`)\n\t * will be treated as if it were missing, allowing defaults to apply and\n\t * preventing validation errors for numeric or boolean types.\n\t *\n\t * @default false\n\t */\n\temptyAsUndefined?: boolean;\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 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>;\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\t// biome-ignore lint/suspicious/noExplicitAny: parse handles both EnvSchema<T> and CompiledEnvSchema at runtime\n\treturn parse(def as any, config);\n}\n","import { $ } from \"@repo/scope\";\nimport { createEnv } from \"./create-env\";\n\nexport { createEnv };\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;\nexport type { ArkEnvConfig, EnvSchema, Infer } from \"./create-env\";\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":"2JAA0C,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,CCYvN,SAAgB,EACf,EACA,EACA,EACiB,CAQjB,IAAM,EAAU,EAHH,EAAO,GAAG,aAAa,CACnC,SAAW,GAAS,EAAY,KAChC,CACqC,CAAQ,CAY9C,OAVI,EAAQ,SAAW,EACf,EASD,E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EACf,EACA,EAAuB,EAAE,CAC6B,CAEtD,OAAO,EAAM,EAAY,EAAO,CC1GjC,MAAa,EAAOC,EAAE,KAQhB,EAAS"}
1
+ {"version":3,"file":"index.mjs","names":["t","e","$","$"],"sources":["../../internal/scope/dist/index.js","../src/arktype/coercion/coerce.ts","../src/arktype/index.ts","../src/create-env.ts","../src/schema.ts","../src/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","import type { BaseType } from \"arktype\";\nimport {\n\tapplyCoercion,\n\ttype CoerceOptions,\n\tfindCoercionPaths,\n} from \"@/coercion/shared\";\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 { stripEmptyStrings } from \"@/coercion/shared\";\nimport { ArkEnvError, type ValidationIssue } from \"@/core\";\nimport type { ArkEnvConfig, EnvSchema } from \"@/create-env\";\nimport { styleText } from \"@/utils/style-text\";\nimport { coerce } from \"./coercion/coerce\";\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 * Converts ArkType's `ArkErrors` (keyed by path) into a flat `ValidationIssue[]`\n * suitable for `ArkEnvError`. Strips leading path references from messages to\n * avoid duplication when `formatInternalErrors` prepends the styled path, and\n * applies cyan styling to inline \"(was …)\" values.\n *\n * @internal\n */\nfunction arkErrorsToIssues(errors: ArkErrors): ValidationIssue[] {\n\treturn Object.entries(errors.byPath).map(([path, error]) => {\n\t\tlet message = error.message;\n\n\t\t// Strip leading path reference if ArkType included it in the message\n\t\tlet trimmed = message.trimStart();\n\t\tif (trimmed.length > 0 && \":.-\".includes(trimmed[0])) {\n\t\t\ttrimmed = trimmed.slice(1).trimStart();\n\t\t}\n\t\tif (trimmed.toLowerCase().startsWith(path.toLowerCase())) {\n\t\t\tlet rest = trimmed.slice(path.length).trimStart();\n\t\t\tif (rest.length > 0 && \":.-\".includes(rest[0])) {\n\t\t\t\trest = rest.slice(1);\n\t\t\t}\n\t\t\tmessage = rest.trimStart();\n\t\t}\n\n\t\t// Style (was ...) inline values\n\t\tconst valueMatch = message.match(/\\(was (.*)\\)/);\n\t\tif (valueMatch?.[1]) {\n\t\t\tconst value = valueMatch[1];\n\t\t\tif (!value.includes(\"\\x1b[\")) {\n\t\t\t\tmessage = message.replace(\n\t\t\t\t\t`(was ${value})`,\n\t\t\t\t\t`(was ${styleText(\"cyan\", value)})`,\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\n\t\treturn { path, message };\n\t});\n}\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\temptyAsUndefined = false,\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// Optionally treat empty strings as undefined\n\tconst processedEnv = emptyAsUndefined ? stripEmptyStrings(env) : env;\n\n\t// Validate the environment variables\n\tconst validatedEnv = finalSchema(processedEnv);\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(arkErrorsToIssues(validatedEnv));\n\t}\n\n\treturn validatedEnv;\n}\n","import type { $ } from \"@repo/scope\";\nimport type {\n\tCompiledEnvSchema,\n\tDict,\n\tInferType,\n\tSchemaShape,\n} from \"@repo/types\";\nimport type { type as at, distill } from \"arktype\";\nimport { parse } from \"./arktype\";\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, $>;\n\n/**\n * Infer the validated and coerced environment object type from a schema.\n * Supports declarative schema shapes, compiled ArkType schemas, and Standard Schema validators.\n *\n * @template T - The schema type\n */\nexport type Infer<T> = T extends SchemaShape\n\t? distill.Out<at.infer<T, $>>\n\t: InferType<T>;\n\n/**\n * The environment variables passed to `createEnv`.\n * Uses `Dict<string>` to enforce\n * compile-time safety: all input environment variables must be strings\n * (or undefined), matching `process.env` semantics.\n */\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\n\t/**\n\t * Whether to treat empty strings (`\"\"`) as `undefined` before validation.\n\t *\n\t * When enabled, an environment variable set to an empty value (e.g. `PORT=`)\n\t * will be treated as if it were missing, allowing defaults to apply and\n\t * preventing validation errors for numeric or boolean types.\n\t *\n\t * @default false\n\t */\n\temptyAsUndefined?: boolean;\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 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>;\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\t// biome-ignore lint/suspicious/noExplicitAny: parse handles both EnvSchema<T> and CompiledEnvSchema at runtime\n\treturn parse(def as any, config);\n}\n","/**\n * Extract the keys from a schema definition dynamically.\n * Supports plain objects, ArkType schemas, and Standard Schema validators.\n *\n * @param schema The schema definition to extract keys from\n * @returns An array of extracted key names\n * @internal\n */\n// biome-ignore lint/suspicious/noExplicitAny: Need to handle various schema formats\nexport function getSchemaKeys(schema: any): string[] {\n\tif (!schema || (typeof schema !== \"object\" && typeof schema !== \"function\")) {\n\t\treturn [];\n\t}\n\n\t// ArkType Type\n\tif (\n\t\tschema.json &&\n\t\ttypeof schema.json === \"object\" &&\n\t\tschema.json.domain === \"object\"\n\t) {\n\t\tconst keys: string[] = [];\n\t\tif (Array.isArray(schema.json.required)) {\n\t\t\tfor (const r of schema.json.required) {\n\t\t\t\tif (r && typeof r === \"object\" && \"key\" in r) {\n\t\t\t\t\tkeys.push(r.key);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tif (Array.isArray(schema.json.optional)) {\n\t\t\tfor (const o of schema.json.optional) {\n\t\t\t\tif (o && typeof o === \"object\" && \"key\" in o) {\n\t\t\t\t\tkeys.push(o.key);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn keys;\n\t}\n\n\t// Standard Schema / JSON Schema fallback\n\tconst std = schema[\"~standard\"];\n\tconst jsonSchemaInput =\n\t\t(typeof std?.jsonSchema?.input === \"function\" && std.jsonSchema.input) ||\n\t\t(typeof schema.jsonSchema?.input === \"function\" && schema.jsonSchema.input);\n\n\tif (jsonSchemaInput) {\n\t\ttry {\n\t\t\tconst json = jsonSchemaInput({ target: \"draft-07\" });\n\t\t\tif (json && typeof json === \"object\" && json.properties) {\n\t\t\t\treturn Object.keys(json.properties);\n\t\t\t}\n\t\t} catch {}\n\t}\n\n\tif (typeof schema.toJSONSchema === \"function\") {\n\t\ttry {\n\t\t\tconst json = schema.toJSONSchema();\n\t\t\tif (json && typeof json === \"object\" && json.properties) {\n\t\t\t\treturn Object.keys(json.properties);\n\t\t\t}\n\t\t} catch {}\n\t}\n\n\tif (typeof schema.toStandardJSONSchema?.v1 === \"function\") {\n\t\ttry {\n\t\t\tconst json = schema.toStandardJSONSchema.v1();\n\t\t\tif (json && typeof json === \"object\" && json.properties) {\n\t\t\t\treturn Object.keys(json.properties);\n\t\t\t}\n\t\t} catch {}\n\t}\n\n\t// Plain object schema\n\treturn Object.keys(schema);\n}\n","import { $ } from \"@repo/scope\";\nimport { createEnv } from \"./create-env\";\nimport { getSchemaKeys } from \"./schema\";\n\nexport { createEnv, getSchemaKeys };\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;\nexport type { ArkEnvConfig, EnvSchema, Infer } from \"./create-env\";\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":"2JAA0C,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,CCYvN,SAAgB,EACf,EACA,EACA,EACiB,CAQjB,IAAM,EAAU,EAHH,EAAO,GAAG,aAAa,CACnC,SAAW,GAAS,EAAY,KAChC,CACqC,CAAQ,CAY9C,OAVI,EAAQ,SAAW,EACf,EASD,EAAG,UAAU,CAClB,KAAM,GAAkB,EAAc,EAAM,EAAS,EAAQ,CAAC,CAC9D,KAAK,EAAO,CCTf,SAAS,EAAkB,EAAsC,CAChE,OAAO,OAAO,QAAQ,EAAO,OAAO,CAAC,KAAK,CAAC,EAAM,KAAW,CAC3D,IAAI,EAAU,EAAM,QAGhB,EAAU,EAAQ,WAAW,CAIjC,GAHI,EAAQ,OAAS,GAAK,MAAM,SAAS,EAAQ,GAAG,GACnD,EAAU,EAAQ,MAAM,EAAE,CAAC,WAAW,EAEnC,EAAQ,aAAa,CAAC,WAAW,EAAK,aAAa,CAAC,CAAE,CACzD,IAAI,EAAO,EAAQ,MAAM,EAAK,OAAO,CAAC,WAAW,CAC7C,EAAK,OAAS,GAAK,MAAM,SAAS,EAAK,GAAG,GAC7C,EA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AY,QAAS,GAC1C,EAAK,KAAK,EAAE,IAAI,CAInB,OAAO,EAIR,IAAM,EAAM,EAAO,aACb,EACJ,OAAO,GAAK,YAAY,OAAU,YAAc,EAAI,WAAW,OAC/D,OAAO,EAAO,YAAY,OAAU,YAAc,EAAO,WAAW,MAEtE,GAAI,EACH,GAAI,CACH,IAAM,EAAO,EAAgB,CAAE,OAAQ,WAAY,CAAC,CACpD,GAAI,GAAQ,OAAO,GAAS,UAAY,EAAK,WAC5C,OAAO,OAAO,KAAK,EAAK,WAAW,MAE7B,EAGT,GAAI,OAAO,EAAO,cAAiB,WAClC,GAAI,CACH,IAAM,EAAO,EAAO,cAAc,CAClC,GAAI,GAAQ,OAAO,GAAS,UAAY,EAAK,WAC5C,OAAO,OAAO,KAAK,EAAK,WAAW,MAE7B,EAGT,GAAI,OAAO,EAAO,sBAAsB,IAAO,WAC9C,GAAI,CACH,IAAM,EAAO,EAAO,qBAAqB,IAAI,CAC7C,GAAI,GAAQ,OAAO,GAAS,UAAY,EAAK,WAC5C,OAAO,OAAO,KAAK,EAAK,WAAW,MAE7B,EAIT,OAAO,OAAO,KAAK,EAAO,CC1D3B,MAAa,EAAOC,EAAE,KAQhB,EAAS"}
@@ -1,3 +1,3 @@
1
- const e=e=>{if(typeof e==`number`||typeof e!=`string`||!e.trim())return e;if(e.trim()===`NaN`)return NaN;let t=Number(e);return Number.isNaN(t)?e:t},t=e=>e===`true`?!0:e===`false`?!1:e,n=e=>{if(typeof e!=`string`)return e;let t=e.trim();if(t[0]!==`{`&&t[0]!==`[`)return e;try{return JSON.parse(t)}catch{return e}},r=e=>{if(e instanceof Date||typeof e!=`string`||!e.trim())return e;let t=new Date(e);return Number.isNaN(t.getTime())?e:t},i=e=>{let t={};for(let n in e){let r=e[n];r!==``&&(t[n]=r)}return t},a=(e,t=[])=>{let n=[];if(!e||typeof e!=`object`)return n;if(`const`in e){let r=typeof e.const;(r===`number`||r===`boolean`)&&n.push({path:[...t],type:`primitive`})}`enum`in e&&Array.isArray(e.enum)&&e.enum.some(e=>typeof e==`number`||typeof e==`boolean`)&&n.push({path:[...t],type:`primitive`});let r=e.type;if(r===`number`||r===`integer`||r===`boolean`)n.push({path:[...t],type:`primitive`});else if(r===`string`&&`format`in e&&(e.format===`date-time`||e.format===`date`))n.push({path:[...t],type:`date`});else if(r===`object`){if(e.properties&&Object.keys(e.properties).length>0){n.push({path:[...t],type:`object`});for(let r in e.properties)n.push(...a(e.properties[r],[...t,r]))}}else r===`array`&&(n.push({path:[...t],type:`array`}),e.items&&(Array.isArray(e.items)?e.items.forEach((e,r)=>{n.push(...a(e,[...t,String(r)]))}):n.push(...a(e.items,[...t,`*`]))));for(let r of[`anyOf`,`allOf`,`oneOf`])if(r in e&&Array.isArray(e[r]))for(let i of e[r])n.push(...a(i,t));let i=new Set;return n.filter(e=>{let t=e.path.join(`/`)+`:`+e.type;return i.has(t)?!1:i.add(t)})},o=(i,a,o={})=>{let{arrayFormat:s=`comma`}=o,c=e=>{if(s===`json`)try{return JSON.parse(e)}catch{return e}return e.trim()?e.split(`,`).map(e=>e.trim()):[]},l=(i,a)=>{if(a===`array`&&typeof i==`string`)return c(i);if(a===`object`&&typeof i==`string`)return n(i);if(a===`date`&&typeof i==`string`)return r(i);if(a===`primitive`){if(Array.isArray(i)){for(let n=0;n<i.length;n++){let r=e(i[n]);i[n]=typeof r==`number`?r:t(i[n])}return i}let n=e(i);return typeof n==`number`?n:t(i)}return i};if(typeof i!=`object`||!i){let e=a.find(e=>e.path.length===0);return e?l(i,e.type):i}let u=[...a].sort((e,t)=>e.path.length-t.path.length),d=(e,t,n)=>{if(!e||typeof e!=`object`||t.length===0)return;let[r,...i]=t;if(i.length===0){if(r===`*`){if(Array.isArray(e))for(let t=0;t<e.length;t++)e[t]=l(e[t],n)}else Object.prototype.hasOwnProperty.call(e,r)&&(e[r]=l(e[r],n));return}if(r===`*`){if(Array.isArray(e))for(let t of e)d(t,i,n)}else d(e[r],i,n)};for(let e of u)d(i,e.path,e.type);return i};export{a as n,i as r,o as t};
1
+ const e=e=>{if(typeof e==`number`||typeof e!=`string`||!e.trim())return e;if(e.trim()===`NaN`)return NaN;let t=Number(e);return Number.isNaN(t)?e:t},t=e=>e===`true`?!0:e===`false`?!1:e,n=e=>{if(typeof e!=`string`)return e;let t=e.trim();if(t[0]!==`{`&&t[0]!==`[`)return e;try{return JSON.parse(t)}catch{return e}},r=e=>{if(e instanceof Date||typeof e!=`string`||!e.trim())return e;let t=new Date(e);return Number.isNaN(t.getTime())?e:t},i=e=>{let t={};for(let n in e){let r=e[n];r!==``&&(t[n]=r)}return t},a=(e,t=[])=>{let n=[];if(!e||typeof e!=`object`)return n;if(`const`in e){let r=typeof e.const;(r===`number`||r===`boolean`)&&n.push({path:[...t],type:`primitive`})}`enum`in e&&Array.isArray(e.enum)&&e.enum.some(e=>typeof e==`number`||typeof e==`boolean`)&&n.push({path:[...t],type:`primitive`});let r=e.type;if(r===`number`||r===`integer`||r===`boolean`)n.push({path:[...t],type:`primitive`});else if(r===`string`&&`format`in e&&(e.format===`date-time`||e.format===`date`))n.push({path:[...t],type:`date`});else if(r===`object`){if(e.properties&&Object.keys(e.properties).length>0){n.push({path:[...t],type:`object`});for(let r in e.properties)n.push(...a(e.properties[r],[...t,r]))}}else r===`array`&&(n.push({path:[...t],type:`array`}),e.items&&(Array.isArray(e.items)?e.items.forEach((e,r)=>{n.push(...a(e,[...t,String(r)]))}):n.push(...a(e.items,[...t,`*`]))));for(let r of[`anyOf`,`allOf`,`oneOf`])if(r in e&&Array.isArray(e[r]))for(let i of e[r])n.push(...a(i,t));let i=new Set;return n.filter(e=>{let t=e.path.join(`/`)+`:`+e.type;return i.has(t)?!1:i.add(t)})},o=(i,a,o={})=>{let{arrayFormat:s=`comma`}=o,c=e=>{if(s===`json`)try{return JSON.parse(e)}catch{return e}return e.trim()?e.split(`,`).map(e=>e.trim()):[]},l=(i,a)=>{if(a===`array`&&typeof i==`string`)return c(i);if(a===`object`&&typeof i==`string`)return n(i);if(a===`date`&&typeof i==`string`)return r(i);if(a===`primitive`){if(Array.isArray(i))return i.map(n=>{if(typeof n!=`string`)return n;let r=e(n);return typeof r==`number`?r:t(n)});if(typeof i!=`string`)return i;let n=e(i);return typeof n==`number`?n:t(i)}return i};if(typeof i!=`object`||!i){let e=a.find(e=>e.path.length===0);return e?l(i,e.type):i}let u=[...a].sort((e,t)=>e.path.length-t.path.length),d=(e,t,n)=>{if(t.length===0)return n(e);let[r,...i]=t;if(r===`*`){if(Array.isArray(e)){let t=!1,r=e.map(e=>{let r=d(e,i,n);return r!==e&&(t=!0),r});return t?r:e}return e}if(!e||typeof e!=`object`)return e;if(Array.isArray(e)){let t=Number(r);if(!Number.isNaN(t)&&t>=0&&t<e.length){let r=d(e[t],i,n);if(r!==e[t]){let n=[...e];return n[t]=r,n}}return e}if(Object.hasOwn(e,r)){let t=d(e[r],i,n);if(t!==e[r])return{...e,[r]:t}}return e},f=i;for(let e of u)e.path.length>0&&(f=d(f,e.path,t=>l(t,e.type)));return f};export{a as n,i as r,o as t};
2
2
 
3
- //# sourceMappingURL=shared-CTq6rhd_.mjs.map
3
+ //# sourceMappingURL=shared-BzftEfkT.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shared-BzftEfkT.mjs","names":[],"sources":["../src/coercion/morphs.ts","../src/coercion/shared.ts"],"sourcesContent":["/**\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\" || !s.trim()) return s;\n\tif (s.trim() === \"NaN\") return Number.NaN;\n\tconst n = Number(s);\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[0] !== \"{\" && trimmed[0] !== \"[\") return s;\n\ttry {\n\t\treturn JSON.parse(trimmed);\n\t} catch {\n\t\treturn s;\n\t}\n};\n\n/**\n * Attempt to coerce a value to a Date.\n *\n * If the input is already a Date, returns it unchanged.\n * If the input is a valid date string, returns a Date object.\n * Otherwise, returns the original value unchanged.\n *\n * @internal\n * @param s - The value to coerce\n * @returns The coerced Date or the original value\n */\nexport const coerceDate = (s: unknown) => {\n\tif (s instanceof Date) return s;\n\tif (typeof s !== \"string\" || !s.trim()) return s;\n\tconst d = new Date(s);\n\treturn Number.isNaN(d.getTime()) ? s : d;\n};\n","import { coerceBoolean, coerceDate, coerceJson, coerceNumber } from \"./morphs\";\n\n/**\n * Remove keys with empty string values from an environment record.\n *\n * When a key is set to `\"\"` (e.g. `PORT=` in a `.env` file), deleting it\n * allows the validator to treat it as missing so that defaults apply.\n *\n * @param env The environment variables record\n * @returns A new record with empty string keys removed\n */\nexport const stripEmptyStrings = (\n\tenv: Record<string, unknown>,\n): Record<string, unknown> => {\n\tconst result: Record<string, unknown> = {};\n\tfor (const key in env) {\n\t\tconst value = env[key];\n\t\tif (value !== \"\") {\n\t\t\tresult[key] = value;\n\t\t}\n\t}\n\treturn result;\n};\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 */\nexport const ARRAY_ITEM_MARKER = \"*\";\n\n/**\n * @internal\n * Information about a path in the schema that requires coercion.\n */\nexport type CoercionTarget = {\n\tpath: string[];\n\ttype: \"primitive\" | \"array\" | \"object\" | \"date\";\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 * Find all paths in a JSON Schema that require coercion.\n *\n * Prioritize \"number\", \"integer\", \"boolean\", \"array\", \"object\", and \"date\" types.\n *\n * @param node The JSON Schema node to traverse\n * @param path The current path segments in the schema tree\n * @returns An array of coercion targets containing their path and type\n */\nexport const findCoercionPaths = (\n\tnode: Record<string, any>,\n\tpath: string[] = [],\n): CoercionTarget[] => {\n\tconst results: CoercionTarget[] = [];\n\tif (!node || typeof node !== \"object\") return results;\n\n\tif (\"const\" in node) {\n\t\tconst t = typeof node.const;\n\t\tif (t === \"number\" || t === \"boolean\") {\n\t\t\tresults.push({ path: [...path], type: \"primitive\" });\n\t\t}\n\t}\n\n\tif (\"enum\" in node && Array.isArray(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\tconst type = node.type;\n\tif (type === \"number\" || type === \"integer\" || type === \"boolean\") {\n\t\tresults.push({ path: [...path], type: \"primitive\" });\n\t} else if (\n\t\ttype === \"string\" &&\n\t\t\"format\" in node &&\n\t\t(node.format === \"date-time\" || node.format === \"date\")\n\t) {\n\t\tresults.push({ path: [...path], type: \"date\" });\n\t} else if (type === \"object\") {\n\t\tif (node.properties && Object.keys(node.properties).length > 0) {\n\t\t\tresults.push({ path: [...path], type: \"object\" });\n\t\t\tfor (const key in node.properties) {\n\t\t\t\tresults.push(\n\t\t\t\t\t...findCoercionPaths(node.properties[key], [...path, key]),\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t} else if (type === \"array\") {\n\t\tresults.push({ path: [...path], type: \"array\" });\n\t\tif (node.items) {\n\t\t\tif (Array.isArray(node.items)) {\n\t\t\t\tnode.items.forEach((item, index) => {\n\t\t\t\t\tresults.push(...findCoercionPaths(item, [...path, String(index)]));\n\t\t\t\t});\n\t\t\t} else {\n\t\t\t\tresults.push(\n\t\t\t\t\t...findCoercionPaths(node.items, [...path, ARRAY_ITEM_MARKER]),\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t}\n\n\tfor (const comb of [\"anyOf\", \"allOf\", \"oneOf\"]) {\n\t\tif (comb in node && Array.isArray(node[comb])) {\n\t\t\tfor (const branch of node[comb]) {\n\t\t\t\tresults.push(...findCoercionPaths(branch, path));\n\t\t\t}\n\t\t}\n\t}\n\n\tconst seen = new Set<string>();\n\treturn results.filter((t) => {\n\t\tconst key = t.path.join(\"/\") + \":\" + t.type;\n\t\treturn seen.has(key) ? false : seen.add(key);\n\t});\n};\n\n/**\n * Apply coercion to a data object based on identified paths.\n *\n * @param data The input environment data object to coerce\n * @param targets The coercion targets mapping paths to types\n * @param options The coercion options, including array parsing format\n * @returns The coerced data object\n */\nexport const applyCoercion = (\n\tdata: unknown,\n\ttargets: CoercionTarget[],\n\toptions: CoerceOptions = {},\n) => {\n\tconst { arrayFormat = \"comma\" } = options;\n\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\t\treturn val.trim() ? val.split(\",\").map((s) => s.trim()) : [];\n\t};\n\n\tconst coerceValue = (val: unknown, type: CoercionTarget[\"type\"]): unknown => {\n\t\tif (type === \"array\" && typeof val === \"string\") {\n\t\t\treturn splitString(val);\n\t\t}\n\t\tif (type === \"object\" && typeof val === \"string\") {\n\t\t\treturn coerceJson(val);\n\t\t}\n\t\tif (type === \"date\" && typeof val === \"string\") {\n\t\t\treturn coerceDate(val);\n\t\t}\n\t\tif (type === \"primitive\") {\n\t\t\tif (Array.isArray(val)) {\n\t\t\t\treturn val.map((item) => {\n\t\t\t\t\tif (typeof item !== \"string\") return item;\n\t\t\t\t\tconst n = coerceNumber(item);\n\t\t\t\t\treturn typeof n === \"number\" ? n : coerceBoolean(item);\n\t\t\t\t});\n\t\t\t}\n\t\t\tif (typeof val !== \"string\") return val;\n\t\t\tconst n = coerceNumber(val);\n\t\t\treturn typeof n === \"number\" ? n : coerceBoolean(val);\n\t\t}\n\t\treturn val;\n\t};\n\n\tif (typeof data !== \"object\" || data === null) {\n\t\tconst root = targets.find((t) => t.path.length === 0);\n\t\tif (root) {\n\t\t\treturn coerceValue(data, root.type);\n\t\t}\n\t\treturn data;\n\t}\n\n\tconst sorted = [...targets].sort((a, b) => a.path.length - b.path.length);\n\n\tconst updateAtPath = (\n\t\tcurrent: any,\n\t\tpath: string[],\n\t\tfn: (val: any) => any,\n\t): any => {\n\t\tif (path.length === 0) {\n\t\t\treturn fn(current);\n\t\t}\n\n\t\tconst [key, ...rest] = path;\n\n\t\tif (key === ARRAY_ITEM_MARKER) {\n\t\t\tif (Array.isArray(current)) {\n\t\t\t\tlet changed = false;\n\t\t\t\tconst nextArr = current.map((item) => {\n\t\t\t\t\tconst nextVal = updateAtPath(item, rest, fn);\n\t\t\t\t\tif (nextVal !== item) {\n\t\t\t\t\t\tchanged = true;\n\t\t\t\t\t}\n\t\t\t\t\treturn nextVal;\n\t\t\t\t});\n\t\t\t\treturn changed ? nextArr : current;\n\t\t\t}\n\t\t\treturn current;\n\t\t}\n\n\t\tif (!current || typeof current !== \"object\") {\n\t\t\treturn current;\n\t\t}\n\n\t\tif (Array.isArray(current)) {\n\t\t\tconst index = Number(key);\n\t\t\tif (!Number.isNaN(index) && index >= 0 && index < current.length) {\n\t\t\t\tconst nextVal = updateAtPath(current[index], rest, fn);\n\t\t\t\tif (nextVal !== current[index]) {\n\t\t\t\t\tconst copy = [...current];\n\t\t\t\t\tcopy[index] = nextVal;\n\t\t\t\t\treturn copy;\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn current;\n\t\t}\n\n\t\tif (Object.hasOwn(current, key)) {\n\t\t\tconst nextVal = updateAtPath(current[key], rest, fn);\n\t\t\tif (nextVal !== current[key]) {\n\t\t\t\treturn {\n\t\t\t\t\t...current,\n\t\t\t\t\t[key]: nextVal,\n\t\t\t\t};\n\t\t\t}\n\t\t}\n\n\t\treturn current;\n\t};\n\n\tlet result = data;\n\tfor (const t of sorted) {\n\t\tif (t.path.length > 0) {\n\t\t\tresult = updateAtPath(result, t.path, (val) => coerceValue(val, t.type));\n\t\t}\n\t}\n\treturn result;\n};\n"],"mappings":"AAWA,MAAa,EAAgB,GAAe,CAE3C,GADI,OAAO,GAAM,UACb,OAAO,GAAM,UAAY,CAAC,EAAE,MAAM,CAAE,OAAO,EAC/C,GAAI,EAAE,MAAM,GAAK,MAAO,MAAO,KAC/B,IAAM,EAAI,OAAO,EAAE,CACnB,OAAO,OAAO,MAAM,EAAE,CAAG,EAAI,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,EAAQ,KAAO,KAAO,EAAQ,KAAO,IAAK,OAAO,EACrD,GAAI,CACH,OAAO,KAAK,MAAM,EAAQ,MACnB,CACP,OAAO,IAeI,EAAc,GAAe,CAEzC,GADI,aAAa,MACb,OAAO,GAAM,UAAY,CAAC,EAAE,MAAM,CAAE,OAAO,EAC/C,IAAM,EAAI,IAAI,KAAK,EAAE,CACrB,OAAO,OAAO,MAAM,EAAE,SAAS,CAAC,CAAG,EAAI,GC5D3B,EACZ,GAC6B,CAC7B,IAAM,EAAkC,EAAE,CAC1C,IAAK,IAAM,KAAO,EAAK,CACtB,IAAM,EAAQ,EAAI,GACd,IAAU,KACb,EAAO,GAAO,GAGhB,OAAO,GAsCK,GACZ,EACA,EAAiB,EAA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AAE,KAAO,GAAQ,EAAY,EAAK,EAAE,KAAK,CAAC,EAG1E,OAAO"}
@@ -1,4 +1,4 @@
1
- const e=e=>{if(typeof e==`number`||typeof e!=`string`||!e.trim())return e;if(e.trim()===`NaN`)return NaN;let t=Number(e);return Number.isNaN(t)?e:t},t=e=>e===`true`?!0:e===`false`?!1:e,n=e=>{if(typeof e!=`string`)return e;let t=e.trim();if(t[0]!==`{`&&t[0]!==`[`)return e;try{return JSON.parse(t)}catch{return e}},r=e=>{if(e instanceof Date||typeof e!=`string`||!e.trim())return e;let t=new Date(e);return Number.isNaN(t.getTime())?e:t},i=e=>{let t={};for(let n in e){let r=e[n];r!==``&&(t[n]=r)}return t},a=(e,t=[])=>{let n=[];if(!e||typeof e!=`object`)return n;if(`const`in e){let r=typeof e.const;(r===`number`||r===`boolean`)&&n.push({path:[...t],type:`primitive`})}`enum`in e&&Array.isArray(e.enum)&&e.enum.some(e=>typeof e==`number`||typeof e==`boolean`)&&n.push({path:[...t],type:`primitive`});let r=e.type;if(r===`number`||r===`integer`||r===`boolean`)n.push({path:[...t],type:`primitive`});else if(r===`string`&&`format`in e&&(e.format===`date-time`||e.format===`date`))n.push({path:[...t],type:`date`});else if(r===`object`){if(e.properties&&Object.keys(e.properties).length>0){n.push({path:[...t],type:`object`});for(let r in e.properties)n.push(...a(e.properties[r],[...t,r]))}}else r===`array`&&(n.push({path:[...t],type:`array`}),e.items&&(Array.isArray(e.items)?e.items.forEach((e,r)=>{n.push(...a(e,[...t,String(r)]))}):n.push(...a(e.items,[...t,`*`]))));for(let r of[`anyOf`,`allOf`,`oneOf`])if(r in e&&Array.isArray(e[r]))for(let i of e[r])n.push(...a(i,t));let i=new Set;return n.filter(e=>{let t=e.path.join(`/`)+`:`+e.type;return i.has(t)?!1:i.add(t)})},o=(i,a,o={})=>{let{arrayFormat:s=`comma`}=o,c=e=>{if(s===`json`)try{return JSON.parse(e)}catch{return e}return e.trim()?e.split(`,`).map(e=>e.trim()):[]},l=(i,a)=>{if(a===`array`&&typeof i==`string`)return c(i);if(a===`object`&&typeof i==`string`)return n(i);if(a===`date`&&typeof i==`string`)return r(i);if(a===`primitive`){if(Array.isArray(i)){for(let n=0;n<i.length;n++){let r=e(i[n]);i[n]=typeof r==`number`?r:t(i[n])}return i}let n=e(i);return typeof n==`number`?n:t(i)}return i};if(typeof i!=`object`||!i){let e=a.find(e=>e.path.length===0);return e?l(i,e.type):i}let u=[...a].sort((e,t)=>e.path.length-t.path.length),d=(e,t,n)=>{if(!e||typeof e!=`object`||t.length===0)return;let[r,...i]=t;if(i.length===0){if(r===`*`){if(Array.isArray(e))for(let t=0;t<e.length;t++)e[t]=l(e[t],n)}else Object.prototype.hasOwnProperty.call(e,r)&&(e[r]=l(e[r],n));return}if(r===`*`){if(Array.isArray(e))for(let t of e)d(t,i,n)}else d(e[r],i,n)};for(let e of u)d(i,e.path,e.type);return i};Object.defineProperty(exports,`n`,{enumerable:!0,get:function(){return a}}),Object.defineProperty(exports,`r`,{enumerable:!0,get:function(){return i}}),Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return o}});
1
+ const e=e=>{if(typeof e==`number`||typeof e!=`string`||!e.trim())return e;if(e.trim()===`NaN`)return NaN;let t=Number(e);return Number.isNaN(t)?e:t},t=e=>e===`true`?!0:e===`false`?!1:e,n=e=>{if(typeof e!=`string`)return e;let t=e.trim();if(t[0]!==`{`&&t[0]!==`[`)return e;try{return JSON.parse(t)}catch{return e}},r=e=>{if(e instanceof Date||typeof e!=`string`||!e.trim())return e;let t=new Date(e);return Number.isNaN(t.getTime())?e:t},i=e=>{let t={};for(let n in e){let r=e[n];r!==``&&(t[n]=r)}return t},a=(e,t=[])=>{let n=[];if(!e||typeof e!=`object`)return n;if(`const`in e){let r=typeof e.const;(r===`number`||r===`boolean`)&&n.push({path:[...t],type:`primitive`})}`enum`in e&&Array.isArray(e.enum)&&e.enum.some(e=>typeof e==`number`||typeof e==`boolean`)&&n.push({path:[...t],type:`primitive`});let r=e.type;if(r===`number`||r===`integer`||r===`boolean`)n.push({path:[...t],type:`primitive`});else if(r===`string`&&`format`in e&&(e.format===`date-time`||e.format===`date`))n.push({path:[...t],type:`date`});else if(r===`object`){if(e.properties&&Object.keys(e.properties).length>0){n.push({path:[...t],type:`object`});for(let r in e.properties)n.push(...a(e.properties[r],[...t,r]))}}else r===`array`&&(n.push({path:[...t],type:`array`}),e.items&&(Array.isArray(e.items)?e.items.forEach((e,r)=>{n.push(...a(e,[...t,String(r)]))}):n.push(...a(e.items,[...t,`*`]))));for(let r of[`anyOf`,`allOf`,`oneOf`])if(r in e&&Array.isArray(e[r]))for(let i of e[r])n.push(...a(i,t));let i=new Set;return n.filter(e=>{let t=e.path.join(`/`)+`:`+e.type;return i.has(t)?!1:i.add(t)})},o=(i,a,o={})=>{let{arrayFormat:s=`comma`}=o,c=e=>{if(s===`json`)try{return JSON.parse(e)}catch{return e}return e.trim()?e.split(`,`).map(e=>e.trim()):[]},l=(i,a)=>{if(a===`array`&&typeof i==`string`)return c(i);if(a===`object`&&typeof i==`string`)return n(i);if(a===`date`&&typeof i==`string`)return r(i);if(a===`primitive`){if(Array.isArray(i))return i.map(n=>{if(typeof n!=`string`)return n;let r=e(n);return typeof r==`number`?r:t(n)});if(typeof i!=`string`)return i;let n=e(i);return typeof n==`number`?n:t(i)}return i};if(typeof i!=`object`||!i){let e=a.find(e=>e.path.length===0);return e?l(i,e.type):i}let u=[...a].sort((e,t)=>e.path.length-t.path.length),d=(e,t,n)=>{if(t.length===0)return n(e);let[r,...i]=t;if(r===`*`){if(Array.isArray(e)){let t=!1,r=e.map(e=>{let r=d(e,i,n);return r!==e&&(t=!0),r});return t?r:e}return e}if(!e||typeof e!=`object`)return e;if(Array.isArray(e)){let t=Number(r);if(!Number.isNaN(t)&&t>=0&&t<e.length){let r=d(e[t],i,n);if(r!==e[t]){let n=[...e];return n[t]=r,n}}return e}if(Object.hasOwn(e,r)){let t=d(e[r],i,n);if(t!==e[r])return{...e,[r]:t}}return e},f=i;for(let e of u)e.path.length>0&&(f=d(f,e.path,t=>l(t,e.type)));return f};Object.defineProperty(exports,`n`,{enumerable:!0,get:function(){return a}}),Object.defineProperty(exports,`r`,{enumerable:!0,get:function(){return i}}),Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return o}});
2
2
 
3
3
  // CJS Interop Shim
4
4
  if (module.exports && module.exports.default) {
package/dist/standard.cjs CHANGED
@@ -1,4 +1,4 @@
1
- Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});const e=require(`./shared-BW9_Fgr8.cjs`),t=require(`./core-BftJnV8f.cjs`);function n(e,n){if(typeof n==`string`)throw new t.t([{path:e,message:`ArkType DSL strings are not supported in "standard" mode. Use a Standard Schema validator (e.g., Zod, Valibot) or import from "arkenv" for ArkType schemas.`}])}function r(e,n){let r=n&&typeof n==`object`&&`~standard`in n&&n[`~standard`];if(!r||typeof r!=`object`||!(`validate`in r)||typeof r.validate!=`function`)throw new t.t([{path:e,message:`Invalid validator: expected a Standard Schema 1.0 validator (must have "~standard" property). Import from "arkenv" to use ArkType schemas.`}])}function i(e){if(!e||typeof e!=`object`||Array.isArray(e))throw new t.t([{path:``,message:`Invalid schema: expected an object mapping in "standard" mode.`}])}function a(e,t){let n={type:`object`,properties:{}},r=!1;for(let i in e){let a=e[i];if(!a){t.push(i);continue}let o=a[`~standard`];if(typeof o?.jsonSchema?.input==`function`)try{let e=o.jsonSchema.input({target:`draft-07`});if(e){n.properties[i]=e,r=!0;continue}}catch{}if(typeof a.jsonSchema?.input==`function`)try{let e=a.jsonSchema.input({target:`draft-07`});if(e){n.properties[i]=e,r=!0;continue}}catch{}if(typeof a.toJSONSchema==`function`)try{let e=a.toJSONSchema();if(e){n.properties[i]=e,r=!0;continue}}catch{}if(typeof a.toStandardJSONSchema?.v1==`function`)try{let e=a.toStandardJSONSchema.v1();if(e){n.properties[i]=e,r=!0;continue}}catch{}t.push(i)}return{jsonSchema:n,hasJsonSchema:r}}function o(e,t){return!t||t.length===0?e:[e,...t.map(e=>typeof e==`object`&&e&&`key`in e?String(e.key):String(e))].join(`.`)}function s(n,r){let{env:i=process.env,onUndeclaredKey:s=`delete`,coerce:c=!0,arrayFormat:l=`comma`,emptyAsUndefined:u=!1}=r,d={},f=[],p=u?e.r(i):i,m=new Set(Object.keys(p)),h={...p},g=[];if(c){let{jsonSchema:t,hasJsonSchema:r}=a(n,g);r&&(h=e.t(h,e.n(t),{arrayFormat:l}))}for(let e in n){let r=n[e],i=h[e];if(!r||typeof r!=`object`||!(`~standard`in r))throw new t.t([{path:e,message:`Invalid schema: expected a Standard Schema 1.0 validator (e.g. Zod, Valibot) in 'standard' mode.`}]);let a=r[`~standard`].validate(i);if(a instanceof Promise)throw new t.t([{path:e,message:`Async validation is not supported. ArkEnv is synchronous.`}]);if(a.issues)for(let t of a.issues){let n=o(e,t.path),r=t.message;c&&g.includes(e)&&(r+=` (Hint: coercion is enabled by default, but the validator for '${e}' lacks Standard JSON Schema support.)`),f.push({path:n,message:r})}else d[e]=a.value;m.delete(e)}if(s!==`delete`)for(let e of m)s===`reject`?f.push({path:e,message:`Undeclared key`}):s===`ignore`&&(d[e]=h[e]);if(f.length>0)throw new t.t(f);return d}function c(e,t){i(e);for(let t in e){let i=e[t];n(t,i),r(t,i)}return s(e,t??{})}const l=c;exports.createEnv=c,exports.default=l;
1
+ Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});const e=require(`./shared-ClquMPfF.cjs`),t=require(`./core-BftJnV8f.cjs`);function n(e,n){if(typeof n==`string`)throw new t.t([{path:e,message:`ArkType DSL strings are not supported in "standard" mode. Use a Standard Schema validator (e.g., Zod, Valibot) or import from "arkenv" for ArkType schemas.`}])}function r(e,n){let r=n&&typeof n==`object`&&`~standard`in n&&n[`~standard`];if(!r||typeof r!=`object`||!(`validate`in r)||typeof r.validate!=`function`)throw new t.t([{path:e,message:`Invalid validator: expected a Standard Schema 1.0 validator (must have "~standard" property). Import from "arkenv" to use ArkType schemas.`}])}function i(e){if(!e||typeof e!=`object`||Array.isArray(e))throw new t.t([{path:``,message:`Invalid schema: expected an object mapping in "standard" mode.`}])}function a(e,t){let n={type:`object`,properties:{}},r=!1;for(let i in e){let a=e[i];if(!a){t.push(i);continue}let o=a[`~standard`];if(typeof o?.jsonSchema?.input==`function`)try{let e=o.jsonSchema.input({target:`draft-07`});if(e){n.properties[i]=e,r=!0;continue}}catch{}if(typeof a.jsonSchema?.input==`function`)try{let e=a.jsonSchema.input({target:`draft-07`});if(e){n.properties[i]=e,r=!0;continue}}catch{}if(typeof a.toJSONSchema==`function`)try{let e=a.toJSONSchema();if(e){n.properties[i]=e,r=!0;continue}}catch{}if(typeof a.toStandardJSONSchema?.v1==`function`)try{let e=a.toStandardJSONSchema.v1();if(e){n.properties[i]=e,r=!0;continue}}catch{}t.push(i)}return{jsonSchema:n,hasJsonSchema:r}}function o(e,t){return!t||t.length===0?e:[e,...t.map(e=>typeof e==`object`&&e&&`key`in e?String(e.key):String(e))].join(`.`)}function s(n,r){let{env:i=process.env,onUndeclaredKey:s=`delete`,coerce:c=!0,arrayFormat:l=`comma`,emptyAsUndefined:u=!1}=r,d={},f=[],p=u?e.r(i):i,m=new Set(Object.keys(p)),h={...p},g=[];if(c){let{jsonSchema:t,hasJsonSchema:r}=a(n,g);r&&(h=e.t(h,e.n(t),{arrayFormat:l}))}for(let e in n){let r=n[e],i=h[e];if(!r||typeof r!=`object`||!(`~standard`in r))throw new t.t([{path:e,message:`Invalid schema: expected a Standard Schema 1.0 validator (e.g. Zod, Valibot) in 'standard' mode.`}]);let a=r[`~standard`].validate(i);if(a instanceof Promise)throw new t.t([{path:e,message:`Async validation is not supported. ArkEnv is synchronous.`}]);if(a.issues)for(let t of a.issues){let n=o(e,t.path),r=t.message;c&&g.includes(e)&&(r+=` (Hint: coercion is enabled by default, but the validator for '${e}' lacks Standard JSON Schema support.)`),f.push({path:n,message:r})}else d[e]=a.value;m.delete(e)}if(s!==`delete`)for(let e of m)s===`reject`?f.push({path:e,message:`Undeclared key`}):s===`ignore`&&(d[e]=h[e]);if(f.length>0)throw new t.t(f);return d}function c(e,t){i(e);for(let t in e){let i=e[t];n(t,i),r(t,i)}return s(e,t??{})}const l=c;exports.createEnv=c,exports.default=l;
2
2
 
3
3
  // CJS Interop Shim
4
4
  if (module.exports && module.exports.default) {
@@ -1,4 +1,4 @@
1
- import { i as StandardSchemaV1 } from "./index-CzNfOanV.cjs";
1
+ import { a as Dict, i as StandardSchemaV1 } from "./index-BspEVkBJ.cjs";
2
2
 
3
3
  //#region src/parse-standard.d.ts
4
4
  /**
@@ -8,7 +8,7 @@ type ParseStandardConfig = {
8
8
  /**
9
9
  * The environment variables to parse. Defaults to `process.env`
10
10
  */
11
- env?: Record<string, string | undefined>;
11
+ env?: Dict<string>;
12
12
  /**
13
13
  * Control how ArkEnv handles environment variables that are not defined in your schema.
14
14
  *
@@ -1 +1 @@
1
- {"version":3,"file":"standard.d.cts","names":[],"sources":["../src/parse-standard.ts","../src/standard.ts"],"mappings":";;;;;;KAWY,mBAAA;EAAmB;;;EAI9B,GAAA,GAAM,MAAA;EAAA;;;;;;;;;;ACJP;;EDiBC,eAAA;ECjB+B;;AAwBhC;;;;;;EDEC,MAAA;ECCgB;;;;;;;;EDQhB,WAAA;ECVK;;;;;;;;;EDqBL,gBAAA;AAAA;;;;AA9CD;;KCAY,iBAAA,GAAoB,mBAAA;;;;;;;;;;;;;AAAhC;;;;;AAwBA;;;;;iBAAgB,SAAA,iBAA0B,MAAA,SAAe,gBAAA,EAAA,CACxD,GAAA,EAAK,CAAA,EACL,MAAA,GAAS,iBAAA,iBACO,CAAA,GAAI,gBAAA,CAAiB,WAAA,CAAY,CAAA,CAAE,CAAA;;;;;;cAmB9C,MAAA,SAAM,SAAA"}
1
+ {"version":3,"file":"standard.d.cts","names":[],"sources":["../src/parse-standard.ts","../src/standard.ts"],"mappings":";;;;;AAWA;KAAY,mBAAA;;;;EAIX,GAAA,GAAM,IAAA;EAaN;;;;;;;;;ACjBD;;;EDiBC,eAAA;ECjBkD;AAwBnD;;;;;;;EDEC,MAAA;ECCiD;;;;;;;;EDQjD,WAAA;ECVA;;;;;;;;;EDqBA,gBAAA;AAAA;;;;AA9CD;;KCAY,iBAAA,GAAoB,mBAAA;;;;;;;;;;;;;AAAhC;;;;;AAwBA;;;;;iBAAgB,SAAA,iBAA0B,MAAA,SAAe,gBAAA,EAAA,CACxD,GAAA,EAAK,CAAA,EACL,MAAA,GAAS,iBAAA,iBACO,CAAA,GAAI,gBAAA,CAAiB,WAAA,CAAY,CAAA,CAAE,CAAA;;;;;;cAmB9C,MAAA,SAAM,SAAA"}
@@ -1,4 +1,4 @@
1
- import { i as StandardSchemaV1 } from "./index-Br22fqkz.mjs";
1
+ import { a as Dict, i as StandardSchemaV1 } from "./index-BuKcfSYK.mjs";
2
2
 
3
3
  //#region src/parse-standard.d.ts
4
4
  /**
@@ -8,7 +8,7 @@ type ParseStandardConfig = {
8
8
  /**
9
9
  * The environment variables to parse. Defaults to `process.env`
10
10
  */
11
- env?: Record<string, string | undefined>;
11
+ env?: Dict<string>;
12
12
  /**
13
13
  * Control how ArkEnv handles environment variables that are not defined in your schema.
14
14
  *
@@ -1 +1 @@
1
- {"version":3,"file":"standard.d.mts","names":[],"sources":["../src/parse-standard.ts","../src/standard.ts"],"mappings":";;;;;;KAWY,mBAAA;EAAmB;;;EAI9B,GAAA,GAAM,MAAA;EAAA;;;;;;;;;;ACJP;;EDiBC,eAAA;ECjB+B;;AAwBhC;;;;;;EDEC,MAAA;ECCgB;;;;;;;;EDQhB,WAAA;ECVK;;;;;;;;;EDqBL,gBAAA;AAAA;;;;AA9CD;;KCAY,iBAAA,GAAoB,mBAAA;;;;;;;;;;;;;AAAhC;;;;;AAwBA;;;;;iBAAgB,SAAA,iBAA0B,MAAA,SAAe,gBAAA,EAAA,CACxD,GAAA,EAAK,CAAA,EACL,MAAA,GAAS,iBAAA,iBACO,CAAA,GAAI,gBAAA,CAAiB,WAAA,CAAY,CAAA,CAAE,CAAA;;;;;;cAmB9C,MAAA,SAAM,SAAA"}
1
+ {"version":3,"file":"standard.d.mts","names":[],"sources":["../src/parse-standard.ts","../src/standard.ts"],"mappings":";;;;;AAWA;KAAY,mBAAA;;;;EAIX,GAAA,GAAM,IAAA;EAaN;;;;;;;;;ACjBD;;;EDiBC,eAAA;ECjBkD;AAwBnD;;;;;;;EDEC,MAAA;ECCiD;;;;;;;;EDQjD,WAAA;ECVA;;;;;;;;;EDqBA,gBAAA;AAAA;;;;AA9CD;;KCAY,iBAAA,GAAoB,mBAAA;;;;;;;;;;;;;AAAhC;;;;;AAwBA;;;;;iBAAgB,SAAA,iBAA0B,MAAA,SAAe,gBAAA,EAAA,CACxD,GAAA,EAAK,CAAA,EACL,MAAA,GAAS,iBAAA,iBACO,CAAA,GAAI,gBAAA,CAAiB,WAAA,CAAY,CAAA,CAAE,CAAA;;;;;;cAmB9C,MAAA,SAAM,SAAA"}
package/dist/standard.mjs CHANGED
@@ -1,3 +1,3 @@
1
- import{n as e,r as t,t as n}from"./shared-CTq6rhd_.mjs";import{t as r}from"./core-B0IkKRzg.mjs";function i(e,t){if(typeof t==`string`)throw new r([{path:e,message:`ArkType DSL strings are not supported in "standard" mode. Use a Standard Schema validator (e.g., Zod, Valibot) or import from "arkenv" for ArkType schemas.`}])}function a(e,t){let n=t&&typeof t==`object`&&`~standard`in t&&t[`~standard`];if(!n||typeof n!=`object`||!(`validate`in n)||typeof n.validate!=`function`)throw new r([{path:e,message:`Invalid validator: expected a Standard Schema 1.0 validator (must have "~standard" property). Import from "arkenv" to use ArkType schemas.`}])}function o(e){if(!e||typeof e!=`object`||Array.isArray(e))throw new r([{path:``,message:`Invalid schema: expected an object mapping in "standard" mode.`}])}function s(e,t){let n={type:`object`,properties:{}},r=!1;for(let i in e){let a=e[i];if(!a){t.push(i);continue}let o=a[`~standard`];if(typeof o?.jsonSchema?.input==`function`)try{let e=o.jsonSchema.input({target:`draft-07`});if(e){n.properties[i]=e,r=!0;continue}}catch{}if(typeof a.jsonSchema?.input==`function`)try{let e=a.jsonSchema.input({target:`draft-07`});if(e){n.properties[i]=e,r=!0;continue}}catch{}if(typeof a.toJSONSchema==`function`)try{let e=a.toJSONSchema();if(e){n.properties[i]=e,r=!0;continue}}catch{}if(typeof a.toStandardJSONSchema?.v1==`function`)try{let e=a.toStandardJSONSchema.v1();if(e){n.properties[i]=e,r=!0;continue}}catch{}t.push(i)}return{jsonSchema:n,hasJsonSchema:r}}function c(e,t){return!t||t.length===0?e:[e,...t.map(e=>typeof e==`object`&&e&&`key`in e?String(e.key):String(e))].join(`.`)}function l(i,a){let{env:o=process.env,onUndeclaredKey:l=`delete`,coerce:u=!0,arrayFormat:d=`comma`,emptyAsUndefined:f=!1}=a,p={},m=[],h=f?t(o):o,g=new Set(Object.keys(h)),_={...h},v=[];if(u){let{jsonSchema:t,hasJsonSchema:r}=s(i,v);r&&(_=n(_,e(t),{arrayFormat:d}))}for(let e in i){let t=i[e],n=_[e];if(!t||typeof t!=`object`||!(`~standard`in t))throw new r([{path:e,message:`Invalid schema: expected a Standard Schema 1.0 validator (e.g. Zod, Valibot) in 'standard' mode.`}]);let a=t[`~standard`].validate(n);if(a instanceof Promise)throw new r([{path:e,message:`Async validation is not supported. ArkEnv is synchronous.`}]);if(a.issues)for(let t of a.issues){let n=c(e,t.path),r=t.message;u&&v.includes(e)&&(r+=` (Hint: coercion is enabled by default, but the validator for '${e}' lacks Standard JSON Schema support.)`),m.push({path:n,message:r})}else p[e]=a.value;g.delete(e)}if(l!==`delete`)for(let e of g)l===`reject`?m.push({path:e,message:`Undeclared key`}):l===`ignore`&&(p[e]=_[e]);if(m.length>0)throw new r(m);return p}function u(e,t){o(e);for(let t in e){let n=e[t];i(t,n),a(t,n)}return l(e,t??{})}const d=u;export{u as createEnv,d as default};
1
+ import{n as e,r as t,t as n}from"./shared-BzftEfkT.mjs";import{t as r}from"./core-B0IkKRzg.mjs";function i(e,t){if(typeof t==`string`)throw new r([{path:e,message:`ArkType DSL strings are not supported in "standard" mode. Use a Standard Schema validator (e.g., Zod, Valibot) or import from "arkenv" for ArkType schemas.`}])}function a(e,t){let n=t&&typeof t==`object`&&`~standard`in t&&t[`~standard`];if(!n||typeof n!=`object`||!(`validate`in n)||typeof n.validate!=`function`)throw new r([{path:e,message:`Invalid validator: expected a Standard Schema 1.0 validator (must have "~standard" property). Import from "arkenv" to use ArkType schemas.`}])}function o(e){if(!e||typeof e!=`object`||Array.isArray(e))throw new r([{path:``,message:`Invalid schema: expected an object mapping in "standard" mode.`}])}function s(e,t){let n={type:`object`,properties:{}},r=!1;for(let i in e){let a=e[i];if(!a){t.push(i);continue}let o=a[`~standard`];if(typeof o?.jsonSchema?.input==`function`)try{let e=o.jsonSchema.input({target:`draft-07`});if(e){n.properties[i]=e,r=!0;continue}}catch{}if(typeof a.jsonSchema?.input==`function`)try{let e=a.jsonSchema.input({target:`draft-07`});if(e){n.properties[i]=e,r=!0;continue}}catch{}if(typeof a.toJSONSchema==`function`)try{let e=a.toJSONSchema();if(e){n.properties[i]=e,r=!0;continue}}catch{}if(typeof a.toStandardJSONSchema?.v1==`function`)try{let e=a.toStandardJSONSchema.v1();if(e){n.properties[i]=e,r=!0;continue}}catch{}t.push(i)}return{jsonSchema:n,hasJsonSchema:r}}function c(e,t){return!t||t.length===0?e:[e,...t.map(e=>typeof e==`object`&&e&&`key`in e?String(e.key):String(e))].join(`.`)}function l(i,a){let{env:o=process.env,onUndeclaredKey:l=`delete`,coerce:u=!0,arrayFormat:d=`comma`,emptyAsUndefined:f=!1}=a,p={},m=[],h=f?t(o):o,g=new Set(Object.keys(h)),_={...h},v=[];if(u){let{jsonSchema:t,hasJsonSchema:r}=s(i,v);r&&(_=n(_,e(t),{arrayFormat:d}))}for(let e in i){let t=i[e],n=_[e];if(!t||typeof t!=`object`||!(`~standard`in t))throw new r([{path:e,message:`Invalid schema: expected a Standard Schema 1.0 validator (e.g. Zod, Valibot) in 'standard' mode.`}]);let a=t[`~standard`].validate(n);if(a instanceof Promise)throw new r([{path:e,message:`Async validation is not supported. ArkEnv is synchronous.`}]);if(a.issues)for(let t of a.issues){let n=c(e,t.path),r=t.message;u&&v.includes(e)&&(r+=` (Hint: coercion is enabled by default, but the validator for '${e}' lacks Standard JSON Schema support.)`),m.push({path:n,message:r})}else p[e]=a.value;g.delete(e)}if(l!==`delete`)for(let e of g)l===`reject`?m.push({path:e,message:`Undeclared key`}):l===`ignore`&&(p[e]=_[e]);if(m.length>0)throw new r(m);return p}function u(e,t){o(e);for(let t in e){let n=e[t];i(t,n),a(t,n)}return l(e,t??{})}const d=u;export{u as createEnv,d as default};
2
2
 
3
3
  //# sourceMappingURL=standard.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"standard.mjs","names":[],"sources":["../src/guards.ts","../src/parse-standard.ts","../src/standard.ts"],"sourcesContent":["import { ArkEnvError } from \"./core\";\n\n/**\n * Throws if the given value is a string (ArkType DSL) in standard mode.\n * @internal\n */\nexport function assertNotArkTypeDsl(key: string, value: unknown): void {\n\tif (typeof value === \"string\") {\n\t\tthrow new ArkEnvError([\n\t\t\t{\n\t\t\t\tpath: key,\n\t\t\t\tmessage:\n\t\t\t\t\t'ArkType DSL strings are not supported in \"standard\" mode. Use a Standard Schema validator (e.g., Zod, Valibot) or import from \"arkenv\" for ArkType schemas.',\n\t\t\t},\n\t\t]);\n\t}\n}\n\n/**\n * Throws if the given value is not a well-formed Standard Schema validator\n * (must have a `~standard` property whose `validate` field is a function).\n * @internal\n */\nexport function assertStandardSchema(key: string, value: unknown): void {\n\tconst std =\n\t\tvalue &&\n\t\ttypeof value === \"object\" &&\n\t\t\"~standard\" in value &&\n\t\t(value as Record<string, unknown>)[\"~standard\"];\n\n\tif (\n\t\t!std ||\n\t\ttypeof std !== \"object\" ||\n\t\t!(\"validate\" in std) ||\n\t\ttypeof (std as Record<string, unknown>).validate !== \"function\"\n\t) {\n\t\tthrow new ArkEnvError([\n\t\t\t{\n\t\t\t\tpath: key,\n\t\t\t\tmessage:\n\t\t\t\t\t'Invalid validator: expected a Standard Schema 1.0 validator (must have \"~standard\" property). Import from \"arkenv\" to use ArkType schemas.',\n\t\t\t},\n\t\t]);\n\t}\n}\n\n/**\n * Throws if `def` is not a plain object (i.e. not a valid schema map).\n * @internal\n */\nexport function assertStandardSchemaMap(\n\tdef: unknown,\n): asserts def is Record<string, unknown> {\n\tif (!def || typeof def !== \"object\" || Array.isArray(def)) {\n\t\tthrow new ArkEnvError([\n\t\t\t{\n\t\t\t\tpath: \"\",\n\t\t\t\tmessage:\n\t\t\t\t\t'Invalid schema: expected an object mapping in \"standard\" mode.',\n\t\t\t},\n\t\t]);\n\t}\n}\n","import type { StandardSchemaV1 } from \"@repo/types\";\nimport {\n\tapplyCoercion,\n\tfindCoercionPaths,\n\tstripEmptyStrings,\n} from \"./coercion/shared\";\nimport { ArkEnvError, type ValidationIssue } from \"./core\";\n\n/**\n * Configuration options for {@link parseStandard}.\n */\nexport type ParseStandardConfig = {\n\t/**\n\t * The environment variables to parse. Defaults to `process.env`\n\t */\n\tenv?: Record<string, string | undefined>;\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.\n\t *\n\t * - `delete` (ArkEnv default): Undeclared keys are allowed on input but stripped from the output.\n\t * - `ignore`: 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 */\n\tonUndeclaredKey?: \"ignore\" | \"delete\" | \"reject\";\n\t/**\n\t * Whether to perform best-effort coercion on the environment variables.\n\t * Coercion requires validators that implement the StandardJSONSchemaV1 spec\n\t * (e.g. Zod, Valibot).\n\t *\n\t * @see https://standard-schema.dev\n\t * @default true\n\t */\n\tcoerce?: boolean;\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\n\t/**\n\t * Whether to treat empty strings (`\"\"`) as `undefined` before validation.\n\t *\n\t * When enabled, an environment variable set to an empty value (e.g. `PORT=`)\n\t * will be treated as if it were missing, allowing defaults to apply and\n\t * preventing validation errors for numeric or boolean types.\n\t *\n\t * @default false\n\t */\n\temptyAsUndefined?: boolean;\n};\n\n/**\n * Extract JSON Schema definitions from standard schema validators.\n */\nfunction extractJsonSchema(\n\tdef: Record<string, unknown>,\n\tmissingJsonSchemaKeys: string[],\n): { jsonSchema: Record<string, any>; hasJsonSchema: boolean } {\n\tconst jsonSchema: Record<string, any> = { type: \"object\", properties: {} };\n\tlet hasJsonSchema = false;\n\n\tfor (const key in def) {\n\t\tconst validator = def[key] as any;\n\t\tif (!validator) {\n\t\t\tmissingJsonSchemaKeys.push(key);\n\t\t\tcontinue;\n\t\t}\n\n\t\t// 1. Standard way via ~standard property\n\t\tconst std = validator[\"~standard\"];\n\t\tif (typeof std?.jsonSchema?.input === \"function\") {\n\t\t\ttry {\n\t\t\t\tconst schema = std.jsonSchema.input({ target: \"draft-07\" });\n\t\t\t\tif (schema) {\n\t\t\t\t\tjsonSchema.properties[key] = schema;\n\t\t\t\t\thasJsonSchema = true;\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t} catch {}\n\t\t}\n\n\t\t// 2. Direct jsonSchema.input on validator\n\t\tif (typeof validator.jsonSchema?.input === \"function\") {\n\t\t\ttry {\n\t\t\t\tconst schema = validator.jsonSchema.input({ target: \"draft-07\" });\n\t\t\t\tif (schema) {\n\t\t\t\t\tjsonSchema.properties[key] = schema;\n\t\t\t\t\thasJsonSchema = true;\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t} catch {}\n\t\t}\n\n\t\t// 3. toJSONSchema method (e.g. zod mini, zod-to-json-schema)\n\t\tif (typeof validator.toJSONSchema === \"function\") {\n\t\t\ttry {\n\t\t\t\tconst schema = validator.toJSONSchema();\n\t\t\t\tif (schema) {\n\t\t\t\t\tjsonSchema.properties[key] = schema;\n\t\t\t\t\thasJsonSchema = true;\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t} catch {}\n\t\t}\n\n\t\t// 4. toStandardJSONSchema.v1 method (e.g. stnl)\n\t\tif (typeof validator.toStandardJSONSchema?.v1 === \"function\") {\n\t\t\ttry {\n\t\t\t\tconst schema = validator.toStandardJSONSchema.v1();\n\t\t\t\tif (schema) {\n\t\t\t\t\tjsonSchema.properties[key] = schema;\n\t\t\t\t\thasJsonSchema = true;\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t} catch {}\n\t\t}\n\n\t\tmissingJsonSchemaKeys.push(key);\n\t}\n\n\treturn { jsonSchema, hasJsonSchema };\n}\n\n/**\n * Format standard schema validation issue path.\n */\nfunction formatIssuePath(\n\tkey: string,\n\tpath:\n\t\t| readonly (\n\t\t\t\t| string\n\t\t\t\t| number\n\t\t\t\t| symbol\n\t\t\t\t| { readonly key: string | number | symbol }\n\t\t )[]\n\t\t| undefined,\n): string {\n\tif (!path || path.length === 0) return key;\n\n\tconst segments = path.map((segment) =>\n\t\tsegment !== null && typeof segment === \"object\" && \"key\" in segment\n\t\t\t? String(segment.key)\n\t\t\t: String(segment),\n\t);\n\treturn [key, ...segments].join(\".\");\n}\n\n/**\n * Parse and validate environment variables using Standard Schema 1.0 validators.\n *\n * @param def An object mapping environment variable keys to Standard Schema 1.0 validators\n * @param config Parsing options, including environment source, undeclared key handling, and coercion config\n * @returns The parsed and validated environment variables\n * @throws An ArkEnvError if validation fails\n */\nexport function parseStandard(\n\tdef: Record<string, unknown>,\n\tconfig: ParseStandardConfig,\n) {\n\tconst {\n\t\tenv = process.env,\n\t\tonUndeclaredKey = \"delete\",\n\t\tcoerce = true,\n\t\tarrayFormat = \"comma\",\n\t\temptyAsUndefined = false,\n\t} = config;\n\tconst output: Record<string, unknown> = {};\n\tconst errors: ValidationIssue[] = [];\n\n\tconst processedEnv = emptyAsUndefined\n\t\t? stripEmptyStrings(env as Record<string, string | undefined>)\n\t\t: env;\n\tconst envKeys = new Set(Object.keys(processedEnv));\n\n\tlet coercedEnv: Record<string, unknown> = { ...processedEnv };\n\tconst missingJsonSchemaKeys: string[] = [];\n\n\tif (coerce) {\n\t\tconst { jsonSchema, hasJsonSchema } = extractJsonSchema(\n\t\t\tdef,\n\t\t\tmissingJsonSchemaKeys,\n\t\t);\n\t\tif (hasJsonSchema) {\n\t\t\tcoercedEnv = applyCoercion(coercedEnv, findCoercionPaths(jsonSchema), {\n\t\t\t\tarrayFormat,\n\t\t\t}) as Record<string, unknown>;\n\t\t}\n\t}\n\n\t// 1. Validate declared keys\n\tfor (const key in def) {\n\t\tconst validator = def[key];\n\t\tconst value = coercedEnv[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 ArkEnvError([\n\t\t\t\t{\n\t\t\t\t\tpath: key,\n\t\t\t\t\tmessage: `Invalid schema: expected a Standard Schema 1.0 validator (e.g. Zod, Valibot) in 'standard' mode.`,\n\t\t\t\t},\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 ArkEnvError([\n\t\t\t\t{\n\t\t\t\t\tpath: key,\n\t\t\t\t\tmessage: \"Async validation is not supported. ArkEnv is synchronous.\",\n\t\t\t\t},\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\tconst issuePath = formatIssuePath(key, issue.path);\n\t\t\t\tlet message = issue.message;\n\n\t\t\t\tif (coerce && missingJsonSchemaKeys.includes(key)) {\n\t\t\t\t\tmessage += ` (Hint: coercion is enabled by default, but the validator for '${key}' lacks Standard JSON Schema support.)`;\n\t\t\t\t}\n\n\t\t\t\terrors.push({\n\t\t\t\t\tpath: issuePath,\n\t\t\t\t\tmessage,\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] = coercedEnv[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 type { StandardSchemaV1 } from \"@repo/types\";\nimport {\n\tassertNotArkTypeDsl,\n\tassertStandardSchema,\n\tassertStandardSchemaMap,\n} from \"./guards\";\nimport { type ParseStandardConfig, parseStandard } from \"./parse-standard\";\n\n/**\n * Configuration options for the `arkenv/standard` entry's `createEnv`.\n */\nexport type StandardEnvConfig = ParseStandardConfig;\n\n/**\n * Parse and validate environment variables using Standard Schema 1.0 validators (e.g. Zod, Valibot).\n *\n * This entry is ArkType-free - ArkType is never imported, even transitively.\n * Use this when your project must not depend on ArkType.\n *\n * @param def An object mapping variable names to Standard Schema validators\n * @param config Optional configuration\n * @returns The validated environment variables\n * @throws An {@link ArkEnvError} if validation fails\n *\n * @example\n * ```ts\n * import arkenv from \"arkenv/standard\";\n * import { z } from \"zod\";\n *\n * const env = arkenv({\n * PORT: z.coerce.number(),\n * HOST: z.string(),\n * });\n * ```\n */\nexport function createEnv<const T extends Record<string, StandardSchemaV1>>(\n\tdef: T,\n\tconfig?: StandardEnvConfig,\n): { [K in keyof T]: StandardSchemaV1.InferOutput<T[K]> } {\n\tassertStandardSchemaMap(def);\n\n\tfor (const key in def) {\n\t\tconst validator = (def as Record<string, unknown>)[key];\n\t\tassertNotArkTypeDsl(key, validator);\n\t\tassertStandardSchema(key, validator);\n\t}\n\n\treturn parseStandard(def as Record<string, unknown>, config ?? {}) as {\n\t\t[K in keyof T]: StandardSchemaV1.InferOutput<T[K]>;\n\t};\n}\n\n/**\n * ArkEnv's Standard Schema 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":"gGAMA,SAAgB,EAAoB,EAAa,EAAsB,CACtE,GAAI,OAAO,GAAU,SACpB,MAAM,IAAI,EAAY,CACrB,CACC,KAAM,EACN,QACC,8JACD,CACD,CAAC,CASJ,SAAgB,EAAqB,EAAa,EAAsB,CACvE,IAAM,EACL,GACA,OAAO,GAAU,UACjB,cAAe,GACd,EAAkC,aAEpC,GACC,CAAC,GACD,OAAO,GAAQ,UACf,EAAE,aAAc,IAChB,OAAQ,EAAgC,UAAa,WAErD,MAAM,IAAI,EAAY,CACrB,CACC,KAAM,EACN,QACC,6IACD,CACD,CAAC,CAQJ,SAAgB,EACf,EACyC,CACzC,GAAI,CAAC,GAAO,OAAO,GAAQ,UAAY,MAAM,QAAQ,EAAI,CACxD,MAAM,IAAI,EAAY,CACrB,CACC,KAAM,GACN,QACC,iEACD,CACD,CAAC,CCGJ,SAAS,EACR,EACA,EAC8D,CAC9D,IAAM,EAAkC,CAAE,KAAM,SAAU,WAAY,EAAE,CAAE,CACtE,EAAgB,GAEpB,IAAK,IAAM,KAAO,EAAK,CACtB,IAAM,EAAY,EAAI,GACtB,GAAI,CAAC,EAAW,CACf,EAAsB,KAAK,EAAI,CAC/B,SAID,IAAM,EAAM,EAAU,aACtB,GAAI,OAAO,GAAK,YAAY,OAAU,WACrC,GAAI,CACH,IAAM,EAAS,EAAI,WAAW,MAAM,CAAE,OAAQ,WAAY,CAAC,CAC3D,GAAI,EAAQ,CACX,EAAW,WAAW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,EAAK,CACtB,IAAM,EAAY,EAAI,GAChB,EAAQ,EAAW,GAGzB,GACC,CAAC,GACD,OAAO,GAAc,UACrB,EAAE,cAAe,GAEjB,MAAM,IAAI,EAAY,CACrB,CACC,KAAM,EACN,QAAS,mGACT,CACD,CAAC,CAGH,IAAM,EAAU,EAA+B,aAAa,SAAS,EAAM,CAE3E,GAAI,aAAkB,QACrB,MAAM,IAAI,EAAY,CACrB,CACC,KAAM,EACN,QAAS,4DACT,CACD,CAAC,CAGH,GAAI,EAAO,OACV,IAAK,IAAM,KAAS,EAAO,OAAQ,CAClC,IAAM,EAAY,EAAgB,EAAK,EAAM,KAAK,CAC9C,EAAU,EAAM,QAEhB,GAAU,EAAsB,SAAS,EAAI,GAChD,GAAW,kEAAkE,EAAI,yCAGlF,EAAO,KAAK,CACX,KAAM,EACN,UACA,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,EAAW,IAK5B,GAAI,EAAO,OAAS,EACnB,MAAM,IAAI,EAAY,EAAO,CAG9B,OAAO,ECxOR,SAAgB,EACf,EACA,EACyD,CACzD,EAAwB,EAAI,CAE5B,IAAK,IAAM,KAAO,EAAK,CACtB,IAAM,EAAa,EAAgC,GACnD,EAAoB,EAAK,EAAU,CACnC,EAAqB,EAAK,EAAU,CAGrC,OAAO,EAAc,EAAgC,GAAU,EAAE,CAAC,CAUnE,MAAM,EAAS"}
1
+ {"version":3,"file":"standard.mjs","names":[],"sources":["../src/guards.ts","../src/parse-standard.ts","../src/standard.ts"],"sourcesContent":["import { ArkEnvError } from \"./core\";\n\n/**\n * Throws if the given value is a string (ArkType DSL) in standard mode.\n * @internal\n */\nexport function assertNotArkTypeDsl(key: string, value: unknown): void {\n\tif (typeof value === \"string\") {\n\t\tthrow new ArkEnvError([\n\t\t\t{\n\t\t\t\tpath: key,\n\t\t\t\tmessage:\n\t\t\t\t\t'ArkType DSL strings are not supported in \"standard\" mode. Use a Standard Schema validator (e.g., Zod, Valibot) or import from \"arkenv\" for ArkType schemas.',\n\t\t\t},\n\t\t]);\n\t}\n}\n\n/**\n * Throws if the given value is not a well-formed Standard Schema validator\n * (must have a `~standard` property whose `validate` field is a function).\n * @internal\n */\nexport function assertStandardSchema(key: string, value: unknown): void {\n\tconst std =\n\t\tvalue &&\n\t\ttypeof value === \"object\" &&\n\t\t\"~standard\" in value &&\n\t\t(value as Record<string, unknown>)[\"~standard\"];\n\n\tif (\n\t\t!std ||\n\t\ttypeof std !== \"object\" ||\n\t\t!(\"validate\" in std) ||\n\t\ttypeof (std as Record<string, unknown>).validate !== \"function\"\n\t) {\n\t\tthrow new ArkEnvError([\n\t\t\t{\n\t\t\t\tpath: key,\n\t\t\t\tmessage:\n\t\t\t\t\t'Invalid validator: expected a Standard Schema 1.0 validator (must have \"~standard\" property). Import from \"arkenv\" to use ArkType schemas.',\n\t\t\t},\n\t\t]);\n\t}\n}\n\n/**\n * Throws if `def` is not a plain object (i.e. not a valid schema map).\n * @internal\n */\nexport function assertStandardSchemaMap(\n\tdef: unknown,\n): asserts def is Record<string, unknown> {\n\tif (!def || typeof def !== \"object\" || Array.isArray(def)) {\n\t\tthrow new ArkEnvError([\n\t\t\t{\n\t\t\t\tpath: \"\",\n\t\t\t\tmessage:\n\t\t\t\t\t'Invalid schema: expected an object mapping in \"standard\" mode.',\n\t\t\t},\n\t\t]);\n\t}\n}\n","import type { Dict, StandardSchemaV1 } from \"@repo/types\";\nimport {\n\tapplyCoercion,\n\tfindCoercionPaths,\n\tstripEmptyStrings,\n} from \"./coercion/shared\";\nimport { ArkEnvError, type ValidationIssue } from \"./core\";\n\n/**\n * Configuration options for {@link parseStandard}.\n */\nexport type ParseStandardConfig = {\n\t/**\n\t * The environment variables to parse. Defaults to `process.env`\n\t */\n\tenv?: Dict<string>;\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.\n\t *\n\t * - `delete` (ArkEnv default): Undeclared keys are allowed on input but stripped from the output.\n\t * - `ignore`: 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 */\n\tonUndeclaredKey?: \"ignore\" | \"delete\" | \"reject\";\n\t/**\n\t * Whether to perform best-effort coercion on the environment variables.\n\t * Coercion requires validators that implement the StandardJSONSchemaV1 spec\n\t * (e.g. Zod, Valibot).\n\t *\n\t * @see https://standard-schema.dev\n\t * @default true\n\t */\n\tcoerce?: boolean;\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\n\t/**\n\t * Whether to treat empty strings (`\"\"`) as `undefined` before validation.\n\t *\n\t * When enabled, an environment variable set to an empty value (e.g. `PORT=`)\n\t * will be treated as if it were missing, allowing defaults to apply and\n\t * preventing validation errors for numeric or boolean types.\n\t *\n\t * @default false\n\t */\n\temptyAsUndefined?: boolean;\n};\n\n/**\n * Extract JSON Schema definitions from standard schema validators.\n */\nfunction extractJsonSchema(\n\tdef: Record<string, unknown>,\n\tmissingJsonSchemaKeys: string[],\n): { jsonSchema: Record<string, any>; hasJsonSchema: boolean } {\n\tconst jsonSchema: Record<string, any> = { type: \"object\", properties: {} };\n\tlet hasJsonSchema = false;\n\n\tfor (const key in def) {\n\t\tconst validator = def[key] as any;\n\t\tif (!validator) {\n\t\t\tmissingJsonSchemaKeys.push(key);\n\t\t\tcontinue;\n\t\t}\n\n\t\t// 1. Standard way via ~standard property\n\t\tconst std = validator[\"~standard\"];\n\t\tif (typeof std?.jsonSchema?.input === \"function\") {\n\t\t\ttry {\n\t\t\t\tconst schema = std.jsonSchema.input({ target: \"draft-07\" });\n\t\t\t\tif (schema) {\n\t\t\t\t\tjsonSchema.properties[key] = schema;\n\t\t\t\t\thasJsonSchema = true;\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t} catch {}\n\t\t}\n\n\t\t// 2. Direct jsonSchema.input on validator\n\t\tif (typeof validator.jsonSchema?.input === \"function\") {\n\t\t\ttry {\n\t\t\t\tconst schema = validator.jsonSchema.input({ target: \"draft-07\" });\n\t\t\t\tif (schema) {\n\t\t\t\t\tjsonSchema.properties[key] = schema;\n\t\t\t\t\thasJsonSchema = true;\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t} catch {}\n\t\t}\n\n\t\t// 3. toJSONSchema method (e.g. zod mini, zod-to-json-schema)\n\t\tif (typeof validator.toJSONSchema === \"function\") {\n\t\t\ttry {\n\t\t\t\tconst schema = validator.toJSONSchema();\n\t\t\t\tif (schema) {\n\t\t\t\t\tjsonSchema.properties[key] = schema;\n\t\t\t\t\thasJsonSchema = true;\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t} catch {}\n\t\t}\n\n\t\t// 4. toStandardJSONSchema.v1 method (e.g. stnl)\n\t\tif (typeof validator.toStandardJSONSchema?.v1 === \"function\") {\n\t\t\ttry {\n\t\t\t\tconst schema = validator.toStandardJSONSchema.v1();\n\t\t\t\tif (schema) {\n\t\t\t\t\tjsonSchema.properties[key] = schema;\n\t\t\t\t\thasJsonSchema = true;\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t} catch {}\n\t\t}\n\n\t\tmissingJsonSchemaKeys.push(key);\n\t}\n\n\treturn { jsonSchema, hasJsonSchema };\n}\n\n/**\n * Format standard schema validation issue path.\n */\nfunction formatIssuePath(\n\tkey: string,\n\tpath:\n\t\t| readonly (\n\t\t\t\t| string\n\t\t\t\t| number\n\t\t\t\t| symbol\n\t\t\t\t| { readonly key: string | number | symbol }\n\t\t )[]\n\t\t| undefined,\n): string {\n\tif (!path || path.length === 0) return key;\n\n\tconst segments = path.map((segment) =>\n\t\tsegment !== null && typeof segment === \"object\" && \"key\" in segment\n\t\t\t? String(segment.key)\n\t\t\t: String(segment),\n\t);\n\treturn [key, ...segments].join(\".\");\n}\n\n/**\n * Parse and validate environment variables using Standard Schema 1.0 validators.\n *\n * @param def An object mapping environment variable keys to Standard Schema 1.0 validators\n * @param config Parsing options, including environment source, undeclared key handling, and coercion config\n * @returns The parsed and validated environment variables\n * @throws An ArkEnvError if validation fails\n */\nexport function parseStandard(\n\tdef: Record<string, unknown>,\n\tconfig: ParseStandardConfig,\n) {\n\tconst {\n\t\tenv = process.env,\n\t\tonUndeclaredKey = \"delete\",\n\t\tcoerce = true,\n\t\tarrayFormat = \"comma\",\n\t\temptyAsUndefined = false,\n\t} = config;\n\tconst output: Record<string, unknown> = {};\n\tconst errors: ValidationIssue[] = [];\n\n\tconst processedEnv = emptyAsUndefined\n\t\t? stripEmptyStrings(env as Dict<string>)\n\t\t: env;\n\tconst envKeys = new Set(Object.keys(processedEnv));\n\n\tlet coercedEnv: Record<string, unknown> = { ...processedEnv };\n\tconst missingJsonSchemaKeys: string[] = [];\n\n\tif (coerce) {\n\t\tconst { jsonSchema, hasJsonSchema } = extractJsonSchema(\n\t\t\tdef,\n\t\t\tmissingJsonSchemaKeys,\n\t\t);\n\t\tif (hasJsonSchema) {\n\t\t\tcoercedEnv = applyCoercion(coercedEnv, findCoercionPaths(jsonSchema), {\n\t\t\t\tarrayFormat,\n\t\t\t}) as Record<string, unknown>;\n\t\t}\n\t}\n\n\t// 1. Validate declared keys\n\tfor (const key in def) {\n\t\tconst validator = def[key];\n\t\tconst value = coercedEnv[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 ArkEnvError([\n\t\t\t\t{\n\t\t\t\t\tpath: key,\n\t\t\t\t\tmessage: `Invalid schema: expected a Standard Schema 1.0 validator (e.g. Zod, Valibot) in 'standard' mode.`,\n\t\t\t\t},\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 ArkEnvError([\n\t\t\t\t{\n\t\t\t\t\tpath: key,\n\t\t\t\t\tmessage: \"Async validation is not supported. ArkEnv is synchronous.\",\n\t\t\t\t},\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\tconst issuePath = formatIssuePath(key, issue.path);\n\t\t\t\tlet message = issue.message;\n\n\t\t\t\tif (coerce && missingJsonSchemaKeys.includes(key)) {\n\t\t\t\t\tmessage += ` (Hint: coercion is enabled by default, but the validator for '${key}' lacks Standard JSON Schema support.)`;\n\t\t\t\t}\n\n\t\t\t\terrors.push({\n\t\t\t\t\tpath: issuePath,\n\t\t\t\t\tmessage,\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] = coercedEnv[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 type { StandardSchemaV1 } from \"@repo/types\";\nimport {\n\tassertNotArkTypeDsl,\n\tassertStandardSchema,\n\tassertStandardSchemaMap,\n} from \"./guards\";\nimport { type ParseStandardConfig, parseStandard } from \"./parse-standard\";\n\n/**\n * Configuration options for the `arkenv/standard` entry's `createEnv`.\n */\nexport type StandardEnvConfig = ParseStandardConfig;\n\n/**\n * Parse and validate environment variables using Standard Schema 1.0 validators (e.g. Zod, Valibot).\n *\n * This entry is ArkType-free - ArkType is never imported, even transitively.\n * Use this when your project must not depend on ArkType.\n *\n * @param def An object mapping variable names to Standard Schema validators\n * @param config Optional configuration\n * @returns The validated environment variables\n * @throws An {@link ArkEnvError} if validation fails\n *\n * @example\n * ```ts\n * import arkenv from \"arkenv/standard\";\n * import { z } from \"zod\";\n *\n * const env = arkenv({\n * PORT: z.coerce.number(),\n * HOST: z.string(),\n * });\n * ```\n */\nexport function createEnv<const T extends Record<string, StandardSchemaV1>>(\n\tdef: T,\n\tconfig?: StandardEnvConfig,\n): { [K in keyof T]: StandardSchemaV1.InferOutput<T[K]> } {\n\tassertStandardSchemaMap(def);\n\n\tfor (const key in def) {\n\t\tconst validator = (def as Record<string, unknown>)[key];\n\t\tassertNotArkTypeDsl(key, validator);\n\t\tassertStandardSchema(key, validator);\n\t}\n\n\treturn parseStandard(def as Record<string, unknown>, config ?? {}) as {\n\t\t[K in keyof T]: StandardSchemaV1.InferOutput<T[K]>;\n\t};\n}\n\n/**\n * ArkEnv's Standard Schema 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":"gGAMA,SAAgB,EAAoB,EAAa,EAAsB,CACtE,GAAI,OAAO,GAAU,SACpB,MAAM,IAAI,EAAY,CACrB,CACC,KAAM,EACN,QACC,8JACD,CACD,CAAC,CASJ,SAAgB,EAAqB,EAAa,EAAsB,CACvE,IAAM,EACL,GACA,OAAO,GAAU,UACjB,cAAe,GACd,EAAkC,aAEpC,GACC,CAAC,GACD,OAAO,GAAQ,UACf,EAAE,aAAc,IAChB,OAAQ,EAAgC,UAAa,WAErD,MAAM,IAAI,EAAY,CACrB,CACC,KAAM,EACN,QACC,6IACD,CACD,CAAC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B,EAAO,GAAO,EAAW,IAK5B,GAAI,EAAO,OAAS,EACnB,MAAM,IAAI,EAAY,EAAO,CAG9B,OAAO,ECxOR,SAAgB,EACf,EACA,EACyD,CACzD,EAAwB,EAAI,CAE5B,IAAK,IAAM,KAAO,EAAK,CACtB,IAAM,EAAa,EAAgC,GACnD,EAAoB,EAAK,EAAU,CACnC,EAAqB,EAAK,EAAU,CAGrC,OAAO,EAAc,EAAgC,GAAU,EAAE,CAAC,CAUnE,MAAM,EAAS"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "arkenv",
3
3
  "type": "module",
4
- "version": "0.12.1",
4
+ "version": "0.12.2",
5
5
  "description": "Typesafe environment variables parsing and validation with ArkType",
6
6
  "main": "./dist/index.cjs",
7
7
  "module": "./dist/index.mjs",
@@ -78,7 +78,7 @@
78
78
  {
79
79
  "name": "arkenv",
80
80
  "path": "dist/index.mjs",
81
- "limit": "2 kB",
81
+ "limit": "2.1 kB",
82
82
  "import": "*",
83
83
  "ignore": [
84
84
  "arktype"
@@ -1 +0,0 @@
1
- {"version":3,"file":"index-Br22fqkz.d.mts","names":["_$arktype","_$arktype_internal_keywords_string_ts0","_$arktype_internal_attributes_ts0","$","trim","To","Submodule","normalize","capitalize","stringDate","stringInteger","ip","stringJson","lower","stringNumeric","url","uuid","Scope","string","In","root","alpha","alphanumeric","hex","base64","creditCard","date","digits","email","integer","json","numeric","regex","semver","upper","preformatted","host","number","NaN","Infinity","epoch","safe","NegativeInfinity","port","Dict","T","Record","StandardTypedV1","Input","Output","Props","Schema","Types","NonNullable","version","vendor","types","input","output","InferInput","InferOutput","StandardSchemaV1","Options","Result","Promise","SuccessResult","FailureResult","Record","Issue","ReadonlyArray","PropertyKey","PathSegment","validate","value","options","issues","libraryOptions","message","path","key","StandardJSONSchemaV1","Converter","Target","jsonSchema","target","type","StandardSchemaV1","InferType","T","Record","errors","Any","_Input","Output","value","R","t","U","_Scope","$","Type","SchemaShape","Record","CompiledEnvSchema"],"sources":["../../internal/scope/dist/index.d.ts","../../internal/types/dist/helpers.d.ts","../../internal/types/dist/standard-schema.d.ts","../../internal/types/dist/infer-type.d.ts","../../internal/types/dist/schema.d.ts"],"mappings":";;;;;;;;AAEoF;;;;cAQtEG,CAAAA,EAAGH,SAAAA,CAAUiB,KAAAA;EACzBC,MAAAA,EAAQlB,SAAAA,CAAUM,SAAAA;IAChBF,IAAAA,EAAMJ,SAAAA,CAAUM,SAAAA,CAAUL,sCAAAA,CAAuCG,IAAAA,CAAKD,CAAAA;MACpE,cAAA,GAAiBgB,EAAAA,aAAejB,iCAAAA,CAAkCG,EAAAA;IAAAA;IAEpEE,SAAAA,EAAWP,SAAAA,CAAUM,SAAAA,CAAUL,sCAAAA,CAAuCM,SAAAA,CAAUJ,CAAAA;MAC9E,cAAA,GAAiBgB,EAAAA,aAAejB,iCAAAA,CAAkCG,EAAAA;IAAAA;IAEpEe,IAAAA;IACAC,KAAAA;IACAC,YAAAA;IACAC,GAAAA;IACAC,MAAAA,EAAQxB,SAAAA,CAAUM,SAAAA;MAChBc,IAAAA;MACAL,GAAAA;IAAAA;MAEA,cAAA;IAAA;IAEFP,UAAAA,EAAYR,SAAAA,CAAUM,SAAAA,CAAUL,sCAAAA,CAAuCO,UAAAA,CAAWL,CAAAA;MAChF,cAAA,GAAiBgB,EAAAA,aAAejB,iCAAAA,CAAkCG,EAAAA;IAAAA;IAEpEoB,UAAAA;IACAC,IAAAA,EAAM1B,SAAAA,CAAUM,SAAAA,CAAUL,sCAAAA,CAAuCQ,UAAAA,CAAWN,CAAAA;MAC1E,cAAA;IAAA;IAEFwB,MAAAA;IACAC,KAAAA;IACAC,OAAAA,EAAS7B,SAAAA,CAAUM,SAAAA,CAAUL,sCAAAA,CAAuCS,aAAAA,CAAcP,CAAAA;MAChF,cAAA;IAAA;IAEFQ,EAAAA,EAAIX,SAAAA,CAAUM,SAAAA,CAAUL,sCAAAA,CAAuCU,EAAAA,CAAGR,CAAAA;MAChE,c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al_keywords_string_ts0","_$arktype_internal_attributes_ts0","$","trim","To","Submodule","normalize","capitalize","stringDate","stringInteger","ip","stringJson","lower","stringNumeric","url","uuid","Scope","string","In","root","alpha","alphanumeric","hex","base64","creditCard","date","digits","email","integer","json","numeric","regex","semver","upper","preformatted","host","number","NaN","Infinity","epoch","safe","NegativeInfinity","port","Dict","T","Record","StandardTypedV1","Input","Output","Props","Schema","Types","NonNullable","version","vendor","types","input","output","InferInput","InferOutput","StandardSchemaV1","Options","Result","Promise","SuccessResult","FailureResult","Record","Issue","ReadonlyArray","PropertyKey","PathSegment","validate","value","options","issues","libraryOptions","message","path","key","StandardJSONSchemaV1","Converter","Target","jsonSchema","target","type","StandardSchemaV1","InferType","T","Record","errors","Any","_Input","Output","value","R","t","U","_Scope","$","Type","SchemaShape","Record","CompiledEnvSchema"],"sources":["../../internal/scope/dist/index.d.ts","../../internal/types/dist/helpers.d.ts","../../internal/types/dist/standard-schema.d.ts","../../internal/types/dist/infer-type.d.ts","../../internal/types/dist/schema.d.ts"],"mappings":";;;;;;;;AAEoF;;;;cAQtEG,CAAAA,EAAGH,SAAAA,CAAUiB,KAAAA;EACzBC,MAAAA,EAAQlB,SAAAA,CAAUM,SAAAA;IAChBF,IAAAA,EAAMJ,SAAAA,CAAUM,SAAAA,CAAUL,sCAAAA,CAAuCG,IAAAA,CAAKD,CAAAA;MACpE,cAAA,GAAiBgB,EAAAA,aAAejB,iCAAAA,CAAkCG,EAAAA;IAAAA;IAEpEE,SAAAA,EAAWP,SAAAA,CAAUM,SAAAA,CAAUL,sCAAAA,CAAuCM,SAAAA,CAAUJ,CAAAA;MAC9E,cAAA,GAAiBgB,EAAAA,aAAejB,iCAAAA,CAAkCG,EAAAA;IAAAA;IAEpEe,IAAAA;IACAC,KAAAA;IACAC,YAAAA;IACAC,GAAAA;IACAC,MAAAA,EAAQxB,SAAAA,CAAUM,SAAAA;MAChBc,IAAAA;MACAL,GAAAA;IAAAA;MAEA,cAAA;IAAA;IAEFP,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AA,CAAYT,MAAAA;AAAAA;;;;;;;AF9EC;;;;;KGSxEoC,SAAAA,MAAeC,CAAAA,SAAUF,gBAAAA,+BAA+CO,MAAAA,GAASL,CAAAA,WAAWM,KAAAA,EAAOL,MAAAA,4CAAiDM,CAAAA,SAAUV,IAAAA,CAAKK,MAAAA,WAAiBK,CAAAA,GAAIP,CAAAA;EAChMQ,CAAAA;AAAAA,IACAC,CAAAA,GAAIT,CAAAA,SAAUH,IAAAA,CAAKM,GAAAA,0BAA6BM,CAAAA;;;KCXxCI,WAAAA,GAAcC,MAAAA;;;;AJA0D;;;;;;;;;KIaxEC,iBAAAA,GAAoBH,IAAAA,CAAKC,WAAAA,EAAaF,CAAAA"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"shared-CTq6rhd_.mjs","names":[],"sources":["../src/coercion/morphs.ts","../src/coercion/shared.ts"],"sourcesContent":["/**\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\" || !s.trim()) return s;\n\tif (s.trim() === \"NaN\") return Number.NaN;\n\tconst n = Number(s);\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[0] !== \"{\" && trimmed[0] !== \"[\") return s;\n\ttry {\n\t\treturn JSON.parse(trimmed);\n\t} catch {\n\t\treturn s;\n\t}\n};\n\n/**\n * Attempt to coerce a value to a Date.\n *\n * If the input is already a Date, returns it unchanged.\n * If the input is a valid date string, returns a Date object.\n * Otherwise, returns the original value unchanged.\n *\n * @internal\n * @param s - The value to coerce\n * @returns The coerced Date or the original value\n */\nexport const coerceDate = (s: unknown) => {\n\tif (s instanceof Date) return s;\n\tif (typeof s !== \"string\" || !s.trim()) return s;\n\tconst d = new Date(s);\n\treturn Number.isNaN(d.getTime()) ? s : d;\n};\n","import { coerceBoolean, coerceDate, coerceJson, coerceNumber } from \"./morphs\";\n\n/**\n * Remove keys with empty string values from an environment record.\n *\n * When a key is set to `\"\"` (e.g. `PORT=` in a `.env` file), deleting it\n * allows the validator to treat it as missing so that defaults apply.\n *\n * @param env The environment variables record\n * @returns A new record with empty string keys removed\n */\nexport const stripEmptyStrings = (\n\tenv: Record<string, string | undefined>,\n): Record<string, string | undefined> => {\n\tconst result: Record<string, string | undefined> = {};\n\tfor (const key in env) {\n\t\tconst value = env[key];\n\t\tif (value !== \"\") {\n\t\t\tresult[key] = value;\n\t\t}\n\t}\n\treturn result;\n};\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 */\nexport const ARRAY_ITEM_MARKER = \"*\";\n\n/**\n * @internal\n * Information about a path in the schema that requires coercion.\n */\nexport type CoercionTarget = {\n\tpath: string[];\n\ttype: \"primitive\" | \"array\" | \"object\" | \"date\";\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 * Find all paths in a JSON Schema that require coercion.\n *\n * Prioritize \"number\", \"integer\", \"boolean\", \"array\", \"object\", and \"date\" types.\n *\n * @param node The JSON Schema node to traverse\n * @param path The current path segments in the schema tree\n * @returns An array of coercion targets containing their path and type\n */\nexport const findCoercionPaths = (\n\tnode: Record<string, any>,\n\tpath: string[] = [],\n): CoercionTarget[] => {\n\tconst results: CoercionTarget[] = [];\n\tif (!node || typeof node !== \"object\") return results;\n\n\tif (\"const\" in node) {\n\t\tconst t = typeof node.const;\n\t\tif (t === \"number\" || t === \"boolean\") {\n\t\t\tresults.push({ path: [...path], type: \"primitive\" });\n\t\t}\n\t}\n\n\tif (\"enum\" in node && Array.isArray(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\tconst type = node.type;\n\tif (type === \"number\" || type === \"integer\" || type === \"boolean\") {\n\t\tresults.push({ path: [...path], type: \"primitive\" });\n\t} else if (\n\t\ttype === \"string\" &&\n\t\t\"format\" in node &&\n\t\t(node.format === \"date-time\" || node.format === \"date\")\n\t) {\n\t\tresults.push({ path: [...path], type: \"date\" });\n\t} else if (type === \"object\") {\n\t\tif (node.properties && Object.keys(node.properties).length > 0) {\n\t\t\tresults.push({ path: [...path], type: \"object\" });\n\t\t\tfor (const key in node.properties) {\n\t\t\t\tresults.push(\n\t\t\t\t\t...findCoercionPaths(node.properties[key], [...path, key]),\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t} else if (type === \"array\") {\n\t\tresults.push({ path: [...path], type: \"array\" });\n\t\tif (node.items) {\n\t\t\tif (Array.isArray(node.items)) {\n\t\t\t\tnode.items.forEach((item, index) => {\n\t\t\t\t\tresults.push(...findCoercionPaths(item, [...path, String(index)]));\n\t\t\t\t});\n\t\t\t} else {\n\t\t\t\tresults.push(\n\t\t\t\t\t...findCoercionPaths(node.items, [...path, ARRAY_ITEM_MARKER]),\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t}\n\n\tfor (const comb of [\"anyOf\", \"allOf\", \"oneOf\"]) {\n\t\tif (comb in node && Array.isArray(node[comb])) {\n\t\t\tfor (const branch of node[comb]) {\n\t\t\t\tresults.push(...findCoercionPaths(branch, path));\n\t\t\t}\n\t\t}\n\t}\n\n\tconst seen = new Set<string>();\n\treturn results.filter((t) => {\n\t\tconst key = t.path.join(\"/\") + \":\" + t.type;\n\t\treturn seen.has(key) ? false : seen.add(key);\n\t});\n};\n\n/**\n * Apply coercion to a data object based on identified paths.\n *\n * @param data The input environment data object to coerce\n * @param targets The coercion targets mapping paths to types\n * @param options The coercion options, including array parsing format\n * @returns The coerced data object\n */\nexport const applyCoercion = (\n\tdata: unknown,\n\ttargets: CoercionTarget[],\n\toptions: CoerceOptions = {},\n) => {\n\tconst { arrayFormat = \"comma\" } = options;\n\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\t\treturn val.trim() ? val.split(\",\").map((s) => s.trim()) : [];\n\t};\n\n\tconst coerceValue = (val: unknown, type: CoercionTarget[\"type\"]): unknown => {\n\t\tif (type === \"array\" && typeof val === \"string\") {\n\t\t\treturn splitString(val);\n\t\t}\n\t\tif (type === \"object\" && typeof val === \"string\") {\n\t\t\treturn coerceJson(val);\n\t\t}\n\t\tif (type === \"date\" && typeof val === \"string\") {\n\t\t\treturn coerceDate(val);\n\t\t}\n\t\tif (type === \"primitive\") {\n\t\t\tif (Array.isArray(val)) {\n\t\t\t\tfor (let i = 0; i < val.length; i++) {\n\t\t\t\t\tconst n = coerceNumber(val[i]);\n\t\t\t\t\tval[i] = typeof n === \"number\" ? n : coerceBoolean(val[i]);\n\t\t\t\t}\n\t\t\t\treturn val;\n\t\t\t}\n\t\t\tconst n = coerceNumber(val);\n\t\t\treturn typeof n === \"number\" ? n : coerceBoolean(val);\n\t\t}\n\t\treturn val;\n\t};\n\n\tif (typeof data !== \"object\" || data === null) {\n\t\tconst root = targets.find((t) => t.path.length === 0);\n\t\tif (root) {\n\t\t\treturn coerceValue(data, root.type);\n\t\t}\n\t\treturn data;\n\t}\n\n\tconst sorted = [...targets].sort((a, b) => a.path.length - b.path.length);\n\n\tconst walk = (current: any, path: string[], type: CoercionTarget[\"type\"]) => {\n\t\tif (!current || typeof current !== \"object\" || path.length === 0) return;\n\n\t\tconst [key, ...rest] = path;\n\n\t\tif (rest.length === 0) {\n\t\t\tif (key === 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\tcurrent[i] = coerceValue(current[i], type);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\t// biome-ignore lint/suspicious/noPrototypeBuiltins: Object.hasOwn is not supported under current tsconfig lib settings\n\t\t\t\tif (Object.prototype.hasOwnProperty.call(current, key)) {\n\t\t\t\t\tcurrent[key] = coerceValue(current[key], type);\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\n\t\tif (key === ARRAY_ITEM_MARKER) {\n\t\t\tif (Array.isArray(current)) {\n\t\t\t\tfor (const item of current) walk(item, rest, type);\n\t\t\t}\n\t\t} else {\n\t\t\twalk(current[key], rest, type);\n\t\t}\n\t};\n\n\tfor (const t of sorted) {\n\t\twalk(data, t.path, t.type);\n\t}\n\treturn data;\n};\n"],"mappings":"AAWA,MAAa,EAAgB,GAAe,CAE3C,GADI,OAAO,GAAM,UACb,OAAO,GAAM,UAAY,CAAC,EAAE,MAAM,CAAE,OAAO,EAC/C,GAAI,EAAE,MAAM,GAAK,MAAO,MAAO,KAC/B,IAAM,EAAI,OAAO,EAAE,CACnB,OAAO,OAAO,MAAM,EAAE,CAAG,EAAI,GAajB,EAAiB,GACzB,IAAM,OAAe,GACrB,IAAM,QAAgB,GACnB,EAaK,EAAc,GAAe,CACzC,GAAI,OAAO,GAAM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