envapt 6.0.2 → 7.0.0-next.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (354) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/README.md +5 -8
  3. package/dist/browser/converters/BuiltInConverters.mjs +1 -1
  4. package/dist/browser/converters/BuiltInConverters.mjs.map +1 -1
  5. package/dist/browser/converters/ValueConverter.d.mts +1 -1
  6. package/dist/browser/converters/ValueConverter.mjs +1 -1
  7. package/dist/browser/converters/ValueConverter.mjs.map +1 -1
  8. package/dist/browser/core/AdvancedMethods.d.mts +1 -1
  9. package/dist/browser/core/AdvancedMethods.mjs +1 -1
  10. package/dist/browser/core/AdvancedMethods.mjs.map +1 -1
  11. package/dist/browser/core/EnvapterBase.d.mts +2 -2
  12. package/dist/browser/core/EnvapterBase.mjs +1 -1
  13. package/dist/browser/core/EnvapterBase.mjs.map +1 -1
  14. package/dist/browser/core/EnvironmentMethods.mjs +1 -1
  15. package/dist/browser/core/EnvironmentMethods.mjs.map +1 -1
  16. package/dist/browser/core/PrimitiveMethods.d.mts +1 -1
  17. package/dist/browser/core/PrimitiveMethods.mjs +1 -1
  18. package/dist/browser/core/PrimitiveMethods.mjs.map +1 -1
  19. package/dist/browser/decorators/{Envapt.d.mts → legacy/Envapt.d.mts} +59 -49
  20. package/dist/browser/decorators/legacy/Envapt.mjs +2 -0
  21. package/dist/browser/decorators/legacy/Envapt.mjs.map +1 -0
  22. package/dist/browser/decorators/legacy/SugarDecorators.d.mts +40 -0
  23. package/dist/browser/decorators/legacy/SugarDecorators.mjs +2 -0
  24. package/dist/browser/decorators/legacy/SugarDecorators.mjs.map +1 -0
  25. package/dist/browser/decorators/legacy/createPropertyDecorator.mjs +2 -0
  26. package/dist/browser/decorators/legacy/createPropertyDecorator.mjs.map +1 -0
  27. package/dist/browser/decorators/modern/Envapt.d.mts +218 -0
  28. package/dist/browser/decorators/modern/Envapt.mjs +2 -0
  29. package/dist/browser/decorators/modern/Envapt.mjs.map +1 -0
  30. package/dist/browser/decorators/modern/SugarDecorators.d.mts +40 -0
  31. package/dist/browser/decorators/modern/SugarDecorators.mjs +2 -0
  32. package/dist/browser/decorators/modern/SugarDecorators.mjs.map +1 -0
  33. package/dist/browser/decorators/modern/createAccessorDecorator.mjs +2 -0
  34. package/dist/browser/decorators/modern/createAccessorDecorator.mjs.map +1 -0
  35. package/dist/browser/decorators/parseEnvaptOptions.mjs +2 -0
  36. package/dist/browser/decorators/parseEnvaptOptions.mjs.map +1 -0
  37. package/dist/browser/decorators/resolveDecoratorValue.mjs +2 -0
  38. package/dist/browser/decorators/resolveDecoratorValue.mjs.map +1 -0
  39. package/dist/browser/{Envapter.d.mts → engine/Envapter.d.mts} +3 -3
  40. package/dist/browser/engine/Envapter.mjs +2 -0
  41. package/dist/browser/engine/Envapter.mjs.map +1 -0
  42. package/dist/browser/{TemplateResolver.d.mts → engine/TemplateResolver.d.mts} +2 -2
  43. package/dist/browser/engine/TemplateResolver.mjs +2 -0
  44. package/dist/browser/engine/TemplateResolver.mjs.map +1 -0
  45. package/dist/browser/engine/Validators.mjs +2 -0
  46. package/dist/browser/engine/Validators.mjs.map +1 -0
  47. package/dist/browser/engine/installFileApiStubs.mjs +2 -0
  48. package/dist/browser/engine/installFileApiStubs.mjs.map +1 -0
  49. package/dist/browser/index.d.mts +9 -8
  50. package/dist/browser/index.mjs +1 -1
  51. package/dist/browser/index.mjs.map +1 -1
  52. package/dist/browser/{Debug.d.mts → infra/Debug.d.mts} +1 -1
  53. package/dist/browser/infra/Debug.mjs.map +1 -0
  54. package/dist/{workerd → browser/infra}/Dotenv.d.mts +1 -1
  55. package/dist/browser/infra/Dotenv.mjs.map +1 -0
  56. package/dist/browser/{Error.d.mts → infra/Error.d.mts} +1 -1
  57. package/dist/browser/infra/Error.mjs.map +1 -0
  58. package/dist/browser/{StandardSchema.d.mts → infra/StandardSchema.d.mts} +1 -1
  59. package/dist/browser/infra/runtime.mjs.map +1 -0
  60. package/dist/browser/legacy.d.mts +4 -0
  61. package/dist/browser/legacy.mjs +1 -0
  62. package/dist/browser/sources/UnboundEnvSource.mjs +1 -1
  63. package/dist/browser/sources/UnboundEnvSource.mjs.map +1 -1
  64. package/dist/browser/types/Decorator.d.mts +26 -0
  65. package/dist/browser/types/Schema.d.mts +1 -1
  66. package/dist/node/config.cjs +1 -1
  67. package/dist/node/config.cjs.map +1 -1
  68. package/dist/node/config.mjs +1 -1
  69. package/dist/node/config.mjs.map +1 -1
  70. package/dist/node/converters/BuiltInConverters.cjs +1 -1
  71. package/dist/node/converters/BuiltInConverters.cjs.map +1 -1
  72. package/dist/node/converters/BuiltInConverters.mjs +1 -1
  73. package/dist/node/converters/BuiltInConverters.mjs.map +1 -1
  74. package/dist/node/converters/ValueConverter.cjs +1 -1
  75. package/dist/node/converters/ValueConverter.cjs.map +1 -1
  76. package/dist/node/converters/ValueConverter.d.cts +1 -1
  77. package/dist/node/converters/ValueConverter.d.mts +1 -1
  78. package/dist/node/converters/ValueConverter.mjs +1 -1
  79. package/dist/node/converters/ValueConverter.mjs.map +1 -1
  80. package/dist/node/core/AdvancedMethods.cjs +1 -1
  81. package/dist/node/core/AdvancedMethods.cjs.map +1 -1
  82. package/dist/node/core/AdvancedMethods.d.cts +1 -1
  83. package/dist/node/core/AdvancedMethods.d.mts +1 -1
  84. package/dist/node/core/AdvancedMethods.mjs +1 -1
  85. package/dist/node/core/AdvancedMethods.mjs.map +1 -1
  86. package/dist/node/core/EnvapterBase.cjs +1 -1
  87. package/dist/node/core/EnvapterBase.cjs.map +1 -1
  88. package/dist/node/core/EnvapterBase.d.cts +2 -2
  89. package/dist/node/core/EnvapterBase.d.mts +2 -2
  90. package/dist/node/core/EnvapterBase.mjs +1 -1
  91. package/dist/node/core/EnvapterBase.mjs.map +1 -1
  92. package/dist/node/core/EnvironmentMethods.cjs +1 -1
  93. package/dist/node/core/EnvironmentMethods.cjs.map +1 -1
  94. package/dist/node/core/EnvironmentMethods.d.cts +1 -1
  95. package/dist/node/core/EnvironmentMethods.d.mts +1 -1
  96. package/dist/node/core/EnvironmentMethods.mjs +1 -1
  97. package/dist/node/core/EnvironmentMethods.mjs.map +1 -1
  98. package/dist/node/core/PrimitiveMethods.cjs +1 -1
  99. package/dist/node/core/PrimitiveMethods.cjs.map +1 -1
  100. package/dist/node/core/PrimitiveMethods.d.cts +1 -1
  101. package/dist/node/core/PrimitiveMethods.d.mts +1 -1
  102. package/dist/node/core/PrimitiveMethods.mjs +1 -1
  103. package/dist/node/core/PrimitiveMethods.mjs.map +1 -1
  104. package/dist/node/decorators/legacy/Envapt.cjs +2 -0
  105. package/dist/node/decorators/legacy/Envapt.cjs.map +1 -0
  106. package/dist/node/decorators/{Envapt.d.cts → legacy/Envapt.d.cts} +59 -49
  107. package/dist/node/decorators/{Envapt.d.mts → legacy/Envapt.d.mts} +59 -49
  108. package/dist/node/decorators/legacy/Envapt.mjs +2 -0
  109. package/dist/node/decorators/legacy/Envapt.mjs.map +1 -0
  110. package/dist/node/decorators/legacy/SugarDecorators.cjs +2 -0
  111. package/dist/node/decorators/legacy/SugarDecorators.cjs.map +1 -0
  112. package/dist/node/decorators/legacy/SugarDecorators.d.cts +40 -0
  113. package/dist/node/decorators/legacy/SugarDecorators.d.mts +42 -0
  114. package/dist/node/decorators/legacy/SugarDecorators.mjs +2 -0
  115. package/dist/node/decorators/legacy/SugarDecorators.mjs.map +1 -0
  116. package/dist/node/decorators/legacy/createPropertyDecorator.cjs +2 -0
  117. package/dist/node/decorators/legacy/createPropertyDecorator.cjs.map +1 -0
  118. package/dist/node/decorators/legacy/createPropertyDecorator.mjs +2 -0
  119. package/dist/node/decorators/legacy/createPropertyDecorator.mjs.map +1 -0
  120. package/dist/node/decorators/modern/Envapt.cjs +2 -0
  121. package/dist/node/decorators/modern/Envapt.cjs.map +1 -0
  122. package/dist/node/decorators/modern/Envapt.d.cts +218 -0
  123. package/dist/node/decorators/modern/Envapt.d.mts +220 -0
  124. package/dist/node/decorators/modern/Envapt.mjs +2 -0
  125. package/dist/node/decorators/modern/Envapt.mjs.map +1 -0
  126. package/dist/node/decorators/modern/SugarDecorators.cjs +2 -0
  127. package/dist/node/decorators/modern/SugarDecorators.cjs.map +1 -0
  128. package/dist/node/decorators/modern/SugarDecorators.d.cts +40 -0
  129. package/dist/node/decorators/modern/SugarDecorators.d.mts +42 -0
  130. package/dist/node/decorators/modern/SugarDecorators.mjs +2 -0
  131. package/dist/node/decorators/modern/SugarDecorators.mjs.map +1 -0
  132. package/dist/node/decorators/modern/createAccessorDecorator.cjs +2 -0
  133. package/dist/node/decorators/modern/createAccessorDecorator.cjs.map +1 -0
  134. package/dist/node/decorators/modern/createAccessorDecorator.mjs +2 -0
  135. package/dist/node/decorators/modern/createAccessorDecorator.mjs.map +1 -0
  136. package/dist/node/decorators/parseEnvaptOptions.cjs +2 -0
  137. package/dist/node/decorators/parseEnvaptOptions.cjs.map +1 -0
  138. package/dist/node/decorators/parseEnvaptOptions.mjs +2 -0
  139. package/dist/node/decorators/parseEnvaptOptions.mjs.map +1 -0
  140. package/dist/node/decorators/resolveDecoratorValue.cjs +2 -0
  141. package/dist/node/decorators/resolveDecoratorValue.cjs.map +1 -0
  142. package/dist/node/decorators/resolveDecoratorValue.mjs +2 -0
  143. package/dist/node/decorators/resolveDecoratorValue.mjs.map +1 -0
  144. package/dist/node/engine/Envapter.cjs +2 -0
  145. package/dist/node/engine/Envapter.cjs.map +1 -0
  146. package/dist/node/{Envapter.d.cts → engine/Envapter.d.cts} +3 -3
  147. package/dist/node/{Envapter.d.mts → engine/Envapter.d.mts} +3 -3
  148. package/dist/node/engine/Envapter.mjs +2 -0
  149. package/dist/node/engine/Envapter.mjs.map +1 -0
  150. package/dist/node/engine/NodeEnvapter.cjs +2 -0
  151. package/dist/node/engine/NodeEnvapter.cjs.map +1 -0
  152. package/dist/node/{NodeEnvapter.d.cts → engine/NodeEnvapter.d.cts} +3 -3
  153. package/dist/node/{NodeEnvapter.d.mts → engine/NodeEnvapter.d.mts} +3 -3
  154. package/dist/node/engine/NodeEnvapter.mjs +2 -0
  155. package/dist/node/engine/NodeEnvapter.mjs.map +1 -0
  156. package/dist/node/engine/TemplateResolver.cjs +2 -0
  157. package/dist/node/engine/TemplateResolver.cjs.map +1 -0
  158. package/dist/node/{TemplateResolver.d.cts → engine/TemplateResolver.d.cts} +2 -2
  159. package/dist/node/{TemplateResolver.d.mts → engine/TemplateResolver.d.mts} +2 -2
  160. package/dist/node/engine/TemplateResolver.mjs +2 -0
  161. package/dist/node/engine/TemplateResolver.mjs.map +1 -0
  162. package/dist/node/engine/Validators.cjs +2 -0
  163. package/dist/node/engine/Validators.cjs.map +1 -0
  164. package/dist/node/engine/Validators.mjs +2 -0
  165. package/dist/node/engine/Validators.mjs.map +1 -0
  166. package/dist/node/index.cjs +1 -1
  167. package/dist/node/index.d.cts +9 -8
  168. package/dist/node/index.d.mts +9 -8
  169. package/dist/node/index.mjs +1 -1
  170. package/dist/node/infra/Debug.cjs.map +1 -0
  171. package/dist/node/{Debug.d.cts → infra/Debug.d.cts} +1 -1
  172. package/dist/node/{Debug.d.mts → infra/Debug.d.mts} +1 -1
  173. package/dist/node/infra/Debug.mjs.map +1 -0
  174. package/dist/node/infra/Dotenv.cjs.map +1 -0
  175. package/dist/node/{Dotenv.d.cts → infra/Dotenv.d.cts} +1 -1
  176. package/dist/node/{Dotenv.d.mts → infra/Dotenv.d.mts} +1 -1
  177. package/dist/node/infra/Dotenv.mjs.map +1 -0
  178. package/dist/node/infra/Error.cjs.map +1 -0
  179. package/dist/node/{Error.d.cts → infra/Error.d.cts} +1 -1
  180. package/dist/node/{Error.d.mts → infra/Error.d.mts} +1 -1
  181. package/dist/node/infra/Error.mjs.map +1 -0
  182. package/dist/node/{StandardSchema.d.cts → infra/StandardSchema.d.cts} +1 -1
  183. package/dist/node/{StandardSchema.d.mts → infra/StandardSchema.d.mts} +1 -1
  184. package/dist/node/infra/runtime.cjs.map +1 -0
  185. package/dist/node/infra/runtime.mjs.map +1 -0
  186. package/dist/node/legacy.cjs +1 -0
  187. package/dist/node/legacy.d.cts +4 -0
  188. package/dist/node/legacy.d.mts +6 -0
  189. package/dist/node/legacy.mjs +1 -0
  190. package/dist/node/sources/UnboundEnvSource.cjs +1 -1
  191. package/dist/node/sources/UnboundEnvSource.cjs.map +1 -1
  192. package/dist/node/sources/UnboundEnvSource.mjs +1 -1
  193. package/dist/node/sources/UnboundEnvSource.mjs.map +1 -1
  194. package/dist/node/types/Decorator.d.cts +26 -0
  195. package/dist/node/types/Decorator.d.mts +28 -0
  196. package/dist/node/types/Schema.d.cts +1 -1
  197. package/dist/node/types/Schema.d.mts +1 -1
  198. package/dist/workerd/converters/BuiltInConverters.mjs +1 -1
  199. package/dist/workerd/converters/BuiltInConverters.mjs.map +1 -1
  200. package/dist/workerd/converters/ValueConverter.d.mts +1 -1
  201. package/dist/workerd/converters/ValueConverter.mjs +1 -1
  202. package/dist/workerd/converters/ValueConverter.mjs.map +1 -1
  203. package/dist/workerd/core/AdvancedMethods.d.mts +1 -1
  204. package/dist/workerd/core/AdvancedMethods.mjs +1 -1
  205. package/dist/workerd/core/AdvancedMethods.mjs.map +1 -1
  206. package/dist/workerd/core/EnvapterBase.d.mts +2 -2
  207. package/dist/workerd/core/EnvapterBase.mjs +1 -1
  208. package/dist/workerd/core/EnvapterBase.mjs.map +1 -1
  209. package/dist/workerd/core/EnvironmentMethods.d.mts +1 -1
  210. package/dist/workerd/core/EnvironmentMethods.mjs +1 -1
  211. package/dist/workerd/core/EnvironmentMethods.mjs.map +1 -1
  212. package/dist/workerd/core/PrimitiveMethods.d.mts +1 -1
  213. package/dist/workerd/core/PrimitiveMethods.mjs +1 -1
  214. package/dist/workerd/core/PrimitiveMethods.mjs.map +1 -1
  215. package/dist/workerd/decorators/{Envapt.d.mts → legacy/Envapt.d.mts} +59 -49
  216. package/dist/workerd/decorators/legacy/Envapt.mjs +2 -0
  217. package/dist/workerd/decorators/legacy/Envapt.mjs.map +1 -0
  218. package/dist/workerd/decorators/legacy/SugarDecorators.d.mts +40 -0
  219. package/dist/workerd/decorators/legacy/SugarDecorators.mjs +2 -0
  220. package/dist/workerd/decorators/legacy/SugarDecorators.mjs.map +1 -0
  221. package/dist/workerd/decorators/legacy/createPropertyDecorator.mjs +2 -0
  222. package/dist/workerd/decorators/legacy/createPropertyDecorator.mjs.map +1 -0
  223. package/dist/workerd/decorators/modern/Envapt.d.mts +218 -0
  224. package/dist/workerd/decorators/modern/Envapt.mjs +2 -0
  225. package/dist/workerd/decorators/modern/Envapt.mjs.map +1 -0
  226. package/dist/workerd/decorators/modern/SugarDecorators.d.mts +40 -0
  227. package/dist/workerd/decorators/modern/SugarDecorators.mjs +2 -0
  228. package/dist/workerd/decorators/modern/SugarDecorators.mjs.map +1 -0
  229. package/dist/workerd/decorators/modern/createAccessorDecorator.mjs +2 -0
  230. package/dist/workerd/decorators/modern/createAccessorDecorator.mjs.map +1 -0
  231. package/dist/workerd/decorators/parseEnvaptOptions.mjs +2 -0
  232. package/dist/workerd/decorators/parseEnvaptOptions.mjs.map +1 -0
  233. package/dist/workerd/decorators/resolveDecoratorValue.mjs +2 -0
  234. package/dist/workerd/decorators/resolveDecoratorValue.mjs.map +1 -0
  235. package/dist/workerd/{Envapter.d.mts → engine/Envapter.d.mts} +3 -3
  236. package/dist/workerd/engine/Envapter.mjs +2 -0
  237. package/dist/workerd/engine/Envapter.mjs.map +1 -0
  238. package/dist/workerd/{TemplateResolver.d.mts → engine/TemplateResolver.d.mts} +2 -2
  239. package/dist/workerd/engine/TemplateResolver.mjs +2 -0
  240. package/dist/workerd/engine/TemplateResolver.mjs.map +1 -0
  241. package/dist/workerd/engine/Validators.mjs +2 -0
  242. package/dist/workerd/engine/Validators.mjs.map +1 -0
  243. package/dist/workerd/engine/installFileApiStubs.mjs +2 -0
  244. package/dist/workerd/engine/installFileApiStubs.mjs.map +1 -0
  245. package/dist/workerd/index.d.mts +9 -8
  246. package/dist/workerd/index.mjs +1 -1
  247. package/dist/workerd/index.mjs.map +1 -1
  248. package/dist/workerd/{Debug.d.mts → infra/Debug.d.mts} +1 -1
  249. package/dist/workerd/infra/Debug.mjs.map +1 -0
  250. package/dist/{browser → workerd/infra}/Dotenv.d.mts +1 -1
  251. package/dist/workerd/infra/Dotenv.mjs.map +1 -0
  252. package/dist/workerd/{Error.d.mts → infra/Error.d.mts} +1 -1
  253. package/dist/workerd/infra/Error.mjs.map +1 -0
  254. package/dist/workerd/{StandardSchema.d.mts → infra/StandardSchema.d.mts} +1 -1
  255. package/dist/workerd/infra/runtime.mjs.map +1 -0
  256. package/dist/workerd/legacy.d.mts +4 -0
  257. package/dist/workerd/legacy.mjs +1 -0
  258. package/dist/workerd/sources/UnboundEnvSource.mjs +1 -1
  259. package/dist/workerd/sources/UnboundEnvSource.mjs.map +1 -1
  260. package/dist/workerd/types/Decorator.d.mts +26 -0
  261. package/dist/workerd/types/Schema.d.mts +1 -1
  262. package/package.json +34 -3
  263. package/dist/browser/Debug.mjs.map +0 -1
  264. package/dist/browser/Dotenv.mjs.map +0 -1
  265. package/dist/browser/Envapter.mjs +0 -2
  266. package/dist/browser/Envapter.mjs.map +0 -1
  267. package/dist/browser/Error.mjs.map +0 -1
  268. package/dist/browser/TemplateResolver.mjs +0 -2
  269. package/dist/browser/TemplateResolver.mjs.map +0 -1
  270. package/dist/browser/Validators.mjs +0 -2
  271. package/dist/browser/Validators.mjs.map +0 -1
  272. package/dist/browser/decorators/Envapt.mjs +0 -2
  273. package/dist/browser/decorators/Envapt.mjs.map +0 -1
  274. package/dist/browser/decorators/SugarDecorators.d.mts +0 -34
  275. package/dist/browser/decorators/SugarDecorators.mjs +0 -2
  276. package/dist/browser/decorators/SugarDecorators.mjs.map +0 -1
  277. package/dist/browser/decorators/createPropertyDecorator.mjs +0 -2
  278. package/dist/browser/decorators/createPropertyDecorator.mjs.map +0 -1
  279. package/dist/browser/installFileApiStubs.mjs +0 -2
  280. package/dist/browser/installFileApiStubs.mjs.map +0 -1
  281. package/dist/browser/runtime.mjs.map +0 -1
  282. package/dist/node/Debug.cjs.map +0 -1
  283. package/dist/node/Debug.mjs.map +0 -1
  284. package/dist/node/Dotenv.cjs.map +0 -1
  285. package/dist/node/Dotenv.mjs.map +0 -1
  286. package/dist/node/Envapter.cjs +0 -2
  287. package/dist/node/Envapter.cjs.map +0 -1
  288. package/dist/node/Envapter.mjs +0 -2
  289. package/dist/node/Envapter.mjs.map +0 -1
  290. package/dist/node/Error.cjs.map +0 -1
  291. package/dist/node/Error.mjs.map +0 -1
  292. package/dist/node/NodeEnvapter.cjs +0 -2
  293. package/dist/node/NodeEnvapter.cjs.map +0 -1
  294. package/dist/node/NodeEnvapter.mjs +0 -2
  295. package/dist/node/NodeEnvapter.mjs.map +0 -1
  296. package/dist/node/TemplateResolver.cjs +0 -2
  297. package/dist/node/TemplateResolver.cjs.map +0 -1
  298. package/dist/node/TemplateResolver.mjs +0 -2
  299. package/dist/node/TemplateResolver.mjs.map +0 -1
  300. package/dist/node/Validators.cjs +0 -2
  301. package/dist/node/Validators.cjs.map +0 -1
  302. package/dist/node/Validators.mjs +0 -2
  303. package/dist/node/Validators.mjs.map +0 -1
  304. package/dist/node/decorators/Envapt.cjs +0 -2
  305. package/dist/node/decorators/Envapt.cjs.map +0 -1
  306. package/dist/node/decorators/Envapt.mjs +0 -2
  307. package/dist/node/decorators/Envapt.mjs.map +0 -1
  308. package/dist/node/decorators/SugarDecorators.cjs +0 -2
  309. package/dist/node/decorators/SugarDecorators.cjs.map +0 -1
  310. package/dist/node/decorators/SugarDecorators.d.cts +0 -34
  311. package/dist/node/decorators/SugarDecorators.d.mts +0 -36
  312. package/dist/node/decorators/SugarDecorators.mjs +0 -2
  313. package/dist/node/decorators/SugarDecorators.mjs.map +0 -1
  314. package/dist/node/decorators/createPropertyDecorator.cjs +0 -2
  315. package/dist/node/decorators/createPropertyDecorator.cjs.map +0 -1
  316. package/dist/node/decorators/createPropertyDecorator.mjs +0 -2
  317. package/dist/node/decorators/createPropertyDecorator.mjs.map +0 -1
  318. package/dist/node/runtime.cjs.map +0 -1
  319. package/dist/node/runtime.mjs.map +0 -1
  320. package/dist/workerd/Debug.mjs.map +0 -1
  321. package/dist/workerd/Dotenv.mjs.map +0 -1
  322. package/dist/workerd/Envapter.mjs +0 -2
  323. package/dist/workerd/Envapter.mjs.map +0 -1
  324. package/dist/workerd/Error.mjs.map +0 -1
  325. package/dist/workerd/TemplateResolver.mjs +0 -2
  326. package/dist/workerd/TemplateResolver.mjs.map +0 -1
  327. package/dist/workerd/Validators.mjs +0 -2
  328. package/dist/workerd/Validators.mjs.map +0 -1
  329. package/dist/workerd/decorators/Envapt.mjs +0 -2
  330. package/dist/workerd/decorators/Envapt.mjs.map +0 -1
  331. package/dist/workerd/decorators/SugarDecorators.d.mts +0 -34
  332. package/dist/workerd/decorators/SugarDecorators.mjs +0 -2
  333. package/dist/workerd/decorators/SugarDecorators.mjs.map +0 -1
  334. package/dist/workerd/decorators/createPropertyDecorator.mjs +0 -2
  335. package/dist/workerd/decorators/createPropertyDecorator.mjs.map +0 -1
  336. package/dist/workerd/installFileApiStubs.mjs +0 -2
  337. package/dist/workerd/installFileApiStubs.mjs.map +0 -1
  338. package/dist/workerd/runtime.mjs.map +0 -1
  339. /package/dist/browser/{Debug.mjs → infra/Debug.mjs} +0 -0
  340. /package/dist/browser/{Dotenv.mjs → infra/Dotenv.mjs} +0 -0
  341. /package/dist/browser/{Error.mjs → infra/Error.mjs} +0 -0
  342. /package/dist/browser/{runtime.mjs → infra/runtime.mjs} +0 -0
  343. /package/dist/node/{Debug.cjs → infra/Debug.cjs} +0 -0
  344. /package/dist/node/{Debug.mjs → infra/Debug.mjs} +0 -0
  345. /package/dist/node/{Dotenv.cjs → infra/Dotenv.cjs} +0 -0
  346. /package/dist/node/{Dotenv.mjs → infra/Dotenv.mjs} +0 -0
  347. /package/dist/node/{Error.cjs → infra/Error.cjs} +0 -0
  348. /package/dist/node/{Error.mjs → infra/Error.mjs} +0 -0
  349. /package/dist/node/{runtime.cjs → infra/runtime.cjs} +0 -0
  350. /package/dist/node/{runtime.mjs → infra/runtime.mjs} +0 -0
  351. /package/dist/workerd/{Debug.mjs → infra/Debug.mjs} +0 -0
  352. /package/dist/workerd/{Dotenv.mjs → infra/Dotenv.mjs} +0 -0
  353. /package/dist/workerd/{Error.mjs → infra/Error.mjs} +0 -0
  354. /package/dist/workerd/{runtime.mjs → infra/runtime.mjs} +0 -0
