zenvx 0.2.0 → 0.2.1

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 (52) hide show
  1. package/README.md +55 -17
  2. package/dist/adapters/next.cjs +151 -0
  3. package/dist/adapters/next.d.cts +6 -0
  4. package/dist/adapters/next.d.ts +6 -0
  5. package/dist/adapters/next.js +32 -0
  6. package/dist/adapters/node.cjs +135 -0
  7. package/dist/adapters/node.d.cts +5 -0
  8. package/dist/adapters/node.d.ts +5 -0
  9. package/dist/adapters/node.js +17 -0
  10. package/dist/adapters/vite.cjs +135 -0
  11. package/dist/adapters/vite.d.cts +5 -0
  12. package/dist/adapters/vite.d.ts +5 -0
  13. package/dist/adapters/vite.js +16 -0
  14. package/dist/chunk-3HCQKBTL.js +29 -0
  15. package/dist/chunk-DX3SLVGQ.js +18 -0
  16. package/dist/chunk-E7OYVDFC.js +67 -0
  17. package/dist/chunk-ELPQSMQJ.js +24 -0
  18. package/dist/chunk-KGVPNFG3.js +43 -0
  19. package/dist/chunk-R2XSSP2M.js +24 -0
  20. package/dist/core/define-env.cjs +125 -0
  21. package/dist/core/define-env.d.cts +6 -0
  22. package/dist/core/define-env.d.ts +6 -0
  23. package/dist/core/define-env.js +9 -0
  24. package/dist/core/generate-example.cjs +71 -0
  25. package/dist/core/generate-example.d.cts +5 -0
  26. package/dist/core/generate-example.d.ts +5 -0
  27. package/dist/core/generate-example.js +6 -0
  28. package/dist/core/parser.cjs +53 -0
  29. package/dist/core/parser.d.cts +6 -0
  30. package/dist/core/parser.d.ts +6 -0
  31. package/dist/core/parser.js +6 -0
  32. package/dist/core/proxy.cjs +42 -0
  33. package/dist/core/proxy.d.cts +3 -0
  34. package/dist/core/proxy.d.ts +3 -0
  35. package/dist/core/proxy.js +6 -0
  36. package/dist/core/tx.cjs +91 -0
  37. package/dist/core/tx.d.cts +42 -0
  38. package/dist/core/tx.d.ts +42 -0
  39. package/dist/core/tx.js +6 -0
  40. package/dist/core/types.cjs +18 -0
  41. package/dist/core/types.d.cts +8 -0
  42. package/dist/core/types.d.ts +8 -0
  43. package/dist/core/types.js +0 -0
  44. package/dist/index.cjs +4 -24
  45. package/dist/index.d.cts +4 -51
  46. package/dist/index.d.ts +4 -51
  47. package/dist/index.js +8 -176
  48. package/dist/types/vite-env.d.cjs +1 -0
  49. package/dist/types/vite-env.d.d.cts +2 -0
  50. package/dist/types/vite-env.d.d.ts +2 -0
  51. package/dist/types/vite-env.d.js +0 -0
  52. package/package.json +18 -6
