@geekmidas/envkit 10.0.0-alpha.2 → 10.0.0-alpha.21

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 (56) hide show
  1. package/dist/{EnvironmentBuilder-CoBQ9Xp2.d.mts → EnvironmentBuilder-DTZ8o3se.d.cts} +5 -5
  2. package/dist/EnvironmentBuilder-DTZ8o3se.d.cts.map +1 -0
  3. package/dist/{EnvironmentBuilder-DeIle4QN.d.cts → EnvironmentBuilder-DTZ8o3se.d.mts} +5 -5
  4. package/dist/EnvironmentBuilder-DTZ8o3se.d.mts.map +1 -0
  5. package/dist/{EnvironmentBuilder-C-2fViCT.mjs → EnvironmentBuilder-Rxq657gm.mjs} +4 -5
  6. package/dist/EnvironmentBuilder-Rxq657gm.mjs.map +1 -0
  7. package/dist/{EnvironmentBuilder-15SdFJdK.cjs → EnvironmentBuilder-wJH3EBbJ.cjs} +16 -16
  8. package/dist/EnvironmentBuilder-wJH3EBbJ.cjs.map +1 -0
  9. package/dist/{EnvironmentParser-DoooZm8n.d.cts → EnvironmentParser-BmJLlm5_.d.cts} +3 -15
  10. package/dist/EnvironmentParser-BmJLlm5_.d.cts.map +1 -0
  11. package/dist/{EnvironmentParser-BY1oCUsc.d.mts → EnvironmentParser-BmJLlm5_.d.mts} +3 -15
  12. package/dist/EnvironmentParser-BmJLlm5_.d.mts.map +1 -0
  13. package/dist/{EnvironmentParser-Bzg5yXG2.cjs → EnvironmentParser-CmhDxs77.cjs} +34 -34
  14. package/dist/EnvironmentParser-CmhDxs77.cjs.map +1 -0
  15. package/dist/{EnvironmentParser-taAKfzT7.mjs → EnvironmentParser-X6Z-jryw.mjs} +10 -12
  16. package/dist/EnvironmentParser-X6Z-jryw.mjs.map +1 -0
  17. package/dist/SnifferEnvironmentParser.cjs +5 -7
  18. package/dist/SnifferEnvironmentParser.cjs.map +1 -1
  19. package/dist/SnifferEnvironmentParser.d.cts +5 -9
  20. package/dist/SnifferEnvironmentParser.d.cts.map +1 -1
  21. package/dist/SnifferEnvironmentParser.d.mts +5 -9
  22. package/dist/SnifferEnvironmentParser.d.mts.map +1 -1
  23. package/dist/SnifferEnvironmentParser.mjs +3 -5
  24. package/dist/SnifferEnvironmentParser.mjs.map +1 -1
  25. package/dist/credentials.cjs +9 -11
  26. package/dist/credentials.cjs.map +1 -1
  27. package/dist/credentials.d.cts +3 -3
  28. package/dist/credentials.d.cts.map +1 -1
  29. package/dist/credentials.d.mts +3 -3
  30. package/dist/credentials.d.mts.map +1 -1
  31. package/dist/credentials.mjs +4 -8
  32. package/dist/credentials.mjs.map +1 -1
  33. package/dist/index.cjs +4 -4
  34. package/dist/index.d.cts +5 -7
  35. package/dist/index.d.cts.map +1 -1
  36. package/dist/index.d.mts +5 -7
  37. package/dist/index.d.mts.map +1 -1
  38. package/dist/index.mjs +3 -4
  39. package/dist/{chunk-CUT6urMc.cjs → rolldown-runtime-VH7oDXx4.cjs} +8 -10
  40. package/dist/sst.cjs +43 -51
  41. package/dist/sst.cjs.map +1 -1
  42. package/dist/sst.d.cts +19 -24
  43. package/dist/sst.d.cts.map +1 -1
  44. package/dist/sst.d.mts +19 -24
  45. package/dist/sst.d.mts.map +1 -1
  46. package/dist/sst.mjs +42 -51
  47. package/dist/sst.mjs.map +1 -1
  48. package/package.json +2 -2
  49. package/dist/EnvironmentBuilder-15SdFJdK.cjs.map +0 -1
  50. package/dist/EnvironmentBuilder-C-2fViCT.mjs.map +0 -1
  51. package/dist/EnvironmentBuilder-CoBQ9Xp2.d.mts.map +0 -1
  52. package/dist/EnvironmentBuilder-DeIle4QN.d.cts.map +0 -1
  53. package/dist/EnvironmentParser-BY1oCUsc.d.mts.map +0 -1
  54. package/dist/EnvironmentParser-Bzg5yXG2.cjs.map +0 -1
  55. package/dist/EnvironmentParser-DoooZm8n.d.cts.map +0 -1
  56. package/dist/EnvironmentParser-taAKfzT7.mjs.map +0 -1
@@ -75,18 +75,18 @@ type OmitType<T> = T extends {
75
75
  /**
76
76
  * Extracts all unique `type` values from a record (excluding plain strings).
77
77
  */
78
- type AllTypeValues<TRecord extends Record<string, InputValue>> = { [K in keyof TRecord]: ExtractType<TRecord[K]> }[keyof TRecord];
78
+ type AllTypeValues<TRecord extends Record<string, InputValue>> = { [K in keyof TRecord]: ExtractType<TRecord[K]>; }[keyof TRecord];
79
79
  /**
80
80
  * For a given type value, finds the corresponding value type (without `type` key).
81
81
  */
82
82
  type ValueForType<TRecord extends Record<string, InputValue>, TType extends string> = { [K in keyof TRecord]: TRecord[K] extends {
83
83
  type: TType;
84
- } ? OmitType<TRecord[K]> : never }[keyof TRecord];
84
+ } ? OmitType<TRecord[K]> : never; }[keyof TRecord];
85
85
  /**
86
86
  * Generates typed resolvers based on the input record.
87
87
  * Keys are the `type` values, values are resolver functions receiving the value without `type`.
88
88
  */
89
- type TypedResolvers<TRecord extends Record<string, InputValue>> = { [TType in AllTypeValues<TRecord>]: EnvironmentResolver<ValueForType<TRecord, TType>> };
89
+ type TypedResolvers<TRecord extends Record<string, InputValue>> = { [TType in AllTypeValues<TRecord>]: EnvironmentResolver<ValueForType<TRecord, TType>>; };
90
90
  /**
91
91
  * A generic, extensible class for building environment variables from
92
92
  * objects with type-discriminated values.
@@ -127,5 +127,5 @@ declare class EnvironmentBuilder<TRecord extends Record<string, InputValue> = Re
127
127
  build(): EnvRecord;
128
128
  }
129
129
  //#endregion
130
- export { EnvRecord, EnvValue, EnvironmentBuilder, EnvironmentBuilderOptions, EnvironmentResolver, InputValue, Resolvers, TypedInputValue, TypedResolvers, environmentCase };
131
- //# sourceMappingURL=EnvironmentBuilder-CoBQ9Xp2.d.mts.map
130
+ export { EnvironmentResolver as a, TypedInputValue as c, EnvironmentBuilderOptions as i, TypedResolvers as l, EnvValue as n, InputValue as o, EnvironmentBuilder as r, Resolvers as s, EnvRecord as t, environmentCase as u };
131
+ //# sourceMappingURL=EnvironmentBuilder-DTZ8o3se.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"EnvironmentBuilder-DTZ8o3se.d.cts","names":[],"sources":["../src/EnvironmentBuilder.ts"],"mappings":";;;;;;;;;;;;iBAagB,gBAAgB;;;;;UAYf;GACf,cAAc;;;;;;KAOJ,uCAAuC;;;;;;;;;KAUvC,oBAAoB,YAAY,aAAa,OAAO,MAAM;;;;KAK1D,YAAY,eAAe;;;;UAKtB;;;;;EAKhB,oBAAoB,aAAa;;;;;KAMtB;EAAwB;GAAe;;;;;KAKvC,gBAAgB;EAC3B,MAAM;GACL;;;;;KAMG,YAAY,KAAK;EAAY,YAAY;IAAqB;;;;KAK9D,SAAS,KAAK;EAAY;IAAiB,KAAK;;;;KAKhD,cAAc,gBAAgB,eAAe,kBAChD,WAAW,UAAU,YAAY,QAAQ,aACnC;;;;KAKH,aACJ,gBAAgB,eAAe,aAC/B,2BAEC,WAAW,UAAU,QAAQ;EAAa,MAAM;IAC9C,SAAS,QAAQ,qBAEb;;;;;KAMI,eAAe,gBAAgB,eAAe,kBACxD,SAAS,cAAc,WAAW,oBAClC,aAAa,SAAS;;;;;;;;;;;;;;;;;;;;;;;cA0BX,mBACZ,gBAAgB,eAAe,cAAc,eAAe,aAC5D,mBAAmB,YAAY,eAAe;mBAE7B;mBACA;mBACA;EAEjB,YACC,QAAQ,SACR,WAAW,YACX,UAAS;;;;;;;;;;;EAmBV,SAAS"}
@@ -75,18 +75,18 @@ type OmitType<T> = T extends {
75
75
  /**
76
76
  * Extracts all unique `type` values from a record (excluding plain strings).
77
77
  */
78
- type AllTypeValues<TRecord extends Record<string, InputValue>> = { [K in keyof TRecord]: ExtractType<TRecord[K]> }[keyof TRecord];
78
+ type AllTypeValues<TRecord extends Record<string, InputValue>> = { [K in keyof TRecord]: ExtractType<TRecord[K]>; }[keyof TRecord];
79
79
  /**
80
80
  * For a given type value, finds the corresponding value type (without `type` key).
81
81
  */
82
82
  type ValueForType<TRecord extends Record<string, InputValue>, TType extends string> = { [K in keyof TRecord]: TRecord[K] extends {
83
83
  type: TType;
84
- } ? OmitType<TRecord[K]> : never }[keyof TRecord];
84
+ } ? OmitType<TRecord[K]> : never; }[keyof TRecord];
85
85
  /**
86
86
  * Generates typed resolvers based on the input record.
87
87
  * Keys are the `type` values, values are resolver functions receiving the value without `type`.
88
88
  */
