@geekmidas/constructs 10.0.0-alpha.166 → 10.0.0-alpha.168

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 (234) hide show
  1. package/dist/Construct-127M7yrl.d.cts.map +1 -1
  2. package/dist/Construct-BMk_CRSD.d.mts.map +1 -1
  3. package/dist/{Cron-D_sfaMGz.d.cts → Cron-Ca_qHQu2.d.cts} +2 -2
  4. package/dist/{Cron-D6Y7BBt3.d.mts.map → Cron-Ca_qHQu2.d.cts.map} +1 -1
  5. package/dist/{Cron-D6Y7BBt3.d.mts → Cron-DPJiR7Lt.d.mts} +2 -2
  6. package/dist/{Cron-D_sfaMGz.d.cts.map → Cron-DPJiR7Lt.d.mts.map} +1 -1
  7. package/dist/{CronBuilder-4BZhkChG.d.mts → CronBuilder-BC4za5Bx.d.mts} +4 -4
  8. package/dist/{CronBuilder-4BZhkChG.d.mts.map → CronBuilder-BC4za5Bx.d.mts.map} +1 -1
  9. package/dist/{CronBuilder-C91MVLSr.d.cts → CronBuilder-C3RrAF1-.d.cts} +4 -4
  10. package/dist/{CronBuilder-C91MVLSr.d.cts.map → CronBuilder-C3RrAF1-.d.cts.map} +1 -1
  11. package/dist/{Endpoint-YYwjqtS1.d.cts → Endpoint-BlIZLsBQ.d.cts} +5 -5
  12. package/dist/{Endpoint-BUoDD96P.d.mts.map → Endpoint-BlIZLsBQ.d.cts.map} +1 -1
  13. package/dist/{Endpoint-BUoDD96P.d.mts → Endpoint-DC7mreOr.d.mts} +5 -5
  14. package/dist/{Endpoint-YYwjqtS1.d.cts.map → Endpoint-DC7mreOr.d.mts.map} +1 -1
  15. package/dist/{EndpointFactory-BbVOeryo.d.mts → EndpointFactory-DCmnCmkX.d.mts} +5 -5
  16. package/dist/{EndpointFactory-BbVOeryo.d.mts.map → EndpointFactory-DCmnCmkX.d.mts.map} +1 -1
  17. package/dist/{EndpointFactory-Hh1r6J_C.d.cts → EndpointFactory-cVTb8kCc.d.cts} +5 -5
  18. package/dist/{EndpointFactory-Hh1r6J_C.d.cts.map → EndpointFactory-cVTb8kCc.d.cts.map} +1 -1
  19. package/dist/{ObjectSubscriberBuilder-DfzXQEKW.d.mts → ObjectSubscriberBuilder-AwGKoUKy.d.mts} +2 -2
  20. package/dist/{ObjectSubscriberBuilder-DfzXQEKW.d.mts.map → ObjectSubscriberBuilder-AwGKoUKy.d.mts.map} +1 -1
  21. package/dist/{ObjectSubscriberBuilder-LWkey_oq.d.cts → ObjectSubscriberBuilder-CB6imsX4.d.cts} +2 -2
  22. package/dist/{ObjectSubscriberBuilder-LWkey_oq.d.cts.map → ObjectSubscriberBuilder-CB6imsX4.d.cts.map} +1 -1
  23. package/dist/{ProcessorBuilder-_jdZlbfW.d.cts → ProcessorBuilder-CeEZ2vCx.d.cts} +2 -2
  24. package/dist/{ProcessorBuilder-D4oYvZeG.d.mts.map → ProcessorBuilder-CeEZ2vCx.d.cts.map} +1 -1
  25. package/dist/{ProcessorBuilder-D4oYvZeG.d.mts → ProcessorBuilder-CwIlm75W.d.mts} +2 -2
  26. package/dist/{ProcessorBuilder-_jdZlbfW.d.cts.map → ProcessorBuilder-CwIlm75W.d.mts.map} +1 -1
  27. package/dist/{Queue-u8w8_HpE.mjs → Queue-9Hh20ZCk.mjs} +3 -3
  28. package/dist/Queue-9Hh20ZCk.mjs.map +1 -0
  29. package/dist/Queue-B8HGg439.d.mts.map +1 -1
  30. package/dist/Queue-C4rijiM7.d.cts.map +1 -1
  31. package/dist/{Queue-D4Iaidrs.cjs → Queue-W1wueijP.cjs} +2 -2
  32. package/dist/Queue-W1wueijP.cjs.map +1 -0
  33. package/dist/{QueueBuilder-BxsZ9o5z.cjs → QueueBuilder-BDcv9B71.cjs} +2 -2
  34. package/dist/{QueueBuilder-BxsZ9o5z.cjs.map → QueueBuilder-BDcv9B71.cjs.map} +1 -1
  35. package/dist/{QueueBuilder-CVS_qPuo.d.mts → QueueBuilder-CUERv8jt.d.mts} +2 -2
  36. package/dist/{QueueBuilder-CVS_qPuo.d.mts.map → QueueBuilder-CUERv8jt.d.mts.map} +1 -1
  37. package/dist/{QueueBuilder-SQli59An.d.cts → QueueBuilder-CmB1vOgn.d.cts} +2 -2
  38. package/dist/{QueueBuilder-SQli59An.d.cts.map → QueueBuilder-CmB1vOgn.d.cts.map} +1 -1
  39. package/dist/{QueueBuilder-2wP5lEC8.mjs → QueueBuilder-CrZL8HHs.mjs} +2 -2
  40. package/dist/{QueueBuilder-2wP5lEC8.mjs.map → QueueBuilder-CrZL8HHs.mjs.map} +1 -1
  41. package/dist/{Topic-DN2gYJ-p.mjs → Topic-BGoOeCT6.mjs} +3 -3
  42. package/dist/Topic-BGoOeCT6.mjs.map +1 -0
  43. package/dist/{Topic-Dp9Q7Lj2.cjs → Topic-DLCZBNwK.cjs} +2 -2
  44. package/dist/Topic-DLCZBNwK.cjs.map +1 -0
  45. package/dist/adaptors/aws.d.cts +2 -2
  46. package/dist/adaptors/aws.d.mts +2 -2
  47. package/dist/adaptors/awsWebsocket.d.cts +1 -1
  48. package/dist/adaptors/awsWebsocket.d.mts +1 -1
  49. package/dist/adaptors/hono.d.cts +1 -1
  50. package/dist/adaptors/hono.d.mts +1 -1
  51. package/dist/adaptors/testing.cjs +15 -15
  52. package/dist/adaptors/testing.cjs.map +1 -1
  53. package/dist/adaptors/testing.d.cts +5 -5
  54. package/dist/adaptors/testing.d.cts.map +1 -1
  55. package/dist/adaptors/testing.d.mts +5 -5
  56. package/dist/adaptors/testing.d.mts.map +1 -1
  57. package/dist/adaptors/testing.mjs +16 -16
  58. package/dist/adaptors/testing.mjs.map +1 -1
  59. package/dist/{auth-DnB9H9KL.d.mts → auth-1yI2wR-4.d.cts} +6 -6
  60. package/dist/{auth-BqWz2JxC.d.cts.map → auth-1yI2wR-4.d.cts.map} +1 -1
  61. package/dist/{auth-BqWz2JxC.d.cts → auth-D4NMXgLt.d.mts} +6 -6
  62. package/dist/{auth-DnB9H9KL.d.mts.map → auth-D4NMXgLt.d.mts.map} +1 -1
  63. package/dist/auth.cjs +5 -5
  64. package/dist/auth.cjs.map +1 -1
  65. package/dist/auth.d.cts +1 -1
  66. package/dist/auth.d.mts +1 -1
  67. package/dist/auth.mjs +6 -6
  68. package/dist/auth.mjs.map +1 -1
  69. package/dist/{cache-CCHcO9Oo.d.mts → cache-0VoeOTF9.d.mts} +2 -2
  70. package/dist/{cache-CCHcO9Oo.d.mts.map → cache-0VoeOTF9.d.mts.map} +1 -1
  71. package/dist/{cache-CQjMNPrC.d.cts → cache-CW-sArzS.d.cts} +2 -2
  72. package/dist/{cache-CQjMNPrC.d.cts.map → cache-CW-sArzS.d.cts.map} +1 -1
  73. package/dist/cache.cjs +1 -1
  74. package/dist/cache.cjs.map +1 -1
  75. package/dist/cache.d.cts +1 -1
  76. package/dist/cache.d.mts +1 -1
  77. package/dist/cache.mjs +2 -2
  78. package/dist/cache.mjs.map +1 -1
  79. package/dist/{construct-interface-CSA9VeWM.d.mts → construct-interface-DhbaONW2.d.cts} +20 -4
  80. package/dist/construct-interface-DhbaONW2.d.cts.map +1 -0
  81. package/dist/{construct-interface-DugP0E5q.d.cts → construct-interface-DxfkFxkl.d.mts} +20 -4
  82. package/dist/construct-interface-DxfkFxkl.d.mts.map +1 -0
  83. package/dist/construct-interface.cjs +9 -0
  84. package/dist/construct-interface.cjs.map +1 -1
  85. package/dist/construct-interface.d.cts +2 -2
  86. package/dist/construct-interface.d.mts +2 -2
  87. package/dist/construct-interface.mjs +9 -1
  88. package/dist/construct-interface.mjs.map +1 -1
  89. package/dist/{credential-DfSAOOdY.mjs → credential-B80mOxwT.mjs} +3 -3
  90. package/dist/credential-B80mOxwT.mjs.map +1 -0
  91. package/dist/{credential-DYymbp_7.cjs → credential-RlgbzZAc.cjs} +2 -2
  92. package/dist/credential-RlgbzZAc.cjs.map +1 -0
  93. package/dist/credential.cjs +1 -1
  94. package/dist/credential.d.cts +1 -1
  95. package/dist/credential.d.mts +1 -1
  96. package/dist/credential.mjs +1 -1
  97. package/dist/crons/index.d.cts +2 -2
  98. package/dist/crons/index.d.mts +2 -2
  99. package/dist/database/kysely.cjs +1 -1
  100. package/dist/database/kysely.d.cts +1 -1
  101. package/dist/database/kysely.d.mts +1 -1
  102. package/dist/database/kysely.mjs +1 -1
  103. package/dist/email.cjs +2 -2
  104. package/dist/email.cjs.map +1 -1
  105. package/dist/email.d.cts +1 -1
  106. package/dist/email.d.mts +1 -1
  107. package/dist/email.mjs +3 -3
  108. package/dist/email.mjs.map +1 -1
  109. package/dist/encryption.cjs +1 -1
  110. package/dist/encryption.cjs.map +1 -1
  111. package/dist/encryption.d.cts +1 -1
  112. package/dist/encryption.d.mts +1 -1
  113. package/dist/encryption.mjs +2 -2
  114. package/dist/encryption.mjs.map +1 -1
  115. package/dist/endpoints/index.d.cts +2 -2
  116. package/dist/endpoints/index.d.mts +2 -2
  117. package/dist/external-api.cjs +3 -3
  118. package/dist/external-api.cjs.map +1 -1
  119. package/dist/external-api.d.cts +1 -1
  120. package/dist/external-api.d.mts +1 -1
  121. package/dist/external-api.mjs +4 -4
  122. package/dist/external-api.mjs.map +1 -1
  123. package/dist/{fake-BqhP8RRQ.d.mts → fake-BvOXkZmj.d.mts} +2 -2
  124. package/dist/{fake-BqhP8RRQ.d.mts.map → fake-BvOXkZmj.d.mts.map} +1 -1
  125. package/dist/{fake-DqieDYYA.d.cts → fake-Djx8E0o1.d.cts} +2 -2
  126. package/dist/{fake-DqieDYYA.d.cts.map → fake-Djx8E0o1.d.cts.map} +1 -1
  127. package/dist/file-server.cjs +79 -20
  128. package/dist/file-server.cjs.map +1 -1
  129. package/dist/file-server.d.cts +35 -17
  130. package/dist/file-server.d.cts.map +1 -1
  131. package/dist/file-server.d.mts +35 -17
  132. package/dist/file-server.d.mts.map +1 -1
  133. package/dist/file-server.mjs +80 -22
  134. package/dist/file-server.mjs.map +1 -1
  135. package/dist/functions/index.d.cts +1 -1
  136. package/dist/functions/index.d.mts +1 -1
  137. package/dist/{inbox-CR3L1fOI.d.cts → inbox-BjvMs7EJ.d.cts} +2 -2
  138. package/dist/{inbox-CR3L1fOI.d.cts.map → inbox-BjvMs7EJ.d.cts.map} +1 -1
  139. package/dist/{inbox-YOdxlyfj.d.mts → inbox-C8bOR9UL.d.mts} +2 -2
  140. package/dist/{inbox-YOdxlyfj.d.mts.map → inbox-C8bOR9UL.d.mts.map} +1 -1
  141. package/dist/inbox.cjs +3 -3
  142. package/dist/inbox.cjs.map +1 -1
  143. package/dist/inbox.d.cts +1 -1
  144. package/dist/inbox.d.mts +1 -1
  145. package/dist/inbox.mjs +4 -4
  146. package/dist/inbox.mjs.map +1 -1
  147. package/dist/{index-DPTHa6Ud.d.cts → index-DaK-C7N3.d.cts} +2 -2
  148. package/dist/{index-BoQ3-M-K.d.mts.map → index-DaK-C7N3.d.cts.map} +1 -1
  149. package/dist/{index-BoQ3-M-K.d.mts → index-vCS4HBEG.d.mts} +2 -2
  150. package/dist/{index-DPTHa6Ud.d.cts.map → index-vCS4HBEG.d.mts.map} +1 -1
  151. package/dist/{kysely-CebjCWTl.d.cts → kysely-2HqIQ2fC.d.cts} +3 -3
  152. package/dist/{kysely-CebjCWTl.d.cts.map → kysely-2HqIQ2fC.d.cts.map} +1 -1
  153. package/dist/{kysely-De5rAC-E.d.mts → kysely-BGvpd_ZH.d.mts} +3 -3
  154. package/dist/{kysely-De5rAC-E.d.mts.map → kysely-BGvpd_ZH.d.mts.map} +1 -1
  155. package/dist/{kysely-Cs4uPO8k.mjs → kysely-Bc9xzaik.mjs} +4 -4
  156. package/dist/kysely-Bc9xzaik.mjs.map +1 -0
  157. package/dist/{kysely-CukArHJ0.cjs → kysely-D7f6J2lh.cjs} +3 -3
  158. package/dist/kysely-D7f6J2lh.cjs.map +1 -0
  159. package/dist/mobile-app.cjs +6 -2
  160. package/dist/mobile-app.cjs.map +1 -1
  161. package/dist/mobile-app.d.cts +5 -1
  162. package/dist/mobile-app.d.cts.map +1 -1
  163. package/dist/mobile-app.d.mts +5 -1
  164. package/dist/mobile-app.d.mts.map +1 -1
  165. package/dist/mobile-app.mjs +8 -4
  166. package/dist/mobile-app.mjs.map +1 -1
  167. package/dist/object-storage.cjs +6 -6
  168. package/dist/object-storage.cjs.map +1 -1
  169. package/dist/object-storage.d.cts +3 -3
  170. package/dist/object-storage.d.cts.map +1 -1
  171. package/dist/object-storage.d.mts +3 -3
  172. package/dist/object-storage.d.mts.map +1 -1
  173. package/dist/object-storage.mjs +7 -7
  174. package/dist/object-storage.mjs.map +1 -1
  175. package/dist/processors/index.d.cts +1 -1
  176. package/dist/processors/index.d.mts +1 -1
  177. package/dist/queue/index.cjs +2 -2
  178. package/dist/queue/index.d.cts +1 -1
  179. package/dist/queue/index.d.mts +1 -1
  180. package/dist/queue/index.mjs +2 -2
  181. package/dist/random-password.d.cts +1 -1
  182. package/dist/random-password.d.mts +1 -1
  183. package/dist/rest-api.cjs +3 -3
  184. package/dist/rest-api.cjs.map +1 -1
  185. package/dist/rest-api.d.cts +4 -4
  186. package/dist/rest-api.d.mts +4 -4
  187. package/dist/rest-api.mjs +4 -4
  188. package/dist/rest-api.mjs.map +1 -1
  189. package/dist/site.cjs +8 -3
  190. package/dist/site.cjs.map +1 -1
  191. package/dist/site.d.cts +7 -2
  192. package/dist/site.d.cts.map +1 -1
  193. package/dist/site.d.mts +7 -2
  194. package/dist/site.d.mts.map +1 -1
  195. package/dist/site.mjs +10 -5
  196. package/dist/site.mjs.map +1 -1
  197. package/dist/subscribers/index.d.cts +1 -1
  198. package/dist/subscribers/index.d.mts +1 -1
  199. package/dist/{telemetry-CObow3Dn.d.mts → telemetry-BirKau0X.d.mts} +2 -2
  200. package/dist/{telemetry-C1oqncFY.d.cts.map → telemetry-BirKau0X.d.mts.map} +1 -1
  201. package/dist/{telemetry-C1oqncFY.d.cts → telemetry-DjJgtQ_N.d.cts} +2 -2
  202. package/dist/{telemetry-CObow3Dn.d.mts.map → telemetry-DjJgtQ_N.d.cts.map} +1 -1
  203. package/dist/telemetry.d.cts +1 -1
  204. package/dist/telemetry.d.mts +1 -1
  205. package/dist/topic/index.cjs +1 -1
  206. package/dist/topic/index.mjs +1 -1
  207. package/dist/{websocket-api-DkF8Hva-.d.cts → websocket-api-B1Wl3tg4.d.cts} +3 -3
  208. package/dist/{websocket-api-CPEzJyDt.d.mts.map → websocket-api-B1Wl3tg4.d.cts.map} +1 -1
  209. package/dist/{websocket-api-CPEzJyDt.d.mts → websocket-api-CvnPDSZB.d.mts} +3 -3
  210. package/dist/{websocket-api-DkF8Hva-.d.cts.map → websocket-api-CvnPDSZB.d.mts.map} +1 -1
  211. package/dist/{websocket-api-czxhekGG.cjs → websocket-api-Zy2U-Qyh.cjs} +4 -4
  212. package/dist/websocket-api-Zy2U-Qyh.cjs.map +1 -0
  213. package/dist/{websocket-api-Bg9SowJ5.mjs → websocket-api-svBCnOAE.mjs} +5 -5
  214. package/dist/{websocket-api-Bg9SowJ5.mjs.map → websocket-api-svBCnOAE.mjs.map} +1 -1
  215. package/dist/websocket-api.cjs +1 -1
  216. package/dist/websocket-api.d.cts +1 -1
  217. package/dist/websocket-api.d.mts +1 -1
  218. package/dist/websocket-api.mjs +1 -1
  219. package/dist/worker.cjs +1 -1
  220. package/dist/worker.d.cts +8 -8
  221. package/dist/worker.d.mts +8 -8
  222. package/dist/worker.mjs +1 -1
  223. package/package.json +31 -31
  224. package/dist/Queue-D4Iaidrs.cjs.map +0 -1
  225. package/dist/Queue-u8w8_HpE.mjs.map +0 -1
  226. package/dist/Topic-DN2gYJ-p.mjs.map +0 -1
  227. package/dist/Topic-Dp9Q7Lj2.cjs.map +0 -1
  228. package/dist/construct-interface-CSA9VeWM.d.mts.map +0 -1
  229. package/dist/construct-interface-DugP0E5q.d.cts.map +0 -1
  230. package/dist/credential-DYymbp_7.cjs.map +0 -1
  231. package/dist/credential-DfSAOOdY.mjs.map +0 -1
  232. package/dist/kysely-Cs4uPO8k.mjs.map +0 -1
  233. package/dist/kysely-CukArHJ0.cjs.map +0 -1
  234. package/dist/websocket-api-czxhekGG.cjs.map +0 -1
