@arkenv/core 1.0.0-alpha.6 → 1.0.0-alpha.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -636,7 +636,7 @@ function parse(def, config) {
636
636
  };
637
637
  } : void 0);
638
638
  const validatedEnv = schemaWithKeys(coercedEnv);
639
- if (validatedEnv instanceof arktype.ArkErrors) throw new ArkEnvError(arkErrorsToIssues(validatedEnv, config));
639
+ if (validatedEnv instanceof arktype.ArkErrors || validatedEnv && typeof validatedEnv === "object" && (validatedEnv[" arkKind"] === "errors" || "byPath" in validatedEnv && typeof validatedEnv.byPath === "object")) throw new ArkEnvError(arkErrorsToIssues(validatedEnv, config));
640
640
  return validatedEnv;
641
641
  }
642
642
 
package/dist/index.mjs CHANGED
@@ -635,7 +635,7 @@ function parse(def, config) {
635
635
  };
636
636
  } : void 0);
637
637
  const validatedEnv = schemaWithKeys(coercedEnv);
638
- if (validatedEnv instanceof ArkErrors) throw new ArkEnvError(arkErrorsToIssues(validatedEnv, config));
638
+ if (validatedEnv instanceof ArkErrors || validatedEnv && typeof validatedEnv === "object" && (validatedEnv[" arkKind"] === "errors" || "byPath" in validatedEnv && typeof validatedEnv.byPath === "object")) throw new ArkEnvError(arkErrorsToIssues(validatedEnv, config));
639
639
  return validatedEnv;
640
640
  }
