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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (333) hide show
  1. package/README.md +46 -3
  2. package/dist/{Construct-Ct8nalEi.d.mts → Construct-DTqYvkPG.d.cts} +11 -13
  3. package/dist/Construct-DTqYvkPG.d.cts.map +1 -0
  4. package/dist/{Construct-BD5neF7w.mjs → Construct-Detz65RA.mjs} +31 -29
  5. package/dist/Construct-Detz65RA.mjs.map +1 -0
  6. package/dist/{Construct-C0ijr2qp.d.cts → Construct-pVadmURD.d.mts} +10 -12
  7. package/dist/Construct-pVadmURD.d.mts.map +1 -0
  8. package/dist/{Construct-CyS3RpTL.cjs → Construct-yG9Sw-5p.cjs} +51 -43
  9. package/dist/Construct-yG9Sw-5p.cjs.map +1 -0
  10. package/dist/{Cron-ByxdOfpE.d.mts → Cron-AYpQq725.d.mts} +13 -6
  11. package/dist/Cron-AYpQq725.d.mts.map +1 -0
  12. package/dist/{Cron-Wqh464aO.d.cts → Cron-Bdcg9OAL.d.cts} +12 -5
  13. package/dist/Cron-Bdcg9OAL.d.cts.map +1 -0
  14. package/dist/{CronBuilder-BL0AP6fs.d.mts → CronBuilder-DR21m9h2.d.cts} +7 -10
  15. package/dist/CronBuilder-DR21m9h2.d.cts.map +1 -0
  16. package/dist/{CronBuilder-BqpEzMPQ.d.cts → CronBuilder-DeBnPVIT.d.mts} +7 -10
  17. package/dist/CronBuilder-DeBnPVIT.d.mts.map +1 -0
  18. package/dist/{CronBuilder-BmABazzH.mjs → CronBuilder-vkjuo1UP.mjs} +23 -15
  19. package/dist/CronBuilder-vkjuo1UP.mjs.map +1 -0
  20. package/dist/{CronBuilder-CkXPJiGO.cjs → CronBuilder-zdTdaT-e.cjs} +33 -25
  21. package/dist/CronBuilder-zdTdaT-e.cjs.map +1 -0
  22. package/dist/{Endpoint-2Wg7T7Cq.d.mts → Endpoint-BxkRWQ8G.d.mts} +63 -84
  23. package/dist/Endpoint-BxkRWQ8G.d.mts.map +1 -0
  24. package/dist/{Endpoint-BiaaMEn_.cjs → Endpoint-CtiPUpRX.cjs} +145 -131
  25. package/dist/Endpoint-CtiPUpRX.cjs.map +1 -0
  26. package/dist/{Endpoint-VIOpSo0S.mjs → Endpoint-DCr5tlbJ.mjs} +117 -109
  27. package/dist/Endpoint-DCr5tlbJ.mjs.map +1 -0
  28. package/dist/{Endpoint-CH9Fn1AD.d.cts → Endpoint-DbYQJgb-.d.cts} +61 -82
  29. package/dist/Endpoint-DbYQJgb-.d.cts.map +1 -0
  30. package/dist/{EndpointFactory-DTTCkGEL.mjs → EndpointFactory-Bs8pu-yY.mjs} +20 -29
  31. package/dist/EndpointFactory-Bs8pu-yY.mjs.map +1 -0
  32. package/dist/{index-BxHDdy6a.d.mts → EndpointFactory-DE6nKtFZ.d.cts} +12 -92
  33. package/dist/EndpointFactory-DE6nKtFZ.d.cts.map +1 -0
  34. package/dist/{index-V2nksZIJ.d.cts → EndpointFactory-T06kTFHg.d.mts} +12 -92
  35. package/dist/EndpointFactory-T06kTFHg.d.mts.map +1 -0
  36. package/dist/{EndpointFactory-ChxLZllA.cjs → EndpointFactory-vE2C1NG1.cjs} +57 -66
  37. package/dist/EndpointFactory-vE2C1NG1.cjs.map +1 -0
  38. package/dist/{HonoEndpointAdaptor-NKQQQbBY.mjs → HonoEndpointAdaptor-Be6UdK0r.mjs} +40 -47
  39. package/dist/{HonoEndpointAdaptor-D233Jvpk.cjs.map → HonoEndpointAdaptor-Be6UdK0r.mjs.map} +1 -1
  40. package/dist/{HonoEndpointAdaptor-D233Jvpk.cjs → HonoEndpointAdaptor-C9aivwKl.cjs} +48 -52
  41. package/dist/HonoEndpointAdaptor-C9aivwKl.cjs.map +1 -0
  42. package/dist/{Queue-D7ZuwBhy.d.cts → Queue-Bhzi2WQC.d.cts} +8 -9
  43. package/dist/Queue-Bhzi2WQC.d.cts.map +1 -0
  44. package/dist/{Queue-gVGfi2Yk.d.mts → Queue-BoUA-e83.d.mts} +9 -10
  45. package/dist/Queue-BoUA-e83.d.mts.map +1 -0
  46. package/dist/{Subscriber-2mEi0ImH.d.cts → Subscriber-CIO3pwji.d.mts} +7 -8
  47. package/dist/Subscriber-CIO3pwji.d.mts.map +1 -0
  48. package/dist/{Subscriber-xTJ9ayPN.d.mts → Subscriber-DQCaiOXF.d.cts} +7 -8
  49. package/dist/Subscriber-DQCaiOXF.d.cts.map +1 -0
  50. package/dist/{SubscriberBuilder-BjkbeT9l.mjs → SubscriberBuilder-B4YRTBng.mjs} +16 -10
  51. package/dist/SubscriberBuilder-B4YRTBng.mjs.map +1 -0
  52. package/dist/{SubscriberBuilder-4OPehf2R.cjs → SubscriberBuilder-C2bCOuPT.cjs} +28 -23
  53. package/dist/SubscriberBuilder-C2bCOuPT.cjs.map +1 -0
  54. package/dist/{SubscriberBuilder-Dptmo-1A.d.mts → SubscriberBuilder-ChX5v948.d.cts} +8 -11
  55. package/dist/SubscriberBuilder-ChX5v948.d.cts.map +1 -0
  56. package/dist/{SubscriberBuilder-waNhzjSM.d.cts → SubscriberBuilder-Dbiaskfi.d.mts} +8 -11
  57. package/dist/SubscriberBuilder-Dbiaskfi.d.mts.map +1 -0
  58. package/dist/{Topic-19QeHBIR.d.cts → Topic-D6blllEn.d.cts} +5 -7
  59. package/dist/Topic-D6blllEn.d.cts.map +1 -0
  60. package/dist/{Topic-DuFeqkBh.d.mts → Topic-DVvheJ_-.d.mts} +6 -8
  61. package/dist/Topic-DVvheJ_-.d.mts.map +1 -0
  62. package/dist/adaptors/aws.cjs +87 -106
  63. package/dist/adaptors/aws.cjs.map +1 -1
  64. package/dist/adaptors/aws.d.cts +14 -27
  65. package/dist/adaptors/aws.d.cts.map +1 -1
  66. package/dist/adaptors/aws.d.mts +16 -29
  67. package/dist/adaptors/aws.d.mts.map +1 -1
  68. package/dist/adaptors/aws.mjs +60 -81
  69. package/dist/adaptors/aws.mjs.map +1 -1
  70. package/dist/adaptors/hono.cjs +3 -10
  71. package/dist/adaptors/hono.d.cts +5 -13
  72. package/dist/adaptors/hono.d.cts.map +1 -1
  73. package/dist/adaptors/hono.d.mts +7 -15
  74. package/dist/adaptors/hono.d.mts.map +1 -1
  75. package/dist/adaptors/hono.mjs +2 -10
  76. package/dist/adaptors/testing.cjs +271 -82
  77. package/dist/adaptors/testing.cjs.map +1 -1
  78. package/dist/adaptors/testing.d.cts +62 -33
  79. package/dist/adaptors/testing.d.cts.map +1 -1
  80. package/dist/adaptors/testing.d.mts +63 -34
  81. package/dist/adaptors/testing.d.mts.map +1 -1
  82. package/dist/adaptors/testing.mjs +249 -63
  83. package/dist/adaptors/testing.mjs.map +1 -1
  84. package/dist/auth-BlO8MUkR.d.cts +123 -0
  85. package/dist/auth-BlO8MUkR.d.cts.map +1 -0
  86. package/dist/auth-CHWIdcQO.d.mts +123 -0
  87. package/dist/auth-CHWIdcQO.d.mts.map +1 -0
  88. package/dist/auth.cjs +41 -16
  89. package/dist/auth.cjs.map +1 -1
  90. package/dist/auth.d.cts +2 -108
  91. package/dist/auth.d.mts +2 -108
  92. package/dist/auth.mjs +32 -8
  93. package/dist/auth.mjs.map +1 -1
  94. package/dist/{cache-BrRz3fEB.d.mts → cache-AgQUMma6.d.mts} +3 -6
  95. package/dist/cache-AgQUMma6.d.mts.map +1 -0
  96. package/dist/{cache-BtZY_tHe.d.cts → cache-obq0fOIM.d.cts} +3 -6
  97. package/dist/cache-obq0fOIM.d.cts.map +1 -0
  98. package/dist/cache.cjs +68 -2
  99. package/dist/cache.cjs.map +1 -0
  100. package/dist/cache.d.cts +1 -2
  101. package/dist/cache.d.mts +1 -2
  102. package/dist/cache.mjs +67 -2
  103. package/dist/cache.mjs.map +1 -0
  104. package/dist/{clone-DblgEZZa.mjs → clone-EKNovYHu.mjs} +3 -3
  105. package/dist/clone-EKNovYHu.mjs.map +1 -0
  106. package/dist/{clone-Dy0cR2SZ.cjs → clone-UGJpvQnL.cjs} +7 -8
  107. package/dist/clone-UGJpvQnL.cjs.map +1 -0
  108. package/dist/{construct-interface-g5GM5pwR.d.mts → construct-interface-Clz7_BwB.d.mts} +15 -6
  109. package/dist/construct-interface-Clz7_BwB.d.mts.map +1 -0
  110. package/dist/{construct-interface-D9d4Gm4p.d.cts → construct-interface-DIaTNKax.d.cts} +15 -6
  111. package/dist/construct-interface-DIaTNKax.d.cts.map +1 -0
  112. package/dist/construct-interface.cjs +87 -7
  113. package/dist/construct-interface.cjs.map +1 -0
  114. package/dist/construct-interface.d.cts +2 -2
  115. package/dist/construct-interface.d.mts +2 -2
  116. package/dist/construct-interface.mjs +81 -2
  117. package/dist/construct-interface.mjs.map +1 -0
  118. package/dist/credential.cjs +43 -9
  119. package/dist/credential.cjs.map +1 -1
  120. package/dist/credential.d.cts +5 -8
  121. package/dist/credential.d.cts.map +1 -1
  122. package/dist/credential.d.mts +5 -8
  123. package/dist/credential.d.mts.map +1 -1
  124. package/dist/credential.mjs +36 -2
  125. package/dist/credential.mjs.map +1 -1
  126. package/dist/crons/index.cjs +68 -10
  127. package/dist/crons/index.cjs.map +1 -1
  128. package/dist/crons/index.d.cts +32 -14
  129. package/dist/crons/index.d.cts.map +1 -1
  130. package/dist/crons/index.d.mts +32 -14
  131. package/dist/crons/index.d.mts.map +1 -1
  132. package/dist/crons/index.mjs +66 -10
  133. package/dist/crons/index.mjs.map +1 -1
  134. package/dist/database/kysely.cjs +28 -14
  135. package/dist/database/kysely.cjs.map +1 -1
  136. package/dist/database/kysely.d.cts +2 -152
  137. package/dist/database/kysely.d.mts +2 -152
  138. package/dist/database/kysely.mjs +16 -4
  139. package/dist/database/kysely.mjs.map +1 -1
  140. package/dist/email.cjs +25 -12
  141. package/dist/email.cjs.map +1 -1
  142. package/dist/email.d.cts +3 -7
  143. package/dist/email.d.cts.map +1 -1
  144. package/dist/email.d.mts +3 -7
  145. package/dist/email.d.mts.map +1 -1
  146. package/dist/email.mjs +16 -3
  147. package/dist/email.mjs.map +1 -1
  148. package/dist/endpoints/index.cjs +7 -10
  149. package/dist/endpoints/index.d.cts +60 -7
  150. package/dist/endpoints/index.d.cts.map +1 -0
  151. package/dist/endpoints/index.d.mts +60 -7
  152. package/dist/endpoints/index.d.mts.map +1 -0
  153. package/dist/endpoints/index.mjs +5 -10
  154. package/dist/file-server.cjs +42 -10
  155. package/dist/file-server.cjs.map +1 -1
  156. package/dist/file-server.d.cts +6 -10
  157. package/dist/file-server.d.cts.map +1 -1
  158. package/dist/file-server.d.mts +6 -10
  159. package/dist/file-server.d.mts.map +1 -1
  160. package/dist/file-server.mjs +34 -2
  161. package/dist/file-server.mjs.map +1 -1
  162. package/dist/functions/index.cjs +2 -6
  163. package/dist/functions/index.d.cts +2 -4
  164. package/dist/functions/index.d.mts +2 -4
  165. package/dist/functions/index.mjs +2 -6
  166. package/dist/{functions-Bd3TPxid.cjs → functions-VnOTEp74.cjs} +309 -264
  167. package/dist/functions-VnOTEp74.cjs.map +1 -0
  168. package/dist/{functions-Cxbo-pEd.mjs → functions-faoJOUmr.mjs} +282 -234
  169. package/dist/functions-faoJOUmr.mjs.map +1 -0
  170. package/dist/index-CeEtxDmK.d.cts +79 -0
  171. package/dist/index-CeEtxDmK.d.cts.map +1 -0
  172. package/dist/index-CeEtxDmK.d.mts +79 -0
  173. package/dist/index-CeEtxDmK.d.mts.map +1 -0
  174. package/dist/{index-JSf9xNIJ.d.cts → index-DU3Twmwh.d.mts} +19 -24
  175. package/dist/index-DU3Twmwh.d.mts.map +1 -0
  176. package/dist/index-fnpjXiA-.d.mts +26 -0
  177. package/dist/index-fnpjXiA-.d.mts.map +1 -0
  178. package/dist/{index-CubPzHd9.d.mts → index-nBQT1tAh.d.cts} +19 -24
  179. package/dist/index-nBQT1tAh.d.cts.map +1 -0
  180. package/dist/index-tE_119SX.d.cts +26 -0
  181. package/dist/index-tE_119SX.d.cts.map +1 -0
  182. package/dist/index.cjs +3 -3
  183. package/dist/index.d.cts +4 -4
  184. package/dist/index.d.mts +4 -4
  185. package/dist/index.mjs +2 -3
  186. package/dist/kysely-CXi49zc2.d.cts +150 -0
  187. package/dist/kysely-CXi49zc2.d.cts.map +1 -0
  188. package/dist/kysely-D3-G5b0j.d.mts +150 -0
  189. package/dist/kysely-D3-G5b0j.d.mts.map +1 -0
  190. package/dist/{lazyAccessors-BoJN3SMd.mjs → lazyAccessors-BHtcqgz2.mjs} +22 -25
  191. package/dist/lazyAccessors-BHtcqgz2.mjs.map +1 -0
  192. package/dist/{lazyAccessors-e3j2oE2m.cjs → lazyAccessors-Dx9NLwJZ.cjs} +72 -76
  193. package/dist/lazyAccessors-Dx9NLwJZ.cjs.map +1 -0
  194. package/dist/object-storage.cjs +18 -10
  195. package/dist/object-storage.cjs.map +1 -1
  196. package/dist/object-storage.d.cts +3 -7
  197. package/dist/object-storage.d.cts.map +1 -1
  198. package/dist/object-storage.d.mts +3 -7
  199. package/dist/object-storage.d.mts.map +1 -1
  200. package/dist/object-storage.mjs +11 -3
  201. package/dist/object-storage.mjs.map +1 -1
  202. package/dist/{processAudits-Dmts9H_b.mjs → processAudits-BpRlPQMW.mjs} +16 -19
  203. package/dist/processAudits-BpRlPQMW.mjs.map +1 -0
  204. package/dist/{processAudits-CGqttuXm.cjs → processAudits-D_2W5x8k.cjs} +26 -30
  205. package/dist/processAudits-D_2W5x8k.cjs.map +1 -0
  206. package/dist/queue/index.cjs +25 -21
  207. package/dist/queue/index.cjs.map +1 -1
  208. package/dist/queue/index.d.cts +8 -15
  209. package/dist/queue/index.d.cts.map +1 -1
  210. package/dist/queue/index.d.mts +8 -15
  211. package/dist/queue/index.d.mts.map +1 -1
  212. package/dist/queue/index.mjs +15 -11
  213. package/dist/queue/index.mjs.map +1 -1
  214. package/dist/rest-api.cjs +88 -62
  215. package/dist/rest-api.cjs.map +1 -1
  216. package/dist/rest-api.d.cts +62 -60
  217. package/dist/rest-api.d.cts.map +1 -1
  218. package/dist/rest-api.d.mts +62 -60
  219. package/dist/rest-api.d.mts.map +1 -1
  220. package/dist/rest-api.mjs +80 -54
  221. package/dist/rest-api.mjs.map +1 -1
  222. package/dist/{chunk-DWy1uDak.cjs → rolldown-runtime-y5ARvAq5.cjs} +14 -18
  223. package/dist/site.cjs +33 -9
  224. package/dist/site.cjs.map +1 -1
  225. package/dist/site.d.cts +11 -22
  226. package/dist/site.d.cts.map +1 -1
  227. package/dist/site.d.mts +11 -22
  228. package/dist/site.d.mts.map +1 -1
  229. package/dist/site.mjs +29 -5
  230. package/dist/site.mjs.map +1 -1
  231. package/dist/subscribers/index.cjs +2 -11
  232. package/dist/subscribers/index.d.cts +3 -14
  233. package/dist/subscribers/index.d.mts +3 -14
  234. package/dist/subscribers/index.mjs +2 -11
  235. package/dist/surfaceEnv-CNimK76p.cjs +56 -0
  236. package/dist/surfaceEnv-CNimK76p.cjs.map +1 -0
  237. package/dist/surfaceEnv-wMT5QzgZ.mjs +45 -0
  238. package/dist/surfaceEnv-wMT5QzgZ.mjs.map +1 -0
  239. package/dist/{telemetry-C3L0iS28.d.cts → telemetry-DGcFlVpB.d.cts} +2 -5
  240. package/dist/telemetry-DGcFlVpB.d.cts.map +1 -0
  241. package/dist/{telemetry-D7bVFLGi.d.mts → telemetry-DGcFlVpB.d.mts} +2 -5
  242. package/dist/telemetry-DGcFlVpB.d.mts.map +1 -0
  243. package/dist/topic/index.cjs +18 -20
  244. package/dist/topic/index.cjs.map +1 -1
  245. package/dist/topic/index.d.cts +3 -32
  246. package/dist/topic/index.d.mts +3 -32
  247. package/dist/topic/index.mjs +8 -10
  248. package/dist/topic/index.mjs.map +1 -1
  249. package/dist/{types-BlAkSuGI.d.cts → types-DMuSQeLL.d.cts} +3 -5
  250. package/dist/types-DMuSQeLL.d.cts.map +1 -0
  251. package/dist/{types-aKksMEWL.d.mts → types-DMuSQeLL.d.mts} +3 -5
  252. package/dist/types-DMuSQeLL.d.mts.map +1 -0
  253. package/dist/types.d.cts +1 -1
  254. package/dist/types.d.mts +1 -1
  255. package/dist/types.mjs +1 -0
  256. package/dist/worker.cjs +109 -35
  257. package/dist/worker.cjs.map +1 -1
  258. package/dist/worker.d.cts +87 -42
  259. package/dist/worker.d.cts.map +1 -1
  260. package/dist/worker.d.mts +87 -42
  261. package/dist/worker.d.mts.map +1 -1
  262. package/dist/worker.mjs +104 -30
  263. package/dist/worker.mjs.map +1 -1
  264. package/package.json +59 -55
  265. package/dist/Construct-BD5neF7w.mjs.map +0 -1
  266. package/dist/Construct-C0ijr2qp.d.cts.map +0 -1
  267. package/dist/Construct-Ct8nalEi.d.mts.map +0 -1
  268. package/dist/Construct-CyS3RpTL.cjs.map +0 -1
  269. package/dist/Cron-ByxdOfpE.d.mts.map +0 -1
  270. package/dist/Cron-Wqh464aO.d.cts.map +0 -1
  271. package/dist/CronBuilder-BL0AP6fs.d.mts.map +0 -1
  272. package/dist/CronBuilder-BmABazzH.mjs.map +0 -1
  273. package/dist/CronBuilder-BqpEzMPQ.d.cts.map +0 -1
  274. package/dist/CronBuilder-CkXPJiGO.cjs.map +0 -1
  275. package/dist/Endpoint-2Wg7T7Cq.d.mts.map +0 -1
  276. package/dist/Endpoint-BiaaMEn_.cjs.map +0 -1
  277. package/dist/Endpoint-CH9Fn1AD.d.cts.map +0 -1
  278. package/dist/Endpoint-VIOpSo0S.mjs.map +0 -1
  279. package/dist/EndpointFactory-ChxLZllA.cjs.map +0 -1
  280. package/dist/EndpointFactory-DTTCkGEL.mjs.map +0 -1
  281. package/dist/HonoEndpointAdaptor-NKQQQbBY.mjs.map +0 -1
  282. package/dist/Queue-D7ZuwBhy.d.cts.map +0 -1
  283. package/dist/Queue-gVGfi2Yk.d.mts.map +0 -1
  284. package/dist/Subscriber-2mEi0ImH.d.cts.map +0 -1
  285. package/dist/Subscriber-xTJ9ayPN.d.mts.map +0 -1
  286. package/dist/SubscriberBuilder-4OPehf2R.cjs.map +0 -1
  287. package/dist/SubscriberBuilder-BjkbeT9l.mjs.map +0 -1
  288. package/dist/SubscriberBuilder-Dptmo-1A.d.mts.map +0 -1
  289. package/dist/SubscriberBuilder-waNhzjSM.d.cts.map +0 -1
  290. package/dist/Topic-19QeHBIR.d.cts.map +0 -1
  291. package/dist/Topic-DuFeqkBh.d.mts.map +0 -1
  292. package/dist/auth.d.cts.map +0 -1
  293. package/dist/auth.d.mts.map +0 -1
  294. package/dist/cache-0ANvRQnD.mjs +0 -51
  295. package/dist/cache-0ANvRQnD.mjs.map +0 -1
  296. package/dist/cache-3WSvAulx.cjs +0 -57
  297. package/dist/cache-3WSvAulx.cjs.map +0 -1
  298. package/dist/cache-BrRz3fEB.d.mts.map +0 -1
  299. package/dist/cache-BtZY_tHe.d.cts.map +0 -1
  300. package/dist/clone-DblgEZZa.mjs.map +0 -1
  301. package/dist/clone-Dy0cR2SZ.cjs.map +0 -1
  302. package/dist/construct-interface-BfjcOD_E.cjs +0 -117
  303. package/dist/construct-interface-BfjcOD_E.cjs.map +0 -1
  304. package/dist/construct-interface-D9d4Gm4p.d.cts.map +0 -1
  305. package/dist/construct-interface-Z4CpS8tK.mjs +0 -81
  306. package/dist/construct-interface-Z4CpS8tK.mjs.map +0 -1
  307. package/dist/construct-interface-g5GM5pwR.d.mts.map +0 -1
  308. package/dist/database/kysely.d.cts.map +0 -1
  309. package/dist/database/kysely.d.mts.map +0 -1
  310. package/dist/functions-Bd3TPxid.cjs.map +0 -1
  311. package/dist/functions-Cxbo-pEd.mjs.map +0 -1
  312. package/dist/index-BxHDdy6a.d.mts.map +0 -1
  313. package/dist/index-CubPzHd9.d.mts.map +0 -1
  314. package/dist/index-JSf9xNIJ.d.cts.map +0 -1
  315. package/dist/index-V2nksZIJ.d.cts.map +0 -1
  316. package/dist/lazyAccessors-BoJN3SMd.mjs.map +0 -1
  317. package/dist/lazyAccessors-e3j2oE2m.cjs.map +0 -1
  318. package/dist/processAudits-CGqttuXm.cjs.map +0 -1
  319. package/dist/processAudits-Dmts9H_b.mjs.map +0 -1
  320. package/dist/subscribers/index.cjs.map +0 -1
  321. package/dist/subscribers/index.d.cts.map +0 -1
  322. package/dist/subscribers/index.d.mts.map +0 -1
  323. package/dist/subscribers/index.mjs.map +0 -1
  324. package/dist/surfaceEnv-BFXEms2f.cjs +0 -39
  325. package/dist/surfaceEnv-BFXEms2f.cjs.map +0 -1
  326. package/dist/surfaceEnv-C3Ktahea.mjs +0 -27
  327. package/dist/surfaceEnv-C3Ktahea.mjs.map +0 -1
  328. package/dist/telemetry-C3L0iS28.d.cts.map +0 -1
  329. package/dist/telemetry-D7bVFLGi.d.mts.map +0 -1
  330. package/dist/topic/index.d.cts.map +0 -1
  331. package/dist/topic/index.d.mts.map +0 -1
  332. package/dist/types-BlAkSuGI.d.cts.map +0 -1
  333. package/dist/types-aKksMEWL.d.mts.map +0 -1