@@ -1,4 +1,4 @@
1
- import { n as Construct } from "./construct-interface-DugP0E5q.cjs";
1
+ import { n as Construct } from "./construct-interface-DhbaONW2.cjs";
2
2
  import { Service } from "@geekmidas/services";
3
3
  import { ConstructName, Declaration } from "@geekmidas/manifest";
4
4
  import { Cache } from "@geekmidas/cache";
@@ -41,4 +41,4 @@ declare class Cache$1<TName extends string = string> implements Construct<TName,
41
41
  }
42
42
  //#endregion
43
43
  export { CacheOptions as n, Cache$1 as t };
44
- //# sourceMappingURL=cache-CQjMNPrC.d.cts.map
44
+ //# sourceMappingURL=cache-CW-sArzS.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"cache-CQjMNPrC.d.cts","names":["Cache","CacheClient"],"sources":["../src/cache.ts"],"mappings":";;;;;UA8BiB;;;;;;;;EAQhB;;EAEA;;cAGYA,QAAM,0CACP,UAAU,OAAOC;mBAaV;WAXT,IAAI;WACJ,SAAS,QAAQ,aAAa,QAAQA;;;;;mBAM9B;EAEjB,YACC,IAAI,cAAc,QACD,UAAS;EAc3B,WAAW;;;;;;;;;;;;UAuBG"}
1
+ {"version":3,"file":"cache-CW-sArzS.d.cts","names":["Cache","CacheClient"],"sources":["../src/cache.ts"],"mappings":";;;;;UA8BiB;;;;;;;;EAQhB;;EAEA;;cAGYA,QAAM,0CACP,UAAU,OAAOC;mBAaV;WAXT,IAAI;WACJ,SAAS,QAAQ,aAAa,QAAQA;;;;;mBAM9B;EAEjB,YACC,IAAI,cAAc,QACD,UAAS;EAc3B,WAAW;;;;;;;;;;;;UAuBG"}
package/dist/cache.cjs CHANGED
@@ -15,7 +15,7 @@ var Cache = class {
15
15
  this.options = options;
16
16
  const canonical = (0, _geekmidas_manifest.canonicalId)(id);
17
17
  this.id = canonical;
18
- this.key = (0, _geekmidas_manifest.provideKey)(canonical, "url");
18
+ this.key = (0, _geekmidas_manifest.providedKeyFor)(canonical, "cache", "url");
19
19
  this.service = {
20
20
  serviceName: (0, _geekmidas_manifest.serviceKey)(canonical),
21
21
  register: (options) => this.connect(options)
@@ -1 +1 @@
1
- {"version":3,"file":"cache.cjs","names":["canonicalId","provideKey","serviceKey","loadCache"],"sources":["../src/cache.ts"],"sourcesContent":["/**\n * `Cache` — a declared key/value cache.\n *\n * The same three-package meeting point as `ObjectStorage` and `Email`: it\n * implements the construct contract, derives its env key through\n * `@geekmidas/manifest`, and hands back a `@geekmidas/cache` client.\n *\n * It names no provider — and unlike `Email`, it cannot name one protocol\n * either. Every mail backend speaks SMTP, so an `smtp://` URL is true of all of\n * them; cache backends genuinely differ, because Upstash speaks HTTP, a Redis\n * speaks its wire protocol, and a table in Postgres speaks SQL. So the scheme in\n * the URL picks the driver, exactly as it does for object storage, and which\n * drivers exist is the generated entry point's decision.\n *\n * The backend is chosen at deploy, not here. An app caching in Postgres and an\n * app caching in Upstash are the same application code.\n */\n\nimport type { Cache as CacheClient } from '@geekmidas/cache';\nimport {\n\ttype ConstructName,\n\tcanonicalId,\n\ttype Declaration,\n\tprovideKey,\n\tserviceKey,\n} from '@geekmidas/manifest';\nimport type { Service, ServiceRegisterOptions } from '@geekmidas/services';\nimport type { Construct } from './construct-interface';\nimport { loadCache } from './optionalPeers';\n\nexport interface CacheOptions {\n\t/**\n\t * The database this cache lives in.\n\t *\n\t * Set by `database.cache()` rather than written by hand — the point of the\n\t * method is that the parent's id comes from the parent rather than from a\n\t * string somebody has to keep in step.\n\t */\n\tof?: string;\n\t/** The table entries are kept in. Defaults to `cache`. */\n\ttable?: string;\n}\n\nexport class Cache<TName extends string = string>\n\timplements Construct<TName, CacheClient>\n{\n\treadonly id: TName;\n\treadonly service: Service<Uncapitalize<TName>, CacheClient>;\n\n\t/**\n\t * Declared once and read by both `declare()` and `connect()`, so the key the\n\t * target publishes and the key the client reads cannot drift.\n\t */\n\tprivate readonly key: string;\n\n\tconstructor(\n\t\tid: ConstructName<TName>,\n\t\tprivate readonly options: CacheOptions = {},\n\t) {\n\t\tconst canonical = canonicalId(id as string);\n\n\t\tthis.id = canonical as TName;\n\t\tthis.key = provideKey(canonical, 'url');\n\n\t\t// A field, not a getter: consumers cache services by object identity.\n\t\tthis.service = {\n\t\t\tserviceName: serviceKey(canonical) as Uncapitalize<TName>,\n\t\t\tregister: (options) => this.connect(options),\n\t\t};\n\t}\n\n\tdeclare(): Declaration[] {\n\t\treturn [\n\t\t\t{\n\t\t\t\tkind: 'cache',\n\t\t\t\tid: this.id,\n\t\t\t\t...(this.options.of ? { of: this.options.of } : {}),\n\t\t\t\t...(this.options.table ? { table: this.options.table } : {}),\n\t\t\t\tprovides: [this.key],\n\t\t\t},\n\t\t];\n\t}\n\n\t/**\n\t * Builds the client from the single URL the target supplied.\n\t *\n\t * Any credential travels in that URL's userinfo rather than in a second key,\n\t * for the same reason a Postgres password does: an address and the thing that\n\t * opens it are one fact, and splitting them is one more thing to keep in step.\n\t *\n\t * The scheme selects the driver, so this construct imports no provider and\n\t * an app that caches in Postgres never resolves a Redis client. Whoever\n\t * assembles the application registers the drivers its target needs.\n\t */\n\tprivate async connect({\n\t\tenvParser,\n\t}: ServiceRegisterOptions): Promise<CacheClient> {\n\t\tconst { url } = envParser\n\t\t\t.create((get) => ({ url: get(this.key).string() }))\n\t\t\t.parse();\n\n\t\t// Loaded here, not at the top: a database's `.cache()` and the test\n\t\t// harness name this construct, and neither may need the package until\n\t\t// a cache is actually opened.\n\t\tconst { createCacheClient } = await loadCache();\n\t\treturn createCacheClient(url);\n\t}\n}\n"],"mappings":";;;;AA2CA,IAAa,QAAb,MAEA;CAYmB;CAXlB;CACA;;;;;CAMA;CAEA,YACC,IACA,UAAyC,CAAC,GACzC;EADgB,KAAA,UAAA;EAEjB,MAAM,aAAA,GAAYA,oBAAAA,YAAAA,CAAY,EAAY;EAE1C,KAAK,KAAK;EACV,KAAK,OAAA,GAAMC,oBAAAA,WAAAA,CAAW,WAAW,KAAK;EAGtC,KAAK,UAAU;GACd,cAAA,GAAaC,oBAAAA,WAAAA,CAAW,SAAS;GACjC,WAAW,YAAY,KAAK,QAAQ,OAAO;EAC5C;CACD;CAEA,UAAyB;EACxB,OAAO,CACN;GACC,MAAM;GACN,IAAI,KAAK;GACT,GAAI,KAAK,QAAQ,KAAK,EAAE,IAAI,KAAK,QAAQ,GAAG,IAAI,CAAC;GACjD,GAAI,KAAK,QAAQ,QAAQ,EAAE,OAAO,KAAK,QAAQ,MAAM,IAAI,CAAC;GAC1D,UAAU,CAAC,KAAK,GAAG;EACpB,CACD;CACD;;;;;;;;;;;;CAaA,MAAc,QAAQ,EACrB,aACgD;EAChD,MAAM,EAAE,QAAQ,UACd,QAAQ,SAAS,EAAE,KAAK,IAAI,KAAK,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,CAClD,MAAM;EAKR,MAAM,EAAE,sBAAsB,MAAMC,sBAAAA,UAAU;EAC9C,OAAO,kBAAkB,GAAG;CAC7B;AACD"}
1
+ {"version":3,"file":"cache.cjs","names":["canonicalId","providedKeyFor","serviceKey","loadCache"],"sources":["../src/cache.ts"],"sourcesContent":["/**\n * `Cache` — a declared key/value cache.\n *\n * The same three-package meeting point as `ObjectStorage` and `Email`: it\n * implements the construct contract, derives its env key through\n * `@geekmidas/manifest`, and hands back a `@geekmidas/cache` client.\n *\n * It names no provider — and unlike `Email`, it cannot name one protocol\n * either. Every mail backend speaks SMTP, so an `smtp://` URL is true of all of\n * them; cache backends genuinely differ, because Upstash speaks HTTP, a Redis\n * speaks its wire protocol, and a table in Postgres speaks SQL. So the scheme in\n * the URL picks the driver, exactly as it does for object storage, and which\n * drivers exist is the generated entry point's decision.\n *\n * The backend is chosen at deploy, not here. An app caching in Postgres and an\n * app caching in Upstash are the same application code.\n */\n\nimport type { Cache as CacheClient } from '@geekmidas/cache';\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 { Construct } from './construct-interface';\nimport { loadCache } from './optionalPeers';\n\nexport interface CacheOptions {\n\t/**\n\t * The database this cache lives in.\n\t *\n\t * Set by `database.cache()` rather than written by hand — the point of the\n\t * method is that the parent's id comes from the parent rather than from a\n\t * string somebody has to keep in step.\n\t */\n\tof?: string;\n\t/** The table entries are kept in. Defaults to `cache`. */\n\ttable?: string;\n}\n\nexport class Cache<TName extends string = string>\n\timplements Construct<TName, CacheClient>\n{\n\treadonly id: TName;\n\treadonly service: Service<Uncapitalize<TName>, CacheClient>;\n\n\t/**\n\t * Declared once and read by both `declare()` and `connect()`, so the key the\n\t * target publishes and the key the client reads cannot drift.\n\t */\n\tprivate readonly key: string;\n\n\tconstructor(\n\t\tid: ConstructName<TName>,\n\t\tprivate readonly options: CacheOptions = {},\n\t) {\n\t\tconst canonical = canonicalId(id as string);\n\n\t\tthis.id = canonical as TName;\n\t\tthis.key = providedKeyFor(canonical, 'cache', 'url');\n\n\t\t// A field, not a getter: consumers cache services by object identity.\n\t\tthis.service = {\n\t\t\tserviceName: serviceKey(canonical) as Uncapitalize<TName>,\n\t\t\tregister: (options) => this.connect(options),\n\t\t};\n\t}\n\n\tdeclare(): Declaration[] {\n\t\treturn [\n\t\t\t{\n\t\t\t\tkind: 'cache',\n\t\t\t\tid: this.id,\n\t\t\t\t...(this.options.of ? { of: this.options.of } : {}),\n\t\t\t\t...(this.options.table ? { table: this.options.table } : {}),\n\t\t\t\tprovides: [this.key],\n\t\t\t},\n\t\t];\n\t}\n\n\t/**\n\t * Builds the client from the single URL the target supplied.\n\t *\n\t * Any credential travels in that URL's userinfo rather than in a second key,\n\t * for the same reason a Postgres password does: an address and the thing that\n\t * opens it are one fact, and splitting them is one more thing to keep in step.\n\t *\n\t * The scheme selects the driver, so this construct imports no provider and\n\t * an app that caches in Postgres never resolves a Redis client. Whoever\n\t * assembles the application registers the drivers its target needs.\n\t */\n\tprivate async connect({\n\t\tenvParser,\n\t}: ServiceRegisterOptions): Promise<CacheClient> {\n\t\tconst { url } = envParser\n\t\t\t.create((get) => ({ url: get(this.key).string() }))\n\t\t\t.parse();\n\n\t\t// Loaded here, not at the top: a database's `.cache()` and the test\n\t\t// harness name this construct, and neither may need the package until\n\t\t// a cache is actually opened.\n\t\tconst { createCacheClient } = await loadCache();\n\t\treturn createCacheClient(url);\n\t}\n}\n"],"mappings":";;;;AA2CA,IAAa,QAAb,MAEA;CAYmB;CAXlB;CACA;;;;;CAMA;CAEA,YACC,IACA,UAAyC,CAAC,GACzC;EADgB,KAAA,UAAA;EAEjB,MAAM,aAAA,GAAYA,oBAAAA,YAAAA,CAAY,EAAY;EAE1C,KAAK,KAAK;EACV,KAAK,OAAA,GAAMC,oBAAAA,eAAAA,CAAe,WAAW,SAAS,KAAK;EAGnD,KAAK,UAAU;GACd,cAAA,GAAaC,oBAAAA,WAAAA,CAAW,SAAS;GACjC,WAAW,YAAY,KAAK,QAAQ,OAAO;EAC5C;CACD;CAEA,UAAyB;EACxB,OAAO,CACN;GACC,MAAM;GACN,IAAI,KAAK;GACT,GAAI,KAAK,QAAQ,KAAK,EAAE,IAAI,KAAK,QAAQ,GAAG,IAAI,CAAC;GACjD,GAAI,KAAK,QAAQ,QAAQ,EAAE,OAAO,KAAK,QAAQ,MAAM,IAAI,CAAC;GAC1D,UAAU,CAAC,KAAK,GAAG;EACpB,CACD;CACD;;;;;;;;;;;;CAaA,MAAc,QAAQ,EACrB,aACgD;EAChD,MAAM,EAAE,QAAQ,UACd,QAAQ,SAAS,EAAE,KAAK,IAAI,KAAK,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,CAClD,MAAM;EAKR,MAAM,EAAE,sBAAsB,MAAMC,sBAAAA,UAAU;EAC9C,OAAO,kBAAkB,GAAG;CAC7B;AACD"}
package/dist/cache.d.cts CHANGED
@@ -1,2 +1,2 @@
1
- import { n as CacheOptions, t as Cache } from "./cache-CQjMNPrC.cjs";
1
+ import { n as CacheOptions, t as Cache } from "./cache-CW-sArzS.cjs";
2
2
  export { Cache, CacheOptions };
package/dist/cache.d.mts CHANGED
@@ -1,2 +1,2 @@
1
- import { n as CacheOptions, t as Cache } from "./cache-CCHcO9Oo.mjs";
1
+ import { n as CacheOptions, t as Cache } from "./cache-0VoeOTF9.mjs";
2
2
  export { Cache, CacheOptions };
package/dist/cache.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  import { o as loadCache } from "./optionalPeers-D7Wt6dnF.mjs";
2
- import { canonicalId, provideKey, serviceKey } from "@geekmidas/manifest";
2
+ import { canonicalId, providedKeyFor, serviceKey } from "@geekmidas/manifest";
3
3
  //#region src/cache.ts
4
4
  var Cache = class {
5
5
  options;
@@ -14,7 +14,7 @@ var Cache = class {
14
14
  this.options = options;
15
15
  const canonical = canonicalId(id);
16
16
  this.id = canonical;
17
- this.key = provideKey(canonical, "url");
17
+ this.key = providedKeyFor(canonical, "cache", "url");
18
18
  this.service = {
19
19
  serviceName: serviceKey(canonical),
20
20
  register: (options) => this.connect(options)
@@ -1 +1 @@
1
- {"version":3,"file":"cache.mjs","names":[],"sources":["../src/cache.ts"],"sourcesContent":["/**\n * `Cache` — a declared key/value cache.\n *\n * The same three-package meeting point as `ObjectStorage` and `Email`: it\n * implements the construct contract, derives its env key through\n * `@geekmidas/manifest`, and hands back a `@geekmidas/cache` client.\n *\n * It names no provider — and unlike `Email`, it cannot name one protocol\n * either. Every mail backend speaks SMTP, so an `smtp://` URL is true of all of\n * them; cache backends genuinely differ, because Upstash speaks HTTP, a Redis\n * speaks its wire protocol, and a table in Postgres speaks SQL. So the scheme in\n * the URL picks the driver, exactly as it does for object storage, and which\n * drivers exist is the generated entry point's decision.\n *\n * The backend is chosen at deploy, not here. An app caching in Postgres and an\n * app caching in Upstash are the same application code.\n */\n\nimport type { Cache as CacheClient } from '@geekmidas/cache';\nimport {\n\ttype ConstructName,\n\tcanonicalId,\n\ttype Declaration,\n\tprovideKey,\n\tserviceKey,\n} from '@geekmidas/manifest';\nimport type { Service, ServiceRegisterOptions } from '@geekmidas/services';\nimport type { Construct } from './construct-interface';\nimport { loadCache } from './optionalPeers';\n\nexport interface CacheOptions {\n\t/**\n\t * The database this cache lives in.\n\t *\n\t * Set by `database.cache()` rather than written by hand — the point of the\n\t * method is that the parent's id comes from the parent rather than from a\n\t * string somebody has to keep in step.\n\t */\n\tof?: string;\n\t/** The table entries are kept in. Defaults to `cache`. */\n\ttable?: string;\n}\n\nexport class Cache<TName extends string = string>\n\timplements Construct<TName, CacheClient>\n{\n\treadonly id: TName;\n\treadonly service: Service<Uncapitalize<TName>, CacheClient>;\n\n\t/**\n\t * Declared once and read by both `declare()` and `connect()`, so the key the\n\t * target publishes and the key the client reads cannot drift.\n\t */\n\tprivate readonly key: string;\n\n\tconstructor(\n\t\tid: ConstructName<TName>,\n\t\tprivate readonly options: CacheOptions = {},\n\t) {\n\t\tconst canonical = canonicalId(id as string);\n\n\t\tthis.id = canonical as TName;\n\t\tthis.key = provideKey(canonical, 'url');\n\n\t\t// A field, not a getter: consumers cache services by object identity.\n\t\tthis.service = {\n\t\t\tserviceName: serviceKey(canonical) as Uncapitalize<TName>,\n\t\t\tregister: (options) => this.connect(options),\n\t\t};\n\t}\n\n\tdeclare(): Declaration[] {\n\t\treturn [\n\t\t\t{\n\t\t\t\tkind: 'cache',\n\t\t\t\tid: this.id,\n\t\t\t\t...(this.options.of ? { of: this.options.of } : {}),\n\t\t\t\t...(this.options.table ? { table: this.options.table } : {}),\n\t\t\t\tprovides: [this.key],\n\t\t\t},\n\t\t];\n\t}\n\n\t/**\n\t * Builds the client from the single URL the target supplied.\n\t *\n\t * Any credential travels in that URL's userinfo rather than in a second key,\n\t * for the same reason a Postgres password does: an address and the thing that\n\t * opens it are one fact, and splitting them is one more thing to keep in step.\n\t *\n\t * The scheme selects the driver, so this construct imports no provider and\n\t * an app that caches in Postgres never resolves a Redis client. Whoever\n\t * assembles the application registers the drivers its target needs.\n\t */\n\tprivate async connect({\n\t\tenvParser,\n\t}: ServiceRegisterOptions): Promise<CacheClient> {\n\t\tconst { url } = envParser\n\t\t\t.create((get) => ({ url: get(this.key).string() }))\n\t\t\t.parse();\n\n\t\t// Loaded here, not at the top: a database's `.cache()` and the test\n\t\t// harness name this construct, and neither may need the package until\n\t\t// a cache is actually opened.\n\t\tconst { createCacheClient } = await loadCache();\n\t\treturn createCacheClient(url);\n\t}\n}\n"],"mappings":";;;AA2CA,IAAa,QAAb,MAEA;CAYmB;CAXlB;CACA;;;;;CAMA;CAEA,YACC,IACA,UAAyC,CAAC,GACzC;EADgB,KAAA,UAAA;EAEjB,MAAM,YAAY,YAAY,EAAY;EAE1C,KAAK,KAAK;EACV,KAAK,MAAM,WAAW,WAAW,KAAK;EAGtC,KAAK,UAAU;GACd,aAAa,WAAW,SAAS;GACjC,WAAW,YAAY,KAAK,QAAQ,OAAO;EAC5C;CACD;CAEA,UAAyB;EACxB,OAAO,CACN;GACC,MAAM;GACN,IAAI,KAAK;GACT,GAAI,KAAK,QAAQ,KAAK,EAAE,IAAI,KAAK,QAAQ,GAAG,IAAI,CAAC;GACjD,GAAI,KAAK,QAAQ,QAAQ,EAAE,OAAO,KAAK,QAAQ,MAAM,IAAI,CAAC;GAC1D,UAAU,CAAC,KAAK,GAAG;EACpB,CACD;CACD;;;;;;;;;;;;CAaA,MAAc,QAAQ,EACrB,aACgD;EAChD,MAAM,EAAE,QAAQ,UACd,QAAQ,SAAS,EAAE,KAAK,IAAI,KAAK,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,CAClD,MAAM;EAKR,MAAM,EAAE,sBAAsB,MAAM,UAAU;EAC9C,OAAO,kBAAkB,GAAG;CAC7B;AACD"}
1
+ {"version":3,"file":"cache.mjs","names":[],"sources":["../src/cache.ts"],"sourcesContent":["/**\n * `Cache` — a declared key/value cache.\n *\n * The same three-package meeting point as `ObjectStorage` and `Email`: it\n * implements the construct contract, derives its env key through\n * `@geekmidas/manifest`, and hands back a `@geekmidas/cache` client.\n *\n * It names no provider — and unlike `Email`, it cannot name one protocol\n * either. Every mail backend speaks SMTP, so an `smtp://` URL is true of all of\n * them; cache backends genuinely differ, because Upstash speaks HTTP, a Redis\n * speaks its wire protocol, and a table in Postgres speaks SQL. So the scheme in\n * the URL picks the driver, exactly as it does for object storage, and which\n * drivers exist is the generated entry point's decision.\n *\n * The backend is chosen at deploy, not here. An app caching in Postgres and an\n * app caching in Upstash are the same application code.\n */\n\nimport type { Cache as CacheClient } from '@geekmidas/cache';\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 { Construct } from './construct-interface';\nimport { loadCache } from './optionalPeers';\n\nexport interface CacheOptions {\n\t/**\n\t * The database this cache lives in.\n\t *\n\t * Set by `database.cache()` rather than written by hand — the point of the\n\t * method is that the parent's id comes from the parent rather than from a\n\t * string somebody has to keep in step.\n\t */\n\tof?: string;\n\t/** The table entries are kept in. Defaults to `cache`. */\n\ttable?: string;\n}\n\nexport class Cache<TName extends string = string>\n\timplements Construct<TName, CacheClient>\n{\n\treadonly id: TName;\n\treadonly service: Service<Uncapitalize<TName>, CacheClient>;\n\n\t/**\n\t * Declared once and read by both `declare()` and `connect()`, so the key the\n\t * target publishes and the key the client reads cannot drift.\n\t */\n\tprivate readonly key: string;\n\n\tconstructor(\n\t\tid: ConstructName<TName>,\n\t\tprivate readonly options: CacheOptions = {},\n\t) {\n\t\tconst canonical = canonicalId(id as string);\n\n\t\tthis.id = canonical as TName;\n\t\tthis.key = providedKeyFor(canonical, 'cache', 'url');\n\n\t\t// A field, not a getter: consumers cache services by object identity.\n\t\tthis.service = {\n\t\t\tserviceName: serviceKey(canonical) as Uncapitalize<TName>,\n\t\t\tregister: (options) => this.connect(options),\n\t\t};\n\t}\n\n\tdeclare(): Declaration[] {\n\t\treturn [\n\t\t\t{\n\t\t\t\tkind: 'cache',\n\t\t\t\tid: this.id,\n\t\t\t\t...(this.options.of ? { of: this.options.of } : {}),\n\t\t\t\t...(this.options.table ? { table: this.options.table } : {}),\n\t\t\t\tprovides: [this.key],\n\t\t\t},\n\t\t];\n\t}\n\n\t/**\n\t * Builds the client from the single URL the target supplied.\n\t *\n\t * Any credential travels in that URL's userinfo rather than in a second key,\n\t * for the same reason a Postgres password does: an address and the thing that\n\t * opens it are one fact, and splitting them is one more thing to keep in step.\n\t *\n\t * The scheme selects the driver, so this construct imports no provider and\n\t * an app that caches in Postgres never resolves a Redis client. Whoever\n\t * assembles the application registers the drivers its target needs.\n\t */\n\tprivate async connect({\n\t\tenvParser,\n\t}: ServiceRegisterOptions): Promise<CacheClient> {\n\t\tconst { url } = envParser\n\t\t\t.create((get) => ({ url: get(this.key).string() }))\n\t\t\t.parse();\n\n\t\t// Loaded here, not at the top: a database's `.cache()` and the test\n\t\t// harness name this construct, and neither may need the package until\n\t\t// a cache is actually opened.\n\t\tconst { createCacheClient } = await loadCache();\n\t\treturn createCacheClient(url);\n\t}\n}\n"],"mappings":";;;AA2CA,IAAa,QAAb,MAEA;CAYmB;CAXlB;CACA;;;;;CAMA;CAEA,YACC,IACA,UAAyC,CAAC,GACzC;EADgB,KAAA,UAAA;EAEjB,MAAM,YAAY,YAAY,EAAY;EAE1C,KAAK,KAAK;EACV,KAAK,MAAM,eAAe,WAAW,SAAS,KAAK;EAGnD,KAAK,UAAU;GACd,aAAa,WAAW,SAAS;GACjC,WAAW,YAAY,KAAK,QAAQ,OAAO;EAC5C;CACD;CAEA,UAAyB;EACxB,OAAO,CACN;GACC,MAAM;GACN,IAAI,KAAK;GACT,GAAI,KAAK,QAAQ,KAAK,EAAE,IAAI,KAAK,QAAQ,GAAG,IAAI,CAAC;GACjD,GAAI,KAAK,QAAQ,QAAQ,EAAE,OAAO,KAAK,QAAQ,MAAM,IAAI,CAAC;GAC1D,UAAU,CAAC,KAAK,GAAG;EACpB,CACD;CACD;;;;;;;;;;;;CAaA,MAAc,QAAQ,EACrB,aACgD;EAChD,MAAM,EAAE,QAAQ,UACd,QAAQ,SAAS,EAAE,KAAK,IAAI,KAAK,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,CAClD,MAAM;EAKR,MAAM,EAAE,sBAAsB,MAAM,UAAU;EAC9C,OAAO,kBAAkB,GAAG;CAC7B;AACD"}
@@ -1,6 +1,6 @@
1
- import { Declaration, Dependency } from "@geekmidas/manifest";
2
- import { Service, ServiceRegisterOptions } from "@geekmidas/services";
3
1
  import { EnvironmentParser } from "@geekmidas/envkit";
2
+ import { Service, ServiceRegisterOptions } from "@geekmidas/services";
3
+ import { Declaration, Dependency } from "@geekmidas/manifest";
4
4
  //#region src/construct-interface.d.ts
5
5
  /**
6
6
  * @typeParam TName - the construct's canonical id, PascalCase. Keeping it a
@@ -68,6 +68,22 @@ interface Authenticator<TSession = unknown> extends Declarable {
68
68
  * @throws {NotAConstruct} when the value declares nothing under its own id.
69
69
  */
70
70
  declare function edgeTo(construct: Declarable): Dependency;
71
+ /**
72
+ * A construct whose public half is a node of its own: what a site's or a
73
+ * mobile app's plain edge points at instead of the construct itself.
74
+ *
75
+ * A `FileServer` is the one: its own node is the bucket, which presigns and
76
+ * writes, and a frontend that only shows the objects needs the address they
77
+ * are served on and nothing that can write to them.
78
+ */
79
+ interface HasPublicFace {
80
+ readonly publicFace: Declarable;
81
+ }
82
+ /**
83
+ * The edge a frontend — a site or a mobile app — has to a construct: its
84
+ * public face where it has one, the construct itself otherwise.
85
+ */
86
+ declare function frontendEdgeTo(construct: Declarable): Dependency;
71
87
  /** What consuming a construct hands you. */
72
88
  type Infer<C> = C extends Construct<string, infer TClient> ? TClient : never;
73
89
  /** A construct's canonical id. */
@@ -163,5 +179,5 @@ declare function serviceOf<TName extends string, TClient>(source: Consumable<TNa
163
179
  */
164
180
  declare function publicUrl(options: ServiceRegisterOptions, key: string): string;
165
181
  //#endregion
166
- export { Infer as a, ServicesOf as c, idsOf as d, isConsumable as f, servicesOf as h, Declarable as i, databaseEdges as l, serviceOf as m, Construct as n, NameOf as o, publicUrl as p, Consumable as r, NotAConstruct as s, Authenticator as t, edgeTo as u };
167
- //# sourceMappingURL=construct-interface-CSA9VeWM.d.mts.map
182
+ export { servicesOf as _, HasPublicFace as a, NotAConstruct as c, edgeTo as d, frontendEdgeTo as f, serviceOf as g, publicUrl as h, Declarable as i, ServicesOf as l, isConsumable as m, Construct as n, Infer as o, idsOf as p, Consumable as r, NameOf as s, Authenticator as t, databaseEdges as u };
183
+ //# sourceMappingURL=construct-interface-DhbaONW2.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"construct-interface-DhbaONW2.d.cts","names":[],"sources":["../src/construct-interface.ts"],"mappings":";;;;;;;;;;;;;UA8BiB,UAAU,+BAA+B;;WAEhD,IAAI;;;;;;;;EASb,WAAW;;;;;;;;WASF,UAAU,mCAEhB,QAAQ,aAAa,QAAQ;;;;;;;;;;;UAYhB,WAAW;WAClB,IAAI;EACb,WAAW;;;;;;;;;;UAWK,cAAc,4BAA4B;EAC1D,OACC,SAAS,SACT,WAAW,wBACT,QAAQ;;;;;;;;;;;;;;iBAeI,OAAO,WAAW,aAAa;;;;;;;;;UAkB9B;WACP,YAAY;;;;;;iBAON,eAAe,WAAW,aAAa;;KAM3C,MAAM,KACjB,UAAU,wBAAwB,WAAW;;KAGlC,OAAO,KAClB,UAAU,gBAAgB,kBAAkB;;;;;;;;;;;UAY5B,WAAW,+BAA+B;WACjD,IAAI;WACJ,SAAS,QAAQ,aAAa,QAAQ;EAC/C,WAAW;;;;;;;;;;KAWA,WAAW,mBAAmB,mBACxC,WAAW,IAAI,EAAE;;;;;;;;iBAUH,iBAAiB,mBAAmB,cACnD,YAAY,IACV,WAAW;;;;;;;;;;iBAiBE,MACf,qBAAqB,cACrB;;;;;;;;;;;;;;iBAkBe,cACf;EACC;EACA;EACA,SAAS;EACT,mBAAmB;GAEpB;EACI;EAAuB;;;cAgBf,sBAAsB;WACb;EAArB,YAAqB;;;;;;;;;iBAqBN,aAAa,iBAAiB,SAAS;;;;;;;;iBAmBvC,UAAU,sBAAsB,SAC/C,QAAQ,WAAW,OAAO,WAAW,QAAQ,OAAO,WAClD,QAAQ,OAAO;;;;;iBAYF,UACf,SAAS,wBACT"}
@@ -1,6 +1,6 @@
1
- import { EnvironmentParser } from "@geekmidas/envkit";
2
- import { Service, ServiceRegisterOptions } from "@geekmidas/services";
3
1
  import { Declaration, Dependency } from "@geekmidas/manifest";
2
+ import { Service, ServiceRegisterOptions } from "@geekmidas/services";
3
+ import { EnvironmentParser } from "@geekmidas/envkit";
4
4
  //#region src/construct-interface.d.ts
5
5
  /**
6
6
  * @typeParam TName - the construct's canonical id, PascalCase. Keeping it a
@@ -68,6 +68,22 @@ interface Authenticator<TSession = unknown> extends Declarable {
68
68
  * @throws {NotAConstruct} when the value declares nothing under its own id.
69
69
  */
70
70
  declare function edgeTo(construct: Declarable): Dependency;
71
+ /**
72
+ * A construct whose public half is a node of its own: what a site's or a
73
+ * mobile app's plain edge points at instead of the construct itself.
74
+ *
75
+ * A `FileServer` is the one: its own node is the bucket, which presigns and
76
+ * writes, and a frontend that only shows the objects needs the address they
77
+ * are served on and nothing that can write to them.
78
+ */
79
+ interface HasPublicFace {
80
+ readonly publicFace: Declarable;
81
+ }
82
+ /**
83
+ * The edge a frontend — a site or a mobile app — has to a construct: its
84
+ * public face where it has one, the construct itself otherwise.
85
+ */
86
+ declare function frontendEdgeTo(construct: Declarable): Dependency;
71
87
  /** What consuming a construct hands you. */
72
88
  type Infer<C> = C extends Construct<string, infer TClient> ? TClient : never;
73
89
  /** A construct's canonical id. */
@@ -163,5 +179,5 @@ declare function serviceOf<TName extends string, TClient>(source: Consumable<TNa
163
179
  */
164
180
  declare function publicUrl(options: ServiceRegisterOptions, key: string): string;
165
181
  //#endregion
166
- export { Infer as a, ServicesOf as c, idsOf as d, isConsumable as f, servicesOf as h, Declarable as i, databaseEdges as l, serviceOf as m, Construct as n, NameOf as o, publicUrl as p, Consumable as r, NotAConstruct as s, Authenticator as t, edgeTo as u };
167
- //# sourceMappingURL=construct-interface-DugP0E5q.d.cts.map
182
+ export { servicesOf as _, HasPublicFace as a, NotAConstruct as c, edgeTo as d, frontendEdgeTo as f, serviceOf as g, publicUrl as h, Declarable as i, ServicesOf as l, isConsumable as m, Construct as n, Infer as o, idsOf as p, Consumable as r, NameOf as s, Authenticator as t, databaseEdges as u };
183
+ //# sourceMappingURL=construct-interface-DxfkFxkl.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"construct-interface-DxfkFxkl.d.mts","names":[],"sources":["../src/construct-interface.ts"],"mappings":";;;;;;;;;;;;;UA8BiB,UAAU,+BAA+B;;WAEhD,IAAI;;;;;;;;EASb,WAAW;;;;;;;;WASF,UAAU,mCAEhB,QAAQ,aAAa,QAAQ;;;;;;;;;;;UAYhB,WAAW;WAClB,IAAI;EACb,WAAW;;;;;;;;;;UAWK,cAAc,4BAA4B;EAC1D,OACC,SAAS,SACT,WAAW,wBACT,QAAQ;;;;;;;;;;;;;;iBAeI,OAAO,WAAW,aAAa;;;;;;;;;UAkB9B;WACP,YAAY;;;;;;iBAON,eAAe,WAAW,aAAa;;KAM3C,MAAM,KACjB,UAAU,wBAAwB,WAAW;;KAGlC,OAAO,KAClB,UAAU,gBAAgB,kBAAkB;;;;;;;;;;;UAY5B,WAAW,+BAA+B;WACjD,IAAI;WACJ,SAAS,QAAQ,aAAa,QAAQ;EAC/C,WAAW;;;;;;;;;;KAWA,WAAW,mBAAmB,mBACxC,WAAW,IAAI,EAAE;;;;;;;;iBAUH,iBAAiB,mBAAmB,cACnD,YAAY,IACV,WAAW;;;;;;;;;;iBAiBE,MACf,qBAAqB,cACrB;;;;;;;;;;;;;;iBAkBe,cACf;EACC;EACA;EACA,SAAS;EACT,mBAAmB;GAEpB;EACI;EAAuB;;;cAgBf,sBAAsB;WACb;EAArB,YAAqB;;;;;;;;;iBAqBN,aAAa,iBAAiB,SAAS;;;;;;;;iBAmBvC,UAAU,sBAAsB,SAC/C,QAAQ,WAAW,OAAO,WAAW,QAAQ,OAAO,WAClD,QAAQ,OAAO;;;;;iBAYF,UACf,SAAS,wBACT"}
@@ -21,6 +21,14 @@ function edgeTo(construct) {
21
21
  };
22
22
  }
23
23
  /**
24
+ * The edge a frontend — a site or a mobile app — has to a construct: its
25
+ * public face where it has one, the construct itself otherwise.
26
+ */
27
+ function frontendEdgeTo(construct) {
28
+ const face = construct.publicFace;
29
+ return edgeTo(face ?? construct);
30
+ }
31
+ /**
24
32
  * The services of a list of constructs, at runtime.
25
33
  *
26
34
  * @throws {NotAConstruct} when handed something else. The type already refuses
@@ -113,6 +121,7 @@ function publicUrl(options, key) {
113
121
  exports.NotAConstruct = NotAConstruct;
114
122
  exports.databaseEdges = databaseEdges;
115
123
  exports.edgeTo = edgeTo;
124
+ exports.frontendEdgeTo = frontendEdgeTo;
116
125
  exports.idsOf = idsOf;
117
126
  exports.isConsumable = isConsumable;
118
127
  exports.publicUrl = publicUrl;
@@ -1 +1 @@
1
- {"version":3,"file":"construct-interface.cjs","names":[],"sources":["../src/construct-interface.ts"],"sourcesContent":["/**\n * The construct contract.\n *\n * A construct is three things at once — an infrastructure requirement at build\n * time, a runtime capability, and something other code can consume — which is\n * what forces exactly these three members.\n *\n * An **interface**, not a base class: `Endpoint`, `Cron`, `Queue`, and `Topic`\n * can satisfy it without inheritance surgery, a lifted `Service` can satisfy it\n * as a plain object, and `.dependsOn()` gets its enforcement structurally — a\n * `Service` (`{ serviceName, register }`) simply does not match\n * `{ id, declare, service }`, with no `instanceof` anywhere.\n *\n * Lives in its own module while the existing abstract `Construct` class is\n * still in use; it takes that name once the class is gone.\n */\n\nimport type { EnvironmentParser } from '@geekmidas/envkit';\nimport type { Declaration, Dependency } from '@geekmidas/manifest';\nimport type { Service, ServiceRegisterOptions } from '@geekmidas/services';\n\n/**\n * @typeParam TName - the construct's canonical id, PascalCase. Keeping it a\n * literal is what lets the service key be `Uncapitalize<TName>` — a TypeScript\n * intrinsic, so no custom transform needs a runtime twin.\n * @typeParam TClient - what consuming this construct hands you. `never` means it\n * owns no address and cannot be consumed: a `Cron` is fired by a schedule and a\n * `Subscriber` is reached through its topic, so `.dependsOn()` on either is a\n * compile error rather than a stub that throws.\n */\nexport interface Construct<TName extends string = string, TClient = never> {\n\t/** Canonical, PascalCase, unique within the manifest. */\n\treadonly id: TName;\n\n\t/**\n\t * The build-time face: what this construct contributes to the manifest.\n\t *\n\t * Returns an array because some constructs contribute more than one node — a\n\t * queue declares the queue and its worker, a database declares its migrator\n\t * and seeder. Most return one.\n\t */\n\tdeclare(): Declaration[];\n\n\t/**\n\t * The consumable face — the address this construct owns, as a client.\n\t *\n\t * A field assigned once rather than a getter. `Construct.getEnvironment`\n\t * and `ServiceDiscovery` cache by service *object*, so a getter returning a\n\t * fresh literal on every access would never hit either cache.\n\t */\n\treadonly service: [TClient] extends [never]\n\t\t? never\n\t\t: Service<Uncapitalize<TName>, TClient>;\n}\n\n/**\n * The build-time face alone — an id and what it contributes to the manifest.\n *\n * Weaker than {@link Consumable} on purpose. An edge is not always an\n * injection: a site depending on an API needs that API's *address at build\n * time* and has no service record to put a client into, so requiring one would\n * make the weakest kind of edge impossible to express with the strongest\n * interface. Discovery asks this same question and nothing more.\n */\nexport interface Declarable<TName extends string = string> {\n\treadonly id: TName;\n\tdeclare(): Declaration[];\n}\n\n/**\n * A construct that authenticates requests — what `RestApi.auth()` takes.\n *\n * `verify` is the one thing every provider shares: given a request's headers,\n * whose request is it — the session, or `null` when there is none. Whether the\n * provider is a server mounted beside the API, deployed elsewhere, or an issuer\n * somebody else runs is its own business; a surface only ever asks this.\n */\nexport interface Authenticator<TSession = unknown> extends Declarable {\n\tverify(\n\t\theaders: Headers,\n\t\tenvParser: EnvironmentParser<{}>,\n\t): Promise<TSession | null>;\n}\n\n/**\n * The edge that points at a construct.\n *\n * A construct's *canonical* node is the one carrying its own id — the others are\n * things it owns rather than things it is, like the signing secret beside an\n * auth server — so the kind an edge records is read off that node instead of\n * being written down beside it. Hand-written kinds are the same fact stated\n * twice, and the copy is what goes stale when a construct changes what it\n * declares.\n *\n * @throws {NotAConstruct} when the value declares nothing under its own id.\n */\nexport function edgeTo(construct: Declarable): Dependency {\n\tconst canonical = construct\n\t\t.declare()\n\t\t.find((declaration) => declaration.id === construct.id);\n\n\tif (!canonical) throw new NotAConstruct(construct);\n\n\treturn { target: construct.id, kind: canonical.kind };\n}\n\n/** What consuming a construct hands you. */\nexport type Infer<C> =\n\tC extends Construct<string, infer TClient> ? TClient : never;\n\n/** A construct's canonical id. */\nexport type NameOf<C> =\n\tC extends Construct<infer TName, unknown> ? TName : never;\n\n/**\n * What `.dependsOn([…])` accepts: a construct that owns a client.\n *\n * Structural, and deliberately narrower than {@link Construct} — it is the\n * face a *consumer* needs, so the builders can accept a database, a bucket, a\n * mail sender, a queue, or a topic without importing any of them. A plain\n * `Service` is not one of these, which is the point: constructs-only confines\n * env sniffing to `.services()` and the explicit lift, so retiring that method\n * retires implicit inference with it.\n */\nexport interface Consumable<TName extends string = string, TClient = unknown> {\n\treadonly id: TName;\n\treadonly service: Service<Uncapitalize<TName>, TClient>;\n\tdeclare(): Declaration[];\n}\n\n/**\n * The services a list of constructs dissolves into.\n *\n * A mapped tuple, so `[db, uploads]` types as `[Service<'orders', Kysely<DB>>,\n * Service<'uploads', StorageClient>]` and the handler's service record gains\n * both keys — the same machinery `.services()` already uses, which is why\n * `dependsOn` needs no type plumbing of its own.\n */\nexport type ServicesOf<T extends readonly Consumable[]> = {\n\t[K in keyof T]: T[K]['service'];\n};\n\n/**\n * The services of a list of constructs, at runtime.\n *\n * @throws {NotAConstruct} when handed something else. The type already refuses\n * it, but a JavaScript caller gets no such warning, and a `Service` slipping\n * through would fail later as an undefined key in the handler.\n */\nexport function servicesOf<const T extends readonly Consumable[]>(\n\tconstructs: T,\n): ServicesOf<T> {\n\treturn constructs.map((construct) => {\n\t\tif (!isConsumable(construct)) throw new NotAConstruct(construct);\n\n\t\treturn construct.service;\n\t}) as ServicesOf<T>;\n}\n\n/**\n * The other half of `servicesOf`: the same edge, as the manifest records it.\n *\n * `.dependsOn()` used to keep only the services, which is what a handler runs\n * with — and an id cannot be recovered from a service name reliably, so the\n * edges were gone by the time the build could read them. Both halves are taken\n * from one call now, and `existing` is folded in so repeated `.dependsOn()`\n * calls accumulate the way `.services()` already does.\n */\nexport function idsOf(\n\tconstructs: readonly Consumable[],\n\texisting: readonly string[] = [],\n): string[] {\n\treturn [...new Set([...existing, ...constructs.map(({ id }) => id)])];\n}\n\n/**\n * The edges after `.database(source)` names a builder's database.\n *\n * A database replaces the one before it — a worker's default, overridden by a\n * runnable that names its own — so the edge the previous one added goes with\n * it. Left behind, a Lambda built from a queue that moved to another database\n * would still be granted the worker's.\n *\n * Only an edge `.database()` added is removed, which is why it is returned as\n * `_databaseEdge` for the next call to read — and not even that one when\n * `.dependsOn()` has since named the same construct, since the handler still\n * reaches it through `services`.\n */\nexport function databaseEdges(\n\tcurrent: {\n\t\tconstructs: readonly string[];\n\t\tedge: string | undefined;\n\t\tservice: Service | undefined;\n\t\tservices: readonly Service[];\n\t},\n\tsource: unknown,\n): { _constructs: string[]; _databaseEdge: string | undefined } {\n\tconst stillDependedOn =\n\t\tcurrent.service !== undefined && current.services.includes(current.service);\n\tconst kept =\n\t\tcurrent.edge && !stillDependedOn\n\t\t\t? current.constructs.filter((id) => id !== current.edge)\n\t\t\t: [...current.constructs];\n\n\tif (!isConsumable(source) || kept.includes(source.id)) {\n\t\treturn { _constructs: kept, _databaseEdge: undefined };\n\t}\n\n\treturn { _constructs: [...kept, source.id], _databaseEdge: source.id };\n}\n\n/** Something that is not a construct was passed to `.dependsOn()`. */\nexport class NotAConstruct extends Error {\n\tconstructor(readonly value: unknown) {\n\t\tconst name =\n\t\t\ttypeof value === 'object' && value !== null && 'serviceName' in value\n\t\t\t\t? `the service '${String((value as { serviceName: unknown }).serviceName)}'`\n\t\t\t\t: `a ${typeof value}`;\n\n\t\tsuper(\n\t\t\t`.dependsOn() takes constructs, and was given ${name}. ` +\n\t\t\t\t`Pass it to .services([…]) instead.`,\n\t\t);\n\t\tthis.name = 'NotAConstruct';\n\t}\n}\n\n/**\n * Whether a value is a construct rather than a bare `Service`.\n *\n * Structural rather than `instanceof`: a construct from a second copy of\n * `@geekmidas/constructs` — a linked workspace, two versions in a lockfile — is\n * still a construct, and `instanceof` is exactly the check that says otherwise.\n */\nexport function isConsumable(value: unknown): value is Consumable {\n\tif (typeof value !== 'object' || value === null) return false;\n\n\tconst candidate = value as Partial<Consumable>;\n\n\treturn (\n\t\ttypeof candidate.id === 'string' &&\n\t\ttypeof candidate.declare === 'function' &&\n\t\ttypeof (candidate.service as Service | undefined)?.serviceName === 'string'\n\t);\n}\n\n/**\n * The service behind either face.\n *\n * `.database()` and the auditor slot take a construct now; they took a\n * `Service` before and still do, because not every hand-written service has a\n * construct to stand for it.\n */\nexport function serviceOf<TName extends string, TClient>(\n\tsource: Consumable<TName, TClient> | Service<TName, TClient>,\n): Service<TName, TClient> {\n\t// A construct's service key is `Uncapitalize<TName>` and the slot is typed\n\t// by `TName`; the two describe the same key, and only the cast says so.\n\treturn isConsumable(source)\n\t\t? (source.service as unknown as Service<TName, TClient>)\n\t\t: (source as Service<TName, TClient>);\n}\n\n/**\n * A surface's or a site's public address, read from its `<ID>_URL` — the\n * client a `RestApi` or a `StaticSite` hands whatever `.dependsOn()` it.\n */\nexport function publicUrl(\n\toptions: ServiceRegisterOptions,\n\tkey: string,\n): string {\n\treturn options.envParser.create((get) => ({ url: get(key).string() })).parse()\n\t\t.url;\n}\n"],"mappings":";;;;;;;;;;;;;;AAgGA,SAAgB,OAAO,WAAmC;CACzD,MAAM,YAAY,UAChB,QAAQ,CAAC,CACT,MAAM,gBAAgB,YAAY,OAAO,UAAU,EAAE;CAEvD,IAAI,CAAC,WAAW,MAAM,IAAI,cAAc,SAAS;CAEjD,OAAO;EAAE,QAAQ,UAAU;EAAI,MAAM,UAAU;CAAK;AACrD;;;;;;;;AA6CA,SAAgB,WACf,YACgB;CAChB,OAAO,WAAW,KAAK,cAAc;EACpC,IAAI,CAAC,aAAa,SAAS,GAAG,MAAM,IAAI,cAAc,SAAS;EAE/D,OAAO,UAAU;CAClB,CAAC;AACF;;;;;;;;;;AAWA,SAAgB,MACf,YACA,WAA8B,CAAC,GACpB;CACX,OAAO,CAAC,mBAAG,IAAI,IAAI,CAAC,GAAG,UAAU,GAAG,WAAW,KAAK,EAAE,SAAS,EAAE,CAAC,CAAC,CAAC;AACrE;;;;;;;;;;;;;;AAeA,SAAgB,cACf,SAMA,QAC+D;CAC/D,MAAM,kBACL,QAAQ,YAAY,KAAA,KAAa,QAAQ,SAAS,SAAS,QAAQ,OAAO;CAC3E,MAAM,OACL,QAAQ,QAAQ,CAAC,kBACd,QAAQ,WAAW,QAAQ,OAAO,OAAO,QAAQ,IAAI,IACrD,CAAC,GAAG,QAAQ,UAAU;CAE1B,IAAI,CAAC,aAAa,MAAM,KAAK,KAAK,SAAS,OAAO,EAAE,GACnD,OAAO;EAAE,aAAa;EAAM,eAAe,KAAA;CAAU;CAGtD,OAAO;EAAE,aAAa,CAAC,GAAG,MAAM,OAAO,EAAE;EAAG,eAAe,OAAO;CAAG;AACtE;;AAGA,IAAa,gBAAb,cAAmC,MAAM;CACnB;CAArB,YAAY,OAAyB;EACpC,MAAM,OACL,OAAO,UAAU,YAAY,UAAU,QAAQ,iBAAiB,QAC7D,gBAAgB,OAAQ,MAAmC,WAAW,EAAE,KACxE,KAAK,OAAO;EAEhB,MACC,gDAAgD,KAAK,qCAEtD;EAToB,KAAA,QAAA;EAUpB,KAAK,OAAO;CACb;AACD;;;;;;;;AASA,SAAgB,aAAa,OAAqC;CACjE,IAAI,OAAO,UAAU,YAAY,UAAU,MAAM,OAAO;CAExD,MAAM,YAAY;CAElB,OACC,OAAO,UAAU,OAAO,YACxB,OAAO,UAAU,YAAY,cAC7B,OAAQ,UAAU,SAAiC,gBAAgB;AAErE;;;;;;;;AASA,SAAgB,UACf,QAC0B;CAG1B,OAAO,aAAa,MAAM,IACtB,OAAO,UACP;AACL;;;;;AAMA,SAAgB,UACf,SACA,KACS;CACT,OAAO,QAAQ,UAAU,QAAQ,SAAS,EAAE,KAAK,IAAI,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,MAAM,CAAC,CAC5E;AACH"}
1
+ {"version":3,"file":"construct-interface.cjs","names":[],"sources":["../src/construct-interface.ts"],"sourcesContent":["/**\n * The construct contract.\n *\n * A construct is three things at once — an infrastructure requirement at build\n * time, a runtime capability, and something other code can consume — which is\n * what forces exactly these three members.\n *\n * An **interface**, not a base class: `Endpoint`, `Cron`, `Queue`, and `Topic`\n * can satisfy it without inheritance surgery, a lifted `Service` can satisfy it\n * as a plain object, and `.dependsOn()` gets its enforcement structurally — a\n * `Service` (`{ serviceName, register }`) simply does not match\n * `{ id, declare, service }`, with no `instanceof` anywhere.\n *\n * Lives in its own module while the existing abstract `Construct` class is\n * still in use; it takes that name once the class is gone.\n */\n\nimport type { EnvironmentParser } from '@geekmidas/envkit';\nimport type { Declaration, Dependency } from '@geekmidas/manifest';\nimport type { Service, ServiceRegisterOptions } from '@geekmidas/services';\n\n/**\n * @typeParam TName - the construct's canonical id, PascalCase. Keeping it a\n * literal is what lets the service key be `Uncapitalize<TName>` — a TypeScript\n * intrinsic, so no custom transform needs a runtime twin.\n * @typeParam TClient - what consuming this construct hands you. `never` means it\n * owns no address and cannot be consumed: a `Cron` is fired by a schedule and a\n * `Subscriber` is reached through its topic, so `.dependsOn()` on either is a\n * compile error rather than a stub that throws.\n */\nexport interface Construct<TName extends string = string, TClient = never> {\n\t/** Canonical, PascalCase, unique within the manifest. */\n\treadonly id: TName;\n\n\t/**\n\t * The build-time face: what this construct contributes to the manifest.\n\t *\n\t * Returns an array because some constructs contribute more than one node — a\n\t * queue declares the queue and its worker, a database declares its migrator\n\t * and seeder. Most return one.\n\t */\n\tdeclare(): Declaration[];\n\n\t/**\n\t * The consumable face — the address this construct owns, as a client.\n\t *\n\t * A field assigned once rather than a getter. `Construct.getEnvironment`\n\t * and `ServiceDiscovery` cache by service *object*, so a getter returning a\n\t * fresh literal on every access would never hit either cache.\n\t */\n\treadonly service: [TClient] extends [never]\n\t\t? never\n\t\t: Service<Uncapitalize<TName>, TClient>;\n}\n\n/**\n * The build-time face alone — an id and what it contributes to the manifest.\n *\n * Weaker than {@link Consumable} on purpose. An edge is not always an\n * injection: a site depending on an API needs that API's *address at build\n * time* and has no service record to put a client into, so requiring one would\n * make the weakest kind of edge impossible to express with the strongest\n * interface. Discovery asks this same question and nothing more.\n */\nexport interface Declarable<TName extends string = string> {\n\treadonly id: TName;\n\tdeclare(): Declaration[];\n}\n\n/**\n * A construct that authenticates requests — what `RestApi.auth()` takes.\n *\n * `verify` is the one thing every provider shares: given a request's headers,\n * whose request is it — the session, or `null` when there is none. Whether the\n * provider is a server mounted beside the API, deployed elsewhere, or an issuer\n * somebody else runs is its own business; a surface only ever asks this.\n */\nexport interface Authenticator<TSession = unknown> extends Declarable {\n\tverify(\n\t\theaders: Headers,\n\t\tenvParser: EnvironmentParser<{}>,\n\t): Promise<TSession | null>;\n}\n\n/**\n * The edge that points at a construct.\n *\n * A construct's *canonical* node is the one carrying its own id — the others are\n * things it owns rather than things it is, like the signing secret beside an\n * auth server — so the kind an edge records is read off that node instead of\n * being written down beside it. Hand-written kinds are the same fact stated\n * twice, and the copy is what goes stale when a construct changes what it\n * declares.\n *\n * @throws {NotAConstruct} when the value declares nothing under its own id.\n */\nexport function edgeTo(construct: Declarable): Dependency {\n\tconst canonical = construct\n\t\t.declare()\n\t\t.find((declaration) => declaration.id === construct.id);\n\n\tif (!canonical) throw new NotAConstruct(construct);\n\n\treturn { target: construct.id, kind: canonical.kind };\n}\n\n/**\n * A construct whose public half is a node of its own: what a site's or a\n * mobile app's plain edge points at instead of the construct itself.\n *\n * A `FileServer` is the one: its own node is the bucket, which presigns and\n * writes, and a frontend that only shows the objects needs the address they\n * are served on and nothing that can write to them.\n */\nexport interface HasPublicFace {\n\treadonly publicFace: Declarable;\n}\n\n/**\n * The edge a frontend — a site or a mobile app — has to a construct: its\n * public face where it has one, the construct itself otherwise.\n */\nexport function frontendEdgeTo(construct: Declarable): Dependency {\n\tconst face = (construct as Partial<HasPublicFace>).publicFace;\n\treturn edgeTo(face ?? construct);\n}\n\n/** What consuming a construct hands you. */\nexport type Infer<C> =\n\tC extends Construct<string, infer TClient> ? TClient : never;\n\n/** A construct's canonical id. */\nexport type NameOf<C> =\n\tC extends Construct<infer TName, unknown> ? TName : never;\n\n/**\n * What `.dependsOn([…])` accepts: a construct that owns a client.\n *\n * Structural, and deliberately narrower than {@link Construct} — it is the\n * face a *consumer* needs, so the builders can accept a database, a bucket, a\n * mail sender, a queue, or a topic without importing any of them. A plain\n * `Service` is not one of these, which is the point: constructs-only confines\n * env sniffing to `.services()` and the explicit lift, so retiring that method\n * retires implicit inference with it.\n */\nexport interface Consumable<TName extends string = string, TClient = unknown> {\n\treadonly id: TName;\n\treadonly service: Service<Uncapitalize<TName>, TClient>;\n\tdeclare(): Declaration[];\n}\n\n/**\n * The services a list of constructs dissolves into.\n *\n * A mapped tuple, so `[db, uploads]` types as `[Service<'orders', Kysely<DB>>,\n * Service<'uploads', StorageClient>]` and the handler's service record gains\n * both keys — the same machinery `.services()` already uses, which is why\n * `dependsOn` needs no type plumbing of its own.\n */\nexport type ServicesOf<T extends readonly Consumable[]> = {\n\t[K in keyof T]: T[K]['service'];\n};\n\n/**\n * The services of a list of constructs, at runtime.\n *\n * @throws {NotAConstruct} when handed something else. The type already refuses\n * it, but a JavaScript caller gets no such warning, and a `Service` slipping\n * through would fail later as an undefined key in the handler.\n */\nexport function servicesOf<const T extends readonly Consumable[]>(\n\tconstructs: T,\n): ServicesOf<T> {\n\treturn constructs.map((construct) => {\n\t\tif (!isConsumable(construct)) throw new NotAConstruct(construct);\n\n\t\treturn construct.service;\n\t}) as ServicesOf<T>;\n}\n\n/**\n * The other half of `servicesOf`: the same edge, as the manifest records it.\n *\n * `.dependsOn()` used to keep only the services, which is what a handler runs\n * with — and an id cannot be recovered from a service name reliably, so the\n * edges were gone by the time the build could read them. Both halves are taken\n * from one call now, and `existing` is folded in so repeated `.dependsOn()`\n * calls accumulate the way `.services()` already does.\n */\nexport function idsOf(\n\tconstructs: readonly Consumable[],\n\texisting: readonly string[] = [],\n): string[] {\n\treturn [...new Set([...existing, ...constructs.map(({ id }) => id)])];\n}\n\n/**\n * The edges after `.database(source)` names a builder's database.\n *\n * A database replaces the one before it — a worker's default, overridden by a\n * runnable that names its own — so the edge the previous one added goes with\n * it. Left behind, a Lambda built from a queue that moved to another database\n * would still be granted the worker's.\n *\n * Only an edge `.database()` added is removed, which is why it is returned as\n * `_databaseEdge` for the next call to read — and not even that one when\n * `.dependsOn()` has since named the same construct, since the handler still\n * reaches it through `services`.\n */\nexport function databaseEdges(\n\tcurrent: {\n\t\tconstructs: readonly string[];\n\t\tedge: string | undefined;\n\t\tservice: Service | undefined;\n\t\tservices: readonly Service[];\n\t},\n\tsource: unknown,\n): { _constructs: string[]; _databaseEdge: string | undefined } {\n\tconst stillDependedOn =\n\t\tcurrent.service !== undefined && current.services.includes(current.service);\n\tconst kept =\n\t\tcurrent.edge && !stillDependedOn\n\t\t\t? current.constructs.filter((id) => id !== current.edge)\n\t\t\t: [...current.constructs];\n\n\tif (!isConsumable(source) || kept.includes(source.id)) {\n\t\treturn { _constructs: kept, _databaseEdge: undefined };\n\t}\n\n\treturn { _constructs: [...kept, source.id], _databaseEdge: source.id };\n}\n\n/** Something that is not a construct was passed to `.dependsOn()`. */\nexport class NotAConstruct extends Error {\n\tconstructor(readonly value: unknown) {\n\t\tconst name =\n\t\t\ttypeof value === 'object' && value !== null && 'serviceName' in value\n\t\t\t\t? `the service '${String((value as { serviceName: unknown }).serviceName)}'`\n\t\t\t\t: `a ${typeof value}`;\n\n\t\tsuper(\n\t\t\t`.dependsOn() takes constructs, and was given ${name}. ` +\n\t\t\t\t`Pass it to .services([…]) instead.`,\n\t\t);\n\t\tthis.name = 'NotAConstruct';\n\t}\n}\n\n/**\n * Whether a value is a construct rather than a bare `Service`.\n *\n * Structural rather than `instanceof`: a construct from a second copy of\n * `@geekmidas/constructs` — a linked workspace, two versions in a lockfile — is\n * still a construct, and `instanceof` is exactly the check that says otherwise.\n */\nexport function isConsumable(value: unknown): value is Consumable {\n\tif (typeof value !== 'object' || value === null) return false;\n\n\tconst candidate = value as Partial<Consumable>;\n\n\treturn (\n\t\ttypeof candidate.id === 'string' &&\n\t\ttypeof candidate.declare === 'function' &&\n\t\ttypeof (candidate.service as Service | undefined)?.serviceName === 'string'\n\t);\n}\n\n/**\n * The service behind either face.\n *\n * `.database()` and the auditor slot take a construct now; they took a\n * `Service` before and still do, because not every hand-written service has a\n * construct to stand for it.\n */\nexport function serviceOf<TName extends string, TClient>(\n\tsource: Consumable<TName, TClient> | Service<TName, TClient>,\n): Service<TName, TClient> {\n\t// A construct's service key is `Uncapitalize<TName>` and the slot is typed\n\t// by `TName`; the two describe the same key, and only the cast says so.\n\treturn isConsumable(source)\n\t\t? (source.service as unknown as Service<TName, TClient>)\n\t\t: (source as Service<TName, TClient>);\n}\n\n/**\n * A surface's or a site's public address, read from its `<ID>_URL` — the\n * client a `RestApi` or a `StaticSite` hands whatever `.dependsOn()` it.\n */\nexport function publicUrl(\n\toptions: ServiceRegisterOptions,\n\tkey: string,\n): string {\n\treturn options.envParser.create((get) => ({ url: get(key).string() })).parse()\n\t\t.url;\n}\n"],"mappings":";;;;;;;;;;;;;;AAgGA,SAAgB,OAAO,WAAmC;CACzD,MAAM,YAAY,UAChB,QAAQ,CAAC,CACT,MAAM,gBAAgB,YAAY,OAAO,UAAU,EAAE;CAEvD,IAAI,CAAC,WAAW,MAAM,IAAI,cAAc,SAAS;CAEjD,OAAO;EAAE,QAAQ,UAAU;EAAI,MAAM,UAAU;CAAK;AACrD;;;;;AAkBA,SAAgB,eAAe,WAAmC;CACjE,MAAM,OAAQ,UAAqC;CACnD,OAAO,OAAO,QAAQ,SAAS;AAChC;;;;;;;;AA6CA,SAAgB,WACf,YACgB;CAChB,OAAO,WAAW,KAAK,cAAc;EACpC,IAAI,CAAC,aAAa,SAAS,GAAG,MAAM,IAAI,cAAc,SAAS;EAE/D,OAAO,UAAU;CAClB,CAAC;AACF;;;;;;;;;;AAWA,SAAgB,MACf,YACA,WAA8B,CAAC,GACpB;CACX,OAAO,CAAC,mBAAG,IAAI,IAAI,CAAC,GAAG,UAAU,GAAG,WAAW,KAAK,EAAE,SAAS,EAAE,CAAC,CAAC,CAAC;AACrE;;;;;;;;;;;;;;AAeA,SAAgB,cACf,SAMA,QAC+D;CAC/D,MAAM,kBACL,QAAQ,YAAY,KAAA,KAAa,QAAQ,SAAS,SAAS,QAAQ,OAAO;CAC3E,MAAM,OACL,QAAQ,QAAQ,CAAC,kBACd,QAAQ,WAAW,QAAQ,OAAO,OAAO,QAAQ,IAAI,IACrD,CAAC,GAAG,QAAQ,UAAU;CAE1B,IAAI,CAAC,aAAa,MAAM,KAAK,KAAK,SAAS,OAAO,EAAE,GACnD,OAAO;EAAE,aAAa;EAAM,eAAe,KAAA;CAAU;CAGtD,OAAO;EAAE,aAAa,CAAC,GAAG,MAAM,OAAO,EAAE;EAAG,eAAe,OAAO;CAAG;AACtE;;AAGA,IAAa,gBAAb,cAAmC,MAAM;CACnB;CAArB,YAAY,OAAyB;EACpC,MAAM,OACL,OAAO,UAAU,YAAY,UAAU,QAAQ,iBAAiB,QAC7D,gBAAgB,OAAQ,MAAmC,WAAW,EAAE,KACxE,KAAK,OAAO;EAEhB,MACC,gDAAgD,KAAK,qCAEtD;EAToB,KAAA,QAAA;EAUpB,KAAK,OAAO;CACb;AACD;;;;;;;;AASA,SAAgB,aAAa,OAAqC;CACjE,IAAI,OAAO,UAAU,YAAY,UAAU,MAAM,OAAO;CAExD,MAAM,YAAY;CAElB,OACC,OAAO,UAAU,OAAO,YACxB,OAAO,UAAU,YAAY,cAC7B,OAAQ,UAAU,SAAiC,gBAAgB;AAErE;;;;;;;;AASA,SAAgB,UACf,QAC0B;CAG1B,OAAO,aAAa,MAAM,IACtB,OAAO,UACP;AACL;;;;;AAMA,SAAgB,UACf,SACA,KACS;CACT,OAAO,QAAQ,UAAU,QAAQ,SAAS,EAAE,KAAK,IAAI,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,MAAM,CAAC,CAC5E;AACH"}
@@ -1,2 +1,2 @@
1
- import { a as Infer, c as ServicesOf, d as idsOf, f as isConsumable, h as servicesOf, i as Declarable, l as databaseEdges, m as serviceOf, n as Construct, o as NameOf, p as publicUrl, r as Consumable, s as NotAConstruct, t as Authenticator, u as edgeTo } from "./construct-interface-DugP0E5q.cjs";
2
- export { Authenticator, Construct, Consumable, Declarable, Infer, NameOf, NotAConstruct, ServicesOf, databaseEdges, edgeTo, idsOf, isConsumable, publicUrl, serviceOf, servicesOf };
1
+ import { _ as servicesOf, a as HasPublicFace, c as NotAConstruct, d as edgeTo, f as frontendEdgeTo, g as serviceOf, h as publicUrl, i as Declarable, l as ServicesOf, m as isConsumable, n as Construct, o as Infer, p as idsOf, r as Consumable, s as NameOf, t as Authenticator, u as databaseEdges } from "./construct-interface-DhbaONW2.cjs";
2
+ export { Authenticator, Construct, Consumable, Declarable, HasPublicFace, Infer, NameOf, NotAConstruct, ServicesOf, databaseEdges, edgeTo, frontendEdgeTo, idsOf, isConsumable, publicUrl, serviceOf, servicesOf };
@@ -1,2 +1,2 @@
1
- import { a as Infer, c as ServicesOf, d as idsOf, f as isConsumable, h as servicesOf, i as Declarable, l as databaseEdges, m as serviceOf, n as Construct, o as NameOf, p as publicUrl, r as Consumable, s as NotAConstruct, t as Authenticator, u as edgeTo } from "./construct-interface-CSA9VeWM.mjs";
2
- export { Authenticator, Construct, Consumable, Declarable, Infer, NameOf, NotAConstruct, ServicesOf, databaseEdges, edgeTo, idsOf, isConsumable, publicUrl, serviceOf, servicesOf };
1
+ import { _ as servicesOf, a as HasPublicFace, c as NotAConstruct, d as edgeTo, f as frontendEdgeTo, g as serviceOf, h as publicUrl, i as Declarable, l as ServicesOf, m as isConsumable, n as Construct, o as Infer, p as idsOf, r as Consumable, s as NameOf, t as Authenticator, u as databaseEdges } from "./construct-interface-DxfkFxkl.mjs";
2
+ export { Authenticator, Construct, Consumable, Declarable, HasPublicFace, Infer, NameOf, NotAConstruct, ServicesOf, databaseEdges, edgeTo, frontendEdgeTo, idsOf, isConsumable, publicUrl, serviceOf, servicesOf };
@@ -20,6 +20,14 @@ function edgeTo(construct) {
20
20
  };
21
21
  }
22
22
  /**
23
+ * The edge a frontend — a site or a mobile app — has to a construct: its
24
+ * public face where it has one, the construct itself otherwise.
25
+ */
26
+ function frontendEdgeTo(construct) {
27
+ const face = construct.publicFace;
28
+ return edgeTo(face ?? construct);
29
+ }
30
+ /**
23
31
  * The services of a list of constructs, at runtime.
24
32
  *
25
33
  * @throws {NotAConstruct} when handed something else. The type already refuses
@@ -109,6 +117,6 @@ function publicUrl(options, key) {
109
117
  return options.envParser.create((get) => ({ url: get(key).string() })).parse().url;
110
118
  }
111
119
  //#endregion
112
- export { NotAConstruct, databaseEdges, edgeTo, idsOf, isConsumable, publicUrl, serviceOf, servicesOf };
120
+ export { NotAConstruct, databaseEdges, edgeTo, frontendEdgeTo, idsOf, isConsumable, publicUrl, serviceOf, servicesOf };
113
121
 
114
122
  //# sourceMappingURL=construct-interface.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"construct-interface.mjs","names":[],"sources":["../src/construct-interface.ts"],"sourcesContent":["/**\n * The construct contract.\n *\n * A construct is three things at once — an infrastructure requirement at build\n * time, a runtime capability, and something other code can consume — which is\n * what forces exactly these three members.\n *\n * An **interface**, not a base class: `Endpoint`, `Cron`, `Queue`, and `Topic`\n * can satisfy it without inheritance surgery, a lifted `Service` can satisfy it\n * as a plain object, and `.dependsOn()` gets its enforcement structurally — a\n * `Service` (`{ serviceName, register }`) simply does not match\n * `{ id, declare, service }`, with no `instanceof` anywhere.\n *\n * Lives in its own module while the existing abstract `Construct` class is\n * still in use; it takes that name once the class is gone.\n */\n\nimport type { EnvironmentParser } from '@geekmidas/envkit';\nimport type { Declaration, Dependency } from '@geekmidas/manifest';\nimport type { Service, ServiceRegisterOptions } from '@geekmidas/services';\n\n/**\n * @typeParam TName - the construct's canonical id, PascalCase. Keeping it a\n * literal is what lets the service key be `Uncapitalize<TName>` — a TypeScript\n * intrinsic, so no custom transform needs a runtime twin.\n * @typeParam TClient - what consuming this construct hands you. `never` means it\n * owns no address and cannot be consumed: a `Cron` is fired by a schedule and a\n * `Subscriber` is reached through its topic, so `.dependsOn()` on either is a\n * compile error rather than a stub that throws.\n */\nexport interface Construct<TName extends string = string, TClient = never> {\n\t/** Canonical, PascalCase, unique within the manifest. */\n\treadonly id: TName;\n\n\t/**\n\t * The build-time face: what this construct contributes to the manifest.\n\t *\n\t * Returns an array because some constructs contribute more than one node — a\n\t * queue declares the queue and its worker, a database declares its migrator\n\t * and seeder. Most return one.\n\t */\n\tdeclare(): Declaration[];\n\n\t/**\n\t * The consumable face — the address this construct owns, as a client.\n\t *\n\t * A field assigned once rather than a getter. `Construct.getEnvironment`\n\t * and `ServiceDiscovery` cache by service *object*, so a getter returning a\n\t * fresh literal on every access would never hit either cache.\n\t */\n\treadonly service: [TClient] extends [never]\n\t\t? never\n\t\t: Service<Uncapitalize<TName>, TClient>;\n}\n\n/**\n * The build-time face alone — an id and what it contributes to the manifest.\n *\n * Weaker than {@link Consumable} on purpose. An edge is not always an\n * injection: a site depending on an API needs that API's *address at build\n * time* and has no service record to put a client into, so requiring one would\n * make the weakest kind of edge impossible to express with the strongest\n * interface. Discovery asks this same question and nothing more.\n */\nexport interface Declarable<TName extends string = string> {\n\treadonly id: TName;\n\tdeclare(): Declaration[];\n}\n\n/**\n * A construct that authenticates requests — what `RestApi.auth()` takes.\n *\n * `verify` is the one thing every provider shares: given a request's headers,\n * whose request is it — the session, or `null` when there is none. Whether the\n * provider is a server mounted beside the API, deployed elsewhere, or an issuer\n * somebody else runs is its own business; a surface only ever asks this.\n */\nexport interface Authenticator<TSession = unknown> extends Declarable {\n\tverify(\n\t\theaders: Headers,\n\t\tenvParser: EnvironmentParser<{}>,\n\t): Promise<TSession | null>;\n}\n\n/**\n * The edge that points at a construct.\n *\n * A construct's *canonical* node is the one carrying its own id — the others are\n * things it owns rather than things it is, like the signing secret beside an\n * auth server — so the kind an edge records is read off that node instead of\n * being written down beside it. Hand-written kinds are the same fact stated\n * twice, and the copy is what goes stale when a construct changes what it\n * declares.\n *\n * @throws {NotAConstruct} when the value declares nothing under its own id.\n */\nexport function edgeTo(construct: Declarable): Dependency {\n\tconst canonical = construct\n\t\t.declare()\n\t\t.find((declaration) => declaration.id === construct.id);\n\n\tif (!canonical) throw new NotAConstruct(construct);\n\n\treturn { target: construct.id, kind: canonical.kind };\n}\n\n/** What consuming a construct hands you. */\nexport type Infer<C> =\n\tC extends Construct<string, infer TClient> ? TClient : never;\n\n/** A construct's canonical id. */\nexport type NameOf<C> =\n\tC extends Construct<infer TName, unknown> ? TName : never;\n\n/**\n * What `.dependsOn([…])` accepts: a construct that owns a client.\n *\n * Structural, and deliberately narrower than {@link Construct} — it is the\n * face a *consumer* needs, so the builders can accept a database, a bucket, a\n * mail sender, a queue, or a topic without importing any of them. A plain\n * `Service` is not one of these, which is the point: constructs-only confines\n * env sniffing to `.services()` and the explicit lift, so retiring that method\n * retires implicit inference with it.\n */\nexport interface Consumable<TName extends string = string, TClient = unknown> {\n\treadonly id: TName;\n\treadonly service: Service<Uncapitalize<TName>, TClient>;\n\tdeclare(): Declaration[];\n}\n\n/**\n * The services a list of constructs dissolves into.\n *\n * A mapped tuple, so `[db, uploads]` types as `[Service<'orders', Kysely<DB>>,\n * Service<'uploads', StorageClient>]` and the handler's service record gains\n * both keys — the same machinery `.services()` already uses, which is why\n * `dependsOn` needs no type plumbing of its own.\n */\nexport type ServicesOf<T extends readonly Consumable[]> = {\n\t[K in keyof T]: T[K]['service'];\n};\n\n/**\n * The services of a list of constructs, at runtime.\n *\n * @throws {NotAConstruct} when handed something else. The type already refuses\n * it, but a JavaScript caller gets no such warning, and a `Service` slipping\n * through would fail later as an undefined key in the handler.\n */\nexport function servicesOf<const T extends readonly Consumable[]>(\n\tconstructs: T,\n): ServicesOf<T> {\n\treturn constructs.map((construct) => {\n\t\tif (!isConsumable(construct)) throw new NotAConstruct(construct);\n\n\t\treturn construct.service;\n\t}) as ServicesOf<T>;\n}\n\n/**\n * The other half of `servicesOf`: the same edge, as the manifest records it.\n *\n * `.dependsOn()` used to keep only the services, which is what a handler runs\n * with — and an id cannot be recovered from a service name reliably, so the\n * edges were gone by the time the build could read them. Both halves are taken\n * from one call now, and `existing` is folded in so repeated `.dependsOn()`\n * calls accumulate the way `.services()` already does.\n */\nexport function idsOf(\n\tconstructs: readonly Consumable[],\n\texisting: readonly string[] = [],\n): string[] {\n\treturn [...new Set([...existing, ...constructs.map(({ id }) => id)])];\n}\n\n/**\n * The edges after `.database(source)` names a builder's database.\n *\n * A database replaces the one before it — a worker's default, overridden by a\n * runnable that names its own — so the edge the previous one added goes with\n * it. Left behind, a Lambda built from a queue that moved to another database\n * would still be granted the worker's.\n *\n * Only an edge `.database()` added is removed, which is why it is returned as\n * `_databaseEdge` for the next call to read — and not even that one when\n * `.dependsOn()` has since named the same construct, since the handler still\n * reaches it through `services`.\n */\nexport function databaseEdges(\n\tcurrent: {\n\t\tconstructs: readonly string[];\n\t\tedge: string | undefined;\n\t\tservice: Service | undefined;\n\t\tservices: readonly Service[];\n\t},\n\tsource: unknown,\n): { _constructs: string[]; _databaseEdge: string | undefined } {\n\tconst stillDependedOn =\n\t\tcurrent.service !== undefined && current.services.includes(current.service);\n\tconst kept =\n\t\tcurrent.edge && !stillDependedOn\n\t\t\t? current.constructs.filter((id) => id !== current.edge)\n\t\t\t: [...current.constructs];\n\n\tif (!isConsumable(source) || kept.includes(source.id)) {\n\t\treturn { _constructs: kept, _databaseEdge: undefined };\n\t}\n\n\treturn { _constructs: [...kept, source.id], _databaseEdge: source.id };\n}\n\n/** Something that is not a construct was passed to `.dependsOn()`. */\nexport class NotAConstruct extends Error {\n\tconstructor(readonly value: unknown) {\n\t\tconst name =\n\t\t\ttypeof value === 'object' && value !== null && 'serviceName' in value\n\t\t\t\t? `the service '${String((value as { serviceName: unknown }).serviceName)}'`\n\t\t\t\t: `a ${typeof value}`;\n\n\t\tsuper(\n\t\t\t`.dependsOn() takes constructs, and was given ${name}. ` +\n\t\t\t\t`Pass it to .services([…]) instead.`,\n\t\t);\n\t\tthis.name = 'NotAConstruct';\n\t}\n}\n\n/**\n * Whether a value is a construct rather than a bare `Service`.\n *\n * Structural rather than `instanceof`: a construct from a second copy of\n * `@geekmidas/constructs` — a linked workspace, two versions in a lockfile — is\n * still a construct, and `instanceof` is exactly the check that says otherwise.\n */\nexport function isConsumable(value: unknown): value is Consumable {\n\tif (typeof value !== 'object' || value === null) return false;\n\n\tconst candidate = value as Partial<Consumable>;\n\n\treturn (\n\t\ttypeof candidate.id === 'string' &&\n\t\ttypeof candidate.declare === 'function' &&\n\t\ttypeof (candidate.service as Service | undefined)?.serviceName === 'string'\n\t);\n}\n\n/**\n * The service behind either face.\n *\n * `.database()` and the auditor slot take a construct now; they took a\n * `Service` before and still do, because not every hand-written service has a\n * construct to stand for it.\n */\nexport function serviceOf<TName extends string, TClient>(\n\tsource: Consumable<TName, TClient> | Service<TName, TClient>,\n): Service<TName, TClient> {\n\t// A construct's service key is `Uncapitalize<TName>` and the slot is typed\n\t// by `TName`; the two describe the same key, and only the cast says so.\n\treturn isConsumable(source)\n\t\t? (source.service as unknown as Service<TName, TClient>)\n\t\t: (source as Service<TName, TClient>);\n}\n\n/**\n * A surface's or a site's public address, read from its `<ID>_URL` — the\n * client a `RestApi` or a `StaticSite` hands whatever `.dependsOn()` it.\n */\nexport function publicUrl(\n\toptions: ServiceRegisterOptions,\n\tkey: string,\n): string {\n\treturn options.envParser.create((get) => ({ url: get(key).string() })).parse()\n\t\t.url;\n}\n"],"mappings":";;;;;;;;;;;;;AAgGA,SAAgB,OAAO,WAAmC;CACzD,MAAM,YAAY,UAChB,QAAQ,CAAC,CACT,MAAM,gBAAgB,YAAY,OAAO,UAAU,EAAE;CAEvD,IAAI,CAAC,WAAW,MAAM,IAAI,cAAc,SAAS;CAEjD,OAAO;EAAE,QAAQ,UAAU;EAAI,MAAM,UAAU;CAAK;AACrD;;;;;;;;AA6CA,SAAgB,WACf,YACgB;CAChB,OAAO,WAAW,KAAK,cAAc;EACpC,IAAI,CAAC,aAAa,SAAS,GAAG,MAAM,IAAI,cAAc,SAAS;EAE/D,OAAO,UAAU;CAClB,CAAC;AACF;;;;;;;;;;AAWA,SAAgB,MACf,YACA,WAA8B,CAAC,GACpB;CACX,OAAO,CAAC,mBAAG,IAAI,IAAI,CAAC,GAAG,UAAU,GAAG,WAAW,KAAK,EAAE,SAAS,EAAE,CAAC,CAAC,CAAC;AACrE;;;;;;;;;;;;;;AAeA,SAAgB,cACf,SAMA,QAC+D;CAC/D,MAAM,kBACL,QAAQ,YAAY,KAAA,KAAa,QAAQ,SAAS,SAAS,QAAQ,OAAO;CAC3E,MAAM,OACL,QAAQ,QAAQ,CAAC,kBACd,QAAQ,WAAW,QAAQ,OAAO,OAAO,QAAQ,IAAI,IACrD,CAAC,GAAG,QAAQ,UAAU;CAE1B,IAAI,CAAC,aAAa,MAAM,KAAK,KAAK,SAAS,OAAO,EAAE,GACnD,OAAO;EAAE,aAAa;EAAM,eAAe,KAAA;CAAU;CAGtD,OAAO;EAAE,aAAa,CAAC,GAAG,MAAM,OAAO,EAAE;EAAG,eAAe,OAAO;CAAG;AACtE;;AAGA,IAAa,gBAAb,cAAmC,MAAM;CACnB;CAArB,YAAY,OAAyB;EACpC,MAAM,OACL,OAAO,UAAU,YAAY,UAAU,QAAQ,iBAAiB,QAC7D,gBAAgB,OAAQ,MAAmC,WAAW,EAAE,KACxE,KAAK,OAAO;EAEhB,MACC,gDAAgD,KAAK,qCAEtD;EAToB,KAAA,QAAA;EAUpB,KAAK,OAAO;CACb;AACD;;;;;;;;AASA,SAAgB,aAAa,OAAqC;CACjE,IAAI,OAAO,UAAU,YAAY,UAAU,MAAM,OAAO;CAExD,MAAM,YAAY;CAElB,OACC,OAAO,UAAU,OAAO,YACxB,OAAO,UAAU,YAAY,cAC7B,OAAQ,UAAU,SAAiC,gBAAgB;AAErE;;;;;;;;AASA,SAAgB,UACf,QAC0B;CAG1B,OAAO,aAAa,MAAM,IACtB,OAAO,UACP;AACL;;;;;AAMA,SAAgB,UACf,SACA,KACS;CACT,OAAO,QAAQ,UAAU,QAAQ,SAAS,EAAE,KAAK,IAAI,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,MAAM,CAAC,CAC5E;AACH"}
1
+ {"version":3,"file":"construct-interface.mjs","names":[],"sources":["../src/construct-interface.ts"],"sourcesContent":["/**\n * The construct contract.\n *\n * A construct is three things at once — an infrastructure requirement at build\n * time, a runtime capability, and something other code can consume — which is\n * what forces exactly these three members.\n *\n * An **interface**, not a base class: `Endpoint`, `Cron`, `Queue`, and `Topic`\n * can satisfy it without inheritance surgery, a lifted `Service` can satisfy it\n * as a plain object, and `.dependsOn()` gets its enforcement structurally — a\n * `Service` (`{ serviceName, register }`) simply does not match\n * `{ id, declare, service }`, with no `instanceof` anywhere.\n *\n * Lives in its own module while the existing abstract `Construct` class is\n * still in use; it takes that name once the class is gone.\n */\n\nimport type { EnvironmentParser } from '@geekmidas/envkit';\nimport type { Declaration, Dependency } from '@geekmidas/manifest';\nimport type { Service, ServiceRegisterOptions } from '@geekmidas/services';\n\n/**\n * @typeParam TName - the construct's canonical id, PascalCase. Keeping it a\n * literal is what lets the service key be `Uncapitalize<TName>` — a TypeScript\n * intrinsic, so no custom transform needs a runtime twin.\n * @typeParam TClient - what consuming this construct hands you. `never` means it\n * owns no address and cannot be consumed: a `Cron` is fired by a schedule and a\n * `Subscriber` is reached through its topic, so `.dependsOn()` on either is a\n * compile error rather than a stub that throws.\n */\nexport interface Construct<TName extends string = string, TClient = never> {\n\t/** Canonical, PascalCase, unique within the manifest. */\n\treadonly id: TName;\n\n\t/**\n\t * The build-time face: what this construct contributes to the manifest.\n\t *\n\t * Returns an array because some constructs contribute more than one node — a\n\t * queue declares the queue and its worker, a database declares its migrator\n\t * and seeder. Most return one.\n\t */\n\tdeclare(): Declaration[];\n\n\t/**\n\t * The consumable face — the address this construct owns, as a client.\n\t *\n\t * A field assigned once rather than a getter. `Construct.getEnvironment`\n\t * and `ServiceDiscovery` cache by service *object*, so a getter returning a\n\t * fresh literal on every access would never hit either cache.\n\t */\n\treadonly service: [TClient] extends [never]\n\t\t? never\n\t\t: Service<Uncapitalize<TName>, TClient>;\n}\n\n/**\n * The build-time face alone — an id and what it contributes to the manifest.\n *\n * Weaker than {@link Consumable} on purpose. An edge is not always an\n * injection: a site depending on an API needs that API's *address at build\n * time* and has no service record to put a client into, so requiring one would\n * make the weakest kind of edge impossible to express with the strongest\n * interface. Discovery asks this same question and nothing more.\n */\nexport interface Declarable<TName extends string = string> {\n\treadonly id: TName;\n\tdeclare(): Declaration[];\n}\n\n/**\n * A construct that authenticates requests — what `RestApi.auth()` takes.\n *\n * `verify` is the one thing every provider shares: given a request's headers,\n * whose request is it — the session, or `null` when there is none. Whether the\n * provider is a server mounted beside the API, deployed elsewhere, or an issuer\n * somebody else runs is its own business; a surface only ever asks this.\n */\nexport interface Authenticator<TSession = unknown> extends Declarable {\n\tverify(\n\t\theaders: Headers,\n\t\tenvParser: EnvironmentParser<{}>,\n\t): Promise<TSession | null>;\n}\n\n/**\n * The edge that points at a construct.\n *\n * A construct's *canonical* node is the one carrying its own id — the others are\n * things it owns rather than things it is, like the signing secret beside an\n * auth server — so the kind an edge records is read off that node instead of\n * being written down beside it. Hand-written kinds are the same fact stated\n * twice, and the copy is what goes stale when a construct changes what it\n * declares.\n *\n * @throws {NotAConstruct} when the value declares nothing under its own id.\n */\nexport function edgeTo(construct: Declarable): Dependency {\n\tconst canonical = construct\n\t\t.declare()\n\t\t.find((declaration) => declaration.id === construct.id);\n\n\tif (!canonical) throw new NotAConstruct(construct);\n\n\treturn { target: construct.id, kind: canonical.kind };\n}\n\n/**\n * A construct whose public half is a node of its own: what a site's or a\n * mobile app's plain edge points at instead of the construct itself.\n *\n * A `FileServer` is the one: its own node is the bucket, which presigns and\n * writes, and a frontend that only shows the objects needs the address they\n * are served on and nothing that can write to them.\n */\nexport interface HasPublicFace {\n\treadonly publicFace: Declarable;\n}\n\n/**\n * The edge a frontend — a site or a mobile app — has to a construct: its\n * public face where it has one, the construct itself otherwise.\n */\nexport function frontendEdgeTo(construct: Declarable): Dependency {\n\tconst face = (construct as Partial<HasPublicFace>).publicFace;\n\treturn edgeTo(face ?? construct);\n}\n\n/** What consuming a construct hands you. */\nexport type Infer<C> =\n\tC extends Construct<string, infer TClient> ? TClient : never;\n\n/** A construct's canonical id. */\nexport type NameOf<C> =\n\tC extends Construct<infer TName, unknown> ? TName : never;\n\n/**\n * What `.dependsOn([…])` accepts: a construct that owns a client.\n *\n * Structural, and deliberately narrower than {@link Construct} — it is the\n * face a *consumer* needs, so the builders can accept a database, a bucket, a\n * mail sender, a queue, or a topic without importing any of them. A plain\n * `Service` is not one of these, which is the point: constructs-only confines\n * env sniffing to `.services()` and the explicit lift, so retiring that method\n * retires implicit inference with it.\n */\nexport interface Consumable<TName extends string = string, TClient = unknown> {\n\treadonly id: TName;\n\treadonly service: Service<Uncapitalize<TName>, TClient>;\n\tdeclare(): Declaration[];\n}\n\n/**\n * The services a list of constructs dissolves into.\n *\n * A mapped tuple, so `[db, uploads]` types as `[Service<'orders', Kysely<DB>>,\n * Service<'uploads', StorageClient>]` and the handler's service record gains\n * both keys — the same machinery `.services()` already uses, which is why\n * `dependsOn` needs no type plumbing of its own.\n */\nexport type ServicesOf<T extends readonly Consumable[]> = {\n\t[K in keyof T]: T[K]['service'];\n};\n\n/**\n * The services of a list of constructs, at runtime.\n *\n * @throws {NotAConstruct} when handed something else. The type already refuses\n * it, but a JavaScript caller gets no such warning, and a `Service` slipping\n * through would fail later as an undefined key in the handler.\n */\nexport function servicesOf<const T extends readonly Consumable[]>(\n\tconstructs: T,\n): ServicesOf<T> {\n\treturn constructs.map((construct) => {\n\t\tif (!isConsumable(construct)) throw new NotAConstruct(construct);\n\n\t\treturn construct.service;\n\t}) as ServicesOf<T>;\n}\n\n/**\n * The other half of `servicesOf`: the same edge, as the manifest records it.\n *\n * `.dependsOn()` used to keep only the services, which is what a handler runs\n * with — and an id cannot be recovered from a service name reliably, so the\n * edges were gone by the time the build could read them. Both halves are taken\n * from one call now, and `existing` is folded in so repeated `.dependsOn()`\n * calls accumulate the way `.services()` already does.\n */\nexport function idsOf(\n\tconstructs: readonly Consumable[],\n\texisting: readonly string[] = [],\n): string[] {\n\treturn [...new Set([...existing, ...constructs.map(({ id }) => id)])];\n}\n\n/**\n * The edges after `.database(source)` names a builder's database.\n *\n * A database replaces the one before it — a worker's default, overridden by a\n * runnable that names its own — so the edge the previous one added goes with\n * it. Left behind, a Lambda built from a queue that moved to another database\n * would still be granted the worker's.\n *\n * Only an edge `.database()` added is removed, which is why it is returned as\n * `_databaseEdge` for the next call to read — and not even that one when\n * `.dependsOn()` has since named the same construct, since the handler still\n * reaches it through `services`.\n */\nexport function databaseEdges(\n\tcurrent: {\n\t\tconstructs: readonly string[];\n\t\tedge: string | undefined;\n\t\tservice: Service | undefined;\n\t\tservices: readonly Service[];\n\t},\n\tsource: unknown,\n): { _constructs: string[]; _databaseEdge: string | undefined } {\n\tconst stillDependedOn =\n\t\tcurrent.service !== undefined && current.services.includes(current.service);\n\tconst kept =\n\t\tcurrent.edge && !stillDependedOn\n\t\t\t? current.constructs.filter((id) => id !== current.edge)\n\t\t\t: [...current.constructs];\n\n\tif (!isConsumable(source) || kept.includes(source.id)) {\n\t\treturn { _constructs: kept, _databaseEdge: undefined };\n\t}\n\n\treturn { _constructs: [...kept, source.id], _databaseEdge: source.id };\n}\n\n/** Something that is not a construct was passed to `.dependsOn()`. */\nexport class NotAConstruct extends Error {\n\tconstructor(readonly value: unknown) {\n\t\tconst name =\n\t\t\ttypeof value === 'object' && value !== null && 'serviceName' in value\n\t\t\t\t? `the service '${String((value as { serviceName: unknown }).serviceName)}'`\n\t\t\t\t: `a ${typeof value}`;\n\n\t\tsuper(\n\t\t\t`.dependsOn() takes constructs, and was given ${name}. ` +\n\t\t\t\t`Pass it to .services([…]) instead.`,\n\t\t);\n\t\tthis.name = 'NotAConstruct';\n\t}\n}\n\n/**\n * Whether a value is a construct rather than a bare `Service`.\n *\n * Structural rather than `instanceof`: a construct from a second copy of\n * `@geekmidas/constructs` — a linked workspace, two versions in a lockfile — is\n * still a construct, and `instanceof` is exactly the check that says otherwise.\n */\nexport function isConsumable(value: unknown): value is Consumable {\n\tif (typeof value !== 'object' || value === null) return false;\n\n\tconst candidate = value as Partial<Consumable>;\n\n\treturn (\n\t\ttypeof candidate.id === 'string' &&\n\t\ttypeof candidate.declare === 'function' &&\n\t\ttypeof (candidate.service as Service | undefined)?.serviceName === 'string'\n\t);\n}\n\n/**\n * The service behind either face.\n *\n * `.database()` and the auditor slot take a construct now; they took a\n * `Service` before and still do, because not every hand-written service has a\n * construct to stand for it.\n */\nexport function serviceOf<TName extends string, TClient>(\n\tsource: Consumable<TName, TClient> | Service<TName, TClient>,\n): Service<TName, TClient> {\n\t// A construct's service key is `Uncapitalize<TName>` and the slot is typed\n\t// by `TName`; the two describe the same key, and only the cast says so.\n\treturn isConsumable(source)\n\t\t? (source.service as unknown as Service<TName, TClient>)\n\t\t: (source as Service<TName, TClient>);\n}\n\n/**\n * A surface's or a site's public address, read from its `<ID>_URL` — the\n * client a `RestApi` or a `StaticSite` hands whatever `.dependsOn()` it.\n */\nexport function publicUrl(\n\toptions: ServiceRegisterOptions,\n\tkey: string,\n): string {\n\treturn options.envParser.create((get) => ({ url: get(key).string() })).parse()\n\t\t.url;\n}\n"],"mappings":";;;;;;;;;;;;;AAgGA,SAAgB,OAAO,WAAmC;CACzD,MAAM,YAAY,UAChB,QAAQ,CAAC,CACT,MAAM,gBAAgB,YAAY,OAAO,UAAU,EAAE;CAEvD,IAAI,CAAC,WAAW,MAAM,IAAI,cAAc,SAAS;CAEjD,OAAO;EAAE,QAAQ,UAAU;EAAI,MAAM,UAAU;CAAK;AACrD;;;;;AAkBA,SAAgB,eAAe,WAAmC;CACjE,MAAM,OAAQ,UAAqC;CACnD,OAAO,OAAO,QAAQ,SAAS;AAChC;;;;;;;;AA6CA,SAAgB,WACf,YACgB;CAChB,OAAO,WAAW,KAAK,cAAc;EACpC,IAAI,CAAC,aAAa,SAAS,GAAG,MAAM,IAAI,cAAc,SAAS;EAE/D,OAAO,UAAU;CAClB,CAAC;AACF;;;;;;;;;;AAWA,SAAgB,MACf,YACA,WAA8B,CAAC,GACpB;CACX,OAAO,CAAC,mBAAG,IAAI,IAAI,CAAC,GAAG,UAAU,GAAG,WAAW,KAAK,EAAE,SAAS,EAAE,CAAC,CAAC,CAAC;AACrE;;;;;;;;;;;;;;AAeA,SAAgB,cACf,SAMA,QAC+D;CAC/D,MAAM,kBACL,QAAQ,YAAY,KAAA,KAAa,QAAQ,SAAS,SAAS,QAAQ,OAAO;CAC3E,MAAM,OACL,QAAQ,QAAQ,CAAC,kBACd,QAAQ,WAAW,QAAQ,OAAO,OAAO,QAAQ,IAAI,IACrD,CAAC,GAAG,QAAQ,UAAU;CAE1B,IAAI,CAAC,aAAa,MAAM,KAAK,KAAK,SAAS,OAAO,EAAE,GACnD,OAAO;EAAE,aAAa;EAAM,eAAe,KAAA;CAAU;CAGtD,OAAO;EAAE,aAAa,CAAC,GAAG,MAAM,OAAO,EAAE;EAAG,eAAe,OAAO;CAAG;AACtE;;AAGA,IAAa,gBAAb,cAAmC,MAAM;CACnB;CAArB,YAAY,OAAyB;EACpC,MAAM,OACL,OAAO,UAAU,YAAY,UAAU,QAAQ,iBAAiB,QAC7D,gBAAgB,OAAQ,MAAmC,WAAW,EAAE,KACxE,KAAK,OAAO;EAEhB,MACC,gDAAgD,KAAK,qCAEtD;EAToB,KAAA,QAAA;EAUpB,KAAK,OAAO;CACb;AACD;;;;;;;;AASA,SAAgB,aAAa,OAAqC;CACjE,IAAI,OAAO,UAAU,YAAY,UAAU,MAAM,OAAO;CAExD,MAAM,YAAY;CAElB,OACC,OAAO,UAAU,OAAO,YACxB,OAAO,UAAU,YAAY,cAC7B,OAAQ,UAAU,SAAiC,gBAAgB;AAErE;;;;;;;;AASA,SAAgB,UACf,QAC0B;CAG1B,OAAO,aAAa,MAAM,IACtB,OAAO,UACP;AACL;;;;;AAMA,SAAgB,UACf,SACA,KACS;CACT,OAAO,QAAQ,UAAU,QAAQ,SAAS,EAAE,KAAK,IAAI,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,MAAM,CAAC,CAC5E;AACH"}
@@ -1,4 +1,4 @@
1
- import { canonicalId, provideKey, serviceKey } from "@geekmidas/manifest";
1
+ import { canonicalId, providedKeyFor, serviceKey } from "@geekmidas/manifest";
2
2
  import { parseSchema } from "@geekmidas/schema/parser";
3
3
  //#region src/fake.ts
4
4
  /**
@@ -123,7 +123,7 @@ var Credential = class {
123
123
  this.options = options;
124
124
  const canonical = canonicalId(id);
125
125
  this.id = canonical;
126
- this.keys = { credentials: provideKey(canonical, "credentials") };
126
+ this.keys = { credentials: providedKeyFor(canonical, "credential", "credentials") };
127
127
  this.service = {
128
128
  serviceName: serviceKey(canonical),
129
129
  register: (registerOptions) => this.connect(registerOptions)
@@ -219,4 +219,4 @@ function describe(issues) {
219
219
  //#endregion
220
220
  export { fake as a, readCredentials as i, MalformedCredential as n, isFake as o, decodeCredentials as r, Credential as t };
221
221
 
222
- //# sourceMappingURL=credential-DfSAOOdY.mjs.map
222
+ //# sourceMappingURL=credential-B80mOxwT.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"credential-B80mOxwT.mjs","names":[],"sources":["../src/fake.ts","../src/credential.ts"],"sourcesContent":["/**\n * Fakes: what a test stage — and `gkm dev --fake` — is handed in place of a\n * third party.\n *\n * An `ExternalApi`'s fake answers its requests and says which credentials it\n * accepts; a `Credential`'s fake is the value the test stage is handed in\n * place of the one a third party issued. Both live at `test/fakes/<id>.ts`,\n * found by convention and default-exported:\n *\n * ```ts\n * // test/fakes/polar.ts\n * export default fake.app<typeof polar>(new Hono()…, {\n * credentials: { clientId: 'fake', clientSecret: 'fake' },\n * });\n *\n * // test/fakes/reviewer-password.ts\n * export default fake.credential<typeof reviewerPassword>(\n * 'a-reviewer-password-for-tests',\n * );\n * ```\n *\n * **The construct never names its fake**, so a fake cannot end up in a\n * deployed bundle however the bundler follows imports. gkm reads the folder\n * for `gkm test` (and the suite it starts) and for `gkm dev --fake`, and for\n * nothing that acts on a deployed stage: a deploy still refuses a stage that\n * lacks the real value.\n */\n\nimport type { StandardSchemaV1 } from '@standard-schema/spec';\nimport type { Credential } from './credential';\nimport type { ExternalApi } from './external-api';\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/** 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 * What a construct's credentials look like going in, for a fake to supply —\n * an external API's `credentials` schema, or a credential's `schema`.\n */\ntype CredentialsOf<TConstruct> =\n\tTConstruct extends ExternalApi<string, infer TSchema, unknown>\n\t\t? StandardSchemaV1.InferInput<TSchema>\n\t\t: TConstruct extends Credential<string, infer TSchema>\n\t\t\t? StandardSchemaV1.InferInput<TSchema>\n\t\t\t: unknown;\n\n/**\n * A third party's stand-in, as `test/fakes/<id>.ts` default-exports it.\n *\n * `credentials` are what a local or test stage is handed as `<ID>_CREDENTIALS`\n * in place of the stage's own: what an external API's fake accepts, or a\n * credential's test value.\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\t| {\n\t\t\t/** A `Credential`'s test value — nothing to serve. */\n\t\t\treadonly kind: 'credential';\n\t }\n);\n\n/**\n * Build the fake `test/fakes/<id>.ts` default-exports.\n *\n * Pass the construct's type to have the value checked against its schema —\n * `fake.app<typeof polar>(…)`, `fake.credential<typeof stripe>(…)`.\n */\nexport const fake = {\n\t/** A working implementation of an external 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 an external API's 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\t/**\n\t * A `Credential`'s value on the test stage and under `gkm dev --fake`, as\n\t * its schema takes it — a string, or the object a JSON credential holds.\n\t * It is validated where it is read, like the real one.\n\t */\n\tcredential<TCredential = unknown>(\n\t\tcredentials: CredentialsOf<TCredential>,\n\t): Fake {\n\t\treturn { [FAKE]: true, kind: 'credential', credentials };\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","/**\n * `Credential` — a third-party credential with a shape.\n *\n * The answer to the design's first open question, \"where does `Secret` sit?\".\n * It sits beside a secret rather than replacing it, because the two differ by\n * *lifecycle* and that is the only difference worth two kinds for: a secret is\n * generated and rotated by the platform and is one opaque string, while a\n * credential is issued by someone else, arrives with several fields, and is\n * worth validating on the way in.\n *\n * ```ts\n * export const stripe = new Credential('Stripe', {\n * schema: z.object({ secretKey: z.string(), webhookSecret: z.string() }),\n * });\n *\n * // in a handler — no await, already parsed and validated\n * services.stripe.secretKey\n * ```\n *\n * **Nothing about it is async at the call site**, which is the part that looks\n * like it should be hard and is not. `Service.register()` may return a promise\n * and `ServiceDiscovery` awaits every one before a handler runs, so fetching a\n * value and validating it — including when a StandardSchema's `~standard.validate`\n * returns a promise of its own — both happen inside that existing seam.\n *\n * **One key holding JSON, not one key per field.** That is the shape a secret\n * manager stores, and it is the only shape that works with an arbitrary\n * StandardSchema: the spec has no introspection API, so enumerating a schema's\n * fields means reaching into one library's internals (`.shape`) and being wrong\n * for every other.\n *\n * **A test stage is handed a fake.** Nobody issues a credential to a test\n * stage set up fresh — CI's auto-setup stores no third party's values — so a\n * credential a test reaches has a fake at `test/fakes/<id>.ts`, the folder an\n * `ExternalApi`'s fake lives in:\n *\n * ```ts\n * // test/fakes/stripe.ts\n * import { fake } from '@geekmidas/constructs/credential';\n * import type { stripe } from '../../constructs/stripe';\n *\n * export default fake.credential<typeof stripe>({\n * secretKey: 'sk_test_fake',\n * webhookSecret: 'whsec_fake',\n * });\n * ```\n *\n * gkm reads it for `gkm test` and `gkm dev --fake` only, and the construct\n * never names it, so it is in no deployed bundle and a deploy still refuses a\n * stage without the real value.\n */\n\nimport {\n\ttype ConstructName,\n\tcanonicalId,\n\ttype Declaration,\n\tprovidedKeyFor,\n\tserviceKey,\n} from '@geekmidas/manifest';\nimport { parseSchema } from '@geekmidas/schema/parser';\nimport type { Service, ServiceRegisterOptions } from '@geekmidas/services';\nimport type { StandardSchemaV1 } from '@standard-schema/spec';\nimport type { Consumable } from './construct-interface';\n\n/** What a credential's schema yields. */\ntype Value<TSchema extends StandardSchemaV1> =\n\tStandardSchemaV1.InferOutput<TSchema>;\n\nexport interface CredentialOptions<TSchema extends StandardSchemaV1> {\n\t/**\n\t * What the credential must look like.\n\t *\n\t * Validated at registration, so a malformed or half-set credential fails\n\t * when the process starts rather than on the first request that needs the\n\t * one field somebody forgot.\n\t */\n\tschema: TSchema;\n\t/**\n\t * Re-resolve on every registration instead of once per process.\n\t *\n\t * Off by default: a credential is resolved once and reused, because the\n\t * alternative is a fetch on every request. The cost of that default is that\n\t * a rotated credential needs a restart, which is the right trade for a value\n\t * that changes a few times a year — and this is the escape hatch for when it\n\t * is not.\n\t */\n\trefresh?: boolean;\n}\n\nexport class Credential<\n\tTName extends string = string,\n\tTSchema extends StandardSchemaV1 = StandardSchemaV1,\n> implements Consumable<TName, Value<TSchema>>\n{\n\t// `Consumable` rather than `Construct`, and not by preference: `Construct`\n\t// types its service as `[TClient] extends [never] ? never : Service<…>` so\n\t// that a `Cron` cannot be depended on, and TypeScript cannot evaluate that\n\t// conditional while `TClient` is still a type parameter. Every construct\n\t// with a concrete client satisfies `Construct`; the first one whose client\n\t// is generic cannot. `Consumable` is the face `.dependsOn()` requires and\n\t// carries no conditional, so it is the honest annotation here.\n\treadonly id: TName;\n\treadonly service: Service<Uncapitalize<TName>, Value<TSchema>>;\n\n\t/**\n\t * Declared once and read by both `declare()` and `connect()`, so the key the\n\t * target publishes and the key the client reads cannot drift.\n\t */\n\tprivate readonly keys: { credentials: string };\n\n\t/**\n\t * The resolved value, held as the *promise* rather than the value.\n\t *\n\t * Caching the promise is what makes two concurrent registrations share one\n\t * resolution: caching the value would let both start before either finished,\n\t * which is a duplicated fetch every cold start rather than never.\n\t */\n\tprivate resolved?: Promise<Value<TSchema>>;\n\n\tconstructor(\n\t\tid: ConstructName<TName>,\n\t\tprivate readonly options: CredentialOptions<TSchema>,\n\t) {\n\t\tconst canonical = canonicalId(id as string);\n\n\t\tthis.id = canonical as TName;\n\t\tthis.keys = {\n\t\t\tcredentials: providedKeyFor(canonical, 'credential', '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) => this.connect(registerOptions),\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.schema;\n\t}\n\n\tdeclare(): Declaration[] {\n\t\treturn [\n\t\t\t{\n\t\t\t\tkind: 'credential',\n\t\t\t\tid: this.id,\n\t\t\t\tprovides: [this.keys.credentials],\n\t\t\t},\n\t\t];\n\t}\n\n\tprivate connect(options: ServiceRegisterOptions): Promise<Value<TSchema>> {\n\t\tif (this.options.refresh) return this.resolve(options);\n\n\t\tthis.resolved ??= this.resolve(options);\n\n\t\treturn this.resolved;\n\t}\n\n\tprivate resolve(options: ServiceRegisterOptions): Promise<Value<TSchema>> {\n\t\treturn readCredentials(\n\t\t\tthis.id,\n\t\t\tthis.keys.credentials,\n\t\t\tthis.options.schema,\n\t\t\toptions.envParser,\n\t\t);\n\t}\n}\n\n/**\n * A credentials key, read and validated against its schema.\n *\n * Shared with every construct that holds a third party's credentials — an\n * `ExternalApi` reads its own the same way — so the shape a stage stores and\n * the error a bad value raises are the same everywhere.\n *\n * @throws {MalformedCredential} when the value is not what the schema says.\n */\nexport async function readCredentials<TSchema extends StandardSchemaV1>(\n\tid: string,\n\tkey: string,\n\tschema: TSchema,\n\tenvParser: ServiceRegisterOptions['envParser'],\n): Promise<Value<TSchema>> {\n\tconst { raw } = envParser\n\t\t.create((get) => ({ raw: get(key).string() }))\n\t\t.parse();\n\n\ttry {\n\t\treturn await parseSchema(schema, decodeCredentials(raw));\n\t} catch (issues) {\n\t\tthrow new MalformedCredential(id, key, issues);\n\t}\n}\n\n/**\n * The raw environment value as the thing the schema should see.\n *\n * JSON when it is JSON, and the string itself when it is not — a credential\n * with a single opaque field is ordinary, and requiring `\"…\"` around it would\n * be ceremony that every operator setting one by hand would get wrong once.\n *\n * Exported so a tool checking a value before it is stored reads it exactly as\n * the process that uses it will.\n */\nexport function decodeCredentials(raw: string): unknown {\n\tconst value = raw.startsWith(JSON_SCHEME)\n\t\t? raw.slice(JSON_SCHEME.length)\n\t\t: raw;\n\n\ttry {\n\t\treturn JSON.parse(value);\n\t} catch {\n\t\treturn value;\n\t}\n}\n\n/**\n * The explicit form, for the case a credential legitimately *is* a JSON string\n * and must not be parsed into an object. Rare, and cheaper to support than to\n * explain.\n */\nconst JSON_SCHEME = 'json:';\n\n/** A credential was set, and is not what its schema says it should be. */\nexport class MalformedCredential extends Error {\n\tconstructor(\n\t\treadonly id: string,\n\t\treadonly key: string,\n\t\treadonly issues: unknown,\n\t) {\n\t\tsuper(\n\t\t\t`${key} is not a valid ${id} credential. ` +\n\t\t\t\t`It is validated where it is read, so this is the value that is set ` +\n\t\t\t\t`rather than the code that uses it: ${describe(issues)}`,\n\t\t);\n\t\tthis.name = 'MalformedCredential';\n\t}\n}\n\n/** StandardSchema issues as one line. */\nfunction describe(issues: unknown): string {\n\tif (!Array.isArray(issues)) return String(issues);\n\n\treturn issues\n\t\t.map((issue: StandardSchemaV1.Issue) => {\n\t\t\tconst path = issue.path\n\t\t\t\t?.map((segment) =>\n\t\t\t\t\ttypeof segment === 'object' ? String(segment.key) : String(segment),\n\t\t\t\t)\n\t\t\t\t.join('.');\n\n\t\t\treturn path ? `${path}: ${issue.message}` : issue.message;\n\t\t})\n\t\t.join('; ');\n}\n\nexport { type Fake, fake, isFake } from './fake';\n"],"mappings":";;;;;;;AAoCA,MAAM,OAAO,OAAO,IAAI,4BAA4B;;;;;;;AAqDpD,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;;;;;;CAOA,WACC,aACO;EACP,OAAO;IAAG,OAAO;GAAM,MAAM;GAAc;EAAY;CACxD;AACD;;AAGA,SAAgB,OAAO,OAA+B;CACrD,OACC,OAAO,UAAU,YACjB,UAAU,QACT,MAA+B,UAAU;AAE5C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AC/CA,IAAa,aAAb,MAIA;CA4BmB;CApBlB;CACA;;;;;CAMA;;;;;;;;CASA;CAEA,YACC,IACA,SACC;EADgB,KAAA,UAAA;EAEjB,MAAM,YAAY,YAAY,EAAY;EAE1C,KAAK,KAAK;EACV,KAAK,OAAO,EACX,aAAa,eAAe,WAAW,cAAc,aAAa,EACnE;EAGA,KAAK,UAAU;GACd,aAAa,WAAW,SAAS;GACjC,WAAW,oBAAoB,KAAK,QAAQ,eAAe;EAC5D;CACD;;;;;;;CAQA,IAAI,oBAA6B;EAChC,OAAO,KAAK,QAAQ;CACrB;CAEA,UAAyB;EACxB,OAAO,CACN;GACC,MAAM;GACN,IAAI,KAAK;GACT,UAAU,CAAC,KAAK,KAAK,WAAW;EACjC,CACD;CACD;CAEA,QAAgB,SAA0D;EACzE,IAAI,KAAK,QAAQ,SAAS,OAAO,KAAK,QAAQ,OAAO;EAErD,KAAK,aAAa,KAAK,QAAQ,OAAO;EAEtC,OAAO,KAAK;CACb;CAEA,QAAgB,SAA0D;EACzE,OAAO,gBACN,KAAK,IACL,KAAK,KAAK,aACV,KAAK,QAAQ,QACb,QAAQ,SACT;CACD;AACD;;;;;;;;;;AAWA,eAAsB,gBACrB,IACA,KACA,QACA,WAC0B;CAC1B,MAAM,EAAE,QAAQ,UACd,QAAQ,SAAS,EAAE,KAAK,IAAI,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,CAC7C,MAAM;CAER,IAAI;EACH,OAAO,MAAM,YAAY,QAAQ,kBAAkB,GAAG,CAAC;CACxD,SAAS,QAAQ;EAChB,MAAM,IAAI,oBAAoB,IAAI,KAAK,MAAM;CAC9C;AACD;;;;;;;;;;;AAYA,SAAgB,kBAAkB,KAAsB;CACvD,MAAM,QAAQ,IAAI,WAAW,WAAW,IACrC,IAAI,MAAM,YAAY,MAAM,IAC5B;CAEH,IAAI;EACH,OAAO,KAAK,MAAM,KAAK;CACxB,QAAQ;EACP,OAAO;CACR;AACD;;;;;;AAOA,MAAM,cAAc;;AAGpB,IAAa,sBAAb,cAAyC,MAAM;CAEpC;CACA;CACA;CAHV,YACC,IACA,KACA,QACC;EACD,MACC,GAAG,IAAI,kBAAkB,GAAG,qHAEW,SAAS,MAAM,GACvD;EARS,KAAA,KAAA;EACA,KAAA,MAAA;EACA,KAAA,SAAA;EAOT,KAAK,OAAO;CACb;AACD;;AAGA,SAAS,SAAS,QAAyB;CAC1C,IAAI,CAAC,MAAM,QAAQ,MAAM,GAAG,OAAO,OAAO,MAAM;CAEhD,OAAO,OACL,KAAK,UAAkC;EACvC,MAAM,OAAO,MAAM,MAChB,KAAK,YACN,OAAO,YAAY,WAAW,OAAO,QAAQ,GAAG,IAAI,OAAO,OAAO,CACnE,CAAC,CACA,KAAK,GAAG;EAEV,OAAO,OAAO,GAAG,KAAK,IAAI,MAAM,YAAY,MAAM;CACnD,CAAC,CAAC,CACD,KAAK,IAAI;AACZ"}
@@ -123,7 +123,7 @@ var Credential = class {
123
123
  this.options = options;
124
124
  const canonical = (0, _geekmidas_manifest.canonicalId)(id);
125
125
  this.id = canonical;
126
- this.keys = { credentials: (0, _geekmidas_manifest.provideKey)(canonical, "credentials") };
126
+ this.keys = { credentials: (0, _geekmidas_manifest.providedKeyFor)(canonical, "credential", "credentials") };
127
127
  this.service = {
128
128
  serviceName: (0, _geekmidas_manifest.serviceKey)(canonical),
129
129
  register: (registerOptions) => this.connect(registerOptions)
@@ -254,4 +254,4 @@ Object.defineProperty(exports, "readCredentials", {
254
254
  }
255
255
  });
256
256
 
257
- //# sourceMappingURL=credential-DYymbp_7.cjs.map
257
+ //# sourceMappingURL=credential-RlgbzZAc.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"credential-RlgbzZAc.cjs","names":["canonicalId","providedKeyFor","serviceKey","parseSchema"],"sources":["../src/fake.ts","../src/credential.ts"],"sourcesContent":["/**\n * Fakes: what a test stage — and `gkm dev --fake` — is handed in place of a\n * third party.\n *\n * An `ExternalApi`'s fake answers its requests and says which credentials it\n * accepts; a `Credential`'s fake is the value the test stage is handed in\n * place of the one a third party issued. Both live at `test/fakes/<id>.ts`,\n * found by convention and default-exported:\n *\n * ```ts\n * // test/fakes/polar.ts\n * export default fake.app<typeof polar>(new Hono()…, {\n * credentials: { clientId: 'fake', clientSecret: 'fake' },\n * });\n *\n * // test/fakes/reviewer-password.ts\n * export default fake.credential<typeof reviewerPassword>(\n * 'a-reviewer-password-for-tests',\n * );\n * ```\n *\n * **The construct never names its fake**, so a fake cannot end up in a\n * deployed bundle however the bundler follows imports. gkm reads the folder\n * for `gkm test` (and the suite it starts) and for `gkm dev --fake`, and for\n * nothing that acts on a deployed stage: a deploy still refuses a stage that\n * lacks the real value.\n */\n\nimport type { StandardSchemaV1 } from '@standard-schema/spec';\nimport type { Credential } from './credential';\nimport type { ExternalApi } from './external-api';\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/** 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 * What a construct's credentials look like going in, for a fake to supply —\n * an external API's `credentials` schema, or a credential's `schema`.\n */\ntype CredentialsOf<TConstruct> =\n\tTConstruct extends ExternalApi<string, infer TSchema, unknown>\n\t\t? StandardSchemaV1.InferInput<TSchema>\n\t\t: TConstruct extends Credential<string, infer TSchema>\n\t\t\t? StandardSchemaV1.InferInput<TSchema>\n\t\t\t: unknown;\n\n/**\n * A third party's stand-in, as `test/fakes/<id>.ts` default-exports it.\n *\n * `credentials` are what a local or test stage is handed as `<ID>_CREDENTIALS`\n * in place of the stage's own: what an external API's fake accepts, or a\n * credential's test value.\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\t| {\n\t\t\t/** A `Credential`'s test value — nothing to serve. */\n\t\t\treadonly kind: 'credential';\n\t }\n);\n\n/**\n * Build the fake `test/fakes/<id>.ts` default-exports.\n *\n * Pass the construct's type to have the value checked against its schema —\n * `fake.app<typeof polar>(…)`, `fake.credential<typeof stripe>(…)`.\n */\nexport const fake = {\n\t/** A working implementation of an external 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 an external API's 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\t/**\n\t * A `Credential`'s value on the test stage and under `gkm dev --fake`, as\n\t * its schema takes it — a string, or the object a JSON credential holds.\n\t * It is validated where it is read, like the real one.\n\t */\n\tcredential<TCredential = unknown>(\n\t\tcredentials: CredentialsOf<TCredential>,\n\t): Fake {\n\t\treturn { [FAKE]: true, kind: 'credential', credentials };\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","/**\n * `Credential` — a third-party credential with a shape.\n *\n * The answer to the design's first open question, \"where does `Secret` sit?\".\n * It sits beside a secret rather than replacing it, because the two differ by\n * *lifecycle* and that is the only difference worth two kinds for: a secret is\n * generated and rotated by the platform and is one opaque string, while a\n * credential is issued by someone else, arrives with several fields, and is\n * worth validating on the way in.\n *\n * ```ts\n * export const stripe = new Credential('Stripe', {\n * schema: z.object({ secretKey: z.string(), webhookSecret: z.string() }),\n * });\n *\n * // in a handler — no await, already parsed and validated\n * services.stripe.secretKey\n * ```\n *\n * **Nothing about it is async at the call site**, which is the part that looks\n * like it should be hard and is not. `Service.register()` may return a promise\n * and `ServiceDiscovery` awaits every one before a handler runs, so fetching a\n * value and validating it — including when a StandardSchema's `~standard.validate`\n * returns a promise of its own — both happen inside that existing seam.\n *\n * **One key holding JSON, not one key per field.** That is the shape a secret\n * manager stores, and it is the only shape that works with an arbitrary\n * StandardSchema: the spec has no introspection API, so enumerating a schema's\n * fields means reaching into one library's internals (`.shape`) and being wrong\n * for every other.\n *\n * **A test stage is handed a fake.** Nobody issues a credential to a test\n * stage set up fresh — CI's auto-setup stores no third party's values — so a\n * credential a test reaches has a fake at `test/fakes/<id>.ts`, the folder an\n * `ExternalApi`'s fake lives in:\n *\n * ```ts\n * // test/fakes/stripe.ts\n * import { fake } from '@geekmidas/constructs/credential';\n * import type { stripe } from '../../constructs/stripe';\n *\n * export default fake.credential<typeof stripe>({\n * secretKey: 'sk_test_fake',\n * webhookSecret: 'whsec_fake',\n * });\n * ```\n *\n * gkm reads it for `gkm test` and `gkm dev --fake` only, and the construct\n * never names it, so it is in no deployed bundle and a deploy still refuses a\n * stage without the real value.\n */\n\nimport {\n\ttype ConstructName,\n\tcanonicalId,\n\ttype Declaration,\n\tprovidedKeyFor,\n\tserviceKey,\n} from '@geekmidas/manifest';\nimport { parseSchema } from '@geekmidas/schema/parser';\nimport type { Service, ServiceRegisterOptions } from '@geekmidas/services';\nimport type { StandardSchemaV1 } from '@standard-schema/spec';\nimport type { Consumable } from './construct-interface';\n\n/** What a credential's schema yields. */\ntype Value<TSchema extends StandardSchemaV1> =\n\tStandardSchemaV1.InferOutput<TSchema>;\n\nexport interface CredentialOptions<TSchema extends StandardSchemaV1> {\n\t/**\n\t * What the credential must look like.\n\t *\n\t * Validated at registration, so a malformed or half-set credential fails\n\t * when the process starts rather than on the first request that needs the\n\t * one field somebody forgot.\n\t */\n\tschema: TSchema;\n\t/**\n\t * Re-resolve on every registration instead of once per process.\n\t *\n\t * Off by default: a credential is resolved once and reused, because the\n\t * alternative is a fetch on every request. The cost of that default is that\n\t * a rotated credential needs a restart, which is the right trade for a value\n\t * that changes a few times a year — and this is the escape hatch for when it\n\t * is not.\n\t */\n\trefresh?: boolean;\n}\n\nexport class Credential<\n\tTName extends string = string,\n\tTSchema extends StandardSchemaV1 = StandardSchemaV1,\n> implements Consumable<TName, Value<TSchema>>\n{\n\t// `Consumable` rather than `Construct`, and not by preference: `Construct`\n\t// types its service as `[TClient] extends [never] ? never : Service<…>` so\n\t// that a `Cron` cannot be depended on, and TypeScript cannot evaluate that\n\t// conditional while `TClient` is still a type parameter. Every construct\n\t// with a concrete client satisfies `Construct`; the first one whose client\n\t// is generic cannot. `Consumable` is the face `.dependsOn()` requires and\n\t// carries no conditional, so it is the honest annotation here.\n\treadonly id: TName;\n\treadonly service: Service<Uncapitalize<TName>, Value<TSchema>>;\n\n\t/**\n\t * Declared once and read by both `declare()` and `connect()`, so the key the\n\t * target publishes and the key the client reads cannot drift.\n\t */\n\tprivate readonly keys: { credentials: string };\n\n\t/**\n\t * The resolved value, held as the *promise* rather than the value.\n\t *\n\t * Caching the promise is what makes two concurrent registrations share one\n\t * resolution: caching the value would let both start before either finished,\n\t * which is a duplicated fetch every cold start rather than never.\n\t */\n\tprivate resolved?: Promise<Value<TSchema>>;\n\n\tconstructor(\n\t\tid: ConstructName<TName>,\n\t\tprivate readonly options: CredentialOptions<TSchema>,\n\t) {\n\t\tconst canonical = canonicalId(id as string);\n\n\t\tthis.id = canonical as TName;\n\t\tthis.keys = {\n\t\t\tcredentials: providedKeyFor(canonical, 'credential', '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) => this.connect(registerOptions),\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.schema;\n\t}\n\n\tdeclare(): Declaration[] {\n\t\treturn [\n\t\t\t{\n\t\t\t\tkind: 'credential',\n\t\t\t\tid: this.id,\n\t\t\t\tprovides: [this.keys.credentials],\n\t\t\t},\n\t\t];\n\t}\n\n\tprivate connect(options: ServiceRegisterOptions): Promise<Value<TSchema>> {\n\t\tif (this.options.refresh) return this.resolve(options);\n\n\t\tthis.resolved ??= this.resolve(options);\n\n\t\treturn this.resolved;\n\t}\n\n\tprivate resolve(options: ServiceRegisterOptions): Promise<Value<TSchema>> {\n\t\treturn readCredentials(\n\t\t\tthis.id,\n\t\t\tthis.keys.credentials,\n\t\t\tthis.options.schema,\n\t\t\toptions.envParser,\n\t\t);\n\t}\n}\n\n/**\n * A credentials key, read and validated against its schema.\n *\n * Shared with every construct that holds a third party's credentials — an\n * `ExternalApi` reads its own the same way — so the shape a stage stores and\n * the error a bad value raises are the same everywhere.\n *\n * @throws {MalformedCredential} when the value is not what the schema says.\n */\nexport async function readCredentials<TSchema extends StandardSchemaV1>(\n\tid: string,\n\tkey: string,\n\tschema: TSchema,\n\tenvParser: ServiceRegisterOptions['envParser'],\n): Promise<Value<TSchema>> {\n\tconst { raw } = envParser\n\t\t.create((get) => ({ raw: get(key).string() }))\n\t\t.parse();\n\n\ttry {\n\t\treturn await parseSchema(schema, decodeCredentials(raw));\n\t} catch (issues) {\n\t\tthrow new MalformedCredential(id, key, issues);\n\t}\n}\n\n/**\n * The raw environment value as the thing the schema should see.\n *\n * JSON when it is JSON, and the string itself when it is not — a credential\n * with a single opaque field is ordinary, and requiring `\"…\"` around it would\n * be ceremony that every operator setting one by hand would get wrong once.\n *\n * Exported so a tool checking a value before it is stored reads it exactly as\n * the process that uses it will.\n */\nexport function decodeCredentials(raw: string): unknown {\n\tconst value = raw.startsWith(JSON_SCHEME)\n\t\t? raw.slice(JSON_SCHEME.length)\n\t\t: raw;\n\n\ttry {\n\t\treturn JSON.parse(value);\n\t} catch {\n\t\treturn value;\n\t}\n}\n\n/**\n * The explicit form, for the case a credential legitimately *is* a JSON string\n * and must not be parsed into an object. Rare, and cheaper to support than to\n * explain.\n */\nconst JSON_SCHEME = 'json:';\n\n/** A credential was set, and is not what its schema says it should be. */\nexport class MalformedCredential extends Error {\n\tconstructor(\n\t\treadonly id: string,\n\t\treadonly key: string,\n\t\treadonly issues: unknown,\n\t) {\n\t\tsuper(\n\t\t\t`${key} is not a valid ${id} credential. ` +\n\t\t\t\t`It is validated where it is read, so this is the value that is set ` +\n\t\t\t\t`rather than the code that uses it: ${describe(issues)}`,\n\t\t);\n\t\tthis.name = 'MalformedCredential';\n\t}\n}\n\n/** StandardSchema issues as one line. */\nfunction describe(issues: unknown): string {\n\tif (!Array.isArray(issues)) return String(issues);\n\n\treturn issues\n\t\t.map((issue: StandardSchemaV1.Issue) => {\n\t\t\tconst path = issue.path\n\t\t\t\t?.map((segment) =>\n\t\t\t\t\ttypeof segment === 'object' ? String(segment.key) : String(segment),\n\t\t\t\t)\n\t\t\t\t.join('.');\n\n\t\t\treturn path ? `${path}: ${issue.message}` : issue.message;\n\t\t})\n\t\t.join('; ');\n}\n\nexport { type Fake, fake, isFake } from './fake';\n"],"mappings":";;;;;;;AAoCA,MAAM,OAAO,OAAO,IAAI,4BAA4B;;;;;;;AAqDpD,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;;;;;;CAOA,WACC,aACO;EACP,OAAO;IAAG,OAAO;GAAM,MAAM;GAAc;EAAY;CACxD;AACD;;AAGA,SAAgB,OAAO,OAA+B;CACrD,OACC,OAAO,UAAU,YACjB,UAAU,QACT,MAA+B,UAAU;AAE5C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AC/CA,IAAa,aAAb,MAIA;CA4BmB;CApBlB;CACA;;;;;CAMA;;;;;;;;CASA;CAEA,YACC,IACA,SACC;EADgB,KAAA,UAAA;EAEjB,MAAM,aAAA,GAAYA,oBAAAA,YAAAA,CAAY,EAAY;EAE1C,KAAK,KAAK;EACV,KAAK,OAAO,EACX,cAAA,GAAaC,oBAAAA,eAAAA,CAAe,WAAW,cAAc,aAAa,EACnE;EAGA,KAAK,UAAU;GACd,cAAA,GAAaC,oBAAAA,WAAAA,CAAW,SAAS;GACjC,WAAW,oBAAoB,KAAK,QAAQ,eAAe;EAC5D;CACD;;;;;;;CAQA,IAAI,oBAA6B;EAChC,OAAO,KAAK,QAAQ;CACrB;CAEA,UAAyB;EACxB,OAAO,CACN;GACC,MAAM;GACN,IAAI,KAAK;GACT,UAAU,CAAC,KAAK,KAAK,WAAW;EACjC,CACD;CACD;CAEA,QAAgB,SAA0D;EACzE,IAAI,KAAK,QAAQ,SAAS,OAAO,KAAK,QAAQ,OAAO;EAErD,KAAK,aAAa,KAAK,QAAQ,OAAO;EAEtC,OAAO,KAAK;CACb;CAEA,QAAgB,SAA0D;EACzE,OAAO,gBACN,KAAK,IACL,KAAK,KAAK,aACV,KAAK,QAAQ,QACb,QAAQ,SACT;CACD;AACD;;;;;;;;;;AAWA,eAAsB,gBACrB,IACA,KACA,QACA,WAC0B;CAC1B,MAAM,EAAE,QAAQ,UACd,QAAQ,SAAS,EAAE,KAAK,IAAI,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,CAC7C,MAAM;CAER,IAAI;EACH,OAAO,OAAA,GAAMC,yBAAAA,YAAAA,CAAY,QAAQ,kBAAkB,GAAG,CAAC;CACxD,SAAS,QAAQ;EAChB,MAAM,IAAI,oBAAoB,IAAI,KAAK,MAAM;CAC9C;AACD;;;;;;;;;;;AAYA,SAAgB,kBAAkB,KAAsB;CACvD,MAAM,QAAQ,IAAI,WAAW,WAAW,IACrC,IAAI,MAAM,YAAY,MAAM,IAC5B;CAEH,IAAI;EACH,OAAO,KAAK,MAAM,KAAK;CACxB,QAAQ;EACP,OAAO;CACR;AACD;;;;;;AAOA,MAAM,cAAc;;AAGpB,IAAa,sBAAb,cAAyC,MAAM;CAEpC;CACA;CACA;CAHV,YACC,IACA,KACA,QACC;EACD,MACC,GAAG,IAAI,kBAAkB,GAAG,qHAEW,SAAS,MAAM,GACvD;EARS,KAAA,KAAA;EACA,KAAA,MAAA;EACA,KAAA,SAAA;EAOT,KAAK,OAAO;CACb;AACD;;AAGA,SAAS,SAAS,QAAyB;CAC1C,IAAI,CAAC,MAAM,QAAQ,MAAM,GAAG,OAAO,OAAO,MAAM;CAEhD,OAAO,OACL,KAAK,UAAkC;EACvC,MAAM,OAAO,MAAM,MAChB,KAAK,YACN,OAAO,YAAY,WAAW,OAAO,QAAQ,GAAG,IAAI,OAAO,OAAO,CACnE,CAAC,CACA,KAAK,GAAG;EAEV,OAAO,OAAO,GAAG,KAAK,IAAI,MAAM,YAAY,MAAM;CACnD,CAAC,CAAC,CACD,KAAK,IAAI;AACZ"}
@@ -1,5 +1,5 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_credential = require("./credential-DYymbp_7.cjs");
2
+ const require_credential = require("./credential-RlgbzZAc.cjs");
3
3
  exports.Credential = require_credential.Credential;
4
4
  exports.MalformedCredential = require_credential.MalformedCredential;
5
5
  exports.decodeCredentials = require_credential.decodeCredentials;
@@ -1,2 +1,2 @@
1
- import { c as Credential, d as decodeCredentials, f as readCredentials, i as isFake, l as CredentialOptions, r as fake, t as Fake, u as MalformedCredential } from "./fake-DqieDYYA.cjs";
1
+ import { c as Credential, d as decodeCredentials, f as readCredentials, i as isFake, l as CredentialOptions, r as fake, t as Fake, u as MalformedCredential } from "./fake-Djx8E0o1.cjs";
2
2
  export { Credential, CredentialOptions, type Fake, MalformedCredential, decodeCredentials, fake, isFake, readCredentials };
@@ -1,2 +1,2 @@
1
- import { c as Credential, d as decodeCredentials, f as readCredentials, i as isFake, l as CredentialOptions, r as fake, t as Fake, u as MalformedCredential } from "./fake-BqhP8RRQ.mjs";
1
+ import { c as Credential, d as decodeCredentials, f as readCredentials, i as isFake, l as CredentialOptions, r as fake, t as Fake, u as MalformedCredential } from "./fake-BvOXkZmj.mjs";
2
2
  export { Credential, CredentialOptions, type Fake, MalformedCredential, decodeCredentials, fake, isFake, readCredentials };
@@ -1,2 +1,2 @@
1
- import { a as fake, i as readCredentials, n as MalformedCredential, o as isFake, r as decodeCredentials, t as Credential } from "./credential-DfSAOOdY.mjs";
1
+ import { a as fake, i as readCredentials, n as MalformedCredential, o as isFake, r as decodeCredentials, t as Credential } from "./credential-B80mOxwT.mjs";
2
2
  export { Credential, MalformedCredential, decodeCredentials, fake, isFake, readCredentials };
@@ -1,5 +1,5 @@
1
- import { i as ScheduleExpression, n as CronExpression, r as RateExpression, t as Cron } from "../Cron-D_sfaMGz.cjs";
2
- import { t as CronBuilder } from "../CronBuilder-C91MVLSr.cjs";
1
+ import { i as ScheduleExpression, n as CronExpression, r as RateExpression, t as Cron } from "../Cron-Ca_qHQu2.cjs";
2
+ import { t as CronBuilder } from "../CronBuilder-C3RrAF1-.cjs";
3
3
  import { ServiceDiscovery } from "@geekmidas/services";
4
4
  //#region src/crons/inProcess.d.ts
5
5
  /** A schedule that is running, and the way to stop it. */
@@ -1,5 +1,5 @@
1
- import { i as ScheduleExpression, n as CronExpression, r as RateExpression, t as Cron } from "../Cron-D6Y7BBt3.mjs";
2
- import { t as CronBuilder } from "../CronBuilder-4BZhkChG.mjs";
1
+ import { i as ScheduleExpression, n as CronExpression, r as RateExpression, t as Cron } from "../Cron-DPJiR7Lt.mjs";
2
+ import { t as CronBuilder } from "../CronBuilder-BC4za5Bx.mjs";
3
3
  import { ServiceDiscovery } from "@geekmidas/services";
4
4
  //#region src/crons/inProcess.d.ts
5
5
  /** A schedule that is running, and the way to stop it. */
@@ -1,4 +1,4 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_kysely = require("../kysely-CukArHJ0.cjs");
2
+ const require_kysely = require("../kysely-D7f6J2lh.cjs");
3
3
  exports.KyselyDatabase = require_kysely.KyselyDatabase;
4
4
  exports.closeDatabasePools = require_kysely.closeDatabasePools;
@@ -1,2 +1,2 @@
1
- import { a as closeDatabasePools, i as ReadOnlyDatabase, n as KyselyDatabaseOptions, r as PostgresRuntime, t as KyselyDatabase } from "../kysely-CebjCWTl.cjs";
1
+ import { a as closeDatabasePools, i as ReadOnlyDatabase, n as KyselyDatabaseOptions, r as PostgresRuntime, t as KyselyDatabase } from "../kysely-2HqIQ2fC.cjs";
2
2
  export { KyselyDatabase, KyselyDatabaseOptions, PostgresRuntime, ReadOnlyDatabase, closeDatabasePools };
@@ -1,2 +1,2 @@
1
- import { a as closeDatabasePools, i as ReadOnlyDatabase, n as KyselyDatabaseOptions, r as PostgresRuntime, t as KyselyDatabase } from "../kysely-De5rAC-E.mjs";
1
+ import { a as closeDatabasePools, i as ReadOnlyDatabase, n as KyselyDatabaseOptions, r as PostgresRuntime, t as KyselyDatabase } from "../kysely-BGvpd_ZH.mjs";
2
2
  export { KyselyDatabase, KyselyDatabaseOptions, PostgresRuntime, ReadOnlyDatabase, closeDatabasePools };
@@ -1,2 +1,2 @@
1
- import { n as closeDatabasePools, t as KyselyDatabase } from "../kysely-Cs4uPO8k.mjs";
1
+ import { n as closeDatabasePools, t as KyselyDatabase } from "../kysely-Bc9xzaik.mjs";
2
2
  export { KyselyDatabase, closeDatabasePools };
package/dist/email.cjs CHANGED
@@ -16,8 +16,8 @@ var Email = class {
16
16
  const canonical = (0, _geekmidas_manifest.canonicalId)(id);
17
17
  this.id = canonical;
18
18
  this.keys = {
19
- url: (0, _geekmidas_manifest.provideKey)(canonical, "url"),
20
- from: (0, _geekmidas_manifest.provideKey)(canonical, "from")
19
+ url: (0, _geekmidas_manifest.providedKeyFor)(canonical, "email", "url"),
20
+ from: (0, _geekmidas_manifest.providedKeyFor)(canonical, "email", "from")
21
21
  };
22
22
  this.service = {
23
23
  serviceName: (0, _geekmidas_manifest.serviceKey)(canonical),