@geekmidas/constructs 10.0.0-alpha.12 → 10.0.0-alpha.13

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 (317) hide show
  1. package/dist/{Construct-BD5neF7w.mjs → Construct-BeYVu_QF.mjs} +30 -28
  2. package/dist/Construct-BeYVu_QF.mjs.map +1 -0
  3. package/dist/{Construct-Ct8nalEi.d.mts → Construct-DfbwIntp.d.cts} +10 -12
  4. package/dist/Construct-DfbwIntp.d.cts.map +1 -0
  5. package/dist/{Construct-CyS3RpTL.cjs → Construct-DqdlARxq.cjs} +50 -42
  6. package/dist/{Construct-BD5neF7w.mjs.map → Construct-DqdlARxq.cjs.map} +1 -1
  7. package/dist/{Construct-C0ijr2qp.d.cts → Construct-l5aOn_jv.d.mts} +9 -11
  8. package/dist/Construct-l5aOn_jv.d.mts.map +1 -0
  9. package/dist/{Cron-DmQ8vQ4b.d.cts → Cron-DKqnnTdH.d.cts} +4 -5
  10. package/dist/Cron-DKqnnTdH.d.cts.map +1 -0
  11. package/dist/{Cron-dh4rUgib.d.mts → Cron-SyqS5oWJ.d.mts} +5 -6
  12. package/dist/Cron-SyqS5oWJ.d.mts.map +1 -0
  13. package/dist/{CronBuilder-Da0C0edR.cjs → CronBuilder-BdnI6lxF.cjs} +24 -25
  14. package/dist/CronBuilder-BdnI6lxF.cjs.map +1 -0
  15. package/dist/{CronBuilder-BquXDbDI.d.cts → CronBuilder-CRGnDfTq.d.mts} +7 -10
  16. package/dist/CronBuilder-CRGnDfTq.d.mts.map +1 -0
  17. package/dist/{CronBuilder-CYKT5RiO.mjs → CronBuilder-D_0HNBTr.mjs} +14 -15
  18. package/dist/CronBuilder-D_0HNBTr.mjs.map +1 -0
  19. package/dist/{CronBuilder-CGgY2080.d.mts → CronBuilder-Df1q9PNy.d.cts} +7 -10
  20. package/dist/CronBuilder-Df1q9PNy.d.cts.map +1 -0
  21. package/dist/{Endpoint-DCQPMdUX.mjs → Endpoint-BCiCYvx2.mjs} +79 -106
  22. package/dist/Endpoint-BCiCYvx2.mjs.map +1 -0
  23. package/dist/{Endpoint-BjWKinFA.d.mts → Endpoint-C6yyHpRS.d.cts} +14 -65
  24. package/dist/Endpoint-C6yyHpRS.d.cts.map +1 -0
  25. package/dist/{Endpoint-dav89W6-.d.cts → Endpoint-DuT4TEEq.d.mts} +14 -65
  26. package/dist/Endpoint-DuT4TEEq.d.mts.map +1 -0
  27. package/dist/{Endpoint-DcWXE-SZ.cjs → Endpoint-s0AyrQGC.cjs} +101 -128
  28. package/dist/Endpoint-s0AyrQGC.cjs.map +1 -0
  29. package/dist/{EndpointFactory-CdWB7wPw.cjs → EndpointFactory-M8OQKZRY.cjs} +57 -66
  30. package/dist/EndpointFactory-M8OQKZRY.cjs.map +1 -0
  31. package/dist/{EndpointFactory-CjV8F_lJ.mjs → EndpointFactory-ptPR1cXw.mjs} +20 -29
  32. package/dist/EndpointFactory-ptPR1cXw.mjs.map +1 -0
  33. package/dist/{HonoEndpointAdaptor-DtL9j19R.cjs → HonoEndpointAdaptor-7QagYKdP.cjs} +48 -52
  34. package/dist/HonoEndpointAdaptor-7QagYKdP.cjs.map +1 -0
  35. package/dist/{HonoEndpointAdaptor-P1ahhZHu.mjs → HonoEndpointAdaptor-CYHA0WAt.mjs} +40 -47
  36. package/dist/{HonoEndpointAdaptor-DtL9j19R.cjs.map → HonoEndpointAdaptor-CYHA0WAt.mjs.map} +1 -1
  37. package/dist/{Queue-D7ZuwBhy.d.cts → Queue-D9X6OoON.d.mts} +10 -11
  38. package/dist/Queue-D9X6OoON.d.mts.map +1 -0
  39. package/dist/{Queue-gVGfi2Yk.d.mts → Queue-DYPB2KWL.d.cts} +10 -11
  40. package/dist/Queue-DYPB2KWL.d.cts.map +1 -0
  41. package/dist/{Subscriber-2mEi0ImH.d.cts → Subscriber-C4heaAyO.d.mts} +7 -8
  42. package/dist/Subscriber-C4heaAyO.d.mts.map +1 -0
  43. package/dist/{Subscriber-xTJ9ayPN.d.mts → Subscriber-CotDUELC.d.cts} +7 -8
  44. package/dist/Subscriber-CotDUELC.d.cts.map +1 -0
  45. package/dist/{SubscriberBuilder-Dptmo-1A.d.mts → SubscriberBuilder-BEv0eoHy.d.cts} +8 -11
  46. package/dist/SubscriberBuilder-BEv0eoHy.d.cts.map +1 -0
  47. package/dist/{SubscriberBuilder-4OPehf2R.cjs → SubscriberBuilder-C0ZEtGDI.cjs} +28 -23
  48. package/dist/SubscriberBuilder-C0ZEtGDI.cjs.map +1 -0
  49. package/dist/{SubscriberBuilder-BjkbeT9l.mjs → SubscriberBuilder-h7B_cHMr.mjs} +16 -10
  50. package/dist/SubscriberBuilder-h7B_cHMr.mjs.map +1 -0
  51. package/dist/{SubscriberBuilder-waNhzjSM.d.cts → SubscriberBuilder-tyH5yTk5.d.mts} +8 -11
  52. package/dist/SubscriberBuilder-tyH5yTk5.d.mts.map +1 -0
  53. package/dist/{Topic-19QeHBIR.d.cts → Topic-DEVGo0Dm.d.cts} +5 -7
  54. package/dist/Topic-DEVGo0Dm.d.cts.map +1 -0
  55. package/dist/{Topic-DuFeqkBh.d.mts → Topic-zk_6Gthr.d.mts} +6 -8
  56. package/dist/Topic-zk_6Gthr.d.mts.map +1 -0
  57. package/dist/adaptors/aws.cjs +87 -106
  58. package/dist/adaptors/aws.cjs.map +1 -1
  59. package/dist/adaptors/aws.d.cts +14 -27
  60. package/dist/adaptors/aws.d.cts.map +1 -1
  61. package/dist/adaptors/aws.d.mts +16 -29
  62. package/dist/adaptors/aws.d.mts.map +1 -1
  63. package/dist/adaptors/aws.mjs +60 -81
  64. package/dist/adaptors/aws.mjs.map +1 -1
  65. package/dist/adaptors/hono.cjs +3 -10
  66. package/dist/adaptors/hono.d.cts +5 -13
  67. package/dist/adaptors/hono.d.cts.map +1 -1
  68. package/dist/adaptors/hono.d.mts +7 -15
  69. package/dist/adaptors/hono.d.mts.map +1 -1
  70. package/dist/adaptors/hono.mjs +2 -10
  71. package/dist/adaptors/testing.cjs +60 -73
  72. package/dist/adaptors/testing.cjs.map +1 -1
  73. package/dist/adaptors/testing.d.cts +17 -28
  74. package/dist/adaptors/testing.d.cts.map +1 -1
  75. package/dist/adaptors/testing.d.mts +18 -29
  76. package/dist/adaptors/testing.d.mts.map +1 -1
  77. package/dist/adaptors/testing.mjs +42 -55
  78. package/dist/adaptors/testing.mjs.map +1 -1
  79. package/dist/auth.cjs +39 -14
  80. package/dist/auth.cjs.map +1 -1
  81. package/dist/auth.d.cts +5 -9
  82. package/dist/auth.d.cts.map +1 -1
  83. package/dist/auth.d.mts +5 -9
  84. package/dist/auth.d.mts.map +1 -1
  85. package/dist/auth.mjs +30 -5
  86. package/dist/auth.mjs.map +1 -1
  87. package/dist/cache.cjs +68 -2
  88. package/dist/cache.cjs.map +1 -0
  89. package/dist/cache.d.cts +43 -3
  90. package/dist/cache.d.cts.map +1 -0
  91. package/dist/cache.d.mts +43 -3
  92. package/dist/cache.d.mts.map +1 -0
  93. package/dist/cache.mjs +67 -2
  94. package/dist/cache.mjs.map +1 -0
  95. package/dist/{clone-DblgEZZa.mjs → clone-EKNovYHu.mjs} +3 -3
  96. package/dist/clone-EKNovYHu.mjs.map +1 -0
  97. package/dist/{clone-Dy0cR2SZ.cjs → clone-UGJpvQnL.cjs} +7 -8
  98. package/dist/clone-UGJpvQnL.cjs.map +1 -0
  99. package/dist/{construct-interface-g5GM5pwR.d.mts → construct-interface-DPlxfpoS.d.mts} +3 -6
  100. package/dist/construct-interface-DPlxfpoS.d.mts.map +1 -0
  101. package/dist/{construct-interface-D9d4Gm4p.d.cts → construct-interface-DgXTJcOD.d.cts} +3 -6
  102. package/dist/construct-interface-DgXTJcOD.d.cts.map +1 -0
  103. package/dist/construct-interface.cjs +87 -7
  104. package/dist/construct-interface.cjs.map +1 -0
  105. package/dist/construct-interface.d.cts +1 -1
  106. package/dist/construct-interface.d.mts +1 -1
  107. package/dist/construct-interface.mjs +81 -2
  108. package/dist/construct-interface.mjs.map +1 -0
  109. package/dist/credential.cjs +43 -9
  110. package/dist/credential.cjs.map +1 -1
  111. package/dist/credential.d.cts +5 -8
  112. package/dist/credential.d.cts.map +1 -1
  113. package/dist/credential.d.mts +5 -8
  114. package/dist/credential.d.mts.map +1 -1
  115. package/dist/credential.mjs +36 -2
  116. package/dist/credential.mjs.map +1 -1
  117. package/dist/crons/index.cjs +4 -7
  118. package/dist/crons/index.cjs.map +1 -1
  119. package/dist/crons/index.d.cts +5 -11
  120. package/dist/crons/index.d.cts.map +1 -1
  121. package/dist/crons/index.d.mts +5 -11
  122. package/dist/crons/index.d.mts.map +1 -1
  123. package/dist/crons/index.mjs +3 -7
  124. package/dist/crons/index.mjs.map +1 -1
  125. package/dist/database/kysely.cjs +28 -14
  126. package/dist/database/kysely.cjs.map +1 -1
  127. package/dist/database/kysely.d.cts +5 -8
  128. package/dist/database/kysely.d.cts.map +1 -1
  129. package/dist/database/kysely.d.mts +6 -9
  130. package/dist/database/kysely.d.mts.map +1 -1
  131. package/dist/database/kysely.mjs +16 -4
  132. package/dist/database/kysely.mjs.map +1 -1
  133. package/dist/email.cjs +25 -12
  134. package/dist/email.cjs.map +1 -1
  135. package/dist/email.d.cts +3 -7
  136. package/dist/email.d.cts.map +1 -1
  137. package/dist/email.d.mts +3 -7
  138. package/dist/email.d.mts.map +1 -1
  139. package/dist/email.mjs +16 -3
  140. package/dist/email.mjs.map +1 -1
  141. package/dist/endpoints/index.cjs +6 -10
  142. package/dist/endpoints/index.d.cts +3 -7
  143. package/dist/endpoints/index.d.mts +3 -7
  144. package/dist/endpoints/index.mjs +5 -10
  145. package/dist/file-server.cjs +42 -10
  146. package/dist/file-server.cjs.map +1 -1
  147. package/dist/file-server.d.cts +6 -10
  148. package/dist/file-server.d.cts.map +1 -1
  149. package/dist/file-server.d.mts +6 -10
  150. package/dist/file-server.d.mts.map +1 -1
  151. package/dist/file-server.mjs +34 -2
  152. package/dist/file-server.mjs.map +1 -1
  153. package/dist/functions/index.cjs +3 -6
  154. package/dist/functions/index.d.cts +2 -4
  155. package/dist/functions/index.d.mts +2 -4
  156. package/dist/functions/index.mjs +2 -6
  157. package/dist/{functions-i_la-N5r.cjs → functions-B6qCvfmy.cjs} +298 -252
  158. package/dist/functions-B6qCvfmy.cjs.map +1 -0
  159. package/dist/{functions-14lpEFL4.mjs → functions-C53GW2eQ.mjs} +272 -229
  160. package/dist/functions-C53GW2eQ.mjs.map +1 -0
  161. package/dist/{index-BknhM6Ux.d.mts → index-B2urf3YI.d.cts} +4 -9
  162. package/dist/index-B2urf3YI.d.cts.map +1 -0
  163. package/dist/{index-Bd5FqCoe.d.cts → index-BPSZ_Lp_.d.cts} +9 -38
  164. package/dist/index-BPSZ_Lp_.d.cts.map +1 -0
  165. package/dist/{index-lAO9egTb.d.mts → index-BoZ-iisU.d.mts} +12 -41
  166. package/dist/index-BoZ-iisU.d.mts.map +1 -0
  167. package/dist/{index-_ajboYxK.d.mts → index-CdaU--_B.d.cts} +10 -16
  168. package/dist/index-CdaU--_B.d.cts.map +1 -0
  169. package/dist/index-CeEtxDmK.d.cts +79 -0
  170. package/dist/index-CeEtxDmK.d.cts.map +1 -0
  171. package/dist/index-CeEtxDmK.d.mts +79 -0
  172. package/dist/index-CeEtxDmK.d.mts.map +1 -0
  173. package/dist/{index-CBSfrowv.d.cts → index-DMCDvnsM.d.mts} +4 -9
  174. package/dist/index-DMCDvnsM.d.mts.map +1 -0
  175. package/dist/{index-D24Xm79M.d.cts → index-PQRWOQj4.d.mts} +10 -16
  176. package/dist/index-PQRWOQj4.d.mts.map +1 -0
  177. package/dist/index.cjs +3 -3
  178. package/dist/index.d.cts +4 -4
  179. package/dist/index.d.mts +4 -4
  180. package/dist/index.mjs +2 -3
  181. package/dist/{lazyAccessors-BoJN3SMd.mjs → lazyAccessors-BHtcqgz2.mjs} +22 -25
  182. package/dist/lazyAccessors-BHtcqgz2.mjs.map +1 -0
  183. package/dist/{lazyAccessors-e3j2oE2m.cjs → lazyAccessors-Dx9NLwJZ.cjs} +72 -76
  184. package/dist/lazyAccessors-Dx9NLwJZ.cjs.map +1 -0
  185. package/dist/object-storage.cjs +18 -10
  186. package/dist/object-storage.cjs.map +1 -1
  187. package/dist/object-storage.d.cts +3 -7
  188. package/dist/object-storage.d.cts.map +1 -1
  189. package/dist/object-storage.d.mts +3 -7
  190. package/dist/object-storage.d.mts.map +1 -1
  191. package/dist/object-storage.mjs +11 -3
  192. package/dist/object-storage.mjs.map +1 -1
  193. package/dist/{processAudits-Dmts9H_b.mjs → processAudits-BpRlPQMW.mjs} +16 -19
  194. package/dist/processAudits-BpRlPQMW.mjs.map +1 -0
  195. package/dist/{processAudits-CGqttuXm.cjs → processAudits-D_2W5x8k.cjs} +26 -30
  196. package/dist/processAudits-D_2W5x8k.cjs.map +1 -0
  197. package/dist/queue/index.cjs +25 -21
  198. package/dist/queue/index.cjs.map +1 -1
  199. package/dist/queue/index.d.cts +8 -15
  200. package/dist/queue/index.d.cts.map +1 -1
  201. package/dist/queue/index.d.mts +8 -15
  202. package/dist/queue/index.d.mts.map +1 -1
  203. package/dist/queue/index.mjs +15 -11
  204. package/dist/queue/index.mjs.map +1 -1
  205. package/dist/rest-api.cjs +15 -17
  206. package/dist/rest-api.cjs.map +1 -1
  207. package/dist/rest-api.d.cts +15 -20
  208. package/dist/rest-api.d.cts.map +1 -1
  209. package/dist/rest-api.d.mts +9 -14
  210. package/dist/rest-api.d.mts.map +1 -1
  211. package/dist/rest-api.mjs +7 -9
  212. package/dist/rest-api.mjs.map +1 -1
  213. package/dist/{chunk-DWy1uDak.cjs → rolldown-runtime-y5ARvAq5.cjs} +14 -18
  214. package/dist/site.cjs +31 -7
  215. package/dist/site.cjs.map +1 -1
  216. package/dist/site.d.cts +3 -7
  217. package/dist/site.d.cts.map +1 -1
  218. package/dist/site.d.mts +3 -7
  219. package/dist/site.d.mts.map +1 -1
  220. package/dist/site.mjs +27 -3
  221. package/dist/site.mjs.map +1 -1
  222. package/dist/subscribers/index.cjs +3 -6
  223. package/dist/subscribers/index.d.cts +2 -5
  224. package/dist/subscribers/index.d.mts +2 -5
  225. package/dist/subscribers/index.mjs +2 -6
  226. package/dist/surfaceEnv-CNimK76p.cjs +56 -0
  227. package/dist/surfaceEnv-CNimK76p.cjs.map +1 -0
  228. package/dist/surfaceEnv-wMT5QzgZ.mjs +45 -0
  229. package/dist/surfaceEnv-wMT5QzgZ.mjs.map +1 -0
  230. package/dist/{telemetry-C3L0iS28.d.cts → telemetry-DGcFlVpB.d.cts} +2 -5
  231. package/dist/telemetry-DGcFlVpB.d.cts.map +1 -0
  232. package/dist/{telemetry-D7bVFLGi.d.mts → telemetry-DGcFlVpB.d.mts} +2 -5
  233. package/dist/telemetry-DGcFlVpB.d.mts.map +1 -0
  234. package/dist/topic/index.cjs +18 -20
  235. package/dist/topic/index.cjs.map +1 -1
  236. package/dist/topic/index.d.cts +3 -4
  237. package/dist/topic/index.d.mts +3 -4
  238. package/dist/topic/index.mjs +8 -10
  239. package/dist/topic/index.mjs.map +1 -1
  240. package/dist/{types-BlAkSuGI.d.cts → types-DMuSQeLL.d.cts} +3 -5
  241. package/dist/types-DMuSQeLL.d.cts.map +1 -0
  242. package/dist/{types-aKksMEWL.d.mts → types-DMuSQeLL.d.mts} +3 -5
  243. package/dist/types-DMuSQeLL.d.mts.map +1 -0
  244. package/dist/types.d.cts +1 -1
  245. package/dist/types.d.mts +1 -1
  246. package/dist/types.mjs +1 -0
  247. package/dist/worker.cjs +13 -14
  248. package/dist/worker.cjs.map +1 -1
  249. package/dist/worker.d.cts +21 -27
  250. package/dist/worker.d.cts.map +1 -1
  251. package/dist/worker.d.mts +14 -19
  252. package/dist/worker.d.mts.map +1 -1
  253. package/dist/worker.mjs +8 -9
  254. package/dist/worker.mjs.map +1 -1
  255. package/package.json +30 -30
  256. package/dist/Construct-C0ijr2qp.d.cts.map +0 -1
  257. package/dist/Construct-Ct8nalEi.d.mts.map +0 -1
  258. package/dist/Construct-CyS3RpTL.cjs.map +0 -1
  259. package/dist/Cron-DmQ8vQ4b.d.cts.map +0 -1
  260. package/dist/Cron-dh4rUgib.d.mts.map +0 -1
  261. package/dist/CronBuilder-BquXDbDI.d.cts.map +0 -1
  262. package/dist/CronBuilder-CGgY2080.d.mts.map +0 -1
  263. package/dist/CronBuilder-CYKT5RiO.mjs.map +0 -1
  264. package/dist/CronBuilder-Da0C0edR.cjs.map +0 -1
  265. package/dist/Endpoint-BjWKinFA.d.mts.map +0 -1
  266. package/dist/Endpoint-DCQPMdUX.mjs.map +0 -1
  267. package/dist/Endpoint-DcWXE-SZ.cjs.map +0 -1
  268. package/dist/Endpoint-dav89W6-.d.cts.map +0 -1
  269. package/dist/EndpointFactory-CdWB7wPw.cjs.map +0 -1
  270. package/dist/EndpointFactory-CjV8F_lJ.mjs.map +0 -1
  271. package/dist/HonoEndpointAdaptor-P1ahhZHu.mjs.map +0 -1
  272. package/dist/Queue-D7ZuwBhy.d.cts.map +0 -1
  273. package/dist/Queue-gVGfi2Yk.d.mts.map +0 -1
  274. package/dist/Subscriber-2mEi0ImH.d.cts.map +0 -1
  275. package/dist/Subscriber-xTJ9ayPN.d.mts.map +0 -1
  276. package/dist/SubscriberBuilder-4OPehf2R.cjs.map +0 -1
  277. package/dist/SubscriberBuilder-BjkbeT9l.mjs.map +0 -1
  278. package/dist/SubscriberBuilder-Dptmo-1A.d.mts.map +0 -1
  279. package/dist/SubscriberBuilder-waNhzjSM.d.cts.map +0 -1
  280. package/dist/Topic-19QeHBIR.d.cts.map +0 -1
  281. package/dist/Topic-DuFeqkBh.d.mts.map +0 -1
  282. package/dist/cache-0ANvRQnD.mjs +0 -51
  283. package/dist/cache-0ANvRQnD.mjs.map +0 -1
  284. package/dist/cache-3WSvAulx.cjs +0 -57
  285. package/dist/cache-3WSvAulx.cjs.map +0 -1
  286. package/dist/cache-BrRz3fEB.d.mts +0 -47
  287. package/dist/cache-BrRz3fEB.d.mts.map +0 -1
  288. package/dist/cache-BtZY_tHe.d.cts +0 -47
  289. package/dist/cache-BtZY_tHe.d.cts.map +0 -1
  290. package/dist/clone-DblgEZZa.mjs.map +0 -1
  291. package/dist/clone-Dy0cR2SZ.cjs.map +0 -1
  292. package/dist/construct-interface-BfjcOD_E.cjs +0 -117
  293. package/dist/construct-interface-BfjcOD_E.cjs.map +0 -1
  294. package/dist/construct-interface-D9d4Gm4p.d.cts.map +0 -1
  295. package/dist/construct-interface-Z4CpS8tK.mjs +0 -81
  296. package/dist/construct-interface-Z4CpS8tK.mjs.map +0 -1
  297. package/dist/construct-interface-g5GM5pwR.d.mts.map +0 -1
  298. package/dist/functions-14lpEFL4.mjs.map +0 -1
  299. package/dist/functions-i_la-N5r.cjs.map +0 -1
  300. package/dist/index-Bd5FqCoe.d.cts.map +0 -1
  301. package/dist/index-BknhM6Ux.d.mts.map +0 -1
  302. package/dist/index-CBSfrowv.d.cts.map +0 -1
  303. package/dist/index-D24Xm79M.d.cts.map +0 -1
  304. package/dist/index-_ajboYxK.d.mts.map +0 -1
  305. package/dist/index-lAO9egTb.d.mts.map +0 -1
  306. package/dist/lazyAccessors-BoJN3SMd.mjs.map +0 -1
  307. package/dist/lazyAccessors-e3j2oE2m.cjs.map +0 -1
  308. package/dist/processAudits-CGqttuXm.cjs.map +0 -1
  309. package/dist/processAudits-Dmts9H_b.mjs.map +0 -1
  310. package/dist/surfaceEnv-BFXEms2f.cjs +0 -39
  311. package/dist/surfaceEnv-BFXEms2f.cjs.map +0 -1
  312. package/dist/surfaceEnv-C3Ktahea.mjs +0 -27
  313. package/dist/surfaceEnv-C3Ktahea.mjs.map +0 -1
  314. package/dist/telemetry-C3L0iS28.d.cts.map +0 -1
  315. package/dist/telemetry-D7bVFLGi.d.mts.map +0 -1
  316. package/dist/types-BlAkSuGI.d.cts.map +0 -1
  317. package/dist/types-aKksMEWL.d.mts.map +0 -1
