arkenv 1.0.0-alpha.1 → 1.0.0-alpha.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/core-7-JO-N-w.d.cts +82 -0
- package/dist/core-7-JO-N-w.d.cts.map +1 -0
- package/dist/{core-B0IkKRzg.mjs → core-A65KioHX.mjs} +3 -3
- package/dist/core-A65KioHX.mjs.map +1 -0
- package/dist/core-BaGd9k2K.d.mts +76 -0
- package/dist/core-BaGd9k2K.d.mts.map +1 -0
- package/dist/{core-BftJnV8f.cjs → core-CA13n2Iu.cjs} +2 -2
- package/dist/core.cjs +1 -1
- package/dist/core.d.cts +3 -40
- package/dist/core.d.mts +2 -40
- package/dist/core.mjs +1 -1
- package/dist/errors-C_uh86xh.mjs +3 -0
- package/dist/errors-C_uh86xh.mjs.map +1 -0
- package/dist/errors-Dn6WQ2pP.cjs +8 -0
- package/dist/{index-CzNfOanV.d.cts → index-Do-2CL1V.d.cts} +2 -2
- package/dist/index-Do-2CL1V.d.cts.map +1 -0
- package/dist/{index-Br22fqkz.d.mts → index-NbQAnciD.d.mts} +2 -2
- package/dist/index-NbQAnciD.d.mts.map +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +62 -12
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +62 -12
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +1 -1
- package/dist/index.mjs.map +1 -1
- package/dist/standard.cjs +1 -1
- package/dist/standard.d.cts +24 -5
- package/dist/standard.d.cts.map +1 -1
- package/dist/standard.d.mts +24 -5
- package/dist/standard.d.mts.map +1 -1
- package/dist/standard.mjs +1 -1
- package/dist/standard.mjs.map +1 -1
- package/package.json +3 -3
- package/dist/core-B0IkKRzg.mjs.map +0 -1
- package/dist/core.d.cts.map +0 -1
- package/dist/core.d.mts.map +0 -1
- package/dist/index-Br22fqkz.d.mts.map +0 -1
- package/dist/index-CzNfOanV.d.cts.map +0 -1
- package/dist/shared-B7lIFzfk.mjs +0 -3
- package/dist/shared-B7lIFzfk.mjs.map +0 -1
- package/dist/shared-Bx3sbEJf.cjs +0 -8
package/dist/standard.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"standard.mjs","names":[],"sources":["../src/guards.ts","../src/parse-standard.ts","../src/standard.ts"],"sourcesContent":["import { ArkEnvError } from \"./core\";\n\n/**\n * Throws if the given value is a string (ArkType DSL) in standard mode.\n * @internal\n */\nexport function assertNotArkTypeDsl(key: string, value: unknown): void {\n\tif (typeof value === \"string\") {\n\t\tthrow new ArkEnvError([\n\t\t\t{\n\t\t\t\tpath: key,\n\t\t\t\tmessage:\n\t\t\t\t\t'ArkType DSL strings are not supported in \"standard\" mode. Use a Standard Schema validator (e.g., Zod, Valibot) or import from \"arkenv\" for ArkType schemas.',\n\t\t\t},\n\t\t]);\n\t}\n}\n\n/**\n * Throws if the given value is not a well-formed Standard Schema validator\n * (must have a `~standard` property whose `validate` field is a function).\n * @internal\n */\nexport function assertStandardSchema(key: string, value: unknown): void {\n\tconst std =\n\t\tvalue &&\n\t\ttypeof value === \"object\" &&\n\t\t\"~standard\" in value &&\n\t\t(value as Record<string, unknown>)[\"~standard\"];\n\n\tif (\n\t\t!std ||\n\t\ttypeof std !== \"object\" ||\n\t\t!(\"validate\" in std) ||\n\t\ttypeof (std as Record<string, unknown>).validate !== \"function\"\n\t) {\n\t\tthrow new ArkEnvError([\n\t\t\t{\n\t\t\t\tpath: key,\n\t\t\t\tmessage:\n\t\t\t\t\t'Invalid validator: expected a Standard Schema 1.0 validator (must have \"~standard\" property). Import from \"arkenv\" to use ArkType schemas.',\n\t\t\t},\n\t\t]);\n\t}\n}\n\n/**\n * Throws if `def` is not a plain object (i.e. not a valid schema map).\n * @internal\n */\nexport function assertStandardSchemaMap(\n\tdef: unknown,\n): asserts def is Record<string, unknown> {\n\tif (!def || typeof def !== \"object\" || Array.isArray(def)) {\n\t\tthrow new ArkEnvError([\n\t\t\t{\n\t\t\t\tpath: \"\",\n\t\t\t\tmessage:\n\t\t\t\t\t'Invalid schema: expected an object mapping in \"standard\" mode.',\n\t\t\t},\n\t\t]);\n\t}\n}\n","import type { StandardSchemaV1 } from \"@repo/types\";\nimport {\n\tapplyCoercion,\n\tfindCoercionPaths,\n\tstripEmptyStrings,\n} from \"./coercion/shared\";\nimport { ArkEnvError, type ValidationIssue } from \"./core\";\n\n/**\n * Configuration options for {@link parseStandard}.\n */\nexport type ParseStandardConfig = {\n\t/**\n\t * The environment variables to parse. Defaults to `process.env`\n\t */\n\tenv?: Record<string, string | undefined>;\n\t/**\n\t * Control how ArkEnv handles environment variables that are not defined in your schema.\n\t *\n\t * Defaults to `'delete'` to ensure your output object only contains\n\t * keys you've explicitly declared.\n\t *\n\t * - `delete` (ArkEnv default): Undeclared keys are allowed on input but stripped from the output.\n\t * - `ignore`: Undeclared keys are allowed and preserved in the output.\n\t * - `reject`: Undeclared keys will cause validation to fail.\n\t *\n\t * @default \"delete\"\n\t */\n\tonUndeclaredKey?: \"ignore\" | \"delete\" | \"reject\";\n\t/**\n\t * Whether to perform best-effort coercion on the environment variables.\n\t * Coercion requires validators that implement the StandardJSONSchemaV1 spec\n\t * (e.g. Zod, Valibot).\n\t *\n\t * @see https://standard-schema.dev\n\t * @default true\n\t */\n\tcoerce?: boolean;\n\t/**\n\t * The format to use for array parsing when coercion is enabled.\n\t *\n\t * - `comma` (default): Strings are split by comma and trimmed.\n\t * - `json`: Strings are parsed as JSON.\n\t *\n\t * @default \"comma\"\n\t */\n\tarrayFormat?: \"comma\" | \"json\";\n\n\t/**\n\t * Whether to treat empty strings (`\"\"`) as `undefined` before validation.\n\t *\n\t * When enabled, an environment variable set to an empty value (e.g. `PORT=`)\n\t * will be treated as if it were missing, allowing defaults to apply and\n\t * preventing validation errors for numeric or boolean types.\n\t *\n\t * @default false\n\t */\n\temptyAsUndefined?: boolean;\n};\n\n/**\n * Extract JSON Schema definitions from standard schema validators.\n */\nfunction extractJsonSchema(\n\tdef: Record<string, unknown>,\n\tmissingJsonSchemaKeys: string[],\n): { jsonSchema: Record<string, any>; hasJsonSchema: boolean } {\n\tconst jsonSchema: Record<string, any> = { type: \"object\", properties: {} };\n\tlet hasJsonSchema = false;\n\n\tfor (const key in def) {\n\t\tconst validator = def[key] as any;\n\t\tif (!validator) {\n\t\t\tmissingJsonSchemaKeys.push(key);\n\t\t\tcontinue;\n\t\t}\n\n\t\t// 1. Standard way via ~standard property\n\t\tconst std = validator[\"~standard\"];\n\t\tif (typeof std?.jsonSchema?.input === \"function\") {\n\t\t\ttry {\n\t\t\t\tconst schema = std.jsonSchema.input({ target: \"draft-07\" });\n\t\t\t\tif (schema) {\n\t\t\t\t\tjsonSchema.properties[key] = schema;\n\t\t\t\t\thasJsonSchema = true;\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t} catch {}\n\t\t}\n\n\t\t// 2. Direct jsonSchema.input on validator\n\t\tif (typeof validator.jsonSchema?.input === \"function\") {\n\t\t\ttry {\n\t\t\t\tconst schema = validator.jsonSchema.input({ target: \"draft-07\" });\n\t\t\t\tif (schema) {\n\t\t\t\t\tjsonSchema.properties[key] = schema;\n\t\t\t\t\thasJsonSchema = true;\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t} catch {}\n\t\t}\n\n\t\t// 3. toJSONSchema method (e.g. zod mini, zod-to-json-schema)\n\t\tif (typeof validator.toJSONSchema === \"function\") {\n\t\t\ttry {\n\t\t\t\tconst schema = validator.toJSONSchema();\n\t\t\t\tif (schema) {\n\t\t\t\t\tjsonSchema.properties[key] = schema;\n\t\t\t\t\thasJsonSchema = true;\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t} catch {}\n\t\t}\n\n\t\t// 4. toStandardJSONSchema.v1 method (e.g. stnl)\n\t\tif (typeof validator.toStandardJSONSchema?.v1 === \"function\") {\n\t\t\ttry {\n\t\t\t\tconst schema = validator.toStandardJSONSchema.v1();\n\t\t\t\tif (schema) {\n\t\t\t\t\tjsonSchema.properties[key] = schema;\n\t\t\t\t\thasJsonSchema = true;\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t} catch {}\n\t\t}\n\n\t\tmissingJsonSchemaKeys.push(key);\n\t}\n\n\treturn { jsonSchema, hasJsonSchema };\n}\n\n/**\n * Format standard schema validation issue path.\n */\nfunction formatIssuePath(\n\tkey: string,\n\tpath:\n\t\t| readonly (\n\t\t\t\t| string\n\t\t\t\t| number\n\t\t\t\t| symbol\n\t\t\t\t| { readonly key: string | number | symbol }\n\t\t )[]\n\t\t| undefined,\n): string {\n\tif (!path || path.length === 0) return key;\n\n\tconst segments = path.map((segment) =>\n\t\tsegment !== null && typeof segment === \"object\" && \"key\" in segment\n\t\t\t? String(segment.key)\n\t\t\t: String(segment),\n\t);\n\treturn [key, ...segments].join(\".\");\n}\n\n/**\n * Parse and validate environment variables using Standard Schema 1.0 validators.\n *\n * @param def An object mapping environment variable keys to Standard Schema 1.0 validators\n * @param config Parsing options, including environment source, undeclared key handling, and coercion config\n * @returns The parsed and validated environment variables\n * @throws An ArkEnvError if validation fails\n */\nexport function parseStandard(\n\tdef: Record<string, unknown>,\n\tconfig: ParseStandardConfig,\n) {\n\tconst {\n\t\tenv = process.env,\n\t\tonUndeclaredKey = \"delete\",\n\t\tcoerce = true,\n\t\tarrayFormat = \"comma\",\n\t\temptyAsUndefined = false,\n\t} = config;\n\tconst output: Record<string, unknown> = {};\n\tconst errors: ValidationIssue[] = [];\n\n\tconst processedEnv = emptyAsUndefined\n\t\t? stripEmptyStrings(env as Record<string, string | undefined>)\n\t\t: env;\n\tconst envKeys = new Set(Object.keys(processedEnv));\n\n\tlet coercedEnv: Record<string, unknown> = { ...processedEnv };\n\tconst missingJsonSchemaKeys: string[] = [];\n\n\tif (coerce) {\n\t\tconst { jsonSchema, hasJsonSchema } = extractJsonSchema(\n\t\t\tdef,\n\t\t\tmissingJsonSchemaKeys,\n\t\t);\n\t\tif (hasJsonSchema) {\n\t\t\tcoercedEnv = applyCoercion(coercedEnv, findCoercionPaths(jsonSchema), {\n\t\t\t\tarrayFormat,\n\t\t\t}) as Record<string, unknown>;\n\t\t}\n\t}\n\n\t// 1. Validate declared keys\n\tfor (const key in def) {\n\t\tconst validator = def[key];\n\t\tconst value = coercedEnv[key];\n\n\t\t// Check if it's a Standard Schema validator\n\t\tif (\n\t\t\t!validator ||\n\t\t\ttypeof validator !== \"object\" ||\n\t\t\t!(\"~standard\" in validator)\n\t\t) {\n\t\t\tthrow new ArkEnvError([\n\t\t\t\t{\n\t\t\t\t\tpath: key,\n\t\t\t\t\tmessage: `Invalid schema: expected a Standard Schema 1.0 validator (e.g. Zod, Valibot) in 'standard' mode.`,\n\t\t\t\t},\n\t\t\t]);\n\t\t}\n\n\t\tconst result = (validator as StandardSchemaV1)[\"~standard\"].validate(value);\n\n\t\tif (result instanceof Promise) {\n\t\t\tthrow new ArkEnvError([\n\t\t\t\t{\n\t\t\t\t\tpath: key,\n\t\t\t\t\tmessage: \"Async validation is not supported. ArkEnv is synchronous.\",\n\t\t\t\t},\n\t\t\t]);\n\t\t}\n\n\t\tif (result.issues) {\n\t\t\tfor (const issue of result.issues) {\n\t\t\t\tconst issuePath = formatIssuePath(key, issue.path);\n\t\t\t\tlet message = issue.message;\n\n\t\t\t\tif (coerce && missingJsonSchemaKeys.includes(key)) {\n\t\t\t\t\tmessage += ` (Hint: coercion is enabled by default, but the validator for '${key}' lacks Standard JSON Schema support.)`;\n\t\t\t\t}\n\n\t\t\t\terrors.push({\n\t\t\t\t\tpath: issuePath,\n\t\t\t\t\tmessage,\n\t\t\t\t});\n\t\t\t}\n\t\t} else {\n\t\t\toutput[key] = result.value;\n\t\t}\n\n\t\tenvKeys.delete(key);\n\t}\n\n\t// 2. Handle undeclared keys\n\tif (onUndeclaredKey !== \"delete\") {\n\t\tfor (const key of envKeys) {\n\t\t\tif (onUndeclaredKey === \"reject\") {\n\t\t\t\terrors.push({\n\t\t\t\t\tpath: key,\n\t\t\t\t\tmessage: \"Undeclared key\",\n\t\t\t\t});\n\t\t\t} else if (onUndeclaredKey === \"ignore\") {\n\t\t\t\toutput[key] = coercedEnv[key];\n\t\t\t}\n\t\t}\n\t}\n\n\tif (errors.length > 0) {\n\t\tthrow new ArkEnvError(errors);\n\t}\n\n\treturn output;\n}\n","import type { StandardSchemaV1 } from \"@repo/types\";\nimport {\n\tassertNotArkTypeDsl,\n\tassertStandardSchema,\n\tassertStandardSchemaMap,\n} from \"./guards\";\nimport { type ParseStandardConfig, parseStandard } from \"./parse-standard\";\n\n/**\n * Configuration options for the `arkenv/standard` entry's `arkenv`.\n */\nexport type StandardEnvConfig = ParseStandardConfig;\n\n/**\n * Parse and validate environment variables using Standard Schema 1.0 validators (e.g. Zod, Valibot).\n *\n * This entry is ArkType-free - ArkType is never imported, even transitively.\n * Use this when your project must not depend on ArkType.\n *\n * @param def An object mapping variable names to Standard Schema validators\n * @param config Optional configuration\n * @returns The validated environment variables\n * @throws An {@link ArkEnvError} if validation fails\n *\n * @example\n * ```ts\n * import arkenv from \"arkenv/standard\";\n * import { z } from \"zod\";\n *\n * const env = arkenv({\n * PORT: z.coerce.number(),\n * HOST: z.string(),\n * });\n * ```\n */\nexport function arkenv<const T extends Record<string, StandardSchemaV1>>(\n\tdef: T,\n\tconfig?: StandardEnvConfig,\n): { [K in keyof T]: StandardSchemaV1.InferOutput<T[K]> } {\n\tassertStandardSchemaMap(def);\n\n\tfor (const key in def) {\n\t\tconst validator = (def as Record<string, unknown>)[key];\n\t\tassertNotArkTypeDsl(key, validator);\n\t\tassertStandardSchema(key, validator);\n\t}\n\n\treturn parseStandard(def as Record<string, unknown>, config ?? {}) as {\n\t\t[K in keyof T]: StandardSchemaV1.InferOutput<T[K]>;\n\t};\n}\n\n/**\n * ArkEnv's Standard Schema export\n *\n * {@link https://arkenv.js.org | ArkEnv} is a typesafe environment variables validator from editor to runtime.\n */\nexport default arkenv;\n"],"mappings":"gGAMA,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AAS,EAAO,OAAQ,CAClC,IAAM,EAAY,EAAgB,EAAK,EAAM,KAAK,CAC9C,EAAU,EAAM,QAEhB,GAAU,EAAsB,SAAS,EAAI,GAChD,GAAW,kEAAkE,EAAI,yCAGlF,EAAO,KAAK,CACX,KAAM,EACN,UACA,CAAC,MAGH,EAAO,GAAO,EAAO,MAGtB,EAAQ,OAAO,EAAI,CAIpB,GAAI,IAAoB,aAClB,IAAM,KAAO,EACb,IAAoB,SACvB,EAAO,KAAK,CACX,KAAM,EACN,QAAS,iBACT,CAAC,CACQ,IAAoB,WAC9B,EAAO,GAAO,EAAW,IAK5B,GAAI,EAAO,OAAS,EACnB,MAAM,IAAI,EAAY,EAAO,CAG9B,OAAO,ECxOR,SAAgB,EACf,EACA,EACyD,CACzD,EAAwB,EAAI,CAE5B,IAAK,IAAM,KAAO,EAAK,CACtB,IAAM,EAAa,EAAgC,GACnD,EAAoB,EAAK,EAAU,CACnC,EAAqB,EAAK,EAAU,CAGrC,OAAO,EAAc,EAAgC,GAAU,EAAE,CAAC"}
|
|
1
|
+
{"version":3,"file":"standard.mjs","names":[],"sources":["../src/guards.ts","../src/utils/standard-helpers.ts","../src/parse-standard.ts","../src/standard.ts"],"sourcesContent":["import { ArkEnvError } from \"./core\";\n\n/**\n * Throws if the given value is a string (ArkType DSL) in standard mode.\n * @internal\n */\nexport function assertNotArkTypeDsl(key: string, value: unknown): void {\n\tif (typeof value === \"string\") {\n\t\tthrow new ArkEnvError([\n\t\t\t{\n\t\t\t\tpath: key,\n\t\t\t\tmessage:\n\t\t\t\t\t'ArkType DSL strings are not supported in \"standard\" mode. Use a Standard Schema validator (e.g., Zod, Valibot) or import from \"arkenv\" for ArkType schemas.',\n\t\t\t\tcode: \"INVALID_SCHEMA\",\n\t\t\t},\n\t\t]);\n\t}\n}\n\n/**\n * Throws if the given value is not a well-formed Standard Schema validator\n * (must have a `~standard` property whose `validate` field is a function).\n * @internal\n */\nexport function assertStandardSchema(key: string, value: unknown): void {\n\tconst std =\n\t\tvalue &&\n\t\ttypeof value === \"object\" &&\n\t\t\"~standard\" in value &&\n\t\t(value as Record<string, unknown>)[\"~standard\"];\n\n\tif (\n\t\t!std ||\n\t\ttypeof std !== \"object\" ||\n\t\t!(\"validate\" in std) ||\n\t\ttypeof (std as Record<string, unknown>).validate !== \"function\"\n\t) {\n\t\tthrow new ArkEnvError([\n\t\t\t{\n\t\t\t\tpath: key,\n\t\t\t\tmessage:\n\t\t\t\t\t'Invalid validator: expected a Standard Schema 1.0 validator (must have \"~standard\" property). Import from \"arkenv\" to use ArkType schemas.',\n\t\t\t\tcode: \"INVALID_SCHEMA\",\n\t\t\t},\n\t\t]);\n\t}\n}\n\n/**\n * Throws if `def` is not a plain object (i.e. not a valid schema map).\n * @internal\n */\nexport function assertStandardSchemaMap(\n\tdef: unknown,\n): asserts def is Record<string, unknown> {\n\tif (!def || typeof def !== \"object\" || Array.isArray(def)) {\n\t\tthrow new ArkEnvError([\n\t\t\t{\n\t\t\t\tpath: \"\",\n\t\t\t\tmessage:\n\t\t\t\t\t'Invalid schema: expected an object mapping in \"standard\" mode.',\n\t\t\t\tcode: \"INVALID_SCHEMA\",\n\t\t\t},\n\t\t]);\n\t}\n}\n","/**\n * Extract JSON Schema definitions from standard schema validators.\n *\n * @param def The schema dictionary mapping keys to validators\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 */\nexport function extractJsonSchema(def: Record<string, unknown>): {\n\tjsonSchema: Record<string, any>;\n\thasJsonSchema: boolean;\n\tmissingKeys: string[];\n} {\n\tconst jsonSchema: Record<string, any> = { type: \"object\", properties: {} };\n\tlet hasJsonSchema = false;\n\tconst missingKeys: string[] = [];\n\n\tfor (const key in def) {\n\t\tconst validator = def[key] as any;\n\t\tif (!validator) {\n\t\t\tmissingKeys.push(key);\n\t\t\tcontinue;\n\t\t}\n\n\t\t// 1. Standard way via ~standard property\n\t\tconst std = validator[\"~standard\"];\n\t\tif (typeof std?.jsonSchema?.input === \"function\") {\n\t\t\ttry {\n\t\t\t\tconst schema = std.jsonSchema.input({ target: \"draft-07\" });\n\t\t\t\tif (schema) {\n\t\t\t\t\tjsonSchema.properties[key] = schema;\n\t\t\t\t\thasJsonSchema = true;\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t} catch {}\n\t\t}\n\n\t\t// 2. Direct jsonSchema.input on validator\n\t\tif (typeof validator.jsonSchema?.input === \"function\") {\n\t\t\ttry {\n\t\t\t\tconst schema = validator.jsonSchema.input({ target: \"draft-07\" });\n\t\t\t\tif (schema) {\n\t\t\t\t\tjsonSchema.properties[key] = schema;\n\t\t\t\t\thasJsonSchema = true;\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t} catch {}\n\t\t}\n\n\t\t// 3. toJSONSchema method (e.g. zod mini, zod-to-json-schema)\n\t\tif (typeof validator.toJSONSchema === \"function\") {\n\t\t\ttry {\n\t\t\t\tconst schema = validator.toJSONSchema();\n\t\t\t\tif (schema) {\n\t\t\t\t\tjsonSchema.properties[key] = schema;\n\t\t\t\t\thasJsonSchema = true;\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t} catch {}\n\t\t}\n\n\t\t// 4. toStandardJSONSchema.v1 method (e.g. stnl)\n\t\tif (typeof validator.toStandardJSONSchema?.v1 === \"function\") {\n\t\t\ttry {\n\t\t\t\tconst schema = validator.toStandardJSONSchema.v1();\n\t\t\t\tif (schema) {\n\t\t\t\t\tjsonSchema.properties[key] = schema;\n\t\t\t\t\thasJsonSchema = true;\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t} catch {}\n\t\t}\n\n\t\tmissingKeys.push(key);\n\t}\n\n\treturn { jsonSchema, hasJsonSchema, missingKeys };\n}\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 */\nexport function getProp(\n\ts: string | number | symbol | { readonly key: string | number | symbol },\n): string {\n\treturn typeof s === \"object\" && s !== null && \"key\" in s\n\t\t? String(s.key)\n\t\t: String(s);\n}\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 */\nexport function formatIssuePath(\n\tkey: string,\n\tpath:\n\t\t| readonly (\n\t\t\t\t| string\n\t\t\t\t| number\n\t\t\t\t| symbol\n\t\t\t\t| { readonly key: string | number | symbol }\n\t\t )[]\n\t\t| undefined,\n): string {\n\tif (!path || path.length === 0) return key;\n\treturn [key, ...path.map(getProp)].join(\".\");\n}\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 */\nexport function traverseReceivedValue(\n\trawVal: string,\n\tpath: readonly (\n\t\t| string\n\t\t| number\n\t\t| symbol\n\t\t| { readonly key: string | number | symbol }\n\t)[],\n): { receivedVal: unknown; traversalError?: string | undefined } {\n\tlet receivedVal: unknown = rawVal;\n\tlet traversalError: string | undefined;\n\n\ttry {\n\t\tlet current: any = rawVal;\n\t\tconst trimmed = rawVal.trim();\n\t\tif (trimmed[0] === \"{\" || trimmed[0] === \"[\") {\n\t\t\ttry {\n\t\t\t\tcurrent = JSON.parse(rawVal);\n\t\t\t} catch (e: any) {\n\t\t\t\ttraversalError = `[Unparseable JSON: ${e.message}]`;\n\t\t\t}\n\t\t}\n\t\tif (!traversalError) {\n\t\t\tfor (const seg of path) {\n\t\t\t\tcurrent = current?.[getProp(seg)];\n\t\t\t}\n\t\t\treceivedVal = current;\n\t\t}\n\t} catch (e: any) {\n\t\ttraversalError = `[Traversal error: ${e.message}]`;\n\t}\n\n\treturn { receivedVal, traversalError };\n}\n","import type { Dict, StandardSchemaV1 } from \"@repo/types\";\nimport { coerceEnvironment } from \"@/coercion\";\nimport { ArkEnvError, type EnvIssue, type EnvIssueMeta } from \"./core\";\nimport {\n\tbuildEnvIssue,\n\tformatStandardIssueMessage,\n\tgetStandardMeta,\n\tmapStandardCode,\n} from \"./utils/errors\";\nimport {\n\textractJsonSchema,\n\tformatIssuePath,\n\ttraverseReceivedValue,\n} from \"./utils/standard-helpers\";\n\n/*\n * ⚠️ ARCHITECTURAL WARNING: DO NOT DRY THIS FILE ⚠️\n *\n * This file contains parsing logic that looks very similar to the code in\n * `src/arktype/index.ts`. **This duplication is 100% intentional.**\n *\n * `parse-standard.ts` powers the `arkenv/standard` module export. The entire\n * purpose of the `arkenv/standard` entrypoint is to guarantee a zero-dependency\n * environment for users utilizing Zod or Valibot, ensuring the `arktype` library\n * is NEVER included in their bundle.\n *\n * If you attempt to DRY up this code by merging it with the ArkType parser or\n * importing utilities from `src/arktype/*`, bundlers will statically trace those\n * imports and silently drag the entire ArkType library into the `arkenv/standard`\n * bundle.\n *\n * Prioritize strict module boundaries and tree-shaking over DRYness.\n */\n\n/**\n * Configuration options for {@link parseStandard}.\n */\nexport type ParseStandardConfig = {\n\t/**\n\t * The environment variables to parse. Defaults to `process.env`\n\t */\n\tenv?: Dict<string>;\n\t/**\n\t * Control how ArkEnv handles environment variables that are not defined in your schema.\n\t *\n\t * Defaults to `'delete'` to ensure your output object only contains\n\t * keys you've explicitly declared.\n\t *\n\t * - `delete` (ArkEnv default): Undeclared keys are allowed on input but stripped from the output.\n\t * - `ignore`: Undeclared keys are allowed and preserved in the output.\n\t * - `reject`: Undeclared keys will cause validation to fail.\n\t *\n\t * @default \"delete\"\n\t */\n\tonUndeclaredKey?: \"ignore\" | \"delete\" | \"reject\";\n\t/**\n\t * Whether to 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 perform best-effort coercion on the environment variables.\n\t * Coercion requires validators that implement the StandardJSONSchemaV1 spec\n\t * (e.g. Zod, Valibot).\n\t *\n\t * @see https://standard-schema.dev\n\t * @default true\n\t */\n\tcoerce?: boolean;\n\n\t/**\n\t * The format to use for array parsing when coercion is enabled.\n\t *\n\t * - `comma` (default): Strings are split by comma and trimmed.\n\t * - `json`: Strings are parsed as JSON.\n\t *\n\t * @default \"comma\"\n\t */\n\tarrayFormat?: \"comma\" | \"json\";\n\n\t/**\n\t * Whether to treat empty strings (`\"\"`) as `undefined` before validation.\n\t *\n\t * When enabled, an environment variable set to an empty value (e.g. `PORT=`)\n\t * will be treated as if it were missing, allowing defaults to apply and\n\t * preventing validation errors for numeric or boolean types.\n\t *\n\t * @default false\n\t */\n\temptyAsUndefined?: boolean;\n\n\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\n/**\n * Parse and validate environment variables using Standard Schema 1.0 validators.\n *\n * @param def An object mapping environment variable keys to Standard Schema 1.0 validators\n * @param config Parsing options, including environment source, undeclared key handling, and coercion config\n * @returns The parsed and validated environment variables\n * @throws An ArkEnvError if validation fails\n */\nexport function parseStandard(\n\tdef: Record<string, unknown>,\n\tconfig: ParseStandardConfig,\n): Record<string, unknown> {\n\tconst {\n\t\tenv = process.env,\n\t\tonUndeclaredKey = \"delete\",\n\t\tcoerce = true,\n\t\tarrayFormat = \"comma\",\n\t\temptyAsUndefined = false,\n\t} = config;\n\tconst output: Record<string, unknown> = {};\n\tconst errors: EnvIssue[] = [];\n\n\tconst {\n\t\tprocessedEnv,\n\t\tcoercedEnv,\n\t\tmissingKeys: missingJsonSchemaKeys,\n\t} = coerceEnvironment(\n\t\tenv as Dict<string>,\n\t\temptyAsUndefined,\n\t\tarrayFormat,\n\t\tcoerce\n\t\t\t? () => {\n\t\t\t\t\tconst { jsonSchema, hasJsonSchema, missingKeys } =\n\t\t\t\t\t\textractJsonSchema(def);\n\t\t\t\t\treturn {\n\t\t\t\t\t\tschema: jsonSchema,\n\t\t\t\t\t\thasSchema: hasJsonSchema,\n\t\t\t\t\t\tmissingKeys,\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t: undefined,\n\t);\n\tconst envKeys = new Set(Object.keys(processedEnv));\n\n\t// 1. Validate declared keys\n\tfor (const key in def) {\n\t\tconst validator = def[key];\n\t\tconst value = coercedEnv[key];\n\n\t\t// Check if it's a Standard Schema validator\n\t\tif (\n\t\t\t!validator ||\n\t\t\ttypeof validator !== \"object\" ||\n\t\t\t!(\"~standard\" in validator)\n\t\t) {\n\t\t\tthrow new ArkEnvError([\n\t\t\t\tbuildEnvIssue(\n\t\t\t\t\tkey,\n\t\t\t\t\t`Invalid schema: expected a Standard Schema 1.0 validator (e.g. Zod, Valibot) in 'standard' mode.`,\n\t\t\t\t\t\"INVALID_SCHEMA\",\n\t\t\t\t),\n\t\t\t]);\n\t\t}\n\n\t\tconst result = (validator as StandardSchemaV1)[\"~standard\"].validate(value);\n\n\t\tif (result instanceof Promise) {\n\t\t\tthrow new ArkEnvError([\n\t\t\t\tbuildEnvIssue(\n\t\t\t\t\tkey,\n\t\t\t\t\t\"Async validation is not supported. ArkEnv is synchronous.\",\n\t\t\t\t\t\"INVALID_SCHEMA\",\n\t\t\t\t),\n\t\t\t]);\n\t\t}\n\n\t\tif (result.issues) {\n\t\t\tfor (const issue of result.issues) {\n\t\t\t\tconst issuePath = formatIssuePath(key, issue.path);\n\n\t\t\t\tlet receivedVal: unknown;\n\t\t\t\tlet traversalError: string | undefined;\n\n\t\t\t\tif (key in processedEnv) {\n\t\t\t\t\tconst rawVal = processedEnv[key];\n\t\t\t\t\tif (typeof rawVal === \"string\" && issue.path?.length) {\n\t\t\t\t\t\tconst traversed = traverseReceivedValue(rawVal, issue.path);\n\t\t\t\t\t\treceivedVal = traversed.receivedVal;\n\t\t\t\t\t\ttraversalError = traversed.traversalError;\n\t\t\t\t\t} else {\n\t\t\t\t\t\treceivedVal = rawVal;\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\treceivedVal = (issue as any).received;\n\t\t\t\t}\n\n\t\t\t\tconst issueCode = (issue as any).code || \"invalid_type\";\n\t\t\t\tconst msg = issue.message || \"\";\n\t\t\t\tconst code = mapStandardCode(issueCode, msg, receivedVal);\n\n\t\t\t\tconst expected = (issue as any).expected || undefined;\n\t\t\t\tconst bounds = getStandardMeta(issue);\n\n\t\t\t\tconst meta: EnvIssueMeta = {\n\t\t\t\t\t...bounds,\n\t\t\t\t};\n\t\t\t\tconst iss = issue as any;\n\t\t\t\tif (iss.validation !== undefined) meta.validation = iss.validation;\n\t\t\t\tif (traversalError !== undefined) meta.traversalError = traversalError;\n\n\t\t\t\tlet message = formatStandardIssueMessage(\n\t\t\t\t\tissue.message || \"\",\n\t\t\t\t\tcode,\n\t\t\t\t\texpected,\n\t\t\t\t\treceivedVal,\n\t\t\t\t\tissuePath,\n\t\t\t\t\tconfig,\n\t\t\t\t);\n\n\t\t\t\tif (coerce && missingJsonSchemaKeys.includes(key)) {\n\t\t\t\t\tmessage += ` (Hint: coercion is enabled by default, but the validator for '${key}' lacks Standard JSON Schema support.)`;\n\t\t\t\t}\n\n\t\t\t\terrors.push(\n\t\t\t\t\tbuildEnvIssue(issuePath, message, code, meta, expected, receivedVal),\n\t\t\t\t);\n\t\t\t}\n\t\t} else {\n\t\t\toutput[key] = result.value;\n\t\t}\n\n\t\tenvKeys.delete(key);\n\t}\n\n\t// 2. Handle undeclared keys\n\tif (onUndeclaredKey !== \"delete\") {\n\t\tfor (const key of envKeys) {\n\t\t\tif (onUndeclaredKey === \"reject\") {\n\t\t\t\terrors.push(buildEnvIssue(key, \"Undeclared key\", \"UNDECLARED_KEY\"));\n\t\t\t} else if (onUndeclaredKey === \"ignore\") {\n\t\t\t\toutput[key] = coercedEnv[key];\n\t\t\t}\n\t\t}\n\t}\n\n\tif (errors.length > 0) {\n\t\tthrow new ArkEnvError(errors);\n\t}\n\n\treturn output;\n}\n","import type { StandardSchemaV1 } from \"@repo/types\";\nimport { ArkEnvError, type SafeArkEnvResult } from \"./core\";\nimport {\n\tassertNotArkTypeDsl,\n\tassertStandardSchema,\n\tassertStandardSchemaMap,\n} from \"./guards\";\nimport { type ParseStandardConfig, parseStandard } from \"./parse-standard\";\nimport { safeExecute } from \"./utils/errors\";\n\n/**\n * Configuration options for the `arkenv/standard` entry's `arkenv`.\n */\nexport type StandardEnvConfig = ParseStandardConfig;\n\n/**\n * Parse and validate environment variables using Standard Schema 1.0 validators (e.g. Zod, Valibot).\n *\n * This entry is ArkType-free - ArkType is never imported, even transitively.\n * Use this when your project must not depend on ArkType.\n *\n * @param def An object mapping variable names to Standard Schema validators\n * @param config Optional configuration\n * @returns The validated environment variables, or a SafeArkEnvResult if `{ safe: true }` is configured\n * @throws An {@link ArkEnvError} if validation fails and `safe` is not enabled\n *\n * @example\n * ```ts\n * import arkenv from \"arkenv/standard\";\n * import { z } from \"zod\";\n *\n * const env = arkenv({\n * PORT: z.coerce.number(),\n * HOST: z.string(),\n * });\n * ```\n */\nexport function arkenv<const T extends Record<string, StandardSchemaV1>>(\n\tdef: T,\n\tconfig?: StandardEnvConfig & { safe?: false },\n): { [K in keyof T]: StandardSchemaV1.InferOutput<T[K]> };\nexport function arkenv<const T extends Record<string, StandardSchemaV1>>(\n\tdef: T,\n\tconfig: StandardEnvConfig & { safe: true },\n): SafeArkEnvResult<{ [K in keyof T]: StandardSchemaV1.InferOutput<T[K]> }>;\nexport function arkenv<const T extends Record<string, StandardSchemaV1>>(\n\tdef: T,\n\tconfig: StandardEnvConfig = {},\n):\n\t| { [K in keyof T]: StandardSchemaV1.InferOutput<T[K]> }\n\t| SafeArkEnvResult<{ [K in keyof T]: StandardSchemaV1.InferOutput<T[K]> }> {\n\tassertStandardSchemaMap(def);\n\n\tfor (const key in def) {\n\t\tconst validator = (def as Record<string, unknown>)[key];\n\t\tassertNotArkTypeDsl(key, validator);\n\t\tassertStandardSchema(key, validator);\n\t}\n\n\tif (config.safe) {\n\t\treturn safeExecute(\n\t\t\t() =>\n\t\t\t\tparseStandard(def as Record<string, unknown>, config) as {\n\t\t\t\t\t[K in keyof T]: StandardSchemaV1.InferOutput<T[K]>;\n\t\t\t\t},\n\t\t);\n\t}\n\n\treturn parseStandard(def as Record<string, unknown>, config) as {\n\t\t[K in keyof T]: StandardSchemaV1.InferOutput<T[K]>;\n\t};\n}\n\n/**\n * ArkEnv's Standard Schema export\n *\n * {@link https://arkenv.js.org | ArkEnv} is a typesafe environment variables validator from editor to runtime.\n */\nexport default arkenv;\n"],"mappings":"qHAMA,SAAgB,EAAoB,EAAa,EAAsB,CACtE,GAAI,OAAO,GAAU,SACpB,MAAM,IAAI,EAAY,CACrB,CACC,KAAM,EACN,QACC,8JACD,KAAM,iBACN,CACD,CAAC,CASJ,SAAgB,EAAqB,EAAa,EAAsB,CACvE,IAAM,EACL,GACA,OAAO,GAAU,UACjB,cAAe,GACd,EAAkC,aAEpC,GACC,CAAC,GACD,OAAO,GAAQ,UACf,EAAE,aAAc,IAChB,OAAQ,EAAgC,UAAa,WAErD,MAAM,IAAI,EAAY,CACrB,CACC,KAAM,EACN,QACC,6IACD,KAAM,iBACN,CACD,CAAC,CAQJ,SAAgB,EACf,EACyC,CACzC,GAAI,CAAC,GAAO,OAAO,GAAQ,UAAY,MAAM,QAAQ,EAAI,CACxD,MAAM,IAAI,EAAY,CACrB,CACC,KAAM,GACN,QACC,iEACD,KAAM,iBACN,CACD,CAAC,CCxDJ,SAAgB,EAAkB,EAIhC,CACD,IAAM,EAAkC,CAAE,KAAM,SAAU,WAAY,EAAE,CAAE,CACtE,EAAgB,GACd,EAAwB,EAAE,CAEhC,IAAK,IAAM,KAAO,EAAK,CACtB,IAAM,EAAY,EAAI,GACtB,GAAI,CAAC,EAAW,CACf,EAAY,KAAK,EAAI,CACrB,SAID,IAAM,EAAM,EAAU,aACtB,GAAI,OAAO,GAAK,YAAY,OAAU,WACrC,GAAI,CACH,IAAM,EAAS,EAAI,WAAW,MAAM,CAAE,OAAQ,W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AAe,IAAA,KAAW,EAAK,WAAa,EAAI,YACpD,IAAmB,IAAA,KAAW,EAAK,eAAiB,GAExD,IAAI,EAAU,EACb,EAAM,SAAW,GACjB,EACA,EACA,EACA,EACA,EACA,CAEG,GAAU,EAAsB,SAAS,EAAI,GAChD,GAAW,kEAAkE,EAAI,yCAGlF,EAAO,KACN,EAAc,EAAW,EAAS,EAAM,EAAM,EAAU,EAAY,CACpE,MAGF,EAAO,GAAO,EAAO,MAGtB,EAAQ,OAAO,EAAI,CAIpB,GAAI,IAAoB,aAClB,IAAM,KAAO,EACb,IAAoB,SACvB,EAAO,KAAK,EAAc,EAAK,iBAAkB,iBAAiB,CAAC,CACzD,IAAoB,WAC9B,EAAO,GAAO,EAAW,IAK5B,GAAI,EAAO,OAAS,EACnB,MAAM,IAAI,EAAY,EAAO,CAG9B,OAAO,EC9MR,SAAgB,EACf,EACA,EAA4B,EAAE,CAG6C,CAC3E,EAAwB,EAAI,CAE5B,IAAK,IAAM,KAAO,EAAK,CACtB,IAAM,EAAa,EAAgC,GACnD,EAAoB,EAAK,EAAU,CACnC,EAAqB,EAAK,EAAU,CAYrC,OATI,EAAO,KACH,MAEL,EAAc,EAAgC,EAAO,CAGtD,CAGK,EAAc,EAAgC,EAAO"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "arkenv",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.0.0-alpha.
|
|
4
|
+
"version": "1.0.0-alpha.2",
|
|
5
5
|
"description": "Typesafe environment variables parsing and validation with ArkType",
|
|
6
6
|
"main": "./dist/index.cjs",
|
|
7
7
|
"module": "./dist/index.mjs",
|
|
@@ -78,7 +78,7 @@
|
|
|
78
78
|
{
|
|
79
79
|
"name": "arkenv",
|
|
80
80
|
"path": "dist/index.mjs",
|
|
81
|
-
"limit": "2 kB",
|
|
81
|
+
"limit": "2.7 kB",
|
|
82
82
|
"import": "*",
|
|
83
83
|
"ignore": [
|
|
84
84
|
"arktype"
|
|
@@ -87,7 +87,7 @@
|
|
|
87
87
|
{
|
|
88
88
|
"name": "arkenv/standard",
|
|
89
89
|
"path": "dist/standard.mjs",
|
|
90
|
-
"limit": "
|
|
90
|
+
"limit": "3.5 kB",
|
|
91
91
|
"import": "*"
|
|
92
92
|
},
|
|
93
93
|
{
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"core-B0IkKRzg.mjs","names":[],"sources":["../src/utils/indent.ts","../src/utils/style-text.ts","../src/core.ts"],"sourcesContent":["/**\n * Options for the `indent` function\n */\ntype IndentOptions = {\n\t/**\n\t * Whether to detect newlines and indent each line individually, defaults to false (indenting the whole string)\n\t */\n\tdontDetectNewlines?: boolean;\n};\n\n/**\n * Indent a string by a given amount\n * @param str - The string to indent\n * @param amt - The amount to indent by, defaults to 2\n * @param options - {@link IndentOptions}\n * @returns The indented string\n */\nexport const indent = (\n\tstr: string,\n\tamt = 2,\n\t{ dontDetectNewlines = false }: IndentOptions = {},\n) => {\n\tconst detectNewlines = !dontDetectNewlines;\n\tif (detectNewlines) {\n\t\treturn str\n\t\t\t.split(\"\\n\")\n\t\t\t.map((line) => `${\" \".repeat(amt)}${line}`)\n\t\t\t.join(\"\\n\");\n\t}\n\n\treturn `${\" \".repeat(amt)}${str}`;\n};\n","/**\n * Cross-platform text styling utility\n * Uses ANSI colors in Node environments, plain text in browsers\n * Respects NO_COLOR, CI environment variables, and TTY detection\n */\n\n// ANSI color codes for Node environments\nconst colors = {\n\tred: \"\\x1b[31m\",\n\tyellow: \"\\x1b[33m\",\n\tcyan: \"\\x1b[36m\",\n\treset: \"\\x1b[0m\",\n} as const;\n\n/**\n * Check if we're in a Node environment (not browser)\n * Checked dynamically to allow for testing with mocked globals\n */\nconst isNode = (): boolean =>\n\ttypeof process !== \"undefined\" &&\n\tprocess.versions != null &&\n\tprocess.versions.node != null;\n\n/**\n * Check if colors should be disabled based on environment\n * Respects NO_COLOR, CI environment variables, and TTY detection\n */\nconst shouldDisableColors = (): boolean => {\n\tif (!isNode()) return true;\n\n\t// Respect NO_COLOR environment variable (https://no-color.org/)\n\tif (process.env.NO_COLOR !== undefined) return true;\n\n\t// Disable colors in CI environments by default\n\tif (process.env.CI !== undefined) return true;\n\n\t// Disable colors if not writing to a TTY\n\tif (process.stdout && !process.stdout.isTTY) return true;\n\n\treturn false;\n};\n\n/**\n * Style text with color. Uses ANSI codes in Node, plain text in browsers.\n * @param color - The color to apply\n * @param text - The text to style\n * @returns Styled text in Node (if colors enabled), plain text otherwise\n */\nexport const styleText = (\n\tcolor: \"red\" | \"yellow\" | \"cyan\",\n\ttext: string,\n): string => {\n\t// Use ANSI colors only in Node environments with colors enabled\n\tif (isNode() && !shouldDisableColors()) {\n\t\treturn `${colors[color]}${text}${colors.reset}`;\n\t}\n\t// Fall back to plain text in browsers or when colors are disabled\n\treturn text;\n};\n","import { indent } from \"./utils/indent\";\nimport { styleText } from \"./utils/style-text\";\n\n/**\n * A single validation issue produced during environment variable parsing.\n * Used by {@link ArkEnvError} to report which key failed and why.\n */\nexport type ValidationIssue = {\n\tpath: string;\n\tmessage: string;\n};\n\nexport const formatInternalErrors = (errors: ValidationIssue[]): string =>\n\terrors\n\t\t.map(\n\t\t\t(error) =>\n\t\t\t\t`${styleText(\"yellow\", error.path)} ${error.message.trimStart()}`,\n\t\t)\n\t\t.join(\"\\n\");\n\n/**\n * Error thrown when environment variable validation fails.\n *\n * This error extends the native `Error` class and provides formatted error messages\n * that clearly indicate which environment variables are invalid and why.\n *\n * @example\n * ```ts\n * import arkenv from 'arkenv';\n * import { ArkEnvError } from 'arkenv/core';\n *\n * try {\n * const env = arkenv({\n * PORT: 'number.port',\n * HOST: 'string.host',\n * });\n * } catch (error) {\n * if (error instanceof ArkEnvError) {\n * console.error('Environment validation failed:', error.message);\n * }\n * }\n * ```\n */\nexport class ArkEnvError extends Error {\n\tconstructor(\n\t\terrors: ValidationIssue[],\n\t\tmessage = \"Errors found while validating environment variables\",\n\t) {\n\t\tconst formattedErrors = formatInternalErrors(errors);\n\t\tsuper(`${styleText(\"red\", message)}\\n${indent(formattedErrors)}\\n`);\n\t\tthis.name = \"ArkEnvError\";\n\t}\n}\n\nObject.defineProperty(ArkEnvError, \"name\", { value: \"ArkEnvError\" });\n"],"mappings":"AAiBA,MAAa,GACZ,EACA,EAAM,EACN,CAAE,qBAAqB,IAAyB,EAAE,GAE1B,EAQjB,GAAG,IAAI,OAAO,EAAI,GAAG,IANpB,EACL,MAAM;EAAK,CACX,IAAK,GAAS,GAAG,IAAI,OAAO,EAAI,GAAG,IAAO,CAC1C,KAAK;EAAK,CCpBR,EAAS,CACd,IAAK,WACL,OAAQ,WACR,KAAM,WACN,MAAO,UACP,CAMK,MACL,OAAO,QAAY,KACnB,QAAQ,UAAY,MACpB,QAAQ,SAAS,MAAQ,KAMpB,MAUL,GATI,CAAC,GAAQ,EAGT,QAAQ,IAAI,WAAa,IAAA,IAGzB,QAAQ,IAAI,KAAO,IAAA,IAGnB,QAAQ,QAAU,CAAC,QAAQ,OAAO,OAW1B,GACZ,EACA,IAGI,GAAQ,EAAI,CAAC,GAAqB,CAC9B,GAAG,EAAO,KAAS,IAAO,EAAO,QAGlC,EC7CK,EAAwB,GACpC,EACE,IACC,GACA,GAAG,EAAU,SAAU,EAAM,KAAK,CAAC,GAAG,EAAM,QAAQ,WAAW,GAChE,CACA,KAAK;EAAK,CAyBb,IAAa,EAAb,cAAiC,KAAM,CACtC,YACC,EACA,EAAU,sDACT,CACD,IAAM,EAAkB,EAAqB,EAAO,CACpD,MAAM,GAAG,EAAU,MAAO,EAAQ,CAAC,IAAI,EAAO,EAAgB,CAAC,IAAI,CACnE,KAAK,KAAO,gBAId,OAAO,eAAe,EAAa,OAAQ,CAAE,MAAO,cAAe,CAAC"}
|
package/dist/core.d.cts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"core.d.cts","names":[],"sources":["../src/core.ts"],"mappings":";;AAOA;;;KAAY,eAAA;EACX,IAAA;EACA,OAAA;AAAA;AAAA,cAGY,oBAAA,GAAwB,MAAA,EAAQ,eAAA;;;AA+B7C;;;;;;;;;;;;;;;;;;;;;cAAa,WAAA,SAAoB,KAAA;cAE/B,MAAA,EAAQ,eAAA,IACR,OAAA;AAAA"}
|
package/dist/core.d.mts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"core.d.mts","names":[],"sources":["../src/core.ts"],"mappings":";;AAOA;;;KAAY,eAAA;EACX,IAAA;EACA,OAAA;AAAA;AAAA,cAGY,oBAAA,GAAwB,MAAA,EAAQ,eAAA;;;AA+B7C;;;;;;;;;;;;;;;;;;;;;cAAa,WAAA,SAAoB,KAAA;cAE/B,MAAA,EAAQ,eAAA,IACR,OAAA;AAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index-Br22fqkz.d.mts","names":["_$arktype","_$arktype_internal_keywords_string_ts0","_$arktype_internal_attributes_ts0","$","trim","To","Submodule","normalize","capitalize","stringDate","stringInteger","ip","stringJson","lower","stringNumeric","url","uuid","Scope","string","In","root","alpha","alphanumeric","hex","base64","creditCard","date","digits","email","integer","json","numeric","regex","semver","upper","preformatted","host","number","NaN","Infinity","epoch","safe","NegativeInfinity","port","Dict","T","Record","StandardTypedV1","Input","Output","Props","Schema","Types","NonNullable","version","vendor","types","input","output","InferInput","InferOutput","StandardSchemaV1","Options","Result","Promise","SuccessResult","FailureResult","Record","Issue","ReadonlyArray","PropertyKey","PathSegment","validate","value","options","issues","libraryOptions","message","path","key","StandardJSONSchemaV1","Converter","Target","jsonSchema","target","type","StandardSchemaV1","InferType","T","Record","errors","Any","_Input","Output","value","R","t","U","_Scope","$","Type","SchemaShape","Record","CompiledEnvSchema"],"sources":["../../internal/scope/dist/index.d.ts","../../internal/types/dist/helpers.d.ts","../../internal/types/dist/standard-schema.d.ts","../../internal/types/dist/infer-type.d.ts","../../internal/types/dist/schema.d.ts"],"mappings":";;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CaoE,MAAAA,EAAQN,aAAAA,CAAcD,KAAAA;EAAAA;EF7CJnE;EAAAA,UEgDrBmE,KAAAA;IFhDsEjE;IAAAA,SEkDnE0E,OAAAA;IFjDM1D;IAAAA,SEmDN2D,IAAAA,GAAOT,aAAAA,CAAcC,WAAAA,GAAcC,WAAAA;EAAAA;EFjDhDnD;EAAAA,UEoDUmD,WAAAA;IFlDVjD;IAAAA,SEoDayD,GAAAA,EAAKT,WAAAA;EAAAA;EFlDVtE;EAAAA,UEqDEoD,KAAAA,2BAAgCJ,KAAAA,UAAeD,eAAAA,CAAgBK,KAAAA,CAAMJ,KAAAA,EAAOC,MAAAA;EFnDpFlC;EAAAA,KEsDG4C,UAAAA,gBAA0BZ,eAAAA,IAAmBA,eAAAA,CAAgBY,UAAAA,CAAWR,MAAAA;EFlD7E3C;EAAAA,KEoDKoD,WAAAA,gBAA2Bb,eAAAA,IAAmBA,eAAAA,CAAgBa,WAAAA,CAAYT,MAAAA;AAAAA;;;;;;;AF9EC;;;;;KGSxEoC,SAAAA,MAAeC,CAAAA,SAAUF,gBAAAA,+BAA+CO,MAAAA,GAASL,CAAAA,WAAWM,KAAAA,EAAOL,MAAAA,4CAAiDM,CAAAA,SAAUV,IAAAA,CAAKK,MAAAA,WAAiBK,CAAAA,GAAIP,CAAAA;EAChMQ,CAAAA;AAAAA,IACAC,CAAAA,GAAIT,CAAAA,SAAUH,IAAAA,CAAKM,GAAAA,0BAA6BM,CAAAA;;;KCXxCI,WAAAA,GAAcC,MAAAA;;;;AJA0D;;;;;;;;;KIaxEC,iBAAAA,GAAoBH,IAAAA,CAAKC,WAAAA,EAAaF,CAAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index-CzNfOanV.d.cts","names":["_$arktype","_$arktype_internal_keywords_string_ts0","_$arktype_internal_attributes_ts0","$","trim","To","Submodule","normalize","capitalize","stringDate","stringInteger","ip","stringJson","lower","stringNumeric","url","uuid","Scope","string","In","root","alpha","alphanumeric","hex","base64","creditCard","date","digits","email","integer","json","numeric","regex","semver","upper","preformatted","host","number","NaN","Infinity","epoch","safe","NegativeInfinity","port","Dict","T","Record","StandardTypedV1","Input","Output","Props","Schema","Types","NonNullable","version","vendor","types","input","output","InferInput","InferOutput","StandardSchemaV1","Options","Result","Promise","SuccessResult","FailureResult","Record","Issue","ReadonlyArray","PropertyKey","PathSegment","validate","value","options","issues","libraryOptions","message","path","key","StandardJSONSchemaV1","Converter","Target","jsonSchema","target","type","StandardSchemaV1","InferType","T","Record","errors","Any","_Input","Output","value","R","t","U","_Scope","$","Type","SchemaShape","Record","CompiledEnvSchema"],"sources":["../../internal/scope/dist/index.d.ts","../../internal/types/dist/helpers.d.ts","../../internal/types/dist/standard-schema.d.ts","../../internal/types/dist/infer-type.d.ts","../../internal/types/dist/schema.d.ts"],"mappings":";;;;;;;;AAEoF;;;;cAQtEG,CAAAA,EAAGH,SAAAA,CAAUiB,KAAAA;EACzBC,MAAAA,EAAQlB,SAAAA,CAAUM,SAAAA;IAChBF,IAAAA,EAAMJ,SAAAA,CAAUM,SAAAA,CAAUL,sCAAAA,CAAuCG,IAAAA,CAAKD,CAAAA;MACpE,cAAA,GAAiBgB,EAAAA,aAAejB,iCAAAA,CAAkCG,EAAAA;IAAAA;IAEpEE,SAAAA,EAAWP,SAAAA,CAAUM,SAAAA,CAAUL,sCAAAA,CAAuCM,SAAAA,CAAUJ,CAAAA;MAC9E,cAAA,GAAiBgB,EAAAA,aAAejB,iCAAAA,CAAkCG,EAAAA;IAAAA;IAEpEe,IAAAA;IACAC,KAAAA;IACAC,YAAAA;IACAC,GAAAA;IACAC,MAAAA,EAAQxB,SAAAA,CAAUM,SAAAA;MAChBc,IAAAA;MACAL,GAAAA;IAAAA;MAEA,cAAA;IAAA;IAEFP,UAAAA,EAAYR,SAAAA,CAAUM,SAAAA,CAAUL,sCAAAA,CAAuCO,UAAAA,CAAWL,CAAAA;MAChF,cAAA,GAAiBgB,EAAAA,aAAejB,iCAA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AAWM,KAAAA,EAAOL,MAAAA,4CAAiDM,CAAAA,SAAUV,IAAAA,CAAKK,MAAAA,WAAiBK,CAAAA,GAAIP,CAAAA;EAChMQ,CAAAA;AAAAA,IACAC,CAAAA,GAAIT,CAAAA,SAAUH,IAAAA,CAAKM,GAAAA,0BAA6BM,CAAAA;;;KCXxCI,WAAAA,GAAcC,MAAAA;;;;AJA0D;;;;;;;;;KIaxEC,iBAAAA,GAAoBH,IAAAA,CAAKC,WAAAA,EAAaF,CAAAA"}
|
package/dist/shared-B7lIFzfk.mjs
DELETED
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
const e=e=>{if(typeof e==`number`||typeof e!=`string`||!e.trim())return e;if(e.trim()===`NaN`)return NaN;let t=Number(e);return Number.isNaN(t)?e:t},t=e=>e===`true`?!0:e===`false`?!1:e,n=e=>{if(typeof e!=`string`)return e;let t=e.trim();if(t[0]!==`{`&&t[0]!==`[`)return e;try{return JSON.parse(t)}catch{return e}},r=e=>{if(e instanceof Date||typeof e!=`string`||!e.trim())return e;let t=new Date(e);return Number.isNaN(t.getTime())?e:t},i=e=>{let t={};for(let n in e){let r=e[n];r!==``&&(t[n]=r)}return t},a=(e,t=[])=>{let n=[];if(!e||typeof e!=`object`||Array.isArray(e))return n;let r=e;if(`const`in r){let e=typeof r.const;(e===`number`||e===`boolean`)&&n.push({path:[...t],type:`primitive`})}`enum`in r&&Array.isArray(r.enum)&&r.enum.some(e=>typeof e==`number`||typeof e==`boolean`)&&n.push({path:[...t],type:`primitive`});let i=r.type;if(i===`number`||i===`integer`||i===`boolean`)n.push({path:[...t],type:`primitive`});else if(i===`string`&&`format`in r&&(r.format===`date-time`||r.format===`date`))n.push({path:[...t],type:`date`});else if(i===`object`){if(r.properties&&Object.keys(r.properties).length>0){n.push({path:[...t],type:`object`});for(let e in r.properties)n.push(...a(r.properties[e],[...t,e]))}}else i===`array`&&(n.push({path:[...t],type:`array`}),r.items&&(Array.isArray(r.items)?r.items.forEach((e,r)=>{n.push(...a(e,[...t,String(r)]))}):n.push(...a(r.items,[...t,`*`]))));for(let e of[`anyOf`,`allOf`,`oneOf`])if(r[e]&&Array.isArray(r[e]))for(let i of r[e])n.push(...a(i,t));let o=new Set;return n.filter(e=>{let t=e.path.join(`/`)+`:`+e.type;return o.has(t)?!1:o.add(t)})},o=(i,a,o={})=>{let{arrayFormat:s=`comma`}=o,c=e=>{if(s===`json`)try{return JSON.parse(e)}catch{return e}return e.trim()?e.split(`,`).map(e=>e.trim()):[]},l=(i,a)=>{if(a===`array`&&typeof i==`string`)return c(i);if(a===`object`&&typeof i==`string`)return n(i);if(a===`date`&&typeof i==`string`)return r(i);if(a===`primitive`){if(Array.isArray(i)){for(let n=0;n<i.length;n++){let r=e(i[n]);i[n]=typeof r==`number`?r:t(i[n])}return i}let n=e(i);return typeof n==`number`?n:t(i)}return i};if(typeof i!=`object`||!i){let e=a.find(e=>e.path.length===0);return e?l(i,e.type):i}let u=[...a].sort((e,t)=>e.path.length-t.path.length),d=(e,t,n)=>{if(!e||typeof e!=`object`||t.length===0)return;let[r,...i]=t;if(i.length===0){if(r===`*`){if(Array.isArray(e))for(let t=0;t<e.length;t++)e[t]=l(e[t],n)}else Object.prototype.hasOwnProperty.call(e,r)&&(e[r]=l(e[r],n));return}if(r===`*`){if(Array.isArray(e))for(let t of e)d(t,i,n)}else d(e[r],i,n)};for(let e of u)d(i,e.path,e.type);return i};export{a as n,i as r,o as t};
|
|
2
|
-
|
|
3
|
-
//# sourceMappingURL=shared-B7lIFzfk.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"shared-B7lIFzfk.mjs","names":[],"sources":["../src/coercion/morphs.ts","../src/coercion/shared.ts"],"sourcesContent":["/**\n * Attempt to coerce a value to a number.\n *\n * If the input is already a number, returns it unchanged.\n * If the input is a string that can be parsed as a number, returns the parsed number.\n * Otherwise, returns the original value unchanged.\n *\n * @internal\n * @param s - The value to coerce\n * @returns The coerced number or the original value\n */\nexport const coerceNumber = (s: unknown) => {\n\tif (typeof s === \"number\") return s;\n\tif (typeof s !== \"string\" || !s.trim()) return s;\n\tif (s.trim() === \"NaN\") return Number.NaN;\n\tconst n = Number(s);\n\treturn Number.isNaN(n) ? s : n;\n};\n\n/**\n * Attempt to coerce a value to a boolean.\n *\n * Convert the strings \"true\" and \"false\" to their boolean equivalents.\n * All other values are returned unchanged.\n *\n * @internal\n * @param s - The value to coerce\n * @returns The coerced boolean or the original value\n */\nexport const coerceBoolean = (s: unknown) => {\n\tif (s === \"true\") return true;\n\tif (s === \"false\") return false;\n\treturn s;\n};\n\n/**\n * Attempt to parse a value as JSON.\n *\n * If the input is a string that starts with `{` or `[` and can be parsed as JSON,\n * returns the parsed object or array. Otherwise, returns the original value unchanged.\n *\n * @internal\n * @param s - The value to parse\n * @returns The parsed JSON or the original value\n */\nexport const coerceJson = (s: unknown) => {\n\tif (typeof s !== \"string\") return s;\n\tconst trimmed = s.trim();\n\tif (trimmed[0] !== \"{\" && trimmed[0] !== \"[\") return s;\n\ttry {\n\t\treturn JSON.parse(trimmed);\n\t} catch {\n\t\treturn s;\n\t}\n};\n\n/**\n * Attempt to coerce a value to a Date.\n *\n * If the input is already a Date, returns it unchanged.\n * If the input is a valid date string, returns a Date object.\n * Otherwise, returns the original value unchanged.\n *\n * @internal\n * @param s - The value to coerce\n * @returns The coerced Date or the original value\n */\nexport const coerceDate = (s: unknown) => {\n\tif (s instanceof Date) return s;\n\tif (typeof s !== \"string\" || !s.trim()) return s;\n\tconst d = new Date(s);\n\treturn Number.isNaN(d.getTime()) ? s : d;\n};\n","import { coerceBoolean, coerceDate, coerceJson, coerceNumber } from \"./morphs\";\n\n/**\n * Remove keys with empty string values from an environment record.\n *\n * When a key is set to `\"\"` (e.g. `PORT=` in a `.env` file), deleting it\n * allows the validator to treat it as missing so that defaults apply.\n *\n * @param env The environment variables record\n * @returns A new record with empty string keys removed\n */\nexport const stripEmptyStrings = (\n\tenv: Record<string, string | undefined>,\n): Record<string, string | undefined> => {\n\tconst result: Record<string, string | undefined> = {};\n\tfor (const key in env) {\n\t\tconst value = env[key];\n\t\tif (value !== \"\") {\n\t\t\tresult[key] = value;\n\t\t}\n\t}\n\treturn result;\n};\n\n/**\n * A marker used in the coercion path to indicate that the target\n * is the *elements* of an array, rather than the array property itself.\n */\nexport const ARRAY_ITEM_MARKER = \"*\";\n\n/**\n * @internal\n * Information about a path in the schema that requires coercion.\n */\nexport type CoercionTarget = {\n\tpath: string[];\n\ttype: \"primitive\" | \"array\" | \"object\" | \"date\";\n};\n\n/**\n * Options for coercion behavior.\n */\nexport type CoerceOptions = {\n\t/**\n\t * format to use for array parsing\n\t * @default \"comma\"\n\t */\n\tarrayFormat?: \"comma\" | \"json\";\n};\n\n/**\n * Internal representation of a JSON Schema node for coercion traversal.\n */\ntype JsonSchemaNode = {\n\ttype?: string | string[];\n\tconst?: unknown;\n\tenum?: unknown[];\n\tformat?: string;\n\tproperties?: Record<string, unknown>;\n\titems?: unknown | unknown[];\n\tanyOf?: unknown[];\n\tallOf?: unknown[];\n\toneOf?: unknown[];\n};\n\n/**\n * Find all paths in a JSON Schema that require coercion.\n *\n * Prioritize \"number\", \"integer\", \"boolean\", \"array\", \"object\", and \"date\" types.\n *\n * @param node The JSON Schema node to traverse\n * @param path The current path segments in the schema tree\n * @returns An array of coercion targets containing their path and type\n */\nexport const findCoercionPaths = (\n\tnode: unknown,\n\tpath: string[] = [],\n): CoercionTarget[] => {\n\tconst results: CoercionTarget[] = [];\n\tif (!node || typeof node !== \"object\" || Array.isArray(node)) return results;\n\n\tconst n = node as JsonSchemaNode;\n\n\tif (\"const\" in n) {\n\t\tconst t = typeof n.const;\n\t\tif (t === \"number\" || t === \"boolean\") {\n\t\t\tresults.push({ path: [...path], type: \"primitive\" });\n\t\t}\n\t}\n\n\tif (\"enum\" in n && Array.isArray(n.enum)) {\n\t\tif (n.enum.some((v) => typeof v === \"number\" || typeof v === \"boolean\")) {\n\t\t\tresults.push({ path: [...path], type: \"primitive\" });\n\t\t}\n\t}\n\n\tconst type = n.type;\n\tif (type === \"number\" || type === \"integer\" || type === \"boolean\") {\n\t\tresults.push({ path: [...path], type: \"primitive\" });\n\t} else if (\n\t\ttype === \"string\" &&\n\t\t\"format\" in n &&\n\t\t(n.format === \"date-time\" || n.format === \"date\")\n\t) {\n\t\tresults.push({ path: [...path], type: \"date\" });\n\t} else if (type === \"object\") {\n\t\tif (n.properties && Object.keys(n.properties).length > 0) {\n\t\t\tresults.push({ path: [...path], type: \"object\" });\n\t\t\tfor (const key in n.properties) {\n\t\t\t\tresults.push(...findCoercionPaths(n.properties[key], [...path, key]));\n\t\t\t}\n\t\t}\n\t} else if (type === \"array\") {\n\t\tresults.push({ path: [...path], type: \"array\" });\n\t\tif (n.items) {\n\t\t\tif (Array.isArray(n.items)) {\n\t\t\t\tn.items.forEach((item, index) => {\n\t\t\t\t\tresults.push(...findCoercionPaths(item, [...path, String(index)]));\n\t\t\t\t});\n\t\t\t} else {\n\t\t\t\tresults.push(\n\t\t\t\t\t...findCoercionPaths(n.items, [...path, ARRAY_ITEM_MARKER]),\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t}\n\n\tfor (const comb of [\"anyOf\", \"allOf\", \"oneOf\"] as const) {\n\t\tif (n[comb] && Array.isArray(n[comb])) {\n\t\t\tfor (const branch of n[comb]) {\n\t\t\t\tresults.push(...findCoercionPaths(branch, path));\n\t\t\t}\n\t\t}\n\t}\n\n\tconst seen = new Set<string>();\n\treturn results.filter((t) => {\n\t\tconst key = t.path.join(\"/\") + \":\" + t.type;\n\t\treturn seen.has(key) ? false : seen.add(key);\n\t});\n};\n\n/**\n * Apply coercion to a data object based on identified paths.\n *\n * @param data The input environment data object to coerce\n * @param targets The coercion targets mapping paths to types\n * @param options The coercion options, including array parsing format\n * @returns The coerced data object\n */\nexport const applyCoercion = <T = unknown>(\n\tdata: T,\n\ttargets: CoercionTarget[],\n\toptions: CoerceOptions = {},\n): T => {\n\tconst { arrayFormat = \"comma\" } = options;\n\n\tconst splitString = (val: string) => {\n\t\tif (arrayFormat === \"json\") {\n\t\t\ttry {\n\t\t\t\treturn JSON.parse(val);\n\t\t\t} catch {\n\t\t\t\treturn val;\n\t\t\t}\n\t\t}\n\t\treturn val.trim() ? val.split(\",\").map((s) => s.trim()) : [];\n\t};\n\n\tconst coerceValue = (val: unknown, type: CoercionTarget[\"type\"]): unknown => {\n\t\tif (type === \"array\" && typeof val === \"string\") {\n\t\t\treturn splitString(val);\n\t\t}\n\t\tif (type === \"object\" && typeof val === \"string\") {\n\t\t\treturn coerceJson(val);\n\t\t}\n\t\tif (type === \"date\" && typeof val === \"string\") {\n\t\t\treturn coerceDate(val);\n\t\t}\n\t\tif (type === \"primitive\") {\n\t\t\tif (Array.isArray(val)) {\n\t\t\t\tfor (let i = 0; i < val.length; i++) {\n\t\t\t\t\tconst n = coerceNumber(val[i]);\n\t\t\t\t\tval[i] = typeof n === \"number\" ? n : coerceBoolean(val[i]);\n\t\t\t\t}\n\t\t\t\treturn val;\n\t\t\t}\n\t\t\tconst n = coerceNumber(val);\n\t\t\treturn typeof n === \"number\" ? n : coerceBoolean(val);\n\t\t}\n\t\treturn val;\n\t};\n\n\tif (typeof data !== \"object\" || data === null) {\n\t\tconst root = targets.find((t) => t.path.length === 0);\n\t\tif (root) {\n\t\t\treturn coerceValue(data, root.type) as T;\n\t\t}\n\t\treturn data;\n\t}\n\n\tconst sorted = [...targets].sort((a, b) => a.path.length - b.path.length);\n\n\tconst walk = (current: any, path: string[], type: CoercionTarget[\"type\"]) => {\n\t\tif (!current || typeof current !== \"object\" || path.length === 0) return;\n\n\t\tconst [key, ...rest] = path;\n\n\t\tif (rest.length === 0) {\n\t\t\tif (key === ARRAY_ITEM_MARKER) {\n\t\t\t\tif (Array.isArray(current)) {\n\t\t\t\t\tfor (let i = 0; i < current.length; i++) {\n\t\t\t\t\t\tcurrent[i] = coerceValue(current[i], type);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\t// biome-ignore lint/suspicious/noPrototypeBuiltins: Object.hasOwn is not supported under current tsconfig lib settings\n\t\t\t\tif (Object.prototype.hasOwnProperty.call(current, key)) {\n\t\t\t\t\tcurrent[key] = coerceValue(current[key], type);\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\n\t\tif (key === ARRAY_ITEM_MARKER) {\n\t\t\tif (Array.isArray(current)) {\n\t\t\t\tfor (const item of current) walk(item, rest, type);\n\t\t\t}\n\t\t} else {\n\t\t\twalk(current[key], rest, type);\n\t\t}\n\t};\n\n\tfor (const t of sorted) {\n\t\twalk(data, t.path, t.type);\n\t}\n\treturn data;\n};\n"],"mappings":"AAWA,MAAa,EAAgB,GAAe,CAE3C,GADI,OAAO,GAAM,UACb,OAAO,GAAM,UAAY,CAAC,EAAE,MAAM,CAAE,OAAO,EAC/C,GAAI,EAAE,MAAM,GAAK,MAAO,MAAO,KAC/B,IAAM,EAAI,OAAO,EAAE,CACnB,OAAO,OAAO,MAAM,EAAE,CAAG,EAAI,GAajB,EAAiB,GACzB,IAAM,OAAe,GACrB,IAAM,QAAgB,GACnB,EAaK,EAAc,GAAe,CACzC,GAAI,OAAO,GAAM,SAAU,OAAO,EAClC,IAAM,EAAU,EAAE,MAAM,CACxB,GAAI,EAAQ,KAAO,KAAO,EAAQ,KAAO,IAAK,OAAO,EACrD,GAAI,CACH,OAAO,KAAK,MAAM,EAAQ,MACnB,CACP,OAAO,IAeI,EAAc,GAAe,CAEzC,GADI,aAAa,MACb,OAAO,GAAM,UAAY,CAAC,EAAE,MAAM,CAAE,OAAO,EAC/C,IAAM,EAAI,IAAI,KAAK,EAAE,CACrB,OAAO,OAAO,MAAM,EAAE,SAAS,CAAC,CAAG,EAAI,GC5D3B,EACZ,GACwC,CACxC,IAAM,EAA6C,EAAE,CACrD,IAAK,IAAM,KAAO,EAAK,CACtB,IAAM,EAAQ,EAAI,GACd,IAAU,KACb,EAAO,GAAO,GAGhB,OAAO,GAqDK,GAC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B,OAAO,OAAO,GAAM,SAAW,EAAI,EAAc,EAAI,CAEtD,OAAO,GAGR,GAAI,OAAO,GAAS,WAAY,EAAe,CAC9C,IAAM,EAAO,EAAQ,KAAM,GAAM,EAAE,KAAK,SAAW,EAAE,CAIrD,OAHI,EACI,EAAY,EAAM,EAAK,KAAK,CAE7B,EAGR,IAAM,EAAS,CAAC,GAAG,EAAQ,CAAC,MAAM,EAAG,IAAM,EAAE,KAAK,OAAS,EAAE,KAAK,OAAO,CAEnE,GAAQ,EAAc,EAAgB,IAAiC,CAC5E,GAAI,CAAC,GAAW,OAAO,GAAY,UAAY,EAAK,SAAW,EAAG,OAElE,GAAM,CAAC,EAAK,GAAG,GAAQ,EAEvB,GAAI,EAAK,SAAW,EAAG,CACtB,GAAI,IAAA,QACC,MAAM,QAAQ,EAAQ,CACzB,IAAK,IAAI,EAAI,EAAG,EAAI,EAAQ,OAAQ,IACnC,EAAQ,GAAK,EAAY,EAAQ,GAAI,EAAK,MAKxC,OAAO,UAAU,eAAe,KAAK,EAAS,EAAI,GACrD,EAAQ,GAAO,EAAY,EAAQ,GAAM,EAAK,EAGhD,OAGD,GAAI,IAAA,QACC,MAAM,QAAQ,EAAQ,CACzB,IAAK,IAAM,KAAQ,EAAS,EAAK,EAAM,EAAM,EAAK,MAGnD,EAAK,EAAQ,GAAM,EAAM,EAAK,EAIhC,IAAK,IAAM,KAAK,EACf,EAAK,EAAM,EAAE,KAAM,EAAE,KAAK,CAE3B,OAAO"}
|
package/dist/shared-Bx3sbEJf.cjs
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
const e=e=>{if(typeof e==`number`||typeof e!=`string`||!e.trim())return e;if(e.trim()===`NaN`)return NaN;let t=Number(e);return Number.isNaN(t)?e:t},t=e=>e===`true`?!0:e===`false`?!1:e,n=e=>{if(typeof e!=`string`)return e;let t=e.trim();if(t[0]!==`{`&&t[0]!==`[`)return e;try{return JSON.parse(t)}catch{return e}},r=e=>{if(e instanceof Date||typeof e!=`string`||!e.trim())return e;let t=new Date(e);return Number.isNaN(t.getTime())?e:t},i=e=>{let t={};for(let n in e){let r=e[n];r!==``&&(t[n]=r)}return t},a=(e,t=[])=>{let n=[];if(!e||typeof e!=`object`||Array.isArray(e))return n;let r=e;if(`const`in r){let e=typeof r.const;(e===`number`||e===`boolean`)&&n.push({path:[...t],type:`primitive`})}`enum`in r&&Array.isArray(r.enum)&&r.enum.some(e=>typeof e==`number`||typeof e==`boolean`)&&n.push({path:[...t],type:`primitive`});let i=r.type;if(i===`number`||i===`integer`||i===`boolean`)n.push({path:[...t],type:`primitive`});else if(i===`string`&&`format`in r&&(r.format===`date-time`||r.format===`date`))n.push({path:[...t],type:`date`});else if(i===`object`){if(r.properties&&Object.keys(r.properties).length>0){n.push({path:[...t],type:`object`});for(let e in r.properties)n.push(...a(r.properties[e],[...t,e]))}}else i===`array`&&(n.push({path:[...t],type:`array`}),r.items&&(Array.isArray(r.items)?r.items.forEach((e,r)=>{n.push(...a(e,[...t,String(r)]))}):n.push(...a(r.items,[...t,`*`]))));for(let e of[`anyOf`,`allOf`,`oneOf`])if(r[e]&&Array.isArray(r[e]))for(let i of r[e])n.push(...a(i,t));let o=new Set;return n.filter(e=>{let t=e.path.join(`/`)+`:`+e.type;return o.has(t)?!1:o.add(t)})},o=(i,a,o={})=>{let{arrayFormat:s=`comma`}=o,c=e=>{if(s===`json`)try{return JSON.parse(e)}catch{return e}return e.trim()?e.split(`,`).map(e=>e.trim()):[]},l=(i,a)=>{if(a===`array`&&typeof i==`string`)return c(i);if(a===`object`&&typeof i==`string`)return n(i);if(a===`date`&&typeof i==`string`)return r(i);if(a===`primitive`){if(Array.isArray(i)){for(let n=0;n<i.length;n++){let r=e(i[n]);i[n]=typeof r==`number`?r:t(i[n])}return i}let n=e(i);return typeof n==`number`?n:t(i)}return i};if(typeof i!=`object`||!i){let e=a.find(e=>e.path.length===0);return e?l(i,e.type):i}let u=[...a].sort((e,t)=>e.path.length-t.path.length),d=(e,t,n)=>{if(!e||typeof e!=`object`||t.length===0)return;let[r,...i]=t;if(i.length===0){if(r===`*`){if(Array.isArray(e))for(let t=0;t<e.length;t++)e[t]=l(e[t],n)}else Object.prototype.hasOwnProperty.call(e,r)&&(e[r]=l(e[r],n));return}if(r===`*`){if(Array.isArray(e))for(let t of e)d(t,i,n)}else d(e[r],i,n)};for(let e of u)d(i,e.path,e.type);return i};Object.defineProperty(exports,`n`,{enumerable:!0,get:function(){return a}}),Object.defineProperty(exports,`r`,{enumerable:!0,get:function(){return i}}),Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return o}});
|
|
2
|
-
|
|
3
|
-
// CJS Interop Shim
|
|
4
|
-
if (module.exports && module.exports.default) {
|
|
5
|
-
Object.assign(module.exports.default, module.exports);
|
|
6
|
-
module.exports = module.exports.default;
|
|
7
|
-
}
|
|
8
|
-
|