@e-n-v/env 0.0.2 → 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 +57 -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
@@ -1,1759 +1,22 @@
1
- //#region rolldown:runtime
2
- var __create = Object.create;
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __export = (all) => {
9
- let target = {};
10
- for (var name in all) __defProp(target, name, {
11
- get: all[name],
12
- enumerable: true
13
- });
14
- return target;
15
- };
16
- var __copyProps = (to, from, except, desc) => {
17
- if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
18
- key = keys[i];
19
- if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
20
- get: ((k) => from[k]).bind(null, key),
21
- enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
22
- });
23
- }
24
- return to;
25
- };
26
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
27
- value: mod,
28
- enumerable: true
29
- }) : target, mod));
30
-
31
- //#endregion
32
- let node_fs = require("node:fs");
33
- node_fs = __toESM(node_fs);
34
- let node_path = require("node:path");
35
- node_path = __toESM(node_path);
36
- let node_fs_promises = require("node:fs/promises");
37
- node_fs_promises = __toESM(node_fs_promises);
38
- let fs = require("fs");
39
- fs = __toESM(fs);
40
- let zod = require("zod");
41
- zod = __toESM(zod);
42
- let zod_v4_core = require("zod/v4/core");
43
- zod_v4_core = __toESM(zod_v4_core);
44
- let node_process = require("node:process");
45
- node_process = __toESM(node_process);
46
- let __clack_core = require("@clack/core");
47
- __clack_core = __toESM(__clack_core);
48
- let node_url = require("node:url");
49
- node_url = __toESM(node_url);
50
- let picocolors = require("picocolors");
51
- picocolors = __toESM(picocolors);
52
- let node_readline = require("node:readline");
53
- node_readline = __toESM(node_readline);
54
-
55
- //#region ../files/src/utils.ts
56
- function normalizeContent(content) {
57
- return content.replace(/\r\n/g, "\n");
58
- }
59
- function splitLines(content) {
60
- return content === "" ? [] : content.split("\n");
61
- }
62
- function validateKey(key) {
63
- const trimmed = key.trim();
64
- if (!trimmed) throw new TypeError("Environment variable name cannot be empty");
65
- if (!/^[A-Za-z_][A-Za-z0-9_]*$/.test(trimmed)) throw new TypeError(`Invalid environment variable name: ${trimmed}`);
66
- return trimmed;
67
- }
68
- function parseAssignmentEndingAt(lines, endIndex) {
69
- const lastLine = lines[endIndex];
70
- if (typeof lastLine !== "string" || isSkippableLine(lastLine)) return null;
71
- const block = [];
72
- let start = endIndex;
73
- while (start >= 0) {
74
- const currentLine = lines[start];
75
- if (typeof currentLine !== "string") break;
76
- block.unshift(currentLine);
77
- if (containsAssignmentOperator(currentLine)) {
78
- const parsed = tryParseAssignmentBlock(block);
79
- if (!parsed) return null;
80
- return {
81
- ...parsed,
82
- startIndex: start,
83
- endIndex
84
- };
85
- }
86
- start -= 1;
87
- }
88
- return null;
89
- }
90
- function isSkippableLine(line) {
91
- const trimmed = line.trim();
92
- return trimmed.length === 0 || trimmed.startsWith("#");
93
- }
94
- function containsAssignmentOperator(line) {
95
- const trimmed = line.trimStart();
96
- if (trimmed.length === 0 || trimmed.startsWith("#")) return false;
97
- const commentIndex = trimmed.indexOf("#");
98
- return (commentIndex === -1 ? trimmed : trimmed.slice(0, commentIndex)).includes("=");
99
- }
100
- function tryParseAssignmentBlock(blockLines) {
101
- if (blockLines.length === 0) return null;
102
- const firstLine = blockLines[0];
103
- const leadingMatch = firstLine.match(/^\s*/);
104
- const leading = leadingMatch ? leadingMatch[0] : "";
105
- let remainder = firstLine.slice(leading.length);
106
- if (remainder.length === 0 || remainder.startsWith("#")) return null;
107
- let exportPrefix = "";
108
- if (remainder.startsWith("export")) {
109
- const afterExport = remainder.slice(6);
110
- if (/^\s/.test(afterExport)) {
111
- const spacingMatch = afterExport.match(/^\s+/);
112
- const spacing = spacingMatch ? spacingMatch[0] : " ";
113
- exportPrefix = `export${spacing}`;
114
- remainder = afterExport.slice(spacing.length);
115
- }
116
- }
117
- const equalsIndex = remainder.indexOf("=");
118
- if (equalsIndex === -1) return null;
119
- const key = validateKey(remainder.slice(0, equalsIndex).trim());
120
- const parsedValue = parseValueSource([remainder.slice(equalsIndex + 1).replace(/^\s+/, ""), ...blockLines.slice(1)].join("\n"));
121
- if (!parsedValue) return null;
122
- const trailingTrimmed = parsedValue.trailing.trim();
123
- if (trailingTrimmed.length > 0 && !trailingTrimmed.startsWith("#")) return null;
124
- return {
125
- key,
126
- value: parsedValue.value,
127
- leading,
128
- exportPrefix,
129
- trailing: parsedValue.trailing,
130
- lines: [...blockLines]
131
- };
132
- }
133
- function parseValueSource(source) {
134
- if (source.length === 0) return {
135
- value: "",
136
- trailing: ""
137
- };
138
- const firstChar = source[0];
139
- if (firstChar === "\"") return parseDoubleQuotedValue(source);
140
- if (firstChar === "'") return parseSingleQuotedValue(source);
141
- if (source.includes("\n")) return null;
142
- const commentIndex = source.indexOf(" #");
143
- const raw = commentIndex === -1 ? source : source.slice(0, commentIndex);
144
- const trailing = commentIndex === -1 ? source.slice(raw.length) : source.slice(commentIndex);
145
- return {
146
- value: raw.trim(),
147
- trailing
148
- };
149
- }
150
- function parseDoubleQuotedValue(source) {
151
- let value = "";
152
- let escaping = false;
153
- for (let i = 1; i < source.length; i += 1) {
154
- const char = source[i] ?? "";
155
- if (escaping) {
156
- switch (char) {
157
- case "n":
158
- value += "\n";
159
- break;
160
- case "r":
161
- value += "\r";
162
- break;
163
- case "t":
164
- value += " ";
165
- break;
166
- case "\"":
167
- value += "\"";
168
- break;
169
- case "\\":
170
- value += "\\";
171
- break;
172
- default:
173
- value += char;
174
- break;
175
- }
176
- escaping = false;
177
- continue;
178
- }
179
- if (char === "\\") {
180
- escaping = true;
181
- continue;
182
- }
183
- if (char === "\"") {
184
- const trailing = source.slice(i + 1);
185
- return {
186
- value,
187
- trailing
188
- };
189
- }
190
- if (char === "\n") {
191
- value += "\n";
192
- continue;
193
- }
194
- value += char;
195
- }
196
- return null;
197
- }
198
- function parseSingleQuotedValue(source) {
199
- let value = "";
200
- for (let i = 1; i < source.length; i += 1) {
201
- const char = source[i] ?? "";
202
- if (char === "'") {
203
- const trailing = source.slice(i + 1);
204
- return {
205
- value,
206
- trailing
207
- };
208
- }
209
- if (char === "\n") {
210
- value += "\n";
211
- continue;
212
- }
213
- value += char;
214
- }
215
- return null;
216
- }
217
-
218
- //#endregion
219
- //#region ../files/src/get.ts
220
- function get(content, arg) {
221
- const lines = splitLines(normalizeContent(content));
222
- if (typeof arg === "undefined") {
223
- const map = scanAll(lines);
224
- return Object.fromEntries(map);
225
- }
226
- if (typeof arg === "string") return scanForSingle(lines, arg);
227
- const normalizedTargets = Array.from(new Set(arg.map((name) => validateKey(name))));
228
- const lookup = scanForMany(lines, new Set(normalizedTargets));
229
- const ordered = normalizedTargets.map((key) => [key, lookup.get(key)]);
230
- return Object.fromEntries(ordered);
231
- }
232
- function scanAll(lines) {
233
- const result = /* @__PURE__ */ new Map();
234
- iterateAssignments(lines, (assignment) => {
235
- if (!result.has(assignment.key)) result.set(assignment.key, assignment.value);
236
- });
237
- return result;
238
- }
239
- function scanForSingle(lines, target) {
240
- const name = validateKey(target);
241
- let found;
242
- iterateAssignments(lines, (assignment) => {
243
- if (assignment.key === name) {
244
- found = assignment.value;
245
- return true;
246
- }
247
- });
248
- return found;
249
- }
250
- function scanForMany(lines, targets) {
251
- const normalizedTargets = /* @__PURE__ */ new Set();
252
- for (const target of targets) normalizedTargets.add(validateKey(target));
253
- const found = /* @__PURE__ */ new Map();
254
- const remaining = new Set(normalizedTargets);
255
- iterateAssignments(lines, (assignment) => {
256
- if (!remaining.has(assignment.key) || found.has(assignment.key)) return;
257
- found.set(assignment.key, assignment.value);
258
- remaining.delete(assignment.key);
259
- if (remaining.size === 0) return true;
260
- });
261
- return found;
262
- }
263
- function iterateAssignments(lines, callback) {
264
- for (let i = lines.length - 1; i >= 0;) {
265
- const parsed = parseAssignmentEndingAt(lines, i);
266
- if (!parsed) {
267
- i -= 1;
268
- continue;
269
- }
270
- if (callback(parsed) === true) return;
271
- i = parsed.startIndex - 1;
272
- }
273
- }
274
-
275
- //#endregion
276
- //#region ../files/src/set.ts
277
- function set(content, arg, value) {
278
- const normalized = normalizeContent(content);
279
- const lines = splitLines(normalized);
280
- const entries = normalizeWriteArguments(arg, value);
281
- if (entries.length === 0) return ensureTrailingNewline(normalized);
282
- const replacements = new Map(entries);
283
- const touched = /* @__PURE__ */ new Set();
284
- for (let i = lines.length - 1; i >= 0;) {
285
- if (replacements.size === 0) break;
286
- const parsed = parseAssignmentEndingAt(lines, i);
287
- if (!parsed) {
288
- i -= 1;
289
- continue;
290
- }
291
- const { key, startIndex, endIndex, leading, exportPrefix, trailing, value: currentValue } = parsed;
292
- const nextValue = replacements.get(key);
293
- if (typeof nextValue === "undefined" || touched.has(key)) {
294
- i = startIndex - 1;
295
- continue;
296
- }
297
- if (nextValue === currentValue) {
298
- touched.add(key);
299
- replacements.delete(key);
300
- i = startIndex - 1;
301
- continue;
302
- }
303
- const block = buildAssignmentLines(key, nextValue, {
304
- leading,
305
- exportPrefix,
306
- trailing
307
- });
308
- lines.splice(startIndex, endIndex - startIndex + 1, ...block);
309
- touched.add(key);
310
- replacements.delete(key);
311
- i = startIndex - 1;
312
- }
313
- for (const [key, val] of entries) {
314
- if (touched.has(key)) continue;
315
- const block = buildAssignmentLines(key, val);
316
- const insertIndex = lines.length > 0 && lines[lines.length - 1] === "" ? lines.length - 1 : lines.length;
317
- lines.splice(insertIndex, 0, ...block);
318
- touched.add(key);
319
- }
320
- return ensureTrailingNewline(lines.join("\n"));
321
- }
322
- function ensureTrailingNewline(content) {
323
- if (content.length === 0) return "";
324
- if (!content.endsWith("\n")) return `${content}\n`;
325
- return content;
326
- }
327
- function isObjectRecord(value) {
328
- return typeof value === "object" && value !== null && !Array.isArray(value);
329
- }
330
- function normalizeWriteArguments(arg, value) {
331
- if (typeof arg === "string") {
332
- if (typeof value === "undefined") throw new TypeError(`Value for variable "${arg}" must be provided`);
333
- return [[validateKey(arg), formatValueInput(value)]];
334
- }
335
- if (!isObjectRecord(arg)) throw new TypeError("Argument must be a string name or an object of key-value pairs");
336
- const entries = [];
337
- for (const [key, rawValue] of Object.entries(arg)) {
338
- if (typeof rawValue === "undefined") throw new TypeError(`Value for variable "${key}" must be provided`);
339
- entries.push([validateKey(key), formatValueInput(rawValue)]);
340
- }
341
- return entries;
342
- }
343
- function formatValueInput(value) {
344
- if (typeof value === "bigint") return value.toString();
345
- return String(value);
346
- }
347
- function serializeValue(value) {
348
- const normalized = value.replace(/\r\n/g, "\n").replace(/\r/g, "\n");
349
- if (!(normalized.length === 0 || /[\s"'\\#]/.test(normalized) || normalized.includes("\n"))) return normalized;
350
- let result = "\"";
351
- for (const char of normalized) {
352
- if (char === "\"") {
353
- result += "\\\"";
354
- continue;
355
- }
356
- if (char === "\\") {
357
- result += "\\\\";
358
- continue;
359
- }
360
- if (char === "\n") {
361
- result += "\n";
362
- continue;
363
- }
364
- result += char;
365
- }
366
- result += "\"";
367
- return result;
368
- }
369
- function buildAssignmentLines(key, value, style = {}) {
370
- const leading = style.leading ?? "";
371
- const exportPrefix = style.exportPrefix ?? "";
372
- const trailing = style.trailing ?? "";
373
- const segments = serializeValue(value).split("\n");
374
- return segments.map((segment, index) => {
375
- if (index === 0) return `${leading}${exportPrefix}${key}=${segment}${segments.length === 1 ? trailing : ""}`;
376
- if (index === segments.length - 1 && trailing && segments.length > 1) return `${segment}${trailing}`;
377
- return segment;
378
- });
379
- }
380
-
381
- //#endregion
382
- //#region ../files/src/EnvSource.ts
383
- var EnvSource = class {
384
- filePath;
385
- constructor(filePath) {
386
- this.filePath = (0, node_path.resolve)(process.cwd(), filePath);
387
- }
388
- readSync(arg) {
389
- const content = this.readContentSync();
390
- if (typeof arg === "undefined") return get(content);
391
- if (typeof arg === "string") return get(content, arg);
392
- return get(content, arg);
393
- }
394
- async read(arg) {
395
- const content = await this.readContent();
396
- if (typeof arg === "undefined") return get(content);
397
- if (typeof arg === "string") return get(content, arg);
398
- return get(content, arg);
399
- }
400
- writeSync(arg, value) {
401
- const originalContent = this.readContentSync();
402
- let nextContent;
403
- if (typeof arg === "string") nextContent = set(originalContent, arg, value);
404
- else nextContent = set(originalContent, arg);
405
- if (nextContent === originalContent) return;
406
- this.ensureDirectorySync();
407
- (0, node_fs.writeFileSync)(this.filePath, nextContent, "utf8");
408
- }
409
- async write(arg, value) {
410
- const originalContent = await this.readContent();
411
- let nextContent;
412
- if (typeof arg === "string") nextContent = set(originalContent, arg, value);
413
- else nextContent = set(originalContent, arg);
414
- if (nextContent === originalContent) return;
415
- await this.ensureDirectory();
416
- await node_fs.promises.writeFile(this.filePath, nextContent, "utf8");
417
- }
418
- readContentSync() {
419
- try {
420
- return (0, node_fs.readFileSync)(this.filePath, "utf8").replace(/\r\n/g, "\n");
421
- } catch (error) {
422
- if (error.code === "ENOENT") return "";
423
- throw error;
424
- }
425
- }
426
- async readContent() {
427
- try {
428
- return (await node_fs.promises.readFile(this.filePath, "utf8")).replace(/\r\n/g, "\n");
429
- } catch (error) {
430
- if (error.code === "ENOENT") return "";
431
- throw error;
432
- }
433
- }
434
- ensureDirectorySync() {
435
- try {
436
- (0, node_fs.mkdirSync)((0, node_path.dirname)(this.filePath), { recursive: true });
437
- } catch (error) {
438
- if (error.code !== "EEXIST") throw error;
439
- }
440
- }
441
- async ensureDirectory() {
442
- try {
443
- await node_fs.promises.mkdir((0, node_path.dirname)(this.filePath), { recursive: true });
444
- } catch (error) {
445
- if (error.code !== "EEXIST") throw error;
446
- }
447
- }
448
- };
449
-
450
- //#endregion
451
- //#region ../channels/src/channels/default/DefaultEnvChannel.ts
452
- /**
453
- * Default implementation of EnvChannel that works with .env files using envrw
454
- */
455
- var DefaultEnvChannel = class {
456
- envSource;
457
- /**
458
- * Create a new DefaultEnvChannel
459
- * @param filePath - Path to the .env file to manage
460
- */
461
- constructor(filePath) {
462
- this.envSource = new EnvSource(filePath);
463
- }
464
- /**
465
- * Get all environment variables
466
- * @returns Promise that resolves to object containing all environment variable key-value pairs
467
- */
468
- async get() {
469
- return await this.envSource.read();
470
- }
471
- /**
472
- * Set multiple environment variables
473
- * @param values - Object containing key-value pairs to set
474
- * @returns Promise that resolves when the values have been set
475
- */
476
- async set(values) {
477
- await this.envSource.write(values);
478
- }
479
- };
480
-
481
- //#endregion
482
- //#region ../channels/src/channels/dotenv/DotEnvChannel.ts
483
- function isFileNotFound(error) {
484
- return typeof error === "object" && error !== null && "code" in error && error.code === "ENOENT";
485
- }
486
- function normalizeParsed(parsed) {
487
- if (!parsed) return {};
488
- const result = {};
489
- for (const [key, value] of Object.entries(parsed)) {
490
- if (typeof value === "undefined") continue;
491
- result[key] = value;
492
- }
493
- return result;
494
- }
495
- var DotEnvChannel = class {
496
- dotenv;
497
- targetPath;
498
- absolutePath;
499
- encoding;
500
- parseOptions;
501
- envSource;
502
- constructor(dotenv, defaultPath = ".env", getOptions = {}, parseOptions = {}) {
503
- this.dotenv = dotenv;
504
- this.targetPath = (typeof getOptions.path === "string" ? getOptions.path : void 0) ?? defaultPath;
505
- this.absolutePath = (0, node_path.resolve)(process.cwd(), this.targetPath);
506
- this.encoding = getOptions.encoding ?? "utf8";
507
- this.parseOptions = { ...parseOptions };
508
- this.envSource = new EnvSource(this.targetPath);
509
- }
510
- async get() {
511
- try {
512
- const content = await (0, node_fs_promises.readFile)(this.absolutePath, { encoding: this.encoding });
513
- return normalizeParsed(this.dotenv.parse(content, this.parseOptions));
514
- } catch (error) {
515
- if (isFileNotFound(error)) return {};
516
- throw error;
517
- }
518
- }
519
- async set(values) {
520
- await this.envSource.write(values);
521
- const parsed = await this.get();
522
- const mismatches = [];
523
- for (const [key, expected] of Object.entries(values)) {
524
- const actual = parsed[key];
525
- if (actual !== expected) mismatches.push(`${key}=expected(${JSON.stringify(expected)}) actual(${JSON.stringify(actual)})`);
526
- }
527
- if (mismatches.length > 0) throw new Error(`Failed to correctly write values to ${this.targetPath}: ${mismatches.join(", ")}`);
528
- }
529
- getPrimaryPath() {
530
- return this.targetPath;
531
- }
532
- clearCache() {}
533
- };
534
-
535
- //#endregion
536
- //#region ../channels/src/channels/dotenvx/DotEnvXChannel.ts
537
- /**
538
- * Simple DotEnvX implementation of EnvChannel that wraps @dotenvx/dotenvx library
539
- * This is just an API mapping wrapper without caching or complex state management
540
- */
541
- var DotEnvXChannel = class {
542
- dotenvx;
543
- getOptions;
544
- setOptions;
545
- defaultPath;
546
- /**
547
- * Create a new DotEnvXChannel
548
- * @param dotenvx - The dotenvx instance to use
549
- * @param defaultPath - Default path for env files
550
- * @param getOptions - Options for get operations
551
- * @param setOptions - Options for set operations
552
- */
553
- constructor(dotenvx, defaultPath = ".env", getOptions = {}, setOptions = {}) {
554
- this.dotenvx = dotenvx;
555
- this.defaultPath = defaultPath;
556
- this.getOptions = getOptions;
557
- this.setOptions = setOptions;
558
- }
559
- /**
560
- * Get all environment variables
561
- * @returns Promise that resolves to object containing all environment variable key-value pairs
562
- */
563
- async get() {
564
- try {
565
- return this.dotenvx.config({
566
- processEnv: {},
567
- quiet: true,
568
- ignore: ["MISSING_ENV_FILE"],
569
- path: this.defaultPath,
570
- ...this.getOptions
571
- }).parsed || {};
572
- } catch {
573
- return {};
574
- }
575
- }
576
- /**
577
- * Set multiple environment variables
578
- * @param values - Object containing key-value pairs to set
579
- * @returns Promise that resolves when the values have been set
580
- */
581
- async set(values) {
582
- if (!(0, fs.existsSync)(this.defaultPath)) (0, fs.writeFileSync)(this.defaultPath, "", "utf8");
583
- try {
584
- const options = {
585
- path: this.defaultPath,
586
- ...this.setOptions
587
- };
588
- for (const [key, value] of Object.entries(values)) this.dotenvx.set(key, value, options);
589
- } catch (error) {
590
- throw new Error(`Failed to set environment variables: ${error}`);
591
- }
592
- }
593
- /**
594
- * Get the primary path being used for env files
595
- * @returns The primary path
596
- */
597
- getPrimaryPath() {
598
- return this.defaultPath;
599
- }
600
- /**
601
- * Clear any cached data (no-op for this implementation since we don't cache)
602
- */
603
- clearCache() {}
604
- };
605
-
606
- //#endregion
607
- //#region ../channels/src/channels/processenv/ProcessEnvChannel.ts
608
- /**
609
- * EnvChannel implementation that works with process.env
610
- * This channel reads from and writes to the current process environment
611
- */
612
- var ProcessEnvChannel = class {
613
- /**
614
- * Get all environment variables from process.env
615
- * @returns Promise that resolves to object containing all environment variable key-value pairs
616
- */
617
- async get() {
618
- const env = {};
619
- for (const [key, value] of Object.entries(process.env)) if (value !== void 0) env[key] = value;
620
- return env;
621
- }
622
- /**
623
- * Set multiple environment variables in process.env
624
- * @param values - Object containing key-value pairs to set
625
- * @returns Promise that resolves when the values have been set
626
- */
627
- async set(values) {
628
- for (const [key, value] of Object.entries(values)) process.env[key] = value;
629
- }
630
- };
631
-
632
- //#endregion
633
- //#region ../channels/src/resolveChannel.ts
634
- /**
635
- * Resolve channel options into an EnvChannel instance
636
- * @param options - The channel options to resolve
637
- * @param defaultPath - Default path to use for env files (default: ".env")
638
- * @returns An EnvChannel instance
639
- */
640
- function resolveChannel(options, defaultPath = ".env") {
641
- if (options === void 0 || options === "default") return new DefaultEnvChannel(defaultPath);
642
- if (options === "processenv") return new ProcessEnvChannel();
643
- if (typeof options === "object" && options !== null) {
644
- if ("dotenv" in options) {
645
- const { dotenv, get: getOptions = {}, parse: parseOptions = {}, path } = options;
646
- if (!dotenv) throw new Error("Dotenv instance is required for dotenv channel");
647
- const resolvedPath = path ?? defaultPath;
648
- const mergedGetOptions = { ...getOptions };
649
- if (typeof mergedGetOptions.path !== "string") mergedGetOptions.path = resolvedPath;
650
- return new DotEnvChannel(dotenv, resolvedPath, mergedGetOptions, parseOptions ?? {});
651
- }
652
- if ("dotenvx" in options) {
653
- const { dotenvx, get: getOptions = {}, set: setOptions = {} } = options;
654
- if (!dotenvx) throw new Error("DotEnvX instance is required for dotenvx channel");
655
- return new DotEnvXChannel(dotenvx, defaultPath, getOptions, setOptions);
656
- }
657
- if ("process" in options) {
658
- if (options.process && typeof options.process === "object" && "env" in options.process) return new ProcessEnvChannel();
659
- throw new Error("Invalid process object provided to channel config");
660
- }
661
- if ("name" in options) if (options.name === "default") return new DefaultEnvChannel(defaultPath);
662
- else if (options.name === "processenv") return new ProcessEnvChannel();
663
- else throw new Error(`Unknown channel name: ${options.name}`);
664
- }
665
- throw new Error(`Invalid channel options: ${options}`);
666
- }
667
-
668
- //#endregion
669
- //#region ../core/src/schemas/EnvVarSchemaBase.ts
670
- var EnvVarSchemaBase = class {
671
- required;
672
- default;
673
- description;
674
- process;
675
- constructor(input) {
676
- this.required = input?.required ?? true;
677
- this.default = input?.default;
678
- this.description = input?.description;
679
- this.process = input.process;
680
- }
681
- };
682
-
683
- //#endregion
684
- //#region ../core/src/processing/processors.ts
685
- /**
686
- * Default processors for environment variable types.
687
- * Each processor factory returns a function that takes a value and returns T | undefined.
688
- * Returns undefined for empty/null values, throws descriptive errors for invalid values.
689
- */
690
- /**
691
- * Create a string processor - pass through as-is
692
- */
693
- const stringProcessor = () => (value) => {
694
- if (typeof value !== "string") throw new Error("Value must be a string");
695
- return value === "" ? void 0 : value;
696
- };
697
- /**
698
- * Create a number processor using parseFloat
699
- */
700
- const numberProcessor = () => (value) => {
701
- if (typeof value !== "string") throw new Error("Value must be a string");
702
- const trimmed = value.trim();
703
- if (trimmed === "") return;
704
- const parsed = parseFloat(trimmed);
705
- if (isNaN(parsed)) throw new Error(`"${value}" is not a valid number`);
706
- return parsed;
707
- };
708
- /**
709
- * Create a boolean processor from string representation
710
- */
711
- const booleanProcessor = () => (value) => {
712
- if (typeof value !== "string") throw new Error("Value must be a string");
713
- const trimmed = value.trim().toLowerCase();
714
- if (trimmed === "") return;
715
- if (trimmed === "true" || trimmed === "1" || trimmed === "yes" || trimmed === "on") return true;
716
- if (trimmed === "false" || trimmed === "0" || trimmed === "no" || trimmed === "off") return false;
717
- throw new Error(`"${value}" is not a valid boolean. Use: true/false, 1/0, yes/no, or on/off`);
718
- };
719
- /**
720
- * Create an enum processor that validates values against allowed options
721
- */
722
- const enumProcessor = (allowedValues) => (value) => {
723
- if (typeof value !== "string") throw new Error("Value must be a string");
724
- const trimmed = value.trim();
725
- if (trimmed === "") return;
726
- if (!allowedValues.includes(trimmed)) throw new Error(`"${value}" is not a valid option. Must be one of: ${allowedValues.join(", ")}`);
727
- return trimmed;
728
- };
729
- /**
730
- * Default processors map for each environment variable type
731
- */
732
- const processors = {
733
- string: stringProcessor,
734
- number: numberProcessor,
735
- boolean: booleanProcessor,
736
- enum: enumProcessor
737
- };
738
-
739
- //#endregion
740
- //#region ../core/src/schemas/typed/BooleanEnvVarSchema.ts
741
- var BooleanEnvVarSchema = class extends EnvVarSchemaBase {
742
- type = "boolean";
743
- constructor(input = {}) {
744
- super({
745
- ...input,
746
- process: input.process ?? processors.boolean()
747
- });
748
- }
749
- };
750
-
751
- //#endregion
752
- //#region ../core/src/schemas/typed/EnumEnvVarSchema.ts
753
- var EnumEnvVarSchema = class extends EnvVarSchemaBase {
754
- type = "enum";
755
- values;
756
- constructor(input) {
757
- super({
758
- ...input,
759
- process: input.process ?? processors.enum(input.values)
760
- });
761
- this.values = input.values;
762
- }
763
- };
764
-
765
- //#endregion
766
- //#region ../core/src/schemas/typed/NumberEnvVarSchema.ts
767
- var NumberEnvVarSchema = class extends EnvVarSchemaBase {
768
- type = "number";
769
- constructor(input = {}) {
770
- super({
771
- ...input,
772
- process: input.process ?? processors.number()
773
- });
774
- }
775
- };
776
-
777
- //#endregion
778
- //#region ../core/src/schemas/typed/StringEnvVarSchema.ts
779
- var StringEnvVarSchema = class extends EnvVarSchemaBase {
780
- type = "string";
781
- secret;
782
- constructor(input = {}) {
783
- super({
784
- ...input,
785
- process: input.process ?? processors.string()
786
- });
787
- this.secret = input.secret;
788
- }
789
- };
790
-
791
- //#endregion
792
- //#region ../core/src/schemas/EnvVarSchema.ts
793
- /**
794
- * Type guard to check if a value is a EnvVarSchema instance
795
- */
796
- function isEnvVarSchema(value) {
797
- return value instanceof StringEnvVarSchema || value instanceof NumberEnvVarSchema || value instanceof BooleanEnvVarSchema || value instanceof EnumEnvVarSchema;
798
- }
799
-
800
- //#endregion
801
- //#region ../core/src/processing/preprocessors.ts
802
- const defaultBooleanPreprocessorOptions = {
803
- true: [
804
- "on",
805
- "enabled",
806
- "active",
807
- "yes"
808
- ],
809
- false: [
810
- "off",
811
- "disabled",
812
- "inactive",
813
- "no"
814
- ]
815
- };
816
- /**
817
- * Create a string preprocessor - pass through unchanged
818
- */
819
- const stringPreprocessor = () => (value) => value;
820
- /**
821
- * Create a number preprocessor that strips commas and whitespace
822
- */
823
- const numberPreprocessor = () => (value) => {
824
- try {
825
- const cleaned = value.replace(/,/g, "").trim();
826
- if (/^-?\d*\.?\d+$/.test(cleaned)) return cleaned;
827
- } catch {}
828
- return value;
829
- };
830
- /**
831
- * Create a boolean preprocessor that normalizes common truthy/falsy phrases
832
- */
833
- const booleanPreprocessor = (options = defaultBooleanPreprocessorOptions) => {
834
- const normalize = (candidate) => candidate.toLowerCase().trim();
835
- const trueValues = new Set(options.true.map(normalize));
836
- const falseValues = new Set(options.false.map(normalize));
837
- for (const candidate of trueValues) if (falseValues.has(candidate)) throw new Error(`Boolean preprocessor option value "${candidate}" cannot map to both true and false`);
838
- return (value) => {
839
- try {
840
- const cleaned = normalize(value);
841
- if (trueValues.has(cleaned)) return true;
842
- if (falseValues.has(cleaned)) return false;
843
- } catch {}
844
- return value;
845
- };
846
- };
847
- /**
848
- * Create an enum preprocessor - pass through unchanged
849
- */
850
- const enumPreprocessor = () => (value) => value;
851
- /**
852
- * Default preprocessors map for each environment variable type
853
- */
854
- const preprocessors = {
855
- string: stringPreprocessor,
856
- number: numberPreprocessor,
857
- boolean: booleanPreprocessor,
858
- enum: enumPreprocessor
859
- };
860
-
861
- //#endregion
862
- //#region ../core/src/processing/Preprocessor.ts
863
- const optionKeyMap = {
864
- string: "string",
865
- number: "number",
866
- boolean: "boolean",
867
- enum: "enum"
868
- };
869
- const explicitPreprocessorFactories = {
870
- string: stringPreprocessor,
871
- number: numberPreprocessor,
872
- boolean: booleanPreprocessor,
873
- enum: enumPreprocessor
874
- };
875
- function createDefaultPreprocessor(envVarType) {
876
- switch (envVarType) {
877
- case "number": return numberPreprocessor();
878
- case "boolean": return booleanPreprocessor();
879
- default: return;
880
- }
881
- }
882
- function createExplicitPreprocessor(envVarType) {
883
- const factory = explicitPreprocessorFactories[envVarType];
884
- if (!factory) return;
885
- return factory();
886
- }
887
- /**
888
- * Resolve the effective preprocessor for a given environment variable type.
889
- * Respects custom overrides and falls back to built-in defaults (number, boolean).
890
- */
891
- function resolvePreprocessor(envVarType, preprocessorOptions) {
892
- if (envVarType === "boolean") {
893
- const override = preprocessorOptions?.boolean;
894
- if (override === void 0) return createDefaultPreprocessor(envVarType);
895
- if (override === false) return;
896
- if (override === true) return createExplicitPreprocessor(envVarType);
897
- if (typeof override === "function") return override;
898
- return booleanPreprocessor(override);
899
- }
900
- const key = optionKeyMap[envVarType];
901
- const custom = preprocessorOptions?.[key];
902
- if (custom === void 0) return createDefaultPreprocessor(envVarType);
903
- if (custom === false) return;
904
- if (custom === true) return createExplicitPreprocessor(envVarType);
905
- return custom;
906
- }
907
-
908
- //#endregion
909
- //#region ../converters/src/converters/zod/ZodV3Converter.ts
910
- /**
911
- * Zod v3 schema converter implementation
912
- */
913
- var ZodV3Converter = class {
914
- applies(schema) {
915
- return isZodV3Schema(schema);
916
- }
917
- convert(schema) {
918
- return convertFromZodV3Schema(schema);
919
- }
920
- };
921
- /**
922
- * Check if a schema is a Zod v3 schema
923
- */
924
- function isZodV3Schema(schema) {
925
- if (!schema || typeof schema !== "object") return false;
926
- const candidate = schema;
927
- return Boolean(candidate._def && !("_zod" in candidate) && (candidate._def.typeName || typeof candidate.parse === "function"));
928
- }
929
- /**
930
- * Extract definition from Zod v3 schema
931
- */
932
- function getV3Def(schema) {
933
- return schema._def || {};
934
- }
935
- /**
936
- * Get the type name from a Zod v3 definition
937
- */
938
- function getV3TypeName(def) {
939
- return def.typeName || "unknown";
940
- }
941
- /**
942
- * Check if a type is a wrapper type that should be unwrapped
943
- */
944
- function isV3WrapperType(typeName) {
945
- return [
946
- "ZodOptional",
947
- "ZodDefault",
948
- "ZodEffects",
949
- "ZodNullable",
950
- "ZodNullish",
951
- "ZodReadonly",
952
- "ZodBranded",
953
- "ZodCatch"
954
- ].includes(typeName);
955
- }
956
- /**
957
- * Get inner schema from wrapper
958
- */
959
- function getV3InnerSchema(def) {
960
- return def.innerType || def.schema;
961
- }
962
- /**
963
- * Get default value from definition
964
- */
965
- function getV3DefaultValue(def) {
966
- if (def.defaultValue === void 0) return void 0;
967
- return typeof def.defaultValue === "function" ? def.defaultValue() : def.defaultValue;
968
- }
969
- /**
970
- * Extract enum values from schema
971
- */
972
- function extractV3EnumValues(def) {
973
- if (!Array.isArray(def.values)) return void 0;
974
- return def.values.map((v) => String(v));
975
- }
976
- /**
977
- * Get description from schema
978
- */
979
- function getV3Description(schema, def) {
980
- const directDesc = schema.description;
981
- if (typeof directDesc === "string" && directDesc.length > 0) return directDesc;
982
- if (typeof def.description === "string" && def.description.length > 0) return def.description;
983
- }
984
- /**
985
- * Resolve environment variable type from schema
986
- */
987
- function resolveV3EnvVarType(schema) {
988
- const def = getV3Def(schema);
989
- switch (getV3TypeName(def)) {
990
- case "ZodString": return "string";
991
- case "ZodNumber": return "number";
992
- case "ZodBoolean": return "boolean";
993
- case "ZodEnum": return "enum";
994
- default:
995
- if (def.values) return "enum";
996
- return "string";
997
- }
998
- }
999
- function peelV3Schema(schema) {
1000
- let current = schema;
1001
- let required = true;
1002
- let defaultValue = void 0;
1003
- let description = void 0;
1004
- for (let i = 0; i < 20; i++) {
1005
- const def = getV3Def(current);
1006
- const typeName = getV3TypeName(def);
1007
- if (!description) description = getV3Description(current, def);
1008
- if (!isV3WrapperType(typeName)) break;
1009
- if (typeName === "ZodOptional" || typeName === "ZodNullish") required = false;
1010
- if (typeName === "ZodDefault" && defaultValue === void 0) defaultValue = getV3DefaultValue(def);
1011
- const inner = getV3InnerSchema(def);
1012
- if (!inner) break;
1013
- current = inner;
1014
- }
1015
- return {
1016
- schema: current,
1017
- required,
1018
- default: defaultValue,
1019
- description
1020
- };
1021
- }
1022
- /**
1023
- * Create a process function for Zod v3 schemas
1024
- */
1025
- function createV3ProcessFunction(schema, type) {
1026
- return (value) => {
1027
- try {
1028
- let processSchema = schema;
1029
- if (type === "number") processSchema = zod.z.coerce.number();
1030
- else if (type === "boolean") processSchema = zod.z.string().transform((val) => {
1031
- const lower = val.toLowerCase().trim();
1032
- if ([
1033
- "true",
1034
- "1",
1035
- "yes",
1036
- "on",
1037
- "enabled"
1038
- ].includes(lower)) return true;
1039
- if ([
1040
- "false",
1041
- "0",
1042
- "no",
1043
- "off",
1044
- "disabled"
1045
- ].includes(lower)) return false;
1046
- throw new Error(`Expected boolean value, received "${val}"`);
1047
- });
1048
- const result = processSchema.safeParse(value);
1049
- if (result.success) return result.data;
1050
- throw new Error(`Failed to parse value "${value}": ${result.error.issues.map((issue) => issue.message).join("; ")}`);
1051
- } catch (error) {
1052
- const message = error instanceof Error ? error.message : String(error);
1053
- throw new Error(message);
1054
- }
1055
- };
1056
- }
1057
- /**
1058
- * Convert Zod v3 schema to EnvVarSchema
1059
- */
1060
- function convertFromZodV3Schema(schema) {
1061
- const peeled = peelV3Schema(schema);
1062
- const type = resolveV3EnvVarType(peeled.schema);
1063
- const def = getV3Def(peeled.schema);
1064
- switch (type) {
1065
- case "boolean": return new BooleanEnvVarSchema({
1066
- process: createV3ProcessFunction(peeled.schema, "boolean"),
1067
- required: peeled.required,
1068
- default: typeof peeled.default === "boolean" ? peeled.default : void 0,
1069
- description: peeled.description
1070
- });
1071
- case "number": return new NumberEnvVarSchema({
1072
- process: createV3ProcessFunction(peeled.schema, "number"),
1073
- required: peeled.required,
1074
- default: typeof peeled.default === "number" ? peeled.default : void 0,
1075
- description: peeled.description
1076
- });
1077
- case "enum": {
1078
- const values = extractV3EnumValues(def) || [];
1079
- return new EnumEnvVarSchema({
1080
- process: createV3ProcessFunction(peeled.schema, "enum"),
1081
- values,
1082
- required: peeled.required,
1083
- default: typeof peeled.default === "string" ? peeled.default : void 0,
1084
- description: peeled.description
1085
- });
1086
- }
1087
- case "string":
1088
- default: {
1089
- const process$1 = createV3ProcessFunction(peeled.schema, "string");
1090
- const defaultValue = typeof peeled.default === "string" ? peeled.default : void 0;
1091
- return new StringEnvVarSchema({
1092
- process: process$1,
1093
- required: peeled.required,
1094
- default: defaultValue,
1095
- description: peeled.description
1096
- });
1097
- }
1098
- }
1099
- }
1100
-
1101
- //#endregion
1102
- //#region ../converters/src/converters/zod/ZodV4Converter.ts
1103
- /**
1104
- * Zod v4 schema converter implementation
1105
- */
1106
- var ZodV4Converter = class {
1107
- applies(schema) {
1108
- return isZodV4Schema(schema);
1109
- }
1110
- convert(schema) {
1111
- return convertFromZodV4Schema(schema);
1112
- }
1113
- };
1114
- /**
1115
- * Check if a schema is a Zod v4 schema
1116
- */
1117
- function isZodV4Schema(schema) {
1118
- if (!schema || typeof schema !== "object") return false;
1119
- return "_zod" in schema;
1120
- }
1121
- /**
1122
- * Extract definition from Zod v4 schema
1123
- */
1124
- function getV4Def(schema) {
1125
- const container = schema;
1126
- if (container._zod && container._zod.def) return container._zod.def;
1127
- return {};
1128
- }
1129
- /**
1130
- * Get the type name from a Zod v4 definition
1131
- */
1132
- function getV4TypeName(def) {
1133
- return def.type || "unknown";
1134
- }
1135
- /**
1136
- * Check if a type is a wrapper type that should be unwrapped
1137
- */
1138
- function isV4WrapperType(typeName) {
1139
- return [
1140
- "optional",
1141
- "default",
1142
- "catch",
1143
- "readonly",
1144
- "brand",
1145
- "prefault",
1146
- "nullable",
1147
- "nullish"
1148
- ].includes(typeName);
1149
- }
1150
- /**
1151
- * Get inner schema from wrapper
1152
- */
1153
- function getV4InnerSchema(def) {
1154
- return def.innerType || def.schema || def.in || def.inner;
1155
- }
1156
- /**
1157
- * Get default value from definition
1158
- */
1159
- function getV4DefaultValue(def) {
1160
- if (def.defaultValue !== void 0) return typeof def.defaultValue === "function" ? def.defaultValue() : def.defaultValue;
1161
- if (def.prefaultValue !== void 0) return typeof def.prefaultValue === "function" ? def.prefaultValue() : def.prefaultValue;
1162
- }
1163
- /**
1164
- * Extract enum values from schema
1165
- */
1166
- function extractV4EnumValues(def) {
1167
- if (Array.isArray(def.values)) return def.values.map((v) => String(v));
1168
- if (def.entries && typeof def.entries === "object") return Object.values(def.entries).map((v) => String(v));
1169
- }
1170
- /**
1171
- * Get description from schema
1172
- */
1173
- function getV4Description(schema, def) {
1174
- const directDesc = schema.description;
1175
- if (typeof directDesc === "string" && directDesc.length > 0) return directDesc;
1176
- if (typeof def.description === "string" && def.description.length > 0) return def.description;
1177
- const metaFn = schema.meta;
1178
- if (typeof metaFn === "function") {
1179
- const meta = metaFn.call(schema);
1180
- if (meta?.description && typeof meta.description === "string") return meta.description.trim();
1181
- }
1182
- }
1183
- /**
1184
- * Resolve environment variable type from schema
1185
- */
1186
- function resolveV4EnvVarType(schema) {
1187
- const def = getV4Def(schema);
1188
- switch (getV4TypeName(def)) {
1189
- case "string": return "string";
1190
- case "number":
1191
- case "int": return "number";
1192
- case "boolean":
1193
- case "stringbool": return "boolean";
1194
- case "pipe":
1195
- if (def.in && def.out) {
1196
- const inType = resolveV4EnvVarType(def.in);
1197
- const outType = resolveV4EnvVarType(def.out);
1198
- if (inType === "string" && outType === "boolean") return "boolean";
1199
- }
1200
- return "string";
1201
- case "enum": return "enum";
1202
- default:
1203
- if (def.values || def.entries) return "enum";
1204
- return "string";
1205
- }
1206
- }
1207
- function peelV4Schema(schema) {
1208
- let current = schema;
1209
- let required = true;
1210
- let defaultValue = void 0;
1211
- let description = void 0;
1212
- for (let i = 0; i < 20; i++) {
1213
- const def = getV4Def(current);
1214
- const typeName = getV4TypeName(def);
1215
- if (!description) description = getV4Description(current, def);
1216
- if (!isV4WrapperType(typeName)) if (typeName === "pipe" && def.in && def.out) {
1217
- const inType = resolveV4EnvVarType(def.in);
1218
- const outType = resolveV4EnvVarType(def.out);
1219
- if (inType === "string" && outType === "boolean") break;
1220
- } else break;
1221
- if (typeName === "optional" || typeName === "nullish") required = false;
1222
- if ((typeName === "default" || typeName === "prefault") && defaultValue === void 0) defaultValue = getV4DefaultValue(def);
1223
- const inner = getV4InnerSchema(def);
1224
- if (!inner) break;
1225
- current = inner;
1226
- }
1227
- return {
1228
- schema: current,
1229
- required,
1230
- default: defaultValue,
1231
- description
1232
- };
1233
- }
1234
- /**
1235
- * Create a process function for Zod v4 schemas
1236
- */
1237
- function createV4ProcessFunction(schema, type, originalSchema) {
1238
- return (value) => {
1239
- try {
1240
- let processSchema = schema;
1241
- const def = getV4Def(schema);
1242
- const typeName = getV4TypeName(def);
1243
- if (typeName === "stringbool" || typeName === "pipe" && def.in && def.out && resolveV4EnvVarType(def.in) === "string" && resolveV4EnvVarType(def.out) === "boolean") processSchema = originalSchema;
1244
- else if (type === "number") processSchema = zod.z.coerce.number();
1245
- else if (type === "boolean") processSchema = zod.z.stringbool();
1246
- const result = zod_v4_core.safeParse(processSchema, value);
1247
- if (result.success) return result.data;
1248
- throw new Error(`Failed to parse value "${value}": ${result.error.issues.map((issue) => issue.message).join("; ")}`);
1249
- } catch (error) {
1250
- const message = error instanceof Error ? error.message : String(error);
1251
- throw new Error(message);
1252
- }
1253
- };
1254
- }
1255
- /**
1256
- * Convert Zod v4 schema to EnvVarSchema
1257
- */
1258
- function convertFromZodV4Schema(schema) {
1259
- const peeled = peelV4Schema(schema);
1260
- const type = resolveV4EnvVarType(peeled.schema);
1261
- const def = getV4Def(peeled.schema);
1262
- switch (type) {
1263
- case "boolean": return new BooleanEnvVarSchema({
1264
- process: createV4ProcessFunction(peeled.schema, "boolean", schema),
1265
- required: peeled.required,
1266
- default: typeof peeled.default === "boolean" ? peeled.default : void 0,
1267
- description: peeled.description
1268
- });
1269
- case "number": return new NumberEnvVarSchema({
1270
- process: createV4ProcessFunction(peeled.schema, "number", schema),
1271
- required: peeled.required,
1272
- default: typeof peeled.default === "number" ? peeled.default : void 0,
1273
- description: peeled.description
1274
- });
1275
- case "enum": {
1276
- const values = extractV4EnumValues(def) || [];
1277
- return new EnumEnvVarSchema({
1278
- process: createV4ProcessFunction(peeled.schema, "enum", schema),
1279
- values,
1280
- required: peeled.required,
1281
- default: typeof peeled.default === "string" ? peeled.default : void 0,
1282
- description: peeled.description
1283
- });
1284
- }
1285
- case "string":
1286
- default: {
1287
- const process$1 = createV4ProcessFunction(peeled.schema, "string", schema);
1288
- const defaultValue = typeof peeled.default === "string" ? peeled.default : void 0;
1289
- return new StringEnvVarSchema({
1290
- process: process$1,
1291
- required: peeled.required,
1292
- default: defaultValue,
1293
- description: peeled.description
1294
- });
1295
- }
1296
- }
1297
- }
1298
-
1299
- //#endregion
1300
- //#region ../converters/src/converters/joi/JoiConverter.ts
1301
- /**
1302
- * Joi schema converter implementation
1303
- */
1304
- var JoiConverter = class {
1305
- applies(schema) {
1306
- return isJoiSchema(schema);
1307
- }
1308
- convert(schema) {
1309
- return convertFromJoiSchema(schema);
1310
- }
1311
- };
1312
- /**
1313
- * Check if a schema is a Joi schema using the official API
1314
- */
1315
- function isJoiSchema(schema) {
1316
- if (!schema || typeof schema !== "object") return false;
1317
- const candidate = schema;
1318
- if (!(typeof candidate.describe === "function" && typeof candidate.validate === "function")) return false;
1319
- if (candidate.isJoi === true) return true;
1320
- const hasAsyncVariant = typeof candidate.validateAsync === "function";
1321
- const hasRoot = typeof candidate.$_root === "object" && candidate.$_root !== null;
1322
- const hasFlags = typeof candidate._flags === "object" && candidate._flags !== null;
1323
- return hasAsyncVariant || hasRoot || hasFlags;
1324
- }
1325
- /**
1326
- * Get description from Joi schema using public API first, internal as fallback
1327
- */
1328
- function getJoiDescription(schema) {
1329
- try {
1330
- return schema.describe()?.flags?.description;
1331
- } catch {
1332
- return schema._flags?.description;
1333
- }
1334
- }
1335
- /**
1336
- * Check if schema is required using public API first, internal as fallback
1337
- */
1338
- function isJoiRequired(schema) {
1339
- try {
1340
- const presence = schema.describe()?.flags?.presence;
1341
- if (presence === "required") return true;
1342
- if (presence === "optional") return false;
1343
- return presence === void 0;
1344
- } catch {
1345
- const flags = schema._flags;
1346
- if (flags?.presence === "required") return true;
1347
- if (flags?.presence === "optional") return false;
1348
- return true;
1349
- }
1350
- }
1351
- /**
1352
- * Get default value from Joi schema using public API first, internal as fallback
1353
- */
1354
- function getJoiDefaultValue(schema) {
1355
- try {
1356
- const defaultValue = schema.describe()?.flags?.default;
1357
- return typeof defaultValue === "function" ? defaultValue() : defaultValue;
1358
- } catch {
1359
- const flags = schema._flags;
1360
- if (flags?.default !== void 0) {
1361
- const defaultValue = flags.default;
1362
- return typeof defaultValue === "function" ? defaultValue() : defaultValue;
1363
- }
1364
- return;
1365
- }
1366
- }
1367
- /**
1368
- * Get valid values for enum-like schemas using public API first, internal as fallback
1369
- */
1370
- function getJoiValidValues(schema) {
1371
- const values = [];
1372
- let isOnlySchema = false;
1373
- try {
1374
- const description = schema.describe();
1375
- if (description?.allow && Array.isArray(description.allow)) values.push(...description.allow);
1376
- isOnlySchema = description?.flags?.only === true;
1377
- } catch {
1378
- if (schema._valids?._values) values.push(...Array.from(schema._valids._values));
1379
- isOnlySchema = schema._flags?.only === true;
1380
- }
1381
- if (isOnlySchema && values.length > 0) return values.map((v) => String(v));
1382
- }
1383
- /**
1384
- * Resolve environment variable type from Joi schema using public API first, internal as fallback
1385
- */
1386
- function resolveJoiEnvVarType(schema) {
1387
- let type;
1388
- const exposedSchema = schema;
1389
- try {
1390
- type = schema.describe()?.type;
1391
- } catch {
1392
- type = exposedSchema._type || schema.type;
1393
- }
1394
- const validValues = getJoiValidValues(schema);
1395
- if (validValues && validValues.length > 0) return "enum";
1396
- switch (type) {
1397
- case "string": return "string";
1398
- case "number": return "number";
1399
- case "boolean": return "boolean";
1400
- default: return "string";
1401
- }
1402
- }
1403
- /**
1404
- * Create a process function for Joi schemas
1405
- */
1406
- function createJoiProcessFunction(schema, type) {
1407
- return (value) => {
1408
- try {
1409
- let processValue$1 = value;
1410
- if (type === "number") {
1411
- const num = Number(value);
1412
- if (Number.isNaN(num)) throw new Error(`Expected number, received "${value}"`);
1413
- processValue$1 = num;
1414
- } else if (type === "boolean") {
1415
- const lower = value.toLowerCase().trim();
1416
- if ([
1417
- "true",
1418
- "1",
1419
- "yes",
1420
- "on",
1421
- "enabled"
1422
- ].includes(lower)) processValue$1 = true;
1423
- else if ([
1424
- "false",
1425
- "0",
1426
- "no",
1427
- "off",
1428
- "disabled"
1429
- ].includes(lower)) processValue$1 = false;
1430
- else throw new Error(`Expected boolean value, received "${value}"`);
1431
- }
1432
- const result = schema.validate(processValue$1, { convert: true });
1433
- if (result.error) {
1434
- const message = result.error.details ? result.error.details.map((d) => d.message).join("; ") : result.error.message || String(result.error);
1435
- throw new Error(`Validation failed: ${message}`);
1436
- }
1437
- return result.value;
1438
- } catch (error) {
1439
- const message = error instanceof Error ? error.message : String(error);
1440
- throw new Error(message);
1441
- }
1442
- };
1443
- }
1444
- /**
1445
- * Convert Joi schema to EnvVarSchema
1446
- */
1447
- function convertFromJoiSchema(schema) {
1448
- const type = resolveJoiEnvVarType(schema);
1449
- const required = isJoiRequired(schema);
1450
- const defaultValue = getJoiDefaultValue(schema);
1451
- const description = getJoiDescription(schema);
1452
- switch (type) {
1453
- case "boolean": return new BooleanEnvVarSchema({
1454
- process: createJoiProcessFunction(schema, "boolean"),
1455
- required,
1456
- default: typeof defaultValue === "boolean" ? defaultValue : void 0,
1457
- description
1458
- });
1459
- case "number": return new NumberEnvVarSchema({
1460
- process: createJoiProcessFunction(schema, "number"),
1461
- required,
1462
- default: typeof defaultValue === "number" ? defaultValue : void 0,
1463
- description
1464
- });
1465
- case "enum": {
1466
- const values = getJoiValidValues(schema) || [];
1467
- return new EnumEnvVarSchema({
1468
- process: createJoiProcessFunction(schema, "enum"),
1469
- values,
1470
- required,
1471
- default: typeof defaultValue === "string" ? defaultValue : void 0,
1472
- description
1473
- });
1474
- }
1475
- case "string":
1476
- default: return new StringEnvVarSchema({
1477
- process: createJoiProcessFunction(schema, "string"),
1478
- required,
1479
- default: typeof defaultValue === "string" ? defaultValue : void 0,
1480
- description
1481
- });
1482
- }
1483
- }
1484
-
1485
- //#endregion
1486
- //#region ../converters/src/converters/superstruct/SuperstructConverter.ts
1487
- /**
1488
- * Superstruct schema converter implementation
1489
- */
1490
- var SuperstructConverter = class {
1491
- applies(schema) {
1492
- return isSuperstructSchema(schema);
1493
- }
1494
- convert(schema) {
1495
- return convertFromSuperstruct(schema);
1496
- }
1497
- };
1498
- /**
1499
- * Detect if a value looks like a Superstruct Struct instance
1500
- */
1501
- function isSuperstructSchema(value) {
1502
- if (!value || typeof value !== "object") return false;
1503
- const candidate = value;
1504
- return typeof candidate.type === "string" && typeof candidate.validate === "function" && typeof candidate.create === "function";
1505
- }
1506
- /**
1507
- * Convert a Superstruct schema to an EnvVarSchema
1508
- */
1509
- function convertFromSuperstruct(schema) {
1510
- const resolvedType = resolveSuperstructEnvVarType(schema);
1511
- const required = isStructRequired(schema);
1512
- const description = getStructDescription(schema);
1513
- const defaultValue = getStructDefault(schema);
1514
- if (resolvedType === "enum") {
1515
- const values = extractEnumValues(schema);
1516
- if (!values || values.length === 0) return createStringEnvVarSchema(schema, required, defaultValue, description);
1517
- const readonlyValues = values;
1518
- return new EnumEnvVarSchema({
1519
- process: createSuperstructProcessFunction(schema, "enum"),
1520
- values: readonlyValues,
1521
- required,
1522
- default: typeof defaultValue === "string" ? defaultValue : void 0,
1523
- description
1524
- });
1525
- }
1526
- if (resolvedType === "boolean") return new BooleanEnvVarSchema({
1527
- process: createSuperstructProcessFunction(schema, "boolean"),
1528
- required,
1529
- default: typeof defaultValue === "boolean" ? defaultValue : void 0,
1530
- description
1531
- });
1532
- if (resolvedType === "number") return new NumberEnvVarSchema({
1533
- process: createSuperstructProcessFunction(schema, "number"),
1534
- required,
1535
- default: typeof defaultValue === "number" ? defaultValue : void 0,
1536
- description
1537
- });
1538
- return createStringEnvVarSchema(schema, required, defaultValue, description);
1539
- }
1540
- function createStringEnvVarSchema(schema, required, defaultValue, description) {
1541
- return new StringEnvVarSchema({
1542
- process: createSuperstructProcessFunction(schema, "string"),
1543
- required,
1544
- default: typeof defaultValue === "string" ? defaultValue : void 0,
1545
- description
1546
- });
1547
- }
1548
- function resolveSuperstructEnvVarType(schema) {
1549
- switch (getStructType(schema)) {
1550
- case "boolean": return "boolean";
1551
- case "number":
1552
- case "integer": return "number";
1553
- case "enums": return "enum";
1554
- case "literal": return typeof schema.schema === "string" ? "enum" : "string";
1555
- default: return "string";
1556
- }
1557
- }
1558
- function getStructType(schema) {
1559
- const typeValue = schema.type;
1560
- return typeof typeValue === "string" ? typeValue : "unknown";
1561
- }
1562
- function extractEnumValues(schema) {
1563
- const typeName = getStructType(schema);
1564
- if (typeName === "enums") {
1565
- const structSchema = schema.schema;
1566
- if (structSchema && typeof structSchema === "object") {
1567
- const rawValues = Object.values(structSchema);
1568
- if (rawValues.every((value) => typeof value === "string")) return rawValues;
1569
- }
1570
- }
1571
- if (typeName === "literal") {
1572
- const value = schema.schema;
1573
- if (typeof value === "string") return [value];
1574
- }
1575
- }
1576
- function isStructRequired(schema) {
1577
- try {
1578
- const [error] = schema.validate(void 0);
1579
- return !!error;
1580
- } catch {
1581
- return true;
1582
- }
1583
- }
1584
- function getStructDefault(schema) {
1585
- try {
1586
- const [error, value] = schema.validate(void 0, { coerce: true });
1587
- if (!error && value !== void 0) return value;
1588
- } catch {}
1589
- }
1590
- function getStructDescription(schema) {
1591
- const structSchema = schema.schema;
1592
- if (structSchema && typeof structSchema === "object" && typeof structSchema.description === "string") return structSchema.description;
1593
- if (typeof schema.description === "string") return schema.description;
1594
- }
1595
- function createSuperstructProcessFunction(schema, type) {
1596
- return (value) => {
1597
- if (typeof value !== "string") throw new Error("Value must be a string");
1598
- let candidate = value;
1599
- if (type === "number") {
1600
- const trimmed = value.trim();
1601
- if (trimmed === "") candidate = void 0;
1602
- else {
1603
- const parsed = Number(trimmed);
1604
- if (Number.isNaN(parsed) || !Number.isFinite(parsed)) throw new Error(`"${value}" is not a valid number`);
1605
- candidate = parsed;
1606
- }
1607
- } else if (type === "boolean") {
1608
- const trimmed = value.trim().toLowerCase();
1609
- if (trimmed === "") candidate = void 0;
1610
- else if ([
1611
- "true",
1612
- "1",
1613
- "yes",
1614
- "on",
1615
- "enabled"
1616
- ].includes(trimmed)) candidate = true;
1617
- else if ([
1618
- "false",
1619
- "0",
1620
- "no",
1621
- "off",
1622
- "disabled"
1623
- ].includes(trimmed)) candidate = false;
1624
- else throw new Error(`"${value}" is not a valid boolean. Use: true/false, 1/0, yes/no, on/off, or enabled/disabled`);
1625
- } else if (value === "") candidate = void 0;
1626
- const [error, result] = schema.validate(candidate, { coerce: true });
1627
- if (error) throw new Error(error.message);
1628
- return result;
1629
- };
1630
- }
1631
-
1632
- //#endregion
1633
- //#region ../converters/src/converters.ts
1634
- /**
1635
- * Registry of available schema converters
1636
- */
1637
- const converters = [
1638
- new ZodV4Converter(),
1639
- new ZodV3Converter(),
1640
- new JoiConverter(),
1641
- new SuperstructConverter()
1642
- ];
1643
-
1644
- //#endregion
1645
- //#region ../models/src/resolve.ts
1646
- /**
1647
- * Resolve any supported schema to a EnvVarSchema.
1648
- *
1649
- * This is the main entry point for converting external schemas
1650
- * (like Zod schemas) to envcredible's internal schema format.
1651
- * If the input is already a EnvVarSchema, it returns it directly.
1652
- *
1653
- * @param schema - The schema to convert (e.g., Zod v3/v4 schema or EnvVarSchema)
1654
- * @returns EnvVarSchema that can be used with envcredible
1655
- * @throws Error if no converter can handle the schema
1656
- */
1657
- function resolveSchema(schema) {
1658
- if (isEnvVarSchema(schema)) return schema;
1659
- for (const converter of converters) if (converter.applies(schema)) return converter.convert(schema);
1660
- throw new Error(`No converter found for schema. Supported types: Zod v3, Zod v4, Joi, Superstruct, EnvVarSchema. Received: ${typeof schema}`);
1661
- }
1662
- /**
1663
- * Resolve mixed schema map (Zod schemas or EnvVarSchema) to pure EnvVarSchema map.
1664
- *
1665
- * This function takes a map where values can be:
1666
- * - Zod v3 schemas
1667
- * - Zod v4 schemas
1668
- * - Already resolved EnvVarSchema instances
1669
- *
1670
- * And converts everything to EnvVarSchema instances that can be used throughout envcredible.
1671
- *
1672
- * @param schemas - Object mapping environment variable names to various schema types
1673
- * @returns Record mapping env var names to EnvVarSchema instances
1674
- */
1675
- function resolveSchemas(schemas) {
1676
- const resolved = {};
1677
- for (const [key, schema] of Object.entries(schemas)) try {
1678
- resolved[key] = resolveSchema(schema);
1679
- } catch (error) {
1680
- const message = error instanceof Error ? error.message : String(error);
1681
- throw new Error(`Failed to resolve schema for environment variable "${key}": ${message}`);
1682
- }
1683
- return resolved;
1684
- }
1685
-
1686
- //#endregion
1687
- //#region ../models/src/EnvModel.ts
1688
- /**
1689
- * Environment variable specification container
1690
- * Encapsulates schemas and preprocessor configuration
1691
- */
1692
- var EnvModel = class {
1693
- /**
1694
- * Resolved environment variable schemas
1695
- */
1696
- schemas;
1697
- /**
1698
- * Preprocessing configuration for environment variable types
1699
- */
1700
- preprocess;
1701
- /**
1702
- * Create an EnvModel instance from options
1703
- * @param options - Specification options
1704
- */
1705
- constructor(options) {
1706
- this.schemas = resolveSchemas(options.schemas);
1707
- this.preprocess = this.resolvePreprocessors(options.preprocess);
1708
- }
1709
- /**
1710
- * Resolve preprocessor configuration from options
1711
- * @param config - Preprocessor configuration (true, false, or partial object)
1712
- * @returns Resolved preprocessors object
1713
- */
1714
- resolvePreprocessors(config) {
1715
- if (config === false) return {
1716
- string: false,
1717
- number: false,
1718
- boolean: false,
1719
- enum: false
1720
- };
1721
- if (config === true || config === void 0) return {};
1722
- return { ...config };
1723
- }
1724
- };
1725
-
1726
- //#endregion
1727
- //#region ../models/src/model.ts
1728
- /**
1729
- * Create an environment variable model
1730
- *
1731
- * Sugar utility for creating EnvModel instances with full type inference
1732
- *
1733
- * @param options - Model options
1734
- * @returns EnvModel instance with inferred types
1735
- *
1736
- * @example
1737
- * ```typescript
1738
- * import { define, s } from "@e-n-v/models";
1739
- *
1740
- * export default define({
1741
- * schemas: {
1742
- * PORT: s.number({ default: 3000 }),
1743
- * DATABASE_URL: s.string(),
1744
- * DEBUG: s.boolean({ default: false })
1745
- * },
1746
- * preprocess: true
1747
- * });
1748
- * ```
1749
- */
1750
- function define(options) {
1751
- return new EnvModel(options);
1752
- }
1
+ const require_chunk = require('./chunk-pbleEpgJ.cjs');
2
+ const require_resolveChannel = require('./resolveChannel-CjAuxy3p.cjs');
3
+ const require_src = require('./src-meUnCASg.cjs');
4
+ const require_src$1 = require('./src-XjL5cyPG.cjs');
5
+ let node_path = require("node:path");
6
+ node_path = require_chunk.__toESM(node_path);
7
+ let node_url = require("node:url");
8
+ node_url = require_chunk.__toESM(node_url);
9
+ let node_process = require("node:process");
10
+ node_process = require_chunk.__toESM(node_process);
11
+ let __clack_core = require("@clack/core");
12
+ __clack_core = require_chunk.__toESM(__clack_core);
13
+ let picocolors = require("picocolors");
14
+ picocolors = require_chunk.__toESM(picocolors);
15
+ let node_readline = require("node:readline");
16
+ node_readline = require_chunk.__toESM(node_readline);
1753
17
 
1754
- //#endregion
1755
18
  //#region ../prompt/src/options/defaults.ts
1756
- var defaults_exports = /* @__PURE__ */ __export({
19
+ var defaults_exports = /* @__PURE__ */ require_chunk.__export({
1757
20
  ENV_PATH: () => ENV_PATH,
1758
21
  SECRET_PATTERNS: () => SECRET_PATTERNS,
1759
22
  TRUNCATE_LENGTH: () => TRUNCATE_LENGTH
@@ -1764,7 +27,7 @@ const SECRET_PATTERNS = Object.freeze([
1764
27
  /password/i,
1765
28
  /passphrase/i,
1766
29
  /secret/i,
1767
- /token/i,
30
+ /(?<!expires[_-]?in[_-]?)token(?![_-]?(?:expires|expiry|expiration|ttl|lifetime|duration|age|max[_-]?age|validity))/i,
1768
31
  /api[_-]?key/i,
1769
32
  /client[_-]?secret/i,
1770
33
  /private[_-]?key/i,
@@ -2251,28 +514,18 @@ function processValue(envKey, value, schema, preprocess) {
2251
514
  };
2252
515
  const activePreprocessor = (() => {
2253
516
  if (preprocess === false) return;
2254
- if (preprocess === true) return resolvePreprocessor(schema.type, { [schema.type]: true });
517
+ if (preprocess === true) return require_src.resolvePreprocessor(schema.type, { [schema.type]: true });
2255
518
  if (typeof preprocess === "function") return preprocess;
2256
- return resolvePreprocessor(schema.type);
519
+ return require_src.resolvePreprocessor(schema.type);
2257
520
  })();
2258
521
  const processedValue = activePreprocessor ? activePreprocessor(value) : value;
2259
- if (schema.type === "boolean" && typeof processedValue === "boolean") return {
2260
- value: processedValue,
2261
- rawValue: value,
2262
- isValid: true
2263
- };
2264
- if (schema.type === "number" && typeof processedValue === "number") return {
2265
- value: processedValue,
2266
- rawValue: value,
2267
- isValid: true
2268
- };
2269
- if (typeof processedValue === "string") return {
2270
- value: schema.process(processedValue),
2271
- rawValue: value,
2272
- isValid: true
2273
- };
522
+ let stringValue;
523
+ if (typeof processedValue === "boolean") stringValue = String(processedValue);
524
+ else if (typeof processedValue === "number") stringValue = String(processedValue);
525
+ else if (typeof processedValue === "string") stringValue = processedValue;
526
+ else stringValue = value;
2274
527
  return {
2275
- value: schema.process(value),
528
+ value: schema.process(stringValue),
2276
529
  rawValue: value,
2277
530
  isValid: true
2278
531
  };
@@ -3665,10 +1918,10 @@ function createPrompt({ key, schema, currentValue, theme, truncate, shouldMask,
3665
1918
  const booleanOverride = preprocessors$1?.boolean;
3666
1919
  let booleanPreprocess;
3667
1920
  if (booleanOverride === void 0) booleanPreprocess = void 0;
3668
- else if (booleanOverride === true) booleanPreprocess = booleanPreprocessor();
1921
+ else if (booleanOverride === true) booleanPreprocess = require_src.preprocessors.boolean();
3669
1922
  else if (booleanOverride === false) booleanPreprocess = false;
3670
1923
  else if (typeof booleanOverride === "function") booleanPreprocess = booleanOverride;
3671
- else booleanPreprocess = booleanPreprocessor(booleanOverride);
1924
+ else booleanPreprocess = require_src.preprocessors.boolean(booleanOverride);
3672
1925
  return new EnvBooleanPrompt(schema, {
3673
1926
  ...baseOptions,
3674
1927
  current: currentValue,
@@ -3863,7 +2116,7 @@ async function prompt(modelOrOptions, interactiveOptions) {
3863
2116
  let schemas;
3864
2117
  let preprocessConfig;
3865
2118
  let finalOptions;
3866
- if (modelOrOptions instanceof EnvModel) {
2119
+ if (modelOrOptions instanceof require_src$1.EnvModel) {
3867
2120
  const model = modelOrOptions;
3868
2121
  finalOptions = interactiveOptions || {};
3869
2122
  schemas = model.schemas;
@@ -3872,7 +2125,7 @@ async function prompt(modelOrOptions, interactiveOptions) {
3872
2125
  const options = modelOrOptions;
3873
2126
  finalOptions = options;
3874
2127
  if (options.schemas) {
3875
- schemas = resolveSchemas(options.schemas);
2128
+ schemas = require_src$1.resolveSchemas(options.schemas);
3876
2129
  preprocessConfig = options.preprocess;
3877
2130
  } else throw new Error("Either provide a model or schemas in options");
3878
2131
  }
@@ -3882,7 +2135,7 @@ async function prompt(modelOrOptions, interactiveOptions) {
3882
2135
  const secrets = finalOptions.secrets ?? SECRET_PATTERNS;
3883
2136
  const input = node_process.stdin;
3884
2137
  const output = node_process.stdout;
3885
- const channel = isEnvChannel(finalOptions.channel) ? finalOptions.channel : resolveChannel(finalOptions.channel, path);
2138
+ const channel = isEnvChannel(finalOptions.channel) ? finalOptions.channel : require_resolveChannel.resolveChannel(finalOptions.channel, path);
3886
2139
  const theme = resolveTheme(finalOptions.theme);
3887
2140
  await new Session({
3888
2141
  schemas,
@@ -3898,201 +2151,15 @@ async function prompt(modelOrOptions, interactiveOptions) {
3898
2151
  }
3899
2152
 
3900
2153
  //#endregion
3901
- Object.defineProperty(exports, 'BooleanEnvVarSchema', {
3902
- enumerable: true,
3903
- get: function () {
3904
- return BooleanEnvVarSchema;
3905
- }
3906
- });
3907
- Object.defineProperty(exports, 'DefaultEnvChannel', {
3908
- enumerable: true,
3909
- get: function () {
3910
- return DefaultEnvChannel;
3911
- }
3912
- });
3913
- Object.defineProperty(exports, 'DotEnvChannel', {
3914
- enumerable: true,
3915
- get: function () {
3916
- return DotEnvChannel;
3917
- }
3918
- });
3919
- Object.defineProperty(exports, 'DotEnvXChannel', {
3920
- enumerable: true,
3921
- get: function () {
3922
- return DotEnvXChannel;
3923
- }
3924
- });
3925
- Object.defineProperty(exports, 'EnumEnvVarSchema', {
3926
- enumerable: true,
3927
- get: function () {
3928
- return EnumEnvVarSchema;
3929
- }
3930
- });
3931
- Object.defineProperty(exports, 'EnvModel', {
3932
- enumerable: true,
3933
- get: function () {
3934
- return EnvModel;
3935
- }
3936
- });
3937
- Object.defineProperty(exports, 'EnvSource', {
3938
- enumerable: true,
3939
- get: function () {
3940
- return EnvSource;
3941
- }
3942
- });
3943
- Object.defineProperty(exports, 'EnvVarSchemaBase', {
3944
- enumerable: true,
3945
- get: function () {
3946
- return EnvVarSchemaBase;
3947
- }
3948
- });
3949
- Object.defineProperty(exports, 'NumberEnvVarSchema', {
3950
- enumerable: true,
3951
- get: function () {
3952
- return NumberEnvVarSchema;
3953
- }
3954
- });
3955
- Object.defineProperty(exports, 'ProcessEnvChannel', {
3956
- enumerable: true,
3957
- get: function () {
3958
- return ProcessEnvChannel;
3959
- }
3960
- });
3961
- Object.defineProperty(exports, 'StringEnvVarSchema', {
3962
- enumerable: true,
3963
- get: function () {
3964
- return StringEnvVarSchema;
3965
- }
3966
- });
3967
- Object.defineProperty(exports, '__export', {
3968
- enumerable: true,
3969
- get: function () {
3970
- return __export;
3971
- }
3972
- });
3973
- Object.defineProperty(exports, '__toESM', {
3974
- enumerable: true,
3975
- get: function () {
3976
- return __toESM;
3977
- }
3978
- });
3979
- Object.defineProperty(exports, 'booleanPreprocessor', {
3980
- enumerable: true,
3981
- get: function () {
3982
- return booleanPreprocessor;
3983
- }
3984
- });
3985
- Object.defineProperty(exports, 'booleanProcessor', {
3986
- enumerable: true,
3987
- get: function () {
3988
- return booleanProcessor;
3989
- }
3990
- });
3991
2154
  Object.defineProperty(exports, 'defaults_exports', {
3992
2155
  enumerable: true,
3993
2156
  get: function () {
3994
2157
  return defaults_exports;
3995
2158
  }
3996
2159
  });
3997
- Object.defineProperty(exports, 'define', {
3998
- enumerable: true,
3999
- get: function () {
4000
- return define;
4001
- }
4002
- });
4003
- Object.defineProperty(exports, 'enumPreprocessor', {
4004
- enumerable: true,
4005
- get: function () {
4006
- return enumPreprocessor;
4007
- }
4008
- });
4009
- Object.defineProperty(exports, 'enumProcessor', {
4010
- enumerable: true,
4011
- get: function () {
4012
- return enumProcessor;
4013
- }
4014
- });
4015
- Object.defineProperty(exports, 'get', {
4016
- enumerable: true,
4017
- get: function () {
4018
- return get;
4019
- }
4020
- });
4021
- Object.defineProperty(exports, 'isEnvVarSchema', {
4022
- enumerable: true,
4023
- get: function () {
4024
- return isEnvVarSchema;
4025
- }
4026
- });
4027
- Object.defineProperty(exports, 'numberPreprocessor', {
4028
- enumerable: true,
4029
- get: function () {
4030
- return numberPreprocessor;
4031
- }
4032
- });
4033
- Object.defineProperty(exports, 'numberProcessor', {
4034
- enumerable: true,
4035
- get: function () {
4036
- return numberProcessor;
4037
- }
4038
- });
4039
- Object.defineProperty(exports, 'preprocessors', {
4040
- enumerable: true,
4041
- get: function () {
4042
- return preprocessors;
4043
- }
4044
- });
4045
- Object.defineProperty(exports, 'processors', {
4046
- enumerable: true,
4047
- get: function () {
4048
- return processors;
4049
- }
4050
- });
4051
2160
  Object.defineProperty(exports, 'prompt', {
4052
2161
  enumerable: true,
4053
2162
  get: function () {
4054
2163
  return prompt;
4055
2164
  }
4056
- });
4057
- Object.defineProperty(exports, 'resolveChannel', {
4058
- enumerable: true,
4059
- get: function () {
4060
- return resolveChannel;
4061
- }
4062
- });
4063
- Object.defineProperty(exports, 'resolvePreprocessor', {
4064
- enumerable: true,
4065
- get: function () {
4066
- return resolvePreprocessor;
4067
- }
4068
- });
4069
- Object.defineProperty(exports, 'resolveSchema', {
4070
- enumerable: true,
4071
- get: function () {
4072
- return resolveSchema;
4073
- }
4074
- });
4075
- Object.defineProperty(exports, 'resolveSchemas', {
4076
- enumerable: true,
4077
- get: function () {
4078
- return resolveSchemas;
4079
- }
4080
- });
4081
- Object.defineProperty(exports, 'set', {
4082
- enumerable: true,
4083
- get: function () {
4084
- return set;
4085
- }
4086
- });
4087
- Object.defineProperty(exports, 'stringPreprocessor', {
4088
- enumerable: true,
4089
- get: function () {
4090
- return stringPreprocessor;
4091
- }
4092
- });
4093
- Object.defineProperty(exports, 'stringProcessor', {
4094
- enumerable: true,
4095
- get: function () {
4096
- return stringProcessor;
4097
- }
4098
2165
  });