@@ -1,13 +1,13 @@
1
- import { ArrayOf } from "../converters/Converters.mjs";
2
- import { BuiltInConverter, ConverterFunction, InferConverterFallbackType, InferPrimitiveReturnType, PrimitiveConstructor } from "../types/Conversion.mjs";
3
- import { InferSchemaOutput, StandardSchemaV1 } from "../StandardSchema.mjs";
4
- import { SchemaConstraint } from "../types/Schema.mjs";
5
- import { EnvKeyInput } from "../types/Env.mjs";
1
+ import { ArrayOf } from "../../converters/Converters.mjs";
2
+ import { BuiltInConverter, ConverterFunction, InferConverterFallbackType, InferConverterReturnType, InferPrimitiveReturnType, PrimitiveConstructor } from "../../types/Conversion.mjs";
3
+ import { InferSchemaOutput, StandardSchemaV1 } from "../../infra/StandardSchema.mjs";
4
+ import { SchemaConstraint } from "../../types/Schema.mjs";
5
+ import { EnvKeyInput } from "../../types/Env.mjs";
6
+ import { EnvaptFieldDecorator } from "../../types/Decorator.mjs";
6
7
 
7
- //#region src/decorators/Envapt.d.ts
8
+ //#region src/decorators/legacy/Envapt.d.ts
8
9
  /**
9
- * Usage 1: Either a custom converter function + fallback (both required), OR a fallback
10
- * only (no converter).
10
+ * A custom converter function with a fallback (both required), or a fallback only.
11
11
  *
12
12
  * @param key - Environment variable name(s) to load
13
13
  * @param options - Configuration options
@@ -15,7 +15,6 @@ import { EnvKeyInput } from "../types/Env.mjs";
15
15
  * @example
16
16
  * ```ts
17
17
  * class Config extends Envapter {
18
- * // Custom converter that validates a non-empty API key
19
18
  * \@Envapt('API_KEY', {
20
19
  * fallback: 'default-key',
21
20
  * converter(raw, _fallback) {
@@ -25,30 +24,32 @@ import { EnvKeyInput } from "../types/Env.mjs";
25
24
  * })
26
25
  * static readonly apiKey: string;
27
26
  *
28
- * // Fallback-only (no converter): string fallback
29
27
  * \@Envapt('LOG_FILE', { fallback: '/var/log/app.log' })
30
28
  * static readonly logFile: string;
31
29
  *
32
- * // Fallback-only: arbitrary object fallback
33
30
  * \@Envapt('RETRY_POLICY', { fallback: { retries: 3, backoff: 'exponential' } })
34
31
  * static readonly retryPolicy: unknown;
35
32
  * }
36
33
  * ```
37
34
  */
