@@ -16,8 +16,9 @@ import { styleText } from "./style-text";
1616 * maintained manually based on ArkType's internal error reporting behavior.
1717 *
1818 * @see https://arktype.io/docs/intro
19+ * @internal
1920 */
20- const ARKTYPE_CODE_MAP = {
21+ const ARKTYPE_CODE_MAP : Record < string , EnvIssueCode > = {
2122 required : "MISSING_VARIABLE" ,
2223 pattern : "PATTERN_MISMATCH" ,
2324 min : "VALUE_TOO_SMALL" ,
@@ -29,26 +30,25 @@ const ARKTYPE_CODE_MAP = {
2930 sequence : "INVALID_TYPE" ,
3031 intersection : "INVALID_TYPE" ,
3132 union : "INVALID_TYPE" ,
32- } satisfies Record < string , EnvIssueCode > ;
33+ } ;
3334
3435/**
3536 * Map an ArkType validation error code to a normalized EnvIssueCode.
3637 *
3738 * @param engineCode The raw code returned by the ArkType engine
3839 * @returns The normalized EnvIssueCode classification
40+ * @internal
3941 */
4042export function mapArkTypeCode ( engineCode : string ) : EnvIssueCode {
41- return (
42- ( ARKTYPE_CODE_MAP as Record < string , EnvIssueCode > ) [ engineCode ] ??
43- "INVALID_FORMAT"
44- ) ;
43+ return ARKTYPE_CODE_MAP [ engineCode ] ?? "INVALID_FORMAT" ;
4544}
4645
4746/**
4847 * Extract validation boundary metadata from an ArkType error object.
4948 *
5049 * @param error The raw error object from ArkType
5150 * @returns An object containing normalized min and/or max values if present
51+ * @internal
5252 */
5353export function getArkTypeMeta ( error : any ) : { min ?: number ; max ?: number } {
5454 const min = error . min ?? error . rule ;
@@ -59,6 +59,16 @@ export function getArkTypeMeta(error: any): { min?: number; max?: number } {
5959 } ;
6060}
6161
62+ /**
63+ * Mapping of Standard Schema validation issue codes to normalized EnvIssueCode classification codes.
64+ *
65+ * This serves as an internal translation map specifically for Standard Schema validators
66+ * (such as Zod or Valibot) to map their engine-specific error keys to our unified union type.
67+ * It is not a duplicate Source of Truth for the allowed issue codes themselves, which are
68+ * defined solely by the `EnvIssueCode` type in `core.ts`.
69+ *
70+ * @internal
71+ */
6272const STANDARD_CODE_MAP : Record < string , EnvIssueCode > = {
6373 too_small : "VALUE_TOO_SMALL" ,
6474 too_big : "VALUE_TOO_LARGE" ,
@@ -74,6 +84,7 @@ const STANDARD_CODE_MAP: Record<string, EnvIssueCode> = {
7484 * @param message The error message associated with the issue
7585 * @param receivedVal The raw value received by the validator
7686 * @returns The normalized EnvIssueCode classification
87+ * @internal
7788 */
7889export function mapStandardCode (
7990 engineCode : string ,
@@ -102,6 +113,7 @@ export function mapStandardCode(
102113 *
103114 * @param issue The raw issue from Standard Schema
104115 * @returns An object containing normalized min and/or max values if present
116+ * @internal
105117 */
106118export function getStandardMeta ( issue : any ) : { min ?: number ; max ?: number } {
107119 const min = issue . minimum ?? issue . min ;
@@ -117,6 +129,7 @@ export function getStandardMeta(issue: any): { min?: number; max?: number } {
117129 *
118130 * @param parseFn The function that parses the environment variables and might throw an ArkEnvError
119131 * @returns A SafeArkEnvResult containing either the parsed data or the caught ArkEnvError
132+ * @internal
120133 */
121134export function executeSafe < T > ( parseFn : ( ) => T ) : SafeArkEnvResult < T > {
122135 try {
@@ -139,6 +152,7 @@ export function executeSafe<T>(parseFn: () => T): SafeArkEnvResult<T> {
139152 * @param expected The expected type or value shape description
140153 * @param received The raw value received (redacted in string formatting if sensitive)
141154 * @returns A fully populated EnvIssue
155+ * @internal
142156 */
143157export function buildEnvIssue (
144158 path : string ,
@@ -165,6 +179,7 @@ export function buildEnvIssue(
165179 * @param path The environment variable name/path under validation
166180 * @param config Optional config containing the debugSecrets override
167181 * @returns The formatted message string
182+ * @internal
168183 */
169184export function formatStandardIssueMessage (
170185 baseMessage : string ,
@@ -203,6 +218,7 @@ export function formatStandardIssueMessage(
203218 * @param path The environment variable name/path under validation
204219 * @param debugSecrets Optional override for debug secrets mode
205220 * @returns The message with redacted/styled `(was …)` value
221+ * @internal
206222 */
207223export function redactMessageWasValue (
208224 message : string ,
0 commit comments