@geekmidas/constructs 10.0.0-alpha.9 → 10.0.0-alpha.91

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 (425) hide show
  1. package/README.md +222 -158
  2. package/dist/{Construct-BD5neF7w.mjs → Construct-B1vGBPme.mjs} +33 -34
  3. package/dist/Construct-B1vGBPme.mjs.map +1 -0
  4. package/dist/Construct-BQALFCh2.d.cts +230 -0
  5. package/dist/Construct-BQALFCh2.d.cts.map +1 -0
  6. package/dist/{Construct-CyS3RpTL.cjs → Construct-DUSXuTHP.cjs} +53 -48
  7. package/dist/Construct-DUSXuTHP.cjs.map +1 -0
  8. package/dist/Construct-QXnl3VqT.d.mts +230 -0
  9. package/dist/Construct-QXnl3VqT.d.mts.map +1 -0
  10. package/dist/{Cron-DmQ8vQ4b.d.cts → Cron-DI3nKoic.d.cts} +15 -9
  11. package/dist/Cron-DI3nKoic.d.cts.map +1 -0
  12. package/dist/{Cron-dh4rUgib.d.mts → Cron-uYAHPnp7.d.mts} +15 -9
  13. package/dist/Cron-uYAHPnp7.d.mts.map +1 -0
  14. package/dist/{CronBuilder-Da0C0edR.cjs → CronBuilder-C0Ek1-RA.cjs} +47 -31
  15. package/dist/CronBuilder-C0Ek1-RA.cjs.map +1 -0
  16. package/dist/CronBuilder-DaSUm2Na.d.mts +47 -0
  17. package/dist/CronBuilder-DaSUm2Na.d.mts.map +1 -0
  18. package/dist/{CronBuilder-CYKT5RiO.mjs → CronBuilder-Dmix_Pen.mjs} +37 -21
  19. package/dist/CronBuilder-Dmix_Pen.mjs.map +1 -0
  20. package/dist/CronBuilder-g1lZLWyG.d.cts +47 -0
  21. package/dist/CronBuilder-g1lZLWyG.d.cts.map +1 -0
  22. package/dist/{Endpoint-DCQPMdUX.mjs → Endpoint-BG4UJ9oA.mjs} +146 -109
  23. package/dist/Endpoint-BG4UJ9oA.mjs.map +1 -0
  24. package/dist/{Endpoint-DcWXE-SZ.cjs → Endpoint-BoUg8ocM.cjs} +174 -131
  25. package/dist/Endpoint-BoUg8ocM.cjs.map +1 -0
  26. package/dist/{Endpoint-BjWKinFA.d.mts → Endpoint-Du-NwPX2.d.mts} +83 -91
  27. package/dist/Endpoint-Du-NwPX2.d.mts.map +1 -0
  28. package/dist/{Endpoint-dav89W6-.d.cts → Endpoint-aCvBMPoH.d.cts} +82 -90
  29. package/dist/Endpoint-aCvBMPoH.d.cts.map +1 -0
  30. package/dist/{EndpointFactory-CjV8F_lJ.mjs → EndpointFactory-BDtsrEvJ.mjs} +57 -76
  31. package/dist/EndpointFactory-BDtsrEvJ.mjs.map +1 -0
  32. package/dist/{EndpointFactory-CdWB7wPw.cjs → EndpointFactory-DJ7gXLpR.cjs} +93 -112
  33. package/dist/EndpointFactory-DJ7gXLpR.cjs.map +1 -0
  34. package/dist/{index-Bd5FqCoe.d.cts → EndpointFactory-DMYdJCOj.d.mts} +78 -134
  35. package/dist/EndpointFactory-DMYdJCOj.d.mts.map +1 -0
  36. package/dist/{index-lAO9egTb.d.mts → EndpointFactory-I7s1co3Y.d.cts} +79 -135
  37. package/dist/EndpointFactory-I7s1co3Y.d.cts.map +1 -0
  38. package/dist/Function-DuqGcbOI.d.mts +76 -0
  39. package/dist/Function-DuqGcbOI.d.mts.map +1 -0
  40. package/dist/Function-Pu-1kKZz.d.cts +76 -0
  41. package/dist/Function-Pu-1kKZz.d.cts.map +1 -0
  42. package/dist/{HonoEndpointAdaptor-P1ahhZHu.mjs → HonoEndpointAdaptor-PtPlbeKY.mjs} +75 -56
  43. package/dist/HonoEndpointAdaptor-PtPlbeKY.mjs.map +1 -0
  44. package/dist/{HonoEndpointAdaptor-DtL9j19R.cjs → HonoEndpointAdaptor-zVzVLJEO.cjs} +83 -61
  45. package/dist/HonoEndpointAdaptor-zVzVLJEO.cjs.map +1 -0
  46. package/dist/Queue-A3wfD0it.cjs +109 -0
  47. package/dist/Queue-A3wfD0it.cjs.map +1 -0
  48. package/dist/Queue-D6USGS4q.mjs +104 -0
  49. package/dist/Queue-D6USGS4q.mjs.map +1 -0
  50. package/dist/{Queue-D7ZuwBhy.d.cts → Queue-DlsHRzUp.d.mts} +48 -48
  51. package/dist/Queue-DlsHRzUp.d.mts.map +1 -0
  52. package/dist/{Queue-gVGfi2Yk.d.mts → Queue-HPyi0e1i.d.cts} +49 -49
  53. package/dist/Queue-HPyi0e1i.d.cts.map +1 -0
  54. package/dist/QueueBuilder-BjuF0UBl.cjs +135 -0
  55. package/dist/QueueBuilder-BjuF0UBl.cjs.map +1 -0
  56. package/dist/QueueBuilder-Cue73M4t.mjs +118 -0
  57. package/dist/QueueBuilder-Cue73M4t.mjs.map +1 -0
  58. package/dist/QueueBuilder-OSi6LkV9.d.cts +75 -0
  59. package/dist/QueueBuilder-OSi6LkV9.d.cts.map +1 -0
  60. package/dist/QueueBuilder-QHsnVt1P.d.mts +75 -0
  61. package/dist/QueueBuilder-QHsnVt1P.d.mts.map +1 -0
  62. package/dist/{Subscriber-2mEi0ImH.d.cts → Subscriber-Bpp02cGr.d.cts} +29 -20
  63. package/dist/Subscriber-Bpp02cGr.d.cts.map +1 -0
  64. package/dist/{Subscriber-xTJ9ayPN.d.mts → Subscriber-CtN9R48-.d.mts} +29 -20
  65. package/dist/Subscriber-CtN9R48-.d.mts.map +1 -0
  66. package/dist/{SubscriberBuilder-BjkbeT9l.mjs → SubscriberBuilder-CDy4nHCz.mjs} +50 -24
  67. package/dist/SubscriberBuilder-CDy4nHCz.mjs.map +1 -0
  68. package/dist/SubscriberBuilder-CuCMFpYW.d.mts +67 -0
  69. package/dist/SubscriberBuilder-CuCMFpYW.d.mts.map +1 -0
  70. package/dist/{SubscriberBuilder-4OPehf2R.cjs → SubscriberBuilder-D_owVoHo.cjs} +61 -36
  71. package/dist/SubscriberBuilder-D_owVoHo.cjs.map +1 -0
  72. package/dist/SubscriberBuilder-g3fAVWgs.d.cts +67 -0
  73. package/dist/SubscriberBuilder-g3fAVWgs.d.cts.map +1 -0
  74. package/dist/Topic-D74b5cgs.mjs +99 -0
  75. package/dist/Topic-D74b5cgs.mjs.map +1 -0
  76. package/dist/Topic-GHxcU8AG.cjs +104 -0
  77. package/dist/Topic-GHxcU8AG.cjs.map +1 -0
  78. package/dist/adaptors/aws.cjs +131 -220
  79. package/dist/adaptors/aws.cjs.map +1 -1
  80. package/dist/adaptors/aws.d.cts +34 -53
  81. package/dist/adaptors/aws.d.cts.map +1 -1
  82. package/dist/adaptors/aws.d.mts +34 -53
  83. package/dist/adaptors/aws.d.mts.map +1 -1
  84. package/dist/adaptors/aws.mjs +102 -193
  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 +8 -17
  90. package/dist/adaptors/hono.d.mts.map +1 -1
  91. package/dist/adaptors/hono.mjs +2 -10
  92. package/dist/adaptors/testing.cjs +743 -89
  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 +706 -70
  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-CcuceLYo.d.mts +268 -0
  103. package/dist/auth-CcuceLYo.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-CXh6GIgb.d.mts} +3 -6
  111. package/dist/cache-CXh6GIgb.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/{clone-DblgEZZa.mjs → clone-EKNovYHu.mjs} +3 -3
  125. package/dist/clone-EKNovYHu.mjs.map +1 -0
  126. package/dist/{clone-Dy0cR2SZ.cjs → clone-UGJpvQnL.cjs} +7 -8
  127. package/dist/clone-UGJpvQnL.cjs.map +1 -0
  128. package/dist/{construct-interface-D9d4Gm4p.d.cts → construct-interface-B1AfqRl4.d.cts} +42 -11
  129. package/dist/construct-interface-B1AfqRl4.d.cts.map +1 -0
  130. package/dist/{construct-interface-g5GM5pwR.d.mts → construct-interface-DluK3_da.d.mts} +42 -11
  131. package/dist/construct-interface-DluK3_da.d.mts.map +1 -0
  132. package/dist/construct-interface.cjs +113 -7
  133. package/dist/construct-interface.cjs.map +1 -0
  134. package/dist/construct-interface.d.cts +2 -2
  135. package/dist/construct-interface.d.mts +2 -2
  136. package/dist/construct-interface.mjs +106 -2
  137. package/dist/construct-interface.mjs.map +1 -0
  138. package/dist/credential.cjs +77 -17
  139. package/dist/credential.cjs.map +1 -1
  140. package/dist/credential.d.cts +34 -9
  141. package/dist/credential.d.cts.map +1 -1
  142. package/dist/credential.d.mts +34 -9
  143. package/dist/credential.d.mts.map +1 -1
  144. package/dist/credential.mjs +71 -13
  145. package/dist/credential.mjs.map +1 -1
  146. package/dist/crons/index.cjs +129 -7
  147. package/dist/crons/index.cjs.map +1 -1
  148. package/dist/crons/index.d.cts +45 -11
  149. package/dist/crons/index.d.cts.map +1 -1
  150. package/dist/crons/index.d.mts +45 -11
  151. package/dist/crons/index.d.mts.map +1 -1
  152. package/dist/crons/index.mjs +127 -8
  153. package/dist/crons/index.mjs.map +1 -1
  154. package/dist/database/kysely.cjs +4 -181
  155. package/dist/database/kysely.d.cts +2 -152
  156. package/dist/database/kysely.d.mts +2 -152
  157. package/dist/database/kysely.mjs +2 -180
  158. package/dist/email.cjs +25 -12
  159. package/dist/email.cjs.map +1 -1
  160. package/dist/email.d.cts +3 -7
  161. package/dist/email.d.cts.map +1 -1
  162. package/dist/email.d.mts +3 -7
  163. package/dist/email.d.mts.map +1 -1
  164. package/dist/email.mjs +16 -3
  165. package/dist/email.mjs.map +1 -1
  166. package/dist/encryption.cjs +96 -0
  167. package/dist/encryption.cjs.map +1 -0
  168. package/dist/encryption.d.cts +117 -0
  169. package/dist/encryption.d.cts.map +1 -0
  170. package/dist/encryption.d.mts +117 -0
  171. package/dist/encryption.d.mts.map +1 -0
  172. package/dist/encryption.mjs +83 -0
  173. package/dist/encryption.mjs.map +1 -0
  174. package/dist/endpoints/index.cjs +8 -10
  175. package/dist/endpoints/index.d.cts +51 -7
  176. package/dist/endpoints/index.d.cts.map +1 -0
  177. package/dist/endpoints/index.d.mts +51 -7
  178. package/dist/endpoints/index.d.mts.map +1 -0
  179. package/dist/endpoints/index.mjs +6 -10
  180. package/dist/external-api-MJ8id87V.d.mts +105 -0
  181. package/dist/external-api-MJ8id87V.d.mts.map +1 -0
  182. package/dist/external-api-O107yzZJ.d.cts +105 -0
  183. package/dist/external-api-O107yzZJ.d.cts.map +1 -0
  184. package/dist/external-api.cjs +142 -0
  185. package/dist/external-api.cjs.map +1 -0
  186. package/dist/external-api.d.cts +2 -0
  187. package/dist/external-api.d.mts +2 -0
  188. package/dist/external-api.mjs +139 -0
  189. package/dist/external-api.mjs.map +1 -0
  190. package/dist/file-server.cjs +42 -10
  191. package/dist/file-server.cjs.map +1 -1
  192. package/dist/file-server.d.cts +6 -10
  193. package/dist/file-server.d.cts.map +1 -1
  194. package/dist/file-server.d.mts +6 -10
  195. package/dist/file-server.d.mts.map +1 -1
  196. package/dist/file-server.mjs +34 -2
  197. package/dist/file-server.mjs.map +1 -1
  198. package/dist/functions/index.cjs +3 -6
  199. package/dist/functions/index.d.cts +3 -4
  200. package/dist/functions/index.d.mts +3 -4
  201. package/dist/functions/index.mjs +2 -6
  202. package/dist/{functions-14lpEFL4.mjs → functions-BFizikJU.mjs} +376 -238
  203. package/dist/{functions-14lpEFL4.mjs.map → functions-BFizikJU.mjs.map} +1 -1
  204. package/dist/{functions-i_la-N5r.cjs → functions-CfzJG9hK.cjs} +414 -264
  205. package/dist/functions-CfzJG9hK.cjs.map +1 -0
  206. package/dist/index-BuzRvKOQ.d.cts +115 -0
  207. package/dist/index-BuzRvKOQ.d.cts.map +1 -0
  208. package/dist/index-CTkKOer4.d.mts +115 -0
  209. package/dist/index-CTkKOer4.d.mts.map +1 -0
  210. package/dist/index-CeEtxDmK.d.cts +79 -0
  211. package/dist/index-CeEtxDmK.d.cts.map +1 -0
  212. package/dist/index-CeEtxDmK.d.mts +79 -0
  213. package/dist/index-CeEtxDmK.d.mts.map +1 -0
  214. package/dist/index.cjs +6 -3
  215. package/dist/index.d.cts +27 -4
  216. package/dist/index.d.cts.map +1 -0
  217. package/dist/index.d.mts +27 -4
  218. package/dist/index.d.mts.map +1 -0
  219. package/dist/index.mjs +3 -3
  220. package/dist/kms-B-Hm3d5r.cjs +85 -0
  221. package/dist/kms-B-Hm3d5r.cjs.map +1 -0
  222. package/dist/kms-BdUlMJEZ.mjs +85 -0
  223. package/dist/kms-BdUlMJEZ.mjs.map +1 -0
  224. package/dist/kysely-Bii4l6eP.mjs +370 -0
  225. package/dist/kysely-Bii4l6eP.mjs.map +1 -0
  226. package/dist/kysely-CO_Dk43W.cjs +383 -0
  227. package/dist/kysely-CO_Dk43W.cjs.map +1 -0
  228. package/dist/kysely-D0bpzgPs.d.cts +175 -0
  229. package/dist/kysely-D0bpzgPs.d.cts.map +1 -0
  230. package/dist/kysely-DUqC3Ie0.d.mts +175 -0
  231. package/dist/kysely-DUqC3Ie0.d.mts.map +1 -0
  232. package/dist/{telemetry-C3L0iS28.d.cts → lambdaTelemetry-8vnmVZQ5.d.cts} +3 -6
  233. package/dist/lambdaTelemetry-8vnmVZQ5.d.cts.map +1 -0
  234. package/dist/{telemetry-D7bVFLGi.d.mts → lambdaTelemetry-8vnmVZQ5.d.mts} +3 -6
  235. package/dist/lambdaTelemetry-8vnmVZQ5.d.mts.map +1 -0
  236. package/dist/{lazyAccessors-BoJN3SMd.mjs → lazyAccessors-CFanua0O.mjs} +20 -60
  237. package/dist/lazyAccessors-CFanua0O.mjs.map +1 -0
  238. package/dist/{lazyAccessors-e3j2oE2m.cjs → lazyAccessors-hJKGv8Ay.cjs} +60 -113
  239. package/dist/lazyAccessors-hJKGv8Ay.cjs.map +1 -0
  240. package/dist/mobile-app.cjs +73 -0
  241. package/dist/mobile-app.cjs.map +1 -0
  242. package/dist/mobile-app.d.cts +61 -0
  243. package/dist/mobile-app.d.cts.map +1 -0
  244. package/dist/mobile-app.d.mts +61 -0
  245. package/dist/mobile-app.d.mts.map +1 -0
  246. package/dist/mobile-app.mjs +72 -0
  247. package/dist/mobile-app.mjs.map +1 -0
  248. package/dist/object-storage.cjs +18 -10
  249. package/dist/object-storage.cjs.map +1 -1
  250. package/dist/object-storage.d.cts +3 -7
  251. package/dist/object-storage.d.cts.map +1 -1
  252. package/dist/object-storage.d.mts +3 -7
  253. package/dist/object-storage.d.mts.map +1 -1
  254. package/dist/object-storage.mjs +11 -3
  255. package/dist/object-storage.mjs.map +1 -1
  256. package/dist/processAudits-BRRVVHUB.mjs +131 -0
  257. package/dist/processAudits-BRRVVHUB.mjs.map +1 -0
  258. package/dist/processAudits-DasOZjPl.cjs +154 -0
  259. package/dist/processAudits-DasOZjPl.cjs.map +1 -0
  260. package/dist/queue/index.cjs +6 -189
  261. package/dist/queue/index.d.cts +3 -60
  262. package/dist/queue/index.d.mts +3 -60
  263. package/dist/queue/index.mjs +3 -186
  264. package/dist/rest-api.cjs +90 -59
  265. package/dist/rest-api.cjs.map +1 -1
  266. package/dist/rest-api.d.cts +70 -42
  267. package/dist/rest-api.d.cts.map +1 -1
  268. package/dist/rest-api.d.mts +70 -42
  269. package/dist/rest-api.d.mts.map +1 -1
  270. package/dist/rest-api.mjs +82 -51
  271. package/dist/rest-api.mjs.map +1 -1
  272. package/dist/{chunk-DWy1uDak.cjs → rolldown-runtime-y5ARvAq5.cjs} +14 -18
  273. package/dist/runSubscriber-BHvJ8POr.mjs +109 -0
  274. package/dist/runSubscriber-BHvJ8POr.mjs.map +1 -0
  275. package/dist/runSubscriber-D8nLXIv1.cjs +126 -0
  276. package/dist/runSubscriber-D8nLXIv1.cjs.map +1 -0
  277. package/dist/shutdown-BMJmAhSt.cjs +38 -0
  278. package/dist/shutdown-BMJmAhSt.cjs.map +1 -0
  279. package/dist/shutdown-C7xa8x9S.mjs +27 -0
  280. package/dist/shutdown-C7xa8x9S.mjs.map +1 -0
  281. package/dist/site.cjs +33 -7
  282. package/dist/site.cjs.map +1 -1
  283. package/dist/site.d.cts +17 -7
  284. package/dist/site.d.cts.map +1 -1
  285. package/dist/site.d.mts +17 -7
  286. package/dist/site.d.mts.map +1 -1
  287. package/dist/site.mjs +29 -3
  288. package/dist/site.mjs.map +1 -1
  289. package/dist/stages-BSCF19o2.d.cts +56 -0
  290. package/dist/stages-BSCF19o2.d.cts.map +1 -0
  291. package/dist/stages-BSCF19o2.d.mts +56 -0
  292. package/dist/stages-BSCF19o2.d.mts.map +1 -0
  293. package/dist/subscribers/index.cjs +118 -6
  294. package/dist/subscribers/index.cjs.map +1 -0
  295. package/dist/subscribers/index.d.cts +51 -6
  296. package/dist/subscribers/index.d.cts.map +1 -0
  297. package/dist/subscribers/index.d.mts +51 -6
  298. package/dist/subscribers/index.d.mts.map +1 -0
  299. package/dist/subscribers/index.mjs +115 -5
  300. package/dist/subscribers/index.mjs.map +1 -0
  301. package/dist/surfaceEnv-CNimK76p.cjs +56 -0
  302. package/dist/surfaceEnv-CNimK76p.cjs.map +1 -0
  303. package/dist/surfaceEnv-wMT5QzgZ.mjs +45 -0
  304. package/dist/surfaceEnv-wMT5QzgZ.mjs.map +1 -0
  305. package/dist/telemetry-B48RLjyk.d.cts +40 -0
  306. package/dist/telemetry-B48RLjyk.d.cts.map +1 -0
  307. package/dist/telemetry-DRtT1_0A.d.mts +40 -0
  308. package/dist/telemetry-DRtT1_0A.d.mts.map +1 -0
  309. package/dist/telemetry.cjs +56 -0
  310. package/dist/telemetry.cjs.map +1 -0
  311. package/dist/telemetry.d.cts +2 -0
  312. package/dist/telemetry.d.mts +2 -0
  313. package/dist/telemetry.mjs +55 -0
  314. package/dist/telemetry.mjs.map +1 -0
  315. package/dist/topic/index.cjs +3 -137
  316. package/dist/topic/index.d.cts +2 -4
  317. package/dist/topic/index.d.mts +2 -4
  318. package/dist/topic/index.mjs +2 -134
  319. package/dist/tracing-CxaZ98IB.mjs +110 -0
  320. package/dist/tracing-CxaZ98IB.mjs.map +1 -0
  321. package/dist/tracing-DPMidF_r.cjs +127 -0
  322. package/dist/tracing-DPMidF_r.cjs.map +1 -0
  323. package/dist/{types-BlAkSuGI.d.cts → types-DMuSQeLL.d.cts} +3 -5
  324. package/dist/types-DMuSQeLL.d.cts.map +1 -0
  325. package/dist/{types-aKksMEWL.d.mts → types-DMuSQeLL.d.mts} +3 -5
  326. package/dist/types-DMuSQeLL.d.mts.map +1 -0
  327. package/dist/types.d.cts +1 -1
  328. package/dist/types.d.mts +1 -1
  329. package/dist/types.mjs +1 -0
  330. package/dist/worker.cjs +59 -34
  331. package/dist/worker.cjs.map +1 -1
  332. package/dist/worker.d.cts +70 -45
  333. package/dist/worker.d.cts.map +1 -1
  334. package/dist/worker.d.mts +70 -44
  335. package/dist/worker.d.mts.map +1 -1
  336. package/dist/worker.mjs +54 -29
  337. package/dist/worker.mjs.map +1 -1
  338. package/package.json +96 -42
  339. package/dist/Construct-BD5neF7w.mjs.map +0 -1
  340. package/dist/Construct-C0ijr2qp.d.cts +0 -117
  341. package/dist/Construct-C0ijr2qp.d.cts.map +0 -1
  342. package/dist/Construct-Ct8nalEi.d.mts +0 -117
  343. package/dist/Construct-Ct8nalEi.d.mts.map +0 -1
  344. package/dist/Construct-CyS3RpTL.cjs.map +0 -1
  345. package/dist/Cron-DmQ8vQ4b.d.cts.map +0 -1
  346. package/dist/Cron-dh4rUgib.d.mts.map +0 -1
  347. package/dist/CronBuilder-BquXDbDI.d.cts +0 -44
  348. package/dist/CronBuilder-BquXDbDI.d.cts.map +0 -1
  349. package/dist/CronBuilder-CGgY2080.d.mts +0 -44
  350. package/dist/CronBuilder-CGgY2080.d.mts.map +0 -1
  351. package/dist/CronBuilder-CYKT5RiO.mjs.map +0 -1
  352. package/dist/CronBuilder-Da0C0edR.cjs.map +0 -1
  353. package/dist/Endpoint-BjWKinFA.d.mts.map +0 -1
  354. package/dist/Endpoint-DCQPMdUX.mjs.map +0 -1
  355. package/dist/Endpoint-DcWXE-SZ.cjs.map +0 -1
  356. package/dist/Endpoint-dav89W6-.d.cts.map +0 -1
  357. package/dist/EndpointFactory-CdWB7wPw.cjs.map +0 -1
  358. package/dist/EndpointFactory-CjV8F_lJ.mjs.map +0 -1
  359. package/dist/HonoEndpointAdaptor-DtL9j19R.cjs.map +0 -1
  360. package/dist/HonoEndpointAdaptor-P1ahhZHu.mjs.map +0 -1
  361. package/dist/Queue-D7ZuwBhy.d.cts.map +0 -1
  362. package/dist/Queue-gVGfi2Yk.d.mts.map +0 -1
  363. package/dist/Subscriber-2mEi0ImH.d.cts.map +0 -1
  364. package/dist/Subscriber-xTJ9ayPN.d.mts.map +0 -1
  365. package/dist/SubscriberBuilder-4OPehf2R.cjs.map +0 -1
  366. package/dist/SubscriberBuilder-BjkbeT9l.mjs.map +0 -1
  367. package/dist/SubscriberBuilder-Dptmo-1A.d.mts +0 -62
  368. package/dist/SubscriberBuilder-Dptmo-1A.d.mts.map +0 -1
  369. package/dist/SubscriberBuilder-waNhzjSM.d.cts +0 -62
  370. package/dist/SubscriberBuilder-waNhzjSM.d.cts.map +0 -1
  371. package/dist/Topic-19QeHBIR.d.cts +0 -91
  372. package/dist/Topic-19QeHBIR.d.cts.map +0 -1
  373. package/dist/Topic-DuFeqkBh.d.mts +0 -91
  374. package/dist/Topic-DuFeqkBh.d.mts.map +0 -1
  375. package/dist/auth.d.cts.map +0 -1
  376. package/dist/auth.d.mts.map +0 -1
  377. package/dist/cache-0ANvRQnD.mjs +0 -51
  378. package/dist/cache-0ANvRQnD.mjs.map +0 -1
  379. package/dist/cache-3WSvAulx.cjs +0 -57
  380. package/dist/cache-3WSvAulx.cjs.map +0 -1
  381. package/dist/cache-BrRz3fEB.d.mts.map +0 -1
  382. package/dist/cache-BtZY_tHe.d.cts.map +0 -1
  383. package/dist/clone-DblgEZZa.mjs.map +0 -1
  384. package/dist/clone-Dy0cR2SZ.cjs.map +0 -1
  385. package/dist/construct-interface-BfjcOD_E.cjs +0 -117
  386. package/dist/construct-interface-BfjcOD_E.cjs.map +0 -1
  387. package/dist/construct-interface-D9d4Gm4p.d.cts.map +0 -1
  388. package/dist/construct-interface-Z4CpS8tK.mjs +0 -81
  389. package/dist/construct-interface-Z4CpS8tK.mjs.map +0 -1
  390. package/dist/construct-interface-g5GM5pwR.d.mts.map +0 -1
  391. package/dist/database/kysely.cjs.map +0 -1
  392. package/dist/database/kysely.d.cts.map +0 -1
  393. package/dist/database/kysely.d.mts.map +0 -1
  394. package/dist/database/kysely.mjs.map +0 -1
  395. package/dist/functions-i_la-N5r.cjs.map +0 -1
  396. package/dist/index-Bd5FqCoe.d.cts.map +0 -1
  397. package/dist/index-BknhM6Ux.d.mts +0 -31
  398. package/dist/index-BknhM6Ux.d.mts.map +0 -1
  399. package/dist/index-CBSfrowv.d.cts +0 -31
  400. package/dist/index-CBSfrowv.d.cts.map +0 -1
  401. package/dist/index-D24Xm79M.d.cts +0 -171
  402. package/dist/index-D24Xm79M.d.cts.map +0 -1
  403. package/dist/index-_ajboYxK.d.mts +0 -171
  404. package/dist/index-_ajboYxK.d.mts.map +0 -1
  405. package/dist/index-lAO9egTb.d.mts.map +0 -1
  406. package/dist/lazyAccessors-BoJN3SMd.mjs.map +0 -1
  407. package/dist/lazyAccessors-e3j2oE2m.cjs.map +0 -1
  408. package/dist/processAudits-CGqttuXm.cjs +0 -92
  409. package/dist/processAudits-CGqttuXm.cjs.map +0 -1
  410. package/dist/processAudits-Dmts9H_b.mjs +0 -80
  411. package/dist/processAudits-Dmts9H_b.mjs.map +0 -1
  412. package/dist/queue/index.cjs.map +0 -1
  413. package/dist/queue/index.d.cts.map +0 -1
  414. package/dist/queue/index.d.mts.map +0 -1
  415. package/dist/queue/index.mjs.map +0 -1
  416. package/dist/surfaceEnv-BFXEms2f.cjs +0 -39
  417. package/dist/surfaceEnv-BFXEms2f.cjs.map +0 -1
  418. package/dist/surfaceEnv-C3Ktahea.mjs +0 -27
  419. package/dist/surfaceEnv-C3Ktahea.mjs.map +0 -1
  420. package/dist/telemetry-C3L0iS28.d.cts.map +0 -1
  421. package/dist/telemetry-D7bVFLGi.d.mts.map +0 -1
  422. package/dist/topic/index.cjs.map +0 -1
  423. package/dist/topic/index.mjs.map +0 -1
  424. package/dist/types-BlAkSuGI.d.cts.map +0 -1
  425. package/dist/types-aKksMEWL.d.mts.map +0 -1