@@ -1,3 +1,82 @@
1
- import { NotAConstruct, edgeTo, idsOf, isConsumable, serviceOf, servicesOf } from "./construct-interface-Z4CpS8tK.mjs";
1
+ //#region src/construct-interface.ts
2
+ /**
3
+ * The edge that points at a construct.
4
+ *
5
+ * A construct's *canonical* node is the one carrying its own id — the others are
6
+ * things it owns rather than things it is, like the signing secret beside an
7
+ * auth server — so the kind an edge records is read off that node instead of
8
+ * being written down beside it. Hand-written kinds are the same fact stated
9
+ * twice, and the copy is what goes stale when a construct changes what it
10
+ * declares.
11
+ *
12
+ * @throws {NotAConstruct} when the value declares nothing under its own id.
13
+ */
14
+ function edgeTo(construct) {
15
+ const canonical = construct.declare().find((declaration) => declaration.id === construct.id);
16
+ if (!canonical) throw new NotAConstruct(construct);
17
+ return {
18
+ target: construct.id,
19
+ kind: canonical.kind
20
+ };
21
+ }
22
+ /**
23
+ * The services of a list of constructs, at runtime.
24
+ *
25
+ * @throws {NotAConstruct} when handed something else. The type already refuses
26
+ * it, but a JavaScript caller gets no such warning, and a `Service` slipping
27
+ * through would fail later as an undefined key in the handler.
28
+ */
29
+ function servicesOf(constructs) {
30
+ return constructs.map((construct) => {
31
+ if (!isConsumable(construct)) throw new NotAConstruct(construct);
32
+ return construct.service;
33
+ });
34
+ }
35
+ /**
36
+ * The other half of `servicesOf`: the same edge, as the manifest records it.
37
+ *
38
+ * `.dependsOn()` used to keep only the services, which is what a handler runs
39
+ * with — and an id cannot be recovered from a service name reliably, so the
40
+ * edges were gone by the time the build could read them. Both halves are taken
41
+ * from one call now, and `existing` is folded in so repeated `.dependsOn()`
42
+ * calls accumulate the way `.services()` already does.
43
+ */
44
+ function idsOf(constructs, existing = []) {
45
+ return [.../* @__PURE__ */ new Set([...existing, ...constructs.map(({ id }) => id)])];
46
+ }
47
+ /** Something that is not a construct was passed to `.dependsOn()`. */
48
+ var NotAConstruct = class extends Error {
49
+ value;
50
+ constructor(value) {
51
+ const name = typeof value === "object" && value !== null && "serviceName" in value ? `the service '${String(value.serviceName)}'` : `a ${typeof value}`;
52
+ super(`.dependsOn() takes constructs, and was given ${name}. Pass it to .services([…]) instead, or lift it with Construct.fromService().`);
53
+ this.value = value;
54
+ this.name = "NotAConstruct";
55
+ }
56
+ };
57
+ /**
58
+ * Whether a value is a construct rather than a bare `Service`.
59
+ *
60
+ * Structural rather than `instanceof`: a construct from a second copy of
61
+ * `@geekmidas/constructs` — a linked workspace, two versions in a lockfile — is
62
+ * still a construct, and `instanceof` is exactly the check that says otherwise.
63
+ */
64
+ function isConsumable(value) {
65
+ if (typeof value !== "object" || value === null) return false;
66
+ const candidate = value;
67
+ return typeof candidate.id === "string" && typeof candidate.declare === "function" && typeof candidate.service?.serviceName === "string";
68
+ }
69
+ /**
70
+ * The service behind either face.
71
+ *
72
+ * `.database()` and the publisher slots take a construct now; they took a
73
+ * `Service` before and still do, because a hand-written one is exactly what
74
+ * `Construct.fromService` exists to lift and not everything has been lifted.
75
+ */
76
+ function serviceOf(source) {
77
+ return isConsumable(source) ? source.service : source;
78
+ }
79
+ //#endregion
80
+ export { NotAConstruct, edgeTo, idsOf, isConsumable, serviceOf, servicesOf };
2
81
 