35
+ declare function Envapt(key: EnvKeyInput, options: {
36
+ fallback: undefined;
37
+ converter?: undefined;
38
+ }): EnvaptFieldDecorator<string | undefined>;
38
39
  declare function Envapt<TFallback>(key: EnvKeyInput, options: {
39
40
  converter: (raw: string | undefined, fallback: TFallback) => TFallback;
40
41
  fallback: TFallback;
41
42
  } | {
42
43
  fallback: TFallback;
43
44
  converter?: undefined;
44
- }): PropertyDecorator;
45
+ }): EnvaptFieldDecorator<TFallback>;
45
46
  /**
46
- * Usage 2: Custom converter function without fallback. Either omit `required` (returns the
47
- * converter's output, possibly `undefined`) or pass `required: true` to throw `MissingEnvValue`
48
- * on missing/empty values.
47
+ * A custom converter function without a fallback. Omit `required` to return the converter's
48
+ * output (possibly `undefined`), or pass `required: true` to throw `MissingEnvValue` on
49
+ * missing or empty values.
49
50
  *
50
51
  * @param key - Environment variable name(s) to load
51
- * @param options - Configuration options with custom converter only, with optional `required: true`
52
+ * @param options - Configuration options
52
53
  * @public
53
54
  * @example
54
55
  * ```ts
@@ -72,15 +73,11 @@ declare function Envapt<TReturnType>(key: EnvKeyInput, options: {
72
73
  } | {
73
74
  converter: ConverterFunction<TReturnType>;
74
75
  required: true;
75
- }): PropertyDecorator;
76
+ }): EnvaptFieldDecorator<TReturnType>;
76
77
  /**
77
- * Usage 3: Built-in or array converter with optional fallback OR `required: true`.
78
- *
79
- * `InferConverterFallbackType` handles asymmetric cases: scalar `Converters.Time` accepts
80
- * `TimeFallback`, and `ArrayOf<'time'>` accepts `TimeFallback[]`. Every other converter
81
- * reduces to `InferConverterReturnType`. The two object-shape branches are mutually
82
- * exclusive: either provide a `fallback`, or pass `required: true` to throw
83
- * `MissingEnvValue` on missing/empty values.
78
+ * A built-in or array converter with a fallback, or `required: true`. The fallback type tracks
79
+ * the converter, so `Converters.Time` takes a number or time-string and `Converters.Url` takes
80
+ * a `URL` instance.
84
81
  *
85
82
  * @param key - Environment variable name(s) to load
86
83
  * @param options - Configuration options
@@ -90,23 +87,21 @@ declare function Envapt<TReturnType>(key: EnvKeyInput, options: {
90
87
  * import { Converters } from 'envapt';
91
88
  *
92
89
  * class Config extends Envapter {
93
- * // Use built-in Number converter with a numeric fallback
94
90
  * \@Envapt('APP_PORT', { converter: Converters.Number, fallback: 3000 })
95
91
  * static readonly port: number;
96
92
  *
97
- * // Url converter: the fallback is a URL instance, not a string
93
+ * // the Url fallback is a URL instance, not a string
98
94
  * \@Envapt('APP_URL', { converter: Converters.Url, fallback: new URL('http://localhost:3000') })
99
95
  * static readonly url: URL;
100
96
  *
101
- * // Prefer CANARY_URL when present, otherwise fall back to APP_URL
97
+ * // prefers CANARY_URL when present, otherwise APP_URL
102
98
  * \@Envapt(['CANARY_URL', 'APP_URL'], { converter: Converters.Url })
103
99
  * static readonly canaryUrl: URL | null;
104
100
  *
105
- * // `Converters.Time` accepts either a number (milliseconds) or a time-string fallback (`<number><unit>`).
101
+ * // Time takes a number (milliseconds) or a time-string fallback (`<number><unit>`)
106
102
  * \@Envapt('REQUEST_TIMEOUT', { converter: Converters.Time, fallback: '10s' })
107
103
  * static readonly requestTimeout: number;
108
104
  *
109
- * // Array converter: comma-separated list of origins -> string[]
110
105
  * \@Envapt('ALLOWED_ORIGINS', {
111
106
  * converter: Converters.array({ of: Converters.String }),
112
107
  * fallback: ['https://example.com']
@@ -120,21 +115,29 @@ declare function Envapt<TReturnType>(key: EnvKeyInput, options: {
120
115
  */