@@ -0,0 +1,67 @@
1
+ // src/core/tx.ts
2
+ import { z } from "zod";
3
+ var SEMVER_REGEX = /^\d+\.\d+\.\d+(-[0-9A-Za-z-.]+)?$/;
4
+ var tx = {
5
+ /**
6
+ * STRICT STRING:
7
+ * Rejects purely numeric strings (e.g. "12345").
8
+ * Good for API Keys.
9
+ */
10
+ string: (message = "Value should be text, but looks like a number.") => z.string().trim().regex(/^(?!\d+$).+$/, { error: message }).describe("Non-numeric string"),
11
+ /**
12
+ * SMART NUMBER:
13
+ * Automatically converts "3000" -> 3000.
14
+ * Fails if the value is not a valid number (e.g. "abc").
15
+ */
16
+ number: (message = "Must be a number") => z.coerce.number({ error: message }).finite().describe("Numeric value"),
17
+ /**
18
+ * PORT VALIDATOR:
19
+ * Coerces to number and ensures it is between 1 and 65535.
20
+ */
21
+ port: (message = "Must be a valid port (1\u201365535)") => z.coerce.number({ error: message }).int().min(1).max(65535).describe("TCP/UDP port number (1\u201365535)"),
22
+ /**
23
+ * SMART BOOLEAN:
24
+ * Handles "true", "TRUE", "1" -> true
25
+ * Handles "false", "FALSE", "0" -> false
26
+ * Throws error on anything else.
27
+ */
28
+ bool: (message) => {
29
+ return z.union([z.string(), z.boolean()]).transform((val, ctx) => {
30
+ if (typeof val === "boolean") return val;
31
+ const v = val.toLowerCase();
32
+ if (v === "true" || v === "1") return true;
33
+ if (v === "false" || v === "0") return false;
34
+ ctx.addIssue({
35
+ code: z.ZodIssueCode.custom,
36
+ message: message || 'Must be a boolean ("true"/"false"/"1"/"0")'
37
+ });
38
+ return z.NEVER;
39
+ });
40
+ },
41
+ /**
42
+ * URL:
43
+ * Strict URL checking.
44
+ */
45
+ url: (message = "Must be a valid URL (e.g. https://...)") => z.url({ error: message }).describe("A valid URL including protocol"),
46
+ email: (message = "Must be a valid email address") => z.email({ error: message }).describe("A valid email address"),
47
+ positiveNumber: (message = "Must be > 0") => z.coerce.number().gt(0, { error: message }).describe("A positive number"),
48
+ nonEmptyString: (message = "Cannot be empty") => z.string().trim().min(1, { error: message }).describe("A non-empty string"),
49
+ semver: (message = "Must be valid semver") => z.string().regex(SEMVER_REGEX, { error: message }).describe("Semantic version (x.y.z)"),
50
+ path: (message = "Must be a valid path") => z.string().trim().min(1, { error: message }).describe("Filesystem path"),
51
+ enum: (values, message = `Must be one of: ${values.join(", ")}`) => z.enum(values, { error: message }).describe(`One of: ${values.join(", ")}`),
52
+ json: (message = "Must be valid JSON") => z.string().transform((val, ctx) => {
53
+ try {
54
+ return JSON.parse(val);
55
+ } catch {
56
+ ctx.addIssue({
57
+ code: "custom",
58
+ error: message
59
+ });
60
+ return z.NEVER;
61
+ }
62
+ }).describe("JSON-encoded value")
63
+ };
64
+
65
+ export {
66
+ tx
67
+ };
@@ -0,0 +1,24 @@
1
+ import {
2
+ generateExample
3
+ } from "./chunk-KGVPNFG3.js";
4
+ import {
5
+ parseEnv
6
+ } from "./chunk-3HCQKBTL.js";
7
+ import {
8
+ createTypedProxy
9
+ } from "./chunk-DX3SLVGQ.js";
10
+
11
+ // src/core/define-env.ts
12
+ import { z } from "zod";
13
+ function defineEnv(shape, source, options) {
14
+ const schema = z.object(shape);
15
+ const parsed = parseEnv(schema, source, options?.mode ?? "runtime");
16
+ if (options?.generateExample) {
17
+ generateExample(schema);
18
+ }
19
+ return createTypedProxy(parsed);
20
+ }
21
+
22
+ export {
23
+ defineEnv
24
+ };
@@ -0,0 +1,43 @@
1
+ // src/core/generate-example.ts
2
+ import {
3
+ ZodDefault,
4
+ ZodOptional,
5
+ ZodString,
6
+ ZodNumber,
7
+ ZodBoolean
8
+ } from "zod";
9
+ import fs from "fs";
10
+ function getZodTypeName(schema) {
11
+ let type = "unknown";
12
+ if (schema instanceof ZodString) type = "string";
13
+ else if (schema instanceof ZodNumber) type = "number";
14
+ else if (schema instanceof ZodBoolean) type = "boolean";
15
+ return type;
16
+ }
17
+ function generateExample(schema, path = ".env.example") {
18
+ const header = [
19
+ "# Example environment variables",
20
+ "# Copy this file to .env and fill in the values",
21
+ ""
22
+ ];
23
+ const lines = Object.entries(schema.shape).map(([key, zodSchema]) => {
24
+ let placeholder = "";
25
+ let othertype = null;
26
+ let actualSchema = zodSchema;
27
+ if (zodSchema instanceof ZodOptional) actualSchema = zodSchema.unwrap();
28
+ if (zodSchema instanceof ZodDefault) {
29
+ actualSchema = zodSchema.def.innerType;
30
+ placeholder = zodSchema.def.defaultValue ?? "";
31
+ othertype = typeof zodSchema.def.defaultValue;
32
+ }
33
+ const type = getZodTypeName(actualSchema);
34
+ return `${key}=${placeholder ?? ""} # ${othertype ?? type}`;
35
+ });
36
+ const content = [...header, ...lines].join("\n") + "\n";
37
+ fs.writeFileSync(path, content);
38
+ console.log(`\u2705 .env.example generated at ${path}`);
39
+ }
40
+
41
+ export {
42
+ generateExample
43
+ };
@@ -0,0 +1,24 @@
1
+ import {
2
+ createTypedProxy
3
+ } from "./chunk-DX3SLVGQ.js";
4
+ import {
5
+ generateExample
6
+ } from "./chunk-KGVPNFG3.js";
7
+ import {
8
+ parseEnv
9
+ } from "./chunk-3HCQKBTL.js";
10
+
11
+ // src/core/define-env.ts
12
+ import { z } from "zod";
13
+ function defineEnv(shape, source, options) {
14
+ const schema = z.object(shape);
15
+ const parsed = parseEnv(schema, source, options?.mode ?? "runtime");
16
+ if (options?.generateExample) {
17
+ generateExample(schema);
18
+ }
19
+ return createTypedProxy(parsed);
20
+ }
21
+
22
+ export {
23
+ defineEnv
24
+ };
@@ -0,0 +1,125 @@
1
+ "use strict";
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 = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+
30
+ // src/core/define-env.ts
31
+ var define_env_exports = {};
32
+ __export(define_env_exports, {
33
+ defineEnv: () => defineEnv
34
+ });
35
+ module.exports = __toCommonJS(define_env_exports);
36
+ var import_zod3 = require("zod");
37
+
38
+ // src/core/parser.ts
39
+ var import_zod = require("zod");
40
+ function parseEnv(schema, source, mode = "runtime") {
41
+ const result = schema.safeParse(source);
42
+ if (!result.success) {
43
+ const issues = result.error.issues.map((i) => `\u274C ${i.path.join(".")}: ${i.message}`).join("\n");
44
+ const header = mode === "build" ? [
45
+ "\u250C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510",
46
+ "\u2502 \u274C INVALID ENVIRONMENT VARIABLES DETECTED \u2502",
47
+ "\u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518"
48
+ ] : [
49
+ "\u250C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510",
50
+ "\u2502 \u26A0 WARNING INVALID ENVIRONMENT VARIABLES \u26A0 \u2502",
51
+ "\u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518"
52
+ ];
53
+ const box = ["", ...header, issues, ""].join("\n");
54
+ if (mode === "build") {
55
+ throw new Error(box);
56
+ } else {
57
+ console.warn(box);
58
+ process.exit(1);
59
+ }
60
+ }
61
+ return result.success ? result.data : {};
62
+ }
63
+
64
+ // src/core/proxy.ts
65
+ function createTypedProxy(obj) {
66
+ return new Proxy(obj, {
67
+ get(target, prop) {
68
+ if (!(prop in target)) {
69
+ console.error(
70
+ `\u274C Tried to access undefined environment variable "${prop}"`
71
+ );
72
+ process.exit(1);
73
+ }
74
+ return target[prop];
75
+ }
76
+ });
77
+ }
78
+
79
+ // src/core/generate-example.ts
80
+ var import_zod2 = require("zod");
81
+ var import_fs = __toESM(require("fs"), 1);
82
+ function getZodTypeName(schema) {
83
+ let type = "unknown";
84
+ if (schema instanceof import_zod2.ZodString) type = "string";
85
+ else if (schema instanceof import_zod2.ZodNumber) type = "number";
86
+ else if (schema instanceof import_zod2.ZodBoolean) type = "boolean";
87
+ return type;
88
+ }
89
+ function generateExample(schema, path = ".env.example") {
90
+ const header = [
91
+ "# Example environment variables",
92
+ "# Copy this file to .env and fill in the values",
93
+ ""
94
+ ];
95
+ const lines = Object.entries(schema.shape).map(([key, zodSchema]) => {
96
+ let placeholder = "";
97
+ let othertype = null;
98
+ let actualSchema = zodSchema;
99
+ if (zodSchema instanceof import_zod2.ZodOptional) actualSchema = zodSchema.unwrap();
100
+ if (zodSchema instanceof import_zod2.ZodDefault) {
101
+ actualSchema = zodSchema.def.innerType;
102
+ placeholder = zodSchema.def.defaultValue ?? "";
103
+ othertype = typeof zodSchema.def.defaultValue;
104
+ }
105
+ const type = getZodTypeName(actualSchema);
106
+ return `${key}=${placeholder ?? ""} # ${othertype ?? type}`;
107
+ });
108
+ const content = [...header, ...lines].join("\n") + "\n";
109
+ import_fs.default.writeFileSync(path, content);
110
+ console.log(`\u2705 .env.example generated at ${path}`);
111
+ }
112
+
113
+ // src/core/define-env.ts
114
+ function defineEnv(shape, source, options) {
115
+ const schema = import_zod3.z.object(shape);
116
+ const parsed = parseEnv(schema, source, options?.mode ?? "runtime");
117
+ if (options?.generateExample) {
118
+ generateExample(schema);
119
+ }
120
+ return createTypedProxy(parsed);
121
+ }
122
+ // Annotate the CommonJS export names for ESM import in node:
123
+ 0 && (module.exports = {
124
+ defineEnv
125
+ });
@@ -0,0 +1,6 @@
1
+ import { z } from 'zod';
2
+ import { DefineEnvOptions } from './types.cjs';
3
+
4
+ declare function defineEnv<T extends z.ZodRawShape>(shape: T, source: Record<string, unknown>, options?: DefineEnvOptions): { [K in keyof T]: z.core.output<T[K]>; };
5
+
6
+ export { defineEnv };
@@ -0,0 +1,6 @@
1
+ import { z } from 'zod';
2
+ import { DefineEnvOptions } from './types.js';
3
+
4
+ declare function defineEnv<T extends z.ZodRawShape>(shape: T, source: Record<string, unknown>, options?: DefineEnvOptions): { [K in keyof T]: z.core.output<T[K]>; };
5
+
6
+ export { defineEnv };
@@ -0,0 +1,9 @@
1
+ import {
2
+ defineEnv
3
+ } from "../chunk-ELPQSMQJ.js";
4
+ import "../chunk-KGVPNFG3.js";
5
+ import "../chunk-3HCQKBTL.js";
6
+ import "../chunk-DX3SLVGQ.js";
7
+ export {
8
+ defineEnv
9
+ };
@@ -0,0 +1,71 @@
1
+ "use strict";
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 = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+
30
+ // src/core/generate-example.ts
31
+ var generate_example_exports = {};
32
+ __export(generate_example_exports, {
33
+ generateExample: () => generateExample
34
+ });
35
+ module.exports = __toCommonJS(generate_example_exports);
36
+ var import_zod = require("zod");
37
+ var import_fs = __toESM(require("fs"), 1);
38
+ function getZodTypeName(schema) {
39
+ let type = "unknown";
40
+ if (schema instanceof import_zod.ZodString) type = "string";
41
+ else if (schema instanceof import_zod.ZodNumber) type = "number";
42
+ else if (schema instanceof import_zod.ZodBoolean) type = "boolean";
43
+ return type;
44
+ }
45
+ function generateExample(schema, path = ".env.example") {
46
+ const header = [
47
+ "# Example environment variables",
48
+ "# Copy this file to .env and fill in the values",
49
+ ""
50
+ ];
51
+ const lines = Object.entries(schema.shape).map(([key, zodSchema]) => {
52
+ let placeholder = "";
53
+ let othertype = null;
54
+ let actualSchema = zodSchema;
55
+ if (zodSchema instanceof import_zod.ZodOptional) actualSchema = zodSchema.unwrap();
56
+ if (zodSchema instanceof import_zod.ZodDefault) {
57
+ actualSchema = zodSchema.def.innerType;
58
+ placeholder = zodSchema.def.defaultValue ?? "";
59
+ othertype = typeof zodSchema.def.defaultValue;
60
+ }
61
+ const type = getZodTypeName(actualSchema);
62
+ return `${key}=${placeholder ?? ""} # ${othertype ?? type}`;
63
+ });
64
+ const content = [...header, ...lines].join("\n") + "\n";
65
+ import_fs.default.writeFileSync(path, content);
66
+ console.log(`\u2705 .env.example generated at ${path}`);
67
+ }
68
+ // Annotate the CommonJS export names for ESM import in node:
69
+ 0 && (module.exports = {
70
+ generateExample
71
+ });
@@ -0,0 +1,5 @@
1
+ import { ZodRawShape, ZodObject } from 'zod';
2
+
3
+ declare function generateExample<T extends ZodRawShape>(schema: ZodObject<T>, path?: string): void;
4
+
5
+ export { generateExample };
@@ -0,0 +1,5 @@
1
+ import { ZodRawShape, ZodObject } from 'zod';
2
+
3
+ declare function generateExample<T extends ZodRawShape>(schema: ZodObject<T>, path?: string): void;
4
+
5
+ export { generateExample };
@@ -0,0 +1,6 @@
1
+ import {
2
+ generateExample
3
+ } from "../chunk-KGVPNFG3.js";
4
+ export {
5
+ generateExample
6
+ };
@@ -0,0 +1,53 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/core/parser.ts
21
+ var parser_exports = {};
22
+ __export(parser_exports, {
23
+ parseEnv: () => parseEnv
24
+ });
25
+ module.exports = __toCommonJS(parser_exports);
26
+ var import_zod = require("zod");
27
+ function parseEnv(schema, source, mode = "runtime") {
28
+ const result = schema.safeParse(source);
29
+ if (!result.success) {
30
+ const issues = result.error.issues.map((i) => `\u274C ${i.path.join(".")}: ${i.message}`).join("\n");
31
+ const header = mode === "build" ? [
32
+ "\u250C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510",
33
+ "\u2502 \u274C INVALID ENVIRONMENT VARIABLES DETECTED \u2502",
34
+ "\u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518"
35
+ ] : [
36
+ "\u250C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510",
37
+ "\u2502 \u26A0 WARNING INVALID ENVIRONMENT VARIABLES \u26A0 \u2502",
38
+ "\u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518"
39
+ ];
40
+ const box = ["", ...header, issues, ""].join("\n");
41
+ if (mode === "build") {
42
+ throw new Error(box);
43
+ } else {
44
+ console.warn(box);
45
+ process.exit(1);
46
+ }
47
+ }
48
+ return result.success ? result.data : {};
49
+ }
50
+ // Annotate the CommonJS export names for ESM import in node:
51
+ 0 && (module.exports = {
52
+ parseEnv
53
+ });
@@ -0,0 +1,6 @@
1
+ import { ZodRawShape, ZodObject, z } from 'zod';
2
+ import { ValidationMode } from './types.cjs';
3
+
4
+ declare function parseEnv<T extends ZodRawShape>(schema: ZodObject<T>, source: Record<string, unknown>, mode?: ValidationMode): z.infer<ZodObject<T>>;
5
+
6
+ export { parseEnv };
@@ -0,0 +1,6 @@
1
+ import { ZodRawShape, ZodObject, z } from 'zod';
2
+ import { ValidationMode } from './types.js';
3
+
4
+ declare function parseEnv<T extends ZodRawShape>(schema: ZodObject<T>, source: Record<string, unknown>, mode?: ValidationMode): z.infer<ZodObject<T>>;
5
+
6
+ export { parseEnv };
@@ -0,0 +1,6 @@
1
+ import {
2
+ parseEnv
3
+ } from "../chunk-3HCQKBTL.js";
4
+ export {
5
+ parseEnv
6
+ };
@@ -0,0 +1,42 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/core/proxy.ts
21
+ var proxy_exports = {};
22
+ __export(proxy_exports, {
23
+ createTypedProxy: () => createTypedProxy
24
+ });
25
+ module.exports = __toCommonJS(proxy_exports);
26
+ function createTypedProxy(obj) {
27
+ return new Proxy(obj, {
28
+ get(target, prop) {
29
+ if (!(prop in target)) {
30
+ console.error(
31
+ `\u274C Tried to access undefined environment variable "${prop}"`
32
+ );
33
+ process.exit(1);
34
+ }
35
+ return target[prop];
36
+ }
37
+ });
38
+ }
39
+ // Annotate the CommonJS export names for ESM import in node:
40
+ 0 && (module.exports = {
41
+ createTypedProxy
42
+ });
@@ -0,0 +1,3 @@
1
+ declare function createTypedProxy<T extends object>(obj: T): T;
2
+
3
+ export { createTypedProxy };
@@ -0,0 +1,3 @@
1
+ declare function createTypedProxy<T extends object>(obj: T): T;
2
+
3
+ export { createTypedProxy };
@@ -0,0 +1,6 @@
1
+ import {
2
+ createTypedProxy
3
+ } from "../chunk-DX3SLVGQ.js";
4
+ export {
5
+ createTypedProxy
6
+ };
@@ -0,0 +1,91 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/core/tx.ts
21
+ var tx_exports = {};
22
+ __export(tx_exports, {
23
+ tx: () => tx
24
+ });
25
+ module.exports = __toCommonJS(tx_exports);
26
+ var import_zod = require("zod");
27
+ var SEMVER_REGEX = /^\d+\.\d+\.\d+(-[0-9A-Za-z-.]+)?$/;
28
+ var tx = {
29
+ /**
30
+ * STRICT STRING:
31
+ * Rejects purely numeric strings (e.g. "12345").
32
+ * Good for API Keys.
33
+ */
34
+ string: (message = "Value should be text, but looks like a number.") => import_zod.z.string().trim().regex(/^(?!\d+$).+$/, { error: message }).describe("Non-numeric string"),
35
+ /**
36
+ * SMART NUMBER:
37
+ * Automatically converts "3000" -> 3000.
38
+ * Fails if the value is not a valid number (e.g. "abc").
39
+ */
40
+ number: (message = "Must be a number") => import_zod.z.coerce.number({ error: message }).finite().describe("Numeric value"),
41
+ /**
42
+ * PORT VALIDATOR:
43
+ * Coerces to number and ensures it is between 1 and 65535.
44
+ */
45
+ port: (message = "Must be a valid port (1\u201365535)") => import_zod.z.coerce.number({ error: message }).int().min(1).max(65535).describe("TCP/UDP port number (1\u201365535)"),
46
+ /**
47
+ * SMART BOOLEAN:
48
+ * Handles "true", "TRUE", "1" -> true
49
+ * Handles "false", "FALSE", "0" -> false
50
+ * Throws error on anything else.
51
+ */
52
+ bool: (message) => {
53
+ return import_zod.z.union([import_zod.z.string(), import_zod.z.boolean()]).transform((val, ctx) => {
54
+ if (typeof val === "boolean") return val;
55
+ const v = val.toLowerCase();
56
+ if (v === "true" || v === "1") return true;
57
+ if (v === "false" || v === "0") return false;
58
+ ctx.addIssue({
59
+ code: import_zod.z.ZodIssueCode.custom,
60
+ message: message || 'Must be a boolean ("true"/"false"/"1"/"0")'
61
+ });
62
+ return import_zod.z.NEVER;
63
+ });
64
+ },
65
+ /**
66
+ * URL:
67
+ * Strict URL checking.
68
+ */
69
+ url: (message = "Must be a valid URL (e.g. https://...)") => import_zod.z.url({ error: message }).describe("A valid URL including protocol"),
70
+ email: (message = "Must be a valid email address") => import_zod.z.email({ error: message }).describe("A valid email address"),
71
+ positiveNumber: (message = "Must be > 0") => import_zod.z.coerce.number().gt(0, { error: message }).describe("A positive number"),
72
+ nonEmptyString: (message = "Cannot be empty") => import_zod.z.string().trim().min(1, { error: message }).describe("A non-empty string"),
73
+ semver: (message = "Must be valid semver") => import_zod.z.string().regex(SEMVER_REGEX, { error: message }).describe("Semantic version (x.y.z)"),
74
+ path: (message = "Must be a valid path") => import_zod.z.string().trim().min(1, { error: message }).describe("Filesystem path"),
75
+ enum: (values, message = `Must be one of: ${values.join(", ")}`) => import_zod.z.enum(values, { error: message }).describe(`One of: ${values.join(", ")}`),
76
+ json: (message = "Must be valid JSON") => import_zod.z.string().transform((val, ctx) => {
77
+ try {
78
+ return JSON.parse(val);
79
+ } catch {
80
+ ctx.addIssue({
81
+ code: "custom",
82
+ error: message
83
+ });
84
+ return import_zod.z.NEVER;
85
+ }
86
+ }).describe("JSON-encoded value")
87
+ };
88
+ // Annotate the CommonJS export names for ESM import in node:
89
+ 0 && (module.exports = {
90
+ tx
91
+ });