package/dist/cache.mjs CHANGED
@@ -1,3 +1,68 @@
1
- import { Cache } from "./cache-0ANvRQnD.mjs";
1
+ import { canonicalId, provideKey, serviceKey } from "@geekmidas/manifest";
2
+ import { createCacheClient } from "@geekmidas/cache";
3
+ //#region src/cache.ts
4
+ /**
5
+ * `Cache` — a declared key/value cache.
6
+ *
7
+ * The same three-package meeting point as `ObjectStorage` and `Email`: it
8
+ * implements the construct contract, derives its env key through
9
+ * `@geekmidas/manifest`, and hands back a `@geekmidas/cache` client.
10
+ *
11
+ * It names no provider — and unlike `Email`, it cannot name one protocol
12
+ * either. Every mail backend speaks SMTP, so an `smtp://` URL is true of all of
13
+ * them; cache backends genuinely differ, because Upstash speaks HTTP, a Redis
14
+ * speaks its wire protocol, and a table in Postgres speaks SQL. So the scheme in
15
+ * the URL picks the driver, exactly as it does for object storage, and which
16
+ * drivers exist is the generated entry point's decision.
17
+ *
18
+ * The backend is chosen at deploy, not here. An app caching in Postgres and an
19
+ * app caching in Upstash are the same application code.
20
+ */
21
+ var Cache = class {
22
+ options;
23
+ id;
24
+ service;
25
+ /**
26
+ * Declared once and read by both `declare()` and `connect()`, so the key the
27
+ * target publishes and the key the client reads cannot drift.
28
+ */
29
+ key;
30
+ constructor(id, options = {}) {
31
+ this.options = options;
32
+ const canonical = canonicalId(id);
33
+ this.id = canonical;
34
+ this.key = provideKey(canonical, "url");
35
+ this.service = {
36
+ serviceName: serviceKey(canonical),
37
+ register: (options) => this.connect(options)
38
+ };
39
+ }
40
+ declare() {
41
+ return [{
42
+ kind: "cache",
43
+ id: this.id,
44
+ ...this.options.of ? { of: this.options.of } : {},
45
+ ...this.options.table ? { table: this.options.table } : {},
46
+ provides: [this.key]
47
+ }];
48
+ }
49
+ /**
50
+ * Builds the client from the single URL the target supplied.
51
+ *
52
+ * Any credential travels in that URL's userinfo rather than in a second key,
53
+ * for the same reason a Postgres password does: an address and the thing that
54
+ * opens it are one fact, and splitting them is one more thing to keep in step.
55
+ *
56
+ * The scheme selects the driver, so this construct imports no provider and
57
+ * an app that caches in Postgres never resolves a Redis client. Whoever
58
+ * assembles the application registers the drivers its target needs.
59
+ */
60
+ async connect({ envParser }) {
61
+ const { url } = envParser.create((get) => ({ url: get(this.key).string() })).parse();
62
+ return createCacheClient(url);
63
+ }
64
+ };
65
+ //#endregion
66
+ export { Cache };
2
67
 
