envapt 7.0.3 → 8.0.0-next.0

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 (298) hide show
  1. package/CHANGELOG.md +32 -101
  2. package/README.md +5 -5
  3. package/dist/node/converters/BuiltInConverters.cjs +1 -1
  4. package/dist/node/converters/BuiltInConverters.cjs.map +1 -1
  5. package/dist/node/converters/BuiltInConverters.mjs +1 -1
  6. package/dist/node/converters/BuiltInConverters.mjs.map +1 -1
  7. package/dist/node/converters/Converters.cjs.map +1 -1
  8. package/dist/node/converters/Converters.mjs.map +1 -1
  9. package/dist/node/converters/ValueConverter.cjs +1 -1
  10. package/dist/node/converters/ValueConverter.cjs.map +1 -1
  11. package/dist/node/converters/ValueConverter.mjs +1 -1
  12. package/dist/node/converters/ValueConverter.mjs.map +1 -1
  13. package/dist/node/core/AdvancedMethods.cjs +1 -1
  14. package/dist/node/core/AdvancedMethods.cjs.map +1 -1
  15. package/dist/node/core/AdvancedMethods.mjs +1 -1
  16. package/dist/node/core/AdvancedMethods.mjs.map +1 -1
  17. package/dist/node/core/EnvapterBase.cjs +1 -1
  18. package/dist/node/core/EnvapterBase.cjs.map +1 -1
  19. package/dist/node/core/EnvapterBase.mjs +1 -1
  20. package/dist/node/core/EnvapterBase.mjs.map +1 -1
  21. package/dist/node/core/Environment.cjs +2 -0
  22. package/dist/node/core/Environment.cjs.map +1 -0
  23. package/dist/node/core/Environment.mjs +2 -0
  24. package/dist/node/core/Environment.mjs.map +1 -0
  25. package/dist/node/core/EnvironmentMethods.cjs +1 -1
  26. package/dist/node/core/EnvironmentMethods.cjs.map +1 -1
  27. package/dist/node/core/EnvironmentMethods.mjs +1 -1
  28. package/dist/node/core/EnvironmentMethods.mjs.map +1 -1
  29. package/dist/node/core/PrimitiveMethods.cjs +1 -1
  30. package/dist/node/core/PrimitiveMethods.cjs.map +1 -1
  31. package/dist/node/core/PrimitiveMethods.mjs +1 -1
  32. package/dist/node/core/PrimitiveMethods.mjs.map +1 -1
  33. package/dist/node/core/engine.cjs +2 -0
  34. package/dist/node/core/engine.cjs.map +1 -0
  35. package/dist/node/core/engine.mjs +2 -0
  36. package/dist/node/core/engine.mjs.map +1 -0
  37. package/dist/node/core/paths.cjs +2 -0
  38. package/dist/node/core/paths.cjs.map +1 -0
  39. package/dist/node/core/paths.mjs +2 -0
  40. package/dist/node/core/paths.mjs.map +1 -0
  41. package/dist/node/core/state.cjs +2 -0
  42. package/dist/node/core/state.cjs.map +1 -0
  43. package/dist/node/core/state.mjs +2 -0
  44. package/dist/node/core/state.mjs.map +1 -0
  45. package/dist/node/decorators/resolveDecoratorValue.cjs +1 -1
  46. package/dist/node/decorators/resolveDecoratorValue.cjs.map +1 -1
  47. package/dist/node/decorators/resolveDecoratorValue.mjs +1 -1
  48. package/dist/node/decorators/resolveDecoratorValue.mjs.map +1 -1
  49. package/dist/node/engine/Envapter.cjs +1 -1
  50. package/dist/node/engine/Envapter.cjs.map +1 -1
  51. package/dist/node/engine/Envapter.mjs +1 -1
  52. package/dist/node/engine/Envapter.mjs.map +1 -1
  53. package/dist/node/engine/NodeEnvapter.cjs +1 -1
  54. package/dist/node/engine/NodeEnvapter.cjs.map +1 -1
  55. package/dist/node/engine/NodeEnvapter.mjs +1 -1
  56. package/dist/node/engine/NodeEnvapter.mjs.map +1 -1
  57. package/dist/node/engine/TemplateResolver.cjs +1 -1
  58. package/dist/node/engine/TemplateResolver.cjs.map +1 -1
  59. package/dist/node/engine/TemplateResolver.mjs +1 -1
  60. package/dist/node/engine/TemplateResolver.mjs.map +1 -1
  61. package/dist/node/engine/Validators.cjs +1 -1
  62. package/dist/node/engine/Validators.cjs.map +1 -1
  63. package/dist/node/engine/Validators.mjs +1 -1
  64. package/dist/node/engine/Validators.mjs.map +1 -1
  65. package/dist/node/index.cjs +1 -1
  66. package/dist/node/index.mjs +1 -1
  67. package/dist/node/infra/Error.cjs +1 -1
  68. package/dist/node/infra/Error.cjs.map +1 -1
  69. package/dist/node/infra/Error.mjs +1 -1
  70. package/dist/node/infra/Error.mjs.map +1 -1
  71. package/dist/node/infra/recase.cjs +2 -0
  72. package/dist/node/infra/recase.cjs.map +1 -0
  73. package/dist/node/infra/recase.mjs +2 -0
  74. package/dist/node/infra/recase.mjs.map +1 -0
  75. package/dist/node/infra/runtime.cjs.map +1 -1
  76. package/dist/node/infra/runtime.mjs.map +1 -1
  77. package/dist/node/sources/{NodeEnvSource.cjs → FileSource.cjs} +2 -2
  78. package/dist/node/sources/FileSource.cjs.map +1 -0
  79. package/dist/node/sources/{NodeEnvSource.mjs → FileSource.mjs} +2 -2
  80. package/dist/node/sources/FileSource.mjs.map +1 -0
  81. package/dist/node/sources/{ManualEnvSource.cjs → PortableSource.cjs} +2 -2
  82. package/dist/node/sources/PortableSource.cjs.map +1 -0
  83. package/dist/{browser/sources/ManualEnvSource.mjs → node/sources/PortableSource.mjs} +2 -2
  84. package/dist/node/sources/PortableSource.mjs.map +1 -0
  85. package/dist/node/sources/{UnboundEnvSource.cjs → UnboundSource.cjs} +2 -2
  86. package/dist/node/sources/UnboundSource.cjs.map +1 -0
  87. package/dist/{browser/sources/UnboundEnvSource.mjs → node/sources/UnboundSource.mjs} +2 -2
  88. package/dist/node/sources/UnboundSource.mjs.map +1 -0
  89. package/dist/node/sources/coerce.cjs.map +1 -1
  90. package/dist/node/sources/coerce.mjs.map +1 -1
  91. package/dist/node/sources/merge.cjs +2 -0
  92. package/dist/node/sources/merge.cjs.map +1 -0
  93. package/dist/node/sources/merge.mjs +2 -0
  94. package/dist/node/sources/merge.mjs.map +1 -0
  95. package/dist/portable/converters/BuiltInConverters.mjs +2 -0
  96. package/dist/portable/converters/BuiltInConverters.mjs.map +1 -0
  97. package/dist/portable/converters/Converters.mjs.map +1 -0
  98. package/dist/portable/converters/ValueConverter.mjs +2 -0
  99. package/dist/portable/converters/ValueConverter.mjs.map +1 -0
  100. package/dist/portable/core/AdvancedMethods.mjs +2 -0
  101. package/dist/portable/core/AdvancedMethods.mjs.map +1 -0
  102. package/dist/portable/core/EnvapterBase.mjs +2 -0
  103. package/dist/portable/core/EnvapterBase.mjs.map +1 -0
  104. package/dist/portable/core/Environment.mjs +2 -0
  105. package/dist/portable/core/Environment.mjs.map +1 -0
  106. package/dist/portable/core/EnvironmentMethods.mjs +2 -0
  107. package/dist/portable/core/EnvironmentMethods.mjs.map +1 -0
  108. package/dist/portable/core/PrimitiveMethods.mjs +2 -0
  109. package/dist/portable/core/PrimitiveMethods.mjs.map +1 -0
  110. package/dist/portable/core/engine.mjs +2 -0
  111. package/dist/portable/core/engine.mjs.map +1 -0
  112. package/dist/portable/core/paths.mjs +2 -0
  113. package/dist/portable/core/paths.mjs.map +1 -0
  114. package/dist/portable/core/state.mjs +2 -0
  115. package/dist/portable/core/state.mjs.map +1 -0
  116. package/dist/portable/decorators/resolveDecoratorValue.mjs +2 -0
  117. package/dist/portable/decorators/resolveDecoratorValue.mjs.map +1 -0
  118. package/dist/portable/engine/Envapter.mjs +2 -0
  119. package/dist/portable/engine/Envapter.mjs.map +1 -0
  120. package/dist/portable/engine/PortableEnvapter.mjs +2 -0
  121. package/dist/portable/engine/PortableEnvapter.mjs.map +1 -0
  122. package/dist/portable/engine/TemplateResolver.mjs +2 -0
  123. package/dist/portable/engine/TemplateResolver.mjs.map +1 -0
  124. package/dist/portable/engine/Validators.mjs +2 -0
  125. package/dist/portable/engine/Validators.mjs.map +1 -0
  126. package/dist/portable/engine/fileApiStub.mjs +2 -0
  127. package/dist/portable/engine/fileApiStub.mjs.map +1 -0
  128. package/dist/portable/index.mjs +1 -0
  129. package/dist/{browser → portable}/infra/Error.mjs +1 -1
  130. package/dist/{browser → portable}/infra/Error.mjs.map +1 -1
  131. package/dist/portable/infra/recase.mjs +2 -0
  132. package/dist/portable/infra/recase.mjs.map +1 -0
  133. package/dist/portable/infra/runtime.mjs.map +1 -0
  134. package/dist/{browser/sources/WorkerEnvSource.mjs → portable/sources/PortableSource.mjs} +2 -2
  135. package/dist/portable/sources/PortableSource.mjs.map +1 -0
  136. package/dist/{node/sources/UnboundEnvSource.mjs → portable/sources/UnboundSource.mjs} +2 -2
  137. package/dist/portable/sources/UnboundSource.mjs.map +1 -0
  138. package/dist/portable/sources/coerce.mjs.map +1 -0
  139. package/dist/portable/sources/merge.mjs +2 -0
  140. package/dist/portable/sources/merge.mjs.map +1 -0
  141. package/dist/types/converters/Converters.d.mts +1 -15
  142. package/dist/types/core/AdvancedMethods.d.mts +31 -19
  143. package/dist/types/core/EnvapterBase.d.mts +16 -30
  144. package/dist/types/core/Environment.d.mts +25 -0
  145. package/dist/types/core/EnvironmentMethods.d.mts +2 -67
  146. package/dist/types/core/PrimitiveMethods.d.mts +2 -10
  147. package/dist/types/engine/Envapter.d.mts +2 -3
  148. package/dist/types/engine/NodeEnvapter.d.mts +4 -7
  149. package/dist/types/engine/PortableEnvapter.d.mts +17 -5
  150. package/dist/types/index.d.mts +10 -13
  151. package/dist/types/index.portable.d.mts +9 -12
  152. package/dist/types/infra/Error.d.mts +3 -1
  153. package/dist/types/infra/StandardSchema.d.mts +1 -12
  154. package/dist/types/sources/{NodeEnvSource.d.mts → FileSource.d.mts} +5 -5
  155. package/dist/types/sources/PortableSource.d.mts +24 -0
  156. package/dist/types/sources/merge.d.mts +13 -0
  157. package/dist/types/types/Casing.d.mts +8 -0
  158. package/dist/types/types/Conversion.d.mts +9 -66
  159. package/dist/types/types/Decorator.d.mts +0 -14
  160. package/dist/types/types/Env.d.mts +1 -10
  161. package/dist/types/types/Options.d.mts +9 -2
  162. package/dist/types/types/Schema.d.mts +1 -13
  163. package/dist/types/types/Source.d.mts +8 -28
  164. package/package.json +62 -19
  165. package/aliases/browser.d.mts +0 -7
  166. package/aliases/browser.mjs +0 -4
  167. package/aliases/workerd.d.mts +0 -7
  168. package/aliases/workerd.mjs +0 -4
  169. package/dist/browser/converters/BuiltInConverters.mjs +0 -2
  170. package/dist/browser/converters/BuiltInConverters.mjs.map +0 -1
  171. package/dist/browser/converters/Converters.mjs.map +0 -1
  172. package/dist/browser/converters/ValueConverter.mjs +0 -2
  173. package/dist/browser/converters/ValueConverter.mjs.map +0 -1
  174. package/dist/browser/core/AdvancedMethods.mjs +0 -2
  175. package/dist/browser/core/AdvancedMethods.mjs.map +0 -1
  176. package/dist/browser/core/EnvapterBase.mjs +0 -2
  177. package/dist/browser/core/EnvapterBase.mjs.map +0 -1
  178. package/dist/browser/core/EnvironmentMethods.mjs +0 -2
  179. package/dist/browser/core/EnvironmentMethods.mjs.map +0 -1
  180. package/dist/browser/core/PrimitiveMethods.mjs +0 -2
  181. package/dist/browser/core/PrimitiveMethods.mjs.map +0 -1
  182. package/dist/browser/decorators/resolveDecoratorValue.mjs +0 -2
  183. package/dist/browser/decorators/resolveDecoratorValue.mjs.map +0 -1
  184. package/dist/browser/engine/Envapter.mjs +0 -2
  185. package/dist/browser/engine/Envapter.mjs.map +0 -1
  186. package/dist/browser/engine/PortableEnvapter.mjs +0 -2
  187. package/dist/browser/engine/PortableEnvapter.mjs.map +0 -1
  188. package/dist/browser/engine/TemplateResolver.mjs +0 -2
  189. package/dist/browser/engine/TemplateResolver.mjs.map +0 -1
  190. package/dist/browser/engine/Validators.mjs +0 -2
  191. package/dist/browser/engine/Validators.mjs.map +0 -1
  192. package/dist/browser/engine/installFileApiStubs.mjs +0 -2
  193. package/dist/browser/engine/installFileApiStubs.mjs.map +0 -1
  194. package/dist/browser/index.mjs +0 -1
  195. package/dist/browser/infra/runtime.mjs.map +0 -1
  196. package/dist/browser/sources/ManualEnvSource.mjs.map +0 -1
  197. package/dist/browser/sources/UnboundEnvSource.mjs.map +0 -1
  198. package/dist/browser/sources/WorkerEnvSource.mjs.map +0 -1
  199. package/dist/browser/sources/coerce.mjs.map +0 -1
  200. package/dist/node/sources/ManualEnvSource.cjs.map +0 -1
  201. package/dist/node/sources/ManualEnvSource.mjs +0 -2
  202. package/dist/node/sources/ManualEnvSource.mjs.map +0 -1
  203. package/dist/node/sources/NodeEnvSource.cjs.map +0 -1
  204. package/dist/node/sources/NodeEnvSource.mjs.map +0 -1
  205. package/dist/node/sources/UnboundEnvSource.cjs.map +0 -1
  206. package/dist/node/sources/UnboundEnvSource.mjs.map +0 -1
  207. package/dist/node/sources/WorkerEnvSource.cjs +0 -2
  208. package/dist/node/sources/WorkerEnvSource.cjs.map +0 -1
  209. package/dist/node/sources/WorkerEnvSource.mjs +0 -2
  210. package/dist/node/sources/WorkerEnvSource.mjs.map +0 -1
  211. package/dist/types/converters/ValueConverter.d.mts +0 -25
  212. package/dist/types/engine/TemplateResolver.d.mts +0 -17
  213. package/dist/types/sources/ManualEnvSource.d.mts +0 -22
  214. package/dist/types/sources/WorkerEnvSource.d.mts +0 -22
  215. package/dist/workerd/converters/BuiltInConverters.mjs +0 -2
  216. package/dist/workerd/converters/BuiltInConverters.mjs.map +0 -1
  217. package/dist/workerd/converters/Converters.mjs +0 -2
  218. package/dist/workerd/converters/Converters.mjs.map +0 -1
  219. package/dist/workerd/converters/ListOfBuiltInConverters.mjs +0 -2
  220. package/dist/workerd/converters/ListOfBuiltInConverters.mjs.map +0 -1
  221. package/dist/workerd/converters/ValueConverter.mjs +0 -2
  222. package/dist/workerd/converters/ValueConverter.mjs.map +0 -1
  223. package/dist/workerd/core/AdvancedMethods.mjs +0 -2
  224. package/dist/workerd/core/AdvancedMethods.mjs.map +0 -1
  225. package/dist/workerd/core/EnvapterBase.mjs +0 -2
  226. package/dist/workerd/core/EnvapterBase.mjs.map +0 -1
  227. package/dist/workerd/core/EnvironmentMethods.mjs +0 -2
  228. package/dist/workerd/core/EnvironmentMethods.mjs.map +0 -1
  229. package/dist/workerd/core/PrimitiveMethods.mjs +0 -2
  230. package/dist/workerd/core/PrimitiveMethods.mjs.map +0 -1
  231. package/dist/workerd/decorators/legacy/Envapt.mjs +0 -2
  232. package/dist/workerd/decorators/legacy/Envapt.mjs.map +0 -1
  233. package/dist/workerd/decorators/legacy/SugarDecorators.mjs +0 -2
  234. package/dist/workerd/decorators/legacy/SugarDecorators.mjs.map +0 -1
  235. package/dist/workerd/decorators/legacy/createPropertyDecorator.mjs +0 -2
  236. package/dist/workerd/decorators/legacy/createPropertyDecorator.mjs.map +0 -1
  237. package/dist/workerd/decorators/modern/Envapt.mjs +0 -2
  238. package/dist/workerd/decorators/modern/Envapt.mjs.map +0 -1
  239. package/dist/workerd/decorators/modern/SugarDecorators.mjs +0 -2
  240. package/dist/workerd/decorators/modern/SugarDecorators.mjs.map +0 -1
  241. package/dist/workerd/decorators/modern/createAccessorDecorator.mjs +0 -2
  242. package/dist/workerd/decorators/modern/createAccessorDecorator.mjs.map +0 -1
  243. package/dist/workerd/decorators/parseEnvaptOptions.mjs +0 -2
  244. package/dist/workerd/decorators/parseEnvaptOptions.mjs.map +0 -1
  245. package/dist/workerd/decorators/resolveDecoratorValue.mjs +0 -2
  246. package/dist/workerd/decorators/resolveDecoratorValue.mjs.map +0 -1
  247. package/dist/workerd/engine/Envapter.mjs +0 -2
  248. package/dist/workerd/engine/Envapter.mjs.map +0 -1
  249. package/dist/workerd/engine/PortableEnvapter.mjs +0 -2
  250. package/dist/workerd/engine/PortableEnvapter.mjs.map +0 -1
  251. package/dist/workerd/engine/TemplateResolver.mjs +0 -2
  252. package/dist/workerd/engine/TemplateResolver.mjs.map +0 -1
  253. package/dist/workerd/engine/Validators.mjs +0 -2
  254. package/dist/workerd/engine/Validators.mjs.map +0 -1
  255. package/dist/workerd/engine/installFileApiStubs.mjs +0 -2
  256. package/dist/workerd/engine/installFileApiStubs.mjs.map +0 -1
  257. package/dist/workerd/index.mjs +0 -1
  258. package/dist/workerd/infra/Debug.mjs +0 -2
  259. package/dist/workerd/infra/Debug.mjs.map +0 -1
  260. package/dist/workerd/infra/Dotenv.mjs +0 -3
  261. package/dist/workerd/infra/Dotenv.mjs.map +0 -1
  262. package/dist/workerd/infra/Error.mjs +0 -2
  263. package/dist/workerd/infra/Error.mjs.map +0 -1
  264. package/dist/workerd/infra/runtime.mjs +0 -2
  265. package/dist/workerd/infra/runtime.mjs.map +0 -1
  266. package/dist/workerd/legacy.mjs +0 -1
  267. package/dist/workerd/sources/ManualEnvSource.mjs +0 -2
  268. package/dist/workerd/sources/ManualEnvSource.mjs.map +0 -1
  269. package/dist/workerd/sources/UnboundEnvSource.mjs +0 -2
  270. package/dist/workerd/sources/UnboundEnvSource.mjs.map +0 -1
  271. package/dist/workerd/sources/WorkerEnvSource.mjs +0 -2
  272. package/dist/workerd/sources/WorkerEnvSource.mjs.map +0 -1
  273. package/dist/workerd/sources/coerce.mjs +0 -2
  274. package/dist/workerd/sources/coerce.mjs.map +0 -1
  275. /package/dist/{browser → portable}/converters/Converters.mjs +0 -0
  276. /package/dist/{browser → portable}/converters/ListOfBuiltInConverters.mjs +0 -0
  277. /package/dist/{browser → portable}/converters/ListOfBuiltInConverters.mjs.map +0 -0
  278. /package/dist/{browser → portable}/decorators/legacy/Envapt.mjs +0 -0
  279. /package/dist/{browser → portable}/decorators/legacy/Envapt.mjs.map +0 -0
  280. /package/dist/{browser → portable}/decorators/legacy/SugarDecorators.mjs +0 -0
  281. /package/dist/{browser → portable}/decorators/legacy/SugarDecorators.mjs.map +0 -0
  282. /package/dist/{browser → portable}/decorators/legacy/createPropertyDecorator.mjs +0 -0
  283. /package/dist/{browser → portable}/decorators/legacy/createPropertyDecorator.mjs.map +0 -0
  284. /package/dist/{browser → portable}/decorators/modern/Envapt.mjs +0 -0
  285. /package/dist/{browser → portable}/decorators/modern/Envapt.mjs.map +0 -0
  286. /package/dist/{browser → portable}/decorators/modern/SugarDecorators.mjs +0 -0
  287. /package/dist/{browser → portable}/decorators/modern/SugarDecorators.mjs.map +0 -0
  288. /package/dist/{browser → portable}/decorators/modern/createAccessorDecorator.mjs +0 -0
  289. /package/dist/{browser → portable}/decorators/modern/createAccessorDecorator.mjs.map +0 -0
  290. /package/dist/{browser → portable}/decorators/parseEnvaptOptions.mjs +0 -0
  291. /package/dist/{browser → portable}/decorators/parseEnvaptOptions.mjs.map +0 -0
  292. /package/dist/{browser → portable}/infra/Debug.mjs +0 -0
  293. /package/dist/{browser → portable}/infra/Debug.mjs.map +0 -0
  294. /package/dist/{browser → portable}/infra/Dotenv.mjs +0 -0
  295. /package/dist/{browser → portable}/infra/Dotenv.mjs.map +0 -0
  296. /package/dist/{browser → portable}/infra/runtime.mjs +0 -0
  297. /package/dist/{browser → portable}/legacy.mjs +0 -0
  298. /package/dist/{browser → portable}/sources/coerce.mjs +0 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AdvancedMethods.mjs","names":[],"sources":["../../../src/core/AdvancedMethods.ts"],"sourcesContent":["import { resolveKeyInput, templateResolver, treatAsMissing, valueConverter } from './engine';\nimport { PrimitiveMethods } from './PrimitiveMethods';\nimport { debugWarn } from '../infra/Debug';\nimport { EnvaptError, EnvaptErrorCodes } from '../infra/Error';\nimport { recase } from '../infra/recase';\n\nimport type { ArrayOf } from '../converters';\nimport type { TemplateResolver } from '../engine/TemplateResolver';\nimport type { InferSchemaOutput, StandardSchemaV1 } from '../infra/StandardSchema';\nimport type {\n AdvancedConverterReturn,\n BuiltInConverter,\n ConditionalReturn,\n ConverterFunction,\n EnvaptConverter,\n EnvKeyInput,\n InferConverterReturnType,\n InferSpecField,\n KeyCasing,\n RecaseKey,\n RequiredSpec,\n SchemaConstraint,\n TimeFallback\n} from '../types';\n\nfunction formatKeyForError(key: EnvKeyInput): string {\n return Array.isArray(key) ? `[${key.join(', ')}]` : String(key);\n}\n\n// template-resolve a present value, treating a post-trim-empty result as missing regardless of strict.\n// a module function so getRequired/getRequiredAll and Envapter.require share it without exposing it on any subclass.\nexport function resolveRequired(\n resolved: { key: string; value: string | undefined },\n templateResolver: TemplateResolver\n): { key: string; value: string | undefined } {\n if (resolved.value === undefined) return resolved;\n const value = templateResolver.resolveTemplate(resolved.key, resolved.value);\n return { key: resolved.key, value: value.trim() === '' ? undefined : value };\n}\n\n/**\n * Mixin for advanced methods for environment variable conversion using built-in and custom converters\n * @internal\n */\nexport class AdvancedMethods extends PrimitiveMethods {\n /**\n * Get an environment variable using a built-in converter.\n *\n * Supports both scalar tokens (e.g. `Converters.Number`) and `ArrayOf<...>` tokens\n * produced by `Converters.array(...)`. The key can be a single name or an ordered list.\n * The first defined value wins.\n */\n // Time-specific overload must precede the generic BuiltInConverter overload so it wins\n // overload resolution (TimeFallback accepts time-strings like `'10s'`).\n static getUsing<TFallback extends TimeFallback | undefined = undefined>(\n key: EnvKeyInput,\n converter: 'time',\n fallback?: TFallback\n ): ConditionalReturn<number, TFallback>;\n static getUsing<TConverter extends BuiltInConverter | ArrayOf, TFallback = undefined>(\n key: EnvKeyInput,\n converter: TConverter,\n fallback?: TFallback\n ): AdvancedConverterReturn<TConverter, TFallback>;\n static getUsing<TReturn>(key: EnvKeyInput, converter: BuiltInConverter | ArrayOf, fallback?: TReturn): TReturn;\n static getUsing<TConverter extends BuiltInConverter | ArrayOf, TFallback = undefined>(\n key: EnvKeyInput,\n converter: TConverter,\n fallback?: TFallback\n ): AdvancedConverterReturn<TConverter, TFallback> {\n const { key: resolvedKey, value } = resolveKeyInput(key);\n\n // missing with no fallback returns undefined, matching the primitive methods. with a fallback,\n // route through the parser so asymmetric types (TimeFallback, TimeFallback[] for `of: time`)\n // coerce to the return type.\n if (treatAsMissing(value) && fallback === undefined) {\n debugWarn(`${resolvedKey} is missing or empty`);\n return undefined as AdvancedConverterReturn<TConverter, TFallback>;\n }\n\n const hasFallback = fallback !== undefined;\n const result = valueConverter.convertValue(resolvedKey, fallback, converter, hasFallback);\n\n return result as AdvancedConverterReturn<TConverter, TFallback>;\n }\n\n /**\n * @see {@link AdvancedMethods.getUsing}\n */\n getUsing<TFallback extends TimeFallback | undefined = undefined>(\n key: EnvKeyInput,\n converter: 'time',\n fallback?: TFallback\n ): ConditionalReturn<number, TFallback>;\n getUsing<TConverter extends BuiltInConverter | ArrayOf, TFallback = undefined>(\n key: EnvKeyInput,\n converter: TConverter,\n fallback?: TFallback\n ): AdvancedConverterReturn<TConverter, TFallback>;\n getUsing<TReturn>(key: EnvKeyInput, converter: BuiltInConverter | ArrayOf, fallback?: TReturn): TReturn;\n getUsing<TConverter extends BuiltInConverter | ArrayOf, TFallback = undefined>(\n key: EnvKeyInput,\n converter: TConverter,\n fallback?: TFallback\n ): AdvancedConverterReturn<TConverter, TFallback> {\n return AdvancedMethods.getUsing(key, converter, fallback);\n }\n\n /**\n * Get an environment variable using a custom converter function.\n * Accepts a single key or an ordered list for automatic fallback.\n */\n static getWith<TReturnType, TFallback extends TReturnType | undefined = undefined>(\n key: EnvKeyInput,\n converter: ConverterFunction<TReturnType>,\n fallback?: TFallback\n ): ConditionalReturn<TReturnType, TFallback> {\n const { key: resolvedKey, value } = resolveKeyInput(key);\n if (treatAsMissing(value)) {\n debugWarn(`${resolvedKey} is missing or empty`);\n return fallback as ConditionalReturn<TReturnType, TFallback>;\n }\n\n const hasFallback = fallback !== undefined;\n const result = valueConverter.convertValue<TReturnType>(resolvedKey, fallback, converter, hasFallback);\n\n return result as ConditionalReturn<TReturnType, TFallback>;\n }\n\n /**\n * @see {@link AdvancedMethods.getWith}\n */\n getWith<TReturnType, TFallback extends TReturnType | undefined = undefined>(\n key: EnvKeyInput,\n converter: ConverterFunction<TReturnType>,\n fallback?: TFallback\n ): ConditionalReturn<TReturnType, TFallback> {\n return AdvancedMethods.getWith(key, converter, fallback);\n }\n\n /**\n * Read a required environment variable and convert it, throwing `MissingEnvValue` when the value\n * is missing or empty. Returns the non-undefined converter output. Accepts a built-in or `ArrayOf`\n * token, or a custom parser function. The key can be a single name or an ordered list.\n */\n static getRequired<TConverter extends BuiltInConverter | ArrayOf>(\n key: EnvKeyInput,\n converter: TConverter\n ): InferConverterReturnType<TConverter>;\n static getRequired<TReturnType>(key: EnvKeyInput, converter: ConverterFunction<TReturnType, string>): TReturnType;\n static getRequired<TConverter extends BuiltInConverter | ArrayOf, TReturnType>(\n key: EnvKeyInput,\n converter: TConverter | ConverterFunction<TReturnType, string>\n ): InferConverterReturnType<TConverter> | TReturnType {\n // a required read treats empty as missing, so an empty value falls through to the next candidate.\n const candidates: readonly string[] = typeof key === 'string' ? [key] : key;\n let resolvedKey = '';\n let value: string | undefined;\n for (const candidate of candidates) {\n const resolved = resolveRequired(resolveKeyInput(candidate), templateResolver);\n resolvedKey = resolved.key;\n if (resolved.value !== undefined) {\n value = resolved.value;\n break;\n }\n }\n if (value === undefined) {\n throw new EnvaptError(\n EnvaptErrorCodes.MissingEnvValue,\n `Required environment variable \"${formatKeyForError(key)}\" is missing or empty.`\n );\n }\n // cast widens the raw-string parser back to convertValue's ConverterFunction<T> (value proven present above).\n const result = valueConverter.convertValue<TReturnType>(\n resolvedKey,\n undefined,\n converter as EnvaptConverter<TReturnType>,\n false\n );\n // convertValue returns null for a present value it can't convert, which would break the non-undefined return.\n if (result === undefined || result === null) {\n throw new EnvaptError(\n EnvaptErrorCodes.MissingEnvValue,\n `Required environment variable \"${formatKeyForError(key)}\" is present but could not be converted.`\n );\n }\n return result;\n }\n\n /**\n * @see {@link AdvancedMethods.getRequired}\n */\n getRequired<TConverter extends BuiltInConverter | ArrayOf>(\n key: EnvKeyInput,\n converter: TConverter\n ): InferConverterReturnType<TConverter>;\n getRequired<TReturnType>(key: EnvKeyInput, converter: ConverterFunction<TReturnType, string>): TReturnType;\n getRequired<TConverter extends BuiltInConverter | ArrayOf, TReturnType>(\n key: EnvKeyInput,\n converter: TConverter | ConverterFunction<TReturnType, string>\n ): InferConverterReturnType<TConverter> | TReturnType {\n return AdvancedMethods.getRequired(key, converter as ConverterFunction<TReturnType, string>);\n }\n\n /**\n * Read a group of required environment variables in one call. Each key in `spec` maps to a\n * converter (a token, an `array()` token, or a custom parser), and the returned record holds\n * every converted value, all non-undefined. Collects every missing or empty key and throws one\n * `MissingEnvValue` listing them all. Pass a `casing` (`'camelCase'`, `'PascalCase'`, or\n * `'kebab-case'`) to rename the record keys, splitting on underscores, which assumes the\n * conventional SCREAMING_SNAKE env-var names. With no casing the keys stay as-is.\n */\n static getRequiredAll<Spec extends RequiredSpec, Casing extends KeyCasing | undefined = undefined>(\n spec: Spec,\n casing?: Casing\n ): { [K in keyof Spec as RecaseKey<K & string, Casing>]: InferSpecField<Spec[K]> } {\n const keys = Object.keys(spec);\n const missing = keys.filter(\n (key) => resolveRequired(resolveKeyInput(key), templateResolver).value === undefined\n );\n if (missing.length > 0) {\n throw new EnvaptError(\n EnvaptErrorCodes.MissingEnvValue,\n `Missing required environment variables: ${missing.join(', ')}.`\n );\n }\n\n const result: Record<string, unknown> = {};\n for (const key of keys) {\n // same widening cast as getRequired, every value was proven present above.\n const converted = valueConverter.convertValue<unknown>(\n key,\n undefined,\n spec[key] as EnvaptConverter<unknown>,\n false\n );\n if (converted === undefined || converted === null) {\n throw new EnvaptError(\n EnvaptErrorCodes.MissingEnvValue,\n `Required environment variable \"${key}\" is present but could not be converted.`\n );\n }\n result[recase(key, casing)] = converted;\n }\n return result as { [K in keyof Spec as RecaseKey<K & string, Casing>]: InferSpecField<Spec[K]> };\n }\n\n /**\n * @see {@link AdvancedMethods.getRequiredAll}\n */\n getRequiredAll<Spec extends RequiredSpec, Casing extends KeyCasing | undefined = undefined>(\n spec: Spec,\n casing?: Casing\n ): { [K in keyof Spec as RecaseKey<K & string, Casing>]: InferSpecField<Spec[K]> } {\n return AdvancedMethods.getRequiredAll(spec, casing);\n }\n\n /**\n * Validate an environment variable through a {@link StandardSchemaV1}-conformant schema\n * (zod, valibot, arktype, etc). Throws `MissingEnvValue` if the env value is absent and\n * no fallback is provided. The fallback, when provided, is returned as-is on missing.\n * It does NOT pass through the schema, mirroring custom-converter behavior.\n *\n * Synchronous schemas only. A Promise-returning `validate` triggers an\n * `InvalidUserDefinedConfig` throw at the call site.\n *\n * @example\n * ```ts\n * import { z } from 'zod';\n * const port = Envapter.parse('PORT', z.coerce.number().min(1024).max(65535), 3000);\n * ```\n */\n static parse<Schema extends StandardSchemaV1>(\n key: EnvKeyInput,\n schema: SchemaConstraint<Schema>,\n fallback?: InferSchemaOutput<Schema>\n ): InferSchemaOutput<Schema> {\n const hasFallback = arguments.length > 2;\n // SchemaConstraint resolves to the unsatisfiable SchemaMustBeSync brand for async\n // schemas, so reaching this body means the input is structurally a sync Schema.\n const result = valueConverter.convertWithSchema(\n key,\n schema as unknown as StandardSchemaV1,\n fallback,\n hasFallback\n );\n return result;\n }\n\n /**\n * @see {@link AdvancedMethods.parse}\n */\n parse<Schema extends StandardSchemaV1>(\n key: EnvKeyInput,\n schema: SchemaConstraint<Schema>,\n fallback?: InferSchemaOutput<Schema>\n ): InferSchemaOutput<Schema> {\n const hasFallback = arguments.length > 2;\n const result = valueConverter.convertWithSchema(\n key,\n schema as unknown as StandardSchemaV1,\n fallback,\n hasFallback\n );\n return result;\n }\n}\n"],"mappings":"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"}
