arkenv 0.7.7 → 0.7.8
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.d.cts +5 -4
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.ts +5 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +5 -5
package/dist/index.d.cts
CHANGED
|
@@ -82,6 +82,7 @@ declare const $: arktype0.Scope<{
|
|
|
82
82
|
}>;
|
|
83
83
|
boolean: (In: boolean | "false" | "true") => arktype0.Out<boolean>;
|
|
84
84
|
}>;
|
|
85
|
+
type $ = (typeof $)["t"];
|
|
85
86
|
//#endregion
|
|
86
87
|
//#endregion
|
|
87
88
|
//#region ../internal/types/dist/infer-type.d.ts
|
|
@@ -98,10 +99,10 @@ declare const SchemaShape: arktype_internal_variants_object_ts0.ObjectType<{
|
|
|
98
99
|
[x: string]: unknown;
|
|
99
100
|
}, {}>;
|
|
100
101
|
type SchemaShape = typeof SchemaShape.infer;
|
|
101
|
-
type EnvSchemaWithType = Type<SchemaShape,
|
|
102
|
+
type EnvSchemaWithType = Type<SchemaShape, $>;
|
|
102
103
|
//#endregion
|
|
103
104
|
//#region src/create-env.d.ts
|
|
104
|
-
type EnvSchema<def$1> = type$1.validate<def$1,
|
|
105
|
+
type EnvSchema<def$1> = type$1.validate<def$1, $>;
|
|
105
106
|
type RuntimeEnvironment = Record<string, string | undefined>;
|
|
106
107
|
/**
|
|
107
108
|
* TODO: `SchemaShape` is basically `Record<string, unknown>`.
|
|
@@ -115,9 +116,9 @@ type RuntimeEnvironment = Record<string, string | undefined>;
|
|
|
115
116
|
* @returns The validated environment variable schema
|
|
116
117
|
* @throws An {@link ArkEnvError | error} if the environment variables are invalid.
|
|
117
118
|
*/
|
|
119
|
+
declare function createEnv<const T extends SchemaShape>(def: EnvSchema<T>, env?: RuntimeEnvironment): distill.Out<type$1.infer<T, $>>;
|
|
118
120
|
declare function createEnv<T extends EnvSchemaWithType>(def: T, env?: RuntimeEnvironment): InferType<T>;
|
|
119
|
-
declare function createEnv<const T extends SchemaShape>(def: EnvSchema<T
|
|
120
|
-
declare function createEnv<const T extends SchemaShape>(def: EnvSchema<T> | EnvSchemaWithType, env?: RuntimeEnvironment): distill.Out<type$1.infer<T, (typeof $)["t"]>> | InferType<typeof def>;
|
|
121
|
+
declare function createEnv<const T extends SchemaShape>(def: EnvSchema<T> | EnvSchemaWithType, env?: RuntimeEnvironment): distill.Out<type$1.infer<T, $>> | InferType<typeof def>;
|
|
121
122
|
//#endregion
|
|
122
123
|
//#region src/type.d.ts
|
|
123
124
|
declare const type: arktype_internal_type_ts0.TypeParser<{
|
package/dist/index.d.cts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.cts","names":["arktype0","arktype_internal_keywords_string_ts0","arktype_internal_attributes_ts0","$","trim","To","Submodule","normalize","capitalize","stringDate","stringInteger","ip","stringJson","lower","stringNumeric","url","uuid","Out","Scope","type","InferType","T","Record","
|
|
1
|
+
{"version":3,"file":"index.d.cts","names":["arktype0","arktype_internal_keywords_string_ts0","arktype_internal_attributes_ts0","$","trim","To","Submodule","normalize","capitalize","stringDate","stringInteger","ip","stringJson","lower","stringNumeric","url","uuid","Out","Scope","type","InferType","T","Record","errors","Any","$","Type","SchemaShape","arktype_internal_variants_object_ts0","ObjectType","infer","EnvSchemaWithType"],"sources":["../../internal/scope/dist/index.d.ts","../../internal/types/dist/infer-type.d.ts","../../internal/types/dist/schema.d.ts","../src/create-env.ts","../src/type.ts","../src/errors.ts","../src/index.ts"],"sourcesContent":["import * as arktype0 from \"arktype\";\nimport * as arktype_internal_keywords_string_ts0 from \"arktype/internal/keywords/string.ts\";\nimport * as arktype_internal_attributes_ts0 from \"arktype/internal/attributes.ts\";\n\n//#region src/index.d.ts\n/**\n * The root scope for the ArkEnv library, containing extensions to the ArkType scopes with ArkEnv-specific types like `string.host` and `number.port`.\n */\ndeclare const $: arktype0.Scope<{\n string: arktype0.Submodule<{\n trim: arktype0.Submodule<arktype_internal_keywords_string_ts0.trim.$ & {\n \" arkInferred\": (In: string) => arktype_internal_attributes_ts0.To<string>;\n }>;\n normalize: arktype0.Submodule<arktype_internal_keywords_string_ts0.normalize.$ & {\n \" arkInferred\": (In: string) => arktype_internal_attributes_ts0.To<string>;\n }>;\n root: string;\n alpha: string;\n alphanumeric: string;\n hex: string;\n base64: arktype0.Submodule<{\n root: string;\n url: string;\n } & {\n \" arkInferred\": string;\n }>;\n capitalize: arktype0.Submodule<arktype_internal_keywords_string_ts0.capitalize.$ & {\n \" arkInferred\": (In: string) => arktype_internal_attributes_ts0.To<string>;\n }>;\n creditCard: string;\n date: arktype0.Submodule<arktype_internal_keywords_string_ts0.stringDate.$ & {\n \" arkInferred\": string;\n }>;\n digits: string;\n email: string;\n integer: arktype0.Submodule<arktype_internal_keywords_string_ts0.stringInteger.$ & {\n \" arkInferred\": string;\n }>;\n ip: arktype0.Submodule<arktype_internal_keywords_string_ts0.ip.$ & {\n \" arkInferred\": string;\n }>;\n json: arktype0.Submodule<arktype_internal_keywords_string_ts0.stringJson.$ & {\n \" arkInferred\": string;\n }>;\n lower: arktype0.Submodule<arktype_internal_keywords_string_ts0.lower.$ & {\n \" arkInferred\": (In: string) => arktype_internal_attributes_ts0.To<string>;\n }>;\n numeric: arktype0.Submodule<arktype_internal_keywords_string_ts0.stringNumeric.$ & {\n \" arkInferred\": string;\n }>;\n regex: string;\n semver: string;\n upper: arktype0.Submodule<{\n root: (In: string) => arktype_internal_attributes_ts0.To<string>;\n preformatted: string;\n } & {\n \" arkInferred\": (In: string) => arktype_internal_attributes_ts0.To<string>;\n }>;\n url: arktype0.Submodule<arktype_internal_keywords_string_ts0.url.$ & {\n \" arkInferred\": string;\n }>;\n uuid: arktype0.Submodule<arktype_internal_keywords_string_ts0.uuid.$ & {\n \" arkInferred\": string;\n }>;\n \" arkInferred\": string;\n host: string;\n }>;\n number: arktype0.Submodule<{\n NaN: number;\n Infinity: number;\n root: number;\n integer: number;\n \" arkInferred\": number;\n epoch: number;\n safe: number;\n NegativeInfinity: number;\n port: (In: string) => arktype0.Out<number>;\n }>;\n boolean: (In: boolean | \"false\" | \"true\") => arktype0.Out<boolean>;\n}>;\ntype $ = (typeof $)[\"t\"];\n//#endregion\nexport { $ };\n//# sourceMappingURL=index.d.ts.map","import type { type } from \"arktype\";\n/**\n * Extract the inferred type from an ArkType type definition by checking its call signature.\n * When a type definition is called, it returns either the validated value or type.errors.\n *\n * @template T - The ArkType type definition to infer from\n */\nexport type InferType<T> = T extends (value: Record<string, string | undefined>) => infer R ? R extends type.errors ? never : R : T extends type.Any<infer U, infer _Scope> ? U : never;\n//# sourceMappingURL=infer-type.d.ts.map","import type { $ } from \"@repo/scope\";\nimport { type Type } from \"arktype\";\nexport declare const SchemaShape: import(\"arktype/internal/variants/object.ts\").ObjectType<{\n [x: string]: unknown;\n}, {}>;\nexport type SchemaShape = typeof SchemaShape.infer;\nexport type EnvSchemaWithType = Type<SchemaShape, $>;\n//# sourceMappingURL=schema.d.ts.map"],"mappings":";;;;;;;;;;;;AAEkF,cAMpEG,CAuEZ,EAvEeH,QAAAA,CAASkB,KAuExB,CAAA;EArE2BjB,MAAAA,EADnBD,QAAAA,CAASM,SACUL,CAAAA;IACSC,IAAAA,EAD5BF,QAAAA,CAASM,SACmBJ,CADTD,oCAAAA,CAAqCG,IAAAA,CAAKD,CACDE,GAAAA;MAD5DL,cAASM,EAAAA,CAAAA,EAAAA,EAAAA,MAAAA,EAAAA,GACmBJ,+BAAAA,CAAgCG,EADnDC,CAAAA,MAAAA,CAAAA;IAGeL,CAAAA,CAAAA;IACIC,SAAAA,EADvBF,QAAAA,CAASM,SAC8CD,CADpCJ,oCAAAA,CAAqCM,SAAAA,CAAUJ,CACXE,GAAAA;MADvDL,cAASM,EAAAA,CAAAA,EAAAA,EAAAA,MAAAA,EAAAA,GACcJ,+BAAAA,CAAgCG,EAD9CC,CAAAA,MAAA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AAC,MAAA,EAAA,qCAAA,CAAA,MAAA,CAAA;;;;ICzENiB,CAAAA,CAAAA;IAAeC,GAAAA,oBAAAA,8CAAAA;MAAkBC,cAAAA,EAAAA,MAAAA;IAAgEC,CAAAA,CAAAA;IAAqBF,IAAAA,oBAAAA,+CAAAA;MAAeG,cAAAA,EAAAA,MAAAA;IAAG,CAAA,CAAA;;;;ECL/HG,MAAAA,oBAEfC,CAAAA;IACMD,GAAAA,EAAAA,MAAW;IACXI,QAAAA,EAAAA,MAAiB;IAAQJ,IAAAA,EAAAA,MAAAA;IAAaF,OAAAA,EAAAA,MAAAA;IAAlBC,cAAAA,EAAAA,MAAAA;IAAI,KAAA,EAAA,MAAA;;;;ECAxB,CAAA,CAAA;EAA6B,OAAA,EAAA,CAAA,EAAA,EAAA,OAAA,GAAA,OAAA,GAAA,MAAA,EAAA,eAAA,CAAA,OAAA,CAAA;CAAK,CAAA;;;cEsBjC,WAAA,SAAoB,KAAA;ELpBnBvB,WAuEZ,CAAA,MAAA,EKjDQ,SLiDR,EAAA,OAAA,CAAA,EAAA,MAAA;;;;;;;;;cMtEI,eAAM"}
|
package/dist/index.d.ts
CHANGED
|
@@ -82,6 +82,7 @@ declare const $: arktype0.Scope<{
|
|
|
82
82
|
}>;
|
|
83
83
|
boolean: (In: boolean | "false" | "true") => arktype0.Out<boolean>;
|
|
84
84
|
}>;
|
|
85
|
+
type $ = (typeof $)["t"];
|
|
85
86
|
//#endregion
|
|
86
87
|
//#endregion
|
|
87
88
|
//#region ../internal/types/dist/infer-type.d.ts
|
|
@@ -98,10 +99,10 @@ declare const SchemaShape: arktype_internal_variants_object_ts0.ObjectType<{
|
|
|
98
99
|
[x: string]: unknown;
|
|
99
100
|
}, {}>;
|
|
100
101
|
type SchemaShape = typeof SchemaShape.infer;
|
|
101
|
-
type EnvSchemaWithType = Type<SchemaShape,
|
|
102
|
+
type EnvSchemaWithType = Type<SchemaShape, $>;
|
|
102
103
|
//#endregion
|
|
103
104
|
//#region src/create-env.d.ts
|
|
104
|
-
type EnvSchema<def$1> = type$1.validate<def$1,
|
|
105
|
+
type EnvSchema<def$1> = type$1.validate<def$1, $>;
|
|
105
106
|
type RuntimeEnvironment = Record<string, string | undefined>;
|
|
106
107
|
/**
|
|
107
108
|
* TODO: `SchemaShape` is basically `Record<string, unknown>`.
|
|
@@ -115,9 +116,9 @@ type RuntimeEnvironment = Record<string, string | undefined>;
|
|
|
115
116
|
* @returns The validated environment variable schema
|
|
116
117
|
* @throws An {@link ArkEnvError | error} if the environment variables are invalid.
|
|
117
118
|
*/
|
|
119
|
+
declare function createEnv<const T extends SchemaShape>(def: EnvSchema<T>, env?: RuntimeEnvironment): distill.Out<type$1.infer<T, $>>;
|
|
118
120
|
declare function createEnv<T extends EnvSchemaWithType>(def: T, env?: RuntimeEnvironment): InferType<T>;
|
|
119
|
-
declare function createEnv<const T extends SchemaShape>(def: EnvSchema<T
|
|
120
|
-
declare function createEnv<const T extends SchemaShape>(def: EnvSchema<T> | EnvSchemaWithType, env?: RuntimeEnvironment): distill.Out<type$1.infer<T, (typeof $)["t"]>> | InferType<typeof def>;
|
|
121
|
+
declare function createEnv<const T extends SchemaShape>(def: EnvSchema<T> | EnvSchemaWithType, env?: RuntimeEnvironment): distill.Out<type$1.infer<T, $>> | InferType<typeof def>;
|
|
121
122
|
//#endregion
|
|
122
123
|
//#region src/type.d.ts
|
|
123
124
|
declare const type: arktype_internal_type_ts0.TypeParser<{
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":["arktype0","arktype_internal_keywords_string_ts0","arktype_internal_attributes_ts0","$","trim","To","Submodule","normalize","capitalize","stringDate","stringInteger","ip","stringJson","lower","stringNumeric","url","uuid","Out","Scope","type","InferType","T","Record","
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":["arktype0","arktype_internal_keywords_string_ts0","arktype_internal_attributes_ts0","$","trim","To","Submodule","normalize","capitalize","stringDate","stringInteger","ip","stringJson","lower","stringNumeric","url","uuid","Out","Scope","type","InferType","T","Record","errors","Any","$","Type","SchemaShape","arktype_internal_variants_object_ts0","ObjectType","infer","EnvSchemaWithType"],"sources":["../../internal/scope/dist/index.d.ts","../../internal/types/dist/infer-type.d.ts","../../internal/types/dist/schema.d.ts","../src/create-env.ts","../src/type.ts","../src/errors.ts","../src/index.ts"],"sourcesContent":["import * as arktype0 from \"arktype\";\nimport * as arktype_internal_keywords_string_ts0 from \"arktype/internal/keywords/string.ts\";\nimport * as arktype_internal_attributes_ts0 from \"arktype/internal/attributes.ts\";\n\n//#region src/index.d.ts\n/**\n * The root scope for the ArkEnv library, containing extensions to the ArkType scopes with ArkEnv-specific types like `string.host` and `number.port`.\n */\ndeclare const $: arktype0.Scope<{\n string: arktype0.Submodule<{\n trim: arktype0.Submodule<arktype_internal_keywords_string_ts0.trim.$ & {\n \" arkInferred\": (In: string) => arktype_internal_attributes_ts0.To<string>;\n }>;\n normalize: arktype0.Submodule<arktype_internal_keywords_string_ts0.normalize.$ & {\n \" arkInferred\": (In: string) => arktype_internal_attributes_ts0.To<string>;\n }>;\n root: string;\n alpha: string;\n alphanumeric: string;\n hex: string;\n base64: arktype0.Submodule<{\n root: string;\n url: string;\n } & {\n \" arkInferred\": string;\n }>;\n capitalize: arktype0.Submodule<arktype_internal_keywords_string_ts0.capitalize.$ & {\n \" arkInferred\": (In: string) => arktype_internal_attributes_ts0.To<string>;\n }>;\n creditCard: string;\n date: arktype0.Submodule<arktype_internal_keywords_string_ts0.stringDate.$ & {\n \" arkInferred\": string;\n }>;\n digits: string;\n email: string;\n integer: arktype0.Submodule<arktype_internal_keywords_string_ts0.stringInteger.$ & {\n \" arkInferred\": string;\n }>;\n ip: arktype0.Submodule<arktype_internal_keywords_string_ts0.ip.$ & {\n \" arkInferred\": string;\n }>;\n json: arktype0.Submodule<arktype_internal_keywords_string_ts0.stringJson.$ & {\n \" arkInferred\": string;\n }>;\n lower: arktype0.Submodule<arktype_internal_keywords_string_ts0.lower.$ & {\n \" arkInferred\": (In: string) => arktype_internal_attributes_ts0.To<string>;\n }>;\n numeric: arktype0.Submodule<arktype_internal_keywords_string_ts0.stringNumeric.$ & {\n \" arkInferred\": string;\n }>;\n regex: string;\n semver: string;\n upper: arktype0.Submodule<{\n root: (In: string) => arktype_internal_attributes_ts0.To<string>;\n preformatted: string;\n } & {\n \" arkInferred\": (In: string) => arktype_internal_attributes_ts0.To<string>;\n }>;\n url: arktype0.Submodule<arktype_internal_keywords_string_ts0.url.$ & {\n \" arkInferred\": string;\n }>;\n uuid: arktype0.Submodule<arktype_internal_keywords_string_ts0.uuid.$ & {\n \" arkInferred\": string;\n }>;\n \" arkInferred\": string;\n host: string;\n }>;\n number: arktype0.Submodule<{\n NaN: number;\n Infinity: number;\n root: number;\n integer: number;\n \" arkInferred\": number;\n epoch: number;\n safe: number;\n NegativeInfinity: number;\n port: (In: string) => arktype0.Out<number>;\n }>;\n boolean: (In: boolean | \"false\" | \"true\") => arktype0.Out<boolean>;\n}>;\ntype $ = (typeof $)[\"t\"];\n//#endregion\nexport { $ };\n//# sourceMappingURL=index.d.ts.map","import type { type } from \"arktype\";\n/**\n * Extract the inferred type from an ArkType type definition by checking its call signature.\n * When a type definition is called, it returns either the validated value or type.errors.\n *\n * @template T - The ArkType type definition to infer from\n */\nexport type InferType<T> = T extends (value: Record<string, string | undefined>) => infer R ? R extends type.errors ? never : R : T extends type.Any<infer U, infer _Scope> ? U : never;\n//# sourceMappingURL=infer-type.d.ts.map","import type { $ } from \"@repo/scope\";\nimport { type Type } from \"arktype\";\nexport declare const SchemaShape: import(\"arktype/internal/variants/object.ts\").ObjectType<{\n [x: string]: unknown;\n}, {}>;\nexport type SchemaShape = typeof SchemaShape.infer;\nexport type EnvSchemaWithType = Type<SchemaShape, $>;\n//# sourceMappingURL=schema.d.ts.map"],"mappings":";;;;;;;;;;;;AAEkF,cAMpEG,CAuEZ,EAvEeH,QAAAA,CAASkB,KAuExB,CAAA;EArE2B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":"index.js","names":["e","n","t","r","i","t","n","e","$","$"],"sources":["../../internal/keywords/dist/index.js","../../internal/scope/dist/index.js","../src/utils/indent.ts","../src/utils/style-text.ts","../src/errors.ts","../src/type.ts","../src/create-env.ts","../src/index.ts"],"sourcesContent":["import{type as e}from\"arktype\";const t=e(`string`,`=>`,(e,t)=>{let n=Number.parseInt(e,10);return(!Number.isInteger(n)||!(0<=n&&n<=65535))&&t.mustBe(`an integer between 0 and 65535`),n}),n=e(`string.ip | 'localhost'`),r=e(`'true' | 'false' | true | false`,`=>`,e=>e===`true`||e===!0);export{r as boolean,n as host,t as port};\n//# sourceMappingURL=index.js.map","import{boolean as e,host as t,port as n}from\"@repo/keywords\";import{scope as r,type as i}from\"arktype\";const a=r({string:i.module({...i.keywords.string,host:t}),number:i.module({...i.keywords.number,port:n}),boolean:e});export{a as $};\n//# sourceMappingURL=index.js.map","/**\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 type { ArkErrors } from \"arktype\";\nimport { indent, styleText } from \"./utils\";\n\n/**\n * Format the errors returned by ArkType to be more readable\n * @param errors - The errors returned by ArkType\n * @returns A string of the formatted errors\n */\nexport const formatErrors = (errors: ArkErrors): string =>\n\tObject.entries(errors.byPath)\n\t\t.map(([path, error]) => {\n\t\t\tconst messageWithoutPath = error.message.startsWith(path)\n\t\t\t\t? error.message.slice(path.length)\n\t\t\t\t: error.message;\n\n\t\t\t// Extract the value in parentheses if it exists\n\t\t\tconst valueMatch = messageWithoutPath.match(/\\(was \"([^\"]+)\"\\)/);\n\t\t\tconst formattedMessage = valueMatch\n\t\t\t\t? messageWithoutPath.replace(\n\t\t\t\t\t\t`(was \"${valueMatch[1]}\")`,\n\t\t\t\t\t\t`(was ${styleText(\"cyan\", `\"${valueMatch[1]}\"`)})`,\n\t\t\t\t\t)\n\t\t\t\t: messageWithoutPath;\n\n\t\t\treturn `${styleText(\"yellow\", path)}${formattedMessage}`;\n\t\t})\n\t\t.join(\"\\n\");\n\nexport class ArkEnvError extends Error {\n\tconstructor(\n\t\terrors: ArkErrors,\n\t\tmessage = \"Errors found while validating environment variables\",\n\t) {\n\t\tsuper(`${styleText(\"red\", message)}\\n${indent(formatErrors(errors))}\\n`);\n\t\tthis.name = \"ArkEnvError\";\n\t}\n}\n","import { $ } from \"@repo/scope\";\n\nexport const type = $.type;\n","import { $ } from \"@repo/scope\";\nimport type { EnvSchemaWithType, InferType, SchemaShape } from \"@repo/types\";\nimport type { type as at, distill } from \"arktype\";\nimport { ArkEnvError } from \"./errors\";\nimport { type } from \"./type\";\n\nexport type EnvSchema<def> = at.validate<def,
|
|
1
|
+
{"version":3,"file":"index.js","names":["e","n","t","r","i","t","n","e","$","$"],"sources":["../../internal/keywords/dist/index.js","../../internal/scope/dist/index.js","../src/utils/indent.ts","../src/utils/style-text.ts","../src/errors.ts","../src/type.ts","../src/create-env.ts","../src/index.ts"],"sourcesContent":["import{type as e}from\"arktype\";const t=e(`string`,`=>`,(e,t)=>{let n=Number.parseInt(e,10);return(!Number.isInteger(n)||!(0<=n&&n<=65535))&&t.mustBe(`an integer between 0 and 65535`),n}),n=e(`string.ip | 'localhost'`),r=e(`'true' | 'false' | true | false`,`=>`,e=>e===`true`||e===!0);export{r as boolean,n as host,t as port};\n//# sourceMappingURL=index.js.map","import{boolean as e,host as t,port as n}from\"@repo/keywords\";import{scope as r,type as i}from\"arktype\";const a=r({string:i.module({...i.keywords.string,host:t}),number:i.module({...i.keywords.number,port:n}),boolean:e});export{a as $};\n//# sourceMappingURL=index.js.map","/**\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 type { ArkErrors } from \"arktype\";\nimport { indent, styleText } from \"./utils\";\n\n/**\n * Format the errors returned by ArkType to be more readable\n * @param errors - The errors returned by ArkType\n * @returns A string of the formatted errors\n */\nexport const formatErrors = (errors: ArkErrors): string =>\n\tObject.entries(errors.byPath)\n\t\t.map(([path, error]) => {\n\t\t\tconst messageWithoutPath = error.message.startsWith(path)\n\t\t\t\t? error.message.slice(path.length)\n\t\t\t\t: error.message;\n\n\t\t\t// Extract the value in parentheses if it exists\n\t\t\tconst valueMatch = messageWithoutPath.match(/\\(was \"([^\"]+)\"\\)/);\n\t\t\tconst formattedMessage = valueMatch\n\t\t\t\t? messageWithoutPath.replace(\n\t\t\t\t\t\t`(was \"${valueMatch[1]}\")`,\n\t\t\t\t\t\t`(was ${styleText(\"cyan\", `\"${valueMatch[1]}\"`)})`,\n\t\t\t\t\t)\n\t\t\t\t: messageWithoutPath;\n\n\t\t\treturn `${styleText(\"yellow\", path)}${formattedMessage}`;\n\t\t})\n\t\t.join(\"\\n\");\n\nexport class ArkEnvError extends Error {\n\tconstructor(\n\t\terrors: ArkErrors,\n\t\tmessage = \"Errors found while validating environment variables\",\n\t) {\n\t\tsuper(`${styleText(\"red\", message)}\\n${indent(formatErrors(errors))}\\n`);\n\t\tthis.name = \"ArkEnvError\";\n\t}\n}\n","import { $ } from \"@repo/scope\";\n\nexport const type = $.type;\n","import { $ } from \"@repo/scope\";\nimport type { EnvSchemaWithType, InferType, SchemaShape } from \"@repo/types\";\nimport type { type as at, distill } from \"arktype\";\nimport { ArkEnvError } from \"./errors\";\nimport { type } from \"./type\";\n\nexport type EnvSchema<def> = at.validate<def, $>;\ntype RuntimeEnvironment = Record<string, string | undefined>;\n\n/**\n * TODO: `SchemaShape` is basically `Record<string, unknown>`.\n * If possible, find a better type than \"const T extends Record<string, unknown>\",\n * and be as close as possible to the type accepted by ArkType's `type`.\n */\n\n/**\n * Create an environment variables object from a schema and an environment\n * @param def - The environment variable schema (raw object or type definition created with `type()`)\n * @param env - The environment variables to validate, defaults to `process.env`\n * @returns The validated environment variable schema\n * @throws An {@link ArkEnvError | error} if the environment variables are invalid.\n */\nexport function createEnv<const T extends SchemaShape>(\n\tdef: EnvSchema<T>,\n\tenv?: RuntimeEnvironment,\n): distill.Out<at.infer<T, $>>;\nexport function createEnv<T extends EnvSchemaWithType>(\n\tdef: T,\n\tenv?: RuntimeEnvironment,\n): InferType<T>;\nexport function createEnv<const T extends SchemaShape>(\n\tdef: EnvSchema<T> | EnvSchemaWithType,\n\tenv?: RuntimeEnvironment,\n): distill.Out<at.infer<T, $>> | InferType<typeof def>;\nexport function createEnv<const T extends SchemaShape>(\n\tdef: EnvSchema<T> | EnvSchemaWithType,\n\tenv: RuntimeEnvironment = process.env,\n): distill.Out<at.infer<T, $>> | InferType<typeof def> {\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 schema =\n\t\ttypeof def === \"function\" && \"assert\" in def\n\t\t\t? def\n\t\t\t: $.type.raw(def as EnvSchema<T>);\n\n\tconst validatedEnv = schema(env);\n\n\tif (validatedEnv instanceof type.errors) {\n\t\tthrow new ArkEnvError(validatedEnv);\n\t}\n\n\treturn validatedEnv;\n}\n","export type { EnvSchema } from \"./create-env\";\n\nimport { createEnv } from \"./create-env\";\n\n/**\n * `arkenv`'s main export, an alias for {@link createEnv}\n *\n * {@link https://arkenv.js.org | ArkEnv} is a typesafe environment variables parser powered by {@link https://arktype.io | ArkType}, TypeScript's 1:1 validator.\n */\nconst arkenv = createEnv;\nexport default arkenv;\nexport { type } from \"./type\";\nexport { createEnv };\nexport { ArkEnvError } from \"./errors\";\n"],"mappings":"0CAA+B,MAAM,EAAEA,EAAE,SAAS,MAAM,EAAE,IAAI,CAAC,IAAIC,EAAE,OAAO,SAAS,EAAE,GAAG,CAAC,OAAO,CAAC,OAAO,UAAU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G,GAAG,CAAC,GAChD,CACA,EAEH,MAAO,GAAG,EAAU,SAAU,EAAK,GAAG,KACrC,CACD,KAAK;EAAK,CAEb,IAAa,EAAb,cAAiC,KAAM,CACtC,YACC,EACA,EAAU,sDACT,CACD,MAAM,GAAG,EAAU,MAAO,EAAQ,CAAC,IAAI,EAAO,EAAa,EAAO,CAAC,CAAC,IAAI,CACxE,KAAK,KAAO,gBChCd,MAAa,EAAOC,EAAE,KCgCtB,SAAgB,EACf,EACA,EAA0B,QAAQ,IACoB,CAQtD,IAAM,GAJL,OAAO,GAAQ,YAAc,WAAY,EACtC,EACAC,EAAE,KAAK,IAAI,EAAoB,EAEP,EAAI,CAEhC,GAAI,aAAwB,EAAK,OAChC,MAAM,IAAI,EAAY,EAAa,CAGpC,OAAO,ECzCR,IAAA,EADe"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "arkenv",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.7.
|
|
4
|
+
"version": "0.7.8",
|
|
5
5
|
"main": "./dist/index.cjs",
|
|
6
6
|
"module": "./dist/index.js",
|
|
7
7
|
"types": "./dist/index.d.ts",
|
|
@@ -33,16 +33,16 @@
|
|
|
33
33
|
"devDependencies": {
|
|
34
34
|
"@size-limit/esbuild-why": "11.2.0",
|
|
35
35
|
"@size-limit/preset-small-lib": "11.2.0",
|
|
36
|
-
"@types/node": "24.10.
|
|
36
|
+
"@types/node": "24.10.2",
|
|
37
37
|
"arktype": "2.1.28",
|
|
38
38
|
"rimraf": "6.1.2",
|
|
39
39
|
"size-limit": "11.2.0",
|
|
40
|
-
"tsdown": "0.
|
|
40
|
+
"tsdown": "0.17.0",
|
|
41
41
|
"typescript": "5.9.3",
|
|
42
42
|
"vitest": "4.0.15",
|
|
43
|
-
"@repo/scope": "0.0.0",
|
|
44
43
|
"@repo/keywords": "0.0.0",
|
|
45
|
-
"@repo/
|
|
44
|
+
"@repo/scope": "0.0.1",
|
|
45
|
+
"@repo/types": "0.0.2"
|
|
46
46
|
},
|
|
47
47
|
"peerDependencies": {
|
|
48
48
|
"arktype": "^2.1.22"
|