3
- export { Cache };
68
+ //# sourceMappingURL=cache.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cache.mjs","names":[],"sources":["../src/cache.ts"],"sourcesContent":["/**\n * `Cache` — a declared key/value cache.\n *\n * The same three-package meeting point as `ObjectStorage` and `Email`: it\n * implements the construct contract, derives its env key through\n * `@geekmidas/manifest`, and hands back a `@geekmidas/cache` client.\n *\n * It names no provider — and unlike `Email`, it cannot name one protocol\n * either. Every mail backend speaks SMTP, so an `smtp://` URL is true of all of\n * them; cache backends genuinely differ, because Upstash speaks HTTP, a Redis\n * speaks its wire protocol, and a table in Postgres speaks SQL. So the scheme in\n * the URL picks the driver, exactly as it does for object storage, and which\n * drivers exist is the generated entry point's decision.\n *\n * The backend is chosen at deploy, not here. An app caching in Postgres and an\n * app caching in Upstash are the same application code.\n */\n\nimport { type Cache as CacheClient, createCacheClient } from '@geekmidas/cache';\nimport {\n\ttype ConstructName,\n\tcanonicalId,\n\ttype Declaration,\n\tprovideKey,\n\tserviceKey,\n} from '@geekmidas/manifest';\nimport type { Service, ServiceRegisterOptions } from '@geekmidas/services';\nimport type { Construct } from './construct-interface';\n\nexport interface CacheOptions {\n\t/**\n\t * The database this cache lives in.\n\t *\n\t * Set by `database.cache()` rather than written by hand — the point of the\n\t * method is that the parent's id comes from the parent rather than from a\n\t * string somebody has to keep in step.\n\t */\n\tof?: string;\n\t/** The table entries are kept in. Defaults to `cache`. */\n\ttable?: string;\n}\n\nexport class Cache<TName extends string = string>\n\timplements Construct<TName, CacheClient>\n{\n\treadonly id: TName;\n\treadonly service: Service<Uncapitalize<TName>, CacheClient>;\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 key: string;\n\n\tconstructor(\n\t\tid: ConstructName<TName>,\n\t\tprivate readonly options: CacheOptions = {},\n\t) {\n\t\tconst canonical = canonicalId(id as string);\n\n\t\tthis.id = canonical as TName;\n\t\tthis.key = provideKey(canonical, 'url');\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: (options) => this.connect(options),\n\t\t};\n\t}\n\n\tdeclare(): Declaration[] {\n\t\treturn [\n\t\t\t{\n\t\t\t\tkind: 'cache',\n\t\t\t\tid: this.id,\n\t\t\t\t...(this.options.of ? { of: this.options.of } : {}),\n\t\t\t\t...(this.options.table ? { table: this.options.table } : {}),\n\t\t\t\tprovides: [this.key],\n\t\t\t},\n\t\t];\n\t}\n\n\t/**\n\t * Builds the client from the single URL the target supplied.\n\t *\n\t * Any credential travels in that URL's userinfo rather than in a second key,\n\t * for the same reason a Postgres password does: an address and the thing that\n\t * opens it are one fact, and splitting them is one more thing to keep in step.\n\t *\n\t * The scheme selects the driver, so this construct imports no provider and\n\t * an app that caches in Postgres never resolves a Redis client. Whoever\n\t * assembles the application registers the drivers its target needs.\n\t */\n\tprivate async connect({\n\t\tenvParser,\n\t}: ServiceRegisterOptions): Promise<CacheClient> {\n\t\tconst { url } = envParser\n\t\t\t.create((get) => ({ url: get(this.key).string() }))\n\t\t\t.parse();\n\n\t\treturn createCacheClient(url);\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AA0CA,IAAa,QAAb,MAEA;CAYmB;CAXlB;CACA;;;;;CAMA;CAEA,YACC,IACA,UAAyC,CAAC,GACzC;EADgB,KAAA,UAAA;EAEjB,MAAM,YAAY,YAAY,EAAY;EAE1C,KAAK,KAAK;EACV,KAAK,MAAM,WAAW,WAAW,KAAK;EAGtC,KAAK,UAAU;GACd,aAAa,WAAW,SAAS;GACjC,WAAW,YAAY,KAAK,QAAQ,OAAO;EAC5C;CACD;CAEA,UAAyB;EACxB,OAAO,CACN;GACC,MAAM;GACN,IAAI,KAAK;GACT,GAAI,KAAK,QAAQ,KAAK,EAAE,IAAI,KAAK,QAAQ,GAAG,IAAI,CAAC;GACjD,GAAI,KAAK,QAAQ,QAAQ,EAAE,OAAO,KAAK,QAAQ,MAAM,IAAI,CAAC;GAC1D,UAAU,CAAC,KAAK,GAAG;EACpB,CACD;CACD;;;;;;;;;;;;CAaA,MAAc,QAAQ,EACrB,aACgD;EAChD,MAAM,EAAE,QAAQ,UACd,QAAQ,SAAS,EAAE,KAAK,IAAI,KAAK,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,CAClD,MAAM;EAER,OAAO,kBAAkB,GAAG;CAC7B;AACD"}
@@ -33,7 +33,7 @@ function cloneWith(instance, delta) {
33
33
  const next = Object.create(Object.getPrototypeOf(instance));
34
34
  return Object.assign(next, instance, delta);
35
35
  }