@@ -0,0 +1,2 @@
1
+ import{cache as e,state as t}from"./state.mjs";import{Validator as n}from"../engine/Validators.mjs";import{bindRuntimeFromSource as r}from"../infra/runtime.mjs";import{getDebugLevel as i,setDebugLevel as a}from"../infra/Debug.mjs";import{ensureLoaded as o,mirrorToProcessEnv as s,refreshCache as c,resolveKeyInput as l}from"./engine.mjs";var u=class{static set strict(e){t.strict=e,c()}static get strict(){return t.strict}static set debug(e){a(e)}static get debug(){return i()}static set syncProcessEnv(r){n.validateSyncProcessEnv(r);let i=t.syncProcessEnv;t.syncProcessEnv=r,!i&&r&&e.size>0&&s()}static get syncProcessEnv(){return t.syncProcessEnv}static set fileApiMode(e){n.validateFileApiMode(e),t.fileApiMode=e}static get fileApiMode(){return t.fileApiMode}static load(){o()}static useSource(e){t.source=e,r(e),c()}getRaw(e){return l(e).value}};export{u as EnvapterBase};
2
+ //# sourceMappingURL=EnvapterBase.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"EnvapterBase.mjs","names":[],"sources":["../../../src/core/EnvapterBase.ts"],"sourcesContent":["import { ensureLoaded, mirrorToProcessEnv, refreshCache, resolveKeyInput } from './engine';\nimport { cache, state } from './state';\nimport { Validator } from '../engine/Validators';\nimport { getDebugLevel, setDebugLevel } from '../infra/Debug';\nimport { bindRuntimeFromSource } from '../infra/runtime';\n\nimport type { DebugLevel } from '../infra/Debug';\nimport type { EnvKeyInput, FileApiMode, Source } from '../types';\n\n/** @internal */\nexport abstract class EnvapterBase {\n /**\n * Enable or disable strict mode. Default `false`. Setting refreshes the cache so\n * previously-cached converted values get re-evaluated under the new rule.\n */\n static set strict(value: boolean) {\n state.strict = value;\n refreshCache();\n }\n\n static get strict(): boolean {\n return state.strict;\n }\n\n /**\n * Set the debug log level. Defaults to `silent`. When unset, reads `ENVAPT_DEBUG` from the\n * bound source on first access. The setter overrides any env-var value. Output goes to stderr\n * on Node (the console elsewhere), prefixed with `[envapt]`.\n */\n static set debug(level: DebugLevel) {\n setDebugLevel(level);\n }\n\n static get debug(): DebugLevel {\n return getDebugLevel();\n }\n\n /**\n * Opt-in mirror of dotenv-loaded keys back to `process.env`. Default `false`.\n *\n * Only keys the loader actually wrote are mirrored, so collision behavior follows\n * `envFileOptions.override`: with the default `false`, pre-existing `process.env` values\n * are preserved. With `true`, the file value wins in both the cache and the mirror.\n *\n * Flipping `false → true` mirrors the existing tracked delta immediately (no cache\n * refresh). Flipping `true → false` is one-way: previously mirrored keys remain in\n * `process.env` until the process exits.\n */\n static set syncProcessEnv(value: boolean) {\n Validator.validateSyncProcessEnv(value);\n const previous = state.syncProcessEnv;\n state.syncProcessEnv = value;\n if (!previous && value && cache.size > 0) mirrorToProcessEnv();\n }\n\n static get syncProcessEnv(): boolean {\n return state.syncProcessEnv;\n }\n\n /**\n * On the portable build, this controls the filesystem-only config APIs (`envPaths`, `baseDir`,\n * `envFileOptions`, `configureProfiles`, `resetProfiles`). `'warn'` (the default) warns once and\n * no-ops, `'throw'` throws {@link EnvaptError} `FileApiUnsupported`. The node build runs these\n * APIs normally and this value has no effect there.\n */\n static set fileApiMode(mode: FileApiMode) {\n Validator.validateFileApiMode(mode);\n // no refreshCache, this only gates the portable stubs.\n state.fileApiMode = mode;\n }\n\n static get fileApiMode(): FileApiMode {\n return state.fileApiMode;\n }\n\n /**\n * Eagerly load the `.env` cascade now instead of lazily on the first read. Idempotent: a no-op\n * once the cache is built. Useful before mirroring to `process.env` (see {@link syncProcessEnv}),\n * which is what the `envapt/config` side-effect entry does.\n */\n static load(): void {\n ensureLoaded();\n }\n\n /**\n * Bind the environment {@link Source}. On Node the entry binds {@link FileSource} for you\n * (a `process.env` snapshot plus the `.env` cascade). On the browser or Workers, pass a\n * `PortableSource` (or any `Source`) before reading. Clears and rebuilds the cache.\n */\n static useSource(source: Source): void {\n state.source = source;\n bindRuntimeFromSource(source);\n refreshCache();\n }\n\n /**\n * Read an environment variable as its raw string, skipping parsing and conversion.\n */\n getRaw(key: EnvKeyInput): string | undefined {\n return resolveKeyInput(key).value;\n }\n}\n"],"mappings":"kVAUA,IAAsB,EAAtB,KAAmC,CAK/B,WAAW,OAAO,EAAgB,CAC9B,EAAM,OAAS,EACf,EAAa,CACjB,CAEA,WAAW,QAAkB,CACzB,OAAO,EAAM,MACjB,CAOA,WAAW,MAAM,EAAmB,CAChC,EAAc,CAAK,CACvB,CAEA,WAAW,OAAoB,CAC3B,OAAO,EAAc,CACzB,CAaA,WAAW,eAAe,EAAgB,CACtC,EAAU,uBAAuB,CAAK,EACtC,IAAM,EAAW,EAAM,eACvB,EAAM,eAAiB,EACnB,CAAC,GAAY,GAAS,EAAM,KAAO,GAAG,EAAmB,CACjE,CAEA,WAAW,gBAA0B,CACjC,OAAO,EAAM,cACjB,CAQA,WAAW,YAAY,EAAmB,CACtC,EAAU,oBAAoB,CAAI,EAElC,EAAM,YAAc,CACxB,CAEA,WAAW,aAA2B,CAClC,OAAO,EAAM,WACjB,CAOA,OAAO,MAAa,CAChB,EAAa,CACjB,CAOA,OAAO,UAAU,EAAsB,CACnC,EAAM,OAAS,EACf,EAAsB,CAAM,EAC5B,EAAa,CACjB,CAKA,OAAO,EAAsC,CACzC,OAAO,EAAgB,CAAG,CAAC,CAAC,KAChC,CACJ"}
@@ -0,0 +1,2 @@
1
+ let e=function(e){return e[e.Development=0]=`Development`,e[e.Staging=1]=`Staging`,e[e.Production=2]=`Production`,e[e.Test=3]=`Test`,e}({});const t=[`ENVIRONMENT`,`ENV`,`NODE_ENV`,`MODE`];function n(e){switch(e.toLowerCase()){case`production`:return 2;case`staging`:return 1;case`test`:return 3;case`development`:return 0;default:return}}function r(e){for(let n of t){let t=e(n);if(t!==void 0&&t.length>0)return t}}export{t as ENV_KEYS,e as Environment,r as firstEnvKeyValue,n as parseEnvironment};
2
+ //# sourceMappingURL=Environment.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Environment.mjs","names":[],"sources":["../../../src/core/Environment.ts"],"sourcesContent":["/**\n * Environment types supported by Envapter\n *\n * The following keys are checked in order until the first with a non-empty value is found, or defaulting to development if none are set:\n * - `ENVIRONMENT`\n * - `ENV`\n * - `NODE_ENV`\n * - `MODE`\n *\n * @public\n */\nexport enum Environment {\n /** The default when no environment variable names a known environment. */\n Development,\n /** Selected when an environment variable reads `staging`. */\n Staging,\n /** Selected when an environment variable reads `production`. */\n Production,\n /** Selected when an environment variable reads `test`. */\n Test\n}\n\n// highest precedence first\nexport const ENV_KEYS = ['ENVIRONMENT', 'ENV', 'NODE_ENV', 'MODE'] as const;\n\nexport function parseEnvironment(raw: string): Environment | undefined {\n switch (raw.toLowerCase()) {\n case 'production':\n return Environment.Production;\n case 'staging':\n return Environment.Staging;\n case 'test':\n return Environment.Test;\n case 'development':\n return Environment.Development;\n default:\n return undefined;\n }\n}\n\nexport function firstEnvKeyValue(read: (key: string) => string | undefined): string | undefined {\n for (const key of ENV_KEYS) {\n const value = read(key);\n if (value !== undefined && value.length > 0) return value;\n }\n return undefined;\n}\n"],"mappings":"AAWA,IAAY,EAAL,SAAA,EAAA,OAEH,GAAA,EAAA,YAAA,GAAA,cAEA,EAAA,EAAA,QAAA,GAAA,UAEA,EAAA,EAAA,WAAA,GAAA,aAEA,EAAA,EAAA,KAAA,GAAA,QACJ,EAAA,CAAA,CAAA,EAGA,MAAa,EAAW,CAAC,cAAe,MAAO,WAAY,MAAM,EAEjE,SAAgB,EAAiB,EAAsC,CACnE,OAAQ,EAAI,YAAY,EAAxB,CACI,IAAK,aACD,MAAA,GACJ,IAAK,UACD,MAAA,GACJ,IAAK,OACD,MAAA,GACJ,IAAK,cACD,MAAA,GACJ,QACI,MACR,CACJ,CAEA,SAAgB,EAAiB,EAA+D,CAC5F,IAAK,IAAM,KAAO,EAAU,CACxB,IAAM,EAAQ,EAAK,CAAG,EACtB,GAAI,IAAU,IAAA,IAAa,EAAM,OAAS,EAAG,OAAO,CACxD,CAEJ"}
@@ -0,0 +1,2 @@
1
+ import"./Environment.mjs";import{state as e}from"./state.mjs";import{determineEnvironment as t}from"./engine.mjs";import{EnvapterBase as n}from"./EnvapterBase.mjs";var r=class r extends n{static get environment(){return e.environment===void 0&&t(),e.environment}static set environment(e){t(e)}get environment(){return r.environment}set environment(e){t(e)}static get isProduction(){return this.environment===2}get isProduction(){return r.environment===2}static get isStaging(){return this.environment===1}get isStaging(){return r.environment===1}static get isDevelopment(){return this.environment===0}get isDevelopment(){return r.environment===0}static get isTest(){return this.environment===3}get isTest(){return r.environment===3}};export{r as EnvironmentMethods};
2
+ //# sourceMappingURL=EnvironmentMethods.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"EnvironmentMethods.mjs","names":[],"sources":["../../../src/core/EnvironmentMethods.ts"],"sourcesContent":["import { determineEnvironment } from './engine';\nimport { EnvapterBase } from './EnvapterBase';\nimport { Environment } from './Environment';\nimport { state } from './state';\n\n/**\n * Mixin for environment detection and checking methods\n * @internal\n */\nexport class EnvironmentMethods extends EnvapterBase {\n /**\n * Get the current application environment\n */\n static get environment(): Environment {\n if (state.environment === undefined) {\n determineEnvironment();\n }\n return state.environment as Environment;\n }\n\n /**\n * Set the application environment. Accepts either Environment enum or string value.\n */\n static set environment(env: string | Environment) {\n determineEnvironment(env);\n }\n\n /**\n * @see {@link EnvironmentMethods.environment}\n */\n get environment(): Environment {\n return EnvironmentMethods.environment;\n }\n\n /**\n * @see {@link EnvironmentMethods.environment}\n */\n set environment(env: string | Environment) {\n determineEnvironment(env);\n }\n\n /**\n * Check if the current environment is production\n */\n static get isProduction(): boolean {\n return this.environment === Environment.Production;\n }\n\n /**\n * @see {@link EnvironmentMethods.isProduction}\n */\n get isProduction(): boolean {\n return EnvironmentMethods.environment === Environment.Production;\n }\n\n /**\n * Check if the current environment is staging\n */\n static get isStaging(): boolean {\n return this.environment === Environment.Staging;\n }\n\n /**\n * @see {@link EnvironmentMethods.isStaging}\n */\n get isStaging(): boolean {\n return EnvironmentMethods.environment === Environment.Staging;\n }\n\n /**\n * Check if the current environment is development\n */\n static get isDevelopment(): boolean {\n return this.environment === Environment.Development;\n }\n\n /**\n * @see {@link EnvironmentMethods.isDevelopment}\n */\n get isDevelopment(): boolean {\n return EnvironmentMethods.environment === Environment.Development;\n }\n\n /**\n * Check if the current environment is test\n */\n static get isTest(): boolean {\n return this.environment === Environment.Test;\n }\n\n /**\n * @see {@link EnvironmentMethods.isTest}\n */\n get isTest(): boolean {\n return EnvironmentMethods.environment === Environment.Test;\n }\n}\n"],"mappings":"oKASA,IAAa,EAAb,MAAa,UAA2B,CAAa,CAIjD,WAAW,aAA2B,CAIlC,OAHI,EAAM,cAAgB,IAAA,IACtB,EAAqB,EAElB,EAAM,WACjB,CAKA,WAAW,YAAY,EAA2B,CAC9C,EAAqB,CAAG,CAC5B,CAKA,IAAI,aAA2B,CAC3B,OAAO,EAAmB,WAC9B,CAKA,IAAI,YAAY,EAA2B,CACvC,EAAqB,CAAG,CAC5B,CAKA,WAAW,cAAwB,CAC/B,OAAO,KAAK,cAAA,CAChB,CAKA,IAAI,cAAwB,CACxB,OAAO,EAAmB,cAAA,CAC9B,CAKA,WAAW,WAAqB,CAC5B,OAAO,KAAK,cAAA,CAChB,CAKA,IAAI,WAAqB,CACrB,OAAO,EAAmB,cAAA,CAC9B,CAKA,WAAW,eAAyB,CAChC,OAAO,KAAK,cAAA,CAChB,CAKA,IAAI,eAAyB,CACzB,OAAO,EAAmB,cAAA,CAC9B,CAKA,WAAW,QAAkB,CACzB,OAAO,KAAK,cAAA,CAChB,CAKA,IAAI,QAAkB,CAClB,OAAO,EAAmB,cAAA,CAC9B,CACJ"}
@@ -0,0 +1,2 @@
1
+ import{readPrimitive as e}from"./engine.mjs";import{EnvironmentMethods as t}from"./EnvironmentMethods.mjs";var n=class extends t{static get(t,n){return e(t,0,n)}get(t,n){return e(t,0,n)}static getNumber(t,n){return e(t,1,n)}getNumber(t,n){return e(t,1,n)}static getBoolean(t,n){return e(t,2,n)}getBoolean(t,n){return e(t,2,n)}static getBigInt(t,n){return e(t,3,n)}getBigInt(t,n){return e(t,3,n)}static getSymbol(t,n){return e(t,4,n)}getSymbol(t,n){return e(t,4,n)}};export{n as PrimitiveMethods};
2
+ //# sourceMappingURL=PrimitiveMethods.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PrimitiveMethods.mjs","names":[],"sources":["../../../src/core/PrimitiveMethods.ts"],"sourcesContent":["import { Primitive, readPrimitive } from './engine';\nimport { EnvironmentMethods } from './EnvironmentMethods';\n\nimport type { ConditionalReturn, EnvKeyInput } from '../types';\n\n/**\n * @internal\n */\nexport class PrimitiveMethods extends EnvironmentMethods {\n /**\n * Get a string environment variable with optional fallback.\n * Supports template variable resolution using `${VAR}` syntax.\n * Accepts a single key or an ordered array of keys (first match wins).\n */\n static get<Default extends string | undefined = undefined>(\n key: EnvKeyInput,\n def?: Default\n ): ConditionalReturn<string, Default> {\n return readPrimitive(key, Primitive.String, def);\n }\n\n /**\n * @see {@link PrimitiveMethods.get}\n */\n get<Default extends string | undefined = undefined>(\n key: EnvKeyInput,\n def?: Default\n ): ConditionalReturn<string, Default> {\n return readPrimitive(key, Primitive.String, def);\n }\n\n /**\n * Get a number environment variable with optional fallback.\n * Automatically converts string values to numbers.\n * Accepts a single key or an ordered array of keys (first match wins).\n */\n static getNumber<Default extends number | undefined = undefined>(\n key: EnvKeyInput,\n def?: Default\n ): ConditionalReturn<number, Default> {\n return readPrimitive(key, Primitive.Number, def);\n }\n\n /**\n * @see {@link PrimitiveMethods.getNumber}\n */\n getNumber<Default extends number | undefined = undefined>(\n key: EnvKeyInput,\n def?: Default\n ): ConditionalReturn<number, Default> {\n return readPrimitive(key, Primitive.Number, def);\n }\n\n /**\n * Get a boolean environment variable with optional fallback.\n * Recognizes: `1`, `yes`, `true`, `on` as **true**; `0`, `no`, `false`, `off` as **false** (case-insensitive).\n * Accepts a single key or an ordered array of keys (first match wins).\n */\n static getBoolean<Default extends boolean | undefined = undefined>(\n key: EnvKeyInput,\n def?: Default\n ): ConditionalReturn<boolean, Default> {\n return readPrimitive(key, Primitive.Boolean, def);\n }\n\n /**\n * @see {@link PrimitiveMethods.getBoolean}\n */\n getBoolean<Default extends boolean | undefined = undefined>(\n key: EnvKeyInput,\n def?: Default\n ): ConditionalReturn<boolean, Default> {\n return readPrimitive(key, Primitive.Boolean, def);\n }\n\n /**\n * Get a bigint environment variable with optional fallback.\n * Automatically converts string values to bigint.\n * Accepts a single key or an ordered array of keys (first match wins).\n */\n static getBigInt<Default extends bigint | undefined = undefined>(\n key: EnvKeyInput,\n def?: Default\n ): ConditionalReturn<bigint, Default> {\n return readPrimitive(key, Primitive.BigInt, def);\n }\n\n /**\n * @see {@link PrimitiveMethods.getBigInt}\n */\n getBigInt<Default extends bigint | undefined = undefined>(\n key: EnvKeyInput,\n def?: Default\n ): ConditionalReturn<bigint, Default> {\n return readPrimitive(key, Primitive.BigInt, def);\n }\n\n /**\n * Get a symbol environment variable with optional fallback.\n * Creates a symbol from the string value.\n * Accepts a single key or an ordered array of keys (first match wins).\n */\n static getSymbol<Default extends symbol | undefined = undefined>(\n key: EnvKeyInput,\n def?: Default\n ): ConditionalReturn<symbol, Default> {\n return readPrimitive(key, Primitive.Symbol, def);\n }\n\n /**\n * @see {@link PrimitiveMethods.getSymbol}\n */\n getSymbol<Default extends symbol | undefined = undefined>(\n key: EnvKeyInput,\n def?: Default\n ): ConditionalReturn<symbol, Default> {\n return readPrimitive(key, Primitive.Symbol, def);\n }\n}\n"],"mappings":"2GAQA,IAAa,EAAb,cAAsC,CAAmB,CAMrD,OAAO,IACH,EACA,EACkC,CAClC,OAAO,EAAc,EAAA,EAAuB,CAAG,CACnD,CAKA,IACI,EACA,EACkC,CAClC,OAAO,EAAc,EAAA,EAAuB,CAAG,CACnD,CAOA,OAAO,UACH,EACA,EACkC,CAClC,OAAO,EAAc,EAAA,EAAuB,CAAG,CACnD,CAKA,UACI,EACA,EACkC,CAClC,OAAO,EAAc,EAAA,EAAuB,CAAG,CACnD,CAOA,OAAO,WACH,EACA,EACmC,CACnC,OAAO,EAAc,EAAA,EAAwB,CAAG,CACpD,CAKA,WACI,EACA,EACmC,CACnC,OAAO,EAAc,EAAA,EAAwB,CAAG,CACpD,CAOA,OAAO,UACH,EACA,EACkC,CAClC,OAAO,EAAc,EAAA,EAAuB,CAAG,CACnD,CAKA,UACI,EACA,EACkC,CAClC,OAAO,EAAc,EAAA,EAAuB,CAAG,CACnD,CAOA,OAAO,UACH,EACA,EACkC,CAClC,OAAO,EAAc,EAAA,EAAuB,CAAG,CACnD,CAKA,UACI,EACA,EACkC,CAClC,OAAO,EAAc,EAAA,EAAuB,CAAG,CACnD,CACJ"}
@@ -0,0 +1,2 @@
1
+ import{ENV_KEYS as e,firstEnvKeyValue as t,parseEnvironment as n}from"./Environment.mjs";import{EnvaptError as r}from"../infra/Error.mjs";import{BuiltInConverters as i}from"../converters/BuiltInConverters.mjs";import{cache as a,state as o}from"./state.mjs";import{ValueConverter as s}from"../converters/ValueConverter.mjs";import{resolveEffectivePaths as c}from"./paths.mjs";import{debugVerbose as l,debugWarn as u}from"../infra/Debug.mjs";import{TemplateResolver as d}from"../engine/TemplateResolver.mjs";import{loadDotenv as f}from"../infra/Dotenv.mjs";function p(e){let t=Array.isArray(e)?e:[e];if(t.length===0)throw new r(304,`At least one environment key must be provided.`);if(t.some(e=>typeof e!=`string`))throw new r(304,`Environment keys must be strings.`);if(t.some(e=>e.trim()===``))throw new r(304,`Environment keys cannot be empty strings.`);for(let e of t){let t=h().get(e);if(t!==void 0)return{key:e,value:t}}return{key:t[0],value:void 0}}function m(e){return!!(e===void 0||e===``||o.strict&&e.trim()===``)}function h(){if(!o.cacheBuilt){let e=o.source,t={...e.readVars()},n=new Set;if(e.supportsFiles){l(`base dir: ${o.baseDir??`working directory`}`);let r=c();l(`effective .env paths: ${r.length===0?`(none)`:r.join(`, `)}`);try{n=f({...o.userDefinedEnvFileOptions,path:r,processEnv:t,readFile:e.readFile.bind(e)})}catch(e){u(`failed to load .env: ${e instanceof Error?e.message:String(e)}`)}}o.dotenvAddedKeys=n;for(let[e,n]of Object.entries(t))a.set(e,n);l(`cache populated: ${a.size} keys total`),o.cacheBuilt=!0,o.syncProcessEnv&&_()}return a}function g(){o.environmentExplicitlySet||(o.environment=void 0),a.clear(),o.cacheBuilt=!1,o.dotenvAddedKeys=new Set,l(`cache cleared, reloading config`),h()}function _(){if(o.dotenvAddedKeys.size===0)return;let e=o.source;if(!e.supportsFiles)return;let t={};for(let e of o.dotenvAddedKeys){let n=a.get(e);typeof n==`string`&&(t[e]=v(e,n),l(`mirrored ${e} to the ambient environment`))}e.writeVars(t),l(`mirrored ${o.dotenvAddedKeys.size} keys to the ambient environment`)}function v(e,t){return x.resolveTemplate(e,t)}function y(r){if(typeof r==`number`){o.environment=r,o.environmentExplicitlySet=!0;return}if(typeof r==`string`){o.environment=n(r)??0,o.environmentExplicitlySet=!0;return}let i=t(e=>{let t=h().get(e);return typeof t==`string`?t:void 0});if(i===void 0){u(`no environment set (looked for ${e.join(`, `)}); defaulting to development`),o.environment=0;return}let a=n(i);if(a===void 0){u(`unrecognized environment "${i}"; defaulting to development`),o.environment=0;return}o.environment=a}const b={getRaw:e=>p(e).value,get:(e,t)=>C(e,0,t)},x=new d(b),S=new s(b);function C(e,t,n){let{key:r,value:a}=p(e);if(m(a))return u(n===void 0?`${r} is missing or empty`:`${r} is missing or empty, using fallback ${String(n)}`),n;let o=x.resolveTemplate(r,String(a)),s;return s=t===1?i.number(o,n):t===2?i.boolean(o,n):t===3?i.bigint(o,n):t===4?i.symbol(o,n):i.string(o,n),s}export{y as determineEnvironment,h as ensureLoaded,_ as mirrorToProcessEnv,C as readPrimitive,g as refreshCache,p as resolveKeyInput,x as templateResolver,m as treatAsMissing,S as valueConverter};
2
+ //# sourceMappingURL=engine.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"engine.mjs","names":[],"sources":["../../../src/core/engine.ts"],"sourcesContent":["import { BuiltInConverters, ValueConverter } from '../converters';\nimport { ENV_KEYS, Environment, firstEnvKeyValue, parseEnvironment } from './Environment';\nimport { resolveEffectivePaths } from './paths';\nimport { cache, state } from './state';\nimport { TemplateResolver } from '../engine/TemplateResolver';\nimport { debugVerbose, debugWarn } from '../infra/Debug';\nimport { loadDotenv } from '../infra/Dotenv';\nimport { EnvaptError, EnvaptErrorCodes } from '../infra/Error';\n\nimport type { ConditionalReturn, EnvKeyInput } from '../types';\nimport type { EnvapterService } from '../types/Env';\n\nexport function resolveKeyInput(keyInput: EnvKeyInput): { key: string; value: string | undefined } {\n const keys = Array.isArray(keyInput) ? keyInput : [keyInput];\n const normalizedKeys = keys as readonly string[];\n\n if (normalizedKeys.length === 0) {\n throw new EnvaptError(EnvaptErrorCodes.InvalidKeyInput, 'At least one environment key must be provided.');\n }\n\n if (normalizedKeys.some((k) => typeof k !== 'string')) {\n throw new EnvaptError(EnvaptErrorCodes.InvalidKeyInput, 'Environment keys must be strings.');\n }\n\n if (normalizedKeys.some((k) => k.trim() === '')) {\n throw new EnvaptError(EnvaptErrorCodes.InvalidKeyInput, 'Environment keys cannot be empty strings.');\n }\n\n for (const candidate of normalizedKeys) {\n const value = ensureLoaded().get(candidate) as string | undefined;\n if (value !== undefined) return { key: candidate, value };\n }\n\n return { key: normalizedKeys[0] as string, value: undefined };\n}\n\nexport function treatAsMissing(value: string | undefined): boolean {\n if (value === undefined || value === '') return true;\n if (state.strict && value.trim() === '') return true;\n return false;\n}\n\nexport function ensureLoaded(): Map<string, unknown> {\n if (!state.cacheBuilt) {\n const source = state.source;\n // Clone so the loader and downstream reads never mutate the source's backing object.\n const isolatedEnv: Record<string, string> = { ...source.readVars() };\n\n let added = new Set<string>();\n // Sources without a filesystem (injected objects on the browser or Workers) skip the .env\n // cascade, profiles, and envPaths. Only the readVars() snapshot populates the cache.\n if (source.supportsFiles) {\n debugVerbose(`base dir: ${state.baseDir ?? 'working directory'}`);\n // Outside the try below so a missing configured profile path surfaces its EnvaptError. Only dotenv parse errors stay caught.\n const effectivePaths = resolveEffectivePaths();\n debugVerbose(`effective .env paths: ${effectivePaths.length === 0 ? '(none)' : effectivePaths.join(', ')}`);\n try {\n added = loadDotenv({\n ...state.userDefinedEnvFileOptions,\n path: effectivePaths,\n processEnv: isolatedEnv,\n readFile: source.readFile.bind(source)\n });\n } catch (error) {\n debugWarn(`failed to load .env: ${error instanceof Error ? error.message : String(error)}`);\n }\n }\n state.dotenvAddedKeys = added;\n for (const [key, value] of Object.entries(isolatedEnv)) cache.set(key, value);\n debugVerbose(`cache populated: ${cache.size} keys total`);\n // set before mirroring, whose template expansion reads the cache and would re-enter this build otherwise\n state.cacheBuilt = true;\n if (state.syncProcessEnv) mirrorToProcessEnv();\n }\n\n return cache;\n}\n\nexport function refreshCache(): void {\n // Reset an inferred environment so re-hydration re-determines it from current state. An explicit\n // Envapter.environment = X is preserved through the refresh and used for cascade selection.\n if (!state.environmentExplicitlySet) state.environment = undefined;\n cache.clear();\n state.cacheBuilt = false;\n state.dotenvAddedKeys = new Set<string>();\n debugVerbose('cache cleared, reloading config');\n ensureLoaded();\n}\n\nexport function mirrorToProcessEnv(): void {\n if (state.dotenvAddedKeys.size === 0) return;\n const source = state.source;\n /* v8 ignore next -- @preserve dotenv keys only accumulate under a file source, so the delta implies supportsFiles here */\n if (!source.supportsFiles) return;\n const mirrored: Record<string, string> = {};\n for (const key of state.dotenvAddedKeys) {\n const value = cache.get(key);\n /* v8 ignore next -- @preserve loader only writes strings, defensive against future cache contents */\n if (typeof value !== 'string') continue;\n mirrored[key] = resolveForMirror(key, value);\n debugVerbose(`mirrored ${key} to the ambient environment`);\n }\n source.writeVars(mirrored);\n debugVerbose(`mirrored ${state.dotenvAddedKeys.size} keys to the ambient environment`);\n}\n\nfunction resolveForMirror(key: string, value: string): string {\n return templateResolver.resolveTemplate(key, value);\n}\n\nexport function determineEnvironment(env?: string | Environment): void {\n if (typeof env === 'number') {\n state.environment = env;\n state.environmentExplicitlySet = true;\n return;\n }\n if (typeof env === 'string') {\n state.environment = parseEnvironment(env) ?? Environment.Development;\n state.environmentExplicitlySet = true;\n return;\n }\n\n const raw = firstEnvKeyValue((key) => {\n const value = ensureLoaded().get(key);\n return typeof value === 'string' ? value : undefined;\n });\n if (raw === undefined) {\n debugWarn(`no environment set (looked for ${ENV_KEYS.join(', ')}); defaulting to development`);\n state.environment = Environment.Development;\n return;\n }\n const parsed = parseEnvironment(raw);\n if (parsed === undefined) {\n debugWarn(`unrecognized environment \"${raw}\"; defaulting to development`);\n state.environment = Environment.Development;\n return;\n }\n state.environment = parsed;\n}\n\n/**\n * @internal\n */\nexport enum Primitive {\n String,\n Number,\n Boolean,\n BigInt,\n Symbol\n}\n\n// getRaw is the raw string lookup, get is the template-resolved string read. Lazy arrows so the\n// resolver singletons below store envService without calling readPrimitive, which reads\n// templateResolver before it is assigned.\nconst envService: EnvapterService = {\n getRaw: (key) => resolveKeyInput(key).value,\n get: (key, def) => readPrimitive<string, string | undefined>(key, Primitive.String, def)\n};\n\nexport const templateResolver: TemplateResolver = new TemplateResolver(envService);\nexport const valueConverter: ValueConverter = new ValueConverter(envService);\n\nexport function readPrimitive<EnvVarReturnType, DefaultType extends EnvVarReturnType | undefined = undefined>(\n key: EnvKeyInput,\n type: Primitive,\n def?: DefaultType\n): ConditionalReturn<EnvVarReturnType, DefaultType> {\n const { key: resolvedKey, value } = resolveKeyInput(key);\n if (treatAsMissing(value)) {\n if (def !== undefined) debugWarn(`${resolvedKey} is missing or empty, using fallback ${String(def)}`);\n else debugWarn(`${resolvedKey} is missing or empty`);\n return def as ConditionalReturn<EnvVarReturnType, DefaultType>;\n }\n\n const parsed = templateResolver.resolveTemplate(resolvedKey, String(value));\n\n let result: EnvVarReturnType;\n if (type === Primitive.Number) result = BuiltInConverters.number(parsed, def as number) as EnvVarReturnType;\n else if (type === Primitive.Boolean) result = BuiltInConverters.boolean(parsed, def as boolean) as EnvVarReturnType;\n else if (type === Primitive.BigInt) result = BuiltInConverters.bigint(parsed, def as bigint) as EnvVarReturnType;\n else if (type === Primitive.Symbol) result = BuiltInConverters.symbol(parsed, def as symbol) as EnvVarReturnType;\n else result = BuiltInConverters.string(parsed, def as string) as EnvVarReturnType;\n\n return result;\n}\n"],"mappings":"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"}
@@ -0,0 +1,2 @@
1
+ import{Environment as e,firstEnvKeyValue as t,parseEnvironment as n}from"./Environment.mjs";import{EnvaptError as r}from"../infra/Error.mjs";import{state as i}from"./state.mjs";function a(e){let t=i.baseDir;if(t===void 0)return e;let n=i.source;return n.supportsFiles?n.resolvePath(t,e):e}function o(e){let t=i.source;return t.supportsFiles?t.readFile(e,`utf8`)!==void 0:!1}function s(t){let n=e[t].toLowerCase();return[`.env.${n}.local`,`.env.${n}`,`.env.local`,`.env`].map(e=>a(e)).filter(e=>o(e))}function c(e){return e?Array.isArray(e.paths)?e.paths:[e.paths]:[]}function l(){if(i.environment!==void 0)return i.environment;let e=i.source.readVars(),r=t(t=>e[t]);return r===void 0?0:n(r)??0}function u(){if(i.envPathsExplicitlySet)return i.envPaths.map(e=>a(e));let e=l(),t=i.profiles?.[e],n=c(t);if(n.length>0){let e=n.filter(e=>!o(a(e)));if(e.length>0)throw new r(303,`Environment file not found at path: ${e.join(`, `)}`)}let u=i.profiles?.useDefaults===!1?[]:s(e);return[...n.map(e=>a(e)),...u]}export{u as resolveEffectivePaths};
2
+ //# sourceMappingURL=paths.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"paths.mjs","names":[],"sources":["../../../src/core/paths.ts"],"sourcesContent":["import { Environment, firstEnvKeyValue, parseEnvironment } from './Environment';\nimport { state } from './state';\nimport { EnvaptError, EnvaptErrorCodes } from '../infra/Error';\n\nimport type { EnvProfile, FileCapableSource, Source } from '../types';\n\n// No baseDir: candidate returned unchanged so the source resolves it against its own default\n// (process.cwd() on Node). Resolution goes through the source to keep this node-free.\nexport function resolveAgainstBase(candidate: string): string {\n const baseDir = state.baseDir;\n if (baseDir === undefined) return candidate;\n const source = state.source;\n /* v8 ignore next -- @preserve callers are all file-gated, so the source is never bare here */\n if (!source.supportsFiles) return candidate;\n return source.resolvePath(baseDir, candidate);\n}\n\n// File-based config (envPaths/baseDir/configureProfiles) is meaningless without a filesystem, and it\n// throws instead of silently ignoring it on the browser or Workers. Narrows the source so callers\n// can use the file capabilities (resolvePath/normalizeBaseDir) after the check.\nexport function assertFileApiSupported(api: string, source: Source): asserts source is FileCapableSource {\n if (!source.supportsFiles) {\n throw new EnvaptError(\n EnvaptErrorCodes.FileApiUnsupported,\n `${api} requires a filesystem-backed source; the bound source does not support .env files.`\n );\n }\n}\n\n// Existence via the bound source instead of fs.existsSync/accessSync: a file \"exists\" when the source\n// can read it.\nexport function sourceFileExists(path: string): boolean {\n const source = state.source;\n /* v8 ignore next -- @preserve every caller is file-gated, so this never sees a bare source */\n if (!source.supportsFiles) return false;\n return source.readFile(path, 'utf8') !== undefined;\n}\n\n// Precedence is most-specific-wins (matches Vite / Astro / Vocs): `.env.${env}.local` > `.env.${env}`\n// > `.env.local` > `.env`. This differs from dotenv-flow / Next.js, which put `.env.local` above\n// `.env.${env}`. Most-specific-wins keeps a committed `.env.production` authoritative regardless of a\n// stray `.env.local`. Missing files are filtered.\nfunction buildCascadePaths(env: Environment): string[] {\n const envName = Environment[env].toLowerCase();\n return [`.env.${envName}.local`, `.env.${envName}`, '.env.local', '.env']\n .map((name) => resolveAgainstBase(name))\n .filter((p) => sourceFileExists(p));\n}\n\nfunction normalizeProfilePaths(profile: EnvProfile | undefined): string[] {\n if (!profile) return [];\n return Array.isArray(profile.paths) ? profile.paths : [profile.paths];\n}\n\n// Reads the source's raw vars, not the cache, because cascade selection runs before the `.env` load.\n// `Envapter.environment` may differ post-load if a file sets `ENVIRONMENT`.\nfunction getCascadeEnvironment(): Environment {\n if (state.environment !== undefined) return state.environment;\n\n const vars = state.source.readVars();\n const raw = firstEnvKeyValue((key) => vars[key]);\n return raw === undefined ? Environment.Development : (parseEnvironment(raw) ?? Environment.Development);\n}\n\n/**\n * Resolve the `.env` paths to load. When `envPaths` was explicitly set, only those load. Otherwise\n * layer any `configureProfiles` paths for the active environment (higher precedence) over the\n * dotenv-flow cascade, all in dotenv first-wins order. `useDefaults: false` drops the cascade.\n */\nexport function resolveEffectivePaths(): string[] {\n if (state.envPathsExplicitlySet) return state.envPaths.map((p) => resolveAgainstBase(p));\n\n const env = getCascadeEnvironment();\n const profileEntry = state.profiles?.[env];\n const profilePaths = normalizeProfilePaths(profileEntry);\n\n // Validate that explicitly configured profile paths exist for the active env.\n if (profilePaths.length > 0) {\n const missing = profilePaths.filter((p) => !sourceFileExists(resolveAgainstBase(p)));\n if (missing.length > 0) {\n throw new EnvaptError(\n EnvaptErrorCodes.EnvFilesNotFound,\n `Environment file not found at path: ${missing.join(', ')}`\n );\n }\n }\n\n const cascade = state.profiles?.useDefaults === false ? [] : buildCascadePaths(env);\n return [...profilePaths.map((p) => resolveAgainstBase(p)), ...cascade];\n}\n"],"mappings":"iLAQA,SAAgB,EAAmB,EAA2B,CAC1D,IAAM,EAAU,EAAM,QACtB,GAAI,IAAY,IAAA,GAAW,OAAO,EAClC,IAAM,EAAS,EAAM,OAGrB,OADK,EAAO,cACL,EAAO,YAAY,EAAS,CAAS,EADV,CAEtC,CAgBA,SAAgB,EAAiB,EAAuB,CACpD,IAAM,EAAS,EAAM,OAGrB,OADK,EAAO,cACL,EAAO,SAAS,EAAM,MAAM,IAAM,IAAA,GADP,EAEtC,CAMA,SAAS,EAAkB,EAA4B,CACnD,IAAM,EAAU,EAAY,EAAI,CAAC,YAAY,EAC7C,MAAO,CAAC,QAAQ,EAAQ,QAAS,QAAQ,IAAW,aAAc,MAAM,CAAC,CACpE,IAAK,GAAS,EAAmB,CAAI,CAAC,CAAC,CACvC,OAAQ,GAAM,EAAiB,CAAC,CAAC,CAC1C,CAEA,SAAS,EAAsB,EAA2C,CAEtE,OADK,EACE,MAAM,QAAQ,EAAQ,KAAK,EAAI,EAAQ,MAAQ,CAAC,EAAQ,KAAK,EAD/C,CAAC,CAE1B,CAIA,SAAS,GAAqC,CAC1C,GAAI,EAAM,cAAgB,IAAA,GAAW,OAAO,EAAM,YAElD,IAAM,EAAO,EAAM,OAAO,SAAS,EAC7B,EAAM,EAAkB,GAAQ,EAAK,EAAI,EAC/C,OAAO,IAAQ,IAAA,GAAA,EAAuC,EAAiB,CAAG,GAAA,CAC9E,CAOA,SAAgB,GAAkC,CAC9C,GAAI,EAAM,sBAAuB,OAAO,EAAM,SAAS,IAAK,GAAM,EAAmB,CAAC,CAAC,EAEvF,IAAM,EAAM,EAAsB,EAC5B,EAAe,EAAM,WAAW,GAChC,EAAe,EAAsB,CAAY,EAGvD,GAAI,EAAa,OAAS,EAAG,CACzB,IAAM,EAAU,EAAa,OAAQ,GAAM,CAAC,EAAiB,EAAmB,CAAC,CAAC,CAAC,EACnF,GAAI,EAAQ,OAAS,EACjB,MAAM,IAAI,EAAA,IAEN,uCAAuC,EAAQ,KAAK,IAAI,GAC5D,CAER,CAEA,IAAM,EAAU,EAAM,UAAU,cAAgB,GAAQ,CAAC,EAAI,EAAkB,CAAG,EAClF,MAAO,CAAC,GAAG,EAAa,IAAK,GAAM,EAAmB,CAAC,CAAC,EAAG,GAAG,CAAO,CACzE"}
@@ -0,0 +1,2 @@
1
+ import{UnboundSource as e}from"../sources/UnboundSource.mjs";const t={envPaths:[`.env`],envPathsExplicitlySet:!1,baseDir:void 0,userDefinedEnvFileOptions:{},strict:!1,syncProcessEnv:!1,fileApiMode:`warn`,dotenvAddedKeys:new Set,cacheBuilt:!1,source:new e,environment:void 0,environmentExplicitlySet:!1,profiles:void 0},n=new Map;export{n as cache,t as state};
2
+ //# sourceMappingURL=state.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"state.mjs","names":[],"sources":["../../../src/core/state.ts"],"sourcesContent":["import { UnboundSource } from '../sources/UnboundSource';\n\nimport type { Environment } from './Environment';\nimport type { EnvFileOptions } from '../infra/Dotenv';\nimport type { FileApiMode, ProfilesConfig, Source } from '../types';\n\n// The engine's mutable state that should not be exposed in the package exports map.\nexport const state = {\n envPaths: ['.env'] as string[],\n envPathsExplicitlySet: false,\n baseDir: undefined as string | undefined,\n userDefinedEnvFileOptions: {} as EnvFileOptions,\n strict: false,\n syncProcessEnv: false,\n fileApiMode: 'warn' as FileApiMode,\n // loader-written keys only (collisions skipped), refilled on every cache rebuild.\n dotenvAddedKeys: new Set<string>(),\n // cache.size can't tell built-and-empty from not-built, so a source resolving to no keys would rebuild on every read without this.\n cacheBuilt: false,\n // unbound by default so non-Node builds throw NoSourceBound on read until useSource() runs.\n source: new UnboundSource() as Source,\n environment: undefined as Environment | undefined,\n environmentExplicitlySet: false,\n profiles: undefined as ProfilesConfig | undefined\n};\n\nexport const cache = new Map<string, unknown>();\n"],"mappings":"6DAOA,MAAa,EAAQ,CACjB,SAAU,CAAC,MAAM,EACjB,sBAAuB,GACvB,QAAS,IAAA,GACT,0BAA2B,CAAC,EAC5B,OAAQ,GACR,eAAgB,GAChB,YAAa,OAEb,gBAAiB,IAAI,IAErB,WAAY,GAEZ,OAAQ,IAAI,EACZ,YAAa,IAAA,GACb,yBAA0B,GAC1B,SAAU,IAAA,EACd,EAEa,EAAQ,IAAI"}
@@ -0,0 +1,2 @@
1
+ import{EnvaptError as e}from"../infra/Error.mjs";import{cache as t}from"../core/state.mjs";import{ValueConverter as n}from"../converters/ValueConverter.mjs";import{Envapter as r}from"../engine/Envapter.mjs";function i(e){return Array.isArray(e)?`[${e.join(`, `)}]`:String(e)}const a=new WeakMap;let o=0;function s(e,t,n){let r=a.get(e);return r===void 0&&(r=o++,a.set(e,r)),`${r}.${t?`static`:`instance`}.${n}`}function c(a,o,s){let{fallback:c,converter:l,hasFallback:u,required:d,schema:f}=o;if(t.has(s))return t.get(s);let p=new r;if(d&&f===void 0){let t=p.getRaw(a);if(t===void 0||t.trim()===``)throw new e(305,`Required environment variable "${i(a)}" is missing or empty.`)}let m=new n(p),h=f===void 0?m.convertValue(a,c,l,u):m.convertWithSchema(a,f,c,u);return t.set(s,h),h}export{s as decoratorCacheKey,c as resolveDecoratorValue};
2
+ //# sourceMappingURL=resolveDecoratorValue.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resolveDecoratorValue.mjs","names":[],"sources":["../../../src/decorators/resolveDecoratorValue.ts"],"sourcesContent":["import { ValueConverter } from '../converters';\nimport { cache } from '../core/state';\nimport { Envapter } from '../engine/Envapter';\nimport { EnvaptError, EnvaptErrorCodes } from '../infra/Error';\n\nimport type { StandardSchemaV1 } from '../infra/StandardSchema';\nimport type { EnvaptConverter, EnvKeyInput } from '../types';\n\nexport interface DecoratorConfig<TFallback> {\n fallback: TFallback | undefined;\n converter: EnvaptConverter<TFallback> | undefined;\n hasFallback: boolean;\n required: boolean;\n schema: StandardSchemaV1 | undefined;\n}\n\nfunction formatKeyForError(key: EnvKeyInput): string {\n return Array.isArray(key) ? `[${key.join(', ')}]` : String(key);\n}\n\nconst classIds = new WeakMap<object, number>();\nlet nextClassId = 0;\n\n// keyed on the constructor object, not its name, so two same-named classes (and a same-named\n// static/instance pair) stay in separate cache slots\nexport function decoratorCacheKey(owner: object, isStatic: boolean, prop: string): string {\n let id = classIds.get(owner);\n if (id === undefined) {\n id = nextClassId++;\n classIds.set(owner, id);\n }\n return `${id}.${isStatic ? 'static' : 'instance'}.${prop}`;\n}\n\nexport function resolveDecoratorValue<TFallback>(\n key: EnvKeyInput,\n config: DecoratorConfig<TFallback>,\n cacheKey: string\n): TFallback | null | undefined {\n const { fallback, converter, hasFallback, required, schema } = config;\n\n // .has(), not a get()-truthiness check, so a cached undefined (fallback: undefined, or a converter\n // that returns undefined) resolves once instead of re-running on every access\n if (cache.has(cacheKey)) return cache.get(cacheKey) as TFallback | null | undefined;\n\n const envapter = new Envapter();\n\n if (required && schema === undefined) {\n const rawValue = envapter.getRaw(key);\n if (rawValue === undefined || rawValue.trim() === '') {\n throw new EnvaptError(\n EnvaptErrorCodes.MissingEnvValue,\n `Required environment variable \"${formatKeyForError(key)}\" is missing or empty.`\n );\n }\n }\n\n const valueConverter = new ValueConverter(envapter);\n const value =\n schema !== undefined\n ? (valueConverter.convertWithSchema(key, schema, fallback, hasFallback) as TFallback)\n : valueConverter.convertValue(key, fallback, converter, hasFallback);\n\n cache.set(cacheKey, value);\n return value;\n}\n"],"mappings":"+MAgBA,SAAS,EAAkB,EAA0B,CACjD,OAAO,MAAM,QAAQ,CAAG,EAAI,IAAI,EAAI,KAAK,IAAI,EAAE,GAAK,OAAO,CAAG,CAClE,CAEA,MAAM,EAAW,IAAI,QACrB,IAAI,EAAc,EAIlB,SAAgB,EAAkB,EAAe,EAAmB,EAAsB,CACtF,IAAI,EAAK,EAAS,IAAI,CAAK,EAK3B,OAJI,IAAO,IAAA,KACP,EAAK,IACL,EAAS,IAAI,EAAO,CAAE,GAEnB,GAAG,EAAG,GAAG,EAAW,SAAW,WAAW,GAAG,GACxD,CAEA,SAAgB,EACZ,EACA,EACA,EAC4B,CAC5B,GAAM,CAAE,WAAU,YAAW,cAAa,WAAU,UAAW,EAI/D,GAAI,EAAM,IAAI,CAAQ,EAAG,OAAO,EAAM,IAAI,CAAQ,EAElD,IAAM,EAAW,IAAI,EAErB,GAAI,GAAY,IAAW,IAAA,GAAW,CAClC,IAAM,EAAW,EAAS,OAAO,CAAG,EACpC,GAAI,IAAa,IAAA,IAAa,EAAS,KAAK,IAAM,GAC9C,MAAM,IAAI,EAAA,IAEN,kCAAkC,EAAkB,CAAG,EAAE,uBAC7D,CAER,CAEA,IAAM,EAAiB,IAAI,EAAe,CAAQ,EAC5C,EACF,IAAW,IAAA,GAEL,EAAe,aAAa,EAAK,EAAU,EAAW,CAAW,EADhE,EAAe,kBAAkB,EAAK,EAAQ,EAAU,CAAW,EAI9E,OADA,EAAM,IAAI,EAAU,CAAK,EAClB,CACX"}
@@ -0,0 +1,2 @@
1
+ import"../core/Environment.mjs";import{EnvaptError as e}from"../infra/Error.mjs";import{resolveKeyInput as t,templateResolver as n}from"../core/engine.mjs";import{AdvancedMethods as r,resolveRequired as i}from"../core/AdvancedMethods.mjs";var a=class a extends r{static resolve(t,...n){let r=a.strict;return t.reduce((t,i,a)=>{let o=n[a];if(!o)return t+i;let s=super.get(o,``);if(r&&s.trim()===``)throw new e(305,`Cannot resolve template variable "\${${o}}": value is missing or empty.`);return t+i+s},``)}resolve(e,...t){return a.resolve(e,...t)}static require(...r){let a=r.filter(e=>i(t(e),n).value===void 0);if(a.length>0)throw new e(305,`Missing required environment variables: ${a.join(`, `)}.`)}require(...e){a.require(...e)}};export{a as Envapter};
2
+ //# sourceMappingURL=Envapter.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Envapter.mjs","names":[],"sources":["../../../src/engine/Envapter.ts"],"sourcesContent":["import { AdvancedMethods } from '../core';\nimport { resolveRequired } from '../core/AdvancedMethods';\nimport { resolveKeyInput, templateResolver } from '../core/engine';\nimport { EnvaptError, EnvaptErrorCodes } from '../infra/Error';\n\nexport { Environment } from '../core';\n\n/**\n * Main configuration class for environment variable management.\n *\n * Provides both static and instance methods for retrieving typed environment variables\n * with support for template resolution, multiple .env files, and environment detection.\n *\n * Extend your own classes from this to define properties with \\@Envapt decorators and get access to environment-variable methods.\n *\n * @example\n * ```ts\n * // Static usage\n * const port = Envapter.getNumber('PORT', 3000);\n * const url = Envapter.get('API_URL', 'http://localhost');\n * const replica = Envapter.get(['READONLY_URL', 'DATABASE_URL'], 'sqlite://memory');\n *\n * // Instance usage\n * const env = new Envapter();\n * const dbUrl = env.get('DATABASE_URL', 'sqlite://memory');\n * const primaryHost = env.get(['PRIMARY_HOST', 'SECONDARY_HOST']);\n * ```\n *\n * @public\n */\nexport class Envapter extends AdvancedMethods {\n /**\n * Tagged template literal for resolving environment variables in template strings.\n *\n * @example\n * ```ts\n * // Given API_HOST=api.example.com and API_PORT=8080 in environment\n * const endpoint = Envapter.resolve`Connecting to ${'API_HOST'}:${'API_PORT'}`;\n * // Returns: \"Connecting to api.example.com:8080\"\n *\n * // Works with template variables in .env too:\n * // API_URL=https://${API_HOST}:${API_PORT}\n * const message = Envapter.resolve`Service endpoint: ${'API_URL'}`;\n * // Returns: \"Service endpoint: https://api.example.com:8080\"\n * ```\n */\n static resolve(strings: TemplateStringsArray, ...keys: string[]): string {\n const strict = Envapter.strict;\n return strings.reduce((result, string, i) => {\n const envKey = keys[i];\n if (!envKey) return result + string;\n const raw = super.get(envKey, '');\n if (strict && raw.trim() === '') {\n throw new EnvaptError(\n EnvaptErrorCodes.MissingEnvValue,\n `Cannot resolve template variable \"\\${${envKey}}\": value is missing or empty.`\n );\n }\n return result + string + raw;\n }, '');\n }\n\n /**\n * @see {@link Envapter.resolve}\n */\n resolve(strings: TemplateStringsArray, ...keys: string[]): string {\n return Envapter.resolve(strings, ...keys);\n }\n\n /**\n * Assert that one or more environment variables are present and non-empty (post-trim,\n * after template resolution). Throws `MissingEnvValue` listing every missing key.\n *\n * For a typed required read in functional code, use `Envapter.getRequired(key, converter)`.\n *\n * @example\n * ```ts\n * Envapter.require('DATABASE_URL');\n * Envapter.require('DATABASE_URL', 'API_KEY', 'SENTRY_DSN');\n * ```\n */\n static require(...keys: [string, ...string[]]): void {\n const missing = keys.filter((k) => resolveRequired(resolveKeyInput(k), templateResolver).value === undefined);\n\n if (missing.length > 0) {\n throw new EnvaptError(\n EnvaptErrorCodes.MissingEnvValue,\n `Missing required environment variables: ${missing.join(', ')}.`\n );\n }\n }\n\n /**\n * @see {@link Envapter.require}\n */\n require(...keys: [string, ...string[]]): void {\n Envapter.require(...keys);\n }\n}\n"],"mappings":"+OA8BA,IAAa,EAAb,MAAa,UAAiB,CAAgB,CAgB1C,OAAO,QAAQ,EAA+B,GAAG,EAAwB,CACrE,IAAM,EAAS,EAAS,OACxB,OAAO,EAAQ,QAAQ,EAAQ,EAAQ,IAAM,CACzC,IAAM,EAAS,EAAK,GACpB,GAAI,CAAC,EAAQ,OAAO,EAAS,EAC7B,IAAM,EAAM,MAAM,IAAI,EAAQ,EAAE,EAChC,GAAI,GAAU,EAAI,KAAK,IAAM,GACzB,MAAM,IAAI,EAAA,IAEN,wCAAwC,EAAO,+BACnD,EAEJ,OAAO,EAAS,EAAS,CAC7B,EAAG,EAAE,CACT,CAKA,QAAQ,EAA+B,GAAG,EAAwB,CAC9D,OAAO,EAAS,QAAQ,EAAS,GAAG,CAAI,CAC5C,CAcA,OAAO,QAAQ,GAAG,EAAmC,CACjD,IAAM,EAAU,EAAK,OAAQ,GAAM,EAAgB,EAAgB,CAAC,EAAG,CAAgB,CAAC,CAAC,QAAU,IAAA,EAAS,EAE5G,GAAI,EAAQ,OAAS,EACjB,MAAM,IAAI,EAAA,IAEN,2CAA2C,EAAQ,KAAK,IAAI,EAAE,EAClE,CAER,CAKA,QAAQ,GAAG,EAAmC,CAC1C,EAAS,QAAQ,GAAG,CAAI,CAC5B,CACJ"}
@@ -0,0 +1,2 @@
1
+ import{Envapter as e}from"./Envapter.mjs";import{portableFileApiRead as t,portableFileApiWrite as n}from"./fileApiStub.mjs";var r=class extends e{static get envPaths(){return t(`envPaths`,[])}static set envPaths(e){n(`envPaths`)}static get baseDir(){return t(`baseDir`,void 0)}static set baseDir(e){n(`baseDir`)}static get envFileOptions(){return t(`envFileOptions`,{})}static set envFileOptions(e){n(`envFileOptions`)}static configureProfiles(e){n(`configureProfiles`)}static resetProfiles(){n(`resetProfiles`)}};export{r as PortableEnvapter};
2
+ //# sourceMappingURL=PortableEnvapter.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PortableEnvapter.mjs","names":[],"sources":["../../../src/engine/PortableEnvapter.ts"],"sourcesContent":["import { Envapter } from './Envapter';\nimport { portableFileApiRead, portableFileApiWrite } from './fileApiStub';\n\nimport type { EnvFileOptions } from '../infra/Dotenv';\nimport type { ProfilesConfig } from '../types';\n\n/**\n * The browser/Workers/edge facade. {@link Envapter} with the filesystem-only config APIs present in\n * the type but inert at runtime by default. Under the default `fileApiMode` of `'warn'` they warn once\n * and no-op (getters return an empty default matching their type, setters do nothing). `'throw'` restores\n * the {@link EnvaptError} `FileApiUnsupported`. The read side still throws `NoSourceBound` on first read\n * until `useSource` binds a source.\n * @public\n */\nexport class PortableEnvapter extends Envapter {\n static get envPaths(): string[] {\n return portableFileApiRead('envPaths', []);\n }\n static set envPaths(_paths: string[] | string) {\n portableFileApiWrite('envPaths');\n }\n\n static get baseDir(): string | undefined {\n return portableFileApiRead('baseDir', undefined);\n }\n static set baseDir(_value: string | URL | undefined) {\n portableFileApiWrite('baseDir');\n }\n\n static get envFileOptions(): EnvFileOptions {\n return portableFileApiRead('envFileOptions', {});\n }\n static set envFileOptions(_config: EnvFileOptions) {\n portableFileApiWrite('envFileOptions');\n }\n\n static configureProfiles(_config: ProfilesConfig): void {\n portableFileApiWrite('configureProfiles');\n }\n\n static resetProfiles(): void {\n portableFileApiWrite('resetProfiles');\n }\n}\n"],"mappings":"4HAcA,IAAa,EAAb,cAAsC,CAAS,CAC3C,WAAW,UAAqB,CAC5B,OAAO,EAAoB,WAAY,CAAC,CAAC,CAC7C,CACA,WAAW,SAAS,EAA2B,CAC3C,EAAqB,UAAU,CACnC,CAEA,WAAW,SAA8B,CACrC,OAAO,EAAoB,UAAW,IAAA,EAAS,CACnD,CACA,WAAW,QAAQ,EAAkC,CACjD,EAAqB,SAAS,CAClC,CAEA,WAAW,gBAAiC,CACxC,OAAO,EAAoB,iBAAkB,CAAC,CAAC,CACnD,CACA,WAAW,eAAe,EAAyB,CAC/C,EAAqB,gBAAgB,CACzC,CAEA,OAAO,kBAAkB,EAA+B,CACpD,EAAqB,mBAAmB,CAC5C,CAEA,OAAO,eAAsB,CACzB,EAAqB,eAAe,CACxC,CACJ"}
@@ -0,0 +1,2 @@
1
+ import{EnvaptError as e}from"../infra/Error.mjs";import{state as t}from"../core/state.mjs";import{debugWarn as n}from"../infra/Debug.mjs";var r=class{envService;TEMPLATE_REGEX=/\${\w*}/g;constructor(e){this.envService=e}resolveTemplate(r,i,a=new Set){a.add(r);let o=t.strict,s=i.replace(this.TEMPLATE_REGEX,t=>{let i=t.slice(2,-1);if(a.has(i))return t;let s=this.envService.getRaw(i);if(s===void 0||s===``||o&&s.trim()===``){if(o)throw new e(305,`Cannot resolve template variable "\${${i}}": value is missing or empty.`);return n(`unresolved template \${${i}} preserved as literal`),t}let c=this.resolveTemplate(i,s,new Set(a));return c.includes(`\${${r}}`)||c===s&&/\$\{[^}]*\}/.test(c)?t:c});return a.delete(r),s}};export{r as TemplateResolver};
2
+ //# sourceMappingURL=TemplateResolver.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TemplateResolver.mjs","names":[],"sources":["../../../src/engine/TemplateResolver.ts"],"sourcesContent":["import { state } from '../core/state';\nimport { debugWarn } from '../infra/Debug';\nimport { EnvaptError, EnvaptErrorCodes } from '../infra/Error';\n\nimport type { EnvapterService } from '../types/Env';\n\n/**\n * Resolve `${VAR}` template references in environment values, guarding against circular\n * references and missing variables.\n * @internal\n */\nexport class TemplateResolver {\n private readonly TEMPLATE_REGEX = /\\${\\w*}/g;\n\n constructor(private readonly envService: EnvapterService) {}\n\n resolveTemplate(key: string, value: string, stack: Set<string> = new Set<string>()): string {\n stack.add(key);\n const strict = state.strict;\n\n const out = value.replace(this.TEMPLATE_REGEX, (template) => {\n const variable = template.slice(2, -1);\n\n if (stack.has(variable)) return template; // cycle, preserve\n\n const raw = this.envService.getRaw(variable);\n const isMissing = raw === undefined || raw === '' || (strict && raw.trim() === '');\n if (isMissing) {\n if (strict) {\n throw new EnvaptError(\n EnvaptErrorCodes.MissingEnvValue,\n `Cannot resolve template variable \"\\${${variable}}\": value is missing or empty.`\n );\n }\n debugWarn(`unresolved template \\${${variable}} preserved as literal`);\n return template; // missing or empty, preserve\n }\n\n const resolved = this.resolveTemplate(variable, raw, new Set(stack));\n\n // If resolution still references the current key, skip replacement (indirect cycle)\n if (resolved.includes(`\\${${key}}`)) return template;\n\n // If nothing changed (unresolved placeholders stayed), also preserve original template\n if (resolved === raw && /\\$\\{[^}]*\\}/.test(resolved)) return template;\n\n return resolved;\n });\n\n stack.delete(key);\n return out;\n }\n}\n"],"mappings":"0IAWA,IAAa,EAAb,KAA8B,CAGG,WAF7B,eAAkC,WAElC,YAAY,EAA8C,CAA7B,KAAA,WAAA,CAA8B,CAE3D,gBAAgB,EAAa,EAAe,EAAqB,IAAI,IAAuB,CACxF,EAAM,IAAI,CAAG,EACb,IAAM,EAAS,EAAM,OAEf,EAAM,EAAM,QAAQ,KAAK,eAAiB,GAAa,CACzD,IAAM,EAAW,EAAS,MAAM,EAAG,EAAE,EAErC,GAAI,EAAM,IAAI,CAAQ,EAAG,OAAO,EAEhC,IAAM,EAAM,KAAK,WAAW,OAAO,CAAQ,EAE3C,GADkB,IAAQ,IAAA,IAAa,IAAQ,IAAO,GAAU,EAAI,KAAK,IAAM,GAChE,CACX,GAAI,EACA,MAAM,IAAI,EAAA,IAEN,wCAAwC,EAAS,+BACrD,EAGJ,OADA,EAAU,0BAA0B,EAAS,uBAAuB,EAC7D,CACX,CAEA,IAAM,EAAW,KAAK,gBAAgB,EAAU,EAAK,IAAI,IAAI,CAAK,CAAC,EAQnE,OALI,EAAS,SAAS,MAAM,EAAI,EAAE,GAG9B,IAAa,GAAO,cAAc,KAAK,CAAQ,EAAU,EAEtD,CACX,CAAC,EAGD,OADA,EAAM,OAAO,CAAG,EACT,CACX,CACJ"}
@@ -0,0 +1,2 @@
1
+ import{isArrayOf as e}from"../converters/Converters.mjs";import{EnvaptError as t}from"../infra/Error.mjs";import{BuiltInConverterTypeCheckers as n,ListOfBuiltInConverters as r}from"../converters/ListOfBuiltInConverters.mjs";var i=class{static isBuiltInConverter(e){return typeof e==`string`?r.includes(e):!1}static isArrayConverter(t){return e(t)}static isStandardSchema(e){if(typeof e!=`object`||!e||!(`~standard`in e))return!1;let t=e[`~standard`];if(typeof t!=`object`||!t)return!1;let n=t;return n.version===1&&typeof n.validate==`function`}static customConvertor(e){if(typeof e!=`function`)throw new t(203,`Custom converter must be a function, got ${typeof e}.`)}static arrayConverter(n){if(!e(n))throw new t(201,`Expected an ArrayOf<...> token produced by Converters.array(...)`);if(typeof n.delimiter!=`string`||n.delimiter.length===0)throw new t(301,`ArrayOf<...> requires a non-empty string delimiter, got ${typeof n.delimiter}`);let i=n.of;if(!(typeof i==`string`&&r.includes(i))&&typeof i!=`function`)throw new t(201,`ArrayOf<...> element ("of") must be a built-in scalar token or a function, got ${typeof i}`)}static builtInConverter(e){if(typeof e!=`string`)throw new t(204,`Expected string, got ${typeof e}`);if(!r.includes(e))throw new t(202,`"${e}" is not a valid converter type. Valid types are: ${r.join(`,`)}`)}static validateBuiltInConverterFallback(e,r){let i=n[e];if(!i(r))throw new t(104,`Fallback type does not match converter "${e}". Expected ${e} compatible type.`)}static validateArrayFallbackElementTypes(e){if(e.length===0)return;let n=typeof e[0];if(e.some((e,t)=>t===0?!1:typeof e!==n))throw new t(103,`All elements in array fallback must have the same type. Found mixed types.`)}static validateArrayConverterElementTypeMatch(e,r){if(r.length===0||typeof e==`function`)return;let i=e;if(i===`time`){let e=r.every(e=>typeof e==`number`),n=r.every(e=>typeof e==`string`);if(!e&&!n)throw new t(103,`Time array fallback must be all numbers or all time-string entries.`);return}let a=n[i],o=r[0];if(!a(o))throw new t(103,`Array converter type "${i}" does not match fallback element type. Expected ${i} compatible elements.`)}static isPrimitiveConstructor(e){return e===String||e===Number||e===Boolean||e===BigInt||e===Symbol}static coercePrimitiveFallback(e,t){return this.isCorrectPrimitiveType(e,t)?t:this.performPrimitiveCoercion(e,t)}static isCorrectPrimitiveType(e,t){return e===String&&typeof t==`string`||e===Number&&typeof t==`number`||e===Boolean&&typeof t==`boolean`||e===BigInt&&typeof t==`bigint`||e===Symbol&&typeof t==`symbol`}static performPrimitiveCoercion(e,n){try{if(e===String)return String(n);if(e===Number)return Number(n);if(e===Boolean)return!!n;if(e===BigInt)return BigInt(n);if(e===Symbol)return Symbol.for(String(n))}catch(n){throw new t(205,`Failed to coerce fallback value using ${e.name}: ${n.message}`)}throw new t(205,`Unknown primitive converter: ${e.name}`)}static validateSyncProcessEnv(e){if(typeof e!=`boolean`)throw new t(302,`Envapter.syncProcessEnv must be a boolean, got ${typeof e}.`)}static validateFileApiMode(e){if(e!==`warn`&&e!==`throw`)throw new t(302,`Envapter.fileApiMode must be 'warn' or 'throw', got ${typeof e==`string`?`'${e}'`:typeof e}.`)}static validateEnvFileOptions(e){let n=new Set([`encoding`,`override`]),r=Object.keys(e).filter(e=>!n.has(e));if(r.length>0)throw new t(302,`Invalid envFileOptions: ${r.join(`, `)}. Allowed options: ${Array.from(n).join(`, `)}. For debug output, use Envapter.debug or the ENVAPT_DEBUG env var.`);return!0}static validateEnvFilesExist(e,n){let r=e.filter(e=>!n(e));if(r.length>0)throw new t(303,`Environment file not found at path: ${r.join(`, `)}`)}};export{i as Validator};
2
+ //# sourceMappingURL=Validators.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Validators.mjs","names":[],"sources":["../../../src/engine/Validators.ts"],"sourcesContent":["// Import the converter modules directly, not via the `./converters` barrel: that barrel pulls in\n// ValueConverter, which imports this Validator, so a barrel import here would cycle.\nimport { isArrayOf } from '../converters/Converters';\nimport { ListOfBuiltInConverters, BuiltInConverterTypeCheckers } from '../converters/ListOfBuiltInConverters';\nimport { EnvaptError, EnvaptErrorCodes } from '../infra/Error';\n\nimport type { ArrayOf, ConverterToken } from '../converters/Converters';\nimport type { EnvFileOptions } from '../infra/Dotenv';\nimport type { StandardSchemaV1 } from '../infra/StandardSchema';\nimport type { BuiltInConverter, ConverterFunction, EnvaptConverter, FileApiMode } from '../types';\n\n// eslint-disable-next-line @typescript-eslint/no-extraneous-class -- cohesive dispatch of stateless type guards, same shape as BuiltInConverters\nexport class Validator {\n /**\n * Check if a value is a built-in scalar converter token\n */\n static isBuiltInConverter<TFallback>(value: EnvaptConverter<TFallback>): value is BuiltInConverter {\n if (typeof value === 'string') return ListOfBuiltInConverters.includes(value);\n return false;\n }\n\n /**\n * Check if a value is an `ArrayOf<...>` token produced by {@link Converters.array}.\n */\n static isArrayConverter(value: unknown): value is ArrayOf {\n return isArrayOf(value);\n }\n\n // Structural check: `version === 1` + callable `validate` is the minimum dispatchable\n // shape per the Standard Schema spec.\n static isStandardSchema(value: unknown): value is StandardSchemaV1 {\n if (typeof value !== 'object' || value === null) return false;\n if (!('~standard' in value)) return false;\n const slot = value['~standard'];\n if (typeof slot !== 'object' || slot === null) return false;\n const props = slot as { version?: unknown; validate?: unknown };\n return props.version === 1 && typeof props.validate === 'function';\n }\n\n static customConvertor<TFallback>(\n converter: EnvaptConverter<TFallback>\n ): asserts converter is ConverterFunction<TFallback> {\n if (typeof converter !== 'function') {\n throw new EnvaptError(\n EnvaptErrorCodes.InvalidCustomConverter,\n `Custom converter must be a function, got ${typeof converter}.`\n );\n }\n }\n\n /**\n * Runtime validation that the `ArrayOf<...>` configuration is well-formed.\n */\n static arrayConverter(value: unknown): asserts value is ArrayOf {\n if (!isArrayOf(value)) {\n throw new EnvaptError(\n EnvaptErrorCodes.InvalidArrayConverterType,\n 'Expected an ArrayOf<...> token produced by Converters.array(...)'\n );\n }\n\n if (typeof value.delimiter !== 'string' || value.delimiter.length === 0) {\n throw new EnvaptError(\n EnvaptErrorCodes.MissingDelimiter,\n `ArrayOf<...> requires a non-empty string delimiter, got ${typeof value.delimiter}`\n );\n }\n\n const elementOf = value.of;\n const isScalar = typeof elementOf === 'string' && ListOfBuiltInConverters.includes(elementOf);\n const isCustomFn = typeof elementOf === 'function';\n if (!isScalar && !isCustomFn) {\n throw new EnvaptError(\n EnvaptErrorCodes.InvalidArrayConverterType,\n `ArrayOf<...> element (\"of\") must be a built-in scalar token or a function, got ${typeof elementOf}`\n );\n }\n }\n\n /**\n * Validate that a string is a valid built-in scalar converter token\n */\n static builtInConverter(value: unknown): asserts value is BuiltInConverter {\n if (typeof value !== 'string') {\n throw new EnvaptError(EnvaptErrorCodes.InvalidConverterType, `Expected string, got ${typeof value}`);\n }\n\n if (!ListOfBuiltInConverters.includes(value as ConverterToken)) {\n throw new EnvaptError(\n EnvaptErrorCodes.InvalidBuiltInConverter,\n `\"${value}\" is not a valid converter type. Valid types are: ${ListOfBuiltInConverters.join(',')}`\n );\n }\n }\n\n /**\n * Validate that fallback type matches the converter's return type for built-in converters\n */\n static validateBuiltInConverterFallback(converter: BuiltInConverter, fallback: unknown): void {\n const typeChecker = BuiltInConverterTypeCheckers[converter];\n if (!typeChecker(fallback)) {\n throw new EnvaptError(\n EnvaptErrorCodes.FallbackConverterTypeMismatch,\n `Fallback type does not match converter \"${converter}\". Expected ${converter} compatible type.`\n );\n }\n }\n\n /**\n * Validate that all elements in an array fallback have consistent types\n */\n static validateArrayFallbackElementTypes(fallback: unknown[]): void {\n if (fallback.length === 0) return;\n\n const firstElementType = typeof fallback[0];\n const hasInconsistentTypes = fallback.some((element, index) => {\n if (index === 0) return false;\n return typeof element !== firstElementType;\n });\n\n if (hasInconsistentTypes) {\n throw new EnvaptError(\n EnvaptErrorCodes.ArrayFallbackElementTypeMismatch,\n `All elements in array fallback must have the same type. Found mixed types.`\n );\n }\n }\n\n /**\n * Validate that an `ArrayOf<...>` element converter matches the runtime types of its\n * fallback elements. For `Converters.Time` arrays the element-time-string format is also\n * checked here.\n */\n static validateArrayConverterElementTypeMatch(elementOf: ArrayOf['of'], fallback: unknown[]): void {\n if (fallback.length === 0) return;\n\n if (typeof elementOf === 'function') {\n // Custom element converters can return anything; we can't statically validate the fallback shape.\n return;\n }\n\n const elementToken = elementOf;\n\n // Time array fallbacks may be number[] OR string[] (TimeFallback[]).\n if (elementToken === 'time') {\n const everyNumber = fallback.every((v) => typeof v === 'number');\n const everyString = fallback.every((v) => typeof v === 'string');\n if (!everyNumber && !everyString) {\n throw new EnvaptError(\n EnvaptErrorCodes.ArrayFallbackElementTypeMismatch,\n 'Time array fallback must be all numbers or all time-string entries.'\n );\n }\n return;\n }\n\n const typeChecker = BuiltInConverterTypeCheckers[elementToken];\n const firstElement = fallback[0];\n if (!typeChecker(firstElement)) {\n throw new EnvaptError(\n EnvaptErrorCodes.ArrayFallbackElementTypeMismatch,\n `Array converter type \"${elementToken}\" does not match fallback element type. Expected ${elementToken} compatible elements.`\n );\n }\n }\n\n /**\n * Check if a value is a primitive constructor\n */\n static isPrimitiveConstructor(\n value: unknown\n ): value is typeof String | typeof Number | typeof Boolean | typeof BigInt | typeof Symbol {\n return value === String || value === Number || value === Boolean || value === BigInt || value === Symbol;\n }\n\n /**\n * Safely coerce a fallback value using a primitive constructor\n */\n static coercePrimitiveFallback<CoercedType>(\n converter: typeof String | typeof Number | typeof Boolean | typeof BigInt | typeof Symbol,\n fallback: unknown\n ): CoercedType {\n if (this.isCorrectPrimitiveType(converter, fallback)) return fallback as CoercedType;\n return this.performPrimitiveCoercion<CoercedType>(converter, fallback);\n }\n\n private static isCorrectPrimitiveType(\n converter: typeof String | typeof Number | typeof Boolean | typeof BigInt | typeof Symbol,\n fallback: unknown\n ): boolean {\n if (converter === String && typeof fallback === 'string') return true;\n if (converter === Number && typeof fallback === 'number') return true;\n if (converter === Boolean && typeof fallback === 'boolean') return true;\n if (converter === BigInt && typeof fallback === 'bigint') return true;\n if (converter === Symbol && typeof fallback === 'symbol') return true;\n return false;\n }\n\n private static performPrimitiveCoercion<CoercedType>(\n converter: typeof String | typeof Number | typeof Boolean | typeof BigInt | typeof Symbol,\n fallback: unknown\n ): CoercedType {\n try {\n if (converter === String) return String(fallback) as CoercedType;\n if (converter === Number) return Number(fallback) as CoercedType;\n if (converter === Boolean) return Boolean(fallback) as CoercedType;\n if (converter === BigInt) return BigInt(fallback as string | number | bigint) as CoercedType;\n /* v8 ignore next -- @preserve */\n if (converter === Symbol) return Symbol.for(String(fallback)) as CoercedType;\n } catch (error) {\n throw new EnvaptError(\n EnvaptErrorCodes.PrimitiveCoercionFailed,\n `Failed to coerce fallback value using ${converter.name}: ${(error as Error).message}`\n );\n }\n\n /* v8 ignore next -- @preserve */\n throw new EnvaptError(\n EnvaptErrorCodes.PrimitiveCoercionFailed,\n `Unknown primitive converter: ${converter.name}`\n );\n }\n\n /**\n * Reject non-boolean inputs to `Envapter.syncProcessEnv` so a truthy typo\n * (`'true'`, `1`, etc.) does not silently enable the mirror.\n */\n static validateSyncProcessEnv(value: unknown): asserts value is boolean {\n if (typeof value !== 'boolean') {\n throw new EnvaptError(\n EnvaptErrorCodes.InvalidUserDefinedConfig,\n `Envapter.syncProcessEnv must be a boolean, got ${typeof value}.`\n );\n }\n }\n\n static validateFileApiMode(value: unknown): asserts value is FileApiMode {\n if (value !== 'warn' && value !== 'throw') {\n const got = typeof value === 'string' ? `'${value}'` : typeof value;\n throw new EnvaptError(\n EnvaptErrorCodes.InvalidUserDefinedConfig,\n `Envapter.fileApiMode must be 'warn' or 'throw', got ${got}.`\n );\n }\n }\n\n /**\n * Make sure the user hasn't provided prohibited options in their dotenv config\n */\n static validateEnvFileOptions(config: object): config is EnvFileOptions {\n const validKeys = new Set(['encoding', 'override']);\n const invalidKeys = Object.keys(config).filter((key) => !validKeys.has(key));\n\n if (invalidKeys.length > 0) {\n throw new EnvaptError(\n EnvaptErrorCodes.InvalidUserDefinedConfig,\n `Invalid envFileOptions: ${invalidKeys.join(', ')}. Allowed options: ${Array.from(validKeys).join(', ')}. For debug output, use Envapter.debug or the ENVAPT_DEBUG env var.`\n );\n }\n\n return true;\n }\n\n // Existence is probed through the caller-supplied `fileExists` (backed by the bound source) so\n // this stays free of `node:fs`.\n static validateEnvFilesExist(paths: string[], fileExists: (path: string) => boolean): void {\n const missing = paths.filter((p) => !fileExists(p));\n\n if (missing.length > 0) {\n throw new EnvaptError(\n EnvaptErrorCodes.EnvFilesNotFound,\n `Environment file not found at path: ${missing.join(', ')}`\n );\n }\n }\n}\n"],"mappings":"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"}
@@ -0,0 +1,2 @@
1
+ import{EnvaptError as e}from"../infra/Error.mjs";import{writeRuntimeLine as t}from"../infra/runtime.mjs";import{EnvapterBase as n}from"../core/EnvapterBase.mjs";const r=new Set;function i(t){throw new e(306,`Envapter.${t} requires a filesystem-backed source and is not available in this build.`)}function a(e){r.has(e)||(r.add(e),t(`[envapt] Envapter.${e} is a filesystem-only API and has no effect in the portable build. Set Envapter.fileApiMode = 'throw' to throw instead.`))}function o(e,t){return n.fileApiMode===`throw`&&i(e),a(e),t}function s(e){n.fileApiMode===`throw`&&i(e),a(e)}export{o as portableFileApiRead,s as portableFileApiWrite};
2
+ //# sourceMappingURL=fileApiStub.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fileApiStub.mjs","names":[],"sources":["../../../src/engine/fileApiStub.ts"],"sourcesContent":["import { EnvapterBase } from '../core/EnvapterBase';\nimport { EnvaptError, EnvaptErrorCodes } from '../infra/Error';\nimport { writeRuntimeLine } from '../infra/runtime';\n\n// EnvapterBase must never import this module back, or the chain cycles.\nconst warned = new Set<string>();\n\nfunction fileApiUnsupported(api: string): never {\n throw new EnvaptError(\n EnvaptErrorCodes.FileApiUnsupported,\n `Envapter.${api} requires a filesystem-backed source and is not available in this build.`\n );\n}\n\n// warns regardless of Envapter.debug (debugWarn would gate on it)\nfunction warnOnce(api: string): void {\n if (warned.has(api)) return;\n warned.add(api);\n writeRuntimeLine(\n `[envapt] Envapter.${api} is a filesystem-only API and has no effect in the portable build. ` +\n `Set Envapter.fileApiMode = 'throw' to throw instead.`\n );\n}\n\nexport function portableFileApiRead<Value>(api: string, fallback: Value): Value {\n if (EnvapterBase.fileApiMode === 'throw') fileApiUnsupported(api);\n warnOnce(api);\n // warn mode no-ops, so the read returns the getter's empty default rather than undefined\n return fallback;\n}\n\nexport function portableFileApiWrite(api: string): void {\n if (EnvapterBase.fileApiMode === 'throw') fileApiUnsupported(api);\n warnOnce(api);\n}\n"],"mappings":"iKAKA,MAAM,EAAS,IAAI,IAEnB,SAAS,EAAmB,EAAoB,CAC5C,MAAM,IAAI,EAAA,IAEN,YAAY,EAAI,yEACpB,CACJ,CAGA,SAAS,EAAS,EAAmB,CAC7B,EAAO,IAAI,CAAG,IAClB,EAAO,IAAI,CAAG,EACd,EACI,qBAAqB,EAAI,wHAE7B,EACJ,CAEA,SAAgB,EAA2B,EAAa,EAAwB,CAI5E,OAHI,EAAa,cAAgB,SAAS,EAAmB,CAAG,EAChE,EAAS,CAAG,EAEL,CACX,CAEA,SAAgB,EAAqB,EAAmB,CAChD,EAAa,cAAgB,SAAS,EAAmB,CAAG,EAChE,EAAS,CAAG,CAChB"}
@@ -0,0 +1 @@
1
+ import{Environment as e}from"./core/Environment.mjs";import{Converters as t,isArrayOf as n}from"./converters/Converters.mjs";import{EnvaptError as r,EnvaptErrorCodes as i}from"./infra/Error.mjs";import{PortableSource as a}from"./sources/PortableSource.mjs";import{merge as o}from"./sources/merge.mjs";import{Envapt as s}from"./decorators/modern/Envapt.mjs";import{EnvBool as c,EnvNum as l,EnvStr as u,EnvTime as d,EnvUrl as f}from"./decorators/modern/SugarDecorators.mjs";import{PortableEnvapter as p}from"./engine/PortableEnvapter.mjs";export{t as Converters,c as EnvBool,l as EnvNum,u as EnvStr,d as EnvTime,f as EnvUrl,s as Envapt,r as EnvaptError,i as EnvaptErrorCodes,p as Envapter,e as Environment,a as PortableSource,n as isArrayOf,o as merge};
@@ -1,2 +1,2 @@
1
- let e=function(e){return e[e.InvalidFallback=101]=`InvalidFallback`,e[e.InvalidFallbackType=102]=`InvalidFallbackType`,e[e.ArrayFallbackElementTypeMismatch=103]=`ArrayFallbackElementTypeMismatch`,e[e.FallbackConverterTypeMismatch=104]=`FallbackConverterTypeMismatch`,e[e.MalformedTimeFallback=105]=`MalformedTimeFallback`,e[e.InvalidArrayConverterType=201]=`InvalidArrayConverterType`,e[e.InvalidBuiltInConverter=202]=`InvalidBuiltInConverter`,e[e.InvalidCustomConverter=203]=`InvalidCustomConverter`,e[e.InvalidConverterType=204]=`InvalidConverterType`,e[e.PrimitiveCoercionFailed=205]=`PrimitiveCoercionFailed`,e[e.ArrayElementConversionFailed=206]=`ArrayElementConversionFailed`,e[e.EmptyArrayElement=207]=`EmptyArrayElement`,e[e.SchemaValidationFailed=208]=`SchemaValidationFailed`,e[e.SchemaThrew=209]=`SchemaThrew`,e[e.MissingDelimiter=301]=`MissingDelimiter`,e[e.InvalidUserDefinedConfig=302]=`InvalidUserDefinedConfig`,e[e.EnvFilesNotFound=303]=`EnvFilesNotFound`,e[e.InvalidKeyInput=304]=`InvalidKeyInput`,e[e.MissingEnvValue=305]=`MissingEnvValue`,e[e.FileApiUnsupported=306]=`FileApiUnsupported`,e[e.NoSourceBound=307]=`NoSourceBound`,e}({});var t=class extends Error{code;issues;constructor(e,t,n){super(t,n?.cause===void 0?void 0:{cause:n.cause}),this.name=`EnvaptError [${e}]`,this.code=e,this.issues=n?.issues}};export{t as EnvaptError,e as EnvaptErrorCodes};
1
+ let e=function(e){return e[e.InvalidFallback=101]=`InvalidFallback`,e[e.InvalidFallbackType=102]=`InvalidFallbackType`,e[e.ArrayFallbackElementTypeMismatch=103]=`ArrayFallbackElementTypeMismatch`,e[e.FallbackConverterTypeMismatch=104]=`FallbackConverterTypeMismatch`,e[e.MalformedTimeFallback=105]=`MalformedTimeFallback`,e[e.InvalidArrayConverterType=201]=`InvalidArrayConverterType`,e[e.InvalidBuiltInConverter=202]=`InvalidBuiltInConverter`,e[e.InvalidCustomConverter=203]=`InvalidCustomConverter`,e[e.InvalidConverterType=204]=`InvalidConverterType`,e[e.PrimitiveCoercionFailed=205]=`PrimitiveCoercionFailed`,e[e.ArrayElementConversionFailed=206]=`ArrayElementConversionFailed`,e[e.EmptyArrayElement=207]=`EmptyArrayElement`,e[e.SchemaValidationFailed=208]=`SchemaValidationFailed`,e[e.SchemaThrew=209]=`SchemaThrew`,e[e.MissingDelimiter=301]=`MissingDelimiter`,e[e.InvalidUserDefinedConfig=302]=`InvalidUserDefinedConfig`,e[e.EnvFilesNotFound=303]=`EnvFilesNotFound`,e[e.InvalidKeyInput=304]=`InvalidKeyInput`,e[e.MissingEnvValue=305]=`MissingEnvValue`,e[e.FileApiUnsupported=306]=`FileApiUnsupported`,e[e.NoSourceBound=307]=`NoSourceBound`,e[e.InvalidMergedSource=308]=`InvalidMergedSource`,e}({});var t=class extends Error{code;issues;constructor(e,t,n){super(t,n?.cause===void 0?void 0:{cause:n.cause}),this.name=`EnvaptError [${e}]`,this.code=e,this.issues=n?.issues}};export{t as EnvaptError,e as EnvaptErrorCodes};
2
2
  //# sourceMappingURL=Error.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"Error.mjs","names":[],"sources":["../../../src/infra/Error.ts"],"sourcesContent":["/* eslint-disable no-magic-numbers */\nimport type { StandardSchemaV1 } from './StandardSchema';\n\n/**\n * Numeric codes carried by {@link EnvaptError.code}, grouped by fallback (1xx), converter (2xx),\n * and configuration (3xx) failures.\n */\nexport enum EnvaptErrorCodes {\n // Fallback related errors\n /** Thrown when an invalid fallback value is provided */\n InvalidFallback = 101,\n /** Thrown when fallback value type doesn't match expected converter type */\n InvalidFallbackType = 102,\n /** Thrown when array fallback contains elements of wrong type */\n ArrayFallbackElementTypeMismatch = 103,\n /** Thrown when fallback type doesn't match the specified converter */\n FallbackConverterTypeMismatch = 104,\n /** Thrown when a time-string fallback is malformed (does not match the required `<number><unit>` format) */\n MalformedTimeFallback = 105,\n\n // Converter related errors\n /** Thrown when invalid array converter configuration is provided */\n InvalidArrayConverterType = 201,\n /** Thrown when an invalid built-in converter is specified */\n InvalidBuiltInConverter = 202,\n /** Thrown when a custom converter is not a function */\n InvalidCustomConverter = 203,\n /** Thrown when converter type is not recognized */\n InvalidConverterType = 204,\n /** Thrown when primitive type coercion on fallback value fails */\n PrimitiveCoercionFailed = 205,\n /** Thrown when an array element fails to convert to the configured element type */\n ArrayElementConversionFailed = 206,\n /** Thrown under strict mode when an array element is empty or whitespace only */\n EmptyArrayElement = 207,\n /** Thrown when a Standard Schema returns issues for a non-empty env value */\n SchemaValidationFailed = 208,\n /** Thrown when a Standard Schema's `validate` itself throws (e.g. a refinement that crashes) */\n SchemaThrew = 209,\n\n // Other errors\n /** Thrown when delimiter is missing in array converter configuration */\n // This doesn't happen because 203 is thrown when object without delimiter is passed\n MissingDelimiter = 301,\n /** Thrown when invalid user-defined configuration is provided */\n InvalidUserDefinedConfig = 302,\n /** Thrown when specified environment files don't exist */\n EnvFilesNotFound = 303,\n /** Thrown when no valid environment key is provided */\n InvalidKeyInput = 304,\n /** Thrown when a required environment value is missing or empty (post-trim) */\n MissingEnvValue = 305,\n /** Thrown when a file-based API (envPaths, baseDir, configureProfiles) is used on a source without filesystem support */\n FileApiUnsupported = 306,\n /** Thrown when an environment value is read before a source is bound via Envapter.useSource */\n NoSourceBound = 307\n}\n\ninterface EnvaptErrorOptions {\n issues?: readonly StandardSchemaV1.Issue[];\n cause?: unknown;\n}\n\n/**\n * Custom error for better DX and debugging when using Envapt.\n *\n * @example\n * ```ts\n * throw new EnvaptError(EnvaptErrorCodes.InvalidFallback, \"Invalid fallback value provided for environment variable.\");\n * ```\n */\nexport class EnvaptError extends Error {\n /** The {@link EnvaptErrorCodes} value identifying what failed. */\n public readonly code: EnvaptErrorCodes;\n /**\n * Populated only for {@link EnvaptErrorCodes.SchemaValidationFailed} (208). For every other\n * code this is `undefined`. Lets callers do `if (err.code === 208) err.issues?.forEach(...)`\n * without a type cast.\n */\n public readonly issues: readonly StandardSchemaV1.Issue[] | undefined;\n\n /** Create an error carrying an {@link EnvaptErrorCodes} code, a message, and optional `cause` / `issues`. */\n constructor(code: EnvaptErrorCodes, message: string, options?: EnvaptErrorOptions) {\n super(message, options?.cause !== undefined ? { cause: options.cause } : undefined);\n this.name = `EnvaptError [${code}]`;\n this.code = code;\n this.issues = options?.issues;\n }\n}\n"],"mappings":"AAOA,IAAY,EAAL,SAAA,EAAA,OAGH,GAAA,EAAA,gBAAA,KAAA,kBAEA,EAAA,EAAA,oBAAA,KAAA,sBAEA,EAAA,EAAA,iCAAA,KAAA,mCAEA,EAAA,EAAA,8BAAA,KAAA,gCAEA,EAAA,EAAA,sBAAA,KAAA,wBAIA,EAAA,EAAA,0BAAA,KAAA,4BAEA,EAAA,EAAA,wBAAA,KAAA,0BAEA,EAAA,EAAA,uBAAA,KAAA,yBAEA,EAAA,EAAA,qBAAA,KAAA,uBAEA,EAAA,EAAA,wBAAA,KAAA,0BAEA,EAAA,EAAA,6BAAA,KAAA,+BAEA,EAAA,EAAA,kBAAA,KAAA,oBAEA,EAAA,EAAA,uBAAA,KAAA,yBAEA,EAAA,EAAA,YAAA,KAAA,cAKA,EAAA,EAAA,iBAAA,KAAA,mBAEA,EAAA,EAAA,yBAAA,KAAA,2BAEA,EAAA,EAAA,iBAAA,KAAA,mBAEA,EAAA,EAAA,gBAAA,KAAA,kBAEA,EAAA,EAAA,gBAAA,KAAA,kBAEA,EAAA,EAAA,mBAAA,KAAA,qBAEA,EAAA,EAAA,cAAA,KAAA,iBACJ,EAAA,CAAA,CAAA,EAeA,IAAa,EAAb,cAAiC,KAAM,CAEnC,KAMA,OAGA,YAAY,EAAwB,EAAiB,EAA8B,CAC/E,MAAM,EAAS,GAAS,QAAU,IAAA,GAAuC,IAAA,GAA3B,CAAE,MAAO,EAAQ,KAAM,CAAa,EAClF,KAAK,KAAO,gBAAgB,EAAK,GACjC,KAAK,KAAO,EACZ,KAAK,OAAS,GAAS,MAC3B,CACJ"}
