@geekmidas/constructs 10.0.0-alpha.18 → 10.0.0-alpha.181

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 (485) hide show
  1. package/README.md +246 -158
  2. package/dist/Construct-127M7yrl.d.cts +231 -0
  3. package/dist/Construct-127M7yrl.d.cts.map +1 -0
  4. package/dist/Construct-BMk_CRSD.d.mts +231 -0
  5. package/dist/Construct-BMk_CRSD.d.mts.map +1 -0
  6. package/dist/{Construct-BeYVu_QF.mjs → Construct-CGuc_Ijk.mjs} +8 -9
  7. package/dist/Construct-CGuc_Ijk.mjs.map +1 -0
  8. package/dist/{Construct-DqdlARxq.cjs → Construct-DorKS0Ua.cjs} +8 -9
  9. package/dist/Construct-DorKS0Ua.cjs.map +1 -0
  10. package/dist/{Cron-l4Wlz6G9.d.mts → Cron-BcA8F0S-.d.cts} +16 -9
  11. package/dist/Cron-BcA8F0S-.d.cts.map +1 -0
  12. package/dist/{Cron-zsoSAwZo.d.cts → Cron-z2CiuQT_.d.mts} +15 -8
  13. package/dist/Cron-z2CiuQT_.d.mts.map +1 -0
  14. package/dist/{CronBuilder-D_0HNBTr.mjs → CronBuilder-BJ5LoadF.mjs} +28 -11
  15. package/dist/CronBuilder-BJ5LoadF.mjs.map +1 -0
  16. package/dist/CronBuilder-BZvo34X2.d.cts +47 -0
  17. package/dist/CronBuilder-BZvo34X2.d.cts.map +1 -0
  18. package/dist/{CronBuilder-BdnI6lxF.cjs → CronBuilder-B_NSP-Y5.cjs} +27 -10
  19. package/dist/CronBuilder-B_NSP-Y5.cjs.map +1 -0
  20. package/dist/CronBuilder-BbgKo8OI.d.mts +47 -0
  21. package/dist/CronBuilder-BbgKo8OI.d.mts.map +1 -0
  22. package/dist/Endpoint-52z1P0Ue.cjs +581 -0
  23. package/dist/Endpoint-52z1P0Ue.cjs.map +1 -0
  24. package/dist/{Endpoint-oS-Fe3d_.d.mts → Endpoint-CIDUreMW.d.mts} +104 -23
  25. package/dist/Endpoint-CIDUreMW.d.mts.map +1 -0
  26. package/dist/{Endpoint-DBflWAe4.d.cts → Endpoint-COisi9jw.d.cts} +101 -20
  27. package/dist/Endpoint-COisi9jw.d.cts.map +1 -0
  28. package/dist/Endpoint-sUOU7uLx.mjs +552 -0
  29. package/dist/Endpoint-sUOU7uLx.mjs.map +1 -0
  30. package/dist/{EndpointFactory-Bm3aKRdV.mjs → EndpointFactory-Bzi9Sl7r.mjs} +269 -53
  31. package/dist/EndpointFactory-Bzi9Sl7r.mjs.map +1 -0
  32. package/dist/{index-Cc4kKPag.d.mts → EndpointFactory-CIM80WIK.d.mts} +189 -106
  33. package/dist/EndpointFactory-CIM80WIK.d.mts.map +1 -0
  34. package/dist/{index-C1ZwNOOk.d.cts → EndpointFactory-CfBg6jJE.d.cts} +187 -104
  35. package/dist/EndpointFactory-CfBg6jJE.d.cts.map +1 -0
  36. package/dist/{EndpointFactory-CLvWuHyt.cjs → EndpointFactory-Cf_Cs1ym.cjs} +309 -51
  37. package/dist/EndpointFactory-Cf_Cs1ym.cjs.map +1 -0
  38. package/dist/Function-BIEsY0Hm.d.cts +76 -0
  39. package/dist/Function-BIEsY0Hm.d.cts.map +1 -0
  40. package/dist/Function-BKReud5p.d.mts +76 -0
  41. package/dist/Function-BKReud5p.d.mts.map +1 -0
  42. package/dist/{HonoEndpointAdaptor-92zavCsV.cjs → HonoEndpointAdaptor-BTbqfSaa.cjs} +115 -41
  43. package/dist/HonoEndpointAdaptor-BTbqfSaa.cjs.map +1 -0
  44. package/dist/{HonoEndpointAdaptor-yYaU7jVJ.mjs → HonoEndpointAdaptor-CBVey2cY.mjs} +112 -38
  45. package/dist/HonoEndpointAdaptor-CBVey2cY.mjs.map +1 -0
  46. package/dist/ObjectSubscriberBuilder-Ci_Cc-WZ.d.mts +129 -0
  47. package/dist/ObjectSubscriberBuilder-Ci_Cc-WZ.d.mts.map +1 -0
  48. package/dist/ObjectSubscriberBuilder-DWtLxfAJ.d.cts +129 -0
  49. package/dist/ObjectSubscriberBuilder-DWtLxfAJ.d.cts.map +1 -0
  50. package/dist/ProcessorBuilder-CdLwJK4k.d.mts +216 -0
  51. package/dist/ProcessorBuilder-CdLwJK4k.d.mts.map +1 -0
  52. package/dist/ProcessorBuilder-ClD7tmEe.d.cts +216 -0
  53. package/dist/ProcessorBuilder-ClD7tmEe.d.cts.map +1 -0
  54. package/dist/Queue-9Hh20ZCk.mjs +104 -0
  55. package/dist/Queue-9Hh20ZCk.mjs.map +1 -0
  56. package/dist/{Queue-D9X6OoON.d.mts → Queue-B8HGg439.d.mts} +42 -41
  57. package/dist/Queue-B8HGg439.d.mts.map +1 -0
  58. package/dist/{Queue-DYPB2KWL.d.cts → Queue-C4rijiM7.d.cts} +43 -42
  59. package/dist/Queue-C4rijiM7.d.cts.map +1 -0
  60. package/dist/Queue-W1wueijP.cjs +109 -0
  61. package/dist/Queue-W1wueijP.cjs.map +1 -0
  62. package/dist/QueueBuilder-BDcv9B71.cjs +135 -0
  63. package/dist/QueueBuilder-BDcv9B71.cjs.map +1 -0
  64. package/dist/QueueBuilder-CjULiiDN.d.mts +75 -0
  65. package/dist/QueueBuilder-CjULiiDN.d.mts.map +1 -0
  66. package/dist/QueueBuilder-CrZL8HHs.mjs +118 -0
  67. package/dist/QueueBuilder-CrZL8HHs.mjs.map +1 -0
  68. package/dist/QueueBuilder-Dacm9qAv.d.cts +75 -0
  69. package/dist/QueueBuilder-Dacm9qAv.d.cts.map +1 -0
  70. package/dist/Subscriber-5rCX1Nph.d.cts +83 -0
  71. package/dist/Subscriber-5rCX1Nph.d.cts.map +1 -0
  72. package/dist/Subscriber-CtQXhcL7.d.mts +83 -0
  73. package/dist/Subscriber-CtQXhcL7.d.mts.map +1 -0
  74. package/dist/SubscriberBuilder-CpFhShTJ.mjs +238 -0
  75. package/dist/SubscriberBuilder-CpFhShTJ.mjs.map +1 -0
  76. package/dist/SubscriberBuilder-DJEvNRdD.cjs +261 -0
  77. package/dist/SubscriberBuilder-DJEvNRdD.cjs.map +1 -0
  78. package/dist/Topic-BGoOeCT6.mjs +99 -0
  79. package/dist/Topic-BGoOeCT6.mjs.map +1 -0
  80. package/dist/Topic-DLCZBNwK.cjs +104 -0
  81. package/dist/Topic-DLCZBNwK.cjs.map +1 -0
  82. package/dist/adaptors/aws.cjs +147 -168
  83. package/dist/adaptors/aws.cjs.map +1 -1
  84. package/dist/adaptors/aws.d.cts +57 -48
  85. package/dist/adaptors/aws.d.cts.map +1 -1
  86. package/dist/adaptors/aws.d.mts +58 -49
  87. package/dist/adaptors/aws.d.mts.map +1 -1
  88. package/dist/adaptors/aws.mjs +142 -164
  89. package/dist/adaptors/aws.mjs.map +1 -1
  90. package/dist/adaptors/awsWebsocket.cjs +354 -0
  91. package/dist/adaptors/awsWebsocket.cjs.map +1 -0
  92. package/dist/adaptors/awsWebsocket.d.cts +156 -0
  93. package/dist/adaptors/awsWebsocket.d.cts.map +1 -0
  94. package/dist/adaptors/awsWebsocket.d.mts +156 -0
  95. package/dist/adaptors/awsWebsocket.d.mts.map +1 -0
  96. package/dist/adaptors/awsWebsocket.mjs +347 -0
  97. package/dist/adaptors/awsWebsocket.mjs.map +1 -0
  98. package/dist/adaptors/hono.cjs +1 -1
  99. package/dist/adaptors/hono.d.cts +8 -7
  100. package/dist/adaptors/hono.d.cts.map +1 -1
  101. package/dist/adaptors/hono.d.mts +10 -9
  102. package/dist/adaptors/hono.d.mts.map +1 -1
  103. package/dist/adaptors/hono.mjs +1 -1
  104. package/dist/adaptors/testing.cjs +1174 -41
  105. package/dist/adaptors/testing.cjs.map +1 -1
  106. package/dist/adaptors/testing.d.cts +517 -40
  107. package/dist/adaptors/testing.d.cts.map +1 -1
  108. package/dist/adaptors/testing.d.mts +517 -40
  109. package/dist/adaptors/testing.d.mts.map +1 -1
  110. package/dist/adaptors/testing.mjs +1140 -36
  111. package/dist/adaptors/testing.mjs.map +1 -1
  112. package/dist/auth-CutSfNlr.d.mts +274 -0
  113. package/dist/auth-CutSfNlr.d.mts.map +1 -0
  114. package/dist/auth-b9ADezz9.d.cts +274 -0
  115. package/dist/auth-b9ADezz9.d.cts.map +1 -0
  116. package/dist/auth.cjs +311 -26
  117. package/dist/auth.cjs.map +1 -1
  118. package/dist/auth.d.cts +2 -104
  119. package/dist/auth.d.mts +2 -104
  120. package/dist/auth.mjs +307 -28
  121. package/dist/auth.mjs.map +1 -1
  122. package/dist/cache-9wLNSy3O.d.cts +44 -0
  123. package/dist/cache-9wLNSy3O.d.cts.map +1 -0
  124. package/dist/cache-BFPs_CGs.d.mts +44 -0
  125. package/dist/cache-BFPs_CGs.d.mts.map +1 -0
  126. package/dist/cache.cjs +4 -20
  127. package/dist/cache.cjs.map +1 -1
  128. package/dist/cache.d.cts +2 -43
  129. package/dist/cache.d.mts +2 -43
  130. package/dist/cache.mjs +4 -20
  131. package/dist/cache.mjs.map +1 -1
  132. package/dist/cipher-C1lEFX63.mjs +225 -0
  133. package/dist/cipher-C1lEFX63.mjs.map +1 -0
  134. package/dist/cipher-CVxfwLjk.cjs +332 -0
  135. package/dist/cipher-CVxfwLjk.cjs.map +1 -0
  136. package/dist/cipher-DSDxPRIp.d.cts +106 -0
  137. package/dist/cipher-DSDxPRIp.d.cts.map +1 -0
  138. package/dist/cipher-DSDxPRIp.d.mts +106 -0
  139. package/dist/cipher-DSDxPRIp.d.mts.map +1 -0
  140. package/dist/{construct-interface-DPlxfpoS.d.mts → construct-interface-CVoejIpo.d.cts} +79 -8
  141. package/dist/construct-interface-CVoejIpo.d.cts.map +1 -0
  142. package/dist/{construct-interface-DgXTJcOD.d.cts → construct-interface-Nw5Dt9AC.d.mts} +79 -8
  143. package/dist/construct-interface-Nw5Dt9AC.d.mts.map +1 -0
  144. package/dist/construct-interface.cjs +62 -4
  145. package/dist/construct-interface.cjs.map +1 -1
  146. package/dist/construct-interface.d.cts +2 -2
  147. package/dist/construct-interface.d.mts +2 -2
  148. package/dist/construct-interface.mjs +59 -5
  149. package/dist/construct-interface.mjs.map +1 -1
  150. package/dist/credential-B80mOxwT.mjs +222 -0
  151. package/dist/credential-B80mOxwT.mjs.map +1 -0
  152. package/dist/credential-RlgbzZAc.cjs +257 -0
  153. package/dist/credential-RlgbzZAc.cjs.map +1 -0
  154. package/dist/credential.cjs +7 -129
  155. package/dist/credential.d.cts +2 -58
  156. package/dist/credential.d.mts +2 -58
  157. package/dist/credential.mjs +2 -128
  158. package/dist/crons/index.cjs +127 -1
  159. package/dist/crons/index.cjs.map +1 -1
  160. package/dist/crons/index.d.cts +43 -3
  161. package/dist/crons/index.d.cts.map +1 -1
  162. package/dist/crons/index.d.mts +43 -3
  163. package/dist/crons/index.d.mts.map +1 -1
  164. package/dist/crons/index.mjs +126 -2
  165. package/dist/crons/index.mjs.map +1 -1
  166. package/dist/database/kysely.cjs +3 -194
  167. package/dist/database/kysely.d.cts +2 -149
  168. package/dist/database/kysely.d.mts +2 -149
  169. package/dist/database/kysely.mjs +2 -192
  170. package/dist/email.cjs +24 -17
  171. package/dist/email.cjs.map +1 -1
  172. package/dist/email.d.cts +15 -5
  173. package/dist/email.d.cts.map +1 -1
  174. package/dist/email.d.mts +16 -6
  175. package/dist/email.d.mts.map +1 -1
  176. package/dist/email.mjs +23 -17
  177. package/dist/email.mjs.map +1 -1
  178. package/dist/encryption/kms.cjs +95 -0
  179. package/dist/encryption/kms.cjs.map +1 -0
  180. package/dist/encryption/kms.d.cts +7 -0
  181. package/dist/encryption/kms.d.cts.map +1 -0
  182. package/dist/encryption/kms.d.mts +7 -0
  183. package/dist/encryption/kms.d.mts.map +1 -0
  184. package/dist/encryption/kms.mjs +93 -0
  185. package/dist/encryption/kms.mjs.map +1 -0
  186. package/dist/encryption.cjs +116 -0
  187. package/dist/encryption.cjs.map +1 -0
  188. package/dist/encryption.d.cts +37 -0
  189. package/dist/encryption.d.cts.map +1 -0
  190. package/dist/encryption.d.mts +37 -0
  191. package/dist/encryption.d.mts.map +1 -0
  192. package/dist/encryption.mjs +101 -0
  193. package/dist/encryption.mjs.map +1 -0
  194. package/dist/endpoints/index.cjs +32 -10
  195. package/dist/endpoints/index.d.cts +106 -3
  196. package/dist/endpoints/index.d.cts.map +1 -0
  197. package/dist/endpoints/index.d.mts +106 -3
  198. package/dist/endpoints/index.d.mts.map +1 -0
  199. package/dist/endpoints/index.mjs +6 -4
  200. package/dist/expire-C586zznE.d.cts +38 -0
  201. package/dist/expire-C586zznE.d.cts.map +1 -0
  202. package/dist/expire-C586zznE.d.mts +38 -0
  203. package/dist/expire-C586zznE.d.mts.map +1 -0
  204. package/dist/external-api.cjs +106 -0
  205. package/dist/external-api.cjs.map +1 -0
  206. package/dist/external-api.d.cts +2 -0
  207. package/dist/external-api.d.mts +2 -0
  208. package/dist/external-api.mjs +103 -0
  209. package/dist/external-api.mjs.map +1 -0
  210. package/dist/fake-JI5uN1SF.d.cts +201 -0
  211. package/dist/fake-JI5uN1SF.d.cts.map +1 -0
  212. package/dist/fake-zpuXpBmY.d.mts +201 -0
  213. package/dist/fake-zpuXpBmY.d.mts.map +1 -0
  214. package/dist/file-server.cjs +170 -49
  215. package/dist/file-server.cjs.map +1 -1
  216. package/dist/file-server.d.cts +148 -16
  217. package/dist/file-server.d.cts.map +1 -1
  218. package/dist/file-server.d.mts +148 -16
  219. package/dist/file-server.d.mts.map +1 -1
  220. package/dist/file-server.mjs +168 -51
  221. package/dist/file-server.mjs.map +1 -1
  222. package/dist/functions/index.cjs +1 -1
  223. package/dist/functions/index.d.cts +2 -1
  224. package/dist/functions/index.d.mts +2 -1
  225. package/dist/functions/index.mjs +1 -1
  226. package/dist/{functions-C53GW2eQ.mjs → functions-BvIDQKAA.mjs} +117 -22
  227. package/dist/functions-BvIDQKAA.mjs.map +1 -0
  228. package/dist/{functions-B6qCvfmy.cjs → functions-DLF6-IK8.cjs} +122 -18
  229. package/dist/functions-DLF6-IK8.cjs.map +1 -0
  230. package/dist/inbox-CXLU7h_8.d.cts +195 -0
  231. package/dist/inbox-CXLU7h_8.d.cts.map +1 -0
  232. package/dist/inbox-DYFsLd9A.d.mts +195 -0
  233. package/dist/inbox-DYFsLd9A.d.mts.map +1 -0
  234. package/dist/inbox.cjs +291 -0
  235. package/dist/inbox.cjs.map +1 -0
  236. package/dist/inbox.d.cts +2 -0
  237. package/dist/inbox.d.mts +2 -0
  238. package/dist/inbox.mjs +283 -0
  239. package/dist/inbox.mjs.map +1 -0
  240. package/dist/index-BpE9_6l5.d.mts +115 -0
  241. package/dist/index-BpE9_6l5.d.mts.map +1 -0
  242. package/dist/{index-CeEtxDmK.d.cts → index-DdRjYhiJ.d.cts} +42 -2
  243. package/dist/{index-CeEtxDmK.d.cts.map → index-DdRjYhiJ.d.cts.map} +1 -1
  244. package/dist/{index-CeEtxDmK.d.mts → index-DdRjYhiJ.d.mts} +42 -2
  245. package/dist/{index-CeEtxDmK.d.mts.map → index-DdRjYhiJ.d.mts.map} +1 -1
  246. package/dist/index-zRChehJ9.d.cts +115 -0
  247. package/dist/index-zRChehJ9.d.cts.map +1 -0
  248. package/dist/index.cjs +4 -1
  249. package/dist/index.d.cts +26 -3
  250. package/dist/index.d.cts.map +1 -0
  251. package/dist/index.d.mts +26 -3
  252. package/dist/index.d.mts.map +1 -0
  253. package/dist/index.mjs +3 -2
  254. package/dist/kysely-5PAqFBzo.d.mts +216 -0
  255. package/dist/kysely-5PAqFBzo.d.mts.map +1 -0
  256. package/dist/kysely-Bc9xzaik.mjs +371 -0
  257. package/dist/kysely-Bc9xzaik.mjs.map +1 -0
  258. package/dist/kysely-D7f6J2lh.cjs +384 -0
  259. package/dist/kysely-D7f6J2lh.cjs.map +1 -0
  260. package/dist/kysely-lxNUBSTP.d.cts +216 -0
  261. package/dist/kysely-lxNUBSTP.d.cts.map +1 -0
  262. package/dist/{telemetry-DGcFlVpB.d.cts → lambdaTelemetry-8vnmVZQ5.d.cts} +2 -2
  263. package/dist/lambdaTelemetry-8vnmVZQ5.d.cts.map +1 -0
  264. package/dist/{telemetry-DGcFlVpB.d.mts → lambdaTelemetry-8vnmVZQ5.d.mts} +2 -2
  265. package/dist/lambdaTelemetry-8vnmVZQ5.d.mts.map +1 -0
  266. package/dist/mobile-app.cjs +79 -0
  267. package/dist/mobile-app.cjs.map +1 -0
  268. package/dist/mobile-app.d.cts +78 -0
  269. package/dist/mobile-app.d.cts.map +1 -0
  270. package/dist/mobile-app.d.mts +78 -0
  271. package/dist/mobile-app.d.mts.map +1 -0
  272. package/dist/mobile-app.mjs +78 -0
  273. package/dist/mobile-app.mjs.map +1 -0
  274. package/dist/object-storage.cjs +50 -7
  275. package/dist/object-storage.cjs.map +1 -1
  276. package/dist/object-storage.d.cts +37 -3
  277. package/dist/object-storage.d.cts.map +1 -1
  278. package/dist/object-storage.d.mts +37 -3
  279. package/dist/object-storage.d.mts.map +1 -1
  280. package/dist/object-storage.mjs +49 -9
  281. package/dist/object-storage.mjs.map +1 -1
  282. package/dist/optionalPeers-D7Wt6dnF.mjs +140 -0
  283. package/dist/optionalPeers-D7Wt6dnF.mjs.map +1 -0
  284. package/dist/optionalPeers-DuNQXXe1.cjs +223 -0
  285. package/dist/optionalPeers-DuNQXXe1.cjs.map +1 -0
  286. package/dist/origins-BjxYht13.cjs +96 -0
  287. package/dist/origins-BjxYht13.cjs.map +1 -0
  288. package/dist/origins-Boc9qbo-.mjs +73 -0
  289. package/dist/origins-Boc9qbo-.mjs.map +1 -0
  290. package/dist/pattern-C1CEcglD.mjs +241 -0
  291. package/dist/pattern-C1CEcglD.mjs.map +1 -0
  292. package/dist/pattern-QFaUIr77.cjs +288 -0
  293. package/dist/pattern-QFaUIr77.cjs.map +1 -0
  294. package/dist/privateAddress-Bg5fUsbp.mjs +21 -0
  295. package/dist/privateAddress-Bg5fUsbp.mjs.map +1 -0
  296. package/dist/privateAddress-CqGyuFHn.cjs +26 -0
  297. package/dist/privateAddress-CqGyuFHn.cjs.map +1 -0
  298. package/dist/processors/index.cjs +214 -0
  299. package/dist/processors/index.cjs.map +1 -0
  300. package/dist/processors/index.d.cts +78 -0
  301. package/dist/processors/index.d.cts.map +1 -0
  302. package/dist/processors/index.d.mts +78 -0
  303. package/dist/processors/index.d.mts.map +1 -0
  304. package/dist/processors/index.mjs +193 -0
  305. package/dist/processors/index.mjs.map +1 -0
  306. package/dist/queue/index.cjs +5 -192
  307. package/dist/queue/index.d.cts +3 -53
  308. package/dist/queue/index.d.mts +3 -53
  309. package/dist/queue/index.mjs +3 -190
  310. package/dist/random-password.cjs +86 -0
  311. package/dist/random-password.cjs.map +1 -0
  312. package/dist/random-password.d.cts +30 -0
  313. package/dist/random-password.d.cts.map +1 -0
  314. package/dist/random-password.d.mts +30 -0
  315. package/dist/random-password.d.mts.map +1 -0
  316. package/dist/random-password.mjs +84 -0
  317. package/dist/random-password.mjs.map +1 -0
  318. package/dist/readOnlyStorage-C7bCe-z5.cjs +101 -0
  319. package/dist/readOnlyStorage-C7bCe-z5.cjs.map +1 -0
  320. package/dist/readOnlyStorage-DMCeLuS2.mjs +78 -0
  321. package/dist/readOnlyStorage-DMCeLuS2.mjs.map +1 -0
  322. package/dist/readRequestBody-BmKnPl0a.mjs +293 -0
  323. package/dist/readRequestBody-BmKnPl0a.mjs.map +1 -0
  324. package/dist/{lazyAccessors-Dx9NLwJZ.cjs → readRequestBody-CN9GVdeE.cjs} +141 -47
  325. package/dist/readRequestBody-CN9GVdeE.cjs.map +1 -0
  326. package/dist/{processAudits-D_2W5x8k.cjs → requestLogger-CnoYd-Ah.cjs} +63 -3
  327. package/dist/requestLogger-CnoYd-Ah.cjs.map +1 -0
  328. package/dist/{processAudits-BpRlPQMW.mjs → requestLogger-D2JS7pPM.mjs} +51 -3
  329. package/dist/requestLogger-D2JS7pPM.mjs.map +1 -0
  330. package/dist/rest-api.cjs +100 -73
  331. package/dist/rest-api.cjs.map +1 -1
  332. package/dist/rest-api.d.cts +83 -59
  333. package/dist/rest-api.d.cts.map +1 -1
  334. package/dist/rest-api.d.mts +83 -59
  335. package/dist/rest-api.d.mts.map +1 -1
  336. package/dist/rest-api.mjs +97 -76
  337. package/dist/rest-api.mjs.map +1 -1
  338. package/dist/runSubscriber-HEqXkin1.mjs +117 -0
  339. package/dist/runSubscriber-HEqXkin1.mjs.map +1 -0
  340. package/dist/runSubscriber-sVJfLA0-.cjs +134 -0
  341. package/dist/runSubscriber-sVJfLA0-.cjs.map +1 -0
  342. package/dist/shutdown-BMJmAhSt.cjs +38 -0
  343. package/dist/shutdown-BMJmAhSt.cjs.map +1 -0
  344. package/dist/shutdown-C7xa8x9S.mjs +27 -0
  345. package/dist/shutdown-C7xa8x9S.mjs.map +1 -0
  346. package/dist/site.cjs +140 -10
  347. package/dist/site.cjs.map +1 -1
  348. package/dist/site.d.cts +156 -3
  349. package/dist/site.d.cts.map +1 -1
  350. package/dist/site.d.mts +156 -3
  351. package/dist/site.d.mts.map +1 -1
  352. package/dist/site.mjs +120 -13
  353. package/dist/site.mjs.map +1 -1
  354. package/dist/stages-DaTaoQei.d.cts +73 -0
  355. package/dist/stages-DaTaoQei.d.cts.map +1 -0
  356. package/dist/stages-DaTaoQei.d.mts +73 -0
  357. package/dist/stages-DaTaoQei.d.mts.map +1 -0
  358. package/dist/subscribers/index.cjs +134 -1
  359. package/dist/subscribers/index.cjs.map +1 -0
  360. package/dist/subscribers/index.d.cts +74 -3
  361. package/dist/subscribers/index.d.cts.map +1 -0
  362. package/dist/subscribers/index.d.mts +74 -3
  363. package/dist/subscribers/index.d.mts.map +1 -0
  364. package/dist/subscribers/index.mjs +132 -2
  365. package/dist/subscribers/index.mjs.map +1 -0
  366. package/dist/telemetry-BbLyS7ln.d.cts +57 -0
  367. package/dist/telemetry-BbLyS7ln.d.cts.map +1 -0
  368. package/dist/telemetry-DWX-qKUh.d.mts +57 -0
  369. package/dist/telemetry-DWX-qKUh.d.mts.map +1 -0
  370. package/dist/telemetry.cjs +64 -0
  371. package/dist/telemetry.cjs.map +1 -0
  372. package/dist/telemetry.d.cts +2 -0
  373. package/dist/telemetry.d.mts +2 -0
  374. package/dist/telemetry.mjs +63 -0
  375. package/dist/telemetry.mjs.map +1 -0
  376. package/dist/topic/index.cjs +2 -134
  377. package/dist/topic/index.d.cts +2 -3
  378. package/dist/topic/index.d.mts +2 -3
  379. package/dist/topic/index.mjs +2 -132
  380. package/dist/tracing-Bbj1uoFJ.mjs +127 -0
  381. package/dist/tracing-Bbj1uoFJ.mjs.map +1 -0
  382. package/dist/tracing-C0ooU0V2.cjs +150 -0
  383. package/dist/tracing-C0ooU0V2.cjs.map +1 -0
  384. package/dist/websocket-api-9ndLBolx.d.cts +1207 -0
  385. package/dist/websocket-api-9ndLBolx.d.cts.map +1 -0
  386. package/dist/websocket-api-BPPXF79i.d.mts +1207 -0
  387. package/dist/websocket-api-BPPXF79i.d.mts.map +1 -0
  388. package/dist/websocket-api-C6LGg9-D.mjs +1716 -0
  389. package/dist/websocket-api-C6LGg9-D.mjs.map +1 -0
  390. package/dist/websocket-api-CoKPJJRl.cjs +1895 -0
  391. package/dist/websocket-api-CoKPJJRl.cjs.map +1 -0
  392. package/dist/websocket-api.cjs +42 -0
  393. package/dist/websocket-api.d.cts +2 -0
  394. package/dist/websocket-api.d.mts +2 -0
  395. package/dist/websocket-api.mjs +3 -0
  396. package/dist/worker.cjs +174 -32
  397. package/dist/worker.cjs.map +1 -1
  398. package/dist/worker.d.cts +147 -47
  399. package/dist/worker.d.cts.map +1 -1
  400. package/dist/worker.d.mts +147 -47
  401. package/dist/worker.d.mts.map +1 -1
  402. package/dist/worker.mjs +175 -33
  403. package/dist/worker.mjs.map +1 -1
  404. package/package.json +180 -43
  405. package/dist/Construct-BeYVu_QF.mjs.map +0 -1
  406. package/dist/Construct-DfbwIntp.d.cts +0 -115
  407. package/dist/Construct-DfbwIntp.d.cts.map +0 -1
  408. package/dist/Construct-DqdlARxq.cjs.map +0 -1
  409. package/dist/Construct-l5aOn_jv.d.mts +0 -115
  410. package/dist/Construct-l5aOn_jv.d.mts.map +0 -1
  411. package/dist/Cron-l4Wlz6G9.d.mts.map +0 -1
  412. package/dist/Cron-zsoSAwZo.d.cts.map +0 -1
  413. package/dist/CronBuilder-BdnI6lxF.cjs.map +0 -1
  414. package/dist/CronBuilder-CyT71Nzg.d.cts +0 -41
  415. package/dist/CronBuilder-CyT71Nzg.d.cts.map +0 -1
  416. package/dist/CronBuilder-D_0HNBTr.mjs.map +0 -1
  417. package/dist/CronBuilder-UoNgFe8S.d.mts +0 -41
  418. package/dist/CronBuilder-UoNgFe8S.d.mts.map +0 -1
  419. package/dist/Endpoint-BpZHtJ2W.cjs +0 -1689
  420. package/dist/Endpoint-BpZHtJ2W.cjs.map +0 -1
  421. package/dist/Endpoint-DBflWAe4.d.cts.map +0 -1
  422. package/dist/Endpoint-ONsly_dq.mjs +0 -1671
  423. package/dist/Endpoint-ONsly_dq.mjs.map +0 -1
  424. package/dist/Endpoint-oS-Fe3d_.d.mts.map +0 -1
  425. package/dist/EndpointFactory-Bm3aKRdV.mjs.map +0 -1
  426. package/dist/EndpointFactory-CLvWuHyt.cjs.map +0 -1
  427. package/dist/HonoEndpointAdaptor-92zavCsV.cjs.map +0 -1
  428. package/dist/HonoEndpointAdaptor-yYaU7jVJ.mjs.map +0 -1
  429. package/dist/Queue-D9X6OoON.d.mts.map +0 -1
  430. package/dist/Queue-DYPB2KWL.d.cts.map +0 -1
  431. package/dist/Subscriber-C4heaAyO.d.mts +0 -51
  432. package/dist/Subscriber-C4heaAyO.d.mts.map +0 -1
  433. package/dist/Subscriber-CotDUELC.d.cts +0 -51
  434. package/dist/Subscriber-CotDUELC.d.cts.map +0 -1
  435. package/dist/SubscriberBuilder-BEv0eoHy.d.cts +0 -59
  436. package/dist/SubscriberBuilder-BEv0eoHy.d.cts.map +0 -1
  437. package/dist/SubscriberBuilder-C0ZEtGDI.cjs +0 -125
  438. package/dist/SubscriberBuilder-C0ZEtGDI.cjs.map +0 -1
  439. package/dist/SubscriberBuilder-h7B_cHMr.mjs +0 -114
  440. package/dist/SubscriberBuilder-h7B_cHMr.mjs.map +0 -1
  441. package/dist/SubscriberBuilder-tyH5yTk5.d.mts +0 -59
  442. package/dist/SubscriberBuilder-tyH5yTk5.d.mts.map +0 -1
  443. package/dist/Topic-DEVGo0Dm.d.cts +0 -89
  444. package/dist/Topic-DEVGo0Dm.d.cts.map +0 -1
  445. package/dist/Topic-zk_6Gthr.d.mts +0 -89
  446. package/dist/Topic-zk_6Gthr.d.mts.map +0 -1
  447. package/dist/auth.d.cts.map +0 -1
  448. package/dist/auth.d.mts.map +0 -1
  449. package/dist/cache.d.cts.map +0 -1
  450. package/dist/cache.d.mts.map +0 -1
  451. package/dist/construct-interface-DPlxfpoS.d.mts.map +0 -1
  452. package/dist/construct-interface-DgXTJcOD.d.cts.map +0 -1
  453. package/dist/credential.cjs.map +0 -1
  454. package/dist/credential.d.cts.map +0 -1
  455. package/dist/credential.d.mts.map +0 -1
  456. package/dist/credential.mjs.map +0 -1
  457. package/dist/database/kysely.cjs.map +0 -1
  458. package/dist/database/kysely.d.cts.map +0 -1
  459. package/dist/database/kysely.d.mts.map +0 -1
  460. package/dist/database/kysely.mjs.map +0 -1
  461. package/dist/functions-B6qCvfmy.cjs.map +0 -1
  462. package/dist/functions-C53GW2eQ.mjs.map +0 -1
  463. package/dist/index-B2urf3YI.d.cts +0 -26
  464. package/dist/index-B2urf3YI.d.cts.map +0 -1
  465. package/dist/index-C1ZwNOOk.d.cts.map +0 -1
  466. package/dist/index-Cc4kKPag.d.mts.map +0 -1
  467. package/dist/index-DMCDvnsM.d.mts +0 -26
  468. package/dist/index-DMCDvnsM.d.mts.map +0 -1
  469. package/dist/index-D_frT6MP.d.cts +0 -165
  470. package/dist/index-D_frT6MP.d.cts.map +0 -1
  471. package/dist/index-DcyIYbDS.d.mts +0 -165
  472. package/dist/index-DcyIYbDS.d.mts.map +0 -1
  473. package/dist/lazyAccessors-BHtcqgz2.mjs +0 -211
  474. package/dist/lazyAccessors-BHtcqgz2.mjs.map +0 -1
  475. package/dist/lazyAccessors-Dx9NLwJZ.cjs.map +0 -1
  476. package/dist/processAudits-BpRlPQMW.mjs.map +0 -1
  477. package/dist/processAudits-D_2W5x8k.cjs.map +0 -1
  478. package/dist/queue/index.cjs.map +0 -1
  479. package/dist/queue/index.d.cts.map +0 -1
  480. package/dist/queue/index.d.mts.map +0 -1
  481. package/dist/queue/index.mjs.map +0 -1
  482. package/dist/telemetry-DGcFlVpB.d.cts.map +0 -1
  483. package/dist/telemetry-DGcFlVpB.d.mts.map +0 -1
  484. package/dist/topic/index.cjs.map +0 -1
  485. package/dist/topic/index.mjs.map +0 -1