121
116
  declare function Envapt<TConverter extends BuiltInConverter | ArrayOf>(key: EnvKeyInput, options: {
122
117
  converter: TConverter;
123
- fallback?: InferConverterFallbackType<TConverter> | undefined;
118
+ fallback: InferConverterFallbackType<TConverter>;
124
119
  required?: false;
125
120
  } | {
126
121
  converter: TConverter;
127
122
  required: true;
128
- }): PropertyDecorator;
123
+ }): EnvaptFieldDecorator<InferConverterReturnType<TConverter>>;
124
+ declare function Envapt<TConverter extends BuiltInConverter | ArrayOf>(key: EnvKeyInput, options: {
125
+ converter: TConverter;
126
+ fallback: undefined;
127
+ required?: false;
128
+ }): EnvaptFieldDecorator<InferConverterReturnType<TConverter> | undefined>;
129
+ declare function Envapt<TConverter extends BuiltInConverter | ArrayOf>(key: EnvKeyInput, options: {
130
+ converter: TConverter;
131
+ required?: false;
132
+ }): EnvaptFieldDecorator<InferConverterReturnType<TConverter> | null>;
129
133
  /**
130
- * Usage 4: Primitive constructor with optional fallback
134
+ * A primitive constructor (`Number`, `Boolean`) with an optional fallback.
131
135
  *
132
136
  * @param key - Environment variable name(s) to load
133
- * @param options - Configuration options with primitive constructor
137
+ * @param options - Configuration options
134
138
  * @public
135
139
  * @example
136
140
  * ```ts
137
- * // Use primitive constructors to coerce values
138
141
  * class Config extends Envapter {
139
142
  * \@Envapt('MAX_CONNECTIONS', { converter: Number, fallback: 100 })
140
143
  * static readonly maxConnections: number;
@@ -146,17 +149,26 @@ declare function Envapt<TConverter extends BuiltInConverter | ArrayOf>(key: EnvK
146
149
  */