1
+ {"version":3,"file":"Error.mjs","names":[],"sources":["../../../src/infra/Error.ts"],"sourcesContent":["/* eslint-disable no-magic-numbers */\nimport type { StandardSchemaV1 } from './StandardSchema';\n\n/**\n * Numeric codes carried by {@link EnvaptError.code}, grouped by fallback (1xx), converter (2xx),\n * and configuration (3xx) failures.\n */\nexport enum EnvaptErrorCodes {\n // Fallback related errors\n /** Thrown when an invalid fallback value is provided */\n InvalidFallback = 101,\n /** Thrown when fallback value type doesn't match expected converter type */\n InvalidFallbackType = 102,\n /** Thrown when array fallback contains elements of wrong type */\n ArrayFallbackElementTypeMismatch = 103,\n /** Thrown when fallback type doesn't match the specified converter */\n FallbackConverterTypeMismatch = 104,\n /** Thrown when a time-string fallback is malformed (does not match the required `<number><unit>` format) */\n MalformedTimeFallback = 105,\n\n // Converter related errors\n /** Thrown when invalid array converter configuration is provided */\n InvalidArrayConverterType = 201,\n /** Thrown when an invalid built-in converter is specified */\n InvalidBuiltInConverter = 202,\n /** Thrown when a custom converter is not a function */\n InvalidCustomConverter = 203,\n /** Thrown when converter type is not recognized */\n InvalidConverterType = 204,\n /** Thrown when primitive type coercion on fallback value fails */\n PrimitiveCoercionFailed = 205,\n /** Thrown when an array element fails to convert to the configured element type */\n ArrayElementConversionFailed = 206,\n /** Thrown under strict mode when an array element is empty or whitespace only */\n EmptyArrayElement = 207,\n /** Thrown when a Standard Schema returns issues for a non-empty env value */\n SchemaValidationFailed = 208,\n /** Thrown when a Standard Schema's `validate` itself throws (e.g. a refinement that crashes) */\n SchemaThrew = 209,\n\n // Other errors\n /** Thrown when delimiter is missing in array converter configuration */\n // This doesn't happen because 203 is thrown when object without delimiter is passed\n MissingDelimiter = 301,\n /** Thrown when invalid user-defined configuration is provided */\n InvalidUserDefinedConfig = 302,\n /** Thrown when specified environment files don't exist */\n EnvFilesNotFound = 303,\n /** Thrown when no valid environment key is provided */\n InvalidKeyInput = 304,\n /** Thrown when a required environment value is missing or empty (post-trim) */\n MissingEnvValue = 305,\n /** Thrown when a file-based API (envPaths, baseDir, configureProfiles) is used on a source without filesystem support */\n FileApiUnsupported = 306,\n /** Thrown when an environment value is read before a source is bound via Envapter.useSource */\n NoSourceBound = 307,\n /** Thrown when `merge` is called with no members, or with more than one filesystem-backed source */\n InvalidMergedSource = 308\n}\n\ninterface EnvaptErrorOptions {\n issues?: readonly StandardSchemaV1.Issue[];\n cause?: unknown;\n}\n\n/**\n * Custom error for better DX and debugging when using Envapt.\n *\n * @example\n * ```ts\n * throw new EnvaptError(EnvaptErrorCodes.InvalidFallback, \"Invalid fallback value provided for environment variable.\");\n * ```\n */\nexport class EnvaptError extends Error {\n /** The {@link EnvaptErrorCodes} value identifying what failed. */\n public readonly code: EnvaptErrorCodes;\n /**\n * Populated only for {@link EnvaptErrorCodes.SchemaValidationFailed} (208). For every other\n * code this is `undefined`. Lets callers do `if (err.code === 208) err.issues?.forEach(...)`\n * without a type cast.\n */\n public readonly issues: readonly StandardSchemaV1.Issue[] | undefined;\n\n /** Create an error carrying an {@link EnvaptErrorCodes} code, a message, and optional `cause` / `issues`. */\n constructor(code: EnvaptErrorCodes, message: string, options?: EnvaptErrorOptions) {\n super(message, options?.cause !== undefined ? { cause: options.cause } : undefined);\n this.name = `EnvaptError [${code}]`;\n this.code = code;\n this.issues = options?.issues;\n }\n}\n"],"mappings":"AAOA,IAAY,EAAL,SAAA,EAAA,OAGH,GAAA,EAAA,gBAAA,KAAA,kBAEA,EAAA,EAAA,oBAAA,KAAA,sBAEA,EAAA,EAAA,iCAAA,KAAA,mCAEA,EAAA,EAAA,8BAAA,KAAA,gCAEA,EAAA,EAAA,sBAAA,KAAA,wBAIA,EAAA,EAAA,0BAAA,KAAA,4BAEA,EAAA,EAAA,wBAAA,KAAA,0BAEA,EAAA,EAAA,uBAAA,KAAA,yBAEA,EAAA,EAAA,qBAAA,KAAA,uBAEA,EAAA,EAAA,wBAAA,KAAA,0BAEA,EAAA,EAAA,6BAAA,KAAA,+BAEA,EAAA,EAAA,kBAAA,KAAA,oBAEA,EAAA,EAAA,uBAAA,KAAA,yBAEA,EAAA,EAAA,YAAA,KAAA,cAKA,EAAA,EAAA,iBAAA,KAAA,mBAEA,EAAA,EAAA,yBAAA,KAAA,2BAEA,EAAA,EAAA,iBAAA,KAAA,mBAEA,EAAA,EAAA,gBAAA,KAAA,kBAEA,EAAA,EAAA,gBAAA,KAAA,kBAEA,EAAA,EAAA,mBAAA,KAAA,qBAEA,EAAA,EAAA,cAAA,KAAA,gBAEA,EAAA,EAAA,oBAAA,KAAA,uBACJ,EAAA,CAAA,CAAA,EAeA,IAAa,EAAb,cAAiC,KAAM,CAEnC,KAMA,OAGA,YAAY,EAAwB,EAAiB,EAA8B,CAC/E,MAAM,EAAS,GAAS,QAAU,IAAA,GAAuC,IAAA,GAA3B,CAAE,MAAO,EAAQ,KAAM,CAAa,EAClF,KAAK,KAAO,gBAAgB,EAAK,GACjC,KAAK,KAAO,EACZ,KAAK,OAAS,GAAS,MAC3B,CACJ"}
@@ -0,0 +1,2 @@
1
+ function e(e,t){if(t===void 0)return e;let n=e.split(`_`).filter(e=>e.length>0);if(t===`kebab-case`)return n.map(e=>e.toLowerCase()).join(`-`);let r=n.map(e=>e.charAt(0).toUpperCase()+e.slice(1).toLowerCase()).join(``);return t===`PascalCase`?r:r.charAt(0).toLowerCase()+r.slice(1)}export{e as recase};
2
+ //# sourceMappingURL=recase.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"recase.mjs","names":[],"sources":["../../../src/infra/recase.ts"],"sourcesContent":["import type { KeyCasing } from '../types';\n\n// underscore-delimited words, kept in step with the RecaseKey type transforms in types/Casing.ts.\nexport function recase(name: string, casing?: KeyCasing): string {\n if (casing === undefined) return name;\n const words = name.split('_').filter((word) => word.length > 0);\n if (casing === 'kebab-case') return words.map((word) => word.toLowerCase()).join('-');\n const pascal = words.map((word) => word.charAt(0).toUpperCase() + word.slice(1).toLowerCase()).join('');\n return casing === 'PascalCase' ? pascal : pascal.charAt(0).toLowerCase() + pascal.slice(1);\n}\n"],"mappings":"AAGA,SAAgB,EAAO,EAAc,EAA4B,CAC7D,GAAI,IAAW,IAAA,GAAW,OAAO,EACjC,IAAM,EAAQ,EAAK,MAAM,GAAG,CAAC,CAAC,OAAQ,GAAS,EAAK,OAAS,CAAC,EAC9D,GAAI,IAAW,aAAc,OAAO,EAAM,IAAK,GAAS,EAAK,YAAY,CAAC,CAAC,CAAC,KAAK,GAAG,EACpF,IAAM,EAAS,EAAM,IAAK,GAAS,EAAK,OAAO,CAAC,CAAC,CAAC,YAAY,EAAI,EAAK,MAAM,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,KAAK,EAAE,EACtG,OAAO,IAAW,aAAe,EAAS,EAAO,OAAO,CAAC,CAAC,CAAC,YAAY,EAAI,EAAO,MAAM,CAAC,CAC7F"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"runtime.mjs","names":[],"sources":["../../../src/infra/runtime.ts"],"sourcesContent":["import type { Source } from '../types';\n\n// importing Debug back into EnvapterBase would cycle, so the source and sink are injected via the setters below.\n/* v8 ignore start -- @preserve replaced at load on Node, so the Node suite never runs these defaults */\nlet sink: (line: string) => void = (line) => {\n // eslint-disable-next-line no-console -- the off-Node fallback log sink\n console.error(line);\n};\nlet envReader: () => Record<string, string> = () => ({});\n/* v8 ignore stop */\n\nexport function setRuntimeSink(fn: (line: string) => void): void {\n sink = fn;\n}\n\nexport function writeRuntimeLine(line: string): void {\n sink(line);\n}\n\nexport function readRuntimeEnv(): Record<string, string> {\n return envReader();\n}\n\nexport function bindRuntimeFromSource(source: Source): void {\n envReader = (): Record<string, string> => source.readVars();\n}\n"],"mappings":"AAIA,IAAI,EAAgC,GAAS,CAEzC,QAAQ,MAAM,CAAI,CACtB,EACI,OAAiD,CAAC,GAOtD,SAAgB,EAAiB,EAAoB,CACjD,EAAK,CAAI,CACb,CAEA,SAAgB,GAAyC,CACrD,OAAO,EAAU,CACrB,CAEA,SAAgB,EAAsB,EAAsB,CACxD,MAA0C,EAAO,SAAS,CAC9D"}
@@ -1,2 +1,2 @@
1
- import{coerceToStringRecord as e}from"./coerce.mjs";var t=class{supportsFiles=!1;vars;constructor(t){this.vars=e(t)}readVars(){return{...this.vars}}};export{t as WorkerEnvSource};
2
- //# sourceMappingURL=WorkerEnvSource.mjs.map
1
+ import{coerceToStringRecord as e}from"./coerce.mjs";var t=class{supportsFiles=!1;vars;constructor(t){this.vars=e(t)}readVars(){return{...this.vars}}};export{t as PortableSource};
2
+ //# sourceMappingURL=PortableSource.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PortableSource.mjs","names":[],"sources":["../../../src/sources/PortableSource.ts"],"sourcesContent":["import { coerceToStringRecord } from './coerce';\n\nimport type { BareSource } from '../types';\n\n/**\n * Environment source seeded from an object you provide, for every runtime without a filesystem. The\n * config your bundler injects into a browser build (Vite's `import.meta.env`, a webpack `DefinePlugin`\n * global), the Cloudflare `env` binding, a Vercel Edge or Fastly config object, a test fixture, or any\n * plain object. Pass it straight through. Non-string values are JSON-stringified so the converters\n * still apply, which means they must be JSON-serializable. Without a filesystem the `.env` cascade and\n * file APIs do not apply.\n * @public\n */\nexport class PortableSource implements BareSource {\n /** Always `false`. With no filesystem, the `.env` cascade and file APIs do not apply. */\n readonly supportsFiles = false;\n private readonly vars: Record<string, string>;\n\n /** Seed the source from `vars`. Non-string values are JSON-stringified so the converters still apply. */\n constructor(vars: object) {\n this.vars = coerceToStringRecord(vars);\n }\n\n /** Returns a snapshot clone of the provided object as plain strings. */\n readVars(): Record<string, string> {\n return { ...this.vars };\n }\n}\n"],"mappings":"oDAaA,IAAa,EAAb,KAAkD,CAE9C,cAAyB,GACzB,KAGA,YAAY,EAAc,CACtB,KAAK,KAAO,EAAqB,CAAI,CACzC,CAGA,UAAmC,CAC/B,MAAO,CAAE,GAAG,KAAK,IAAK,CAC1B,CACJ"}
@@ -1,2 +1,2 @@
1
- import{EnvaptError as e}from"../infra/Error.mjs";var t=class{supportsFiles=!1;readVars(){throw new e(307,`No environment source is bound. Call Envapter.useSource(...) with a source such as new ManualEnvSource({...}) or new WorkerEnvSource(env) before reading.`)}};export{t as UnboundEnvSource};
2
- //# sourceMappingURL=UnboundEnvSource.mjs.map
1
+ import{EnvaptError as e}from"../infra/Error.mjs";var t=class{supportsFiles=!1;readVars(){throw new e(307,`No environment source is bound. Call Envapter.useSource(...) with a source such as new PortableSource({...}) before reading.`)}};export{t as UnboundSource};
2
+ //# sourceMappingURL=UnboundSource.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"UnboundSource.mjs","names":[],"sources":["../../../src/sources/UnboundSource.ts"],"sourcesContent":["import { EnvaptError, EnvaptErrorCodes } from '../infra/Error';\n\nimport type { BareSource } from '../types';\n\n/**\n * The default source until one is bound. Every read throws NoSourceBound so a forgotten `useSource`\n * surfaces at read time instead of silently yielding nothing. The Node entry binds {@link FileSource}\n * at load, browser and Workers bundles must call `Envapter.useSource(...)` before reading.\n * @internal\n */\nexport class UnboundSource implements BareSource {\n readonly supportsFiles = false;\n\n readVars(): Record<string, string> {\n throw new EnvaptError(\n EnvaptErrorCodes.NoSourceBound,\n 'No environment source is bound. Call Envapter.useSource(...) with a source such as new PortableSource({...}) before reading.'\n );\n }\n}\n"],"mappings":"iDAUA,IAAa,EAAb,KAAiD,CAC7C,cAAyB,GAEzB,UAAmC,CAC/B,MAAM,IAAI,EAAA,IAEN,8HACJ,CACJ,CACJ"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"coerce.mjs","names":[],"sources":["../../../src/sources/coerce.ts"],"sourcesContent":["// The returned record is fresh, so a caller mutating its object\n// later cannot leak into the source, and non-string values are JSON-stringified.\nexport function coerceToStringRecord(env: object): Record<string, string> {\n const snapshot: Record<string, string> = {};\n // `object` so a Cloudflare `Env` (an interface with no index signature) is accepted. cast to a record\n // to read entries as `unknown` rather than `any`.\n for (const [key, value] of Object.entries(env as Record<string, unknown>)) {\n if (typeof value === 'string') {\n snapshot[key] = value;\n continue;\n }\n const encoded = JSON.stringify(value);\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition -- TS lib mistypes JSON.stringify's return as always-string when it is string | undefined at runtime\n if (encoded !== undefined) snapshot[key] = encoded;\n }\n return snapshot;\n}\n"],"mappings":"AAEA,SAAgB,EAAqB,EAAqC,CACtE,IAAM,EAAmC,CAAC,EAG1C,IAAK,GAAM,CAAC,EAAK,KAAU,OAAO,QAAQ,CAA8B,EAAG,CACvE,GAAI,OAAO,GAAU,SAAU,CAC3B,EAAS,GAAO,EAChB,QACJ,CACA,IAAM,EAAU,KAAK,UAAU,CAAK,EAEhC,IAAY,IAAA,KAAW,EAAS,GAAO,EAC/C,CACA,OAAO,CACX"}
@@ -0,0 +1,2 @@
1
+ import{EnvaptError as e}from"../infra/Error.mjs";function t(...t){if(t.length===0)throw new e(308,`merge requires at least one source.`);let n=t.filter(e=>e.supportsFiles===!0);if(n.length>1)throw new e(308,`merge accepts at most one filesystem-backed source, so the .env cascade and file APIs route to a single member.`);let r=()=>{let e={};for(let n of t)Object.assign(e,n.readVars());return e},i=n[0];return i?{readVars:r,supportsFiles:!0,readFile:(e,t)=>i.readFile(e,t),resolvePath:(e,t)=>i.resolvePath(e,t),normalizeBaseDir:e=>i.normalizeBaseDir(e),writeVars:e=>i.writeVars(e)}:{readVars:r}}export{t as merge};
2
+ //# sourceMappingURL=merge.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"merge.mjs","names":[],"sources":["../../../src/sources/merge.ts"],"sourcesContent":["import { EnvaptError, EnvaptErrorCodes } from '../infra/Error';\n\nimport type { FileCapableSource, Source } from '../types';\n\n/**\n * Compose several sources into one, read last-wins. A later member's value overrides an earlier\n * member's value for the same key. Bind the result with `Envapter.useSource`. Throws\n * {@link EnvaptErrorCodes.InvalidMergedSource} with no members or with more than one file-backed member.\n * @public\n */\nexport function merge(...members: Source[]): Source {\n if (members.length === 0) {\n throw new EnvaptError(EnvaptErrorCodes.InvalidMergedSource, 'merge requires at least one source.');\n }\n\n const fileMembers = members.filter((m): m is FileCapableSource => m.supportsFiles === true);\n if (fileMembers.length > 1) {\n throw new EnvaptError(\n EnvaptErrorCodes.InvalidMergedSource,\n 'merge accepts at most one filesystem-backed source, so the .env cascade and file APIs route to a single member.'\n );\n }\n\n const readVars = (): Record<string, string> => {\n const merged: Record<string, string> = {};\n for (const m of members) Object.assign(merged, m.readVars());\n return merged;\n };\n\n const fileMember = fileMembers[0];\n if (!fileMember) return { readVars };\n\n const fileCapable: FileCapableSource = {\n readVars,\n supportsFiles: true,\n readFile: (path, encoding) => fileMember.readFile(path, encoding),\n resolvePath: (baseDir, candidate) => fileMember.resolvePath(baseDir, candidate),\n normalizeBaseDir: (value) => fileMember.normalizeBaseDir(value),\n writeVars: (vars) => fileMember.writeVars(vars)\n };\n return fileCapable;\n}\n"],"mappings":"iDAUA,SAAgB,EAAM,GAAG,EAA2B,CAChD,GAAI,EAAQ,SAAW,EACnB,MAAM,IAAI,EAAA,IAAkD,qCAAqC,EAGrG,IAAM,EAAc,EAAQ,OAAQ,GAA8B,EAAE,gBAAkB,EAAI,EAC1F,GAAI,EAAY,OAAS,EACrB,MAAM,IAAI,EAAA,IAEN,iHACJ,EAGJ,IAAM,MAAyC,CAC3C,IAAM,EAAiC,CAAC,EACxC,IAAK,IAAM,KAAK,EAAS,OAAO,OAAO,EAAQ,EAAE,SAAS,CAAC,EAC3D,OAAO,CACX,EAEM,EAAa,EAAY,GAW/B,OAVK,EAUE,CAPH,WACA,cAAe,GACf,UAAW,EAAM,IAAa,EAAW,SAAS,EAAM,CAAQ,EAChE,aAAc,EAAS,IAAc,EAAW,YAAY,EAAS,CAAS,EAC9E,iBAAmB,GAAU,EAAW,iBAAiB,CAAK,EAC9D,UAAY,GAAS,EAAW,UAAU,CAAI,CAEjC,EAVO,CAAE,UAAS,CAWvC"}
@@ -24,24 +24,10 @@ type ConverterToken = (typeof SCALAR)[keyof typeof SCALAR];
24
24
  * @public