@@ -1,5 +1,7 @@
1
- import { a as createAuthorizer, i as BUILT_IN_SECURITY_SCHEMES, n as EndpointBuilder, o as getSecurityScheme, r as RLS_BYPASS, s as isBuiltInSecurityScheme, t as EndpointFactory } from "../EndpointFactory-Bm3aKRdV.mjs";
2
- import { n as ResponseBuilder, t as Endpoint } from "../Endpoint-ONsly_dq.mjs";
1
+ import { a as UploadAcceptInvalid, c as UploadExpiryInvalid, d as BUILT_IN_SECURITY_SCHEMES, f as createAuthorizer, i as UPLOAD_POST_SCHEMA, l as UploadMaxSizeInvalid, m as isBuiltInSecurityScheme, n as EndpointBuilder, o as UploadContentTypeRefused, p as getSecurityScheme, r as UploadEndpointBuilder, s as UploadContentTypeUnresolved, t as EndpointFactory, u as RLS_BYPASS } from "../EndpointFactory-Bzi9Sl7r.mjs";
2
+ import { i as publishConstructEvents } from "../functions-BvIDQKAA.mjs";
3
+ import { a as NoAuthenticator, i as SuccessStatus, n as RedirectStatus, r as ResponseBuilder, t as Endpoint } from "../Endpoint-sUOU7uLx.mjs";
3
4
  import { n as envParserFor, t as defaultEnvParser } from "../surfaceEnv-wMT5QzgZ.mjs";