147
150
  declare function Envapt<TConstructor extends PrimitiveConstructor>(key: EnvKeyInput, options: {
148
151
  converter: TConstructor;
149
- fallback?: InferPrimitiveReturnType<TConstructor>;
152
+ fallback: InferPrimitiveReturnType<TConstructor>;
150
153
  required?: false;
151
154
  } | {
152
155
  converter: TConstructor;
153
156
  required: true;
154
- }): PropertyDecorator;
157
+ }): EnvaptFieldDecorator<InferPrimitiveReturnType<TConstructor>>;
158
+ declare function Envapt<TConstructor extends PrimitiveConstructor>(key: EnvKeyInput, options: {
159
+ converter: TConstructor;
160
+ fallback: undefined;
161
+ required?: false;
162
+ }): EnvaptFieldDecorator<InferPrimitiveReturnType<TConstructor> | undefined>;
163
+ declare function Envapt<TConstructor extends PrimitiveConstructor>(key: EnvKeyInput, options: {
164
+ converter: TConstructor;
165
+ required?: false;
166
+ }): EnvaptFieldDecorator<InferPrimitiveReturnType<TConstructor> | null>;
155
167
  /**
156
- * Usage 5: Required, no converter (raw string). Throws `MissingEnvValue` on first access if
157
- * the env value is missing or empty (post-trim). Independent of global `Envapter.strict`.
158
- * Combining `required: true` with `fallback` fails to match any overload at compile time;
159
- * the runtime Validator catches dynamic objects that bypass the types.
168
+ * Required, no converter (raw string). Throws `MissingEnvValue` on first access when the env
169
+ * value is missing or empty after trimming, independent of the global `Envapter.strict` flag.
170
+ * Pairing `required: true` with `fallback` matches no overload at compile time, and the runtime
171
+ * Validator rejects dynamic objects that bypass the types.
160
172
  *
161
173
  * @param key - Environment variable name(s) to load
162
174
  * @param options - `{ required: true }`
@@ -171,7 +183,7 @@ declare function Envapt<TConstructor extends PrimitiveConstructor>(key: EnvKeyIn
171
183
  */
172
184
  declare function Envapt(key: EnvKeyInput, options: {
173
185
  required: true;
174
- }): PropertyDecorator;
186
+ }): EnvaptFieldDecorator<string>;
175
187
  /**
176
188
  * No-fallback form. The property resolves from env or `null`.
177
189
  *
@@ -179,20 +191,18 @@ declare function Envapt(key: EnvKeyInput, options: {
179
191
  * @public
180
192
  * @example
181
193
  * ```ts
182
- * // Classic API: no fallback — property will resolve from env or be null
183
194
  * class Config extends Envapter {
184
195
  * \@Envapt('SIMPLE_VALUE')
185
196
  * static readonly simple?: string | null;
186
197
  * }
187
198
  * ```
188
199
  */
189
- declare function Envapt<_TReturnType = string | null>(key: EnvKeyInput): PropertyDecorator;
200
+ declare function Envapt(key: EnvKeyInput): EnvaptFieldDecorator<string | null>;
190
201
  /**
191
- * Usage 6: Standard Schema v1 adapter (zod, valibot, arktype, hand-rolled). Synchronous
192
- * schemas only; a Promise-returning `validate` triggers a runtime
193
- * `InvalidUserDefinedConfig` throw. Combining `schema` with `converter` fails to match any
194
- * overload at compile time; the runtime Validator catches dynamic objects that bypass the
195
- * types.
202
+ * A Standard Schema v1 adapter (zod, valibot, arktype, hand-rolled). Synchronous schemas only,
203
+ * so a Promise-returning `validate` throws `InvalidUserDefinedConfig` at runtime. Pairing
204
+ * `schema` with `converter` matches no overload at compile time, and the runtime Validator
205
+ * rejects dynamic objects that bypass the types.
196
206
  * @public
197
207
  */
198
208
  declare function Envapt<Schema extends StandardSchemaV1>(key: EnvKeyInput, options: {
@@ -202,7 +212,7 @@ declare function Envapt<Schema extends StandardSchemaV1>(key: EnvKeyInput, optio
202
212
  } | {
203
213
  schema: SchemaConstraint<Schema>;
204
214
  required: true;
205
- }): PropertyDecorator;
215
+ }): EnvaptFieldDecorator<InferSchemaOutput<Schema>>;
206
216
  //#endregion
207
217
  export { Envapt };
208
218
  //# sourceMappingURL=Envapt.d.mts.map