36
-
37
36
  //#endregion
38
- export { cloneWith };
39
- //# sourceMappingURL=clone-DblgEZZa.mjs.map
37
+ export { cloneWith as t };
38
+
39
+ //# sourceMappingURL=clone-EKNovYHu.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"clone-EKNovYHu.mjs","names":[],"sources":["../src/clone.ts"],"sourcesContent":["/**\n * Cloning a builder, without enumerating its fields.\n *\n * The builders were mutable singletons that reset themselves by listing every\n * field at the end of `.handle()`. Two things followed from that, and both were\n * real:\n *\n * A configured base could not be reused. `const fn = f.logger(log)` handed back\n * `f` itself, and the first `.handle()` reset `_logger` to the default — so the\n * second handler built from that base silently logged somewhere else. Every\n * field in the reset block behaved the same way, which made\n * `f.logger(l).timeout(60_000)` a base that worked exactly once.\n *\n * And a field left out of the reset list leaked into the next handler instead.\n * `_constructs` was left out, so a function was granted a bucket a *previous*\n * function had declared — an over-grant in the field a deploy reads to size an\n * IAM policy.\n *\n * Both are the same defect: a hand-maintained list of fields that has to be\n * edited every time a field is added, and is silent when it isn't. So this\n * copies whatever the instance actually has, and the list stops existing. The\n * prototype is carried over, so `instanceof` and every method still resolve,\n * and the constructor is deliberately not re-run — this copies state rather\n * than initialising it.\n *\n * Fields must be replaced rather than mutated in place: a clone and its parent\n * share whatever array a field points at, so `_events.push(…)` would be seen by\n * both. Every builder assigns a fresh array instead, which is what makes\n * sharing the reference safe.\n */\nexport function cloneWith<T extends object>(\n\tinstance: T,\n\tdelta: Record<string, unknown>,\n): T {\n\tconst next = Object.create(Object.getPrototypeOf(instance)) as T;\n\n\treturn Object.assign(next, instance, delta);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8BA,SAAgB,UACf,UACA,OACI;CACJ,MAAM,OAAO,OAAO,OAAO,OAAO,eAAe,QAAQ,CAAC;CAE1D,OAAO,OAAO,OAAO,MAAM,UAAU,KAAK;AAC3C"}
@@ -1,4 +1,3 @@
1
-
2
1
  //#region src/clone.ts