641
641
 
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","names":["t","e","$","$"],"sources":["../../internal/scope/dist/index.js","../../internal/utils/dist/boundary-access-error.js","../../internal/utils/dist/index.js","../src/arktype/index.ts","../src/arkenv.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","//#region src/utils/boundary-access-error.ts\n/**\n* `error.name` for the validation class {@link ArkEnvError}.\n*/\nconst ARKENV_ERROR_NAME = \"ArkEnvError\";\n/**\n* Build the message for a client read of a server-only env key.\n*\n* Native `Error` (name stays `\"Error\"`). Next.js taint voice\n* (`Do not … since it will leak`) plus a last-place breadcrumb\n* (`(prevented by ArkEnv)`) so agents can attribute the throw.\n* No trailing period. Shared across Next, Nuxt, Vite, and Bun —\n* \"on the client\", not \"Client Components\".\n*\n* @param key The server-only environment variable name\n* @returns The boundary access error message\n*/\nfunction boundaryAccessErrorMessage(key) {\n\treturn `Do not access server-only key '${key}' on the client since it will leak sensitive data (prevented by ArkEnv)`;\n}\n\n//#endregion\nexport { ARKENV_ERROR_NAME, boundaryAccessErrorMessage };\n//# sourceMappingURL=boundary-access-error.js.map","import { ARKENV_ERROR_NAME, boundaryAccessErrorMessage } from \"./boundary-access-error.js\";\n\n//#region src/coercion/morphs.ts\n/**\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*/\nconst coerceNumber = (s) => {\n\tif (typeof s === \"number\") return s;\n\tif (typeof s !== \"string\" || !s.trim()) return s;\n\tif (s.trim() === \"NaN\") return NaN;\n\tconst n = Number(s);\n\treturn Number.isNaN(n) ? s : 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*/\nconst coerceBoolean = (s) => {\n\tif (s === \"true\") return true;\n\tif (s === \"false\") return false;\n\treturn s;\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*/\nconst coerceJson = (s) => {\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* 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*/\nconst coerceDate = (s) => {\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\n//#endregion\n//#region src/coercion/shared.ts\n/**\n* Remove keys with empty string values from an environment record.\n*\n* When a key is set to `\"\"` (e.g. `PORT=` in a `.env` file), deleting it\n* allows the validator to treat it as missing so that defaults apply.\n*\n* @param env The environment variables record\n* @returns A new record with empty string keys removed\n*/\nconst stripEmptyStrings = (env) => {\n\tconst result = {};\n\tfor (const key in env) {\n\t\tconst value = env[key];\n\t\tif (value !== \"\") result[key] = value;\n\t}\n\treturn result;\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* 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*/\nconst findCoercionPaths = (node, path = []) => {\n\tconst results = [];\n\tif (!node || typeof node !== \"object\" || Array.isArray(node)) return results;\n\tconst n = node;\n\tif (\"const\" in n) {\n\t\tconst t = typeof n.const;\n\t\tif (t === \"number\" || t === \"boolean\") results.push({\n\t\t\tpath: [...path],\n\t\t\ttype: \"primitive\"\n\t\t});\n\t}\n\tif (\"enum\" in n && Array.isArray(n.enum)) {\n\t\tif (n.enum.some((v) => typeof v === \"number\" || typeof v === \"boolean\")) results.push({\n\t\t\tpath: [...path],\n\t\t\ttype: \"primitive\"\n\t\t});\n\t}\n\tconst type = n.type;\n\tif (type === \"number\" || type === \"integer\" || type === \"boolean\") results.push({\n\t\tpath: [...path],\n\t\ttype: \"primitive\"\n\t});\n\telse if (type === \"string\" && \"format\" in n && (n.format === \"date-time\" || n.format === \"date\")) results.push({\n\t\tpath: [...path],\n\t\ttype: \"date\"\n\t});\n\telse if (type === \"object\") {\n\t\tif (n.properties && Object.keys(n.properties).length > 0) {\n\t\t\tresults.push({\n\t\t\t\tpath: [...path],\n\t\t\t\ttype: \"object\"\n\t\t\t});\n\t\t\tfor (const key in n.properties) results.push(...findCoercionPaths(n.properties[key], [...path, key]));\n\t\t}\n\t} else if (type === \"array\") {\n\t\tresults.push({\n\t\t\tpath: [...path],\n\t\t\ttype: \"array\"\n\t\t});\n\t\tif (n.items) if (Array.isArray(n.items)) n.items.forEach((item, index) => {\n\t\t\tresults.push(...findCoercionPaths(item, [...path, String(index)]));\n\t\t});\n\t\telse results.push(...findCoercionPaths(n.items, [...path, \"*\"]));\n\t}\n\tfor (const comb of [\n\t\t\"anyOf\",\n\t\t\"allOf\",\n\t\t\"oneOf\"\n\t]) if (n[comb] && Array.isArray(n[comb])) for (const branch of n[comb]) results.push(...findCoercionPaths(branch, path));\n\tconst seen = /* @__PURE__ */ new Set();\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* 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*/\nconst applyCoercion = (data, targets, options = {}) => {\n\tconst { arrayFormat = \"comma\" } = options;\n\tconst splitString = (val) => {\n\t\tif (arrayFormat === \"json\") try {\n\t\t\treturn JSON.parse(val);\n\t\t} catch {\n\t\t\treturn val;\n\t\t}\n\t\treturn val.trim() ? val.split(\",\").map((s) => s.trim()) : [];\n\t};\n\tconst coerceValue = (val, type) => {\n\t\tif (type === \"array\" && typeof val === \"string\") return splitString(val);\n\t\tif (type === \"object\" && typeof val === \"string\") return coerceJson(val);\n\t\tif (type === \"date\" && typeof val === \"string\") return coerceDate(val);\n\t\tif (type === \"primitive\") {\n\t\t\tif (Array.isArray(val)) return val.map((item) => {\n\t\t\t\tif (typeof item !== \"string\") return item;\n\t\t\t\tconst n = coerceNumber(item);\n\t\t\t\treturn typeof n === \"number\" ? n : coerceBoolean(item);\n\t\t\t});\n\t\t\tif (typeof val !== \"string\") return val;\n\t\t\tconst n = coerceNumber(val);\n\t\t\treturn typeof n === \"number\" ? n : coerceBoolean(val);\n\t\t}\n\t\treturn val;\n\t};\n\tif (typeof data !== \"object\" || data === null) {\n\t\tconst root = targets.find((t) => t.path.length === 0);\n\t\tif (root) return coerceValue(data, root.type);\n\t\treturn data;\n\t}\n\tconst sorted = [...targets].sort((a, b) => a.path.length - b.path.length);\n\tconst updateAtPath = (current, path, fn) => {\n\t\tif (path.length === 0) return fn(current);\n\t\tconst [key, ...rest] = path;\n\t\tif (key === \"*\") {\n\t\t\tif (Array.isArray(current)) {\n\t\t\t\tlet changed = false;\n\t\t\t\tconst nextArr = current.map((item) => {\n\t\t\t\t\tconst nextVal = updateAtPath(item, rest, fn);\n\t\t\t\t\tif (nextVal !== item) changed = true;\n\t\t\t\t\treturn nextVal;\n\t\t\t\t});\n\t\t\t\treturn changed ? nextArr : current;\n\t\t\t}\n\t\t\treturn current;\n\t\t}\n\t\tif (!current || typeof current !== \"object\") return current;\n\t\tif (Array.isArray(current)) {\n\t\t\tconst index = Number(key);\n\t\t\tif (!Number.isNaN(index) && index >= 0 && index < current.length) {\n\t\t\t\tconst nextVal = updateAtPath(current[index], rest, fn);\n\t\t\t\tif (nextVal !== current[index]) {\n\t\t\t\t\tconst copy = [...current];\n\t\t\t\t\tcopy[index] = nextVal;\n\t\t\t\t\treturn copy;\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn current;\n\t\t}\n\t\tif (Object.hasOwn(current, key)) {\n\t\t\tconst nextVal = updateAtPath(current[key], rest, fn);\n\t\t\tif (nextVal !== current[key]) return {\n\t\t\t\t...current,\n\t\t\t\t[key]: nextVal\n\t\t\t};\n\t\t}\n\t\treturn current;\n\t};\n\tlet result = data;\n\tfor (const t of sorted) if (t.path.length > 0) result = updateAtPath(result, t.path, (val) => coerceValue(val, t.type));\n\treturn result;\n};\n\n//#endregion\n//#region src/coercion/environment.ts\n/**\n* Prepare an environment record by optionally stripping empty strings and applying coercion.\n*\n* @param env The raw environment variables\n* @param emptyAsUndefined Whether to strip empty string values before processing\n* @param arrayFormat The format to use for array coercion\n* @param getSchema Optional callback that returns a JSON Schema and whether it exists,\n* used to determine coercion targets. When omitted, no coercion is performed.\n* @returns The processed environment, the coerced environment, and any missing schema keys\n*/\nfunction coerceEnvironment(env, emptyAsUndefined, arrayFormat, getSchema) {\n\tconst processedEnv = emptyAsUndefined ? stripEmptyStrings(env) : env;\n\tlet coercedEnv = { ...processedEnv };\n\tconst missingKeys = [];\n\tif (getSchema) {\n\t\tconst result = getSchema();\n\t\tmissingKeys.push(...result.missingKeys || []);\n\t\tif (result.hasSchema) coercedEnv = applyCoercion(coercedEnv, findCoercionPaths(result.schema), { arrayFormat });\n\t}\n\treturn {\n\t\tprocessedEnv,\n\t\tcoercedEnv,\n\t\tmissingKeys\n\t};\n}\n\n//#endregion\n//#region src/utils/indent.ts\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*/\nconst indent = (str, amt = 2, { dontDetectNewlines = false } = {}) => {\n\tif (!dontDetectNewlines) return str.split(\"\\n\").map((line) => `${\" \".repeat(amt)}${line}`).join(\"\\n\");\n\treturn `${\" \".repeat(amt)}${str}`;\n};\n\n//#endregion\n//#region src/utils/style-text.ts\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*/\nconst colors = {\n\tred: \"\\x1B[31m\",\n\tyellow: \"\\x1B[33m\",\n\tcyan: \"\\x1B[36m\",\n\treset: \"\\x1B[0m\"\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 = () => typeof process !== \"undefined\" && process.versions != null && process.versions.node != null;\n/**\n* Check if colors should be disabled based on environment\n* Respects NO_COLOR, CI environment variables, and TTY detection\n*/\nconst shouldDisableColors = () => {\n\tif (!isNode()) return true;\n\tif (process.env.NO_COLOR !== void 0) return true;\n\tif (process.env.CI !== void 0) return true;\n\tif (process.stdout && !process.stdout.isTTY) return true;\n\treturn false;\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*/\nconst styleText = (color, text) => {\n\tif (isNode() && !shouldDisableColors()) return `${colors[color]}${text}${colors.reset}`;\n\treturn text;\n};\n\n//#endregion\n//#region src/core.ts\n/**\n* Format a list of normalized environment issues into a single styled string.\n*\n* @param issues - The array of normalized issues to format\n* @returns The formatted and styled error report string\n*/\nfunction formatIssues(issues) {\n\treturn issues.map((issue) => {\n\t\treturn `${styleText(\"yellow\", issue.path)} ${issue.message.trimStart()}`;\n\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* 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*/\nvar ArkEnvError = class extends Error {\n\tconstructor(issues, message = \"Errors found while validating environment variables\") {\n\t\tconst formattedIssues = formatIssues(issues);\n\t\tsuper(`${styleText(\"red\", message)}\\n${indent(formattedIssues)}\\n`);\n\t\tthis.name = ARKENV_ERROR_NAME;\n\t\tthis.issues = issues;\n\t}\n};\nObject.defineProperty(ArkEnvError, \"name\", { value: ARKENV_ERROR_NAME });\n\n//#endregion\n//#region src/guards.ts\n/**\n* Throws if the given value is a string (ArkType DSL) in standard mode.\n* @internal\n*/\nfunction assertNotArkTypeDsl(key, value) {\n\tif (typeof value === \"string\") throw new ArkEnvError([{\n\t\tpath: key,\n\t\tmessage: \"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\tcode: \"INVALID_SCHEMA\"\n\t}]);\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*/\nfunction assertStandardSchema(key, value) {\n\tconst std = value && typeof value === \"object\" && \"~standard\" in value && value[\"~standard\"];\n\tif (!std || typeof std !== \"object\" || !(\"validate\" in std) || typeof std.validate !== \"function\") throw new ArkEnvError([{\n\t\tpath: key,\n\t\tmessage: \"Invalid validator: expected a Standard Schema 1.0 validator (must have \\\"~standard\\\" property). Import from \\\"arkenv\\\" to use ArkType schemas.\",\n\t\tcode: \"INVALID_SCHEMA\"\n\t}]);\n}\n/**\n* Throws if `def` is not a plain object (i.e. not a valid schema map).\n* @internal\n*/\nfunction assertStandardSchemaMap(def) {\n\tif (!def || typeof def !== \"object\" || Array.isArray(def)) throw new ArkEnvError([{\n\t\tpath: \"\",\n\t\tmessage: \"Invalid schema: expected an object mapping in \\\"standard\\\" mode.\",\n\t\tcode: \"INVALID_SCHEMA\"\n\t}]);\n}\n\n//#endregion\n//#region src/utils/redact.ts\n/**\n* Regex pattern matching sensitive environment variable names.\n*\n* Matches keywords commonly associated with secrets (e.g. secret, key, token,\n* password, pass, auth, jwt, cert, credential, db_url). Excludes public keys\n* via the `shouldRedact` helper.\n*\n* @see {@link shouldRedact}\n*/\nconst SENSITIVE_PATTERN = /secret|(_|^)key(_|$)|token|(_|^)password(_|$)|(_|^)pass(_|$)|(_|^)auth(_|$)|jwt|cert|credential|database_url|db_url/i;\n/**\n* Check if debug secrets mode is enabled.\n*\n* Debug secrets mode can be enabled programmatically via the `debugSecrets` config option,\n* or globally by setting the `ARKENV_DEBUG_SECRETS` environment variable to `\"true\"` or `\"1\"`.\n*\n* @param configSecrets Programmatic override option for debugging secrets\n* @returns A boolean indicating if debug secrets mode is active\n*/\nfunction isDebugSecrets(configSecrets) {\n\tif (configSecrets !== void 0) return configSecrets;\n\tif (typeof process === \"undefined\") return false;\n\tconst val = process.env.ARKENV_DEBUG_SECRETS;\n\treturn val === \"true\" || val === \"1\";\n}\n/**\n* Determine if an environment variable path matches sensitive keyword patterns.\n*\n* By default, environment variables that contain sensitive keywords (e.g. 'secret', 'key',\n* 'token', 'password', 'auth', 'jwt', 'cert', 'credential', 'db_url') are flagged for redaction,\n* unless they are explicitly marked as public (e.g., matching 'public').\n*\n* Redaction prevents sensitive values from being logged or printed to the terminal\n* when environment validation fails.\n*\n* @param path The environment variable name/path under validation\n* @returns A boolean indicating if the path is sensitive and should be redacted\n*/\nfunction shouldRedact(path) {\n\treturn SENSITIVE_PATTERN.test(path) && !/public/i.test(path);\n}\n/**\n* Safely format and serialize an environment value for error reporting.\n*\n* Serializes primitive values and objects while redacting sensitive values if debugSecrets is disabled.\n* Limits object and array serialization to the first 3 keys/elements to prevent excessively large log outputs.\n*\n* @param val The raw received environment variable value\n* @param path The variable name/path under validation\n* @param options Configuration options, including debugSecrets override\n* @returns The formatted string representation of the value\n*/\nfunction safeStringify(val, path, options) {\n\tconst debug = isDebugSecrets(options?.debugSecrets);\n\tif (val === void 0) return \"missing\";\n\tif (val === null) return \"null\";\n\tif (!debug && shouldRedact(path)) return \"[REDACTED]\";\n\tif (typeof val === \"string\") return JSON.stringify(val);\n\tif (typeof val === \"number\" || typeof val === \"boolean\" || typeof val === \"bigint\") return String(val);\n\tif (typeof val === \"symbol\") return val.toString();\n\tif (typeof val === \"function\") return \"[Function]\";\n\tif (val && typeof val === \"object\") try {\n\t\tif (Array.isArray(val)) {\n\t\t\tconst res = val.slice(0, 3).map((x) => safeStringify(x, path, options));\n\t\t\tif (val.length > 3) res.push(`...(+${val.length - 3} more)`);\n\t\t\treturn `[${res.join(\", \")}]`;\n\t\t}\n\t\tconst keys = Object.keys(val);\n\t\tconst res = keys.slice(0, 3).map((k) => `${k}: ${safeStringify(val[k], path, options)}`);\n\t\tif (keys.length > 3) res.push(`...(+${keys.length - 3} more)`);\n\t\treturn `{ ${res.join(\", \")} }`;\n\t} catch {\n\t\treturn Object.prototype.toString.call(val);\n\t}\n\treturn String(val);\n}\n\n//#endregion\n//#region src/utils/errors.ts\n/**\n* Mapping of Standard Schema validation issue codes to normalized EnvIssueCode classification codes.\n*\n* This serves as an internal translation map specifically for Standard Schema validators\n* (such as Zod or Valibot) to map their engine-specific error keys to our unified union type.\n* It is not a duplicate Source of Truth for the allowed issue codes themselves, which are\n* defined solely by the `EnvIssueCode` type in `core.ts`.\n*\n* @internal\n*/\nconst STANDARD_CODE_MAP = {\n\ttoo_small: \"VALUE_TOO_SMALL\",\n\ttoo_big: \"VALUE_TOO_LARGE\",\n\tinvalid_string: \"INVALID_FORMAT\",\n\tinvalid_date: \"INVALID_FORMAT\",\n\tcustom: \"INVALID_FORMAT\"\n};\n/**\n* Map a Standard Schema validation issue to a normalized EnvIssueCode.\n*\n* @param engineCode The raw issue code from the Standard Schema engine\n* @param message The error message associated with the issue\n* @param receivedVal The raw value received by the validator\n* @returns The normalized EnvIssueCode classification\n* @internal\n*/\nfunction mapStandardCode(engineCode, message, receivedVal) {\n\tconst msg = message.toLowerCase();\n\tif (engineCode === \"invalid_type\" && (receivedVal === void 0 || receivedVal === \"undefined\") || msg === \"required\") return \"MISSING_VARIABLE\";\n\tif (engineCode in STANDARD_CODE_MAP) return STANDARD_CODE_MAP[engineCode];\n\tif (/regex|pattern|match/.test(msg)) return \"PATTERN_MISMATCH\";\n\treturn \"INVALID_TYPE\";\n}\n/**\n* Extract validation boundary metadata from a Standard Schema issue.\n*\n* @param issue The raw issue from Standard Schema\n* @returns An object containing normalized min and/or max values if present\n* @internal\n*/\nfunction getStandardMeta(issue) {\n\tconst min = issue.minimum ?? issue.min;\n\tconst max = issue.maximum ?? issue.max;\n\treturn {\n\t\t...typeof min === \"number\" ? { min } : {},\n\t\t...typeof max === \"number\" ? { max } : {}\n\t};\n}\n/**\n* Execute a parser function and return a SafeArkEnvResult.\n*\n* @param parseFn The function that parses the environment variables and might throw an ArkEnvError\n* @returns A SafeArkEnvResult containing either the parsed data or the caught ArkEnvError\n* @internal\n*/\nfunction safeExecute(parseFn) {\n\ttry {\n\t\treturn {\n\t\t\tsuccess: true,\n\t\t\tdata: parseFn()\n\t\t};\n\t} catch (error) {\n\t\tif (error instanceof ArkEnvError) return {\n\t\t\tsuccess: false,\n\t\t\tissues: error.issues\n\t\t};\n\t\tthrow error;\n\t}\n}\n/**\n* Build a normalized {@link EnvIssue}.\n*\n* @param path The dot-separated property path/name of the environment variable\n* @param message The descriptive, user-friendly error message\n* @param code The normalized classification code for the issue\n* @param meta Additional validation metadata and engine codes\n* @param expected The expected type or value shape description\n* @param received The raw value received (redacted in string formatting if sensitive)\n* @returns A fully populated EnvIssue\n* @internal\n*/\nfunction buildEnvIssue(path, message, code, meta, expected, received) {\n\tconst issue = {\n\t\tpath,\n\t\tmessage,\n\t\tcode,\n\t\tmeta: meta ?? {}\n\t};\n\tif (expected) issue.expected = expected;\n\tif (received !== void 0) issue.received = received;\n\treturn issue;\n}\n/**\n* Format a Standard Schema validation issue message, appending a `(was …)` substring\n* and redacting sensitive values when appropriate.\n*\n* @param baseMessage The raw message from the Standard Schema validator\n* @param code The normalized issue code\n* @param expected The expected type description, if any\n* @param receivedVal The raw value received by the validator\n* @param path The environment variable name/path under validation\n* @param config Optional config containing the debugSecrets override\n* @returns The formatted message string\n* @internal\n*/\nfunction formatStandardIssueMessage(baseMessage, code, expected, receivedVal, path, config) {\n\tif (code === \"MISSING_VARIABLE\") return expected ? `must be ${expected} (was missing)` : \"is required\";\n\tif (baseMessage.includes(\"(was \")) return baseMessage;\n\tconst suffix = `(was ${styleText(\"cyan\", !isDebugSecrets(config?.debugSecrets) && shouldRedact(path) ? \"[REDACTED]\" : safeStringify(receivedVal, path, config))})`;\n\treturn expected && !baseMessage.includes(\"Expected\") ? `must be ${expected} ${suffix}` : `${baseMessage} ${suffix}`;\n}\n\n//#endregion\n//#region src/utils/standard-helpers.ts\n/**\n* Whether `value` is a plain object (`{}` / Object.create(null) style).\n* Rejects arrays, `Date`, functions, boxed primitives, etc.\n* @internal\n*/\nfunction isPlainObject(value) {\n\treturn Object.prototype.toString.call(value) === \"[object Object]\";\n}\n/**\n* Extract JSON Schema definitions from standard schema validators.\n*\n* @param def The schema dictionary mapping keys to validators\n* @param toJsonSchema Optional fallback converter when a key has no Standard JSON Schema on the value\n* @returns The generated JSON Schema, a flag indicating if any JSON Schema was found,\n* and a list of keys that do not support JSON Schema\n* @throws {ArkEnvError} When `toJsonSchema` throws or returns a non-plain object for a key\n*/\nfunction extractJsonSchema(def, toJsonSchema) {\n\tconst jsonSchema = {\n\t\ttype: \"object\",\n\t\tproperties: {}\n\t};\n\tlet hasJsonSchema = false;\n\tconst missingKeys = [];\n\tfor (const key in def) {\n\t\tconst validator = def[key];\n\t\tif (!validator) {\n\t\t\tmissingKeys.push(key);\n\t\t\tcontinue;\n\t\t}\n\t\tconst std = validator[\"~standard\"];\n\t\tif (typeof std?.jsonSchema?.input === \"function\") try {\n\t\t\tconst schema = std.jsonSchema.input({ target: \"draft-07\" });\n\t\t\tif (schema) {\n\t\t\t\tjsonSchema.properties[key] = schema;\n\t\t\t\thasJsonSchema = true;\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t} catch {}\n\t\tif (typeof validator.jsonSchema?.input === \"function\") try {\n\t\t\tconst schema = validator.jsonSchema.input({ target: \"draft-07\" });\n\t\t\tif (schema) {\n\t\t\t\tjsonSchema.properties[key] = schema;\n\t\t\t\thasJsonSchema = true;\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t} catch {}\n\t\tif (typeof validator.toJSONSchema === \"function\") try {\n\t\t\tconst schema = validator.toJSONSchema();\n\t\t\tif (schema) {\n\t\t\t\tjsonSchema.properties[key] = schema;\n\t\t\t\thasJsonSchema = true;\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t} catch {}\n\t\tif (typeof validator.toStandardJSONSchema?.v1 === \"function\") try {\n\t\t\tconst schema = validator.toStandardJSONSchema.v1();\n\t\t\tif (schema) {\n\t\t\t\tjsonSchema.properties[key] = schema;\n\t\t\t\thasJsonSchema = true;\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t} catch {}\n\t\tif (toJsonSchema) {\n\t\t\tlet converted;\n\t\t\ttry {\n\t\t\t\tconverted = toJsonSchema(validator);\n\t\t\t} catch (error) {\n\t\t\t\tthrow new ArkEnvError([buildEnvIssue(key, `toJsonSchema failed for '${key}': ${error instanceof Error ? error.message : String(error)}`, \"INVALID_SCHEMA\")]);\n\t\t\t}\n\t\t\tif (!converted) {\n\t\t\t\tmissingKeys.push(key);\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif (!isPlainObject(converted)) throw new ArkEnvError([buildEnvIssue(key, `toJsonSchema must return a plain object or undefined for '${key}'.`, \"INVALID_SCHEMA\")]);\n\t\t\tjsonSchema.properties[key] = converted;\n\t\t\thasJsonSchema = true;\n\t\t\tcontinue;\n\t\t}\n\t\tmissingKeys.push(key);\n\t}\n\treturn {\n\t\tjsonSchema,\n\t\thasJsonSchema,\n\t\tmissingKeys\n\t};\n}\n/**\n* Get the property key from a path segment.\n*\n* @param s The path segment which can be a key or a segment object\n* @returns The string representation of the property key\n*/\nfunction getProp(s) {\n\treturn typeof s === \"object\" && s !== null && \"key\" in s ? String(s.key) : String(s);\n}\n/**\n* Format standard schema validation issue path.\n*\n* @param key The base key of the environment variable\n* @param path The relative path segments of the issue\n* @returns The formatted dot-separated path string\n*/\nfunction formatIssuePath(key, path) {\n\tif (!path || path.length === 0) return key;\n\treturn [key, ...path.map(getProp)].join(\".\");\n}\n/**\n* Traverse the raw string value (attempting to parse as JSON if it represents an object/array)\n* to extract the nested value targeted by the issue path.\n*\n* @param rawVal The raw string value of the environment variable\n* @param path The path segments of the validation issue\n* @returns An object containing the resolved nested value and an optional traversal error string\n*/\nfunction traverseReceivedValue(rawVal, path) {\n\tlet receivedVal = rawVal;\n\tlet traversalError;\n\ttry {\n\t\tlet current = rawVal;\n\t\tconst trimmed = rawVal.trim();\n\t\tif (trimmed[0] === \"{\" || trimmed[0] === \"[\") try {\n\t\t\tcurrent = JSON.parse(rawVal);\n\t\t} catch (e) {\n\t\t\ttraversalError = `[Unparseable JSON: ${e.message}]`;\n\t\t}\n\t\tif (!traversalError) {\n\t\t\tfor (const seg of path) current = current?.[getProp(seg)];\n\t\t\treceivedVal = current;\n\t\t}\n\t} catch (e) {\n\t\ttraversalError = `[Traversal error: ${e.message}]`;\n\t}\n\treturn {\n\t\treceivedVal,\n\t\ttraversalError\n\t};\n}\n\n//#endregion\n//#region src/parse-standard.ts\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*/\nfunction parseStandard(def, config) {\n\tconst { env = process.env, onUndeclaredKey = \"delete\", coerce = true, arrayFormat = \"comma\", emptyAsUndefined = false, toJsonSchema } = config;\n\tconst output = {};\n\tconst errors = [];\n\tconst { processedEnv, coercedEnv, missingKeys: missingJsonSchemaKeys } = coerceEnvironment(env, emptyAsUndefined, arrayFormat, coerce ? () => {\n\t\tconst { jsonSchema, hasJsonSchema, missingKeys } = extractJsonSchema(def, toJsonSchema);\n\t\treturn {\n\t\t\tschema: jsonSchema,\n\t\t\thasSchema: hasJsonSchema,\n\t\t\tmissingKeys\n\t\t};\n\t} : void 0);\n\tconst envKeys = new Set(Object.keys(processedEnv));\n\tfor (const key in def) {\n\t\tconst validator = def[key];\n\t\tconst value = coercedEnv[key];\n\t\tif (!validator || typeof validator !== \"object\" || !(\"~standard\" in validator)) throw new ArkEnvError([buildEnvIssue(key, `Invalid schema: expected a Standard Schema 1.0 validator (e.g. Zod, Valibot) in 'standard' mode.`, \"INVALID_SCHEMA\")]);\n\t\tconst result = validator[\"~standard\"].validate(value);\n\t\tif (result instanceof Promise) throw new ArkEnvError([buildEnvIssue(key, \"Async validation is not supported. ArkEnv is synchronous.\", \"INVALID_SCHEMA\")]);\n\t\tif (result.issues) for (const issue of result.issues) {\n\t\t\tconst issuePath = formatIssuePath(key, issue.path);\n\t\t\tlet receivedVal;\n\t\t\tlet traversalError;\n\t\t\tif (key in processedEnv) {\n\t\t\t\tconst rawVal = processedEnv[key];\n\t\t\t\tif (typeof rawVal === \"string\" && issue.path?.length) {\n\t\t\t\t\tconst traversed = traverseReceivedValue(rawVal, issue.path);\n\t\t\t\t\treceivedVal = traversed.receivedVal;\n\t\t\t\t\ttraversalError = traversed.traversalError;\n\t\t\t\t} else receivedVal = rawVal;\n\t\t\t} else receivedVal = issue.received;\n\t\t\tconst code = mapStandardCode(issue.code || \"invalid_type\", issue.message || \"\", receivedVal);\n\t\t\tconst expected = issue.expected || void 0;\n\t\t\tconst meta = { ...getStandardMeta(issue) };\n\t\t\tconst iss = issue;\n\t\t\tif (iss.validation !== void 0) meta.validation = iss.validation;\n\t\t\tif (traversalError !== void 0) meta.traversalError = traversalError;\n\t\t\tlet message = formatStandardIssueMessage(issue.message || \"\", code, expected, receivedVal, issuePath, config);\n\t\t\tif (coerce && missingJsonSchemaKeys.includes(key)) message += ` (Hint: coercion is enabled by default, but the validator for '${key}' lacks Standard JSON Schema support.)`;\n\t\t\terrors.push(buildEnvIssue(issuePath, message, code, meta, expected, receivedVal));\n\t\t}\n\t\telse output[key] = result.value;\n\t\tenvKeys.delete(key);\n\t}\n\tif (onUndeclaredKey !== \"delete\") {\n\t\tfor (const key of envKeys) if (onUndeclaredKey === \"reject\") errors.push(buildEnvIssue(key, \"Undeclared key\", \"UNDECLARED_KEY\"));\n\t\telse if (onUndeclaredKey === \"ignore\") output[key] = coercedEnv[key];\n\t}\n\tif (errors.length > 0) throw new ArkEnvError(errors);\n\treturn output;\n}\n\n//#endregion\n//#region src/schema.ts\n/**\n* Extract the keys from a schema definition.\n* Supports plain objects, ArkType schemas, and Standard Schema validators.\n*\n* @param schema The schema definition to extract keys from\n* @returns An array of extracted key names\n*/\nfunction getSchemaKeys(schema) {\n\tif (!schema || typeof schema !== \"object\" && typeof schema !== \"function\") return [];\n\tif (schema.json && typeof schema.json === \"object\" && schema.json.domain === \"object\") {\n\t\tconst keys = [];\n\t\tif (Array.isArray(schema.json.required)) {\n\t\t\tfor (const r of schema.json.required) if (r && typeof r === \"object\" && \"key\" in r) keys.push(r.key);\n\t\t}\n\t\tif (Array.isArray(schema.json.optional)) {\n\t\t\tfor (const o of schema.json.optional) if (o && typeof o === \"object\" && \"key\" in o) keys.push(o.key);\n\t\t}\n\t\treturn keys;\n\t}\n\tconst std = schema[\"~standard\"];\n\tconst jsonSchemaInput = typeof std?.jsonSchema?.input === \"function\" && std.jsonSchema.input || typeof schema.jsonSchema?.input === \"function\" && schema.jsonSchema.input;\n\tif (jsonSchemaInput) try {\n\t\tconst json = jsonSchemaInput({ target: \"draft-07\" });\n\t\tif (json && typeof json === \"object\" && json.properties) return Object.keys(json.properties);\n\t} catch {}\n\tif (typeof schema.toJSONSchema === \"function\") try {\n\t\tconst json = schema.toJSONSchema();\n\t\tif (json && typeof json === \"object\" && json.properties) return Object.keys(json.properties);\n\t} catch {}\n\tif (typeof schema.toStandardJSONSchema?.v1 === \"function\") try {\n\t\tconst json = schema.toStandardJSONSchema.v1();\n\t\tif (json && typeof json === \"object\" && json.properties) return Object.keys(json.properties);\n\t} catch {}\n\treturn Object.keys(schema);\n}\n\n//#endregion\n//#region src/schema-capture.ts\nconst SCHEMA_CAPTURE_KEY = \"__ARKENV_SCHEMA_CAPTURE__\";\n/**\n* Read the process-global schema-capture bag so separately loaded copies of\n* `@arkenv/core` / `@arkenv/standard` (for example via Jiti) share one flag.\n*\n* @returns The shared capture state\n*/\nfunction getSchemaCaptureState() {\n\tconst globals = globalThis;\n\tif (!globals[SCHEMA_CAPTURE_KEY]) globals[SCHEMA_CAPTURE_KEY] = {\n\t\tcapturing: false,\n\t\tdefinitions: []\n\t};\n\treturn globals[SCHEMA_CAPTURE_KEY];\n}\n/**\n* Start recording `arkenv()` schema arguments instead of validating the environment.\n*\n* CLI-supporting API: tools such as the ArkEnv CLI use this to inspect a user's\n* schema module without requiring `process.env` to be populated.\n*/\nfunction beginSchemaCapture() {\n\tconst state = getSchemaCaptureState();\n\tstate.capturing = true;\n\tstate.definitions = [];\n}\n/**\n* Stop recording and return the captured `arkenv()` schema definitions.\n*\n* @returns Schema definitions recorded since {@link beginSchemaCapture}\n*/\nfunction endSchemaCapture() {\n\tconst state = getSchemaCaptureState();\n\tstate.capturing = false;\n\tconst definitions = state.definitions.slice();\n\tstate.definitions = [];\n\treturn definitions;\n}\n/**\n* Report whether schema capture mode is active.\n*\n* @returns `true` when {@link beginSchemaCapture} is in effect\n*/\nfunction isCapturingSchema() {\n\treturn getSchemaCaptureState().capturing;\n}\n/**\n* Record an `arkenv()` schema definition while capture mode is active.\n*\n* @param def The schema definition passed to `arkenv()`\n*/\nfunction recordSchemaCapture(def) {\n\tconst state = getSchemaCaptureState();\n\tif (state.capturing) state.definitions.push(def);\n}\n\n//#endregion\n//#region src/utils/format-build-error.ts\n/**\n* Standard prefix for ArkEnv build-time log messages.\n*/\nconst BUILD_PREFIX = \"[ArkEnv]\";\n/**\n* Format an error message with the standard build prefix.\n*/\nfunction formatBuildError(message) {\n\treturn `${BUILD_PREFIX} ${message}`;\n}\n\n//#endregion\nexport { ARKENV_ERROR_NAME, ARRAY_ITEM_MARKER, ArkEnvError, BUILD_PREFIX, applyCoercion, assertNotArkTypeDsl, assertStandardSchema, assertStandardSchemaMap, beginSchemaCapture, boundaryAccessErrorMessage, buildEnvIssue, coerceBoolean, coerceDate, coerceEnvironment, coerceJson, coerceNumber, endSchemaCapture, extractJsonSchema, findCoercionPaths, formatBuildError, formatIssuePath, formatIssues, formatStandardIssueMessage, getProp, getSchemaKeys, getStandardMeta, indent, isCapturingSchema, isDebugSecrets, mapStandardCode, parseStandard, recordSchemaCapture, safeExecute, safeStringify, shouldRedact, stripEmptyStrings, styleText, traverseReceivedValue };\n//# sourceMappingURL=index.js.map","import { $ } from \"@repo/scope\";\nimport type { SchemaShape } from \"@repo/types\";\nimport {\n\tArkEnvError,\n\tbuildEnvIssue,\n\tcoerceEnvironment,\n\ttype EnvIssue,\n\ttype EnvIssueCode,\n\ttype EnvIssueMeta,\n\tisDebugSecrets,\n\tshouldRedact,\n\tstyleText,\n} from \"@repo/utils\";\nimport type { ArkError, distill } from \"arktype\";\nimport { ArkErrors } from \"arktype\";\nimport type { ArkEnvConfig, EnvSchema } from \"@/arkenv\";\n\nconst ARKTYPE_CODE_MAP = {\n\trequired: \"MISSING_VARIABLE\",\n\tpattern: \"PATTERN_MISMATCH\",\n\tmin: \"VALUE_TOO_SMALL\",\n\tminLength: \"VALUE_TOO_SMALL\",\n\tmax: \"VALUE_TOO_LARGE\",\n\tmaxLength: \"VALUE_TOO_LARGE\",\n\tdivisor: \"INVALID_TYPE\",\n\tintersection: \"INVALID_TYPE\",\n\tunion: \"INVALID_TYPE\",\n\tunit: \"INVALID_TYPE\",\n\tproto: \"INVALID_TYPE\",\n\tdomain: \"INVALID_TYPE\",\n\texactLength: \"INVALID_FORMAT\",\n\tbefore: \"INVALID_FORMAT\",\n\tafter: \"INVALID_FORMAT\",\n\tpredicate: \"CUSTOM\",\n} satisfies Record<ArkError[\"code\"], EnvIssueCode>;\n\n/**\n * Map an ArkType error code to an ArkEnv issue code.\n *\n * @param engineCode The ArkType engine error code\n * @returns The corresponding ArkEnv issue code\n */\nfunction mapArkTypeCode(engineCode: string): EnvIssueCode {\n\treturn engineCode in ARKTYPE_CODE_MAP\n\t\t? ARKTYPE_CODE_MAP[engineCode as keyof typeof ARKTYPE_CODE_MAP]\n\t\t: \"INVALID_FORMAT\";\n}\n\n/**\n * Extract numeric bounds from an ArkType error object.\n *\n * @param error The ArkType error object\n * @returns An object containing optional min and max bounds\n */\nfunction getArkTypeMeta(error: any): { min?: number; max?: number } {\n\tconst min = error.min ?? error.rule;\n\tconst max = error.max;\n\treturn {\n\t\t...(typeof min === \"number\" ? { min } : {}),\n\t\t...(typeof max === \"number\" ? { max } : {}),\n\t};\n}\n\n/**\n * Redact and colorize the value inside a \"(was ...)\" message fragment.\n *\n * @param message The validation error message\n * @param path The environment variable key path\n * @param debugSecrets Whether to display sensitive values in debug mode\n * @returns The modified error message with styled or redacted value\n */\nfunction redactMessageWasValue(\n\tmessage: string,\n\tpath: string,\n\tdebugSecrets?: boolean,\n): string {\n\tconst valueMatch = message.match(/\\(was (.*)\\)/);\n\tif (!valueMatch?.[1]) return message;\n\n\tconst value = valueMatch[1];\n\tconst debug = isDebugSecrets(debugSecrets);\n\tconst displayedValue = !debug && shouldRedact(path) ? \"[REDACTED]\" : value;\n\n\tif (displayedValue.includes(\"\\x1b[\")) return message;\n\n\treturn message.replace(\n\t\t`(was ${value})`,\n\t\t`(was ${styleText(\"cyan\", displayedValue)})`,\n\t);\n}\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 * Convert ArkType's `ArkErrors` (keyed by path) into a flat `EnvIssue[]`\n * suitable for `ArkEnvError`.\n *\n * @param errors The ArkType errors object to convert\n * @param config Optional ArkEnvConfig to read debugSecrets options\n * @returns An array of flattened validation issues\n *\n * @internal\n */\nfunction arkErrorsToIssues(\n\terrors: ArkErrors,\n\tconfig?: ArkEnvConfig,\n): EnvIssue[] {\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// Redact and style (was ...) inline values\n\t\tmessage = redactMessageWasValue(message, path, config?.debugSecrets);\n\n\t\t// Map code and metadata using centralized helpers\n\t\tconst code = mapArkTypeCode(error.code);\n\t\tconst bounds = getArkTypeMeta(error);\n\t\tconst meta: EnvIssueMeta = {\n\t\t\t...bounds,\n\t\t};\n\n\t\treturn buildEnvIssue(\n\t\t\tpath,\n\t\t\tmessage,\n\t\t\tcode,\n\t\t\tmeta,\n\t\t\terror.expected,\n\t\t\terror.code === \"required\" ? undefined : error.data,\n\t\t);\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 * @param def The ArkType schema definition to validate against\n * @param config The configuration object for parsing and coercion\n * @returns The parsed and validated environment variables\n * @throws {@link ArkEnvError} if validation fails\n *\n * @internal\n */\nexport function parse<const T extends SchemaShape>(\n\tdef: EnvSchema<T>,\n\tconfig: ArkEnvConfig,\n) {\n\tconst {\n\t\tenv = process.env,\n\t\tcoerce: shouldCoerce = true,\n\t\tonUndeclaredKey = \"delete\",\n\t\tarrayFormat = \"comma\",\n\t\temptyAsUndefined = false,\n\t} = config;\n\n\t// If def is a type definition (has assert method), use it directly\n\t// Otherwise, use raw() to convert the schema definition\n\tconst isCompiledType = typeof def === \"function\" && \"assert\" in def;\n\tconst schema = (isCompiledType ? def : $.type.raw(def)) as any;\n\n\t// Apply the `onUndeclaredKey` option\n\tconst schemaWithKeys = schema.onUndeclaredKey(onUndeclaredKey);\n\n\t// Optionally strip empty strings and apply coercion\n\tconst { coercedEnv } = coerceEnvironment(\n\t\tenv,\n\t\temptyAsUndefined,\n\t\tarrayFormat,\n\t\tshouldCoerce\n\t\t\t? () => {\n\t\t\t\t\tconst json = schemaWithKeys.in.toJsonSchema({\n\t\t\t\t\t\tfallback: (ctx: { base: unknown }) => ctx.base,\n\t\t\t\t\t});\n\t\t\t\t\treturn { schema: json, hasSchema: true };\n\t\t\t\t}\n\t\t\t: undefined,\n\t);\n\n\t// Validate the environment variables\n\tconst validatedEnv = schemaWithKeys(coercedEnv);\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, config));\n\t}\n\n\treturn validatedEnv;\n}\n","import type { $ } from \"@repo/scope\";\nimport type {\n\tCompiledEnvSchema,\n\tInferType,\n\tSchemaShape,\n\tStandardSchemaV1,\n} from \"@repo/types\";\nimport {\n\tArkEnvError,\n\tisCapturingSchema,\n\trecordSchemaCapture,\n\ttype SafeArkEnvResult,\n\tsafeExecute,\n} from \"@repo/utils\";\nimport type { type as at, distill } from \"arktype\";\nimport { parse } from \"./arktype\";\n\n/**\n * Declarative environment schema definition accepted by ArkEnv.\n *\n * Maps environment variable names to schema definitions (e.g. ArkType DSL\n * strings or Standard Schema validators).\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> =\n\tT extends StandardSchemaV1<infer _Input, infer Output>\n\t\t? Output\n\t\t: T extends { t: infer U }\n\t\t\t? U\n\t\t\t: T extends at.Any<infer U, infer _Scope>\n\t\t\t\t? U\n\t\t\t\t: T extends SchemaShape\n\t\t\t\t\t? distill.Out<at.infer<T, $>>\n\t\t\t\t\t: InferType<T>;\n\n/**\n * Configuration options for `arkenv`\n */\nexport type ArkEnvConfig = {\n\t/**\n\t * The environment variables to parse. Defaults to `process.env`.\n\t *\n\t * All values must be strings (or `undefined`) to match `process.env` semantics.\n\t */\n\tenv?: Record<string, string | undefined>;\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'` so the output object only contains keys you've declared.\n\t *\n\t * - `delete` (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 * @see https://arktype.io/docs/configuration#onundeclaredkey\n\t */\n\tonUndeclaredKey?: \"ignore\" | \"delete\" | \"reject\";\n\n\t/**\n\t * The format to use for array parsing when coercion is enabled.\n\t *\n\t * - `comma` (default): Strings are split by comma and trimmed.\n\t * - `json`: Strings are parsed as JSON.\n\t *\n\t * @default \"comma\"\n\t */\n\tarrayFormat?: \"comma\" | \"json\";\n\n\t/**\n\t * Whether to bypass secret redaction and print raw sensitive values during debugging.\n\t * Defaults to checking `process.env.ARKENV_DEBUG_SECRETS === \"true\"` or `\"1\"`.\n\t */\n\tdebugSecrets?: boolean;\n\n\t/**\n\t * Whether to treat empty strings (`\"\"`) as `undefined` before validation.\n\t *\n\t * When enabled, an environment variable set to an empty value (e.g. `PORT=`)\n\t * will be treated as if it were missing, allowing defaults to apply and\n\t * preventing validation errors for numeric or boolean types.\n\t *\n\t * @default false\n\t */\n\temptyAsUndefined?: boolean;\n\n\t/**\n\t * Whether to return a safe result object instead of throwing an error on validation failure.\n\t *\n\t * When enabled, the function returns an object with `{ success: true, data }` or `{ success: false, issues }`.\n\t *\n\t * @default false\n\t */\n\tsafe?: boolean;\n};\n\nexport type { SafeArkEnvResult };\n\n/**\n * Parsed environment object inferred from an EnvSchema or CompiledEnvSchema.\n */\nexport type ArkenvOutput<T extends SchemaShape, D> =\n\t| distill.Out<at.infer<T, $>>\n\t| InferType<D>;\n\n/**\n * Parse and validate environment variables using ArkType or Standard Schema.\n *\n * @param def The schema definition\n * @param config The evaluation configuration\n * @returns The parsed environment variables, a SafeArkEnvResult if `{ safe: true }` is configured, or a value-less stub when schema capture is active\n * @throws An {@link ArkEnvError | error} if the environment variables are invalid and `safe` is not enabled\n */\nexport function arkenv<const T extends SchemaShape>(\n\tdef: EnvSchema<T>,\n\tconfig?: ArkEnvConfig & { safe?: false },\n): distill.Out<at.infer<T, $>>;\nexport function arkenv<T extends CompiledEnvSchema>(\n\tdef: T,\n\tconfig?: ArkEnvConfig & { safe?: false },\n): InferType<T>;\nexport function arkenv<\n\tconst T extends SchemaShape,\n\tconst D extends EnvSchema<T> | CompiledEnvSchema,\n>(def: D, config?: ArkEnvConfig & { safe?: false }): ArkenvOutput<T, D>;\nexport function arkenv<const T extends SchemaShape>(\n\tdef: EnvSchema<T>,\n\tconfig: ArkEnvConfig & { safe: true },\n): SafeArkEnvResult<distill.Out<at.infer<T, $>>>;\nexport function arkenv<T extends CompiledEnvSchema>(\n\tdef: T,\n\tconfig: ArkEnvConfig & { safe: true },\n): SafeArkEnvResult<InferType<T>>;\nexport function arkenv<\n\tconst T extends SchemaShape,\n\tconst D extends EnvSchema<T> | CompiledEnvSchema,\n>(\n\tdef: D,\n\tconfig: ArkEnvConfig & { safe: true },\n): SafeArkEnvResult<ArkenvOutput<T, D>>;\nexport function arkenv<\n\tconst T extends SchemaShape,\n\tconst D extends EnvSchema<T> | CompiledEnvSchema,\n>(\n\tdef: D,\n\tconfig: ArkEnvConfig = {},\n): ArkenvOutput<T, D> | SafeArkEnvResult<ArkenvOutput<T, D>> {\n\tif (isCapturingSchema()) {\n\t\trecordSchemaCapture(def);\n\t\t// Capture records the schema only. The returned object has no values, so\n\t\t// schema modules must stay declarative and must not require env at module scope.\n\t\treturn {} as ArkenvOutput<T, D>;\n\t}\n\tif (config.safe) {\n\t\treturn safeExecute(() => parse(def as any, config));\n\t}\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 {\n\tArkEnvError,\n\ttype EnvIssue,\n\tformatIssues,\n\tgetSchemaKeys,\n} from \"@repo/utils\";\nimport { arkenv } from \"./arkenv\";\n\nexport type { EnvIssue };\nexport { ArkEnvError, arkenv, formatIssues, getSchemaKeys };\n/**\n * Like ArkType's `type`, but with ArkEnv's extra keywords, such as:\n *\n * - `string.host` – a hostname (e.g. `\"localhost\"`, `\"127.0.0.1\"`)\n * - `number.port` – a port number (e.g. `8080`)\n *\n * See ArkType's docs for the full API:\n * https://arktype.io/docs/type-api\n */\nexport const type = $.type;\nexport type {\n\tArkEnvConfig,\n\tEnvSchema,\n\tInfer,\n\tSafeArkEnvResult,\n} from \"./arkenv\";\n\nexport default arkenv;\n"],"mappings":";;;AAA0C,MAAM,IAAEA,OAAE,+BAA+B,EAAC,IAAEA,OAAE,0BAA0B,EAAC,IAAEC,MAAE;CAAC,QAAOD,OAAE,OAAO;EAAC,GAAGA,OAAE,SAAS;EAAO,MAAK;EAAE,CAAC;CAAC,QAAOA,OAAE,OAAO;EAAC,GAAGA,OAAE,SAAS;EAAO,MAAK;EAAE,CAAC;CAAC,CAAC;;;;;;;ACIvN,MAAM,oBAAoB;;;;;;;;;;;;;;;ACU1B,MAAM,gBAAgB,MAAM;AAC3B,KAAI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E;AAQtB,kBAAe"}
1
+ {"version":3,"file":"index.mjs","names":["t","e","$","$"],"sources":["../../internal/scope/dist/index.js","../../internal/utils/dist/boundary-access-error.js","../../internal/utils/dist/index.js","../src/arktype/index.ts","../src/arkenv.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","//#region src/utils/boundary-access-error.ts\n/**\n* `error.name` for the validation class {@link ArkEnvError}.\n*/\nconst ARKENV_ERROR_NAME = \"ArkEnvError\";\n/**\n* Build the message for a client read of a server-only env key.\n*\n* Native `Error` (name stays `\"Error\"`). Next.js taint voice\n* (`Do not … since it will leak`) plus a last-place breadcrumb\n* (`(prevented by ArkEnv)`) so agents can attribute the throw.\n* No trailing period. Shared across Next, Nuxt, Vite, and Bun —\n* \"on the client\", not \"Client Components\".\n*\n* @param key The server-only environment variable name\n* @returns The boundary access error message\n*/\nfunction boundaryAccessErrorMessage(key) {\n\treturn `Do not access server-only key '${key}' on the client since it will leak sensitive data (prevented by ArkEnv)`;\n}\n\n//#endregion\nexport { ARKENV_ERROR_NAME, boundaryAccessErrorMessage };\n//# sourceMappingURL=boundary-access-error.js.map","import { ARKENV_ERROR_NAME, boundaryAccessErrorMessage } from \"./boundary-access-error.js\";\n\n//#region src/coercion/morphs.ts\n/**\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*/\nconst coerceNumber = (s) => {\n\tif (typeof s === \"number\") return s;\n\tif (typeof s !== \"string\" || !s.trim()) return s;\n\tif (s.trim() === \"NaN\") return NaN;\n\tconst n = Number(s);\n\treturn Number.isNaN(n) ? s : 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*/\nconst coerceBoolean = (s) => {\n\tif (s === \"true\") return true;\n\tif (s === \"false\") return false;\n\treturn s;\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*/\nconst coerceJson = (s) => {\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* 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*/\nconst coerceDate = (s) => {\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\n//#endregion\n//#region src/coercion/shared.ts\n/**\n* Remove keys with empty string values from an environment record.\n*\n* When a key is set to `\"\"` (e.g. `PORT=` in a `.env` file), deleting it\n* allows the validator to treat it as missing so that defaults apply.\n*\n* @param env The environment variables record\n* @returns A new record with empty string keys removed\n*/\nconst stripEmptyStrings = (env) => {\n\tconst result = {};\n\tfor (const key in env) {\n\t\tconst value = env[key];\n\t\tif (value !== \"\") result[key] = value;\n\t}\n\treturn result;\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* 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*/\nconst findCoercionPaths = (node, path = []) => {\n\tconst results = [];\n\tif (!node || typeof node !== \"object\" || Array.isArray(node)) return results;\n\tconst n = node;\n\tif (\"const\" in n) {\n\t\tconst t = typeof n.const;\n\t\tif (t === \"number\" || t === \"boolean\") results.push({\n\t\t\tpath: [...path],\n\t\t\ttype: \"primitive\"\n\t\t});\n\t}\n\tif (\"enum\" in n && Array.isArray(n.enum)) {\n\t\tif (n.enum.some((v) => typeof v === \"number\" || typeof v === \"boolean\")) results.push({\n\t\t\tpath: [...path],\n\t\t\ttype: \"primitive\"\n\t\t});\n\t}\n\tconst type = n.type;\n\tif (type === \"number\" || type === \"integer\" || type === \"boolean\") results.push({\n\t\tpath: [...path],\n\t\ttype: \"primitive\"\n\t});\n\telse if (type === \"string\" && \"format\" in n && (n.format === \"date-time\" || n.format === \"date\")) results.push({\n\t\tpath: [...path],\n\t\ttype: \"date\"\n\t});\n\telse if (type === \"object\") {\n\t\tif (n.properties && Object.keys(n.properties).length > 0) {\n\t\t\tresults.push({\n\t\t\t\tpath: [...path],\n\t\t\t\ttype: \"object\"\n\t\t\t});\n\t\t\tfor (const key in n.properties) results.push(...findCoercionPaths(n.properties[key], [...path, key]));\n\t\t}\n\t} else if (type === \"array\") {\n\t\tresults.push({\n\t\t\tpath: [...path],\n\t\t\ttype: \"array\"\n\t\t});\n\t\tif (n.items) if (Array.isArray(n.items)) n.items.forEach((item, index) => {\n\t\t\tresults.push(...findCoercionPaths(item, [...path, String(index)]));\n\t\t});\n\t\telse results.push(...findCoercionPaths(n.items, [...path, \"*\"]));\n\t}\n\tfor (const comb of [\n\t\t\"anyOf\",\n\t\t\"allOf\",\n\t\t\"oneOf\"\n\t]) if (n[comb] && Array.isArray(n[comb])) for (const branch of n[comb]) results.push(...findCoercionPaths(branch, path));\n\tconst seen = /* @__PURE__ */ new Set();\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* 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*/\nconst applyCoercion = (data, targets, options = {}) => {\n\tconst { arrayFormat = \"comma\" } = options;\n\tconst splitString = (val) => {\n\t\tif (arrayFormat === \"json\") try {\n\t\t\treturn JSON.parse(val);\n\t\t} catch {\n\t\t\treturn val;\n\t\t}\n\t\treturn val.trim() ? val.split(\",\").map((s) => s.trim()) : [];\n\t};\n\tconst coerceValue = (val, type) => {\n\t\tif (type === \"array\" && typeof val === \"string\") return splitString(val);\n\t\tif (type === \"object\" && typeof val === \"string\") return coerceJson(val);\n\t\tif (type === \"date\" && typeof val === \"string\") return coerceDate(val);\n\t\tif (type === \"primitive\") {\n\t\t\tif (Array.isArray(val)) return val.map((item) => {\n\t\t\t\tif (typeof item !== \"string\") return item;\n\t\t\t\tconst n = coerceNumber(item);\n\t\t\t\treturn typeof n === \"number\" ? n : coerceBoolean(item);\n\t\t\t});\n\t\t\tif (typeof val !== \"string\") return val;\n\t\t\tconst n = coerceNumber(val);\n\t\t\treturn typeof n === \"number\" ? n : coerceBoolean(val);\n\t\t}\n\t\treturn val;\n\t};\n\tif (typeof data !== \"object\" || data === null) {\n\t\tconst root = targets.find((t) => t.path.length === 0);\n\t\tif (root) return coerceValue(data, root.type);\n\t\treturn data;\n\t}\n\tconst sorted = [...targets].sort((a, b) => a.path.length - b.path.length);\n\tconst updateAtPath = (current, path, fn) => {\n\t\tif (path.length === 0) return fn(current);\n\t\tconst [key, ...rest] = path;\n\t\tif (key === \"*\") {\n\t\t\tif (Array.isArray(current)) {\n\t\t\t\tlet changed = false;\n\t\t\t\tconst nextArr = current.map((item) => {\n\t\t\t\t\tconst nextVal = updateAtPath(item, rest, fn);\n\t\t\t\t\tif (nextVal !== item) changed = true;\n\t\t\t\t\treturn nextVal;\n\t\t\t\t});\n\t\t\t\treturn changed ? nextArr : current;\n\t\t\t}\n\t\t\treturn current;\n\t\t}\n\t\tif (!current || typeof current !== \"object\") return current;\n\t\tif (Array.isArray(current)) {\n\t\t\tconst index = Number(key);\n\t\t\tif (!Number.isNaN(index) && index >= 0 && index < current.length) {\n\t\t\t\tconst nextVal = updateAtPath(current[index], rest, fn);\n\t\t\t\tif (nextVal !== current[index]) {\n\t\t\t\t\tconst copy = [...current];\n\t\t\t\t\tcopy[index] = nextVal;\n\t\t\t\t\treturn copy;\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn current;\n\t\t}\n\t\tif (Object.hasOwn(current, key)) {\n\t\t\tconst nextVal = updateAtPath(current[key], rest, fn);\n\t\t\tif (nextVal !== current[key]) return {\n\t\t\t\t...current,\n\t\t\t\t[key]: nextVal\n\t\t\t};\n\t\t}\n\t\treturn current;\n\t};\n\tlet result = data;\n\tfor (const t of sorted) if (t.path.length > 0) result = updateAtPath(result, t.path, (val) => coerceValue(val, t.type));\n\treturn result;\n};\n\n//#endregion\n//#region src/coercion/environment.ts\n/**\n* Prepare an environment record by optionally stripping empty strings and applying coercion.\n*\n* @param env The raw environment variables\n* @param emptyAsUndefined Whether to strip empty string values before processing\n* @param arrayFormat The format to use for array coercion\n* @param getSchema Optional callback that returns a JSON Schema and whether it exists,\n* used to determine coercion targets. When omitted, no coercion is performed.\n* @returns The processed environment, the coerced environment, and any missing schema keys\n*/\nfunction coerceEnvironment(env, emptyAsUndefined, arrayFormat, getSchema) {\n\tconst processedEnv = emptyAsUndefined ? stripEmptyStrings(env) : env;\n\tlet coercedEnv = { ...processedEnv };\n\tconst missingKeys = [];\n\tif (getSchema) {\n\t\tconst result = getSchema();\n\t\tmissingKeys.push(...result.missingKeys || []);\n\t\tif (result.hasSchema) coercedEnv = applyCoercion(coercedEnv, findCoercionPaths(result.schema), { arrayFormat });\n\t}\n\treturn {\n\t\tprocessedEnv,\n\t\tcoercedEnv,\n\t\tmissingKeys\n\t};\n}\n\n//#endregion\n//#region src/utils/indent.ts\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*/\nconst indent = (str, amt = 2, { dontDetectNewlines = false } = {}) => {\n\tif (!dontDetectNewlines) return str.split(\"\\n\").map((line) => `${\" \".repeat(amt)}${line}`).join(\"\\n\");\n\treturn `${\" \".repeat(amt)}${str}`;\n};\n\n//#endregion\n//#region src/utils/style-text.ts\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*/\nconst colors = {\n\tred: \"\\x1B[31m\",\n\tyellow: \"\\x1B[33m\",\n\tcyan: \"\\x1B[36m\",\n\treset: \"\\x1B[0m\"\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 = () => typeof process !== \"undefined\" && process.versions != null && process.versions.node != null;\n/**\n* Check if colors should be disabled based on environment\n* Respects NO_COLOR, CI environment variables, and TTY detection\n*/\nconst shouldDisableColors = () => {\n\tif (!isNode()) return true;\n\tif (process.env.NO_COLOR !== void 0) return true;\n\tif (process.env.CI !== void 0) return true;\n\tif (process.stdout && !process.stdout.isTTY) return true;\n\treturn false;\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*/\nconst styleText = (color, text) => {\n\tif (isNode() && !shouldDisableColors()) return `${colors[color]}${text}${colors.reset}`;\n\treturn text;\n};\n\n//#endregion\n//#region src/core.ts\n/**\n* Format a list of normalized environment issues into a single styled string.\n*\n* @param issues - The array of normalized issues to format\n* @returns The formatted and styled error report string\n*/\nfunction formatIssues(issues) {\n\treturn issues.map((issue) => {\n\t\treturn `${styleText(\"yellow\", issue.path)} ${issue.message.trimStart()}`;\n\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* 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*/\nvar ArkEnvError = class extends Error {\n\tconstructor(issues, message = \"Errors found while validating environment variables\") {\n\t\tconst formattedIssues = formatIssues(issues);\n\t\tsuper(`${styleText(\"red\", message)}\\n${indent(formattedIssues)}\\n`);\n\t\tthis.name = ARKENV_ERROR_NAME;\n\t\tthis.issues = issues;\n\t}\n};\nObject.defineProperty(ArkEnvError, \"name\", { value: ARKENV_ERROR_NAME });\n\n//#endregion\n//#region src/guards.ts\n/**\n* Throws if the given value is a string (ArkType DSL) in standard mode.\n* @internal\n*/\nfunction assertNotArkTypeDsl(key, value) {\n\tif (typeof value === \"string\") throw new ArkEnvError([{\n\t\tpath: key,\n\t\tmessage: \"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\tcode: \"INVALID_SCHEMA\"\n\t}]);\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*/\nfunction assertStandardSchema(key, value) {\n\tconst std = value && typeof value === \"object\" && \"~standard\" in value && value[\"~standard\"];\n\tif (!std || typeof std !== \"object\" || !(\"validate\" in std) || typeof std.validate !== \"function\") throw new ArkEnvError([{\n\t\tpath: key,\n\t\tmessage: \"Invalid validator: expected a Standard Schema 1.0 validator (must have \\\"~standard\\\" property). Import from \\\"arkenv\\\" to use ArkType schemas.\",\n\t\tcode: \"INVALID_SCHEMA\"\n\t}]);\n}\n/**\n* Throws if `def` is not a plain object (i.e. not a valid schema map).\n* @internal\n*/\nfunction assertStandardSchemaMap(def) {\n\tif (!def || typeof def !== \"object\" || Array.isArray(def)) throw new ArkEnvError([{\n\t\tpath: \"\",\n\t\tmessage: \"Invalid schema: expected an object mapping in \\\"standard\\\" mode.\",\n\t\tcode: \"INVALID_SCHEMA\"\n\t}]);\n}\n\n//#endregion\n//#region src/utils/redact.ts\n/**\n* Regex pattern matching sensitive environment variable names.\n*\n* Matches keywords commonly associated with secrets (e.g. secret, key, token,\n* password, pass, auth, jwt, cert, credential, db_url). Excludes public keys\n* via the `shouldRedact` helper.\n*\n* @see {@link shouldRedact}\n*/\nconst SENSITIVE_PATTERN = /secret|(_|^)key(_|$)|token|(_|^)password(_|$)|(_|^)pass(_|$)|(_|^)auth(_|$)|jwt|cert|credential|database_url|db_url/i;\n/**\n* Check if debug secrets mode is enabled.\n*\n* Debug secrets mode can be enabled programmatically via the `debugSecrets` config option,\n* or globally by setting the `ARKENV_DEBUG_SECRETS` environment variable to `\"true\"` or `\"1\"`.\n*\n* @param configSecrets Programmatic override option for debugging secrets\n* @returns A boolean indicating if debug secrets mode is active\n*/\nfunction isDebugSecrets(configSecrets) {\n\tif (configSecrets !== void 0) return configSecrets;\n\tif (typeof process === \"undefined\") return false;\n\tconst val = process.env.ARKENV_DEBUG_SECRETS;\n\treturn val === \"true\" || val === \"1\";\n}\n/**\n* Determine if an environment variable path matches sensitive keyword patterns.\n*\n* By default, environment variables that contain sensitive keywords (e.g. 'secret', 'key',\n* 'token', 'password', 'auth', 'jwt', 'cert', 'credential', 'db_url') are flagged for redaction,\n* unless they are explicitly marked as public (e.g., matching 'public').\n*\n* Redaction prevents sensitive values from being logged or printed to the terminal\n* when environment validation fails.\n*\n* @param path The environment variable name/path under validation\n* @returns A boolean indicating if the path is sensitive and should be redacted\n*/\nfunction shouldRedact(path) {\n\treturn SENSITIVE_PATTERN.test(path) && !/public/i.test(path);\n}\n/**\n* Safely format and serialize an environment value for error reporting.\n*\n* Serializes primitive values and objects while redacting sensitive values if debugSecrets is disabled.\n* Limits object and array serialization to the first 3 keys/elements to prevent excessively large log outputs.\n*\n* @param val The raw received environment variable value\n* @param path The variable name/path under validation\n* @param options Configuration options, including debugSecrets override\n* @returns The formatted string representation of the value\n*/\nfunction safeStringify(val, path, options) {\n\tconst debug = isDebugSecrets(options?.debugSecrets);\n\tif (val === void 0) return \"missing\";\n\tif (val === null) return \"null\";\n\tif (!debug && shouldRedact(path)) return \"[REDACTED]\";\n\tif (typeof val === \"string\") return JSON.stringify(val);\n\tif (typeof val === \"number\" || typeof val === \"boolean\" || typeof val === \"bigint\") return String(val);\n\tif (typeof val === \"symbol\") return val.toString();\n\tif (typeof val === \"function\") return \"[Function]\";\n\tif (val && typeof val === \"object\") try {\n\t\tif (Array.isArray(val)) {\n\t\t\tconst res = val.slice(0, 3).map((x) => safeStringify(x, path, options));\n\t\t\tif (val.length > 3) res.push(`...(+${val.length - 3} more)`);\n\t\t\treturn `[${res.join(\", \")}]`;\n\t\t}\n\t\tconst keys = Object.keys(val);\n\t\tconst res = keys.slice(0, 3).map((k) => `${k}: ${safeStringify(val[k], path, options)}`);\n\t\tif (keys.length > 3) res.push(`...(+${keys.length - 3} more)`);\n\t\treturn `{ ${res.join(\", \")} }`;\n\t} catch {\n\t\treturn Object.prototype.toString.call(val);\n\t}\n\treturn String(val);\n}\n\n//#endregion\n//#region src/utils/errors.ts\n/**\n* Mapping of Standard Schema validation issue codes to normalized EnvIssueCode classification codes.\n*\n* This serves as an internal translation map specifically for Standard Schema validators\n* (such as Zod or Valibot) to map their engine-specific error keys to our unified union type.\n* It is not a duplicate Source of Truth for the allowed issue codes themselves, which are\n* defined solely by the `EnvIssueCode` type in `core.ts`.\n*\n* @internal\n*/\nconst STANDARD_CODE_MAP = {\n\ttoo_small: \"VALUE_TOO_SMALL\",\n\ttoo_big: \"VALUE_TOO_LARGE\",\n\tinvalid_string: \"INVALID_FORMAT\",\n\tinvalid_date: \"INVALID_FORMAT\",\n\tcustom: \"INVALID_FORMAT\"\n};\n/**\n* Map a Standard Schema validation issue to a normalized EnvIssueCode.\n*\n* @param engineCode The raw issue code from the Standard Schema engine\n* @param message The error message associated with the issue\n* @param receivedVal The raw value received by the validator\n* @returns The normalized EnvIssueCode classification\n* @internal\n*/\nfunction mapStandardCode(engineCode, message, receivedVal) {\n\tconst msg = message.toLowerCase();\n\tif (engineCode === \"invalid_type\" && (receivedVal === void 0 || receivedVal === \"undefined\") || msg === \"required\") return \"MISSING_VARIABLE\";\n\tif (engineCode in STANDARD_CODE_MAP) return STANDARD_CODE_MAP[engineCode];\n\tif (/regex|pattern|match/.test(msg)) return \"PATTERN_MISMATCH\";\n\treturn \"INVALID_TYPE\";\n}\n/**\n* Extract validation boundary metadata from a Standard Schema issue.\n*\n* @param issue The raw issue from Standard Schema\n* @returns An object containing normalized min and/or max values if present\n* @internal\n*/\nfunction getStandardMeta(issue) {\n\tconst min = issue.minimum ?? issue.min;\n\tconst max = issue.maximum ?? issue.max;\n\treturn {\n\t\t...typeof min === \"number\" ? { min } : {},\n\t\t...typeof max === \"number\" ? { max } : {}\n\t};\n}\n/**\n* Execute a parser function and return a SafeArkEnvResult.\n*\n* @param parseFn The function that parses the environment variables and might throw an ArkEnvError\n* @returns A SafeArkEnvResult containing either the parsed data or the caught ArkEnvError\n* @internal\n*/\nfunction safeExecute(parseFn) {\n\ttry {\n\t\treturn {\n\t\t\tsuccess: true,\n\t\t\tdata: parseFn()\n\t\t};\n\t} catch (error) {\n\t\tif (error instanceof ArkEnvError) return {\n\t\t\tsuccess: false,\n\t\t\tissues: error.issues\n\t\t};\n\t\tthrow error;\n\t}\n}\n/**\n* Build a normalized {@link EnvIssue}.\n*\n* @param path The dot-separated property path/name of the environment variable\n* @param message The descriptive, user-friendly error message\n* @param code The normalized classification code for the issue\n* @param meta Additional validation metadata and engine codes\n* @param expected The expected type or value shape description\n* @param received The raw value received (redacted in string formatting if sensitive)\n* @returns A fully populated EnvIssue\n* @internal\n*/\nfunction buildEnvIssue(path, message, code, meta, expected, received) {\n\tconst issue = {\n\t\tpath,\n\t\tmessage,\n\t\tcode,\n\t\tmeta: meta ?? {}\n\t};\n\tif (expected) issue.expected = expected;\n\tif (received !== void 0) issue.received = received;\n\treturn issue;\n}\n/**\n* Format a Standard Schema validation issue message, appending a `(was …)` substring\n* and redacting sensitive values when appropriate.\n*\n* @param baseMessage The raw message from the Standard Schema validator\n* @param code The normalized issue code\n* @param expected The expected type description, if any\n* @param receivedVal The raw value received by the validator\n* @param path The environment variable name/path under validation\n* @param config Optional config containing the debugSecrets override\n* @returns The formatted message string\n* @internal\n*/\nfunction formatStandardIssueMessage(baseMessage, code, expected, receivedVal, path, config) {\n\tif (code === \"MISSING_VARIABLE\") return expected ? `must be ${expected} (was missing)` : \"is required\";\n\tif (baseMessage.includes(\"(was \")) return baseMessage;\n\tconst suffix = `(was ${styleText(\"cyan\", !isDebugSecrets(config?.debugSecrets) && shouldRedact(path) ? \"[REDACTED]\" : safeStringify(receivedVal, path, config))})`;\n\treturn expected && !baseMessage.includes(\"Expected\") ? `must be ${expected} ${suffix}` : `${baseMessage} ${suffix}`;\n}\n\n//#endregion\n//#region src/utils/standard-helpers.ts\n/**\n* Whether `value` is a plain object (`{}` / Object.create(null) style).\n* Rejects arrays, `Date`, functions, boxed primitives, etc.\n* @internal\n*/\nfunction isPlainObject(value) {\n\treturn Object.prototype.toString.call(value) === \"[object Object]\";\n}\n/**\n* Extract JSON Schema definitions from standard schema validators.\n*\n* @param def The schema dictionary mapping keys to validators\n* @param toJsonSchema Optional fallback converter when a key has no Standard JSON Schema on the value\n* @returns The generated JSON Schema, a flag indicating if any JSON Schema was found,\n* and a list of keys that do not support JSON Schema\n* @throws {ArkEnvError} When `toJsonSchema` throws or returns a non-plain object for a key\n*/\nfunction extractJsonSchema(def, toJsonSchema) {\n\tconst jsonSchema = {\n\t\ttype: \"object\",\n\t\tproperties: {}\n\t};\n\tlet hasJsonSchema = false;\n\tconst missingKeys = [];\n\tfor (const key in def) {\n\t\tconst validator = def[key];\n\t\tif (!validator) {\n\t\t\tmissingKeys.push(key);\n\t\t\tcontinue;\n\t\t}\n\t\tconst std = validator[\"~standard\"];\n\t\tif (typeof std?.jsonSchema?.input === \"function\") try {\n\t\t\tconst schema = std.jsonSchema.input({ target: \"draft-07\" });\n\t\t\tif (schema) {\n\t\t\t\tjsonSchema.properties[key] = schema;\n\t\t\t\thasJsonSchema = true;\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t} catch {}\n\t\tif (typeof validator.jsonSchema?.input === \"function\") try {\n\t\t\tconst schema = validator.jsonSchema.input({ target: \"draft-07\" });\n\t\t\tif (schema) {\n\t\t\t\tjsonSchema.properties[key] = schema;\n\t\t\t\thasJsonSchema = true;\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t} catch {}\n\t\tif (typeof validator.toJSONSchema === \"function\") try {\n\t\t\tconst schema = validator.toJSONSchema();\n\t\t\tif (schema) {\n\t\t\t\tjsonSchema.properties[key] = schema;\n\t\t\t\thasJsonSchema = true;\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t} catch {}\n\t\tif (typeof validator.toStandardJSONSchema?.v1 === \"function\") try {\n\t\t\tconst schema = validator.toStandardJSONSchema.v1();\n\t\t\tif (schema) {\n\t\t\t\tjsonSchema.properties[key] = schema;\n\t\t\t\thasJsonSchema = true;\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t} catch {}\n\t\tif (toJsonSchema) {\n\t\t\tlet converted;\n\t\t\ttry {\n\t\t\t\tconverted = toJsonSchema(validator);\n\t\t\t} catch (error) {\n\t\t\t\tthrow new ArkEnvError([buildEnvIssue(key, `toJsonSchema failed for '${key}': ${error instanceof Error ? error.message : String(error)}`, \"INVALID_SCHEMA\")]);\n\t\t\t}\n\t\t\tif (!converted) {\n\t\t\t\tmissingKeys.push(key);\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif (!isPlainObject(converted)) throw new ArkEnvError([buildEnvIssue(key, `toJsonSchema must return a plain object or undefined for '${key}'.`, \"INVALID_SCHEMA\")]);\n\t\t\tjsonSchema.properties[key] = converted;\n\t\t\thasJsonSchema = true;\n\t\t\tcontinue;\n\t\t}\n\t\tmissingKeys.push(key);\n\t}\n\treturn {\n\t\tjsonSchema,\n\t\thasJsonSchema,\n\t\tmissingKeys\n\t};\n}\n/**\n* Get the property key from a path segment.\n*\n* @param s The path segment which can be a key or a segment object\n* @returns The string representation of the property key\n*/\nfunction getProp(s) {\n\treturn typeof s === \"object\" && s !== null && \"key\" in s ? String(s.key) : String(s);\n}\n/**\n* Format standard schema validation issue path.\n*\n* @param key The base key of the environment variable\n* @param path The relative path segments of the issue\n* @returns The formatted dot-separated path string\n*/\nfunction formatIssuePath(key, path) {\n\tif (!path || path.length === 0) return key;\n\treturn [key, ...path.map(getProp)].join(\".\");\n}\n/**\n* Traverse the raw string value (attempting to parse as JSON if it represents an object/array)\n* to extract the nested value targeted by the issue path.\n*\n* @param rawVal The raw string value of the environment variable\n* @param path The path segments of the validation issue\n* @returns An object containing the resolved nested value and an optional traversal error string\n*/\nfunction traverseReceivedValue(rawVal, path) {\n\tlet receivedVal = rawVal;\n\tlet traversalError;\n\ttry {\n\t\tlet current = rawVal;\n\t\tconst trimmed = rawVal.trim();\n\t\tif (trimmed[0] === \"{\" || trimmed[0] === \"[\") try {\n\t\t\tcurrent = JSON.parse(rawVal);\n\t\t} catch (e) {\n\t\t\ttraversalError = `[Unparseable JSON: ${e.message}]`;\n\t\t}\n\t\tif (!traversalError) {\n\t\t\tfor (const seg of path) current = current?.[getProp(seg)];\n\t\t\treceivedVal = current;\n\t\t}\n\t} catch (e) {\n\t\ttraversalError = `[Traversal error: ${e.message}]`;\n\t}\n\treturn {\n\t\treceivedVal,\n\t\ttraversalError\n\t};\n}\n\n//#endregion\n//#region src/parse-standard.ts\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*/\nfunction parseStandard(def, config) {\n\tconst { env = process.env, onUndeclaredKey = \"delete\", coerce = true, arrayFormat = \"comma\", emptyAsUndefined = false, toJsonSchema } = config;\n\tconst output = {};\n\tconst errors = [];\n\tconst { processedEnv, coercedEnv, missingKeys: missingJsonSchemaKeys } = coerceEnvironment(env, emptyAsUndefined, arrayFormat, coerce ? () => {\n\t\tconst { jsonSchema, hasJsonSchema, missingKeys } = extractJsonSchema(def, toJsonSchema);\n\t\treturn {\n\t\t\tschema: jsonSchema,\n\t\t\thasSchema: hasJsonSchema,\n\t\t\tmissingKeys\n\t\t};\n\t} : void 0);\n\tconst envKeys = new Set(Object.keys(processedEnv));\n\tfor (const key in def) {\n\t\tconst validator = def[key];\n\t\tconst value = coercedEnv[key];\n\t\tif (!validator || typeof validator !== \"object\" || !(\"~standard\" in validator)) throw new ArkEnvError([buildEnvIssue(key, `Invalid schema: expected a Standard Schema 1.0 validator (e.g. Zod, Valibot) in 'standard' mode.`, \"INVALID_SCHEMA\")]);\n\t\tconst result = validator[\"~standard\"].validate(value);\n\t\tif (result instanceof Promise) throw new ArkEnvError([buildEnvIssue(key, \"Async validation is not supported. ArkEnv is synchronous.\", \"INVALID_SCHEMA\")]);\n\t\tif (result.issues) for (const issue of result.issues) {\n\t\t\tconst issuePath = formatIssuePath(key, issue.path);\n\t\t\tlet receivedVal;\n\t\t\tlet traversalError;\n\t\t\tif (key in processedEnv) {\n\t\t\t\tconst rawVal = processedEnv[key];\n\t\t\t\tif (typeof rawVal === \"string\" && issue.path?.length) {\n\t\t\t\t\tconst traversed = traverseReceivedValue(rawVal, issue.path);\n\t\t\t\t\treceivedVal = traversed.receivedVal;\n\t\t\t\t\ttraversalError = traversed.traversalError;\n\t\t\t\t} else receivedVal = rawVal;\n\t\t\t} else receivedVal = issue.received;\n\t\t\tconst code = mapStandardCode(issue.code || \"invalid_type\", issue.message || \"\", receivedVal);\n\t\t\tconst expected = issue.expected || void 0;\n\t\t\tconst meta = { ...getStandardMeta(issue) };\n\t\t\tconst iss = issue;\n\t\t\tif (iss.validation !== void 0) meta.validation = iss.validation;\n\t\t\tif (traversalError !== void 0) meta.traversalError = traversalError;\n\t\t\tlet message = formatStandardIssueMessage(issue.message || \"\", code, expected, receivedVal, issuePath, config);\n\t\t\tif (coerce && missingJsonSchemaKeys.includes(key)) message += ` (Hint: coercion is enabled by default, but the validator for '${key}' lacks Standard JSON Schema support.)`;\n\t\t\terrors.push(buildEnvIssue(issuePath, message, code, meta, expected, receivedVal));\n\t\t}\n\t\telse output[key] = result.value;\n\t\tenvKeys.delete(key);\n\t}\n\tif (onUndeclaredKey !== \"delete\") {\n\t\tfor (const key of envKeys) if (onUndeclaredKey === \"reject\") errors.push(buildEnvIssue(key, \"Undeclared key\", \"UNDECLARED_KEY\"));\n\t\telse if (onUndeclaredKey === \"ignore\") output[key] = coercedEnv[key];\n\t}\n\tif (errors.length > 0) throw new ArkEnvError(errors);\n\treturn output;\n}\n\n//#endregion\n//#region src/schema.ts\n/**\n* Extract the keys from a schema definition.\n* Supports plain objects, ArkType schemas, and Standard Schema validators.\n*\n* @param schema The schema definition to extract keys from\n* @returns An array of extracted key names\n*/\nfunction getSchemaKeys(schema) {\n\tif (!schema || typeof schema !== \"object\" && typeof schema !== \"function\") return [];\n\tif (schema.json && typeof schema.json === \"object\" && schema.json.domain === \"object\") {\n\t\tconst keys = [];\n\t\tif (Array.isArray(schema.json.required)) {\n\t\t\tfor (const r of schema.json.required) if (r && typeof r === \"object\" && \"key\" in r) keys.push(r.key);\n\t\t}\n\t\tif (Array.isArray(schema.json.optional)) {\n\t\t\tfor (const o of schema.json.optional) if (o && typeof o === \"object\" && \"key\" in o) keys.push(o.key);\n\t\t}\n\t\treturn keys;\n\t}\n\tconst std = schema[\"~standard\"];\n\tconst jsonSchemaInput = typeof std?.jsonSchema?.input === \"function\" && std.jsonSchema.input || typeof schema.jsonSchema?.input === \"function\" && schema.jsonSchema.input;\n\tif (jsonSchemaInput) try {\n\t\tconst json = jsonSchemaInput({ target: \"draft-07\" });\n\t\tif (json && typeof json === \"object\" && json.properties) return Object.keys(json.properties);\n\t} catch {}\n\tif (typeof schema.toJSONSchema === \"function\") try {\n\t\tconst json = schema.toJSONSchema();\n\t\tif (json && typeof json === \"object\" && json.properties) return Object.keys(json.properties);\n\t} catch {}\n\tif (typeof schema.toStandardJSONSchema?.v1 === \"function\") try {\n\t\tconst json = schema.toStandardJSONSchema.v1();\n\t\tif (json && typeof json === \"object\" && json.properties) return Object.keys(json.properties);\n\t} catch {}\n\treturn Object.keys(schema);\n}\n\n//#endregion\n//#region src/schema-capture.ts\nconst SCHEMA_CAPTURE_KEY = \"__ARKENV_SCHEMA_CAPTURE__\";\n/**\n* Read the process-global schema-capture bag so separately loaded copies of\n* `@arkenv/core` / `@arkenv/standard` (for example via Jiti) share one flag.\n*\n* @returns The shared capture state\n*/\nfunction getSchemaCaptureState() {\n\tconst globals = globalThis;\n\tif (!globals[SCHEMA_CAPTURE_KEY]) globals[SCHEMA_CAPTURE_KEY] = {\n\t\tcapturing: false,\n\t\tdefinitions: []\n\t};\n\treturn globals[SCHEMA_CAPTURE_KEY];\n}\n/**\n* Start recording `arkenv()` schema arguments instead of validating the environment.\n*\n* CLI-supporting API: tools such as the ArkEnv CLI use this to inspect a user's\n* schema module without requiring `process.env` to be populated.\n*/\nfunction beginSchemaCapture() {\n\tconst state = getSchemaCaptureState();\n\tstate.capturing = true;\n\tstate.definitions = [];\n}\n/**\n* Stop recording and return the captured `arkenv()` schema definitions.\n*\n* @returns Schema definitions recorded since {@link beginSchemaCapture}\n*/\nfunction endSchemaCapture() {\n\tconst state = getSchemaCaptureState();\n\tstate.capturing = false;\n\tconst definitions = state.definitions.slice();\n\tstate.definitions = [];\n\treturn definitions;\n}\n/**\n* Report whether schema capture mode is active.\n*\n* @returns `true` when {@link beginSchemaCapture} is in effect\n*/\nfunction isCapturingSchema() {\n\treturn getSchemaCaptureState().capturing;\n}\n/**\n* Record an `arkenv()` schema definition while capture mode is active.\n*\n* @param def The schema definition passed to `arkenv()`\n*/\nfunction recordSchemaCapture(def) {\n\tconst state = getSchemaCaptureState();\n\tif (state.capturing) state.definitions.push(def);\n}\n\n//#endregion\n//#region src/utils/format-build-error.ts\n/**\n* Standard prefix for ArkEnv build-time log messages.\n*/\nconst BUILD_PREFIX = \"[ArkEnv]\";\n/**\n* Format an error message with the standard build prefix.\n*/\nfunction formatBuildError(message) {\n\treturn `${BUILD_PREFIX} ${message}`;\n}\n\n//#endregion\nexport { ARKENV_ERROR_NAME, ARRAY_ITEM_MARKER, ArkEnvError, BUILD_PREFIX, applyCoercion, assertNotArkTypeDsl, assertStandardSchema, assertStandardSchemaMap, beginSchemaCapture, boundaryAccessErrorMessage, buildEnvIssue, coerceBoolean, coerceDate, coerceEnvironment, coerceJson, coerceNumber, endSchemaCapture, extractJsonSchema, findCoercionPaths, formatBuildError, formatIssuePath, formatIssues, formatStandardIssueMessage, getProp, getSchemaKeys, getStandardMeta, indent, isCapturingSchema, isDebugSecrets, mapStandardCode, parseStandard, recordSchemaCapture, safeExecute, safeStringify, shouldRedact, stripEmptyStrings, styleText, traverseReceivedValue };\n//# sourceMappingURL=index.js.map","import { $ } from \"@repo/scope\";\nimport type { SchemaShape } from \"@repo/types\";\nimport {\n\tArkEnvError,\n\tbuildEnvIssue,\n\tcoerceEnvironment,\n\ttype EnvIssue,\n\ttype EnvIssueCode,\n\ttype EnvIssueMeta,\n\tisDebugSecrets,\n\tshouldRedact,\n\tstyleText,\n} from \"@repo/utils\";\nimport type { ArkError, distill } from \"arktype\";\nimport { ArkErrors } from \"arktype\";\nimport type { ArkEnvConfig, EnvSchema } from \"@/arkenv\";\n\nconst ARKTYPE_CODE_MAP = {\n\trequired: \"MISSING_VARIABLE\",\n\tpattern: \"PATTERN_MISMATCH\",\n\tmin: \"VALUE_TOO_SMALL\",\n\tminLength: \"VALUE_TOO_SMALL\",\n\tmax: \"VALUE_TOO_LARGE\",\n\tmaxLength: \"VALUE_TOO_LARGE\",\n\tdivisor: \"INVALID_TYPE\",\n\tintersection: \"INVALID_TYPE\",\n\tunion: \"INVALID_TYPE\",\n\tunit: \"INVALID_TYPE\",\n\tproto: \"INVALID_TYPE\",\n\tdomain: \"INVALID_TYPE\",\n\texactLength: \"INVALID_FORMAT\",\n\tbefore: \"INVALID_FORMAT\",\n\tafter: \"INVALID_FORMAT\",\n\tpredicate: \"CUSTOM\",\n} satisfies Record<ArkError[\"code\"], EnvIssueCode>;\n\n/**\n * Map an ArkType error code to an ArkEnv issue code.\n *\n * @param engineCode The ArkType engine error code\n * @returns The corresponding ArkEnv issue code\n */\nfunction mapArkTypeCode(engineCode: string): EnvIssueCode {\n\treturn engineCode in ARKTYPE_CODE_MAP\n\t\t? ARKTYPE_CODE_MAP[engineCode as keyof typeof ARKTYPE_CODE_MAP]\n\t\t: \"INVALID_FORMAT\";\n}\n\n/**\n * Extract numeric bounds from an ArkType error object.\n *\n * @param error The ArkType error object\n * @returns An object containing optional min and max bounds\n */\nfunction getArkTypeMeta(error: any): { min?: number; max?: number } {\n\tconst min = error.min ?? error.rule;\n\tconst max = error.max;\n\treturn {\n\t\t...(typeof min === \"number\" ? { min } : {}),\n\t\t...(typeof max === \"number\" ? { max } : {}),\n\t};\n}\n\n/**\n * Redact and colorize the value inside a \"(was ...)\" message fragment.\n *\n * @param message The validation error message\n * @param path The environment variable key path\n * @param debugSecrets Whether to display sensitive values in debug mode\n * @returns The modified error message with styled or redacted value\n */\nfunction redactMessageWasValue(\n\tmessage: string,\n\tpath: string,\n\tdebugSecrets?: boolean,\n): string {\n\tconst valueMatch = message.match(/\\(was (.*)\\)/);\n\tif (!valueMatch?.[1]) return message;\n\n\tconst value = valueMatch[1];\n\tconst debug = isDebugSecrets(debugSecrets);\n\tconst displayedValue = !debug && shouldRedact(path) ? \"[REDACTED]\" : value;\n\n\tif (displayedValue.includes(\"\\x1b[\")) return message;\n\n\treturn message.replace(\n\t\t`(was ${value})`,\n\t\t`(was ${styleText(\"cyan\", displayedValue)})`,\n\t);\n}\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 * Convert ArkType's `ArkErrors` (keyed by path) into a flat `EnvIssue[]`\n * suitable for `ArkEnvError`.\n *\n * @param errors The ArkType errors object to convert\n * @param config Optional ArkEnvConfig to read debugSecrets options\n * @returns An array of flattened validation issues\n *\n * @internal\n */\nfunction arkErrorsToIssues(\n\terrors: ArkErrors,\n\tconfig?: ArkEnvConfig,\n): EnvIssue[] {\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// Redact and style (was ...) inline values\n\t\tmessage = redactMessageWasValue(message, path, config?.debugSecrets);\n\n\t\t// Map code and metadata using centralized helpers\n\t\tconst code = mapArkTypeCode(error.code);\n\t\tconst bounds = getArkTypeMeta(error);\n\t\tconst meta: EnvIssueMeta = {\n\t\t\t...bounds,\n\t\t};\n\n\t\treturn buildEnvIssue(\n\t\t\tpath,\n\t\t\tmessage,\n\t\t\tcode,\n\t\t\tmeta,\n\t\t\terror.expected,\n\t\t\terror.code === \"required\" ? undefined : error.data,\n\t\t);\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 * @param def The ArkType schema definition to validate against\n * @param config The configuration object for parsing and coercion\n * @returns The parsed and validated environment variables\n * @throws {@link ArkEnvError} if validation fails\n *\n * @internal\n */\nexport function parse<const T extends SchemaShape>(\n\tdef: EnvSchema<T>,\n\tconfig: ArkEnvConfig,\n) {\n\tconst {\n\t\tenv = process.env,\n\t\tcoerce: shouldCoerce = true,\n\t\tonUndeclaredKey = \"delete\",\n\t\tarrayFormat = \"comma\",\n\t\temptyAsUndefined = false,\n\t} = config;\n\n\t// If def is a type definition (has assert method), use it directly\n\t// Otherwise, use raw() to convert the schema definition\n\tconst isCompiledType = typeof def === \"function\" && \"assert\" in def;\n\tconst schema = (isCompiledType ? def : $.type.raw(def)) as any;\n\n\t// Apply the `onUndeclaredKey` option\n\tconst schemaWithKeys = schema.onUndeclaredKey(onUndeclaredKey);\n\n\t// Optionally strip empty strings and apply coercion\n\tconst { coercedEnv } = coerceEnvironment(\n\t\tenv,\n\t\temptyAsUndefined,\n\t\tarrayFormat,\n\t\tshouldCoerce\n\t\t\t? () => {\n\t\t\t\t\tconst json = schemaWithKeys.in.toJsonSchema({\n\t\t\t\t\t\tfallback: (ctx: { base: unknown }) => ctx.base,\n\t\t\t\t\t});\n\t\t\t\t\treturn { schema: json, hasSchema: true };\n\t\t\t\t}\n\t\t\t: undefined,\n\t);\n\n\t// Validate the environment variables\n\tconst validatedEnv = schemaWithKeys(coercedEnv);\n\n\t// In ArkType 2.x, calling a type as a function returns the validated data or ArkErrors.\n\tif (\n\t\tvalidatedEnv instanceof ArkErrors ||\n\t\t(validatedEnv &&\n\t\t\ttypeof validatedEnv === \"object\" &&\n\t\t\t((validatedEnv as any)[\" arkKind\"] === \"errors\" ||\n\t\t\t\t(\"byPath\" in validatedEnv &&\n\t\t\t\t\ttypeof (validatedEnv as any).byPath === \"object\")))\n\t) {\n\t\tthrow new ArkEnvError(arkErrorsToIssues(validatedEnv as any, config));\n\t}\n\n\treturn validatedEnv;\n}\n","import type { $ } from \"@repo/scope\";\nimport type {\n\tCompiledEnvSchema,\n\tInferType,\n\tSchemaShape,\n\tStandardSchemaV1,\n} from \"@repo/types\";\nimport {\n\tArkEnvError,\n\tisCapturingSchema,\n\trecordSchemaCapture,\n\ttype SafeArkEnvResult,\n\tsafeExecute,\n} from \"@repo/utils\";\nimport type { type as at, distill } from \"arktype\";\nimport { parse } from \"./arktype\";\n\n/**\n * Declarative environment schema definition accepted by ArkEnv.\n *\n * Maps environment variable names to schema definitions (e.g. ArkType DSL\n * strings or Standard Schema validators).\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> =\n\tT extends StandardSchemaV1<infer _Input, infer Output>\n\t\t? Output\n\t\t: T extends { t: infer U }\n\t\t\t? U\n\t\t\t: T extends at.Any<infer U, infer _Scope>\n\t\t\t\t? U\n\t\t\t\t: T extends SchemaShape\n\t\t\t\t\t? distill.Out<at.infer<T, $>>\n\t\t\t\t\t: InferType<T>;\n\n/**\n * Configuration options for `arkenv`\n */\nexport type ArkEnvConfig = {\n\t/**\n\t * The environment variables to parse. Defaults to `process.env`.\n\t *\n\t * All values must be strings (or `undefined`) to match `process.env` semantics.\n\t */\n\tenv?: Record<string, string | undefined>;\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'` so the output object only contains keys you've declared.\n\t *\n\t * - `delete` (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 * @see https://arktype.io/docs/configuration#onundeclaredkey\n\t */\n\tonUndeclaredKey?: \"ignore\" | \"delete\" | \"reject\";\n\n\t/**\n\t * The format to use for array parsing when coercion is enabled.\n\t *\n\t * - `comma` (default): Strings are split by comma and trimmed.\n\t * - `json`: Strings are parsed as JSON.\n\t *\n\t * @default \"comma\"\n\t */\n\tarrayFormat?: \"comma\" | \"json\";\n\n\t/**\n\t * Whether to bypass secret redaction and print raw sensitive values during debugging.\n\t * Defaults to checking `process.env.ARKENV_DEBUG_SECRETS === \"true\"` or `\"1\"`.\n\t */\n\tdebugSecrets?: boolean;\n\n\t/**\n\t * Whether to treat empty strings (`\"\"`) as `undefined` before validation.\n\t *\n\t * When enabled, an environment variable set to an empty value (e.g. `PORT=`)\n\t * will be treated as if it were missing, allowing defaults to apply and\n\t * preventing validation errors for numeric or boolean types.\n\t *\n\t * @default false\n\t */\n\temptyAsUndefined?: boolean;\n\n\t/**\n\t * Whether to return a safe result object instead of throwing an error on validation failure.\n\t *\n\t * When enabled, the function returns an object with `{ success: true, data }` or `{ success: false, issues }`.\n\t *\n\t * @default false\n\t */\n\tsafe?: boolean;\n};\n\nexport type { SafeArkEnvResult };\n\n/**\n * Parsed environment object inferred from an EnvSchema or CompiledEnvSchema.\n */\nexport type ArkenvOutput<T extends SchemaShape, D> =\n\t| distill.Out<at.infer<T, $>>\n\t| InferType<D>;\n\n/**\n * Parse and validate environment variables using ArkType or Standard Schema.\n *\n * @param def The schema definition\n * @param config The evaluation configuration\n * @returns The parsed environment variables, a SafeArkEnvResult if `{ safe: true }` is configured, or a value-less stub when schema capture is active\n * @throws An {@link ArkEnvError | error} if the environment variables are invalid and `safe` is not enabled\n */\nexport function arkenv<const T extends SchemaShape>(\n\tdef: EnvSchema<T>,\n\tconfig?: ArkEnvConfig & { safe?: false },\n): distill.Out<at.infer<T, $>>;\nexport function arkenv<T extends CompiledEnvSchema>(\n\tdef: T,\n\tconfig?: ArkEnvConfig & { safe?: false },\n): InferType<T>;\nexport function arkenv<\n\tconst T extends SchemaShape,\n\tconst D extends EnvSchema<T> | CompiledEnvSchema,\n>(def: D, config?: ArkEnvConfig & { safe?: false }): ArkenvOutput<T, D>;\nexport function arkenv<const T extends SchemaShape>(\n\tdef: EnvSchema<T>,\n\tconfig: ArkEnvConfig & { safe: true },\n): SafeArkEnvResult<distill.Out<at.infer<T, $>>>;\nexport function arkenv<T extends CompiledEnvSchema>(\n\tdef: T,\n\tconfig: ArkEnvConfig & { safe: true },\n): SafeArkEnvResult<InferType<T>>;\nexport function arkenv<\n\tconst T extends SchemaShape,\n\tconst D extends EnvSchema<T> | CompiledEnvSchema,\n>(\n\tdef: D,\n\tconfig: ArkEnvConfig & { safe: true },\n): SafeArkEnvResult<ArkenvOutput<T, D>>;\nexport function arkenv<\n\tconst T extends SchemaShape,\n\tconst D extends EnvSchema<T> | CompiledEnvSchema,\n>(\n\tdef: D,\n\tconfig: ArkEnvConfig = {},\n): ArkenvOutput<T, D> | SafeArkEnvResult<ArkenvOutput<T, D>> {\n\tif (isCapturingSchema()) {\n\t\trecordSchemaCapture(def);\n\t\t// Capture records the schema only. The returned object has no values, so\n\t\t// schema modules must stay declarative and must not require env at module scope.\n\t\treturn {} as ArkenvOutput<T, D>;\n\t}\n\tif (config.safe) {\n\t\treturn safeExecute(() => parse(def as any, config));\n\t}\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 {\n\tArkEnvError,\n\ttype EnvIssue,\n\tformatIssues,\n\tgetSchemaKeys,\n} from \"@repo/utils\";\nimport { arkenv } from \"./arkenv\";\n\nexport type { EnvIssue };\nexport { ArkEnvError, arkenv, formatIssues, getSchemaKeys };\n/**\n * Like ArkType's `type`, but with ArkEnv's extra keywords, such as:\n *\n * - `string.host` – a hostname (e.g. `\"localhost\"`, `\"127.0.0.1\"`)\n * - `number.port` – a port number (e.g. `8080`)\n *\n * See ArkType's docs for the full API:\n * https://arktype.io/docs/type-api\n */\nexport const type = $.type;\nexport type {\n\tArkEnvConfig,\n\tEnvSchema,\n\tInfer,\n\tSafeArkEnvResult,\n} from \"./arkenv\";\n\nexport default arkenv;\n"],"mappings":";;;AAA0C,MAAM,IAAEA,OAAE,+BAA+B,EAAC,IAAEA,OAAE,0BAA0B,EAAC,IAAEC,MAAE;CAAC,QAAOD,OAAE,OAAO;EAAC,GAAGA,OAAE,SAAS;EAAO,MAAK;EAAE,CAAC;CAAC,QAAOA,OAAE,OAAO;EAAC,GAAGA,OAAE,SAAS;EAAO,MAAK;EAAE,CAAC;CAAC,CAAC;;;;;;;ACIvN,MAAM,oBAAoB;;;;;;;;;;;;;;;ACU1B,MAAM,gBAAgB,MAAM;AAC3B,KAAI,OAAO,MAAM,SAAU,QAAO;AAClC,KAAI,OAAO,MAAM,YAAY,CAAC,EAAE,MAAM,CAAE,QAAO;AAC/C,KAAI,EAAE,MAAM,KAAK,MAAO,QAAO;CAC/B,MAAM,IAAI,OAAO,EAAE;AACnB,QAAO,OAAO,MAAM,EAAE,GAAG,IAAI;;;;;;;;;;;;AAY9B,MAAM,iBAAiB,MAAM;AAC5B,KAAI,MAAM,OAAQ,QAAO;AACzB,KAAI,MAAM,QAAS,QAAO;AAC1B,QAAO;;;;;;;;;;;;AAYR,MAAM,cAAc,MAAM;AACzB,KAAI,OAAO,MAAM,SAAU,QAAO;CAClC,MAAM,UAAU,EAAE,MAAM;AACxB,KAAI,QAAQ,OAAO,OAAO,QAAQ,OAAO,IAAK,QAAO;AACrD,KAAI;AACH,SAAO,KAAK,MAAM,QAAQ;SACnB;AACP,SAAO;;;;;;;;;;;;;;AAcT,MAAM,cAAc,MAAM;AACzB,KAAI,aAAa,KAAM,QAAO;AAC9B,KAAI,OAAO,MAAM,YAAY,CAAC,EAAE,MAAM,CAA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AAK,IAAI,IAAI,EAGxB,gBAAgB,gBAAgB;CAG9D,MAAM,EAAE,eAAe,kBACtB,KACA,kBACA,aACA,qBACS;AAIN,SAAO;GAAE,QAHI,eAAe,GAAG,aAAa,EAC3C,WAAW,QAA2B,IAAI,MAC1C,CACoB;GAAE,WAAW;GAAM;KAExC,OACH;CAGD,MAAM,eAAe,eAAe,WAAW;AAG/C,KACC,wBAAwB,aACvB,gBACA,OAAO,iBAAiB,aACtB,aAAqB,gBAAgB,YACrC,YAAY,gBACZ,OAAQ,aAAqB,WAAW,UAE3C,OAAM,IAAI,YAAY,kBAAkB,cAAqB,OAAO,CAAC;AAGtE,QAAO;;;;;ACvER,SAAgB,OAIf,KACA,SAAuB,EAAE,EACmC;AAC5D,KAAI,mBAAmB,EAAE;AACxB,sBAAoB,IAAI;AAGxB,SAAO,EAAE;;AAEV,KAAI,OAAO,KACV,QAAO,kBAAkB,MAAM,KAAY,OAAO,CAAC;AAGpD,QAAO,MAAM,KAAY,OAAO;;;;;;;;;;;;;;ACtJjC,MAAa,OAAOC,EAAE;AAQtB,kBAAe"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@arkenv/core",
3
3
  "type": "module",
4
- "version": "1.0.0-alpha.6",
4
+ "version": "1.0.0-alpha.7",
5
5
  "description": "Typesafe environment variables parsing and validation with ArkType",
6
6
  "main": "./dist/index.cjs",
7
7
  "module": "./dist/index.mjs",
@@ -54,7 +54,7 @@
54
54
  "typescript": "6.0.3",
55
55
  "vitest": "4.1.5",
56
56
  "zod": "4.4.1",
57
- "@arkenv/standard": "1.0.0-alpha.6",
57
+ "@arkenv/standard": "1.0.0-alpha.7",
58
58
  "@repo/scope": "0.1.3",
59
59
  "@repo/types": "0.1.0",
60
60
  "@repo/utils": "0.1.3"