envapt 7.1.0 → 8.0.0-next.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (341) hide show
  1. package/CHANGELOG.md +44 -99
  2. package/README.md +1 -1
  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/missing.cjs +2 -0
  38. package/dist/node/core/missing.cjs.map +1 -0
  39. package/dist/node/core/missing.mjs +2 -0
  40. package/dist/node/core/missing.mjs.map +1 -0
  41. package/dist/node/core/paths.cjs +2 -0
  42. package/dist/node/core/paths.cjs.map +1 -0
  43. package/dist/node/core/paths.mjs +2 -0
  44. package/dist/node/core/paths.mjs.map +1 -0
  45. package/dist/node/core/state.cjs +2 -0
  46. package/dist/node/core/state.cjs.map +1 -0
  47. package/dist/node/core/state.mjs +2 -0
  48. package/dist/node/core/state.mjs.map +1 -0
  49. package/dist/node/decorators/legacy/Envapt.cjs.map +1 -1
  50. package/dist/node/decorators/legacy/Envapt.mjs.map +1 -1
  51. package/dist/node/decorators/legacy/SugarDecorators.cjs.map +1 -1
  52. package/dist/node/decorators/legacy/SugarDecorators.mjs.map +1 -1
  53. package/dist/node/decorators/modern/Envapt.cjs.map +1 -1
  54. package/dist/node/decorators/modern/Envapt.mjs.map +1 -1
  55. package/dist/node/decorators/modern/SugarDecorators.cjs.map +1 -1
  56. package/dist/node/decorators/modern/SugarDecorators.mjs.map +1 -1
  57. package/dist/node/decorators/resolveDecoratorValue.cjs +1 -1
  58. package/dist/node/decorators/resolveDecoratorValue.cjs.map +1 -1
  59. package/dist/node/decorators/resolveDecoratorValue.mjs +1 -1
  60. package/dist/node/decorators/resolveDecoratorValue.mjs.map +1 -1
  61. package/dist/node/engine/Envapter.cjs +1 -1
  62. package/dist/node/engine/Envapter.cjs.map +1 -1
  63. package/dist/node/engine/Envapter.mjs +1 -1
  64. package/dist/node/engine/Envapter.mjs.map +1 -1
  65. package/dist/node/engine/NodeEnvapter.cjs +1 -1
  66. package/dist/node/engine/NodeEnvapter.cjs.map +1 -1
  67. package/dist/node/engine/NodeEnvapter.mjs +1 -1
  68. package/dist/node/engine/NodeEnvapter.mjs.map +1 -1
  69. package/dist/node/engine/TemplateResolver.cjs +1 -1
  70. package/dist/node/engine/TemplateResolver.cjs.map +1 -1
  71. package/dist/node/engine/TemplateResolver.mjs +1 -1
  72. package/dist/node/engine/TemplateResolver.mjs.map +1 -1
  73. package/dist/node/engine/Validators.cjs +1 -1
  74. package/dist/node/engine/Validators.cjs.map +1 -1
  75. package/dist/node/engine/Validators.mjs +1 -1
  76. package/dist/node/engine/Validators.mjs.map +1 -1
  77. package/dist/node/index.cjs +1 -1
  78. package/dist/node/index.mjs +1 -1
  79. package/dist/node/infra/Debug.cjs +1 -1
  80. package/dist/node/infra/Debug.cjs.map +1 -1
  81. package/dist/node/infra/Debug.mjs +1 -1
  82. package/dist/node/infra/Debug.mjs.map +1 -1
  83. package/dist/node/infra/Dotenv.cjs.map +1 -1
  84. package/dist/node/infra/Dotenv.mjs.map +1 -1
  85. package/dist/node/infra/Error.cjs +1 -1
  86. package/dist/node/infra/Error.cjs.map +1 -1
  87. package/dist/node/infra/Error.mjs +1 -1
  88. package/dist/node/infra/Error.mjs.map +1 -1
  89. package/dist/node/infra/recase.cjs +2 -0
  90. package/dist/node/infra/recase.cjs.map +1 -0
  91. package/dist/node/infra/recase.mjs +2 -0
  92. package/dist/node/infra/recase.mjs.map +1 -0
  93. package/dist/node/infra/runtime.cjs +1 -1
  94. package/dist/node/infra/runtime.cjs.map +1 -1
  95. package/dist/node/infra/runtime.mjs +1 -1
  96. package/dist/node/infra/runtime.mjs.map +1 -1
  97. package/dist/node/sources/{NodeEnvSource.cjs → FileSource.cjs} +2 -2
  98. package/dist/node/sources/FileSource.cjs.map +1 -0
  99. package/dist/node/sources/{NodeEnvSource.mjs → FileSource.mjs} +2 -2
  100. package/dist/node/sources/FileSource.mjs.map +1 -0
  101. package/dist/node/sources/PortableSource.cjs.map +1 -1
  102. package/dist/node/sources/PortableSource.mjs.map +1 -1
  103. package/dist/node/sources/{UnboundEnvSource.cjs → UnboundSource.cjs} +2 -2
  104. package/dist/node/sources/UnboundSource.cjs.map +1 -0
  105. package/dist/{browser/sources/UnboundEnvSource.mjs → node/sources/UnboundSource.mjs} +2 -2
  106. package/dist/node/sources/UnboundSource.mjs.map +1 -0
  107. package/dist/node/sources/coerce.cjs.map +1 -1
  108. package/dist/node/sources/coerce.mjs.map +1 -1
  109. package/dist/node/sources/merge.cjs +2 -0
  110. package/dist/node/sources/merge.cjs.map +1 -0
  111. package/dist/node/sources/merge.mjs +2 -0
  112. package/dist/node/sources/merge.mjs.map +1 -0
  113. package/dist/node/sources/normalizeSource.cjs +2 -0
  114. package/dist/node/sources/normalizeSource.cjs.map +1 -0
  115. package/dist/node/sources/normalizeSource.mjs +2 -0
  116. package/dist/node/sources/normalizeSource.mjs.map +1 -0
  117. package/dist/portable/converters/BuiltInConverters.mjs +2 -0
  118. package/dist/portable/converters/BuiltInConverters.mjs.map +1 -0
  119. package/dist/portable/converters/Converters.mjs.map +1 -0
  120. package/dist/portable/converters/ValueConverter.mjs +2 -0
  121. package/dist/portable/converters/ValueConverter.mjs.map +1 -0
  122. package/dist/portable/core/AdvancedMethods.mjs +2 -0
  123. package/dist/portable/core/AdvancedMethods.mjs.map +1 -0
  124. package/dist/portable/core/EnvapterBase.mjs +2 -0
  125. package/dist/portable/core/EnvapterBase.mjs.map +1 -0
  126. package/dist/portable/core/Environment.mjs +2 -0
  127. package/dist/portable/core/Environment.mjs.map +1 -0
  128. package/dist/portable/core/EnvironmentMethods.mjs +2 -0
  129. package/dist/portable/core/EnvironmentMethods.mjs.map +1 -0
  130. package/dist/portable/core/PrimitiveMethods.mjs +2 -0
  131. package/dist/portable/core/PrimitiveMethods.mjs.map +1 -0
  132. package/dist/portable/core/engine.mjs +2 -0
  133. package/dist/portable/core/engine.mjs.map +1 -0
  134. package/dist/portable/core/missing.mjs +2 -0
  135. package/dist/portable/core/missing.mjs.map +1 -0
  136. package/dist/portable/core/paths.mjs +2 -0
  137. package/dist/portable/core/paths.mjs.map +1 -0
  138. package/dist/portable/core/state.mjs +2 -0
  139. package/dist/portable/core/state.mjs.map +1 -0
  140. package/dist/{workerd → portable}/decorators/legacy/Envapt.mjs.map +1 -1
  141. package/dist/portable/decorators/legacy/SugarDecorators.mjs.map +1 -0
  142. package/dist/{browser → portable}/decorators/modern/Envapt.mjs.map +1 -1
  143. package/dist/portable/decorators/modern/SugarDecorators.mjs.map +1 -0
  144. package/dist/portable/decorators/resolveDecoratorValue.mjs +2 -0
  145. package/dist/portable/decorators/resolveDecoratorValue.mjs.map +1 -0
  146. package/dist/portable/engine/Envapter.mjs +2 -0
  147. package/dist/portable/engine/Envapter.mjs.map +1 -0
  148. package/dist/portable/engine/PortableEnvapter.mjs +2 -0
  149. package/dist/portable/engine/PortableEnvapter.mjs.map +1 -0
  150. package/dist/portable/engine/TemplateResolver.mjs +2 -0
  151. package/dist/portable/engine/TemplateResolver.mjs.map +1 -0
  152. package/dist/portable/engine/Validators.mjs +2 -0
  153. package/dist/portable/engine/Validators.mjs.map +1 -0
  154. package/dist/portable/engine/fileApiStub.mjs +2 -0
  155. package/dist/portable/engine/fileApiStub.mjs.map +1 -0
  156. package/dist/portable/index.mjs +1 -0
  157. package/dist/portable/infra/Debug.mjs +2 -0
  158. package/dist/portable/infra/Debug.mjs.map +1 -0
  159. package/dist/portable/infra/Dotenv.mjs.map +1 -0
  160. package/dist/{browser → portable}/infra/Error.mjs +1 -1
  161. package/dist/portable/infra/Error.mjs.map +1 -0
  162. package/dist/portable/infra/recase.mjs +2 -0
  163. package/dist/portable/infra/recase.mjs.map +1 -0
  164. package/dist/portable/infra/runtime.mjs +2 -0
  165. package/dist/portable/infra/runtime.mjs.map +1 -0
  166. package/dist/portable/sources/PortableSource.mjs.map +1 -0
  167. package/dist/{node/sources/UnboundEnvSource.mjs → portable/sources/UnboundSource.mjs} +2 -2
  168. package/dist/portable/sources/UnboundSource.mjs.map +1 -0
  169. package/dist/portable/sources/coerce.mjs.map +1 -0
  170. package/dist/portable/sources/merge.mjs +2 -0
  171. package/dist/portable/sources/merge.mjs.map +1 -0
  172. package/dist/portable/sources/normalizeSource.mjs +2 -0
  173. package/dist/portable/sources/normalizeSource.mjs.map +1 -0
  174. package/dist/types/converters/Converters.d.mts +3 -24
  175. package/dist/types/core/AdvancedMethods.d.mts +40 -19
  176. package/dist/types/core/EnvapterBase.d.mts +21 -26
  177. package/dist/types/core/Environment.d.mts +26 -0
  178. package/dist/types/core/EnvironmentMethods.d.mts +8 -67
  179. package/dist/types/core/PrimitiveMethods.d.mts +7 -10
  180. package/dist/types/decorators/legacy/SugarDecorators.d.mts +5 -0
  181. package/dist/types/decorators/modern/SugarDecorators.d.mts +5 -0
  182. package/dist/types/engine/Envapter.d.mts +6 -5
  183. package/dist/types/engine/NodeEnvapter.d.mts +18 -9
  184. package/dist/types/engine/PortableEnvapter.d.mts +17 -5
  185. package/dist/types/index.d.mts +10 -14
  186. package/dist/types/index.portable.d.mts +9 -13
  187. package/dist/types/infra/Debug.d.mts +1 -0
  188. package/dist/types/infra/Dotenv.d.mts +1 -0
  189. package/dist/types/infra/Error.d.mts +5 -1
  190. package/dist/types/infra/StandardSchema.d.mts +2 -12
  191. package/dist/types/sources/{NodeEnvSource.d.mts → FileSource.d.mts} +6 -5
  192. package/dist/types/sources/PortableSource.d.mts +3 -2
  193. package/dist/types/sources/merge.d.mts +16 -0
  194. package/dist/types/types/Casing.d.mts +8 -0
  195. package/dist/types/types/Conversion.d.mts +12 -71
  196. package/dist/types/types/Decorator.d.mts +0 -14
  197. package/dist/types/types/Env.d.mts +1 -10
  198. package/dist/types/types/Options.d.mts +13 -2
  199. package/dist/types/types/Schema.d.mts +1 -13
  200. package/dist/types/types/Source.d.mts +11 -33
  201. package/package.json +62 -19
  202. package/aliases/browser.d.mts +0 -7
  203. package/aliases/browser.mjs +0 -4
  204. package/aliases/workerd.d.mts +0 -7
  205. package/aliases/workerd.mjs +0 -4
  206. package/dist/browser/converters/BuiltInConverters.mjs +0 -2
  207. package/dist/browser/converters/BuiltInConverters.mjs.map +0 -1
  208. package/dist/browser/converters/Converters.mjs.map +0 -1
  209. package/dist/browser/converters/ValueConverter.mjs +0 -2
  210. package/dist/browser/converters/ValueConverter.mjs.map +0 -1
  211. package/dist/browser/core/AdvancedMethods.mjs +0 -2
  212. package/dist/browser/core/AdvancedMethods.mjs.map +0 -1
  213. package/dist/browser/core/EnvapterBase.mjs +0 -2
  214. package/dist/browser/core/EnvapterBase.mjs.map +0 -1
  215. package/dist/browser/core/EnvironmentMethods.mjs +0 -2
  216. package/dist/browser/core/EnvironmentMethods.mjs.map +0 -1
  217. package/dist/browser/core/PrimitiveMethods.mjs +0 -2
  218. package/dist/browser/core/PrimitiveMethods.mjs.map +0 -1
  219. package/dist/browser/decorators/legacy/Envapt.mjs.map +0 -1
  220. package/dist/browser/decorators/legacy/SugarDecorators.mjs.map +0 -1
  221. package/dist/browser/decorators/modern/SugarDecorators.mjs.map +0 -1
  222. package/dist/browser/decorators/resolveDecoratorValue.mjs +0 -2
  223. package/dist/browser/decorators/resolveDecoratorValue.mjs.map +0 -1
  224. package/dist/browser/engine/Envapter.mjs +0 -2
  225. package/dist/browser/engine/Envapter.mjs.map +0 -1
  226. package/dist/browser/engine/PortableEnvapter.mjs +0 -2
  227. package/dist/browser/engine/PortableEnvapter.mjs.map +0 -1
  228. package/dist/browser/engine/TemplateResolver.mjs +0 -2
  229. package/dist/browser/engine/TemplateResolver.mjs.map +0 -1
  230. package/dist/browser/engine/Validators.mjs +0 -2
  231. package/dist/browser/engine/Validators.mjs.map +0 -1
  232. package/dist/browser/engine/installFileApiStubs.mjs +0 -2
  233. package/dist/browser/engine/installFileApiStubs.mjs.map +0 -1
  234. package/dist/browser/index.mjs +0 -1
  235. package/dist/browser/infra/Debug.mjs +0 -2
  236. package/dist/browser/infra/Debug.mjs.map +0 -1
  237. package/dist/browser/infra/Dotenv.mjs.map +0 -1
  238. package/dist/browser/infra/Error.mjs.map +0 -1
  239. package/dist/browser/infra/runtime.mjs +0 -2
  240. package/dist/browser/infra/runtime.mjs.map +0 -1
  241. package/dist/browser/sources/ManualEnvSource.mjs +0 -2
  242. package/dist/browser/sources/ManualEnvSource.mjs.map +0 -1
  243. package/dist/browser/sources/PortableSource.mjs.map +0 -1
  244. package/dist/browser/sources/UnboundEnvSource.mjs.map +0 -1
  245. package/dist/browser/sources/WorkerEnvSource.mjs +0 -2
  246. package/dist/browser/sources/WorkerEnvSource.mjs.map +0 -1
  247. package/dist/browser/sources/coerce.mjs.map +0 -1
  248. package/dist/node/sources/ManualEnvSource.cjs +0 -2
  249. package/dist/node/sources/ManualEnvSource.cjs.map +0 -1
  250. package/dist/node/sources/ManualEnvSource.mjs +0 -2
  251. package/dist/node/sources/ManualEnvSource.mjs.map +0 -1
  252. package/dist/node/sources/NodeEnvSource.cjs.map +0 -1
  253. package/dist/node/sources/NodeEnvSource.mjs.map +0 -1
  254. package/dist/node/sources/UnboundEnvSource.cjs.map +0 -1
  255. package/dist/node/sources/UnboundEnvSource.mjs.map +0 -1
  256. package/dist/node/sources/WorkerEnvSource.cjs +0 -2
  257. package/dist/node/sources/WorkerEnvSource.cjs.map +0 -1
  258. package/dist/node/sources/WorkerEnvSource.mjs +0 -2
  259. package/dist/node/sources/WorkerEnvSource.mjs.map +0 -1
  260. package/dist/types/converters/ValueConverter.d.mts +0 -25
  261. package/dist/types/engine/TemplateResolver.d.mts +0 -17
  262. package/dist/types/sources/ManualEnvSource.d.mts +0 -12
  263. package/dist/types/sources/WorkerEnvSource.d.mts +0 -12
  264. package/dist/workerd/converters/BuiltInConverters.mjs +0 -2
  265. package/dist/workerd/converters/BuiltInConverters.mjs.map +0 -1
  266. package/dist/workerd/converters/Converters.mjs +0 -2
  267. package/dist/workerd/converters/Converters.mjs.map +0 -1
  268. package/dist/workerd/converters/ListOfBuiltInConverters.mjs +0 -2
  269. package/dist/workerd/converters/ListOfBuiltInConverters.mjs.map +0 -1
  270. package/dist/workerd/converters/ValueConverter.mjs +0 -2
  271. package/dist/workerd/converters/ValueConverter.mjs.map +0 -1
  272. package/dist/workerd/core/AdvancedMethods.mjs +0 -2
  273. package/dist/workerd/core/AdvancedMethods.mjs.map +0 -1
  274. package/dist/workerd/core/EnvapterBase.mjs +0 -2
  275. package/dist/workerd/core/EnvapterBase.mjs.map +0 -1
  276. package/dist/workerd/core/EnvironmentMethods.mjs +0 -2
  277. package/dist/workerd/core/EnvironmentMethods.mjs.map +0 -1
  278. package/dist/workerd/core/PrimitiveMethods.mjs +0 -2
  279. package/dist/workerd/core/PrimitiveMethods.mjs.map +0 -1
  280. package/dist/workerd/decorators/legacy/Envapt.mjs +0 -2
  281. package/dist/workerd/decorators/legacy/SugarDecorators.mjs +0 -2
  282. package/dist/workerd/decorators/legacy/SugarDecorators.mjs.map +0 -1
  283. package/dist/workerd/decorators/legacy/createPropertyDecorator.mjs +0 -2
  284. package/dist/workerd/decorators/legacy/createPropertyDecorator.mjs.map +0 -1
  285. package/dist/workerd/decorators/modern/Envapt.mjs +0 -2
  286. package/dist/workerd/decorators/modern/Envapt.mjs.map +0 -1
  287. package/dist/workerd/decorators/modern/SugarDecorators.mjs +0 -2
  288. package/dist/workerd/decorators/modern/SugarDecorators.mjs.map +0 -1
  289. package/dist/workerd/decorators/modern/createAccessorDecorator.mjs +0 -2
  290. package/dist/workerd/decorators/modern/createAccessorDecorator.mjs.map +0 -1
  291. package/dist/workerd/decorators/parseEnvaptOptions.mjs +0 -2
  292. package/dist/workerd/decorators/parseEnvaptOptions.mjs.map +0 -1
  293. package/dist/workerd/decorators/resolveDecoratorValue.mjs +0 -2
  294. package/dist/workerd/decorators/resolveDecoratorValue.mjs.map +0 -1
  295. package/dist/workerd/engine/Envapter.mjs +0 -2
  296. package/dist/workerd/engine/Envapter.mjs.map +0 -1
  297. package/dist/workerd/engine/PortableEnvapter.mjs +0 -2
  298. package/dist/workerd/engine/PortableEnvapter.mjs.map +0 -1
  299. package/dist/workerd/engine/TemplateResolver.mjs +0 -2
  300. package/dist/workerd/engine/TemplateResolver.mjs.map +0 -1
  301. package/dist/workerd/engine/Validators.mjs +0 -2
  302. package/dist/workerd/engine/Validators.mjs.map +0 -1
  303. package/dist/workerd/engine/installFileApiStubs.mjs +0 -2
  304. package/dist/workerd/engine/installFileApiStubs.mjs.map +0 -1
  305. package/dist/workerd/index.mjs +0 -1
  306. package/dist/workerd/infra/Debug.mjs +0 -2
  307. package/dist/workerd/infra/Debug.mjs.map +0 -1
  308. package/dist/workerd/infra/Dotenv.mjs +0 -3
  309. package/dist/workerd/infra/Dotenv.mjs.map +0 -1
  310. package/dist/workerd/infra/Error.mjs +0 -2
  311. package/dist/workerd/infra/Error.mjs.map +0 -1
  312. package/dist/workerd/infra/runtime.mjs +0 -2
  313. package/dist/workerd/infra/runtime.mjs.map +0 -1
  314. package/dist/workerd/legacy.mjs +0 -1
  315. package/dist/workerd/sources/ManualEnvSource.mjs +0 -2
  316. package/dist/workerd/sources/ManualEnvSource.mjs.map +0 -1
  317. package/dist/workerd/sources/PortableSource.mjs +0 -2
  318. package/dist/workerd/sources/PortableSource.mjs.map +0 -1
  319. package/dist/workerd/sources/UnboundEnvSource.mjs +0 -2
  320. package/dist/workerd/sources/UnboundEnvSource.mjs.map +0 -1
  321. package/dist/workerd/sources/WorkerEnvSource.mjs +0 -2
  322. package/dist/workerd/sources/WorkerEnvSource.mjs.map +0 -1
  323. package/dist/workerd/sources/coerce.mjs +0 -2
  324. package/dist/workerd/sources/coerce.mjs.map +0 -1
  325. /package/dist/{browser → portable}/converters/Converters.mjs +0 -0
  326. /package/dist/{browser → portable}/converters/ListOfBuiltInConverters.mjs +0 -0
  327. /package/dist/{browser → portable}/converters/ListOfBuiltInConverters.mjs.map +0 -0
  328. /package/dist/{browser → portable}/decorators/legacy/Envapt.mjs +0 -0
  329. /package/dist/{browser → portable}/decorators/legacy/SugarDecorators.mjs +0 -0
  330. /package/dist/{browser → portable}/decorators/legacy/createPropertyDecorator.mjs +0 -0
  331. /package/dist/{browser → portable}/decorators/legacy/createPropertyDecorator.mjs.map +0 -0
  332. /package/dist/{browser → portable}/decorators/modern/Envapt.mjs +0 -0
  333. /package/dist/{browser → portable}/decorators/modern/SugarDecorators.mjs +0 -0
  334. /package/dist/{browser → portable}/decorators/modern/createAccessorDecorator.mjs +0 -0
  335. /package/dist/{browser → portable}/decorators/modern/createAccessorDecorator.mjs.map +0 -0
  336. /package/dist/{browser → portable}/decorators/parseEnvaptOptions.mjs +0 -0
  337. /package/dist/{browser → portable}/decorators/parseEnvaptOptions.mjs.map +0 -0
  338. /package/dist/{browser → portable}/infra/Dotenv.mjs +0 -0
  339. /package/dist/{browser → portable}/legacy.mjs +0 -0
  340. /package/dist/{browser → portable}/sources/PortableSource.mjs +0 -0
  341. /package/dist/{browser → portable}/sources/coerce.mjs +0 -0
