@e-n-v/env 0.0.7 → 0.0.9

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.
Files changed (103) hide show
  1. package/dist/{BooleanMap-B7MeMkJC.d.ts → BooleanMap-BPQuO3Ae.d.ts} +1 -3
  2. package/dist/{BooleanMap-D93UJnv5.d.cts → BooleanMap-CX_YrPCf.d.cts} +1 -3
  3. package/dist/EnvChannelOptions-BbKeuO-o.d.cts +366 -0
  4. package/dist/EnvChannelOptions-BbKeuO-o.d.ts +366 -0
  5. package/dist/{EnvSource-DA3ZGlES.js → EnvSource-WAGWqRVM.js} +6 -10
  6. package/dist/{EnvSource-BVnmdHku.cjs → EnvSource-s8F_M_6O.cjs} +21 -28
  7. package/dist/EnvVarSchema-CDZGmnex.cjs +15 -0
  8. package/dist/EnvVarSchema-Dr6q7jf6.js +10 -0
  9. package/dist/{ProcessEnvChannel-Do4-yiLI.d.ts → ProcessEnvChannel-CwhV7_EB.d.ts} +2 -4
  10. package/dist/{ProcessEnvChannel-D465c-dp.d.cts → ProcessEnvChannel-DWHPZePe.d.cts} +2 -4
  11. package/dist/channels.cjs +3 -4
  12. package/dist/channels.d.cts +3 -4
  13. package/dist/channels.d.ts +3 -4
  14. package/dist/channels.js +2 -4
  15. package/dist/cli.cjs +10 -23
  16. package/dist/cli.d.cts +1 -1
  17. package/dist/cli.d.ts +1 -1
  18. package/dist/cli.js +7 -13
  19. package/dist/core.cjs +13 -14
  20. package/dist/core.d.cts +147 -6
  21. package/dist/core.d.ts +147 -6
  22. package/dist/core.js +9 -11
  23. package/dist/{custom-Bt_wnxIu.js → custom-Bd-jLg80.js} +3 -12
  24. package/dist/{custom-D_Rqjm09.cjs → custom-Dyb9TnER.cjs} +48 -58
  25. package/dist/files.cjs +6 -6
  26. package/dist/files.d.cts +2 -2
  27. package/dist/files.d.ts +2 -2
  28. package/dist/files.js +2 -5
  29. package/dist/{parse-awxwtQ1N.d.ts → index-B2eNij2x.d.cts} +1 -2
  30. package/dist/{parse-5fpTbjTr.d.cts → index-BHTM8nxS.d.ts} +1 -2
  31. package/dist/{prompt-DG8haZjn.d.ts → index-BKBW9Dxs.d.cts} +3 -4
  32. package/dist/{prompt-lmZdPaBh.d.cts → index-CEyOIRdj.d.ts} +3 -4
  33. package/dist/{EnvModel-BiT0OiDZ.d.ts → index-Cb0abjLf.d.ts} +59 -7
  34. package/dist/{EnvModel-I0fWZZ_n.d.cts → index-Cz3frUwZ.d.cts} +58 -6
  35. package/dist/index.cjs +27 -30
  36. package/dist/index.d.cts +11 -13
  37. package/dist/index.d.ts +11 -13
  38. package/dist/index.js +8 -14
  39. package/dist/model.cjs +10 -11
  40. package/dist/model.d.cts +2 -35
  41. package/dist/model.d.ts +2 -35
  42. package/dist/model.js +2 -6
  43. package/dist/parse.cjs +14 -14
  44. package/dist/parse.d.cts +5 -8
  45. package/dist/parse.d.ts +5 -8
  46. package/dist/parse.js +4 -7
  47. package/dist/preprocessors-BKuIcZa1.d.ts +83 -0
  48. package/dist/preprocessors-DFVyF0c7.d.cts +83 -0
  49. package/dist/prompt.cjs +12 -15
  50. package/dist/prompt.d.cts +5 -10
  51. package/dist/prompt.d.ts +5 -10
  52. package/dist/prompt.js +3 -9
  53. package/dist/{redis-Cazgs3_J.cjs → redis-CyTF0SYT.cjs} +260 -268
  54. package/dist/{redis-DXhlNtvD.js → redis-D18f4ztf.js} +15 -22
  55. package/dist/{index-UQm0jdkG.d.cts → redis-DsW-Vkwq.d.cts} +2 -6
  56. package/dist/{index-ClKndmJv.d.ts → redis-tRD4nAy_.d.ts} +2 -6
  57. package/dist/{resolveChannel-v9BDsw-M.js → resolveChannel-D1Fzl4TL.js} +59 -63
  58. package/dist/{resolveChannel-CjAuxy3p.cjs → resolveChannel-DxZNYdDe.cjs} +84 -92
  59. package/dist/{chunk-pbleEpgJ.cjs → rolldown-runtime-C0BPl7ul.cjs} +15 -16
  60. package/dist/{chunk-Bp6m_JJh.js → rolldown-runtime-D7D4PA-g.js} +4 -4
  61. package/dist/{schema-DdDa3Qjy.d.cts → schema-B-JLVS42.d.ts} +1 -3
  62. package/dist/{schema-CHypJTDK.d.ts → schema-B1i83alz.d.cts} +1 -3
  63. package/dist/schema-CtP5lpU1.js +11 -0
  64. package/dist/schema-D9nJKipf.cjs +22 -0
  65. package/dist/schemas/zod.cjs +42 -340
  66. package/dist/schemas/zod.d.cts +112 -114
  67. package/dist/schemas/zod.d.ts +112 -114
  68. package/dist/schemas/zod.js +111 -401
  69. package/dist/schemas.cjs +152 -155
  70. package/dist/schemas.d.cts +1 -2
  71. package/dist/schemas.d.ts +1 -2
  72. package/dist/schemas.js +2 -6
  73. package/dist/{src-CdqOYilA.cjs → src-5GYFbR9n.cjs} +21 -24
  74. package/dist/{src-BrNrE0hX.js → src-8rEOvFG5.js} +11 -14
  75. package/dist/{src-DI-VW4dW.js → src-CdzAzdq-.js} +77 -110
  76. package/dist/{src-B5Qu-M-r.js → src-Cg49gGJb.js} +9 -43
  77. package/dist/{src-dO72HN6e.cjs → src-CttkcdpE.cjs} +90 -130
  78. package/dist/{src-PHSSk-t3.cjs → src-D5KzIEH_.cjs} +130 -110
  79. package/dist/{src-DVdOONrX.cjs → src-DB0Har0j.cjs} +911 -932
  80. package/dist/{src-DQaQ28lz.js → src-DWc-WWjX.js} +107 -89
  81. package/dist/{src-vBXlFkSP.js → src-DvUBRBe3.js} +115 -136
  82. package/dist/{src-DywfI0fM.cjs → src-TZx_e95f.cjs} +78 -131
  83. package/dist/{vars-DF9DoAF4.d.ts → vars-DtzGL5Nc.d.cts} +1 -4
  84. package/dist/{vars-KUgv2rti.d.cts → vars-obKYxaSu.d.ts} +1 -4
  85. package/dist/vars.cjs +175 -160
  86. package/dist/vars.d.cts +2 -6
  87. package/dist/vars.d.ts +2 -6
  88. package/dist/vars.js +21 -9
  89. package/package.json +3 -2
  90. package/dist/EnvChannelOptions-BPkWDrmr.d.cts +0 -108
  91. package/dist/EnvChannelOptions-CRwDLWjd.d.ts +0 -108
  92. package/dist/coerce-DNIuYAx4.js +0 -11028
  93. package/dist/coerce-b7UVodS9.cjs +0 -12365
  94. package/dist/model-BNDYMM9l.d.ts +0 -29
  95. package/dist/model-CJMnbGuS.d.cts +0 -29
  96. package/dist/validate-8HbVniNt.d.cts +0 -204
  97. package/dist/validate-CE8hQ5JG.d.ts +0 -204
  98. package/dist/vars-BHXXBiY1.cjs +0 -27
  99. package/dist/vars-FOuH_HuL.js +0 -22
  100. /package/dist/{EnvChannel-LMIRYvT1.d.cts → EnvChannel-CfSwa_25.d.cts} +0 -0
  101. /package/dist/{EnvChannel-w27PEm7x.d.ts → EnvChannel-CfSwa_25.d.ts} +0 -0
  102. /package/dist/{StringEnvVarSchema-BwSGgmeG.d.ts → StringEnvVarSchema-D9Jr1Aws.d.cts} +0 -0
  103. /package/dist/{StringEnvVarSchema-DnsZTIS0.d.cts → StringEnvVarSchema-D9Jr1Aws.d.ts} +0 -0