3
- export { NotAConstruct, edgeTo, idsOf, isConsumable, serviceOf, servicesOf };
82
+ //# sourceMappingURL=construct-interface.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"construct-interface.mjs","names":[],"sources":["../src/construct-interface.ts"],"sourcesContent":["/**\n * The construct contract.\n *\n * A construct is three things at once — an infrastructure requirement at build\n * time, a runtime capability, and something other code can consume — which is\n * what forces exactly these three members.\n *\n * An **interface**, not a base class: `Endpoint`, `Cron`, `Queue`, and `Topic`\n * can satisfy it without inheritance surgery, a lifted `Service` can satisfy it\n * as a plain object, and `.dependsOn()` gets its enforcement structurally — a\n * `Service` (`{ serviceName, register }`) simply does not match\n * `{ id, declare, service }`, with no `instanceof` anywhere.\n *\n * Lives in its own module while the existing abstract `Construct` class is\n * still in use; it takes that name once the class is gone.\n */\n\nimport type { Declaration, Dependency } from '@geekmidas/manifest';\nimport type { Service } from '@geekmidas/services';\n\n/**\n * @typeParam TName - the construct's canonical id, PascalCase. Keeping it a\n * literal is what lets the service key be `Uncapitalize<TName>` — a TypeScript\n * intrinsic, so no custom transform needs a runtime twin.\n * @typeParam TClient - what consuming this construct hands you. `never` means it\n * owns no address and cannot be consumed: a `Cron` is fired by a schedule and a\n * `Subscriber` is reached through its topic, so `.dependsOn()` on either is a\n * compile error rather than a stub that throws.\n */\nexport interface Construct<TName extends string = string, TClient = never> {\n\t/** Canonical, PascalCase, unique within the manifest. */\n\treadonly id: TName;\n\n\t/**\n\t * The build-time face: what this construct contributes to the manifest.\n\t *\n\t * Returns an array because some constructs contribute more than one node — a\n\t * queue declares the queue and its worker, a database declares its migrator\n\t * and seeder. Most return one.\n\t */\n\tdeclare(): Declaration[];\n\n\t/**\n\t * The consumable face — the address this construct owns, as a client.\n\t *\n\t * A field assigned once rather than a getter. `Construct.getEnvironment`\n\t * caches by service *object*, and `Topic.publisher` returns a fresh literal\n\t * on every access, so that cache never hits for topics or queues today.\n\t */\n\treadonly service: [TClient] extends [never]\n\t\t? never\n\t\t: Service<Uncapitalize<TName>, TClient>;\n}\n\n/**\n * The build-time face alone — an id and what it contributes to the manifest.\n *\n * Weaker than {@link Consumable} on purpose. An edge is not always an\n * injection: a site depending on an API needs that API's *address at build\n * time* and has no service record to put a client into, so requiring one would\n * make the weakest kind of edge impossible to express with the strongest\n * interface. Discovery asks this same question and nothing more.\n */\nexport interface Declarable<TName extends string = string> {\n\treadonly id: TName;\n\tdeclare(): Declaration[];\n}\n\n/**\n * The edge that points at a construct.\n *\n * A construct's *canonical* node is the one carrying its own id — the others are\n * things it owns rather than things it is, like the signing secret beside an\n * auth server — so the kind an edge records is read off that node instead of\n * being written down beside it. Hand-written kinds are the same fact stated\n * twice, and the copy is what goes stale when a construct changes what it\n * declares.\n *\n * @throws {NotAConstruct} when the value declares nothing under its own id.\n */\nexport function edgeTo(construct: Declarable): Dependency {\n\tconst canonical = construct\n\t\t.declare()\n\t\t.find((declaration) => declaration.id === construct.id);\n\n\tif (!canonical) throw new NotAConstruct(construct);\n\n\treturn { target: construct.id, kind: canonical.kind };\n}\n\n/** What consuming a construct hands you. */\nexport type Infer<C> =\n\tC extends Construct<string, infer TClient> ? TClient : never;\n\n/** A construct's canonical id. */\nexport type NameOf<C> =\n\tC extends Construct<infer TName, unknown> ? TName : never;\n\n/**\n * What `.dependsOn([…])` accepts: a construct that owns a client.\n *\n * Structural, and deliberately narrower than {@link Construct} — it is the\n * face a *consumer* needs, so the builders can accept a database, a bucket, a\n * mail sender, a queue, or a topic without importing any of them. A plain\n * `Service` is not one of these, which is the point: constructs-only confines\n * env sniffing to `.services()` and the explicit lift, so retiring that method\n * retires implicit inference with it.\n */\nexport interface Consumable<TName extends string = string, TClient = unknown> {\n\treadonly id: TName;\n\treadonly service: Service<Uncapitalize<TName>, TClient>;\n\tdeclare(): Declaration[];\n}\n\n/**\n * The services a list of constructs dissolves into.\n *\n * A mapped tuple, so `[db, uploads]` types as `[Service<'orders', Kysely<DB>>,\n * Service<'uploads', StorageClient>]` and the handler's service record gains\n * both keys — the same machinery `.services()` already uses, which is why\n * `dependsOn` needs no type plumbing of its own.\n */\nexport type ServicesOf<T extends readonly Consumable[]> = {\n\t[K in keyof T]: T[K]['service'];\n};\n\n/**\n * The services of a list of constructs, at runtime.\n *\n * @throws {NotAConstruct} when handed something else. The type already refuses\n * it, but a JavaScript caller gets no such warning, and a `Service` slipping\n * through would fail later as an undefined key in the handler.\n */\nexport function servicesOf<const T extends readonly Consumable[]>(\n\tconstructs: T,\n): ServicesOf<T> {\n\treturn constructs.map((construct) => {\n\t\tif (!isConsumable(construct)) throw new NotAConstruct(construct);\n\n\t\treturn construct.service;\n\t}) as ServicesOf<T>;\n}\n\n/**\n * The other half of `servicesOf`: the same edge, as the manifest records it.\n *\n * `.dependsOn()` used to keep only the services, which is what a handler runs\n * with — and an id cannot be recovered from a service name reliably, so the\n * edges were gone by the time the build could read them. Both halves are taken\n * from one call now, and `existing` is folded in so repeated `.dependsOn()`\n * calls accumulate the way `.services()` already does.\n */\nexport function idsOf(\n\tconstructs: readonly Consumable[],\n\texisting: readonly string[] = [],\n): string[] {\n\treturn [...new Set([...existing, ...constructs.map(({ id }) => id)])];\n}\n\n/** Something that is not a construct was passed to `.dependsOn()`. */\nexport class NotAConstruct extends Error {\n\tconstructor(readonly value: unknown) {\n\t\tconst name =\n\t\t\ttypeof value === 'object' && value !== null && 'serviceName' in value\n\t\t\t\t? `the service '${String((value as { serviceName: unknown }).serviceName)}'`\n\t\t\t\t: `a ${typeof value}`;\n\n\t\tsuper(\n\t\t\t`.dependsOn() takes constructs, and was given ${name}. ` +\n\t\t\t\t`Pass it to .services([…]) instead, or lift it with ` +\n\t\t\t\t`Construct.fromService().`,\n\t\t);\n\t\tthis.name = 'NotAConstruct';\n\t}\n}\n\n/**\n * Whether a value is a construct rather than a bare `Service`.\n *\n * Structural rather than `instanceof`: a construct from a second copy of\n * `@geekmidas/constructs` — a linked workspace, two versions in a lockfile — is\n * still a construct, and `instanceof` is exactly the check that says otherwise.\n */\nexport function isConsumable(value: unknown): value is Consumable {\n\tif (typeof value !== 'object' || value === null) return false;\n\n\tconst candidate = value as Partial<Consumable>;\n\n\treturn (\n\t\ttypeof candidate.id === 'string' &&\n\t\ttypeof candidate.declare === 'function' &&\n\t\ttypeof (candidate.service as Service | undefined)?.serviceName === 'string'\n\t);\n}\n\n/**\n * The service behind either face.\n *\n * `.database()` and the publisher slots take a construct now; they took a\n * `Service` before and still do, because a hand-written one is exactly what\n * `Construct.fromService` exists to lift and not everything has been lifted.\n */\nexport function serviceOf<TName extends string, TClient>(\n\tsource: Consumable<TName, TClient> | Service<TName, TClient>,\n): Service<TName, TClient> {\n\t// A construct's service key is `Uncapitalize<TName>` and the slot is typed\n\t// by `TName`; the two describe the same key, and only the cast says so.\n\treturn isConsumable(source)\n\t\t? (source.service as unknown as Service<TName, TClient>)\n\t\t: (source as Service<TName, TClient>);\n}\n"],"mappings":";;;;;;;;;;;;;AAgFA,SAAgB,OAAO,WAAmC;CACzD,MAAM,YAAY,UAChB,QAAQ,CAAC,CACT,MAAM,gBAAgB,YAAY,OAAO,UAAU,EAAE;CAEvD,IAAI,CAAC,WAAW,MAAM,IAAI,cAAc,SAAS;CAEjD,OAAO;EAAE,QAAQ,UAAU;EAAI,MAAM,UAAU;CAAK;AACrD;;;;;;;;AA6CA,SAAgB,WACf,YACgB;CAChB,OAAO,WAAW,KAAK,cAAc;EACpC,IAAI,CAAC,aAAa,SAAS,GAAG,MAAM,IAAI,cAAc,SAAS;EAE/D,OAAO,UAAU;CAClB,CAAC;AACF;;;;;;;;;;AAWA,SAAgB,MACf,YACA,WAA8B,CAAC,GACpB;CACX,OAAO,CAAC,mBAAG,IAAI,IAAI,CAAC,GAAG,UAAU,GAAG,WAAW,KAAK,EAAE,SAAS,EAAE,CAAC,CAAC,CAAC;AACrE;;AAGA,IAAa,gBAAb,cAAmC,MAAM;CACnB;CAArB,YAAY,OAAyB;EACpC,MAAM,OACL,OAAO,UAAU,YAAY,UAAU,QAAQ,iBAAiB,QAC7D,gBAAgB,OAAQ,MAAmC,WAAW,EAAE,KACxE,KAAK,OAAO;EAEhB,MACC,gDAAgD,KAAK,8EAGtD;EAVoB,KAAA,QAAA;EAWpB,KAAK,OAAO;CACb;AACD;;;;;;;;AASA,SAAgB,aAAa,OAAqC;CACjE,IAAI,OAAO,UAAU,YAAY,UAAU,MAAM,OAAO;CAExD,MAAM,YAAY;CAElB,OACC,OAAO,UAAU,OAAO,YACxB,OAAO,UAAU,YAAY,cAC7B,OAAQ,UAAU,SAAiC,gBAAgB;AAErE;;;;;;;;AASA,SAAgB,UACf,QAC0B;CAG1B,OAAO,aAAa,MAAM,IACtB,OAAO,UACP;AACL"}
@@ -1,9 +1,40 @@
1
- const require_chunk = require('./chunk-DWy1uDak.cjs');
2
- const __geekmidas_manifest = require_chunk.__toESM(require("@geekmidas/manifest"));
3
- const __geekmidas_schema_parser = require_chunk.__toESM(require("@geekmidas/schema/parser"));
4
-
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ let _geekmidas_manifest = require("@geekmidas/manifest");
3
+ let _geekmidas_schema_parser = require("@geekmidas/schema/parser");
5
4
  //#region src/credential.ts