25
25
  */
26
26
  type CustomElementConverter<TReturn = unknown> = (raw: string) => TReturn;
27
- /**
28
- * Valid element converters for {@link Converters.array}: any scalar token except
29
- * `json` and `regexp` (those don't compose as array elements), or a custom function.
30
- * @public
31
- */
32
27
  type ArrayElement = Exclude<ConverterToken, 'json' | 'regexp'> | CustomElementConverter;
33
- /**
34
- * Phantom-branded token produced by {@link Converters.array}. The `T` type parameter carries
35
- * the element converter through any variable indirection so inference survives. The
36
- * `__envaptKind` discriminant is present at runtime for dispatch.
37
- * @public
38
- */
39
28
  interface ArrayOf<TElement extends ArrayElement = ArrayElement> {
40
- /** Runtime discriminant marking this token as an array converter. Don't use directly. */
41
29
  readonly __envaptKind: 'array';
42
- /** The element converter applied to each split slot. */
43
30
  readonly of: TElement;
44
- /** The string the raw value is split on. */
45
31
  readonly delimiter: string;
46
32
  }
47
33
  /**
@@ -92,5 +78,5 @@ declare const Converters: {
92
78
  readonly Time: "time";
93
79
  };
94
80
  //#endregion
95
- export { ArrayElement, ArrayOf, ConverterToken, Converters, CustomElementConverter, isArrayOf };
81
+ export { ArrayOf, ConverterToken, Converters, CustomElementConverter, isArrayOf };
96
82
  //# sourceMappingURL=Converters.d.mts.map
@@ -1,19 +1,12 @@
1
1
  import { ArrayOf } from "../converters/Converters.mjs";
2
- import { AdvancedConverterReturn, BuiltInConverter, ConditionalReturn, ConverterFunction, InferConverterReturnType, TimeFallback } from "../types/Conversion.mjs";
2
+ import { AdvancedConverterReturn, BuiltInConverter, ConditionalReturn, ConverterFunction, InferConverterReturnType, InferSpecField, RequiredSpec, TimeFallback } from "../types/Conversion.mjs";
3
+ import { KeyCasing, RecaseKey } from "../types/Casing.mjs";
3
4
  import { InferSchemaOutput, StandardSchemaV1 } from "../infra/StandardSchema.mjs";
4
5
  import { SchemaConstraint } from "../types/Schema.mjs";
5
6
  import { EnvKeyInput } from "../types/Env.mjs";
6
7
  import { PrimitiveMethods } from "./PrimitiveMethods.mjs";
7
8
 
8
9
  //#region src/core/AdvancedMethods.d.ts
9
- interface GetUsingRequiredOptions<TConverter> {
10
- converter: TConverter;
11
- required: true;
12
- }
13
- interface GetWithRequiredOptions<TReturnType> {
14
- converter: ConverterFunction<TReturnType>;
15
- required: true;
16
- }
17
10
  /**
18
11
  * Mixin for advanced methods for environment variable conversion using built-in and custom converters
19
12
  * @internal
@@ -23,38 +16,57 @@ declare class AdvancedMethods extends PrimitiveMethods {
23
16
  * Get an environment variable using a built-in converter.
24
17
  *
25
18
  * Supports both scalar tokens (e.g. `Converters.Number`) and `ArrayOf<...>` tokens
26
- * produced by `Converters.array(...)`. The key can be a single name or an ordered list;
27
- * the first defined value wins.
19
+ * produced by `Converters.array(...)`. The key can be a single name or an ordered list.
20
+ * The first defined value wins.
28
21
  */