package/dist/cli.cjs CHANGED
@@ -1,24 +1,12 @@
1
1
  #!/usr/bin/env node
2
- const require_chunk = require('./chunk-pbleEpgJ.cjs');
3
- require('./EnvSource-BVnmdHku.cjs');
4
- require('./resolveChannel-CjAuxy3p.cjs');
5
- const require_src = require('./src-dO72HN6e.cjs');
6
- require('./src-DywfI0fM.cjs');
7
- require('./coerce-b7UVodS9.cjs');
8
- const require_src$2 = require('./src-PHSSk-t3.cjs');
2
+ const require_src = require("./src-D5KzIEH_.cjs");
3
+ const require_src$1 = require("./src-CttkcdpE.cjs");
9
4
  let node_path = require("node:path");
10
- node_path = require_chunk.__toESM(node_path);
11
5
  let node_fs_promises = require("node:fs/promises");
12
- node_fs_promises = require_chunk.__toESM(node_fs_promises);
13
- let commander = require("commander");
14
- commander = require_chunk.__toESM(commander);
15
6
  let node_url = require("node:url");
16
- node_url = require_chunk.__toESM(node_url);
17
7
  let node_os = require("node:os");
18
- node_os = require_chunk.__toESM(node_os);
8
+ let commander = require("commander");
19
9
  let tsx_esm_api = require("tsx/esm/api");
20
- tsx_esm_api = require_chunk.__toESM(tsx_esm_api);
21
-
22
10
  //#region ../cli/src/index.ts
23
11
  let tsxRegistered = false;
24
12
  const DEFAULT_MODEL_BASENAME = "env.model";
@@ -31,7 +19,7 @@ const MODEL_EXTENSIONS = [
31
19
  ".mjs",
32
20
  ".cjs"
33
21
  ];