4
- import { a as createHonoHeaders, i as createHonoCookies, l as publishConstructEvents, n as createApiGatewayHeaders, o as createNoopCookies, s as createNoopHeaders, t as createApiGatewayCookies } from "../lazyAccessors-BHtcqgz2.mjs";
5
- export { BUILT_IN_SECURITY_SCHEMES, Endpoint, EndpointBuilder, EndpointFactory, RLS_BYPASS, ResponseBuilder, createApiGatewayCookies, createApiGatewayHeaders, createAuthorizer, createHonoCookies, createHonoHeaders, createNoopCookies, createNoopHeaders, defaultEnvParser, envParserFor, getSecurityScheme, isBuiltInSecurityScheme, publishConstructEvents };
5
+ import { a as createApiGatewayCookies, c as createHonoCookies, d as createNoopHeaders, i as readRequestBody, l as createHonoHeaders, n as SUPPORTED_BODY_TYPES, o as createApiGatewayHeaders, r as UnsupportedRequestContentType, t as MalformedRequestBody, u as createNoopCookies } from "../readRequestBody-BmKnPl0a.mjs";
6
+ import { trustsOrigin } from "@geekmidas/manifest";
7
+ export { BUILT_IN_SECURITY_SCHEMES, Endpoint, EndpointBuilder, EndpointFactory, MalformedRequestBody, NoAuthenticator, RLS_BYPASS, RedirectStatus, ResponseBuilder, SUPPORTED_BODY_TYPES, SuccessStatus, UPLOAD_POST_SCHEMA, UnsupportedRequestContentType, UploadAcceptInvalid, UploadContentTypeRefused, UploadContentTypeUnresolved, UploadEndpointBuilder, UploadExpiryInvalid, UploadMaxSizeInvalid, createApiGatewayCookies, createApiGatewayHeaders, createAuthorizer, createHonoCookies, createHonoHeaders, createNoopCookies, createNoopHeaders, defaultEnvParser, envParserFor, getSecurityScheme, isBuiltInSecurityScheme, publishConstructEvents, readRequestBody, trustsOrigin };
@@ -0,0 +1,38 @@
1
+ //#region src/expire.d.ts
2
+ /**
3
+ * How long a bucket keeps the objects under a prefix.
4
+ *
5
+ * Shared by `ObjectStorage` and the bucket a `FileServer` vends, because it is
6
+ * a fact about the bucket rather than about who serves it: a prefix of
7
+ * generated files that nobody reads back grows for ever unless the bucket
8
+ * itself is told to drop them.
9
+ *
10
+ * ```ts
11
+ * new ObjectStorage('Private', { expire: { 'quotes/': { days: 30 } } });
12
+ * ```
13
+ *
14
+ * Whole days, because that is the unit S3's lifecycle — and MinIO's — counts
15
+ * in. Prefixes are literal: a lifecycle rule matches the start of a key and
16
+ * has no globs, so a pattern that looks like one is refused rather than
17
+ * silently matching nothing.
18
+ */
19
+ type ObjectExpiry = Readonly<Record<string, {
20
+ readonly days: number;
21
+ }>>;
22
+ /** An expiry prefix the bucket could not match the way it reads. */
23
+ declare class ExpiryPrefixInvalid extends Error {
24
+ readonly bucket: string;
25
+ readonly prefix: string;
26
+ readonly reason: string;
27
+ constructor(bucket: string, prefix: string, reason: string);
28
+ }
29
+ /** An expiry that is not a whole number of days, one or more. */
30
+ declare class ExpiryDaysInvalid extends Error {
31
+ readonly bucket: string;
32
+ readonly prefix: string;
33
+ readonly days: unknown;
34
+ constructor(bucket: string, prefix: string, days: unknown);
35
+ }
36
+ //#endregion
37
+ export { ExpiryPrefixInvalid as n, ObjectExpiry as r, ExpiryDaysInvalid as t };
38
+ //# sourceMappingURL=expire-C586zznE.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"expire-C586zznE.d.cts","names":[],"sources":["../src/expire.ts"],"mappings":";;;;;;;;;;;;;;;;;;KAiBY,eAAe,SAAS;WAA0B;;;cAGjD,4BAA4B;WAE9B;WACA;WACA;EAHV,YACU,gBACA,gBACA;;;cAWE,0BAA0B;WAE5B;WACA;WACA;EAHV,YACU,gBACA,gBACA"}
@@ -0,0 +1,38 @@
1
+ //#region src/expire.d.ts
2
+ /**
3
+ * How long a bucket keeps the objects under a prefix.
4
+ *
5
+ * Shared by `ObjectStorage` and the bucket a `FileServer` vends, because it is
6
+ * a fact about the bucket rather than about who serves it: a prefix of
7
+ * generated files that nobody reads back grows for ever unless the bucket
8
+ * itself is told to drop them.
9
+ *
10
+ * ```ts
11
+ * new ObjectStorage('Private', { expire: { 'quotes/': { days: 30 } } });
12
+ * ```
13
+ *
14
+ * Whole days, because that is the unit S3's lifecycle — and MinIO's — counts
15
+ * in. Prefixes are literal: a lifecycle rule matches the start of a key and
16
+ * has no globs, so a pattern that looks like one is refused rather than
17
+ * silently matching nothing.
18
+ */
19
+ type ObjectExpiry = Readonly<Record<string, {
20
+ readonly days: number;
21
+ }>>;
22
+ /** An expiry prefix the bucket could not match the way it reads. */
23
+ declare class ExpiryPrefixInvalid extends Error {
24
+ readonly bucket: string;
25
+ readonly prefix: string;
26
+ readonly reason: string;
27
+ constructor(bucket: string, prefix: string, reason: string);
28
+ }
29
+ /** An expiry that is not a whole number of days, one or more. */
30
+ declare class ExpiryDaysInvalid extends Error {
31
+ readonly bucket: string;
32
+ readonly prefix: string;
33
+ readonly days: unknown;
34
+ constructor(bucket: string, prefix: string, days: unknown);
35
+ }
36
+ //#endregion
37
+ export { ExpiryPrefixInvalid as n, ObjectExpiry as r, ExpiryDaysInvalid as t };
38
+ //# sourceMappingURL=expire-C586zznE.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"expire-C586zznE.d.mts","names":[],"sources":["../src/expire.ts"],"mappings":";;;;;;;;;;;;;;;;;;KAiBY,eAAe,SAAS;WAA0B;;;cAGjD,4BAA4B;WAE9B;WACA;WACA;EAHV,YACU,gBACA,gBACA;;;cAWE,0BAA0B;WAE5B;WACA;WACA;EAHV,YACU,gBACA,gBACA"}
@@ -0,0 +1,106 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ const require_credential = require("./credential-RlgbzZAc.cjs");
3
+ const require_tracing = require("./tracing-C0ooU0V2.cjs");
4
+ let _geekmidas_manifest = require("@geekmidas/manifest");
5
+ //#region src/external-api.ts
6
+ /**
7
+ * `ExternalApi` — an HTTP API somebody else runs.
8
+ *
9
+ * Polar, Stripe, a payment gateway: nothing to provision, but an address that
10
+ * changes by stage and credentials the provider issued for each one. Without a
11
+ * construct every integration writes that switching by hand — an optional
12
+ * `POLAR_URL`, a fake started somewhere, a client built in a service — and the
13
+ * target cannot see any of it.
14
+ *
15
+ * ```ts
16
+ * // constructs/polar.ts
17
+ * export const polar = new ExternalApi('Polar', {
18
+ * url: 'https://www.polaraccesslink.com',
19
+ * credentials: z.object({ clientId: z.string(), clientSecret: z.string() }),
20
+ * client: ({ url, credentials }) => new PolarClient(url, credentials),
21
+ * });
22
+ *
23
+ * // test/fakes/polar.ts
24
+ * export default fake.app(new Hono().post('/v3/oauth2/token', …), {
25
+ * credentials: { clientId: 'fake', clientSecret: 'fake' },
26
+ * });
27
+ *
28
+ * // in a handler — the real API deployed, the fake locally and in tests
29
+ * .dependsOn([polar])
30
+ * .handle(({ services }) => services.polar.exchangeCode(code))
31
+ * ```
32
+ *
33
+ * Deployed, the URL is `url` — one for every stage, or one per stage name with
34
+ * a `default` — and the credentials are the stage's `<ID>_CREDENTIALS`, one
35
+ * JSON value read the way a `Credential`'s is. Locally and in tests both come
36
+ * from the fake.
37
+ *
38
+ * **The construct never names its fake.** It is found by convention, at
39
+ * `test/fakes/<id>.ts`, and read only by gkm and the generated test harness —
40
+ * so a fake, and the recorded responses it answers from, cannot end up in a
41
+ * deployed bundle however the bundler follows imports.
42
+ */
43
+ var ExternalApi = class {
44
+ options;
45
+ id;
46
+ service;
47
+ /** Read by both `declare()` and `connect()`, so the two cannot drift. */
48
+ keys;
49
+ /** The promise, so concurrent registrations share one client. */
50
+ connected;
51
+ constructor(id, options) {
52
+ this.options = options;
53
+ const canonical = (0, _geekmidas_manifest.canonicalId)(id);
54
+ this.id = canonical;
55
+ this.keys = {
56
+ url: (0, _geekmidas_manifest.providedKeyFor)(canonical, "external-api", "url"),
57
+ credentials: (0, _geekmidas_manifest.providedKeyFor)(canonical, "external-api", "credentials")
58
+ };
59
+ this.service = {
60
+ serviceName: (0, _geekmidas_manifest.serviceKey)(canonical),
61
+ register: (registerOptions) => {
62
+ this.connected ??= this.connect(registerOptions);
63
+ return this.connected;
64
+ }
65
+ };
66
+ }
67
+ /**
68
+ * What the stage's `<ID>_CREDENTIALS` must look like — the schema the value
69
+ * is validated against where it is read. Public so a tool setting the value
70
+ * (`gkm secrets:add`) can check it, and describe its fields, before it is
71
+ * stored rather than at the first request.
72
+ */
73
+ get credentialsSchema() {
74
+ return this.options.credentials;
75
+ }
76
+ declare() {
77
+ return [{
78
+ kind: "external-api",
79
+ id: this.id,
80
+ url: this.options.url,
81
+ provides: [this.keys.url, this.keys.credentials]
82
+ }];
83
+ }
84
+ async connect(options) {
85
+ const { url } = options.envParser.create((get) => ({ url: get(this.keys.url).string() })).parse();
86
+ const credentials = await require_credential.readCredentials(this.id, this.keys.credentials, this.options.credentials, options.envParser);
87
+ const client = await this.options.client({
88
+ url,
89
+ credentials
90
+ });
91
+ return require_tracing.traceClient(this.id, client, { "server.address": hostOf(url) });
92
+ }
93
+ };
94
+ function hostOf(url) {
95
+ try {
96
+ return new URL(url).host;
97
+ } catch {
98
+ return url;
99
+ }
100
+ }
101
+ //#endregion
102
+ exports.ExternalApi = ExternalApi;
103
+ exports.fake = require_credential.fake;
104
+ exports.isFake = require_credential.isFake;
105
+
106
+ //# sourceMappingURL=external-api.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"external-api.cjs","names":["canonicalId","providedKeyFor","serviceKey","readCredentials","traceClient"],"sources":["../src/external-api.ts"],"sourcesContent":["/**\n * `ExternalApi` — an HTTP API somebody else runs.\n *\n * Polar, Stripe, a payment gateway: nothing to provision, but an address that\n * changes by stage and credentials the provider issued for each one. Without a\n * construct every integration writes that switching by hand — an optional\n * `POLAR_URL`, a fake started somewhere, a client built in a service — and the\n * target cannot see any of it.\n *\n * ```ts\n * // constructs/polar.ts\n * export const polar = new ExternalApi('Polar', {\n * url: 'https://www.polaraccesslink.com',\n * credentials: z.object({ clientId: z.string(), clientSecret: z.string() }),\n * client: ({ url, credentials }) => new PolarClient(url, credentials),\n * });\n *\n * // test/fakes/polar.ts\n * export default fake.app(new Hono().post('/v3/oauth2/token', …), {\n * credentials: { clientId: 'fake', clientSecret: 'fake' },\n * });\n *\n * // in a handler — the real API deployed, the fake locally and in tests\n * .dependsOn([polar])\n * .handle(({ services }) => services.polar.exchangeCode(code))\n * ```\n *\n * Deployed, the URL is `url` — one for every stage, or one per stage name with\n * a `default` — and the credentials are the stage's `<ID>_CREDENTIALS`, one\n * JSON value read the way a `Credential`'s is. Locally and in tests both come\n * from the fake.\n *\n * **The construct never names its fake.** It is found by convention, at\n * `test/fakes/<id>.ts`, and read only by gkm and the generated test harness —\n * so a fake, and the recorded responses it answers from, cannot end up in a\n * deployed bundle however the bundler follows imports.\n */\n\nimport {\n\ttype ConstructName,\n\tcanonicalId,\n\ttype Declaration,\n\tprovidedKeyFor,\n\tserviceKey,\n} from '@geekmidas/manifest';\nimport type { Service, ServiceRegisterOptions } from '@geekmidas/services';\nimport type { StandardSchemaV1 } from '@standard-schema/spec';\nimport type { Consumable } from './construct-interface';\nimport { readCredentials } from './credential';\nimport type { DeployedStage, LocalStage } from './stages';\nimport { traceClient } from './tracing';\n\n/** What a credentials schema yields. */\ntype Value<TSchema extends StandardSchemaV1> =\n\tStandardSchemaV1.InferOutput<TSchema>;\n\n/**\n * Where an external API answers: one URL for every stage, or one per stage\n * name with `default` for any stage not listed.\n *\n * Keyed by the stages `gkm.config.ts` declares once `.gkm/stages.d.ts` exists,\n * so a key that names no stage — `prodution` — is a type error rather than a\n * URL nothing reads. Without the file any key goes, as before.\n */\nexport type ExternalApiUrl =\n\t| string\n\t| (string extends LocalStage | DeployedStage\n\t\t\t? Readonly<Record<string, string>>\n\t\t\t: { readonly [S in LocalStage | DeployedStage]?: string } & {\n\t\t\t\t\treadonly default?: string;\n\t\t\t\t});\n\nexport interface ExternalApiOptions<TSchema extends StandardSchemaV1, TClient> {\n\t/**\n\t * Where it answers deployed: one URL for every stage, or one per stage\n\t * name, with `default` for any stage not listed.\n\t */\n\turl: ExternalApiUrl;\n\t/** What the stage's `<ID>_CREDENTIALS` must look like. */\n\tcredentials: TSchema;\n\t/** What a handler is handed, built from where it answers and the credentials. */\n\tclient: (connection: {\n\t\turl: string;\n\t\tcredentials: Value<TSchema>;\n\t}) => TClient | Promise<TClient>;\n}\n\nexport class ExternalApi<\n\tTName extends string = string,\n\tTSchema extends StandardSchemaV1 = StandardSchemaV1,\n\tTClient = unknown,\n> implements Consumable<TName, TClient>\n{\n\t// `Consumable` for the reason `Credential` gives: a client generic in\n\t// `TClient` cannot satisfy `Construct`'s conditional service type.\n\treadonly id: TName;\n\treadonly service: Service<Uncapitalize<TName>, TClient>;\n\n\t/** Read by both `declare()` and `connect()`, so the two cannot drift. */\n\tprivate readonly keys: { url: string; credentials: string };\n\n\t/** The promise, so concurrent registrations share one client. */\n\tprivate connected?: Promise<TClient>;\n\n\tconstructor(\n\t\tid: ConstructName<TName>,\n\t\tprivate readonly options: ExternalApiOptions<TSchema, TClient>,\n\t) {\n\t\tconst canonical = canonicalId(id as string);\n\n\t\tthis.id = canonical as TName;\n\t\tthis.keys = {\n\t\t\turl: providedKeyFor(canonical, 'external-api', 'url'),\n\t\t\tcredentials: providedKeyFor(canonical, 'external-api', 'credentials'),\n\t\t};\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) => {\n\t\t\t\tthis.connected ??= this.connect(registerOptions);\n\t\t\t\treturn this.connected;\n\t\t\t},\n\t\t};\n\t}\n\n\t/**\n\t * What the stage's `<ID>_CREDENTIALS` must look like — the schema the value\n\t * is validated against where it is read. Public so a tool setting the value\n\t * (`gkm secrets:add`) can check it, and describe its fields, before it is\n\t * stored rather than at the first request.\n\t */\n\tget credentialsSchema(): TSchema {\n\t\treturn this.options.credentials;\n\t}\n\n\tdeclare(): Declaration[] {\n\t\treturn [\n\t\t\t{\n\t\t\t\tkind: 'external-api',\n\t\t\t\tid: this.id,\n\t\t\t\t// The stage-keyed map is a record of URLs to the manifest, which\n\t\t\t\t// reads it by whatever stage it is resolving.\n\t\t\t\turl: this.options.url as Readonly<Record<string, string>> | string,\n\t\t\t\tprovides: [this.keys.url, this.keys.credentials],\n\t\t\t},\n\t\t];\n\t}\n\n\tprivate async connect(options: ServiceRegisterOptions): Promise<TClient> {\n\t\tconst { url } = options.envParser\n\t\t\t.create((get) => ({ url: get(this.keys.url).string() }))\n\t\t\t.parse();\n\t\tconst credentials = await readCredentials(\n\t\t\tthis.id,\n\t\t\tthis.keys.credentials,\n\t\t\tthis.options.credentials,\n\t\t\toptions.envParser,\n\t\t);\n\n\t\tconst client = await this.options.client({ url, credentials });\n\t\t// Each call a span carrying this API's name — the parent of the fetch\n\t\t// it makes, which is traced already.\n\t\treturn traceClient(this.id, client, {\n\t\t\t'server.address': hostOf(url),\n\t\t});\n\t}\n}\n\nfunction hostOf(url: string): string {\n\ttry {\n\t\treturn new URL(url).host;\n\t} catch {\n\t\treturn url;\n\t}\n}\n\nexport {\n\ttype Fake,\n\ttype FetchHandler,\n\tfake,\n\tisFake,\n} from './fake';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAuFA,IAAa,cAAb,MAKA;CAcmB;CAXlB;CACA;;CAGA;;CAGA;CAEA,YACC,IACA,SACC;EADgB,KAAA,UAAA;EAEjB,MAAM,aAAA,GAAYA,oBAAAA,YAAAA,CAAY,EAAY;EAE1C,KAAK,KAAK;EACV,KAAK,OAAO;GACX,MAAA,GAAKC,oBAAAA,eAAAA,CAAe,WAAW,gBAAgB,KAAK;GACpD,cAAA,GAAaA,oBAAAA,eAAAA,CAAe,WAAW,gBAAgB,aAAa;EACrE;EAGA,KAAK,UAAU;GACd,cAAA,GAAaC,oBAAAA,WAAAA,CAAW,SAAS;GACjC,WAAW,oBAAoB;IAC9B,KAAK,cAAc,KAAK,QAAQ,eAAe;IAC/C,OAAO,KAAK;GACb;EACD;CACD;;;;;;;CAQA,IAAI,oBAA6B;EAChC,OAAO,KAAK,QAAQ;CACrB;CAEA,UAAyB;EACxB,OAAO,CACN;GACC,MAAM;GACN,IAAI,KAAK;GAGT,KAAK,KAAK,QAAQ;GAClB,UAAU,CAAC,KAAK,KAAK,KAAK,KAAK,KAAK,WAAW;EAChD,CACD;CACD;CAEA,MAAc,QAAQ,SAAmD;EACxE,MAAM,EAAE,QAAQ,QAAQ,UACtB,QAAQ,SAAS,EAAE,KAAK,IAAI,KAAK,KAAK,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,CACvD,MAAM;EACR,MAAM,cAAc,MAAMC,mBAAAA,gBACzB,KAAK,IACL,KAAK,KAAK,aACV,KAAK,QAAQ,aACb,QAAQ,SACT;EAEA,MAAM,SAAS,MAAM,KAAK,QAAQ,OAAO;GAAE;GAAK;EAAY,CAAC;EAG7D,OAAOC,gBAAAA,YAAY,KAAK,IAAI,QAAQ,EACnC,kBAAkB,OAAO,GAAG,EAC7B,CAAC;CACF;AACD;AAEA,SAAS,OAAO,KAAqB;CACpC,IAAI;EACH,OAAO,IAAI,IAAI,GAAG,CAAC,CAAC;CACrB,QAAQ;EACP,OAAO;CACR;AACD"}
@@ -0,0 +1,2 @@
1
+ import { a as ExternalApi, i as isFake, n as FetchHandler, o as ExternalApiOptions, r as fake, s as ExternalApiUrl, t as Fake } from "./fake-JI5uN1SF.cjs";
2
+ export { ExternalApi, ExternalApiOptions, ExternalApiUrl, type Fake, type FetchHandler, fake, isFake };
@@ -0,0 +1,2 @@
1
+ import { a as ExternalApi, i as isFake, n as FetchHandler, o as ExternalApiOptions, r as fake, s as ExternalApiUrl, t as Fake } from "./fake-zpuXpBmY.mjs";
2
+ export { ExternalApi, ExternalApiOptions, ExternalApiUrl, type Fake, type FetchHandler, fake, isFake };
@@ -0,0 +1,103 @@
1
+ import { a as fake, i as readCredentials, o as isFake } from "./credential-B80mOxwT.mjs";
2
+ import { i as traceClient } from "./tracing-Bbj1uoFJ.mjs";
3
+ import { canonicalId, providedKeyFor, serviceKey } from "@geekmidas/manifest";
4
+ //#region src/external-api.ts
5
+ /**
6
+ * `ExternalApi` — an HTTP API somebody else runs.
7
+ *
8
+ * Polar, Stripe, a payment gateway: nothing to provision, but an address that
9
+ * changes by stage and credentials the provider issued for each one. Without a
10
+ * construct every integration writes that switching by hand — an optional
11
+ * `POLAR_URL`, a fake started somewhere, a client built in a service — and the
12
+ * target cannot see any of it.
13
+ *
14
+ * ```ts
15
+ * // constructs/polar.ts
16
+ * export const polar = new ExternalApi('Polar', {
17
+ * url: 'https://www.polaraccesslink.com',
18
+ * credentials: z.object({ clientId: z.string(), clientSecret: z.string() }),
19
+ * client: ({ url, credentials }) => new PolarClient(url, credentials),
20
+ * });
21
+ *
22
+ * // test/fakes/polar.ts
23
+ * export default fake.app(new Hono().post('/v3/oauth2/token', …), {
24
+ * credentials: { clientId: 'fake', clientSecret: 'fake' },
25
+ * });
26
+ *
27
+ * // in a handler — the real API deployed, the fake locally and in tests
28
+ * .dependsOn([polar])
29
+ * .handle(({ services }) => services.polar.exchangeCode(code))
30
+ * ```
31
+ *
32
+ * Deployed, the URL is `url` — one for every stage, or one per stage name with
33
+ * a `default` — and the credentials are the stage's `<ID>_CREDENTIALS`, one
34
+ * JSON value read the way a `Credential`'s is. Locally and in tests both come
35
+ * from the fake.
36
+ *
37
+ * **The construct never names its fake.** It is found by convention, at
38
+ * `test/fakes/<id>.ts`, and read only by gkm and the generated test harness —
39
+ * so a fake, and the recorded responses it answers from, cannot end up in a
40
+ * deployed bundle however the bundler follows imports.
41
+ */
42
+ var ExternalApi = class {
43
+ options;
44
+ id;
45
+ service;
46
+ /** Read by both `declare()` and `connect()`, so the two cannot drift. */
47
+ keys;
48
+ /** The promise, so concurrent registrations share one client. */
49
+ connected;
50
+ constructor(id, options) {
51
+ this.options = options;
52
+ const canonical = canonicalId(id);
53
+ this.id = canonical;
54
+ this.keys = {
55
+ url: providedKeyFor(canonical, "external-api", "url"),
56
+ credentials: providedKeyFor(canonical, "external-api", "credentials")
57
+ };
58
+ this.service = {
59
+ serviceName: serviceKey(canonical),
60
+ register: (registerOptions) => {
61
+ this.connected ??= this.connect(registerOptions);
62
+ return this.connected;
63
+ }
64
+ };
65
+ }
66
+ /**
67
+ * What the stage's `<ID>_CREDENTIALS` must look like — the schema the value
68
+ * is validated against where it is read. Public so a tool setting the value
69
+ * (`gkm secrets:add`) can check it, and describe its fields, before it is
70
+ * stored rather than at the first request.
71
+ */
72
+ get credentialsSchema() {
73
+ return this.options.credentials;
74
+ }
75
+ declare() {
76
+ return [{
77
+ kind: "external-api",
78
+ id: this.id,
79
+ url: this.options.url,
80
+ provides: [this.keys.url, this.keys.credentials]
81
+ }];
82
+ }
83
+ async connect(options) {
84
+ const { url } = options.envParser.create((get) => ({ url: get(this.keys.url).string() })).parse();
85
+ const credentials = await readCredentials(this.id, this.keys.credentials, this.options.credentials, options.envParser);
86
+ const client = await this.options.client({
87
+ url,
88
+ credentials
89
+ });
90
+ return traceClient(this.id, client, { "server.address": hostOf(url) });
91
+ }
92
+ };
93
+ function hostOf(url) {
94
+ try {
95
+ return new URL(url).host;
96
+ } catch {
97
+ return url;
98
+ }
99
+ }
100
+ //#endregion
101
+ export { ExternalApi, fake, isFake };
102
+
103
+ //# sourceMappingURL=external-api.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"external-api.mjs","names":[],"sources":["../src/external-api.ts"],"sourcesContent":["/**\n * `ExternalApi` — an HTTP API somebody else runs.\n *\n * Polar, Stripe, a payment gateway: nothing to provision, but an address that\n * changes by stage and credentials the provider issued for each one. Without a\n * construct every integration writes that switching by hand — an optional\n * `POLAR_URL`, a fake started somewhere, a client built in a service — and the\n * target cannot see any of it.\n *\n * ```ts\n * // constructs/polar.ts\n * export const polar = new ExternalApi('Polar', {\n * url: 'https://www.polaraccesslink.com',\n * credentials: z.object({ clientId: z.string(), clientSecret: z.string() }),\n * client: ({ url, credentials }) => new PolarClient(url, credentials),\n * });\n *\n * // test/fakes/polar.ts\n * export default fake.app(new Hono().post('/v3/oauth2/token', …), {\n * credentials: { clientId: 'fake', clientSecret: 'fake' },\n * });\n *\n * // in a handler — the real API deployed, the fake locally and in tests\n * .dependsOn([polar])\n * .handle(({ services }) => services.polar.exchangeCode(code))\n * ```\n *\n * Deployed, the URL is `url` — one for every stage, or one per stage name with\n * a `default` — and the credentials are the stage's `<ID>_CREDENTIALS`, one\n * JSON value read the way a `Credential`'s is. Locally and in tests both come\n * from the fake.\n *\n * **The construct never names its fake.** It is found by convention, at\n * `test/fakes/<id>.ts`, and read only by gkm and the generated test harness —\n * so a fake, and the recorded responses it answers from, cannot end up in a\n * deployed bundle however the bundler follows imports.\n */\n\nimport {\n\ttype ConstructName,\n\tcanonicalId,\n\ttype Declaration,\n\tprovidedKeyFor,\n\tserviceKey,\n} from '@geekmidas/manifest';\nimport type { Service, ServiceRegisterOptions } from '@geekmidas/services';\nimport type { StandardSchemaV1 } from '@standard-schema/spec';\nimport type { Consumable } from './construct-interface';\nimport { readCredentials } from './credential';\nimport type { DeployedStage, LocalStage } from './stages';\nimport { traceClient } from './tracing';\n\n/** What a credentials schema yields. */\ntype Value<TSchema extends StandardSchemaV1> =\n\tStandardSchemaV1.InferOutput<TSchema>;\n\n/**\n * Where an external API answers: one URL for every stage, or one per stage\n * name with `default` for any stage not listed.\n *\n * Keyed by the stages `gkm.config.ts` declares once `.gkm/stages.d.ts` exists,\n * so a key that names no stage — `prodution` — is a type error rather than a\n * URL nothing reads. Without the file any key goes, as before.\n */\nexport type ExternalApiUrl =\n\t| string\n\t| (string extends LocalStage | DeployedStage\n\t\t\t? Readonly<Record<string, string>>\n\t\t\t: { readonly [S in LocalStage | DeployedStage]?: string } & {\n\t\t\t\t\treadonly default?: string;\n\t\t\t\t});\n\nexport interface ExternalApiOptions<TSchema extends StandardSchemaV1, TClient> {\n\t/**\n\t * Where it answers deployed: one URL for every stage, or one per stage\n\t * name, with `default` for any stage not listed.\n\t */\n\turl: ExternalApiUrl;\n\t/** What the stage's `<ID>_CREDENTIALS` must look like. */\n\tcredentials: TSchema;\n\t/** What a handler is handed, built from where it answers and the credentials. */\n\tclient: (connection: {\n\t\turl: string;\n\t\tcredentials: Value<TSchema>;\n\t}) => TClient | Promise<TClient>;\n}\n\nexport class ExternalApi<\n\tTName extends string = string,\n\tTSchema extends StandardSchemaV1 = StandardSchemaV1,\n\tTClient = unknown,\n> implements Consumable<TName, TClient>\n{\n\t// `Consumable` for the reason `Credential` gives: a client generic in\n\t// `TClient` cannot satisfy `Construct`'s conditional service type.\n\treadonly id: TName;\n\treadonly service: Service<Uncapitalize<TName>, TClient>;\n\n\t/** Read by both `declare()` and `connect()`, so the two cannot drift. */\n\tprivate readonly keys: { url: string; credentials: string };\n\n\t/** The promise, so concurrent registrations share one client. */\n\tprivate connected?: Promise<TClient>;\n\n\tconstructor(\n\t\tid: ConstructName<TName>,\n\t\tprivate readonly options: ExternalApiOptions<TSchema, TClient>,\n\t) {\n\t\tconst canonical = canonicalId(id as string);\n\n\t\tthis.id = canonical as TName;\n\t\tthis.keys = {\n\t\t\turl: providedKeyFor(canonical, 'external-api', 'url'),\n\t\t\tcredentials: providedKeyFor(canonical, 'external-api', 'credentials'),\n\t\t};\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) => {\n\t\t\t\tthis.connected ??= this.connect(registerOptions);\n\t\t\t\treturn this.connected;\n\t\t\t},\n\t\t};\n\t}\n\n\t/**\n\t * What the stage's `<ID>_CREDENTIALS` must look like — the schema the value\n\t * is validated against where it is read. Public so a tool setting the value\n\t * (`gkm secrets:add`) can check it, and describe its fields, before it is\n\t * stored rather than at the first request.\n\t */\n\tget credentialsSchema(): TSchema {\n\t\treturn this.options.credentials;\n\t}\n\n\tdeclare(): Declaration[] {\n\t\treturn [\n\t\t\t{\n\t\t\t\tkind: 'external-api',\n\t\t\t\tid: this.id,\n\t\t\t\t// The stage-keyed map is a record of URLs to the manifest, which\n\t\t\t\t// reads it by whatever stage it is resolving.\n\t\t\t\turl: this.options.url as Readonly<Record<string, string>> | string,\n\t\t\t\tprovides: [this.keys.url, this.keys.credentials],\n\t\t\t},\n\t\t];\n\t}\n\n\tprivate async connect(options: ServiceRegisterOptions): Promise<TClient> {\n\t\tconst { url } = options.envParser\n\t\t\t.create((get) => ({ url: get(this.keys.url).string() }))\n\t\t\t.parse();\n\t\tconst credentials = await readCredentials(\n\t\t\tthis.id,\n\t\t\tthis.keys.credentials,\n\t\t\tthis.options.credentials,\n\t\t\toptions.envParser,\n\t\t);\n\n\t\tconst client = await this.options.client({ url, credentials });\n\t\t// Each call a span carrying this API's name — the parent of the fetch\n\t\t// it makes, which is traced already.\n\t\treturn traceClient(this.id, client, {\n\t\t\t'server.address': hostOf(url),\n\t\t});\n\t}\n}\n\nfunction hostOf(url: string): string {\n\ttry {\n\t\treturn new URL(url).host;\n\t} catch {\n\t\treturn url;\n\t}\n}\n\nexport {\n\ttype Fake,\n\ttype FetchHandler,\n\tfake,\n\tisFake,\n} from './fake';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAuFA,IAAa,cAAb,MAKA;CAcmB;CAXlB;CACA;;CAGA;;CAGA;CAEA,YACC,IACA,SACC;EADgB,KAAA,UAAA;EAEjB,MAAM,YAAY,YAAY,EAAY;EAE1C,KAAK,KAAK;EACV,KAAK,OAAO;GACX,KAAK,eAAe,WAAW,gBAAgB,KAAK;GACpD,aAAa,eAAe,WAAW,gBAAgB,aAAa;EACrE;EAGA,KAAK,UAAU;GACd,aAAa,WAAW,SAAS;GACjC,WAAW,oBAAoB;IAC9B,KAAK,cAAc,KAAK,QAAQ,eAAe;IAC/C,OAAO,KAAK;GACb;EACD;CACD;;;;;;;CAQA,IAAI,oBAA6B;EAChC,OAAO,KAAK,QAAQ;CACrB;CAEA,UAAyB;EACxB,OAAO,CACN;GACC,MAAM;GACN,IAAI,KAAK;GAGT,KAAK,KAAK,QAAQ;GAClB,UAAU,CAAC,KAAK,KAAK,KAAK,KAAK,KAAK,WAAW;EAChD,CACD;CACD;CAEA,MAAc,QAAQ,SAAmD;EACxE,MAAM,EAAE,QAAQ,QAAQ,UACtB,QAAQ,SAAS,EAAE,KAAK,IAAI,KAAK,KAAK,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,CACvD,MAAM;EACR,MAAM,cAAc,MAAM,gBACzB,KAAK,IACL,KAAK,KAAK,aACV,KAAK,QAAQ,aACb,QAAQ,SACT;EAEA,MAAM,SAAS,MAAM,KAAK,QAAQ,OAAO;GAAE;GAAK;EAAY,CAAC;EAG7D,OAAO,YAAY,KAAK,IAAI,QAAQ,EACnC,kBAAkB,OAAO,GAAG,EAC7B,CAAC;CACF;AACD;AAEA,SAAS,OAAO,KAAqB;CACpC,IAAI;EACH,OAAO,IAAI,IAAI,GAAG,CAAC,CAAC;CACrB,QAAQ;EACP,OAAO;CACR;AACD"}
@@ -0,0 +1,201 @@
1
+ import { n as StandardSchemaV1 } from "./index-DdRjYhiJ.cjs";
2
+ import { r as Consumable } from "./construct-interface-CVoejIpo.cjs";
3
+ import { n as DeployedStage, r as LocalStage } from "./stages-DaTaoQei.cjs";
4
+ import { Service, ServiceRegisterOptions } from "@geekmidas/services";
5
+ import { ConstructName, Declaration } from "@geekmidas/manifest";
6
+ //#region src/credential.d.ts
7
+ /** What a credential's schema yields. */
8
+ type Value$1<TSchema extends StandardSchemaV1> = StandardSchemaV1.InferOutput<TSchema>;
9
+ interface CredentialOptions<TSchema extends StandardSchemaV1> {
10
+ /**
11
+ * What the credential must look like.
12
+ *
13
+ * Validated at registration, so a malformed or half-set credential fails
14
+ * when the process starts rather than on the first request that needs the
15
+ * one field somebody forgot.
16
+ */
17
+ schema: TSchema;
18
+ /**
19
+ * Re-resolve on every registration instead of once per process.
20
+ *
21
+ * Off by default: a credential is resolved once and reused, because the
22
+ * alternative is a fetch on every request. The cost of that default is that
23
+ * a rotated credential needs a restart, which is the right trade for a value
24
+ * that changes a few times a year — and this is the escape hatch for when it
25
+ * is not.
26
+ */
27
+ refresh?: boolean;
28
+ }
29
+ declare class Credential<TName extends string = string, TSchema extends StandardSchemaV1 = StandardSchemaV1> implements Consumable<TName, Value$1<TSchema>> {
30
+ private readonly options;
31
+ readonly id: TName;
32
+ readonly service: Service<Uncapitalize<TName>, Value$1<TSchema>>;
33
+ /**
34
+ * Declared once and read by both `declare()` and `connect()`, so the key the
35
+ * target publishes and the key the client reads cannot drift.
36
+ */
37
+ private readonly keys;
38
+ /**
39
+ * The resolved value, held as the *promise* rather than the value.
40
+ *
41
+ * Caching the promise is what makes two concurrent registrations share one
42
+ * resolution: caching the value would let both start before either finished,
43
+ * which is a duplicated fetch every cold start rather than never.
44
+ */
45
+ private resolved?;
46
+ constructor(id: ConstructName<TName>, options: CredentialOptions<TSchema>);
47
+ /**
48
+ * What the stage's `<ID>_CREDENTIALS` must look like — the schema the value
49
+ * is validated against where it is read. Public so a tool setting the value
50
+ * (`gkm secrets:add`) can check it, and describe its fields, before it is
51
+ * stored rather than at the first request.
52
+ */
53
+ get credentialsSchema(): TSchema;
54
+ declare(): Declaration[];
55
+ private connect;
56
+ private resolve;
57
+ }
58
+ /**
59
+ * A credentials key, read and validated against its schema.
60
+ *
61
+ * Shared with every construct that holds a third party's credentials — an
62
+ * `ExternalApi` reads its own the same way — so the shape a stage stores and
63
+ * the error a bad value raises are the same everywhere.
64
+ *
65
+ * @throws {MalformedCredential} when the value is not what the schema says.
66
+ */
67
+ declare function readCredentials<TSchema extends StandardSchemaV1>(id: string, key: string, schema: TSchema, envParser: ServiceRegisterOptions['envParser']): Promise<Value$1<TSchema>>;
68
+ /**
69
+ * The raw environment value as the thing the schema should see.
70
+ *
71
+ * JSON when it is JSON, and the string itself when it is not — a credential
72
+ * with a single opaque field is ordinary, and requiring `"…"` around it would
73
+ * be ceremony that every operator setting one by hand would get wrong once.
74
+ *
75
+ * Exported so a tool checking a value before it is stored reads it exactly as
76
+ * the process that uses it will.
77
+ */
78
+ declare function decodeCredentials(raw: string): unknown;
79
+ /** A credential was set, and is not what its schema says it should be. */
80
+ declare class MalformedCredential extends Error {
81
+ readonly id: string;
82
+ readonly key: string;
83
+ readonly issues: unknown;
84
+ constructor(id: string, key: string, issues: unknown);
85
+ }
86
+ //#endregion
87
+ //#region src/external-api.d.ts
88
+ /** What a credentials schema yields. */
89
+ type Value<TSchema extends StandardSchemaV1> = StandardSchemaV1.InferOutput<TSchema>;
90
+ /**
91
+ * Where an external API answers: one URL for every stage, or one per stage
92
+ * name with `default` for any stage not listed.
93
+ *
94
+ * Keyed by the stages `gkm.config.ts` declares once `.gkm/stages.d.ts` exists,
95
+ * so a key that names no stage — `prodution` — is a type error rather than a
96
+ * URL nothing reads. Without the file any key goes, as before.
97
+ */
98
+ type ExternalApiUrl = string | (string extends LocalStage | DeployedStage ? Readonly<Record<string, string>> : { readonly [S in LocalStage | DeployedStage]?: string; } & {
99
+ readonly default?: string;
100
+ });
101
+ interface ExternalApiOptions<TSchema extends StandardSchemaV1, TClient> {
102
+ /**
103
+ * Where it answers deployed: one URL for every stage, or one per stage
104
+ * name, with `default` for any stage not listed.
105
+ */
106
+ url: ExternalApiUrl;
107
+ /** What the stage's `<ID>_CREDENTIALS` must look like. */
108
+ credentials: TSchema;
109
+ /** What a handler is handed, built from where it answers and the credentials. */
110
+ client: (connection: {
111
+ url: string;
112
+ credentials: Value<TSchema>;
113
+ }) => TClient | Promise<TClient>;
114
+ }
115
+ declare class ExternalApi<TName extends string = string, TSchema extends StandardSchemaV1 = StandardSchemaV1, TClient = unknown> implements Consumable<TName, TClient> {
116
+ private readonly options;
117
+ readonly id: TName;
118
+ readonly service: Service<Uncapitalize<TName>, TClient>;
119
+ /** Read by both `declare()` and `connect()`, so the two cannot drift. */
120
+ private readonly keys;
121
+ /** The promise, so concurrent registrations share one client. */
122
+ private connected?;
123
+ constructor(id: ConstructName<TName>, options: ExternalApiOptions<TSchema, TClient>);
124
+ /**
125
+ * What the stage's `<ID>_CREDENTIALS` must look like — the schema the value
126
+ * is validated against where it is read. Public so a tool setting the value
127
+ * (`gkm secrets:add`) can check it, and describe its fields, before it is
128
+ * stored rather than at the first request.
129
+ */
130
+ get credentialsSchema(): TSchema;
131
+ declare(): Declaration[];
132
+ private connect;
133
+ }
134
+ //#endregion
135
+ //#region src/fake.d.ts
136
+ /**
137
+ * Marks a fake. A registered symbol, so a fake built by a second copy of this
138
+ * package — a linked workspace, two versions in a lockfile — is still one.
139
+ */
140
+ declare const FAKE: unique symbol;
141
+ /** Anything that answers a request — a Hono app, or a bare `{ fetch }`. */
142
+ interface FetchHandler {
143
+ fetch(request: Request): Response | Promise<Response>;
144
+ }
145
+ /**
146
+ * What a construct's credentials look like going in, for a fake to supply —
147
+ * an external API's `credentials` schema, or a credential's `schema`.
148
+ */
149
+ type CredentialsOf<TConstruct> = TConstruct extends ExternalApi<string, infer TSchema, unknown> ? StandardSchemaV1.InferInput<TSchema> : TConstruct extends Credential<string, infer TSchema> ? StandardSchemaV1.InferInput<TSchema> : unknown;
150
+ /**
151
+ * A third party's stand-in, as `test/fakes/<id>.ts` default-exports it.
152
+ *
153
+ * `credentials` are what a local or test stage is handed as `<ID>_CREDENTIALS`
154
+ * in place of the stage's own: what an external API's fake accepts, or a
155
+ * credential's test value.
156
+ */
157
+ type Fake = {
158
+ readonly [FAKE]: true;
159
+ readonly credentials: unknown;
160
+ } & ({
161
+ readonly kind: 'app';
162
+ /** Served by gkm: in-process in a test, on its own port in `gkm dev`. */
163
+ readonly handler: FetchHandler;
164
+ } | {
165
+ readonly kind: 'image';
166
+ /** The provider's own local server, run as a container. */
167
+ readonly image: string;
168
+ /** The port it listens on inside the container. */
169
+ readonly port: number;
170
+ } | {
171
+ /** A `Credential`'s test value — nothing to serve. */
172
+ readonly kind: 'credential';
173
+ });
174
+ /**
175
+ * Build the fake `test/fakes/<id>.ts` default-exports.
176
+ *
177
+ * Pass the construct's type to have the value checked against its schema —
178
+ * `fake.app<typeof polar>(…)`, `fake.credential<typeof stripe>(…)`.
179
+ */
180
+ declare const fake: {
181
+ /** A working implementation of an external API, kept beside the tests that use it. */
182
+ app<TApi = unknown>(handler: FetchHandler, options: {
183
+ credentials: CredentialsOf<TApi>;
184
+ }): Fake;
185
+ /** A local server an external API's provider publishes — `stripe/stripe-mock`. */
186
+ image<TApi = unknown>(image: string, options: {
187
+ port: number;
188
+ credentials: CredentialsOf<TApi>;
189
+ }): Fake;
190
+ /**
191
+ * A `Credential`'s value on the test stage and under `gkm dev --fake`, as
192
+ * its schema takes it — a string, or the object a JSON credential holds.
193
+ * It is validated where it is read, like the real one.
194
+ */
195
+ credential<TCredential = unknown>(credentials: CredentialsOf<TCredential>): Fake;
196
+ };
197
+ /** Whether a value is a fake — what gkm asks of a `test/fakes` default export. */
198
+ declare function isFake(value: unknown): value is Fake;
199
+ //#endregion
200
+ export { ExternalApi as a, Credential as c, decodeCredentials as d, readCredentials as f, isFake as i, CredentialOptions as l, FetchHandler as n, ExternalApiOptions as o, fake as r, ExternalApiUrl as s, Fake as t, MalformedCredential as u };
201
+ //# sourceMappingURL=fake-JI5uN1SF.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fake-JI5uN1SF.d.cts","names":["Value"],"sources":["../src/credential.ts","../src/external-api.ts","../src/fake.ts"],"mappings":";;;;;;;KAiEKA,QAAM,gBAAgB,oBAC1B,iBAAiB,YAAY;UAEb,kBAAkB,gBAAgB;;;;;;;;EAQlD,QAAQ;;;;;;;;;;EAUR;;cAGY,WACZ,+BACA,gBAAgB,mBAAmB,6BACvB,WAAW,OAAOA,QAAM;mBA6BlB;WApBT,IAAI;WACJ,SAAS,QAAQ,aAAa,QAAQA,QAAM;;;;;mBAMpC;;;;;;;;UAST;EAER,YACC,IAAI,cAAc,QACD,SAAS,kBAAkB;;;;;;;MAsBzC,qBAAqB;EAIzB,WAAW;UAUH;UAQA;;;;;;;;;;;iBAmBa,gBAAgB,gBAAgB,kBACrD,YACA,aACA,QAAQ,SACR,WAAW,sCACT,QAAQA,QAAM;;;;;;;;;;;iBAsBD,kBAAkB;;cAoBrB,4BAA4B;WAE9B;WACA;WACA;EAHV,YACU,YACA,aACA;;;;;KCtLN,MAAM,gBAAgB,oBAC1B,iBAAiB,YAAY;;;;;;;;;KAUlB,0CAEO,aAAa,gBAC3B,SAAS,sCACG,KAAK,aAAa;WACrB;;UAGG,mBAAmB,gBAAgB,kBAAkB;;;;;EAKrE,KAAK;;EAEL,aAAa;;EAEb,SAAS;IACR;IACA,aAAa,MAAM;QACd,UAAU,QAAQ;;cAGZ,YACZ,+BACA,gBAAgB,mBAAmB,kBACnC,8BACY,WAAW,OAAO;mBAeZ;WAXT,IAAI;WACJ,SAAS,QAAQ,aAAa,QAAQ;;mBAG9B;;UAGT;EAER,YACC,IAAI,cAAc,QACD,SAAS,mBAAmB,SAAS;;;;;;;MA0BnD,qBAAqB;EAIzB,WAAW;UAaG;;;;;;;;cCjHT;;UAGW;EAChB,MAAM,SAAS,UAAU,WAAW,QAAQ;;;;;;KAOxC,cAAc,cAClB,mBAAmB,0BAA0B,oBAC1C,iBAAiB,WAAW,WAC5B,mBAAmB,yBAAyB,WAC3C,iBAAiB,WAAW;;;;;;;;KAUrB;YACD;WACD;;WAGE;;WAEA,SAAS;;WAGT;;WAEA;;WAEA;;;WAIA;;;;;;;;cAUC;;EAEZ,IAAI,gBAAc,SACR,cAAY;IACV,aAAa,cAAc;MACpC;;EAUH,MAAM,gBAAc,eACN;IACF;IAAc,aAAa,cAAc;MAClD;;;;;;EAeH,WAAW,uBAAqB,aAClB,cAAc,eACzB;;;iBAMY,OAAO,iBAAiB,SAAS"}