29
22
  static getUsing<TFallback extends TimeFallback | undefined = undefined>(key: EnvKeyInput, converter: 'time', fallback?: TFallback): ConditionalReturn<number, TFallback>;
30
23
  static getUsing<TConverter extends BuiltInConverter | ArrayOf, TFallback = undefined>(key: EnvKeyInput, converter: TConverter, fallback?: TFallback): AdvancedConverterReturn<TConverter, TFallback>;
31
24
  static getUsing<TReturn>(key: EnvKeyInput, converter: BuiltInConverter | ArrayOf, fallback?: TReturn): TReturn;
32
- static getUsing(key: EnvKeyInput, options: GetUsingRequiredOptions<'time'>): number;
33
- static getUsing<TConverter extends BuiltInConverter | ArrayOf>(key: EnvKeyInput, options: GetUsingRequiredOptions<TConverter>): InferConverterReturnType<TConverter>;
34
25
  /**
35
26
  * @see {@link AdvancedMethods.getUsing}
36
27
  */
37
28
  getUsing<TFallback extends TimeFallback | undefined = undefined>(key: EnvKeyInput, converter: 'time', fallback?: TFallback): ConditionalReturn<number, TFallback>;
38
29
  getUsing<TConverter extends BuiltInConverter | ArrayOf, TFallback = undefined>(key: EnvKeyInput, converter: TConverter, fallback?: TFallback): AdvancedConverterReturn<TConverter, TFallback>;
