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

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 (454) hide show
  1. package/README.md +222 -158
  2. package/dist/Construct-B7AXn0xH.d.mts +230 -0
  3. package/dist/Construct-B7AXn0xH.d.mts.map +1 -0
  4. package/dist/Construct-CFW0zjdD.d.cts +230 -0
  5. package/dist/Construct-CFW0zjdD.d.cts.map +1 -0
  6. package/dist/{Construct-BD5neF7w.mjs → Construct-CKUA-CTA.mjs} +35 -35
  7. package/dist/Construct-CKUA-CTA.mjs.map +1 -0
  8. package/dist/{Construct-CyS3RpTL.cjs → Construct-DEOVauyA.cjs} +55 -49
  9. package/dist/Construct-DEOVauyA.cjs.map +1 -0
  10. package/dist/{Cron-DmQ8vQ4b.d.cts → Cron-bdGRSROY.d.cts} +15 -9
  11. package/dist/Cron-bdGRSROY.d.cts.map +1 -0
  12. package/dist/{Cron-dh4rUgib.d.mts → Cron-i4Uetezh.d.mts} +15 -9
  13. package/dist/Cron-i4Uetezh.d.mts.map +1 -0
  14. package/dist/CronBuilder-9H4BnD6W.d.mts +47 -0
  15. package/dist/CronBuilder-9H4BnD6W.d.mts.map +1 -0
  16. package/dist/{CronBuilder-Da0C0edR.cjs → CronBuilder-BXTG10u5.cjs} +47 -31
  17. package/dist/CronBuilder-BXTG10u5.cjs.map +1 -0
  18. package/dist/CronBuilder-B_24LZpn.d.cts +47 -0
  19. package/dist/CronBuilder-B_24LZpn.d.cts.map +1 -0
  20. package/dist/{CronBuilder-CYKT5RiO.mjs → CronBuilder-D3sF9tS_.mjs} +37 -21
  21. package/dist/CronBuilder-D3sF9tS_.mjs.map +1 -0
  22. package/dist/{Endpoint-BjWKinFA.d.mts → Endpoint-CeFkSwh5.d.mts} +129 -99
  23. package/dist/Endpoint-CeFkSwh5.d.mts.map +1 -0
  24. package/dist/{Endpoint-dav89W6-.d.cts → Endpoint-DgrpG15P.d.cts} +127 -97
  25. package/dist/Endpoint-DgrpG15P.d.cts.map +1 -0
  26. package/dist/{Endpoint-DCQPMdUX.mjs → Endpoint-gPXhHKhJ.mjs} +208 -100
  27. package/dist/Endpoint-gPXhHKhJ.mjs.map +1 -0
  28. package/dist/{Endpoint-DcWXE-SZ.cjs → Endpoint-yhR2T2Wt.cjs} +248 -122
  29. package/dist/Endpoint-yhR2T2Wt.cjs.map +1 -0
  30. package/dist/{EndpointFactory-CdWB7wPw.cjs → EndpointFactory-CSrAyazj.cjs} +361 -112
  31. package/dist/EndpointFactory-CSrAyazj.cjs.map +1 -0
  32. package/dist/{index-lAO9egTb.d.mts → EndpointFactory-Cc863XJS.d.cts} +190 -136
  33. package/dist/EndpointFactory-Cc863XJS.d.cts.map +1 -0
  34. package/dist/{index-Bd5FqCoe.d.cts → EndpointFactory-Dbw9ugkX.d.mts} +189 -135
  35. package/dist/EndpointFactory-Dbw9ugkX.d.mts.map +1 -0
  36. package/dist/{EndpointFactory-CjV8F_lJ.mjs → EndpointFactory-c2ZugGig.mjs} +283 -76
  37. package/dist/EndpointFactory-c2ZugGig.mjs.map +1 -0
  38. package/dist/Function-B0uZhZnU.d.cts +76 -0
  39. package/dist/Function-B0uZhZnU.d.cts.map +1 -0
  40. package/dist/Function-B_9R7Zy1.d.mts +76 -0
  41. package/dist/Function-B_9R7Zy1.d.mts.map +1 -0
  42. package/dist/{HonoEndpointAdaptor-DtL9j19R.cjs → HonoEndpointAdaptor-CN1jjUBJ.cjs} +115 -71
  43. package/dist/HonoEndpointAdaptor-CN1jjUBJ.cjs.map +1 -0
  44. package/dist/{HonoEndpointAdaptor-P1ahhZHu.mjs → HonoEndpointAdaptor-euH1oSdY.mjs} +105 -64
  45. package/dist/HonoEndpointAdaptor-euH1oSdY.mjs.map +1 -0
  46. package/dist/{Queue-D7ZuwBhy.d.cts → Queue-B-dDXyjF.d.mts} +48 -48
  47. package/dist/Queue-B-dDXyjF.d.mts.map +1 -0
  48. package/dist/Queue-BhuofM3k.cjs +109 -0
  49. package/dist/Queue-BhuofM3k.cjs.map +1 -0
  50. package/dist/{Queue-gVGfi2Yk.d.mts → Queue-JbIjVtTf.d.cts} +49 -49
  51. package/dist/Queue-JbIjVtTf.d.cts.map +1 -0
  52. package/dist/Queue-cmhqEBOB.mjs +104 -0
  53. package/dist/Queue-cmhqEBOB.mjs.map +1 -0
  54. package/dist/QueueBuilder-48W-q8In.d.mts +75 -0
  55. package/dist/QueueBuilder-48W-q8In.d.mts.map +1 -0
  56. package/dist/QueueBuilder-DXu1qxT1.mjs +118 -0
  57. package/dist/QueueBuilder-DXu1qxT1.mjs.map +1 -0
  58. package/dist/QueueBuilder-DdU2klPu.cjs +135 -0
  59. package/dist/QueueBuilder-DdU2klPu.cjs.map +1 -0
  60. package/dist/QueueBuilder-MfpkJ3R9.d.cts +75 -0
  61. package/dist/QueueBuilder-MfpkJ3R9.d.cts.map +1 -0
  62. package/dist/{Subscriber-2mEi0ImH.d.cts → Subscriber-CEt7kHkc.d.cts} +29 -20
  63. package/dist/Subscriber-CEt7kHkc.d.cts.map +1 -0
  64. package/dist/{Subscriber-xTJ9ayPN.d.mts → Subscriber-dsxc5LKa.d.mts} +29 -20
  65. package/dist/Subscriber-dsxc5LKa.d.mts.map +1 -0
  66. package/dist/SubscriberBuilder-BRa_nrmH.d.cts +67 -0
  67. package/dist/SubscriberBuilder-BRa_nrmH.d.cts.map +1 -0
  68. package/dist/SubscriberBuilder-D9bkrYzH.d.mts +67 -0
  69. package/dist/SubscriberBuilder-D9bkrYzH.d.mts.map +1 -0
  70. package/dist/{SubscriberBuilder-BjkbeT9l.mjs → SubscriberBuilder-DRXfxWn_.mjs} +50 -24
  71. package/dist/SubscriberBuilder-DRXfxWn_.mjs.map +1 -0
  72. package/dist/{SubscriberBuilder-4OPehf2R.cjs → SubscriberBuilder-M2EAgQhC.cjs} +61 -36
  73. package/dist/SubscriberBuilder-M2EAgQhC.cjs.map +1 -0
  74. package/dist/Topic-D2R0r24C.mjs +99 -0
  75. package/dist/Topic-D2R0r24C.mjs.map +1 -0
  76. package/dist/Topic-DwS3QO0m.cjs +104 -0
  77. package/dist/Topic-DwS3QO0m.cjs.map +1 -0
  78. package/dist/adaptors/aws.cjs +200 -246
  79. package/dist/adaptors/aws.cjs.map +1 -1
  80. package/dist/adaptors/aws.d.cts +58 -62
  81. package/dist/adaptors/aws.d.cts.map +1 -1
  82. package/dist/adaptors/aws.d.mts +59 -63
  83. package/dist/adaptors/aws.d.mts.map +1 -1
  84. package/dist/adaptors/aws.mjs +171 -219
  85. package/dist/adaptors/aws.mjs.map +1 -1
  86. package/dist/adaptors/hono.cjs +3 -10
  87. package/dist/adaptors/hono.d.cts +7 -16
  88. package/dist/adaptors/hono.d.cts.map +1 -1
  89. package/dist/adaptors/hono.d.mts +9 -18
  90. package/dist/adaptors/hono.d.mts.map +1 -1
  91. package/dist/adaptors/hono.mjs +2 -10
  92. package/dist/adaptors/testing.cjs +765 -99
  93. package/dist/adaptors/testing.cjs.map +1 -1
  94. package/dist/adaptors/testing.d.cts +351 -54
  95. package/dist/adaptors/testing.d.cts.map +1 -1
  96. package/dist/adaptors/testing.d.mts +351 -54
  97. package/dist/adaptors/testing.d.mts.map +1 -1
  98. package/dist/adaptors/testing.mjs +726 -78
  99. package/dist/adaptors/testing.mjs.map +1 -1
  100. package/dist/auth-BMCJN30Y.d.cts +268 -0
  101. package/dist/auth-BMCJN30Y.d.cts.map +1 -0
  102. package/dist/auth-D_0788uW.d.mts +268 -0
  103. package/dist/auth-D_0788uW.d.mts.map +1 -0
  104. package/dist/auth.cjs +301 -33
  105. package/dist/auth.cjs.map +1 -1
  106. package/dist/auth.d.cts +2 -108
  107. package/dist/auth.d.mts +2 -108
  108. package/dist/auth.mjs +289 -27
  109. package/dist/auth.mjs.map +1 -1
  110. package/dist/{cache-BrRz3fEB.d.mts → cache-5QZzh5Er.d.mts} +3 -6
  111. package/dist/cache-5QZzh5Er.d.mts.map +1 -0
  112. package/dist/{cache-BtZY_tHe.d.cts → cache-DnGDGly3.d.cts} +3 -6
  113. package/dist/cache-DnGDGly3.d.cts.map +1 -0
  114. package/dist/cache.cjs +68 -2
  115. package/dist/cache.cjs.map +1 -0
  116. package/dist/cache.d.cts +1 -2
  117. package/dist/cache.d.mts +1 -2
  118. package/dist/cache.mjs +67 -2
  119. package/dist/cache.mjs.map +1 -0
  120. package/dist/cipher-C1lEFX63.mjs +225 -0
  121. package/dist/cipher-C1lEFX63.mjs.map +1 -0
  122. package/dist/cipher-CVxfwLjk.cjs +332 -0
  123. package/dist/cipher-CVxfwLjk.cjs.map +1 -0
  124. package/dist/cipher-DSDxPRIp.d.cts +106 -0
  125. package/dist/cipher-DSDxPRIp.d.cts.map +1 -0
  126. package/dist/cipher-DSDxPRIp.d.mts +106 -0
  127. package/dist/cipher-DSDxPRIp.d.mts.map +1 -0
  128. package/dist/{clone-DblgEZZa.mjs → clone-EKNovYHu.mjs} +3 -3
  129. package/dist/clone-EKNovYHu.mjs.map +1 -0
  130. package/dist/{clone-Dy0cR2SZ.cjs → clone-UGJpvQnL.cjs} +7 -8
  131. package/dist/clone-UGJpvQnL.cjs.map +1 -0
  132. package/dist/{construct-interface-D9d4Gm4p.d.cts → construct-interface-B1AfqRl4.d.cts} +42 -11
  133. package/dist/construct-interface-B1AfqRl4.d.cts.map +1 -0
  134. package/dist/{construct-interface-g5GM5pwR.d.mts → construct-interface-ZvYQbivO.d.mts} +42 -11
  135. package/dist/construct-interface-ZvYQbivO.d.mts.map +1 -0
  136. package/dist/construct-interface.cjs +113 -7
  137. package/dist/construct-interface.cjs.map +1 -0
  138. package/dist/construct-interface.d.cts +2 -2
  139. package/dist/construct-interface.d.mts +2 -2
  140. package/dist/construct-interface.mjs +106 -2
  141. package/dist/construct-interface.mjs.map +1 -0
  142. package/dist/credential-DYymbp_7.cjs +257 -0
  143. package/dist/credential-DYymbp_7.cjs.map +1 -0
  144. package/dist/credential-DfSAOOdY.mjs +222 -0
  145. package/dist/credential-DfSAOOdY.mjs.map +1 -0
  146. package/dist/credential.cjs +8 -96
  147. package/dist/credential.d.cts +2 -61
  148. package/dist/credential.d.mts +2 -61
  149. package/dist/credential.mjs +2 -94
  150. package/dist/crons/index.cjs +129 -7
  151. package/dist/crons/index.cjs.map +1 -1
  152. package/dist/crons/index.d.cts +45 -11
  153. package/dist/crons/index.d.cts.map +1 -1
  154. package/dist/crons/index.d.mts +45 -11
  155. package/dist/crons/index.d.mts.map +1 -1
  156. package/dist/crons/index.mjs +127 -8
  157. package/dist/crons/index.mjs.map +1 -1
  158. package/dist/database/kysely.cjs +4 -181
  159. package/dist/database/kysely.d.cts +2 -152
  160. package/dist/database/kysely.d.mts +2 -152
  161. package/dist/database/kysely.mjs +2 -180
  162. package/dist/email.cjs +25 -12
  163. package/dist/email.cjs.map +1 -1
  164. package/dist/email.d.cts +3 -7
  165. package/dist/email.d.cts.map +1 -1
  166. package/dist/email.d.mts +4 -8
  167. package/dist/email.d.mts.map +1 -1
  168. package/dist/email.mjs +16 -3
  169. package/dist/email.mjs.map +1 -1
  170. package/dist/encryption/kms.cjs +95 -0
  171. package/dist/encryption/kms.cjs.map +1 -0
  172. package/dist/encryption/kms.d.cts +7 -0
  173. package/dist/encryption/kms.d.cts.map +1 -0
  174. package/dist/encryption/kms.d.mts +7 -0
  175. package/dist/encryption/kms.d.mts.map +1 -0
  176. package/dist/encryption/kms.mjs +93 -0
  177. package/dist/encryption/kms.mjs.map +1 -0
  178. package/dist/encryption.cjs +116 -0
  179. package/dist/encryption.cjs.map +1 -0
  180. package/dist/encryption.d.cts +37 -0
  181. package/dist/encryption.d.cts.map +1 -0
  182. package/dist/encryption.d.mts +37 -0
  183. package/dist/encryption.d.mts.map +1 -0
  184. package/dist/encryption.mjs +101 -0
  185. package/dist/encryption.mjs.map +1 -0
  186. package/dist/endpoints/index.cjs +27 -16
  187. package/dist/endpoints/index.d.cts +105 -7
  188. package/dist/endpoints/index.d.cts.map +1 -0
  189. package/dist/endpoints/index.d.mts +105 -7
  190. package/dist/endpoints/index.d.mts.map +1 -0
  191. package/dist/endpoints/index.mjs +6 -10
  192. package/dist/expire-C586zznE.d.cts +38 -0
  193. package/dist/expire-C586zznE.d.cts.map +1 -0
  194. package/dist/expire-C586zznE.d.mts +38 -0
  195. package/dist/expire-C586zznE.d.mts.map +1 -0
  196. package/dist/expire-CieftS01.cjs +67 -0
  197. package/dist/expire-CieftS01.cjs.map +1 -0
  198. package/dist/expire-CpzUAfr9.mjs +50 -0
  199. package/dist/expire-CpzUAfr9.mjs.map +1 -0
  200. package/dist/external-api.cjs +106 -0
  201. package/dist/external-api.cjs.map +1 -0
  202. package/dist/external-api.d.cts +2 -0
  203. package/dist/external-api.d.mts +2 -0
  204. package/dist/external-api.mjs +103 -0
  205. package/dist/external-api.mjs.map +1 -0
  206. package/dist/fake-B7rvi4Qp.d.cts +201 -0
  207. package/dist/fake-B7rvi4Qp.d.cts.map +1 -0
  208. package/dist/fake-JXbkdao8.d.mts +201 -0
  209. package/dist/fake-JXbkdao8.d.mts.map +1 -0
  210. package/dist/file-server.cjs +66 -11
  211. package/dist/file-server.cjs.map +1 -1
  212. package/dist/file-server.d.cts +25 -10
  213. package/dist/file-server.d.cts.map +1 -1
  214. package/dist/file-server.d.mts +25 -10
  215. package/dist/file-server.d.mts.map +1 -1
  216. package/dist/file-server.mjs +58 -4
  217. package/dist/file-server.mjs.map +1 -1
  218. package/dist/functions/index.cjs +3 -6
  219. package/dist/functions/index.d.cts +3 -4
  220. package/dist/functions/index.d.mts +3 -4
  221. package/dist/functions/index.mjs +2 -6
  222. package/dist/{functions-14lpEFL4.mjs → functions-CTI-hDem.mjs} +376 -238
  223. package/dist/{functions-14lpEFL4.mjs.map → functions-CTI-hDem.mjs.map} +1 -1
  224. package/dist/{functions-i_la-N5r.cjs → functions-D7O5SGVc.cjs} +414 -264
  225. package/dist/functions-D7O5SGVc.cjs.map +1 -0
  226. package/dist/index-Cd2w-DRL.d.cts +115 -0
  227. package/dist/index-Cd2w-DRL.d.cts.map +1 -0
  228. package/dist/index-DdRjYhiJ.d.cts +119 -0
  229. package/dist/index-DdRjYhiJ.d.cts.map +1 -0
  230. package/dist/index-DdRjYhiJ.d.mts +119 -0
  231. package/dist/index-DdRjYhiJ.d.mts.map +1 -0
  232. package/dist/index-aBIcAiH5.d.mts +115 -0
  233. package/dist/index-aBIcAiH5.d.mts.map +1 -0
  234. package/dist/index.cjs +6 -3
  235. package/dist/index.d.cts +27 -4
  236. package/dist/index.d.cts.map +1 -0
  237. package/dist/index.d.mts +27 -4
  238. package/dist/index.d.mts.map +1 -0
  239. package/dist/index.mjs +3 -3
  240. package/dist/kysely-BHYV-WC-.d.cts +216 -0
  241. package/dist/kysely-BHYV-WC-.d.cts.map +1 -0
  242. package/dist/kysely-CAW3QSqp.d.mts +216 -0
  243. package/dist/kysely-CAW3QSqp.d.mts.map +1 -0
  244. package/dist/kysely-Cs4uPO8k.mjs +371 -0
  245. package/dist/kysely-Cs4uPO8k.mjs.map +1 -0
  246. package/dist/kysely-CukArHJ0.cjs +384 -0
  247. package/dist/kysely-CukArHJ0.cjs.map +1 -0
  248. package/dist/{telemetry-C3L0iS28.d.cts → lambdaTelemetry-8vnmVZQ5.d.cts} +3 -6
  249. package/dist/lambdaTelemetry-8vnmVZQ5.d.cts.map +1 -0
  250. package/dist/{telemetry-D7bVFLGi.d.mts → lambdaTelemetry-8vnmVZQ5.d.mts} +3 -6
  251. package/dist/lambdaTelemetry-8vnmVZQ5.d.mts.map +1 -0
  252. package/dist/mobile-app.cjs +74 -0
  253. package/dist/mobile-app.cjs.map +1 -0
  254. package/dist/mobile-app.d.cts +73 -0
  255. package/dist/mobile-app.d.cts.map +1 -0
  256. package/dist/mobile-app.d.mts +73 -0
  257. package/dist/mobile-app.d.mts.map +1 -0
  258. package/dist/mobile-app.mjs +73 -0
  259. package/dist/mobile-app.mjs.map +1 -0
  260. package/dist/object-storage.cjs +26 -11
  261. package/dist/object-storage.cjs.map +1 -1
  262. package/dist/object-storage.d.cts +12 -7
  263. package/dist/object-storage.d.cts.map +1 -1
  264. package/dist/object-storage.d.mts +12 -7
  265. package/dist/object-storage.d.mts.map +1 -1
  266. package/dist/object-storage.mjs +18 -5
  267. package/dist/object-storage.mjs.map +1 -1
  268. package/dist/queue/index.cjs +6 -189
  269. package/dist/queue/index.d.cts +3 -60
  270. package/dist/queue/index.d.mts +3 -60
  271. package/dist/queue/index.mjs +3 -186
  272. package/dist/random-password.cjs +86 -0
  273. package/dist/random-password.cjs.map +1 -0
  274. package/dist/random-password.d.cts +30 -0
  275. package/dist/random-password.d.cts.map +1 -0
  276. package/dist/random-password.d.mts +30 -0
  277. package/dist/random-password.d.mts.map +1 -0
  278. package/dist/random-password.mjs +84 -0
  279. package/dist/random-password.mjs.map +1 -0
  280. package/dist/{lazyAccessors-BoJN3SMd.mjs → readRequestBody-BTIl3k-D.mjs} +117 -60
  281. package/dist/readRequestBody-BTIl3k-D.mjs.map +1 -0
  282. package/dist/readRequestBody-Dej_L3c4.cjs +342 -0
  283. package/dist/readRequestBody-Dej_L3c4.cjs.map +1 -0
  284. package/dist/requestLogger-BZcXwdBs.cjs +207 -0
  285. package/dist/requestLogger-BZcXwdBs.cjs.map +1 -0
  286. package/dist/requestLogger-pA4gi3E1.mjs +178 -0
  287. package/dist/requestLogger-pA4gi3E1.mjs.map +1 -0
  288. package/dist/rest-api.cjs +90 -59
  289. package/dist/rest-api.cjs.map +1 -1
  290. package/dist/rest-api.d.cts +70 -42
  291. package/dist/rest-api.d.cts.map +1 -1
  292. package/dist/rest-api.d.mts +70 -42
  293. package/dist/rest-api.d.mts.map +1 -1
  294. package/dist/rest-api.mjs +82 -51
  295. package/dist/rest-api.mjs.map +1 -1
  296. package/dist/{chunk-DWy1uDak.cjs → rolldown-runtime-y5ARvAq5.cjs} +14 -18
  297. package/dist/runSubscriber-BHvJ8POr.mjs +109 -0
  298. package/dist/runSubscriber-BHvJ8POr.mjs.map +1 -0
  299. package/dist/runSubscriber-D8nLXIv1.cjs +126 -0
  300. package/dist/runSubscriber-D8nLXIv1.cjs.map +1 -0
  301. package/dist/shutdown-BMJmAhSt.cjs +38 -0
  302. package/dist/shutdown-BMJmAhSt.cjs.map +1 -0
  303. package/dist/shutdown-C7xa8x9S.mjs +27 -0
  304. package/dist/shutdown-C7xa8x9S.mjs.map +1 -0
  305. package/dist/site.cjs +33 -7
  306. package/dist/site.cjs.map +1 -1
  307. package/dist/site.d.cts +17 -7
  308. package/dist/site.d.cts.map +1 -1
  309. package/dist/site.d.mts +17 -7
  310. package/dist/site.d.mts.map +1 -1
  311. package/dist/site.mjs +29 -3
  312. package/dist/site.mjs.map +1 -1
  313. package/dist/stages-BSCF19o2.d.cts +56 -0
  314. package/dist/stages-BSCF19o2.d.cts.map +1 -0
  315. package/dist/stages-BSCF19o2.d.mts +56 -0
  316. package/dist/stages-BSCF19o2.d.mts.map +1 -0
  317. package/dist/subscribers/index.cjs +118 -6
  318. package/dist/subscribers/index.cjs.map +1 -0
  319. package/dist/subscribers/index.d.cts +51 -6
  320. package/dist/subscribers/index.d.cts.map +1 -0
  321. package/dist/subscribers/index.d.mts +51 -6
  322. package/dist/subscribers/index.d.mts.map +1 -0
  323. package/dist/subscribers/index.mjs +115 -5
  324. package/dist/subscribers/index.mjs.map +1 -0
  325. package/dist/surfaceEnv-CNimK76p.cjs +56 -0
  326. package/dist/surfaceEnv-CNimK76p.cjs.map +1 -0
  327. package/dist/surfaceEnv-wMT5QzgZ.mjs +45 -0
  328. package/dist/surfaceEnv-wMT5QzgZ.mjs.map +1 -0
  329. package/dist/telemetry-B48RLjyk.d.cts +40 -0
  330. package/dist/telemetry-B48RLjyk.d.cts.map +1 -0
  331. package/dist/telemetry-BEoBn6GO.d.mts +40 -0
  332. package/dist/telemetry-BEoBn6GO.d.mts.map +1 -0
  333. package/dist/telemetry.cjs +56 -0
  334. package/dist/telemetry.cjs.map +1 -0
  335. package/dist/telemetry.d.cts +2 -0
  336. package/dist/telemetry.d.mts +2 -0
  337. package/dist/telemetry.mjs +55 -0
  338. package/dist/telemetry.mjs.map +1 -0
  339. package/dist/topic/index.cjs +3 -137
  340. package/dist/topic/index.d.cts +2 -4
  341. package/dist/topic/index.d.mts +2 -4
  342. package/dist/topic/index.mjs +2 -134
  343. package/dist/tracing-Bbj1uoFJ.mjs +127 -0
  344. package/dist/tracing-Bbj1uoFJ.mjs.map +1 -0
  345. package/dist/tracing-C0ooU0V2.cjs +150 -0
  346. package/dist/tracing-C0ooU0V2.cjs.map +1 -0
  347. package/dist/{types-BlAkSuGI.d.cts → types-DMuSQeLL.d.cts} +3 -5
  348. package/dist/types-DMuSQeLL.d.cts.map +1 -0
  349. package/dist/{types-aKksMEWL.d.mts → types-DMuSQeLL.d.mts} +3 -5
  350. package/dist/types-DMuSQeLL.d.mts.map +1 -0
  351. package/dist/types.d.cts +1 -1
  352. package/dist/types.d.mts +1 -1
  353. package/dist/types.mjs +1 -0
  354. package/dist/worker.cjs +59 -34
  355. package/dist/worker.cjs.map +1 -1
  356. package/dist/worker.d.cts +70 -45
  357. package/dist/worker.d.cts.map +1 -1
  358. package/dist/worker.d.mts +71 -45
  359. package/dist/worker.d.mts.map +1 -1
  360. package/dist/worker.mjs +54 -29
  361. package/dist/worker.mjs.map +1 -1
  362. package/package.json +115 -41
  363. package/dist/Construct-BD5neF7w.mjs.map +0 -1
  364. package/dist/Construct-C0ijr2qp.d.cts +0 -117
  365. package/dist/Construct-C0ijr2qp.d.cts.map +0 -1
  366. package/dist/Construct-Ct8nalEi.d.mts +0 -117
  367. package/dist/Construct-Ct8nalEi.d.mts.map +0 -1
  368. package/dist/Construct-CyS3RpTL.cjs.map +0 -1
  369. package/dist/Cron-DmQ8vQ4b.d.cts.map +0 -1
  370. package/dist/Cron-dh4rUgib.d.mts.map +0 -1
  371. package/dist/CronBuilder-BquXDbDI.d.cts +0 -44
  372. package/dist/CronBuilder-BquXDbDI.d.cts.map +0 -1
  373. package/dist/CronBuilder-CGgY2080.d.mts +0 -44
  374. package/dist/CronBuilder-CGgY2080.d.mts.map +0 -1
  375. package/dist/CronBuilder-CYKT5RiO.mjs.map +0 -1
  376. package/dist/CronBuilder-Da0C0edR.cjs.map +0 -1
  377. package/dist/Endpoint-BjWKinFA.d.mts.map +0 -1
  378. package/dist/Endpoint-DCQPMdUX.mjs.map +0 -1
  379. package/dist/Endpoint-DcWXE-SZ.cjs.map +0 -1
  380. package/dist/Endpoint-dav89W6-.d.cts.map +0 -1
  381. package/dist/EndpointFactory-CdWB7wPw.cjs.map +0 -1
  382. package/dist/EndpointFactory-CjV8F_lJ.mjs.map +0 -1
  383. package/dist/HonoEndpointAdaptor-DtL9j19R.cjs.map +0 -1
  384. package/dist/HonoEndpointAdaptor-P1ahhZHu.mjs.map +0 -1
  385. package/dist/Queue-D7ZuwBhy.d.cts.map +0 -1
  386. package/dist/Queue-gVGfi2Yk.d.mts.map +0 -1
  387. package/dist/Subscriber-2mEi0ImH.d.cts.map +0 -1
  388. package/dist/Subscriber-xTJ9ayPN.d.mts.map +0 -1
  389. package/dist/SubscriberBuilder-4OPehf2R.cjs.map +0 -1
  390. package/dist/SubscriberBuilder-BjkbeT9l.mjs.map +0 -1
  391. package/dist/SubscriberBuilder-Dptmo-1A.d.mts +0 -62
  392. package/dist/SubscriberBuilder-Dptmo-1A.d.mts.map +0 -1
  393. package/dist/SubscriberBuilder-waNhzjSM.d.cts +0 -62
  394. package/dist/SubscriberBuilder-waNhzjSM.d.cts.map +0 -1
  395. package/dist/Topic-19QeHBIR.d.cts +0 -91
  396. package/dist/Topic-19QeHBIR.d.cts.map +0 -1
  397. package/dist/Topic-DuFeqkBh.d.mts +0 -91
  398. package/dist/Topic-DuFeqkBh.d.mts.map +0 -1
  399. package/dist/auth.d.cts.map +0 -1
  400. package/dist/auth.d.mts.map +0 -1
  401. package/dist/cache-0ANvRQnD.mjs +0 -51
  402. package/dist/cache-0ANvRQnD.mjs.map +0 -1
  403. package/dist/cache-3WSvAulx.cjs +0 -57
  404. package/dist/cache-3WSvAulx.cjs.map +0 -1
  405. package/dist/cache-BrRz3fEB.d.mts.map +0 -1
  406. package/dist/cache-BtZY_tHe.d.cts.map +0 -1
  407. package/dist/clone-DblgEZZa.mjs.map +0 -1
  408. package/dist/clone-Dy0cR2SZ.cjs.map +0 -1
  409. package/dist/construct-interface-BfjcOD_E.cjs +0 -117
  410. package/dist/construct-interface-BfjcOD_E.cjs.map +0 -1
  411. package/dist/construct-interface-D9d4Gm4p.d.cts.map +0 -1
  412. package/dist/construct-interface-Z4CpS8tK.mjs +0 -81
  413. package/dist/construct-interface-Z4CpS8tK.mjs.map +0 -1
  414. package/dist/construct-interface-g5GM5pwR.d.mts.map +0 -1
  415. package/dist/credential.cjs.map +0 -1
  416. package/dist/credential.d.cts.map +0 -1
  417. package/dist/credential.d.mts.map +0 -1
  418. package/dist/credential.mjs.map +0 -1
  419. package/dist/database/kysely.cjs.map +0 -1
  420. package/dist/database/kysely.d.cts.map +0 -1
  421. package/dist/database/kysely.d.mts.map +0 -1
  422. package/dist/database/kysely.mjs.map +0 -1
  423. package/dist/functions-i_la-N5r.cjs.map +0 -1
  424. package/dist/index-Bd5FqCoe.d.cts.map +0 -1
  425. package/dist/index-BknhM6Ux.d.mts +0 -31
  426. package/dist/index-BknhM6Ux.d.mts.map +0 -1
  427. package/dist/index-CBSfrowv.d.cts +0 -31
  428. package/dist/index-CBSfrowv.d.cts.map +0 -1
  429. package/dist/index-D24Xm79M.d.cts +0 -171
  430. package/dist/index-D24Xm79M.d.cts.map +0 -1
  431. package/dist/index-_ajboYxK.d.mts +0 -171
  432. package/dist/index-_ajboYxK.d.mts.map +0 -1
  433. package/dist/index-lAO9egTb.d.mts.map +0 -1
  434. package/dist/lazyAccessors-BoJN3SMd.mjs.map +0 -1
  435. package/dist/lazyAccessors-e3j2oE2m.cjs +0 -274
  436. package/dist/lazyAccessors-e3j2oE2m.cjs.map +0 -1
  437. package/dist/processAudits-CGqttuXm.cjs +0 -92
  438. package/dist/processAudits-CGqttuXm.cjs.map +0 -1
  439. package/dist/processAudits-Dmts9H_b.mjs +0 -80
  440. package/dist/processAudits-Dmts9H_b.mjs.map +0 -1
  441. package/dist/queue/index.cjs.map +0 -1
  442. package/dist/queue/index.d.cts.map +0 -1
  443. package/dist/queue/index.d.mts.map +0 -1
  444. package/dist/queue/index.mjs.map +0 -1
  445. package/dist/surfaceEnv-BFXEms2f.cjs +0 -39
  446. package/dist/surfaceEnv-BFXEms2f.cjs.map +0 -1
  447. package/dist/surfaceEnv-C3Ktahea.mjs +0 -27
  448. package/dist/surfaceEnv-C3Ktahea.mjs.map +0 -1
  449. package/dist/telemetry-C3L0iS28.d.cts.map +0 -1
  450. package/dist/telemetry-D7bVFLGi.d.mts.map +0 -1
  451. package/dist/topic/index.cjs.map +0 -1
  452. package/dist/topic/index.mjs.map +0 -1
  453. package/dist/types-BlAkSuGI.d.cts.map +0 -1
  454. package/dist/types-aKksMEWL.d.mts.map +0 -1