89
- type TypedResolvers<TRecord extends Record<string, InputValue>> = { [TType in AllTypeValues<TRecord>]: EnvironmentResolver<ValueForType<TRecord, TType>> };
89
+ type TypedResolvers<TRecord extends Record<string, InputValue>> = { [TType in AllTypeValues<TRecord>]: EnvironmentResolver<ValueForType<TRecord, TType>>; };
90
90
  /**
91
91
  * A generic, extensible class for building environment variables from
92
92
  * objects with type-discriminated values.
@@ -127,5 +127,5 @@ declare class EnvironmentBuilder<TRecord extends Record<string, InputValue> = Re
127
127
  build(): EnvRecord;
128
128
  }
129
129
  //#endregion
130
- export { EnvRecord, EnvValue, EnvironmentBuilder, EnvironmentBuilderOptions, EnvironmentResolver, InputValue, Resolvers, TypedInputValue, TypedResolvers, environmentCase };
131
- //# sourceMappingURL=EnvironmentBuilder-DeIle4QN.d.cts.map
130
+ export { EnvironmentResolver as a, TypedInputValue as c, EnvironmentBuilderOptions as i, TypedResolvers as l, EnvValue as n, InputValue as o, EnvironmentBuilder as r, Resolvers as s, EnvRecord as t, environmentCase as u };
131
+ //# sourceMappingURL=EnvironmentBuilder-DTZ8o3se.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"EnvironmentBuilder-DTZ8o3se.d.mts","names":[],"sources":["../src/EnvironmentBuilder.ts"],"mappings":";;;;;;;;;;;;iBAagB,gBAAgB;;;;;UAYf;GACf,cAAc;;;;;;KAOJ,uCAAuC;;;;;;;;;KAUvC,oBAAoB,YAAY,aAAa,OAAO,MAAM;;;;KAK1D,YAAY,eAAe;;;;UAKtB;;;;;EAKhB,oBAAoB,aAAa;;;;;KAMtB;EAAwB;GAAe;;;;;KAKvC,gBAAgB;EAC3B,MAAM;GACL;;;;;KAMG,YAAY,KAAK;EAAY,YAAY;IAAqB;;;;KAK9D,SAAS,KAAK;EAAY;IAAiB,KAAK;;;;KAKhD,cAAc,gBAAgB,eAAe,kBAChD,WAAW,UAAU,YAAY,QAAQ,aACnC;;;;KAKH,aACJ,gBAAgB,eAAe,aAC/B,2BAEC,WAAW,UAAU,QAAQ;EAAa,MAAM;IAC9C,SAAS,QAAQ,qBAEb;;;;;KAMI,eAAe,gBAAgB,eAAe,kBACxD,SAAS,cAAc,WAAW,oBAClC,aAAa,SAAS;;;;;;;;;;;;;;;;;;;;;;;cA0BX,mBACZ,gBAAgB,eAAe,cAAc,eAAe,aAC5D,mBAAmB,YAAY,eAAe;mBAE7B;mBACA;mBACA;EAEjB,YACC,QAAQ,SACR,WAAW,YACX,UAAS;;;;;;;;;;;EAmBV,SAAS"}
@@ -1,5 +1,4 @@
1
1
  import snakecase from "lodash.snakecase";
2
-
3
2
  //#region src/EnvironmentBuilder.ts
4
3
  /**
5
4
  * Converts a string to environment variable case format (UPPER_SNAKE_CASE).
@@ -65,7 +64,7 @@ var EnvironmentBuilder = class {
65
64
  env[environmentCase(key)] = value;
66
65
  continue;
67
66
  }
68
- const { type,...rest } = value;
67
+ const { type, ...rest } = value;
69
68
  const resolver = this.resolvers[type];
70
69
  if (resolver) {
71
70
  const resolved = resolver(key, rest);
@@ -75,7 +74,7 @@ var EnvironmentBuilder = class {
75
74
  return env;
76
75
  }
77
76
  };
78
-
79
77
  //#endregion
80
- export { EnvironmentBuilder, environmentCase };
81
- //# sourceMappingURL=EnvironmentBuilder-C-2fViCT.mjs.map
78
+ export { environmentCase as n, EnvironmentBuilder as t };
79
+
80
+ //# sourceMappingURL=EnvironmentBuilder-Rxq657gm.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"EnvironmentBuilder-Rxq657gm.mjs","names":[],"sources":["../src/EnvironmentBuilder.ts"],"sourcesContent":["import snakecase from 'lodash.snakecase';\n\n/**\n * Converts a string to environment variable case format (UPPER_SNAKE_CASE).\n * Numbers following underscores are preserved without the underscore.\n *\n * @param name - The string to convert\n * @returns The converted string in environment variable format\n *\n * @example\n * environmentCase('myVariable') // 'MY_VARIABLE'\n * environmentCase('api2') // 'API2'\n */\nexport function environmentCase(name: string): string {\n\treturn snakecase(name)\n\t\t.toUpperCase()\n\t\t.replace(/_\\d+/g, (r) => {\n\t\t\treturn r.replace('_', '');\n\t\t});\n}\n\n/**\n * A record of environment variable names to their values.\n * Values can be primitives or nested records.\n */\nexport interface EnvRecord {\n\t[key: string]: EnvValue;\n}\n\n/**\n * Represents a value that can be stored in an environment record.\n * Can be a primitive value or a nested record of environment values.\n */\nexport type EnvValue = string | number | boolean | EnvRecord;\n\n/**\n * A resolver function that converts a typed value into environment variables.\n *\n * @template T - The type of value this resolver handles (without the `type` key)\n * @param key - The key name from the input record\n * @param value - The value to resolve (without the `type` key)\n * @returns A record of environment variable names to their values\n */\nexport type EnvironmentResolver<T = any> = (key: string, value: T) => EnvRecord;\n\n/**\n * A map of type discriminator strings to their resolver functions.\n */\nexport type Resolvers = Record<string, EnvironmentResolver<any>>;\n\n/**\n * Options for configuring the EnvironmentBuilder.\n */\nexport interface EnvironmentBuilderOptions {\n\t/**\n\t * Handler called when a value's type doesn't match any registered resolver.\n\t * Defaults to console.warn.\n\t */\n\tonUnmatchedValue?: (key: string, value: unknown) => void;\n}\n\n/**\n * Input value type - either a string or an object with a `type` discriminator.\n */\nexport type InputValue = string | { type: string; [key: string]: unknown };\n\n/**\n * Base type for typed input values with a specific type discriminator.\n */\nexport type TypedInputValue<TType extends string = string> = {\n\ttype: TType;\n\t[key: string]: unknown;\n};\n\n/**\n * Extracts the `type` string value from an input value.\n */\ntype ExtractType<T> = T extends { type: infer U extends string } ? U : never;\n\n/**\n * Removes the `type` key from an object type.\n */\ntype OmitType<T> = T extends { type: string } ? Omit<T, 'type'> : never;\n\n/**\n * Extracts all unique `type` values from a record (excluding plain strings).\n */\ntype AllTypeValues<TRecord extends Record<string, InputValue>> = {\n\t[K in keyof TRecord]: ExtractType<TRecord[K]>;\n}[keyof TRecord];\n\n/**\n * For a given type value, finds the corresponding value type (without `type` key).\n */\ntype ValueForType<\n\tTRecord extends Record<string, InputValue>,\n\tTType extends string,\n> = {\n\t[K in keyof TRecord]: TRecord[K] extends { type: TType }\n\t\t? OmitType<TRecord[K]>\n\t\t: never;\n}[keyof TRecord];\n\n/**\n * Generates typed resolvers based on the input record.\n * Keys are the `type` values, values are resolver functions receiving the value without `type`.\n */\nexport type TypedResolvers<TRecord extends Record<string, InputValue>> = {\n\t[TType in AllTypeValues<TRecord>]: EnvironmentResolver<\n\t\tValueForType<TRecord, TType>\n\t>;\n};\n\n/**\n * A generic, extensible class for building environment variables from\n * objects with type-discriminated values.\n *\n * @template TRecord - The input record type for type inference\n * @template TResolvers - The resolvers type (defaults to TypedResolvers<TRecord>)\n *\n * @example\n * ```typescript\n * const env = new EnvironmentBuilder(\n * {\n * apiKey: { type: 'secret', value: 'xyz' },\n * appName: 'my-app'\n * },\n * {\n * // `value` is typed as { value: string } (without `type`)\n * secret: (key, value) => ({ [key]: value.value }),\n * }\n * ).build();\n * // { API_KEY: 'xyz', APP_NAME: 'my-app' }\n * ```\n */\nexport class EnvironmentBuilder<\n\tTRecord extends Record<string, InputValue> = Record<string, InputValue>,\n\tTResolvers extends Resolvers = TypedResolvers<TRecord>,\n> {\n\tprivate readonly record: TRecord;\n\tprivate readonly resolvers: TResolvers;\n\tprivate readonly options: Required<EnvironmentBuilderOptions>;\n\n\tconstructor(\n\t\trecord: TRecord,\n\t\tresolvers: TResolvers,\n\t\toptions: EnvironmentBuilderOptions = {},\n\t) {\n\t\tthis.record = record;\n\t\tthis.resolvers = resolvers;\n\t\tthis.options = {\n\t\t\tonUnmatchedValue: options.onUnmatchedValue ?? ((_key, _value) => {}),\n\t\t};\n\t}\n\n\t/**\n\t * Build environment variables from the input record.\n\t *\n\t * - Plain string values are passed through with key transformation\n\t * - Object values with a `type` property are matched against resolvers\n\t * - Resolvers receive values without the `type` key\n\t * - Only root-level keys are transformed to UPPER_SNAKE_CASE\n\t *\n\t * @returns A record of environment variables\n\t */\n\tbuild(): EnvRecord {\n\t\tconst env: EnvRecord = {};\n\n\t\tfor (const [key, value] of Object.entries(this.record)) {\n\t\t\t// Handle plain string values\n\t\t\tif (typeof value === 'string') {\n\t\t\t\tenv[environmentCase(key)] = value;\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\t// Handle objects with type discriminator\n\t\t\tconst { type, ...rest } = value;\n\t\t\tconst resolver = this.resolvers[type];\n\t\t\tif (resolver) {\n\t\t\t\tconst resolved = resolver(key, rest);\n\t\t\t\t// Transform only root-level keys from resolver output\n\t\t\t\tfor (const [resolvedKey, resolvedValue] of Object.entries(resolved)) {\n\t\t\t\t\tenv[environmentCase(resolvedKey)] = resolvedValue;\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tthis.options.onUnmatchedValue(key, value);\n\t\t\t}\n\t\t}\n\n\t\treturn env;\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;AAaA,SAAgB,gBAAgB,MAAsB;CACrD,OAAO,UAAU,IAAI,CAAC,CACpB,YAAY,CAAC,CACb,QAAQ,UAAU,MAAM;EACxB,OAAO,EAAE,QAAQ,KAAK,EAAE;CACzB,CAAC;AACH;;;;;;;;;;;;;;;;;;;;;;;AAoHA,IAAa,qBAAb,MAGE;CACD;CACA;CACA;CAEA,YACC,QACA,WACA,UAAqC,CAAC,GACrC;EACD,KAAK,SAAS;EACd,KAAK,YAAY;EACjB,KAAK,UAAU,EACd,kBAAkB,QAAQ,sBAAsB,MAAM,WAAW,CAAC,GACnE;CACD;;;;;;;;;;;CAYA,QAAmB;EAClB,MAAM,MAAiB,CAAC;EAExB,KAAK,MAAM,CAAC,KAAK,UAAU,OAAO,QAAQ,KAAK,MAAM,GAAG;GAEvD,IAAI,OAAO,UAAU,UAAU;IAC9B,IAAI,gBAAgB,GAAG,KAAK;IAC5B;GACD;GAGA,MAAM,EAAE,MAAM,GAAG,SAAS;GAC1B,MAAM,WAAW,KAAK,UAAU;GAChC,IAAI,UAAU;IACb,MAAM,WAAW,SAAS,KAAK,IAAI;IAEnC,KAAK,MAAM,CAAC,aAAa,kBAAkB,OAAO,QAAQ,QAAQ,GACjE,IAAI,gBAAgB,WAAW,KAAK;GAEtC,OACC,KAAK,QAAQ,iBAAiB,KAAK,KAAK;EAE1C;EAEA,OAAO;CACR;AACD"}
@@ -1,6 +1,6 @@
1
- const require_chunk = require('./chunk-CUT6urMc.cjs');
2
- const lodash_snakecase = require_chunk.__toESM(require("lodash.snakecase"));
3
-
1
+ const require_rolldown_runtime = require("./rolldown-runtime-VH7oDXx4.cjs");
2
+ let lodash_snakecase = require("lodash.snakecase");
3
+ lodash_snakecase = require_rolldown_runtime.__toESM(lodash_snakecase, 1);
4
4
  //#region src/EnvironmentBuilder.ts
5
5
  /**
6
6
  * Converts a string to environment variable case format (UPPER_SNAKE_CASE).
@@ -66,7 +66,7 @@ var EnvironmentBuilder = class {
66
66
  env[environmentCase(key)] = value;
67
67
  continue;
68
68
  }
69
- const { type,...rest } = value;
69
+ const { type, ...rest } = value;
70
70
  const resolver = this.resolvers[type];
71
71
  if (resolver) {
72
72
  const resolved = resolver(key, rest);
@@ -76,18 +76,18 @@ var EnvironmentBuilder = class {
76
76
  return env;
77
77
  }
78
78
  };
79
-
80
79
  //#endregion
81
- Object.defineProperty(exports, 'EnvironmentBuilder', {
82
- enumerable: true,
83
- get: function () {
84
- return EnvironmentBuilder;
85
- }
80
+ Object.defineProperty(exports, "EnvironmentBuilder", {
81
+ enumerable: true,
82
+ get: function() {
83
+ return EnvironmentBuilder;
84
+ }
86
85
  });
87
- Object.defineProperty(exports, 'environmentCase', {
88
- enumerable: true,
89
- get: function () {
90
- return environmentCase;
91
- }
86
+ Object.defineProperty(exports, "environmentCase", {
87
+ enumerable: true,
88
+ get: function() {
89
+ return environmentCase;
90
+ }
92
91
  });
93
- //# sourceMappingURL=EnvironmentBuilder-15SdFJdK.cjs.map
92
+
93
+ //# sourceMappingURL=EnvironmentBuilder-wJH3EBbJ.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"EnvironmentBuilder-wJH3EBbJ.cjs","names":["snakecase"],"sources":["../src/EnvironmentBuilder.ts"],"sourcesContent":["import snakecase from 'lodash.snakecase';\n\n/**\n * Converts a string to environment variable case format (UPPER_SNAKE_CASE).\n * Numbers following underscores are preserved without the underscore.\n *\n * @param name - The string to convert\n * @returns The converted string in environment variable format\n *\n * @example\n * environmentCase('myVariable') // 'MY_VARIABLE'\n * environmentCase('api2') // 'API2'\n */\nexport function environmentCase(name: string): string {\n\treturn snakecase(name)\n\t\t.toUpperCase()\n\t\t.replace(/_\\d+/g, (r) => {\n\t\t\treturn r.replace('_', '');\n\t\t});\n}\n\n/**\n * A record of environment variable names to their values.\n * Values can be primitives or nested records.\n */\nexport interface EnvRecord {\n\t[key: string]: EnvValue;\n}\n\n/**\n * Represents a value that can be stored in an environment record.\n * Can be a primitive value or a nested record of environment values.\n */\nexport type EnvValue = string | number | boolean | EnvRecord;\n\n/**\n * A resolver function that converts a typed value into environment variables.\n *\n * @template T - The type of value this resolver handles (without the `type` key)\n * @param key - The key name from the input record\n * @param value - The value to resolve (without the `type` key)\n * @returns A record of environment variable names to their values\n */\nexport type EnvironmentResolver<T = any> = (key: string, value: T) => EnvRecord;\n\n/**\n * A map of type discriminator strings to their resolver functions.\n */\nexport type Resolvers = Record<string, EnvironmentResolver<any>>;\n\n/**\n * Options for configuring the EnvironmentBuilder.\n */\nexport interface EnvironmentBuilderOptions {\n\t/**\n\t * Handler called when a value's type doesn't match any registered resolver.\n\t * Defaults to console.warn.\n\t */\n\tonUnmatchedValue?: (key: string, value: unknown) => void;\n}\n\n/**\n * Input value type - either a string or an object with a `type` discriminator.\n */\nexport type InputValue = string | { type: string; [key: string]: unknown };\n\n/**\n * Base type for typed input values with a specific type discriminator.\n */\nexport type TypedInputValue<TType extends string = string> = {\n\ttype: TType;\n\t[key: string]: unknown;\n};\n\n/**\n * Extracts the `type` string value from an input value.\n */\ntype ExtractType<T> = T extends { type: infer U extends string } ? U : never;\n\n/**\n * Removes the `type` key from an object type.\n */\ntype OmitType<T> = T extends { type: string } ? Omit<T, 'type'> : never;\n\n/**\n * Extracts all unique `type` values from a record (excluding plain strings).\n */\ntype AllTypeValues<TRecord extends Record<string, InputValue>> = {\n\t[K in keyof TRecord]: ExtractType<TRecord[K]>;\n}[keyof TRecord];\n\n/**\n * For a given type value, finds the corresponding value type (without `type` key).\n */\ntype ValueForType<\n\tTRecord extends Record<string, InputValue>,\n\tTType extends string,\n> = {\n\t[K in keyof TRecord]: TRecord[K] extends { type: TType }\n\t\t? OmitType<TRecord[K]>\n\t\t: never;\n}[keyof TRecord];\n\n/**\n * Generates typed resolvers based on the input record.\n * Keys are the `type` values, values are resolver functions receiving the value without `type`.\n */\nexport type TypedResolvers<TRecord extends Record<string, InputValue>> = {\n\t[TType in AllTypeValues<TRecord>]: EnvironmentResolver<\n\t\tValueForType<TRecord, TType>\n\t>;\n};\n\n/**\n * A generic, extensible class for building environment variables from\n * objects with type-discriminated values.\n *\n * @template TRecord - The input record type for type inference\n * @template TResolvers - The resolvers type (defaults to TypedResolvers<TRecord>)\n *\n * @example\n * ```typescript\n * const env = new EnvironmentBuilder(\n * {\n * apiKey: { type: 'secret', value: 'xyz' },\n * appName: 'my-app'\n * },\n * {\n * // `value` is typed as { value: string } (without `type`)\n * secret: (key, value) => ({ [key]: value.value }),\n * }\n * ).build();\n * // { API_KEY: 'xyz', APP_NAME: 'my-app' }\n * ```\n */\nexport class EnvironmentBuilder<\n\tTRecord extends Record<string, InputValue> = Record<string, InputValue>,\n\tTResolvers extends Resolvers = TypedResolvers<TRecord>,\n> {\n\tprivate readonly record: TRecord;\n\tprivate readonly resolvers: TResolvers;\n\tprivate readonly options: Required<EnvironmentBuilderOptions>;\n\n\tconstructor(\n\t\trecord: TRecord,\n\t\tresolvers: TResolvers,\n\t\toptions: EnvironmentBuilderOptions = {},\n\t) {\n\t\tthis.record = record;\n\t\tthis.resolvers = resolvers;\n\t\tthis.options = {\n\t\t\tonUnmatchedValue: options.onUnmatchedValue ?? ((_key, _value) => {}),\n\t\t};\n\t}\n\n\t/**\n\t * Build environment variables from the input record.\n\t *\n\t * - Plain string values are passed through with key transformation\n\t * - Object values with a `type` property are matched against resolvers\n\t * - Resolvers receive values without the `type` key\n\t * - Only root-level keys are transformed to UPPER_SNAKE_CASE\n\t *\n\t * @returns A record of environment variables\n\t */\n\tbuild(): EnvRecord {\n\t\tconst env: EnvRecord = {};\n\n\t\tfor (const [key, value] of Object.entries(this.record)) {\n\t\t\t// Handle plain string values\n\t\t\tif (typeof value === 'string') {\n\t\t\t\tenv[environmentCase(key)] = value;\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\t// Handle objects with type discriminator\n\t\t\tconst { type, ...rest } = value;\n\t\t\tconst resolver = this.resolvers[type];\n\t\t\tif (resolver) {\n\t\t\t\tconst resolved = resolver(key, rest);\n\t\t\t\t// Transform only root-level keys from resolver output\n\t\t\t\tfor (const [resolvedKey, resolvedValue] of Object.entries(resolved)) {\n\t\t\t\t\tenv[environmentCase(resolvedKey)] = resolvedValue;\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tthis.options.onUnmatchedValue(key, value);\n\t\t\t}\n\t\t}\n\n\t\treturn env;\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;AAaA,SAAgB,gBAAgB,MAAsB;CACrD,QAAA,GAAOA,iBAAAA,QAAAA,CAAU,IAAI,CAAC,CACpB,YAAY,CAAC,CACb,QAAQ,UAAU,MAAM;EACxB,OAAO,EAAE,QAAQ,KAAK,EAAE;CACzB,CAAC;AACH;;;;;;;;;;;;;;;;;;;;;;;AAoHA,IAAa,qBAAb,MAGE;CACD;CACA;CACA;CAEA,YACC,QACA,WACA,UAAqC,CAAC,GACrC;EACD,KAAK,SAAS;EACd,KAAK,YAAY;EACjB,KAAK,UAAU,EACd,kBAAkB,QAAQ,sBAAsB,MAAM,WAAW,CAAC,GACnE;CACD;;;;;;;;;;;CAYA,QAAmB;EAClB,MAAM,MAAiB,CAAC;EAExB,KAAK,MAAM,CAAC,KAAK,UAAU,OAAO,QAAQ,KAAK,MAAM,GAAG;GAEvD,IAAI,OAAO,UAAU,UAAU;IAC9B,IAAI,gBAAgB,GAAG,KAAK;IAC5B;GACD;GAGA,MAAM,EAAE,MAAM,GAAG,SAAS;GAC1B,MAAM,WAAW,KAAK,UAAU;GAChC,IAAI,UAAU;IACb,MAAM,WAAW,SAAS,KAAK,IAAI;IAEnC,KAAK,MAAM,CAAC,aAAa,kBAAkB,OAAO,QAAQ,QAAQ,GACjE,IAAI,gBAAgB,WAAW,KAAK;GAEtC,OACC,KAAK,QAAQ,iBAAiB,KAAK,KAAK;EAE1C;EAEA,OAAO;CACR;AACD"}
@@ -1,7 +1,5 @@
1
1
  import { z } from "zod/v4";
2
-
3
2
  //#region src/EnvironmentParser.d.ts
4
-
5
3
  /**
6
4
  * Parses and validates configuration objects against Zod schemas.
7
5
  * Handles nested configurations and aggregates validation errors.
@@ -117,7 +115,7 @@ declare class EnvironmentParser<T extends EmptyObject> {
117
115
  *
118
116
  * @template T - The configuration object type
119
117
  */
120
- type InferConfig<T extends EmptyObject> = { [K in keyof T]: T[K] extends z.ZodSchema ? z.infer<T[K]> : T[K] extends Record<string, unknown> ? InferConfig<T[K]> : T[K] };
118
+ type InferConfig<T extends EmptyObject> = { [K in keyof T]: T[K] extends z.ZodSchema ? z.infer<T[K]> : T[K] extends Record<string, unknown> ? InferConfig<T[K]> : T[K]; };
121
119
  /**
122
120
  * Function type for fetching environment variables with Zod validation.
123
121
  * Returns a Zod object scoped to a specific environment variable.
@@ -127,21 +125,11 @@ type InferConfig<T extends EmptyObject> = { [K in keyof T]: T[K] extends z.ZodSc
127
125
  * @returns A Zod object for defining the schema
128
126
  */
129
127
  type EnvFetcher<TPath extends string = string> = (name: TPath) => typeof z;
130
- /**
131
- * Function type for building environment configuration objects.
132
- * Takes an EnvFetcher and returns a configuration object with Zod schemas.
133
- *
134
- * @template TResponse - The response configuration object type
135
- * @param get - The environment variable fetcher function
136
- * @returns The configuration object with Zod schemas
137
- */
138
-
139
128
  /**
140
129
  * Type alias for a generic object with unknown values.
141
130
  * Used as a constraint for configuration objects.
142
131
  */
143
132
  type EmptyObject = Record<string | number | symbol, unknown>;
144
- //# sourceMappingURL=EnvironmentParser.d.ts.map
145
133
  //#endregion
146
- export { ConfigParser, EmptyObject, EnvFetcher, EnvironmentParser, InferConfig };
147
- //# sourceMappingURL=EnvironmentParser-DoooZm8n.d.cts.map
134
+ export { InferConfig as a, EnvironmentParser as i, EmptyObject as n, EnvFetcher as r, ConfigParser as t };
135
+ //# sourceMappingURL=EnvironmentParser-BmJLlm5_.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"EnvironmentParser-BmJLlm5_.d.cts","names":[],"sources":["../src/EnvironmentParser.ts"],"mappings":";;;;;;;;cAWa,aAAa,kBAAkB;mBAQzB;mBACA;;;;;;;EAFlB,YACkB,QAAQ,WACR,UAAS;;;;;EAM3B,SAAS,YAAY;;;;;;;;;;;;;;;;;EAmErB;;;;;;;;;;;;;;;;;;;;;cAwBY,kBAAkB,UAAU;mBAWX;;;;mBAPZ;;;;;;EAOjB,YAA6B,QAAQ;;;;;;;;;UAU7B;;;;;;;;UA0EA;;;;;;;EAkDR,OAAO,gBAAgB,aACtB,UAAU,KAAK,eAAe,UAC5B,aAAa;;;;;;;;;;;;;;EAkBhB;;;;;;;;KAWW,YAAY,UAAU,kBAChC,WAAW,IAAI,EAAE,WAAW,EAAE,YAC5B,EAAE,MAAM,EAAE,MACV,EAAE,WAAW,0BACZ,YAAY,EAAE,MACd,EAAE;;;;;;;;;KAWK,WAAW,kCACtB,MAAM,iBACK;;;;;KAkBA,cAAc"}
@@ -1,7 +1,5 @@
1
1
  import { z } from "zod/v4";
2
-
3
2
  //#region src/EnvironmentParser.d.ts
4
-
5
3
  /**
6
4
  * Parses and validates configuration objects against Zod schemas.
7
5
  * Handles nested configurations and aggregates validation errors.
@@ -117,7 +115,7 @@ declare class EnvironmentParser<T extends EmptyObject> {
117
115
  *
118
116
  * @template T - The configuration object type
119
117
  */
120
- type InferConfig<T extends EmptyObject> = { [K in keyof T]: T[K] extends z.ZodSchema ? z.infer<T[K]> : T[K] extends Record<string, unknown> ? InferConfig<T[K]> : T[K] };
118
+ type InferConfig<T extends EmptyObject> = { [K in keyof T]: T[K] extends z.ZodSchema ? z.infer<T[K]> : T[K] extends Record<string, unknown> ? InferConfig<T[K]> : T[K]; };
121
119
  /**
122
120
  * Function type for fetching environment variables with Zod validation.
123
121
  * Returns a Zod object scoped to a specific environment variable.
@@ -127,21 +125,11 @@ type InferConfig<T extends EmptyObject> = { [K in keyof T]: T[K] extends z.ZodSc
127
125
  * @returns A Zod object for defining the schema
128
126
  */
129
127
  type EnvFetcher<TPath extends string = string> = (name: TPath) => typeof z;
130
- /**
131
- * Function type for building environment configuration objects.
132
- * Takes an EnvFetcher and returns a configuration object with Zod schemas.
133
- *
134
- * @template TResponse - The response configuration object type
135
- * @param get - The environment variable fetcher function
136
- * @returns The configuration object with Zod schemas
137
- */
138
-
139
128
  /**
140
129
  * Type alias for a generic object with unknown values.
141
130
  * Used as a constraint for configuration objects.
142
131
  */
143
132
  type EmptyObject = Record<string | number | symbol, unknown>;
144
- //# sourceMappingURL=EnvironmentParser.d.ts.map
145
133
  //#endregion
146
- export { ConfigParser, EmptyObject, EnvFetcher, EnvironmentParser, InferConfig };
147
- //# sourceMappingURL=EnvironmentParser-BY1oCUsc.d.mts.map
134
+ export { InferConfig as a, EnvironmentParser as i, EmptyObject as n, EnvFetcher as r, ConfigParser as t };
135
+ //# sourceMappingURL=EnvironmentParser-BmJLlm5_.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"EnvironmentParser-BmJLlm5_.d.mts","names":[],"sources":["../src/EnvironmentParser.ts"],"mappings":";;;;;;;;cAWa,aAAa,kBAAkB;mBAQzB;mBACA;;;;;;;EAFlB,YACkB,QAAQ,WACR,UAAS;;;;;EAM3B,SAAS,YAAY;;;;;;;;;;;;;;;;;EAmErB;;;;;;;;;;;;;;;;;;;;;cAwBY,kBAAkB,UAAU;mBAWX;;;;mBAPZ;;;;;;EAOjB,YAA6B,QAAQ;;;;;;;;;UAU7B;;;;;;;;UA0EA;;;;;;;EAkDR,OAAO,gBAAgB,aACtB,UAAU,KAAK,eAAe,UAC5B,aAAa;;;;;;;;;;;;;;EAkBhB;;;;;;;;KAWW,YAAY,UAAU,kBAChC,WAAW,IAAI,EAAE,WAAW,EAAE,YAC5B,EAAE,MAAM,EAAE,MACV,EAAE,WAAW,0BACZ,YAAY,EAAE,MACd,EAAE;;;;;;;;;KAWK,WAAW,kCACtB,MAAM,iBACK;;;;;KAkBA,cAAc"}
@@ -1,8 +1,9 @@
1
- const require_chunk = require('./chunk-CUT6urMc.cjs');
2
- const zod_v4 = require_chunk.__toESM(require("zod/v4"));
3
- const lodash_get = require_chunk.__toESM(require("lodash.get"));
4
- const lodash_set = require_chunk.__toESM(require("lodash.set"));
5
-
1
+ const require_rolldown_runtime = require("./rolldown-runtime-VH7oDXx4.cjs");
2
+ let lodash_get = require("lodash.get");
3
+ lodash_get = require_rolldown_runtime.__toESM(lodash_get, 1);
4
+ let lodash_set = require("lodash.set");
5
+ lodash_set = require_rolldown_runtime.__toESM(lodash_set, 1);
6
+ let zod_v4 = require("zod/v4");
6
7
  //#region src/formatter.ts
7
8
  /**
8
9
  * ANSI color codes for terminal output.
@@ -47,8 +48,7 @@ const colors = {
47
48
  * ```
48
49
  */
49
50
  function formatParseError(error, options = {}) {
50
- const useColors = options.colors ?? (process.stdout?.isTTY && process.env.NO_COLOR == null);
51
- const c = useColors ? colors : {
51
+ const c = options.colors ?? (process.stdout?.isTTY && process.env.NO_COLOR == null) ? colors : {
52
52
  reset: "",
53
53
  red: "",
54
54
  yellow: "",
@@ -66,8 +66,7 @@ function formatParseError(error, options = {}) {
66
66
  if (match?.[1]) envName = match[1];
67
67
  }
68
68
  const received = "received" in issue ? issue.received : void 0;
69
- const isMissing = issue.code === "invalid_type" && (received === "undefined" || received === "null");
70
- if (isMissing) missingVars.push({
69
+ if (issue.code === "invalid_type" && (received === "undefined" || received === "null")) missingVars.push({
71
70
  name: envName || "Unknown",
72
71
  message: cleanMessage(issue.message)
73
72
  });
@@ -110,7 +109,6 @@ function isDevelopment() {
110
109
  const nodeEnv = process.env.NODE_ENV?.toLowerCase();
111
110
  return nodeEnv == null || nodeEnv === "development" || nodeEnv === "dev";
112
111
  }
113
-
114
112
  //#endregion
115
113
  //#region src/EnvironmentParser.ts
116
114
  /**
@@ -120,6 +118,8 @@ function isDevelopment() {
120
118
  * @template TResponse - The shape of the configuration object
121
119
  */
122
120
  var ConfigParser = class {
121
+ config;
122
+ envVars;
123
123
  /**
124
124
  * Creates a new ConfigParser instance.
125
125
  *
@@ -201,6 +201,7 @@ var ConfigParser = class {
201
201
  * ```
202
202
  */
203
203
  var EnvironmentParser = class {
204
+ config;
204
205
  /**
205
206
  * Set to track which environment variable names have been accessed
206
207
  */
@@ -297,8 +298,7 @@ var EnvironmentParser = class {
297
298
  * @returns A ConfigParser object that can be used to parse the config object
298
299
  */
299
300
  create(builder) {
300
- const config = builder(this.getZodGetter);
301
- return new ConfigParser(config, this.accessedVars);
301
+ return new ConfigParser(builder(this.getZodGetter), this.accessedVars);
302
302
  }
303
303
  /**
304
304
  * Returns an array of environment variable names that were accessed via the getter.
@@ -317,30 +317,30 @@ var EnvironmentParser = class {
317
317
  return Array.from(this.accessedVars).sort();
318
318
  }
319
319
  };
320
-
321
320
  //#endregion
322
- Object.defineProperty(exports, 'ConfigParser', {
323
- enumerable: true,
324
- get: function () {
325
- return ConfigParser;
326
- }
321
+ Object.defineProperty(exports, "ConfigParser", {
322
+ enumerable: true,
323
+ get: function() {
324
+ return ConfigParser;
325
+ }
327
326
  });
328
- Object.defineProperty(exports, 'EnvironmentParser', {
329
- enumerable: true,
330
- get: function () {
331
- return EnvironmentParser;
332
- }
327
+ Object.defineProperty(exports, "EnvironmentParser", {
328
+ enumerable: true,
329
+ get: function() {
330
+ return EnvironmentParser;
331
+ }
333
332
  });
334
- Object.defineProperty(exports, 'formatParseError', {
335
- enumerable: true,
336
- get: function () {
337
- return formatParseError;
338
- }
333
+ Object.defineProperty(exports, "formatParseError", {
334
+ enumerable: true,
335
+ get: function() {
336
+ return formatParseError;
337
+ }
339
338
  });
340
- Object.defineProperty(exports, 'isDevelopment', {
341
- enumerable: true,
342
- get: function () {
343
- return isDevelopment;
344
- }
339
+ Object.defineProperty(exports, "isDevelopment", {
340
+ enumerable: true,
341
+ get: function() {
342
+ return isDevelopment;
343
+ }
345
344
  });
346
- //# sourceMappingURL=EnvironmentParser-Bzg5yXG2.cjs.map
345
+
346
+ //# sourceMappingURL=EnvironmentParser-CmhDxs77.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"EnvironmentParser-CmhDxs77.cjs","names":["z","get"],"sources":["../src/formatter.ts","../src/EnvironmentParser.ts"],"sourcesContent":["import type { z } from 'zod/v4';\n\n/**\n * Options for formatting parse errors.\n */\nexport interface FormatOptions {\n\t/** Whether to use colors in output. Defaults to auto-detect TTY. */\n\tcolors?: boolean;\n}\n\n/**\n * ANSI color codes for terminal output.\n */\nconst colors = {\n\treset: '\\x1b[0m',\n\tred: '\\x1b[31m',\n\tyellow: '\\x1b[33m',\n\tcyan: '\\x1b[36m',\n\tdim: '\\x1b[2m',\n\tbold: '\\x1b[1m',\n};\n\n/**\n * Formats a ZodError into a user-friendly string for development.\n *\n * @param error - The ZodError to format\n * @param options - Formatting options\n * @returns Formatted error message\n *\n * @example\n * ```typescript\n * try {\n * config.parse();\n * } catch (error) {\n * if (error instanceof ZodError) {\n * console.error(formatParseError(error));\n * }\n * }\n * ```\n *\n * Output:\n * ```\n * Environment Configuration Failed\n *\n * Missing Variables:\n * DATABASE_URL - Required\n * JWT_SECRET - Required\n *\n * Invalid Values:\n * NODE_ENV = \"invalid\"\n * Expected: \"development\" | \"staging\" | \"production\"\n * ```\n */\nexport function formatParseError(\n\terror: z.ZodError,\n\toptions: FormatOptions = {},\n): string {\n\tconst useColors =\n\t\toptions.colors ?? (process.stdout?.isTTY && process.env.NO_COLOR == null);\n\n\tconst c = useColors\n\t\t? colors\n\t\t: { reset: '', red: '', yellow: '', cyan: '', dim: '', bold: '' };\n\n\tconst missingVars: Array<{ name: string; message: string }> = [];\n\tconst invalidVars: Array<{ name: string; value: unknown; message: string }> =\n\t\t[];\n\n\tfor (const issue of error.issues) {\n\t\t// Extract environment variable name from path or message\n\t\tlet envName = '';\n\t\tif (issue.path.length > 0) {\n\t\t\t// Join the full path with '.' to show nested config keys and env var name\n\t\t\tenvName = issue.path.map(String).join('.');\n\t\t} else {\n\t\t\t// Try to extract from message like 'Environment variable \"NAME\": ...'\n\t\t\tconst match = issue.message.match(/Environment variable \"([^\"]+)\"/);\n\t\t\tif (match?.[1]) {\n\t\t\t\tenvName = match[1];\n\t\t\t}\n\t\t}\n\n\t\t// Determine if this is a missing or invalid value\n\t\t// Use type guard for received property\n\t\tconst received = 'received' in issue ? issue.received : undefined;\n\t\tconst isMissing =\n\t\t\tissue.code === 'invalid_type' &&\n\t\t\t(received === 'undefined' || received === 'null');\n\n\t\tif (isMissing) {\n\t\t\tmissingVars.push({\n\t\t\t\tname: envName || 'Unknown',\n\t\t\t\tmessage: cleanMessage(issue.message),\n\t\t\t});\n\t\t} else {\n\t\t\tinvalidVars.push({\n\t\t\t\tname: envName || 'Unknown',\n\t\t\t\tvalue: received,\n\t\t\t\tmessage: cleanMessage(issue.message),\n\t\t\t});\n\t\t}\n\t}\n\n\tconst lines: string[] = [];\n\n\tlines.push('');\n\tlines.push(`${c.red}${c.bold}Environment Configuration Failed${c.reset}`);\n\tlines.push('');\n\n\tif (missingVars.length > 0) {\n\t\tlines.push(`${c.yellow}Missing Variables:${c.reset}`);\n\t\tfor (const v of missingVars) {\n\t\t\tlines.push(` ${c.cyan}${v.name}${c.reset} ${c.dim}- Required${c.reset}`);\n\t\t}\n\t\tlines.push('');\n\t}\n\n\tif (invalidVars.length > 0) {\n\t\tlines.push(`${c.yellow}Invalid Values:${c.reset}`);\n\t\tfor (const v of invalidVars) {\n\t\t\tconst valueStr =\n\t\t\t\tv.value !== undefined ? ` = ${JSON.stringify(v.value)}` : '';\n\t\t\tlines.push(` ${c.cyan}${v.name}${c.reset}${valueStr}`);\n\t\t\tlines.push(` ${c.dim}${v.message}${c.reset}`);\n\t\t}\n\t\tlines.push('');\n\t}\n\n\treturn lines.join('\\n');\n}\n\n/**\n * Cleans up a Zod error message by removing redundant prefixes.\n */\nfunction cleanMessage(message: string): string {\n\t// Remove \"Environment variable \"NAME\": \" prefix if present\n\treturn message.replace(/^Environment variable \"[^\"]+\": /, '');\n}\n\n/**\n * Checks if the current environment is development.\n */\nexport function isDevelopment(): boolean {\n\tconst nodeEnv = process.env.NODE_ENV?.toLowerCase();\n\treturn nodeEnv == null || nodeEnv === 'development' || nodeEnv === 'dev';\n}\n","import get from 'lodash.get';\nimport set from 'lodash.set';\nimport { z } from 'zod/v4';\nimport { formatParseError, isDevelopment } from './formatter.js';\n\n/**\n * Parses and validates configuration objects against Zod schemas.\n * Handles nested configurations and aggregates validation errors.\n *\n * @template TResponse - The shape of the configuration object\n */\nexport class ConfigParser<TResponse extends EmptyObject> {\n\t/**\n\t * Creates a new ConfigParser instance.\n\t *\n\t * @param config - The configuration object to parse\n\t * @param envVars - Set of environment variable names that were accessed\n\t */\n\tconstructor(\n\t\tprivate readonly config: TResponse,\n\t\tprivate readonly envVars: Set<string> = new Set(),\n\t) {}\n\t/**\n\t * Parses the config object and validates it against the Zod schemas\n\t * @returns The parsed config object\n\t */\n\tparse(): InferConfig<TResponse> {\n\t\tconst errors: z.core.$ZodIssue[] = [];\n\n\t\tconst parseDeep = <T>(config: T, path: string[] = []) => {\n\t\t\tconst result: EmptyObject = {};\n\n\t\t\tif (config && typeof config !== 'object') {\n\t\t\t\treturn config;\n\t\t\t}\n\n\t\t\tfor (const key in config) {\n\t\t\t\tconst schema = config[key];\n\t\t\t\tconst currentPath = [...path, key];\n\n\t\t\t\tif (schema instanceof z.ZodType) {\n\t\t\t\t\tconst parsed = schema.safeParse(undefined);\n\t\t\t\t\tif (parsed.success) {\n\t\t\t\t\t\tset(result, key, parsed.data);\n\t\t\t\t\t} else {\n\t\t\t\t\t\t// If the schema is invalid, assign the error\n\t\t\t\t\t\terrors.push(\n\t\t\t\t\t\t\t...parsed.error.issues.map((issue) => ({\n\t\t\t\t\t\t\t\t...issue,\n\t\t\t\t\t\t\t\tpath: [...currentPath, ...(issue.path as string[])],\n\t\t\t\t\t\t\t})),\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t} else if (schema) {\n\t\t\t\t\tset(result, key, parseDeep(schema as EmptyObject, currentPath));\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn result;\n\t\t};\n\n\t\tconst parsedConfig = parseDeep(\n\t\t\tthis.config,\n\t\t) as unknown as InferConfig<TResponse>;\n\n\t\tif (errors.length > 0) {\n\t\t\tconst zodError = new z.ZodError(errors);\n\t\t\t// In development, log a formatted error message before throwing\n\t\t\tif (isDevelopment()) {\n\t\t\t\tconsole.error(formatParseError(zodError));\n\t\t\t}\n\t\t\tthrow zodError;\n\t\t}\n\n\t\treturn parsedConfig;\n\t}\n\n\t/**\n\t * Returns an array of environment variable names that were accessed during config creation.\n\t * This is useful for deployment and configuration management to know which env vars are required.\n\t *\n\t * @returns Array of environment variable names, sorted alphabetically\n\t *\n\t * @example\n\t * ```typescript\n\t * const config = envParser.create((get) => ({\n\t * dbUrl: get('DATABASE_URL').string(),\n\t * port: get('PORT').number()\n\t * }));\n\t *\n\t * config.getEnvironmentVariables(); // ['DATABASE_URL', 'PORT']\n\t * ```\n\t */\n\tgetEnvironmentVariables(): string[] {\n\t\treturn Array.from(this.envVars).sort();\n\t}\n}\n\n/**\n * Parses environment variables with type-safe validation using Zod schemas.\n * Provides a fluent API for defining environment variable schemas with automatic\n * error context enrichment.\n *\n * @template T - The type of the configuration object (typically process.env)\n *\n * @example\n * ```typescript\n * const config = new EnvironmentParser(process.env)\n * .create((get) => ({\n * port: get('PORT').string().transform(Number).default(3000),\n * database: {\n * url: get('DATABASE_URL').string().url()\n * }\n * }))\n * .parse();\n * ```\n */\nexport class EnvironmentParser<T extends EmptyObject> {\n\t/**\n\t * Set to track which environment variable names have been accessed\n\t */\n\tprivate readonly accessedVars: Set<string> = new Set();\n\n\t/**\n\t * Creates a new EnvironmentParser instance.\n\t *\n\t * @param config - The configuration object to parse (typically process.env)\n\t */\n\tconstructor(private readonly config: T) {}\n\n\t/**\n\t * Wraps a Zod schema to intercept parse/safeParse calls and enrich error messages\n\t * with environment variable context.\n\t *\n\t * @param schema - The Zod schema to wrap\n\t * @param name - The environment variable name for error context\n\t * @returns A wrapped Zod schema with enhanced error reporting\n\t */\n\tprivate wrapSchema = (schema: z.ZodType, name: string): z.ZodType => {\n\t\t// Create a proxy that intercepts all method calls on the schema\n\t\treturn new Proxy(schema, {\n\t\t\tget: (target, prop) => {\n\t\t\t\tif (prop === 'parse') {\n\t\t\t\t\treturn () => {\n\t\t\t\t\t\tconst value = get(this.config, name);\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\treturn target.parse(value);\n\t\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\t\tif (error instanceof z.ZodError) {\n\t\t\t\t\t\t\t\t// Modify the error to include the environment variable name\n\t\t\t\t\t\t\t\tconst modifiedIssues = error.issues.map((issue) => ({\n\t\t\t\t\t\t\t\t\t...issue,\n\t\t\t\t\t\t\t\t\tmessage: `Environment variable \"${name}\": ${issue.message}`,\n\t\t\t\t\t\t\t\t\tpath: [name, ...issue.path],\n\t\t\t\t\t\t\t\t}));\n\t\t\t\t\t\t\t\tthrow new z.ZodError(modifiedIssues);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tthrow error;\n\t\t\t\t\t\t}\n\t\t\t\t\t};\n\t\t\t\t}\n\n\t\t\t\tif (prop === 'safeParse') {\n\t\t\t\t\treturn () => {\n\t\t\t\t\t\tconst value = get(this.config, name);\n\t\t\t\t\t\tconst result = target.safeParse(value);\n\n\t\t\t\t\t\tif (!result.success) {\n\t\t\t\t\t\t\t// Modify the error to include the environment variable name\n\t\t\t\t\t\t\tconst modifiedIssues = result.error.issues.map(\n\t\t\t\t\t\t\t\t(issue: z.core.$ZodIssue) => ({\n\t\t\t\t\t\t\t\t\t...issue,\n\t\t\t\t\t\t\t\t\tmessage: `Environment variable \"${name}\": ${issue.message}`,\n\t\t\t\t\t\t\t\t\tpath: [name, ...issue.path],\n\t\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t\tsuccess: false as const,\n\t\t\t\t\t\t\t\terror: new z.ZodError(modifiedIssues),\n\t\t\t\t\t\t\t};\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\treturn result;\n\t\t\t\t\t};\n\t\t\t\t}\n\n\t\t\t\t// For any method that returns a new schema (like transform, optional, etc.),\n\t\t\t\t// wrap the result as well\n\t\t\t\tconst originalProp = target[prop as keyof typeof target];\n\t\t\t\tif (typeof originalProp === 'function') {\n\t\t\t\t\treturn (...args: any[]) => {\n\t\t\t\t\t\tconst result = originalProp.apply(target, args);\n\t\t\t\t\t\t// If the result is a ZodType, wrap it too\n\t\t\t\t\t\tif (result && typeof result === 'object' && 'parse' in result) {\n\t\t\t\t\t\t\treturn this.wrapSchema(result, name);\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn result;\n\t\t\t\t\t};\n\t\t\t\t}\n\n\t\t\t\treturn originalProp;\n\t\t\t},\n\t\t});\n\t};\n\n\t/**\n\t * Creates a proxied version of the Zod object that wraps all schema creators\n\t * to provide enhanced error messages with environment variable context.\n\t *\n\t * @param name - The environment variable name\n\t * @returns A proxied Zod object with wrapped schema creators\n\t */\n\tprivate getZodGetter = (name: string) => {\n\t\t// Track that this environment variable was accessed\n\t\tthis.accessedVars.add(name);\n\n\t\t// Return an object that has all Zod schemas but with our wrapper\n\t\treturn new Proxy(\n\t\t\t{ ...z },\n\t\t\t{\n\t\t\t\tget: (target, prop) => {\n\t\t\t\t\t// deno-lint-ignore ban-ts-comment\n\t\t\t\t\t// @ts-expect-error\n\t\t\t\t\tconst value = target[prop];\n\n\t\t\t\t\tif (typeof value === 'function') {\n\t\t\t\t\t\t// Return a wrapper around each Zod schema creator\n\t\t\t\t\t\treturn (...args: any[]) => {\n\t\t\t\t\t\t\tconst schema = value(...args);\n\t\t\t\t\t\t\treturn this.wrapSchema(schema, name);\n\t\t\t\t\t\t};\n\t\t\t\t\t}\n\n\t\t\t\t\t// Handle objects like z.coerce\n\t\t\t\t\tif (value && typeof value === 'object') {\n\t\t\t\t\t\treturn new Proxy(value, {\n\t\t\t\t\t\t\tget: (nestedTarget, nestedProp) => {\n\t\t\t\t\t\t\t\tconst nestedValue =\n\t\t\t\t\t\t\t\t\tnestedTarget[nestedProp as keyof typeof nestedTarget];\n\t\t\t\t\t\t\t\tif (typeof nestedValue === 'function') {\n\t\t\t\t\t\t\t\t\treturn (...args: any[]) => {\n\t\t\t\t\t\t\t\t\t\tconst schema = nestedValue(...args);\n\t\t\t\t\t\t\t\t\t\treturn this.wrapSchema(schema, name);\n\t\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\treturn nestedValue;\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\n\t\t\t\t\treturn value;\n\t\t\t\t},\n\t\t\t},\n\t\t);\n\t};\n\n\t/**\n\t * Creates a new ConfigParser object that can be used to parse the config object\n\t *\n\t * @param builder - A function that takes a getter function and returns a config object\n\t * @returns A ConfigParser object that can be used to parse the config object\n\t */\n\tcreate<TReturn extends EmptyObject>(\n\t\tbuilder: (get: EnvFetcher) => TReturn,\n\t): ConfigParser<TReturn> {\n\t\tconst config = builder(this.getZodGetter);\n\t\treturn new ConfigParser(config, this.accessedVars);\n\t}\n\n\t/**\n\t * Returns an array of environment variable names that were accessed via the getter.\n\t * This is useful for build-time analysis to determine which env vars a service needs.\n\t *\n\t * @returns Array of environment variable names, sorted alphabetically\n\t *\n\t * @example\n\t * ```typescript\n\t * const sniffer = new EnvironmentParser({});\n\t * service.register(sniffer);\n\t * const envVars = sniffer.getEnvironmentVariables(); // ['DATABASE_URL', 'PORT']\n\t * ```\n\t */\n\tgetEnvironmentVariables(): string[] {\n\t\treturn Array.from(this.accessedVars).sort();\n\t}\n}\n\n/**\n * Infers the TypeScript type of a configuration object based on its Zod schemas.\n * Recursively processes nested objects and extracts types from Zod schemas.\n *\n * @template T - The configuration object type\n */\nexport type InferConfig<T extends EmptyObject> = {\n\t[K in keyof T]: T[K] extends z.ZodSchema\n\t\t? z.infer<T[K]>\n\t\t: T[K] extends Record<string, unknown>\n\t\t\t? InferConfig<T[K]>\n\t\t\t: T[K];\n};\n\n/**\n * Function type for fetching environment variables with Zod validation.\n * Returns a Zod object scoped to a specific environment variable.\n *\n * @template TPath - The environment variable path type\n * @param name - The environment variable name\n * @returns A Zod object for defining the schema\n */\nexport type EnvFetcher<TPath extends string = string> = (\n\tname: TPath,\n) => typeof z;\n\n/**\n * Function type for building environment configuration objects.\n * Takes an EnvFetcher and returns a configuration object with Zod schemas.\n *\n * @template TResponse - The response configuration object type\n * @param get - The environment variable fetcher function\n * @returns The configuration object with Zod schemas\n */\nexport type EnvironmentBuilder<TResponse extends EmptyObject> = (\n\tget: EnvFetcher,\n) => TResponse;\n\n/**\n * Type alias for a generic object with unknown values.\n * Used as a constraint for configuration objects.\n */\nexport type EmptyObject = Record<string | number | symbol, unknown>;\n"],"mappings":";;;;;;;;;;AAaA,MAAM,SAAS;CACd,OAAO;CACP,KAAK;CACL,QAAQ;CACR,MAAM;CACN,KAAK;CACL,MAAM;AACP;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiCA,SAAgB,iB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AAK;CAC3C;AACD"}
@@ -1,7 +1,6 @@
1
- import { z } from "zod/v4";
2
1
  import get from "lodash.get";
3
2
  import set from "lodash.set";
4
-
3
+ import { z } from "zod/v4";
5
4
  //#region src/formatter.ts
6
5
  /**
7
6
  * ANSI color codes for terminal output.
@@ -46,8 +45,7 @@ const colors = {
46
45
  * ```
47
46
  */
48
47
  function formatParseError(error, options = {}) {
49
- const useColors = options.colors ?? (process.stdout?.isTTY && process.env.NO_COLOR == null);
50
- const c = useColors ? colors : {
48
+ const c = options.colors ?? (process.stdout?.isTTY && process.env.NO_COLOR == null) ? colors : {
51
49
  reset: "",
52
50
  red: "",
53
51
  yellow: "",
@@ -65,8 +63,7 @@ function formatParseError(error, options = {}) {
65
63
  if (match?.[1]) envName = match[1];
66
64
  }
67
65
  const received = "received" in issue ? issue.received : void 0;
68
- const isMissing = issue.code === "invalid_type" && (received === "undefined" || received === "null");
69
- if (isMissing) missingVars.push({
66
+ if (issue.code === "invalid_type" && (received === "undefined" || received === "null")) missingVars.push({
70
67
  name: envName || "Unknown",
71
68
  message: cleanMessage(issue.message)
72
69
  });
@@ -109,7 +106,6 @@ function isDevelopment() {
109
106
  const nodeEnv = process.env.NODE_ENV?.toLowerCase();
110
107
  return nodeEnv == null || nodeEnv === "development" || nodeEnv === "dev";
111
108
  }
112
-
113
109
  //#endregion
114
110
  //#region src/EnvironmentParser.ts
115
111
  /**
@@ -119,6 +115,8 @@ function isDevelopment() {
119
115
  * @template TResponse - The shape of the configuration object
120
116
  */
121
117
  var ConfigParser = class {
118
+ config;
119
+ envVars;
122
120
  /**
123
121
  * Creates a new ConfigParser instance.
124
122
  *
@@ -200,6 +198,7 @@ var ConfigParser = class {
200
198
  * ```
201
199
  */
202
200
  var EnvironmentParser = class {
201
+ config;
203
202
  /**
204
203
  * Set to track which environment variable names have been accessed
205
204
  */
@@ -296,8 +295,7 @@ var EnvironmentParser = class {
296
295
  * @returns A ConfigParser object that can be used to parse the config object
297
296
  */
298
297
  create(builder) {
299
- const config = builder(this.getZodGetter);
300
- return new ConfigParser(config, this.accessedVars);
298
+ return new ConfigParser(builder(this.getZodGetter), this.accessedVars);
301
299
  }
302
300
  /**
303
301
  * Returns an array of environment variable names that were accessed via the getter.
@@ -316,7 +314,7 @@ var EnvironmentParser = class {
316
314
  return Array.from(this.accessedVars).sort();
317
315
  }
318
316
  };
319
-
320
317
  //#endregion
321
- export { ConfigParser, EnvironmentParser, formatParseError, isDevelopment };
322
- //# sourceMappingURL=EnvironmentParser-taAKfzT7.mjs.map
318
+ export { isDevelopment as i, EnvironmentParser as n, formatParseError as r, ConfigParser as t };
319
+
320
+ //# sourceMappingURL=EnvironmentParser-X6Z-jryw.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"EnvironmentParser-X6Z-jryw.mjs","names":[],"sources":["../src/formatter.ts","../src/EnvironmentParser.ts"],"sourcesContent":["import type { z } from 'zod/v4';\n\n/**\n * Options for formatting parse errors.\n */\nexport interface FormatOptions {\n\t/** Whether to use colors in output. Defaults to auto-detect TTY. */\n\tcolors?: boolean;\n}\n\n/**\n * ANSI color codes for terminal output.\n */\nconst colors = {\n\treset: '\\x1b[0m',\n\tred: '\\x1b[31m',\n\tyellow: '\\x1b[33m',\n\tcyan: '\\x1b[36m',\n\tdim: '\\x1b[2m',\n\tbold: '\\x1b[1m',\n};\n\n/**\n * Formats a ZodError into a user-friendly string for development.\n *\n * @param error - The ZodError to format\n * @param options - Formatting options\n * @returns Formatted error message\n *\n * @example\n * ```typescript\n * try {\n * config.parse();\n * } catch (error) {\n * if (error instanceof ZodError) {\n * console.error(formatParseError(error));\n * }\n * }\n * ```\n *\n * Output:\n * ```\n * Environment Configuration Failed\n *\n * Missing Variables:\n * DATABASE_URL - Required\n * JWT_SECRET - Required\n *\n * Invalid Values:\n * NODE_ENV = \"invalid\"\n * Expected: \"development\" | \"staging\" | \"production\"\n * ```\n */\nexport function formatParseError(\n\terror: z.ZodError,\n\toptions: FormatOptions = {},\n): string {\n\tconst useColors =\n\t\toptions.colors ?? (process.stdout?.isTTY && process.env.NO_COLOR == null);\n\n\tconst c = useColors\n\t\t? colors\n\t\t: { reset: '', red: '', yellow: '', cyan: '', dim: '', bold: '' };\n\n\tconst missingVars: Array<{ name: string; message: string }> = [];\n\tconst invalidVars: Array<{ name: string; value: unknown; message: string }> =\n\t\t[];\n\n\tfor (const issue of error.issues) {\n\t\t// Extract environment variable name from path or message\n\t\tlet envName = '';\n\t\tif (issue.path.length > 0) {\n\t\t\t// Join the full path with '.' to show nested config keys and env var name\n\t\t\tenvName = issue.path.map(String).join('.');\n\t\t} else {\n\t\t\t// Try to extract from message like 'Environment variable \"NAME\": ...'\n\t\t\tconst match = issue.message.match(/Environment variable \"([^\"]+)\"/);\n\t\t\tif (match?.[1]) {\n\t\t\t\tenvName = match[1];\n\t\t\t}\n\t\t}\n\n\t\t// Determine if this is a missing or invalid value\n\t\t// Use type guard for received property\n\t\tconst received = 'received' in issue ? issue.received : undefined;\n\t\tconst isMissing =\n\t\t\tissue.code === 'invalid_type' &&\n\t\t\t(received === 'undefined' || received === 'null');\n\n\t\tif (isMissing) {\n\t\t\tmissingVars.push({\n\t\t\t\tname: envName || 'Unknown',\n\t\t\t\tmessage: cleanMessage(issue.message),\n\t\t\t});\n\t\t} else {\n\t\t\tinvalidVars.push({\n\t\t\t\tname: envName || 'Unknown',\n\t\t\t\tvalue: received,\n\t\t\t\tmessage: cleanMessage(issue.message),\n\t\t\t});\n\t\t}\n\t}\n\n\tconst lines: string[] = [];\n\n\tlines.push('');\n\tlines.push(`${c.red}${c.bold}Environment Configuration Failed${c.reset}`);\n\tlines.push('');\n\n\tif (missingVars.length > 0) {\n\t\tlines.push(`${c.yellow}Missing Variables:${c.reset}`);\n\t\tfor (const v of missingVars) {\n\t\t\tlines.push(` ${c.cyan}${v.name}${c.reset} ${c.dim}- Required${c.reset}`);\n\t\t}\n\t\tlines.push('');\n\t}\n\n\tif (invalidVars.length > 0) {\n\t\tlines.push(`${c.yellow}Invalid Values:${c.reset}`);\n\t\tfor (const v of invalidVars) {\n\t\t\tconst valueStr =\n\t\t\t\tv.value !== undefined ? ` = ${JSON.stringify(v.value)}` : '';\n\t\t\tlines.push(` ${c.cyan}${v.name}${c.reset}${valueStr}`);\n\t\t\tlines.push(` ${c.dim}${v.message}${c.reset}`);\n\t\t}\n\t\tlines.push('');\n\t}\n\n\treturn lines.join('\\n');\n}\n\n/**\n * Cleans up a Zod error message by removing redundant prefixes.\n */\nfunction cleanMessage(message: string): string {\n\t// Remove \"Environment variable \"NAME\": \" prefix if present\n\treturn message.replace(/^Environment variable \"[^\"]+\": /, '');\n}\n\n/**\n * Checks if the current environment is development.\n */\nexport function isDevelopment(): boolean {\n\tconst nodeEnv = process.env.NODE_ENV?.toLowerCase();\n\treturn nodeEnv == null || nodeEnv === 'development' || nodeEnv === 'dev';\n}\n","import get from 'lodash.get';\nimport set from 'lodash.set';\nimport { z } from 'zod/v4';\nimport { formatParseError, isDevelopment } from './formatter.js';\n\n/**\n * Parses and validates configuration objects against Zod schemas.\n * Handles nested configurations and aggregates validation errors.\n *\n * @template TResponse - The shape of the configuration object\n */\nexport class ConfigParser<TResponse extends EmptyObject> {\n\t/**\n\t * Creates a new ConfigParser instance.\n\t *\n\t * @param config - The configuration object to parse\n\t * @param envVars - Set of environment variable names that were accessed\n\t */\n\tconstructor(\n\t\tprivate readonly config: TResponse,\n\t\tprivate readonly envVars: Set<string> = new Set(),\n\t) {}\n\t/**\n\t * Parses the config object and validates it against the Zod schemas\n\t * @returns The parsed config object\n\t */\n\tparse(): InferConfig<TResponse> {\n\t\tconst errors: z.core.$ZodIssue[] = [];\n\n\t\tconst parseDeep = <T>(config: T, path: string[] = []) => {\n\t\t\tconst result: EmptyObject = {};\n\n\t\t\tif (config && typeof config !== 'object') {\n\t\t\t\treturn config;\n\t\t\t}\n\n\t\t\tfor (const key in config) {\n\t\t\t\tconst schema = config[key];\n\t\t\t\tconst currentPath = [...path, key];\n\n\t\t\t\tif (schema instanceof z.ZodType) {\n\t\t\t\t\tconst parsed = schema.safeParse(undefined);\n\t\t\t\t\tif (parsed.success) {\n\t\t\t\t\t\tset(result, key, parsed.data);\n\t\t\t\t\t} else {\n\t\t\t\t\t\t// If the schema is invalid, assign the error\n\t\t\t\t\t\terrors.push(\n\t\t\t\t\t\t\t...parsed.error.issues.map((issue) => ({\n\t\t\t\t\t\t\t\t...issue,\n\t\t\t\t\t\t\t\tpath: [...currentPath, ...(issue.path as string[])],\n\t\t\t\t\t\t\t})),\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t} else if (schema) {\n\t\t\t\t\tset(result, key, parseDeep(schema as EmptyObject, currentPath));\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn result;\n\t\t};\n\n\t\tconst parsedConfig = parseDeep(\n\t\t\tthis.config,\n\t\t) as unknown as InferConfig<TResponse>;\n\n\t\tif (errors.length > 0) {\n\t\t\tconst zodError = new z.ZodError(errors);\n\t\t\t// In development, log a formatted error message before throwing\n\t\t\tif (isDevelopment()) {\n\t\t\t\tconsole.error(formatParseError(zodError));\n\t\t\t}\n\t\t\tthrow zodError;\n\t\t}\n\n\t\treturn parsedConfig;\n\t}\n\n\t/**\n\t * Returns an array of environment variable names that were accessed during config creation.\n\t * This is useful for deployment and configuration management to know which env vars are required.\n\t *\n\t * @returns Array of environment variable names, sorted alphabetically\n\t *\n\t * @example\n\t * ```typescript\n\t * const config = envParser.create((get) => ({\n\t * dbUrl: get('DATABASE_URL').string(),\n\t * port: get('PORT').number()\n\t * }));\n\t *\n\t * config.getEnvironmentVariables(); // ['DATABASE_URL', 'PORT']\n\t * ```\n\t */\n\tgetEnvironmentVariables(): string[] {\n\t\treturn Array.from(this.envVars).sort();\n\t}\n}\n\n/**\n * Parses environment variables with type-safe validation using Zod schemas.\n * Provides a fluent API for defining environment variable schemas with automatic\n * error context enrichment.\n *\n * @template T - The type of the configuration object (typically process.env)\n *\n * @example\n * ```typescript\n * const config = new EnvironmentParser(process.env)\n * .create((get) => ({\n * port: get('PORT').string().transform(Number).default(3000),\n * database: {\n * url: get('DATABASE_URL').string().url()\n * }\n * }))\n * .parse();\n * ```\n */\nexport class EnvironmentParser<T extends EmptyObject> {\n\t/**\n\t * Set to track which environment variable names have been accessed\n\t */\n\tprivate readonly accessedVars: Set<string> = new Set();\n\n\t/**\n\t * Creates a new EnvironmentParser instance.\n\t *\n\t * @param config - The configuration object to parse (typically process.env)\n\t */\n\tconstructor(private readonly config: T) {}\n\n\t/**\n\t * Wraps a Zod schema to intercept parse/safeParse calls and enrich error messages\n\t * with environment variable context.\n\t *\n\t * @param schema - The Zod schema to wrap\n\t * @param name - The environment variable name for error context\n\t * @returns A wrapped Zod schema with enhanced error reporting\n\t */\n\tprivate wrapSchema = (schema: z.ZodType, name: string): z.ZodType => {\n\t\t// Create a proxy that intercepts all method calls on the schema\n\t\treturn new Proxy(schema, {\n\t\t\tget: (target, prop) => {\n\t\t\t\tif (prop === 'parse') {\n\t\t\t\t\treturn () => {\n\t\t\t\t\t\tconst value = get(this.config, name);\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\treturn target.parse(value);\n\t\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\t\tif (error instanceof z.ZodError) {\n\t\t\t\t\t\t\t\t// Modify the error to include the environment variable name\n\t\t\t\t\t\t\t\tconst modifiedIssues = error.issues.map((issue) => ({\n\t\t\t\t\t\t\t\t\t...issue,\n\t\t\t\t\t\t\t\t\tmessage: `Environment variable \"${name}\": ${issue.message}`,\n\t\t\t\t\t\t\t\t\tpath: [name, ...issue.path],\n\t\t\t\t\t\t\t\t}));\n\t\t\t\t\t\t\t\tthrow new z.ZodError(modifiedIssues);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tthrow error;\n\t\t\t\t\t\t}\n\t\t\t\t\t};\n\t\t\t\t}\n\n\t\t\t\tif (prop === 'safeParse') {\n\t\t\t\t\treturn () => {\n\t\t\t\t\t\tconst value = get(this.config, name);\n\t\t\t\t\t\tconst result = target.safeParse(value);\n\n\t\t\t\t\t\tif (!result.success) {\n\t\t\t\t\t\t\t// Modify the error to include the environment variable name\n\t\t\t\t\t\t\tconst modifiedIssues = result.error.issues.map(\n\t\t\t\t\t\t\t\t(issue: z.core.$ZodIssue) => ({\n\t\t\t\t\t\t\t\t\t...issue,\n\t\t\t\t\t\t\t\t\tmessage: `Environment variable \"${name}\": ${issue.message}`,\n\t\t\t\t\t\t\t\t\tpath: [name, ...issue.path],\n\t\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t\tsuccess: false as const,\n\t\t\t\t\t\t\t\terror: new z.ZodError(modifiedIssues),\n\t\t\t\t\t\t\t};\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\treturn result;\n\t\t\t\t\t};\n\t\t\t\t}\n\n\t\t\t\t// For any method that returns a new schema (like transform, optional, etc.),\n\t\t\t\t// wrap the result as well\n\t\t\t\tconst originalProp = target[prop as keyof typeof target];\n\t\t\t\tif (typeof originalProp === 'function') {\n\t\t\t\t\treturn (...args: any[]) => {\n\t\t\t\t\t\tconst result = originalProp.apply(target, args);\n\t\t\t\t\t\t// If the result is a ZodType, wrap it too\n\t\t\t\t\t\tif (result && typeof result === 'object' && 'parse' in result) {\n\t\t\t\t\t\t\treturn this.wrapSchema(result, name);\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn result;\n\t\t\t\t\t};\n\t\t\t\t}\n\n\t\t\t\treturn originalProp;\n\t\t\t},\n\t\t});\n\t};\n\n\t/**\n\t * Creates a proxied version of the Zod object that wraps all schema creators\n\t * to provide enhanced error messages with environment variable context.\n\t *\n\t * @param name - The environment variable name\n\t * @returns A proxied Zod object with wrapped schema creators\n\t */\n\tprivate getZodGetter = (name: string) => {\n\t\t// Track that this environment variable was accessed\n\t\tthis.accessedVars.add(name);\n\n\t\t// Return an object that has all Zod schemas but with our wrapper\n\t\treturn new Proxy(\n\t\t\t{ ...z },\n\t\t\t{\n\t\t\t\tget: (target, prop) => {\n\t\t\t\t\t// deno-lint-ignore ban-ts-comment\n\t\t\t\t\t// @ts-expect-error\n\t\t\t\t\tconst value = target[prop];\n\n\t\t\t\t\tif (typeof value === 'function') {\n\t\t\t\t\t\t// Return a wrapper around each Zod schema creator\n\t\t\t\t\t\treturn (...args: any[]) => {\n\t\t\t\t\t\t\tconst schema = value(...args);\n\t\t\t\t\t\t\treturn this.wrapSchema(schema, name);\n\t\t\t\t\t\t};\n\t\t\t\t\t}\n\n\t\t\t\t\t// Handle objects like z.coerce\n\t\t\t\t\tif (value && typeof value === 'object') {\n\t\t\t\t\t\treturn new Proxy(value, {\n\t\t\t\t\t\t\tget: (nestedTarget, nestedProp) => {\n\t\t\t\t\t\t\t\tconst nestedValue =\n\t\t\t\t\t\t\t\t\tnestedTarget[nestedProp as keyof typeof nestedTarget];\n\t\t\t\t\t\t\t\tif (typeof nestedValue === 'function') {\n\t\t\t\t\t\t\t\t\treturn (...args: any[]) => {\n\t\t\t\t\t\t\t\t\t\tconst schema = nestedValue(...args);\n\t\t\t\t\t\t\t\t\t\treturn this.wrapSchema(schema, name);\n\t\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\treturn nestedValue;\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\n\t\t\t\t\treturn value;\n\t\t\t\t},\n\t\t\t},\n\t\t);\n\t};\n\n\t/**\n\t * Creates a new ConfigParser object that can be used to parse the config object\n\t *\n\t * @param builder - A function that takes a getter function and returns a config object\n\t * @returns A ConfigParser object that can be used to parse the config object\n\t */\n\tcreate<TReturn extends EmptyObject>(\n\t\tbuilder: (get: EnvFetcher) => TReturn,\n\t): ConfigParser<TReturn> {\n\t\tconst config = builder(this.getZodGetter);\n\t\treturn new ConfigParser(config, this.accessedVars);\n\t}\n\n\t/**\n\t * Returns an array of environment variable names that were accessed via the getter.\n\t * This is useful for build-time analysis to determine which env vars a service needs.\n\t *\n\t * @returns Array of environment variable names, sorted alphabetically\n\t *\n\t * @example\n\t * ```typescript\n\t * const sniffer = new EnvironmentParser({});\n\t * service.register(sniffer);\n\t * const envVars = sniffer.getEnvironmentVariables(); // ['DATABASE_URL', 'PORT']\n\t * ```\n\t */\n\tgetEnvironmentVariables(): string[] {\n\t\treturn Array.from(this.accessedVars).sort();\n\t}\n}\n\n/**\n * Infers the TypeScript type of a configuration object based on its Zod schemas.\n * Recursively processes nested objects and extracts types from Zod schemas.\n *\n * @template T - The configuration object type\n */\nexport type InferConfig<T extends EmptyObject> = {\n\t[K in keyof T]: T[K] extends z.ZodSchema\n\t\t? z.infer<T[K]>\n\t\t: T[K] extends Record<string, unknown>\n\t\t\t? InferConfig<T[K]>\n\t\t\t: T[K];\n};\n\n/**\n * Function type for fetching environment variables with Zod validation.\n * Returns a Zod object scoped to a specific environment variable.\n *\n * @template TPath - The environment variable path type\n * @param name - The environment variable name\n * @returns A Zod object for defining the schema\n */\nexport type EnvFetcher<TPath extends string = string> = (\n\tname: TPath,\n) => typeof z;\n\n/**\n * Function type for building environment configuration objects.\n * Takes an EnvFetcher and returns a configuration object with Zod schemas.\n *\n * @template TResponse - The response configuration object type\n * @param get - The environment variable fetcher function\n * @returns The configuration object with Zod schemas\n */\nexport type EnvironmentBuilder<TResponse extends EmptyObject> = (\n\tget: EnvFetcher,\n) => TResponse;\n\n/**\n * Type alias for a generic object with unknown values.\n * Used as a constraint for configuration objects.\n */\nexport type EmptyObject = Record<string | number | symbol, unknown>;\n"],"mappings":";;;;;;;AAaA,MAAM,SAAS;CACd,OAAO;CACP,KAAK;CACL,QAAQ;CACR,MAAM;CACN,KAAK;CACL,MAAM;AACP;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiCA,SAAgB,iBACf,OACA,UAAyB,CAAC,GACjB;CAIT,MAAM,IAFL,QAAQ,WAAW,QAAQ,QAAQ,SAAS,QAAQ,IAAI,YAAY,QAGlE,SACA;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IAAI,OAAO,iBAAiB,YAC3B,QAAQ,GAAG,SAAgB;IAC1B,MAAM,SAAS,aAAa,MAAM,QAAQ,IAAI;IAE9C,IAAI,UAAU,OAAO,WAAW,YAAY,WAAW,QACtD,OAAO,KAAK,WAAW,QAAQ,IAAI;IAEpC,OAAO;GACR;GAGD,OAAO;EACR,EACD,CAAC;CACF;;;;;;;;CASA,gBAAwB,SAAiB;EAExC,KAAK,aAAa,IAAI,IAAI;EAG1B,OAAO,IAAI,MACV,EAAE,GAAG,EAAE,GACP,EACC,MAAM,QAAQ,SAAS;GAGtB,MAAM,QAAQ,OAAO;GAErB,IAAI,OAAO,UAAU,YAEpB,QAAQ,GAAG,SAAgB;IAC1B,MAAM,SAAS,MAAM,GAAG,IAAI;IAC5B,OAAO,KAAK,WAAW,QAAQ,IAAI;GACpC;GAID,IAAI,SAAS,OAAO,UAAU,UAC7B,OAAO,IAAI,MAAM,OAAO,EACvB,MAAM,cAAc,eAAe;IAClC,MAAM,cACL,aAAa;IACd,IAAI,OAAO,gBAAgB,YAC1B,QAAQ,GAAG,SAAgB;KAC1B,MAAM,SAAS,YAAY,GAAG,IAAI;KAClC,OAAO,KAAK,WAAW,QAAQ,IAAI;IACpC;IAED,OAAO;GACR,EACD,CAAC;GAGF,OAAO;EACR,EACD,CACD;CACD;;;;;;;CAQA,OACC,SACwB;EAExB,OAAO,IAAI,aADI,QAAQ,KAAK,YACJ,GAAQ,KAAK,YAAY;CAClD;;;;;;;;;;;;;;CAeA,0BAAoC;EACnC,OAAO,MAAM,KAAK,KAAK,YAAY,CAAC,CAAC,KAAK;CAC3C;AACD"}
@@ -1,7 +1,6 @@
1
- const require_chunk = require('./chunk-CUT6urMc.cjs');
2
- const require_EnvironmentParser = require('./EnvironmentParser-Bzg5yXG2.cjs');
3
- const zod_v4 = require_chunk.__toESM(require("zod/v4"));
4
-
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ const require_EnvironmentParser = require("./EnvironmentParser-CmhDxs77.cjs");
3
+ let zod_v4 = require("zod/v4");
5
4
  //#region src/SnifferEnvironmentParser.ts
6
5
  /**
7
6
  * A specialized EnvironmentParser for build-time analysis that tracks
@@ -90,8 +89,7 @@ var SnifferEnvironmentParser = class {
90
89
  * Creates a ConfigParser that will return mock values when parsed.
91
90
  */
92
91
  create(builder) {
93
- const config = builder(this.getZodGetter);
94
- return new SnifferConfigParser(config, this.accessedVars);
92
+ return new SnifferConfigParser(builder(this.getZodGetter), this.accessedVars);
95
93
  }
96
94
  /**
97
95
  * Returns all environment variable names that were accessed.
@@ -205,8 +203,8 @@ async function sniffWithFireAndForget(sniffer, operation, options = {}) {
205
203
  unhandledRejections
206
204
  };
207
205
  }
208
-
209
206
  //#endregion
210
207
  exports.SnifferEnvironmentParser = SnifferEnvironmentParser;
211
208
  exports.sniffWithFireAndForget = sniffWithFireAndForget;
209
+
212
210
  //# sourceMappingURL=SnifferEnvironmentParser.cjs.map