39
30
  getUsing<TReturn>(key: EnvKeyInput, converter: BuiltInConverter | ArrayOf, fallback?: TReturn): TReturn;
40
- getUsing(key: EnvKeyInput, options: GetUsingRequiredOptions<'time'>): number;
41
- getUsing<TConverter extends BuiltInConverter | ArrayOf>(key: EnvKeyInput, options: GetUsingRequiredOptions<TConverter>): InferConverterReturnType<TConverter>;
42
31
  /**
43
32
  * Get an environment variable using a custom converter function.
44
33
  * Accepts a single key or an ordered list for automatic fallback.
45
34
  */
46
35
  static getWith<TReturnType, TFallback extends TReturnType | undefined = undefined>(key: EnvKeyInput, converter: ConverterFunction<TReturnType>, fallback?: TFallback): ConditionalReturn<TReturnType, TFallback>;
47
- static getWith<TReturnType>(key: EnvKeyInput, options: GetWithRequiredOptions<TReturnType>): TReturnType;
48
36
  /**
49
37
  * @see {@link AdvancedMethods.getWith}
50
38
  */
51
39
  getWith<TReturnType, TFallback extends TReturnType | undefined = undefined>(key: EnvKeyInput, converter: ConverterFunction<TReturnType>, fallback?: TFallback): ConditionalReturn<TReturnType, TFallback>;