@@ -0,0 +1,105 @@
1
+ import { t as StandardSchemaV1 } from "./index-CeEtxDmK.mjs";
2
+ import { r as Consumable } from "./construct-interface-DluK3_da.mjs";
3
+ import { n as DeployedStage, r as LocalStage } from "./stages-BSCF19o2.mjs";
4
+ import { ConstructName, Declaration } from "@geekmidas/manifest";
5
+ import { Service } from "@geekmidas/services";
6
+ //#region src/external-api.d.ts
7
+ /** What a credentials schema yields. */
8
+ type Value<TSchema extends StandardSchemaV1> = StandardSchemaV1.InferOutput<TSchema>;
9
+ /**
10
+ * Where an external API answers: one URL for every stage, or one per stage
11
+ * name with `default` for any stage not listed.
12
+ *
13
+ * Keyed by the stages `gkm.config.ts` declares once `.gkm/stages.d.ts` exists,
14
+ * so a key that names no stage — `prodution` — is a type error rather than a
15
+ * URL nothing reads. Without the file any key goes, as before.
16
+ */
17
+ type ExternalApiUrl = string | (string extends LocalStage | DeployedStage ? Readonly<Record<string, string>> : { readonly [S in LocalStage | DeployedStage]?: string; } & {
18
+ readonly default?: string;
19
+ });
20
+ interface ExternalApiOptions<TSchema extends StandardSchemaV1, TClient> {
21
+ /**
22
+ * Where it answers deployed: one URL for every stage, or one per stage
23
+ * name, with `default` for any stage not listed.
24
+ */
25
+ url: ExternalApiUrl;
26
+ /** What the stage's `<ID>_CREDENTIALS` must look like. */
27
+ credentials: TSchema;
28
+ /** What a handler is handed, built from where it answers and the credentials. */
29
+ client: (connection: {
30
+ url: string;
31
+ credentials: Value<TSchema>;
32
+ }) => TClient | Promise<TClient>;
33
+ }
34
+ declare class ExternalApi<TName extends string = string, TSchema extends StandardSchemaV1 = StandardSchemaV1, TClient = unknown> implements Consumable<TName, TClient> {
35
+ private readonly options;
36
+ readonly id: TName;
37
+ readonly service: Service<Uncapitalize<TName>, TClient>;
38
+ /** Read by both `declare()` and `connect()`, so the two cannot drift. */
39
+ private readonly keys;
40
+ /** The promise, so concurrent registrations share one client. */
41
+ private connected?;
42
+ constructor(id: ConstructName<TName>, options: ExternalApiOptions<TSchema, TClient>);
43
+ /**
44
+ * What the stage's `<ID>_CREDENTIALS` must look like — the schema the value
45
+ * is validated against where it is read. Public so a tool setting the value
46
+ * (`gkm secrets:add`) can check it, and describe its fields, before it is
47
+ * stored rather than at the first request.
48
+ */
49
+ get credentialsSchema(): TSchema;
50
+ declare(): Declaration[];
51
+ private connect;
52
+ }
53
+ /** Anything that answers a request — a Hono app, or a bare `{ fetch }`. */
54
+ interface FetchHandler {
55
+ fetch(request: Request): Response | Promise<Response>;
56
+ }
57
+ /**
58
+ * Marks a fake. A registered symbol, so a fake built by a second copy of this
59
+ * package — a linked workspace, two versions in a lockfile — is still one.
60
+ */
61
+ declare const FAKE: unique symbol;
62
+ /** What an external API's credentials look like going in, for a fake to supply. */
63
+ type CredentialsOf<TApi> = TApi extends ExternalApi<string, infer TSchema, unknown> ? StandardSchemaV1.InferInput<TSchema> : unknown;
64
+ /**
65
+ * An external API's stand-in, as `test/fakes/<id>.ts` default-exports it.
66
+ *
67
+ * `credentials` are what the fake accepts, and what a local or test stage is
68
+ * handed as `<ID>_CREDENTIALS` in place of the stage's own.
69
+ */
70
+ type Fake = {
71
+ readonly [FAKE]: true;
72
+ readonly credentials: unknown;
73
+ } & ({
74
+ readonly kind: 'app';
75
+ /** Served by gkm: in-process in a test, on its own port in `gkm dev`. */
76
+ readonly handler: FetchHandler;
77
+ } | {
78
+ readonly kind: 'image';
79
+ /** The provider's own local server, run as a container. */
80
+ readonly image: string;
81
+ /** The port it listens on inside the container. */
82
+ readonly port: number;
83
+ });
84
+ /**
85
+ * Build the fake `test/fakes/<id>.ts` default-exports.
86
+ *
87
+ * Pass the API's type to have the credentials checked against its schema —
88
+ * `fake.app<typeof polar>(…)`.
89
+ */
90
+ declare const fake: {
91
+ /** A working implementation of the API, kept beside the tests that use it. */
92
+ app<TApi = unknown>(handler: FetchHandler, options: {
93
+ credentials: CredentialsOf<TApi>;
94
+ }): Fake;
95
+ /** A local server the provider publishes — `stripe/stripe-mock`. */
96
+ image<TApi = unknown>(image: string, options: {
97
+ port: number;
98
+ credentials: CredentialsOf<TApi>;
99
+ }): Fake;
100
+ };
101
+ /** Whether a value is a fake — what gkm asks of a `test/fakes` default export. */
102
+ declare function isFake(value: unknown): value is Fake;
103
+ //#endregion
104
+ export { FetchHandler as a, Fake as i, ExternalApiOptions as n, fake as o, ExternalApiUrl as r, isFake as s, ExternalApi as t };
105
+ //# sourceMappingURL=external-api-MJ8id87V.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"external-api-MJ8id87V.d.mts","names":[],"sources":["../src/external-api.ts"],"mappings":";;;;;;;KAqDK,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;;;UA6BE;EAChB,MAAM,SAAS,UAAU,WAAW,QAAQ;;;;;;cAOvC;;KAGD,cAAc,QAClB,aAAa,0BAA0B,oBACpC,iBAAiB,WAAW;;;;;;;KASpB;YACD;WACD;;WAGE;;WAEA,SAAS;;WAGT;;WAEA;;WAEA;;;;;;;;cAUC;;EAEZ,IAAI,gBAAc,SACR,cAAY;IACV,aAAa,cAAc;MACpC;;EAUH,MAAM,gBAAc,eACN;IACF;IAAc,aAAa,cAAc;MAClD;;;iBAYY,OAAO,iBAAiB,SAAS"}
@@ -0,0 +1,105 @@
1
+ import { t as StandardSchemaV1 } from "./index-CeEtxDmK.cjs";
2
+ import { r as Consumable } from "./construct-interface-B1AfqRl4.cjs";
3
+ import { n as DeployedStage, r as LocalStage } from "./stages-BSCF19o2.cjs";
4
+ import { Service } from "@geekmidas/services";
5
+ import { ConstructName, Declaration } from "@geekmidas/manifest";
6
+ //#region src/external-api.d.ts
7
+ /** What a credentials schema yields. */
8
+ type Value<TSchema extends StandardSchemaV1> = StandardSchemaV1.InferOutput<TSchema>;
9
+ /**
10
+ * Where an external API answers: one URL for every stage, or one per stage
11
+ * name with `default` for any stage not listed.
12
+ *
13
+ * Keyed by the stages `gkm.config.ts` declares once `.gkm/stages.d.ts` exists,
14
+ * so a key that names no stage — `prodution` — is a type error rather than a
15
+ * URL nothing reads. Without the file any key goes, as before.
16
+ */
17
+ type ExternalApiUrl = string | (string extends LocalStage | DeployedStage ? Readonly<Record<string, string>> : { readonly [S in LocalStage | DeployedStage]?: string; } & {
18
+ readonly default?: string;
19
+ });
20
+ interface ExternalApiOptions<TSchema extends StandardSchemaV1, TClient> {
21
+ /**
22
+ * Where it answers deployed: one URL for every stage, or one per stage
23
+ * name, with `default` for any stage not listed.
24
+ */
25
+ url: ExternalApiUrl;
26
+ /** What the stage's `<ID>_CREDENTIALS` must look like. */
27
+ credentials: TSchema;
28
+ /** What a handler is handed, built from where it answers and the credentials. */
29
+ client: (connection: {
30
+ url: string;
31
+ credentials: Value<TSchema>;
32
+ }) => TClient | Promise<TClient>;
33
+ }
34
+ declare class ExternalApi<TName extends string = string, TSchema extends StandardSchemaV1 = StandardSchemaV1, TClient = unknown> implements Consumable<TName, TClient> {
35
+ private readonly options;
36
+ readonly id: TName;
37
+ readonly service: Service<Uncapitalize<TName>, TClient>;
38
+ /** Read by both `declare()` and `connect()`, so the two cannot drift. */
39
+ private readonly keys;
40
+ /** The promise, so concurrent registrations share one client. */
41
+ private connected?;
42
+ constructor(id: ConstructName<TName>, options: ExternalApiOptions<TSchema, TClient>);
43
+ /**
44
+ * What the stage's `<ID>_CREDENTIALS` must look like — the schema the value
45
+ * is validated against where it is read. Public so a tool setting the value
46
+ * (`gkm secrets:add`) can check it, and describe its fields, before it is
47
+ * stored rather than at the first request.
48
+ */
49
+ get credentialsSchema(): TSchema;
50
+ declare(): Declaration[];
51
+ private connect;
52
+ }
53
+ /** Anything that answers a request — a Hono app, or a bare `{ fetch }`. */
54
+ interface FetchHandler {
55
+ fetch(request: Request): Response | Promise<Response>;
56
+ }
57
+ /**
58
+ * Marks a fake. A registered symbol, so a fake built by a second copy of this
59
+ * package — a linked workspace, two versions in a lockfile — is still one.
60
+ */
61
+ declare const FAKE: unique symbol;
62
+ /** What an external API's credentials look like going in, for a fake to supply. */
63
+ type CredentialsOf<TApi> = TApi extends ExternalApi<string, infer TSchema, unknown> ? StandardSchemaV1.InferInput<TSchema> : unknown;
64
+ /**
65
+ * An external API's stand-in, as `test/fakes/<id>.ts` default-exports it.
66
+ *
67
+ * `credentials` are what the fake accepts, and what a local or test stage is
68
+ * handed as `<ID>_CREDENTIALS` in place of the stage's own.
69
+ */
70
+ type Fake = {
71
+ readonly [FAKE]: true;
72
+ readonly credentials: unknown;
73
+ } & ({
74
+ readonly kind: 'app';
75
+ /** Served by gkm: in-process in a test, on its own port in `gkm dev`. */
76
+ readonly handler: FetchHandler;
77
+ } | {
78
+ readonly kind: 'image';
79
+ /** The provider's own local server, run as a container. */
80
+ readonly image: string;
81
+ /** The port it listens on inside the container. */
82
+ readonly port: number;
83
+ });
84
+ /**
85
+ * Build the fake `test/fakes/<id>.ts` default-exports.
86
+ *
87
+ * Pass the API's type to have the credentials checked against its schema —
88
+ * `fake.app<typeof polar>(…)`.
89
+ */
90
+ declare const fake: {
91
+ /** A working implementation of the API, kept beside the tests that use it. */
92
+ app<TApi = unknown>(handler: FetchHandler, options: {
93
+ credentials: CredentialsOf<TApi>;
94
+ }): Fake;
95
+ /** A local server the provider publishes — `stripe/stripe-mock`. */
96
+ image<TApi = unknown>(image: string, options: {
97
+ port: number;
98
+ credentials: CredentialsOf<TApi>;
99
+ }): Fake;
100
+ };
101
+ /** Whether a value is a fake — what gkm asks of a `test/fakes` default export. */
102
+ declare function isFake(value: unknown): value is Fake;
103
+ //#endregion
104
+ export { FetchHandler as a, Fake as i, ExternalApiOptions as n, fake as o, ExternalApiUrl as r, isFake as s, ExternalApi as t };
105
+ //# sourceMappingURL=external-api-O107yzZJ.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"external-api-O107yzZJ.d.cts","names":[],"sources":["../src/external-api.ts"],"mappings":";;;;;;;KAqDK,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;;;UA6BE;EAChB,MAAM,SAAS,UAAU,WAAW,QAAQ;;;;;;cAOvC;;KAGD,cAAc,QAClB,aAAa,0BAA0B,oBACpC,iBAAiB,WAAW;;;;;;;KASpB;YACD;WACD;;WAGE;;WAEA,SAAS;;WAGT;;WAEA;;WAEA;;;;;;;;cAUC;;EAEZ,IAAI,gBAAc,SACR,cAAY;IACV,aAAa,cAAc;MACpC;;EAUH,MAAM,gBAAc,eACN;IACF;IAAc,aAAa,cAAc;MAClD;;;iBAYY,OAAO,iBAAiB,SAAS"}
@@ -0,0 +1,142 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ const require_credential = require("./credential.cjs");
3
+ const require_tracing = require("./tracing-DPMidF_r.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.provideKey)(canonical, "url"),
57
+ credentials: (0, _geekmidas_manifest.provideKey)(canonical, "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
+ /**
102
+ * Marks a fake. A registered symbol, so a fake built by a second copy of this
103
+ * package — a linked workspace, two versions in a lockfile — is still one.
104
+ */
105
+ const FAKE = Symbol.for("@geekmidas/constructs/fake");
106
+ /**
107
+ * Build the fake `test/fakes/<id>.ts` default-exports.
108
+ *
109
+ * Pass the API's type to have the credentials checked against its schema —
110
+ * `fake.app<typeof polar>(…)`.
111
+ */
112
+ const fake = {
113
+ /** A working implementation of the API, kept beside the tests that use it. */
114
+ app(handler, options) {
115
+ return {
116
+ [FAKE]: true,
117
+ kind: "app",
118
+ handler,
119
+ credentials: options.credentials
120
+ };
121
+ },
122
+ /** A local server the provider publishes — `stripe/stripe-mock`. */
123
+ image(image, options) {
124
+ return {
125
+ [FAKE]: true,
126
+ kind: "image",
127
+ image,
128
+ port: options.port,
129
+ credentials: options.credentials
130
+ };
131
+ }
132
+ };
133
+ /** Whether a value is a fake — what gkm asks of a `test/fakes` default export. */
134
+ function isFake(value) {
135
+ return typeof value === "object" && value !== null && value[FAKE] === true;
136
+ }
137
+ //#endregion
138
+ exports.ExternalApi = ExternalApi;
139
+ exports.fake = fake;
140
+ exports.isFake = isFake;
141
+
142
+ //# sourceMappingURL=external-api.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"external-api.cjs","names":["canonicalId","provideKey","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\tprovideKey,\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: provideKey(canonical, 'url'),\n\t\t\tcredentials: provideKey(canonical, '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\n/** Anything that answers a request — a Hono app, or a bare `{ fetch }`. */\nexport interface FetchHandler {\n\tfetch(request: Request): Response | Promise<Response>;\n}\n\n/**\n * Marks a fake. A registered symbol, so a fake built by a second copy of this\n * package — a linked workspace, two versions in a lockfile — is still one.\n */\nconst FAKE = Symbol.for('@geekmidas/constructs/fake');\n\n/** What an external API's credentials look like going in, for a fake to supply. */\ntype CredentialsOf<TApi> =\n\tTApi extends ExternalApi<string, infer TSchema, unknown>\n\t\t? StandardSchemaV1.InferInput<TSchema>\n\t\t: unknown;\n\n/**\n * An external API's stand-in, as `test/fakes/<id>.ts` default-exports it.\n *\n * `credentials` are what the fake accepts, and what a local or test stage is\n * handed as `<ID>_CREDENTIALS` in place of the stage's own.\n */\nexport type Fake = {\n\treadonly [FAKE]: true;\n\treadonly credentials: unknown;\n} & (\n\t| {\n\t\t\treadonly kind: 'app';\n\t\t\t/** Served by gkm: in-process in a test, on its own port in `gkm dev`. */\n\t\t\treadonly handler: FetchHandler;\n\t }\n\t| {\n\t\t\treadonly kind: 'image';\n\t\t\t/** The provider's own local server, run as a container. */\n\t\t\treadonly image: string;\n\t\t\t/** The port it listens on inside the container. */\n\t\t\treadonly port: number;\n\t }\n);\n\n/**\n * Build the fake `test/fakes/<id>.ts` default-exports.\n *\n * Pass the API's type to have the credentials checked against its schema —\n * `fake.app<typeof polar>(…)`.\n */\nexport const fake = {\n\t/** A working implementation of the API, kept beside the tests that use it. */\n\tapp<TApi = unknown>(\n\t\thandler: FetchHandler,\n\t\toptions: { credentials: CredentialsOf<TApi> },\n\t): Fake {\n\t\treturn {\n\t\t\t[FAKE]: true,\n\t\t\tkind: 'app',\n\t\t\thandler,\n\t\t\tcredentials: options.credentials,\n\t\t};\n\t},\n\n\t/** A local server the provider publishes — `stripe/stripe-mock`. */\n\timage<TApi = unknown>(\n\t\timage: string,\n\t\toptions: { port: number; credentials: CredentialsOf<TApi> },\n\t): Fake {\n\t\treturn {\n\t\t\t[FAKE]: true,\n\t\t\tkind: 'image',\n\t\t\timage,\n\t\t\tport: options.port,\n\t\t\tcredentials: options.credentials,\n\t\t};\n\t},\n};\n\n/** Whether a value is a fake — what gkm asks of a `test/fakes` default export. */\nexport function isFake(value: unknown): value is Fake {\n\treturn (\n\t\ttypeof value === 'object' &&\n\t\tvalue !== null &&\n\t\t(value as { [FAKE]?: unknown })[FAKE] === true\n\t);\n}\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,WAAAA,CAAW,WAAW,KAAK;GAChC,cAAA,GAAaA,oBAAAA,WAAAA,CAAW,WAAW,aAAa;EACjD;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;;;;;AAWA,MAAM,OAAO,OAAO,IAAI,4BAA4B;;;;;;;AAsCpD,MAAa,OAAO;;CAEnB,IACC,SACA,SACO;EACP,OAAO;IACL,OAAO;GACR,MAAM;GACN;GACA,aAAa,QAAQ;EACtB;CACD;;CAGA,MACC,OACA,SACO;EACP,OAAO;IACL,OAAO;GACR,MAAM;GACN;GACA,MAAM,QAAQ;GACd,aAAa,QAAQ;EACtB;CACD;AACD;;AAGA,SAAgB,OAAO,OAA+B;CACrD,OACC,OAAO,UAAU,YACjB,UAAU,QACT,MAA+B,UAAU;AAE5C"}
@@ -0,0 +1,2 @@
1
+ import { a as FetchHandler, i as Fake, n as ExternalApiOptions, o as fake, r as ExternalApiUrl, s as isFake, t as ExternalApi } from "./external-api-O107yzZJ.cjs";
2
+ export { ExternalApi, ExternalApiOptions, ExternalApiUrl, Fake, FetchHandler, fake, isFake };
@@ -0,0 +1,2 @@
1
+ import { a as FetchHandler, i as Fake, n as ExternalApiOptions, o as fake, r as ExternalApiUrl, s as isFake, t as ExternalApi } from "./external-api-MJ8id87V.mjs";
2
+ export { ExternalApi, ExternalApiOptions, ExternalApiUrl, Fake, FetchHandler, fake, isFake };
@@ -0,0 +1,139 @@
1
+ import { readCredentials } from "./credential.mjs";
2
+ import { r as traceClient } from "./tracing-CxaZ98IB.mjs";
3
+ import { canonicalId, provideKey, 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: provideKey(canonical, "url"),
56
+ credentials: provideKey(canonical, "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
+ /**
101
+ * Marks a fake. A registered symbol, so a fake built by a second copy of this
102
+ * package — a linked workspace, two versions in a lockfile — is still one.
103
+ */
104
+ const FAKE = Symbol.for("@geekmidas/constructs/fake");
105
+ /**
106
+ * Build the fake `test/fakes/<id>.ts` default-exports.
107
+ *
108
+ * Pass the API's type to have the credentials checked against its schema —
109
+ * `fake.app<typeof polar>(…)`.
110
+ */
111
+ const fake = {
112
+ /** A working implementation of the API, kept beside the tests that use it. */
113
+ app(handler, options) {
114
+ return {
115
+ [FAKE]: true,
116
+ kind: "app",
117
+ handler,
118
+ credentials: options.credentials
119
+ };
120
+ },
121
+ /** A local server the provider publishes — `stripe/stripe-mock`. */
122
+ image(image, options) {
123
+ return {
124
+ [FAKE]: true,
125
+ kind: "image",
126
+ image,
127
+ port: options.port,
128
+ credentials: options.credentials
129
+ };
130
+ }
131
+ };
132
+ /** Whether a value is a fake — what gkm asks of a `test/fakes` default export. */
133
+ function isFake(value) {
134
+ return typeof value === "object" && value !== null && value[FAKE] === true;
135
+ }
136
+ //#endregion
137
+ export { ExternalApi, fake, isFake };
138
+
139
+ //# 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\tprovideKey,\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: provideKey(canonical, 'url'),\n\t\t\tcredentials: provideKey(canonical, '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\n/** Anything that answers a request — a Hono app, or a bare `{ fetch }`. */\nexport interface FetchHandler {\n\tfetch(request: Request): Response | Promise<Response>;\n}\n\n/**\n * Marks a fake. A registered symbol, so a fake built by a second copy of this\n * package — a linked workspace, two versions in a lockfile — is still one.\n */\nconst FAKE = Symbol.for('@geekmidas/constructs/fake');\n\n/** What an external API's credentials look like going in, for a fake to supply. */\ntype CredentialsOf<TApi> =\n\tTApi extends ExternalApi<string, infer TSchema, unknown>\n\t\t? StandardSchemaV1.InferInput<TSchema>\n\t\t: unknown;\n\n/**\n * An external API's stand-in, as `test/fakes/<id>.ts` default-exports it.\n *\n * `credentials` are what the fake accepts, and what a local or test stage is\n * handed as `<ID>_CREDENTIALS` in place of the stage's own.\n */\nexport type Fake = {\n\treadonly [FAKE]: true;\n\treadonly credentials: unknown;\n} & (\n\t| {\n\t\t\treadonly kind: 'app';\n\t\t\t/** Served by gkm: in-process in a test, on its own port in `gkm dev`. */\n\t\t\treadonly handler: FetchHandler;\n\t }\n\t| {\n\t\t\treadonly kind: 'image';\n\t\t\t/** The provider's own local server, run as a container. */\n\t\t\treadonly image: string;\n\t\t\t/** The port it listens on inside the container. */\n\t\t\treadonly port: number;\n\t }\n);\n\n/**\n * Build the fake `test/fakes/<id>.ts` default-exports.\n *\n * Pass the API's type to have the credentials checked against its schema —\n * `fake.app<typeof polar>(…)`.\n */\nexport const fake = {\n\t/** A working implementation of the API, kept beside the tests that use it. */\n\tapp<TApi = unknown>(\n\t\thandler: FetchHandler,\n\t\toptions: { credentials: CredentialsOf<TApi> },\n\t): Fake {\n\t\treturn {\n\t\t\t[FAKE]: true,\n\t\t\tkind: 'app',\n\t\t\thandler,\n\t\t\tcredentials: options.credentials,\n\t\t};\n\t},\n\n\t/** A local server the provider publishes — `stripe/stripe-mock`. */\n\timage<TApi = unknown>(\n\t\timage: string,\n\t\toptions: { port: number; credentials: CredentialsOf<TApi> },\n\t): Fake {\n\t\treturn {\n\t\t\t[FAKE]: true,\n\t\t\tkind: 'image',\n\t\t\timage,\n\t\t\tport: options.port,\n\t\t\tcredentials: options.credentials,\n\t\t};\n\t},\n};\n\n/** Whether a value is a fake — what gkm asks of a `test/fakes` default export. */\nexport function isFake(value: unknown): value is Fake {\n\treturn (\n\t\ttypeof value === 'object' &&\n\t\tvalue !== null &&\n\t\t(value as { [FAKE]?: unknown })[FAKE] === true\n\t);\n}\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,WAAW,WAAW,KAAK;GAChC,aAAa,WAAW,WAAW,aAAa;EACjD;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;;;;;AAWA,MAAM,OAAO,OAAO,IAAI,4BAA4B;;;;;;;AAsCpD,MAAa,OAAO;;CAEnB,IACC,SACA,SACO;EACP,OAAO;IACL,OAAO;GACR,MAAM;GACN;GACA,aAAa,QAAQ;EACtB;CACD;;CAGA,MACC,OACA,SACO;EACP,OAAO;IACL,OAAO;GACR,MAAM;GACN;GACA,MAAM,QAAQ;GACd,aAAa,QAAQ;EACtB;CACD;AACD;;AAGA,SAAgB,OAAO,OAA+B;CACrD,OACC,OAAO,UAAU,YACjB,UAAU,QACT,MAA+B,UAAU;AAE5C"}
@@ -1,10 +1,41 @@
1
- const require_chunk = require('./chunk-DWy1uDak.cjs');
2
- const __geekmidas_manifest = require_chunk.__toESM(require("@geekmidas/manifest"));
3
- const __geekmidas_storage = require_chunk.__toESM(require("@geekmidas/storage"));
4
-
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ let _geekmidas_manifest = require("@geekmidas/manifest");
3
+ let _geekmidas_storage = require("@geekmidas/storage");
5
4
  //#region src/file-server.ts
5
+ /**
6
+ * `FileServer` — a domain that serves a bucket's objects.
7
+ *
8
+ * `ObjectStorage` is the bucket: it writes, it presigns, and its URL is never
9
+ * public. Serving those objects on a domain is a different thing, and it is a
10
+ * construct of its own rather than a flag on the bucket — see
11
+ * `docs/design/constructs-paradigm.md`, "Why a separate construct, and what it
12
+ * costs", for the comparison that rules the other two shapes out.
13
+ *
14
+ * ```ts
15
+ * export const uploads = new FileServer('Uploads', { open: ['brand/**'] });
16
+ *
17
+ * uploads.getUploadURL({ path, contentType }) // an S3 presign at the bucket
18
+ * uploads.url('brand/logo.png') // open path — no signature
19
+ * uploads.signedUrl('invoices/7.pdf') // one object, one recipient
20
+ * ```
21
+ *
22
+ * **One construct, one client, both halves.** How a file lands in the bucket is
23
+ * the same whether or not it is served, so splitting the upload half from the
24
+ * serving half would be ceremony rather than safety. The client is a *superset*
25
+ * of `StorageClient`, made literal in the type, so anything taking
26
+ * `services.uploads` keeps compiling when the construct behind it grows a
27
+ * serving half.
28
+ *
29
+ * **The id names the bucket, not the surface.** This is the detail that has to
30
+ * be right before anything ships, because getting it backwards is destructive:
31
+ * the migration people actually perform is serving a bucket they already have,
32
+ * and naming the bucket after the construct makes that edit *add* a node rather
33
+ * than rename the one holding the data.
34
+ */
6
35
  /** A key was asked to be served unsigned, and no open pattern admits it. */
7
36
  var NotOpen = class extends Error {
37
+ key;
38
+ open;
8
39
  constructor(key, open) {
9
40
  super(`'${key}' is not served without a signature. ` + (open.length ? `Open paths: ${open.join(", ")}. Use signedUrl() for anything else.` : "This file server declares no open paths, so every object needs signedUrl()."));
10
41
  this.key = key;
@@ -13,6 +44,7 @@ var NotOpen = class extends Error {
13
44
  }
14
45
  };
15
46
  var FileServer = class {
47
+ options;
16
48
  id;
17
49
  service;
18
50
  /** The id of the surface node, as opposed to the bucket's. */
@@ -25,17 +57,17 @@ var FileServer = class {
25
57
  keys;
26
58
  constructor(id, options = {}) {
27
59
  this.options = options;
28
- const canonical = (0, __geekmidas_manifest.canonicalId)(id);
60
+ const canonical = (0, _geekmidas_manifest.canonicalId)(id);
29
61
  this.id = canonical;
30
62
  this.open = options.open ?? [];
31
63
  const originId = options.origin?.id ?? canonical;
32
64
  this.surfaceId = `${canonical}Server`;
33
65
  this.keys = {
34
- origin: (0, __geekmidas_manifest.provideKey)(originId, "url"),
35
- server: (0, __geekmidas_manifest.provideKey)(this.surfaceId, "url")
66
+ origin: (0, _geekmidas_manifest.provideKey)(originId, "url"),
67
+ server: (0, _geekmidas_manifest.provideKey)(this.surfaceId, "url")
36
68
  };
37
69
  this.service = {
38
- serviceName: (0, __geekmidas_manifest.serviceKey)(canonical),
70
+ serviceName: (0, _geekmidas_manifest.serviceKey)(canonical),
39
71
  register: (registerOptions) => this.connect(registerOptions)
40
72
  };
41
73
  }
@@ -99,7 +131,7 @@ var FileServer = class {
99
131
  origin: get(this.keys.origin).string(),
100
132
  server: get(this.keys.server).string()
101
133
  })).parse();
102
- const storage = (0, __geekmidas_storage.createStorageClient)(origin);
134
+ const storage = (0, _geekmidas_storage.createStorageClient)(origin);
103
135
  const base = server.replace(/\/+$/, "");
104
136
  const serve = (key) => {
105
137
  if (!this.serves(key)) throw new NotOpen(key, this.open);
@@ -147,8 +179,8 @@ function globToRegExp(pattern) {
147
179
  }
148
180
  return new RegExp(`^${source}$`);
149
181
  }
150
-
151
182
  //#endregion
152
183
  exports.FileServer = FileServer;
153
184
  exports.NotOpen = NotOpen;
185
+
154
186
  //# sourceMappingURL=file-server.cjs.map