@e-n-v/env 0.0.1 → 0.0.4

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 (99) hide show
  1. package/README.md +43 -24
  2. package/dist/BooleanMap-B2eIP3tZ.d.cts +32 -0
  3. package/dist/BooleanMap-DmFnCA-O.d.ts +32 -0
  4. package/dist/EnvChannel-LMIRYvT1.d.cts +16 -0
  5. package/dist/EnvChannel-w27PEm7x.d.ts +16 -0
  6. package/dist/EnvChannelOptions-BPkWDrmr.d.cts +108 -0
  7. package/dist/EnvChannelOptions-CRwDLWjd.d.ts +108 -0
  8. package/dist/EnvModel-CrGclUpJ.d.cts +134 -0
  9. package/dist/EnvModel-D8rt0EJ6.d.ts +134 -0
  10. package/dist/EnvSource-BVnmdHku.cjs +420 -0
  11. package/dist/EnvSource-DA3ZGlES.js +400 -0
  12. package/dist/ProcessEnvChannel-D465c-dp.d.cts +97 -0
  13. package/dist/ProcessEnvChannel-Do4-yiLI.d.ts +97 -0
  14. package/dist/StringEnvVarSchema-B8MT7htU.d.ts +64 -0
  15. package/dist/StringEnvVarSchema-BF6C0nyT.d.cts +64 -0
  16. package/dist/channels.cjs +8 -0
  17. package/dist/channels.d.cts +20 -0
  18. package/dist/channels.d.ts +20 -0
  19. package/dist/channels.js +4 -0
  20. package/dist/chunk-pbleEpgJ.cjs +44 -0
  21. package/dist/cli.cjs +16 -10
  22. package/dist/cli.js +7 -2
  23. package/dist/coerce-DNIuYAx4.js +11028 -0
  24. package/dist/coerce-b7UVodS9.cjs +12365 -0
  25. package/dist/core.cjs +68 -0
  26. package/dist/core.d.cts +6 -0
  27. package/dist/core.d.ts +6 -0
  28. package/dist/core.js +40 -0
  29. package/dist/custom-Bt_wnxIu.js +114 -0
  30. package/dist/custom-D_Rqjm09.cjs +168 -0
  31. package/dist/files.cjs +18 -0
  32. package/dist/files.d.cts +38 -0
  33. package/dist/files.d.ts +38 -0
  34. package/dist/files.js +13 -0
  35. package/dist/index-D8pslhp4.d.cts +170 -0
  36. package/dist/index-Dq_0aeAL.d.ts +170 -0
  37. package/dist/model-Dic8IJsf.d.ts +29 -0
  38. package/dist/model-ft0WhSSS.d.cts +29 -0
  39. package/dist/model.cjs +14 -0
  40. package/dist/model.d.cts +35 -0
  41. package/dist/model.d.ts +35 -0
  42. package/dist/model.js +9 -0
  43. package/dist/parse-BT1QSa5e.d.cts +28 -0
  44. package/dist/parse-DwtLpVhC.d.ts +28 -0
  45. package/dist/parse.cjs +17 -0
  46. package/dist/parse.d.cts +52 -0
  47. package/dist/parse.d.ts +52 -0
  48. package/dist/parse.js +10 -0
  49. package/dist/prompt-C5WudV9x.d.cts +74 -0
  50. package/dist/prompt-yKdccbtZ.d.ts +74 -0
  51. package/dist/prompt.cjs +24 -0
  52. package/dist/prompt.d.cts +17 -0
  53. package/dist/prompt.d.ts +17 -0
  54. package/dist/prompt.js +12 -0
  55. package/dist/redis-CJOpRPjc.js +395 -0
  56. package/dist/redis-EcC7TX3K.cjs +611 -0
  57. package/dist/resolveChannel-CjAuxy3p.cjs +257 -0
  58. package/dist/resolveChannel-v9BDsw-M.js +224 -0
  59. package/dist/root.cjs +36 -0
  60. package/dist/root.d.cts +21 -0
  61. package/dist/root.d.ts +21 -0
  62. package/dist/root.js +21 -0
  63. package/dist/schema-DH4GiW9A.d.cts +18 -0
  64. package/dist/schema-jN4EtvEP.d.ts +18 -0
  65. package/dist/schemas/zod.cjs +629 -0
  66. package/dist/schemas/zod.d.cts +239 -0
  67. package/dist/schemas/zod.d.ts +239 -0
  68. package/dist/schemas/zod.js +550 -0
  69. package/dist/schemas.cjs +133 -0
  70. package/dist/schemas.d.cts +3 -0
  71. package/dist/schemas.d.ts +3 -0
  72. package/dist/schemas.js +6 -0
  73. package/dist/src-B7FG1rak.js +638 -0
  74. package/dist/src-BBwjK5SK.js +127 -0
  75. package/dist/src-CLTURaoo.js +311 -0
  76. package/dist/src-CVdUqK3q.js +850 -0
  77. package/dist/src-Cjo2XA4n.cjs +138 -0
  78. package/dist/{src-oetJm-nZ.cjs → src-DWYoqPX1.cjs} +31 -1964
  79. package/dist/src-DZmpNGrQ.cjs +1411 -0
  80. package/dist/{src-RlCvrI0s.js → src-Dtv7TlJx.js} +14 -1726
  81. package/dist/src-XjL5cyPG.cjs +873 -0
  82. package/dist/src-meUnCASg.cjs +413 -0
  83. package/dist/validate-BxA3a-ns.d.cts +203 -0
  84. package/dist/validate-CyxrRacF.d.ts +203 -0
  85. package/dist/vars-BNVI6k89.d.ts +21 -0
  86. package/dist/vars-CYOaskkK.cjs +27 -0
  87. package/dist/vars-CptZRPX5.d.cts +21 -0
  88. package/dist/vars-DOW0LiiN.js +22 -0
  89. package/dist/vars.cjs +138 -0
  90. package/dist/vars.d.cts +7 -0
  91. package/dist/vars.d.ts +7 -0
  92. package/dist/vars.js +9 -0
  93. package/package.json +59 -9
  94. package/assets/demo.gif +0 -0
  95. package/assets/env-logo.png +0 -0
  96. package/dist/bundle.cjs +0 -1290
  97. package/dist/bundle.d.cts +0 -1057
  98. package/dist/bundle.d.ts +0 -1055
  99. package/dist/bundle.js +0 -1244