52
- getWith<TReturnType>(key: EnvKeyInput, options: GetWithRequiredOptions<TReturnType>): TReturnType;
40
+ /**
41
+ * Read a required environment variable and convert it, throwing `MissingEnvValue` when the value
42
+ * is missing or empty. Returns the non-undefined converter output. Accepts a built-in or `ArrayOf`
43
+ * token, or a custom parser function. The key can be a single name or an ordered list.
44
+ */
45
+ static getRequired<TConverter extends BuiltInConverter | ArrayOf>(key: EnvKeyInput, converter: TConverter): InferConverterReturnType<TConverter>;
46
+ static getRequired<TReturnType>(key: EnvKeyInput, converter: ConverterFunction<TReturnType, string>): TReturnType;
47
+ /**
48
+ * @see {@link AdvancedMethods.getRequired}
49
+ */
50
+ getRequired<TConverter extends BuiltInConverter | ArrayOf>(key: EnvKeyInput, converter: TConverter): InferConverterReturnType<TConverter>;
51
+ getRequired<TReturnType>(key: EnvKeyInput, converter: ConverterFunction<TReturnType, string>): TReturnType;
52
+ /**
53
+ * Read a group of required environment variables in one call. Each key in `spec` maps to a
54
+ * converter (a token, an `array()` token, or a custom parser), and the returned record holds
55
+ * every converted value, all non-undefined. Collects every missing or empty key and throws one
56
+ * `MissingEnvValue` listing them all. Pass a `casing` (`'camelCase'`, `'PascalCase'`, or
57
+ * `'kebab-case'`) to rename the record keys, splitting on underscores, which assumes the
58
+ * conventional SCREAMING_SNAKE env-var names. With no casing the keys stay as-is.
59
+ */
60
+ static getRequiredAll<Spec extends RequiredSpec, Casing extends KeyCasing | undefined = undefined>(spec: Spec, casing?: Casing): { [K in keyof Spec as RecaseKey<K & string, Casing>]: InferSpecField<Spec[K]> };
61
+ /**
62
+ * @see {@link AdvancedMethods.getRequiredAll}
63
+ */
64
+ getRequiredAll<Spec extends RequiredSpec, Casing extends KeyCasing | undefined = undefined>(spec: Spec, casing?: Casing): { [K in keyof Spec as RecaseKey<K & string, Casing>]: InferSpecField<Spec[K]> };
53
65
  /**
54
66
  * Validate an environment variable through a {@link StandardSchemaV1}-conformant schema
55
67
  * (zod, valibot, arktype, etc). Throws `MissingEnvValue` if the env value is absent and
56
- * no fallback is provided. The fallback, when provided, is returned as-is on missing;
57
- * it does NOT pass through the schema (mirrors custom-converter behavior).
68
+ * no fallback is provided. The fallback, when provided, is returned as-is on missing.
69
+ * It does NOT pass through the schema, mirroring custom-converter behavior.
58
70
  *
59
71
  * Synchronous schemas only. A Promise-returning `validate` triggers an
60
72
  * `InvalidUserDefinedConfig` throw at the call site.