@@ -0,0 +1,2 @@
1
+ import{EnvaptError as e}from"../infra/Error.mjs";import{isMissing as t}from"./missing.mjs";import{debugWarn as n}from"../infra/Debug.mjs";import{resolveKeyInput as r,templateResolver as i,valueConverter as a}from"./engine.mjs";import{PrimitiveMethods as o}from"./PrimitiveMethods.mjs";import{recase as s}from"../infra/recase.mjs";function c(e){return Array.isArray(e)?`[${e.join(`, `)}]`:String(e)}function l(e,n){if(e.value===void 0)return e;let r=n.resolveTemplate(e.key,e.value);return{key:e.key,value:t(r)?void 0:r}}var u=class u extends o{static getUsing(e,i,o){let{key:s,value:c}=r(e);if(t(c)&&o===void 0){n(`${s} is missing or empty`);return}let l=o!==void 0;return a.convertValue(s,o,i,l)}getUsing(e,t,n){return u.getUsing(e,t,n)}static getWith(e,i,o){let{key:s,value:c}=r(e);if(t(c))return n(`${s} is missing or empty`),o;let l=o!==void 0;return a.convertValue(s,o,i,l)}getWith(e,t,n){return u.getWith(e,t,n)}static getRequired(t,n){let o=typeof t==`string`?[t]:t,s=``,u;for(let e of o){let t=l(r(e),i);if(s=t.key,t.value!==void 0){u=t.value;break}}if(u===void 0)throw new e(305,`Required environment variable "${c(t)}" is missing or empty.`);let d=a.convertValue(s,void 0,n,!1);if(d==null)throw new e(305,`Required environment variable "${c(t)}" is present but could not be converted.`);return d}getRequired(e,t){return u.getRequired(e,t)}static getRequiredAll(t,n){let o=Object.keys(t),c=o.filter(e=>l(r(e),i).value===void 0);if(c.length>0)throw new e(305,`Missing required environment variables: ${c.join(`, `)}.`);let u={};for(let r of o){let i=a.convertValue(r,void 0,t[r],!1);if(i==null)throw new e(305,`Required environment variable "${r}" is present but could not be converted.`);u[s(r,n)]=i}return u}getRequiredAll(e,t){return u.getRequiredAll(e,t)}static parse(e,t,n){let r=arguments.length>2;return a.convertWithSchema(e,t,n,r)}parse(e,t,n){let r=arguments.length>2;return a.convertWithSchema(e,t,n,r)}};export{u as AdvancedMethods,l as resolveRequired};
2
+ //# sourceMappingURL=AdvancedMethods.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AdvancedMethods.mjs","names":[],"sources":["../../../src/core/AdvancedMethods.ts"],"sourcesContent":["import { resolveKeyInput, templateResolver, valueConverter } from './engine';\nimport { isMissing } from './missing';\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, then apply the shared missing check so a resolved blank falls\n// through (empty always, whitespace-only under 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: isMissing(value) ? 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 * @see {@link https://envapt.materwelon.dev/docs/envapter#converters}\n * @see {@link https://envapt.materwelon.dev/docs/converters#custom-converters}\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 (isMissing(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 * @see {@link https://envapt.materwelon.dev/docs/envapter#converters}\n * @see {@link https://envapt.materwelon.dev/docs/converters#custom-converters}\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 (isMissing(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 * @see {@link https://envapt.materwelon.dev/docs/envapter#fail-fast-on-missing-values}\n * @see {@link https://envapt.materwelon.dev/docs/converters#require-a-converted-value}\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 * @see {@link https://envapt.materwelon.dev/docs/envapter#fail-fast-on-missing-values}\n * @see {@link https://envapt.materwelon.dev/docs/converters#require-a-converted-value}\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 * @see {@link https://envapt.materwelon.dev/docs/standard-schema#any-conformant-validator-or-none}\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";import{normalizeSource as u}from"../sources/normalizeSource.mjs";var d=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){let n=u(e);t.source=n,r(n),c()}getRaw(e){return l(e).value}};export{d 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';\nimport { normalizeSource } from '../sources/normalizeSource';\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 * @see {@link https://envapt.materwelon.dev/docs/strict-mode#what-strict-mode-changes}\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 * @see {@link https://envapt.materwelon.dev/docs/configuration#debug-logging}\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 * @see {@link https://envapt.materwelon.dev/docs/configuration#mirroring-to-processenv}\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 * @see {@link https://envapt.materwelon.dev/docs/compatibility#binding-by-runtime}\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 * @see {@link https://envapt.materwelon.dev/docs/configuration#which-files-load}\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. Pass a `(key) => string | undefined` reader for\n * a source that reads one key at a time and cannot list its keys. Clears and rebuilds the cache.\n * @see {@link https://envapt.materwelon.dev/docs/sources#the-providers}\n */\n static useSource(source: Source | ((key: string) => string | undefined)): void {\n const resolved = normalizeSource(source);\n state.source = resolved;\n bindRuntimeFromSource(resolved);\n refreshCache();\n }\n\n /**\n * Read an environment variable as its raw string, skipping parsing and conversion.\n * @see {@link https://envapt.materwelon.dev/docs/envapter#raw-values}\n */\n getRaw(key: EnvKeyInput): string | undefined {\n return resolveKeyInput(key).value;\n }\n}\n"],"mappings":"mZAWA,IAAsB,EAAtB,KAAmC,CAM/B,WAAW,OAAO,EAAgB,CAC9B,EAAM,OAAS,EACf,EAAa,CACjB,CAEA,WAAW,QAAkB,CACzB,OAAO,EAAM,MACjB,CAQA,WAAW,MAAM,EAAmB,CAChC,EAAc,CAAK,CACvB,CAEA,WAAW,OAAoB,CAC3B,OAAO,EAAc,CACzB,CAcA,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,CASA,WAAW,YAAY,EAAmB,CACtC,EAAU,oBAAoB,CAAI,EAElC,EAAM,YAAc,CACxB,CAEA,WAAW,aAA2B,CAClC,OAAO,EAAM,WACjB,CAQA,OAAO,MAAa,CAChB,EAAa,CACjB,CASA,OAAO,UAAU,EAA8D,CAC3E,IAAM,EAAW,EAAgB,CAAM,EACvC,EAAM,OAAS,EACf,EAAsB,CAAQ,EAC9B,EAAa,CACjB,CAMA,OAAO,EAAsC,CACzC,OAAO,EAAgB,CAAG,CAAC,CAAC,KAChC,CACJ"}
@@ -0,0 +1,2 @@
1
+ import{isMissing as e}from"./missing.mjs";let t=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 n=[`ENVIRONMENT`,`ENV`,`NODE_ENV`,`MODE`];function r(e){switch(e.toLowerCase()){case`production`:return 2;case`staging`:return 1;case`test`:return 3;case`development`:return 0;default:return}}function i(t){for(let r of n){let n=t(r);if(!e(n))return n}}export{n as ENV_KEYS,t as Environment,i as firstEnvKeyValue,r as parseEnvironment};
2
+ //# sourceMappingURL=Environment.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Environment.mjs","names":[],"sources":["../../../src/core/Environment.ts"],"sourcesContent":["import { isMissing } from './missing';\n\n/**\n * Environment types supported by Envapter\n *\n * The following keys are checked in order until the first with a present (non-missing) value, defaulting to development if none are set:\n * - `ENVIRONMENT`\n * - `ENV`\n * - `NODE_ENV`\n * - `MODE`\n *\n * @public\n * @see {@link https://envapt.materwelon.dev/docs/environment#detecting-the-environment}\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 (!isMissing(value)) return value;\n }\n return undefined;\n}\n"],"mappings":"0CAcA,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,CAAC,EAAU,CAAK,EAAG,OAAO,CAClC,CAEJ"}
@@ -0,0 +1,2 @@
1
+ import{state as e}from"./state.mjs";import"./Environment.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 * @see {@link https://envapt.materwelon.dev/docs/environment#detecting-the-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 * @see {@link https://envapt.materwelon.dev/docs/environment#detecting-the-environment}\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 * @see {@link https://envapt.materwelon.dev/docs/environment#branching-on-the-environment}\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 * @see {@link https://envapt.materwelon.dev/docs/environment#branching-on-the-environment}\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 * @see {@link https://envapt.materwelon.dev/docs/environment#branching-on-the-environment}\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 * @see {@link https://envapt.materwelon.dev/docs/environment#branching-on-the-environment}\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,CAKjD,WAAW,aAA2B,CAIlC,OAHI,EAAM,cAAgB,IAAA,IACtB,EAAqB,EAElB,EAAM,WACjB,CAMA,WAAW,YAAY,EAA2B,CAC9C,EAAqB,CAAG,CAC5B,CAKA,IAAI,aAA2B,CAC3B,OAAO,EAAmB,WAC9B,CAKA,IAAI,YAAY,EAA2B,CACvC,EAAqB,CAAG,CAC5B,CAMA,WAAW,cAAwB,CAC/B,OAAO,KAAK,cAAA,CAChB,CAKA,IAAI,cAAwB,CACxB,OAAO,EAAmB,cAAA,CAC9B,CAMA,WAAW,WAAqB,CAC5B,OAAO,KAAK,cAAA,CAChB,CAKA,IAAI,WAAqB,CACrB,OAAO,EAAmB,cAAA,CAC9B,CAMA,WAAW,eAAyB,CAChC,OAAO,KAAK,cAAA,CAChB,CAKA,IAAI,eAAyB,CACzB,OAAO,EAAmB,cAAA,CAC9B,CAMA,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 * @see {@link https://envapt.materwelon.dev/docs/envapter#primitives}\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 * @see {@link https://envapt.materwelon.dev/docs/envapter#primitives}\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 * @see {@link https://envapt.materwelon.dev/docs/envapter#primitives}\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 * @see {@link https://envapt.materwelon.dev/docs/envapter#primitives}\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 * @see {@link https://envapt.materwelon.dev/docs/envapter#primitives}\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,CAOrD,OAAO,IACH,EACA,EACkC,CAClC,OAAO,EAAc,EAAA,EAAuB,CAAG,CACnD,CAKA,IACI,EACA,EACkC,CAClC,OAAO,EAAc,EAAA,EAAuB,CAAG,CACnD,CAQA,OAAO,UACH,EACA,EACkC,CAClC,OAAO,EAAc,EAAA,EAAuB,CAAG,CACnD,CAKA,UACI,EACA,EACkC,CAClC,OAAO,EAAc,EAAA,EAAuB,CAAG,CACnD,CAQA,OAAO,WACH,EACA,EACmC,CACnC,OAAO,EAAc,EAAA,EAAwB,CAAG,CACpD,CAKA,WACI,EACA,EACmC,CACnC,OAAO,EAAc,EAAA,EAAwB,CAAG,CACpD,CAQA,OAAO,UACH,EACA,EACkC,CAClC,OAAO,EAAc,EAAA,EAAuB,CAAG,CACnD,CAKA,UACI,EACA,EACkC,CAClC,OAAO,EAAc,EAAA,EAAuB,CAAG,CACnD,CAQA,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{EnvaptError as e}from"../infra/Error.mjs";import{cache as t,state as n}from"./state.mjs";import{isMissing as r}from"./missing.mjs";import{ENV_KEYS as i,firstEnvKeyValue as a,parseEnvironment as o}from"./Environment.mjs";import{BuiltInConverters as s}from"../converters/BuiltInConverters.mjs";import{debugVerbose as c,debugWarn as l}from"../infra/Debug.mjs";import{ValueConverter as u}from"../converters/ValueConverter.mjs";import{resolveEffectivePaths as d}from"./paths.mjs";import{TemplateResolver as f}from"../engine/TemplateResolver.mjs";import{loadDotenv as p}from"../infra/Dotenv.mjs";function m(t){let n=Array.isArray(t)?t:[t];if(n.length===0)throw new e(304,`At least one environment key must be provided.`);if(n.some(e=>typeof e!=`string`))throw new e(304,`Environment keys must be strings.`);if(n.some(e=>e.trim()===``))throw new e(304,`Environment keys cannot be empty strings.`);let i;for(let e of n){let t=g(e);if(t!==void 0){if(!r(t))return{key:e,value:t};i??={key:e,value:t}}}return i??{key:n[0],value:void 0}}function h(){if(!n.cacheBuilt){let e=n.source,r={...e.readVars()},i=new Set;if(e.supportsFiles){c(`base dir: ${n.baseDir??`working directory`}`);let t=d();c(`effective .env paths: ${t.length===0?`(none)`:t.join(`, `)}`);try{i=p({...n.userDefinedEnvFileOptions,path:t,processEnv:r,readFile:e.readFile.bind(e)})}catch(e){l(`failed to load .env: ${e instanceof Error?e.message:String(e)}`)}}n.dotenvAddedKeys=i;for(let[e,n]of Object.entries(r))t.set(e,n);c(`cache populated: ${t.size} keys total`),n.cacheBuilt=!0,n.syncProcessEnv&&v()}return t}function g(e){let t=h();if(t.has(e)){let n=t.get(e);return typeof n==`string`?n:void 0}let r=n.source;if(typeof r.readVar!=`function`)return;let i=r.readVar(e);return t.set(e,i),i}function _(){n.environmentExplicitlySet||(n.environment=void 0),t.clear(),n.cacheBuilt=!1,n.dotenvAddedKeys=new Set,c(`cache cleared, reloading config`),h()}function v(){if(n.dotenvAddedKeys.size===0)return;let e=n.source;if(!e.supportsFiles)return;let r={};for(let e of n.dotenvAddedKeys){let n=t.get(e);typeof n==`string`&&(r[e]=y(e,n),c(`mirrored ${e} to the ambient environment`))}e.writeVars(r),c(`mirrored ${n.dotenvAddedKeys.size} keys to the ambient environment`)}function y(e,t){return C.resolveTemplate(e,t)}function b(e){if(typeof e==`number`){n.environment=e,n.environmentExplicitlySet=!0;return}if(typeof e==`string`){n.environment=o(e)??0,n.environmentExplicitlySet=!0;return}let t=a(e=>g(e));if(t===void 0){l(`no environment set (looked for ${i.join(`, `)}); defaulting to development`),n.environment=0;return}let r=o(t);if(r===void 0){l(`unrecognized environment "${t}"; defaulting to development`),n.environment=0;return}n.environment=r}const x={0:`string`,1:`number`,2:`boolean`,3:`bigint`,4:`symbol`},S={getRaw:e=>m(e).value,get:(e,t)=>T(e,0,t)},C=new f(S),w=new u(S);function T(e,t,n){let{key:i,value:a}=m(e);if(r(a))return l(n===void 0?`${i} is missing or empty`:`${i} is missing or empty, using fallback ${String(n)}`),n;let o=C.resolveTemplate(i,String(a)),u;return u=t===1?s.number(o):t===2?s.boolean(o):t===3?s.bigint(o):t===4?s.symbol(o):s.string(o),u===void 0?(c(`could not convert ${i} as ${x[t]}${n===void 0?``:`, using the fallback`}`),n):u}export{b as determineEnvironment,h as ensureLoaded,v as mirrorToProcessEnv,T as readPrimitive,_ as refreshCache,m as resolveKeyInput,C as templateResolver,w 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 { isMissing } from './missing';\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 // An ordered read keeps trying so a present-but-empty candidate falls through to the next, matching\n // getRequired and firstEnvKeyValue. A single key or an all-empty list resolves to the first present value.\n let firstPresent: { key: string; value: string } | undefined;\n for (const candidate of normalizedKeys) {\n const value = readCached(candidate);\n if (value === undefined) continue;\n if (!isMissing(value)) return { key: candidate, value };\n firstPresent ??= { key: candidate, value };\n }\n\n return firstPresent ?? { key: normalizedKeys[0] as string, value: undefined };\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\nfunction readCached(key: string): string | undefined {\n const c = ensureLoaded();\n // decorator memoization also stores non-string values in this shared cache\n if (c.has(key)) {\n const cached = c.get(key);\n return typeof cached === 'string' ? cached : undefined;\n }\n const source = state.source;\n if (typeof source.readVar !== 'function') return undefined;\n const value = source.readVar(key);\n // cache a miss too, so a later read of an absent key skips the reader\n c.set(key, value);\n return value;\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) => readCached(key));\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\nconst PRIMITIVE_NAMES: Record<Primitive, string> = {\n [Primitive.String]: 'string',\n [Primitive.Number]: 'number',\n [Primitive.Boolean]: 'boolean',\n [Primitive.BigInt]: 'bigint',\n [Primitive.Symbol]: '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 (isMissing(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 converted: EnvVarReturnType | undefined;\n if (type === Primitive.Number) converted = BuiltInConverters.number(parsed) as EnvVarReturnType | undefined;\n else if (type === Primitive.Boolean) converted = BuiltInConverters.boolean(parsed) as EnvVarReturnType | undefined;\n else if (type === Primitive.BigInt) converted = BuiltInConverters.bigint(parsed) as EnvVarReturnType | undefined;\n else if (type === Primitive.Symbol) converted = BuiltInConverters.symbol(parsed) as EnvVarReturnType | undefined;\n else converted = BuiltInConverters.string(parsed) as EnvVarReturnType | undefined;\n\n if (converted === undefined) {\n // key and type only, no value: env values can be secrets and verbose logs reach stderr\n debugVerbose(\n `could not convert ${resolvedKey} as ${PRIMITIVE_NAMES[type]}${def !== undefined ? ', using the fallback' : ''}`\n );\n return def as ConditionalReturn<EnvVarReturnType, DefaultType>;\n }\n\n return converted;\n}\n"],"mappings":"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"}
@@ -0,0 +1,2 @@
1
+ import{state as e}from"./state.mjs";function t(t){return!!(t===void 0||t===``||e.strict&&t.trim()===``)}export{t as isMissing};
2
+ //# sourceMappingURL=missing.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"missing.mjs","names":[],"sources":["../../../src/core/missing.ts"],"sourcesContent":["import { state } from './state';\n\n// this should be used to determine if a value is missing EVERYWHERE so the behavior is consistent\nexport function isMissing(value: string | undefined): boolean {\n if (value === undefined || value === '') return true;\n if (state.strict && value.trim() === '') return true;\n return false;\n}\n"],"mappings":"oCAGA,SAAgB,EAAU,EAAoC,CAG1D,MADA,GADI,IAAU,IAAA,IAAa,IAAU,IACjC,EAAM,QAAU,EAAM,KAAK,IAAM,GAEzC"}
@@ -0,0 +1,2 @@
1
+ import{EnvaptError as e}from"../infra/Error.mjs";import{state as t}from"./state.mjs";import{Environment as n,firstEnvKeyValue as r,parseEnvironment as i}from"./Environment.mjs";function a(e){let n=t.baseDir;if(n===void 0)return e;let r=t.source;return r.supportsFiles?r.resolvePath(n,e):e}function o(e){let n=t.source;return n.supportsFiles?n.readFile(e,`utf8`)!==void 0:!1}function s(e){let t=n[e].toLowerCase();return[`.env.${t}.local`,`.env.${t}`,`.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(t.environment!==void 0)return t.environment;let e=t.source,n=e.readVars(),a=r(t=>n[t]??e.readVar?.(t));return a===void 0?0:i(a)??0}function u(){if(t.envPathsExplicitlySet)return t.envPaths.map(e=>a(e));let n=l(),r=t.profiles?.[n],i=c(r);if(i.length>0){let t=i.filter(e=>!o(a(e)));if(t.length>0)throw new e(303,`Environment file not found at path: ${t.join(`, `)}`)}let u=t.profiles?.useDefaults===!1?[]:s(n);return[...i.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// the cache is not built yet here, so read the reader directly (readCached would re-enter this build)\nfunction getCascadeEnvironment(): Environment {\n if (state.environment !== undefined) return state.environment;\n\n const source = state.source;\n const vars = source.readVars();\n const raw = firstEnvKeyValue((key) => vars[key] ?? source.readVar?.(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,CAGA,SAAS,GAAqC,CAC1C,GAAI,EAAM,cAAgB,IAAA,GAAW,OAAO,EAAM,YAElD,IAAM,EAAS,EAAM,OACf,EAAO,EAAO,SAAS,EACvB,EAAM,EAAkB,GAAQ,EAAK,IAAQ,EAAO,UAAU,CAAG,CAAC,EACxE,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"}
@@ -1 +1 @@
1
- {"version":3,"file":"Envapt.mjs","names":[],"sources":["../../../../src/decorators/legacy/Envapt.ts"],"sourcesContent":["import { createPropertyDecorator } from './createPropertyDecorator';\nimport { parseEnvaptOptions } from '../parseEnvaptOptions';\n\nimport type { ArrayOf } from '../../converters';\nimport type { InferSchemaOutput, StandardSchemaV1 } from '../../infra/StandardSchema';\nimport type {\n BuiltInConverter,\n ConverterFunction,\n EnvaptFieldDecorator,\n EnvKeyInput,\n InferConverterFallbackType,\n InferConverterReturnType,\n InferPrimitiveReturnType,\n PrimitiveConstructor,\n SchemaConstraint\n} from '../../types';\n\n/**\n * A custom converter function with a fallback (both required), or a fallback only.\n *\n * @param key - Environment variable name(s) to load\n * @param options - Configuration options\n * @public\n * @example\n * ```ts\n * class Config extends Envapter {\n * \\@Envapt('API_KEY', {\n * fallback: 'default-key',\n * converter(raw, _fallback) {\n * if (!raw || raw.trim() === '') throw new Error('API_KEY required');\n * return raw.trim();\n * }\n * })\n * static readonly apiKey: string;\n *\n * \\@Envapt('LOG_FILE', { fallback: '/var/log/app.log' })\n * static readonly logFile: string;\n *\n * \\@Envapt('RETRY_POLICY', { fallback: { retries: 3, backoff: 'exponential' } })\n * static readonly retryPolicy: unknown;\n * }\n * ```\n */\nexport function Envapt(\n key: EnvKeyInput,\n options: { fallback: undefined; converter?: undefined }\n): EnvaptFieldDecorator<string | undefined>;\nexport function Envapt<TFallback>(\n key: EnvKeyInput,\n options:\n | { converter: (raw: string | undefined, fallback: TFallback) => TFallback; fallback: TFallback }\n | { fallback: TFallback; converter?: undefined }\n): EnvaptFieldDecorator<TFallback>;\n\n/**\n * A custom converter function without a fallback. Omit `required` to return the converter's\n * output (possibly `undefined`), or pass `required: true` to throw `MissingEnvValue` on\n * missing or empty values.\n *\n * @param key - Environment variable name(s) to load\n * @param options - Configuration options\n * @public\n * @example\n * ```ts\n * class Config extends Envapter {\n * \\@Envapt('FEATURE_FLAGS', { converter(raw) {\n * return raw ? raw.split('|').map(s => s.trim()) : [];\n * } })\n * static readonly featureFlags: string[];\n *\n * \\@Envapt('JWT_SECRET', {\n * converter: (raw) => Buffer.from(raw ?? '', 'base64'),\n * required: true\n * })\n * static readonly jwtSecret: Buffer;\n * }\n * ```\n */\nexport function Envapt<TReturnType>(\n key: EnvKeyInput,\n options:\n | { converter: ConverterFunction<TReturnType>; required?: false }\n | { converter: ConverterFunction<TReturnType>; required: true }\n): EnvaptFieldDecorator<TReturnType>;\n\n/**\n * A built-in or array converter with a fallback, or `required: true`. The fallback type tracks\n * the converter, so `Converters.Time` takes a number or time-string and `Converters.Url` takes\n * a `URL` instance.\n *\n * @param key - Environment variable name(s) to load\n * @param options - Configuration options\n * @public\n * @example\n * ```ts\n * import { Converters } from 'envapt';\n *\n * class Config extends Envapter {\n * \\@Envapt('APP_PORT', { converter: Converters.Number, fallback: 3000 })\n * static readonly port: number;\n *\n * // the Url fallback is a URL instance, not a string\n * \\@Envapt('APP_URL', { converter: Converters.Url, fallback: new URL('http://localhost:3000') })\n * static readonly url: URL;\n *\n * // prefers CANARY_URL when present, otherwise APP_URL\n * \\@Envapt(['CANARY_URL', 'APP_URL'], { converter: Converters.Url })\n * static readonly canaryUrl: URL | null;\n *\n * // Time takes a number (milliseconds) or a time-string fallback (`<number><unit>`)\n * \\@Envapt('REQUEST_TIMEOUT', { converter: Converters.Time, fallback: '10s' })\n * static readonly requestTimeout: number;\n *\n * \\@Envapt('ALLOWED_ORIGINS', {\n * converter: Converters.array({ of: Converters.String }),\n * fallback: ['https://example.com']\n * })\n * static readonly allowedOrigins: string[];\n *\n * \\@Envapt('DATABASE_URL', { converter: Converters.Url, required: true })\n * static readonly databaseUrl: URL;\n * }\n * ```\n */\nexport function Envapt<TConverter extends BuiltInConverter | ArrayOf>(\n key: EnvKeyInput,\n options:\n | { converter: TConverter; fallback: InferConverterFallbackType<TConverter>; required?: false }\n | { converter: TConverter; required: true }\n): EnvaptFieldDecorator<InferConverterReturnType<TConverter>>;\nexport function Envapt<TConverter extends BuiltInConverter | ArrayOf>(\n key: EnvKeyInput,\n options: { converter: TConverter; fallback: undefined; required?: false }\n): EnvaptFieldDecorator<InferConverterReturnType<TConverter> | undefined>;\nexport function Envapt<TConverter extends BuiltInConverter | ArrayOf>(\n key: EnvKeyInput,\n options: { converter: TConverter; required?: false }\n): EnvaptFieldDecorator<InferConverterReturnType<TConverter> | null>;\n\n/**\n * A primitive constructor (`Number`, `Boolean`) with an optional fallback.\n *\n * @param key - Environment variable name(s) to load\n * @param options - Configuration options\n * @public\n * @example\n * ```ts\n * class Config extends Envapter {\n * \\@Envapt('MAX_CONNECTIONS', { converter: Number, fallback: 100 })\n * static readonly maxConnections: number;\n *\n * \\@Envapt('FEATURE_ENABLED', { converter: Boolean, fallback: false })\n * static readonly featureEnabled: boolean;\n * }\n * ```\n */\nexport function Envapt<TConstructor extends PrimitiveConstructor>(\n key: EnvKeyInput,\n options:\n | { converter: TConstructor; fallback: InferPrimitiveReturnType<TConstructor>; required?: false }\n | { converter: TConstructor; required: true }\n): EnvaptFieldDecorator<InferPrimitiveReturnType<TConstructor>>;\nexport function Envapt<TConstructor extends PrimitiveConstructor>(\n key: EnvKeyInput,\n options: { converter: TConstructor; fallback: undefined; required?: false }\n): EnvaptFieldDecorator<InferPrimitiveReturnType<TConstructor> | undefined>;\nexport function Envapt<TConstructor extends PrimitiveConstructor>(\n key: EnvKeyInput,\n options: { converter: TConstructor; required?: false }\n): EnvaptFieldDecorator<InferPrimitiveReturnType<TConstructor> | null>;\n\n/**\n * Required, no converter (raw string). Throws `MissingEnvValue` on first access when the env\n * value is missing or empty after trimming, independent of the global `Envapter.strict` flag.\n * Pairing `required: true` with `fallback` matches no overload at compile time, and the runtime\n * Validator rejects dynamic objects that bypass the types.\n *\n * @param key - Environment variable name(s) to load\n * @param options - `{ required: true }`\n * @public\n * @example\n * ```ts\n * class Config extends Envapter {\n * \\@Envapt('API_KEY', { required: true })\n * static readonly apiKey: string;\n * }\n * ```\n */\nexport function Envapt(key: EnvKeyInput, options: { required: true }): EnvaptFieldDecorator<string>;\n\n/**\n * No-fallback form. The property resolves from env or `null`.\n *\n * @param key - Environment variable name(s) to load\n * @public\n * @example\n * ```ts\n * class Config extends Envapter {\n * \\@Envapt('SIMPLE_VALUE')\n * static readonly simple?: string | null;\n * }\n * ```\n */\nexport function Envapt(key: EnvKeyInput): EnvaptFieldDecorator<string | null>;\n\n/**\n * A Standard Schema v1 adapter (zod, valibot, arktype, hand-rolled). Synchronous schemas only,\n * so a Promise-returning `validate` throws `InvalidUserDefinedConfig` at runtime. Pairing\n * `schema` with `converter` matches no overload at compile time, and the runtime Validator\n * rejects dynamic objects that bypass the types.\n * @public\n */\nexport function Envapt<Schema extends StandardSchemaV1>(\n key: EnvKeyInput,\n options:\n | { schema: SchemaConstraint<Schema>; fallback?: InferSchemaOutput<Schema>; required?: false }\n | { schema: SchemaConstraint<Schema>; required: true }\n): EnvaptFieldDecorator<InferSchemaOutput<Schema>>;\n\n/**\n * Instance or static property decorator that loads and converts an environment variable.\n */\nexport function Envapt<TFallback = unknown>(key: EnvKeyInput, options?: unknown): EnvaptFieldDecorator<unknown> {\n return createPropertyDecorator(key, parseEnvaptOptions<TFallback>(options)) as EnvaptFieldDecorator<unknown>;\n}\n"],"mappings":"uIA8NA,SAAgB,EAA4B,EAAkB,EAAkD,CAC5G,OAAO,EAAwB,EAAK,EAA8B,CAAO,CAAC,CAC9E"}
1
+ {"version":3,"file":"Envapt.mjs","names":[],"sources":["../../../../src/decorators/legacy/Envapt.ts"],"sourcesContent":["import { createPropertyDecorator } from './createPropertyDecorator';\nimport { parseEnvaptOptions } from '../parseEnvaptOptions';\n\nimport type { ArrayOf } from '../../converters';\nimport type { InferSchemaOutput, StandardSchemaV1 } from '../../infra/StandardSchema';\nimport type {\n BuiltInConverter,\n ConverterFunction,\n EnvaptFieldDecorator,\n EnvKeyInput,\n InferConverterFallbackType,\n InferConverterReturnType,\n InferPrimitiveReturnType,\n PrimitiveConstructor,\n SchemaConstraint\n} from '../../types';\n\n/**\n * A custom converter function with a fallback (both required), or a fallback only.\n *\n * @param key - Environment variable name(s) to load\n * @param options - Configuration options\n * @public\n * @example\n * ```ts\n * class Config extends Envapter {\n * \\@Envapt('API_KEY', {\n * fallback: 'default-key',\n * converter(raw, _fallback) {\n * if (!raw || raw.trim() === '') throw new Error('API_KEY required');\n * return raw.trim();\n * }\n * })\n * static readonly apiKey: string;\n *\n * \\@Envapt('LOG_FILE', { fallback: '/var/log/app.log' })\n * static readonly logFile: string;\n *\n * \\@Envapt('RETRY_POLICY', { fallback: { retries: 3, backoff: 'exponential' } })\n * static readonly retryPolicy: unknown;\n * }\n * ```\n */\nexport function Envapt(\n key: EnvKeyInput,\n options: { fallback: undefined; converter?: undefined }\n): EnvaptFieldDecorator<string | undefined>;\nexport function Envapt<TFallback>(\n key: EnvKeyInput,\n options:\n | { converter: (raw: string | undefined, fallback: TFallback) => TFallback; fallback: TFallback }\n | { fallback: TFallback; converter?: undefined }\n): EnvaptFieldDecorator<TFallback>;\n\n/**\n * A custom converter function without a fallback. Omit `required` to return the converter's\n * output (possibly `undefined`), or pass `required: true` to throw `MissingEnvValue` on\n * missing or empty values.\n *\n * @param key - Environment variable name(s) to load\n * @param options - Configuration options\n * @public\n * @example\n * ```ts\n * class Config extends Envapter {\n * \\@Envapt('FEATURE_FLAGS', { converter(raw) {\n * return raw ? raw.split('|').map(s => s.trim()) : [];\n * } })\n * static readonly featureFlags: string[];\n *\n * \\@Envapt('JWT_SECRET', {\n * converter: (raw) => Buffer.from(raw ?? '', 'base64'),\n * required: true\n * })\n * static readonly jwtSecret: Buffer;\n * }\n * ```\n */\nexport function Envapt<TReturnType>(\n key: EnvKeyInput,\n options:\n | { converter: ConverterFunction<TReturnType>; required?: false }\n | { converter: ConverterFunction<TReturnType>; required: true }\n): EnvaptFieldDecorator<TReturnType>;\n\n/**\n * A built-in or array converter with a fallback, or `required: true`. The fallback type tracks\n * the converter, so `Converters.Time` takes a number or time-string and `Converters.Url` takes\n * a `URL` instance.\n *\n * @param key - Environment variable name(s) to load\n * @param options - Configuration options\n * @public\n * @example\n * ```ts\n * import { Converters } from 'envapt';\n *\n * class Config extends Envapter {\n * \\@Envapt('APP_PORT', { converter: Converters.Number, fallback: 3000 })\n * static readonly port: number;\n *\n * // the Url fallback is a URL instance, not a string\n * \\@Envapt('APP_URL', { converter: Converters.Url, fallback: new URL('http://localhost:3000') })\n * static readonly url: URL;\n *\n * // prefers CANARY_URL when present, otherwise APP_URL\n * \\@Envapt(['CANARY_URL', 'APP_URL'], { converter: Converters.Url })\n * static readonly canaryUrl: URL | null;\n *\n * // Time takes a number (milliseconds) or a time-string fallback (`<number><unit>`)\n * \\@Envapt('REQUEST_TIMEOUT', { converter: Converters.Time, fallback: '10s' })\n * static readonly requestTimeout: number;\n *\n * \\@Envapt('ALLOWED_ORIGINS', {\n * converter: Converters.array({ of: Converters.String }),\n * fallback: ['https://example.com']\n * })\n * static readonly allowedOrigins: string[];\n *\n * \\@Envapt('DATABASE_URL', { converter: Converters.Url, required: true })\n * static readonly databaseUrl: URL;\n * }\n * ```\n */\nexport function Envapt<TConverter extends BuiltInConverter | ArrayOf>(\n key: EnvKeyInput,\n options:\n | { converter: TConverter; fallback: InferConverterFallbackType<TConverter>; required?: false }\n | { converter: TConverter; required: true }\n): EnvaptFieldDecorator<InferConverterReturnType<TConverter>>;\nexport function Envapt<TConverter extends BuiltInConverter | ArrayOf>(\n key: EnvKeyInput,\n options: { converter: TConverter; fallback: undefined; required?: false }\n): EnvaptFieldDecorator<InferConverterReturnType<TConverter> | undefined>;\nexport function Envapt<TConverter extends BuiltInConverter | ArrayOf>(\n key: EnvKeyInput,\n options: { converter: TConverter; required?: false }\n): EnvaptFieldDecorator<InferConverterReturnType<TConverter> | null>;\n\n/**\n * A primitive constructor (`Number`, `Boolean`) with an optional fallback.\n *\n * @param key - Environment variable name(s) to load\n * @param options - Configuration options\n * @public\n * @example\n * ```ts\n * class Config extends Envapter {\n * \\@Envapt('MAX_CONNECTIONS', { converter: Number, fallback: 100 })\n * static readonly maxConnections: number;\n *\n * \\@Envapt('FEATURE_ENABLED', { converter: Boolean, fallback: false })\n * static readonly featureEnabled: boolean;\n * }\n * ```\n */\nexport function Envapt<TConstructor extends PrimitiveConstructor>(\n key: EnvKeyInput,\n options:\n | { converter: TConstructor; fallback: InferPrimitiveReturnType<TConstructor>; required?: false }\n | { converter: TConstructor; required: true }\n): EnvaptFieldDecorator<InferPrimitiveReturnType<TConstructor>>;\nexport function Envapt<TConstructor extends PrimitiveConstructor>(\n key: EnvKeyInput,\n options: { converter: TConstructor; fallback: undefined; required?: false }\n): EnvaptFieldDecorator<InferPrimitiveReturnType<TConstructor> | undefined>;\nexport function Envapt<TConstructor extends PrimitiveConstructor>(\n key: EnvKeyInput,\n options: { converter: TConstructor; required?: false }\n): EnvaptFieldDecorator<InferPrimitiveReturnType<TConstructor> | null>;\n\n/**\n * Required, no converter (raw string). Throws `MissingEnvValue` on first access when the env\n * value is missing or empty after trimming, independent of the global `Envapter.strict` flag.\n * Pairing `required: true` with `fallback` matches no overload at compile time, and the runtime\n * Validator rejects dynamic objects that bypass the types.\n *\n * @param key - Environment variable name(s) to load\n * @param options - `{ required: true }`\n * @public\n * @example\n * ```ts\n * class Config extends Envapter {\n * \\@Envapt('API_KEY', { required: true })\n * static readonly apiKey: string;\n * }\n * ```\n */\nexport function Envapt(key: EnvKeyInput, options: { required: true }): EnvaptFieldDecorator<string>;\n\n/**\n * No-fallback form. The property resolves from env or `null`.\n *\n * @param key - Environment variable name(s) to load\n * @public\n * @example\n * ```ts\n * class Config extends Envapter {\n * \\@Envapt('SIMPLE_VALUE')\n * static readonly simple?: string | null;\n * }\n * ```\n */\nexport function Envapt(key: EnvKeyInput): EnvaptFieldDecorator<string | null>;\n\n/**\n * A Standard Schema v1 adapter (zod, valibot, arktype, hand-rolled). Synchronous schemas only,\n * so a Promise-returning `validate` throws `InvalidUserDefinedConfig` at runtime. Pairing\n * `schema` with `converter` matches no overload at compile time, and the runtime Validator\n * rejects dynamic objects that bypass the types.\n * @public\n */\nexport function Envapt<Schema extends StandardSchemaV1>(\n key: EnvKeyInput,\n options:\n | { schema: SchemaConstraint<Schema>; fallback?: InferSchemaOutput<Schema>; required?: false }\n | { schema: SchemaConstraint<Schema>; required: true }\n): EnvaptFieldDecorator<InferSchemaOutput<Schema>>;\n\n/**\n * Instance or static property decorator that loads and converts an environment variable.\n * @see {@link https://envapt.materwelon.dev/docs/decorators#declaring-decorated-fields}\n */\nexport function Envapt<TFallback = unknown>(key: EnvKeyInput, options?: unknown): EnvaptFieldDecorator<unknown> {\n return createPropertyDecorator(key, parseEnvaptOptions<TFallback>(options)) as EnvaptFieldDecorator<unknown>;\n}\n"],"mappings":"uIA+NA,SAAgB,EAA4B,EAAkB,EAAkD,CAC5G,OAAO,EAAwB,EAAK,EAA8B,CAAO,CAAC,CAC9E"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SugarDecorators.mjs","names":[],"sources":["../../../../src/decorators/legacy/SugarDecorators.ts"],"sourcesContent":["import { createPropertyDecorator } from './createPropertyDecorator';\nimport { Converters } from '../../converters';\n\nimport type { ConverterToken } from '../../converters';\nimport type { EnvaptFieldDecorator, EnvKeyInput, TimeFallback } from '../../types';\n\nfunction sugar<TFallback>(\n converter: ConverterToken,\n key: EnvKeyInput,\n fallback: TFallback | undefined\n): EnvaptFieldDecorator<TFallback> {\n // the runtime installer is a plain (target, key) decorator, so the cast only adds a\n // compile-time field-type constraint with no runtime counterpart\n return createPropertyDecorator<TFallback>(key, {\n converter,\n fallback,\n hasFallback: fallback !== undefined,\n required: false,\n schema: undefined\n }) as EnvaptFieldDecorator<TFallback>;\n}\n\n/**\n * Shorthand for `@Envapt(key, { converter: Converters.Boolean, fallback })`.\n * @public\n * @see {@link https://envapt.materwelon.dev/docs/decorators#shorthand-decorators}\n */\nexport function EnvBool(key: EnvKeyInput, fallback: boolean): EnvaptFieldDecorator<boolean>;\nexport function EnvBool(key: EnvKeyInput): EnvaptFieldDecorator<boolean | null>;\nexport function EnvBool(key: EnvKeyInput, fallback?: boolean): EnvaptFieldDecorator<boolean | null> {\n return sugar(Converters.Boolean, key, fallback);\n}\n\n/**\n * Shorthand for `@Envapt(key, { converter: Converters.Number, fallback })`.\n * @public\n * @see {@link https://envapt.materwelon.dev/docs/decorators#shorthand-decorators}\n */\nexport function EnvNum(key: EnvKeyInput, fallback: number): EnvaptFieldDecorator<number>;\nexport function EnvNum(key: EnvKeyInput): EnvaptFieldDecorator<number | null>;\nexport function EnvNum(key: EnvKeyInput, fallback?: number): EnvaptFieldDecorator<number | null> {\n return sugar(Converters.Number, key, fallback);\n}\n\n/**\n * Shorthand for `@Envapt(key, { converter: Converters.String, fallback })`.\n * @public\n * @see {@link https://envapt.materwelon.dev/docs/decorators#shorthand-decorators}\n */\nexport function EnvStr(key: EnvKeyInput, fallback: string): EnvaptFieldDecorator<string>;\nexport function EnvStr(key: EnvKeyInput): EnvaptFieldDecorator<string | null>;\nexport function EnvStr(key: EnvKeyInput, fallback?: string): EnvaptFieldDecorator<string | null> {\n return sugar(Converters.String, key, fallback);\n}\n\n/**\n * Shorthand for `@Envapt(key, { converter: Converters.Time, fallback })`. The fallback is a\n * millisecond number or a time string (`'15m'`), and the resolved value is always milliseconds.\n * @public\n * @see {@link https://envapt.materwelon.dev/docs/decorators#shorthand-decorators}\n */\nexport function EnvTime(key: EnvKeyInput, fallback: TimeFallback): EnvaptFieldDecorator<number>;\nexport function EnvTime(key: EnvKeyInput): EnvaptFieldDecorator<number | null>;\nexport function EnvTime(key: EnvKeyInput, fallback?: TimeFallback): EnvaptFieldDecorator<number | null> {\n return sugar(Converters.Time, key, fallback);\n}\n\n/**\n * Shorthand for `@Envapt(key, { converter: Converters.Url, fallback })`. The fallback is a `URL`\n * instance, not a URL string.\n * @public\n * @see {@link https://envapt.materwelon.dev/docs/decorators#shorthand-decorators}\n */\nexport function EnvUrl(key: EnvKeyInput, fallback: URL): EnvaptFieldDecorator<URL>;\nexport function EnvUrl(key: EnvKeyInput): EnvaptFieldDecorator<URL | null>;\nexport function EnvUrl(key: EnvKeyInput, fallback?: URL): EnvaptFieldDecorator<URL | null> {\n return sugar(Converters.Url, key, fallback);\n}\n"],"mappings":"qIAMA,SAAS,EACL,EACA,EACA,EAC+B,CAG/B,OAAO,EAAmC,EAAK,CAC3C,YACA,WACA,YAAa,IAAa,IAAA,GAC1B,SAAU,GACV,OAAQ,IAAA,EACZ,CAAC,CACL,CASA,SAAgB,EAAQ,EAAkB,EAA0D,CAChG,OAAO,EAAM,EAAW,QAAS,EAAK,CAAQ,CAClD,CASA,SAAgB,EAAO,EAAkB,EAAwD,CAC7F,OAAO,EAAM,EAAW,OAAQ,EAAK,CAAQ,CACjD,CASA,SAAgB,EAAO,EAAkB,EAAwD,CAC7F,OAAO,EAAM,EAAW,OAAQ,EAAK,CAAQ,CACjD,CAUA,SAAgB,EAAQ,EAAkB,EAA8D,CACpG,OAAO,EAAM,EAAW,KAAM,EAAK,CAAQ,CAC/C,CAUA,SAAgB,EAAO,EAAkB,EAAkD,CACvF,OAAO,EAAM,EAAW,IAAK,EAAK,CAAQ,CAC9C"}
@@ -1 +1 @@
1
- {"version":3,"file":"Envapt.mjs","names":[],"sources":["../../../../src/decorators/modern/Envapt.ts"],"sourcesContent":["import { createAccessorDecorator } from './createAccessorDecorator';\nimport { parseEnvaptOptions } from '../parseEnvaptOptions';\n\nimport type { ArrayOf } from '../../converters';\nimport type { InferSchemaOutput, StandardSchemaV1 } from '../../infra/StandardSchema';\nimport type {\n BuiltInConverter,\n ConverterFunction,\n EnvaptAccessorDecorator,\n EnvKeyInput,\n InferConverterFallbackType,\n InferConverterReturnType,\n InferPrimitiveReturnType,\n PrimitiveConstructor,\n SchemaConstraint\n} from '../../types';\n\n/**\n * A custom converter function with a fallback (both required), or a fallback only.\n *\n * @param key - Environment variable name(s) to load\n * @param options - Configuration options\n * @public\n * @example\n * ```ts\n * class Config {\n * \\@Envapt('API_KEY', {\n * fallback: 'default-key',\n * converter(raw, _fallback) {\n * if (!raw || raw.trim() === '') throw new Error('API_KEY required');\n * return raw.trim();\n * }\n * })\n * static accessor apiKey: string;\n *\n * \\@Envapt('LOG_FILE', { fallback: '/var/log/app.log' })\n * static accessor logFile: string;\n *\n * \\@Envapt('RETRY_POLICY', { fallback: { retries: 3, backoff: 'exponential' } })\n * static accessor retryPolicy: unknown;\n * }\n * ```\n */\nexport function Envapt(\n key: EnvKeyInput,\n options: { fallback: undefined; converter?: undefined }\n): EnvaptAccessorDecorator<string | undefined>;\nexport function Envapt<TFallback>(\n key: EnvKeyInput,\n options:\n | { converter: (raw: string | undefined, fallback: TFallback) => TFallback; fallback: TFallback }\n | { fallback: TFallback; converter?: undefined }\n): EnvaptAccessorDecorator<TFallback>;\n\n/**\n * A custom converter function without a fallback. Omit `required` to return the converter's\n * output (possibly `undefined`), or pass `required: true` to throw `MissingEnvValue` on\n * missing or empty values.\n *\n * @param key - Environment variable name(s) to load\n * @param options - Configuration options\n * @public\n * @example\n * ```ts\n * class Config {\n * \\@Envapt('FEATURE_FLAGS', { converter(raw) {\n * return raw ? raw.split('|').map(s => s.trim()) : [];\n * } })\n * static accessor featureFlags: string[];\n *\n * \\@Envapt('JWT_SECRET', {\n * converter: (raw) => Buffer.from(raw ?? '', 'base64'),\n * required: true\n * })\n * static accessor jwtSecret: Buffer;\n * }\n * ```\n */\nexport function Envapt<TReturnType>(\n key: EnvKeyInput,\n options:\n | { converter: ConverterFunction<TReturnType>; required?: false }\n | { converter: ConverterFunction<TReturnType>; required: true }\n): EnvaptAccessorDecorator<TReturnType>;\n\n/**\n * A built-in or array converter with a fallback, or `required: true`. The fallback type tracks\n * the converter, so `Converters.Time` takes a number or time-string and `Converters.Url` takes\n * a `URL` instance.\n *\n * @param key - Environment variable name(s) to load\n * @param options - Configuration options\n * @public\n * @example\n * ```ts\n * import { Converters } from 'envapt';\n *\n * class Config {\n * \\@Envapt('APP_PORT', { converter: Converters.Number, fallback: 3000 })\n * static accessor port: number;\n *\n * // the Url fallback is a URL instance, not a string\n * \\@Envapt('APP_URL', { converter: Converters.Url, fallback: new URL('http://localhost:3000') })\n * static accessor url: URL;\n *\n * // prefers CANARY_URL when present, otherwise APP_URL\n * \\@Envapt(['CANARY_URL', 'APP_URL'], { converter: Converters.Url })\n * static accessor canaryUrl: URL | null;\n *\n * // Time takes a number (milliseconds) or a time-string fallback (`<number><unit>`)\n * \\@Envapt('REQUEST_TIMEOUT', { converter: Converters.Time, fallback: '10s' })\n * static accessor requestTimeout: number;\n *\n * \\@Envapt('ALLOWED_ORIGINS', {\n * converter: Converters.array({ of: Converters.String }),\n * fallback: ['https://example.com']\n * })\n * static accessor allowedOrigins: string[];\n *\n * \\@Envapt('DATABASE_URL', { converter: Converters.Url, required: true })\n * static accessor databaseUrl: URL;\n * }\n * ```\n */\nexport function Envapt<TConverter extends BuiltInConverter | ArrayOf>(\n key: EnvKeyInput,\n options:\n | { converter: TConverter; fallback: InferConverterFallbackType<TConverter>; required?: false }\n | { converter: TConverter; required: true }\n): EnvaptAccessorDecorator<InferConverterReturnType<TConverter>>;\nexport function Envapt<TConverter extends BuiltInConverter | ArrayOf>(\n key: EnvKeyInput,\n options: { converter: TConverter; fallback: undefined; required?: false }\n): EnvaptAccessorDecorator<InferConverterReturnType<TConverter> | undefined>;\nexport function Envapt<TConverter extends BuiltInConverter | ArrayOf>(\n key: EnvKeyInput,\n options: { converter: TConverter; required?: false }\n): EnvaptAccessorDecorator<InferConverterReturnType<TConverter> | null>;\n\n/**\n * A primitive constructor (`Number`, `Boolean`) with an optional fallback.\n *\n * @param key - Environment variable name(s) to load\n * @param options - Configuration options\n * @public\n * @example\n * ```ts\n * class Config {\n * \\@Envapt('MAX_CONNECTIONS', { converter: Number, fallback: 100 })\n * static accessor maxConnections: number;\n *\n * \\@Envapt('FEATURE_ENABLED', { converter: Boolean, fallback: false })\n * static accessor featureEnabled: boolean;\n * }\n * ```\n */\nexport function Envapt<TConstructor extends PrimitiveConstructor>(\n key: EnvKeyInput,\n options:\n | { converter: TConstructor; fallback: InferPrimitiveReturnType<TConstructor>; required?: false }\n | { converter: TConstructor; required: true }\n): EnvaptAccessorDecorator<InferPrimitiveReturnType<TConstructor>>;\nexport function Envapt<TConstructor extends PrimitiveConstructor>(\n key: EnvKeyInput,\n options: { converter: TConstructor; fallback: undefined; required?: false }\n): EnvaptAccessorDecorator<InferPrimitiveReturnType<TConstructor> | undefined>;\nexport function Envapt<TConstructor extends PrimitiveConstructor>(\n key: EnvKeyInput,\n options: { converter: TConstructor; required?: false }\n): EnvaptAccessorDecorator<InferPrimitiveReturnType<TConstructor> | null>;\n\n/**\n * Required, no converter (raw string). Throws `MissingEnvValue` on first access when the env\n * value is missing or empty after trimming, independent of the global `Envapter.strict` flag.\n * Pairing `required: true` with `fallback` matches no overload at compile time, and the runtime\n * Validator rejects dynamic objects that bypass the types.\n *\n * @param key - Environment variable name(s) to load\n * @param options - `{ required: true }`\n * @public\n * @example\n * ```ts\n * class Config {\n * \\@Envapt('API_KEY', { required: true })\n * static accessor apiKey: string;\n * }\n * ```\n */\nexport function Envapt(key: EnvKeyInput, options: { required: true }): EnvaptAccessorDecorator<string>;\n\n/**\n * No-fallback form. The property resolves from env or `null`.\n *\n * @param key - Environment variable name(s) to load\n * @public\n * @example\n * ```ts\n * class Config {\n * \\@Envapt('SIMPLE_VALUE')\n * static accessor simple: string | null;\n * }\n * ```\n */\nexport function Envapt(key: EnvKeyInput): EnvaptAccessorDecorator<string | null>;\n\n/**\n * A Standard Schema v1 adapter (zod, valibot, arktype, hand-rolled). Synchronous schemas only,\n * so a Promise-returning `validate` throws `InvalidUserDefinedConfig` at runtime. Pairing\n * `schema` with `converter` matches no overload at compile time, and the runtime Validator\n * rejects dynamic objects that bypass the types.\n * @public\n */\nexport function Envapt<Schema extends StandardSchemaV1>(\n key: EnvKeyInput,\n options:\n | { schema: SchemaConstraint<Schema>; fallback?: InferSchemaOutput<Schema>; required?: false }\n | { schema: SchemaConstraint<Schema>; required: true }\n): EnvaptAccessorDecorator<InferSchemaOutput<Schema>>;\n\n/**\n * Modern (TC39 Stage 3) accessor decorator that loads and converts an environment variable. The\n * decorated property uses the `accessor` keyword and needs no `experimentalDecorators` flag.\n * Instance accessors need the definite-assignment `!`, static accessors do not.\n *\n * @param key - Environment variable name(s) to load\n * @param options - Converter, fallback, `required`, or `schema`. See the overloads.\n * @public\n * @example\n * ```ts\n * import { Envapt, Converters } from 'envapt';\n *\n * class Config {\n * \\@Envapt('APP_PORT', { converter: Converters.Number, fallback: 3000 })\n * static accessor port: number;\n *\n * \\@Envapt('DATABASE_URL', { converter: Converters.Url, required: true })\n * accessor databaseUrl!: URL;\n * }\n * ```\n */\n/* v8 ignore start -- @preserve oxc (vitest's transform) breaks modern accessor decorators (context.name unset), so the tsc stage3-emit harness covers these, not vitest */\nexport function Envapt<TFallback = unknown>(key: EnvKeyInput, options?: unknown): EnvaptAccessorDecorator<unknown> {\n return createAccessorDecorator(key, parseEnvaptOptions<TFallback>(options)) as EnvaptAccessorDecorator<unknown>;\n}\n/* v8 ignore stop */\n"],"mappings":"uIAiPA,SAAgB,EAA4B,EAAkB,EAAqD,CAC/G,OAAO,EAAwB,EAAK,EAA8B,CAAO,CAAC,CAC9E"}
1
+ {"version":3,"file":"Envapt.mjs","names":[],"sources":["../../../../src/decorators/modern/Envapt.ts"],"sourcesContent":["import { createAccessorDecorator } from './createAccessorDecorator';\nimport { parseEnvaptOptions } from '../parseEnvaptOptions';\n\nimport type { ArrayOf } from '../../converters';\nimport type { InferSchemaOutput, StandardSchemaV1 } from '../../infra/StandardSchema';\nimport type {\n BuiltInConverter,\n ConverterFunction,\n EnvaptAccessorDecorator,\n EnvKeyInput,\n InferConverterFallbackType,\n InferConverterReturnType,\n InferPrimitiveReturnType,\n PrimitiveConstructor,\n SchemaConstraint\n} from '../../types';\n\n/**\n * A custom converter function with a fallback (both required), or a fallback only.\n *\n * @param key - Environment variable name(s) to load\n * @param options - Configuration options\n * @public\n * @example\n * ```ts\n * class Config {\n * \\@Envapt('API_KEY', {\n * fallback: 'default-key',\n * converter(raw, _fallback) {\n * if (!raw || raw.trim() === '') throw new Error('API_KEY required');\n * return raw.trim();\n * }\n * })\n * static accessor apiKey: string;\n *\n * \\@Envapt('LOG_FILE', { fallback: '/var/log/app.log' })\n * static accessor logFile: string;\n *\n * \\@Envapt('RETRY_POLICY', { fallback: { retries: 3, backoff: 'exponential' } })\n * static accessor retryPolicy: unknown;\n * }\n * ```\n */\nexport function Envapt(\n key: EnvKeyInput,\n options: { fallback: undefined; converter?: undefined }\n): EnvaptAccessorDecorator<string | undefined>;\nexport function Envapt<TFallback>(\n key: EnvKeyInput,\n options:\n | { converter: (raw: string | undefined, fallback: TFallback) => TFallback; fallback: TFallback }\n | { fallback: TFallback; converter?: undefined }\n): EnvaptAccessorDecorator<TFallback>;\n\n/**\n * A custom converter function without a fallback. Omit `required` to return the converter's\n * output (possibly `undefined`), or pass `required: true` to throw `MissingEnvValue` on\n * missing or empty values.\n *\n * @param key - Environment variable name(s) to load\n * @param options - Configuration options\n * @public\n * @example\n * ```ts\n * class Config {\n * \\@Envapt('FEATURE_FLAGS', { converter(raw) {\n * return raw ? raw.split('|').map(s => s.trim()) : [];\n * } })\n * static accessor featureFlags: string[];\n *\n * \\@Envapt('JWT_SECRET', {\n * converter: (raw) => Buffer.from(raw ?? '', 'base64'),\n * required: true\n * })\n * static accessor jwtSecret: Buffer;\n * }\n * ```\n */\nexport function Envapt<TReturnType>(\n key: EnvKeyInput,\n options:\n | { converter: ConverterFunction<TReturnType>; required?: false }\n | { converter: ConverterFunction<TReturnType>; required: true }\n): EnvaptAccessorDecorator<TReturnType>;\n\n/**\n * A built-in or array converter with a fallback, or `required: true`. The fallback type tracks\n * the converter, so `Converters.Time` takes a number or time-string and `Converters.Url` takes\n * a `URL` instance.\n *\n * @param key - Environment variable name(s) to load\n * @param options - Configuration options\n * @public\n * @example\n * ```ts\n * import { Converters } from 'envapt';\n *\n * class Config {\n * \\@Envapt('APP_PORT', { converter: Converters.Number, fallback: 3000 })\n * static accessor port: number;\n *\n * // the Url fallback is a URL instance, not a string\n * \\@Envapt('APP_URL', { converter: Converters.Url, fallback: new URL('http://localhost:3000') })\n * static accessor url: URL;\n *\n * // prefers CANARY_URL when present, otherwise APP_URL\n * \\@Envapt(['CANARY_URL', 'APP_URL'], { converter: Converters.Url })\n * static accessor canaryUrl: URL | null;\n *\n * // Time takes a number (milliseconds) or a time-string fallback (`<number><unit>`)\n * \\@Envapt('REQUEST_TIMEOUT', { converter: Converters.Time, fallback: '10s' })\n * static accessor requestTimeout: number;\n *\n * \\@Envapt('ALLOWED_ORIGINS', {\n * converter: Converters.array({ of: Converters.String }),\n * fallback: ['https://example.com']\n * })\n * static accessor allowedOrigins: string[];\n *\n * \\@Envapt('DATABASE_URL', { converter: Converters.Url, required: true })\n * static accessor databaseUrl: URL;\n * }\n * ```\n */\nexport function Envapt<TConverter extends BuiltInConverter | ArrayOf>(\n key: EnvKeyInput,\n options:\n | { converter: TConverter; fallback: InferConverterFallbackType<TConverter>; required?: false }\n | { converter: TConverter; required: true }\n): EnvaptAccessorDecorator<InferConverterReturnType<TConverter>>;\nexport function Envapt<TConverter extends BuiltInConverter | ArrayOf>(\n key: EnvKeyInput,\n options: { converter: TConverter; fallback: undefined; required?: false }\n): EnvaptAccessorDecorator<InferConverterReturnType<TConverter> | undefined>;\nexport function Envapt<TConverter extends BuiltInConverter | ArrayOf>(\n key: EnvKeyInput,\n options: { converter: TConverter; required?: false }\n): EnvaptAccessorDecorator<InferConverterReturnType<TConverter> | null>;\n\n/**\n * A primitive constructor (`Number`, `Boolean`) with an optional fallback.\n *\n * @param key - Environment variable name(s) to load\n * @param options - Configuration options\n * @public\n * @example\n * ```ts\n * class Config {\n * \\@Envapt('MAX_CONNECTIONS', { converter: Number, fallback: 100 })\n * static accessor maxConnections: number;\n *\n * \\@Envapt('FEATURE_ENABLED', { converter: Boolean, fallback: false })\n * static accessor featureEnabled: boolean;\n * }\n * ```\n */\nexport function Envapt<TConstructor extends PrimitiveConstructor>(\n key: EnvKeyInput,\n options:\n | { converter: TConstructor; fallback: InferPrimitiveReturnType<TConstructor>; required?: false }\n | { converter: TConstructor; required: true }\n): EnvaptAccessorDecorator<InferPrimitiveReturnType<TConstructor>>;\nexport function Envapt<TConstructor extends PrimitiveConstructor>(\n key: EnvKeyInput,\n options: { converter: TConstructor; fallback: undefined; required?: false }\n): EnvaptAccessorDecorator<InferPrimitiveReturnType<TConstructor> | undefined>;\nexport function Envapt<TConstructor extends PrimitiveConstructor>(\n key: EnvKeyInput,\n options: { converter: TConstructor; required?: false }\n): EnvaptAccessorDecorator<InferPrimitiveReturnType<TConstructor> | null>;\n\n/**\n * Required, no converter (raw string). Throws `MissingEnvValue` on first access when the env\n * value is missing or empty after trimming, independent of the global `Envapter.strict` flag.\n * Pairing `required: true` with `fallback` matches no overload at compile time, and the runtime\n * Validator rejects dynamic objects that bypass the types.\n *\n * @param key - Environment variable name(s) to load\n * @param options - `{ required: true }`\n * @public\n * @example\n * ```ts\n * class Config {\n * \\@Envapt('API_KEY', { required: true })\n * static accessor apiKey: string;\n * }\n * ```\n */\nexport function Envapt(key: EnvKeyInput, options: { required: true }): EnvaptAccessorDecorator<string>;\n\n/**\n * No-fallback form. The property resolves from env or `null`.\n *\n * @param key - Environment variable name(s) to load\n * @public\n * @example\n * ```ts\n * class Config {\n * \\@Envapt('SIMPLE_VALUE')\n * static accessor simple: string | null;\n * }\n * ```\n */\nexport function Envapt(key: EnvKeyInput): EnvaptAccessorDecorator<string | null>;\n\n/**\n * A Standard Schema v1 adapter (zod, valibot, arktype, hand-rolled). Synchronous schemas only,\n * so a Promise-returning `validate` throws `InvalidUserDefinedConfig` at runtime. Pairing\n * `schema` with `converter` matches no overload at compile time, and the runtime Validator\n * rejects dynamic objects that bypass the types.\n * @public\n */\nexport function Envapt<Schema extends StandardSchemaV1>(\n key: EnvKeyInput,\n options:\n | { schema: SchemaConstraint<Schema>; fallback?: InferSchemaOutput<Schema>; required?: false }\n | { schema: SchemaConstraint<Schema>; required: true }\n): EnvaptAccessorDecorator<InferSchemaOutput<Schema>>;\n\n/**\n * Modern (TC39 Stage 3) accessor decorator that loads and converts an environment variable. The\n * decorated property uses the `accessor` keyword and needs no `experimentalDecorators` flag.\n * Instance accessors need the definite-assignment `!`, static accessors do not.\n *\n * @param key - Environment variable name(s) to load\n * @param options - Converter, fallback, `required`, or `schema`. See the overloads.\n * @public\n * @example\n * ```ts\n * import { Envapt, Converters } from 'envapt';\n *\n * class Config {\n * \\@Envapt('APP_PORT', { converter: Converters.Number, fallback: 3000 })\n * static accessor port: number;\n *\n * \\@Envapt('DATABASE_URL', { converter: Converters.Url, required: true })\n * accessor databaseUrl!: URL;\n * }\n * ```\n * @see {@link https://envapt.materwelon.dev/docs/decorators#declaring-decorated-fields}\n */\n/* v8 ignore start -- @preserve oxc (vitest's transform) breaks modern accessor decorators (context.name unset), so the tsc stage3-emit harness covers these, not vitest */\nexport function Envapt<TFallback = unknown>(key: EnvKeyInput, options?: unknown): EnvaptAccessorDecorator<unknown> {\n return createAccessorDecorator(key, parseEnvaptOptions<TFallback>(options)) as EnvaptAccessorDecorator<unknown>;\n}\n/* v8 ignore stop */\n"],"mappings":"uIAkPA,SAAgB,EAA4B,EAAkB,EAAqD,CAC/G,OAAO,EAAwB,EAAK,EAA8B,CAAO,CAAC,CAC9E"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SugarDecorators.mjs","names":[],"sources":["../../../../src/decorators/modern/SugarDecorators.ts"],"sourcesContent":["import { createAccessorDecorator } from './createAccessorDecorator';\nimport { Converters } from '../../converters';\n\nimport type { ConverterToken } from '../../converters';\nimport type { EnvaptAccessorDecorator, EnvKeyInput, TimeFallback } from '../../types';\n\n/* v8 ignore start -- @preserve oxc (vitest's transform) breaks modern accessor decorators (context.name unset), so the tsc stage3-emit harness covers these, not vitest */\nfunction sugar<TFallback>(\n converter: ConverterToken,\n key: EnvKeyInput,\n fallback: TFallback | undefined\n): EnvaptAccessorDecorator<TFallback> {\n // the runtime installer is a plain accessor decorator, so the cast only adds a\n // compile-time field-type constraint with no runtime counterpart\n return createAccessorDecorator<TFallback>(key, {\n converter,\n fallback,\n hasFallback: fallback !== undefined,\n required: false,\n schema: undefined\n }) as EnvaptAccessorDecorator<TFallback>;\n}\n\n/**\n * Shorthand for `@Envapt(key, { converter: Converters.Boolean, fallback })`.\n * @public\n * @see {@link https://envapt.materwelon.dev/docs/decorators#shorthand-decorators}\n */\nexport function EnvBool(key: EnvKeyInput, fallback: boolean): EnvaptAccessorDecorator<boolean>;\nexport function EnvBool(key: EnvKeyInput): EnvaptAccessorDecorator<boolean | null>;\nexport function EnvBool(key: EnvKeyInput, fallback?: boolean): EnvaptAccessorDecorator<boolean | null> {\n return sugar(Converters.Boolean, key, fallback);\n}\n\n/**\n * Shorthand for `@Envapt(key, { converter: Converters.Number, fallback })`.\n * @public\n * @see {@link https://envapt.materwelon.dev/docs/decorators#shorthand-decorators}\n */\nexport function EnvNum(key: EnvKeyInput, fallback: number): EnvaptAccessorDecorator<number>;\nexport function EnvNum(key: EnvKeyInput): EnvaptAccessorDecorator<number | null>;\nexport function EnvNum(key: EnvKeyInput, fallback?: number): EnvaptAccessorDecorator<number | null> {\n return sugar(Converters.Number, key, fallback);\n}\n\n/**\n * Shorthand for `@Envapt(key, { converter: Converters.String, fallback })`.\n * @public\n * @see {@link https://envapt.materwelon.dev/docs/decorators#shorthand-decorators}\n */\nexport function EnvStr(key: EnvKeyInput, fallback: string): EnvaptAccessorDecorator<string>;\nexport function EnvStr(key: EnvKeyInput): EnvaptAccessorDecorator<string | null>;\nexport function EnvStr(key: EnvKeyInput, fallback?: string): EnvaptAccessorDecorator<string | null> {\n return sugar(Converters.String, key, fallback);\n}\n\n/**\n * Shorthand for `@Envapt(key, { converter: Converters.Time, fallback })`. The fallback is a\n * millisecond number or a time string (`'15m'`), and the resolved value is always milliseconds.\n * @public\n * @see {@link https://envapt.materwelon.dev/docs/decorators#shorthand-decorators}\n */\nexport function EnvTime(key: EnvKeyInput, fallback: TimeFallback): EnvaptAccessorDecorator<number>;\nexport function EnvTime(key: EnvKeyInput): EnvaptAccessorDecorator<number | null>;\nexport function EnvTime(key: EnvKeyInput, fallback?: TimeFallback): EnvaptAccessorDecorator<number | null> {\n return sugar(Converters.Time, key, fallback);\n}\n\n/**\n * Shorthand for `@Envapt(key, { converter: Converters.Url, fallback })`. The fallback is a `URL`\n * instance, not a URL string.\n * @public\n * @see {@link https://envapt.materwelon.dev/docs/decorators#shorthand-decorators}\n */\nexport function EnvUrl(key: EnvKeyInput, fallback: URL): EnvaptAccessorDecorator<URL>;\nexport function EnvUrl(key: EnvKeyInput): EnvaptAccessorDecorator<URL | null>;\nexport function EnvUrl(key: EnvKeyInput, fallback?: URL): EnvaptAccessorDecorator<URL | null> {\n return sugar(Converters.Url, key, fallback);\n}\n/* v8 ignore stop */\n"],"mappings":"qIAOA,SAAS,EACL,EACA,EACA,EACkC,CAGlC,OAAO,EAAmC,EAAK,CAC3C,YACA,WACA,YAAa,IAAa,IAAA,GAC1B,SAAU,GACV,OAAQ,IAAA,EACZ,CAAC,CACL,CASA,SAAgB,EAAQ,EAAkB,EAA6D,CACnG,OAAO,EAAM,EAAW,QAAS,EAAK,CAAQ,CAClD,CASA,SAAgB,EAAO,EAAkB,EAA2D,CAChG,OAAO,EAAM,EAAW,OAAQ,EAAK,CAAQ,CACjD,CASA,SAAgB,EAAO,EAAkB,EAA2D,CAChG,OAAO,EAAM,EAAW,OAAQ,EAAK,CAAQ,CACjD,CAUA,SAAgB,EAAQ,EAAkB,EAAiE,CACvG,OAAO,EAAM,EAAW,KAAM,EAAK,CAAQ,CAC/C,CAUA,SAAgB,EAAO,EAAkB,EAAqD,CAC1F,OAAO,EAAM,EAAW,IAAK,EAAK,CAAQ,CAC9C"}
@@ -0,0 +1,2 @@
1
+ import{EnvaptError as e}from"../infra/Error.mjs";import{cache as t}from"../core/state.mjs";import{isMissing as n}from"../core/missing.mjs";import{ValueConverter as r}from"../converters/ValueConverter.mjs";import{Envapter as i}from"../engine/Envapter.mjs";function a(e){return Array.isArray(e)?`[${e.join(`, `)}]`:String(e)}const o=new WeakMap;let s=0;function c(e,t,n){let r=o.get(e);return r===void 0&&(r=s++,o.set(e,r)),`${r}.${t?`static`:`instance`}.${n}`}function l(o,s,c){let{fallback:l,converter:u,hasFallback:d,required:f,schema:p}=s;if(t.has(c))return t.get(c);let m=new i;if(f&&p===void 0&&n(m.getRaw(o)))throw new e(305,`Required environment variable "${a(o)}" is missing or empty.`);let h=new r(m),g=p===void 0?h.convertValue(o,l,u,d):h.convertWithSchema(o,p,l,d);return t.set(c,g),g}export{c as decoratorCacheKey,l 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 { isMissing } from '../core/missing';\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 (isMissing(rawValue)) {\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":"+PAiBA,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,IAEnB,EADa,EAAS,OAAO,CACZ,CAAC,EAClB,MAAM,IAAI,EAAA,IAEN,kCAAkC,EAAkB,CAAG,EAAE,uBAC7D,EAIR,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{EnvaptError as e}from"../infra/Error.mjs";import"../core/Environment.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 * @see {@link https://envapt.materwelon.dev/docs/templates#the-resolve-tagged-template}\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 after template\n * resolution. Throws `MissingEnvValue` listing every missing key. A whitespace-only value\n * counts as missing only under strict mode.\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,CAiB1C,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,CAeA,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{isMissing as n}from"../core/missing.mjs";import{debugWarn as r}from"../infra/Debug.mjs";var i=class{envService;TEMPLATE_REGEX=/\${\w*}/g;constructor(e){this.envService=e}resolveTemplate(i,a,o=new Set){o.add(i);let s=t.strict,c=a.replace(this.TEMPLATE_REGEX,t=>{let a=t.slice(2,-1);if(o.has(a))return t;let c=this.envService.getRaw(a);if(c===void 0||n(c)){if(s)throw new e(305,`Cannot resolve template variable "\${${a}}": value is missing or empty.`);return r(`unresolved template \${${a}} preserved as literal`),t}let l=this.resolveTemplate(a,c,new Set(o));return l.includes(`\${${i}}`)||l===c&&/\$\{[^}]*\}/.test(l)?t:l});return o.delete(i),c}};export{i as TemplateResolver};
2
+ //# sourceMappingURL=TemplateResolver.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TemplateResolver.mjs","names":[],"sources":["../../../src/engine/TemplateResolver.ts"],"sourcesContent":["import { isMissing } from '../core/missing';\nimport { 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 if (raw === undefined || isMissing(raw)) {\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":"0LAYA,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,EAC3C,GAAI,IAAQ,IAAA,IAAa,EAAU,CAAG,EAAG,CACrC,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{EnvaptError as e}from"../infra/Error.mjs";import{isArrayOf as t}from"../converters/Converters.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(e){return t(e)}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(t){if(typeof t!=`function`)throw new e(203,`Custom converter must be a function, got ${typeof t}.`)}static arrayConverter(n){if(!t(n))throw new e(201,`Expected an ArrayOf<...> token produced by Converters.array(...)`);if(typeof n.delimiter!=`string`||n.delimiter.length===0)throw new e(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 e(201,`ArrayOf<...> element ("of") must be a built-in scalar token or a function, got ${typeof i}`)}static builtInConverter(t){if(typeof t!=`string`)throw new e(204,`Expected string, got ${typeof t}`);if(!r.includes(t))throw new e(202,`"${t}" is not a valid converter type. Valid types are: ${r.join(`,`)}`)}static validateBuiltInConverterFallback(t,r){let i=n[t];if(!i(r))throw new e(104,`Fallback type does not match converter "${t}". Expected ${t} compatible type.`)}static validateArrayFallbackElementTypes(t){if(t.length===0)return;let n=typeof t[0];if(t.some((e,t)=>t===0?!1:typeof e!==n))throw new e(103,`All elements in array fallback must have the same type. Found mixed types.`)}static validateArrayConverterElementTypeMatch(t,r){if(r.length===0||typeof t==`function`)return;let i=t;if(i===`time`){let t=r.every(e=>typeof e==`number`),n=r.every(e=>typeof e==`string`);if(!t&&!n)throw new e(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 e(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(t,n){try{if(t===String)return String(n);if(t===Number)return Number(n);if(t===Boolean)return!!n;if(t===BigInt)return BigInt(n);if(t===Symbol)return Symbol.for(String(n))}catch(n){throw new e(205,`Failed to coerce fallback value using ${t.name}: ${n.message}`)}throw new e(205,`Unknown primitive converter: ${t.name}`)}static validateSyncProcessEnv(t){if(typeof t!=`boolean`)throw new e(302,`Envapter.syncProcessEnv must be a boolean, got ${typeof t}.`)}static validateFileApiMode(t){if(t!==`warn`&&t!==`throw`)throw new e(302,`Envapter.fileApiMode must be 'warn' or 'throw', got ${typeof t==`string`?`'${t}'`:typeof t}.`)}static validateEnvFileOptions(t){let n=new Set([`encoding`,`override`]),r=Object.keys(t).filter(e=>!n.has(e));if(r.length>0)throw new e(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(t,n){let r=t.filter(e=>!n(e));if(r.length>0)throw new e(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{EnvaptError as e,EnvaptErrorCodes as t}from"./infra/Error.mjs";import{Environment as n}from"./core/Environment.mjs";import{Converters as r}from"./converters/Converters.mjs";import{PortableSource as i}from"./sources/PortableSource.mjs";import{merge as a}from"./sources/merge.mjs";import{Envapt as o}from"./decorators/modern/Envapt.mjs";import{EnvBool as s,EnvNum as c,EnvStr as l,EnvTime as u,EnvUrl as d}from"./decorators/modern/SugarDecorators.mjs";import{PortableEnvapter as f}from"./engine/PortableEnvapter.mjs";export{r as Converters,s as EnvBool,c as EnvNum,l as EnvStr,u as EnvTime,d as EnvUrl,o as Envapt,e as EnvaptError,t as EnvaptErrorCodes,f as Envapter,n as Environment,i as PortableSource,a as merge};
@@ -0,0 +1,2 @@
1
+ import{EnvaptError as e}from"./Error.mjs";import{readRuntimeVar as t,writeRuntimeLine as n}from"./runtime.mjs";const r=new Set([`silent`,`warn`,`verbose`]);let i=`silent`,a=!1;function o(e){return e!==void 0&&r.has(e)}function s(){if(!a){let e=t(`ENVAPT_DEBUG`);i=o(e)?e:`silent`,a=!0}return i}function c(t){if(!o(t))throw new e(302,`Invalid debug level "${String(t)}". Expected 'silent' | 'warn' | 'verbose'.`);i=t,a=!0}function l(){return s()}function u(e){let t=s();(t===`warn`||t===`verbose`)&&n(`[envapt] ${e}`)}function d(e){s()===`verbose`&&n(`[envapt] ${e}`)}export{d as debugVerbose,u as debugWarn,l as getDebugLevel,c as setDebugLevel};
2
+ //# sourceMappingURL=Debug.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Debug.mjs","names":[],"sources":["../../../src/infra/Debug.ts"],"sourcesContent":["import { EnvaptError, EnvaptErrorCodes } from './Error';\nimport { readRuntimeVar, writeRuntimeLine } from './runtime';\n\n/**\n * Debug log levels for {@link Envapter.debug}. `silent` (default) emits nothing.\n * `warn` covers signals that might indicate misconfiguration, failed file reads,\n * unresolved templates (when not strict), and any read of a missing or empty variable\n * (whether it returns a fallback or `undefined`). `verbose` adds every loaded file,\n * per-file key count, per-key load lines, and effective-paths / cache-rebuild notices.\n * @public\n * @see {@link https://envapt.materwelon.dev/docs/configuration#debug-logging}\n */\nexport type DebugLevel = 'silent' | 'warn' | 'verbose';\n\nconst VALID_LEVELS: ReadonlySet<string> = new Set<DebugLevel>(['silent', 'warn', 'verbose']);\n\nlet currentLevel: DebugLevel = 'silent';\nlet initialized = false;\n\nfunction isDebugLevel(value: string | undefined): value is DebugLevel {\n return value !== undefined && VALID_LEVELS.has(value);\n}\n\n// Reads `ENVAPT_DEBUG` lazily on first access. Setter wins after that.\nfunction resolveLevel(): DebugLevel {\n if (!initialized) {\n const fromEnv = readRuntimeVar('ENVAPT_DEBUG');\n currentLevel = isDebugLevel(fromEnv) ? fromEnv : 'silent';\n initialized = true;\n }\n return currentLevel;\n}\n\n/** @internal */\nexport function setDebugLevel(level: DebugLevel): void {\n if (!isDebugLevel(level)) {\n throw new EnvaptError(\n EnvaptErrorCodes.InvalidUserDefinedConfig,\n `Invalid debug level \"${String(level)}\". Expected 'silent' | 'warn' | 'verbose'.`\n );\n }\n currentLevel = level;\n initialized = true;\n}\n\n/** @internal */\nexport function getDebugLevel(): DebugLevel {\n return resolveLevel();\n}\n\n/** @internal */\nexport function resetDebugForTesting(): void {\n currentLevel = 'silent';\n initialized = false;\n}\n\n/** @internal */\nexport function debugWarn(message: string): void {\n const level = resolveLevel();\n if (level === 'warn' || level === 'verbose') {\n writeRuntimeLine(`[envapt] ${message}`);\n }\n}\n\n/** @internal */\nexport function debugVerbose(message: string): void {\n if (resolveLevel() === 'verbose') {\n writeRuntimeLine(`[envapt] ${message}`);\n }\n}\n"],"mappings":"+GAcA,MAAM,EAAoC,IAAI,IAAgB,CAAC,SAAU,OAAQ,SAAS,CAAC,EAE3F,IAAI,EAA2B,SAC3B,EAAc,GAElB,SAAS,EAAa,EAAgD,CAClE,OAAO,IAAU,IAAA,IAAa,EAAa,IAAI,CAAK,CACxD,CAGA,SAAS,GAA2B,CAChC,GAAI,CAAC,EAAa,CACd,IAAM,EAAU,EAAe,cAAc,EAC7C,EAAe,EAAa,CAAO,EAAI,EAAU,SACjD,EAAc,EAClB,CACA,OAAO,CACX,CAGA,SAAgB,EAAc,EAAyB,CACnD,GAAI,CAAC,EAAa,CAAK,EACnB,MAAM,IAAI,EAAA,IAEN,wBAAwB,OAAO,CAAK,EAAE,2CAC1C,EAEJ,EAAe,EACf,EAAc,EAClB,CAGA,SAAgB,GAA4B,CACxC,OAAO,EAAa,CACxB,CASA,SAAgB,EAAU,EAAuB,CAC7C,IAAM,EAAQ,EAAa,GACvB,IAAU,QAAU,IAAU,YAC9B,EAAiB,YAAY,GAAS,CAE9C,CAGA,SAAgB,EAAa,EAAuB,CAC5C,EAAa,IAAM,WACnB,EAAiB,YAAY,GAAS,CAE9C"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Dotenv.mjs","names":[],"sources":["../../../src/infra/Dotenv.ts"],"sourcesContent":["import { debugVerbose, debugWarn } from './Debug';\n\n/**\n * Public options for the internal `.env` loader. Mirrors the subset of dotenv's\n * `config()` options that envapt actually supports (no DOTENV_KEY, no quiet).\n * For debug output, use `Envapter.debug` (or the `ENVAPT_DEBUG` env var).\n *\n * @public\n * @see {@link https://envapt.materwelon.dev/docs/configuration#which-files-load}\n */\nexport interface EnvFileOptions {\n /** Encoding for reading .env files. Defaults to 'utf8'. */\n encoding?: string;\n /** When true, later files override earlier ones (and existing processEnv values). Default false (first-wins). */\n override?: boolean;\n}\n\n/**\n * Internal call signature used by `EnvapterBase`. The `path` and `processEnv`\n * fields are managed by envapt and never user-supplied.\n * @internal\n */\nexport interface LoadDotenvInput extends EnvFileOptions {\n path: string | string[];\n processEnv: Record<string, string>;\n // Injected so the loader stays free of `node:fs`. Returns `undefined` when the file is absent.\n readFile(path: string, encoding: string): string | undefined;\n}\n\n// Matches: optional `export`, KEY name, optional whitespace, `=`, optional whitespace, value tail.\n// Multi-line quoted values are handled by re-buffering subsequent lines below.\n// Bounded by anchors with linear-time quantifiers; no catastrophic backtracking risk -- justified\n// eslint-disable-next-line security/detect-unsafe-regex\nconst KEY_LINE_RE = /^\\s*(?:export\\s+)?([A-Za-z_][A-Za-z0-9_]*)\\s*=(.*)$/u;\n\n/**\n * Parse a `.env` text blob into a `Map<string, string>`.\n *\n * Supported syntax:\n * - `KEY=value` and `export KEY=value`\n * - blank lines and full-line `# comments`\n * - single-quoted `'literal'` values (no escape interpretation)\n * - double-quoted `\"value\"` values (interprets `\\n`, `\\r`, `\\t`, `\\\\`, `\\\"`)\n * - backtick-quoted values (literal, like single quotes)\n * - quoted values may span multiple lines\n * - inline `# comment` after an unquoted value (requires whitespace before `#`)\n * - empty values resolve to `\"\"`\n *\n * Mirrors dotenv's quirk where unescaped inner quotes inside a quoted value\n * are tolerated by greedy-matching to the rightmost matching quote on the\n * (possibly multi-line) value buffer. This is what lets a value like\n * `JSON=\"{\"name\":\"x\"}\"` round-trip without escaping.\n *\n * Does NOT perform `${VAR}` expansion — envapt's `Parser` handles that downstream.\n * @internal\n */\nexport function parseDotenv(src: string): Map<string, string> {\n const out = new Map<string, string>();\n const lines = src.split(/\\r?\\n/u);\n\n for (let i = 0; i < lines.length; i++) {\n const consumed = parseEntry(lines, i);\n i = consumed.endLine;\n if (consumed.entry) out.set(consumed.entry.key, consumed.entry.value);\n }\n\n return out;\n}\n\ninterface ParsedEntry {\n key: string;\n value: string;\n}\n\nfunction parseEntry(lines: string[], start: number): { entry: ParsedEntry | undefined; endLine: number } {\n /* v8 ignore next -- @preserve caller bounds-checks start so this never falls back */\n const line = lines[start] ?? '';\n const trimmedLine = line.trim();\n if (trimmedLine === '' || trimmedLine.startsWith('#')) return { entry: undefined, endLine: start };\n\n const match = line.match(KEY_LINE_RE);\n if (!match) return { entry: undefined, endLine: start };\n\n const key = match[1] as string;\n // Drop only leading whitespace before the value; trailing whitespace and inline comments\n // are dealt with below depending on whether the value is quoted.\n /* v8 ignore next -- @preserve regex group 2 always matches via `(.*)`, fallback is defensive */\n const rest = (match[2] ?? '').replace(/^\\s+/u, '');\n const firstChar = rest[0];\n\n if (firstChar === '\"' || firstChar === \"'\" || firstChar === '`') {\n const consumed = consumeQuotedValue(rest, lines, start, firstChar);\n return { entry: { key, value: consumed.value }, endLine: consumed.endLine };\n }\n\n return { entry: { key, value: stripInlineComment(rest) }, endLine: start };\n}\n\nfunction consumeQuotedValue(\n firstLineRest: string,\n lines: string[],\n startLine: number,\n quote: string\n): { value: string; endLine: number } {\n let buffer = firstLineRest;\n let cursor = startLine;\n let closeIdx = findLastUnescapedQuote(buffer, quote);\n\n while (closeIdx < 0 && cursor < lines.length - 1) {\n cursor++;\n /* v8 ignore next -- @preserve cursor is bounded by the while condition above */\n buffer += `\\n${lines[cursor] ?? ''}`;\n closeIdx = findLastUnescapedQuote(buffer, quote);\n }\n\n const inner = closeIdx > 0 ? buffer.slice(1, closeIdx) : buffer.slice(1);\n return { value: quote === '\"' ? unescapeDouble(inner) : inner, endLine: cursor };\n}\n\nfunction stripInlineComment(value: string): string {\n const hashIdx = findInlineCommentStart(value);\n const stripped = hashIdx === -1 ? value : value.slice(0, hashIdx);\n return stripped.trimEnd();\n}\n\nfunction findInlineCommentStart(value: string): number {\n for (let i = 0; i < value.length; i++) {\n if (value[i] === '#' && (i === 0 || /\\s/u.test(value[i - 1] as string))) return i;\n }\n return -1;\n}\n\n/**\n * Find the rightmost matching closing quote in `buffer` (skipping index 0 which is the\n * opening quote). For `\"`, a quote preceded by an odd number of backslashes is escaped\n * and ignored. Single and backtick quotes do not unescape.\n */\nfunction findLastUnescapedQuote(buffer: string, quote: string): number {\n for (let i = buffer.length - 1; i > 0; i--) {\n if (buffer[i] !== quote) continue;\n if (quote === '\"') {\n let backslashes = 0;\n let k = i - 1;\n while (k >= 0 && buffer[k] === '\\\\') {\n backslashes++;\n k--;\n }\n if (backslashes % 2 === 1) continue; // escaped\n }\n return i;\n }\n return -1;\n}\n\nfunction unescapeDouble(raw: string): string {\n let out = '';\n for (let i = 0; i < raw.length; i++) {\n const ch = raw[i];\n if (ch !== '\\\\' || i === raw.length - 1) {\n out += ch;\n continue;\n }\n const next = raw[i + 1];\n i++;\n switch (next) {\n case 'n':\n out += '\\n';\n break;\n case 'r':\n out += '\\r';\n break;\n case 't':\n out += '\\t';\n break;\n case '\\\\':\n out += '\\\\';\n break;\n case '\"':\n out += '\"';\n break;\n default:\n /* v8 ignore next -- @preserve `next` is always defined when this branch is reached (guarded above) */\n out += `\\\\${next ?? ''}`;\n }\n }\n return out;\n}\n\n/**\n * Load one or more `.env` files into a target `processEnv` map. Mirrors the\n * subset of dotenv's `config()` semantics that envapt depends on: first-wins\n * across multiple paths by default, optional `override: true`, optional\n * non-UTF8 encoding, missing files are skipped silently.\n *\n * Returns the set of keys actually written into `input.processEnv`. Skipped\n * collisions (under default `override: false`) are NOT included.\n * @internal\n */\nexport function loadDotenv(input: LoadDotenvInput): Set<string> {\n const paths = Array.isArray(input.path) ? input.path : [input.path];\n const encoding = input.encoding ?? 'utf8';\n const override = input.override ?? false;\n const written = new Set<string>();\n\n for (const filePath of paths) {\n const src = input.readFile(filePath, encoding);\n if (src === undefined) {\n debugWarn(`could not read ${filePath}`);\n continue;\n }\n\n const parsed = parseDotenv(src);\n debugVerbose(`loaded ${filePath}: ${parsed.size} ${parsed.size === 1 ? 'key' : 'keys'}`);\n for (const [key, value] of parsed) {\n const exists = Object.prototype.hasOwnProperty.call(input.processEnv, key);\n if (!exists || override) {\n input.processEnv[key] = value;\n written.add(key);\n debugVerbose(`${filePath} -> ${key}`);\n }\n }\n }\n\n return written;\n}\n"],"mappings":"0DAiCA,MAAM,EAAc,uDAuBpB,SAAgB,EAAY,EAAkC,CAC1D,IAAM,EAAM,IAAI,IACV,EAAQ,EAAI,MAAM,QAAQ,EAEhC,IAAK,IAAI,EAAI,EAAG,EAAI,EAAM,OAAQ,IAAK,CACnC,IAAM,EAAW,EAAW,EAAO,CAAC,EACpC,EAAI,EAAS,QACT,EAAS,OAAO,EAAI,IAAI,EAAS,MAAM,IAAK,EAAS,MAAM,KAAK,CACxE,CAEA,OAAO,CACX,CAOA,SAAS,EAAW,EAAiB,EAAoE,CAErG,IAAM,EAAO,EAAM,IAAU,GACvB,EAAc,EAAK,KAAK,EAC9B,GAAI,IAAgB,IAAM,EAAY,WAAW,GAAG,EAAG,MAAO,CAAE,MAAO,IAAA,GAAW,QAAS,CAAM,EAEjG,IAAM,EAAQ,EAAK,MAAM,CAAW,EACpC,GAAI,CAAC,EAAO,MAAO,CAAE,MAAO,IAAA,GAAW,QAAS,CAAM,EAEtD,IAAM,EAAM,EAAM,GAIZ,GAAQ,EAAM,IAAM,GAAA,CAAI,QAAQ,QAAS,EAAE,EAC3C,EAAY,EAAK,GAEvB,GAAI,IAAc,KAAO,IAAc,KAAO,IAAc,IAAK,CAC7D,IAAM,EAAW,EAAmB,EAAM,EAAO,EAAO,CAAS,EACjE,MAAO,CAAE,MAAO,CAAE,MAAK,MAAO,EAAS,KAAM,EAAG,QAAS,EAAS,OAAQ,CAC9E,CAEA,MAAO,CAAE,MAAO,CAAE,MAAK,MAAO,EAAmB,CAAI,CAAE,EAAG,QAAS,CAAM,CAC7E,CAEA,SAAS,EACL,EACA,EACA,EACA,EACkC,CAClC,IAAI,EAAS,EACT,EAAS,EACT,EAAW,EAAuB,EAAQ,CAAK,EAEnD,KAAO,EAAW,GAAK,EAAS,EAAM,OAAS,GAC3C,IAEA,GAAU,KAAK,EAAM,IAAW,KAChC,EAAW,EAAuB,EAAQ,CAAK,EAGnD,IAAM,EAAQ,EAAW,EAAI,EAAO,MAAM,EAAG,CAAQ,EAAI,EAAO,MAAM,CAAC,EACvE,MAAO,CAAE,MAAO,IAAU,IAAM,EAAe,CAAK,EAAI,EAAO,QAAS,CAAO,CACnF,CAEA,SAAS,EAAmB,EAAuB,CAC/C,IAAM,EAAU,EAAuB,CAAK,EAE5C,OADiB,IAAY,GAAK,EAAQ,EAAM,MAAM,EAAG,CAAO,EAAA,CAChD,QAAQ,CAC5B,CAEA,SAAS,EAAuB,EAAuB,CACnD,IAAK,IAAI,EAAI,EAAG,EAAI,EAAM,OAAQ,IAC9B,GAAI,EAAM,KAAO,MAAQ,IAAM,GAAK,MAAM,KAAK,EAAM,EAAI,EAAY,GAAI,OAAO,EAEpF,MAAO,EACX,CAOA,SAAS,EAAuB,EAAgB,EAAuB,CACnE,IAAK,IAAI,EAAI,EAAO,OAAS,EAAG,EAAI,EAAG,IAC/B,KAAO,KAAO,EAClB,IAAI,IAAU,IAAK,CACf,IAAI,EAAc,EACd,EAAI,EAAI,EACZ,KAAO,GAAK,GAAK,EAAO,KAAO,MAC3B,IACA,IAEJ,GAAI,EAAc,GAAM,EAAG,QAC/B,CACA,OAAO,CADP,CAGJ,MAAO,EACX,CAEA,SAAS,EAAe,EAAqB,CACzC,IAAI,EAAM,GACV,IAAK,IAAI,EAAI,EAAG,EAAI,EAAI,OAAQ,IAAK,CACjC,IAAM,EAAK,EAAI,GACf,GAAI,IAAO,MAAQ,IAAM,EAAI,OAAS,EAAG,CACrC,GAAO,EACP,QACJ,CACA,IAAM,EAAO,EAAI,EAAI,GAErB,OADA,IACQ,EAAR,CACI,IAAK,IACD,GAAO;EACP,MACJ,IAAK,IACD,GAAO,KACP,MACJ,IAAK,IACD,GAAO,IACP,MACJ,IAAK,KACD,GAAO,KACP,MACJ,IAAK,IACD,GAAO,IACP,MACJ,QAEI,GAAO,KAAK,GAAQ,IAC5B,CACJ,CACA,OAAO,CACX,CAYA,SAAgB,EAAW,EAAqC,CAC5D,IAAM,EAAQ,MAAM,QAAQ,EAAM,IAAI,EAAI,EAAM,KAAO,CAAC,EAAM,IAAI,EAC5D,EAAW,EAAM,UAAY,OAC7B,EAAW,EAAM,UAAY,GAC7B,EAAU,IAAI,IAEpB,IAAK,IAAM,KAAY,EAAO,CAC1B,IAAM,EAAM,EAAM,SAAS,EAAU,CAAQ,EAC7C,GAAI,IAAQ,IAAA,GAAW,CACnB,EAAU,kBAAkB,GAAU,EACtC,QACJ,CAEA,IAAM,EAAS,EAAY,CAAG,EAC9B,EAAa,UAAU,EAAS,IAAI,EAAO,KAAK,GAAG,EAAO,OAAS,EAAI,MAAQ,QAAQ,EACvF,IAAK,GAAM,CAAC,EAAK,KAAU,GAEnB,CADW,OAAO,UAAU,eAAe,KAAK,EAAM,WAAY,CAC5D,GAAK,KACX,EAAM,WAAW,GAAO,EACxB,EAAQ,IAAI,CAAG,EACf,EAAa,GAAG,EAAS,MAAM,GAAK,EAGhD,CAEA,OAAO,CACX"}
@@ -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
@@ -0,0 +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 * @see {@link https://envapt.materwelon.dev/docs/errors#codes}\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 * @see {@link https://envapt.materwelon.dev/docs/errors#the-error-shape}\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":"AAQA,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,EAgBA,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,2 @@
1
+ let e=e=>{console.error(e)},t=()=>({}),n;function r(t){e(t)}function i(e){let r=t()[e];if(r!==void 0)return r;try{return n?.(e)}catch{return}}function a(e){t=()=>e.readVars();let r=e.readVar;n=typeof r==`function`?r.bind(e):void 0}export{a as bindRuntimeFromSource,i as readRuntimeVar,r as writeRuntimeLine};
2
+ //# sourceMappingURL=runtime.mjs.map