@@ -1,117 +0,0 @@
1
-
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 [...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
- 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
-
80
- //#endregion
81
- Object.defineProperty(exports, 'NotAConstruct', {
82
- enumerable: true,
83
- get: function () {
84
- return NotAConstruct;
85
- }
86
- });
87
- Object.defineProperty(exports, 'edgeTo', {
88
- enumerable: true,
89
- get: function () {
90
- return edgeTo;
91
- }
92
- });
93
- Object.defineProperty(exports, 'idsOf', {
94
- enumerable: true,
95
- get: function () {
96
- return idsOf;
97
- }
98
- });
99
- Object.defineProperty(exports, 'isConsumable', {
100
- enumerable: true,
101
- get: function () {
102
- return isConsumable;
103
- }
104
- });
105
- Object.defineProperty(exports, 'serviceOf', {
106
- enumerable: true,
107
- get: function () {
108
- return serviceOf;
109
- }
110
- });
111
- Object.defineProperty(exports, 'servicesOf', {
112
- enumerable: true,
113
- get: function () {
114
- return servicesOf;
115
- }
116
- });
117
- //# sourceMappingURL=construct-interface-BfjcOD_E.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"construct-interface-BfjcOD_E.cjs","names":["construct: Declarable","constructs: T","constructs: readonly Consumable[]","existing: readonly string[]","value: unknown","source: Consumable<TName, TClient> | Service<TName, TClient>"],"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,OAAOA,WAAmC;CACzD,MAAM,YAAY,UAChB,SAAS,CACT,KAAK,CAAC,gBAAgB,YAAY,OAAO,UAAU,GAAG;AAExD,MAAK,UAAW,OAAM,IAAI,cAAc;AAExC,QAAO;EAAE,QAAQ,UAAU;EAAI,MAAM,UAAU;CAAM;AACrD;;;;;;;;AA6CD,SAAgB,WACfC,YACgB;AAChB,QAAO,WAAW,IAAI,CAAC,cAAc;AACpC,OAAK,aAAa,UAAU,CAAE,OAAM,IAAI,cAAc;AAEtD,SAAO,UAAU;CACjB,EAAC;AACF;;;;;;;;;;AAWD,SAAgB,MACfC,YACAC,WAA8B,CAAE,GACrB;AACX,QAAO,CAAC,GAAG,IAAI,IAAI,CAAC,GAAG,UAAU,GAAG,WAAW,IAAI,CAAC,EAAE,IAAI,KAAK,GAAG,AAAC,EAAE;AACrE;;AAGD,IAAa,gBAAb,cAAmC,MAAM;CACxC,YAAqBC,OAAgB;EACpC,MAAM,cACE,UAAU,YAAY,UAAU,QAAQ,iBAAiB,SAC5D,eAAe,OAAQ,MAAmC,YAAY,CAAC,MACvE,WAAW,MAAM;AAEtB,SACE,+CAA+C,KAAK,+EAGrD;EAVmB;AAWpB,OAAK,OAAO;CACZ;AACD;;;;;;;;AASD,SAAgB,aAAaA,OAAqC;AACjE,YAAW,UAAU,YAAY,UAAU,KAAM,QAAO;CAExD,MAAM,YAAY;AAElB,eACQ,UAAU,OAAO,mBACjB,UAAU,YAAY,qBACrB,UAAU,SAAiC,gBAAgB;AAEpE;;;;;;;;AASD,SAAgB,UACfC,QAC0B;AAG1B,QAAO,aAAa,OAAO,GACvB,OAAO,UACP;AACJ"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"construct-interface-D9d4Gm4p.d.cts","names":[],"sources":["../src/construct-interface.ts"],"sourcesContent":[],"mappings":";;;;;AAiEuB;AAevB;;;;AAAyD;AAWzD;;;AACW,UA/DM,SA+DN,CAAA,cAAA,MAAA,GAAA,MAAA,EAAA,UAAA,KAAA,CAAA,CAAA;EAAS;EAAiC,SAAA,EAAA,EA7DvC,KA6DuC;EAGzC;;;;;AACsC;AAYlD;EAA2B,OAAA,EAAA,EApEf,WAoEe,EAAA;EAAA;;;;;;AAGJ;EAWX,SAAA,OAAU,EAAA,CAzEF,OAyEE,CAAA,SAAA,CAAA,KAAA,CAAA,GAAA,KAAA,GAvElB,OAuEkB,CAvEV,YAuEU,CAvEG,KAuEH,CAAA,EAvEW,OAuEX,CAAA;;;;;;AACF;AAUpB;;;;AAEc,UAxEG,UAwEH,CAAA,cAAA,MAAA,GAAA,MAAA,CAAA,CAAA;EAAC,SAAZ,EAAA,EAvEW,KAuEX;EAAU,OAAA,EAAA,EAtED,WAsEC,EAAA;AAiBb;AAQA;AAuBA;AAmBA;;;;;;;;;;AAEG,iBA5Ha,MAAA,CA4Hb,SAAA,EA5H+B,UA4H/B,CAAA,EA5H4C,UA4H5C;AAAO;KAjHE,WACX,UAAU,mCAAmC;;KAGlC,YACX,UAAU,kCAAkC;;;;;;;;;;;UAY5B;eACH;oBACK,QAAQ,aAAa,QAAQ;aACpC;;;;;;;;;;KAWA,8BAA8B,8BAC7B,IAAI,EAAE;;;;;;;;iBAUH,oCAAoC,0BACvC,IACV,WAAW;;;;;;;;;;iBAiBE,KAAA,sBACM;;cAOT,aAAA,SAAsB,KAAK;;;;;;;;;;;iBAuBxB,YAAA,2BAAuC;;;;;;;;iBAmBvC,iDACP,WAAW,OAAO,WAAW,QAAQ,OAAO,WAClD,QAAQ,OAAO"}
@@ -1,81 +0,0 @@
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 [...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
- constructor(value) {
50
- const name = typeof value === "object" && value !== null && "serviceName" in value ? `the service '${String(value.serviceName)}'` : `a ${typeof value}`;
51
- super(`.dependsOn() takes constructs, and was given ${name}. Pass it to .services([…]) instead, or lift it with Construct.fromService().`);
52
- this.value = value;
53
- this.name = "NotAConstruct";
54
- }
55
- };
56
- /**
57
- * Whether a value is a construct rather than a bare `Service`.
58
- *
59
- * Structural rather than `instanceof`: a construct from a second copy of
60
- * `@geekmidas/constructs` — a linked workspace, two versions in a lockfile — is
61
- * still a construct, and `instanceof` is exactly the check that says otherwise.
62
- */
63
- function isConsumable(value) {
64
- if (typeof value !== "object" || value === null) return false;
65
- const candidate = value;
66
- return typeof candidate.id === "string" && typeof candidate.declare === "function" && typeof candidate.service?.serviceName === "string";
67
- }
68
- /**
69
- * The service behind either face.
70
- *
71
- * `.database()` and the publisher slots take a construct now; they took a
72
- * `Service` before and still do, because a hand-written one is exactly what
73
- * `Construct.fromService` exists to lift and not everything has been lifted.
74
- */
75
- function serviceOf(source) {
76
- return isConsumable(source) ? source.service : source;
77
- }
78
-
79
- //#endregion
80
- export { NotAConstruct, edgeTo, idsOf, isConsumable, serviceOf, servicesOf };
81
- //# sourceMappingURL=construct-interface-Z4CpS8tK.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"construct-interface-Z4CpS8tK.mjs","names":["construct: Declarable","constructs: T","constructs: readonly Consumable[]","existing: readonly string[]","value: unknown","source: Consumable<TName, TClient> | Service<TName, TClient>"],"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,OAAOA,WAAmC;CACzD,MAAM,YAAY,UAChB,SAAS,CACT,KAAK,CAAC,gBAAgB,YAAY,OAAO,UAAU,GAAG;AAExD,MAAK,UAAW,OAAM,IAAI,cAAc;AAExC,QAAO;EAAE,QAAQ,UAAU;EAAI,MAAM,UAAU;CAAM;AACrD;;;;;;;;AA6CD,SAAgB,WACfC,YACgB;AAChB,QAAO,WAAW,IAAI,CAAC,cAAc;AACpC,OAAK,aAAa,UAAU,CAAE,OAAM,IAAI,cAAc;AAEtD,SAAO,UAAU;CACjB,EAAC;AACF;;;;;;;;;;AAWD,SAAgB,MACfC,YACAC,WAA8B,CAAE,GACrB;AACX,QAAO,CAAC,GAAG,IAAI,IAAI,CAAC,GAAG,UAAU,GAAG,WAAW,IAAI,CAAC,EAAE,IAAI,KAAK,GAAG,AAAC,EAAE;AACrE;;AAGD,IAAa,gBAAb,cAAmC,MAAM;CACxC,YAAqBC,OAAgB;EACpC,MAAM,cACE,UAAU,YAAY,UAAU,QAAQ,iBAAiB,SAC5D,eAAe,OAAQ,MAAmC,YAAY,CAAC,MACvE,WAAW,MAAM;AAE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A8B,8BAC7B,IAAI,EAAE;;;;;;;;iBAUH,oCAAoC,0BACvC,IACV,WAAW;;;;;;;;;;iBAiBE,KAAA,sBACM;;cAOT,aAAA,SAAsB,KAAK;;;;;;;;;;;iBAuBxB,YAAA,2BAAuC;;;;;;;;iBAmBvC,iDACP,WAAW,OAAO,WAAW,QAAQ,OAAO,WAClD,QAAQ,OAAO"}
@@ -1 +0,0 @@
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,QAA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6BACvB,WAAW,OAAO,MAAM;;eASvB;oBACK,QAAQ,aAAa,QAAQ,MAAM;;;;;;;;;;;;;;kBAkBhD,cAAc,iBACQ,kBAAkB;aAclC;;;;;cA4DC,mBAAA,SAA4B,KAAK"}
@@ -1 +0,0 @@
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 +0,0 @@
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;AACx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AAM,QAAQ,IAAI,MAAM;CAClD,EAAC,CACD,KAAK,KAAK;AACZ"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"kysely.cjs","names":["id: ConstructName<TName>","options: KyselyDatabaseOptions","derivedFrom?: DerivedFrom","DEFAULT_POSTGRES_VERSION","id: ConstructName<TCache>","options: { table?: string }","Cache","id: ConstructName<TTenant>","options: ServiceRegisterOptions","as: { owner?: boolean }","kysely","Kysely","PostgresDialect","url: string"],"sources":["../../src/database/kysely.ts"],"sourcesContent":["/**\n * `KyselyDatabase` — a declared Postgres database, typed by its schema.\n *\n * It declares a logical database, a schema, and the roles that reach it, and\n * hands back a Kysely client built from the one URL the adapter supplied. It\n * names no cloud: `--target=aws` fills that URL from RDS, local dev from the\n * Postgres container.\n *\n * Transactions and RLS context are the execution wrapper's job — it opens the\n * transaction and puts it in `ctx.db`. This construct does not resolve\n * connections per request.\n */\n\nimport {\n\ttype ConstructName,\n\tcanonicalId,\n\tDEFAULT_POSTGRES_VERSION,\n\ttype Declaration,\n\ttype PostgresVersion,\n\tprovideKey,\n\tserviceKey,\n} from '@geekmidas/manifest';\nimport type { Service, ServiceRegisterOptions } from '@geekmidas/services';\nimport { Kysely, type KyselyConfig, PostgresDialect } from 'kysely';\nimport pg from 'pg';\nimport { Cache } from '../cache';\nimport type { Construct } from '../construct-interface';\n\n/** The schema a database uses when it does not say otherwise. */\nconst DEFAULT_SCHEMA = 'app';\n\n/**\n * Everything Kysely takes, plus what this construct declares.\n *\n * `dialect` is omitted because the construct owns it — it is built from the one\n * URL the adapter supplied, which is the whole point of the construct. The rest\n * of `KyselyConfig` (`plugins`, `log`) is the app's business and passes\n * straight through, so anything Kysely adds later arrives without being\n * tracked here.\n */\nexport interface KyselyDatabaseOptions extends Omit<KyselyConfig, 'dialect'> {\n\t/**\n\t * The schema, pinned on both roles' `search_path`.\n\t *\n\t * Defaults to `app` — the role the schema plays, rather than a restatement\n\t * of the database's own name, which reads correctly beside `auth` and\n\t * `pgboss` and keeps the application off `public`.\n\t */\n\tschema?: string;\n\t/**\n\t * Provision the owner/runtime role split. Defaults to on.\n\t *\n\t * Off falls back to the cluster's master credential in both URLs, giving up\n\t * the DDL/DML split and putting credentials that can drop a table into the\n\t * function's environment. A deliberate downgrade, not a default.\n\t */\n\troles?: boolean;\n\t/**\n\t * The Postgres major version to provision.\n\t *\n\t * Declared here so one statement reaches both targets. It was previously\n\t * set in two unrelated places — a container tag locally, nothing at all on\n\t * AWS (so Aurora chose) — which is how local came to run 18 while deployed\n\t * ran 17.7 with nothing recording the difference.\n\t *\n\t * Defaults to {@link DEFAULT_POSTGRES_VERSION}.\n\t */\n\tversion?: PostgresVersion;\n}\n\n/** What makes a construct derived rather than a database in its own right. */\ninterface DerivedFrom {\n\tkind: 'database-reader' | 'database-schema';\n\tof: string;\n\tschema?: string;\n}\n\n/**\n * @typeParam DB - the database's schema.\n * @typeParam TName - the canonical id. TypeScript has no partial\n * type-argument inference, so `new KyselyDatabase<OrdersDB>('orders')` leaves\n * this at its default and the service key widens to `string`. `db` still types\n * through `.database()`, which infers from the service.\n */\nexport class KyselyDatabase<DB = unknown, TName extends string = string>\n\timplements Construct<TName, Kysely<DB>>\n{\n\treadonly id: TName;\n\treadonly service: Service<Uncapitalize<TName>, Kysely<DB>>;\n\n\t/**\n\t * Declared once and read by both `declare()` and `connect()`, so the key the\n\t * build publishes and the key the client reads cannot drift.\n\t */\n\tprivate readonly config: { url: string; ownerUrl: string };\n\tprivate readonly schemaName: string;\n\tprivate readonly roles: boolean;\n\tprivate readonly version: PostgresVersion;\n\tprivate readonly derivedFrom?: DerivedFrom;\n\n\tconstructor(\n\t\tid: ConstructName<TName>,\n\t\tprivate readonly options: KyselyDatabaseOptions = {},\n\t\tderivedFrom?: DerivedFrom,\n\t) {\n\t\t// Canonicalises, so `orders` and `Orders` are one construct rather than\n\t\t// two that collide. Throws on anything that cannot become a valid id.\n\t\tconst canonical = canonicalId(id as string);\n\n\t\tthis.id = canonical as TName;\n\t\tthis.config = {\n\t\t\turl: provideKey(canonical, 'url'),\n\t\t\townerUrl: provideKey(canonical, 'ownerUrl'),\n\t\t};\n\t\tthis.schemaName = options.schema ?? DEFAULT_SCHEMA;\n\t\tthis.roles = options.roles ?? true;\n\t\tthis.version = options.version ?? DEFAULT_POSTGRES_VERSION;\n\t\tthis.derivedFrom = derivedFrom;\n\n\t\t// A field, not a getter: service discovery caches by object identity.\n\t\tthis.service = {\n\t\t\tserviceName: serviceKey(canonical) as Uncapitalize<TName>,\n\t\t\t// Forwards the whole options object — cherry-picking `envParser` strips\n\t\t\t// `context` and with it the request-scoped logger.\n\t\t\tregister: (registerOptions) => this.connect(registerOptions),\n\t\t};\n\t}\n\n\tdeclare(): Declaration[] {\n\t\tif (this.derivedFrom) {\n\t\t\tconst { kind, of, schema } = this.derivedFrom;\n\n\t\t\treturn [\n\t\t\t\tkind === 'database-schema'\n\t\t\t\t\t? {\n\t\t\t\t\t\t\tkind,\n\t\t\t\t\t\t\tid: this.id,\n\t\t\t\t\t\t\tof,\n\t\t\t\t\t\t\tschema: schema ?? this.schemaName,\n\t\t\t\t\t\t\t// The runtime key alone — see the note below on the parent.\n\t\t\t\t\t\t\tprovides: [this.config.url],\n\t\t\t\t\t\t}\n\t\t\t\t\t: {\n\t\t\t\t\t\t\tkind,\n\t\t\t\t\t\t\tid: this.id,\n\t\t\t\t\t\t\tof,\n\t\t\t\t\t\t\t// A reader has no owner URL of its own — nothing migrates\n\t\t\t\t\t\t\t// through a read-only endpoint — so this is the one key.\n\t\t\t\t\t\t\tprovides: [this.config.url],\n\t\t\t\t\t\t},\n\t\t\t];\n\t\t}\n\n\t\treturn [\n\t\t\t{\n\t\t\t\tkind: 'database',\n\t\t\t\tid: this.id,\n\t\t\t\tengine: 'postgres',\n\t\t\t\tschema: this.schemaName,\n\t\t\t\tversion: this.version,\n\t\t\t\t// One key, the runtime role's. `config` also holds the owner key and\n\t\t\t\t// it is deliberately absent here: a key in `provides` is a key an\n\t\t\t\t// edge can name, and nothing should be able to depend on DDL rights.\n\t\t\t\tprovides: [this.config.url],\n\t\t\t\t...(this.roles ? {} : { roles: false }),\n\t\t\t},\n\t\t];\n\t}\n\n\t/**\n\t * A read-only endpoint on this database.\n\t *\n\t * Read-only is enforced by the reader role's grants rather than by which\n\t * endpoint it resolves to, so falling back to the writer where no replica\n\t * exists is safe rather than a silently writable connection behind a name\n\t * that says reader. There is no `writer()`: the database *is* the writer, so\n\t * a replica can never be reached by accident.\n\t *\n\t * The return type is narrower than this class on purpose — see\n\t * {@link ReadOnlyDatabase}.\n\t */\n\treader(): ReadOnlyDatabase<DB, `${TName}Reader`> {\n\t\treturn new KyselyDatabase<DB, `${TName}Reader`>(\n\t\t\t`${this.id}Reader` as ConstructName<`${TName}Reader`>,\n\t\t\tthis.options,\n\t\t\t{ kind: 'database-reader', of: this.id },\n\t\t);\n\t}\n\n\t/**\n\t * A cache that lives in this database.\n\t *\n\t * The same strengthening `schema()` is over a second database: `new\n\t * Cache('Sessions')` says the app caches and leaves where to the deployment,\n\t * while this says it caches *here* — which is a fact about the application\n\t * and so belongs in its code.\n\t *\n\t * What it buys beyond being explicit: the table's schema and the role that\n\t * reaches it come from this database rather than from a second convention,\n\t * and the backend no longer has to guess which database \"the database\" meant\n\t * when an app declares two.\n\t *\n\t * A cache is not a `KyselyDatabase`, so this returns a `Cache` — the client\n\t * is a key/value store, not a query builder, and typing it as the parent\n\t * would be a convenience that lies.\n\t */\n\tcache<TCache extends string = `${TName}Cache`>(\n\t\tid: ConstructName<TCache> = `${this.id}Cache` as ConstructName<TCache>,\n\t\toptions: { table?: string } = {},\n\t): Cache<TCache> {\n\t\treturn new Cache<TCache>(id, {\n\t\t\tof: this.id,\n\t\t\t...(options.table ? { table: options.table } : {}),\n\t\t});\n\t}\n\n\t/**\n\t * A second schema in this database, with its own role(s) and its own URL —\n\t * so this database's role holds no grant on those tables at all.\n\t *\n\t * Typed separately because a tenant has its own tables: the point is that\n\t * `auth.selectFrom('sessions')` type-checks and\n\t * `orders.selectFrom('sessions')` does not.\n\t */\n\tschema<TenantDB, TTenant extends string>(\n\t\tid: ConstructName<TTenant>,\n\t\toptions: KyselyDatabaseOptions = {},\n\t): KyselyDatabase<TenantDB, TTenant> {\n\t\treturn new KyselyDatabase<TenantDB, TTenant>(id, options, {\n\t\t\tkind: 'database-schema',\n\t\t\tof: this.id,\n\t\t\tschema: options.schema ?? (id as string).toLowerCase(),\n\t\t});\n\t}\n\n\t/**\n\t * A connection as the *owner* role — the one that may create, alter and drop.\n\t *\n\t * A `Service` rather than part of the construct, and deliberately so: a\n\t * construct is what `.dependsOn()` accepts, and nothing should be able to\n\t * depend on this. A migrator asks for it by name; a handler cannot ask at\n\t * all, which is the security property the role split exists for.\n\t *\n\t * Falls back to the runtime URL where no owner URL was published — the\n\t * `roles: false` downgrade, where there is only one credential and it is the\n\t * cluster master's.\n\t */\n\tget owner(): Service<`${Uncapitalize<TName>}Owner`, Kysely<DB>> {\n\t\treturn {\n\t\t\tserviceName:\n\t\t\t\t`${serviceKey(this.id)}Owner` as `${Uncapitalize<TName>}Owner`,\n\t\t\tregister: (options) => this.connect(options, { owner: true }),\n\t\t};\n\t}\n\n\tprivate async connect(\n\t\toptions: ServiceRegisterOptions,\n\t\tas: { owner?: boolean } = {},\n\t): Promise<Kysely<DB>> {\n\t\tconst { url, ownerUrl } = options.envParser\n\t\t\t.create((get) => ({\n\t\t\t\turl: get(this.config.url).string(),\n\t\t\t\townerUrl: get(this.config.ownerUrl).string().optional(),\n\t\t\t}))\n\t\t\t.parse();\n\n\t\t// Split what the manifest declared from what Kysely takes, so neither\n\t\t// leaks into the other: `schema` and `roles` describe infrastructure and\n\t\t// mean nothing to a client.\n\t\tconst { schema: _schema, roles: _roles, ...kysely } = this.options;\n\n\t\treturn new Kysely<DB>({\n\t\t\t...kysely,\n\t\t\tdialect: new PostgresDialect({\n\t\t\t\tpool: pool(as.owner ? (ownerUrl ?? url) : url),\n\t\t\t}),\n\t\t});\n\t}\n}\n\n/**\n * A pool for one URL, with its schema actually on the search path.\n *\n * `?search_path=` is not a libpq parameter — a URL carrying it connects\n * happily and then resolves every unqualified name against `public`, which is\n * how a schema tenant silently writes its tables into the database it was\n * separated from. Postgres takes it as a startup option instead, so the URL\n * keeps the readable form the target derives and this turns it into the thing\n * the server understands.\n */\nfunction pool(url: string): pg.Pool {\n\tconst parsed = new URL(url);\n\tconst searchPath = parsed.searchParams.get('search_path');\n\n\tif (!searchPath) return new pg.Pool({ connectionString: url });\n\n\tparsed.searchParams.delete('search_path');\n\n\treturn new pg.Pool({\n\t\tconnectionString: parsed.toString(),\n\t\toptions: `-c search_path=${searchPath}`,\n\t});\n}\n\n/**\n * A database you may read through, and derive nothing from.\n *\n * A reader is terminal in the graph, and this is that fact in the type system.\n * `DERIVES_FROM` gives `cache` and `database-schema` no `database-reader`\n * parent, and there is no reader of a reader — so `orders.reader().cache(…)`\n * has always been illegal, but it type-checked and failed later at\n * `assertDerivations`. That is a long way round to learn that a read-only\n * endpoint cannot own a table something writes to.\n *\n * Omitting the three deriving methods rather than making them throw keeps the\n * failure where it costs least: the editor, on the line that wrote it.\n *\n * The result is deliberately not assignable back to `KyselyDatabase` — a\n * reader is not one, and anything that genuinely needs the writer should say\n * so.\n */\nexport type ReadOnlyDatabase<DB, TName extends string> = Omit<\n\tKyselyDatabase<DB, TName>,\n\t'reader' | 'cache' | 'schema'\n>;\n"],"mappings":";;;;;;;;AA6BA,MAAM,iBAAiB;;;;;;;;AAuDvB,IAAa,iBAAb,MAAa,eAEb;CACC,AAAS;CACT,AAAS;;;;;CAMT,AAAiB;CACjB,AAAiB;CACjB,AAAiB;CACjB,AAAiB;CACjB,AAAiB;CAEjB,YACCA,IACiBC,UAAiC,CAAE,GACpDC,aACC;EAFgB;EAKjB,MAAM,YAAY,sCAAY,GAAa;AAE3C,OAAK,KAAK;AACV,OAAK,SAAS;GACb,KAAK,qCAAW,WAAW,MAAM;GACjC,UAAU,qCAAW,WAAW,WAAW;EAC3C;A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IAAI"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"kysely.mjs","names":["id: ConstructName<TName>","options: KyselyDatabaseOptions","derivedFrom?: DerivedFrom","id: ConstructName<TCache>","options: { table?: string }","id: ConstructName<TTenant>","options: ServiceRegisterOptions","as: { owner?: boolean }","url: string"],"sources":["../../src/database/kysely.ts"],"sourcesContent":["/**\n * `KyselyDatabase` — a declared Postgres database, typed by its schema.\n *\n * It declares a logical database, a schema, and the roles that reach it, and\n * hands back a Kysely client built from the one URL the adapter supplied. It\n * names no cloud: `--target=aws` fills that URL from RDS, local dev from the\n * Postgres container.\n *\n * Transactions and RLS context are the execution wrapper's job — it opens the\n * transaction and puts it in `ctx.db`. This construct does not resolve\n * connections per request.\n */\n\nimport {\n\ttype ConstructName,\n\tcanonicalId,\n\tDEFAULT_POSTGRES_VERSION,\n\ttype Declaration,\n\ttype PostgresVersion,\n\tprovideKey,\n\tserviceKey,\n} from '@geekmidas/manifest';\nimport type { Service, ServiceRegisterOptions } from '@geekmidas/services';\nimport { Kysely, type KyselyConfig, PostgresDialect } from 'kysely';\nimport pg from 'pg';\nimport { Cache } from '../cache';\nimport type { Construct } from '../construct-interface';\n\n/** The schema a database uses when it does not say otherwise. */\nconst DEFAULT_SCHEMA = 'app';\n\n/**\n * Everything Kysely takes, plus what this construct declares.\n *\n * `dialect` is omitted because the construct owns it — it is built from the one\n * URL the adapter supplied, which is the whole point of the construct. The rest\n * of `KyselyConfig` (`plugins`, `log`) is the app's business and passes\n * straight through, so anything Kysely adds later arrives without being\n * tracked here.\n */\nexport interface KyselyDatabaseOptions extends Omit<KyselyConfig, 'dialect'> {\n\t/**\n\t * The schema, pinned on both roles' `search_path`.\n\t *\n\t * Defaults to `app` — the role the schema plays, rather than a restatement\n\t * of the database's own name, which reads correctly beside `auth` and\n\t * `pgboss` and keeps the application off `public`.\n\t */\n\tschema?: string;\n\t/**\n\t * Provision the owner/runtime role split. Defaults to on.\n\t *\n\t * Off falls back to the cluster's master credential in both URLs, giving up\n\t * the DDL/DML split and putting credentials that can drop a table into the\n\t * function's environment. A deliberate downgrade, not a default.\n\t */\n\troles?: boolean;\n\t/**\n\t * The Postgres major version to provision.\n\t *\n\t * Declared here so one statement reaches both targets. It was previously\n\t * set in two unrelated places — a container tag locally, nothing at all on\n\t * AWS (so Aurora chose) — which is how local came to run 18 while deployed\n\t * ran 17.7 with nothing recording the difference.\n\t *\n\t * Defaults to {@link DEFAULT_POSTGRES_VERSION}.\n\t */\n\tversion?: PostgresVersion;\n}\n\n/** What makes a construct derived rather than a database in its own right. */\ninterface DerivedFrom {\n\tkind: 'database-reader' | 'database-schema';\n\tof: string;\n\tschema?: string;\n}\n\n/**\n * @typeParam DB - the database's schema.\n * @typeParam TName - the canonical id. TypeScript has no partial\n * type-argument inference, so `new KyselyDatabase<OrdersDB>('orders')` leaves\n * this at its default and the service key widens to `string`. `db` still types\n * through `.database()`, which infers from the service.\n */\nexport class KyselyDatabase<DB = unknown, TName extends string = string>\n\timplements Construct<TName, Kysely<DB>>\n{\n\treadonly id: TName;\n\treadonly service: Service<Uncapitalize<TName>, Kysely<DB>>;\n\n\t/**\n\t * Declared once and read by both `declare()` and `connect()`, so the key the\n\t * build publishes and the key the client reads cannot drift.\n\t */\n\tprivate readonly config: { url: string; ownerUrl: string };\n\tprivate readonly schemaName: string;\n\tprivate readonly roles: boolean;\n\tprivate readonly version: PostgresVersion;\n\tprivate readonly derivedFrom?: DerivedFrom;\n\n\tconstructor(\n\t\tid: ConstructName<TName>,\n\t\tprivate readonly options: KyselyDatabaseOptions = {},\n\t\tderivedFrom?: DerivedFrom,\n\t) {\n\t\t// Canonicalises, so `orders` and `Orders` are one construct rather than\n\t\t// two that collide. Throws on anything that cannot become a valid id.\n\t\tconst canonical = canonicalId(id as string);\n\n\t\tthis.id = canonical as TName;\n\t\tthis.config = {\n\t\t\turl: provideKey(canonical, 'url'),\n\t\t\townerUrl: provideKey(canonical, 'ownerUrl'),\n\t\t};\n\t\tthis.schemaName = options.schema ?? DEFAULT_SCHEMA;\n\t\tthis.roles = options.roles ?? true;\n\t\tthis.version = options.version ?? DEFAULT_POSTGRES_VERSION;\n\t\tthis.derivedFrom = derivedFrom;\n\n\t\t// A field, not a getter: service discovery caches by object identity.\n\t\tthis.service = {\n\t\t\tserviceName: serviceKey(canonical) as Uncapitalize<TName>,\n\t\t\t// Forwards the whole options object — cherry-picking `envParser` strips\n\t\t\t// `context` and with it the request-scoped logger.\n\t\t\tregister: (registerOptions) => this.connect(registerOptions),\n\t\t};\n\t}\n\n\tdeclare(): Declaration[] {\n\t\tif (this.derivedFrom) {\n\t\t\tconst { kind, of, schema } = this.derivedFrom;\n\n\t\t\treturn [\n\t\t\t\tkind === 'database-schema'\n\t\t\t\t\t? {\n\t\t\t\t\t\t\tkind,\n\t\t\t\t\t\t\tid: this.id,\n\t\t\t\t\t\t\tof,\n\t\t\t\t\t\t\tschema: schema ?? this.schemaName,\n\t\t\t\t\t\t\t// The runtime key alone — see the note below on the parent.\n\t\t\t\t\t\t\tprovides: [this.config.url],\n\t\t\t\t\t\t}\n\t\t\t\t\t: {\n\t\t\t\t\t\t\tkind,\n\t\t\t\t\t\t\tid: this.id,\n\t\t\t\t\t\t\tof,\n\t\t\t\t\t\t\t// A reader has no owner URL of its own — nothing migrates\n\t\t\t\t\t\t\t// through a read-only endpoint — so this is the one key.\n\t\t\t\t\t\t\tprovides: [this.config.url],\n\t\t\t\t\t\t},\n\t\t\t];\n\t\t}\n\n\t\treturn [\n\t\t\t{\n\t\t\t\tkind: 'database',\n\t\t\t\tid: this.id,\n\t\t\t\tengine: 'postgres',\n\t\t\t\tschema: this.schemaName,\n\t\t\t\tversion: this.version,\n\t\t\t\t// One key, the runtime role's. `config` also holds the owner key and\n\t\t\t\t// it is deliberately absent here: a key in `provides` is a key an\n\t\t\t\t// edge can name, and nothing should be able to depend on DDL rights.\n\t\t\t\tprovides: [this.config.url],\n\t\t\t\t...(this.roles ? {} : { roles: false }),\n\t\t\t},\n\t\t];\n\t}\n\n\t/**\n\t * A read-only endpoint on this database.\n\t *\n\t * Read-only is enforced by the reader role's grants rather than by which\n\t * endpoint it resolves to, so falling back to the writer where no replica\n\t * exists is safe rather than a silently writable connection behind a name\n\t * that says reader. There is no `writer()`: the database *is* the writer, so\n\t * a replica can never be reached by accident.\n\t *\n\t * The return type is narrower than this class on purpose — see\n\t * {@link ReadOnlyDatabase}.\n\t */\n\treader(): ReadOnlyDatabase<DB, `${TName}Reader`> {\n\t\treturn new KyselyDatabase<DB, `${TName}Reader`>(\n\t\t\t`${this.id}Reader` as ConstructName<`${TName}Reader`>,\n\t\t\tthis.options,\n\t\t\t{ kind: 'database-reader', of: this.id },\n\t\t);\n\t}\n\n\t/**\n\t * A cache that lives in this database.\n\t *\n\t * The same strengthening `schema()` is over a second database: `new\n\t * Cache('Sessions')` says the app caches and leaves where to the deployment,\n\t * while this says it caches *here* — which is a fact about the application\n\t * and so belongs in its code.\n\t *\n\t * What it buys beyond being explicit: the table's schema and the role that\n\t * reaches it come from this database rather than from a second convention,\n\t * and the backend no longer has to guess which database \"the database\" meant\n\t * when an app declares two.\n\t *\n\t * A cache is not a `KyselyDatabase`, so this returns a `Cache` — the client\n\t * is a key/value store, not a query builder, and typing it as the parent\n\t * would be a convenience that lies.\n\t */\n\tcache<TCache extends string = `${TName}Cache`>(\n\t\tid: ConstructName<TCache> = `${this.id}Cache` as ConstructName<TCache>,\n\t\toptions: { table?: string } = {},\n\t): Cache<TCache> {\n\t\treturn new Cache<TCache>(id, {\n\t\t\tof: this.id,\n\t\t\t...(options.table ? { table: options.table } : {}),\n\t\t});\n\t}\n\n\t/**\n\t * A second schema in this database, with its own role(s) and its own URL —\n\t * so this database's role holds no grant on those tables at all.\n\t *\n\t * Typed separately because a tenant has its own tables: the point is that\n\t * `auth.selectFrom('sessions')` type-checks and\n\t * `orders.selectFrom('sessions')` does not.\n\t */\n\tschema<TenantDB, TTenant extends string>(\n\t\tid: ConstructName<TTenant>,\n\t\toptions: KyselyDatabaseOptions = {},\n\t): KyselyDatabase<TenantDB, TTenant> {\n\t\treturn new KyselyDatabase<TenantDB, TTenant>(id, options, {\n\t\t\tkind: 'database-schema',\n\t\t\tof: this.id,\n\t\t\tschema: options.schema ?? (id as string).toLowerCase(),\n\t\t});\n\t}\n\n\t/**\n\t * A connection as the *owner* role — the one that may create, alter and drop.\n\t *\n\t * A `Service` rather than part of the construct, and deliberately so: a\n\t * construct is what `.dependsOn()` accepts, and nothing should be able to\n\t * depend on this. A migrator asks for it by name; a handler cannot ask at\n\t * all, which is the security property the role split exists for.\n\t *\n\t * Falls back to the runtime URL where no owner URL was published — the\n\t * `roles: false` downgrade, where there is only one credential and it is the\n\t * cluster master's.\n\t */\n\tget owner(): Service<`${Uncapitalize<TName>}Owner`, Kysely<DB>> {\n\t\treturn {\n\t\t\tserviceName:\n\t\t\t\t`${serviceKey(this.id)}Owner` as `${Uncapitalize<TName>}Owner`,\n\t\t\tregister: (options) => this.connect(options, { owner: true }),\n\t\t};\n\t}\n\n\tprivate async connect(\n\t\toptions: ServiceRegisterOptions,\n\t\tas: { owner?: boolean } = {},\n\t): Promise<Kysely<DB>> {\n\t\tconst { url, ownerUrl } = options.envParser\n\t\t\t.create((get) => ({\n\t\t\t\turl: get(this.config.url).string(),\n\t\t\t\townerUrl: get(this.config.ownerUrl).string().optional(),\n\t\t\t}))\n\t\t\t.parse();\n\n\t\t// Split what the manifest declared from what Kysely takes, so neither\n\t\t// leaks into the other: `schema` and `roles` describe infrastructure and\n\t\t// mean nothing to a client.\n\t\tconst { schema: _schema, roles: _roles, ...kysely } = this.options;\n\n\t\treturn new Kysely<DB>({\n\t\t\t...kysely,\n\t\t\tdialect: new PostgresDialect({\n\t\t\t\tpool: pool(as.owner ? (ownerUrl ?? url) : url),\n\t\t\t}),\n\t\t});\n\t}\n}\n\n/**\n * A pool for one URL, with its schema actually on the search path.\n *\n * `?search_path=` is not a libpq parameter — a URL carrying it connects\n * happily and then resolves every unqualified name against `public`, which is\n * how a schema tenant silently writes its tables into the database it was\n * separated from. Postgres takes it as a startup option instead, so the URL\n * keeps the readable form the target derives and this turns it into the thing\n * the server understands.\n */\nfunction pool(url: string): pg.Pool {\n\tconst parsed = new URL(url);\n\tconst searchPath = parsed.searchParams.get('search_path');\n\n\tif (!searchPath) return new pg.Pool({ connectionString: url });\n\n\tparsed.searchParams.delete('search_path');\n\n\treturn new pg.Pool({\n\t\tconnectionString: parsed.toString(),\n\t\toptions: `-c search_path=${searchPath}`,\n\t});\n}\n\n/**\n * A database you may read through, and derive nothing from.\n *\n * A reader is terminal in the graph, and this is that fact in the type system.\n * `DERIVES_FROM` gives `cache` and `database-schema` no `database-reader`\n * parent, and there is no reader of a reader — so `orders.reader().cache(…)`\n * has always been illegal, but it type-checked and failed later at\n * `assertDerivations`. That is a long way round to learn that a read-only\n * endpoint cannot own a table something writes to.\n *\n * Omitting the three deriving methods rather than making them throw keeps the\n * failure where it costs least: the editor, on the line that wrote it.\n *\n * The result is deliberately not assignable back to `KyselyDatabase` — a\n * reader is not one, and anything that genuinely needs the writer should say\n * so.\n */\nexport type ReadOnlyDatabase<DB, TName extends string> = Omit<\n\tKyselyDatabase<DB, TName>,\n\t'reader' | 'cache' | 'schema'\n>;\n"],"mappings":";;;;;;;AA6BA,MAAM,iBAAiB;;;;;;;;AAuDvB,IAAa,iBAAb,MAAa,eAEb;CACC,AAAS;CACT,AAAS;;;;;CAMT,AAAiB;CACjB,AAAiB;CACjB,AAAiB;CACjB,AAAiB;CACjB,AAAiB;CAEjB,YACCA,IACiBC,UAAiC,CAAE,GACpDC,aACC;EAFgB;EAKjB,MAAM,YAAY,YAAY,GAAa;AAE3C,OAAK,KAAK;AACV,OAAK,SAAS;GACb,KAAK,WAAW,WAAW,MAAM;GACjC,UAAU,WAAW,WAAW,WAAW;EAC3C;AACD,OAAK,aAAa,QAAQ,UAAU;AACpC,OAAK,QAAQ,QAAQ,SAAS;AAC9B,OAAK,UAAU,QAAQ,WAAW;AAClC,OAAK,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