@@ -0,0 +1,138 @@
1
+ const require_src = require('./src-meUnCASg.cjs');
2
+ const require_src$1 = require('./src-XjL5cyPG.cjs');
3
+
4
+ //#region ../parse/src/errors/EnvParseError.ts
5
+ /**
6
+ * Error thrown when parsing environment variables fails.
7
+ * Collects all issues so callers can inspect them without relying on subclasses.
8
+ */
9
+ var EnvParseError = class EnvParseError extends Error {
10
+ issues;
11
+ partial;
12
+ constructor(params) {
13
+ const { issues, partial } = params;
14
+ super(EnvParseError.formatMessage(issues));
15
+ this.name = "EnvParseError";
16
+ this.issues = Object.freeze([...issues]);
17
+ this.partial = partial ?? {};
18
+ }
19
+ /** Number of issues encountered while parsing. */
20
+ get issueCount() {
21
+ return this.issues.length;
22
+ }
23
+ /** Keys that were missing but required. */
24
+ get missing() {
25
+ return this.issues.filter((issue) => issue.type === "missing").map((issue) => issue.key);
26
+ }
27
+ /** Keys that were present but invalid. */
28
+ get invalid() {
29
+ return this.issues.filter((issue) => issue.type === "invalid").map((issue) => issue.key);
30
+ }
31
+ /**
32
+ * Get all issue messages as a numbered list for easy logging.
33
+ */
34
+ formatIssues() {
35
+ return this.issues.map((issue, index) => `${index + 1}. ${issue.message}`).join("\n");
36
+ }
37
+ static formatMessage(issues) {
38
+ if (issues.length === 0) return "Environment validation failed with no details.";
39
+ return [`Environment validation failed with ${issues.length} issue${issues.length === 1 ? "" : "s"}:`, ...issues.map((issue) => {
40
+ if (issue.type === "missing") return `- ${issue.key}: ${issue.message}`;
41
+ return `- ${issue.key}: ${issue.message}`;
42
+ })].join("\n");
43
+ }
44
+ };
45
+
46
+ //#endregion
47
+ //#region ../parse/src/parse.ts
48
+ /**
49
+ * Parse and validate environment variables from a source object
50
+ * Does NOT mutate process.env
51
+ */
52
+ function parse(source, modelOrOptions) {
53
+ let resolvedSchemas;
54
+ let preprocessConfig;
55
+ if (modelOrOptions instanceof require_src$1.EnvModel) {
56
+ const model = modelOrOptions;
57
+ resolvedSchemas = model.schemas;
58
+ preprocessConfig = model.preprocess;
59
+ } else {
60
+ const options = modelOrOptions;
61
+ resolvedSchemas = require_src$1.resolveSchemas(options.schemas);
62
+ const config = options.preprocess;
63
+ if (config === false) preprocessConfig = {
64
+ string: false,
65
+ number: false,
66
+ boolean: false,
67
+ enum: false
68
+ };
69
+ else if (config === true || config === void 0) preprocessConfig = {};
70
+ else preprocessConfig = { ...config };
71
+ }
72
+ const result = {};
73
+ const issues = [];
74
+ for (const [key, schema$1] of Object.entries(resolvedSchemas)) {
75
+ const rawValue = source[key];
76
+ if (rawValue === void 0 || rawValue.trim() === "") {
77
+ if (schema$1.default !== void 0) {
78
+ result[key] = schema$1.default;
79
+ continue;
80
+ }
81
+ if (schema$1.required) {
82
+ issues.push({
83
+ type: "missing",
84
+ key,
85
+ message: `Required environment variable "${key}" is missing`
86
+ });
87
+ result[key] = void 0;
88
+ continue;
89
+ }
90
+ result[key] = void 0;
91
+ continue;
92
+ }
93
+ const preprocessor = require_src.resolvePreprocessor(schema$1.type, preprocessConfig);
94
+ const preprocessedValue = preprocessor ? preprocessor(rawValue) : rawValue;
95
+ const stringValue = typeof preprocessedValue === "string" ? preprocessedValue : String(preprocessedValue);
96
+ try {
97
+ const processedValue = schema$1.process(stringValue);
98
+ if (processedValue === void 0) if (schema$1.default !== void 0) result[key] = schema$1.default;
99
+ else if (schema$1.required) {
100
+ issues.push({
101
+ type: "missing",
102
+ key,
103
+ message: `Required environment variable "${key}" is missing`
104
+ });
105
+ result[key] = void 0;
106
+ } else result[key] = void 0;
107
+ else result[key] = processedValue;
108
+ } catch (error) {
109
+ const message = `Environment variable "${key}" validation failed: ${error instanceof Error ? error.message : String(error)}`;
110
+ issues.push({
111
+ type: "invalid",
112
+ key,
113
+ value: rawValue,
114
+ message
115
+ });
116
+ result[key] = void 0;
117
+ }
118
+ }
119
+ if (issues.length > 0) throw new EnvParseError({
120
+ issues,
121
+ partial: { ...result }
122
+ });
123
+ return result;
124
+ }
125
+
126
+ //#endregion
127
+ Object.defineProperty(exports, 'EnvParseError', {
128
+ enumerable: true,
129
+ get: function () {
130
+ return EnvParseError;
131
+ }
132
+ });
133
+ Object.defineProperty(exports, 'parse', {
134
+ enumerable: true,
135
+ get: function () {
136
+ return parse;
137
+ }
138
+ });