@@ -0,0 +1,2 @@
1
+ import{parseEnvaptOptions as e}from"../parseEnvaptOptions.mjs";import{createPropertyDecorator as t}from"./createPropertyDecorator.mjs";function n(n,r){return t(n,e(r))}export{n as Envapt};
2
+ //# sourceMappingURL=Envapt.mjs.map
@@ -0,0 +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"}
@@ -0,0 +1,40 @@
1
+ import { TimeFallback } from "../../types/Conversion.mjs";
2
+ import { EnvKeyInput } from "../../types/Env.mjs";
3
+ import { EnvaptFieldDecorator } from "../../types/Decorator.mjs";
4
+
5
+ //#region src/decorators/legacy/SugarDecorators.d.ts
6
+ /**
7
+ * Shorthand for `@Envapt(key, { converter: Converters.Boolean, fallback })`.
8
+ * @public
9
+ */
10
+ declare function EnvBool(key: EnvKeyInput, fallback: boolean): EnvaptFieldDecorator<boolean>;
11
+ declare function EnvBool(key: EnvKeyInput): EnvaptFieldDecorator<boolean | null>;
12
+ /**
13
+ * Shorthand for `@Envapt(key, { converter: Converters.Number, fallback })`.
14
+ * @public
15
+ */
16
+ declare function EnvNum(key: EnvKeyInput, fallback: number): EnvaptFieldDecorator<number>;
17
+ declare function EnvNum(key: EnvKeyInput): EnvaptFieldDecorator<number | null>;
18
+ /**
19
+ * Shorthand for `@Envapt(key, { converter: Converters.String, fallback })`.
20
+ * @public
21
+ */
22
+ declare function EnvStr(key: EnvKeyInput, fallback: string): EnvaptFieldDecorator<string>;
23
+ declare function EnvStr(key: EnvKeyInput): EnvaptFieldDecorator<string | null>;
24
+ /**
25
+ * Shorthand for `@Envapt(key, { converter: Converters.Time, fallback })`. The fallback is a
26
+ * millisecond number or a time string (`'15m'`), and the resolved value is always milliseconds.
27
+ * @public
28
+ */
29
+ declare function EnvTime(key: EnvKeyInput, fallback: TimeFallback): EnvaptFieldDecorator<number>;
30
+ declare function EnvTime(key: EnvKeyInput): EnvaptFieldDecorator<number | null>;
31
+ /**
32
+ * Shorthand for `@Envapt(key, { converter: Converters.Url, fallback })`. The fallback is a `URL`
33
+ * instance, not a URL string.
34
+ * @public
35
+ */
36
+ declare function EnvUrl(key: EnvKeyInput, fallback: URL): EnvaptFieldDecorator<URL>;
37
+ declare function EnvUrl(key: EnvKeyInput): EnvaptFieldDecorator<URL | null>;
38
+ //#endregion
39
+ export { EnvBool, EnvNum, EnvStr, EnvTime, EnvUrl };
40
+ //# sourceMappingURL=SugarDecorators.d.mts.map
@@ -0,0 +1,2 @@
1
+ import{Converters as e}from"../../converters/Converters.mjs";import{createPropertyDecorator as t}from"./createPropertyDecorator.mjs";function n(e,n,r){return t(n,{converter:e,fallback:r,hasFallback:r!==void 0,required:!1,schema:void 0})}function r(t,r){return n(e.Boolean,t,r)}function i(t,r){return n(e.Number,t,r)}function a(t,r){return n(e.String,t,r)}function o(t,r){return n(e.Time,t,r)}function s(t,r){return n(e.Url,t,r)}export{r as EnvBool,i as EnvNum,a as EnvStr,o as EnvTime,s as EnvUrl};
2
+ //# sourceMappingURL=SugarDecorators.mjs.map
@@ -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 */\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 */\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 */\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 */\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 */\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,CAQA,SAAgB,EAAQ,EAAkB,EAA0D,CAChG,OAAO,EAAM,EAAW,QAAS,EAAK,CAAQ,CAClD,CAQA,SAAgB,EAAO,EAAkB,EAAwD,CAC7F,OAAO,EAAM,EAAW,OAAQ,EAAK,CAAQ,CACjD,CAQA,SAAgB,EAAO,EAAkB,EAAwD,CAC7F,OAAO,EAAM,EAAW,OAAQ,EAAK,CAAQ,CACjD,CASA,SAAgB,EAAQ,EAAkB,EAA8D,CACpG,OAAO,EAAM,EAAW,KAAM,EAAK,CAAQ,CAC/C,CASA,SAAgB,EAAO,EAAkB,EAAkD,CACvF,OAAO,EAAM,EAAW,IAAK,EAAK,CAAQ,CAC9C"}
@@ -0,0 +1,2 @@
1
+ import{EnvaptError as e}from"../../infra/Error.mjs";import{decoratorCacheKey as t,resolveDecoratorValue as n}from"../resolveDecoratorValue.mjs";function r(r,i){return function(a,o){let s=String(o),c=typeof a==`function`,l=t(c?a:a.constructor,c,s);Object.defineProperty(a,s,{get:function(){return n(r,i,l)},set(){throw new e(302,`Cannot assign to "${s}". @Envapt properties resolve from the environment and are read-only.`)},configurable:!1,enumerable:!0})}}export{r as createPropertyDecorator};
2
+ //# sourceMappingURL=createPropertyDecorator.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createPropertyDecorator.mjs","names":[],"sources":["../../../../src/decorators/legacy/createPropertyDecorator.ts"],"sourcesContent":["import { EnvaptError, EnvaptErrorCodes } from '../../infra/Error';\nimport { decoratorCacheKey, resolveDecoratorValue } from '../resolveDecoratorValue';\n\nimport type { EnvKeyInput } from '../../types';\nimport type { DecoratorConfig } from '../resolveDecoratorValue';\n\nexport function createPropertyDecorator<TFallback>(\n key: EnvKeyInput,\n config: DecoratorConfig<TFallback>\n): PropertyDecorator {\n return function (target: object, prop: string | symbol): void {\n const propKey = String(prop);\n const isStatic = typeof target === 'function';\n const owner = isStatic ? target : target.constructor;\n const cacheKey = decoratorCacheKey(owner, isStatic, propKey);\n\n Object.defineProperty(target, propKey, {\n get: function () {\n return resolveDecoratorValue(key, config, cacheKey);\n },\n set(): void {\n throw new EnvaptError(\n EnvaptErrorCodes.InvalidUserDefinedConfig,\n `Cannot assign to \"${propKey}\". @Envapt properties resolve from the environment and are read-only.`\n );\n },\n configurable: false,\n enumerable: true\n });\n };\n}\n"],"mappings":"gJAMA,SAAgB,EACZ,EACA,EACiB,CACjB,OAAO,SAAU,EAAgB,EAA6B,CAC1D,IAAM,EAAU,OAAO,CAAI,EACrB,EAAW,OAAO,GAAW,WAE7B,EAAW,EADH,EAAW,EAAS,EAAO,YACC,EAAU,CAAO,EAE3D,OAAO,eAAe,EAAQ,EAAS,CACnC,IAAK,UAAY,CACb,OAAO,EAAsB,EAAK,EAAQ,CAAQ,CACtD,EACA,KAAY,CACR,MAAM,IAAI,EAAA,IAEN,qBAAqB,EAAQ,sEACjC,CACJ,EACA,aAAc,GACd,WAAY,EAChB,CAAC,CACL,CACJ"}
@@ -0,0 +1,218 @@
1
+ import { ArrayOf } from "../../converters/Converters.mjs";
2
+ import { BuiltInConverter, ConverterFunction, InferConverterFallbackType, InferConverterReturnType, InferPrimitiveReturnType, PrimitiveConstructor } from "../../types/Conversion.mjs";
3
+ import { InferSchemaOutput, StandardSchemaV1 } from "../../infra/StandardSchema.mjs";
4
+ import { SchemaConstraint } from "../../types/Schema.mjs";
5
+ import { EnvKeyInput } from "../../types/Env.mjs";
6
+ import { EnvaptAccessorDecorator } from "../../types/Decorator.mjs";
7
+
8
+ //#region src/decorators/modern/Envapt.d.ts
9
+ /**
10
+ * A custom converter function with a fallback (both required), or a fallback only.
11
+ *
12
+ * @param key - Environment variable name(s) to load
13
+ * @param options - Configuration options
14
+ * @public
15
+ * @example
16
+ * ```ts
17
+ * class Config {
18
+ * \@Envapt('API_KEY', {
19
+ * fallback: 'default-key',
20
+ * converter(raw, _fallback) {
21
+ * if (!raw || raw.trim() === '') throw new Error('API_KEY required');
22
+ * return raw.trim();
23
+ * }
24
+ * })
25
+ * static accessor apiKey: string;
26
+ *
27
+ * \@Envapt('LOG_FILE', { fallback: '/var/log/app.log' })
28
+ * static accessor logFile: string;
29
+ *
30
+ * \@Envapt('RETRY_POLICY', { fallback: { retries: 3, backoff: 'exponential' } })
31
+ * static accessor retryPolicy: unknown;
32
+ * }
33
+ * ```
34
+ */
35
+ declare function Envapt(key: EnvKeyInput, options: {
36
+ fallback: undefined;
37
+ converter?: undefined;
38
+ }): EnvaptAccessorDecorator<string | undefined>;
39
+ declare function Envapt<TFallback>(key: EnvKeyInput, options: {
40
+ converter: (raw: string | undefined, fallback: TFallback) => TFallback;
41
+ fallback: TFallback;
42
+ } | {
43
+ fallback: TFallback;
44
+ converter?: undefined;
45
+ }): EnvaptAccessorDecorator<TFallback>;
46
+ /**
47
+ * A custom converter function without a fallback. Omit `required` to return the converter's
48
+ * output (possibly `undefined`), or pass `required: true` to throw `MissingEnvValue` on
49
+ * missing or empty values.
50
+ *
51
+ * @param key - Environment variable name(s) to load
52
+ * @param options - Configuration options
53
+ * @public
54
+ * @example
55
+ * ```ts
56
+ * class Config {
57
+ * \@Envapt('FEATURE_FLAGS', { converter(raw) {
58
+ * return raw ? raw.split('|').map(s => s.trim()) : [];
59
+ * } })
60
+ * static accessor featureFlags: string[];
61
+ *
62
+ * \@Envapt('JWT_SECRET', {
63
+ * converter: (raw) => Buffer.from(raw ?? '', 'base64'),
64
+ * required: true
65
+ * })
66
+ * static accessor jwtSecret: Buffer;
67
+ * }
68
+ * ```
69
+ */
70
+ declare function Envapt<TReturnType>(key: EnvKeyInput, options: {
71
+ converter: ConverterFunction<TReturnType>;
72
+ required?: false;
73
+ } | {
74
+ converter: ConverterFunction<TReturnType>;
75
+ required: true;
76
+ }): EnvaptAccessorDecorator<TReturnType>;
77
+ /**
78
+ * A built-in or array converter with a fallback, or `required: true`. The fallback type tracks
79
+ * the converter, so `Converters.Time` takes a number or time-string and `Converters.Url` takes
80
+ * a `URL` instance.
81
+ *
82
+ * @param key - Environment variable name(s) to load
83
+ * @param options - Configuration options
84
+ * @public
85
+ * @example
86
+ * ```ts
87
+ * import { Converters } from 'envapt';
88
+ *
89
+ * class Config {
90
+ * \@Envapt('APP_PORT', { converter: Converters.Number, fallback: 3000 })
91
+ * static accessor port: number;
92
+ *
93
+ * // the Url fallback is a URL instance, not a string
94
+ * \@Envapt('APP_URL', { converter: Converters.Url, fallback: new URL('http://localhost:3000') })
95
+ * static accessor url: URL;
96
+ *
97
+ * // prefers CANARY_URL when present, otherwise APP_URL
98
+ * \@Envapt(['CANARY_URL', 'APP_URL'], { converter: Converters.Url })
99
+ * static accessor canaryUrl: URL | null;
100
+ *
101
+ * // Time takes a number (milliseconds) or a time-string fallback (`<number><unit>`)
102
+ * \@Envapt('REQUEST_TIMEOUT', { converter: Converters.Time, fallback: '10s' })
103
+ * static accessor requestTimeout: number;
104
+ *
105
+ * \@Envapt('ALLOWED_ORIGINS', {
106
+ * converter: Converters.array({ of: Converters.String }),
107
+ * fallback: ['https://example.com']
108
+ * })
109
+ * static accessor allowedOrigins: string[];
110
+ *
111
+ * \@Envapt('DATABASE_URL', { converter: Converters.Url, required: true })
112
+ * static accessor databaseUrl: URL;
113
+ * }
114
+ * ```
115
+ */
116
+ declare function Envapt<TConverter extends BuiltInConverter | ArrayOf>(key: EnvKeyInput, options: {
117
+ converter: TConverter;
118
+ fallback: InferConverterFallbackType<TConverter>;
119
+ required?: false;
120
+ } | {
121
+ converter: TConverter;
122
+ required: true;
123
+ }): EnvaptAccessorDecorator<InferConverterReturnType<TConverter>>;
124
+ declare function Envapt<TConverter extends BuiltInConverter | ArrayOf>(key: EnvKeyInput, options: {
125
+ converter: TConverter;
126
+ fallback: undefined;
127
+ required?: false;
128
+ }): EnvaptAccessorDecorator<InferConverterReturnType<TConverter> | undefined>;
129
+ declare function Envapt<TConverter extends BuiltInConverter | ArrayOf>(key: EnvKeyInput, options: {
130
+ converter: TConverter;
131
+ required?: false;
132
+ }): EnvaptAccessorDecorator<InferConverterReturnType<TConverter> | null>;
133
+ /**
134
+ * A primitive constructor (`Number`, `Boolean`) with an optional fallback.
135
+ *
136
+ * @param key - Environment variable name(s) to load
137
+ * @param options - Configuration options
138
+ * @public
139
+ * @example
140
+ * ```ts
141
+ * class Config {
142
+ * \@Envapt('MAX_CONNECTIONS', { converter: Number, fallback: 100 })
143
+ * static accessor maxConnections: number;
144
+ *
145
+ * \@Envapt('FEATURE_ENABLED', { converter: Boolean, fallback: false })
146
+ * static accessor featureEnabled: boolean;
147
+ * }
148
+ * ```
149
+ */
150
+ declare function Envapt<TConstructor extends PrimitiveConstructor>(key: EnvKeyInput, options: {
151
+ converter: TConstructor;
152
+ fallback: InferPrimitiveReturnType<TConstructor>;
153
+ required?: false;
154
+ } | {
155
+ converter: TConstructor;
156
+ required: true;
157
+ }): EnvaptAccessorDecorator<InferPrimitiveReturnType<TConstructor>>;
158
+ declare function Envapt<TConstructor extends PrimitiveConstructor>(key: EnvKeyInput, options: {
159
+ converter: TConstructor;
160
+ fallback: undefined;
161
+ required?: false;
162
+ }): EnvaptAccessorDecorator<InferPrimitiveReturnType<TConstructor> | undefined>;
163
+ declare function Envapt<TConstructor extends PrimitiveConstructor>(key: EnvKeyInput, options: {
164
+ converter: TConstructor;
165
+ required?: false;
166
+ }): EnvaptAccessorDecorator<InferPrimitiveReturnType<TConstructor> | null>;
167
+ /**
168
+ * Required, no converter (raw string). Throws `MissingEnvValue` on first access when the env
169
+ * value is missing or empty after trimming, independent of the global `Envapter.strict` flag.
170
+ * Pairing `required: true` with `fallback` matches no overload at compile time, and the runtime
171
+ * Validator rejects dynamic objects that bypass the types.
172
+ *
173
+ * @param key - Environment variable name(s) to load
174
+ * @param options - `{ required: true }`
175
+ * @public
176
+ * @example
177
+ * ```ts
178
+ * class Config {
179
+ * \@Envapt('API_KEY', { required: true })
180
+ * static accessor apiKey: string;
181
+ * }
182
+ * ```
183
+ */
184
+ declare function Envapt(key: EnvKeyInput, options: {
185
+ required: true;
186
+ }): EnvaptAccessorDecorator<string>;
187
+ /**
188
+ * No-fallback form. The property resolves from env or `null`.
189
+ *
190
+ * @param key - Environment variable name(s) to load
191
+ * @public
192
+ * @example
193
+ * ```ts
194
+ * class Config {
195
+ * \@Envapt('SIMPLE_VALUE')
196
+ * static accessor simple: string | null;
197
+ * }
198
+ * ```
199
+ */
200
+ declare function Envapt(key: EnvKeyInput): EnvaptAccessorDecorator<string | null>;
201
+ /**
202
+ * A Standard Schema v1 adapter (zod, valibot, arktype, hand-rolled). Synchronous schemas only,
203
+ * so a Promise-returning `validate` throws `InvalidUserDefinedConfig` at runtime. Pairing
204
+ * `schema` with `converter` matches no overload at compile time, and the runtime Validator
205
+ * rejects dynamic objects that bypass the types.
206
+ * @public
207
+ */
208
+ declare function Envapt<Schema extends StandardSchemaV1>(key: EnvKeyInput, options: {
209
+ schema: SchemaConstraint<Schema>;
210
+ fallback?: InferSchemaOutput<Schema>;
211
+ required?: false;
212
+ } | {
213
+ schema: SchemaConstraint<Schema>;
214
+ required: true;
215
+ }): EnvaptAccessorDecorator<InferSchemaOutput<Schema>>;
216
+ //#endregion
217
+ export { Envapt };
218
+ //# sourceMappingURL=Envapt.d.mts.map
@@ -0,0 +1,2 @@
1
+ import{createAccessorDecorator as e}from"./createAccessorDecorator.mjs";import{parseEnvaptOptions as t}from"../parseEnvaptOptions.mjs";function n(n,r){return e(n,t(r))}export{n as Envapt};
2
+ //# sourceMappingURL=Envapt.mjs.map
@@ -0,0 +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"}
@@ -0,0 +1,40 @@
1
+ import { TimeFallback } from "../../types/Conversion.mjs";
2
+ import { EnvKeyInput } from "../../types/Env.mjs";
3
+ import { EnvaptAccessorDecorator } from "../../types/Decorator.mjs";
4
+
5
+ //#region src/decorators/modern/SugarDecorators.d.ts
6
+ /**
7
+ * Shorthand for `@Envapt(key, { converter: Converters.Boolean, fallback })`.
8
+ * @public
9
+ */
10
+ declare function EnvBool(key: EnvKeyInput, fallback: boolean): EnvaptAccessorDecorator<boolean>;
11
+ declare function EnvBool(key: EnvKeyInput): EnvaptAccessorDecorator<boolean | null>;
12
+ /**
13
+ * Shorthand for `@Envapt(key, { converter: Converters.Number, fallback })`.
14
+ * @public
15
+ */
16
+ declare function EnvNum(key: EnvKeyInput, fallback: number): EnvaptAccessorDecorator<number>;
17
+ declare function EnvNum(key: EnvKeyInput): EnvaptAccessorDecorator<number | null>;
18
+ /**
19
+ * Shorthand for `@Envapt(key, { converter: Converters.String, fallback })`.
20
+ * @public
21
+ */
22
+ declare function EnvStr(key: EnvKeyInput, fallback: string): EnvaptAccessorDecorator<string>;
23
+ declare function EnvStr(key: EnvKeyInput): EnvaptAccessorDecorator<string | null>;
24
+ /**
25
+ * Shorthand for `@Envapt(key, { converter: Converters.Time, fallback })`. The fallback is a
26
+ * millisecond number or a time string (`'15m'`), and the resolved value is always milliseconds.
27
+ * @public
28
+ */
29
+ declare function EnvTime(key: EnvKeyInput, fallback: TimeFallback): EnvaptAccessorDecorator<number>;
30
+ declare function EnvTime(key: EnvKeyInput): EnvaptAccessorDecorator<number | null>;
31
+ /**
32
+ * Shorthand for `@Envapt(key, { converter: Converters.Url, fallback })`. The fallback is a `URL`
33
+ * instance, not a URL string.
34
+ * @public
35
+ */
36
+ declare function EnvUrl(key: EnvKeyInput, fallback: URL): EnvaptAccessorDecorator<URL>;
37
+ declare function EnvUrl(key: EnvKeyInput): EnvaptAccessorDecorator<URL | null>;
38
+ //#endregion
39
+ export { EnvBool, EnvNum, EnvStr, EnvTime, EnvUrl };
40
+ //# sourceMappingURL=SugarDecorators.d.mts.map
@@ -0,0 +1,2 @@
1
+ import{Converters as e}from"../../converters/Converters.mjs";import{createAccessorDecorator as t}from"./createAccessorDecorator.mjs";function n(e,n,r){return t(n,{converter:e,fallback:r,hasFallback:r!==void 0,required:!1,schema:void 0})}function r(t,r){return n(e.Boolean,t,r)}function i(t,r){return n(e.Number,t,r)}function a(t,r){return n(e.String,t,r)}function o(t,r){return n(e.Time,t,r)}function s(t,r){return n(e.Url,t,r)}export{r as EnvBool,i as EnvNum,a as EnvStr,o as EnvTime,s as EnvUrl};
2
+ //# sourceMappingURL=SugarDecorators.mjs.map
@@ -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 */\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 */\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 */\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 */\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 */\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,CAQA,SAAgB,EAAQ,EAAkB,EAA6D,CACnG,OAAO,EAAM,EAAW,QAAS,EAAK,CAAQ,CAClD,CAQA,SAAgB,EAAO,EAAkB,EAA2D,CAChG,OAAO,EAAM,EAAW,OAAQ,EAAK,CAAQ,CACjD,CAQA,SAAgB,EAAO,EAAkB,EAA2D,CAChG,OAAO,EAAM,EAAW,OAAQ,EAAK,CAAQ,CACjD,CASA,SAAgB,EAAQ,EAAkB,EAAiE,CACvG,OAAO,EAAM,EAAW,KAAM,EAAK,CAAQ,CAC/C,CASA,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{decoratorCacheKey as t,resolveDecoratorValue as n}from"../resolveDecoratorValue.mjs";function r(r,i){return function(a,o){let s=o.name;if(s===void 0)throw new e(302,`The runtime did not provide the accessor name to @Envapt, this Stage 3 decorator transform is unsupported.`);let c=String(s);return{get(){let e=this,a=typeof e==`function`;return n(r,i,t(a?e:e.constructor,a,c))},set(){throw new e(302,`Cannot assign to "${c}". @Envapt accessor properties resolve from the environment and are read-only.`)}}}}export{r as createAccessorDecorator};
2
+ //# sourceMappingURL=createAccessorDecorator.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createAccessorDecorator.mjs","names":[],"sources":["../../../../src/decorators/modern/createAccessorDecorator.ts"],"sourcesContent":["import { EnvaptError, EnvaptErrorCodes } from '../../infra/Error';\nimport { decoratorCacheKey, resolveDecoratorValue } from '../resolveDecoratorValue';\n\nimport type { EnvKeyInput } from '../../types';\nimport type { DecoratorConfig } from '../resolveDecoratorValue';\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 createAccessorDecorator<TFallback>(key: EnvKeyInput, config: DecoratorConfig<TFallback>) {\n return function <This, Value>(\n _target: ClassAccessorDecoratorTarget<This, Value>,\n context: ClassAccessorDecoratorContext<This, Value>\n ): ClassAccessorDecoratorResult<This, Value> {\n const name: string | symbol | undefined = context.name;\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition -- a broken Stage 3 transform can leave context.name unset, which would collapse every accessor to one cache key\n if (name === undefined) {\n throw new EnvaptError(\n EnvaptErrorCodes.InvalidUserDefinedConfig,\n 'The runtime did not provide the accessor name to @Envapt, this Stage 3 decorator transform is unsupported.'\n );\n }\n const propKey = String(name);\n\n return {\n get(this: This): Value {\n const self = this as object;\n // derive static-ness from `this` (the class is a function, an instance is not) rather than\n // context.static, which some transformers (oxc) leave unset, collapsing every owner to Function\n const isStatic = typeof self === 'function';\n const owner = isStatic ? self : self.constructor;\n const cacheKey = decoratorCacheKey(owner, isStatic, propKey);\n return resolveDecoratorValue(key, config, cacheKey) as Value;\n },\n set(): void {\n throw new EnvaptError(\n EnvaptErrorCodes.InvalidUserDefinedConfig,\n `Cannot assign to \"${propKey}\". @Envapt accessor properties resolve from the environment and are read-only.`\n );\n }\n };\n };\n}\n/* v8 ignore stop */\n"],"mappings":"gJAOA,SAAgB,EAAmC,EAAkB,EAAoC,CACrG,OAAO,SACH,EACA,EACyC,CACzC,IAAM,EAAoC,EAAQ,KAElD,GAAI,IAAS,IAAA,GACT,MAAM,IAAI,EAAA,IAEN,4GACJ,EAEJ,IAAM,EAAU,OAAO,CAAI,EAE3B,MAAO,CACH,KAAuB,CACnB,IAAM,EAAO,KAGP,EAAW,OAAO,GAAS,WAGjC,OAAO,EAAsB,EAAK,EADjB,EADH,EAAW,EAAO,EAAK,YACK,EAAU,CACH,CAAC,CACtD,EACA,KAAY,CACR,MAAM,IAAI,EAAA,IAEN,qBAAqB,EAAQ,+EACjC,CACJ,CACJ,CACJ,CACJ"}