5
+ /**
6
+ * `Credential` — a third-party credential with a shape.
7
+ *
8
+ * The answer to the design's first open question, "where does `Secret` sit?".
9
+ * It sits beside a secret rather than replacing it, because the two differ by
10
+ * *lifecycle* and that is the only difference worth two kinds for: a secret is
11
+ * generated and rotated by the platform and is one opaque string, while a
12
+ * credential is issued by someone else, arrives with several fields, and is
13
+ * worth validating on the way in.
14
+ *
15
+ * ```ts
16
+ * export const stripe = new Credential('Stripe', {
17
+ * schema: z.object({ secretKey: z.string(), webhookSecret: z.string() }),
18
+ * });
19
+ *
20
+ * // in a handler — no await, already parsed and validated
21
+ * services.stripe.secretKey
22
+ * ```
23
+ *
24
+ * **Nothing about it is async at the call site**, which is the part that looks
25
+ * like it should be hard and is not. `Service.register()` may return a promise
26
+ * and `ServiceDiscovery` awaits every one before a handler runs, so fetching a
27
+ * value and validating it — including when a StandardSchema's `~standard.validate`
28
+ * returns a promise of its own — both happen inside that existing seam.
29
+ *
30
+ * **One key holding JSON, not one key per field.** That is the shape a secret
31
+ * manager stores, and it is the only shape that works with an arbitrary
32
+ * StandardSchema: the spec has no introspection API, so enumerating a schema's
33
+ * fields means reaching into one library's internals (`.shape`) and being wrong
34
+ * for every other.
35
+ */
6
36
  var Credential = class {
37
+ options;
7
38
  id;
8
39
  service;
9
40
  /**
@@ -21,11 +52,11 @@ var Credential = class {
21
52
  resolved;
22
53
  constructor(id, options) {
23
54
  this.options = options;
24
- const canonical = (0, __geekmidas_manifest.canonicalId)(id);
55
+ const canonical = (0, _geekmidas_manifest.canonicalId)(id);
25
56
  this.id = canonical;
26
- this.keys = { credential: (0, __geekmidas_manifest.provideKey)(canonical, "credential") };
57
+ this.keys = { credential: (0, _geekmidas_manifest.provideKey)(canonical, "credential") };
27
58
  this.service = {
28
- serviceName: (0, __geekmidas_manifest.serviceKey)(canonical),
59
+ serviceName: (0, _geekmidas_manifest.serviceKey)(canonical),
29
60
  register: (registerOptions) => this.connect(registerOptions)
30
61
  };
31
62
  }
@@ -44,7 +75,7 @@ var Credential = class {
44
75
  async resolve(options) {
45
76
  const { raw } = options.envParser.create((get) => ({ raw: get(this.keys.credential).string() })).parse();
46
77
  try {
47
- return await (0, __geekmidas_schema_parser.parseSchema)(this.options.schema, decode(raw));
78
+ return await (0, _geekmidas_schema_parser.parseSchema)(this.options.schema, decode(raw));
48
79
  } catch (issues) {
49
80
  throw new MalformedCredential(this.id, this.keys.credential, issues);
50
81
  }
@@ -73,6 +104,9 @@ function decode(raw) {
73
104
  const JSON_SCHEME = "json:";
74
105
  /** A credential was set, and is not what its schema says it should be. */
75
106
  var MalformedCredential = class extends Error {
107
+ id;
108
+ key;
109
+ issues;
76
110
  constructor(id, key, issues) {
77
111
  super(`${key} is not a valid ${id} credential. It is validated where it is read, so this is the value that is set rather than the code that uses it: ${describe(issues)}`);
78
112
  this.id = id;
@@ -89,8 +123,8 @@ function describe(issues) {
89
123
  return path ? `${path}: ${issue.message}` : issue.message;
90
124
  }).join("; ");
91
125
  }
92
-
93
126
  //#endregion
94
127
  exports.Credential = Credential;
95
128
  exports.MalformedCredential = MalformedCredential;
129
+
96
130
  //# sourceMappingURL=credential.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"credential.cjs","names":["id: ConstructName<TName>","options: CredentialOptions<TSchema>","options: ServiceRegisterOptions","raw: string","id: string","key: string","issues: unknown","issue: StandardSchemaV1.Issue"],"sources":["../src/credential.ts"],"sourcesContent":["/**\n * `Credential` — a third-party credential with a shape.\n *\n * The answer to the design's first open question, \"where does `Secret` sit?\".\n * It sits beside a secret rather than replacing it, because the two differ by\n * *lifecycle* and that is the only difference worth two kinds for: a secret is\n * generated and rotated by the platform and is one opaque string, while a\n * credential is issued by someone else, arrives with several fields, and is\n * worth validating on the way in.\n *\n * ```ts\n * export const stripe = new Credential('Stripe', {\n * schema: z.object({ secretKey: z.string(), webhookSecret: z.string() }),\n * });\n *\n * // in a handler — no await, already parsed and validated\n * services.stripe.secretKey\n * ```\n *\n * **Nothing about it is async at the call site**, which is the part that looks\n * like it should be hard and is not. `Service.register()` may return a promise\n * and `ServiceDiscovery` awaits every one before a handler runs, so fetching a\n * value and validating it — including when a StandardSchema's `~standard.validate`\n * returns a promise of its own — both happen inside that existing seam.\n *\n * **One key holding JSON, not one key per field.** That is the shape a secret\n * manager stores, and it is the only shape that works with an arbitrary\n * StandardSchema: the spec has no introspection API, so enumerating a schema's\n * fields means reaching into one library's internals (`.shape`) and being wrong\n * for every other.\n */\n\nimport {\n\ttype ConstructName,\n\tcanonicalId,\n\ttype Declaration,\n\tprovideKey,\n\tserviceKey,\n} from '@geekmidas/manifest';\nimport { parseSchema } from '@geekmidas/schema/parser';\nimport type { Service, ServiceRegisterOptions } from '@geekmidas/services';\nimport type { StandardSchemaV1 } from '@standard-schema/spec';\nimport type { Consumable } from './construct-interface';\n\n/** What a credential's schema yields. */\ntype Value<TSchema extends StandardSchemaV1> =\n\tStandardSchemaV1.InferOutput<TSchema>;\n\nexport interface CredentialOptions<TSchema extends StandardSchemaV1> {\n\t/**\n\t * What the credential must look like.\n\t *\n\t * Validated at registration, so a malformed or half-set credential fails\n\t * when the process starts rather than on the first request that needs the\n\t * one field somebody forgot.\n\t */\n\tschema: TSchema;\n\t/**\n\t * Re-resolve on every registration instead of once per process.\n\t *\n\t * Off by default: a credential is resolved once and reused, because the\n\t * alternative is a fetch on every request. The cost of that default is that\n\t * a rotated credential needs a restart, which is the right trade for a value\n\t * that changes a few times a year — and this is the escape hatch for when it\n\t * is not.\n\t */\n\trefresh?: boolean;\n}\n\nexport class Credential<\n\tTName extends string = string,\n\tTSchema extends StandardSchemaV1 = StandardSchemaV1,\n> implements Consumable<TName, Value<TSchema>>\n{\n\t// `Consumable` rather than `Construct`, and not by preference: `Construct`\n\t// types its service as `[TClient] extends [never] ? never : Service<…>` so\n\t// that a `Cron` cannot be depended on, and TypeScript cannot evaluate that\n\t// conditional while `TClient` is still a type parameter. Every construct\n\t// with a concrete client satisfies `Construct`; the first one whose client\n\t// is generic cannot. `Consumable` is the face `.dependsOn()` requires and\n\t// carries no conditional, so it is the honest annotation here.\n\treadonly id: TName;\n\treadonly service: Service<Uncapitalize<TName>, Value<TSchema>>;\n\n\t/**\n\t * Declared once and read by both `declare()` and `connect()`, so the key the\n\t * target publishes and the key the client reads cannot drift.\n\t */\n\tprivate readonly keys: { credential: string };\n\n\t/**\n\t * The resolved value, held as the *promise* rather than the value.\n\t *\n\t * Caching the promise is what makes two concurrent registrations share one\n\t * resolution: caching the value would let both start before either finished,\n\t * which is a duplicated fetch every cold start rather than never.\n\t */\n\tprivate resolved?: Promise<Value<TSchema>>;\n\n\tconstructor(\n\t\tid: ConstructName<TName>,\n\t\tprivate readonly options: CredentialOptions<TSchema>,\n\t) {\n\t\tconst canonical = canonicalId(id as string);\n\n\t\tthis.id = canonical as TName;\n\t\tthis.keys = { credential: provideKey(canonical, 'credential') };\n\n\t\t// A field, not a getter: consumers cache services by object identity.\n\t\tthis.service = {\n\t\t\tserviceName: serviceKey(canonical) as Uncapitalize<TName>,\n\t\t\tregister: (registerOptions) => this.connect(registerOptions),\n\t\t};\n\t}\n\n\tdeclare(): Declaration[] {\n\t\treturn [\n\t\t\t{\n\t\t\t\tkind: 'credential',\n\t\t\t\tid: this.id,\n\t\t\t\tprovides: [this.keys.credential],\n\t\t\t},\n\t\t];\n\t}\n\n\tprivate connect(options: ServiceRegisterOptions): Promise<Value<TSchema>> {\n\t\tif (this.options.refresh) return this.resolve(options);\n\n\t\tthis.resolved ??= this.resolve(options);\n\n\t\treturn this.resolved;\n\t}\n\n\tprivate async resolve(\n\t\toptions: ServiceRegisterOptions,\n\t): Promise<Value<TSchema>> {\n\t\tconst { raw } = options.envParser\n\t\t\t.create((get) => ({ raw: get(this.keys.credential).string() }))\n\t\t\t.parse();\n\n\t\ttry {\n\t\t\treturn await parseSchema(this.options.schema, decode(raw));\n\t\t} catch (issues) {\n\t\t\tthrow new MalformedCredential(this.id, this.keys.credential, issues);\n\t\t}\n\t}\n}\n\n/**\n * The raw environment value as the thing the schema should see.\n *\n * JSON when it is JSON, and the string itself when it is not — a credential\n * with a single opaque field is ordinary, and requiring `\"…\"` around it would\n * be ceremony that every operator setting one by hand would get wrong once.\n */\nfunction decode(raw: string): unknown {\n\tconst value = raw.startsWith(JSON_SCHEME)\n\t\t? raw.slice(JSON_SCHEME.length)\n\t\t: raw;\n\n\ttry {\n\t\treturn JSON.parse(value);\n\t} catch {\n\t\treturn value;\n\t}\n}\n\n/**\n * The explicit form, for the case a credential legitimately *is* a JSON string\n * and must not be parsed into an object. Rare, and cheaper to support than to\n * explain.\n */\nconst JSON_SCHEME = 'json:';\n\n/** A credential was set, and is not what its schema says it should be. */\nexport class MalformedCredential extends Error {\n\tconstructor(\n\t\treadonly id: string,\n\t\treadonly key: string,\n\t\treadonly issues: unknown,\n\t) {\n\t\tsuper(\n\t\t\t`${key} is not a valid ${id} credential. ` +\n\t\t\t\t`It is validated where it is read, so this is the value that is set ` +\n\t\t\t\t`rather than the code that uses it: ${describe(issues)}`,\n\t\t);\n\t\tthis.name = 'MalformedCredential';\n\t}\n}\n\n/** StandardSchema issues as one line. */\nfunction describe(issues: unknown): string {\n\tif (!Array.isArray(issues)) return String(issues);\n\n\treturn issues\n\t\t.map((issue: StandardSchemaV1.Issue) => {\n\t\t\tconst path = issue.path\n\t\t\t\t?.map((segment) =>\n\t\t\t\t\ttypeof segment === 'object' ? String(segment.key) : String(segment),\n\t\t\t\t)\n\t\t\t\t.join('.');\n\n\t\t\treturn path ? `${path}: ${issue.message}` : issue.message;\n\t\t})\n\t\t.join('; ');\n}\n"],"mappings":";;;;;AAqEA,IAAa,aAAb,MAIA;CAQC,AAAS;CACT,AAAS;;;;;CAMT,AAAiB;;;;;;;;CASjB,AAAQ;CAER,YACCA,IACiBC,SAChB;EADgB;EAEjB,MAAM,YAAY,sCAAY,GAAa;AAE3C,OAAK,KAAK;AACV,OAAK,OAAO,EAAE,YAAY,qCAAW,WAAW,aAAa,CAAE;AAG/D,OAAK,UAAU;GACd,aAAa,qCAAW,UAAU;GAClC,UAAU,CAAC,oBAAoB,KAAK,QAAQ,gBAAgB;EAC5D;CACD;CAED,UAAyB;AACxB,SAAO,CACN;GACC,MAAM;GACN,IAAI,KAAK;GACT,UAAU,CAAC,KAAK,KAAK,UAAW;EAChC,CACD;CACD;CAED,AAAQ,QAAQC,SAA0D;AACzE,MAAI,KAAK,QAAQ,QAAS,QAAO,KAAK,QAAQ,QAAQ;AAEtD,OAAK,aAAa,KAAK,QAAQ,QAAQ;AAEvC,SAAO,KAAK;CACZ;CAED,MAAc,QACbA,SAC0B;EAC1B,MAAM,EAAE,KAAK,GAAG,QAAQ,UACtB,OAAO,CAAC,SAAS,EAAE,KAAK,IAAI,KAAK,KAAK,WAAW,CAAC,QAAQ,CAAE,GAAE,CAC9D,OAAO;AAET,MAAI;AACH,UAAO,MAAM,2CAAY,KAAK,QAAQ,QAAQ,OAAO,IAAI,CAAC;EAC1D,SAAQ,QAAQ;AAChB,SAAM,IAAI,oBAAoB,KAAK,IAAI,KAAK,KAAK,YAAY;EAC7D;CACD;AACD;;;;;;;;AASD,SAAS,OAAOC,KAAsB;CACrC,MAAM,QAAQ,IAAI,WAAW,YAAY,GACtC,IAAI,MAAM,YAAY,OAAO,GAC7B;AAEH,KAAI;AACH,SAAO,KAAK,MAAM,MAAM;CACxB,QAAO;AACP,SAAO;CACP;AACD;;;;;;AAOD,MAAM,cAAc;;AAGpB,IAAa,sBAAb,cAAyC,MAAM;CAC9C,YACUC,IACAC,KACAC,QACR;AACD,SACE,EAAE,IAAI,kBAAkB,GAAG,qHAEW,SAAS,OAAO,CAAC,EACxD;EARQ;EACA;EACA;AAOT,OAAK,OAAO;CACZ;AACD;;AAGD,SAAS,SAASA,QAAyB;AAC1C,MAAK,MAAM,QAAQ,OAAO,CAAE,QAAO,OAAO,OAAO;AAEjD,QAAO,OACL,IAAI,CAACC,UAAkC;EACvC,MAAM,OAAO,MAAM,MAChB,IAAI,CAAC,mBACC,YAAY,WAAW,OAAO,QAAQ,IAAI,GAAG,OAAO,QAAQ,CACnE,CACA,KAAK,IAAI;AAEX,SAAO,QAAQ,EAAE,KAAK,IAAI,MAAM,QAAQ,IAAI,MAAM;CAClD,EAAC,CACD,KAAK,KAAK;AACZ"}
1
+ {"version":3,"file":"credential.cjs","names":["canonicalId","provideKey","serviceKey","parseSchema"],"sources":["../src/credential.ts"],"sourcesContent":["/**\n * `Credential` — a third-party credential with a shape.\n *\n * The answer to the design's first open question, \"where does `Secret` sit?\".\n * It sits beside a secret rather than replacing it, because the two differ by\n * *lifecycle* and that is the only difference worth two kinds for: a secret is\n * generated and rotated by the platform and is one opaque string, while a\n * credential is issued by someone else, arrives with several fields, and is\n * worth validating on the way in.\n *\n * ```ts\n * export const stripe = new Credential('Stripe', {\n * schema: z.object({ secretKey: z.string(), webhookSecret: z.string() }),\n * });\n *\n * // in a handler — no await, already parsed and validated\n * services.stripe.secretKey\n * ```\n *\n * **Nothing about it is async at the call site**, which is the part that looks\n * like it should be hard and is not. `Service.register()` may return a promise\n * and `ServiceDiscovery` awaits every one before a handler runs, so fetching a\n * value and validating it — including when a StandardSchema's `~standard.validate`\n * returns a promise of its own — both happen inside that existing seam.\n *\n * **One key holding JSON, not one key per field.** That is the shape a secret\n * manager stores, and it is the only shape that works with an arbitrary\n * StandardSchema: the spec has no introspection API, so enumerating a schema's\n * fields means reaching into one library's internals (`.shape`) and being wrong\n * for every other.\n */\n\nimport {\n\ttype ConstructName,\n\tcanonicalId,\n\ttype Declaration,\n\tprovideKey,\n\tserviceKey,\n} from '@geekmidas/manifest';\nimport { parseSchema } from '@geekmidas/schema/parser';\nimport type { Service, ServiceRegisterOptions } from '@geekmidas/services';\nimport type { StandardSchemaV1 } from '@standard-schema/spec';\nimport type { Consumable } from './construct-interface';\n\n/** What a credential's schema yields. */\ntype Value<TSchema extends StandardSchemaV1> =\n\tStandardSchemaV1.InferOutput<TSchema>;\n\nexport interface CredentialOptions<TSchema extends StandardSchemaV1> {\n\t/**\n\t * What the credential must look like.\n\t *\n\t * Validated at registration, so a malformed or half-set credential fails\n\t * when the process starts rather than on the first request that needs the\n\t * one field somebody forgot.\n\t */\n\tschema: TSchema;\n\t/**\n\t * Re-resolve on every registration instead of once per process.\n\t *\n\t * Off by default: a credential is resolved once and reused, because the\n\t * alternative is a fetch on every request. The cost of that default is that\n\t * a rotated credential needs a restart, which is the right trade for a value\n\t * that changes a few times a year — and this is the escape hatch for when it\n\t * is not.\n\t */\n\trefresh?: boolean;\n}\n\nexport class Credential<\n\tTName extends string = string,\n\tTSchema extends StandardSchemaV1 = StandardSchemaV1,\n> implements Consumable<TName, Value<TSchema>>\n{\n\t// `Consumable` rather than `Construct`, and not by preference: `Construct`\n\t// types its service as `[TClient] extends [never] ? never : Service<…>` so\n\t// that a `Cron` cannot be depended on, and TypeScript cannot evaluate that\n\t// conditional while `TClient` is still a type parameter. Every construct\n\t// with a concrete client satisfies `Construct`; the first one whose client\n\t// is generic cannot. `Consumable` is the face `.dependsOn()` requires and\n\t// carries no conditional, so it is the honest annotation here.\n\treadonly id: TName;\n\treadonly service: Service<Uncapitalize<TName>, Value<TSchema>>;\n\n\t/**\n\t * Declared once and read by both `declare()` and `connect()`, so the key the\n\t * target publishes and the key the client reads cannot drift.\n\t */\n\tprivate readonly keys: { credential: string };\n\n\t/**\n\t * The resolved value, held as the *promise* rather than the value.\n\t *\n\t * Caching the promise is what makes two concurrent registrations share one\n\t * resolution: caching the value would let both start before either finished,\n\t * which is a duplicated fetch every cold start rather than never.\n\t */\n\tprivate resolved?: Promise<Value<TSchema>>;\n\n\tconstructor(\n\t\tid: ConstructName<TName>,\n\t\tprivate readonly options: CredentialOptions<TSchema>,\n\t) {\n\t\tconst canonical = canonicalId(id as string);\n\n\t\tthis.id = canonical as TName;\n\t\tthis.keys = { credential: provideKey(canonical, 'credential') };\n\n\t\t// A field, not a getter: consumers cache services by object identity.\n\t\tthis.service = {\n\t\t\tserviceName: serviceKey(canonical) as Uncapitalize<TName>,\n\t\t\tregister: (registerOptions) => this.connect(registerOptions),\n\t\t};\n\t}\n\n\tdeclare(): Declaration[] {\n\t\treturn [\n\t\t\t{\n\t\t\t\tkind: 'credential',\n\t\t\t\tid: this.id,\n\t\t\t\tprovides: [this.keys.credential],\n\t\t\t},\n\t\t];\n\t}\n\n\tprivate connect(options: ServiceRegisterOptions): Promise<Value<TSchema>> {\n\t\tif (this.options.refresh) return this.resolve(options);\n\n\t\tthis.resolved ??= this.resolve(options);\n\n\t\treturn this.resolved;\n\t}\n\n\tprivate async resolve(\n\t\toptions: ServiceRegisterOptions,\n\t): Promise<Value<TSchema>> {\n\t\tconst { raw } = options.envParser\n\t\t\t.create((get) => ({ raw: get(this.keys.credential).string() }))\n\t\t\t.parse();\n\n\t\ttry {\n\t\t\treturn await parseSchema(this.options.schema, decode(raw));\n\t\t} catch (issues) {\n\t\t\tthrow new MalformedCredential(this.id, this.keys.credential, issues);\n\t\t}\n\t}\n}\n\n/**\n * The raw environment value as the thing the schema should see.\n *\n * JSON when it is JSON, and the string itself when it is not — a credential\n * with a single opaque field is ordinary, and requiring `\"…\"` around it would\n * be ceremony that every operator setting one by hand would get wrong once.\n */\nfunction decode(raw: string): unknown {\n\tconst value = raw.startsWith(JSON_SCHEME)\n\t\t? raw.slice(JSON_SCHEME.length)\n\t\t: raw;\n\n\ttry {\n\t\treturn JSON.parse(value);\n\t} catch {\n\t\treturn value;\n\t}\n}\n\n/**\n * The explicit form, for the case a credential legitimately *is* a JSON string\n * and must not be parsed into an object. Rare, and cheaper to support than to\n * explain.\n */\nconst JSON_SCHEME = 'json:';\n\n/** A credential was set, and is not what its schema says it should be. */\nexport class MalformedCredential extends Error {\n\tconstructor(\n\t\treadonly id: string,\n\t\treadonly key: string,\n\t\treadonly issues: unknown,\n\t) {\n\t\tsuper(\n\t\t\t`${key} is not a valid ${id} credential. ` +\n\t\t\t\t`It is validated where it is read, so this is the value that is set ` +\n\t\t\t\t`rather than the code that uses it: ${describe(issues)}`,\n\t\t);\n\t\tthis.name = 'MalformedCredential';\n\t}\n}\n\n/** StandardSchema issues as one line. */\nfunction describe(issues: unknown): string {\n\tif (!Array.isArray(issues)) return String(issues);\n\n\treturn issues\n\t\t.map((issue: StandardSchemaV1.Issue) => {\n\t\t\tconst path = issue.path\n\t\t\t\t?.map((segment) =>\n\t\t\t\t\ttypeof segment === 'object' ? String(segment.key) : String(segment),\n\t\t\t\t)\n\t\t\t\t.join('.');\n\n\t\t\treturn path ? `${path}: ${issue.message}` : issue.message;\n\t\t})\n\t\t.join('; ');\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqEA,IAAa,aAAb,MAIA;CA4BmB;CApBlB;CACA;;;;;CAMA;;;;;;;;CASA;CAEA,YACC,IACA,SACC;EADgB,KAAA,UAAA;EAEjB,MAAM,aAAA,GAAYA,oBAAAA,YAAAA,CAAY,EAAY;EAE1C,KAAK,KAAK;EACV,KAAK,OAAO,EAAE,aAAA,GAAYC,oBAAAA,WAAAA,CAAW,WAAW,YAAY,EAAE;EAG9D,KAAK,UAAU;GACd,cAAA,GAAaC,oBAAAA,WAAAA,CAAW,SAAS;GACjC,WAAW,oBAAoB,KAAK,QAAQ,eAAe;EAC5D;CACD;CAEA,UAAyB;EACxB,OAAO,CACN;GACC,MAAM;GACN,IAAI,KAAK;GACT,UAAU,CAAC,KAAK,KAAK,UAAU;EAChC,CACD;CACD;CAEA,QAAgB,SAA0D;EACzE,IAAI,KAAK,QAAQ,SAAS,OAAO,KAAK,QAAQ,OAAO;EAErD,KAAK,aAAa,KAAK,QAAQ,OAAO;EAEtC,OAAO,KAAK;CACb;CAEA,MAAc,QACb,SAC0B;EAC1B,MAAM,EAAE,QAAQ,QAAQ,UACtB,QAAQ,SAAS,EAAE,KAAK,IAAI,KAAK,KAAK,UAAU,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,CAC9D,MAAM;EAER,IAAI;GACH,OAAO,OAAA,GAAMC,yBAAAA,YAAAA,CAAY,KAAK,QAAQ,QAAQ,OAAO,GAAG,CAAC;EAC1D,SAAS,QAAQ;GAChB,MAAM,IAAI,oBAAoB,KAAK,IAAI,KAAK,KAAK,YAAY,MAAM;EACpE;CACD;AACD;;;;;;;;AASA,SAAS,OAAO,KAAsB;CACrC,MAAM,QAAQ,IAAI,WAAW,WAAW,IACrC,IAAI,MAAM,YAAY,MAAM,IAC5B;CAEH,IAAI;EACH,OAAO,KAAK,MAAM,KAAK;CACxB,QAAQ;EACP,OAAO;CACR;AACD;;;;;;AAOA,MAAM,cAAc;;AAGpB,IAAa,sBAAb,cAAyC,MAAM;CAEpC;CACA;CACA;CAHV,YACC,IACA,KACA,QACC;EACD,MACC,GAAG,IAAI,kBAAkB,GAAG,qHAEW,SAAS,MAAM,GACvD;EARS,KAAA,KAAA;EACA,KAAA,MAAA;EACA,KAAA,SAAA;EAOT,KAAK,OAAO;CACb;AACD;;AAGA,SAAS,SAAS,QAAyB;CAC1C,IAAI,CAAC,MAAM,QAAQ,MAAM,GAAG,OAAO,OAAO,MAAM;CAEhD,OAAO,OACL,KAAK,UAAkC;EACvC,MAAM,OAAO,MAAM,MAChB,KAAK,YACN,OAAO,YAAY,WAAW,OAAO,QAAQ,GAAG,IAAI,OAAO,OAAO,CACnE,CAAC,CACA,KAAK,GAAG;EAEV,OAAO,OAAO,GAAG,KAAK,IAAI,MAAM,YAAY,MAAM;CACnD,CAAC,CAAC,CACD,KAAK,IAAI;AACZ"}
@@ -1,13 +1,11 @@
1
- import { Consumable } from "./construct-interface-D9d4Gm4p.cjs";
1
+ import { t as StandardSchemaV1 } from "./index-CeEtxDmK.cjs";
2
+ import { n as Consumable } from "./construct-interface-DgXTJcOD.cjs";
2
3
  import { Service } from "@geekmidas/services";
3
- import { StandardSchemaV1 } from "@standard-schema/spec";
4
4
  import { ConstructName, Declaration } from "@geekmidas/manifest";
5
-
6
5
  //#region src/credential.d.ts
7
-
8
6
  /** What a credential's schema yields. */
9
7
  type Value<TSchema extends StandardSchemaV1> = StandardSchemaV1.InferOutput<TSchema>;
10
- interface CredentialOptions<TSchema extends StandardSchemaV1> {
8
+ export interface CredentialOptions<TSchema extends StandardSchemaV1> {
11
9
  /**
12
10
  * What the credential must look like.
13
11
  *
@@ -27,7 +25,7 @@ interface CredentialOptions<TSchema extends StandardSchemaV1> {
27
25
  */
28
26
  refresh?: boolean;
29
27
  }
30
- declare class Credential<TName extends string = string, TSchema extends StandardSchemaV1 = StandardSchemaV1> implements Consumable<TName, Value<TSchema>> {
28
+ export declare class Credential<TName extends string = string, TSchema extends StandardSchemaV1 = StandardSchemaV1> implements Consumable<TName, Value<TSchema>> {
31
29
  private readonly options;
32
30
  readonly id: TName;
33
31
  readonly service: Service<Uncapitalize<TName>, Value<TSchema>>;
@@ -50,12 +48,11 @@ declare class Credential<TName extends string = string, TSchema extends Standard
50
48
  private resolve;
51
49
  }
52
50
  /** A credential was set, and is not what its schema says it should be. */
53
- declare class MalformedCredential extends Error {
51
+ export declare class MalformedCredential extends Error {
54
52
  readonly id: string;
55
53
  readonly key: string;
56
54
  readonly issues: unknown;
57
55
  constructor(id: string, key: string, issues: unknown);
58
56
  }
59
57
  //#endregion
60
- export { Credential, CredentialOptions, MalformedCredential };
61
58
  //# sourceMappingURL=credential.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"credential.d.cts","names":[],"sources":["../src/credential.ts"],"sourcesContent":[],"mappings":";;;;;;;;AAwEuB,KA3BlB,KA2BkB,CAAA,gBA3BI,gBA2BJ,CAAA,GA1BtB,gBAAA,CAAiB,WA0BK,CA1BO,OA0BP,CAAA;AAuGV,UA/HI,iBA+HgB,CAAA,gBA/HkB,gBA+HL,CAAA,CAAA;;;;;;;;UAvHrC;;;;;;;;;;;;cAaI,0DAEI,mBAAmB,6BACvB,WAAW,OAAO,MAAM;;eASvB;oBACK,QAAQ,aAAa,QAAQ,MAAM;;;;;;;;;;;;;;kBAkBhD,cAAc,iBACQ,kBAAkB;aAclC;;;;;cA4DC,mBAAA,SAA4B,KAAK"}
1
+ {"version":3,"file":"credential.d.cts","names":[],"sources":["../src/credential.ts"],"mappings":";;;;;;KA6CK,MAAM,gBAAgB,oBAC1B,iBAAiB,YAAY;iBAEb,kBAAkB,gBAAgB;;;;;;;;EAQlD,QAAQ;;;;;;;;;;EAUR;;qBAGY,WACZ,+BACA,gBAAgB,mBAAmB,6BACvB,WAAW,OAAO,MAAM;mBA6BlB;WApBT,IAAI;WACJ,SAAS,QAAQ,aAAa,QAAQ,MAAM;;;;;mBAMpC;;;;;;;;UAST;EAGP,YAAA,IAAI,cAAc,QACD,SAAS,kBAAkB;EAc7C,WAAW;UAUH;UAQM;;;qBA0CF,4BAA4B;WAE9B;WACA;WACA;EAFA,YAAA,YACA,aACA"}
@@ -1,13 +1,11 @@
1
- import { Consumable } from "./construct-interface-g5GM5pwR.mjs";
1
+ import { t as StandardSchemaV1 } from "./index-CeEtxDmK.mjs";
2
+ import { n as Consumable } from "./construct-interface-DPlxfpoS.mjs";
2
3
  import { ConstructName, Declaration } from "@geekmidas/manifest";
3
4
  import { Service } from "@geekmidas/services";
4
- import { StandardSchemaV1 } from "@standard-schema/spec";
5
-
6
5
  //#region src/credential.d.ts
7
-
8
6
  /** What a credential's schema yields. */
9
7
  type Value<TSchema extends StandardSchemaV1> = StandardSchemaV1.InferOutput<TSchema>;
10
- interface CredentialOptions<TSchema extends StandardSchemaV1> {
8
+ export interface CredentialOptions<TSchema extends StandardSchemaV1> {
11
9
  /**
12
10
  * What the credential must look like.
13
11
  *
@@ -27,7 +25,7 @@ interface CredentialOptions<TSchema extends StandardSchemaV1> {
27
25
  */
28
26
  refresh?: boolean;
29
27
  }
30
- declare class Credential<TName extends string = string, TSchema extends StandardSchemaV1 = StandardSchemaV1> implements Consumable<TName, Value<TSchema>> {
28
+ export declare class Credential<TName extends string = string, TSchema extends StandardSchemaV1 = StandardSchemaV1> implements Consumable<TName, Value<TSchema>> {
31
29
  private readonly options;
32
30
  readonly id: TName;
33
31
  readonly service: Service<Uncapitalize<TName>, Value<TSchema>>;
@@ -50,12 +48,11 @@ declare class Credential<TName extends string = string, TSchema extends Standard
50
48
  private resolve;
51
49
  }
52
50
  /** A credential was set, and is not what its schema says it should be. */
53
- declare class MalformedCredential extends Error {
51
+ export declare class MalformedCredential extends Error {
54
52
  readonly id: string;
55
53
  readonly key: string;
56
54
  readonly issues: unknown;
57
55
  constructor(id: string, key: string, issues: unknown);
58
56
  }
59
57
  //#endregion
60
- export { Credential, CredentialOptions, MalformedCredential };
61
58
  //# sourceMappingURL=credential.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"credential.d.mts","names":[],"sources":["../src/credential.ts"],"sourcesContent":[],"mappings":";;;;;;;;AAwEuB,KA3BlB,KA2BkB,CAAA,gBA3BI,gBA2BJ,CAAA,GA1BtB,gBAAA,CAAiB,WA0BK,CA1BO,OA0BP,CAAA;AAuGV,UA/HI,iBA+HgB,CAAA,gBA/HkB,gBA+HL,CAAA,CAAA;;;;;;;;UAvHrC;;;;;;;;;;;;cAaI,0DAEI,mBAAmB,6BACvB,WAAW,OAAO,MAAM;;eASvB;oBACK,QAAQ,aAAa,QAAQ,MAAM;;;;;;;;;;;;;;kBAkBhD,cAAc,iBACQ,kBAAkB;aAclC;;;;;cA4DC,mBAAA,SAA4B,KAAK"}
1
+ {"version":3,"file":"credential.d.mts","names":[],"sources":["../src/credential.ts"],"mappings":";;;;;;KA6CK,MAAM,gBAAgB,oBAC1B,iBAAiB,YAAY;iBAEb,kBAAkB,gBAAgB;;;;;;;;EAQlD,QAAQ;;;;;;;;;;EAUR;;qBAGY,WACZ,+BACA,gBAAgB,mBAAmB,6BACvB,WAAW,OAAO,MAAM;mBA6BlB;WApBT,IAAI;WACJ,SAAS,QAAQ,aAAa,QAAQ,MAAM;;;;;mBAMpC;;;;;;;;UAST;EAGP,YAAA,IAAI,cAAc,QACD,SAAS,kBAAkB;EAc7C,WAAW;UAUH;UAQM;;;qBA0CF,4BAA4B;WAE9B;WACA;WACA;EAFA,YAAA,YACA,aACA"}
@@ -1,8 +1,39 @@
1
1
  import { canonicalId, provideKey, serviceKey } from "@geekmidas/manifest";
2
2
  import { parseSchema } from "@geekmidas/schema/parser";
3
-
4
3
  //#region src/credential.ts
4
+ /**
5
+ * `Credential` — a third-party credential with a shape.
6
+ *
7
+ * The answer to the design's first open question, "where does `Secret` sit?".
8
+ * It sits beside a secret rather than replacing it, because the two differ by
9
+ * *lifecycle* and that is the only difference worth two kinds for: a secret is
10
+ * generated and rotated by the platform and is one opaque string, while a
11
+ * credential is issued by someone else, arrives with several fields, and is
12
+ * worth validating on the way in.
13
+ *
14
+ * ```ts
15
+ * export const stripe = new Credential('Stripe', {
16
+ * schema: z.object({ secretKey: z.string(), webhookSecret: z.string() }),
17
+ * });
18
+ *
19
+ * // in a handler — no await, already parsed and validated
20
+ * services.stripe.secretKey
21
+ * ```
22
+ *
23
+ * **Nothing about it is async at the call site**, which is the part that looks
24
+ * like it should be hard and is not. `Service.register()` may return a promise
25
+ * and `ServiceDiscovery` awaits every one before a handler runs, so fetching a
26
+ * value and validating it — including when a StandardSchema's `~standard.validate`
27
+ * returns a promise of its own — both happen inside that existing seam.
28
+ *
29
+ * **One key holding JSON, not one key per field.** That is the shape a secret
30
+ * manager stores, and it is the only shape that works with an arbitrary
31
+ * StandardSchema: the spec has no introspection API, so enumerating a schema's
32
+ * fields means reaching into one library's internals (`.shape`) and being wrong
33
+ * for every other.
34
+ */
5
35
  var Credential = class {
36
+ options;
6
37
  id;
7
38
  service;
8
39
  /**
@@ -72,6 +103,9 @@ function decode(raw) {
72
103
  const JSON_SCHEME = "json:";
73
104
  /** A credential was set, and is not what its schema says it should be. */
74
105
  var MalformedCredential = class extends Error {
106
+ id;
107
+ key;
108
+ issues;
75
109
  constructor(id, key, issues) {
76
110
  super(`${key} is not a valid ${id} credential. It is validated where it is read, so this is the value that is set rather than the code that uses it: ${describe(issues)}`);
77
111
  this.id = id;
@@ -88,7 +122,7 @@ function describe(issues) {
88
122
  return path ? `${path}: ${issue.message}` : issue.message;
89
123
  }).join("; ");
90
124
  }
91
-
92
125
  //#endregion
93
126
  export { Credential, MalformedCredential };
127
+
94
128
  //# sourceMappingURL=credential.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"credential.mjs","names":["id: ConstructName<TName>","options: CredentialOptions<TSchema>","options: ServiceRegisterOptions","raw: string","id: string","key: string","issues: unknown","issue: StandardSchemaV1.Issue"],"sources":["../src/credential.ts"],"sourcesContent":["/**\n * `Credential` — a third-party credential with a shape.\n *\n * The answer to the design's first open question, \"where does `Secret` sit?\".\n * It sits beside a secret rather than replacing it, because the two differ by\n * *lifecycle* and that is the only difference worth two kinds for: a secret is\n * generated and rotated by the platform and is one opaque string, while a\n * credential is issued by someone else, arrives with several fields, and is\n * worth validating on the way in.\n *\n * ```ts\n * export const stripe = new Credential('Stripe', {\n * schema: z.object({ secretKey: z.string(), webhookSecret: z.string() }),\n * });\n *\n * // in a handler — no await, already parsed and validated\n * services.stripe.secretKey\n * ```\n *\n * **Nothing about it is async at the call site**, which is the part that looks\n * like it should be hard and is not. `Service.register()` may return a promise\n * and `ServiceDiscovery` awaits every one before a handler runs, so fetching a\n * value and validating it — including when a StandardSchema's `~standard.validate`\n * returns a promise of its own — both happen inside that existing seam.\n *\n * **One key holding JSON, not one key per field.** That is the shape a secret\n * manager stores, and it is the only shape that works with an arbitrary\n * StandardSchema: the spec has no introspection API, so enumerating a schema's\n * fields means reaching into one library's internals (`.shape`) and being wrong\n * for every other.\n */\n\nimport {\n\ttype ConstructName,\n\tcanonicalId,\n\ttype Declaration,\n\tprovideKey,\n\tserviceKey,\n} from '@geekmidas/manifest';\nimport { parseSchema } from '@geekmidas/schema/parser';\nimport type { Service, ServiceRegisterOptions } from '@geekmidas/services';\nimport type { StandardSchemaV1 } from '@standard-schema/spec';\nimport type { Consumable } from './construct-interface';\n\n/** What a credential's schema yields. */\ntype Value<TSchema extends StandardSchemaV1> =\n\tStandardSchemaV1.InferOutput<TSchema>;\n\nexport interface CredentialOptions<TSchema extends StandardSchemaV1> {\n\t/**\n\t * What the credential must look like.\n\t *\n\t * Validated at registration, so a malformed or half-set credential fails\n\t * when the process starts rather than on the first request that needs the\n\t * one field somebody forgot.\n\t */\n\tschema: TSchema;\n\t/**\n\t * Re-resolve on every registration instead of once per process.\n\t *\n\t * Off by default: a credential is resolved once and reused, because the\n\t * alternative is a fetch on every request. The cost of that default is that\n\t * a rotated credential needs a restart, which is the right trade for a value\n\t * that changes a few times a year — and this is the escape hatch for when it\n\t * is not.\n\t */\n\trefresh?: boolean;\n}\n\nexport class Credential<\n\tTName extends string = string,\n\tTSchema extends StandardSchemaV1 = StandardSchemaV1,\n> implements Consumable<TName, Value<TSchema>>\n{\n\t// `Consumable` rather than `Construct`, and not by preference: `Construct`\n\t// types its service as `[TClient] extends [never] ? never : Service<…>` so\n\t// that a `Cron` cannot be depended on, and TypeScript cannot evaluate that\n\t// conditional while `TClient` is still a type parameter. Every construct\n\t// with a concrete client satisfies `Construct`; the first one whose client\n\t// is generic cannot. `Consumable` is the face `.dependsOn()` requires and\n\t// carries no conditional, so it is the honest annotation here.\n\treadonly id: TName;\n\treadonly service: Service<Uncapitalize<TName>, Value<TSchema>>;\n\n\t/**\n\t * Declared once and read by both `declare()` and `connect()`, so the key the\n\t * target publishes and the key the client reads cannot drift.\n\t */\n\tprivate readonly keys: { credential: string };\n\n\t/**\n\t * The resolved value, held as the *promise* rather than the value.\n\t *\n\t * Caching the promise is what makes two concurrent registrations share one\n\t * resolution: caching the value would let both start before either finished,\n\t * which is a duplicated fetch every cold start rather than never.\n\t */\n\tprivate resolved?: Promise<Value<TSchema>>;\n\n\tconstructor(\n\t\tid: ConstructName<TName>,\n\t\tprivate readonly options: CredentialOptions<TSchema>,\n\t) {\n\t\tconst canonical = canonicalId(id as string);\n\n\t\tthis.id = canonical as TName;\n\t\tthis.keys = { credential: provideKey(canonical, 'credential') };\n\n\t\t// A field, not a getter: consumers cache services by object identity.\n\t\tthis.service = {\n\t\t\tserviceName: serviceKey(canonical) as Uncapitalize<TName>,\n\t\t\tregister: (registerOptions) => this.connect(registerOptions),\n\t\t};\n\t}\n\n\tdeclare(): Declaration[] {\n\t\treturn [\n\t\t\t{\n\t\t\t\tkind: 'credential',\n\t\t\t\tid: this.id,\n\t\t\t\tprovides: [this.keys.credential],\n\t\t\t},\n\t\t];\n\t}\n\n\tprivate connect(options: ServiceRegisterOptions): Promise<Value<TSchema>> {\n\t\tif (this.options.refresh) return this.resolve(options);\n\n\t\tthis.resolved ??= this.resolve(options);\n\n\t\treturn this.resolved;\n\t}\n\n\tprivate async resolve(\n\t\toptions: ServiceRegisterOptions,\n\t): Promise<Value<TSchema>> {\n\t\tconst { raw } = options.envParser\n\t\t\t.create((get) => ({ raw: get(this.keys.credential).string() }))\n\t\t\t.parse();\n\n\t\ttry {\n\t\t\treturn await parseSchema(this.options.schema, decode(raw));\n\t\t} catch (issues) {\n\t\t\tthrow new MalformedCredential(this.id, this.keys.credential, issues);\n\t\t}\n\t}\n}\n\n/**\n * The raw environment value as the thing the schema should see.\n *\n * JSON when it is JSON, and the string itself when it is not — a credential\n * with a single opaque field is ordinary, and requiring `\"…\"` around it would\n * be ceremony that every operator setting one by hand would get wrong once.\n */\nfunction decode(raw: string): unknown {\n\tconst value = raw.startsWith(JSON_SCHEME)\n\t\t? raw.slice(JSON_SCHEME.length)\n\t\t: raw;\n\n\ttry {\n\t\treturn JSON.parse(value);\n\t} catch {\n\t\treturn value;\n\t}\n}\n\n/**\n * The explicit form, for the case a credential legitimately *is* a JSON string\n * and must not be parsed into an object. Rare, and cheaper to support than to\n * explain.\n */\nconst JSON_SCHEME = 'json:';\n\n/** A credential was set, and is not what its schema says it should be. */\nexport class MalformedCredential extends Error {\n\tconstructor(\n\t\treadonly id: string,\n\t\treadonly key: string,\n\t\treadonly issues: unknown,\n\t) {\n\t\tsuper(\n\t\t\t`${key} is not a valid ${id} credential. ` +\n\t\t\t\t`It is validated where it is read, so this is the value that is set ` +\n\t\t\t\t`rather than the code that uses it: ${describe(issues)}`,\n\t\t);\n\t\tthis.name = 'MalformedCredential';\n\t}\n}\n\n/** StandardSchema issues as one line. */\nfunction describe(issues: unknown): string {\n\tif (!Array.isArray(issues)) return String(issues);\n\n\treturn issues\n\t\t.map((issue: StandardSchemaV1.Issue) => {\n\t\t\tconst path = issue.path\n\t\t\t\t?.map((segment) =>\n\t\t\t\t\ttypeof segment === 'object' ? String(segment.key) : String(segment),\n\t\t\t\t)\n\t\t\t\t.join('.');\n\n\t\t\treturn path ? `${path}: ${issue.message}` : issue.message;\n\t\t})\n\t\t.join('; ');\n}\n"],"mappings":";;;;AAqEA,IAAa,aAAb,MAIA;CAQC,AAAS;CACT,AAAS;;;;;CAMT,AAAiB;;;;;;;;CASjB,AAAQ;CAER,YACCA,IACiBC,SAChB;EADgB;EAEjB,MAAM,YAAY,YAAY,GAAa;AAE3C,OAAK,KAAK;AACV,OAAK,OAAO,EAAE,YAAY,WAAW,WAAW,aAAa,CAAE;AAG/D,OAAK,UAAU;GACd,aAAa,WAAW,UAAU;GAClC,UAAU,CAAC,oBAAoB,KAAK,QAAQ,gBAAgB;EAC5D;CACD;CAED,UAAyB;AACxB,SAAO,CACN;GACC,MAAM;GACN,IAAI,KAAK;GACT,UAAU,CAAC,KAAK,KAAK,UAAW;EAChC,CACD;CACD;CAED,AAAQ,QAAQC,SAA0D;AACzE,MAAI,KAAK,QAAQ,QAAS,QAAO,KAAK,QAAQ,QAAQ;AAEtD,OAAK,aAAa,KAAK,QAAQ,QAAQ;AAEvC,SAAO,KAAK;CACZ;CAED,MAAc,QACbA,SAC0B;EAC1B,MAAM,EAAE,KAAK,GAAG,QAAQ,UACtB,OAAO,CAAC,SAAS,EAAE,KAAK,IAAI,KAAK,KAAK,WAAW,CAAC,QAAQ,CAAE,GAAE,CAC9D,OAAO;AAET,MAAI;AACH,UAAO,MAAM,YAAY,KAAK,QAAQ,QAAQ,OAAO,IAAI,CAAC;EAC1D,SAAQ,QAAQ;AAChB,SAAM,IAAI,oBAAoB,KAAK,IAAI,KAAK,KAAK,YAAY;EAC7D;CACD;AACD;;;;;;;;AASD,SAAS,OAAOC,KAAsB;CACrC,MAAM,QAAQ,IAAI,WAAW,YAAY,GACtC,IAAI,MAAM,YAAY,OAAO,GAC7B;AAEH,KAAI;AACH,SAAO,KAAK,MAAM,MAAM;CACxB,QAAO;AACP,SAAO;CACP;AACD;;;;;;AAOD,MAAM,cAAc;;AAGpB,IAAa,sBAAb,cAAyC,MAAM;CAC9C,YACUC,IACAC,KACAC,QACR;AACD,SACE,EAAE,IAAI,kBAAkB,GAAG,qHAEW,SAAS,OAAO,CAAC,EACxD;EARQ;EACA;EACA;AAOT,OAAK,OAAO;CACZ;AACD;;AAGD,SAAS,SAASA,QAAyB;AAC1C,MAAK,MAAM,QAAQ,OAAO,CAAE,QAAO,OAAO,OAAO;AAEjD,QAAO,OACL,IAAI,CAACC,UAAkC;EACvC,MAAM,OAAO,MAAM,MAChB,IAAI,CAAC,mBACC,YAAY,WAAW,OAAO,QAAQ,IAAI,GAAG,OAAO,QAAQ,CACnE,CACA,KAAK,IAAI;AAEX,SAAO,QAAQ,EAAE,KAAK,IAAI,MAAM,QAAQ,IAAI,MAAM;CAClD,EAAC,CACD,KAAK,KAAK;AACZ"}
1
+ {"version":3,"file":"credential.mjs","names":[],"sources":["../src/credential.ts"],"sourcesContent":["/**\n * `Credential` — a third-party credential with a shape.\n *\n * The answer to the design's first open question, \"where does `Secret` sit?\".\n * It sits beside a secret rather than replacing it, because the two differ by\n * *lifecycle* and that is the only difference worth two kinds for: a secret is\n * generated and rotated by the platform and is one opaque string, while a\n * credential is issued by someone else, arrives with several fields, and is\n * worth validating on the way in.\n *\n * ```ts\n * export const stripe = new Credential('Stripe', {\n * schema: z.object({ secretKey: z.string(), webhookSecret: z.string() }),\n * });\n *\n * // in a handler — no await, already parsed and validated\n * services.stripe.secretKey\n * ```\n *\n * **Nothing about it is async at the call site**, which is the part that looks\n * like it should be hard and is not. `Service.register()` may return a promise\n * and `ServiceDiscovery` awaits every one before a handler runs, so fetching a\n * value and validating it — including when a StandardSchema's `~standard.validate`\n * returns a promise of its own — both happen inside that existing seam.\n *\n * **One key holding JSON, not one key per field.** That is the shape a secret\n * manager stores, and it is the only shape that works with an arbitrary\n * StandardSchema: the spec has no introspection API, so enumerating a schema's\n * fields means reaching into one library's internals (`.shape`) and being wrong\n * for every other.\n */\n\nimport {\n\ttype ConstructName,\n\tcanonicalId,\n\ttype Declaration,\n\tprovideKey,\n\tserviceKey,\n} from '@geekmidas/manifest';\nimport { parseSchema } from '@geekmidas/schema/parser';\nimport type { Service, ServiceRegisterOptions } from '@geekmidas/services';\nimport type { StandardSchemaV1 } from '@standard-schema/spec';\nimport type { Consumable } from './construct-interface';\n\n/** What a credential's schema yields. */\ntype Value<TSchema extends StandardSchemaV1> =\n\tStandardSchemaV1.InferOutput<TSchema>;\n\nexport interface CredentialOptions<TSchema extends StandardSchemaV1> {\n\t/**\n\t * What the credential must look like.\n\t *\n\t * Validated at registration, so a malformed or half-set credential fails\n\t * when the process starts rather than on the first request that needs the\n\t * one field somebody forgot.\n\t */\n\tschema: TSchema;\n\t/**\n\t * Re-resolve on every registration instead of once per process.\n\t *\n\t * Off by default: a credential is resolved once and reused, because the\n\t * alternative is a fetch on every request. The cost of that default is that\n\t * a rotated credential needs a restart, which is the right trade for a value\n\t * that changes a few times a year — and this is the escape hatch for when it\n\t * is not.\n\t */\n\trefresh?: boolean;\n}\n\nexport class Credential<\n\tTName extends string = string,\n\tTSchema extends StandardSchemaV1 = StandardSchemaV1,\n> implements Consumable<TName, Value<TSchema>>\n{\n\t// `Consumable` rather than `Construct`, and not by preference: `Construct`\n\t// types its service as `[TClient] extends [never] ? never : Service<…>` so\n\t// that a `Cron` cannot be depended on, and TypeScript cannot evaluate that\n\t// conditional while `TClient` is still a type parameter. Every construct\n\t// with a concrete client satisfies `Construct`; the first one whose client\n\t// is generic cannot. `Consumable` is the face `.dependsOn()` requires and\n\t// carries no conditional, so it is the honest annotation here.\n\treadonly id: TName;\n\treadonly service: Service<Uncapitalize<TName>, Value<TSchema>>;\n\n\t/**\n\t * Declared once and read by both `declare()` and `connect()`, so the key the\n\t * target publishes and the key the client reads cannot drift.\n\t */\n\tprivate readonly keys: { credential: string };\n\n\t/**\n\t * The resolved value, held as the *promise* rather than the value.\n\t *\n\t * Caching the promise is what makes two concurrent registrations share one\n\t * resolution: caching the value would let both start before either finished,\n\t * which is a duplicated fetch every cold start rather than never.\n\t */\n\tprivate resolved?: Promise<Value<TSchema>>;\n\n\tconstructor(\n\t\tid: ConstructName<TName>,\n\t\tprivate readonly options: CredentialOptions<TSchema>,\n\t) {\n\t\tconst canonical = canonicalId(id as string);\n\n\t\tthis.id = canonical as TName;\n\t\tthis.keys = { credential: provideKey(canonical, 'credential') };\n\n\t\t// A field, not a getter: consumers cache services by object identity.\n\t\tthis.service = {\n\t\t\tserviceName: serviceKey(canonical) as Uncapitalize<TName>,\n\t\t\tregister: (registerOptions) => this.connect(registerOptions),\n\t\t};\n\t}\n\n\tdeclare(): Declaration[] {\n\t\treturn [\n\t\t\t{\n\t\t\t\tkind: 'credential',\n\t\t\t\tid: this.id,\n\t\t\t\tprovides: [this.keys.credential],\n\t\t\t},\n\t\t];\n\t}\n\n\tprivate connect(options: ServiceRegisterOptions): Promise<Value<TSchema>> {\n\t\tif (this.options.refresh) return this.resolve(options);\n\n\t\tthis.resolved ??= this.resolve(options);\n\n\t\treturn this.resolved;\n\t}\n\n\tprivate async resolve(\n\t\toptions: ServiceRegisterOptions,\n\t): Promise<Value<TSchema>> {\n\t\tconst { raw } = options.envParser\n\t\t\t.create((get) => ({ raw: get(this.keys.credential).string() }))\n\t\t\t.parse();\n\n\t\ttry {\n\t\t\treturn await parseSchema(this.options.schema, decode(raw));\n\t\t} catch (issues) {\n\t\t\tthrow new MalformedCredential(this.id, this.keys.credential, issues);\n\t\t}\n\t}\n}\n\n/**\n * The raw environment value as the thing the schema should see.\n *\n * JSON when it is JSON, and the string itself when it is not — a credential\n * with a single opaque field is ordinary, and requiring `\"…\"` around it would\n * be ceremony that every operator setting one by hand would get wrong once.\n */\nfunction decode(raw: string): unknown {\n\tconst value = raw.startsWith(JSON_SCHEME)\n\t\t? raw.slice(JSON_SCHEME.length)\n\t\t: raw;\n\n\ttry {\n\t\treturn JSON.parse(value);\n\t} catch {\n\t\treturn value;\n\t}\n}\n\n/**\n * The explicit form, for the case a credential legitimately *is* a JSON string\n * and must not be parsed into an object. Rare, and cheaper to support than to\n * explain.\n */\nconst JSON_SCHEME = 'json:';\n\n/** A credential was set, and is not what its schema says it should be. */\nexport class MalformedCredential extends Error {\n\tconstructor(\n\t\treadonly id: string,\n\t\treadonly key: string,\n\t\treadonly issues: unknown,\n\t) {\n\t\tsuper(\n\t\t\t`${key} is not a valid ${id} credential. ` +\n\t\t\t\t`It is validated where it is read, so this is the value that is set ` +\n\t\t\t\t`rather than the code that uses it: ${describe(issues)}`,\n\t\t);\n\t\tthis.name = 'MalformedCredential';\n\t}\n}\n\n/** StandardSchema issues as one line. */\nfunction describe(issues: unknown): string {\n\tif (!Array.isArray(issues)) return String(issues);\n\n\treturn issues\n\t\t.map((issue: StandardSchemaV1.Issue) => {\n\t\t\tconst path = issue.path\n\t\t\t\t?.map((segment) =>\n\t\t\t\t\ttypeof segment === 'object' ? String(segment.key) : String(segment),\n\t\t\t\t)\n\t\t\t\t.join('.');\n\n\t\t\treturn path ? `${path}: ${issue.message}` : issue.message;\n\t\t})\n\t\t.join('; ');\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqEA,IAAa,aAAb,MAIA;CA4BmB;CApBlB;CACA;;;;;CAMA;;;;;;;;CASA;CAEA,YACC,IACA,SACC;EADgB,KAAA,UAAA;EAEjB,MAAM,YAAY,YAAY,EAAY;EAE1C,KAAK,KAAK;EACV,KAAK,OAAO,EAAE,YAAY,WAAW,WAAW,YAAY,EAAE;EAG9D,KAAK,UAAU;GACd,aAAa,WAAW,SAAS;GACjC,WAAW,oBAAoB,KAAK,QAAQ,eAAe;EAC5D;CACD;CAEA,UAAyB;EACxB,OAAO,CACN;GACC,MAAM;GACN,IAAI,KAAK;GACT,UAAU,CAAC,KAAK,KAAK,UAAU;EAChC,CACD;CACD;CAEA,QAAgB,SAA0D;EACzE,IAAI,KAAK,QAAQ,SAAS,OAAO,KAAK,QAAQ,OAAO;EAErD,KAAK,aAAa,KAAK,QAAQ,OAAO;EAEtC,OAAO,KAAK;CACb;CAEA,MAAc,QACb,SAC0B;EAC1B,MAAM,EAAE,QAAQ,QAAQ,UACtB,QAAQ,SAAS,EAAE,KAAK,IAAI,KAAK,KAAK,UAAU,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,CAC9D,MAAM;EAER,IAAI;GACH,OAAO,MAAM,YAAY,KAAK,QAAQ,QAAQ,OAAO,GAAG,CAAC;EAC1D,SAAS,QAAQ;GAChB,MAAM,IAAI,oBAAoB,KAAK,IAAI,KAAK,KAAK,YAAY,MAAM;EACpE;CACD;AACD;;;;;;;;AASA,SAAS,OAAO,KAAsB;CACrC,MAAM,QAAQ,IAAI,WAAW,WAAW,IACrC,IAAI,MAAM,YAAY,MAAM,IAC5B;CAEH,IAAI;EACH,OAAO,KAAK,MAAM,KAAK;CACxB,QAAQ;EACP,OAAO;CACR;AACD;;;;;;AAOA,MAAM,cAAc;;AAGpB,IAAa,sBAAb,cAAyC,MAAM;CAEpC;CACA;CACA;CAHV,YACC,IACA,KACA,QACC;EACD,MACC,GAAG,IAAI,kBAAkB,GAAG,qHAEW,SAAS,MAAM,GACvD;EARS,KAAA,KAAA;EACA,KAAA,MAAA;EACA,KAAA,SAAA;EAOT,KAAK,OAAO;CACb;AACD;;AAGA,SAAS,SAAS,QAAyB;CAC1C,IAAI,CAAC,MAAM,QAAQ,MAAM,GAAG,OAAO,OAAO,MAAM;CAEhD,OAAO,OACL,KAAK,UAAkC;EACvC,MAAM,OAAO,MAAM,MAChB,KAAK,YACN,OAAO,YAAY,WAAW,OAAO,QAAQ,GAAG,IAAI,OAAO,OAAO,CACnE,CAAC,CACA,KAAK,GAAG;EAEV,OAAO,OAAO,GAAG,KAAK,IAAI,MAAM,YAAY,MAAM;CACnD,CAAC,CAAC,CACD,KAAK,IAAI;AACZ"}
@@ -1,9 +1,5 @@
1
- require('../construct-interface-BfjcOD_E.cjs');
2
- require('../Construct-CyS3RpTL.cjs');
3
- require('../functions-i_la-N5r.cjs');
4
- require('../clone-Dy0cR2SZ.cjs');
5
- const require_CronBuilder = require('../CronBuilder-Da0C0edR.cjs');
6
-
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ const require_CronBuilder = require("../CronBuilder-BdnI6lxF.cjs");
7
3
  //#region src/crons/schedule.ts
8
4
  /**
9
5
  * A schedule a cron runner can take, as standard five-field cron.
@@ -24,6 +20,7 @@ const require_CronBuilder = require('../CronBuilder-Da0C0edR.cjs');
24
20
  * adjusted by the framework is a bug nobody goes looking for.
25
21
  */
26
22
  var UnrepresentableSchedule = class extends Error {
23
+ schedule;
27
24
  constructor(schedule, reason) {
28
25
  super(`\`${schedule}\` has no exact cron equivalent: ${reason}.\n\nCron says *when*, not *how often*, so an interval is only exact when it divides its unit evenly.
29
26
  Write the schedule you mean instead — \`cron(0 */6 * * *)\` for every sixth hour, say — or pick an interval that divides: minutes into 60, hours into 24.`);
@@ -66,10 +63,10 @@ function toCronExpression(schedule) {
66
63
  throw new UnrepresentableSchedule(schedule, "day-of-month restarts every month, so no multi-day interval is even");
67
64
  }
68
65
  }
69
-
70
66
  //#endregion
71
67
  exports.Cron = require_CronBuilder.Cron;
72
68
  exports.CronBuilder = require_CronBuilder.CronBuilder;
73
69
  exports.UnrepresentableSchedule = UnrepresentableSchedule;
74
70
  exports.toCronExpression = toCronExpression;
71
+
75
72
  //# sourceMappingURL=index.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","names":["schedule: string","reason: string","schedule: ScheduleExpression"],"sources":["../../src/crons/schedule.ts"],"sourcesContent":["import type { ScheduleExpression } from './Cron';\n\n/**\n * A schedule a cron runner can take, as standard five-field cron.\n *\n * `ScheduleExpression` has two spellings. `cron(m h dom mon dow)` is already\n * five-field cron and unwraps; `rate(n unit)` is an interval, and an interval\n * is not a schedule — it says how often, where cron says when.\n *\n * Most intervals still have an exact cron equivalent, because they divide their\n * unit evenly: `rate(5 minutes)` is every fifth minute of every hour, and that\n * is `*​/5 * * * *` precisely. `rate(7 hours)` has none. There is no cron field\n * that means \"every seven hours\" — `*​/7` in the hour field fires at 0, 7, 14\n * and 21 and then starts over at midnight, so the gap between the last firing\n * of one day and the first of the next is three hours rather than seven.\n *\n * Those are refused rather than rounded. A job that runs at the wrong hour is\n * far harder to notice than one that refused to build, and a schedule quietly\n * adjusted by the framework is a bug nobody goes looking for.\n */\nexport class UnrepresentableSchedule extends Error {\n\tconstructor(\n\t\treadonly schedule: string,\n\t\treason: string,\n\t) {\n\t\tsuper(\n\t\t\t`\\`${schedule}\\` has no exact cron equivalent: ${reason}.\\n\\n` +\n\t\t\t\t'Cron says *when*, not *how often*, so an interval is only exact when ' +\n\t\t\t\t'it divides its unit evenly.\\n' +\n\t\t\t\t'Write the schedule you mean instead — `cron(0 */6 * * *)` for every ' +\n\t\t\t\t'sixth hour, say — or pick an interval that divides: minutes into 60, ' +\n\t\t\t\t'hours into 24.',\n\t\t);\n\t\tthis.name = 'UnrepresentableSchedule';\n\t}\n}\n\n/** Units `rate(…)` accepts, singular or plural. */\nconst UNITS = ['minute', 'hour', 'day'] as const;\ntype Unit = (typeof UNITS)[number];\n\n/**\n * Standard five-field cron for a schedule expression.\n *\n * @throws {UnrepresentableSchedule} when a `rate(…)` has no exact equivalent.\n */\nexport function toCronExpression(schedule: ScheduleExpression): string {\n\tconst cron = /^cron\\((.+)\\)$/.exec(schedule);\n\tif (cron?.[1]) return cron[1].trim();\n\n\tconst rate = /^rate\\(\\s*(\\d+)\\s+(\\w+?)s?\\s*\\)$/.exec(schedule);\n\tif (!rate) {\n\t\tthrow new UnrepresentableSchedule(\n\t\t\tschedule,\n\t\t\t'it is neither `cron(…)` nor `rate(n unit)`',\n\t\t);\n\t}\n\n\tconst every = Number(rate[1]);\n\tconst unit = rate[2] as Unit;\n\t/* c8 ignore next */ if (!unit)\n\t\tthrow new UnrepresentableSchedule(schedule, 'no unit');\n\n\tif (!UNITS.includes(unit)) {\n\t\tthrow new UnrepresentableSchedule(\n\t\t\tschedule,\n\t\t\t`\\`${unit}\\` is not one of ${UNITS.join(', ')}`,\n\t\t);\n\t}\n\n\tif (every < 1) {\n\t\tthrow new UnrepresentableSchedule(\n\t\t\tschedule,\n\t\t\t'an interval must be at least 1',\n\t\t);\n\t}\n\n\tswitch (unit) {\n\t\tcase 'minute':\n\t\t\tif (every === 1) return '* * * * *';\n\t\t\tif (60 % every !== 0) {\n\t\t\t\tthrow new UnrepresentableSchedule(\n\t\t\t\t\tschedule,\n\t\t\t\t\t`${every} does not divide 60, so the interval would reset at the top of each hour`,\n\t\t\t\t);\n\t\t\t}\n\t\t\treturn `*/${every} * * * *`;\n\n\t\tcase 'hour':\n\t\t\tif (every === 1) return '0 * * * *';\n\t\t\tif (24 % every !== 0) {\n\t\t\t\tthrow new UnrepresentableSchedule(\n\t\t\t\t\tschedule,\n\t\t\t\t\t`${every} does not divide 24, so the interval would reset at midnight`,\n\t\t\t\t);\n\t\t\t}\n\t\t\treturn `0 */${every} * * *`;\n\n\t\tcase 'day':\n\t\t\tif (every === 1) return '0 0 * * *';\n\t\t\t// `*/n` in day-of-month restarts on the 1st, so a 2-day interval fires\n\t\t\t// on the 1st and 3rd of a 31-day month and then again on the 1st — one\n\t\t\t// day later, not two. No month length makes that come out even.\n\t\t\tthrow new UnrepresentableSchedule(\n\t\t\t\tschedule,\n\t\t\t\t'day-of-month restarts every month, so no multi-day interval is even',\n\t\t\t);\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAoBA,IAAa,0BAAb,cAA6C,MAAM;CAClD,YACUA,UACTC,QACC;AACD,SACE,IAAI,SAAS,mCAAmC,OAAO;2JAMxD;EAVQ;AAWT,OAAK,OAAO;CACZ;AACD;;AAGD,MAAM,QAAQ;CAAC;CAAU;CAAQ;AAAM;;;;;;AAQvC,SAAgB,iBAAiBC,UAAsC;CACtE,MAAM,OAAO,iBAAiB,KAAK,SAAS;AAC5C,KAAI,OAAO,GAAI,QAAO,KAAK,GAAG,MAAM;CAEpC,MAAM,OAAO,mCAAmC,KAAK,SAAS;AAC9D,MAAK,KACJ,OAAM,IAAI,wBACT,UACA;CAIF,MAAM,QAAQ,OAAO,KAAK,GAAG;CAC7B,MAAM,OAAO,KAAK;qBACG,MAAK,KACzB,OAAM,IAAI,wBAAwB,UAAU;AAE7C,MAAK,MAAM,SAAS,KAAK,CACxB,OAAM,IAAI,wBACT,WACC,IAAI,KAAK,mBAAmB,MAAM,KAAK,KAAK,CAAC;AAIhD,KAAI,QAAQ,EACX,OAAM,IAAI,wBACT,UACA;AAIF,SAAQ,MAAR;EACC,KAAK;AACJ,OAAI,UAAU,EAAG,QAAO;AACxB,OAAI,KAAK,UAAU,EAClB,OAAM,IAAI,wBACT,WACC,EAAE,MAAM;AAGX,WAAQ,IAAI,MAAM;EAEnB,KAAK;AACJ,OAAI,UAAU,EAAG,QAAO;AACxB,OAAI,KAAK,UAAU,EAClB,OAAM,IAAI,wBACT,WACC,EAAE,MAAM;AAGX,WAAQ,MAAM,MAAM;EAErB,KAAK;AACJ,OAAI,UAAU,EAAG,QAAO;AAIxB,SAAM,IAAI,wBACT,UACA;CAEF;AACD"}
1
+ {"version":3,"file":"index.cjs","names":[],"sources":["../../src/crons/schedule.ts"],"sourcesContent":["import type { ScheduleExpression } from './Cron';\n\n/**\n * A schedule a cron runner can take, as standard five-field cron.\n *\n * `ScheduleExpression` has two spellings. `cron(m h dom mon dow)` is already\n * five-field cron and unwraps; `rate(n unit)` is an interval, and an interval\n * is not a schedule — it says how often, where cron says when.\n *\n * Most intervals still have an exact cron equivalent, because they divide their\n * unit evenly: `rate(5 minutes)` is every fifth minute of every hour, and that\n * is `*​/5 * * * *` precisely. `rate(7 hours)` has none. There is no cron field\n * that means \"every seven hours\" — `*​/7` in the hour field fires at 0, 7, 14\n * and 21 and then starts over at midnight, so the gap between the last firing\n * of one day and the first of the next is three hours rather than seven.\n *\n * Those are refused rather than rounded. A job that runs at the wrong hour is\n * far harder to notice than one that refused to build, and a schedule quietly\n * adjusted by the framework is a bug nobody goes looking for.\n */\nexport class UnrepresentableSchedule extends Error {\n\tconstructor(\n\t\treadonly schedule: string,\n\t\treason: string,\n\t) {\n\t\tsuper(\n\t\t\t`\\`${schedule}\\` has no exact cron equivalent: ${reason}.\\n\\n` +\n\t\t\t\t'Cron says *when*, not *how often*, so an interval is only exact when ' +\n\t\t\t\t'it divides its unit evenly.\\n' +\n\t\t\t\t'Write the schedule you mean instead — `cron(0 */6 * * *)` for every ' +\n\t\t\t\t'sixth hour, say — or pick an interval that divides: minutes into 60, ' +\n\t\t\t\t'hours into 24.',\n\t\t);\n\t\tthis.name = 'UnrepresentableSchedule';\n\t}\n}\n\n/** Units `rate(…)` accepts, singular or plural. */\nconst UNITS = ['minute', 'hour', 'day'] as const;\ntype Unit = (typeof UNITS)[number];\n\n/**\n * Standard five-field cron for a schedule expression.\n *\n * @throws {UnrepresentableSchedule} when a `rate(…)` has no exact equivalent.\n */\nexport function toCronExpression(schedule: ScheduleExpression): string {\n\tconst cron = /^cron\\((.+)\\)$/.exec(schedule);\n\tif (cron?.[1]) return cron[1].trim();\n\n\tconst rate = /^rate\\(\\s*(\\d+)\\s+(\\w+?)s?\\s*\\)$/.exec(schedule);\n\tif (!rate) {\n\t\tthrow new UnrepresentableSchedule(\n\t\t\tschedule,\n\t\t\t'it is neither `cron(…)` nor `rate(n unit)`',\n\t\t);\n\t}\n\n\tconst every = Number(rate[1]);\n\tconst unit = rate[2] as Unit;\n\t/* c8 ignore next */ if (!unit)\n\t\tthrow new UnrepresentableSchedule(schedule, 'no unit');\n\n\tif (!UNITS.includes(unit)) {\n\t\tthrow new UnrepresentableSchedule(\n\t\t\tschedule,\n\t\t\t`\\`${unit}\\` is not one of ${UNITS.join(', ')}`,\n\t\t);\n\t}\n\n\tif (every < 1) {\n\t\tthrow new UnrepresentableSchedule(\n\t\t\tschedule,\n\t\t\t'an interval must be at least 1',\n\t\t);\n\t}\n\n\tswitch (unit) {\n\t\tcase 'minute':\n\t\t\tif (every === 1) return '* * * * *';\n\t\t\tif (60 % every !== 0) {\n\t\t\t\tthrow new UnrepresentableSchedule(\n\t\t\t\t\tschedule,\n\t\t\t\t\t`${every} does not divide 60, so the interval would reset at the top of each hour`,\n\t\t\t\t);\n\t\t\t}\n\t\t\treturn `*/${every} * * * *`;\n\n\t\tcase 'hour':\n\t\t\tif (every === 1) return '0 * * * *';\n\t\t\tif (24 % every !== 0) {\n\t\t\t\tthrow new UnrepresentableSchedule(\n\t\t\t\t\tschedule,\n\t\t\t\t\t`${every} does not divide 24, so the interval would reset at midnight`,\n\t\t\t\t);\n\t\t\t}\n\t\t\treturn `0 */${every} * * *`;\n\n\t\tcase 'day':\n\t\t\tif (every === 1) return '0 0 * * *';\n\t\t\t// `*/n` in day-of-month restarts on the 1st, so a 2-day interval fires\n\t\t\t// on the 1st and 3rd of a 31-day month and then again on the 1st — one\n\t\t\t// day later, not two. No month length makes that come out even.\n\t\t\tthrow new UnrepresentableSchedule(\n\t\t\t\tschedule,\n\t\t\t\t'day-of-month restarts every month, so no multi-day interval is even',\n\t\t\t);\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAoBA,IAAa,0BAAb,cAA6C,MAAM;CAExC;CADV,YACC,UACA,QACC;EACD,MACC,KAAK,SAAS,mCAAmC,OAAO;0JAMzD;EAVS,KAAA,WAAA;EAWT,KAAK,OAAO;CACb;AACD;;AAGA,MAAM,QAAQ;CAAC;CAAU;CAAQ;AAAK;;;;;;AAQtC,SAAgB,iBAAiB,UAAsC;CACtE,MAAM,OAAO,iBAAiB,KAAK,QAAQ;CAC3C,IAAI,OAAO,IAAI,OAAO,KAAK,EAAE,CAAC,KAAK;CAEnC,MAAM,OAAO,mCAAmC,KAAK,QAAQ;CAC7D,IAAI,CAAC,MACJ,MAAM,IAAI,wBACT,UACA,4CACD;CAGD,MAAM,QAAQ,OAAO,KAAK,EAAE;CAC5B,MAAM,OAAO,KAAK;sBACG,IAAI,CAAC,MACzB,MAAM,IAAI,wBAAwB,UAAU,SAAS;CAEtD,IAAI,CAAC,MAAM,SAAS,IAAI,GACvB,MAAM,IAAI,wBACT,UACA,KAAK,KAAK,mBAAmB,MAAM,KAAK,IAAI,GAC7C;CAGD,IAAI,QAAQ,GACX,MAAM,IAAI,wBACT,UACA,gCACD;CAGD,QAAQ,MAAR;EACC,KAAK;GACJ,IAAI,UAAU,GAAG,OAAO;GACxB,IAAI,KAAK,UAAU,GAClB,MAAM,IAAI,wBACT,UACA,GAAG,MAAM,yEACV;GAED,OAAO,KAAK,MAAM;EAEnB,KAAK;GACJ,IAAI,UAAU,GAAG,OAAO;GACxB,IAAI,KAAK,UAAU,GAClB,MAAM,IAAI,wBACT,UACA,GAAG,MAAM,6DACV;GAED,OAAO,OAAO,MAAM;EAErB,KAAK;GACJ,IAAI,UAAU,GAAG,OAAO;GAIxB,MAAM,IAAI,wBACT,UACA,qEACD;CACF;AACD"}
@@ -1,11 +1,6 @@
1
- import "../Construct-C0ijr2qp.cjs";
2
- import "../index-D24Xm79M.cjs";
3
- import "../construct-interface-D9d4Gm4p.cjs";
4
- import { Cron, CronExpression, RateExpression, ScheduleExpression } from "../Cron-DmQ8vQ4b.cjs";
5
- import { CronBuilder } from "../CronBuilder-BquXDbDI.cjs";
6
-
1
+ import { i as ScheduleExpression, n as CronExpression, r as RateExpression, t as Cron } from "../Cron-DKqnnTdH.cjs";
2
+ import { t as CronBuilder } from "../CronBuilder-Df1q9PNy.cjs";
7
3
  //#region src/crons/schedule.d.ts
8
-
9
4
  /**
10
5
  * A schedule a cron runner can take, as standard five-field cron.
11
6
  *
@@ -24,7 +19,7 @@ import { CronBuilder } from "../CronBuilder-BquXDbDI.cjs";
24
19
  * far harder to notice than one that refused to build, and a schedule quietly
25
20
  * adjusted by the framework is a bug nobody goes looking for.
26
21
  */
27
- declare class UnrepresentableSchedule extends Error {
22
+ export declare class UnrepresentableSchedule extends Error {
28
23
  readonly schedule: string;
29
24
  constructor(schedule: string, reason: string);
30
25
  }
@@ -33,8 +28,7 @@ declare class UnrepresentableSchedule extends Error {
33
28
  *
34
29
  * @throws {UnrepresentableSchedule} when a `rate(…)` has no exact equivalent.
35
30
  */
36
- declare function toCronExpression(schedule: ScheduleExpression): string;
37
- //# sourceMappingURL=schedule.d.ts.map
31
+ export declare function toCronExpression(schedule: ScheduleExpression): string;
38
32
  //#endregion
39
- export { Cron, CronBuilder, CronExpression, RateExpression, ScheduleExpression, UnrepresentableSchedule, toCronExpression };
33
+ export { Cron, CronBuilder, type CronExpression, type RateExpression, type ScheduleExpression };
40
34
  //# sourceMappingURL=index.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.cts","names":[],"sources":["../../src/crons/schedule.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;;;;;AAoBA;AA0BA;;;;;;;;;;;cA1Ba,uBAAA,SAAgC,KAAK;;;;;;;;;iBA0BlC,gBAAA,WAA2B"}
1
+ {"version":3,"file":"index.d.cts","names":[],"sources":["../../src/crons/schedule.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;qBAoBa,gCAAgC;WAElC;EAAA,YAAA,kBACT;;;;;;;wBAuBc,iBAAiB,UAAU"}
@@ -1,11 +1,6 @@
1
- import "../Construct-Ct8nalEi.mjs";
2
- import "../index-_ajboYxK.mjs";
3
- import "../construct-interface-g5GM5pwR.mjs";
4
- import { Cron, CronExpression, RateExpression, ScheduleExpression } from "../Cron-dh4rUgib.mjs";
5
- import { CronBuilder } from "../CronBuilder-CGgY2080.mjs";
6
-
1
+ import { i as ScheduleExpression, n as CronExpression, r as RateExpression, t as Cron } from "../Cron-SyqS5oWJ.mjs";
2
+ import { t as CronBuilder } from "../CronBuilder-CRGnDfTq.mjs";
7
3
  //#region src/crons/schedule.d.ts
8
-
9
4
  /**
10
5
  * A schedule a cron runner can take, as standard five-field cron.
11
6
  *
@@ -24,7 +19,7 @@ import { CronBuilder } from "../CronBuilder-CGgY2080.mjs";
24
19
  * far harder to notice than one that refused to build, and a schedule quietly
25
20
  * adjusted by the framework is a bug nobody goes looking for.
26
21
  */
27
- declare class UnrepresentableSchedule extends Error {
22
+ export declare class UnrepresentableSchedule extends Error {
28
23
  readonly schedule: string;
29
24
  constructor(schedule: string, reason: string);
30
25
  }
@@ -33,8 +28,7 @@ declare class UnrepresentableSchedule extends Error {
33
28
  *
34
29
  * @throws {UnrepresentableSchedule} when a `rate(…)` has no exact equivalent.
35
30
  */
36
- declare function toCronExpression(schedule: ScheduleExpression): string;
37
- //# sourceMappingURL=schedule.d.ts.map
31
+ export declare function toCronExpression(schedule: ScheduleExpression): string;
38
32
  //#endregion
39
- export { Cron, CronBuilder, CronExpression, RateExpression, ScheduleExpression, UnrepresentableSchedule, toCronExpression };
33
+ export { Cron, CronBuilder, type CronExpression, type RateExpression, type ScheduleExpression };
40
34
  //# sourceMappingURL=index.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.mts","names":[],"sources":["../../src/crons/schedule.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;;;;;AAoBA;AA0BA;;;;;;;;;;;cA1Ba,uBAAA,SAAgC,KAAK;;;;;;;;;iBA0BlC,gBAAA,WAA2B"}
1
+ {"version":3,"file":"index.d.mts","names":[],"sources":["../../src/crons/schedule.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;qBAoBa,gCAAgC;WAElC;EAAA,YAAA,kBACT;;;;;;;wBAuBc,iBAAiB,UAAU"}
@@ -1,9 +1,4 @@
1
- import "../Construct-BD5neF7w.mjs";
2
- import "../construct-interface-Z4CpS8tK.mjs";
3
- import "../functions-14lpEFL4.mjs";
4
- import "../clone-DblgEZZa.mjs";
5
- import { Cron, CronBuilder } from "../CronBuilder-CYKT5RiO.mjs";
6
-
1
+ import { n as Cron, t as CronBuilder } from "../CronBuilder-D_0HNBTr.mjs";
7
2
  //#region src/crons/schedule.ts
8
3
  /**
9
4
  * A schedule a cron runner can take, as standard five-field cron.
@@ -24,6 +19,7 @@ import { Cron, CronBuilder } from "../CronBuilder-CYKT5RiO.mjs";
24
19
  * adjusted by the framework is a bug nobody goes looking for.
25
20
  */
26
21
  var UnrepresentableSchedule = class extends Error {
22
+ schedule;
27
23
  constructor(schedule, reason) {
28
24
  super(`\`${schedule}\` has no exact cron equivalent: ${reason}.\n\nCron says *when*, not *how often*, so an interval is only exact when it divides its unit evenly.
29
25
  Write the schedule you mean instead — \`cron(0 */6 * * *)\` for every sixth hour, say — or pick an interval that divides: minutes into 60, hours into 24.`);
@@ -66,7 +62,7 @@ function toCronExpression(schedule) {
66
62
  throw new UnrepresentableSchedule(schedule, "day-of-month restarts every month, so no multi-day interval is even");
67
63
  }
68
64
  }
69
-
70
65
  //#endregion
71
66
  export { Cron, CronBuilder, UnrepresentableSchedule, toCronExpression };
67
+
72
68
  //# sourceMappingURL=index.mjs.map