arkenv 0.11.1 → 0.12.0

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.
@@ -1 +1 @@
1
- {"version":3,"file":"core-B51xxxje.mjs","names":[],"sources":["../src/utils/indent.ts","../src/utils/style-text.ts","../src/core.ts"],"sourcesContent":["/**\n * Options for the `indent` function\n */\ntype IndentOptions = {\n\t/**\n\t * Whether to detect newlines and indent each line individually, defaults to false (indenting the whole string)\n\t */\n\tdontDetectNewlines?: boolean;\n};\n\n/**\n * Indent a string by a given amount\n * @param str - The string to indent\n * @param amt - The amount to indent by, defaults to 2\n * @param options - {@link IndentOptions}\n * @returns The indented string\n */\nexport const indent = (\n\tstr: string,\n\tamt = 2,\n\t{ dontDetectNewlines = false }: IndentOptions = {},\n) => {\n\tconst detectNewlines = !dontDetectNewlines;\n\tif (detectNewlines) {\n\t\treturn str\n\t\t\t.split(\"\\n\")\n\t\t\t.map((line) => `${\" \".repeat(amt)}${line}`)\n\t\t\t.join(\"\\n\");\n\t}\n\n\treturn `${\" \".repeat(amt)}${str}`;\n};\n","/**\n * Cross-platform text styling utility\n * Uses ANSI colors in Node environments, plain text in browsers\n * Respects NO_COLOR, CI environment variables, and TTY detection\n */\n\n// ANSI color codes for Node environments\nconst colors = {\n\tred: \"\\x1b[31m\",\n\tyellow: \"\\x1b[33m\",\n\tcyan: \"\\x1b[36m\",\n\treset: \"\\x1b[0m\",\n} as const;\n\n/**\n * Check if we're in a Node environment (not browser)\n * Checked dynamically to allow for testing with mocked globals\n */\nconst isNode = (): boolean =>\n\ttypeof process !== \"undefined\" &&\n\tprocess.versions != null &&\n\tprocess.versions.node != null;\n\n/**\n * Check if colors should be disabled based on environment\n * Respects NO_COLOR, CI environment variables, and TTY detection\n */\nconst shouldDisableColors = (): boolean => {\n\tif (!isNode()) return true;\n\n\t// Respect NO_COLOR environment variable (https://no-color.org/)\n\tif (process.env.NO_COLOR !== undefined) return true;\n\n\t// Disable colors in CI environments by default\n\tif (process.env.CI !== undefined) return true;\n\n\t// Disable colors if not writing to a TTY\n\tif (process.stdout && !process.stdout.isTTY) return true;\n\n\treturn false;\n};\n\n/**\n * Style text with color. Uses ANSI codes in Node, plain text in browsers.\n * @param color - The color to apply\n * @param text - The text to style\n * @returns Styled text in Node (if colors enabled), plain text otherwise\n */\nexport const styleText = (\n\tcolor: \"red\" | \"yellow\" | \"cyan\",\n\ttext: string,\n): string => {\n\t// Use ANSI colors only in Node environments with colors enabled\n\tif (isNode() && !shouldDisableColors()) {\n\t\treturn `${colors[color]}${text}${colors.reset}`;\n\t}\n\t// Fall back to plain text in browsers or when colors are disabled\n\treturn text;\n};\n","import { indent } from \"./utils/indent.ts\";\nimport { styleText } from \"./utils/style-text.ts\";\n\n/**\n * A single validation issue produced during environment variable parsing.\n * Used by {@link ArkEnvError} to report which key failed and why.\n */\nexport type ValidationIssue = {\n\tpath: string;\n\tmessage: string;\n};\n\nexport const formatInternalErrors = (errors: ValidationIssue[]): string =>\n\terrors\n\t\t.map(\n\t\t\t(error) =>\n\t\t\t\t`${styleText(\"yellow\", error.path)} ${error.message.trimStart()}`,\n\t\t)\n\t\t.join(\"\\n\");\n\n/**\n * Error thrown when environment variable validation fails.\n *\n * This error extends the native `Error` class and provides formatted error messages\n * that clearly indicate which environment variables are invalid and why.\n *\n * @example\n * ```ts\n * import arkenv from 'arkenv';\n * import { ArkEnvError } from 'arkenv/core';\n *\n * try {\n * const env = arkenv({\n * PORT: 'number.port',\n * HOST: 'string.host',\n * });\n * } catch (error) {\n * if (error instanceof ArkEnvError) {\n * console.error('Environment validation failed:', error.message);\n * }\n * }\n * ```\n */\nexport class ArkEnvError extends Error {\n\tconstructor(\n\t\terrors: ValidationIssue[],\n\t\tmessage = \"Errors found while validating environment variables\",\n\t) {\n\t\tconst formattedErrors = formatInternalErrors(errors);\n\t\tsuper(`${styleText(\"red\", message)}\\n${indent(formattedErrors)}\\n`);\n\t\tthis.name = \"ArkEnvError\";\n\t}\n}\n\nObject.defineProperty(ArkEnvError, \"name\", { value: \"ArkEnvError\" });\n"],"mappings":"AAiBA,MAAa,GACZ,EACA,EAAM,EACN,CAAE,qBAAqB,IAAyB,EAAE,GAE1B,EAQjB,GAAG,IAAI,OAAO,EAAI,GAAG,IANpB,EACL,MAAM;EAAK,CACX,IAAK,GAAS,GAAG,IAAI,OAAO,EAAI,GAAG,IAAO,CAC1C,KAAK;EAAK,CCpBR,EAAS,CACd,IAAK,WACL,OAAQ,WACR,KAAM,WACN,MAAO,UACP,CAMK,MACL,OAAO,QAAY,KACnB,QAAQ,UAAY,MACpB,QAAQ,SAAS,MAAQ,KAMpB,MAUL,GATI,CAAC,GAAQ,EAGT,QAAQ,IAAI,WAAa,IAAA,IAGzB,QAAQ,IAAI,KAAO,IAAA,IAGnB,QAAQ,QAAU,CAAC,QAAQ,OAAO,OAW1B,GACZ,EACA,IAGI,GAAQ,EAAI,CAAC,GAAqB,CAC9B,GAAG,EAAO,KAAS,IAAO,EAAO,QAGlC,EC7CK,EAAwB,GACpC,EACE,IACC,GACA,GAAG,EAAU,SAAU,EAAM,KAAK,CAAC,GAAG,EAAM,QAAQ,WAAW,GAChE,CACA,KAAK;EAAK,CAyBb,IAAa,EAAb,cAAiC,KAAM,CACtC,YACC,EACA,EAAU,sDACT,CACD,IAAM,EAAkB,EAAqB,EAAO,CACpD,MAAM,GAAG,EAAU,MAAO,EAAQ,CAAC,IAAI,EAAO,EAAgB,CAAC,IAAI,CACnE,KAAK,KAAO,gBAId,OAAO,eAAe,EAAa,OAAQ,CAAE,MAAO,cAAe,CAAC"}
1
+ {"version":3,"file":"core-B51xxxje.mjs","names":[],"sources":["../src/utils/indent.ts","../src/utils/style-text.ts","../src/core.ts"],"sourcesContent":["/**\n * Options for the `indent` function\n */\ntype IndentOptions = {\n\t/**\n\t * Whether to detect newlines and indent each line individually, defaults to false (indenting the whole string)\n\t */\n\tdontDetectNewlines?: boolean;\n};\n\n/**\n * Indent a string by a given amount\n * @param str - The string to indent\n * @param amt - The amount to indent by, defaults to 2\n * @param options - {@link IndentOptions}\n * @returns The indented string\n */\nexport const indent = (\n\tstr: string,\n\tamt = 2,\n\t{ dontDetectNewlines = false }: IndentOptions = {},\n) => {\n\tconst detectNewlines = !dontDetectNewlines;\n\tif (detectNewlines) {\n\t\treturn str\n\t\t\t.split(\"\\n\")\n\t\t\t.map((line) => `${\" \".repeat(amt)}${line}`)\n\t\t\t.join(\"\\n\");\n\t}\n\n\treturn `${\" \".repeat(amt)}${str}`;\n};\n","/**\n * Cross-platform text styling utility\n * Uses ANSI colors in Node environments, plain text in browsers\n * Respects NO_COLOR, CI environment variables, and TTY detection\n */\n\n// ANSI color codes for Node environments\nconst colors = {\n\tred: \"\\x1b[31m\",\n\tyellow: \"\\x1b[33m\",\n\tcyan: \"\\x1b[36m\",\n\treset: \"\\x1b[0m\",\n} as const;\n\n/**\n * Check if we're in a Node environment (not browser)\n * Checked dynamically to allow for testing with mocked globals\n */\nconst isNode = (): boolean =>\n\ttypeof process !== \"undefined\" &&\n\tprocess.versions != null &&\n\tprocess.versions.node != null;\n\n/**\n * Check if colors should be disabled based on environment\n * Respects NO_COLOR, CI environment variables, and TTY detection\n */\nconst shouldDisableColors = (): boolean => {\n\tif (!isNode()) return true;\n\n\t// Respect NO_COLOR environment variable (https://no-color.org/)\n\tif (process.env.NO_COLOR !== undefined) return true;\n\n\t// Disable colors in CI environments by default\n\tif (process.env.CI !== undefined) return true;\n\n\t// Disable colors if not writing to a TTY\n\tif (process.stdout && !process.stdout.isTTY) return true;\n\n\treturn false;\n};\n\n/**\n * Style text with color. Uses ANSI codes in Node, plain text in browsers.\n * @param color - The color to apply\n * @param text - The text to style\n * @returns Styled text in Node (if colors enabled), plain text otherwise\n */\nexport const styleText = (\n\tcolor: \"red\" | \"yellow\" | \"cyan\",\n\ttext: string,\n): string => {\n\t// Use ANSI colors only in Node environments with colors enabled\n\tif (isNode() && !shouldDisableColors()) {\n\t\treturn `${colors[color]}${text}${colors.reset}`;\n\t}\n\t// Fall back to plain text in browsers or when colors are disabled\n\treturn text;\n};\n","import { indent } from \"./utils/indent\";\nimport { styleText } from \"./utils/style-text\";\n\n/**\n * A single validation issue produced during environment variable parsing.\n * Used by {@link ArkEnvError} to report which key failed and why.\n */\nexport type ValidationIssue = {\n\tpath: string;\n\tmessage: string;\n};\n\nexport const formatInternalErrors = (errors: ValidationIssue[]): string =>\n\terrors\n\t\t.map(\n\t\t\t(error) =>\n\t\t\t\t`${styleText(\"yellow\", error.path)} ${error.message.trimStart()}`,\n\t\t)\n\t\t.join(\"\\n\");\n\n/**\n * Error thrown when environment variable validation fails.\n *\n * This error extends the native `Error` class and provides formatted error messages\n * that clearly indicate which environment variables are invalid and why.\n *\n * @example\n * ```ts\n * import arkenv from 'arkenv';\n * import { ArkEnvError } from 'arkenv/core';\n *\n * try {\n * const env = arkenv({\n * PORT: 'number.port',\n * HOST: 'string.host',\n * });\n * } catch (error) {\n * if (error instanceof ArkEnvError) {\n * console.error('Environment validation failed:', error.message);\n * }\n * }\n * ```\n */\nexport class ArkEnvError extends Error {\n\tconstructor(\n\t\terrors: ValidationIssue[],\n\t\tmessage = \"Errors found while validating environment variables\",\n\t) {\n\t\tconst formattedErrors = formatInternalErrors(errors);\n\t\tsuper(`${styleText(\"red\", message)}\\n${indent(formattedErrors)}\\n`);\n\t\tthis.name = \"ArkEnvError\";\n\t}\n}\n\nObject.defineProperty(ArkEnvError, \"name\", { value: \"ArkEnvError\" });\n"],"mappings":"AAiBA,MAAa,GACZ,EACA,EAAM,EACN,CAAE,qBAAqB,IAAyB,EAAE,GAE1B,EAQjB,GAAG,IAAI,OAAO,EAAI,GAAG,IANpB,EACL,MAAM;EAAK,CACX,IAAK,GAAS,GAAG,IAAI,OAAO,EAAI,GAAG,IAAO,CAC1C,KAAK;EAAK,CCpBR,EAAS,CACd,IAAK,WACL,OAAQ,WACR,KAAM,WACN,MAAO,UACP,CAMK,MACL,OAAO,QAAY,KACnB,QAAQ,UAAY,MACpB,QAAQ,SAAS,MAAQ,KAMpB,MAUL,GATI,CAAC,GAAQ,EAGT,QAAQ,IAAI,WAAa,IAAA,IAGzB,QAAQ,IAAI,KAAO,IAAA,IAGnB,QAAQ,QAAU,CAAC,QAAQ,OAAO,OAW1B,GACZ,EACA,IAGI,GAAQ,EAAI,CAAC,GAAqB,CAC9B,GAAG,EAAO,KAAS,IAAO,EAAO,QAGlC,EC7CK,EAAwB,GACpC,EACE,IACC,GACA,GAAG,EAAU,SAAU,EAAM,KAAK,CAAC,GAAG,EAAM,QAAQ,WAAW,GAChE,CACA,KAAK;EAAK,CAyBb,IAAa,EAAb,cAAiC,KAAM,CACtC,YACC,EACA,EAAU,sDACT,CACD,IAAM,EAAkB,EAAqB,EAAO,CACpD,MAAM,GAAG,EAAU,MAAO,EAAQ,CAAC,IAAI,EAAO,EAAgB,CAAC,IAAI,CACnE,KAAK,KAAO,gBAId,OAAO,eAAe,EAAa,OAAQ,CAAE,MAAO,cAAe,CAAC"}
@@ -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-Bx89Loyb.d.mts.map
204
+ //# sourceMappingURL=index-Br22fqkz.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index-Bx89Loyb.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,EAA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;;;KCXxCI,WAAAA,GAAcC,MAAAA;;;;AJA0D;;;;;;;;;KIaxEC,iBAAAA,GAAoBH,IAAAA,CAAKC,WAAAA,EAAaF,CAAAA"}
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,E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lC;EAAAA,KEsDG4C,UAAAA,gBAA0BZ,eAAAA,IAAmBA,eAAAA,CAAgBY,UAAAA,CAAWR,MAAAA;EFlD7E3C;EAAAA,KEoDKoD,WAAAA,gBAA2Bb,eAAAA,IAAmBA,eAAAA,CAAgBa,WAAAA,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"}
package/dist/index.cjs CHANGED
@@ -1,4 +1,4 @@
1
- Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});const e=require(`./core-Byznlywt.cjs`);let t=require(`arktype`);const n=(0,t.type)(`0 <= number.integer <= 65535`),r=(0,t.type)(`string.ip | 'localhost'`),i=(0,t.scope)({string:t.type.module({...t.type.keywords.string,host:r}),number:t.type.module({...t.type.keywords.number,port:n})}),a=e=>{if(typeof e==`number`||typeof e!=`string`)return e;let t=e.trim();if(t===``)return e;if(t===`NaN`)return NaN;let n=Number(t);return Number.isNaN(n)?e:n},o=e=>e===`true`?!0:e===`false`?!1:e,s=e=>{if(typeof e!=`string`)return e;let t=e.trim();if(!t.startsWith(`{`)&&!t.startsWith(`[`))return e;try{return JSON.parse(t)}catch{return e}},c=(e,t=[])=>{let n=[];if(typeof e==`boolean`)return n;if(`const`in e&&(typeof e.const==`number`||typeof e.const==`boolean`)&&n.push({path:[...t],type:`primitive`}),`enum`in e&&e.enum&&e.enum.some(e=>typeof e==`number`||typeof e==`boolean`)&&n.push({path:[...t],type:`primitive`}),`type`in e)if(e.type===`number`||e.type===`integer`)n.push({path:[...t],type:`primitive`});else if(e.type===`boolean`)n.push({path:[...t],type:`primitive`});else if(e.type===`object`){if(`properties`in e&&e.properties&&Object.keys(e.properties).length>0&&n.push({path:[...t],type:`object`}),`properties`in e&&e.properties)for(let[r,i]of Object.entries(e.properties))n.push(...c(i,[...t,r]))}else e.type===`array`&&(n.push({path:[...t],type:`array`}),`items`in e&&e.items&&(Array.isArray(e.items)?e.items.forEach((e,r)=>{n.push(...c(e,[...t,`${r}`]))}):n.push(...c(e.items,[...t,`*`]))));if(`anyOf`in e&&e.anyOf)for(let r of e.anyOf)n.push(...c(r,t));if(`allOf`in e&&e.allOf)for(let r of e.allOf)n.push(...c(r,t));if(`oneOf`in e&&e.oneOf)for(let r of e.oneOf)n.push(...c(r,t));let r=new Set;return n.filter(e=>{let t=JSON.stringify(e.path)+e.type;return r.has(t)?!1:(r.add(t),!0)})},l=(e,t,n={})=>{let{arrayFormat:r=`comma`}=n,i=e=>{if(r===`json`)try{return JSON.parse(e)}catch{return e}return e.trim()?e.split(`,`).map(e=>e.trim()):[]};if(typeof e!=`object`||!e){if(t.some(e=>e.path.length===0)){let n=t.find(e=>e.path.length===0);if(n?.type===`object`&&typeof e==`string`)return s(e);if(n?.type===`array`&&typeof e==`string`)return i(e);let r=a(e);return typeof r==`number`?r:o(e)}return e}let c=[...t].sort((e,t)=>e.path.length-t.path.length),l=(e,t,n)=>{if(!e||typeof e!=`object`||t.length===0)return;if(t.length===1){let r=t[0];if(r===`*`){if(Array.isArray(e))for(let t=0;t<e.length;t++){let r=e[t];if(n===`primitive`){let n=a(r);typeof n==`number`?e[t]=n:e[t]=o(r)}else n===`object`&&(e[t]=s(r))}return}let c=e;if(Object.prototype.hasOwnProperty.call(c,r)){let e=c[r];if(n===`array`&&typeof e==`string`){c[r]=i(e);return}if(n===`object`&&typeof e==`string`){c[r]=s(e);return}if(Array.isArray(e)){if(n===`primitive`)for(let t=0;t<e.length;t++){let n=e[t],r=a(n);typeof r==`number`?e[t]=r:e[t]=o(n)}}else if(n===`primitive`){let t=a(e);typeof t==`number`?c[r]=t:c[r]=o(e)}}return}let[r,...c]=t;if(r===`*`){if(Array.isArray(e))for(let t of e)l(t,c,n);return}l(e[r],c,n)};for(let t of c)l(e,t.path,t.type);return e};function u(e,t,n){let r=c(t.in.toJsonSchema({fallback:e=>e.base}));return r.length===0?t:e(`unknown`).pipe(e=>l(e,r,n)).pipe(t)}function d(t){return Object.entries(t.byPath).map(([t,n])=>{let r=n.message,i=r.trimStart();if(i.length>0&&`:.-`.includes(i[0])&&(i=i.slice(1).trimStart()),i.toLowerCase().startsWith(t.toLowerCase())){let e=i.slice(t.length).trimStart();e.length>0&&`:.-`.includes(e[0])&&(e=e.slice(1)),r=e.trimStart()}let a=r.match(/\(was (.*)\)/);if(a?.[1]){let t=a[1];t.includes(`\x1B[`)||(r=r.replace(`(was ${t})`,`(was ${e.r(`cyan`,t)})`))}return{path:t,message:r}})}function f(n,r){let{env:a=process.env,coerce:o=!0,onUndeclaredKey:s=`delete`,arrayFormat:c=`comma`}=r,l=(typeof n==`function`&&`assert`in n?n:i.type.raw(n)).onUndeclaredKey(s),f=l;o&&(f=u(i.type,l,{arrayFormat:c}));let p=f(a);if(p instanceof t.ArkErrors)throw new e.t(d(p));return p}function p(e,t={}){return f(e,t)}const m=i.type,h=p;exports.createEnv=p,exports.default=h,exports.type=m;
1
+ Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});const e=require(`./core-Byznlywt.cjs`),t=require(`./shared-Sfv4WYag.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(e,n,r){let i=t.n(n.in.toJsonSchema({fallback:e=>e.base}));return i.length===0?n:e(`unknown`).pipe(e=>t.t(e,i,r)).pipe(n)}function s(t){return Object.entries(t.byPath).map(([t,n])=>{let r=n.message,i=r.trimStart();if(i.length>0&&`:.-`.includes(i[0])&&(i=i.slice(1).trimStart()),i.toLowerCase().startsWith(t.toLowerCase())){let e=i.slice(t.length).trimStart();e.length>0&&`:.-`.includes(e[0])&&(e=e.slice(1)),r=e.trimStart()}let a=r.match(/\(was (.*)\)/);if(a?.[1]){let t=a[1];t.includes(`\x1B[`)||(r=r.replace(`(was ${t})`,`(was ${e.r(`cyan`,t)})`))}return{path:t,message:r}})}function c(t,r){let{env:i=process.env,coerce:c=!0,onUndeclaredKey:l=`delete`,arrayFormat:u=`comma`}=r,d=(typeof t==`function`&&`assert`in t?t:a.type.raw(t)).onUndeclaredKey(l),f=d;c&&(f=o(a.type,d,{arrayFormat:u}));let p=f(i);if(p instanceof n.ArkErrors)throw new e.t(s(p));return p}function l(e,t={}){return c(e,t)}const u=a.type,d=l;exports.createEnv=l,exports.default=d,exports.type=u;
2
2
 
3
3
  // CJS Interop Shim
4
4
  if (module.exports && module.exports.default) {
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-Bx89Loyb.mjs";
1
+ import { a as Dict, n as SchemaShape, o as $, r as InferType, t as CompiledEnvSchema } from "./index-Br22fqkz.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";
package/dist/index.mjs CHANGED
@@ -1,3 +1,3 @@
1
- import{r as e,t}from"./core-B51xxxje.mjs";import{ArkErrors as n,scope as r,type as i}from"arktype";const a=i(`0 <= number.integer <= 65535`),o=i(`string.ip | 'localhost'`),s=r({string:i.module({...i.keywords.string,host:o}),number:i.module({...i.keywords.number,port:a})}),c=e=>{if(typeof e==`number`||typeof e!=`string`)return e;let t=e.trim();if(t===``)return e;if(t===`NaN`)return NaN;let n=Number(t);return Number.isNaN(n)?e:n},l=e=>e===`true`?!0:e===`false`?!1:e,u=e=>{if(typeof e!=`string`)return e;let t=e.trim();if(!t.startsWith(`{`)&&!t.startsWith(`[`))return e;try{return JSON.parse(t)}catch{return e}},d=(e,t=[])=>{let n=[];if(typeof e==`boolean`)return n;if(`const`in e&&(typeof e.const==`number`||typeof e.const==`boolean`)&&n.push({path:[...t],type:`primitive`}),`enum`in e&&e.enum&&e.enum.some(e=>typeof e==`number`||typeof e==`boolean`)&&n.push({path:[...t],type:`primitive`}),`type`in e)if(e.type===`number`||e.type===`integer`)n.push({path:[...t],type:`primitive`});else if(e.type===`boolean`)n.push({path:[...t],type:`primitive`});else if(e.type===`object`){if(`properties`in e&&e.properties&&Object.keys(e.properties).length>0&&n.push({path:[...t],type:`object`}),`properties`in e&&e.properties)for(let[r,i]of Object.entries(e.properties))n.push(...d(i,[...t,r]))}else e.type===`array`&&(n.push({path:[...t],type:`array`}),`items`in e&&e.items&&(Array.isArray(e.items)?e.items.forEach((e,r)=>{n.push(...d(e,[...t,`${r}`]))}):n.push(...d(e.items,[...t,`*`]))));if(`anyOf`in e&&e.anyOf)for(let r of e.anyOf)n.push(...d(r,t));if(`allOf`in e&&e.allOf)for(let r of e.allOf)n.push(...d(r,t));if(`oneOf`in e&&e.oneOf)for(let r of e.oneOf)n.push(...d(r,t));let r=new Set;return n.filter(e=>{let t=JSON.stringify(e.path)+e.type;return r.has(t)?!1:(r.add(t),!0)})},f=(e,t,n={})=>{let{arrayFormat:r=`comma`}=n,i=e=>{if(r===`json`)try{return JSON.parse(e)}catch{return e}return e.trim()?e.split(`,`).map(e=>e.trim()):[]};if(typeof e!=`object`||!e){if(t.some(e=>e.path.length===0)){let n=t.find(e=>e.path.length===0);if(n?.type===`object`&&typeof e==`string`)return u(e);if(n?.type===`array`&&typeof e==`string`)return i(e);let r=c(e);return typeof r==`number`?r:l(e)}return e}let a=[...t].sort((e,t)=>e.path.length-t.path.length),o=(e,t,n)=>{if(!e||typeof e!=`object`||t.length===0)return;if(t.length===1){let r=t[0];if(r===`*`){if(Array.isArray(e))for(let t=0;t<e.length;t++){let r=e[t];if(n===`primitive`){let n=c(r);typeof n==`number`?e[t]=n:e[t]=l(r)}else n===`object`&&(e[t]=u(r))}return}let a=e;if(Object.prototype.hasOwnProperty.call(a,r)){let e=a[r];if(n===`array`&&typeof e==`string`){a[r]=i(e);return}if(n===`object`&&typeof e==`string`){a[r]=u(e);return}if(Array.isArray(e)){if(n===`primitive`)for(let t=0;t<e.length;t++){let n=e[t],r=c(n);typeof r==`number`?e[t]=r:e[t]=l(n)}}else if(n===`primitive`){let t=c(e);typeof t==`number`?a[r]=t:a[r]=l(e)}}return}let[r,...a]=t;if(r===`*`){if(Array.isArray(e))for(let t of e)o(t,a,n);return}o(e[r],a,n)};for(let t of a)o(e,t.path,t.type);return e};function p(e,t,n){let r=d(t.in.toJsonSchema({fallback:e=>e.base}));return r.length===0?t:e(`unknown`).pipe(e=>f(e,r,n)).pipe(t)}function m(t){return Object.entries(t.byPath).map(([t,n])=>{let r=n.message,i=r.trimStart();if(i.length>0&&`:.-`.includes(i[0])&&(i=i.slice(1).trimStart()),i.toLowerCase().startsWith(t.toLowerCase())){let e=i.slice(t.length).trimStart();e.length>0&&`:.-`.includes(e[0])&&(e=e.slice(1)),r=e.trimStart()}let a=r.match(/\(was (.*)\)/);if(a?.[1]){let t=a[1];t.includes(`\x1B[`)||(r=r.replace(`(was ${t})`,`(was ${e(`cyan`,t)})`))}return{path:t,message:r}})}function h(e,r){let{env:i=process.env,coerce:a=!0,onUndeclaredKey:o=`delete`,arrayFormat:c=`comma`}=r,l=(typeof e==`function`&&`assert`in e?e:s.type.raw(e)).onUndeclaredKey(o),u=l;a&&(u=p(s.type,l,{arrayFormat:c}));let d=u(i);if(d instanceof n)throw new t(m(d));return d}function g(e,t={}){return h(e,t)}const _=s.type,v=g;export{g as createEnv,v as default,_ as type};
1
+ import{r as e,t}from"./core-B51xxxje.mjs";import{n,t as r}from"./shared-_ck4b4vs.mjs";import{ArkErrors as i,scope as a,type as o}from"arktype";const s=o(`0 <= number.integer <= 65535`),c=o(`string.ip | 'localhost'`),l=a({string:o.module({...o.keywords.string,host:c}),number:o.module({...o.keywords.number,port:s})});function u(e,t,i){let a=n(t.in.toJsonSchema({fallback:e=>e.base}));return a.length===0?t:e(`unknown`).pipe(e=>r(e,a,i)).pipe(t)}function d(t){return Object.entries(t.byPath).map(([t,n])=>{let r=n.message,i=r.trimStart();if(i.length>0&&`:.-`.includes(i[0])&&(i=i.slice(1).trimStart()),i.toLowerCase().startsWith(t.toLowerCase())){let e=i.slice(t.length).trimStart();e.length>0&&`:.-`.includes(e[0])&&(e=e.slice(1)),r=e.trimStart()}let a=r.match(/\(was (.*)\)/);if(a?.[1]){let t=a[1];t.includes(`\x1B[`)||(r=r.replace(`(was ${t})`,`(was ${e(`cyan`,t)})`))}return{path:t,message:r}})}function f(e,n){let{env:r=process.env,coerce:a=!0,onUndeclaredKey:o=`delete`,arrayFormat:s=`comma`}=n,c=(typeof e==`function`&&`assert`in e?e:l.type.raw(e)).onUndeclaredKey(o),f=c;a&&(f=u(l.type,c,{arrayFormat:s}));let p=f(r);if(p instanceof i)throw new t(d(p));return p}function p(e,t={}){return f(e,t)}const m=l.type,h=p;export{p as createEnv,h as default,m as type};
2
2
 
3
3
  //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","names":["t","e","record","$","$"],"sources":["../../internal/scope/dist/index.js","../src/arktype/coercion/morphs.ts","../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","/**\n * Attempt to coerce a value to a number.\n *\n * If the input is already a number, returns it unchanged.\n * If the input is a string that can be parsed as a number, returns the parsed number.\n * Otherwise, returns the original value unchanged.\n *\n * @internal\n * @param s - The value to coerce\n * @returns The coerced number or the original value\n */\nexport const coerceNumber = (s: unknown) => {\n\tif (typeof s === \"number\") return s;\n\tif (typeof s !== \"string\") return s;\n\tconst trimmed = s.trim();\n\tif (trimmed === \"\") return s;\n\tif (trimmed === \"NaN\") return Number.NaN;\n\tconst n = Number(trimmed);\n\treturn Number.isNaN(n) ? s : n;\n};\n\n/**\n * Attempt to coerce a value to a boolean.\n *\n * Convert the strings \"true\" and \"false\" to their boolean equivalents.\n * All other values are returned unchanged.\n *\n * @internal\n * @param s - The value to coerce\n * @returns The coerced boolean or the original value\n */\nexport const coerceBoolean = (s: unknown) => {\n\tif (s === \"true\") return true;\n\tif (s === \"false\") return false;\n\treturn s;\n};\n\n/**\n * Attempt to parse a value as JSON.\n *\n * If the input is a string that starts with `{` or `[` and can be parsed as JSON,\n * returns the parsed object or array. Otherwise, returns the original value unchanged.\n *\n * @internal\n * @param s - The value to parse\n * @returns The parsed JSON or the original value\n */\nexport const coerceJson = (s: unknown) => {\n\tif (typeof s !== \"string\") return s;\n\tconst trimmed = s.trim();\n\tif (!trimmed.startsWith(\"{\") && !trimmed.startsWith(\"[\")) return s;\n\ttry {\n\t\treturn JSON.parse(trimmed);\n\t} catch {\n\t\treturn s;\n\t}\n};\n","import type { BaseType, JsonSchema } from \"arktype\";\nimport { coerceBoolean, coerceJson, coerceNumber } from \"./morphs.ts\";\n\n/**\n * A marker used in the coercion path to indicate that the target\n * is the *elements* of an array, rather than the array property itself.\n */\nconst ARRAY_ITEM_MARKER = \"*\";\n\n/**\n * @internal\n * Information about a path in the schema that requires coercion.\n */\ntype CoercionTarget = {\n\tpath: string[];\n\ttype: \"primitive\" | \"array\" | \"object\";\n};\n\n/**\n * Options for coercion behavior.\n */\nexport type CoerceOptions = {\n\t/**\n\t * format to use for array parsing\n\t * @default \"comma\"\n\t */\n\tarrayFormat?: \"comma\" | \"json\";\n};\n\n/**\n * Recursively find all paths in a JSON Schema that require coercion.\n * We prioritize \"number\", \"integer\", \"boolean\", \"array\", and \"object\" types.\n */\nconst findCoercionPaths = (\n\tnode: JsonSchema,\n\tpath: string[] = [],\n): CoercionTarget[] => {\n\tconst results: CoercionTarget[] = [];\n\n\tif (typeof node === \"boolean\") {\n\t\treturn results;\n\t}\n\n\tif (\"const\" in node) {\n\t\tif (typeof node.const === \"number\" || typeof node.const === \"boolean\") {\n\t\t\tresults.push({ path: [...path], type: \"primitive\" });\n\t\t}\n\t}\n\n\tif (\"enum\" in node && node.enum) {\n\t\tif (\n\t\t\tnode.enum.some((v) => typeof v === \"number\" || typeof v === \"boolean\")\n\t\t) {\n\t\t\tresults.push({ path: [...path], type: \"primitive\" });\n\t\t}\n\t}\n\n\tif (\"type\" in node) {\n\t\tif (node.type === \"number\" || node.type === \"integer\") {\n\t\t\tresults.push({ path: [...path], type: \"primitive\" });\n\t\t} else if (node.type === \"boolean\") {\n\t\t\tresults.push({ path: [...path], type: \"primitive\" });\n\t\t} else if (node.type === \"object\") {\n\t\t\t// Check if this object has properties defined\n\t\t\t// If it does, we want to coerce the whole object from a JSON string\n\t\t\t// But we also want to recursively check nested properties\n\t\t\tconst hasProperties =\n\t\t\t\t\"properties\" in node &&\n\t\t\t\tnode.properties &&\n\t\t\t\tObject.keys(node.properties).length > 0;\n\n\t\t\tif (hasProperties) {\n\t\t\t\t// Mark this path as needing object coercion (JSON parsing)\n\t\t\t\tresults.push({ path: [...path], type: \"object\" });\n\t\t\t}\n\n\t\t\t// Also recursively check nested properties for their own coercions\n\t\t\tif (\"properties\" in node && node.properties) {\n\t\t\t\tfor (const [key, prop] of Object.entries(node.properties)) {\n\t\t\t\t\tresults.push(\n\t\t\t\t\t\t...findCoercionPaths(prop as JsonSchema, [...path, key]),\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\t\t} else if (node.type === \"array\") {\n\t\t\t// Mark the array itself as a target for splitting strings\n\t\t\tresults.push({ path: [...path], type: \"array\" });\n\n\t\t\tif (\"items\" in node && node.items) {\n\t\t\t\tif (Array.isArray(node.items)) {\n\t\t\t\t\t// Tuple traversal\n\t\t\t\t\tnode.items.forEach((item, index) => {\n\t\t\t\t\t\tresults.push(\n\t\t\t\t\t\t\t...findCoercionPaths(item as JsonSchema, [...path, `${index}`]),\n\t\t\t\t\t\t);\n\t\t\t\t\t});\n\t\t\t\t} else {\n\t\t\t\t\t// List traversal\n\t\t\t\t\tresults.push(\n\t\t\t\t\t\t...findCoercionPaths(node.items as JsonSchema, [\n\t\t\t\t\t\t\t...path,\n\t\t\t\t\t\t\tARRAY_ITEM_MARKER,\n\t\t\t\t\t\t]),\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tif (\"anyOf\" in node && node.anyOf) {\n\t\tfor (const branch of node.anyOf) {\n\t\t\tresults.push(...findCoercionPaths(branch as JsonSchema, path));\n\t\t}\n\t}\n\n\tif (\"allOf\" in node && node.allOf) {\n\t\tfor (const branch of node.allOf) {\n\t\t\tresults.push(...findCoercionPaths(branch as JsonSchema, path));\n\t\t}\n\t}\n\n\tif (\"oneOf\" in node && node.oneOf) {\n\t\tfor (const branch of node.oneOf) {\n\t\t\tresults.push(...findCoercionPaths(branch as JsonSchema, path));\n\t\t}\n\t}\n\n\t// Deduplicate by path and type combination\n\tconst seen = new Set<string>();\n\treturn results.filter((t) => {\n\t\tconst key = JSON.stringify(t.path) + t.type;\n\t\tif (seen.has(key)) return false;\n\t\tseen.add(key);\n\t\treturn true;\n\t});\n};\n\n/**\n * Apply coercion to a data object based on identified paths.\n */\nconst applyCoercion = (\n\tdata: unknown,\n\ttargets: CoercionTarget[],\n\toptions: CoerceOptions = {},\n) => {\n\tconst { arrayFormat = \"comma\" } = options;\n\n\t// Helper to split string to array\n\tconst splitString = (val: string) => {\n\t\tif (arrayFormat === \"json\") {\n\t\t\ttry {\n\t\t\t\treturn JSON.parse(val);\n\t\t\t} catch {\n\t\t\t\treturn val;\n\t\t\t}\n\t\t}\n\n\t\tif (!val.trim()) return [];\n\t\treturn val.split(\",\").map((s) => s.trim());\n\t};\n\n\tif (typeof data !== \"object\" || data === null) {\n\t\t// If root data needs coercion\n\t\tif (targets.some((t) => t.path.length === 0)) {\n\t\t\tconst rootTarget = targets.find((t) => t.path.length === 0);\n\n\t\t\tif (rootTarget?.type === \"object\" && typeof data === \"string\") {\n\t\t\t\treturn coerceJson(data);\n\t\t\t}\n\n\t\t\tif (rootTarget?.type === \"array\" && typeof data === \"string\") {\n\t\t\t\treturn splitString(data);\n\t\t\t}\n\n\t\t\tconst asNumber = coerceNumber(data);\n\t\t\tif (typeof asNumber === \"number\") {\n\t\t\t\treturn asNumber;\n\t\t\t}\n\t\t\treturn coerceBoolean(data);\n\t\t}\n\t\treturn data;\n\t}\n\n\t// Sort targets by path length to ensure parent objects/arrays are coerced before their children\n\tconst sortedTargets = [...targets].sort(\n\t\t(a, b) => a.path.length - b.path.length,\n\t);\n\n\tconst walk = (\n\t\tcurrent: unknown,\n\t\ttargetPath: string[],\n\t\ttype: \"primitive\" | \"array\" | \"object\",\n\t) => {\n\t\tif (!current || typeof current !== \"object\") return;\n\n\t\tif (targetPath.length === 0) {\n\t\t\treturn;\n\t\t}\n\n\t\t// If we've reached the last key, apply coercion\n\t\tif (targetPath.length === 1) {\n\t\t\tconst lastKey = targetPath[0];\n\n\t\t\tif (lastKey === ARRAY_ITEM_MARKER) {\n\t\t\t\tif (Array.isArray(current)) {\n\t\t\t\t\tfor (let i = 0; i < current.length; i++) {\n\t\t\t\t\t\tconst original = current[i];\n\t\t\t\t\t\tif (type === \"primitive\") {\n\t\t\t\t\t\t\tconst asNumber = coerceNumber(original);\n\t\t\t\t\t\t\tif (typeof asNumber === \"number\") {\n\t\t\t\t\t\t\t\tcurrent[i] = asNumber;\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tcurrent[i] = coerceBoolean(original);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} else if (type === \"object\") {\n\t\t\t\t\t\t\tcurrent[i] = coerceJson(original);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst record = current as Record<string, unknown>;\n\t\t\t// biome-ignore lint/suspicious/noPrototypeBuiltins: ES2020 compatibility\n\t\t\tif (Object.prototype.hasOwnProperty.call(record, lastKey)) {\n\t\t\t\tconst original = record[lastKey];\n\n\t\t\t\tif (type === \"array\" && typeof original === \"string\") {\n\t\t\t\t\trecord[lastKey] = splitString(original);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tif (type === \"object\" && typeof original === \"string\") {\n\t\t\t\t\trecord[lastKey] = coerceJson(original);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tif (Array.isArray(original)) {\n\t\t\t\t\tif (type === \"primitive\") {\n\t\t\t\t\t\tfor (let i = 0; i < original.length; i++) {\n\t\t\t\t\t\t\tconst item = original[i];\n\t\t\t\t\t\t\tconst asNumber = coerceNumber(item);\n\t\t\t\t\t\t\tif (typeof asNumber === \"number\") {\n\t\t\t\t\t\t\t\toriginal[i] = asNumber;\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\toriginal[i] = coerceBoolean(item);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tif (type === \"primitive\") {\n\t\t\t\t\t\tconst asNumber = coerceNumber(original);\n\t\t\t\t\t\t// If numeric parsing didn't produce a number, try boolean coercion\n\t\t\t\t\t\tif (typeof asNumber === \"number\") {\n\t\t\t\t\t\t\trecord[lastKey] = asNumber;\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\trecord[lastKey] = coerceBoolean(original);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\n\t\t// Recurse down\n\t\tconst [nextKey, ...rest] = targetPath;\n\n\t\tif (nextKey === ARRAY_ITEM_MARKER) {\n\t\t\tif (Array.isArray(current)) {\n\t\t\t\tfor (const item of current) {\n\t\t\t\t\twalk(item, rest, type);\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\n\t\tconst record = current as Record<string, unknown>;\n\t\twalk(record[nextKey], rest, type);\n\t};\n\n\tfor (const target of sortedTargets) {\n\t\twalk(data, target.path, target.type);\n\t}\n\n\treturn data;\n};\n\n/**\n * Create a coercing wrapper around an ArkType schema using JSON Schema introspection.\n * Pre-process input data to coerce string values to numbers/booleans at identified paths\n * before validation.\n */\nexport function coerce<t, $ = {}>(\n\tat: any,\n\tschema: BaseType<t, $>,\n\toptions?: CoerceOptions,\n): BaseType<t, $> {\n\t// Use a fallback to handle unjsonifiable parts of the schema (like predicates)\n\t// by preserving the base schema. This ensures that even if part of the schema\n\t// cannot be fully represented in JSON Schema, we can still perform coercion\n\t// for the parts that can.\n\tconst json = schema.in.toJsonSchema({\n\t\tfallback: (ctx) => (ctx as any).base,\n\t});\n\tconst targets = findCoercionPaths(json as any);\n\n\tif (targets.length === 0) {\n\t\treturn schema;\n\t}\n\n\t/*\n\t * We use `type(\"unknown\")` to start the pipeline, which initializes a default scope.\n\t * Integrating the original `schema` with its custom scope `$` into this pipeline\n\t * creates a scope mismatch in TypeScript ({} vs $).\n\t * We cast to `BaseType<t, $>` to assert the final contract is maintained.\n\t */\n\treturn at(\"unknown\")\n\t\t.pipe((data: unknown) => applyCoercion(data, targets, options))\n\t\t.pipe(schema) as BaseType<t, $>;\n}\n","import { $ } from \"@repo/scope\";\nimport type { SchemaShape } from \"@repo/types\";\nimport type { distill } from \"arktype\";\nimport { ArkErrors } from \"arktype\";\nimport { ArkEnvError, type ValidationIssue } from \"../core\";\nimport type { ArkEnvConfig, EnvSchema } from \"../create-env\";\nimport { styleText } from \"../utils/style-text.ts\";\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} = config;\n\n\t// If def is a type definition (has assert method), use it directly\n\t// Otherwise, use raw() to convert the schema definition\n\tconst isCompiledType = typeof def === \"function\" && \"assert\" in def;\n\tconst schema = (isCompiledType ? def : $.type.raw(def)) as any;\n\n\t// Apply the `onUndeclaredKey` option\n\tconst schemaWithKeys = schema.onUndeclaredKey(onUndeclaredKey);\n\n\t// Apply coercion transformation to allow strings to be parsed as numbers/booleans\n\tlet finalSchema = schemaWithKeys;\n\tif (shouldCoerce) {\n\t\tfinalSchema = coerce($.type, schemaWithKeys, { arrayFormat });\n\t}\n\n\t// Validate the environment variables\n\tconst validatedEnv = finalSchema(env);\n\n\t// In ArkType 2.x, calling a type as a function returns the validated data or ArkErrors\n\tif (validatedEnv instanceof ArkErrors) {\n\t\tthrow new ArkEnvError(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\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":"mGAA0C,MAAM,EAAEA,EAAE,+BAA+B,CAAC,EAAEA,EAAE,0BAA0B,CAAC,EAAEC,EAAE,CAAC,OAAOD,EAAE,OAAO,CAAC,GAAGA,EAAE,SAAS,OAAO,KAAK,EAAE,CAAC,CAAC,OAAOA,EAAE,OAAO,CAAC,GAAGA,EAAE,SAAS,OAAO,KAAK,EAAE,CAAC,CAAC,CAAC,CCW1M,EAAgB,GAAe,CAE3C,GADI,OAAO,GAAM,UACb,OAAO,GAAM,SAAU,OAAO,EAClC,IAAM,EAAU,EAAE,MAAM,CACxB,GAAI,IAAY,GAAI,OAAO,EAC3B,GAAI,IAAY,MAAO,MAAO,KAC9B,IAAM,EAAI,OA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EAAK,WAAW,CAI3B,IAAM,EAAa,EAAQ,MAAM,eAAe,CAChD,GAAI,IAAa,GAAI,CACpB,IAAM,EAAQ,EAAW,GACpB,EAAM,SAAS,QAAQ,GAC3B,EAAU,EAAQ,QACjB,QAAQ,EAAM,GACd,QAAQ,EAAU,OAAQ,EAAM,CAAC,GACjC,EAIH,MAAO,CAAE,OAAM,UAAS,EACvB,CAmBH,SAAgB,EACf,EACA,EACC,CACD,GAAM,CACL,MAAM,QAAQ,IACd,OAAQ,EAAe,GACvB,kBAAkB,SAClB,cAAc,SACX,EAQE,GAJiB,OAAO,GAAQ,YAAc,WAAY,EAC/B,EAAMC,EAAE,KAAK,IAAI,EAAI,EAGxB,gBAAgB,EAAgB,CAG1D,EAAc,EACd,IACH,EAAc,EAAOA,EAAE,KAAM,EAAgB,CAAE,cAAa,CAAC,EAI9D,IAAM,EAAe,EAAY,EAAI,CAGrC,GAAI,aAAwB,EAC3B,MAAM,IAAI,EAAY,EAAkB,EAAa,CAAC,CAGvD,OAAO,ECPR,SAAgB,EACf,EACA,EAAuB,EAAE,CAC6B,CAEtD,OAAO,EAAM,EAAY,EAAO,CC/FjC,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/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 { 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} = config;\n\n\t// If def is a type definition (has assert method), use it directly\n\t// Otherwise, use raw() to convert the schema definition\n\tconst isCompiledType = typeof def === \"function\" && \"assert\" in def;\n\tconst schema = (isCompiledType ? def : $.type.raw(def)) as any;\n\n\t// Apply the `onUndeclaredKey` option\n\tconst schemaWithKeys = schema.onUndeclaredKey(onUndeclaredKey);\n\n\t// Apply coercion transformation to allow strings to be parsed as numbers/booleans\n\tlet finalSchema = schemaWithKeys;\n\tif (shouldCoerce) {\n\t\tfinalSchema = coerce($.type, schemaWithKeys, { arrayFormat });\n\t}\n\n\t// Validate the environment variables\n\tconst validatedEnv = finalSchema(env);\n\n\t// In ArkType 2.x, calling a type as a function returns the validated data or ArkErrors\n\tif (validatedEnv instanceof ArkErrors) {\n\t\tthrow new ArkEnvError(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\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":"+IAA0C,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,CCVf,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,EAAO,EAAK,MAAM,EAAE,EAErB,EAAU,EAAK,WAAW,CAI3B,IAAM,EAAa,EAAQ,MAAM,eAAe,CAChD,GAAI,IAAa,GAAI,CACpB,IAAM,EAAQ,EAAW,GACpB,EAAM,SAAS,QAAQ,GAC3B,EAAU,EAAQ,QACjB,QAAQ,EAAM,GACd,QAAQ,EAAU,OAAQ,EAAM,CAAC,GACjC,EAIH,MAAO,CAAE,OAAM,UAAS,EACvB,CAmBH,SAAgB,EACf,EACA,EACC,CACD,GAAM,CACL,MAAM,QAAQ,IACd,OAAQ,EAAe,GACvB,kBAAkB,SAClB,cAAc,SACX,EAQE,GAJiB,OAAO,GAAQ,YAAc,WAAY,EAC/B,EAAME,EAAE,KAAK,IAAI,EAAI,EAGxB,gBAAgB,EAAgB,CAG1D,EAAc,EACd,IACH,EAAc,EAAOA,EAAE,KAAM,EAAgB,CAAE,cAAa,CAAC,EAI9D,IAAM,EAAe,EAAY,EAAI,CAGrC,GAAI,aAAwB,EAC3B,MAAM,IAAI,EAAY,EAAkB,EAAa,CAAC,CAGvD,OAAO,ECPR,SAAgB,EACf,EACA,EAAuB,EAAE,CAC6B,CAEtD,OAAO,EAAM,EAAY,EAAO,CC/FjC,MAAa,EAAOC,EAAE,KAQhB,EAAS"}
@@ -0,0 +1,8 @@
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,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(...i(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(...i(e,[...t,String(r)]))}):n.push(...i(e.items,[...t,`*`]))));for(let r of[`anyOf`,`allOf`,`oneOf`])if(r in e&&Array.isArray(e[r]))for(let a of e[r])n.push(...i(a,t));let a=new Set;return n.filter(e=>{let t=e.path.join(`/`)+`:`+e.type;return a.has(t)?!1:a.add(t)})},a=(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 i}}),Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return a}});
2
+
3
+ // CJS Interop Shim
4
+ if (module.exports && module.exports.default) {
5
+ Object.assign(module.exports.default, module.exports);
6
+ module.exports = module.exports.default;
7
+ }
8
+
@@ -0,0 +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,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(...i(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(...i(e,[...t,String(r)]))}):n.push(...i(e.items,[...t,`*`]))));for(let r of[`anyOf`,`allOf`,`oneOf`])if(r in e&&Array.isArray(e[r]))for(let a of e[r])n.push(...i(a,t));let a=new Set;return n.filter(e=>{let t=e.path.join(`/`)+`:`+e.type;return a.has(t)?!1:a.add(t)})},a=(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{i as n,a as t};
2
+
3
+ //# sourceMappingURL=shared-_ck4b4vs.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shared-_ck4b4vs.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 * 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,SAAU,OAAO,EAClC,IAAM,EAAU,EAAE,MAAM,CACxB,GAAI,EAAQ,KAAO,KAAO,EAAQ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},[Symbol.toStringTag]:{value:`Module`}});const e=require(`./core-Byznlywt.cjs`);function t(t,n){if(typeof n==`string`)throw new e.t([{path:t,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 n(t,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 e.t([{path:t,message:`Invalid validator: expected a Standard Schema 1.0 validator (must have "~standard" property). Import from "arkenv" to use ArkType schemas.`}])}function r(t){if(!t||typeof t!=`object`||Array.isArray(t))throw new e.t([{path:``,message:`Invalid schema: expected an object mapping in "standard" mode.`}])}function i(t,n){let{env:r=process.env,onUndeclaredKey:i=`delete`}=n,a={},o=[],s=new Set(Object.keys(r));for(let n in t){let i=t[n],c=r[n];if(!i||typeof i!=`object`||!(`~standard`in i))throw new e.t([{path:n,message:`Invalid schema: expected a Standard Schema 1.0 validator (e.g. Zod, Valibot) in 'standard' mode.`}]);let l=i[`~standard`].validate(c);if(l instanceof Promise)throw new e.t([{path:n,message:`Async validation is not supported. ArkEnv is synchronous.`}]);if(l.issues)for(let e of l.issues){let t=e.path&&e.path.length>0?`${n}.${e.path.map(e=>typeof e==`object`&&e&&`key`in e?String(e.key):String(e)).join(`.`)}`:n;o.push({path:t,message:e.message})}else a[n]=l.value;s.delete(n)}if(i!==`delete`)for(let e of s)i===`reject`?o.push({path:e,message:`Undeclared key`}):i===`ignore`&&(a[e]=r[e]);if(o.length>0)throw new e.t(o);return a}function a(e,a){r(e);for(let r in e){let i=e[r];t(r,i),n(r,i)}return i(e,a??{})}const o=a;exports.createEnv=a,exports.default=o;
1
+ Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});const e=require(`./core-Byznlywt.cjs`),t=require(`./shared-Sfv4WYag.cjs`);function n(t,n){if(typeof n==`string`)throw new e.t([{path:t,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(t,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 e.t([{path:t,message:`Invalid validator: expected a Standard Schema 1.0 validator (must have "~standard" property). Import from "arkenv" to use ArkType schemas.`}])}function i(t){if(!t||typeof t!=`object`||Array.isArray(t))throw new e.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`}=r,u={},d=[],f=new Set(Object.keys(i)),p={...i},m=[];if(c){let{jsonSchema:e,hasJsonSchema:r}=a(n,m);r&&(p=t.t(p,t.n(e),{arrayFormat:l}))}for(let t in n){let r=n[t],i=p[t];if(!r||typeof r!=`object`||!(`~standard`in r))throw new e.t([{path:t,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 e.t([{path:t,message:`Async validation is not supported. ArkEnv is synchronous.`}]);if(a.issues)for(let e of a.issues){let n=o(t,e.path),r=e.message;c&&m.includes(t)&&(r+=` (Hint: coercion is enabled by default, but the validator for '${t}' lacks Standard JSON Schema support.)`),d.push({path:n,message:r})}else u[t]=a.value;f.delete(t)}if(s!==`delete`)for(let e of f)s===`reject`?d.push({path:e,message:`Undeclared key`}):s===`ignore`&&(u[e]=p[e]);if(d.length>0)throw new e.t(d);return u}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) {
@@ -22,6 +22,24 @@ type ParseStandardConfig = {
22
22
  * @default "delete"
23
23
  */
24
24
  onUndeclaredKey?: "ignore" | "delete" | "reject";
25
+ /**
26
+ * Whether to perform best-effort coercion on the environment variables.
27
+ * Coercion requires validators that implement the StandardJSONSchemaV1 spec
28
+ * (e.g. Zod, Valibot).
29
+ *
30
+ * @see https://standard-schema.dev
31
+ * @default true
32
+ */
33
+ coerce?: boolean;
34
+ /**
35
+ * The format to use for array parsing when coercion is enabled.
36
+ *
37
+ * - `comma` (default): Strings are split by comma and trimmed.
38
+ * - `json`: Strings are parsed as JSON.
39
+ *
40
+ * @default "comma"
41
+ */
42
+ arrayFormat?: "comma" | "json";
25
43
  };
26
44
  //#endregion
27
45
  //#region src/standard.d.ts
@@ -35,8 +53,8 @@ type StandardEnvConfig = ParseStandardConfig;
35
53
  * This entry is ArkType-free - ArkType is never imported, even transitively.
36
54
  * Use this when your project must not depend on ArkType.
37
55
  *
38
- * @param def - An object mapping variable names to Standard Schema validators
39
- * @param config - Optional configuration
56
+ * @param def An object mapping variable names to Standard Schema validators
57
+ * @param config Optional configuration
40
58
  * @returns The validated environment variables
41
59
  * @throws An {@link ArkEnvError} if validation fails
42
60
  *
@@ -1 +1 @@
1
- {"version":3,"file":"standard.d.cts","names":[],"sources":["../src/parse-standard.ts","../src/standard.ts"],"mappings":";;;;;;KAMY,mBAAA;EAAmB;;;EAI9B,GAAA,GAAM,MAAA;EAAA;;;;;;;ACCP;;;;;EDYC,eAAA;AAAA;;;;AAjBD;;KCKY,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":";;;;;;KAOY,mBAAA;EAAmB;;;EAI9B,GAAA,GAAM,MAAA;EAAA;;;;;;;;;ACAP;;;EDaC,eAAA;ECbkD;AAwBnD;;;;;;;EDFC,MAAA;ECKiD;;;;;;;;EDIjD,WAAA;AAAA;;;;AAnCD;;KCIY,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-Bx89Loyb.mjs";
1
+ import { i as StandardSchemaV1 } from "./index-Br22fqkz.mjs";
2
2
 
3
3
  //#region src/parse-standard.d.ts
4
4
  /**
@@ -22,6 +22,24 @@ type ParseStandardConfig = {
22
22
  * @default "delete"
23
23
  */
24
24
  onUndeclaredKey?: "ignore" | "delete" | "reject";
25
+ /**
26
+ * Whether to perform best-effort coercion on the environment variables.
27
+ * Coercion requires validators that implement the StandardJSONSchemaV1 spec
28
+ * (e.g. Zod, Valibot).
29
+ *
30
+ * @see https://standard-schema.dev
31
+ * @default true
32
+ */
33
+ coerce?: boolean;
34
+ /**
35
+ * The format to use for array parsing when coercion is enabled.
36
+ *
37
+ * - `comma` (default): Strings are split by comma and trimmed.
38
+ * - `json`: Strings are parsed as JSON.
39
+ *
40
+ * @default "comma"
41
+ */
42
+ arrayFormat?: "comma" | "json";
25
43
  };
26
44
  //#endregion
27
45
  //#region src/standard.d.ts
@@ -35,8 +53,8 @@ type StandardEnvConfig = ParseStandardConfig;
35
53
  * This entry is ArkType-free - ArkType is never imported, even transitively.
36
54
  * Use this when your project must not depend on ArkType.
37
55
  *
38
- * @param def - An object mapping variable names to Standard Schema validators
39
- * @param config - Optional configuration
56
+ * @param def An object mapping variable names to Standard Schema validators
57
+ * @param config Optional configuration
40
58
  * @returns The validated environment variables
41
59
  * @throws An {@link ArkEnvError} if validation fails
42
60
  *
@@ -1 +1 @@
1
- {"version":3,"file":"standard.d.mts","names":[],"sources":["../src/parse-standard.ts","../src/standard.ts"],"mappings":";;;;;;KAMY,mBAAA;EAAmB;;;EAI9B,GAAA,GAAM,MAAA;EAAA;;;;;;;ACCP;;;;;EDYC,eAAA;AAAA;;;;AAjBD;;KCKY,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":";;;;;;KAOY,mBAAA;EAAmB;;;EAI9B,GAAA,GAAM,MAAA;EAAA;;;;;;;;;ACAP;;;EDaC,eAAA;ECbkD;AAwBnD;;;;;;;EDFC,MAAA;ECKiD;;;;;;;;EDIjD,WAAA;AAAA;;;;AAnCD;;KCIY,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{t as e}from"./core-B51xxxje.mjs";function t(t,n){if(typeof n==`string`)throw new e([{path:t,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 n(t,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 e([{path:t,message:`Invalid validator: expected a Standard Schema 1.0 validator (must have "~standard" property). Import from "arkenv" to use ArkType schemas.`}])}function r(t){if(!t||typeof t!=`object`||Array.isArray(t))throw new e([{path:``,message:`Invalid schema: expected an object mapping in "standard" mode.`}])}function i(t,n){let{env:r=process.env,onUndeclaredKey:i=`delete`}=n,a={},o=[],s=new Set(Object.keys(r));for(let n in t){let i=t[n],c=r[n];if(!i||typeof i!=`object`||!(`~standard`in i))throw new e([{path:n,message:`Invalid schema: expected a Standard Schema 1.0 validator (e.g. Zod, Valibot) in 'standard' mode.`}]);let l=i[`~standard`].validate(c);if(l instanceof Promise)throw new e([{path:n,message:`Async validation is not supported. ArkEnv is synchronous.`}]);if(l.issues)for(let e of l.issues){let t=e.path&&e.path.length>0?`${n}.${e.path.map(e=>typeof e==`object`&&e&&`key`in e?String(e.key):String(e)).join(`.`)}`:n;o.push({path:t,message:e.message})}else a[n]=l.value;s.delete(n)}if(i!==`delete`)for(let e of s)i===`reject`?o.push({path:e,message:`Undeclared key`}):i===`ignore`&&(a[e]=r[e]);if(o.length>0)throw new e(o);return a}function a(e,a){r(e);for(let r in e){let i=e[r];t(r,i),n(r,i)}return i(e,a??{})}const o=a;export{a as createEnv,o as default};
1
+ import{t as e}from"./core-B51xxxje.mjs";import{n as t,t as n}from"./shared-_ck4b4vs.mjs";function r(t,n){if(typeof n==`string`)throw new e([{path:t,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 i(t,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 e([{path:t,message:`Invalid validator: expected a Standard Schema 1.0 validator (must have "~standard" property). Import from "arkenv" to use ArkType schemas.`}])}function a(t){if(!t||typeof t!=`object`||Array.isArray(t))throw new e([{path:``,message:`Invalid schema: expected an object mapping in "standard" mode.`}])}function o(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 s(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 c(r,i){let{env:a=process.env,onUndeclaredKey:c=`delete`,coerce:l=!0,arrayFormat:u=`comma`}=i,d={},f=[],p=new Set(Object.keys(a)),m={...a},h=[];if(l){let{jsonSchema:e,hasJsonSchema:i}=o(r,h);i&&(m=n(m,t(e),{arrayFormat:u}))}for(let t in r){let n=r[t],i=m[t];if(!n||typeof n!=`object`||!(`~standard`in n))throw new e([{path:t,message:`Invalid schema: expected a Standard Schema 1.0 validator (e.g. Zod, Valibot) in 'standard' mode.`}]);let a=n[`~standard`].validate(i);if(a instanceof Promise)throw new e([{path:t,message:`Async validation is not supported. ArkEnv is synchronous.`}]);if(a.issues)for(let e of a.issues){let n=s(t,e.path),r=e.message;l&&h.includes(t)&&(r+=` (Hint: coercion is enabled by default, but the validator for '${t}' lacks Standard JSON Schema support.)`),f.push({path:n,message:r})}else d[t]=a.value;p.delete(t)}if(c!==`delete`)for(let e of p)c===`reject`?f.push({path:e,message:`Undeclared key`}):c===`ignore`&&(d[e]=m[e]);if(f.length>0)throw new e(f);return d}function l(e,t){a(e);for(let t in e){let n=e[t];r(t,n),i(t,n)}return c(e,t??{})}const u=l;export{l as createEnv,u 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 { 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};\n\n/**\n * Standard Schema 1.0 parser dispatcher.\n * This helper implements parsing for the `arkenv/standard` entry point.\n *\n * @param def - An object mapping environment variable keys to Standard Schema 1.0 validators.\n * @param config - Parsing options (env source, undeclared key handling).\n */\nexport function parseStandard(\n\tdef: Record<string, unknown>,\n\tconfig: ParseStandardConfig,\n) {\n\tconst { env = process.env, onUndeclaredKey = \"delete\" } = config;\n\tconst output: Record<string, unknown> = {};\n\tconst errors: ValidationIssue[] = [];\n\tconst envKeys = new Set(Object.keys(env));\n\n\t// 1. Validate declared keys\n\tfor (const key in def) {\n\t\tconst validator = def[key];\n\t\tconst value = env[key];\n\n\t\t// Check if it's a Standard Schema validator\n\t\tif (\n\t\t\t!validator ||\n\t\t\ttypeof validator !== \"object\" ||\n\t\t\t!(\"~standard\" in validator)\n\t\t) {\n\t\t\tthrow new 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 =\n\t\t\t\t\tissue.path && issue.path.length > 0\n\t\t\t\t\t\t? `${key}.${issue.path\n\t\t\t\t\t\t\t\t.map((segment) =>\n\t\t\t\t\t\t\t\t\tsegment !== null &&\n\t\t\t\t\t\t\t\t\ttypeof segment === \"object\" &&\n\t\t\t\t\t\t\t\t\t\"key\" in segment\n\t\t\t\t\t\t\t\t\t\t? String(segment.key)\n\t\t\t\t\t\t\t\t\t\t: String(segment),\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t.join(\".\")}`\n\t\t\t\t\t\t: key;\n\t\t\t\terrors.push({\n\t\t\t\t\tpath: issuePath,\n\t\t\t\t\tmessage: issue.message,\n\t\t\t\t});\n\t\t\t}\n\t\t} else {\n\t\t\toutput[key] = result.value;\n\t\t}\n\n\t\tenvKeys.delete(key);\n\t}\n\n\t// 2. Handle undeclared keys\n\tif (onUndeclaredKey !== \"delete\") {\n\t\tfor (const key of envKeys) {\n\t\t\tif (onUndeclaredKey === \"reject\") {\n\t\t\t\terrors.push({\n\t\t\t\t\tpath: key,\n\t\t\t\t\tmessage: \"Undeclared key\",\n\t\t\t\t});\n\t\t\t} else if (onUndeclaredKey === \"ignore\") {\n\t\t\t\toutput[key] = env[key];\n\t\t\t}\n\t\t}\n\t}\n\n\tif (errors.length > 0) {\n\t\tthrow new ArkEnvError(errors);\n\t}\n\n\treturn output;\n}\n","import 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":"wCAMA,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,CC3BJ,SAAgB,EACf,EACA,EACC,CACD,GAAM,CAAE,MAAM,QAAQ,IAAK,kBAAkB,UAAa,EACpD,EAAkC,EAAE,CACpC,EAA4B,EAAE,CAC9B,EAAU,IAAI,IAAI,OAAO,KAAK,EAAI,CAAC,CAGzC,IAAK,IAAM,KAAO,EAAK,CACtB,IAAM,EAAY,EAAI,GAChB,EAAQ,EAAI,GAGlB,GACC,CAAC,GACD,OAAO,GAAc,UACrB,EAAE,cAAe,GAEjB,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,EACL,EAAM,MAAQ,EAAM,KAAK,OAAS,EAC/B,GAAG,EAAI,GAAG,EAAM,KACf,IAAK,GAEL,OAAO,GAAY,UADnB,GAEA,QAAS,EACN,OAAO,EAAQ,IAAI,CACnB,OAAO,EAAQ,CAClB,CACA,KAAK,IAAI,GACV,EACJ,EAAO,KAAK,CACX,KAAM,EACN,QAAS,EAAM,QACf,CAAC,MAGH,EAAO,GAAO,EAAO,MAGtB,EAAQ,OAAO,EAAI,CAIpB,GAAI,IAAoB,aAClB,IAAM,KAAO,EACb,IAAoB,SACvB,EAAO,KAAK,CACX,KAAM,EACN,QAAS,iBACT,CAAC,CACQ,IAAoB,WAC9B,EAAO,GAAO,EAAI,IAKrB,GAAI,EAAO,OAAS,EACnB,MAAM,IAAI,EAAY,EAAO,CAG9B,OAAO,ECjFR,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 { StandardSchemaV1 } from \"@repo/types\";\nimport { applyCoercion, findCoercionPaths } 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\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} = config;\n\tconst output: Record<string, unknown> = {};\n\tconst errors: ValidationIssue[] = [];\n\tconst envKeys = new Set(Object.keys(env));\n\n\tlet coercedEnv: Record<string, unknown> = { ...env };\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":"yFAMA,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,CCZJ,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,GAAO,EAC7B,EAA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D,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,ECpNR,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.11.1",
4
+ "version": "0.12.0",
5
5
  "description": "Typesafe environment variables parsing and validation with ArkType",
6
6
  "main": "./dist/index.cjs",
7
7
  "module": "./dist/index.mjs",
@@ -63,8 +63,8 @@
63
63
  "typescript": "6.0.3",
64
64
  "vitest": "4.1.5",
65
65
  "zod": "4.4.1",
66
- "@repo/scope": "0.1.3",
67
- "@repo/types": "0.1.0"
66
+ "@repo/types": "0.1.0",
67
+ "@repo/scope": "0.1.3"
68
68
  },
69
69
  "peerDependencies": {
70
70
  "arktype": "^2.1.22"
@@ -87,7 +87,7 @@
87
87
  {
88
88
  "name": "arkenv/standard",
89
89
  "path": "dist/standard.mjs",
90
- "limit": "1.1 kB",
90
+ "limit": "2.3 kB",
91
91
  "import": "*"
92
92
  },
93
93
  {
@@ -101,6 +101,7 @@
101
101
  "build": "tsdown",
102
102
  "size": "size-limit --json > .size-limit.json",
103
103
  "test:once": "vitest run",
104
+ "test:dist": "vitest run test/dist.test.ts",
104
105
  "typecheck": "tsc --noEmit",
105
106
  "clean": "rimraf dist node_modules",
106
107
  "test": "vitest",