3
2
  /**
4
3
  * Cloning a builder, without enumerating its fields.
@@ -34,12 +33,12 @@ function cloneWith(instance, delta) {
34
33
  const next = Object.create(Object.getPrototypeOf(instance));
35
34
  return Object.assign(next, instance, delta);
36
35
  }
37
-
38
36
  //#endregion
39
- Object.defineProperty(exports, 'cloneWith', {
40
- enumerable: true,
41
- get: function () {
42
- return cloneWith;
43
- }
37
+ Object.defineProperty(exports, "cloneWith", {
38
+ enumerable: true,
39
+ get: function() {
40
+ return cloneWith;
41
+ }
44
42
  });
45
- //# sourceMappingURL=clone-Dy0cR2SZ.cjs.map
43
+
44
+ //# sourceMappingURL=clone-UGJpvQnL.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"clone-UGJpvQnL.cjs","names":[],"sources":["../src/clone.ts"],"sourcesContent":["/**\n * Cloning a builder, without enumerating its fields.\n *\n * The builders were mutable singletons that reset themselves by listing every\n * field at the end of `.handle()`. Two things followed from that, and both were\n * real:\n *\n * A configured base could not be reused. `const fn = f.logger(log)` handed back\n * `f` itself, and the first `.handle()` reset `_logger` to the default — so the\n * second handler built from that base silently logged somewhere else. Every\n * field in the reset block behaved the same way, which made\n * `f.logger(l).timeout(60_000)` a base that worked exactly once.\n *\n * And a field left out of the reset list leaked into the next handler instead.\n * `_constructs` was left out, so a function was granted a bucket a *previous*\n * function had declared — an over-grant in the field a deploy reads to size an\n * IAM policy.\n *\n * Both are the same defect: a hand-maintained list of fields that has to be\n * edited every time a field is added, and is silent when it isn't. So this\n * copies whatever the instance actually has, and the list stops existing. The\n * prototype is carried over, so `instanceof` and every method still resolve,\n * and the constructor is deliberately not re-run — this copies state rather\n * than initialising it.\n *\n * Fields must be replaced rather than mutated in place: a clone and its parent\n * share whatever array a field points at, so `_events.push(…)` would be seen by\n * both. Every builder assigns a fresh array instead, which is what makes\n * sharing the reference safe.\n */\nexport function cloneWith<T extends object>(\n\tinstance: T,\n\tdelta: Record<string, unknown>,\n): T {\n\tconst next = Object.create(Object.getPrototypeOf(instance)) as T;\n\n\treturn Object.assign(next, instance, delta);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8BA,SAAgB,UACf,UACA,OACI;CACJ,MAAM,OAAO,OAAO,OAAO,OAAO,eAAe,QAAQ,CAAC;CAE1D,OAAO,OAAO,OAAO,MAAM,UAAU,KAAK;AAC3C"}
@@ -1,8 +1,7 @@
1
1
  import { Declaration, Dependency } from "@geekmidas/manifest";
2
+ import { EnvironmentParser } from "@geekmidas/envkit";
2
3
  import { Service } from "@geekmidas/services";
3
-
4
4
  //#region src/construct-interface.d.ts
5
-
6
5
  /**
7
6
  * @typeParam TName - the construct's canonical id, PascalCase. Keeping it a
8
7
  * literal is what lets the service key be `Uncapitalize<TName>` — a TypeScript
@@ -45,6 +44,17 @@ interface Declarable<TName extends string = string> {
45
44
  readonly id: TName;
46
45
  declare(): Declaration[];
47
46
  }
47
+ /**
48
+ * A construct that authenticates requests — what `RestApi.auth()` takes.
49
+ *
50
+ * `verify` is the one thing every provider shares: given a request's headers,
51
+ * whose request is it — the session, or `null` when there is none. Whether the
52
+ * provider is a server mounted beside the API, deployed elsewhere, or an issuer
53
+ * somebody else runs is its own business; a surface only ever asks this.
54
+ */
55
+ interface Authenticator<TSession = unknown> extends Declarable {
56
+ verify(headers: Headers, envParser: EnvironmentParser<{}>): Promise<TSession | null>;
57
+ }
48
58
  /**
49
59
  * The edge that points at a construct.
50
60
  *
@@ -85,7 +95,7 @@ interface Consumable<TName extends string = string, TClient = unknown> {
85
95
  * both keys — the same machinery `.services()` already uses, which is why
86
96
  * `dependsOn` needs no type plumbing of its own.
87
97
  */
88
- type ServicesOf<T extends readonly Consumable[]> = { [K in keyof T]: T[K]['service'] };
98
+ type ServicesOf<T extends readonly Consumable[]> = { [K in keyof T]: T[K]['service']; };
89
99
  /**
90
100
  * The services of a list of constructs, at runtime.
91
101
  *
@@ -125,7 +135,6 @@ declare function isConsumable(value: unknown): value is Consumable;
125
135
  * `Construct.fromService` exists to lift and not everything has been lifted.
126
136
  */
127
137
  declare function serviceOf<TName extends string, TClient>(source: Consumable<TName, TClient> | Service<TName, TClient>): Service<TName, TClient>;
128
- //# sourceMappingURL=construct-interface.d.ts.map
129
138
  //#endregion
130
- export { Construct, Consumable, Declarable, Infer, NameOf, NotAConstruct, ServicesOf, edgeTo, idsOf, isConsumable, serviceOf, servicesOf };
131
- //# sourceMappingURL=construct-interface-g5GM5pwR.d.mts.map
139
+ export { Infer as a, ServicesOf as c, isConsumable as d, serviceOf as f, Declarable as i, edgeTo as l, Construct as n, NameOf as o, servicesOf as p, Consumable as r, NotAConstruct as s, Authenticator as t, idsOf as u };
140
+ //# sourceMappingURL=construct-interface-Clz7_BwB.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"construct-interface-Clz7_BwB.d.mts","names":[],"sources":["../src/construct-interface.ts"],"mappings":";;;;;;;;;;;;;UA8BiB,UAAU,+BAA+B;;WAEhD,IAAI;;;;;;;;EASb,WAAW;;;;;;;;WASF,UAAU,mCAEhB,QAAQ,aAAa,QAAQ;;;;;;;;;;;UAYhB,WAAW;WAClB,IAAI;EACb,WAAW;;;;;;;;;;UAWK,cAAc,4BAA4B;EAC1D,OACC,SAAS,SACT,WAAW,wBACT,QAAQ;;;;;;;;;;;;;;iBAeI,OAAO,WAAW,aAAa;;KAWnC,MAAM,KACjB,UAAU,wBAAwB,WAAW;;KAGlC,OAAO,KAClB,UAAU,gBAAgB,kBAAkB;;;;;;;;;;;UAY5B,WAAW,+BAA+B;WACjD,IAAI;WACJ,SAAS,QAAQ,aAAa,QAAQ;EAC/C,WAAW;;;;;;;;;;KAWA,WAAW,mBAAmB,mBACxC,WAAW,IAAI,EAAE;;;;;;;;iBAUH,iBAAiB,mBAAmB,cACnD,YAAY,IACV,WAAW;;;;;;;;;;iBAiBE,MACf,qBAAqB,cACrB;;cAMY,sBAAsB;WACb;EAArB,YAAqB;;;;;;;;;iBAsBN,aAAa,iBAAiB,SAAS;;;;;;;;iBAmBvC,UAAU,sBAAsB,SAC/C,QAAQ,WAAW,OAAO,WAAW,QAAQ,OAAO,WAClD,QAAQ,OAAO"}
@@ -1,8 +1,7 @@
1
+ import { EnvironmentParser } from "@geekmidas/envkit";
1
2
  import { Service } from "@geekmidas/services";
2
3
  import { Declaration, Dependency } from "@geekmidas/manifest";
3
-
4
4
  //#region src/construct-interface.d.ts
5
-
6
5
  /**
7
6
  * @typeParam TName - the construct's canonical id, PascalCase. Keeping it a
8
7
  * literal is what lets the service key be `Uncapitalize<TName>` — a TypeScript
@@ -45,6 +44,17 @@ interface Declarable<TName extends string = string> {
45
44
  readonly id: TName;
46
45
  declare(): Declaration[];
47
46
  }
47
+ /**
48
+ * A construct that authenticates requests — what `RestApi.auth()` takes.
49
+ *
50
+ * `verify` is the one thing every provider shares: given a request's headers,
51
+ * whose request is it — the session, or `null` when there is none. Whether the
52
+ * provider is a server mounted beside the API, deployed elsewhere, or an issuer
53
+ * somebody else runs is its own business; a surface only ever asks this.
54
+ */
55
+ interface Authenticator<TSession = unknown> extends Declarable {
56
+ verify(headers: Headers, envParser: EnvironmentParser<{}>): Promise<TSession | null>;
57
+ }
48
58
  /**
49
59
  * The edge that points at a construct.
50
60
  *
@@ -85,7 +95,7 @@ interface Consumable<TName extends string = string, TClient = unknown> {
85
95
  * both keys — the same machinery `.services()` already uses, which is why
86
96
  * `dependsOn` needs no type plumbing of its own.
87
97
  */
88
- type ServicesOf<T extends readonly Consumable[]> = { [K in keyof T]: T[K]['service'] };
98
+ type ServicesOf<T extends readonly Consumable[]> = { [K in keyof T]: T[K]['service']; };
89
99
  /**
90
100
  * The services of a list of constructs, at runtime.
91
101
  *
@@ -125,7 +135,6 @@ declare function isConsumable(value: unknown): value is Consumable;
125
135
  * `Construct.fromService` exists to lift and not everything has been lifted.
126
136
  */
127
137
  declare function serviceOf<TName extends string, TClient>(source: Consumable<TName, TClient> | Service<TName, TClient>): Service<TName, TClient>;
128
- //# sourceMappingURL=construct-interface.d.ts.map
129
138
  //#endregion
130
- export { Construct, Consumable, Declarable, Infer, NameOf, NotAConstruct, ServicesOf, edgeTo, idsOf, isConsumable, serviceOf, servicesOf };
131
- //# sourceMappingURL=construct-interface-D9d4Gm4p.d.cts.map
139
+ export { Infer as a, ServicesOf as c, isConsumable as d, serviceOf as f, Declarable as i, edgeTo as l, Construct as n, NameOf as o, servicesOf as p, Consumable as r, NotAConstruct as s, Authenticator as t, idsOf as u };
140
+ //# sourceMappingURL=construct-interface-DIaTNKax.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"construct-interface-DIaTNKax.d.cts","names":[],"sources":["../src/construct-interface.ts"],"mappings":";;;;;;;;;;;;;UA8BiB,UAAU,+BAA+B;;WAEhD,IAAI;;;;;;;;EASb,WAAW;;;;;;;;WASF,UAAU,mCAEhB,QAAQ,aAAa,QAAQ;;;;;;;;;;;UAYhB,WAAW;WAClB,IAAI;EACb,WAAW;;;;;;;;;;UAWK,cAAc,4BAA4B;EAC1D,OACC,SAAS,SACT,WAAW,wBACT,QAAQ;;;;;;;;;;;;;;iBAeI,OAAO,WAAW,aAAa;;KAWnC,MAAM,KACjB,UAAU,wBAAwB,WAAW;;KAGlC,OAAO,KAClB,UAAU,gBAAgB,kBAAkB;;;;;;;;;;;UAY5B,WAAW,+BAA+B;WACjD,IAAI;WACJ,SAAS,QAAQ,aAAa,QAAQ;EAC/C,WAAW;;;;;;;;;;KAWA,WAAW,mBAAmB,mBACxC,WAAW,IAAI,EAAE;;;;;;;;iBAUH,iBAAiB,mBAAmB,cACnD,YAAY,IACV,WAAW;;;;;;;;;;iBAiBE,MACf,qBAAqB,cACrB;;cAMY,sBAAsB;WACb;EAArB,YAAqB;;;;;;;;;iBAsBN,aAAa,iBAAiB,SAAS;;;;;;;;iBAmBvC,UAAU,sBAAsB,SAC/C,QAAQ,WAAW,OAAO,WAAW,QAAQ,OAAO,WAClD,QAAQ,OAAO"}
@@ -1,8 +1,88 @@
1
- const require_construct_interface = require('./construct-interface-BfjcOD_E.cjs');
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ //#region src/construct-interface.ts
3
+ /**
4
+ * The edge that points at a construct.
5
+ *
6
+ * A construct's *canonical* node is the one carrying its own id — the others are
7
+ * things it owns rather than things it is, like the signing secret beside an
8
+ * auth server — so the kind an edge records is read off that node instead of
9
+ * being written down beside it. Hand-written kinds are the same fact stated
10
+ * twice, and the copy is what goes stale when a construct changes what it
11
+ * declares.
12
+ *
13
+ * @throws {NotAConstruct} when the value declares nothing under its own id.
14
+ */
15
+ function edgeTo(construct) {
16
+ const canonical = construct.declare().find((declaration) => declaration.id === construct.id);
17
+ if (!canonical) throw new NotAConstruct(construct);
18
+ return {
19
+ target: construct.id,
20
+ kind: canonical.kind
21
+ };
22
+ }
23
+ /**
24
+ * The services of a list of constructs, at runtime.
25
+ *
26
+ * @throws {NotAConstruct} when handed something else. The type already refuses
27
+ * it, but a JavaScript caller gets no such warning, and a `Service` slipping
28
+ * through would fail later as an undefined key in the handler.
29
+ */
30
+ function servicesOf(constructs) {
31
+ return constructs.map((construct) => {
32
+ if (!isConsumable(construct)) throw new NotAConstruct(construct);
33
+ return construct.service;
34
+ });
35
+ }
36
+ /**
37
+ * The other half of `servicesOf`: the same edge, as the manifest records it.
38
+ *
39
+ * `.dependsOn()` used to keep only the services, which is what a handler runs
40
+ * with — and an id cannot be recovered from a service name reliably, so the
41
+ * edges were gone by the time the build could read them. Both halves are taken
42
+ * from one call now, and `existing` is folded in so repeated `.dependsOn()`
43
+ * calls accumulate the way `.services()` already does.
44
+ */
45
+ function idsOf(constructs, existing = []) {
46
+ return [.../* @__PURE__ */ new Set([...existing, ...constructs.map(({ id }) => id)])];
47
+ }
48
+ /** Something that is not a construct was passed to `.dependsOn()`. */
49
+ var NotAConstruct = class extends Error {
50
+ value;
51
+ constructor(value) {
52
+ const name = typeof value === "object" && value !== null && "serviceName" in value ? `the service '${String(value.serviceName)}'` : `a ${typeof value}`;
53
+ super(`.dependsOn() takes constructs, and was given ${name}. Pass it to .services([…]) instead, or lift it with Construct.fromService().`);
54
+ this.value = value;
55
+ this.name = "NotAConstruct";
56
+ }
57
+ };
58
+ /**
59
+ * Whether a value is a construct rather than a bare `Service`.
60
+ *
61
+ * Structural rather than `instanceof`: a construct from a second copy of
62
+ * `@geekmidas/constructs` — a linked workspace, two versions in a lockfile — is
63
+ * still a construct, and `instanceof` is exactly the check that says otherwise.
64
+ */
65
+ function isConsumable(value) {
66
+ if (typeof value !== "object" || value === null) return false;
67
+ const candidate = value;
68
+ return typeof candidate.id === "string" && typeof candidate.declare === "function" && typeof candidate.service?.serviceName === "string";
69
+ }
70
+ /**
71
+ * The service behind either face.
72
+ *
73
+ * `.database()` and the publisher slots take a construct now; they took a
74
+ * `Service` before and still do, because a hand-written one is exactly what
75
+ * `Construct.fromService` exists to lift and not everything has been lifted.
76
+ */
77
+ function serviceOf(source) {
78
+ return isConsumable(source) ? source.service : source;
79
+ }
80
+ //#endregion
81
+ exports.NotAConstruct = NotAConstruct;
82
+ exports.edgeTo = edgeTo;
83
+ exports.idsOf = idsOf;
84
+ exports.isConsumable = isConsumable;
85
+ exports.serviceOf = serviceOf;
86
+ exports.servicesOf = servicesOf;
2
87
 
3
- exports.NotAConstruct = require_construct_interface.NotAConstruct;
4
- exports.edgeTo = require_construct_interface.edgeTo;
5
- exports.idsOf = require_construct_interface.idsOf;
6
- exports.isConsumable = require_construct_interface.isConsumable;
7
- exports.serviceOf = require_construct_interface.serviceOf;
8
- exports.servicesOf = require_construct_interface.servicesOf;
88
+ //# sourceMappingURL=construct-interface.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"construct-interface.cjs","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 { EnvironmentParser } from '@geekmidas/envkit';\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 * A construct that authenticates requests — what `RestApi.auth()` takes.\n *\n * `verify` is the one thing every provider shares: given a request's headers,\n * whose request is it — the session, or `null` when there is none. Whether the\n * provider is a server mounted beside the API, deployed elsewhere, or an issuer\n * somebody else runs is its own business; a surface only ever asks this.\n */\nexport interface Authenticator<TSession = unknown> extends Declarable {\n\tverify(\n\t\theaders: Headers,\n\t\tenvParser: EnvironmentParser<{}>,\n\t): Promise<TSession | null>;\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":";;;;;;;;;;;;;;AAgGA,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,2 +1,2 @@
1
- import { Construct, Consumable, Declarable, Infer, NameOf, NotAConstruct, ServicesOf, edgeTo, idsOf, isConsumable, serviceOf, servicesOf } from "./construct-interface-D9d4Gm4p.cjs";
2
- export { Construct, Consumable, Declarable, Infer, NameOf, NotAConstruct, ServicesOf, edgeTo, idsOf, isConsumable, serviceOf, servicesOf };
1
+ import { a as Infer, c as ServicesOf, d as isConsumable, f as serviceOf, i as Declarable, l as edgeTo, n as Construct, o as NameOf, p as servicesOf, r as Consumable, s as NotAConstruct, t as Authenticator, u as idsOf } from "./construct-interface-DIaTNKax.cjs";
2
+ export { Authenticator, Construct, Consumable, Declarable, Infer, NameOf, NotAConstruct, ServicesOf, edgeTo, idsOf, isConsumable, serviceOf, servicesOf };
@@ -1,2 +1,2 @@
1
- import { Construct, Consumable, Declarable, Infer, NameOf, NotAConstruct, ServicesOf, edgeTo, idsOf, isConsumable, serviceOf, servicesOf } from "./construct-interface-g5GM5pwR.mjs";
2
- export { Construct, Consumable, Declarable, Infer, NameOf, NotAConstruct, ServicesOf, edgeTo, idsOf, isConsumable, serviceOf, servicesOf };
1
+ import { a as Infer, c as ServicesOf, d as isConsumable, f as serviceOf, i as Declarable, l as edgeTo, n as Construct, o as NameOf, p as servicesOf, r as Consumable, s as NotAConstruct, t as Authenticator, u as idsOf } from "./construct-interface-Clz7_BwB.mjs";
2
+ export { Authenticator, Construct, Consumable, Declarable, Infer, NameOf, NotAConstruct, ServicesOf, edgeTo, idsOf, isConsumable, serviceOf, servicesOf };
@@ -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 { EnvironmentParser } from '@geekmidas/envkit';\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 * A construct that authenticates requests — what `RestApi.auth()` takes.\n *\n * `verify` is the one thing every provider shares: given a request's headers,\n * whose request is it — the session, or `null` when there is none. Whether the\n * provider is a server mounted beside the API, deployed elsewhere, or an issuer\n * somebody else runs is its own business; a surface only ever asks this.\n */\nexport interface Authenticator<TSession = unknown> extends Declarable {\n\tverify(\n\t\theaders: Headers,\n\t\tenvParser: EnvironmentParser<{}>,\n\t): Promise<TSession | null>;\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":";;;;;;;;;;;;;AAgGA,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"}