34
- const IGNORED_DIRECTORIES = new Set([
22
+ const IGNORED_DIRECTORIES = /* @__PURE__ */ new Set([
35
23
  "node_modules",
36
24
  ".git",
37
25
  "dist",
@@ -90,7 +78,7 @@ function resolveModel(moduleExports, origin) {
90
78
  moduleExports.model,
91
79
  moduleExports.EnvModel
92
80
  ].concat(Object.values(moduleExports));
93
- for (const candidate of candidates) if (candidate instanceof require_src$2.EnvModel) return candidate;
81
+ for (const candidate of candidates) if (candidate instanceof require_src.EnvModel) return candidate;
94
82
  throw new Error(`Unable to locate an EnvModel export in ${origin}`);
95
83
  }
96
84
  function resolvePromptOptions(moduleExports, origin) {
@@ -101,7 +89,7 @@ function resolvePromptOptions(moduleExports, origin) {
101
89
  ];
102
90
  for (const candidate of candidates) if (candidate && typeof candidate === "object") return candidate;
103
91
  for (const value of Object.values(moduleExports)) {
104
- if (value instanceof require_src$2.EnvModel) continue;
92
+ if (value instanceof require_src.EnvModel) continue;
105
93
  if (value && typeof value === "object") return value;
106
94
  }
107
95
  throw new Error(`Unable to locate prompt configuration exports in ${origin}`);
@@ -111,11 +99,12 @@ async function handleSetupCommand(modelPathInput, configPathInput) {
111
99
  if (!modelPath) throw new Error("Unable to locate an EnvModel file. Provide a path or create a file named \"env.model.*\".");
112
100
  const model = resolveModel(await importUserModule(modelPath), modelPath);
113
101
  if (!configPathInput) {
114
- await require_src.prompt(model);
102
+ await require_src$1.prompt(model);
115
103
  return;
116
104
  }
117
105
  const configPath = toAbsolutePath(configPathInput);
118
- await require_src.prompt(model, resolvePromptOptions(await importUserModule(configPath), configPath));
106
+ const options = resolvePromptOptions(await importUserModule(configPath), configPath);
107
+ await require_src$1.prompt(model, options);
119
108
  }
120
109
  async function run(argv = process.argv) {
121
110
  const program = new commander.Command();
@@ -135,7 +124,6 @@ async function run(argv = process.argv) {
135
124
  program.showSuggestionAfterError();
136
125
  await program.parseAsync(argv);
137
126
  }
138
-
139
127
  //#endregion
140
128
  //#region src/cli.ts
141
129
  run(process.argv).catch((error) => {
@@ -143,5 +131,4 @@ run(process.argv).catch((error) => {
143
131
  else console.error(error);
144
132
  process.exit(1);
145
133
  });
146
-
147
- //#endregion
134
+ //#endregion
package/dist/cli.d.cts CHANGED
@@ -1 +1 @@
1
- export { };
1
+ export {}
package/dist/cli.d.ts CHANGED
@@ -1 +1 @@
1
- export { };
1
+ export {}
package/dist/cli.js CHANGED
@@ -1,17 +1,12 @@
1
1
  #!/usr/bin/env node
2
- import "./EnvSource-DA3ZGlES.js";
3
- import "./resolveChannel-v9BDsw-M.js";
4
- import { t as prompt } from "./src-DI-VW4dW.js";
5
- import "./src-B5Qu-M-r.js";
6
- import "./coerce-DNIuYAx4.js";
7
- import { n as EnvModel } from "./src-DQaQ28lz.js";
2
+ import { n as EnvModel } from "./src-DWc-WWjX.js";
3
+ import { t as prompt } from "./src-CdzAzdq-.js";
8
4
  import { isAbsolute, join, resolve } from "node:path";
9
5
  import { readdir } from "node:fs/promises";
10
- import { Command } from "commander";
11
6
  import { pathToFileURL } from "node:url";
12
7
  import { homedir } from "node:os";
8
+ import { Command } from "commander";
13
9
  import { register } from "tsx/esm/api";
14
-
15
10
  //#region ../cli/src/index.ts
16
11
  let tsxRegistered = false;
17
12
  const DEFAULT_MODEL_BASENAME = "env.model";
@@ -24,7 +19,7 @@ const MODEL_EXTENSIONS = [
24
19
  ".mjs",
25
20
  ".cjs"
26
21
  ];
27
- const IGNORED_DIRECTORIES = new Set([
22
+ const IGNORED_DIRECTORIES = /* @__PURE__ */ new Set([
28
23
  "node_modules",
29
24
  ".git",
30
25
  "dist",
@@ -108,7 +103,8 @@ async function handleSetupCommand(modelPathInput, configPathInput) {
108
103
  return;
109
104
  }
110
105
  const configPath = toAbsolutePath(configPathInput);
111
- await prompt(model, resolvePromptOptions(await importUserModule(configPath), configPath));
106
+ const options = resolvePromptOptions(await importUserModule(configPath), configPath);
107
+ await prompt(model, options);
112
108
  }
113
109
  async function run(argv = process.argv) {
114
110
  const program = new Command();
@@ -128,7 +124,6 @@ async function run(argv = process.argv) {
128
124
  program.showSuggestionAfterError();
129
125
  await program.parseAsync(argv);
130
126
  }
131
-
132
127
  //#endregion
133
128
  //#region src/cli.ts
134
129
  run(process.argv).catch((error) => {
@@ -136,6 +131,5 @@ run(process.argv).catch((error) => {
136
131
  else console.error(error);
137
132
  process.exit(1);
138
133
  });
139
-
140
134
  //#endregion
141
- export { };
135
+ export {};
package/dist/core.cjs CHANGED
@@ -1,17 +1,18 @@
1
- const require_src = require('./src-DywfI0fM.cjs');
2
- const require_custom = require('./custom-D_Rqjm09.cjs');
3
-
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ const require_src = require("./src-TZx_e95f.cjs");
3
+ const require_EnvVarSchema = require("./EnvVarSchema-CDZGmnex.cjs");
4
+ const require_custom = require("./custom-Dyb9TnER.cjs");
5
+ const require_schema = require("./schema-D9nJKipf.cjs");
4
6
  //#region ../core/src/processing/checks/maxLength.ts
5
7
  /**
6
8
  * String check: maximum length.
7
9
  */
8
- function maxLength(max$1, trait) {
10
+ function maxLength(max, trait) {
9
11
  return (value) => {
10
- if (value.length > max$1) return trait ? [trait] : [`at most ${max$1} characters`];
12
+ if (value.length > max) return trait ? [trait] : [`at most ${max} characters`];
11
13
  return [];
12
14
  };
13
15
  }
14
-
15
16
  //#endregion
16
17
  //#region ../core/src/processing/checks/min.ts
17
18
  /**
@@ -19,11 +20,10 @@ function maxLength(max$1, trait) {
19
20
  */
20
21
  function min(minimum, trait) {
21
22
  return (value) => {
22
- if (value < minimum) return trait ? [trait] : [`at least ${minimum}`];
23
+ if (Number.isNaN(value) || value < minimum) return trait ? [trait] : [`at least ${minimum}`];
23
24
  return [];
24
25
  };
25
26
  }
26
-
27
27
  //#endregion
28
28
  //#region ../core/src/processing/checks/max.ts
29
29
  /**
@@ -31,11 +31,10 @@ function min(minimum, trait) {
31
31
  */
32
32
  function max(maximum, trait) {
33
33
  return (value) => {
34
- if (value > maximum) return trait ? [trait] : [`at most ${maximum}`];
34
+ if (Number.isNaN(value) || value > maximum) return trait ? [trait] : [`at most ${maximum}`];
35
35
  return [];
36
36
  };
37
37
  }
38
-
39
38
  //#endregion
40
39
  exports.BooleanEnvVarSchema = require_src.BooleanEnvVarSchema;
41
40
  exports.EnumEnvVarSchema = require_src.EnumEnvVarSchema;
@@ -48,7 +47,7 @@ exports.custom = require_custom.custom;
48
47
  exports.enumeration = require_src.enumeration;
49
48
  exports.exactLength = require_custom.exactLength;
50
49
  exports.integer = require_custom.integer;
51
- exports.isEnvVarSchema = require_src.isEnvVarSchema;
50
+ exports.isEnvVarSchema = require_EnvVarSchema.isEnvVarSchema;
52
51
  exports.lengthBetween = require_custom.lengthBetween;
53
52
  exports.max = max;
54
53
  exports.maxLength = maxLength;
@@ -60,9 +59,9 @@ exports.pattern = require_custom.pattern;
60
59
  exports.preprocessors = require_src.preprocessors;
61
60
  exports.processors = require_src.processors;
62
61
  exports.resolvePreprocessor = require_src.resolvePreprocessor;
63
- exports.s = require_src.s;
64
- exports.schema = require_src.schema;
62
+ exports.s = require_schema.s;
63
+ exports.schema = require_schema.schema;
65
64
  exports.string = require_src.string;
66
65
  exports.toList = require_src.toList;
67
66
  exports.url = require_custom.url;
68
- exports.validate = require_src.validate;
67
+ exports.validate = require_src.validate;
package/dist/core.d.cts CHANGED
@@ -1,6 +1,147 @@
1
- import { a as EnumEnvVarSchema, c as BooleanEnvVarSchemaInput, d as EnvVarType, f as Processor, i as NumberEnvVarSchemaInput, l as EnvVarSchemaBase, n as StringEnvVarSchemaInput, o as EnumEnvVarSchemaInput, r as NumberEnvVarSchema, s as BooleanEnvVarSchema, t as StringEnvVarSchema, u as EnvVarSchemaInput } from "./StringEnvVarSchema-DnsZTIS0.cjs";
2
- import { C as Check, S as string, _ as preprocessors, a as max, b as boolean, c as oneOf, d as exactLength, f as lengthBetween, g as PreprocessorOptions, h as resolvePreprocessor, i as between, l as url, m as minLength, n as toList, o as min, p as maxLength, r as custom, s as integer, t as validate, u as pattern, v as processors, w as EnvVarSchemaDetails, x as number, y as enumeration } from "./validate-8HbVniNt.cjs";
3
- import { a as isEnvVarSchema, i as EnvVarSchema, n as Preprocessor, r as PreprocessorToggle, t as BooleanMap } from "./BooleanMap-D93UJnv5.cjs";
4
- import { t as EnvChannel } from "./EnvChannel-LMIRYvT1.cjs";
5
- import { n as schema, t as s } from "./schema-DdDa3Qjy.cjs";
6
- export { BooleanEnvVarSchema, BooleanEnvVarSchemaInput, BooleanMap, BooleanMap as BooleanPreprocessorOptions, Check, EnumEnvVarSchema, EnumEnvVarSchemaInput, EnvChannel, EnvVarSchema, EnvVarSchemaBase, EnvVarSchemaDetails, EnvVarSchemaInput, EnvVarType, NumberEnvVarSchema, NumberEnvVarSchemaInput, Preprocessor, PreprocessorToggle, PreprocessorOptions as Preprocessors, Processor, StringEnvVarSchema, StringEnvVarSchemaInput, between, boolean, custom, enumeration, exactLength, integer, isEnvVarSchema, lengthBetween, max, maxLength, min, minLength, number, oneOf, pattern, preprocessors, processors, resolvePreprocessor, s, schema, string, toList, url, validate };
1
+ import { a as EnumEnvVarSchema, c as BooleanEnvVarSchemaInput, d as EnvVarType, f as Processor, i as NumberEnvVarSchemaInput, l as EnvVarSchemaBase, n as StringEnvVarSchemaInput, o as EnumEnvVarSchemaInput, r as NumberEnvVarSchema, s as BooleanEnvVarSchema, t as StringEnvVarSchema, u as EnvVarSchemaInput } from "./StringEnvVarSchema-D9Jr1Aws.cjs";
2
+ import { a as isEnvVarSchema, i as EnvVarSchema, n as Preprocessor, r as PreprocessorToggle, t as BooleanMap } from "./BooleanMap-CX_YrPCf.cjs";
3
+ import { a as number, i as boolean, n as processors, o as string, r as enumeration, s as Check, t as preprocessors } from "./preprocessors-DFVyF0c7.cjs";
4
+ import { t as EnvChannel } from "./EnvChannel-CfSwa_25.cjs";
5
+ import { n as schema, t as s } from "./schema-B1i83alz.cjs";
6
+ //#region ../core/src/schemas/EnvVarSchemaDetails.d.ts
7
+ interface EnvVarSchemaDetails<T> {
8
+ type: EnvVarType;
9
+ required: boolean;
10
+ default?: T;
11
+ description?: string;
12
+ link?: string;
13
+ process?: Processor<T>;
14
+ }
15
+ //#endregion
16
+ //#region ../core/src/processing/options/PreprocessorOptions.d.ts
17
+ type PreprocessorOptions = Partial<{
18
+ /**
19
+ * Custom string preprocessing function
20
+ * Receives the string value and should return a string value
21
+ * @param value - The raw string value from the environment variable
22
+ * @returns Preprocessed string value
23
+ */
24
+ string?: Preprocessor<string> | boolean;
25
+ /**
26
+ * Custom number preprocessing function
27
+ * Receives the string value and should return a string or the target number type
28
+ * @param value - The raw string value from the environment variable
29
+ * @returns Preprocessed string or number value
30
+ */
31
+ number?: Preprocessor<number> | boolean;
32
+ /**
33
+ * Custom boolean preprocessing function
34
+ * Receives the string value and should return a string or the target boolean type
35
+ * @param value - The raw string value from the environment variable
36
+ * @returns Preprocessed string or boolean value
37
+ */
38
+ boolean?: boolean | Preprocessor<boolean> | BooleanMap;
39
+ /**
40
+ * Custom enum preprocessing function
41
+ * Receives the string value and should return a string value
42
+ * @param value - The raw string value from the environment variable
43
+ * @returns Preprocessed string value
44
+ */
45
+ enum?: Preprocessor<string> | boolean;
46
+ }>;
47
+ //#endregion
48
+ //#region ../core/src/processing/preprocessors/resolvePreprocessor.d.ts
49
+ type DefaultPreprocessor<T extends EnvVarType> = T extends "number" ? Preprocessor<number> : T extends "boolean" ? Preprocessor<boolean> : Preprocessor<string>;
50
+ /**
51
+ * Resolve the effective preprocessor for a given environment variable type.
52
+ * Respects custom overrides and falls back to built-in defaults (number, boolean).
53
+ */
54
+ declare function resolvePreprocessor<T extends EnvVarType>(envVarType: T, preprocessorOptions?: PreprocessorOptions): DefaultPreprocessor<T> | undefined;
55
+ //#endregion
56
+ //#region ../core/src/processing/checks/minLength.d.ts
57
+ /**
58
+ * String check: minimum length.
59
+ */
60
+ declare function minLength(min: number, trait?: string): Check<string>;
61
+ //#endregion
62
+ //#region ../core/src/processing/checks/maxLength.d.ts
63
+ /**
64
+ * String check: maximum length.
65
+ */
66
+ declare function maxLength(max: number, trait?: string): Check<string>;
67
+ //#endregion
68
+ //#region ../core/src/processing/checks/lengthBetween.d.ts
69
+ /**
70
+ * String check: length within a range.
71
+ */
72
+ declare function lengthBetween(min: number, max: number, trait?: string): Check<string>;
73
+ //#endregion
74
+ //#region ../core/src/processing/checks/exactLength.d.ts
75
+ /**
76
+ * String check: exact length.
77
+ */
78
+ declare function exactLength(length: number, trait?: string): Check<string>;
79
+ //#endregion
80
+ //#region ../core/src/processing/checks/pattern.d.ts
81
+ /**
82
+ * String check: regex pattern match.
83
+ */
84
+ declare function pattern(regex: RegExp, trait: string | readonly string[]): Check<string>;
85
+ //#endregion
86
+ //#region ../core/src/processing/checks/url.d.ts
87
+ /**
88
+ * String check: valid URL.
89
+ */
90
+ declare function url(trait?: string): Check<string>;
91
+ //#endregion
92
+ //#region ../core/src/processing/checks/oneOf.d.ts
93
+ /**
94
+ * String check: value must be one of the provided values.
95
+ */
96
+ declare function oneOf<T extends string>(values: readonly T[], trait?: string): Check<string>;
97
+ //#endregion
98
+ //#region ../core/src/processing/checks/integer.d.ts
99
+ /**
100
+ * Number check: must be an integer.
101
+ */
102
+ declare function integer(trait?: string): Check<number>;
103
+ //#endregion
104
+ //#region ../core/src/processing/checks/min.d.ts
105
+ /**
106
+ * Number check: minimum value.
107
+ */
108
+ declare function min(minimum: number, trait?: string): Check<number>;
109
+ //#endregion
110
+ //#region ../core/src/processing/checks/max.d.ts
111
+ /**
112
+ * Number check: maximum value.
113
+ */
114
+ declare function max(maximum: number, trait?: string): Check<number>;
115
+ //#endregion
116
+ //#region ../core/src/processing/checks/between.d.ts
117
+ /**
118
+ * Number check: value within a range.
119
+ */
120
+ declare function between(minimum: number, maximum: number, trait?: string): Check<number>;
121
+ //#endregion
122
+ //#region ../core/src/processing/checks/custom.d.ts
123
+ /**
124
+ * Custom check with user-defined validation function.
125
+ * Can return multiple traits.
126
+ */
127
+ declare function custom<T>(fn: (value: T) => boolean, ...traits: string[]): Check<T>;
128
+ //#endregion
129
+ //#region ../core/src/processing/helpers/toList.d.ts
130
+ /**
131
+ * Convert array of items to natural language list.
132
+ * Examples:
133
+ * - [] => ""
134
+ * - ["one"] => "one"
135
+ * - ["one", "two"] => "one and two"
136
+ * - ["one", "two", "three"] => "one, two, and three"
137
+ */
138
+ declare function toList(items: string[]): string;
139
+ //#endregion
140
+ //#region ../core/src/processing/helpers/validate.d.ts
141
+ /**
142
+ * Run checks and aggregate errors.
143
+ * Throws an error with all validation requirements if any check fails.
144
+ */
145
+ declare function validate<T>(value: T, checks: Array<Check<T>>): T;
146
+ //#endregion
147
+ export { BooleanEnvVarSchema, BooleanEnvVarSchemaInput, BooleanMap, type BooleanMap as BooleanPreprocessorOptions, type Check, EnumEnvVarSchema, EnumEnvVarSchemaInput, EnvChannel, type EnvVarSchema, EnvVarSchemaBase, EnvVarSchemaDetails, EnvVarSchemaInput, EnvVarType, NumberEnvVarSchema, NumberEnvVarSchemaInput, Preprocessor, PreprocessorToggle, type PreprocessorOptions as Preprocessors, Processor, StringEnvVarSchema, StringEnvVarSchemaInput, between, boolean, custom, enumeration, exactLength, integer, isEnvVarSchema, lengthBetween, max, maxLength, min, minLength, number, oneOf, pattern, preprocessors, processors, resolvePreprocessor, s, schema, string, toList, url, validate };
package/dist/core.d.ts CHANGED
@@ -1,6 +1,147 @@
1
- import { a as EnumEnvVarSchema, c as BooleanEnvVarSchemaInput, d as EnvVarType, f as Processor, i as NumberEnvVarSchemaInput, l as EnvVarSchemaBase, n as StringEnvVarSchemaInput, o as EnumEnvVarSchemaInput, r as NumberEnvVarSchema, s as BooleanEnvVarSchema, t as StringEnvVarSchema, u as EnvVarSchemaInput } from "./StringEnvVarSchema-BwSGgmeG.js";
2
- import { C as Check, S as string, _ as preprocessors, a as max, b as boolean, c as oneOf, d as exactLength, f as lengthBetween, g as PreprocessorOptions, h as resolvePreprocessor, i as between, l as url, m as minLength, n as toList, o as min, p as maxLength, r as custom, s as integer, t as validate, u as pattern, v as processors, w as EnvVarSchemaDetails, x as number, y as enumeration } from "./validate-CE8hQ5JG.js";
3
- import { a as isEnvVarSchema, i as EnvVarSchema, n as Preprocessor, r as PreprocessorToggle, t as BooleanMap } from "./BooleanMap-B7MeMkJC.js";
4
- import { t as EnvChannel } from "./EnvChannel-w27PEm7x.js";
5
- import { n as schema, t as s } from "./schema-CHypJTDK.js";
6
- export { BooleanEnvVarSchema, BooleanEnvVarSchemaInput, BooleanMap, BooleanMap as BooleanPreprocessorOptions, Check, EnumEnvVarSchema, EnumEnvVarSchemaInput, EnvChannel, EnvVarSchema, EnvVarSchemaBase, EnvVarSchemaDetails, EnvVarSchemaInput, EnvVarType, NumberEnvVarSchema, NumberEnvVarSchemaInput, Preprocessor, PreprocessorToggle, PreprocessorOptions as Preprocessors, Processor, StringEnvVarSchema, StringEnvVarSchemaInput, between, boolean, custom, enumeration, exactLength, integer, isEnvVarSchema, lengthBetween, max, maxLength, min, minLength, number, oneOf, pattern, preprocessors, processors, resolvePreprocessor, s, schema, string, toList, url, validate };
1
+ import { a as EnumEnvVarSchema, c as BooleanEnvVarSchemaInput, d as EnvVarType, f as Processor, i as NumberEnvVarSchemaInput, l as EnvVarSchemaBase, n as StringEnvVarSchemaInput, o as EnumEnvVarSchemaInput, r as NumberEnvVarSchema, s as BooleanEnvVarSchema, t as StringEnvVarSchema, u as EnvVarSchemaInput } from "./StringEnvVarSchema-D9Jr1Aws.js";
2
+ import { a as isEnvVarSchema, i as EnvVarSchema, n as Preprocessor, r as PreprocessorToggle, t as BooleanMap } from "./BooleanMap-BPQuO3Ae.js";
3
+ import { a as number, i as boolean, n as processors, o as string, r as enumeration, s as Check, t as preprocessors } from "./preprocessors-BKuIcZa1.js";
4
+ import { t as EnvChannel } from "./EnvChannel-CfSwa_25.js";
5
+ import { n as schema, t as s } from "./schema-B-JLVS42.js";
6
+ //#region ../core/src/schemas/EnvVarSchemaDetails.d.ts
7
+ interface EnvVarSchemaDetails<T> {
8
+ type: EnvVarType;
9
+ required: boolean;
10
+ default?: T;
11
+ description?: string;
12
+ link?: string;
13
+ process?: Processor<T>;
14
+ }
15
+ //#endregion
16
+ //#region ../core/src/processing/options/PreprocessorOptions.d.ts
17
+ type PreprocessorOptions = Partial<{
18
+ /**
19
+ * Custom string preprocessing function
20
+ * Receives the string value and should return a string value
21
+ * @param value - The raw string value from the environment variable
22
+ * @returns Preprocessed string value
23
+ */
24
+ string?: Preprocessor<string> | boolean;
25
+ /**
26
+ * Custom number preprocessing function
27
+ * Receives the string value and should return a string or the target number type
28
+ * @param value - The raw string value from the environment variable
29
+ * @returns Preprocessed string or number value
30
+ */
31
+ number?: Preprocessor<number> | boolean;
32
+ /**
33
+ * Custom boolean preprocessing function
34
+ * Receives the string value and should return a string or the target boolean type
35
+ * @param value - The raw string value from the environment variable
36
+ * @returns Preprocessed string or boolean value
37
+ */
38
+ boolean?: boolean | Preprocessor<boolean> | BooleanMap;
39
+ /**
40
+ * Custom enum preprocessing function
41
+ * Receives the string value and should return a string value
42
+ * @param value - The raw string value from the environment variable
43
+ * @returns Preprocessed string value
44
+ */
45
+ enum?: Preprocessor<string> | boolean;
46
+ }>;
47
+ //#endregion
48
+ //#region ../core/src/processing/preprocessors/resolvePreprocessor.d.ts
49
+ type DefaultPreprocessor<T extends EnvVarType> = T extends "number" ? Preprocessor<number> : T extends "boolean" ? Preprocessor<boolean> : Preprocessor<string>;
50
+ /**
51
+ * Resolve the effective preprocessor for a given environment variable type.
52
+ * Respects custom overrides and falls back to built-in defaults (number, boolean).
53
+ */
54
+ declare function resolvePreprocessor<T extends EnvVarType>(envVarType: T, preprocessorOptions?: PreprocessorOptions): DefaultPreprocessor<T> | undefined;
55
+ //#endregion
56
+ //#region ../core/src/processing/checks/minLength.d.ts
57
+ /**
58
+ * String check: minimum length.
59
+ */
60
+ declare function minLength(min: number, trait?: string): Check<string>;
61
+ //#endregion
62
+ //#region ../core/src/processing/checks/maxLength.d.ts
63
+ /**
64
+ * String check: maximum length.
65
+ */
66
+ declare function maxLength(max: number, trait?: string): Check<string>;
67
+ //#endregion
68
+ //#region ../core/src/processing/checks/lengthBetween.d.ts
69
+ /**
70
+ * String check: length within a range.
71
+ */
72
+ declare function lengthBetween(min: number, max: number, trait?: string): Check<string>;
73
+ //#endregion
74
+ //#region ../core/src/processing/checks/exactLength.d.ts
75
+ /**
76
+ * String check: exact length.
77
+ */
78
+ declare function exactLength(length: number, trait?: string): Check<string>;
79
+ //#endregion
80
+ //#region ../core/src/processing/checks/pattern.d.ts
81
+ /**
82
+ * String check: regex pattern match.
83
+ */
84
+ declare function pattern(regex: RegExp, trait: string | readonly string[]): Check<string>;
85
+ //#endregion
86
+ //#region ../core/src/processing/checks/url.d.ts
87
+ /**
88
+ * String check: valid URL.
89
+ */
90
+ declare function url(trait?: string): Check<string>;
91
+ //#endregion
92
+ //#region ../core/src/processing/checks/oneOf.d.ts
93
+ /**
94
+ * String check: value must be one of the provided values.
95
+ */
96
+ declare function oneOf<T extends string>(values: readonly T[], trait?: string): Check<string>;
97
+ //#endregion
98
+ //#region ../core/src/processing/checks/integer.d.ts
99
+ /**
100
+ * Number check: must be an integer.
101
+ */
102
+ declare function integer(trait?: string): Check<number>;
103
+ //#endregion
104
+ //#region ../core/src/processing/checks/min.d.ts
105
+ /**
106
+ * Number check: minimum value.
107
+ */
108
+ declare function min(minimum: number, trait?: string): Check<number>;
109
+ //#endregion
110
+ //#region ../core/src/processing/checks/max.d.ts
111
+ /**
112
+ * Number check: maximum value.
113
+ */
114
+ declare function max(maximum: number, trait?: string): Check<number>;
115
+ //#endregion
116
+ //#region ../core/src/processing/checks/between.d.ts
117
+ /**
118
+ * Number check: value within a range.
119
+ */
120
+ declare function between(minimum: number, maximum: number, trait?: string): Check<number>;
121
+ //#endregion
122
+ //#region ../core/src/processing/checks/custom.d.ts
123
+ /**
124
+ * Custom check with user-defined validation function.
125
+ * Can return multiple traits.
126
+ */
127
+ declare function custom<T>(fn: (value: T) => boolean, ...traits: string[]): Check<T>;
128
+ //#endregion
129
+ //#region ../core/src/processing/helpers/toList.d.ts
130
+ /**
131
+ * Convert array of items to natural language list.
132
+ * Examples:
133
+ * - [] => ""
134
+ * - ["one"] => "one"
135
+ * - ["one", "two"] => "one and two"
136
+ * - ["one", "two", "three"] => "one, two, and three"
137
+ */
138
+ declare function toList(items: string[]): string;
139
+ //#endregion
140
+ //#region ../core/src/processing/helpers/validate.d.ts
141
+ /**
142
+ * Run checks and aggregate errors.
143
+ * Throws an error with all validation requirements if any check fails.
144
+ */
145
+ declare function validate<T>(value: T, checks: Array<Check<T>>): T;
146
+ //#endregion
147
+ export { BooleanEnvVarSchema, BooleanEnvVarSchemaInput, BooleanMap, type BooleanMap as BooleanPreprocessorOptions, type Check, EnumEnvVarSchema, EnumEnvVarSchemaInput, EnvChannel, type EnvVarSchema, EnvVarSchemaBase, EnvVarSchemaDetails, EnvVarSchemaInput, EnvVarType, NumberEnvVarSchema, NumberEnvVarSchemaInput, Preprocessor, PreprocessorToggle, type PreprocessorOptions as Preprocessors, Processor, StringEnvVarSchema, StringEnvVarSchemaInput, between, boolean, custom, enumeration, exactLength, integer, isEnvVarSchema, lengthBetween, max, maxLength, min, minLength, number, oneOf, pattern, preprocessors, processors, resolvePreprocessor, s, schema, string, toList, url, validate };
package/dist/core.js CHANGED
@@ -1,17 +1,17 @@
1
- import { _ as EnvVarSchemaBase, a as isEnvVarSchema, c as EnumEnvVarSchema, d as enumeration, f as boolean, g as toList, h as validate, i as preprocessors, l as BooleanEnvVarSchema, m as string, n as schema, o as StringEnvVarSchema, p as number, r as resolvePreprocessor, s as NumberEnvVarSchema, t as s, u as processors } from "./src-B5Qu-M-r.js";
2
- import { a as url, c as lengthBetween, i as oneOf, l as minLength, n as between, o as pattern, r as integer, s as exactLength, t as custom } from "./custom-Bt_wnxIu.js";
3
-
1
+ import { a as EnumEnvVarSchema, c as enumeration, d as string, f as validate, i as NumberEnvVarSchema, l as boolean, m as EnvVarSchemaBase, n as preprocessors, o as BooleanEnvVarSchema, p as toList, r as StringEnvVarSchema, s as processors, t as resolvePreprocessor, u as number } from "./src-Cg49gGJb.js";
2
+ import { t as isEnvVarSchema } from "./EnvVarSchema-Dr6q7jf6.js";
3
+ import { a as url, c as lengthBetween, i as oneOf, l as minLength, n as between, o as pattern, r as integer, s as exactLength, t as custom } from "./custom-Bd-jLg80.js";
4
+ import { n as schema, t as s } from "./schema-CtP5lpU1.js";
4
5
  //#region ../core/src/processing/checks/maxLength.ts
5
6
  /**
6
7
  * String check: maximum length.
7
8
  */
8
- function maxLength(max$1, trait) {
9
+ function maxLength(max, trait) {
9
10
  return (value) => {
10
- if (value.length > max$1) return trait ? [trait] : [`at most ${max$1} characters`];
11
+ if (value.length > max) return trait ? [trait] : [`at most ${max} characters`];
11
12
  return [];
12
13
  };
13
14
  }
14
-
15
15
  //#endregion
16
16
  //#region ../core/src/processing/checks/min.ts
17
17
  /**
@@ -19,11 +19,10 @@ function maxLength(max$1, trait) {
19
19
  */
20
20
  function min(minimum, trait) {
21
21
  return (value) => {
22
- if (value < minimum) return trait ? [trait] : [`at least ${minimum}`];
22
+ if (Number.isNaN(value) || value < minimum) return trait ? [trait] : [`at least ${minimum}`];
23
23
  return [];
24
24
  };
25
25
  }
26
-
27
26
  //#endregion
28
27
  //#region ../core/src/processing/checks/max.ts
29
28
  /**
@@ -31,10 +30,9 @@ function min(minimum, trait) {
31
30
  */
32
31
  function max(maximum, trait) {
33
32
  return (value) => {
34
- if (value > maximum) return trait ? [trait] : [`at most ${maximum}`];
33
+ if (Number.isNaN(value) || value > maximum) return trait ? [trait] : [`at most ${maximum}`];
35
34
  return [];
36
35
  };
37
36
  }
38
-
39
37
  //#endregion
40
- export { BooleanEnvVarSchema, EnumEnvVarSchema, EnvVarSchemaBase, NumberEnvVarSchema, StringEnvVarSchema, between, boolean, custom, enumeration, exactLength, integer, isEnvVarSchema, lengthBetween, max, maxLength, min, minLength, number, oneOf, pattern, preprocessors, processors, resolvePreprocessor, s, schema, string, toList, url, validate };
38
+ export { BooleanEnvVarSchema, EnumEnvVarSchema, EnvVarSchemaBase, NumberEnvVarSchema, StringEnvVarSchema, between, boolean, custom, enumeration, exactLength, integer, isEnvVarSchema, lengthBetween, max, maxLength, min, minLength, number, oneOf, pattern, preprocessors, processors, resolvePreprocessor, s, schema, string, toList, url, validate };
@@ -8,7 +8,6 @@ function minLength(min, trait) {
8
8
  return [];
9
9
  };
10
10
  }
11
-
12
11
  //#endregion
13
12
  //#region ../core/src/processing/checks/lengthBetween.ts
14
13
  /**
@@ -20,7 +19,6 @@ function lengthBetween(min, max, trait) {
20
19
  return [];
21
20
  };
22
21
  }
23
-
24
22
  //#endregion
25
23
  //#region ../core/src/processing/checks/exactLength.ts
26
24
  /**
@@ -32,7 +30,6 @@ function exactLength(length, trait) {
32
30
  return [];
33
31
  };
34
32
  }
35
-
36
33
  //#endregion
37
34
  //#region ../core/src/processing/checks/pattern.ts
38
35
  /**
@@ -44,7 +41,6 @@ function pattern(regex, trait) {
44
41
  return [];
45
42
  };
46
43
  }
47
-
48
44
  //#endregion
49
45
  //#region ../core/src/processing/checks/url.ts
50
46
  /**
@@ -60,7 +56,6 @@ function url(trait) {
60
56
  }
61
57
  };
62
58
  }
63
-
64
59
  //#endregion
65
60
  //#region ../core/src/processing/checks/oneOf.ts
66
61
  /**
@@ -72,7 +67,6 @@ function oneOf(values, trait) {
72
67
  return [];
73
68
  };
74
69
  }
75
-
76
70
  //#endregion
77
71
  //#region ../core/src/processing/checks/integer.ts
78
72
  /**
@@ -84,7 +78,6 @@ function integer(trait) {
84
78
  return [];
85
79
  };
86
80
  }
87
-
88
81
  //#endregion
89
82
  //#region ../core/src/processing/checks/between.ts
90
83
  /**
@@ -92,11 +85,10 @@ function integer(trait) {
92
85
  */
93
86
  function between(minimum, maximum, trait) {
94
87
  return (value) => {
95
- if (value < minimum || value > maximum) return trait ? [trait] : [`between ${minimum} and ${maximum}`];
88
+ if (Number.isNaN(value) || value < minimum || value > maximum) return trait ? [trait] : [`between ${minimum} and ${maximum}`];
96
89
  return [];
97
90
  };
98
91
  }
99
-
100
92
  //#endregion
101
93
  //#region ../core/src/processing/checks/custom.ts
102
94
  /**
@@ -105,10 +97,9 @@ function between(minimum, maximum, trait) {
105
97
  */
106
98
  function custom(fn, ...traits) {
107
99
  return (value) => {
108
- if (!fn(value)) return traits;
100
+ if (!fn(value)) return traits.length > 0 ? [...traits] : ["a valid value"];
109
101
  return [];
110
102
  };
111
103
  }
112
-
113
104
  //#endregion
114
- export { url as a, lengthBetween as c, oneOf as i, minLength as l, between as n, pattern as o, integer as r, exactLength as s, custom as t };
105
+ export { url as a, lengthBetween as c, oneOf as i, minLength as l, between as n, pattern as o, integer as r, exactLength as s, custom as t };